Skip to content

Commit 06e68fe

Browse files
committed
Merge tag 'media/v4.20-3' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media fixes from Mauro Carvalho Chehab: - add a missing include at v4l2-controls uAPI header - minor kAPI update for the request API - some fixes at CEC core - use a lower minimum height for the virtual codec driver - cleanup a gcc warning due to the lack of a fall though markup - tc358743: Remove unnecessary self assignment - fix the V4L event subscription logic - docs: Document metadata format in struct v4l2_format - omap3isp and ipu3-cio2: fix unbinding logic * tag 'media/v4.20-3' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: media: ipu3-cio2: Use cio2_queues_exit media: ipu3-cio2: Unregister device nodes first, then release resources media: omap3isp: Unregister media device as first media: docs: Document metadata format in struct v4l2_format media: v4l: event: Add subscription to list before calling "add" operation media: dm365_ipipeif: better annotate a fall though media: Rename vb2_m2m_request_queue -> v4l2_m2m_request_queue media: cec: increase debug level for 'queue full' media: cec: check for non-OK/NACK conditions while claiming a LA media: vicodec: lower minimum height to 360 media: tc358743: Remove unnecessary self assignment media: v4l: fix uapi mpeg slice params definition v4l2-controls: add a missing include
2 parents f2ce106 + 4e26f69 commit 06e68fe

File tree

15 files changed

+89
-43
lines changed

15 files changed

+89
-43
lines changed

Documentation/media/uapi/v4l/dev-meta.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ To use the :ref:`format` ioctls applications set the ``type`` field of the
4040
the desired operation. Both drivers and applications must set the remainder of
4141
the :c:type:`v4l2_format` structure to 0.
4242

43-
.. _v4l2-meta-format:
43+
.. c:type:: v4l2_meta_format
4444
4545
.. tabularcolumns:: |p{1.4cm}|p{2.2cm}|p{13.9cm}|
4646

Documentation/media/uapi/v4l/vidioc-g-fmt.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ The format as returned by :ref:`VIDIOC_TRY_FMT <VIDIOC_G_FMT>` must be identical
132132
- ``sdr``
133133
- Definition of a data format, see :ref:`pixfmt`, used by SDR
134134
capture and output devices.
135+
* -
136+
- struct :c:type:`v4l2_meta_format`
137+
- ``meta``
138+
- Definition of a metadata format, see :ref:`meta-formats`, used by
139+
metadata capture devices.
135140
* -
136141
- __u8
137142
- ``raw_data``\ [200]

drivers/media/cec/cec-adap.c

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg,
807807
}
808808

809809
if (adap->transmit_queue_sz >= CEC_MAX_MSG_TX_QUEUE_SZ) {
810-
dprintk(1, "%s: transmit queue full\n", __func__);
810+
dprintk(2, "%s: transmit queue full\n", __func__);
811811
return -EBUSY;
812812
}
813813

