aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Gmeiner <christian.gmeiner@gmail.com>2011-10-05 16:48:43 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-10-19 05:59:05 -0400
commitf1a84c9b0a962a940a1f8b9202d84842e54e8d7c (patch)
treee41930f4a70f679ad1633cf87da65a4158823e4c
parent4c2625db6f172114bcc4fd9e62f3c030c5fb4e4c (diff)
[media] adv7175: Make use of media bus pixel codes
The ADV7175A/ADV7176A can operate in either 8-bit or 16-bit YCrCb mode. * 8-Bit YCrCb Mode This default mode accepts multiplexed YCrCb inputs through the P7-P0 pixel inputs. The inputs follow the sequence Cb0, Y0 Cr0, Y1 Cb1, Y2, etc. The Y, Cb and Cr data are input on a rising clock edge. * 16-Bit YCrCb Mode This mode accepts Y inputs through the P7–P0 pixel inputs and multiplexed CrCb inputs through the P15–P8 pixel inputs. The data is loaded on every second rising edge of CLOCK. The inputs follow the sequence Cb0, Y0 Cr0, Y1 Cb1, Y2, etc. Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/adv7175.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c
index d2327dbb473f..206078eca853 100644
--- a/drivers/media/video/adv7175.c
+++ b/drivers/media/video/adv7175.c
@@ -61,6 +61,11 @@ static inline struct adv7175 *to_adv7175(struct v4l2_subdev *sd)
61 61
62static char *inputs[] = { "pass_through", "play_back", "color_bar" }; 62static char *inputs[] = { "pass_through", "play_back", "color_bar" };
63 63
64static enum v4l2_mbus_pixelcode adv7175_codes[] = {
65 V4L2_MBUS_FMT_UYVY8_2X8,
66 V4L2_MBUS_FMT_UYVY8_1X16,
67};
68
64/* ----------------------------------------------------------------------- */ 69/* ----------------------------------------------------------------------- */
65 70
66static inline int adv7175_write(struct v4l2_subdev *sd, u8 reg, u8 value) 71static inline int adv7175_write(struct v4l2_subdev *sd, u8 reg, u8 value)
@@ -296,6 +301,60 @@ static int adv7175_s_routing(struct v4l2_subdev *sd,
296 return 0; 301 return 0;
297} 302}
298 303
304static int adv7175_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
305 enum v4l2_mbus_pixelcode *code)
306{
307 if (index >= ARRAY_SIZE(adv7175_codes))
308 return -EINVAL;
309
310 *code = adv7175_codes[index];
311 return 0;
312}
313
314static int adv7175_g_fmt(struct v4l2_subdev *sd,
315 struct v4l2_mbus_framefmt *mf)
316{
317 u8 val = adv7175_read(sd, 0x7);
318
319 if ((val & 0x40) == (1 << 6))
320 mf->code = V4L2_MBUS_FMT_UYVY8_1X16;
321 else
322 mf->code = V4L2_MBUS_FMT_UYVY8_2X8;
323
324 mf->colorspace = V4L2_COLORSPACE_SMPTE170M;
325 mf->width = 0;
326 mf->height = 0;
327 mf->field = V4L2_FIELD_ANY;
328
329 return 0;
330}
331
332static int adv7175_s_fmt(struct v4l2_subdev *sd,
333 struct v4l2_mbus_framefmt *mf)
334{
335 u8 val = adv7175_read(sd, 0x7);
336 int ret;
337
338 switch (mf->code) {
339 case V4L2_MBUS_FMT_UYVY8_2X8:
340 val &= ~0x40;
341 break;
342
343 case V4L2_MBUS_FMT_UYVY8_1X16:
344 val |= 0x40;
345 break;
346
347 default:
348 v4l2_dbg(1, debug, sd,
349 "illegal v4l2_mbus_framefmt code: %d\n", mf->code);
350 return -EINVAL;
351 }
352
353 ret = adv7175_write(sd, 0x7, val);
354
355 return ret;
356}
357
299static int adv7175_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) 358static int adv7175_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip)
300{ 359{
301 struct i2c_client *client = v4l2_get_subdevdata(sd); 360 struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -324,6 +383,9 @@ static const struct v4l2_subdev_core_ops adv7175_core_ops = {
324static const struct v4l2_subdev_video_ops adv7175_video_ops = { 383static const struct v4l2_subdev_video_ops adv7175_video_ops = {
325 .s_std_output = adv7175_s_std_output, 384 .s_std_output = adv7175_s_std_output,
326 .s_routing = adv7175_s_routing, 385 .s_routing = adv7175_s_routing,
386 .s_mbus_fmt = adv7175_s_fmt,
387 .g_mbus_fmt = adv7175_g_fmt,
388 .enum_mbus_fmt = adv7175_enum_fmt,
327}; 389};
328 390
329static const struct v4l2_subdev_ops adv7175_ops = { 391static const struct v4l2_subdev_ops adv7175_ops = {