]>
Commit | Line | Data |
---|---|---|
04fd09d4 SL |
1 | From cff0f9918e2ae6fa53582e6c929c01aafb209ddc Mon Sep 17 00:00:00 2001 |
2 | From: Ezequiel Garcia <ezequiel@collabora.com> | |
3 | Date: Fri, 8 Feb 2019 11:17:39 -0500 | |
4 | Subject: media: mtk-jpeg: Correct return type for mem2mem buffer helpers | |
5 | ||
6 | [ Upstream commit 1b275e4e8b70dbff9850874b30831c1bd8d3c504 ] | |
7 | ||
8 | Fix the assigned type of mem2mem buffer handling API. | |
9 | Namely, these functions: | |
10 | ||
11 | v4l2_m2m_next_buf | |
12 | v4l2_m2m_last_buf | |
13 | v4l2_m2m_buf_remove | |
14 | v4l2_m2m_next_src_buf | |
15 | v4l2_m2m_next_dst_buf | |
16 | v4l2_m2m_last_src_buf | |
17 | v4l2_m2m_last_dst_buf | |
18 | v4l2_m2m_src_buf_remove | |
19 | v4l2_m2m_dst_buf_remove | |
20 | ||
21 | return a struct vb2_v4l2_buffer, and not a struct vb2_buffer. | |
22 | ||
23 | Fixing this is necessary to fix the mem2mem buffer handling API, | |
24 | changing the return to the correct struct vb2_v4l2_buffer instead | |
25 | of a void pointer. | |
26 | ||
27 | Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com> | |
28 | Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> | |
29 | Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | |
30 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
31 | --- | |
32 | .../media/platform/mtk-jpeg/mtk_jpeg_core.c | 40 +++++++++---------- | |
33 | 1 file changed, 20 insertions(+), 20 deletions(-) | |
34 | ||
35 | diff --git a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c | |
36 | index 226f90886484..46c996936798 100644 | |
37 | --- a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c | |
38 | +++ b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c | |
39 | @@ -702,7 +702,7 @@ end: | |
40 | v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, to_vb2_v4l2_buffer(vb)); | |
41 | } | |
42 | ||
43 | -static void *mtk_jpeg_buf_remove(struct mtk_jpeg_ctx *ctx, | |
44 | +static struct vb2_v4l2_buffer *mtk_jpeg_buf_remove(struct mtk_jpeg_ctx *ctx, | |
45 | enum v4l2_buf_type type) | |
46 | { | |
47 | if (V4L2_TYPE_IS_OUTPUT(type)) | |
48 | @@ -714,7 +714,7 @@ static void *mtk_jpeg_buf_remove(struct mtk_jpeg_ctx *ctx, | |
49 | static int mtk_jpeg_start_streaming(struct vb2_queue *q, unsigned int count) | |
50 | { | |
51 | struct mtk_jpeg_ctx *ctx = vb2_get_drv_priv(q); | |
52 | - struct vb2_buffer *vb; | |
53 | + struct vb2_v4l2_buffer *vb; | |
54 | int ret = 0; | |
55 | ||
56 | ret = pm_runtime_get_sync(ctx->jpeg->dev); | |
57 | @@ -724,14 +724,14 @@ static int mtk_jpeg_start_streaming(struct vb2_queue *q, unsigned int count) | |
58 | return 0; | |
59 | err: | |
60 | while ((vb = mtk_jpeg_buf_remove(ctx, q->type))) | |
61 | - v4l2_m2m_buf_done(to_vb2_v4l2_buffer(vb), VB2_BUF_STATE_QUEUED); | |
62 | + v4l2_m2m_buf_done(vb, VB2_BUF_STATE_QUEUED); | |
63 | return ret; | |
64 | } | |
65 | ||
66 | static void mtk_jpeg_stop_streaming(struct vb2_queue *q) | |
67 | { | |
68 | struct mtk_jpeg_ctx *ctx = vb2_get_drv_priv(q); | |
69 | - struct vb2_buffer *vb; | |
70 | + struct vb2_v4l2_buffer *vb; | |
71 | ||
72 | /* | |
73 | * STREAMOFF is an acknowledgment for source change event. | |
74 | @@ -743,7 +743,7 @@ static void mtk_jpeg_stop_streaming(struct vb2_queue *q) | |
75 | struct mtk_jpeg_src_buf *src_buf; | |
76 | ||
77 | vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); | |
78 | - src_buf = mtk_jpeg_vb2_to_srcbuf(vb); | |
79 | + src_buf = mtk_jpeg_vb2_to_srcbuf(&vb->vb2_buf); | |
80 | mtk_jpeg_set_queue_data(ctx, &src_buf->dec_param); | |
81 | ctx->state = MTK_JPEG_RUNNING; | |
82 | } else if (V4L2_TYPE_IS_OUTPUT(q->type)) { | |
83 | @@ -751,7 +751,7 @@ static void mtk_jpeg_stop_streaming(struct vb2_queue *q) | |
84 | } | |
85 | ||
86 | while ((vb = mtk_jpeg_buf_remove(ctx, q->type))) | |
87 | - v4l2_m2m_buf_done(to_vb2_v4l2_buffer(vb), VB2_BUF_STATE_ERROR); | |
88 | + v4l2_m2m_buf_done(vb, VB2_BUF_STATE_ERROR); | |
89 | ||
90 | pm_runtime_put_sync(ctx->jpeg->dev); | |
91 | } | |
92 | @@ -807,7 +807,7 @@ static void mtk_jpeg_device_run(void *priv) | |
93 | { | |
94 | struct mtk_jpeg_ctx *ctx = priv; | |
95 | struct mtk_jpeg_dev *jpeg = ctx->jpeg; | |
96 | - struct vb2_buffer *src_buf, *dst_buf; | |
97 | + struct vb2_v4l2_buffer *src_buf, *dst_buf; | |
98 | enum vb2_buffer_state buf_state = VB2_BUF_STATE_ERROR; | |
99 | unsigned long flags; | |
100 | struct mtk_jpeg_src_buf *jpeg_src_buf; | |
101 | @@ -817,11 +817,11 @@ static void mtk_jpeg_device_run(void *priv) | |
102 | ||
103 | src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); | |
104 | dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); | |
105 | - jpeg_src_buf = mtk_jpeg_vb2_to_srcbuf(src_buf); | |
106 | + jpeg_src_buf = mtk_jpeg_vb2_to_srcbuf(&src_buf->vb2_buf); | |
107 | ||
108 | if (jpeg_src_buf->flags & MTK_JPEG_BUF_FLAGS_LAST_FRAME) { | |
109 | - for (i = 0; i < dst_buf->num_planes; i++) | |
110 | - vb2_set_plane_payload(dst_buf, i, 0); | |
111 | + for (i = 0; i < dst_buf->vb2_buf.num_planes; i++) | |
112 | + vb2_set_plane_payload(&dst_buf->vb2_buf, i, 0); | |
113 | buf_state = VB2_BUF_STATE_DONE; | |
114 | goto dec_end; | |
115 | } | |
116 | @@ -833,8 +833,8 @@ static void mtk_jpeg_device_run(void *priv) | |
117 | return; | |
118 | } | |
119 | ||
120 | - mtk_jpeg_set_dec_src(ctx, src_buf, &bs); | |
121 | - if (mtk_jpeg_set_dec_dst(ctx, &jpeg_src_buf->dec_param, dst_buf, &fb)) | |
122 | + mtk_jpeg_set_dec_src(ctx, &src_buf->vb2_buf, &bs); | |
123 | + if (mtk_jpeg_set_dec_dst(ctx, &jpeg_src_buf->dec_param, &dst_buf->vb2_buf, &fb)) | |
124 | goto dec_end; | |
125 | ||
126 | spin_lock_irqsave(&jpeg->hw_lock, flags); | |
127 | @@ -849,8 +849,8 @@ static void mtk_jpeg_device_run(void *priv) | |
128 | dec_end: | |
129 | v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); | |
130 | v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); | |
131 | - v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf), buf_state); | |
132 | - v4l2_m2m_buf_done(to_vb2_v4l2_buffer(dst_buf), buf_state); | |
133 | + v4l2_m2m_buf_done(src_buf, buf_state); | |
134 | + v4l2_m2m_buf_done(dst_buf, buf_state); | |
135 | v4l2_m2m_job_finish(jpeg->m2m_dev, ctx->fh.m2m_ctx); | |
136 | } | |
137 | ||
138 | @@ -926,7 +926,7 @@ static irqreturn_t mtk_jpeg_dec_irq(int irq, void *priv) | |
139 | { | |
140 | struct mtk_jpeg_dev *jpeg = priv; | |
141 | struct mtk_jpeg_ctx *ctx; | |
142 | - struct vb2_buffer *src_buf, *dst_buf; | |
143 | + struct vb2_v4l2_buffer *src_buf, *dst_buf; | |
144 | struct mtk_jpeg_src_buf *jpeg_src_buf; | |
145 | enum vb2_buffer_state buf_state = VB2_BUF_STATE_ERROR; | |
146 | u32 dec_irq_ret; | |
147 | @@ -943,7 +943,7 @@ static irqreturn_t mtk_jpeg_dec_irq(int irq, void *priv) | |
148 | ||
149 | src_buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); | |
150 | dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); | |
151 | - jpeg_src_buf = mtk_jpeg_vb2_to_srcbuf(src_buf); | |
152 | + jpeg_src_buf = mtk_jpeg_vb2_to_srcbuf(&src_buf->vb2_buf); | |
153 | ||
154 | if (dec_irq_ret >= MTK_JPEG_DEC_RESULT_UNDERFLOW) | |
155 | mtk_jpeg_dec_reset(jpeg->dec_reg_base); | |
156 | @@ -953,15 +953,15 @@ static irqreturn_t mtk_jpeg_dec_irq(int irq, void *priv) | |
157 | goto dec_end; | |
158 | } | |
159 | ||
160 | - for (i = 0; i < dst_buf->num_planes; i++) | |
161 | - vb2_set_plane_payload(dst_buf, i, | |
162 | + for (i = 0; i < dst_buf->vb2_buf.num_planes; i++) | |
163 | + vb2_set_plane_payload(&dst_buf->vb2_buf, i, | |
164 | jpeg_src_buf->dec_param.comp_size[i]); | |
165 | ||
166 | buf_state = VB2_BUF_STATE_DONE; | |
167 | ||
168 | dec_end: | |
169 | - v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf), buf_state); | |
170 | - v4l2_m2m_buf_done(to_vb2_v4l2_buffer(dst_buf), buf_state); | |
171 | + v4l2_m2m_buf_done(src_buf, buf_state); | |
172 | + v4l2_m2m_buf_done(dst_buf, buf_state); | |
173 | v4l2_m2m_job_finish(jpeg->m2m_dev, ctx->fh.m2m_ctx); | |
174 | return IRQ_HANDLED; | |
175 | } | |
176 | -- | |
177 | 2.19.1 | |
178 |