@@ -1180,6 +1180,8 @@ static int cec_config_log_addr(struct cec_adapter *adap,
11801180
{
11811181
struct cec_log_addrs *las = &adap->log_addrs;
11821182
struct cec_msg msg = { };
1183+
const unsigned int max_retries = 2;
1184+
unsigned int i;
11831185
int err;
11841186

11851187
if (cec_has_log_addr(adap, log_addr))
@@ -1188,19 +1190,44 @@ static int cec_config_log_addr(struct cec_adapter *adap,
11881190
/* Send poll message */
11891191
msg.len = 1;
11901192
msg.msg[0] = (log_addr << 4) | log_addr;
1191-
err = cec_transmit_msg_fh(adap, &msg, NULL, true);
11921193

1193-
/*
1194-
* While trying to poll the physical address was reset
1195-
* and the adapter was unconfigured, so bail out.
1196-
*/
1197-
if (!adap->is_configuring)
1198-
return -EINTR;
1194+
for (i = 0; i < max_retries; i++) {
1195+
err = cec_transmit_msg_fh(adap, &msg, NULL, true);
11991196

1200-
if (err)
1201-
return err;
1197+
/*
1198+
* While trying to poll the physical address was reset
1199+
* and the adapter was unconfigured, so bail out.
1200+
*/
1201+
if (!adap->is_configuring)
1202+
return -EINTR;
1203+
1204+
if (err)
1205+
return err;
12021206

1203-
if (msg.tx_status & CEC_TX_STATUS_OK)
1207+
/*
1208+
* The message was aborted due to a disconnect or
1209+
* unconfigure, just bail out.
1210+
*/
1211+
if (msg.tx_status & CEC_TX_STATUS_ABORTED)
1212+
return -EINTR;
1213+
if (msg.tx_status & CEC_TX_STATUS_OK)
1214+
return 0;
1215+
if (msg.tx_status & CEC_TX_STATUS_NACK)
1216+
break;
1217+
/*
1218+
* Retry up to max_retries times if the message was neither
1219+
* OKed or NACKed. This can happen due to e.g. a Lost
1220+
* Arbitration condition.
1221+
*/
1222+
}
1223+
1224+
/*
1225+
* If we are unable to get an OK or a NACK after max_retries attempts
1226+
* (and note that each attempt already consists of four polls), then
1227+
* then we assume that something is really weird and that it is not a
1228+
* good idea to try and claim this logical address.
1229+
*/
1230+
if (i == max_retries)
12041231
return 0;
12051232

12061233
/*

drivers/media/i2c/tc358743.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1918,7 +1918,6 @@ static int tc358743_probe_of(struct tc358743_state *state)
19181918
ret = v4l2_fwnode_endpoint_alloc_parse(of_fwnode_handle(ep), &endpoint);
19191919
if (ret) {
19201920
dev_err(dev, "failed to parse endpoint\n");
1921-
ret = ret;
19221921
goto put_node;
19231922
}
19241923

drivers/media/pci/intel/ipu3/ipu3-cio2.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,14 +1844,12 @@ static int cio2_pci_probe(struct pci_dev *pci_dev,
18441844
static void cio2_pci_remove(struct pci_dev *pci_dev)
18451845
{
18461846
struct cio2_device *cio2 = pci_get_drvdata(pci_dev);
1847-
unsigned int i;
18481847

1848+
media_device_unregister(&cio2->media_dev);
18491849
cio2_notifier_exit(cio2);
1850+
cio2_queues_exit(cio2);
18501851
cio2_fbpt_exit_dummy(cio2);
1851-
for (i = 0; i < CIO2_QUEUES; i++)
1852-
cio2_queue_exit(cio2, &cio2->queue[i]);
18531852
v4l2_device_unregister(&cio2->v4l2_dev);
1854-
media_device_unregister(&cio2->media_dev);
18551853
media_device_cleanup(&cio2->media_dev);
18561854
mutex_destroy(&cio2->lock);
18571855
}

drivers/media/platform/omap3isp/isp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1587,6 +1587,8 @@ static void isp_pm_complete(struct device *dev)
15871587

15881588
static void isp_unregister_entities(struct isp_device *isp)
15891589
{
1590+
media_device_unregister(&isp->media_dev);
1591+
15901592
omap3isp_csi2_unregister_entities(&isp->isp_csi2a);
15911593
omap3isp_ccp2_unregister_entities(&isp->isp_ccp2);
15921594
omap3isp_ccdc_unregister_entities(&isp->isp_ccdc);
@@ -1597,7 +1599,6 @@ static void isp_unregister_entities(struct isp_device *isp)
15971599
omap3isp_stat_unregister_entities(&isp->isp_hist);
15981600

15991601
v4l2_device_unregister(&isp->v4l2_dev);
1600-
media_device_unregister(&isp->media_dev);
16011602
media_device_cleanup(&isp->media_dev);
16021603
}
16031604

drivers/media/platform/vicodec/vicodec-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ MODULE_PARM_DESC(debug, " activates debug info");
4242
#define MAX_WIDTH 4096U
4343
#define MIN_WIDTH 640U
4444
#define MAX_HEIGHT 2160U
45-
#define MIN_HEIGHT 480U
45+
#define MIN_HEIGHT 360U
4646

4747
#define dprintk(dev, fmt, arg...) \
4848
v4l2_dbg(1, debug, &dev->v4l2_dev, "%s: " fmt, __func__, ## arg)

drivers/media/platform/vim2m.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ static const struct v4l2_m2m_ops m2m_ops = {
10091009

10101010
static const struct media_device_ops m2m_media_ops = {
10111011
.req_validate = vb2_request_validate,
1012-
.req_queue = vb2_m2m_request_queue,
1012+
.req_queue = v4l2_m2m_request_queue,
10131013
};
10141014

10151015
static int vim2m_probe(struct platform_device *pdev)

drivers/media/v4l2-core/v4l2-ctrls.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,6 +1664,11 @@ static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx,
16641664
p_mpeg2_slice_params->forward_ref_index >= VIDEO_MAX_FRAME)
16651665
return -EINVAL;
16661666

1667+
if (p_mpeg2_slice_params->pad ||
1668+
p_mpeg2_slice_params->picture.pad ||
1669+
p_mpeg2_slice_params->sequence.pad)
1670+
return -EINVAL;
1671+
16671672
return 0;
16681673

16691674
case V4L2_CTRL_TYPE_MPEG2_QUANTIZATION:

drivers/media/v4l2-core/v4l2-event.c

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,22 @@ int v4l2_event_pending(struct v4l2_fh *fh)
193193
}
194194
EXPORT_SYMBOL_GPL(v4l2_event_pending);
195195

196+
static void __v4l2_event_unsubscribe(struct v4l2_subscribed_event *sev)
197+
{
198+
struct v4l2_fh *fh = sev->fh;
199+
unsigned int i;
200+
201+
lockdep_assert_held(&fh->subscribe_lock);
202+
assert_spin_locked(&fh->vdev->fh_lock);
203+
204+
/* Remove any pending events for this subscription */
205+
for (i = 0; i < sev->in_use; i++) {
206+
list_del(&sev->events[sev_pos(sev, i)].list);
207+
fh->navailable--;
208+
}
209+
list_del(&sev->list);
210+
}
211+
196212
int v4l2_event_subscribe(struct v4l2_fh *fh,
197213
const struct v4l2_event_subscription *sub, unsigned elems,
198214
const struct v4l2_subscribed_event_ops *ops)
@@ -224,27 +240,23 @@ int v4l2_event_subscribe(struct v4l2_fh *fh,
224240

225241
spin_lock_irqsave(&fh->vdev->fh_lock, flags);
226242
found_ev = v4l2_event_subscribed(fh, sub->type, sub->id);
243+
if (!found_ev)
244+
list_add(&sev->list, &fh->subscribed);
227245
spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);
228246

229247
if (found_ev) {
230248
/* Already listening */
231249
kvfree(sev);
232-
goto out_unlock;
233-
}
234-
235-
if (sev->ops && sev->ops->add) {
250+
} else if (sev->ops && sev->ops->add) {
236251
ret = sev->ops->add(sev, elems);
237252
if (ret) {
253+
spin_lock_irqsave(&fh->vdev->fh_lock, flags);
254+
__v4l2_event_unsubscribe(sev);
255+
spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);
238256
kvfree(sev);
239-
goto out_unlock;
240257
}
241258
}
242259

243-
spin_lock_irqsave(&fh->vdev->fh_lock, flags);
244-
list_add(&sev->list, &fh->subscribed);
245-
spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);
246-
247-
out_unlock:
248260
mutex_unlock(&fh->subscribe_lock);
249261

