Commit ebf984bb authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] v4l2: replace s_mbus_fmt by set_fmt in bridge drivers

Replace all calls to s_mbus_fmt in bridge drivers by calls to the
set_fmt pad op.

Remove the old try/s_mbus_fmt video ops since they are now no longer used.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Acked-by: default avatarPrabhakar Lad <prabhakar.csengg@gmail.com>
Acked-by: default avatarScott Jiang <scott.jiang.linux@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 5eab4983
...@@ -93,13 +93,16 @@ static int cx18_s_video_encoding(struct cx2341x_handler *cxhdl, u32 val) ...@@ -93,13 +93,16 @@ static int cx18_s_video_encoding(struct cx2341x_handler *cxhdl, u32 val)
{ {
struct cx18 *cx = container_of(cxhdl, struct cx18, cxhdl); struct cx18 *cx = container_of(cxhdl, struct cx18, cxhdl);
int is_mpeg1 = val == V4L2_MPEG_VIDEO_ENCODING_MPEG_1; int is_mpeg1 = val == V4L2_MPEG_VIDEO_ENCODING_MPEG_1;
struct v4l2_mbus_framefmt fmt; struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
struct v4l2_mbus_framefmt *fmt = &format.format;
/* fix videodecoder resolution */ /* fix videodecoder resolution */
fmt.width = cxhdl->width / (is_mpeg1 ? 2 : 1); fmt->width = cxhdl->width / (is_mpeg1 ? 2 : 1);
fmt.height = cxhdl->height; fmt->height = cxhdl->height;
fmt.code = MEDIA_BUS_FMT_FIXED; fmt->code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(cx->sd_av, video, s_mbus_fmt, &fmt); v4l2_subdev_call(cx->sd_av, pad, set_fmt, NULL, &format);
return 0; return 0;
} }
......
...@@ -267,7 +267,9 @@ static int cx18_s_fmt_vid_cap(struct file *file, void *fh, ...@@ -267,7 +267,9 @@ static int cx18_s_fmt_vid_cap(struct file *file, void *fh,
{ {
struct cx18_open_id *id = fh2id(fh); struct cx18_open_id *id = fh2id(fh);
struct cx18 *cx = id->cx; struct cx18 *cx = id->cx;
struct v4l2_mbus_framefmt mbus_fmt; struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
struct cx18_stream *s = &cx->streams[id->type]; struct cx18_stream *s = &cx->streams[id->type];
int ret; int ret;
int w, h; int w, h;
...@@ -296,10 +298,10 @@ static int cx18_s_fmt_vid_cap(struct file *file, void *fh, ...@@ -296,10 +298,10 @@ static int cx18_s_fmt_vid_cap(struct file *file, void *fh,
s->vb_bytes_per_line = 1440; /* Packed */ s->vb_bytes_per_line = 1440; /* Packed */
} }
mbus_fmt.width = cx->cxhdl.width = w; format.format.width = cx->cxhdl.width = w;
mbus_fmt.height = cx->cxhdl.height = h; format.format.height = cx->cxhdl.height = h;
mbus_fmt.code = MEDIA_BUS_FMT_FIXED; format.format.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(cx->sd_av, video, s_mbus_fmt, &mbus_fmt); v4l2_subdev_call(cx->sd_av, pad, set_fmt, NULL, &format);
return cx18_g_fmt_vid_cap(file, fh, fmt); return cx18_g_fmt_vid_cap(file, fh, fmt);
} }
......
...@@ -581,7 +581,9 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -581,7 +581,9 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *f) struct v4l2_format *f)
{ {
struct cx23885_dev *dev = video_drvdata(file); struct cx23885_dev *dev = video_drvdata(file);
struct v4l2_mbus_framefmt mbus_fmt; struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
int err; int err;
dprintk(2, "%s()\n", __func__); dprintk(2, "%s()\n", __func__);
...@@ -600,10 +602,10 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -600,10 +602,10 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
dev->field = f->fmt.pix.field; dev->field = f->fmt.pix.field;
dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, dprintk(2, "%s() width=%d height=%d field=%d\n", __func__,
dev->width, dev->height, dev->field); dev->width, dev->height, dev->field);
v4l2_fill_mbus_format(&mbus_fmt, &f->fmt.pix, MEDIA_BUS_FMT_FIXED); v4l2_fill_mbus_format(&format.format, &f->fmt.pix, MEDIA_BUS_FMT_FIXED);
call_all(dev, video, s_mbus_fmt, &mbus_fmt); call_all(dev, pad, set_fmt, NULL, &format);
v4l2_fill_pix_format(&f->fmt.pix, &mbus_fmt); v4l2_fill_pix_format(&f->fmt.pix, &format.format);
/* s_mbus_fmt overwrites f->fmt.pix.field, restore it */ /* set_fmt overwrites f->fmt.pix.field, restore it */
f->fmt.pix.field = dev->field; f->fmt.pix.field = dev->field;
return 0; return 0;
} }
......
...@@ -64,13 +64,15 @@ static int ivtv_s_video_encoding(struct cx2341x_handler *cxhdl, u32 val) ...@@ -64,13 +64,15 @@ static int ivtv_s_video_encoding(struct cx2341x_handler *cxhdl, u32 val)
{ {
struct ivtv *itv = container_of(cxhdl, struct ivtv, cxhdl); struct ivtv *itv = container_of(cxhdl, struct ivtv, cxhdl);
int is_mpeg1 = val == V4L2_MPEG_VIDEO_ENCODING_MPEG_1; int is_mpeg1 = val == V4L2_MPEG_VIDEO_ENCODING_MPEG_1;
struct v4l2_mbus_framefmt fmt; struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
/* fix videodecoder resolution */ /* fix videodecoder resolution */
fmt.width = cxhdl->width / (is_mpeg1 ? 2 : 1); format.format.width = cxhdl->width / (is_mpeg1 ? 2 : 1);
fmt.height = cxhdl->height; format.format.height = cxhdl->height;
fmt.code = MEDIA_BUS_FMT_FIXED; format.format.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(itv->sd_video, video, s_mbus_fmt, &fmt); v4l2_subdev_call(itv->sd_video, pad, set_fmt, NULL, &format);
return 0; return 0;
} }
......
...@@ -581,7 +581,9 @@ static int ivtv_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f ...@@ -581,7 +581,9 @@ static int ivtv_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f
{ {
struct ivtv_open_id *id = fh2id(fh); struct ivtv_open_id *id = fh2id(fh);
struct ivtv *itv = id->itv; struct ivtv *itv = id->itv;
struct v4l2_mbus_framefmt mbus_fmt; struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
int ret = ivtv_try_fmt_vid_cap(file, fh, fmt); int ret = ivtv_try_fmt_vid_cap(file, fh, fmt);
int w = fmt->fmt.pix.width; int w = fmt->fmt.pix.width;
int h = fmt->fmt.pix.height; int h = fmt->fmt.pix.height;
...@@ -599,10 +601,10 @@ static int ivtv_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f ...@@ -599,10 +601,10 @@ static int ivtv_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f
itv->cxhdl.height = h; itv->cxhdl.height = h;
if (v4l2_ctrl_g_ctrl(itv->cxhdl.video_encoding) == V4L2_MPEG_VIDEO_ENCODING_MPEG_1) if (v4l2_ctrl_g_ctrl(itv->cxhdl.video_encoding) == V4L2_MPEG_VIDEO_ENCODING_MPEG_1)
fmt->fmt.pix.width /= 2; fmt->fmt.pix.width /= 2;
mbus_fmt.width = fmt->fmt.pix.width; format.format.width = fmt->fmt.pix.width;
mbus_fmt.height = h; format.format.height = h;
mbus_fmt.code = MEDIA_BUS_FMT_FIXED; format.format.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(itv->sd_video, video, s_mbus_fmt, &mbus_fmt); v4l2_subdev_call(itv->sd_video, pad, set_fmt, NULL, &format);
return ivtv_g_fmt_vid_cap(file, fh, fmt); return ivtv_g_fmt_vid_cap(file, fh, fmt);
} }
......
...@@ -140,11 +140,13 @@ static int empress_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -140,11 +140,13 @@ static int empress_s_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *f) struct v4l2_format *f)
{ {
struct saa7134_dev *dev = video_drvdata(file); struct saa7134_dev *dev = video_drvdata(file);
struct v4l2_mbus_framefmt mbus_fmt; struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
v4l2_fill_mbus_format(&mbus_fmt, &f->fmt.pix, MEDIA_BUS_FMT_FIXED); v4l2_fill_mbus_format(&format.format, &f->fmt.pix, MEDIA_BUS_FMT_FIXED);
saa_call_all(dev, video, s_mbus_fmt, &mbus_fmt); saa_call_all(dev, pad, set_fmt, NULL, &format);
v4l2_fill_pix_format(&f->fmt.pix, &mbus_fmt); v4l2_fill_pix_format(&f->fmt.pix, &format.format);
f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets; f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets;
......
...@@ -1455,7 +1455,6 @@ static int __vpfe_get_format(struct vpfe_device *vpfe, ...@@ -1455,7 +1455,6 @@ static int __vpfe_get_format(struct vpfe_device *vpfe,
static int __vpfe_set_format(struct vpfe_device *vpfe, static int __vpfe_set_format(struct vpfe_device *vpfe,
struct v4l2_format *format, unsigned int *bpp) struct v4l2_format *format, unsigned int *bpp)
{ {
struct v4l2_mbus_framefmt mbus_fmt;
struct vpfe_subdev_info *sdinfo; struct vpfe_subdev_info *sdinfo;
struct v4l2_subdev_format fmt; struct v4l2_subdev_format fmt;
int ret; int ret;
...@@ -1472,23 +1471,11 @@ static int __vpfe_set_format(struct vpfe_device *vpfe, ...@@ -1472,23 +1471,11 @@ static int __vpfe_set_format(struct vpfe_device *vpfe,
pix_to_mbus(vpfe, &format->fmt.pix, &fmt.format); pix_to_mbus(vpfe, &format->fmt.pix, &fmt.format);
ret = v4l2_subdev_call(sdinfo->sd, pad, set_fmt, NULL, &fmt); ret = v4l2_subdev_call(sdinfo->sd, pad, set_fmt, NULL, &fmt);
if (ret && ret != -ENOIOCTLCMD && ret != -ENODEV) if (ret)
return ret; return ret;
if (!ret) {
v4l2_fill_pix_format(&format->fmt.pix, &fmt.format); v4l2_fill_pix_format(&format->fmt.pix, &fmt.format);
mbus_to_pix(vpfe, &fmt.format, &format->fmt.pix, bpp); mbus_to_pix(vpfe, &fmt.format, &format->fmt.pix, bpp);
} else {
ret = v4l2_device_call_until_err(&vpfe->v4l2_dev,
sdinfo->grp_id,
video, s_mbus_fmt,
&mbus_fmt);
if (ret && ret != -ENOIOCTLCMD && ret != -ENODEV)
return ret;
v4l2_fill_pix_format(&format->fmt.pix, &mbus_fmt);
mbus_to_pix(vpfe, &mbus_fmt, &format->fmt.pix, bpp);
}
format->type = vpfe->fmt.type; format->type = vpfe->fmt.type;
......
...@@ -674,7 +674,9 @@ static int bcap_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -674,7 +674,9 @@ static int bcap_s_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *fmt) struct v4l2_format *fmt)
{ {
struct bcap_device *bcap_dev = video_drvdata(file); struct bcap_device *bcap_dev = video_drvdata(file);
struct v4l2_mbus_framefmt mbus_fmt; struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
struct bcap_format bcap_fmt; struct bcap_format bcap_fmt;
struct v4l2_pix_format *pixfmt = &fmt->fmt.pix; struct v4l2_pix_format *pixfmt = &fmt->fmt.pix;
int ret; int ret;
...@@ -687,8 +689,8 @@ static int bcap_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -687,8 +689,8 @@ static int bcap_s_fmt_vid_cap(struct file *file, void *priv,
if (ret < 0) if (ret < 0)
return ret; return ret;
v4l2_fill_mbus_format(&mbus_fmt, pixfmt, bcap_fmt.mbus_code); v4l2_fill_mbus_format(&format.format, pixfmt, bcap_fmt.mbus_code);
ret = v4l2_subdev_call(bcap_dev->sd, video, s_mbus_fmt, &mbus_fmt); ret = v4l2_subdev_call(bcap_dev->sd, pad, set_fmt, NULL, &format);
if (ret < 0) if (ret < 0)
return ret; return ret;
bcap_dev->fmt = *pixfmt; bcap_dev->fmt = *pixfmt;
......
...@@ -979,13 +979,15 @@ static int mcam_cam_set_flip(struct mcam_camera *cam) ...@@ -979,13 +979,15 @@ static int mcam_cam_set_flip(struct mcam_camera *cam)
static int mcam_cam_configure(struct mcam_camera *cam) static int mcam_cam_configure(struct mcam_camera *cam)
{ {
struct v4l2_mbus_framefmt mbus_fmt; struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
int ret; int ret;
v4l2_fill_mbus_format(&mbus_fmt, &cam->pix_format, cam->mbus_code); v4l2_fill_mbus_format(&format.format, &cam->pix_format, cam->mbus_code);
ret = sensor_call(cam, core, init, 0); ret = sensor_call(cam, core, init, 0);
if (ret == 0) if (ret == 0)
ret = sensor_call(cam, video, s_mbus_fmt, &mbus_fmt); ret = sensor_call(cam, pad, set_fmt, NULL, &format);
/* /*
* OV7670 does weird things if flip is set *before* format... * OV7670 does weird things if flip is set *before* format...
*/ */
......
...@@ -679,12 +679,14 @@ static int sh_vou_s_fmt_vid_out(struct file *file, void *priv, ...@@ -679,12 +679,14 @@ static int sh_vou_s_fmt_vid_out(struct file *file, void *priv,
unsigned int img_height_max; unsigned int img_height_max;
int pix_idx; int pix_idx;
struct sh_vou_geometry geo; struct sh_vou_geometry geo;
struct v4l2_mbus_framefmt mbfmt = { struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
/* Revisit: is this the correct code? */ /* Revisit: is this the correct code? */
.code = MEDIA_BUS_FMT_YUYV8_2X8, .format.code = MEDIA_BUS_FMT_YUYV8_2X8,
.field = V4L2_FIELD_INTERLACED, .format.field = V4L2_FIELD_INTERLACED,
.colorspace = V4L2_COLORSPACE_SMPTE170M, .format.colorspace = V4L2_COLORSPACE_SMPTE170M,
}; };
struct v4l2_mbus_framefmt *mbfmt = &format.format;
int ret; int ret;
dev_dbg(vou_dev->v4l2_dev.dev, "%s(): %ux%u -> %ux%u\n", __func__, dev_dbg(vou_dev->v4l2_dev.dev, "%s(): %ux%u -> %ux%u\n", __func__,
...@@ -720,27 +722,27 @@ static int sh_vou_s_fmt_vid_out(struct file *file, void *priv, ...@@ -720,27 +722,27 @@ static int sh_vou_s_fmt_vid_out(struct file *file, void *priv,
vou_adjust_output(&geo, vou_dev->std); vou_adjust_output(&geo, vou_dev->std);
mbfmt.width = geo.output.width; mbfmt->width = geo.output.width;
mbfmt.height = geo.output.height; mbfmt->height = geo.output.height;
ret = v4l2_device_call_until_err(&vou_dev->v4l2_dev, 0, video, ret = v4l2_device_call_until_err(&vou_dev->v4l2_dev, 0, pad,
s_mbus_fmt, &mbfmt); set_fmt, NULL, &format);
/* Must be implemented, so, don't check for -ENOIOCTLCMD */ /* Must be implemented, so, don't check for -ENOIOCTLCMD */
if (ret < 0) if (ret < 0)
return ret; return ret;
dev_dbg(vou_dev->v4l2_dev.dev, "%s(): %ux%u -> %ux%u\n", __func__, dev_dbg(vou_dev->v4l2_dev.dev, "%s(): %ux%u -> %ux%u\n", __func__,
geo.output.width, geo.output.height, mbfmt.width, mbfmt.height); geo.output.width, geo.output.height, mbfmt->width, mbfmt->height);
/* Sanity checks */ /* Sanity checks */
if ((unsigned)mbfmt.width > VOU_MAX_IMAGE_WIDTH || if ((unsigned)mbfmt->width > VOU_MAX_IMAGE_WIDTH ||
(unsigned)mbfmt.height > img_height_max || (unsigned)mbfmt->height > img_height_max ||
mbfmt.code != MEDIA_BUS_FMT_YUYV8_2X8) mbfmt->code != MEDIA_BUS_FMT_YUYV8_2X8)
return -EIO; return -EIO;
if (mbfmt.width != geo.output.width || if (mbfmt->width != geo.output.width ||
mbfmt.height != geo.output.height) { mbfmt->height != geo.output.height) {
geo.output.width = mbfmt.width; geo.output.width = mbfmt->width;
geo.output.height = mbfmt.height; geo.output.height = mbfmt->height;
vou_adjust_input(&geo, vou_dev->std); vou_adjust_input(&geo, vou_dev->std);
} }
...@@ -942,11 +944,12 @@ static int sh_vou_s_crop(struct file *file, void *fh, const struct v4l2_crop *a) ...@@ -942,11 +944,12 @@ static int sh_vou_s_crop(struct file *file, void *fh, const struct v4l2_crop *a)
struct v4l2_crop sd_crop = {.type = V4L2_BUF_TYPE_VIDEO_OUTPUT}; struct v4l2_crop sd_crop = {.type = V4L2_BUF_TYPE_VIDEO_OUTPUT};
struct v4l2_pix_format *pix = &vou_dev->pix; struct v4l2_pix_format *pix = &vou_dev->pix;
struct sh_vou_geometry geo; struct sh_vou_geometry geo;
struct v4l2_mbus_framefmt mbfmt = { struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
/* Revisit: is this the correct code? */ /* Revisit: is this the correct code? */
.code = MEDIA_BUS_FMT_YUYV8_2X8, .format.code = MEDIA_BUS_FMT_YUYV8_2X8,
.field = V4L2_FIELD_INTERLACED, .format.field = V4L2_FIELD_INTERLACED,
.colorspace = V4L2_COLORSPACE_SMPTE170M, .format.colorspace = V4L2_COLORSPACE_SMPTE170M,
}; };
unsigned int img_height_max; unsigned int img_height_max;
int ret; int ret;
...@@ -984,22 +987,22 @@ static int sh_vou_s_crop(struct file *file, void *fh, const struct v4l2_crop *a) ...@@ -984,22 +987,22 @@ static int sh_vou_s_crop(struct file *file, void *fh, const struct v4l2_crop *a)
*/ */
v4l2_device_call_until_err(&vou_dev->v4l2_dev, 0, video, v4l2_device_call_until_err(&vou_dev->v4l2_dev, 0, video,
s_crop, &sd_crop); s_crop, &sd_crop);
mbfmt.width = geo.output.width; format.format.width = geo.output.width;
mbfmt.height = geo.output.height; format.format.height = geo.output.height;
ret = v4l2_device_call_until_err(&vou_dev->v4l2_dev, 0, video, ret = v4l2_device_call_until_err(&vou_dev->v4l2_dev, 0, pad,
s_mbus_fmt, &mbfmt); set_fmt, NULL, &format);
/* Must be implemented, so, don't check for -ENOIOCTLCMD */ /* Must be implemented, so, don't check for -ENOIOCTLCMD */
if (ret < 0) if (ret < 0)
return ret; return ret;
/* Sanity checks */ /* Sanity checks */
if ((unsigned)mbfmt.width > VOU_MAX_IMAGE_WIDTH || if ((unsigned)format.format.width > VOU_MAX_IMAGE_WIDTH ||
(unsigned)mbfmt.height > img_height_max || (unsigned)format.format.height > img_height_max ||
mbfmt.code != MEDIA_BUS_FMT_YUYV8_2X8) format.format.code != MEDIA_BUS_FMT_YUYV8_2X8)
return -EIO; return -EIO;
geo.output.width = mbfmt.width; geo.output.width = format.format.width;
geo.output.height = mbfmt.height; geo.output.height = format.format.height;
/* /*
* No down-scaling. According to the API, current call has precedence: * No down-scaling. According to the API, current call has precedence:
......
...@@ -487,7 +487,10 @@ static int isi_camera_set_fmt(struct soc_camera_device *icd, ...@@ -487,7 +487,10 @@ static int isi_camera_set_fmt(struct soc_camera_device *icd,
struct v4l2_subdev *sd = soc_camera_to_subdev(icd); struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
const struct soc_camera_format_xlate *xlate; const struct soc_camera_format_xlate *xlate;
struct v4l2_pix_format *pix = &f->fmt.pix; struct v4l2_pix_format *pix = &f->fmt.pix;
struct v4l2_mbus_framefmt mf; struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
struct v4l2_mbus_framefmt *mf = &format.format;
int ret; int ret;
xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat); xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat);
...@@ -500,27 +503,27 @@ static int isi_camera_set_fmt(struct soc_camera_device *icd, ...@@ -500,27 +503,27 @@ static int isi_camera_set_fmt(struct soc_camera_device *icd,
dev_dbg(icd->parent, "Plan to set format %dx%d\n", dev_dbg(icd->parent, "Plan to set format %dx%d\n",
pix->width, pix->height); pix->width, pix->height);
mf.width = pix->width; mf->width = pix->width;
mf.height = pix->height; mf->height = pix->height;
mf.field = pix->field; mf->field = pix->field;
mf.colorspace = pix->colorspace; mf->colorspace = pix->colorspace;
mf.code = xlate->code; mf->code = xlate->code;
ret = v4l2_subdev_call(sd, video, s_mbus_fmt, &mf); ret = v4l2_subdev_call(sd, pad, set_fmt, NULL, &format);
if (ret < 0) if (ret < 0)
return ret; return ret;
if (mf.code != xlate->code) if (mf->code != xlate->code)
return -EINVAL; return -EINVAL;
ret = configure_geometry(isi, pix->width, pix->height, xlate->code); ret = configure_geometry(isi, pix->width, pix->height, xlate->code);
if (ret < 0) if (ret < 0)
return ret; return ret;
pix->width = mf.width; pix->width = mf->width;
pix->height = mf.height; pix->height = mf->height;
pix->field = mf.field; pix->field = mf->field;
pix->colorspace = mf.colorspace; pix->colorspace = mf->colorspace;
icd->current_fmt = xlate; icd->current_fmt = xlate;
dev_dbg(icd->parent, "Finally set format %dx%d\n", dev_dbg(icd->parent, "Finally set format %dx%d\n",
......
...@@ -1127,7 +1127,10 @@ static int mx2_camera_set_fmt(struct soc_camera_device *icd, ...@@ -1127,7 +1127,10 @@ static int mx2_camera_set_fmt(struct soc_camera_device *icd,
struct v4l2_subdev *sd = soc_camera_to_subdev(icd); struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
const struct soc_camera_format_xlate *xlate; const struct soc_camera_format_xlate *xlate;
struct v4l2_pix_format *pix = &f->fmt.pix; struct v4l2_pix_format *pix = &f->fmt.pix;
struct v4l2_mbus_framefmt mf; struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
struct v4l2_mbus_framefmt *mf = &format.format;
int ret; int ret;
dev_dbg(icd->parent, "%s: requested params: width = %d, height = %d\n", dev_dbg(icd->parent, "%s: requested params: width = %d, height = %d\n",
...@@ -1140,19 +1143,19 @@ static int mx2_camera_set_fmt(struct soc_camera_device *icd, ...@@ -1140,19 +1143,19 @@ static int mx2_camera_set_fmt(struct soc_camera_device *icd,
return -EINVAL; return -EINVAL;
} }
mf.width = pix->width; mf->width = pix->width;
mf.height = pix->height; mf->height = pix->height;
mf.field = pix->field; mf->field = pix->field;
mf.colorspace = pix->colorspace; mf->colorspace = pix->colorspace;
mf.code = xlate->code; mf->code = xlate->code;
ret = v4l2_subdev_call(sd, video, s_mbus_fmt, &mf); ret = v4l2_subdev_call(sd, pad, set_fmt, NULL, &format);
if (ret < 0 && ret != -ENOIOCTLCMD) if (ret < 0 && ret != -ENOIOCTLCMD)
return ret; return ret;
/* Store width and height returned by the sensor for resizing */ /* Store width and height returned by the sensor for resizing */
pcdev->s_width = mf.width; pcdev->s_width = mf->width;
pcdev->s_height = mf.height; pcdev->s_height = mf->height;
dev_dbg(icd->parent, "%s: sensor params: width = %d, height = %d\n", dev_dbg(icd->parent, "%s: sensor params: width = %d, height = %d\n",
__func__, pcdev->s_width, pcdev->s_height); __func__, pcdev->s_width, pcdev->s_height);
...@@ -1160,19 +1163,19 @@ static int mx2_camera_set_fmt(struct soc_camera_device *icd, ...@@ -1160,19 +1163,19 @@ static int mx2_camera_set_fmt(struct soc_camera_device *icd,
xlate->host_fmt->fourcc); xlate->host_fmt->fourcc);
memset(pcdev->resizing, 0, sizeof(pcdev->resizing)); memset(pcdev->resizing, 0, sizeof(pcdev->resizing));
if ((mf.width != pix->width || mf.height != pix->height) && if ((mf->width != pix->width || mf->height != pix->height) &&
pcdev->emma_prp->cfg.in_fmt == PRP_CNTL_DATA_IN_YUV422) { pcdev->emma_prp->cfg.in_fmt == PRP_CNTL_DATA_IN_YUV422) {
if (mx2_emmaprp_resize(pcdev, &mf, pix, true) < 0) if (mx2_emmaprp_resize(pcdev, mf, pix, true) < 0)
dev_dbg(icd->parent, "%s: can't resize\n", __func__); dev_dbg(icd->parent, "%s: can't resize\n", __func__);
} }
if (mf.code != xlate->code) if (mf->code != xlate->code)
return -EINVAL; return -EINVAL;
pix->width = mf.width; pix->width = mf->width;
pix->height = mf.height; pix->height = mf->height;
pix->field = mf.field; pix->field = mf->field;
pix->colorspace = mf.colorspace; pix->colorspace = mf->colorspace;
icd->current_fmt = xlate; icd->current_fmt = xlate;
dev_dbg(icd->parent, "%s: returned params: width = %d, height = %d\n", dev_dbg(icd->parent, "%s: returned params: width = %d, height = %d\n",
......
...@@ -828,7 +828,7 @@ static int mx3_camera_set_crop(struct soc_camera_device *icd, ...@@ -828,7 +828,7 @@ static int mx3_camera_set_crop(struct soc_camera_device *icd,
if (mf->width & 7) { if (mf->width & 7) {
/* Ouch! We can only handle 8-byte aligned width... */ /* Ouch! We can only handle 8-byte aligned width... */
stride_align(&mf->width); stride_align(&mf->width);
ret = v4l2_subdev_call(sd, video, s_mbus_fmt, mf); ret = v4l2_subdev_call(sd, pad, set_fmt, NULL, &fmt);
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
...@@ -854,7 +854,10 @@ static int mx3_camera_set_fmt(struct soc_camera_device *icd, ...@@ -854,7 +854,10 @@ static int mx3_camera_set_fmt(struct soc_camera_device *icd,
struct v4l2_subdev *sd = soc_camera_to_subdev(icd); struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
const struct soc_camera_format_xlate *xlate; const struct soc_camera_format_xlate *xlate;
struct v4l2_pix_format *pix = &f->fmt.pix; struct v4l2_pix_format *pix = &f->fmt.pix;
struct v4l2_mbus_framefmt mf; struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
struct v4l2_mbus_framefmt *mf = &format.format;
int ret; int ret;
xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat); xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat);
...@@ -875,17 +878,17 @@ static int mx3_camera_set_fmt(struct soc_camera_device *icd, ...@@ -875,17 +878,17 @@ static int mx3_camera_set_fmt(struct soc_camera_device *icd,
configure_geometry(mx3_cam, pix->width, pix->height, xlate->host_fmt); configure_geometry(mx3_cam, pix->width, pix->height, xlate->host_fmt);
mf.width = pix->width; mf->width = pix->width;
mf.height = pix->height; mf->height = pix->height;
mf.field = pix->field; mf->field = pix->field;
mf.colorspace = pix->colorspace; mf->colorspace = pix->colorspace;
mf.code = xlate->code; mf->code = xlate->code;
ret = v4l2_subdev_call(sd, video, s_mbus_fmt, &mf); ret = v4l2_subdev_call(sd, pad, set_fmt, NULL, &format);
if (ret < 0) if (ret < 0)
return ret; return ret;
if (mf.code != xlate->code) if (mf->code != xlate->code)
return -EINVAL; return -EINVAL;
if (!mx3_cam->idmac_channel[0]) { if (!mx3_cam->idmac_channel[0]) {
...@@ -894,11 +897,11 @@ static int mx3_camera_set_fmt(struct soc_camera_device *icd, ...@@ -894,11 +897,11 @@ static int mx3_camera_set_fmt(struct soc_camera_device *icd,
return ret; return ret;
} }
pix->width = mf.width; pix->width = mf->width;
pix->height = mf.height; pix->height = mf->height;
pix->field = mf.field; pix->field = mf->field;
mx3_cam->field = mf.field; mx3_cam->field = mf->field;
pix->colorspace = mf.colorspace; pix->colorspace = mf->colorspace;
icd->current_fmt = xlate; icd->current_fmt = xlate;
dev_dbg(icd->parent, "Sensor set %dx%d\n", pix->width, pix->height); dev_dbg(icd->parent, "Sensor set %dx%d\n", pix->width, pix->height);
......
...@@ -1157,7 +1157,7 @@ static int dma_align(int *width, int *height, ...@@ -1157,7 +1157,7 @@ static int dma_align(int *width, int *height,
return 1; return 1;
} }
#define subdev_call_with_sense(pcdev, dev, icd, sd, function, args...) \ #define subdev_call_with_sense(pcdev, dev, icd, sd, op, function, args...) \
({ \ ({ \
struct soc_camera_sense sense = { \ struct soc_camera_sense sense = { \
.master_clock = pcdev->camexclk, \ .master_clock = pcdev->camexclk, \
...@@ -1168,7 +1168,7 @@ static int dma_align(int *width, int *height, ...@@ -1168,7 +1168,7 @@ static int dma_align(int *width, int *height,
if (pcdev->pdata) \ if (pcdev->pdata) \
sense.pixel_clock_max = pcdev->pdata->lclk_khz_max * 1000; \ sense.pixel_clock_max = pcdev->pdata->lclk_khz_max * 1000; \
icd->sense = &sense; \ icd->sense = &sense; \
__ret = v4l2_subdev_call(sd, video, function, ##args); \ __ret = v4l2_subdev_call(sd, op, function, ##args); \
icd->sense = NULL; \ icd->sense = NULL; \
\ \
if (sense.flags & SOCAM_SENSE_PCLK_CHANGED) { \ if (sense.flags & SOCAM_SENSE_PCLK_CHANGED) { \
...@@ -1182,16 +1182,17 @@ static int dma_align(int *width, int *height, ...@@ -1182,16 +1182,17 @@ static int dma_align(int *width, int *height,
__ret; \ __ret; \
}) })
static int set_mbus_format(struct omap1_cam_dev *pcdev, struct device *dev, static int set_format(struct omap1_cam_dev *pcdev, struct device *dev,
struct soc_camera_device *icd, struct v4l2_subdev *sd, struct soc_camera_device *icd, struct v4l2_subdev *sd,
struct v4l2_mbus_framefmt *mf, struct v4l2_subdev_format *format,
const struct soc_camera_format_xlate *xlate) const struct soc_camera_format_xlate *xlate)
{ {
s32 bytes_per_line; s32 bytes_per_line;
int ret = subdev_call_with_sense(pcdev, dev, icd, sd, s_mbus_fmt, mf); struct v4l2_mbus_framefmt *mf = &format->format;
int ret = subdev_call_with_sense(pcdev, dev, icd, sd, pad, set_fmt, NULL, format);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "%s: s_mbus_fmt failed\n", __func__); dev_err(dev, "%s: set_fmt failed\n", __func__);
return ret; return ret;
} }
...@@ -1230,7 +1231,7 @@ static int omap1_cam_set_crop(struct soc_camera_device *icd, ...@@ -1230,7 +1231,7 @@ static int omap1_cam_set_crop(struct soc_camera_device *icd,
struct v4l2_mbus_framefmt *mf = &fmt.format; struct v4l2_mbus_framefmt *mf = &fmt.format;
int ret; int ret;
ret = subdev_call_with_sense(pcdev, dev, icd, sd, s_crop, crop); ret = subdev_call_with_sense(pcdev, dev, icd, sd, video, s_crop, crop);
if (ret < 0) { if (ret < 0) {
dev_warn(dev, "%s: failed to crop to %ux%u@%u:%u\n", __func__, dev_warn(dev, "%s: failed to crop to %ux%u@%u:%u\n", __func__,
rect->width, rect->height, rect->left, rect->top); rect->width, rect->height, rect->left, rect->top);
...@@ -1254,7 +1255,7 @@ static int omap1_cam_set_crop(struct soc_camera_device *icd, ...@@ -1254,7 +1255,7 @@ static int omap1_cam_set_crop(struct soc_camera_device *icd,
if (!ret) { if (!ret) {
/* sensor returned geometry not DMA aligned, trying to fix */ /* sensor returned geometry not DMA aligned, trying to fix */
ret = set_mbus_format(pcdev, dev, icd, sd, mf, xlate); ret = set_format(pcdev, dev, icd, sd, &fmt, xlate);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "%s: failed to set format\n", __func__); dev_err(dev, "%s: failed to set format\n", __func__);
return ret; return ret;
...@@ -1276,7 +1277,10 @@ static int omap1_cam_set_fmt(struct soc_camera_device *icd, ...@@ -1276,7 +1277,10 @@ static int omap1_cam_set_fmt(struct soc_camera_device *icd,
struct soc_camera_host *ici = to_soc_camera_host(dev); struct soc_camera_host *ici = to_soc_camera_host(dev);
struct omap1_cam_dev *pcdev = ici->priv; struct omap1_cam_dev *pcdev = ici->priv;
struct v4l2_pix_format *pix = &f->fmt.pix; struct v4l2_pix_format *pix = &f->fmt.pix;
struct v4l2_mbus_framefmt mf; struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
struct v4l2_mbus_framefmt *mf = &format.format;
int ret; int ret;
xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat); xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat);
...@@ -1286,13 +1290,13 @@ static int omap1_cam_set_fmt(struct soc_camera_device *icd, ...@@ -1286,13 +1290,13 @@ static int omap1_cam_set_fmt(struct soc_camera_device *icd,
return -EINVAL; return -EINVAL;
} }
mf.width = pix->width; mf->width = pix->width;
mf.height = pix->height; mf->height = pix->height;
mf.field = pix->field; mf->field = pix->field;
mf.colorspace = pix->colorspace; mf->colorspace = pix->colorspace;
mf.code = xlate->code; mf->code = xlate->code;
ret = dma_align(&mf.width, &mf.height, xlate->host_fmt, pcdev->vb_mode, ret = dma_align(&mf->width, &mf->height, xlate->host_fmt, pcdev->vb_mode,
true); true);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "%s: failed to align %ux%u %s with DMA\n", dev_err(dev, "%s: failed to align %ux%u %s with DMA\n",
...@@ -1301,16 +1305,16 @@ static int omap1_cam_set_fmt(struct soc_camera_device *icd, ...@@ -1301,16 +1305,16 @@ static int omap1_cam_set_fmt(struct soc_camera_device *icd,
return ret; return ret;
} }
ret = set_mbus_format(pcdev, dev, icd, sd, &mf, xlate); ret = set_format(pcdev, dev, icd, sd, &format, xlate);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "%s: failed to set format\n", __func__); dev_err(dev, "%s: failed to set format\n", __func__);
return ret; return ret;
} }
pix->width = mf.width; pix->width = mf->width;
pix->height = mf.height; pix->height = mf->height;
pix->field = mf.field; pix->field = mf->field;
pix->colorspace = mf.colorspace; pix->colorspace = mf->colorspace;
icd->current_fmt = xlate; icd->current_fmt = xlate;
return 0; return 0;
......
...@@ -1383,7 +1383,7 @@ static int pxa_camera_set_crop(struct soc_camera_device *icd, ...@@ -1383,7 +1383,7 @@ static int pxa_camera_set_crop(struct soc_camera_device *icd,
v4l_bound_align_image(&mf->width, 48, 2048, 1, v4l_bound_align_image(&mf->width, 48, 2048, 1,
&mf->height, 32, 2048, 0, &mf->height, 32, 2048, 0,
fourcc == V4L2_PIX_FMT_YUV422P ? 4 : 0); fourcc == V4L2_PIX_FMT_YUV422P ? 4 : 0);
ret = v4l2_subdev_call(sd, video, s_mbus_fmt, mf); ret = v4l2_subdev_call(sd, pad, set_fmt, NULL, &fmt);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1425,7 +1425,10 @@ static int pxa_camera_set_fmt(struct soc_camera_device *icd, ...@@ -1425,7 +1425,10 @@ static int pxa_camera_set_fmt(struct soc_camera_device *icd,
.pixel_clock_max = pcdev->ciclk / 4, .pixel_clock_max = pcdev->ciclk / 4,
}; };
struct v4l2_pix_format *pix = &f->fmt.pix; struct v4l2_pix_format *pix = &f->fmt.pix;
struct v4l2_mbus_framefmt mf; struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
struct v4l2_mbus_framefmt *mf = &format.format;
int ret; int ret;
xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat); xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat);
...@@ -1439,15 +1442,15 @@ static int pxa_camera_set_fmt(struct soc_camera_device *icd, ...@@ -1439,15 +1442,15 @@ static int pxa_camera_set_fmt(struct soc_camera_device *icd,
/* The caller holds a mutex. */ /* The caller holds a mutex. */
icd->sense = &sense; icd->sense = &sense;
mf.width = pix->width; mf->width = pix->width;
mf.height = pix->height; mf->height = pix->height;
mf.field = pix->field; mf->field = pix->field;
mf.colorspace = pix->colorspace; mf->colorspace = pix->colorspace;
mf.code = xlate->code; mf->code = xlate->code;
ret = v4l2_subdev_call(sd, video, s_mbus_fmt, &mf); ret = v4l2_subdev_call(sd, pad, set_fmt, NULL, &format);
if (mf.code != xlate->code) if (mf->code != xlate->code)
return -EINVAL; return -EINVAL;
icd->sense = NULL; icd->sense = NULL;
...@@ -1455,10 +1458,10 @@ static int pxa_camera_set_fmt(struct soc_camera_device *icd, ...@@ -1455,10 +1458,10 @@ static int pxa_camera_set_fmt(struct soc_camera_device *icd,
if (ret < 0) { if (ret < 0) {
dev_warn(dev, "Failed to configure for format %x\n", dev_warn(dev, "Failed to configure for format %x\n",
pix->pixelformat); pix->pixelformat);
} else if (pxa_camera_check_frame(mf.width, mf.height)) { } else if (pxa_camera_check_frame(mf->width, mf->height)) {
dev_warn(dev, dev_warn(dev,
"Camera driver produced an unsupported frame %dx%d\n", "Camera driver produced an unsupported frame %dx%d\n",
mf.width, mf.height); mf->width, mf->height);
ret = -EINVAL; ret = -EINVAL;
} else if (sense.flags & SOCAM_SENSE_PCLK_CHANGED) { } else if (sense.flags & SOCAM_SENSE_PCLK_CHANGED) {
if (sense.pixel_clock > sense.pixel_clock_max) { if (sense.pixel_clock > sense.pixel_clock_max) {
...@@ -1473,10 +1476,10 @@ static int pxa_camera_set_fmt(struct soc_camera_device *icd, ...@@ -1473,10 +1476,10 @@ static int pxa_camera_set_fmt(struct soc_camera_device *icd,
if (ret < 0) if (ret < 0)
return ret; return ret;
pix->width = mf.width; pix->width = mf->width;
pix->height = mf.height; pix->height = mf->height;
pix->field = mf.field; pix->field = mf->field;
pix->colorspace = mf.colorspace; pix->colorspace = mf->colorspace;
icd->current_fmt = xlate; icd->current_fmt = xlate;
return ret; return ret;
......
...@@ -1376,8 +1376,8 @@ static int rcar_vin_get_formats(struct soc_camera_device *icd, unsigned int idx, ...@@ -1376,8 +1376,8 @@ static int rcar_vin_get_formats(struct soc_camera_device *icd, unsigned int idx,
mf->height = 960 >> shift; mf->height = 960 >> shift;
ret = v4l2_device_call_until_err(sd->v4l2_dev, ret = v4l2_device_call_until_err(sd->v4l2_dev,
soc_camera_grp_id(icd), soc_camera_grp_id(icd),
video, s_mbus_fmt, pad, set_fmt, NULL,
mf); &fmt);
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
......
...@@ -1111,8 +1111,8 @@ static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, unsigned int ...@@ -1111,8 +1111,8 @@ static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, unsigned int
mf->width = 2560 >> shift; mf->width = 2560 >> shift;
mf->height = 1920 >> shift; mf->height = 1920 >> shift;
ret = v4l2_device_call_until_err(sd->v4l2_dev, ret = v4l2_device_call_until_err(sd->v4l2_dev,
soc_camera_grp_id(icd), video, soc_camera_grp_id(icd), pad,
s_mbus_fmt, mf); set_fmt, NULL, &fmt);
if (ret < 0) if (ret < 0)
return ret; return ret;
shift++; shift++;
...@@ -1286,8 +1286,8 @@ static int sh_mobile_ceu_set_crop(struct soc_camera_device *icd, ...@@ -1286,8 +1286,8 @@ static int sh_mobile_ceu_set_crop(struct soc_camera_device *icd,
if (interm_width < icd->user_width || interm_height < icd->user_height) { if (interm_width < icd->user_width || interm_height < icd->user_height) {
ret = v4l2_device_call_until_err(sd->v4l2_dev, ret = v4l2_device_call_until_err(sd->v4l2_dev,
soc_camera_grp_id(icd), video, soc_camera_grp_id(icd), pad,
s_mbus_fmt, mf); set_fmt, NULL, &fmt);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
...@@ -211,22 +211,23 @@ int soc_camera_client_s_crop(struct v4l2_subdev *sd, ...@@ -211,22 +211,23 @@ int soc_camera_client_s_crop(struct v4l2_subdev *sd,
} }
EXPORT_SYMBOL(soc_camera_client_s_crop); EXPORT_SYMBOL(soc_camera_client_s_crop);
/* Iterative s_mbus_fmt, also updates cached client crop on success */ /* Iterative set_fmt, also updates cached client crop on success */
static int client_s_fmt(struct soc_camera_device *icd, static int client_set_fmt(struct soc_camera_device *icd,
struct v4l2_rect *rect, struct v4l2_rect *subrect, struct v4l2_rect *rect, struct v4l2_rect *subrect,
unsigned int max_width, unsigned int max_height, unsigned int max_width, unsigned int max_height,
struct v4l2_mbus_framefmt *mf, bool host_can_scale) struct v4l2_subdev_format *format, bool host_can_scale)
{ {
struct v4l2_subdev *sd = soc_camera_to_subdev(icd); struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
struct device *dev = icd->parent; struct device *dev = icd->parent;
struct v4l2_mbus_framefmt *mf = &format->format;
unsigned int width = mf->width, height = mf->height, tmp_w, tmp_h; unsigned int width = mf->width, height = mf->height, tmp_w, tmp_h;
struct v4l2_cropcap cap; struct v4l2_cropcap cap;
bool host_1to1; bool host_1to1;
int ret; int ret;
ret = v4l2_device_call_until_err(sd->v4l2_dev, ret = v4l2_device_call_until_err(sd->v4l2_dev,
soc_camera_grp_id(icd), video, soc_camera_grp_id(icd), pad,
s_mbus_fmt, mf); set_fmt, NULL, format);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -265,8 +266,8 @@ static int client_s_fmt(struct soc_camera_device *icd, ...@@ -265,8 +266,8 @@ static int client_s_fmt(struct soc_camera_device *icd,
mf->width = tmp_w; mf->width = tmp_w;
mf->height = tmp_h; mf->height = tmp_h;
ret = v4l2_device_call_until_err(sd->v4l2_dev, ret = v4l2_device_call_until_err(sd->v4l2_dev,
soc_camera_grp_id(icd), video, soc_camera_grp_id(icd), pad,
s_mbus_fmt, mf); set_fmt, NULL, format);
dev_geo(dev, "Camera scaled to %ux%u\n", dev_geo(dev, "Camera scaled to %ux%u\n",
mf->width, mf->height); mf->width, mf->height);
if (ret < 0) { if (ret < 0) {
...@@ -309,7 +310,11 @@ int soc_camera_client_scale(struct soc_camera_device *icd, ...@@ -309,7 +310,11 @@ int soc_camera_client_scale(struct soc_camera_device *icd,
bool host_can_scale, unsigned int shift) bool host_can_scale, unsigned int shift)
{ {
struct device *dev = icd->parent; struct device *dev = icd->parent;
struct v4l2_mbus_framefmt mf_tmp = *mf; struct v4l2_subdev_format fmt_tmp = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
.format = *mf,
};
struct v4l2_mbus_framefmt *mf_tmp = &fmt_tmp.format;
unsigned int scale_h, scale_v; unsigned int scale_h, scale_v;
int ret; int ret;
...@@ -317,25 +322,25 @@ int soc_camera_client_scale(struct soc_camera_device *icd, ...@@ -317,25 +322,25 @@ int soc_camera_client_scale(struct soc_camera_device *icd,
* 5. Apply iterative camera S_FMT for camera user window (also updates * 5. Apply iterative camera S_FMT for camera user window (also updates
* client crop cache and the imaginary sub-rectangle). * client crop cache and the imaginary sub-rectangle).
*/ */
ret = client_s_fmt(icd, rect, subrect, *width, *height, ret = client_set_fmt(icd, rect, subrect, *width, *height,
&mf_tmp, host_can_scale); &fmt_tmp, host_can_scale);
if (ret < 0) if (ret < 0)
return ret; return ret;
dev_geo(dev, "5: camera scaled to %ux%u\n", dev_geo(dev, "5: camera scaled to %ux%u\n",
mf_tmp.width, mf_tmp.height); mf_tmp->width, mf_tmp->height);
/* 6. Retrieve camera output window (g_fmt) */ /* 6. Retrieve camera output window (g_fmt) */
/* unneeded - it is already in "mf_tmp" */ /* unneeded - it is already in "mf_tmp" */
/* 7. Calculate new client scales. */ /* 7. Calculate new client scales. */
scale_h = soc_camera_calc_scale(rect->width, shift, mf_tmp.width); scale_h = soc_camera_calc_scale(rect->width, shift, mf_tmp->width);
scale_v = soc_camera_calc_scale(rect->height, shift, mf_tmp.height); scale_v = soc_camera_calc_scale(rect->height, shift, mf_tmp->height);
mf->width = mf_tmp.width; mf->width = mf_tmp->width;
mf->height = mf_tmp.height; mf->height = mf_tmp->height;
mf->colorspace = mf_tmp.colorspace; mf->colorspace = mf_tmp->colorspace;
/* /*
* 8. Calculate new host crop - apply camera scales to previously * 8. Calculate new host crop - apply camera scales to previously
......
...@@ -249,13 +249,15 @@ static int viacam_set_flip(struct via_camera *cam) ...@@ -249,13 +249,15 @@ static int viacam_set_flip(struct via_camera *cam)
*/ */
static int viacam_configure_sensor(struct via_camera *cam) static int viacam_configure_sensor(struct via_camera *cam)
{ {
struct v4l2_mbus_framefmt mbus_fmt; struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
int ret; int ret;
v4l2_fill_mbus_format(&mbus_fmt, &cam->sensor_format, cam->mbus_code); v4l2_fill_mbus_format(&format.format, &cam->sensor_format, cam->mbus_code);
ret = sensor_call(cam, core, init, 0); ret = sensor_call(cam, core, init, 0);
if (ret == 0) if (ret == 0)
ret = sensor_call(cam, video, s_mbus_fmt, &mbus_fmt); ret = sensor_call(cam, pad, set_fmt, NULL, &format);
/* /*
* OV7670 does weird things if flip is set *before* format... * OV7670 does weird things if flip is set *before* format...
*/ */
......
...@@ -1878,13 +1878,15 @@ static int cx231xx_s_video_encoding(struct cx2341x_handler *cxhdl, u32 val) ...@@ -1878,13 +1878,15 @@ static int cx231xx_s_video_encoding(struct cx2341x_handler *cxhdl, u32 val)
{ {
struct cx231xx *dev = container_of(cxhdl, struct cx231xx, mpeg_ctrl_handler); struct cx231xx *dev = container_of(cxhdl, struct cx231xx, mpeg_ctrl_handler);
int is_mpeg1 = val == V4L2_MPEG_VIDEO_ENCODING_MPEG_1; int is_mpeg1 = val == V4L2_MPEG_VIDEO_ENCODING_MPEG_1;
struct v4l2_mbus_framefmt fmt; struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
/* fix videodecoder resolution */ /* fix videodecoder resolution */
fmt.width = cxhdl->width / (is_mpeg1 ? 2 : 1); format.format.width = cxhdl->width / (is_mpeg1 ? 2 : 1);
fmt.height = cxhdl->height; format.format.height = cxhdl->height;
fmt.code = MEDIA_BUS_FMT_FIXED; format.format.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(dev->sd_cx25840, video, s_mbus_fmt, &fmt); v4l2_subdev_call(dev->sd_cx25840, pad, set_fmt, NULL, &format);
return 0; return 0;
} }
......
...@@ -1013,7 +1013,9 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -1013,7 +1013,9 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
struct cx231xx *dev = fh->dev; struct cx231xx *dev = fh->dev;
int rc; int rc;
struct cx231xx_fmt *fmt; struct cx231xx_fmt *fmt;
struct v4l2_mbus_framefmt mbus_fmt; struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
rc = check_dev(dev); rc = check_dev(dev);
if (rc < 0) if (rc < 0)
...@@ -1041,9 +1043,9 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -1041,9 +1043,9 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
dev->height = f->fmt.pix.height; dev->height = f->fmt.pix.height;
dev->format = fmt; dev->format = fmt;
v4l2_fill_mbus_format(&mbus_fmt, &f->fmt.pix, MEDIA_BUS_FMT_FIXED); v4l2_fill_mbus_format(&format.format, &f->fmt.pix, MEDIA_BUS_FMT_FIXED);
call_all(dev, video, s_mbus_fmt, &mbus_fmt); call_all(dev, pad, set_fmt, NULL, &format);
v4l2_fill_pix_format(&f->fmt.pix, &mbus_fmt); v4l2_fill_pix_format(&f->fmt.pix, &format.format);
return rc; return rc;
} }
...@@ -1061,7 +1063,9 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id norm) ...@@ -1061,7 +1063,9 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id norm)
{ {
struct cx231xx_fh *fh = priv; struct cx231xx_fh *fh = priv;
struct cx231xx *dev = fh->dev; struct cx231xx *dev = fh->dev;
struct v4l2_mbus_framefmt mbus_fmt; struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
int rc; int rc;
rc = check_dev(dev); rc = check_dev(dev);
...@@ -1085,11 +1089,10 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id norm) ...@@ -1085,11 +1089,10 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id norm)
/* We need to reset basic properties in the decoder related to /* We need to reset basic properties in the decoder related to
resolution (since a standard change effects things like the number resolution (since a standard change effects things like the number
of lines in VACT, etc) */ of lines in VACT, etc) */
memset(&mbus_fmt, 0, sizeof(mbus_fmt)); format.format.code = MEDIA_BUS_FMT_FIXED;
mbus_fmt.code = MEDIA_BUS_FMT_FIXED; format.format.width = dev->width;
mbus_fmt.width = dev->width; format.format.height = dev->height;
mbus_fmt.height = dev->height; call_all(dev, pad, set_fmt, NULL, &format);
call_all(dev, video, s_mbus_fmt, &mbus_fmt);
/* do mode control overrides */ /* do mode control overrides */
cx231xx_do_mode_ctrl_overrides(dev); cx231xx_do_mode_ctrl_overrides(dev);
......
...@@ -404,7 +404,9 @@ int em28xx_init_camera(struct em28xx *dev) ...@@ -404,7 +404,9 @@ int em28xx_init_camera(struct em28xx *dev)
.addr = client->addr, .addr = client->addr,
.platform_data = &camlink, .platform_data = &camlink,
}; };
struct v4l2_mbus_framefmt fmt; struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
/* /*
* FIXME: sensor supports resolutions up to 1600x1200, but * FIXME: sensor supports resolutions up to 1600x1200, but
...@@ -425,10 +427,10 @@ int em28xx_init_camera(struct em28xx *dev) ...@@ -425,10 +427,10 @@ int em28xx_init_camera(struct em28xx *dev)
break; break;
} }
fmt.code = MEDIA_BUS_FMT_YUYV8_2X8; format.format.code = MEDIA_BUS_FMT_YUYV8_2X8;
fmt.width = 640; format.format.width = 640;
fmt.height = 480; format.format.height = 480;
v4l2_subdev_call(subdev, video, s_mbus_fmt, &fmt); v4l2_subdev_call(subdev, pad, set_fmt, NULL, &format);
/* NOTE: for UXGA=1600x1200 switch to 12MHz */ /* NOTE: for UXGA=1600x1200 switch to 12MHz */
dev->board.xclk = EM28XX_XCLK_FREQUENCY_24MHZ; dev->board.xclk = EM28XX_XCLK_FREQUENCY_24MHZ;
......
...@@ -250,15 +250,17 @@ static int set_capture_size(struct go7007 *go, struct v4l2_format *fmt, int try) ...@@ -250,15 +250,17 @@ static int set_capture_size(struct go7007 *go, struct v4l2_format *fmt, int try)
go->encoder_v_offset = go->board_info->sensor_v_offset; go->encoder_v_offset = go->board_info->sensor_v_offset;
if (go->board_info->sensor_flags & GO7007_SENSOR_SCALING) { if (go->board_info->sensor_flags & GO7007_SENSOR_SCALING) {
struct v4l2_mbus_framefmt mbus_fmt; struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
mbus_fmt.code = MEDIA_BUS_FMT_FIXED; format.format.code = MEDIA_BUS_FMT_FIXED;
mbus_fmt.width = fmt ? fmt->fmt.pix.width : width; format.format.width = fmt ? fmt->fmt.pix.width : width;
mbus_fmt.height = height; format.format.height = height;
go->encoder_h_halve = 0; go->encoder_h_halve = 0;
go->encoder_v_halve = 0; go->encoder_v_halve = 0;
go->encoder_subsample = 0; go->encoder_subsample = 0;
call_all(&go->v4l2_dev, video, s_mbus_fmt, &mbus_fmt); call_all(&go->v4l2_dev, pad, set_fmt, NULL, &format);
} else { } else {
if (width <= sensor_width / 4) { if (width <= sensor_width / 4) {
go->encoder_h_halve = 1; go->encoder_h_halve = 1;
......
...@@ -2962,14 +2962,17 @@ static void pvr2_subdev_update(struct pvr2_hdw *hdw) ...@@ -2962,14 +2962,17 @@ static void pvr2_subdev_update(struct pvr2_hdw *hdw)
} }
if (hdw->res_hor_dirty || hdw->res_ver_dirty || hdw->force_dirty) { if (hdw->res_hor_dirty || hdw->res_ver_dirty || hdw->force_dirty) {
struct v4l2_mbus_framefmt fmt; struct v4l2_subdev_format format = {
memset(&fmt, 0, sizeof(fmt)); .which = V4L2_SUBDEV_FORMAT_ACTIVE,
fmt.width = hdw->res_hor_val; };
fmt.height = hdw->res_ver_val;
fmt.code = MEDIA_BUS_FMT_FIXED; format.format.width = hdw->res_hor_val;
format.format.height = hdw->res_ver_val;
format.format.code = MEDIA_BUS_FMT_FIXED;
pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_size(%dx%d)", pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_size(%dx%d)",
fmt.width, fmt.height); format.format.width, format.format.height);
v4l2_device_call_all(&hdw->v4l2_dev, 0, video, s_mbus_fmt, &fmt); v4l2_device_call_all(&hdw->v4l2_dev, 0, pad, set_fmt,
NULL, &format);
} }
if (hdw->srate_dirty || hdw->force_dirty) { if (hdw->srate_dirty || hdw->force_dirty) {
......
...@@ -293,10 +293,6 @@ struct v4l2_mbus_frame_desc { ...@@ -293,10 +293,6 @@ struct v4l2_mbus_frame_desc {
g_dv_timings(): Get custom dv timings in the sub device. g_dv_timings(): Get custom dv timings in the sub device.
try_mbus_fmt: try to set a pixel format on a video data source
s_mbus_fmt: set a pixel format on a video data source
g_mbus_config: get supported mediabus configurations g_mbus_config: get supported mediabus configurations
s_mbus_config: set a certain mediabus configuration. This operation is added s_mbus_config: set a certain mediabus configuration. This operation is added
...@@ -334,10 +330,6 @@ struct v4l2_subdev_video_ops { ...@@ -334,10 +330,6 @@ struct v4l2_subdev_video_ops {
struct v4l2_dv_timings *timings); struct v4l2_dv_timings *timings);
int (*query_dv_timings)(struct v4l2_subdev *sd, int (*query_dv_timings)(struct v4l2_subdev *sd,
struct v4l2_dv_timings *timings); struct v4l2_dv_timings *timings);
int (*try_mbus_fmt)(struct v4l2_subdev *sd,
struct v4l2_mbus_framefmt *fmt);
int (*s_mbus_fmt)(struct v4l2_subdev *sd,
struct v4l2_mbus_framefmt *fmt);
int (*g_mbus_config)(struct v4l2_subdev *sd, int (*g_mbus_config)(struct v4l2_subdev *sd,
struct v4l2_mbus_config *cfg); struct v4l2_mbus_config *cfg);
int (*s_mbus_config)(struct v4l2_subdev *sd, int (*s_mbus_config)(struct v4l2_subdev *sd,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment