提交 e1dedcff 编写于 作者: H Hans Verkuil 提交者: Mauro Carvalho Chehab

[media] cobalt: simplify colorspace code

Simplify cobalt_g/try_fmt_vid_cap by not setting the colorspace fields in
pix again (since v4l2_fill_pix_format does that already), and by using
v4l2_fill_mbus_format in cobalt_s_fmt_vid_out which allows the get_fmt
call to be dropped as well.
Signed-off-by: NHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: NMauro Carvalho Chehab <mchehab@osg.samsung.com>
上级 136a5e9e
...@@ -737,10 +737,6 @@ static int cobalt_g_fmt_vid_cap(struct file *file, void *priv_fh, ...@@ -737,10 +737,6 @@ static int cobalt_g_fmt_vid_cap(struct file *file, void *priv_fh,
sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
v4l2_subdev_call(s->sd, pad, get_fmt, NULL, &sd_fmt); v4l2_subdev_call(s->sd, pad, get_fmt, NULL, &sd_fmt);
v4l2_fill_pix_format(pix, &sd_fmt.format); v4l2_fill_pix_format(pix, &sd_fmt.format);
pix->colorspace = sd_fmt.format.colorspace;
pix->xfer_func = sd_fmt.format.xfer_func;
pix->ycbcr_enc = sd_fmt.format.ycbcr_enc;
pix->quantization = sd_fmt.format.quantization;
} }
pix->pixelformat = s->pixfmt; pix->pixelformat = s->pixfmt;
...@@ -783,10 +779,6 @@ static int cobalt_try_fmt_vid_cap(struct file *file, void *priv_fh, ...@@ -783,10 +779,6 @@ static int cobalt_try_fmt_vid_cap(struct file *file, void *priv_fh,
sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
v4l2_subdev_call(s->sd, pad, get_fmt, NULL, &sd_fmt); v4l2_subdev_call(s->sd, pad, get_fmt, NULL, &sd_fmt);
v4l2_fill_pix_format(pix, &sd_fmt.format); v4l2_fill_pix_format(pix, &sd_fmt.format);
pix->colorspace = sd_fmt.format.colorspace;
pix->xfer_func = sd_fmt.format.xfer_func;
pix->ycbcr_enc = sd_fmt.format.ycbcr_enc;
pix->quantization = sd_fmt.format.quantization;
} }
switch (pix->pixelformat) { switch (pix->pixelformat) {
...@@ -933,6 +925,7 @@ static int cobalt_s_fmt_vid_out(struct file *file, void *priv_fh, ...@@ -933,6 +925,7 @@ static int cobalt_s_fmt_vid_out(struct file *file, void *priv_fh,
struct cobalt_stream *s = video_drvdata(file); struct cobalt_stream *s = video_drvdata(file);
struct v4l2_pix_format *pix = &f->fmt.pix; struct v4l2_pix_format *pix = &f->fmt.pix;
struct v4l2_subdev_format sd_fmt = { 0 }; struct v4l2_subdev_format sd_fmt = { 0 };
u32 code;
if (cobalt_try_fmt_vid_out(file, priv_fh, f)) if (cobalt_try_fmt_vid_out(file, priv_fh, f))
return -EINVAL; return -EINVAL;
...@@ -945,9 +938,11 @@ static int cobalt_s_fmt_vid_out(struct file *file, void *priv_fh, ...@@ -945,9 +938,11 @@ static int cobalt_s_fmt_vid_out(struct file *file, void *priv_fh,
switch (pix->pixelformat) { switch (pix->pixelformat) {
case V4L2_PIX_FMT_YUYV: case V4L2_PIX_FMT_YUYV:
s->bpp = COBALT_BYTES_PER_PIXEL_YUYV; s->bpp = COBALT_BYTES_PER_PIXEL_YUYV;
code = MEDIA_BUS_FMT_UYVY8_1X16;
break; break;
case V4L2_PIX_FMT_BGR32: case V4L2_PIX_FMT_BGR32:
s->bpp = COBALT_BYTES_PER_PIXEL_RGB32; s->bpp = COBALT_BYTES_PER_PIXEL_RGB32;
code = MEDIA_BUS_FMT_RGB888_1X24;
break; break;
default: default:
return -EINVAL; return -EINVAL;
...@@ -961,11 +956,7 @@ static int cobalt_s_fmt_vid_out(struct file *file, void *priv_fh, ...@@ -961,11 +956,7 @@ static int cobalt_s_fmt_vid_out(struct file *file, void *priv_fh,
s->ycbcr_enc = pix->ycbcr_enc; s->ycbcr_enc = pix->ycbcr_enc;
s->quantization = pix->quantization; s->quantization = pix->quantization;
sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
v4l2_subdev_call(s->sd, pad, get_fmt, NULL, &sd_fmt); v4l2_fill_mbus_format(&sd_fmt.format, pix, code);
sd_fmt.format.colorspace = pix->colorspace;
sd_fmt.format.xfer_func = pix->xfer_func;
sd_fmt.format.ycbcr_enc = pix->ycbcr_enc;
sd_fmt.format.quantization = pix->quantization;
v4l2_subdev_call(s->sd, pad, set_fmt, NULL, &sd_fmt); v4l2_subdev_call(s->sd, pad, set_fmt, NULL, &sd_fmt);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册