Commit 14a996c3 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull media fixes from Mauro Carvalho Chehab:

 - one regression at vsp1 driver

 - some last time changes for the upcoming request API logic and for
   stateless codec support. As the stateless codec "cedrus" driver is at
   staging, don't apply the MPEG controls as part of the main V4L2 API,
   as those may not be ready for production yet.

* tag 'media/v4.20-5' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media:
  media: Add a Kconfig option for the Request API
  media: extended-controls.rst: add note to the MPEG2 state controls
  media: mpeg2-ctrls.h: move MPEG2 state controls to non-public header
  media: vicodec: set state resolution from raw format
  media: vivid: drop v4l2_ctrl_request_complete() from start_streaming
  media: vb2: don't unbind/put the object when going to state QUEUED
  media: vb2: keep a reference to the request until dqbuf
  media: vb2: skip request checks for VIDIOC_PREPARE_BUF
  media: vb2: don't call __vb2_queue_cancel if vb2_start_streaming failed
  media: cedrus: Fix a NULL vs IS_ERR() check
  media: vsp1: Fix LIF buffer thresholds
parents e6333d72 078ab3ea
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1505,6 +1505,11 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type -
    configuring a stateless hardware decoding pipeline for MPEG-2.
    The bitstream parameters are defined according to :ref:`mpeg2part2`.

    .. note::

       This compound control is not yet part of the public kernel API and
       it is expected to change.

.. c:type:: v4l2_ctrl_mpeg2_slice_params

.. cssclass:: longtable
@@ -1625,6 +1630,11 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type -
    Specifies quantization matrices (as extracted from the bitstream) for the
    associated MPEG-2 slice data.

    .. note::

       This compound control is not yet part of the public kernel API and
       it is expected to change.

.. c:type:: v4l2_ctrl_mpeg2_quantization

.. cssclass:: longtable
+13 −0
Original line number Diff line number Diff line
@@ -110,6 +110,19 @@ config MEDIA_CONTROLLER_DVB

	  This is currently experimental.

config MEDIA_CONTROLLER_REQUEST_API
	bool "Enable Media controller Request API (EXPERIMENTAL)"
	depends on MEDIA_CONTROLLER && STAGING_MEDIA
	default n
	---help---
	  DO NOT ENABLE THIS OPTION UNLESS YOU KNOW WHAT YOU'RE DOING.

	  This option enables the Request API for the Media controller and V4L2
	  interfaces. It is currently needed by a few stateless codec drivers.

	  There is currently no intention to provide API or ABI stability for
	  this new API as of yet.

#
# Video4Linux support
#	Only enables if one of the V4L2 types (ATV, webcam, radio) is selected
+35 −9
Original line number Diff line number Diff line
@@ -947,7 +947,7 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state)
	}
	atomic_dec(&q->owned_by_drv_count);

	if (vb->req_obj.req) {
	if (state != VB2_BUF_STATE_QUEUED && vb->req_obj.req) {
		/* This is not supported at the moment */
		WARN_ON(state == VB2_BUF_STATE_REQUEUEING);
		media_request_object_unbind(&vb->req_obj);
@@ -1359,8 +1359,12 @@ static void vb2_req_release(struct media_request_object *obj)
{
	struct vb2_buffer *vb = container_of(obj, struct vb2_buffer, req_obj);

	if (vb->state == VB2_BUF_STATE_IN_REQUEST)
	if (vb->state == VB2_BUF_STATE_IN_REQUEST) {
		vb->state = VB2_BUF_STATE_DEQUEUED;
		if (vb->request)
			media_request_put(vb->request);
		vb->request = NULL;
	}
}

static const struct media_request_object_ops vb2_core_req_ops = {
@@ -1528,6 +1532,18 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb,
			return ret;

		vb->state = VB2_BUF_STATE_IN_REQUEST;

		/*
		 * Increment the refcount and store the request.
		 * The request refcount is decremented again when the
		 * buffer is dequeued. This is to prevent vb2_buffer_done()
		 * from freeing the request from interrupt context, which can
		 * happen if the application closed the request fd after
		 * queueing the request.
		 */
		media_request_get(req);
		vb->request = req;

		/* Fill buffer information for the userspace */
		if (pb) {
			call_void_bufop(q, copy_timestamp, vb, pb);
@@ -1749,10 +1765,6 @@ static void __vb2_dqbuf(struct vb2_buffer *vb)
			call_void_memop(vb, unmap_dmabuf, vb->planes[i].mem_priv);
			vb->planes[i].dbuf_mapped = 0;
		}
	if (vb->req_obj.req) {
		media_request_object_unbind(&vb->req_obj);
		media_request_object_put(&vb->req_obj);
	}
	call_void_bufop(q, init_buffer, vb);
}

@@ -1797,6 +1809,14 @@ int vb2_core_dqbuf(struct vb2_queue *q, unsigned int *pindex, void *pb,
	/* go back to dequeued state */
	__vb2_dqbuf(vb);

	if (WARN_ON(vb->req_obj.req)) {
		media_request_object_unbind(&vb->req_obj);
		media_request_object_put(&vb->req_obj);
	}
	if (vb->request)
		media_request_put(vb->request);
	vb->request = NULL;

	dprintk(2, "dqbuf of buffer %d, with state %d\n",
			vb->index, vb->state);

@@ -1903,6 +1923,14 @@ static void __vb2_queue_cancel(struct vb2_queue *q)
			vb->prepared = false;
		}
		__vb2_dqbuf(vb);

		if (vb->req_obj.req) {
			media_request_object_unbind(&vb->req_obj);
			media_request_object_put(&vb->req_obj);
		}
		if (vb->request)
			media_request_put(vb->request);
		vb->request = NULL;
	}
}

