Skip to content

Commit 2e9521f

Browse files
committed
Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6
* 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6: [media] V4L: soc-camera: regression fix: calculate .sizeimage in soc_camera.c [media] v4l2-subdev: fix broken subdev control enumeration [media] Fix cx88 remote control input [media] v4l: Release module if subdev registration fails
2 parents 39dcfa5 + dca6b6d commit 2e9521f

4 files changed

Lines changed: 54 additions & 15 deletions

File tree

‎drivers/media/video/cx88/cx88-input.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ void cx88_ir_irq(struct cx88_core *core)
524524
for (todo = 32; todo > 0; todo -= bits) {
525525
ev.pulse = samples & 0x80000000 ? false : true;
526526
bits = min(todo, 32U - fls(ev.pulse ? samples : ~samples));
527-
ev.duration = (bits * NSEC_PER_SEC) / (1000 * ir_samplerate);
527+
ev.duration = (bits * (NSEC_PER_SEC / 1000)) / ir_samplerate;
528528
ir_raw_event_store_with_filter(ir->dev, &ev);
529529
samples <<= bits;
530530
}

‎drivers/media/video/soc_camera.c‎

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,50 @@ unsigned long soc_camera_apply_sensor_flags(struct soc_camera_link *icl,
136136
}
137137
EXPORT_SYMBOL(soc_camera_apply_sensor_flags);
138138

139+
#define pixfmtstr(x) (x) & 0xff, ((x) >> 8) & 0xff, ((x) >> 16) & 0xff, \
140+
((x) >> 24) & 0xff
141+
142+
static int soc_camera_try_fmt(struct soc_camera_device *icd,
143+
struct v4l2_format *f)
144+
{
145+
struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
146+
struct v4l2_pix_format *pix = &f->fmt.pix;
147+
int ret;
148+
149+
dev_dbg(&icd->dev, "TRY_FMT(%c%c%c%c, %ux%u)\n",
150+
pixfmtstr(pix->pixelformat), pix->width, pix->height);
151+
152+
pix->bytesperline = 0;
153+
pix->sizeimage = 0;
154+
155+
ret = ici->ops->try_fmt(icd, f);
156+
if (ret < 0)
157+
return ret;
158+
159+
if (!pix->sizeimage) {
160+
if (!pix->bytesperline) {
161+
const struct soc_camera_format_xlate *xlate;
162+
163+
xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat);
164+
if (!xlate)
165+
return -EINVAL;
166+
167+
ret = soc_mbus_bytes_per_line(pix->width,
168+
xlate->host_fmt);
169+
if (ret > 0)
170+
pix->bytesperline = ret;
171+
}
172+
if (pix->bytesperline)
173+
pix->sizeimage = pix->bytesperline * pix->height;
174+
}
175+
176+
return 0;
177+
}
178+
139179
static int soc_camera_try_fmt_vid_cap(struct file *file, void *priv,
140180
struct v4l2_format *f)
141181
{
142182
struct soc_camera_device *icd = file->private_data;
143-
struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
144183

145184
WARN_ON(priv != file->private_data);
146185

@@ -149,7 +188,7 @@ static int soc_camera_try_fmt_vid_cap(struct file *file, void *priv,
149188
return -EINVAL;
150189

151190
/* limit format to hardware capabilities */
152-
return ici->ops->try_fmt(icd, f);
191+
return soc_camera_try_fmt(icd, f);
153192
}
154193

155194
static int soc_camera_enum_input(struct file *file, void *priv,
@@ -362,9 +401,6 @@ static void soc_camera_free_user_formats(struct soc_camera_device *icd)
362401
icd->user_formats = NULL;
363402
}
364403

365-
#define pixfmtstr(x) (x) & 0xff, ((x) >> 8) & 0xff, ((x) >> 16) & 0xff, \
366-
((x) >> 24) & 0xff
367-
368404
/* Called with .vb_lock held, or from the first open(2), see comment there */
369405
static int soc_camera_set_fmt(struct soc_camera_device *icd,
370406
struct v4l2_format *f)
@@ -377,7 +413,7 @@ static int soc_camera_set_fmt(struct soc_camera_device *icd,
377413
pixfmtstr(pix->pixelformat), pix->width, pix->height);
378414

379415
/* We always call try_fmt() before set_fmt() or set_crop() */
380-
ret = ici->ops->try_fmt(icd, f);
416+
ret = soc_camera_try_fmt(icd, f);
381417
if (ret < 0)
382418
return ret;
383419

‎drivers/media/video/v4l2-device.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,18 @@ int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev,
155155
sd->v4l2_dev = v4l2_dev;
156156
if (sd->internal_ops && sd->internal_ops->registered) {
157157
err = sd->internal_ops->registered(sd);
158-
if (err)
158+
if (err) {
159+
module_put(sd->owner);
159160
return err;
161+
}
160162
}
161163

162164
/* This just returns 0 if either of the two args is NULL */
163165
err = v4l2_ctrl_add_handler(v4l2_dev->ctrl_handler, sd->ctrl_handler);
164166
if (err) {
165167
if (sd->internal_ops && sd->internal_ops->unregistered)
166168
sd->internal_ops->unregistered(sd);
169+
module_put(sd->owner);
167170
return err;
168171
}
169172

‎drivers/media/video/v4l2-subdev.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,25 +155,25 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
155155

156156
switch (cmd) {
157157
case VIDIOC_QUERYCTRL:
158-
return v4l2_subdev_queryctrl(sd, arg);
158+
return v4l2_queryctrl(sd->ctrl_handler, arg);
159159

160160
case VIDIOC_QUERYMENU:
161-
return v4l2_subdev_querymenu(sd, arg);
161+
return v4l2_querymenu(sd->ctrl_handler, arg);
162162

163163
case VIDIOC_G_CTRL:
164-
return v4l2_subdev_g_ctrl(sd, arg);
164+
return v4l2_g_ctrl(sd->ctrl_handler, arg);
165165

166166
case VIDIOC_S_CTRL:
167-
return v4l2_subdev_s_ctrl(sd, arg);
167+
return v4l2_s_ctrl(sd->ctrl_handler, arg);
168168

169169
case VIDIOC_G_EXT_CTRLS:
170-
return v4l2_subdev_g_ext_ctrls(sd, arg);
170+
return v4l2_g_ext_ctrls(sd->ctrl_handler, arg);
171171

172172
case VIDIOC_S_EXT_CTRLS:
173-
return v4l2_subdev_s_ext_ctrls(sd, arg);
173+
return v4l2_s_ext_ctrls(sd->ctrl_handler, arg);
174174

175175
case VIDIOC_TRY_EXT_CTRLS:
176-
return v4l2_subdev_try_ext_ctrls(sd, arg);
176+
return v4l2_try_ext_ctrls(sd->ctrl_handler, arg);
177177

178178
case VIDIOC_DQEVENT:
179179
if (!(sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS))

0 commit comments

Comments
 (0)