Skip to content

Commit 5cfaad6

Browse files
Sylwester NawrockiMauro Carvalho Chehab
authored andcommitted
[media] exynos4-is: Fix format propagation on FIMC-IS-ISP subdev
Ensure TRY formats are propagated from the sink pad to the source pads of the FIMC-IS-ISP subdev and the TRY and ACTIVE formats are separated. [[email protected]: Whitespace cleanup] Signed-off-by: Sylwester Nawrocki <[email protected]> Signed-off-by: Kyungmin Park <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent a055d97 commit 5cfaad6

File tree

2 files changed

+66
-29
lines changed

2 files changed

+66
-29
lines changed

drivers/media/platform/exynos4-is/fimc-isp.c

Lines changed: 64 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -128,31 +128,28 @@ static int fimc_isp_subdev_get_fmt(struct v4l2_subdev *sd,
128128
struct v4l2_subdev_format *fmt)
129129
{
130130
struct fimc_isp *isp = v4l2_get_subdevdata(sd);
131-
struct fimc_is *is = fimc_isp_to_is(isp);
132131
struct v4l2_mbus_framefmt *mf = &fmt->format;
133-
struct v4l2_mbus_framefmt cur_fmt;
134132

135133
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
136-
mf = v4l2_subdev_get_try_format(fh, fmt->pad);
137-
fmt->format = *mf;
134+
*mf = *v4l2_subdev_get_try_format(fh, fmt->pad);
138135
return 0;
139136
}
140137

141138
mf->colorspace = V4L2_COLORSPACE_SRGB;
142139

143140
mutex_lock(&isp->subdev_lock);
144-
__is_get_frame_size(is, &cur_fmt);
145141

146142
if (fmt->pad == FIMC_ISP_SD_PAD_SINK) {
147-
/* full camera input frame size */
148-
mf->width = cur_fmt.width + FIMC_ISP_CAC_MARGIN_WIDTH;
149-
mf->height = cur_fmt.height + FIMC_ISP_CAC_MARGIN_HEIGHT;
150-
mf->code = V4L2_MBUS_FMT_SGRBG10_1X10;
143+
/* ISP OTF input image format */
144+
*mf = isp->sink_fmt;
151145
} else {
152-
/* crop size */
153-
mf->width = cur_fmt.width;
154-
mf->height = cur_fmt.height;
155-
mf->code = V4L2_MBUS_FMT_YUV10_1X30;
146+
/* ISP OTF output image format */
147+
*mf = isp->src_fmt;
148+
149+
if (fmt->pad == FIMC_ISP_SD_PAD_SRC_FIFO) {
150+
mf->colorspace = V4L2_COLORSPACE_JPEG;
151+
mf->code = V4L2_MBUS_FMT_YUV10_1X30;
152+
}
156153
}
157154

158155
mutex_unlock(&isp->subdev_lock);
@@ -164,21 +161,37 @@ static int fimc_isp_subdev_get_fmt(struct v4l2_subdev *sd,
164161
}
165162