250262
return ret;
@@ -279,7 +291,6 @@ int v4l2_event_unsubscribe(struct v4l2_fh *fh,
279291
{
280292
struct v4l2_subscribed_event *sev;
281293
unsigned long flags;
282-
int i;
283294

284295
if (sub->type == V4L2_EVENT_ALL) {
285296
v4l2_event_unsubscribe_all(fh);
@@ -291,14 +302,8 @@ int v4l2_event_unsubscribe(struct v4l2_fh *fh,
291302
spin_lock_irqsave(&fh->vdev->fh_lock, flags);
292303

293304
sev = v4l2_event_subscribed(fh, sub->type, sub->id);
294-
if (sev != NULL) {
295-
/* Remove any pending events for this subscription */
296-
for (i = 0; i < sev->in_use; i++) {
297-
list_del(&sev->events[sev_pos(sev, i)].list);
298-
fh->navailable--;
299-
}
300-
list_del(&sev->list);
301-
}
305+
if (sev != NULL)
306+
__v4l2_event_unsubscribe(sev);
302307

303308
spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);
304309

drivers/media/v4l2-core/v4l2-mem2mem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ void v4l2_m2m_buf_queue(struct v4l2_m2m_ctx *m2m_ctx,
953953
}
954954
EXPORT_SYMBOL_GPL(v4l2_m2m_buf_queue);
955955

956-
void vb2_m2m_request_queue(struct media_request *req)
956+
void v4l2_m2m_request_queue(struct media_request *req)
957957
{
958958
struct media_request_object *obj, *obj_safe;
959959
struct v4l2_m2m_ctx *m2m_ctx = NULL;
@@ -997,7 +997,7 @@ void vb2_m2m_request_queue(struct media_request *req)
997997
if (m2m_ctx)
998998
v4l2_m2m_try_schedule(m2m_ctx);
999999
}
1000-
EXPORT_SYMBOL_GPL(vb2_m2m_request_queue);
1000+
EXPORT_SYMBOL_GPL(v4l2_m2m_request_queue);
10011001

10021002
/* Videobuf2 ioctl helpers */
10031003

drivers/staging/media/davinci_vpfe/dm365_ipipeif.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ static int ipipeif_hw_setup(struct v4l2_subdev *sd)
310310
ipipeif_write(val, ipipeif_base_addr, IPIPEIF_CFG2);
311311
break;
312312
}
313+
/* fall through */
313314

314315
case IPIPEIF_SDRAM_YUV:
315316
/* Set clock divider */

drivers/staging/media/sunxi/cedrus/cedrus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ static const struct v4l2_m2m_ops cedrus_m2m_ops = {
253253

254254
static const struct media_device_ops cedrus_m2m_media_ops = {
255255
.req_validate = cedrus_request_validate,
256-
.req_queue = vb2_m2m_request_queue,
256+
.req_queue = v4l2_m2m_request_queue,
257257
};
258258

259259
static int cedrus_probe(struct platform_device *pdev)

include/media/v4l2-mem2mem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ v4l2_m2m_dst_buf_remove_by_idx(struct v4l2_m2m_ctx *m2m_ctx, unsigned int idx)
624624

625625
/* v4l2 request helper */
626626

627-
void vb2_m2m_request_queue(struct media_request *req);
627+
void v4l2_m2m_request_queue(struct media_request *req);
628628

629629
/* v4l2 ioctl helpers */
630630

include/uapi/linux/v4l2-controls.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
#ifndef __LINUX_V4L2_CONTROLS_H
5151
#define __LINUX_V4L2_CONTROLS_H
5252

53+
#include <linux/types.h>
54+
5355
/* Control classes */
5456
#define V4L2_CTRL_CLASS_USER 0x00980000 /* Old-style 'user' controls */
5557
#define V4L2_CTRL_CLASS_MPEG 0x00990000 /* MPEG-compression controls */
@@ -1110,6 +1112,7 @@ struct v4l2_mpeg2_sequence {
11101112
__u8 profile_and_level_indication;
11111113
__u8 progressive_sequence;
11121114
__u8 chroma_format;
1115+
__u8 pad;
11131116
};
11141117

11151118
struct v4l2_mpeg2_picture {
@@ -1128,6 +1131,7 @@ struct v4l2_mpeg2_picture {
11281131
__u8 alternate_scan;
11291132
__u8 repeat_first_field;
11301133
__u8 progressive_frame;
1134+
__u8 pad;
11311135
};
11321136

11331137
struct v4l2_ctrl_mpeg2_slice_params {
@@ -1142,6 +1146,7 @@ struct v4l2_ctrl_mpeg2_slice_params {
11421146

11431147
__u8 backward_ref_index;
11441148
__u8 forward_ref_index;
1149+
__u8 pad;
11451150
};
11461151

11471152
struct v4l2_ctrl_mpeg2_quantization {

0 commit comments

Comments
 (0)