Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 285169
b: refs/heads/master
c: 0d37d35
h: refs/heads/master
i:
  285167: 7e0a39c
v: v3
  • Loading branch information
Christian Gmeiner authored and Mauro Carvalho Chehab committed Nov 7, 2011
1 parent aadd29d commit 24817ad
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fabade547fd306cd3e8b1dc068ccdfec2553bad5
refs/heads/master: 0d37d35035cb41f01e12082fa6b39a2e465ca4ba
62 changes: 62 additions & 0 deletions trunk/drivers/media/video/adv7170.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ static inline struct adv7170 *to_adv7170(struct v4l2_subdev *sd)

static char *inputs[] = { "pass_through", "play_back" };

static enum v4l2_mbus_pixelcode adv7170_codes[] = {
V4L2_MBUS_FMT_UYVY8_2X8,
V4L2_MBUS_FMT_UYVY8_1X16,
};

/* ----------------------------------------------------------------------- */

static inline int adv7170_write(struct v4l2_subdev *sd, u8 reg, u8 value)
Expand Down Expand Up @@ -258,6 +263,60 @@ static int adv7170_s_routing(struct v4l2_subdev *sd,
return 0;
}

static int adv7170_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
enum v4l2_mbus_pixelcode *code)
{
if (index >= ARRAY_SIZE(adv7170_codes))
return -EINVAL;

*code = adv7170_codes[index];
return 0;
}

static int adv7170_g_fmt(struct v4l2_subdev *sd,
struct v4l2_mbus_framefmt *mf)
{
u8 val = adv7170_read(sd, 0x7);

if ((val & 0x40) == (1 << 6))
mf->code = V4L2_MBUS_FMT_UYVY8_1X16;
else
mf->code = V4L2_MBUS_FMT_UYVY8_2X8;

mf->colorspace = V4L2_COLORSPACE_SMPTE170M;
mf->width = 0;
mf->height = 0;
mf->field = V4L2_FIELD_ANY;

return 0;
}

static int adv7170_s_fmt(struct v4l2_subdev *sd,
struct v4l2_mbus_framefmt *mf)
{
u8 val = adv7170_read(sd, 0x7);
int ret;

switch (mf->code) {
case V4L2_MBUS_FMT_UYVY8_2X8:
val &= ~0x40;
break;

case V4L2_MBUS_FMT_UYVY8_1X16:
val |= 0x40;
break;

default:
v4l2_dbg(1, debug, sd,
"illegal v4l2_mbus_framefmt code: %d\n", mf->code);
return -EINVAL;
}

ret = adv7170_write(sd, 0x7, val);

return ret;
}

static int adv7170_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
Expand All @@ -274,6 +333,9 @@ static const struct v4l2_subdev_core_ops adv7170_core_ops = {
static const struct v4l2_subdev_video_ops adv7170_video_ops = {
.s_std_output = adv7170_s_std_output,
.s_routing = adv7170_s_routing,
.s_mbus_fmt = adv7170_s_fmt,
.g_mbus_fmt = adv7170_g_fmt,
.enum_mbus_fmt = adv7170_enum_fmt,
};

static const struct v4l2_subdev_ops adv7170_ops = {
Expand Down

0 comments on commit 24817ad

Please sign in to comment.