166163
static void __isp_subdev_try_format(struct fimc_isp *isp,
167-
struct v4l2_subdev_format *fmt)
164+
struct v4l2_subdev_fh *fh,
165+
struct v4l2_subdev_format *fmt)
168166
{
169167
struct v4l2_mbus_framefmt *mf = &fmt->format;
168+
struct v4l2_mbus_framefmt *format;
169+
170+
mf->colorspace = V4L2_COLORSPACE_SRGB;
170171

171172
if (fmt->pad == FIMC_ISP_SD_PAD_SINK) {
172173
v4l_bound_align_image(&mf->width, FIMC_ISP_SINK_WIDTH_MIN,
173174
FIMC_ISP_SINK_WIDTH_MAX, 0,
174175
&mf->height, FIMC_ISP_SINK_HEIGHT_MIN,
175176
FIMC_ISP_SINK_HEIGHT_MAX, 0, 0);
176-
isp->subdev_fmt = *mf;
177+
mf->code = V4L2_MBUS_FMT_SGRBG10_1X10;
177178
} else {
179+
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
180+
format = v4l2_subdev_get_try_format(fh,
181+
FIMC_ISP_SD_PAD_SINK);
182+
else
183+
format = &isp->sink_fmt;
184+
178185
/* Allow changing format only on sink pad */
179-
mf->width = isp->subdev_fmt.width - FIMC_ISP_CAC_MARGIN_WIDTH;
180-
mf->height = isp->subdev_fmt.height - FIMC_ISP_CAC_MARGIN_HEIGHT;
181-
mf->code = isp->subdev_fmt.code;
186+
mf->width = format->width - FIMC_ISP_CAC_MARGIN_WIDTH;
187+
mf->height = format->height - FIMC_ISP_CAC_MARGIN_HEIGHT;
188+
189+
if (fmt->pad == FIMC_ISP_SD_PAD_SRC_FIFO) {
190+
mf->code = V4L2_MBUS_FMT_YUV10_1X30;
191+
mf->colorspace = V4L2_COLORSPACE_JPEG;
192+
} else {
193+
mf->code = format->code;
194+
}
182195
}
183196
}
184197

@@ -194,24 +207,47 @@ static int fimc_isp_subdev_set_fmt(struct v4l2_subdev *sd,
194207
isp_dbg(1, sd, "%s: pad%d: code: 0x%x, %dx%d\n",
195208
__func__, fmt->pad, mf->code, mf->width, mf->height);
196209

197-
mf->colorspace = V4L2_COLORSPACE_SRGB;
198-
199210
mutex_lock(&isp->subdev_lock);
200-
__isp_subdev_try_format(isp, fmt);
211+
__isp_subdev_try_format(isp, fh, fmt);
201212

202213
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
203214
mf = v4l2_subdev_get_try_format(fh, fmt->pad);
204215
*mf = fmt->format;
205-
mutex_unlock(&isp->subdev_lock);
206-
return 0;
216+
217+
/* Propagate format to the source pads */
218+
if (fmt->pad == FIMC_ISP_SD_PAD_SINK) {
219+
struct v4l2_subdev_format format = *fmt;
220+
unsigned int pad;
221+
222+
for (pad = FIMC_ISP_SD_PAD_SRC_FIFO;
223+
pad < FIMC_ISP_SD_PADS_NUM; pad++) {
224+
format.pad = pad;
225+
__isp_subdev_try_format(isp, fh, &format);
226+
mf = v4l2_subdev_get_try_format(fh, pad);
227+
*mf = format.format;
228+
}
229+
}
230+
} else {
231+
if (sd->entity.stream_count == 0) {
232+
if (fmt->pad == FIMC_ISP_SD_PAD_SINK) {
233+
struct v4l2_subdev_format format = *fmt;
234+
235+
isp->sink_fmt = *mf;
236+
237+
format.pad = FIMC_ISP_SD_PAD_SRC_DMA;
238+
__isp_subdev_try_format(isp, fh, &format);
239+
240+
isp->src_fmt = format.format;
241+
__is_set_frame_size(is, &isp->src_fmt);
242+
} else {
243+
isp->src_fmt = *mf;
244+
}
245+
} else {
246+
ret = -EBUSY;
247+
}
207248
}
208249

209-
if (sd->entity.stream_count == 0)
210-
__is_set_frame_size(is, mf);
211-
else
212-
ret = -EBUSY;
213250
mutex_unlock(&isp->subdev_lock);
214-
215251
return ret;
216252
}
217253

drivers/media/platform/exynos4-is/fimc-isp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ struct fimc_isp {
145145
struct vb2_alloc_ctx *alloc_ctx;
146146
struct v4l2_subdev subdev;
147147
struct media_pad subdev_pads[FIMC_ISP_SD_PADS_NUM];
148-
struct v4l2_mbus_framefmt subdev_fmt;
148+
struct v4l2_mbus_framefmt src_fmt;
149+
struct v4l2_mbus_framefmt sink_fmt;
149150
struct v4l2_ctrl *test_pattern;
150151
struct fimc_isp_ctrls ctrls;
151152

0 commit comments

Comments
 (0)