diff options
author | Christian Gmeiner <christian.gmeiner@gmail.com> | 2011-10-27 17:50:21 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-11-07 09:42:56 -0500 |
commit | 0d37d35035cb41f01e12082fa6b39a2e465ca4ba (patch) | |
tree | 82eee3bc011fdf05f1932e9c5d7debff53780da1 /drivers/media/video/adv7170.c | |
parent | fabade547fd306cd3e8b1dc068ccdfec2553bad5 (diff) |
[media] Make use of media bus pixel codes in adv7170 driver
The ADV7170/ADV7171 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>
Diffstat (limited to 'drivers/media/video/adv7170.c')
-rw-r--r-- | drivers/media/video/adv7170.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c index 23ba5c37c3e4..879f1d839760 100644 --- a/drivers/media/video/adv7170.c +++ b/drivers/media/video/adv7170.c | |||
@@ -64,6 +64,11 @@ static inline struct adv7170 *to_adv7170(struct v4l2_subdev *sd) | |||
64 | 64 | ||
65 | static char *inputs[] = { "pass_through", "play_back" }; | 65 | static char *inputs[] = { "pass_through", "play_back" }; |
66 | 66 | ||
67 | static enum v4l2_mbus_pixelcode adv7170_codes[] = { | ||
68 | V4L2_MBUS_FMT_UYVY8_2X8, | ||
69 | V4L2_MBUS_FMT_UYVY8_1X16, | ||
70 | }; | ||
71 | |||
67 | /* ----------------------------------------------------------------------- */ | 72 | /* ----------------------------------------------------------------------- */ |
68 | 73 | ||
69 | static inline int adv7170_write(struct v4l2_subdev *sd, u8 reg, u8 value) | 74 | static inline int adv7170_write(struct v4l2_subdev *sd, u8 reg, u8 value) |
@@ -258,6 +263,60 @@ static int adv7170_s_routing(struct v4l2_subdev *sd, | |||
258 | return 0; | 263 | return 0; |
259 | } | 264 | } |
260 | 265 | ||
266 | static int adv7170_enum_fmt(struct v4l2_subdev *sd, unsigned int index, | ||
267 | enum v4l2_mbus_pixelcode *code) | ||
268 | { | ||
269 | if (index >= ARRAY_SIZE(adv7170_codes)) | ||
270 | return -EINVAL; | ||
271 | |||
272 | *code = adv7170_codes[index]; | ||
273 | return 0; | ||
274 | } | ||
275 | |||
276 | static int adv7170_g_fmt(struct v4l2_subdev *sd, | ||
277 | struct v4l2_mbus_framefmt *mf) | ||
278 | { | ||
279 | u8 val = adv7170_read(sd, 0x7); | ||
280 | |||
281 | if ((val & 0x40) == (1 << 6)) | ||
282 | mf->code = V4L2_MBUS_FMT_UYVY8_1X16; | ||
283 | else | ||
284 | mf->code = V4L2_MBUS_FMT_UYVY8_2X8; | ||
285 | |||
286 | mf->colorspace = V4L2_COLORSPACE_SMPTE170M; | ||
287 | mf->width = 0; | ||
288 | mf->height = 0; | ||
289 | mf->field = V4L2_FIELD_ANY; | ||
290 | |||
291 | return 0; | ||
292 | } | ||
293 | |||
294 | static int adv7170_s_fmt(struct v4l2_subdev *sd, | ||
295 | struct v4l2_mbus_framefmt *mf) | ||
296 | { | ||
297 | u8 val = adv7170_read(sd, 0x7); | ||
298 | int ret; | ||
299 | |||
300 | switch (mf->code) { | ||
301 | case V4L2_MBUS_FMT_UYVY8_2X8: | ||
302 | val &= ~0x40; | ||
303 | break; | ||
304 | |||
305 | case V4L2_MBUS_FMT_UYVY8_1X16: | ||
306 | val |= 0x40; | ||
307 | break; | ||
308 | |||
309 | default: | ||
310 | v4l2_dbg(1, debug, sd, | ||
311 | "illegal v4l2_mbus_framefmt code: %d\n", mf->code); | ||
312 | return -EINVAL; | ||
313 | } | ||
314 | |||
315 | ret = adv7170_write(sd, 0x7, val); | ||
316 | |||
317 | return ret; | ||
318 | } | ||
319 | |||
261 | static int adv7170_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) | 320 | static int adv7170_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) |
262 | { | 321 | { |
263 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 322 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
@@ -274,6 +333,9 @@ static const struct v4l2_subdev_core_ops adv7170_core_ops = { | |||
274 | static const struct v4l2_subdev_video_ops adv7170_video_ops = { | 333 | static const struct v4l2_subdev_video_ops adv7170_video_ops = { |
275 | .s_std_output = adv7170_s_std_output, | 334 | .s_std_output = adv7170_s_std_output, |
276 | .s_routing = adv7170_s_routing, | 335 | .s_routing = adv7170_s_routing, |
336 | .s_mbus_fmt = adv7170_s_fmt, | ||
337 | .g_mbus_fmt = adv7170_g_fmt, | ||
338 | .enum_mbus_fmt = adv7170_enum_fmt, | ||
277 | }; | 339 | }; |
278 | 340 | ||
279 | static const struct v4l2_subdev_ops adv7170_ops = { | 341 | static const struct v4l2_subdev_ops adv7170_ops = { |