@@ -1940,11 +1968,9 @@ int vb2_core_streamon(struct vb2_queue *q, unsigned int type)
		if (ret)
			return ret;
		ret = vb2_start_streaming(q);
		if (ret) {
			__vb2_queue_cancel(q);
		if (ret)
			return ret;
	}
	}

	q->streaming = 1;

+9 −4
Original line number Diff line number Diff line
@@ -333,10 +333,10 @@ static int vb2_fill_vb2_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b
}

static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct media_device *mdev,
				    struct v4l2_buffer *b,
				    const char *opname,
				    struct v4l2_buffer *b, bool is_prepare,
				    struct media_request **p_req)
{
	const char *opname = is_prepare ? "prepare_buf" : "qbuf";
	struct media_request *req;
	struct vb2_v4l2_buffer *vbuf;
	struct vb2_buffer *vb;
@@ -378,6 +378,9 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct media_device *md
			return ret;
	}

	if (is_prepare)
		return 0;

	if (!(b->flags & V4L2_BUF_FLAG_REQUEST_FD)) {
		if (q->uses_requests) {
			dprintk(1, "%s: queue uses requests\n", opname);
@@ -631,8 +634,10 @@ static void fill_buf_caps(struct vb2_queue *q, u32 *caps)
		*caps |= V4L2_BUF_CAP_SUPPORTS_USERPTR;
	if (q->io_modes & VB2_DMABUF)
		*caps |= V4L2_BUF_CAP_SUPPORTS_DMABUF;
#ifdef CONFIG_MEDIA_CONTROLLER_REQUEST_API
	if (q->supports_requests)
		*caps |= V4L2_BUF_CAP_SUPPORTS_REQUESTS;
#endif
}

int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)
@@ -657,7 +662,7 @@ int vb2_prepare_buf(struct vb2_queue *q, struct media_device *mdev,
	if (b->flags & V4L2_BUF_FLAG_REQUEST_FD)
		return -EINVAL;

	ret = vb2_queue_or_prepare_buf(q, mdev, b, "prepare_buf", NULL);
	ret = vb2_queue_or_prepare_buf(q, mdev, b, true, NULL);

	return ret ? ret : vb2_core_prepare_buf(q, b->index, b);
}
@@ -729,7 +734,7 @@ int vb2_qbuf(struct vb2_queue *q, struct media_device *mdev,
		return -EBUSY;
	}

	ret = vb2_queue_or_prepare_buf(q, mdev, b, "qbuf", &req);
	ret = vb2_queue_or_prepare_buf(q, mdev, b, false, &req);
	if (ret)
		return ret;
	ret = vb2_core_qbuf(q, b->index, b, req);
+4 −0
Original line number Diff line number Diff line
@@ -381,10 +381,14 @@ static long media_device_get_topology(struct media_device *mdev, void *arg)
static long media_device_request_alloc(struct media_device *mdev,
				       int *alloc_fd)
{
#ifdef CONFIG_MEDIA_CONTROLLER_REQUEST_API
	if (!mdev->ops || !mdev->ops->req_validate || !mdev->ops->req_queue)
		return -ENOTTY;

	return media_request_alloc(mdev, alloc_fd);
#else
	return -ENOTTY;
#endif
}

static long copy_arg_from_user(void *karg, void __user *uarg, unsigned int cmd)
Loading