Sunxi-Cedrus driver for the Allwinner Video Engine, using media requests
Subsystems (5)
v2 cover Sunxi-Cedrus driver for the Allwinner Video Engine, using media requests
This presents a second iteration of the updated Sunxi-Cedrus driver, that supports the Video Engine found in most Allwinner SoCs, starting with the A10. It was tested on both the A20 and the A33.
The initial version of this driver[0] was originally written and submitted by Florent Revest using a previous version of the request API that is necessary to provide coherency between controls and the buffers they apply to.
The driver was adapted to use the latest version of the media request API[1], as submitted by Hand Verkuil. Media request API support is a hard requirement for the Sunxi-Cedrus driver.
This series also contains fixes for issues encountered with the current version of the request API. If accepted, these should eventually be squashed into the request API series.
The driver itself currently only supports MPEG2 and more codecs will be added to the driver eventually. The output frames provided by the Video Engine are in a multi-planar 32x32-tiled YUV format, with a plane for luminance (Y) and a plane for chrominance (UV). A specific format is introduced in the V4L2 API to describe it.
This implementation is based on the significant work that was conducted by various members of the linux-sunxi community for understanding and documenting the Video Engine's innards.
Changes since v1:
* use the latest version of the request API for Hans Verkuil;
* added media controller support and dependency
* renamed v4l2 format to the more explicit V4L2_PIX_FMT_MB32_NV12;
* reworked bindings documentation;
* moved driver to drivers/media/platforms/sunxi/cedrus to pair with incoming CSI support ;
* added a workqueue and lists to schedule buffer completion, since it cannot be done in interrupt context;
* split mpeg2 support into a setup and a trigger function to avoid race condition;
* split video-related ops to a dedicated sunxi_cedrus_video file;
* cleaned up the included headers for each file;
* used device PFN offset instead of subtracting PHYS_BASE;
* used reset_control_reset instead of assert+deassert;
* put the device in reset when removing driver;
* changed dt bindings to use the last 96 Mib of the first 256 MiB of DRAM;
* made it clear in the mpeg frame header structure that forward and backward indexes are used as reference frames for motion vectors;
* lots of small cosmetic and consistency changes, including naming harmonization and headers text rework.
Remaining tasks:
* using the dedicated SRAM controller driver;
* cleaning up registers description and documenting the fields used;
* removing the assigned-clocks property and setting the clock rate in the driver directly;
* testing on more platforms.
Cheers!
Paul Kocialkowski (10):
media: v4l2-ctrls: Add missing v4l2 ctrl unlock
media-request: Add a request complete operation to allow m2m
scheduling
videobuf2-core: Add helper to get buffer private data from media
request
media: vim2m: Implement media request complete op to schedule m2m run
media: v4l: Add definitions for MPEG2 frame format and header metadata
media: v4l: Add definition for Allwinner's MB32-tiled NV12 format
media: platform: Add Sunxi-Cedrus VPU decoder driver
dt-bindings: media: Document bindings for the Sunxi-Cedrus VPU driver
ARM: dts: sun7i-a20: Add Video Engine and reserved memory nodes
ARM: dts: sun8i-a33: Add Video Engine and reserved memory nodes
.../devicetree/bindings/media/sunxi-cedrus.txt | 50 +++ arch/arm/boot/dts/sun7i-a20.dtsi | 31 ++ arch/arm/boot/dts/sun8i-a33.dtsi | 38 ++ drivers/media/common/videobuf2/videobuf2-core.c | 15 + drivers/media/media-request.c | 3 + drivers/media/platform/Kconfig | 15 + drivers/media/platform/Makefile | 1 + drivers/media/platform/sunxi/cedrus/Makefile | 4 + drivers/media/platform/sunxi/cedrus/sunxi_cedrus.c | 292 ++++++++++++ .../platform/sunxi/cedrus/sunxi_cedrus_common.h | 105 +++++ .../media/platform/sunxi/cedrus/sunxi_cedrus_dec.c | 228 ++++++++++ .../media/platform/sunxi/cedrus/sunxi_cedrus_dec.h | 36 ++ .../media/platform/sunxi/cedrus/sunxi_cedrus_hw.c | 201 +++++++++ .../media/platform/sunxi/cedrus/sunxi_cedrus_hw.h | 29 ++ .../platform/sunxi/cedrus/sunxi_cedrus_mpeg2.c | 157 +++++++ .../platform/sunxi/cedrus/sunxi_cedrus_mpeg2.h | 33 ++ .../platform/sunxi/cedrus/sunxi_cedrus_regs.h | 172 +++++++ .../platform/sunxi/cedrus/sunxi_cedrus_video.c | 497 +++++++++++++++++++++ .../platform/sunxi/cedrus/sunxi_cedrus_video.h | 31 ++ drivers/media/platform/vim2m.c | 12 + drivers/media/v4l2-core/v4l2-ctrls.c | 17 +- drivers/media/v4l2-core/v4l2-ioctl.c | 1 + include/media/media-device.h | 2 + include/media/videobuf2-core.h | 1 + include/uapi/linux/v4l2-controls.h | 26 ++ include/uapi/linux/videodev2.h | 4 + 26 files changed, 2000 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/media/sunxi-cedrus.txt create mode 100644 drivers/media/platform/sunxi/cedrus/Makefile create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus.c create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_common.h create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_dec.c create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_dec.h create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_hw.c create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_hw.h create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_mpeg2.c create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_mpeg2.h create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_regs.h create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_video.c create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_video.h
Signature · 1 line
2.16.3
PATCH v2 1/10 media: v4l2-ctrls: Add missing v4l2 ctrl unlock
This adds a missing v4l2_ctrl_unlock call that is required to avoid deadlocks.
--- drivers/media/v4l2-core/v4l2-ctrls.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-ctrls.c +6 -1
@@ -3614,10 +3614,12 @@ void v4l2_ctrl_request_complete(struct media_request *req,continue ;v4l2_ctrl_lock (ctrl); +if (ref->req)ptr_to_ptr (ctrl, ref->req->p_req, ref->p_req);else ptr_to_ptr (ctrl, ctrl->p_cur, ref->p_req); +v4l2_ctrl_unlock (ctrl); }
@@ -3677,8 +3679,11 @@ void v4l2_ctrl_request_setup(struct media_request *req, } } } -if (!have_new_data) + +if (!have_new_data) { +v4l2_ctrl_unlock (master);continue ; + }for (i =0 ; i < master->ncontrols; i++) {if (master->cluster[i]) {
Signature · 1 line
2.16.3
Re: [PATCH v2 01/10] media: v4l2-ctrls: Add missing v4l2 ctrl unlock
Quoted 2 lines · Paul Kocialkowski
This adds a missing
v4l2_ctrl_unlockcall that is required to avoid deadlocks.
Maybe you can explain what the deadlock scenario is?
Quoted 10 lines
Signed-off-by Paul Kocialkowski <[email protected]>--- drivers/media/v4l2-core/v4l2-ctrls.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/media/v4l2-core/v4l2-ctrls.c +0
-0
drivers/media/v4l2-core/v4l2-ctrls.c void v4l2_ctrl_request_complete(struct media_request *req, · line 3622
Quoted 9 lines
drivers/media/v4l2-core/v4l2-ctrls.c +2
-0@@ -3614,10 +3614,12 @@ void v4l2_ctrl_request_complete(struct media_request *req,continue ;v4l2_ctrl_lock (ctrl); +if (ref->req)ptr_to_ptr (ctrl, ref->req->p_req, ref->p_req);else ptr_to_ptr (ctrl, ctrl->p_cur, ref->p_req); +
I'm not sure that this is relevant in this patch.
Maxime
Signature · 10 lines
Maxime Ripard, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180420/6b564f27/attachment.sig>
Re: [PATCH v2 01/10] media: v4l2-ctrls: Add missing v4l2 ctrl unlock
In reply to Paul KocialkowskiQuoted 26 lines · Paul Kocialkowski
This adds a missing
v4l2_ctrl_unlockcall that is required to avoid deadlocks.Signed-off-by Paul Kocialkowski <[email protected]>--- drivers/media/v4l2-core/v4l2-ctrls.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/media/v4l2-core/v4l2-ctrls.c +2
-0@@ -3614,10 +3614,12 @@ void v4l2_ctrl_request_complete(struct media_request *req,continue ;v4l2_ctrl_lock (ctrl); +if (ref->req)ptr_to_ptr (ctrl, ref->req->p_req, ref->p_req);else ptr_to_ptr (ctrl, ctrl->p_cur, ref->p_req); +v4l2_ctrl_unlock (ctrl); }
drivers/media/v4l2-core/v4l2-ctrls.c void v4l2_ctrl_request_setup(struct media_request *req, · line 3686
Quoted 9 lines
drivers/media/v4l2-core/v4l2-ctrls.c +4
-1@@ -3677,8 +3679,11 @@ void v4l2_ctrl_request_setup(struct media_request *req, } } } -if (!have_new_data) + +if (!have_new_data) { +v4l2_ctrl_unlock (master);continue ; + }
Oops! Thanks for finding this. I'll fold this into the relevant patch in my tree.
drivers/media/v4l2-core/v4l2-ctrls.c void v4l2_ctrl_request_setup(struct media_request *req,
Quoted 4 lines
drivers/media/v4l2-core/v4l2-ctrls.c +0
-0for (i =0 ; i < master->ncontrols; i++) {if (master->cluster[i]) {
Regards,
Hans
PATCH v2 2/10 media-request: Add a request complete operation to allow m2m scheduling
In reply to Paul KocialkowskiWhen using the request API in the context of a m2m driver, the operations that come with a m2m run scheduling call in their (m2m-specific) ioctl handler are delayed until the request is queued (for instance, this includes queuing buffers and streamon).
Thus, the m2m run scheduling calls are not called in due time since the request AP's internal plumbing will (rightfully) use the relevant core functions directly instead of the ioctl handler.
This ends up in a situation where nothing happens if there is no run-scheduling ioctl called after queuing the request.
In order to circumvent the issue, a new media operation is introduced, called at the time of handling the media request queue ioctl. It gives m2m drivers a chance to schedule a m2m device run at that time.
The existing req_queue operation cannot be used for this purpose, since it is called with the request queue mutex held, that is eventually needed in the device_run call to apply relevant controls.
--- drivers/media/media-request.c | 3 +++ include/media/media-device.h | 2 ++ 2 files changed, 5 insertions(+)
drivers/media/media-request.c +3 -0
@@ -157,6 +157,9 @@ static long media_request_ioctl_queue(struct media_request *req)media_request_get (req); } +if (mdev->ops->req_complete) + mdev->ops->req_complete (req); +return ret; }
include/media/media-device.h +2 -0
@@ -55,6 +55,7 @@ struct media_entity_notify {* @req_alloc: Allocate a request * @req_free: Free a request * @req_queue: Queue a request +* @req_complete: Complete a request */ struct media_device_ops { int (*link_notify)(struct media_link *link, u32 flags,
@@ -62,6 +63,7 @@ struct media_device_ops {struct media_request *(*req_alloc)(struct media_device *mdev);void (*req_free)(struct media_request *req);int (*req_queue)(struct media_request *req); +void (*req_complete)(struct media_request *req); };/**
Signature · 1 line
2.16.3
Re: [PATCH v2 02/10] media-request: Add a request complete operation to allow m2m scheduling
drivers/media/media-request.c static long media_request_ioctl_queue(struct
Quoted 31 lines · Paul Kocialkowski
When using the request API in the context of a m2m driver, the operations that come with a m2m run scheduling call in their (m2m-specific) ioctl handler are delayed until the request is queued (for instance, this includes queuing buffers and streamon).
Thus, the m2m run scheduling calls are not called in due time since the request AP's internal plumbing will (rightfully) use the relevant core functions directly instead of the ioctl handler.
This ends up in a situation where nothing happens if there is no run-scheduling ioctl called after queuing the request.
In order to circumvent the issue, a new media operation is introduced, called at the time of handling the media request queue ioctl. It gives m2m drivers a chance to schedule a m2m device run at that time.
The existing
req_queueoperation cannot be used for this purpose, since it is called with the request queue mutex held, that is eventually needed in thedevice_runcall to apply relevant controls.Signed-off-by Paul Kocialkowski <[email protected]>--- drivers/media/media-request.c | 3 +++ include/media/media-device.h | 2 ++ 2 files changed, 5 insertions(+)drivers/media/media-request.c +0
-0@@ -157,6 +157,9 @@ static long media_request_ioctl_queue(struct
media_request *req)
Quoted 22 lines
drivers/media/media-request.c +3
-0media_request_get (req); } +if (mdev->ops->req_complete) + mdev->ops->req_complete (req); +return ret; }include/media/media-device.h +1
-0@@ -55,6 +55,7 @@ struct media_entity_notify {* @req_alloc: Allocate a request * @req_free: Free a request * @req_queue: Queue a request +* @req_complete: Complete a request */ struct media_device_ops { int (*link_notify)(struct media_link *link, u32 flags,
include/media/media-device.h struct media_device_ops { · line 66
Quoted 4 lines
include/media/media-device.h +1
-0@@ -62,6 +63,7 @@ struct media_device_ops {struct media_request *(*req_alloc)(struct media_device *mdev);void (*req_free)(struct media_request *req);int (*req_queue)(struct media_request *req); +void (*req_complete)(struct media_request *req);
This is called *before* the request is actually run, isn't it? In that case, wouldn't something like "req_schedule" be less confusing? req_complete implies that the request is already completed.
Re: [PATCH v2 02/10] media-request: Add a request complete operation to allow m2m scheduling
In reply to Paul KocialkowskiQuoted 12 lines · Paul Kocialkowski
When using the request API in the context of a m2m driver, the operations that come with a m2m run scheduling call in their (m2m-specific) ioctl handler are delayed until the request is queued (for instance, this includes queuing buffers and streamon).
Thus, the m2m run scheduling calls are not called in due time since the request AP's internal plumbing will (rightfully) use the relevant core functions directly instead of the ioctl handler.
This ends up in a situation where nothing happens if there is no run-scheduling ioctl called after queuing the request.
Quoted 7 lines
In order to circumvent the issue, a new media operation is introduced, called at the time of handling the media request queue ioctl. It gives m2m drivers a chance to schedule a m2m device run at that time.
The existing
req_queueoperation cannot be used for this purpose, since it is called with the request queue mutex held, that is eventually needed in thedevice_runcall to apply relevant controls.
I'll need to think about this a bit more. I understand the problem so something needs to be done. I would like to avoid adding yet another op, though.
Regards,
Hans
Quoted 42 lines
Signed-off-by Paul Kocialkowski <[email protected]>--- drivers/media/media-request.c | 3 +++ include/media/media-device.h | 2 ++ 2 files changed, 5 insertions(+)drivers/media/media-request.c +3
-0@@ -157,6 +157,9 @@ static long media_request_ioctl_queue(struct media_request *req)media_request_get (req); } +if (mdev->ops->req_complete) + mdev->ops->req_complete (req); +return ret; }include/media/media-device.h +2
-0@@ -55,6 +55,7 @@ struct media_entity_notify {* @req_alloc: Allocate a request * @req_free: Free a request * @req_queue: Queue a request +* @req_complete: Complete a request */ struct media_device_ops { int (*link_notify)(struct media_link *link, u32 flags,@@ -62,6 +63,7 @@ struct media_device_ops {struct media_request *(*req_alloc)(struct media_device *mdev);void (*req_free)(struct media_request *req);int (*req_queue)(struct media_request *req); +void (*req_complete)(struct media_request *req); };/**
Sakari Ailus
maintainerRe: [PATCH v2 02/10] media-request: Add a request complete operation to allow m2m scheduling
In reply to Paul KocialkowskiHi Paul,
Quoted 12 lines · Paul Kocialkowski
When using the request API in the context of a m2m driver, the operations that come with a m2m run scheduling call in their (m2m-specific) ioctl handler are delayed until the request is queued (for instance, this includes queuing buffers and streamon).
Thus, the m2m run scheduling calls are not called in due time since the request AP's internal plumbing will (rightfully) use the relevant core functions directly instead of the ioctl handler.
This ends up in a situation where nothing happens if there is no run-scheduling ioctl called after queuing the request.
Quoted 7 lines
In order to circumvent the issue, a new media operation is introduced, called at the time of handling the media request queue ioctl. It gives m2m drivers a chance to schedule a m2m device run at that time.
The existing
req_queueoperation cannot be used for this purpose, since it is called with the request queue mutex held, that is eventually needed in thedevice_runcall to apply relevant controls.
Based on the description I'm not entirely sure what's the intent here.
What would be the purpose for acquiring the request queue mutex during the execution of the request? It is only intended for serialising access to the request objects while the request is being validated and queued.
If a driver does a significant amount of processing that is not related to managing the request as such, then one option could be to add a work queue for it.
Quoted 44 lines
Signed-off-by Paul Kocialkowski <[email protected]>--- drivers/media/media-request.c | 3 +++ include/media/media-device.h | 2 ++ 2 files changed, 5 insertions(+)drivers/media/media-request.c +3
-0@@ -157,6 +157,9 @@ static long media_request_ioctl_queue(struct media_request *req)media_request_get (req); } +if (mdev->ops->req_complete) + mdev->ops->req_complete (req); +return ret; }include/media/media-device.h +2
-0@@ -55,6 +55,7 @@ struct media_entity_notify {* @req_alloc: Allocate a request * @req_free: Free a request * @req_queue: Queue a request +* @req_complete: Complete a request */ struct media_device_ops { int (*link_notify)(struct media_link *link, u32 flags,@@ -62,6 +63,7 @@ struct media_device_ops {struct media_request *(*req_alloc)(struct media_device *mdev);void (*req_free)(struct media_request *req);int (*req_queue)(struct media_request *req); +void (*req_complete)(struct media_request *req); };/** Signature · 1 line
2.16.3
Signature · 2 lines
Sakari Ailus sakari.ailus at linux.intel.com
Re: [PATCH v2 02/10] media-request: Add a request complete operation to allow m2m scheduling
In reply to Paul KocialkowskiHi,
Quoted 17 lines · Paul Kocialkowski
When using the request API in the context of a m2m driver, the operations that come with a m2m run scheduling call in their (m2m-specific) ioctl handler are delayed until the request is queued (for instance, this includes queuing buffers and streamon).
Thus, the m2m run scheduling calls are not called in due time since the
request AP's internal plumbing will (rightfully) use the relevant core functions directly instead of the ioctl handler.This ends up in a situation where nothing happens if there is no run-scheduling ioctl called after queuing the request.
In order to circumvent the issue, a new media operation is introduced, called at the time of handling the media request queue ioctl. It gives m2m drivers a chance to schedule a m2m device run at that time.
Quoted 5 lines
The existing
req_queueoperation cannot be used for this purpose, since
it is called with the request queue mutex held, that is eventually needed
in thedevice_runcall to apply relevant controls.
This patch will be dropped since it's no longer useful with the latest version of the request API.
Quoted 44 lines
Signed-off-by Paul Kocialkowski <[email protected]>--- drivers/media/media-request.c | 3 +++ include/media/media-device.h | 2 ++ 2 files changed, 5 insertions(+)drivers/media/media- renamed from drivers/media/media-request.c +0
-0
request.c
index415f7e31019d..28ac5ccfe6a2100644drivers/media/media-request.c +3
-0@@ -157,6 +157,9 @@ static long media_request_ioctl_queue(struct media_request *req)media_request_get (req ); } +if (mdev->ops->req_complete) + mdev->ops->req_complete (req); +return ret; }include/media/media- renamed from include/media/media-device.h +0
-0
device.h
index07e323c57202..c7dcf2079cc9100644include/media/media-device.h +2
-0@@ -55,6 +55,7 @@ struct media_entity_notify {* @req_alloc: Allocate a request * @req_free: Free a request * @req_queue: Queue a request +* @req_complete: Complete a request */ struct media_device_ops { int (*link_notify)(struct media_link *link, u32 flags,@@ -62,6 +63,7 @@ struct media_device_ops {struct media_request *(*req_alloc)(struct media_device *mdev);void (*req_free)(struct media_request *req);int (*req_queue)(struct media_request *req); +void (*req_complete)(struct media_request *req); };/**
Signature · 10 lines
Paul Kocialkowski, Bootlin (formerly Free Electrons) Embedded Linux and kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: This is a digitally signed message part URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180504/d4d89b15/attachment.sig>
PATCH v2 3/10 videobuf2-core: Add helper to get buffer private data from media request
In reply to Paul KocialkowskiWhen calling media operation driver callbacks related to media requests, only a pointer to the request itself is provided, which is insufficient to retrieve the driver's context. Since the driver context is usually set as vb2 queue private data and given that the core can determine which objects attached to the request are buffers, it is possible to extract the associated private data for the first buffer found.
This is required in order to access the current m2m context from m2m drivers' private data in the context of media request operation callbacks. More specifically, this allows scheduling m2m device runs from the newly-introduced request complete operation.
--- drivers/media/common/videobuf2/videobuf2-core.c | 15 +++++++++++++++ include/media/videobuf2-core.h | 1 + 2 files changed, 16 insertions(+)
drivers/media/common/videobuf2/videobuf2-core.c +15 -0
@@ -1351,6 +1351,21 @@ bool vb2_core_request_has_buffers(struct media_request *req) }EXPORT_SYMBOL_GPL (vb2_core_request_has_buffers); +void *vb2_core_request_find_buffer_priv (struct media_request *req) +{ +struct media_request_object *obj; +struct vb2_buffer *vb; + + obj =media_request_object_find (req, &vb2_core_req_ops,NULL ); +if (!obj) +return NULL ; + + vb = container_of(obj, struct vb2_buffer, req_obj); + +return vb2_get_drv_priv (vb->vb2_queue); +} +EXPORT_SYMBOL_GPL (vb2_core_request_find_buffer_priv); +int vb2_core_prepare_buf (struct vb2_queue *q,unsigned int index,void *pb,struct media_request *req) {
include/media/videobuf2-core.h +1 -0
@@ -1153,4 +1153,5 @@ int vb2_verify_memory_type(struct vb2_queue *q, enum vb2_memory memory, unsigned int type);bool vb2_core_request_has_buffers (struct media_request *req); +void *vb2_core_request_find_buffer_priv (struct media_request *req);#endif /* _MEDIA_VIDEOBUF2_CORE_H */
Signature · 1 line
2.16.3
Re: [PATCH v2 03/10] videobuf2-core: Add helper to get buffer private data from media request
Quoted 23 lines · Paul Kocialkowski
When calling media operation driver callbacks related to media requests, only a pointer to the request itself is provided, which is insufficient to retrieve the driver's context. Since the driver context is usually set as vb2 queue private data and given that the core can determine which objects attached to the request are buffers, it is possible to extract the associated private data for the first buffer found.
This is required in order to access the current m2m context from m2m drivers' private data in the context of media request operation callbacks. More specifically, this allows scheduling m2m device runs from the newly-introduced request complete operation.
Signed-off-by Paul Kocialkowski <[email protected]>--- drivers/media/common/videobuf2/videobuf2-core.c | 15 +++++++++++++++ include/media/videobuf2-core.h | 1 + 2 files changed, 16 insertions(+)drivers/media/common/videobuf2/videobuf2-core.c +0
-0
drivers/media/common/videobuf2/videobuf2-core.c bool vb2_core_request_has_buffers(struct media_request *req) · line 1359
Quoted 9 lines
drivers/media/common/videobuf2/videobuf2-core.c +6
-0@@ -1351,6 +1351,21 @@ bool vb2_core_request_has_buffers(struct media_request *req) }EXPORT_SYMBOL_GPL (vb2_core_request_has_buffers); +void *vb2_core_request_find_buffer_priv (struct media_request *req) +{ +struct media_request_object *obj; +struct vb2_buffer *vb; + + obj =media_request_object_find (req, &vb2_core_req_ops,NULL );
This increases the object refcount but it is never decreased here.
drivers/media/common/videobuf2/videobuf2-core.c bool vb2_core_request_has_buffers(struct media_request *req) · line 1365
Quoted 6 lines
drivers/media/common/videobuf2/videobuf2-core.c +6
-0+if (!obj) +return NULL ; + + vb = container_of(obj, struct vb2_buffer, req_obj); + +return vb2_get_drv_priv (vb->vb2_queue);
You need to add a media_request_object_put(obj); before returning here.
Regards,
Hans
Quoted 17 lines
drivers/media/common/videobuf2/videobuf2-core.c +3
-0+} +EXPORT_SYMBOL_GPL (vb2_core_request_find_buffer_priv); +int vb2_core_prepare_buf (struct vb2_queue *q,unsigned int index,void *pb,struct media_request *req) {include/media/videobuf2-core.h +1
-0@@ -1153,4 +1153,5 @@ int vb2_verify_memory_type(struct vb2_queue *q, enum vb2_memory memory, unsigned int type);bool vb2_core_request_has_buffers (struct media_request *req); +void *vb2_core_request_find_buffer_priv (struct media_request *req);#endif /* _MEDIA_VIDEOBUF2_CORE_H */
Sakari Ailus
maintainerRe: [PATCH v2 03/10] videobuf2-core: Add helper to get buffer private data from media request
In reply to Paul KocialkowskiHi Paul,
Quoted 11 lines · Paul Kocialkowski
When calling media operation driver callbacks related to media requests, only a pointer to the request itself is provided, which is insufficient to retrieve the driver's context. Since the driver context is usually set as vb2 queue private data and given that the core can determine which objects attached to the request are buffers, it is possible to extract the associated private data for the first buffer found.
This is required in order to access the current m2m context from m2m drivers' private data in the context of media request operation callbacks. More specifically, this allows scheduling m2m device runs from the newly-introduced request complete operation.
Rather than fetching a random buffer from the request objects, I'd suggest to allocate a struct that contains the media request and place the required information there.
Such as was in my older patchset. The patch won't apply but the approach would be useful I think.
Quoted 46 lines
Signed-off-by Paul Kocialkowski <[email protected]>--- drivers/media/common/videobuf2/videobuf2-core.c | 15 +++++++++++++++ include/media/videobuf2-core.h | 1 + 2 files changed, 16 insertions(+)drivers/media/common/videobuf2/videobuf2-core.c +15
-0@@ -1351,6 +1351,21 @@ bool vb2_core_request_has_buffers(struct media_request *req) }EXPORT_SYMBOL_GPL (vb2_core_request_has_buffers); +void *vb2_core_request_find_buffer_priv (struct media_request *req) +{ +struct media_request_object *obj; +struct vb2_buffer *vb; + + obj =media_request_object_find (req, &vb2_core_req_ops,NULL ); +if (!obj) +return NULL ; + + vb = container_of(obj, struct vb2_buffer, req_obj); + +return vb2_get_drv_priv (vb->vb2_queue); +} +EXPORT_SYMBOL_GPL (vb2_core_request_find_buffer_priv); +int vb2_core_prepare_buf (struct vb2_queue *q,unsigned int index,void *pb,struct media_request *req) {include/media/videobuf2-core.h +1
-0@@ -1153,4 +1153,5 @@ int vb2_verify_memory_type(struct vb2_queue *q, enum vb2_memory memory, unsigned int type);bool vb2_core_request_has_buffers (struct media_request *req); +void *vb2_core_request_find_buffer_priv (struct media_request *req);#endif /* _MEDIA_VIDEOBUF2_CORE_H */ Signature · 1 line
2.16.3
Signature · 2 lines
Sakari Ailus sakari.ailus at linux.intel.com
Re: [PATCH v2 03/10] videobuf2-core: Add helper to get buffer private data from media request
In reply to Paul KocialkowskiHi,
Quoted 9 lines · Paul Kocialkowski
When calling media operation driver callbacks related to media requests,
only a pointer to the request itself is provided, which is insufficient
to retrieve the driver's context. Since the driver context is usually set as vb2 queue private data and given that the core can determine which objects attached to the request are buffers, it is possible to extract the associated private data for the first buffer found.
Quoted 4 lines
This is required in order to access the current m2m context from m2m drivers' private data in the context of media request operation callbacks. More specifically, this allows scheduling m2m device runs from the newly-introduced request complete operation.
This patch too will be dropped since it's no longer useful with the latest version of the request API.
Quoted 47 lines
Signed-off-by Paul Kocialkowski <[email protected]>--- drivers/media/common/videobuf2/videobuf2-core.c | 15 +++++++++++++++ include/media/videobuf2-core.h | 1 + 2 files changed, 16 insertions(+)drivers/media/common/videobuf2/videobuf2-core.c +15
-0@@ -1351,6 +1351,21 @@ bool vb2_core_request_has_buffers(struct media_request *req) }EXPORT_SYMBOL_GPL (vb2_core_request_has_buffers); +void *vb2_core_request_find_buffer_priv (struct media_request *req) +{ +struct media_request_object *obj; +struct vb2_buffer *vb; + + obj =media_request_object_find (req, &vb2_core_req_ops,NULL ); +if (!obj) +return NULL ; + + vb = container_of(obj, struct vb2_buffer, req_obj); + +return vb2_get_drv_priv (vb->vb2_queue); +} +EXPORT_SYMBOL_GPL (vb2_core_request_find_buffer_priv); + int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index,void *pb,
drivers/media/common/videobuf2/videobuf2-core.c +0
-0struct media_request *req) {include/media/videobuf2- renamed from include/media/videobuf2-core.h +0
-0
core.h
index032bd1bec555..65c0cf6afb55100644include/media/videobuf2-core.h +1
-0@@ -1153,4 +1153,5 @@ int vb2_verify_memory_type(struct vb2_queue *q, enum vb2_memory memory, unsigned int type);bool vb2_core_request_has_buffers (struct media_request *req); +void *vb2_core_request_find_buffer_priv (struct media_request *req);#endif /* _MEDIA_VIDEOBUF2_CORE_H */
Signature · 10 lines
Paul Kocialkowski, Bootlin (formerly Free Electrons) Embedded Linux and kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: This is a digitally signed message part URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180504/0d885d22/attachment.sig>
PATCH v2 4/10 media: vim2m: Implement media request complete op to schedule m2m run
In reply to Paul KocialkowskiThis adds an implementation of the media request complete operation for the vim2m driver, that ensures that the driver will try to schedule a m2m run whenever a request was completed. Without this operation, no m2m device run will be scheduled in many scenarios.
--- drivers/media/platform/vim2m.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/media/platform/vim2m.c +12 -0
@@ -453,6 +453,17 @@ static void device_isr(struct timer_list *t)schedule_work (&vim2m_dev->work_run); } +static void request_complete (struct media_request *req) +{ +struct vim2m_ctx *curr_ctx; + + curr_ctx = (struct vim2m_ctx *)vb2_core_request_find_buffer_priv (req); +if (curr_ctx ==NULL ) +return ; + +v4l2_m2m_try_schedule (curr_ctx->fh.m2m_ctx); +} +/* * video ioctls */
@@ -1025,6 +1036,7 @@ static const struct v4l2_m2m_ops m2m_ops = {static const struct media_device_ops m2m_media_ops = { .req_queue = vb2_request_queue, + .req_complete = request_complete, };static int vim2m_probe (struct platform_device *pdev)
Signature · 1 line
2.16.3
PATCH v2 5/10 media: v4l: Add definitions for MPEG2 frame format and header metadata
In reply to Paul KocialkowskiStateless video decoding engines require both the MPEG slices and associated metadata from the video stream in order to decode frames.
This introduces definitions for a new pixel format, describing buffers with MPEG2 slice data, as well as a control structure for passing the frame header (metadata) to drivers.
--- drivers/media/v4l2-core/v4l2-ctrls.c | 10 ++++++++++ drivers/media/v4l2-core/v4l2-ioctl.c | 1 + include/uapi/linux/v4l2-controls.h | 26 ++++++++++++++++++++++++++ include/uapi/linux/videodev2.h | 3 +++ 4 files changed, 40 insertions(+)
drivers/media/v4l2-core/v4l2-ctrls.c +10 -0
@@ -761,6 +761,7 @@ const char *v4l2_ctrl_get_name(u32 id)case V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE :return "Vertical MV Search Range" ;case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER :return "Repeat Sequence Header" ;case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME :return "Force Key Frame" ; +case V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR :return "MPEG2 Frame Header" ;/* VPX controls */ case V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS :return "VPX Number of Partitions" ;
@@ -1152,6 +1153,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,case V4L2_CID_RDS_TX_ALT_FREQS : *type =V4L2_CTRL_TYPE_U32 ;break ; +case V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR : + *type =V4L2_CTRL_TYPE_MPEG2_FRAME_HDR ; +break ;default : *type =V4L2_CTRL_TYPE_INTEGER ;break ;
@@ -1472,6 +1476,9 @@ static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx,return -ERANGE ;return 0 ; +case V4L2_CTRL_TYPE_MPEG2_FRAME_HDR : +return 0 ; +default :return -EINVAL ; }
@@ -2046,6 +2053,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,case V4L2_CTRL_TYPE_U32 : elem_size =sizeof (u32);break ; +case V4L2_CTRL_TYPE_MPEG2_FRAME_HDR : + elem_size =sizeof (struct v4l2_ctrl_mpeg2_frame_hdr ); +break ;default :if (type <V4L2_CTRL_COMPOUND_TYPES ) elem_size =sizeof (s32);
drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
@@ -1273,6 +1273,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)case V4L2_PIX_FMT_VC1_ANNEX_L : descr ="VC-1 (SMPTE 412M Annex L)" ;break ;case V4L2_PIX_FMT_VP8 : descr ="VP8" ;break ;case V4L2_PIX_FMT_VP9 : descr ="VP9" ;break ; +case V4L2_PIX_FMT_MPEG2_FRAME : descr ="MPEG2 Frame" ;break ;case V4L2_PIX_FMT_CPIA1 : descr ="GSPCA CPiA YUV" ;break ;case V4L2_PIX_FMT_WNVA : descr ="WNVA" ;break ;case V4L2_PIX_FMT_SN9C10X : descr ="GSPCA SN9C10X" ;break ;
include/uapi/linux/v4l2-controls.h +26 -0
@@ -557,6 +557,8 @@ enum v4l2_mpeg_video_mpeg4_profile { };#define V4L2_CID_MPEG_VIDEO_MPEG4_QPEL (V4L2_CID_MPEG_BASE+407) +#define V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR (V4L2_CID_MPEG_BASE+450) +/* Control IDs for VP8 streams * Although VP8 is not part of MPEG we add these controls to the MPEG class * as that class is already handling other video compression standards
@@ -985,4 +987,28 @@ enum v4l2_detect_md_mode {#define V4L2_CID_DETECT_MD_THRESHOLD_GRID (V4L2_CID_DETECT_CLASS_BASE + 3)#define V4L2_CID_DETECT_MD_REGION_GRID (V4L2_CID_DETECT_CLASS_BASE + 4) +struct v4l2_ctrl_mpeg2_frame_hdr { +__u32 slice_len; +__u32 slice_pos; +enum {MPEG1 ,MPEG2 } type; + +__u16 width; +__u16 height; + +enum {PCT_I =1 ,PCT_P ,PCT_B ,PCT_D } picture_coding_type; +__u8 f_code[2 ][2 ]; + +__u8 intra_dc_precision; +__u8 picture_structure; +__u8 top_field_first; +__u8 frame_pred_frame_dct; +__u8 concealment_motion_vectors; +__u8 q_scale_type; +__u8 intra_vlc_format; +__u8 alternate_scan; + +__u8 backward_ref_index; +__u8 forward_ref_index; +}; +#endif
include/uapi/linux/videodev2.h +3 -0
@@ -635,6 +635,7 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_VC1_ANNEX_L v4l2_fourcc('V', 'C', '1', 'L')/* SMPTE 421M Annex L compliant stream */ #define V4L2_PIX_FMT_VP8 v4l2_fourcc('V', 'P', '8', '0')/* VP8 */ #define V4L2_PIX_FMT_VP9 v4l2_fourcc('V', 'P', '9', '0')/* VP9 */ +#define V4L2_PIX_FMT_MPEG2_FRAME v4l2_fourcc('M', 'G', '2', 'F')/* MPEG2 frame */ /* Vendor-specific formats */ #define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A')/* cpia1 YUV */
@@ -1586,6 +1587,7 @@ struct v4l2_ext_control {__u8 __user *p_u8;__u16 __user *p_u16;__u32 __user *p_u32; +struct v4l2_ctrl_mpeg2_frame_hdr __user *p_mpeg2_frame_hdr;void __user *ptr; }; } __attribute__ ((packed));
@@ -1631,6 +1633,7 @@ enum v4l2_ctrl_type {V4L2_CTRL_TYPE_U8 =0x0100 ,V4L2_CTRL_TYPE_U16 =0x0101 ,V4L2_CTRL_TYPE_U32 =0x0102 , + V4L2_CTRL_TYPE_MPEG2_FRAME_HDR = 0x0109, };/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
Signature · 1 line
2.16.3
Tomasz Figa
maintainerRe: [PATCH v2 05/10] media: v4l: Add definitions for MPEG2 frame format and header metadata
Hi Paul,
On Fri, Apr 20, 2018 at 12:46 AM Paul Kocialkowski < [email protected]> wrote:
[snip]
include/uapi/linux/v4l2-controls.h enum v4l2_detect_md_mode { · line 993
Quoted 4 lines
include/uapi/linux/v4l2-controls.h +4
-0+struct v4l2_ctrl_mpeg2_frame_hdr { +__u32 slice_len; +__u32 slice_pos; +enum {MPEG1 ,MPEG2 } type;
Is enum suitable for UAPI?
include/uapi/linux/v4l2-controls.h enum v4l2_detect_md_mode { · line 998
Quoted 5 lines
include/uapi/linux/v4l2-controls.h +5
-0+ +__u16 width; +__u16 height; + +enum {PCT_I =1 ,PCT_P ,PCT_B ,PCT_D } picture_coding_type;
Ditto.
Review
Quoted 17 lines
include/uapi/linux/v4l2-controls.h +15
-0+__u8 f_code[2 ][2 ]; + +__u8 intra_dc_precision; +__u8 picture_structure; +__u8 top_field_first; +__u8 frame_pred_frame_dct; +__u8 concealment_motion_vectors; +__u8 q_scale_type; +__u8 intra_vlc_format; +__u8 alternate_scan; + +__u8 backward_ref_index; + __u8 forward_ref_index; +}; +#endif (quoted diff) +0
-0
b/include/uapi/linux/videodev2.h
include/uapi/linux/videodev2.h struct v4l2_pix_format { · line 635
Quoted 5 lines
index
31b5728b56e9..4b8336f7bcf0100644include/uapi/linux/videodev2.h +0
-0@@ -635,6 +635,7 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_VC1_ANNEX_L v4l2_fourcc('V', 'C', '1', 'L')/*
SMPTE 421M Annex L compliant stream */
include/uapi/linux/videodev2.h struct v4l2_pix_format {
Quoted 3 lines
include/uapi/linux/videodev2.h +1
-0#define V4L2_PIX_FMT_VP8 v4l2_fourcc('V', 'P', '8', '0')/* VP8 */ #define V4L2_PIX_FMT_VP9 v4l2_fourcc('V', 'P', '9', '0')/* VP9 */ +#define V4L2_PIX_FMT_MPEG2_FRAME v4l2_fourcc('M', 'G', '2', 'F')/*
MPEG2 frame */
include/uapi/linux/videodev2.h struct v4l2_pix_format { · line 640
Quoted 2 lines
include/uapi/linux/videodev2.h +0
-0/* Vendor-specific formats */ #define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A')/* cpia1
YUV */
include/uapi/linux/videodev2.h struct v4l2_ext_control { · line 1590
Quoted 5 lines
include/uapi/linux/videodev2.h +1
-0@@ -1586,6 +1587,7 @@ struct v4l2_ext_control {__u8 __user *p_u8;__u16 __user *p_u16;__u32 __user *p_u32; +struct v4l2_ctrl_mpeg2_frame_hdr __user
*p_mpeg2_frame_hdr;
include/uapi/linux/videodev2.h enum v4l2_ctrl_type { · line 1636
Quoted 8 lines
include/uapi/linux/videodev2.h +1
-0void __user *ptr; }; } __attribute__ ((packed));@@ -1631,6 +1633,7 @@ enum v4l2_ctrl_type {V4L2_CTRL_TYPE_U8 =0x0100 ,V4L2_CTRL_TYPE_U16 =0x0101 ,V4L2_CTRL_TYPE_U32 =0x0102 , + V4L2_CTRL_TYPE_MPEG2_FRAME_HDR = 0x0109,
Why 0x0109?
Best regards,
Tomasz
Re: [PATCH v2 05/10] media: v4l: Add definitions for MPEG2 frame format and header metadata
Hi,
Quoted 11 lines · Tomasz Figa
Hi Paul,
On Fri, Apr 20, 2018 at 12:46 AM Paul Kocialkowski < paul.kocialkowski at bootlin.com> wrote:
[snip]include/uapi/linux/v4l2-controls.h enum v4l2_detect_md_mode { · line 993
Quoted 4 lines
include/uapi/linux/v4l2-controls.h +4
-0+struct v4l2_ctrl_mpeg2_frame_hdr { +__u32 slice_len; +__u32 slice_pos; +enum {MPEG1 ,MPEG2 } type;Is enum suitable for UAPI?
As it turns out, it's not :)
Quoted 55 lines
include/uapi/linux/v4l2-controls.h enum v4l2_detect_md_mode { · line 998
Quoted 5 lines
include/uapi/linux/v4l2-controls.h +5
-0+ +__u16 width; +__u16 height; + +enum {PCT_I =1 ,PCT_P ,PCT_B ,PCT_D } picture_coding_type;Ditto.
Review
Quoted 17 lines
include/uapi/linux/v4l2-controls.h +15
-0+__u8 f_code[2 ][2 ]; + +__u8 intra_dc_precision; +__u8 picture_structure; +__u8 top_field_first; +__u8 frame_pred_frame_dct; +__u8 concealment_motion_vectors; +__u8 q_scale_type; +__u8 intra_vlc_format; +__u8 alternate_scan; + +__u8 backward_ref_index; + __u8 forward_ref_index; +}; +#endif (quoted diff) +0
-0
b/include/uapi/linux/videodev2.hinclude/uapi/linux/videodev2.h struct v4l2_pix_format { · line 636
Quoted 6 lines
index
31b5728b56e9..4b8336f7bcf0100644include/uapi/linux/videodev2.h +0
-0@@ -635,6 +635,7 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_VC1_ANNEX_L v4l2_fourcc('V', 'C', '1', 'L')/* SMPTE 421M Annex L compliant stream */
Quoted 5 lines
include/uapi/linux/videodev2.h +0
-0#define V4L2_PIX_FMT_VP8 v4l2_fourcc('V', 'P', '8', '0')/* VP8 */
#defineV4L2_PIX_FMT_VP9v4l2_fourcc('V', 'P', '9', '0')/*
VP9 */
+#defineV4L2_PIX_FMT_MPEG2_FRAMEv4l2_fourcc('M', 'G', '2', 'F')/*MPEG2 frame */
Quoted 3 lines
/* Vendor-specific formats */
#defineV4L2_PIX_FMT_CPIA1v4l2_fourcc('C', 'P', 'I', 'A')/*
cpia1YUV */
include/uapi/linux/videodev2.h struct v4l2_ext_control { · line 1590
Quoted 5 lines
include/uapi/linux/videodev2.h +1
-0@@ -1586,6 +1587,7 @@ struct v4l2_ext_control {__u8 __user *p_u8;__u16 __user *p_u16;__u32 __user *p_u32; +struct v4l2_ctrl_mpeg2_frame_hdr __user
*p_mpeg2_frame_hdr;
Quoted 10 lines
include/uapi/linux/videodev2.h enum v4l2_ctrl_type { · line 1636
Quoted 8 lines
include/uapi/linux/videodev2.h +1
-0void __user *ptr; }; } __attribute__ ((packed));@@ -1631,6 +1633,7 @@ enum v4l2_ctrl_type {V4L2_CTRL_TYPE_U8 =0x0100 ,V4L2_CTRL_TYPE_U16 =0x0101 ,V4L2_CTRL_TYPE_U32 =0x0102 , + V4L2_CTRL_TYPE_MPEG2_FRAME_HDR = 0x0109,Why
0x0109?
Good catch. I see no reason in particular, so I'll probably make it 0x0103 eventually.
Cheers and thanks for the review!
Signature · 10 lines
Paul Kocialkowski, Bootlin (formerly Free Electrons) Embedded Linux and kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: This is a digitally signed message part URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180504/7bc96baf/attachment.sig>
Re: [PATCH v2 05/10] media: v4l: Add definitions for MPEG2 frame format and header metadata
In reply to Paul KocialkowskiQuoted 86 lines · Paul Kocialkowski
Stateless video decoding engines require both the MPEG slices and associated metadata from the video stream in order to decode frames.
This introduces definitions for a new pixel format, describing buffers with MPEG2 slice data, as well as a control structure for passing the frame header (metadata) to drivers.
Signed-off-by Paul Kocialkowski <[email protected]>Signed-off-by Florent Revest <[email protected]>--- drivers/media/v4l2-core/v4l2-ctrls.c | 10 ++++++++++ drivers/media/v4l2-core/v4l2-ioctl.c | 1 + include/uapi/linux/v4l2-controls.h | 26 ++++++++++++++++++++++++++ include/uapi/linux/videodev2.h | 3 +++ 4 files changed, 40 insertions(+)drivers/media/v4l2-core/v4l2-ctrls.c +10
-0@@ -761,6 +761,7 @@ const char *v4l2_ctrl_get_name(u32 id)case V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE :return "Vertical MV Search Range" ;case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER :return "Repeat Sequence Header" ;case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME :return "Force Key Frame" ; +case V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR :return "MPEG2 Frame Header" ;/* VPX controls */ case V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS :return "VPX Number of Partitions" ;@@ -1152,6 +1153,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,case V4L2_CID_RDS_TX_ALT_FREQS : *type =V4L2_CTRL_TYPE_U32 ;break ; +case V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR : + *type =V4L2_CTRL_TYPE_MPEG2_FRAME_HDR ; +break ;default : *type =V4L2_CTRL_TYPE_INTEGER ;break ;@@ -1472,6 +1476,9 @@ static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx,return -ERANGE ;return 0 ; +case V4L2_CTRL_TYPE_MPEG2_FRAME_HDR : +return 0 ; +default :return -EINVAL ; }@@ -2046,6 +2053,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,case V4L2_CTRL_TYPE_U32 : elem_size =sizeof (u32);break ; +case V4L2_CTRL_TYPE_MPEG2_FRAME_HDR : + elem_size =sizeof (struct v4l2_ctrl_mpeg2_frame_hdr ); +break ;default :if (type <V4L2_CTRL_COMPOUND_TYPES ) elem_size =sizeof (s32);drivers/media/v4l2-core/v4l2-ioctl.c +1
-0@@ -1273,6 +1273,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)case V4L2_PIX_FMT_VC1_ANNEX_L : descr ="VC-1 (SMPTE 412M Annex L)" ;break ;case V4L2_PIX_FMT_VP8 : descr ="VP8" ;break ;case V4L2_PIX_FMT_VP9 : descr ="VP9" ;break ; +case V4L2_PIX_FMT_MPEG2_FRAME : descr ="MPEG2 Frame" ;break ;case V4L2_PIX_FMT_CPIA1 : descr ="GSPCA CPiA YUV" ;break ;case V4L2_PIX_FMT_WNVA : descr ="WNVA" ;break ;case V4L2_PIX_FMT_SN9C10X : descr ="GSPCA SN9C10X" ;break ;include/uapi/linux/v4l2-controls.h +2
-0@@ -557,6 +557,8 @@ enum v4l2_mpeg_video_mpeg4_profile { };#define V4L2_CID_MPEG_VIDEO_MPEG4_QPEL (V4L2_CID_MPEG_BASE+407) +#define V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR (V4L2_CID_MPEG_BASE+450) +/* Control IDs for VP8 streams * Although VP8 is not part of MPEG we add these controls to the MPEG class * as that class is already handling other video compression standards @@ -985,4 +987,28 @@ enum v4l2_detect_md_mode {#define V4L2_CID_DETECT_MD_THRESHOLD_GRID (V4L2_CID_DETECT_CLASS_BASE + 3)#define V4L2_CID_DETECT_MD_REGION_GRID (V4L2_CID_DETECT_CLASS_BASE + 4)
include/uapi/linux/v4l2-controls.h enum v4l2_detect_md_mode { · line 998
Quoted 10 lines
include/uapi/linux/v4l2-controls.h +9
-0+struct v4l2_ctrl_mpeg2_frame_hdr { +__u32 slice_len; +__u32 slice_pos; +enum {MPEG1 ,MPEG2 } type; + +__u16 width; +__u16 height; + +enum {PCT_I =1 ,PCT_P ,PCT_B ,PCT_D } picture_coding_type;
As someone else already mentioned (I believe): avoid enums. Use __u16 instead.
Quoted 4 lines
include/uapi/linux/v4l2-controls.h +4
-0+__u8 f_code[2 ][2 ]; + +__u8 intra_dc_precision; +__u8 picture_structure;
include/uapi/linux/v4l2-controls.h enum v4l2_detect_md_mode { · line 1012
Quoted 10 lines
include/uapi/linux/v4l2-controls.h +10
-0+__u8 top_field_first; +__u8 frame_pred_frame_dct; +__u8 concealment_motion_vectors; +__u8 q_scale_type; +__u8 intra_vlc_format; +__u8 alternate_scan; + +__u8 backward_ref_index; +__u8 forward_ref_index; +};
Please test that the layout and size of this structure is identical for 32 and 64 bit architectures, both on Intel and ARM.
It looks good, but it doesn't hurt to check.
Regards,
Hans
Quoted 31 lines
include/uapi/linux/v4l2-controls.h +1
-0+#endif include/uapi/linux/videodev2.h +3
-0@@ -635,6 +635,7 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_VC1_ANNEX_L v4l2_fourcc('V', 'C', '1', 'L')/* SMPTE 421M Annex L compliant stream */ #define V4L2_PIX_FMT_VP8 v4l2_fourcc('V', 'P', '8', '0')/* VP8 */ #define V4L2_PIX_FMT_VP9 v4l2_fourcc('V', 'P', '9', '0')/* VP9 */ +#define V4L2_PIX_FMT_MPEG2_FRAME v4l2_fourcc('M', 'G', '2', 'F')/* MPEG2 frame */ /* Vendor-specific formats */ #define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A')/* cpia1 YUV */ @@ -1586,6 +1587,7 @@ struct v4l2_ext_control {__u8 __user *p_u8;__u16 __user *p_u16;__u32 __user *p_u32; +struct v4l2_ctrl_mpeg2_frame_hdr __user *p_mpeg2_frame_hdr;void __user *ptr; }; } __attribute__ ((packed));@@ -1631,6 +1633,7 @@ enum v4l2_ctrl_type {V4L2_CTRL_TYPE_U8 =0x0100 ,V4L2_CTRL_TYPE_U16 =0x0101 ,V4L2_CTRL_TYPE_U32 =0x0102 , + V4L2_CTRL_TYPE_MPEG2_FRAME_HDR = 0x0109, };/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
Re: [PATCH v2 05/10] media: v4l: Add definitions for MPEG2 frame format and header metadata
Hi,
Quoted 117 lines · Hans Verkuil
Quoted 116 lines · Paul Kocialkowski
Stateless video decoding engines require both the MPEG slices and associated metadata from the video stream in order to decode frames.
This introduces definitions for a new pixel format, describing buffers
with MPEG2 slice data, as well as a control structure for passing the
frame header (metadata) to drivers.Signed-off-by Paul Kocialkowski <[email protected]>Signed-off-by Florent Revest <[email protected]>--- drivers/media/v4l2-core/v4l2-ctrls.c | 10 ++++++++++ drivers/media/v4l2-core/v4l2-ioctl.c | 1 + include/uapi/linux/v4l2-controls.h | 26 ++++++++++++++++++++++++++ include/uapi/linux/videodev2.h | 3 +++ 4 files changed, 40 insertions(+)drivers/media/v4l2-core/v4l2-ctrls.c +1
-0@@ -761,6 +761,7 @@ const char *v4l2_ctrl_get_name(u32 id)case V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE :return "Vertical MV Search Range" ;case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER :return "Repeat Sequence Header" ;case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME :re turn "Force Key Frame"; +case V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR : return "MPEG2 Frame Header";
drivers/media/v4l2-core/v4l2-ctrls.c +0
-0/* VPX controls */ case V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS :return "VPX Number of Partitions";
drivers/media/v4l2-core/v4l2-ctrls.c +3
-0@@ -1152,6 +1153,9 @@ void v4l2_ctrl_fill(u32 id, const char **name,enum v4l2_ctrl_type *type, case V4L2_CID_RDS_TX_ALT_FREQS: *type =V4L2_CTRL_TYPE_U32 ;break ; +case V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR : + *type =V4L2_CTRL_TYPE_MPEG2_FRAME_HDR ; +break ;default : *type =V4L2_CTRL_TYPE_INTEGER ;drivers/media/v4l2-core/v4l2-ctrls.c +3
-0break ;@@ -1472,6 +1476,9 @@ static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx, return -ERANGE ;return 0 ; +case V4L2_CTRL_TYPE_MPEG2_FRAME_HDR : +return 0 ; +default :return -EINVAL ;drivers/media/v4l2-core/v4l2-ctrls.c +3
-0}@@ -2046,6 +2053,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(structv4l2_ctrl_handler *hdl, case V4L2_CTRL_TYPE_U32: elem_size =sizeof (u32);break ; +case V4L2_CTRL_TYPE_MPEG2_FRAME_HDR : + elem_size =sizeof (struct v4l2_ctrl_mpeg2_frame_hdr ); +break ;default :drivers/media/v4l2-core/v4l2-ctrls.c +0
-0if (type <V4L2_CTRL_COMPOUND_TYPES ) elem_size =sizeof (s32);drivers/media/v4l2-core/v4l2-ioctl.c +0
-0@@ -1273,6 +1273,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt) case V4L2_PIX_FMT_VC1_ANNEX_L: descr = "VC-1 (SMPTE 412M Annex L)"; break;case V4L2_PIX_FMT_VP8 : descr ="VP8" ;break ; case V4L2_PIX_FMT_VP9: descr ="VP9"; break;
drivers/media/v4l2-core/v4l2-ioctl.c +1
-0+ case V4L2_PIX_FMT_MPEG2_FRAME: descr ="MPEG2 Frame"; break;
caseV4L2_PIX_FMT_CPIA1: descr = "GSPCA CPiA
YUV"; break;
caseV4L2_PIX_FMT_WNVA: descr =
"WNVA"; break;
caseV4L2_PIX_FMT_SN9C10X: descr = "GSPCA
SN9C10X"; break;include/uapi/linux/v4l2-controls.h +2
-0@@ -557,6 +557,8 @@ enum v4l2_mpeg_video_mpeg4_profile { };#define V4L2_CID_MPEG_VIDEO_MPEG4_QPEL (V4L2_CID_MPE G_BASE+407) +#define V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR (V4L2_CID_MPEG_BASE+450) +/* Control IDs for VP8 streams * Although VP8 is not part of MPEG we add these controls to the
MPEG class
* as that class is already handling other video compression
standardsinclude/uapi/linux/v4l2-controls.h +0
-0@@ -985,4 +987,28 @@ enum v4l2_detect_md_mode {#define V4L2_CID_DETECT_MD_THRESHOLD_GRID (V4L2_CID_DETECT_C LASS_BASE + 3)#define V4L2_CID_DETECT_MD_REGION_GRID (V4L2_CID_DET ECT_CLASS_BASE + 4)
Quoted 13 lines
Quoted 10 lines
include/uapi/linux/v4l2-controls.h +9
-0+struct v4l2_ctrl_mpeg2_frame_hdr { +__u32 slice_len; +__u32 slice_pos; +enum {MPEG1 ,MPEG2 } type; + +__u16 width; +__u16 height; + +enum {PCT_I =1 ,PCT_P ,PCT_B ,PCT_D }
picture_coding_type;As someone else already mentioned (I believe): avoid enums. Use
__u16instead.
Indeed. I have taken a note of that.
Quoted 19 lines
Quoted 4 lines
include/uapi/linux/v4l2-controls.h +4
-0+__u8 f_code[2 ][2 ]; + +__u8 intra_dc_precision; +__u8 picture_structure;include/uapi/linux/v4l2-controls.h enum v4l2_detect_md_mode { · line 1012
Quoted 10 lines
include/uapi/linux/v4l2-controls.h +10
-0+__u8 top_field_first; +__u8 frame_pred_frame_dct; +__u8 concealment_motion_vectors; +__u8 q_scale_type; +__u8 intra_vlc_format; +__u8 alternate_scan; + +__u8 backward_ref_index; +__u8 forward_ref_index; +};Please test that the layout and size of this structure is identical for 32 and 64 bit
architectures, both on Intel and ARM.
Quoted 1 line
It looks good, but it doesn't hurt to check.
Right, I'll keep that in mind and make sure this is the case.
Cheers and thanks for the review!
Paul
Quoted 44 lines
Regards,
Hans
Quoted 38 lines
include/uapi/linux/v4l2-controls.h +1
-0+#endif include/uapi/linux/videodev2.h +0
-0@@ -635,6 +635,7 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_VC1_ANNEX_L v4l2_fourcc('V', 'C', '1', 'L')/* SMPTE 421M Annex L compliant stream */
#defineV4L2_PIX_FMT_VP8v4l2_fourcc('V', 'P', '8', '0')/*
VP8 */
#defineV4L2_PIX_FMT_VP9v4l2_fourcc('V', 'P', '9', '0')/*
VP9 */
+#defineV4L2_PIX_FMT_MPEG2_FRAMEv4l2_fourcc('M', 'G', '2', 'F')/* MPEG2 frame *//* Vendor-specific formats */
#defineV4L2_PIX_FMT_CPIA1v4l2_fourcc('C', 'P', 'I', 'A')/*
cpia1 YUV */include/uapi/linux/videodev2.h +1
-0@@ -1586,6 +1587,7 @@ struct v4l2_ext_control {__u8 __user *p_u8;__u16 __user *p_u16;__u32 __user *p_u32; +struct v4l2_ctrl_mpeg2_frame_hdr __user *p_mpeg2_frame_hdr;void __user *ptr; };}
__attribute__((packed));include/uapi/linux/videodev2.h +1
-0@@ -1631,6 +1633,7 @@ enum v4l2_ctrl_type {V4L2_CTRL_TYPE_U8 =0x0100 ,V4L2_CTRL_TYPE_U16 =0x0101 ,V4L2_CTRL_TYPE_U32 =0x0102 , + V4L2_CTRL_TYPE_MPEG2_FRAME_HDR = 0x0109, };/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
Signature · 10 lines
Paul Kocialkowski, Bootlin (formerly Free Electrons) Embedded Linux and kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: This is a digitally signed message part URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180504/629ee026/attachment.sig>
Re: [PATCH v2 05/10] media: v4l: Add definitions for MPEG2 frame format and header metadata
In reply to Paul KocialkowskiQuoted 117 lines · Paul Kocialkowski
Stateless video decoding engines require both the MPEG slices and associated metadata from the video stream in order to decode frames.
This introduces definitions for a new pixel format, describing buffers with MPEG2 slice data, as well as a control structure for passing the frame header (metadata) to drivers.
Signed-off-by Paul Kocialkowski <[email protected]>Signed-off-by Florent Revest <[email protected]>--- drivers/media/v4l2-core/v4l2-ctrls.c | 10 ++++++++++ drivers/media/v4l2-core/v4l2-ioctl.c | 1 + include/uapi/linux/v4l2-controls.h | 26 ++++++++++++++++++++++++++ include/uapi/linux/videodev2.h | 3 +++ 4 files changed, 40 insertions(+)drivers/media/v4l2-core/v4l2-ctrls.c +10
-0@@ -761,6 +761,7 @@ const char *v4l2_ctrl_get_name(u32 id)case V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE :return "Vertical MV Search Range" ;case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER :return "Repeat Sequence Header" ;case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME :return "Force Key Frame" ; +case V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR :return "MPEG2 Frame Header" ;/* VPX controls */ case V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS :return "VPX Number of Partitions" ;@@ -1152,6 +1153,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,case V4L2_CID_RDS_TX_ALT_FREQS : *type =V4L2_CTRL_TYPE_U32 ;break ; +case V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR : + *type =V4L2_CTRL_TYPE_MPEG2_FRAME_HDR ; +break ;default : *type =V4L2_CTRL_TYPE_INTEGER ;break ;@@ -1472,6 +1476,9 @@ static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx,return -ERANGE ;return 0 ; +case V4L2_CTRL_TYPE_MPEG2_FRAME_HDR : +return 0 ; +default :return -EINVAL ; }@@ -2046,6 +2053,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,case V4L2_CTRL_TYPE_U32 : elem_size =sizeof (u32);break ; +case V4L2_CTRL_TYPE_MPEG2_FRAME_HDR : + elem_size =sizeof (struct v4l2_ctrl_mpeg2_frame_hdr ); +break ;default :if (type <V4L2_CTRL_COMPOUND_TYPES ) elem_size =sizeof (s32);drivers/media/v4l2-core/v4l2-ioctl.c +1
-0@@ -1273,6 +1273,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)case V4L2_PIX_FMT_VC1_ANNEX_L : descr ="VC-1 (SMPTE 412M Annex L)" ;break ;case V4L2_PIX_FMT_VP8 : descr ="VP8" ;break ;case V4L2_PIX_FMT_VP9 : descr ="VP9" ;break ; +case V4L2_PIX_FMT_MPEG2_FRAME : descr ="MPEG2 Frame" ;break ;case V4L2_PIX_FMT_CPIA1 : descr ="GSPCA CPiA YUV" ;break ;case V4L2_PIX_FMT_WNVA : descr ="WNVA" ;break ;case V4L2_PIX_FMT_SN9C10X : descr ="GSPCA SN9C10X" ;break ;include/uapi/linux/v4l2-controls.h +26
-0@@ -557,6 +557,8 @@ enum v4l2_mpeg_video_mpeg4_profile { };#define V4L2_CID_MPEG_VIDEO_MPEG4_QPEL (V4L2_CID_MPEG_BASE+407) +#define V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR (V4L2_CID_MPEG_BASE+450) +/* Control IDs for VP8 streams * Although VP8 is not part of MPEG we add these controls to the MPEG class * as that class is already handling other video compression standards @@ -985,4 +987,28 @@ enum v4l2_detect_md_mode {#define V4L2_CID_DETECT_MD_THRESHOLD_GRID (V4L2_CID_DETECT_CLASS_BASE + 3)#define V4L2_CID_DETECT_MD_REGION_GRID (V4L2_CID_DETECT_CLASS_BASE + 4) +struct v4l2_ctrl_mpeg2_frame_hdr { +__u32 slice_len; +__u32 slice_pos; +enum {MPEG1 ,MPEG2 } type; + +__u16 width; +__u16 height; + +enum {PCT_I =1 ,PCT_P ,PCT_B ,PCT_D } picture_coding_type; +__u8 f_code[2 ][2 ]; + +__u8 intra_dc_precision; +__u8 picture_structure; +__u8 top_field_first; +__u8 frame_pred_frame_dct; +__u8 concealment_motion_vectors; +__u8 q_scale_type; +__u8 intra_vlc_format; +__u8 alternate_scan; + +__u8 backward_ref_index; +__u8 forward_ref_index; +}; +#endif include/uapi/linux/videodev2.h +0
-0
include/uapi/linux/videodev2.h struct v4l2_pix_format { · line 638
Quoted 4 lines
include/uapi/linux/videodev2.h +1
-0@@ -635,6 +635,7 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_VC1_ANNEX_L v4l2_fourcc('V', 'C', '1', 'L')/* SMPTE 421M Annex L compliant stream */ #define V4L2_PIX_FMT_VP8 v4l2_fourcc('V', 'P', '8', '0')/* VP8 */ #define V4L2_PIX_FMT_VP9 v4l2_fourcc('V', 'P', '9', '0')/* VP9 */ +#define V4L2_PIX_FMT_MPEG2_FRAME v4l2_fourcc('M', 'G', '2', 'F')/* MPEG2 frame */
Needs to be added to v4l_fill_fmtdesc in v4l2-ioctl.c.
Regards,
Hans
Quoted 20 lines
include/uapi/linux/videodev2.h +2
-0/* Vendor-specific formats */ #define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A')/* cpia1 YUV */ @@ -1586,6 +1587,7 @@ struct v4l2_ext_control {__u8 __user *p_u8;__u16 __user *p_u16;__u32 __user *p_u32; +struct v4l2_ctrl_mpeg2_frame_hdr __user *p_mpeg2_frame_hdr;void __user *ptr; }; } __attribute__ ((packed));@@ -1631,6 +1633,7 @@ enum v4l2_ctrl_type {V4L2_CTRL_TYPE_U8 =0x0100 ,V4L2_CTRL_TYPE_U16 =0x0101 ,V4L2_CTRL_TYPE_U32 =0x0102 , + V4L2_CTRL_TYPE_MPEG2_FRAME_HDR = 0x0109, };/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
Sakari Ailus
maintainerRe: [PATCH v2 05/10] media: v4l: Add definitions for MPEG2 frame format and header metadata
In reply to Paul KocialkowskiHi Paul,
Quoted 6 lines · Paul Kocialkowski
Stateless video decoding engines require both the MPEG slices and associated metadata from the video stream in order to decode frames.
This introduces definitions for a new pixel format, describing buffers with MPEG2 slice data, as well as a control structure for passing the frame header (metadata) to drivers.
What's the typical relationship between MPEG2 slice data and the header?
Are the two always used together, do they originate from the same source, for instance? I have to admit I'm not very familiar with MPEG...
Quoted 94 lines
Signed-off-by Paul Kocialkowski <[email protected]>Signed-off-by Florent Revest <[email protected]>--- drivers/media/v4l2-core/v4l2-ctrls.c | 10 ++++++++++ drivers/media/v4l2-core/v4l2-ioctl.c | 1 + include/uapi/linux/v4l2-controls.h | 26 ++++++++++++++++++++++++++ include/uapi/linux/videodev2.h | 3 +++ 4 files changed, 40 insertions(+)drivers/media/v4l2-core/v4l2-ctrls.c +10
-0@@ -761,6 +761,7 @@ const char *v4l2_ctrl_get_name(u32 id)case V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE :return "Vertical MV Search Range" ;case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER :return "Repeat Sequence Header" ;case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME :return "Force Key Frame" ; +case V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR :return "MPEG2 Frame Header" ;/* VPX controls */ case V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS :return "VPX Number of Partitions" ;@@ -1152,6 +1153,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,case V4L2_CID_RDS_TX_ALT_FREQS : *type =V4L2_CTRL_TYPE_U32 ;break ; +case V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR : + *type =V4L2_CTRL_TYPE_MPEG2_FRAME_HDR ; +break ;default : *type =V4L2_CTRL_TYPE_INTEGER ;break ;@@ -1472,6 +1476,9 @@ static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx,return -ERANGE ;return 0 ; +case V4L2_CTRL_TYPE_MPEG2_FRAME_HDR : +return 0 ; +default :return -EINVAL ; }@@ -2046,6 +2053,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,case V4L2_CTRL_TYPE_U32 : elem_size =sizeof (u32);break ; +case V4L2_CTRL_TYPE_MPEG2_FRAME_HDR : + elem_size =sizeof (struct v4l2_ctrl_mpeg2_frame_hdr ); +break ;default :if (type <V4L2_CTRL_COMPOUND_TYPES ) elem_size =sizeof (s32);drivers/media/v4l2-core/v4l2-ioctl.c +1
-0@@ -1273,6 +1273,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)case V4L2_PIX_FMT_VC1_ANNEX_L : descr ="VC-1 (SMPTE 412M Annex L)" ;break ;case V4L2_PIX_FMT_VP8 : descr ="VP8" ;break ;case V4L2_PIX_FMT_VP9 : descr ="VP9" ;break ; +case V4L2_PIX_FMT_MPEG2_FRAME : descr ="MPEG2 Frame" ;break ;case V4L2_PIX_FMT_CPIA1 : descr ="GSPCA CPiA YUV" ;break ;case V4L2_PIX_FMT_WNVA : descr ="WNVA" ;break ;case V4L2_PIX_FMT_SN9C10X : descr ="GSPCA SN9C10X" ;break ;include/uapi/linux/v4l2-controls.h +15
-0@@ -557,6 +557,8 @@ enum v4l2_mpeg_video_mpeg4_profile { };#define V4L2_CID_MPEG_VIDEO_MPEG4_QPEL (V4L2_CID_MPEG_BASE+407) +#define V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR (V4L2_CID_MPEG_BASE+450) +/* Control IDs for VP8 streams * Although VP8 is not part of MPEG we add these controls to the MPEG class * as that class is already handling other video compression standards @@ -985,4 +987,28 @@ enum v4l2_detect_md_mode {#define V4L2_CID_DETECT_MD_THRESHOLD_GRID (V4L2_CID_DETECT_CLASS_BASE + 3)#define V4L2_CID_DETECT_MD_REGION_GRID (V4L2_CID_DETECT_CLASS_BASE + 4) +struct v4l2_ctrl_mpeg2_frame_hdr { +__u32 slice_len; +__u32 slice_pos; +enum {MPEG1 ,MPEG2 } type; + +__u16 width; +__u16 height; + +enum {PCT_I =1 ,PCT_P ,PCT_B ,PCT_D } picture_coding_type; +__u8 f_code[2 ][2 ]; + +__u8 intra_dc_precision; +__u8 picture_structure;
include/uapi/linux/v4l2-controls.h enum v4l2_detect_md_mode { · line 1012
Quoted 10 lines
include/uapi/linux/v4l2-controls.h +10
-0+__u8 top_field_first; +__u8 frame_pred_frame_dct; +__u8 concealment_motion_vectors; +__u8 q_scale_type; +__u8 intra_vlc_format; +__u8 alternate_scan; + +__u8 backward_ref_index; +__u8 forward_ref_index; +};
Besides the comments that have been given, please add __attribute__((packed)) to the struct definition.
include/uapi/linux/videodev2.h struct v4l2_pix_format { · line 638
Quoted 11 lines
include/uapi/linux/v4l2-controls.h +1
-0+#endif include/uapi/linux/videodev2.h +1
-0@@ -635,6 +635,7 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_VC1_ANNEX_L v4l2_fourcc('V', 'C', '1', 'L')/* SMPTE 421M Annex L compliant stream */ #define V4L2_PIX_FMT_VP8 v4l2_fourcc('V', 'P', '8', '0')/* VP8 */ #define V4L2_PIX_FMT_VP9 v4l2_fourcc('V', 'P', '9', '0')/* VP9 */ +#define V4L2_PIX_FMT_MPEG2_FRAME v4l2_fourcc('M', 'G', '2', 'F')/* MPEG2 frame */
This format needs documentation.
Quoted 22 lines
include/uapi/linux/videodev2.h +2
-0/* Vendor-specific formats */ #define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A')/* cpia1 YUV */ @@ -1586,6 +1587,7 @@ struct v4l2_ext_control {__u8 __user *p_u8;__u16 __user *p_u16;__u32 __user *p_u32; +struct v4l2_ctrl_mpeg2_frame_hdr __user *p_mpeg2_frame_hdr;void __user *ptr; }; } __attribute__ ((packed));@@ -1631,6 +1633,7 @@ enum v4l2_ctrl_type {V4L2_CTRL_TYPE_U8 =0x0100 ,V4L2_CTRL_TYPE_U16 =0x0101 ,V4L2_CTRL_TYPE_U32 =0x0102 , + V4L2_CTRL_TYPE_MPEG2_FRAME_HDR = 0x0109, };/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */ Signature · 1 line
2.16.3
Signature · 2 lines
Sakari Ailus sakari.ailus at linux.intel.com
Re: [PATCH v2 05/10] media: v4l: Add definitions for MPEG2 frame format and header metadata
Hi,
Quoted 12 lines · Sakari Ailus
Hi Paul,
Quoted 8 lines · Paul Kocialkowski
Stateless video decoding engines require both the MPEG slices and associated metadata from the video stream in order to decode frames.
This introduces definitions for a new pixel format, describing buffers
with MPEG2 slice data, as well as a control structure for passing the
frame header (metadata) to drivers.
Quoted 6 lines
What's the typical relationship between MPEG2 slice data and the header?
Are the two always used together, do they originate from the same source, for instance? I have to admit I'm not very familiar with MPEG...
Yes, the header is closely related to the slice data, as it expresses the metadata required for properly decoding the slice data. Both are extracted from the MPEG bitstream and there is dedicated metadata for each new set of slices that is decoded to a single frame.
Quoted 126 lines
Quoted 126 lines
Signed-off-by Paul Kocialkowski <[email protected]>Signed-off-by Florent Revest <[email protected]>--- drivers/media/v4l2-core/v4l2-ctrls.c | 10 ++++++++++ drivers/media/v4l2-core/v4l2-ioctl.c | 1 + include/uapi/linux/v4l2-controls.h | 26 ++++++++++++++++++++++++++ include/uapi/linux/videodev2.h | 3 +++ 4 files changed, 40 insertions(+)drivers/media/v4l2-core/v4l2-ctrls.c +1
-0@@ -761,6 +761,7 @@ const char *v4l2_ctrl_get_name(u32 id)case V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE :return "Vertical MV Search Range" ;case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER :return "Repeat Sequence Header" ;case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME :re turn "Force Key Frame"; +case V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR : return "MPEG2 Frame Header";
drivers/media/v4l2-core/v4l2-ctrls.c +0
-0/* VPX controls */ case V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS :return "VPX Number of Partitions";
drivers/media/v4l2-core/v4l2-ctrls.c +3
-0@@ -1152,6 +1153,9 @@ void v4l2_ctrl_fill(u32 id, const char **name,enum v4l2_ctrl_type *type, case V4L2_CID_RDS_TX_ALT_FREQS: *type =V4L2_CTRL_TYPE_U32 ;break ; +case V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR : + *type =V4L2_CTRL_TYPE_MPEG2_FRAME_HDR ; +break ;default : *type =V4L2_CTRL_TYPE_INTEGER ;drivers/media/v4l2-core/v4l2-ctrls.c +3
-0break ;@@ -1472,6 +1476,9 @@ static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx, return -ERANGE ;return 0 ; +case V4L2_CTRL_TYPE_MPEG2_FRAME_HDR : +return 0 ; +default :return -EINVAL ;drivers/media/v4l2-core/v4l2-ctrls.c +3
-0}@@ -2046,6 +2053,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(structv4l2_ctrl_handler *hdl, case V4L2_CTRL_TYPE_U32: elem_size =sizeof (u32);break ; +case V4L2_CTRL_TYPE_MPEG2_FRAME_HDR : + elem_size =sizeof (struct v4l2_ctrl_mpeg2_frame_hdr ); +break ;default :drivers/media/v4l2-core/v4l2-ctrls.c +0
-0if (type <V4L2_CTRL_COMPOUND_TYPES ) elem_size =sizeof (s32);drivers/media/v4l2-core/v4l2-ioctl.c +0
-0@@ -1273,6 +1273,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt) case V4L2_PIX_FMT_VC1_ANNEX_L: descr = "VC-1 (SMPTE 412M Annex L)"; break;case V4L2_PIX_FMT_VP8 : descr ="VP8" ;break ; case V4L2_PIX_FMT_VP9: descr ="VP9"; break;
drivers/media/v4l2-core/v4l2-ioctl.c +1
-0+ case V4L2_PIX_FMT_MPEG2_FRAME: descr ="MPEG2 Frame"; break;
caseV4L2_PIX_FMT_CPIA1: descr = "GSPCA CPiA
YUV"; break;
caseV4L2_PIX_FMT_WNVA: descr =
"WNVA"; break;
caseV4L2_PIX_FMT_SN9C10X: descr = "GSPCA
SN9C10X"; break;include/uapi/linux/v4l2-controls.h +2
-0@@ -557,6 +557,8 @@ enum v4l2_mpeg_video_mpeg4_profile { };#define V4L2_CID_MPEG_VIDEO_MPEG4_QPEL (V4L2_CID_MPE G_BASE+407) +#define V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR (V4L2_CID_MPEG_BASE+450) +/* Control IDs for VP8 streams * Although VP8 is not part of MPEG we add these controls to the
MPEG class
* as that class is already handling other video compression
standardsinclude/uapi/linux/v4l2-controls.h +9
-0@@ -985,4 +987,28 @@ enum v4l2_detect_md_mode {#define V4L2_CID_DETECT_MD_THRESHOLD_GRID (V4L2_CID_DETECT_C LASS_BASE + 3)#define V4L2_CID_DETECT_MD_REGION_GRID (V4L2_CID_DET ECT_CLASS_BASE + 4) +struct v4l2_ctrl_mpeg2_frame_hdr { +__u32 slice_len; +__u32 slice_pos; +enum {MPEG1 ,MPEG2 } type; + +__u16 width; +__u16 height; + +enum {PCT_I =1 ,PCT_P ,PCT_B ,PCT_D }
picture_coding_type;include/uapi/linux/v4l2-controls.h +9
-0+__u8 f_code[2 ][2 ]; + +__u8 intra_dc_precision; +__u8 picture_structure; +__u8 top_field_first; +__u8 frame_pred_frame_dct; +__u8 concealment_motion_vectors; +__u8 q_scale_type; +__u8 intra_vlc_format;
Quoted 8 lines
include/uapi/linux/v4l2-controls.h enum v4l2_detect_md_mode { · line 1012
Quoted 5 lines
include/uapi/linux/v4l2-controls.h +5
-0+__u8 alternate_scan; + +__u8 backward_ref_index; +__u8 forward_ref_index; +};Besides the comments that have been given, please add __attribute__((packed)) to the struct definition.
Noted.
Quoted 10 lines
Quoted 10 lines
include/uapi/linux/v4l2-controls.h +1
-0+#endif include/uapi/linux/videodev2.h +0
-0@@ -635,6 +635,7 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_VC1_ANNEX_L v4l2_fourcc('V', 'C', '1', 'L')/* SMPTE 421M Annex L compliant stream */
Quoted 8 lines
Quoted 6 lines
#define
V4L2_PIX_FMT_VP8v4l2_fourcc('V', 'P', '8', '0')/*
VP8 */
#defineV4L2_PIX_FMT_VP9v4l2_fourcc('V', 'P', '9', '0')/*
VP9 */
+#defineV4L2_PIX_FMT_MPEG2_FRAMEv4l2_fourcc('M', 'G', '2', 'F')/* MPEG2 frame */This format needs documentation.
Noted too. Thanks for the review!
Quoted 26 lines
Quoted 24 lines
/* Vendor-specific formats */
#defineV4L2_PIX_FMT_CPIA1v4l2_fourcc('C', 'P', 'I', 'A')/*
cpia1 YUV */include/uapi/linux/videodev2.h +1
-0@@ -1586,6 +1587,7 @@ struct v4l2_ext_control {__u8 __user *p_u8;__u16 __user *p_u16;__u32 __user *p_u32; +struct v4l2_ctrl_mpeg2_frame_hdr __user *p_mpeg2_frame_hdr;void __user *ptr; };}
__attribute__((packed));include/uapi/linux/videodev2.h +1
-0@@ -1631,6 +1633,7 @@ enum v4l2_ctrl_type {V4L2_CTRL_TYPE_U8 =0x0100 ,V4L2_CTRL_TYPE_U16 =0x0101 ,V4L2_CTRL_TYPE_U32 =0x0102 , + V4L2_CTRL_TYPE_MPEG2_FRAME_HDR = 0x0109, };/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */ Signature · 1 line
2.16.3
Signature · 10 lines
Paul Kocialkowski, Bootlin (formerly Free Electrons) Embedded Linux and kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: This is a digitally signed message part URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180504/618ed7c4/attachment-0001.sig>
Re: [PATCH v2 05/10] media: v4l: Add definitions for MPEG2 frame format and header metadata
In reply to Paul KocialkowskiQuoted 6 lines · Paul Kocialkowski
Stateless video decoding engines require both the MPEG slices and associated metadata from the video stream in order to decode frames.
This introduces definitions for a new pixel format, describing buffers with MPEG2 slice data, as well as a control structure for passing the frame header (metadata) to drivers.
While working on this, I came accross Hugues Fruchet's series that also adds similar definitions for parsed MPEG2 metadata:
https://patchwork.kernel.org/patch/9704707/
Since that version made it to a v6, I will take the time to read the discussion and see what needs to be changed in my proposal, so that we can avoid discussing the same points over a year later.
This will most likely not make it to the next revision of the driver series, so I will keep the format/controls definitions in their v2 state (despite all the useful comments received) and take the time to properly rework things in a future revision.
Cheers,
Paul
Quoted 165 lines
Signed-off-by Paul Kocialkowski <[email protected]>Signed-off-by Florent Revest <[email protected]>--- drivers/media/v4l2-core/v4l2-ctrls.c | 10 ++++++++++ drivers/media/v4l2-core/v4l2-ioctl.c | 1 + include/uapi/linux/v4l2-controls.h | 26 ++++++++++++++++++++++++++ include/uapi/linux/videodev2.h | 3 +++ 4 files changed, 40 insertions(+)drivers/media/v4l2-core/v4l2-ctrls.c +1
-0@@ -761,6 +761,7 @@ const char *v4l2_ctrl_get_name(u32 id)case V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE :re turn "Vertical MV Search Range";case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER :re turn "Repeat Sequence Header";case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME :retu rn "Force Key Frame"; +case V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR : return "MPEG2 Frame Header";
drivers/media/v4l2-core/v4l2-ctrls.c +0
-0/* VPX controls */ case V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS : return "VPX Number of Partitions";
drivers/media/v4l2-core/v4l2-ctrls.c +3
-0@@ -1152,6 +1153,9 @@ void v4l2_ctrl_fill(u32 id, const char **name,enum v4l2_ctrl_type *type, case V4L2_CID_RDS_TX_ALT_FREQS: *type =V4L2_CTRL_TYPE_U32 ;break ; +case V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR : + *type =V4L2_CTRL_TYPE_MPEG2_FRAME_HDR ; +break ;default : *type =V4L2_CTRL_TYPE_INTEGER ;drivers/media/v4l2-core/v4l2-ctrls.c +3
-0break ;@@ -1472,6 +1476,9 @@ static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx, return -ERANGE ;return 0 ; +case V4L2_CTRL_TYPE_MPEG2_FRAME_HDR : +return 0 ; +default :return -EINVAL ;drivers/media/v4l2-core/v4l2-ctrls.c +3
-0}@@ -2046,6 +2053,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(structv4l2_ctrl_handler *hdl, case V4L2_CTRL_TYPE_U32: elem_size =sizeof (u32);break ; +case V4L2_CTRL_TYPE_MPEG2_FRAME_HDR : + elem_size =sizeof (struct v4l2_ctrl_mpeg2_frame_hdr ); +break ;default :if (type <V4L2_CTRL_COMPOUND_TYPES )drivers/media/v4l2-core/v4l2-ctrls.c +0
-0elem_size =sizeof (s32);drivers/media/v4l2-core/v4l2-ioctl.c +0
-0@@ -1273,6 +1273,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt) case V4L2_PIX_FMT_VC1_ANNEX_L: descr = "VC-1 (SMPTE 412M Annex L)"; break;case V4L2_PIX_FMT_VP8 : descr ="VP8" ;break ;case V4L2_PIX_FMT_VP9 : descr ="VP9" ;break;
drivers/media/v4l2-core/v4l2-ioctl.c +1
-0+ case V4L2_PIX_FMT_MPEG2_FRAME: descr = "MPEG2Frame"; break;
caseV4L2_PIX_FMT_CPIA1: descr = "GSPCA CPiA
YUV"; break;
caseV4L2_PIX_FMT_WNVA: descr =
"WNVA"; break;
caseV4L2_PIX_FMT_SN9C10X: descr = "GSPCA
SN9C10X"; break;include/uapi/linux/v4l2-controls.h +2
-0@@ -557,6 +557,8 @@ enum v4l2_mpeg_video_mpeg4_profile { };#define V4L2_CID_MPEG_VIDEO_MPEG4_QPEL (V4L2_CID_MPEG_ BASE+407) +#define V4L2_CID_MPEG_VIDEO_MPEG2_FRAME_HDR (V4L2_CID_MPEG_BASE+450) +/* Control IDs for VP8 streams * Although VP8 is not part of MPEG we add these controls to the
MPEG class
* as that class is already handling other video compression
standardsinclude/uapi/linux/v4l2-controls.h +24
-0@@ -985,4 +987,28 @@ enum v4l2_detect_md_mode {#define V4L2_CID_DETECT_MD_THRESHOLD_GRID (V4L2_CID_DETECT_CLA SS_BASE + 3)#define V4L2_CID_DETECT_MD_REGION_GRID (V4L2_CID_DETEC T_CLASS_BASE + 4) +struct v4l2_ctrl_mpeg2_frame_hdr { +__u32 slice_len; +__u32 slice_pos; +enum {MPEG1 ,MPEG2 } type; + +__u16 width; +__u16 height; + +enum {PCT_I =1 ,PCT_P ,PCT_B ,PCT_D } picture_coding_type; +__u8 f_code[2 ][2 ]; + +__u8 intra_dc_precision; +__u8 picture_structure; +__u8 top_field_first; +__u8 frame_pred_frame_dct; +__u8 concealment_motion_vectors; +__u8 q_scale_type; +__u8 intra_vlc_format; +__u8 alternate_scan; + +__u8 backward_ref_index; +__u8 forward_ref_index; +}; +#endif include/uapi/linux/videodev2.h +0
-0@@ -635,6 +635,7 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_VC1_ANNEX_L v4l2_fourcc('V', 'C', '1', 'L')/* SMPTE 421M Annex L compliant stream */
#defineV4L2_PIX_FMT_VP8v4l2_fourcc('V', 'P', '8', '0')/* VP8
*/
#defineV4L2_PIX_FMT_VP9v4l2_fourcc('V', 'P', '9', '0')/* VP9
*/
+#defineV4L2_PIX_FMT_MPEG2_FRAMEv4l2_fourcc('M', 'G', '2', 'F')/* MPEG2 frame *//* Vendor-specific formats */
#defineV4L2_PIX_FMT_CPIA1v4l2_fourcc('C', 'P', 'I', 'A')/*
cpia1 YUV */include/uapi/linux/videodev2.h +1
-0@@ -1586,6 +1587,7 @@ struct v4l2_ext_control {__u8 __user *p_u8;__u16 __user *p_u16;__u32 __user *p_u32; +struct v4l2_ctrl_mpeg2_frame_hdr __user *p_mpeg2_frame_hdr;void __user *ptr; };}
__attribute__((packed));include/uapi/linux/videodev2.h +1
-0@@ -1631,6 +1633,7 @@ enum v4l2_ctrl_type {V4L2_CTRL_TYPE_U8 =0x0100 ,V4L2_CTRL_TYPE_U16 =0x0101 ,V4L2_CTRL_TYPE_U32 =0x0102 , + V4L2_CTRL_TYPE_MPEG2_FRAME_HDR = 0x0109, };/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
Signature · 10 lines
Paul Kocialkowski, Bootlin (formerly Free Electrons) Embedded Linux and kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: This is a digitally signed message part URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180504/5e7e40ea/attachment.sig>
PATCH v2 6/10 media: v4l: Add definition for Allwinner's MB32-tiled NV12 format
In reply to Paul KocialkowskiThis introduces support for Allwinner's MB32-tiled NV12 format, where each plane is divided into macroblocks of 32x32 pixels. Hence, the size of each plane has to be aligned to 32 bytes. The pixels inside each macroblock are coded as they would be if the macroblock was a single plane, line after line.
The MB32-tiled NV12 format is used by the video engine on Allwinner
platforms: it is the default format for decoded frames (and the only one available in the oldest supported platforms).
--- include/uapi/linux/videodev2.h | 1 + 1 file changed, 1 insertion(+)
include/uapi/linux/videodev2.h +1 -0
@@ -669,6 +669,7 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_Z16 v4l2_fourcc('Z', '1', '6', ' ')/* Depth data 16-bit */ #define V4L2_PIX_FMT_MT21C v4l2_fourcc('M', 'T', '2', '1')/* Mediatek compressed block mode */ #define V4L2_PIX_FMT_INZI v4l2_fourcc('I', 'N', 'Z', 'I')/* Intel Planar Greyscale 10-bit and Depth 16-bit */ +#define V4L2_PIX_FMT_MB32_NV12 v4l2_fourcc('M', 'N', '1', '2')/* Allwinner NV12 in 32x32 macroblocks */ /* 10bit raw bayer packed, 32 bytes for every 25 pixels, last LSB 6 bits unused */ #define V4L2_PIX_FMT_IPU3_SBGGR10 v4l2_fourcc('i', 'p', '3', 'b')/* IPU3 packed 10-bit BGGR bayer */
Signature · 1 line
2.16.3
Re: [PATCH v2 06/10] media: v4l: Add definition for Allwinner's MB32-tiled NV12 format
Quoted 21 lines · Paul Kocialkowski
This introduces support for Allwinner's MB32-tiled NV12 format, where each plane is divided into macroblocks of 32x32 pixels. Hence, the size of each plane has to be aligned to 32 bytes. The pixels inside each macroblock are coded as they would be if the macroblock was a single plane, line after line.
The MB32-tiled NV12 format is used by the video engine on Allwinner
platforms: it is the default format for decoded frames (and the only one available in the oldest supported platforms).Signed-off-by Paul Kocialkowski <[email protected]>--- include/uapi/linux/videodev2.h | 1 + 1 file changed, 1 insertion(+)include/uapi/linux/videodev2.h +0
-0
include/uapi/linux/videodev2.h struct v4l2_pix_format { · line 675
Quoted 7 lines
include/uapi/linux/videodev2.h +1
-0@@ -669,6 +669,7 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_Z16 v4l2_fourcc('Z', '1', '6', ' ')/* Depth data 16-bit */ #define V4L2_PIX_FMT_MT21C v4l2_fourcc('M', 'T', '2', '1')/* Mediatek compressed block mode */ #define V4L2_PIX_FMT_INZI v4l2_fourcc('I', 'N', 'Z', 'I')/* Intel Planar Greyscale 10-bit and Depth 16-bit */ +#define V4L2_PIX_FMT_MB32_NV12 v4l2_fourcc('M', 'N', '1', '2')/* Allwinner NV12 in 32x32 macroblocks */ /* 10bit raw bayer packed, 32 bytes for every 25 pixels, last LSB 6 bits unused */ #define V4L2_PIX_FMT_IPU3_SBGGR10 v4l2_fourcc('i', 'p', '3', 'b')/* IPU3 packed 10-bit BGGR bayer */
Add an entry for this to v4l_fill_fmtdesc() in v4l2-ioctl.c.
It also needs to be documented in the spec.
Regards,
Hans
Re: [PATCH v2 06/10] media: v4l: Add definition for Allwinner's MB32-tiled NV12 format
Hi,
Quoted 42 lines · Hans Verkuil
Quoted 33 lines · Paul Kocialkowski
This introduces support for Allwinner's MB32-tiled NV12 format, where
each plane is divided into macroblocks of 32x32 pixels. Hence, the size
of each plane has to be aligned to 32 bytes. The pixels inside each macroblock are coded as they would be if the macroblock was a single plane, line after line.The MB32-tiled NV12 format is used by the video engine on Allwinner
platforms: it is the default format for decoded frames (and the only one
available in the oldest supported platforms).Signed-off-by Paul Kocialkowski <[email protected]>--- include/uapi/linux/videodev2.h | 1 + 1 file changed, 1 insertion(+)include/uapi/linux/videodev2.h +0
-0@@ -669,6 +669,7 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_Z16 v4l2_fourcc('Z', '1', '6', ' ')/* Depth data 16-bit */
#defineV4L2_PIX_FMT_MT21Cv4l2_fourcc('M', 'T', '2', '1')/*
Mediatek compressed block mode */
#defineV4L2_PIX_FMT_INZIv4l2_fourcc('I', 'N', 'Z', 'I')/*
Intel Planar Greyscale 10-bit and Depth 16-bit */ +#defineV4L2_PIX_FMT_MB32_NV12v4l2_fourcc('M', 'N', '1', '2')/* Allwinner NV12 in 32x32 macroblocks */Quoted 5 lines
/* 10bit raw bayer packed, 32 bytes for every 25 pixels, last LSB 6
bits unused */
#defineV4L2_PIX_FMT_IPU3_SBGGR10v4l2_fourcc('i', 'p', '3',
'b') /* IPU3 packed 10-bit BGGR bayer */Add an entry for this to
v4l_fill_fmtdesc()inv4l2-ioctl.c.
Quoted 1 line
It also needs to be documented in the spec.
Noted, I will look in that direction for the future versions.
Cheers,
Signature · 10 lines
Paul Kocialkowski, Bootlin (formerly Free Electrons) Embedded Linux and kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: This is a digitally signed message part URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180504/89c68886/attachment-0001.sig>
PATCH v2 7/10 media: platform: Add Sunxi-Cedrus VPU decoder driver
In reply to Paul KocialkowskiThis introduces the Sunxi-Cedrus VPU driver that supports the VPU found in Allwinner SoCs, also known as Video Engine. It is implemented through a v4l2 m2m decoder device and a media device (used for media requests). So far, it only supports MPEG2 decoding.
Since this VPU is stateless, synchronization with media requests is required in order to ensure consistency between frame headers that contain metadata about the frame to process and the raw slice data that is used to generate the frame.
This driver was made possible thanks to the long-standing effort carried out by the linux-sunxi community in the interest of reverse engineering, documenting and implementing support for Allwinner VPU.
--- drivers/media/platform/Kconfig | 15 + drivers/media/platform/Makefile | 1 + drivers/media/platform/sunxi/cedrus/Makefile | 4 + drivers/media/platform/sunxi/cedrus/sunxi_cedrus.c | 292 ++++++++++++ .../platform/sunxi/cedrus/sunxi_cedrus_common.h | 105 +++++ .../media/platform/sunxi/cedrus/sunxi_cedrus_dec.c | 228 ++++++++++ .../media/platform/sunxi/cedrus/sunxi_cedrus_dec.h | 36 ++ .../media/platform/sunxi/cedrus/sunxi_cedrus_hw.c | 201 +++++++++ .../media/platform/sunxi/cedrus/sunxi_cedrus_hw.h | 29 ++ .../platform/sunxi/cedrus/sunxi_cedrus_mpeg2.c | 157 +++++++ .../platform/sunxi/cedrus/sunxi_cedrus_mpeg2.h | 33 ++ .../platform/sunxi/cedrus/sunxi_cedrus_regs.h | 172 +++++++ .../platform/sunxi/cedrus/sunxi_cedrus_video.c | 497 +++++++++++++++++++++ .../platform/sunxi/cedrus/sunxi_cedrus_video.h | 31 ++ 14 files changed, 1801 insertions(+) create mode 100644 drivers/media/platform/sunxi/cedrus/Makefile create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus.c create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_common.h create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_dec.c create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_dec.h create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_hw.c create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_hw.h create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_mpeg2.c create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_mpeg2.h create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_regs.h create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_video.c create mode 100644 drivers/media/platform/sunxi/cedrus/sunxi_cedrus_video.h
drivers/media/platform/Kconfig +15 -0
@@ -488,6 +488,21 @@ config VIDEO_TI_VPE Support for the TI VPE(Video Processing Engine) block found on DRA7XX SoC. +config VIDEO_SUNXI_CEDRUS + tristate "Sunxi-Cedrus VPU driver" + depends on VIDEO_DEV && VIDEO_V4L2 && MEDIA_CONTROLLER + depends on ARCH_SUNXI + depends on HAS_DMA + select VIDEOBUF2_DMA_CONTIG + select MEDIA_REQUEST_API + select V4L2_MEM2MEM_DEV + ---help--- + Support for the VPU found in Allwinner SoCs, also known as the Cedar + video engine. + + To compile this driver as a module, choose M here: the module + will be called sunxi-cedrus. + config VIDEO_TI_VPE_DEBUG bool "VPE debug messages" depends on VIDEO_TI_VPE
drivers/media/platform/Makefile +1 -0
@@ -72,6 +72,7 @@ obj-$(CONFIG_VIDEO_ROCKCHIP_RGA) += rockchip/rga/ obj-y += omap/ obj-$(CONFIG_VIDEO_AM437X_VPFE) += am437x/ +obj-$(CONFIG_VIDEO_SUNXI_CEDRUS) += sunxi/cedrus/ obj-$(CONFIG_VIDEO_XILINX) += xilinx/
drivers/media/platform/sunxi/cedrus/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +obj-$(CONFIG_VIDEO_SUNXI_CEDRUS) += sunxi-cedrus.o + +sunxi-cedrus-y = sunxi_cedrus.o sunxi_cedrus_video.o sunxi_cedrus_hw.o \ + sunxi_cedrus_dec.o sunxi_cedrus_mpeg2.o
drivers/media/platform/sunxi/cedrus/sunxi_cedrus.c new file +292 -0
292 lines not on this page · raw message
drivers/media/platform/sunxi/cedrus/sunxi_cedrus_common.h new file +105 -0
105 lines not on this page · raw message
drivers/media/platform/sunxi/cedrus/sunxi_cedrus_dec.c new file +228 -0
228 lines not on this page · raw message
drivers/media/platform/sunxi/cedrus/sunxi_cedrus_dec.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* Sunxi-Cedrus VPU driver +* +* Copyright (C) 2018 Paul Kocialkowski <[email protected]> +* Copyright (C) 2016 Florent Revest <[email protected]> +* +* Based on the vim2m driver, that is: +* +* Copyright (c) 2009-2010 Samsung Electronics Co., Ltd. +* Pawel Osciak, <[email protected]> +* Marek Szyprowski, <[email protected]> +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef _SUNXI_CEDRUS_DEC_H_ +#define _SUNXI_CEDRUS_DEC_H_ + +extern const struct v4l2_ioctl_ops sunxi_cedrus_ioctl_ops; + +void sunxi_cedrus_device_work (struct work_struct *work); +void sunxi_cedrus_device_run (void *priv); +void sunxi_cedrus_job_abort (void *priv); +void sunxi_cedrus_request_complete (struct media_request *req); + +int sunxi_cedrus_queue_init (void *priv,struct vb2_queue *src_vq, +struct vb2_queue *dst_vq); + +#endif
drivers/media/platform/sunxi/cedrus/sunxi_cedrus_hw.c new file +201 -0
201 lines not on this page · raw message
drivers/media/platform/sunxi/cedrus/sunxi_cedrus_hw.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* Sunxi-Cedrus VPU driver +* +* Copyright (C) 2018 Paul Kocialkowski <[email protected]> +* Copyright (C) 2016 Florent Revest <[email protected]> +* +* Based on the vim2m driver, that is: +* +* Copyright (c) 2009-2010 Samsung Electronics Co., Ltd. +* Pawel Osciak, <[email protected]> +* Marek Szyprowski, <[email protected]> +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef _SUNXI_CEDRUS_HW_H_ +#define _SUNXI_CEDRUS_HW_H_ + +int sunxi_cedrus_hw_probe (struct sunxi_cedrus_dev *dev); +void sunxi_cedrus_hw_remove (struct sunxi_cedrus_dev *dev); + +#endif
drivers/media/platform/sunxi/cedrus/sunxi_cedrus_mpeg2.c new file +157 -0
157 lines not on this page · raw message
drivers/media/platform/sunxi/cedrus/sunxi_cedrus_mpeg2.h new file +33 -0
@@ -0,0 +1,33 @@ +/* +* Sunxi-Cedrus VPU driver +* +* Copyright (C) 2018 Paul Kocialkowski <[email protected]> +* Copyright (C) 2016 Florent Revest <[email protected]> +* +* Based on the vim2m driver, that is: +* +* Copyright (c) 2009-2010 Samsung Electronics Co., Ltd. +* Pawel Osciak, <[email protected]> +* Marek Szyprowski, <[email protected]> +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef _SUNXI_CEDRUS_MPEG2_H_ +#define _SUNXI_CEDRUS_MPEG2_H_ + +void sunxi_cedrus_mpeg2_setup (struct sunxi_cedrus_ctx *ctx, +dma_addr_t src_buf_addr, +dma_addr_t dst_luma_addr, +dma_addr_t dst_chroma_addr, +struct v4l2_ctrl_mpeg2_frame_hdr *frame_hdr); +void sunxi_cedrus_mpeg2_trigger (struct sunxi_cedrus_ctx *ctx,bool mpeg1); + +#endif
drivers/media/platform/sunxi/cedrus/sunxi_cedrus_regs.h new file +172 -0
172 lines not on this page · raw message
drivers/media/platform/sunxi/cedrus/sunxi_cedrus_video.c new file +497 -0
497 lines not on this page · raw message
drivers/media/platform/sunxi/cedrus/sunxi_cedrus_video.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* Sunxi-Cedrus VPU driver +* +* Copyright (C) 2018 Paul Kocialkowski <[email protected]> +* Copyright (C) 2016 Florent Revest <[email protected]> +* +* Based on the vim2m driver, that is: +* +* Copyright (c) 2009-2010 Samsung Electronics Co., Ltd. +* Pawel Osciak, <[email protected]> +* Marek Szyprowski, <[email protected]> +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef _SUNXI_CEDRUS_VIDEO_H_ +#define _SUNXI_CEDRUS_VIDEO_H_ + +extern const struct v4l2_ioctl_ops sunxi_cedrus_ioctl_ops; + +int sunxi_cedrus_queue_init (void *priv,struct vb2_queue *src_vq, +struct vb2_queue *dst_vq); + +#endif
Signature · 1 line
2.16.3
Sakari Ailus
maintainerRe: [PATCH v2 07/10] media: platform: Add Sunxi-Cedrus VPU decoder driver
Hi Paul
Quoted 5 lines · Paul Kocialkowski
This introduces the Sunxi-Cedrus VPU driver that supports the VPU found in Allwinner SoCs, also known as Video Engine. It is implemented through a v4l2 m2m decoder device and a media device (used for media requests). So far, it only supports MPEG2 decoding.
Quoted 8 lines
Since this VPU is stateless, synchronization with media requests is required in order to ensure consistency between frame headers that contain metadata about the frame to process and the raw slice data that is used to generate the frame.
This driver was made possible thanks to the long-standing effort carried out by the linux-sunxi community in the interest of reverse engineering, documenting and implementing support for Allwinner VPU.
No code review yet, but DT bindings precede the driver. Please also add the appropriate MAINTAINERS entries.
Signature · 2 lines
Sakari Ailus sakari.ailus at linux.intel.com
Re: [PATCH v2 07/10] media: platform: Add Sunxi-Cedrus VPU decoder driver
Hi,
Quoted 17 lines · Sakari Ailus
Hi Paul
Quoted 14 lines · Paul Kocialkowski
This introduces the Sunxi-Cedrus VPU driver that supports the VPU found
in Allwinner SoCs, also known as Video Engine. It is implemented through
a v4l2 m2m decoder device and a media device (used for media requests).
So far, it only supports MPEG2 decoding.Since this VPU is stateless, synchronization with media requests is required in order to ensure consistency between frame headers that contain metadata about the frame to process and the raw slice data that
is used to generate the frame.
Quoted 6 lines
Quoted 3 lines
This driver was made possible thanks to the long-standing effort carried out by the linux-sunxi community in the interest of reverse engineering, documenting and implementing support for Allwinner VPU.
No code review yet, but DT bindings precede the driver. Please also add the appropriate
MAINTAINERSentries.
Thanks for the indication, will do in the next version(s).
Cheers,
Signature · 10 lines
Paul Kocialkowski, Bootlin (formerly Free Electrons) Embedded Linux and kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: This is a digitally signed message part URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180504/acc41e91/attachment.sig>
PATCH v2 8/10 dt-bindings: media: Document bindings for the Sunxi-Cedrus VPU driver
In reply to Paul KocialkowskiThis adds a device-tree binding document that specifies the properties used by the Sunxi-Cedurs VPU driver, as well as examples.
--- .../devicetree/bindings/media/sunxi-cedrus.txt | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/sunxi-cedrus.txt
Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +50 -0
@@ -0,0 +1,50 @@ +Device-tree bindings for the VPU found in Allwinner SoCs, referred to as the +Video Engine (VE) in Allwinner literature. + +The VPU can only access the first 256 MiB of DRAM, that are DMA-mapped starting +from the DRAM base. This requires specific memory allocation and handling. + +Required properties: +- compatible : "allwinner,sun4i-a10-video-engine"; +- memory-region : DMA pool for buffers allocation; +- clocks : list of clock specifiers, corresponding to entries in + the clock-names property; +- clock-names : should contain "ahb", "mod" and "ram" entries; +- assigned-clocks : list of clocks assigned to the VE; +- assigned-clocks-rates : list of clock rates for the clocks assigned to the VE; +- resets : phandle for reset; +- interrupts : should contain VE interrupt number; +- reg : should contain register base and length of VE. + +Example: + +reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + /* Address must be kept in the lower 256 MiBs of DRAM for VE. */ + ve_memory: cma at 4a000000 { + compatible = "shared-dma-pool"; + reg = <0x4a000000 0x6000000>; + no-map; + linux,cma-default; + }; +}; + +video-engine at 1c0e000 { + compatible = "allwinner,sun4i-a10-video-engine"; + reg = <0x01c0e000 0x1000>; + memory-region = <&ve_memory>; + + clocks = <&ccu CLK_AHB_VE>, <&ccu CLK_VE>, + <&ccu CLK_DRAM_VE>; + clock-names = "ahb", "mod", "ram"; + + assigned-clocks = <&ccu CLK_VE>; + assigned-clock-rates = <320000000>; + + resets = <&ccu RST_VE>; + + interrupts = <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>; +};
Signature · 1 line
2.16.3
Re: [PATCH v2 08/10] dt-bindings: media: Document bindings for the Sunxi-Cedrus VPU driver
Hi Paul,
Quoted 40 lines · Paul Kocialkowski
This adds a device-tree binding document that specifies the properties used by the Sunxi-Cedurs VPU driver, as well as examples.
Signed-off-by Paul Kocialkowski <[email protected]>--- .../devicetree/bindings/media/sunxi-cedrus.txt | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/sunxi-cedrus.txtDocumentation/devicetree/bindings/media/sunxi-cedrus.txt new file +25
-0@@ -0,0 +1,50 @@ +Device-tree bindings for the VPU found in Allwinner SoCs, referred to as the +Video Engine (VE) in Allwinner literature. + +The VPU can only access the first 256 MiB of DRAM, that are DMA-mapped starting +from the DRAM base. This requires specific memory allocation and handling. + +Required properties: +- compatible : "allwinner,sun4i-a10-video-engine"; +- memory-region : DMA pool for buffers allocation; +- clocks : list of clock specifiers, corresponding to entries in + the clock-names property; +- clock-names : should contain "ahb", "mod" and "ram" entries; +- assigned-clocks : list of clocks assigned to the VE; +- assigned-clocks-rates : list of clock rates for the clocks assigned to the VE; +- resets : phandle for reset; +- interrupts : should contain VE interrupt number; +- reg : should contain register base and length of VE. + +Example: + +reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; +
Documentation/devicetree/bindings/media/sunxi-cedrus.txt line 35
Quoted 10 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +10
-0+ /* Address must be kept in the lower 256 MiBs of DRAM for VE. */ + ve_memory: cma at 4a000000 { + compatible = "shared-dma-pool"; + reg = <0x4a000000 0x6000000>; + no-map; + linux,cma-default; + }; +}; + +video-engine at 1c0e000 {
This is not really required by any specification, and not as common as gpu at ..., but could this reasonably be called "vpu at 1c0e000" to follow somewhat-common practice?
Quoted 5 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +5
-0+ compatible = "allwinner,sun4i-a10-video-engine"; + reg = <0x01c0e000 0x1000>; + memory-region = <&ve_memory>; + + clocks = <&ccu CLK_AHB_VE>, <&ccu CLK_VE>,
Documentation/devicetree/bindings/media/sunxi-cedrus.txt line 50
Quoted 10 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +10
-0+ <&ccu CLK_DRAM_VE>; + clock-names = "ahb", "mod", "ram"; + + assigned-clocks = <&ccu CLK_VE>; + assigned-clock-rates = <320000000>; + + resets = <&ccu RST_VE>; + + interrupts = <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>; +};
regards
Philipp
Tomasz Figa
maintainerRe: [PATCH v2 08/10] dt-bindings: media: Document bindings for the Sunxi-Cedrus VPU driver
Hi Paul, Philipp,
Quoted 9 lines · Philipp Zabel
Hi Paul,
Quoted 6 lines · Paul Kocialkowski
This adds a device-tree binding document that specifies the properties used by the Sunxi-Cedurs VPU driver, as well as examples.
Signed-off-by Paul Kocialkowski <[email protected]>--- .../devicetree/bindings/media/sunxi-cedrus.txt | 50
++++++++++++++++++++++
Quoted 2 lines
Quoted 2 lines
1 file changed, 50 insertions(+) create mode 100644
Documentation/devicetree/bindings/media/sunxi-cedrus.txt
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +0
-0
b/Documentation/devicetree/bindings/media/sunxi-cedrus.txt
Quoted 6 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt line 1
Quoted 6 lines
new file mode 100644
index 000000000000..71ad3f9c3352Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +1
-0@@ -0,0 +1,50 @@ +Device-tree bindings for the VPU found in Allwinner SoCs, referred to
as the
Quoted 3 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt
Quoted 3 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +3
-0+Video Engine (VE) in Allwinner literature. + +The VPU can only access the first 256 MiB of DRAM, that are DMA-mapped
starting
Quoted 1 line
Documentation/devicetree/bindings/media/sunxi-cedrus.txt line 5
Quoted 1 line
Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +1
-0+from the DRAM base. This requires specific memory allocation and
handling.
And no IOMMU? Brings back memories.
Quoted 5 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt
Quoted 5 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +5
-0+ +Required properties: +- compatible : "allwinner,sun4i-a10-video-engine"; +- memory-region : DMA pool for buffers allocation; +- clocks : list of clock specifiers, corresponding to
entries in
Quoted 2 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt line 12
Quoted 2 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +2
-0+ the clock-names property; +- clock-names : should contain "ahb", "mod" and "ram"
entries;
Quoted 2 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt line 14
Quoted 2 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +2
-0+- assigned-clocks : list of clocks assigned to the VE; +- assigned-clocks-rates : list of clock rates for the clocks assigned
to the VE;
Quoted 3 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt
Quoted 3 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +3
-0+- resets : phandle for reset; +- interrupts : should contain VE interrupt number; +- reg : should contain register base and length
of VE.
Quoted 14 lines
Quoted 14 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +14
-0+ +Example: + +reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + /* Address must be kept in the lower 256 MiBs of DRAM for VE. */ + ve_memory: cma at 4a000000 { + compatible = "shared-dma-pool"; + reg = <0x4a000000 0x6000000>; + no-map; + linux,cma-default;
Quoted 8 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt line 35
Quoted 4 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +4
-0+ }; +}; + +video-engine at 1c0e000 {This is not really required by any specification, and not as common as gpu at ..., but could this reasonably be called "vpu at 1c0e000" to follow somewhat-common practice?
AFAIR the name is supposed to be somewhat readable for someone that doesn't know the hardware. To me, "video-engine" sounds more obvious than "vpu", but we actually use "codec" already, in case of MFC and JPEG codec on Exynos. If encode/decode is the only functionality of this block, I'd personally go with "codec". If it can do other things, e.g. scaling/rotation without encode/decode, I'd probably call it "video-processor".
Best regards,
Tomasz
Re: [PATCH v2 08/10] dt-bindings: media: Document bindings for the Sunxi-Cedrus VPU driver
Hi and thanks for the review,
Quoted 40 lines · Tomasz Figa
Hi Paul, Philipp,
Quoted 9 lines · Philipp Zabel
Hi Paul,
Quoted 7 lines · Paul Kocialkowski
This adds a device-tree binding document that specifies the properties
used by the Sunxi-Cedurs VPU driver, as well as examples.Signed-off-by Paul Kocialkowski <[email protected]>--- .../devicetree/bindings/media/sunxi-cedrus.txt | 50++++++++++++++++++++++
Quoted 2 lines
Quoted 2 lines
1 file changed, 50 insertions(+) create mode 100644
Documentation/devicetree/bindings/media/sunxi-cedrus.txtQuoted 3 lines
Quoted 3 lines
(quoted diff) +0
-0cedrus.txt
b/Documentation/devicetree/bindings/media/sunxi-cedrus.txtQuoted 7 lines
Quoted 7 lines
new file mode 100644
index 000000000000..71ad3f9c3352Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +1
-0@@ -0,0 +1,50 @@ +Device-tree bindings for the VPU found in Allwinner SoCs,referred to
as the
Quoted 4 lines
Quoted 4 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +3
-0+Video Engine (VE) in Allwinner literature. + +The VPU can only access the first 256 MiB of DRAM, that are DMA-mapped
starting
Quoted 5 lines
Quoted 1 line
Quoted 1 line
+from the DRAM base. This requires specific memory allocation and
handling.
And no IOMMU? Brings back memories.
Exactly, no IOMMU so we don't have much choice but cope with that hardware limitation...
Quoted 47 lines
Quoted 5 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt
Quoted 5 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +5
-0+ +Required properties: +- compatible : "allwinner,sun4i-a10-video-engine"; +- memory-region : DMA pool for buffers allocation; +- clocks : list of clock specifiers, corresponding toentries in
Quoted 3 lines
Quoted 3 lines
+ the clock-names property;
+- clock-names : should contain "ahb", "mod" and
"ram"entries;
Quoted 3 lines
Quoted 3 lines
+- assigned-clocks : list of clocks assigned to the VE; +- assigned-clocks-rates : list of clock rates for the clocksassigned
to the VE;
Quoted 4 lines
Quoted 4 lines
+- resets : phandle for reset; +- interrupts : should contain VE interrupt number; +- reg : should contain register base andlength
of VE.
Quoted 15 lines
Quoted 15 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +9
-0+ +Example: + +reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + /* Address must be kept in the lower 256 MiBs of DRAM forVE. */
Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +5
-0+ ve_memory: cma at 4a000000 { + compatible = "shared-dma-pool"; + reg = <0x4a000000 0x6000000>; + no-map; + linux,cma-default;Quoted 8 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt line 35
Quoted 4 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +4
-0+ }; +}; + +video-engine at 1c0e000 {This is not really required by any specification, and not as common as
gpu at ..., but could this reasonably be called "vpu at 1c0e000" to follow somewhat-common practice?
Quoted 7 lines
AFAIR the name is supposed to be somewhat readable for someone that doesn't know the hardware. To me, "video-engine" sounds more obvious than "vpu", but we actually use "codec" already, in case of MFC and JPEG codec on Exynos. If encode/decode is the only functionality of this block, I'd personally go with "codec". If it can do other things, e.g. scaling/rotation without encode/decode, I'd probably call it "video-processor".
I agree that the term VPU is more commonly associated with video decoding, while video engine could mean a number of things.
The reason I went with "video-engine" here (while still presenting the driver as a VPU driver) is that Video Engine is the term used in Allwinner's litterature. Other nodes in Allwinner device-trees generally stick to these terms (for instance, we have "display-engine" nodes). This also makes it easier to find the matching parts in the documentation.
Cheers,
Signature · 10 lines
Paul Kocialkowski, Bootlin (formerly Free Electrons) Embedded Linux and kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: This is a digitally signed message part URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180420/18984815/attachment.sig>
Rob Herring
maintainerRe: [PATCH v2 08/10] dt-bindings: media: Document bindings for the Sunxi-Cedrus VPU driver
Quoted 110 lines · Paul Kocialkowski
Hi and thanks for the review,
Quoted 40 lines · Tomasz Figa
Hi Paul, Philipp,
Quoted 9 lines · Philipp Zabel
Hi Paul,
Quoted 7 lines · Paul Kocialkowski
This adds a device-tree binding document that specifies the properties
used by the Sunxi-Cedurs VPU driver, as well as examples.Signed-off-by Paul Kocialkowski <[email protected]>--- .../devicetree/bindings/media/sunxi-cedrus.txt | 50++++++++++++++++++++++
Quoted 2 lines
Quoted 2 lines
1 file changed, 50 insertions(+) create mode 100644
Documentation/devicetree/bindings/media/sunxi-cedrus.txtQuoted 3 lines
Quoted 3 lines
(quoted diff) +0
-0cedrus.txt
b/Documentation/devicetree/bindings/media/sunxi-cedrus.txtQuoted 7 lines
Quoted 7 lines
new file mode 100644
index 000000000000..71ad3f9c3352Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +1
-0@@ -0,0 +1,50 @@ +Device-tree bindings for the VPU found in Allwinner SoCs,referred to
as the
Quoted 4 lines
Quoted 4 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +3
-0+Video Engine (VE) in Allwinner literature. + +The VPU can only access the first 256 MiB of DRAM, that are DMA-mapped
starting
Quoted 5 lines
Quoted 1 line
Quoted 1 line
+from the DRAM base. This requires specific memory allocation and
handling.
And no IOMMU? Brings back memories.
Exactly, no IOMMU so we don't have much choice but cope with that hardware limitation...
Quoted 47 lines
Quoted 5 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt
Quoted 5 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +5
-0+ +Required properties: +- compatible : "allwinner,sun4i-a10-video-engine"; +- memory-region : DMA pool for buffers allocation; +- clocks : list of clock specifiers, corresponding toentries in
Quoted 3 lines
Quoted 3 lines
+ the clock-names property;
+- clock-names : should contain "ahb", "mod" and
"ram"entries;
Quoted 3 lines
Quoted 3 lines
+- assigned-clocks : list of clocks assigned to the VE; +- assigned-clocks-rates : list of clock rates for the clocksassigned
to the VE;
Quoted 4 lines
Quoted 4 lines
+- resets : phandle for reset; +- interrupts : should contain VE interrupt number; +- reg : should contain register base andlength
of VE.
Quoted 15 lines
Quoted 15 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +9
-0+ +Example: + +reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + /* Address must be kept in the lower 256 MiBs of DRAM forVE. */
Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +5
-0+ ve_memory: cma at 4a000000 { + compatible = "shared-dma-pool"; + reg = <0x4a000000 0x6000000>; + no-map; + linux,cma-default;Quoted 8 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt line 35
Quoted 4 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +4
-0+ }; +}; + +video-engine at 1c0e000 {This is not really required by any specification, and not as common as
gpu at ..., but could this reasonably be called "vpu at 1c0e000" to follow somewhat-common practice?Quoted 7 lines
AFAIR the name is supposed to be somewhat readable for someone that doesn't know the hardware. To me, "video-engine" sounds more obvious than "vpu", but we actually use "codec" already, in case of MFC and JPEG codec on Exynos. If encode/decode is the only functionality of this block, I'd personally go with "codec". If it can do other things, e.g. scaling/rotation without encode/decode, I'd probably call it "video-processor".
I agree that the term VPU is more commonly associated with video decoding, while video engine could mean a number of things.
Quoted 6 lines
The reason I went with "video-engine" here (while still presenting the driver as a VPU driver) is that Video Engine is the term used in Allwinner's litterature. Other nodes in Allwinner device-trees generally stick to these terms (for instance, we have "display-engine" nodes). This also makes it easier to find the matching parts in the documentation.
'video-codec' is what is defined in the DT spec.
Rob
Re: [PATCH v2 08/10] dt-bindings: media: Document bindings for the Sunxi-Cedrus VPU driver
Hi,
Quoted 136 lines · Rob Herring
Quoted 126 lines · Paul Kocialkowski
Hi and thanks for the review,
Quoted 43 lines · Tomasz Figa
Hi Paul, Philipp,
Quoted 10 lines · Philipp Zabel
Hi Paul,
Quoted 8 lines · Paul Kocialkowski
This adds a device-tree binding document that specifies the properties
used by the Sunxi-Cedurs VPU driver, as well as examples.Signed-off-by Paul Kocialkowski <[email protected]m>
--- .../devicetree/bindings/media/sunxi-cedrus.txt | 50++++++++++++++++++++++
Quoted 2 lines
Quoted 2 lines
1 file changed, 50 insertions(+) create mode 100644
Documentation/devicetree/bindings/media/sunxi-cedrus.txtQuoted 3 lines
Quoted 3 lines
(quoted diff) +0
-0cedrus.txt
b/Documentation/devicetree/bindings/media/sunxi-cedrus.txtQuoted 7 lines
Quoted 7 lines
new file mode 100644
index 000000000000..71ad3f9c3352Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +1
-0@@ -0,0 +1,50 @@ +Device-tree bindings for the VPU found in Allwinner SoCs,referred to
as the
Quoted 5 lines
Quoted 5 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +3
-0+Video Engine (VE) in Allwinner literature. + +The VPU can only access the first 256 MiB of DRAM, that areDMA-
mappedstarting
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
+from the DRAM base. This requires specific memory allocation and
handling.
And no IOMMU? Brings back memories.
Exactly, no IOMMU so we don't have much choice but cope with that hardware limitation...
Quoted 54 lines
Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +5
-0+ +Required properties: +- compatible : "allwinner,sun4i-a10-video-engine"; +- memory-region : DMA pool for buffers allocation; +- clocks : list of clock specifiers,corresponding to
entries in
Quoted 4 lines
Quoted 4 lines
+ the clock-names property;
+- clock-names : should contain "ahb", "mod"
and
"ram"entries;
Quoted 3 lines
Quoted 3 lines
+- assigned-clocks : list of clocks assigned to the VE; +- assigned-clocks-rates : list of clock rates for the clocksassigned
to the VE;
Quoted 5 lines
Quoted 5 lines
+- resets : phandle for reset; +- interrupts : should contain VE interrupt number; +- reg : should contain register baseand
lengthof VE.
Quoted 19 lines
Quoted 19 lines
Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +9
-0+ +Example: + +reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + /* Address must be kept in the lower 256 MiBs of DRAMfor
VE. */Documentation/devicetree/bindings/media/sunxi-cedrus.txt new file +8
-0+ ve_memory: cma at 4a000000 { + compatible = "shared-dma-pool"; + reg = <0x4a000000 0x6000000>; + no-map; + linux,cma-default; + }; +}; +Quoted 8 lines
Quoted 1 line
+video-engine at 1c0e000 {
This is not really required by any specification, and not as common
as
gpu at ..., but could this reasonably be called "vpu at 1c0e000" to follow
somewhat-common practice?Quoted 12 lines
AFAIR the name is supposed to be somewhat readable for someone that
doesn't know the hardware. To me, "video-engine" sounds more obvious
than "vpu", but we actually use "codec" already, in case of MFC and
JPEG codec on Exynos. If encode/decode is the only functionality of
this block, I'd personally go with "codec". If it can do other things,
e.g. scaling/rotation without encode/decode, I'd probably call it "video-processor".I agree that the term VPU is more commonly associated with video decoding, while video engine could mean a number of things.
Quoted 8 lines
The reason I went with "video-engine" here (while still presenting the
driver as a VPU driver) is that Video Engine is the term used in Allwinner's litterature. Other nodes in Allwinner device-trees generally
stick to these terms (for instance, we have "display-engine" nodes). This also makes it easier to find the matching parts in the documentation.
Quoted 1 line
'video-codec' is what is defined in the DT spec.
Is that an actively-enforced guideline or a suggestion? I'd like to keep video-engine just to stick with the technical documentation wording and my personal taste is also to prefer vpu over video-codec (in terms of clarity/straightforwardness) as a second choice.
Still, if the choice isn't up to me, we can go with video-codec (or vpu).
Cheers,
Signature · 10 lines
Paul Kocialkowski, Bootlin (formerly Free Electrons) Embedded Linux and kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: This is a digitally signed message part URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180504/5bbb8dfd/attachment.sig>
Re: [PATCH v2 08/10] dt-bindings: media: Document bindings for the Sunxi-Cedrus VPU driver
Quoted 14 lines · Paul Kocialkowski
Quoted 12 lines
Quoted 11 lines
I agree that the term VPU is more commonly associated with video decoding, while video engine could mean a number of things.
The reason I went with "video-engine" here (while still presenting the
driver as a VPU driver) is that Video Engine is the term used in Allwinner's litterature. Other nodes in Allwinner device-trees generally
stick to these terms (for instance, we have "display-engine" nodes). This also makes it easier to find the matching parts in the documentation.Quoted 1 line
'video-codec' is what is defined in the DT spec.
Quoted 7 lines
Is that an actively-enforced guideline or a suggestion? I'd like to keep video-engine just to stick with the technical documentation wording and my personal taste is also to prefer vpu over video-codec (in terms of clarity/straightforwardness) as a second choice.
Still, if the choice isn't up to me, we can go with video-codec (or vpu).
The unit-name is supposed to reflect the class of the device, and nothing else. If there's already a pre-existing class name defined for these kind of devices, then there's no point in choosing something else.
Maxime
Signature · 10 lines
Maxime Ripard, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180504/edc240ab/attachment.sig>
Re: [PATCH v2 08/10] dt-bindings: media: Document bindings for the Sunxi-Cedrus VPU driver
In reply to Paul KocialkowskiQuoted 8 lines · Paul Kocialkowski
This adds a device-tree binding document that specifies the properties used by the Sunxi-Cedurs VPU driver, as well as examples.
Signed-off-by Paul Kocialkowski <[email protected]>--- .../devicetree/bindings/media/sunxi-cedrus.txt | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/sunxi-cedrus.txt
Other than the one nit about the node name,
PATCH v2 9/10 ARM: dts: sun7i-a20: Add Video Engine and reserved memory nodes
In reply to Paul KocialkowskiThis adds nodes for the Video Engine and the associated reserved memory for the Allwinner A20. Up to 96 MiB of memory are dedicated to the VPU.
The VPU can only map the first 256 MiB of DRAM, so the reserved memory pool has to be located in that area. Following Allwinner's decision in downstream software, the last 96 MiB of the first 256 MiB of RAM are reserved for this purpose.
--- arch/arm/boot/dts/sun7i-a20.dtsi | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
arch/arm/boot/dts/sun7i-a20.dtsi +31 -0
@@ -163,6 +163,20 @@ reg = <0x40000000 0x80000000>; }; + reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + /* Address must be kept in the lower 256 MiBs of DRAM for VE. */ + ve_memory: cma at 4a000000 { + compatible = "shared-dma-pool"; + reg = <0x4a000000 0x6000000>; + no-map; + linux,cma-default; + }; + }; + timer { compatible = "arm,armv7-timer"; interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
@@ -451,6 +465,23 @@ }; }; + ve: video-engine at 1c0e000 { + compatible = "allwinner,sun4i-a10-video-engine"; + reg = <0x01c0e000 0x1000>; + memory-region = <&ve_memory>; + + clocks = <&ccu CLK_AHB_VE>, <&ccu CLK_VE>, + <&ccu CLK_DRAM_VE>; + clock-names = "ahb", "mod", "ram"; + + assigned-clocks = <&ccu CLK_VE>; + assigned-clock-rates = <320000000>; + + resets = <&ccu RST_VE>; + + interrupts = <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>; + }; + mmc0: mmc at 1c0f000 { compatible = "allwinner,sun7i-a20-mmc"; reg = <0x01c0f000 0x1000>;
Signature · 1 line
2.16.3
Re: [PATCH v2 09/10] ARM: dts: sun7i-a20: Add Video Engine and reserved memory nodes
Quoted 21 lines · Paul Kocialkowski
This adds nodes for the Video Engine and the associated reserved memory for the Allwinner A20. Up to 96 MiB of memory are dedicated to the VPU.
The VPU can only map the first 256 MiB of DRAM, so the reserved memory pool has to be located in that area. Following Allwinner's decision in downstream software, the last 96 MiB of the first 256 MiB of RAM are reserved for this purpose.
Signed-off-by Paul Kocialkowski <[email protected]>--- arch/arm/boot/dts/sun7i-a20.dtsi | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)arch/arm/boot/dts/sun7i-a20.dtsi +0
-0@@ -163,6 +163,20 @@ reg = <0x40000000 0x80000000>; };
arch/arm/boot/dts/sun7i-a20.dtsi line 175
Quoted 10 lines
arch/arm/boot/dts/sun7i-a20.dtsi +10
-0+ reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + /* Address must be kept in the lower 256 MiBs of DRAM for VE. */ + ve_memory: cma at 4a000000 { + compatible = "shared-dma-pool"; + reg = <0x4a000000 0x6000000>; + no-map;
I'm not sure why no-map is needed.
And I guess we could use alloc-ranges to make sure the region is in the proper memory range, instead of hardcoding it.
arch/arm/boot/dts/sun7i-a20.dtsi line 469
Quoted 13 lines
arch/arm/boot/dts/sun7i-a20.dtsi +6
-0+ linux,cma-default; + }; + }; + timer { compatible = "arm,armv7-timer"; interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,@@ -451,6 +465,23 @@ }; }; + ve: video-engine at 1c0e000 { + compatible = "allwinner,sun4i-a10-video-engine";
We should have an A20-specific compatible here, at least, so that we can deal with any quirk we might find down the road.
arch/arm/boot/dts/sun7i-a20.dtsi line 471
Quoted 2 lines
arch/arm/boot/dts/sun7i-a20.dtsi +2
-0+ reg = <0x01c0e000 0x1000>; + memory-region = <&ve_memory>;
Since you made the CMA region the default one, you don't need to tie it to that device in particular (and you can drop it being mandatory from your binding as well).
arch/arm/boot/dts/sun7i-a20.dtsi line 478
Quoted 7 lines
arch/arm/boot/dts/sun7i-a20.dtsi +7
-0+ + clocks = <&ccu CLK_AHB_VE>, <&ccu CLK_VE>, + <&ccu CLK_DRAM_VE>; + clock-names = "ahb", "mod", "ram"; + + assigned-clocks = <&ccu CLK_VE>; + assigned-clock-rates = <320000000>;
This should be set from within the driver. If it's something that you absolutely needed for the device to operate, you have no guarantee that the clock rate won't change at any point in time after the device probe, so that's not a proper solution.
And if it's not needed and can be adjusted depending on the framerate/codec/resolution, then it shouldn't be in the DT either.
Don't you also need to map the SRAM on the A20?
Maxime
Signature · 10 lines
Maxime Ripard, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180420/709dd34d/attachment-0001.sig>
Re: [PATCH v2 09/10] ARM: dts: sun7i-a20: Add Video Engine and reserved memory nodes
Hi,
Quoted 28 lines · Maxime Ripard
Quoted 27 lines · Paul Kocialkowski
This adds nodes for the Video Engine and the associated reserved memory
for the Allwinner A20. Up to 96 MiB of memory are dedicated to the VPU.The VPU can only map the first 256 MiB of DRAM, so the reserved memory
pool has to be located in that area. Following Allwinner's decision in
downstream software, the last 96 MiB of the first 256 MiB of RAM are reserved for this purpose.Signed-off-by Paul Kocialkowski <[email protected]>--- arch/arm/boot/dts/sun7i-a20.dtsi | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)arch/arm/boot/dts/sun7i-a20.dtsi +0
-0@@ -163,6 +163,20 @@ reg = <0x40000000 0x80000000>; };
Quoted 13 lines
arch/arm/boot/dts/sun7i-a20.dtsi line 175
Quoted 11 lines
arch/arm/boot/dts/sun7i-a20.dtsi +6
-0+ reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + /* Address must be kept in the lower 256 MiBs ofDRAM for VE. */
arch/arm/boot/dts/sun7i-a20.dtsi +4
-0+ ve_memory: cma at 4a000000 { + compatible = "shared-dma-pool"; + reg = <0x4a000000 0x6000000>; + no-map;I'm not sure why no-map is needed.
In fact, having no-map here would lead to reserving the area as cache- coherent instead of contiguous and thus prevented dmabuf support. Replacing it by "resuable" allows proper CMA reservation.
Quoted 2 lines
And I guess we could use alloc-ranges to make sure the region is in the proper memory range, instead of hardcoding it.
As far as I could understand from the documentation, "alloc-ranges" is used for dynamic allocation while only "reg" is used for static allocation. We are currently going with static allocation and thus reserve the whole 96 MiB. Is using dynamic allocation instead desirable here?
Quoted 12 lines
Quoted 12 lines
arch/arm/boot/dts/sun7i-a20.dtsi +4
-0+ linux,cma-default; + }; + }; + timer { compatible = "arm,armv7-timer"; interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) |
IRQ_TYPE_LEVEL_LOW)>,arch/arm/boot/dts/sun7i-a20.dtsi +0
-0@@ -451,6 +465,23 @@ }; };
Quoted 6 lines
arch/arm/boot/dts/sun7i-a20.dtsi line 470
Quoted 3 lines
arch/arm/boot/dts/sun7i-a20.dtsi +2
-0+ ve: video-engine at 1c0e000 { + compatible = "allwinner,sun4i-a10-video- engine";We should have an A20-specific compatible here, at least, so that we can deal with any quirk we might find down the road.
Yes that's a very good point.
Quoted 6 lines
arch/arm/boot/dts/sun7i-a20.dtsi line 471
Quoted 2 lines
arch/arm/boot/dts/sun7i-a20.dtsi +2
-0+ reg = <0x01c0e000 0x1000>; + memory-region = <&ve_memory>;Since you made the CMA region the default one, you don't need to tie it to that device in particular (and you can drop it being mandatory from your binding as well).
What if another driver (or the system) claims memory from that zone and that the reserved memory ends up not being available for the VPU anymore?
Acccording to the reserved-memory documentation, the reusable property (that we need for dmabuf) puts a limitation that the device driver owning the region must be able to reclaim it back.
How does that work out if the CMA region is not tied to a driver in particular?
Quoted 13 lines
arch/arm/boot/dts/sun7i-a20.dtsi line 478
Quoted 7 lines
arch/arm/boot/dts/sun7i-a20.dtsi +7
-0+ + clocks = <&ccu CLK_AHB_VE>, <&ccu CLK_VE>, + <&ccu CLK_DRAM_VE>; + clock-names = "ahb", "mod", "ram"; + + assigned-clocks = <&ccu CLK_VE>; + assigned-clock-rates = <320000000>;This should be set from within the driver. If it's something that you absolutely needed for the device to operate, you have no guarantee that the clock rate won't change at any point in time after the device probe, so that's not a proper solution.
Quoted 2 lines
And if it's not needed and can be adjusted depending on the framerate/codec/resolution, then it shouldn't be in the DT either.
Yes, that makes sense.
Quoted 1 line
Don't you also need to map the SRAM on the A20?
That's a good point, there is currently no syscon handle for A20 (and also A13). Maybe SRAM is muxed to the VE by default so it "just works"?
I'll investigate on this side, also keeping in mind that the actual solution is to use the SRAM controller driver (but that won't make it to v3).
Cheers and thanks for the review!
Signature · 10 lines
Paul Kocialkowski, Bootlin (formerly Free Electrons) Embedded Linux and kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: This is a digitally signed message part URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180504/62afecee/attachment.sig>
Re: [PATCH v2 09/10] ARM: dts: sun7i-a20: Add Video Engine and reserved memory nodes
Quoted 18 lines · Paul Kocialkowski
Quoted 5 lines
Quoted 5 lines
arch/arm/boot/dts/sun7i-a20.dtsi +5
-0+ reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; +Quoted 8 lines
arch/arm/boot/dts/sun7i-a20.dtsi line 175
Quoted 6 lines
(quoted diff) +1
-0+ /* Address must be kept in the lower 256 MiBs ofDRAM for VE. */
arch/arm/boot/dts/sun7i-a20.dtsi +4
-0+ ve_memory: cma at 4a000000 { + compatible = "shared-dma-pool"; + reg = <0x4a000000 0x6000000>; + no-map;I'm not sure why no-map is needed.
In fact, having no-map here would lead to reserving the area as cache- coherent instead of contiguous and thus prevented dmabuf support. Replacing it by "resuable" allows proper CMA reservation.
Quoted 8 lines
Quoted 2 lines
And I guess we could use alloc-ranges to make sure the region is in the proper memory range, instead of hardcoding it.
As far as I could understand from the documentation, "alloc-ranges" is used for dynamic allocation while only "reg" is used for static allocation. We are currently going with static allocation and thus reserve the whole 96 MiB. Is using dynamic allocation instead desirable here?
I guess we could turn the question backward. Why do we need a static allocation? This isn't a buffer that is always allocated on the same area, but rather that we have a range available. So our constraint is on the range, nothing else.
Quoted 11 lines
Quoted 6 lines
arch/arm/boot/dts/sun7i-a20.dtsi line 471
Quoted 2 lines
arch/arm/boot/dts/sun7i-a20.dtsi +2
-0+ reg = <0x01c0e000 0x1000>; + memory-region = <&ve_memory>;Since you made the CMA region the default one, you don't need to tie it to that device in particular (and you can drop it being mandatory from your binding as well).
What if another driver (or the system) claims memory from that zone and that the reserved memory ends up not being available for the VPU anymore?
Quoted 6 lines
Acccording to the reserved-memory documentation, the reusable property (that we need for dmabuf) puts a limitation that the device driver owning the region must be able to reclaim it back.
How does that work out if the CMA region is not tied to a driver in particular?
I'm not sure to get what you're saying. You have the property linux,cma-default in your reserved region, so the behaviour you described is what you explicitly asked for.
Quoted 19 lines
Quoted 14 lines
arch/arm/boot/dts/sun7i-a20.dtsi line 478
Quoted 8 lines
arch/arm/boot/dts/sun7i-a20.dtsi +7
-0+ + clocks = <&ccu CLK_AHB_VE>, <&ccu CLK_VE>, + <&ccu CLK_DRAM_VE>; + clock-names = "ahb", "mod", "ram"; + + assigned-clocks = <&ccu CLK_VE>; + assigned-clock-rates = <320000000>;This should be set from within the driver. If it's something that you absolutely needed for the device to operate, you have no guarantee that the clock rate won't change at any point in time after the device probe, so that's not a proper solution.
Quoted 2 lines
And if it's not needed and can be adjusted depending on the framerate/codec/resolution, then it shouldn't be in the DT either.
Yes, that makes sense.
Quoted 8 lines
Quoted 1 line
Don't you also need to map the SRAM on the A20?
That's a good point, there is currently no syscon handle for A20 (and also A13). Maybe SRAM is muxed to the VE by default so it "just works"?
I'll investigate on this side, also keeping in mind that the actual solution is to use the SRAM controller driver (but that won't make it to v3).
The SRAM driver is available on the A20, so you should really use that instead of a syscon.
Maxime
Signature · 10 lines
Maxime Ripard, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180504/5dcc102b/attachment.sig>
Re: [PATCH v2 09/10] ARM: dts: sun7i-a20: Add Video Engine and reserved memory nodes
Hi,
Quoted 33 lines · Maxime Ripard
Quoted 24 lines · Paul Kocialkowski
Quoted 6 lines
Quoted 6 lines
arch/arm/boot/dts/sun7i-a20.dtsi +6
-0+ reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + /* Address must be kept in the lower 256 MiBsQuoted 8 lines
arch/arm/boot/dts/sun7i-a20.dtsi line 175
Quoted 6 lines
of
DRAM for VE. */arch/arm/boot/dts/sun7i-a20.dtsi +4
-0+ ve_memory: cma at 4a000000 { + compatible = "shared-dma-pool"; + reg = <0x4a000000 0x6000000>; + no-map;I'm not sure why no-map is needed.
In fact, having no-map here would lead to reserving the area as cache-
coherent instead of contiguous and thus prevented dmabuf support. Replacing it by "resuable" allows proper CMA reservation.Quoted 3 lines
And I guess we could use alloc-ranges to make sure the region is in
the proper memory range, instead of hardcoding it.Quoted 7 lines
As far as I could understand from the documentation, "alloc-ranges" is
used for dynamic allocation while only "reg" is used for static allocation. We are currently going with static allocation and thus reserve the whole 96 MiB. Is using dynamic allocation instead desirable
here?
Quoted 4 lines
I guess we could turn the question backward. Why do we need a static allocation? This isn't a buffer that is always allocated on the same area, but rather that we have a range available. So our constraint is on the range, nothing else.
That makes sense, I will give it a shot with a range then.
Quoted 19 lines
Quoted 19 lines
Quoted 8 lines
arch/arm/boot/dts/sun7i-a20.dtsi line 471
Quoted 2 lines
arch/arm/boot/dts/sun7i-a20.dtsi +2
-0+ reg = <0x01c0e000 0x1000>; + memory-region = <&ve_memory>;Since you made the CMA region the default one, you don't need to tie
it to that device in particular (and you can drop it being mandatory
from your binding as well).What if another driver (or the system) claims memory from that zone and
that the reserved memory ends up not being available for the VPU anymore?Acccording to the reserved-memory documentation, the reusable property
(that we need for dmabuf) puts a limitation that the device driver owning the region must be able to reclaim it back.
Quoted 6 lines
Quoted 2 lines
How does that work out if the CMA region is not tied to a driver in particular?
I'm not sure to get what you're saying. You have the property linux,cma-default in your reserved region, so the behaviour you described is what you explicitly asked for.
My point is that I don't see how the driver can claim back (part of) the reserved area if the area is not explicitly attached to it.
Or is that mechanism made in a way that all drivers wishing to use the reserved memory area can claim it back from the system, but there is no priority (other than first-come first-served) for which drivers claims it back in case two want to use the same reserved region (in a scenario where there isn't enough memory to allow both drivers)?
Quoted 28 lines
Quoted 28 lines
Quoted 16 lines
arch/arm/boot/dts/sun7i-a20.dtsi line 478
Quoted 8 lines
(quoted diff) +2
-0+ + clocks = <&ccu CLK_AHB_VE>, <&ccu
CLK_VE>,arch/arm/boot/dts/sun7i-a20.dtsi +5
-0+ <&ccu CLK_DRAM_VE>; + clock-names = "ahb", "mod", "ram"; + + assigned-clocks = <&ccu CLK_VE>; + assigned-clock-rates = <320000000>;This should be set from within the driver. If it's something that you
absolutely needed for the device to operate, you have no guarantee that the clock rate won't change at any point in time after the device
probe, so that's not a proper solution.Quoted 2 lines
And if it's not needed and can be adjusted depending on the framerate/codec/resolution, then it shouldn't be in the DT either.
Yes, that makes sense.
Quoted 1 line
Don't you also need to map the SRAM on the A20?
That's a good point, there is currently no syscon handle for A20 (and
also A13). Maybe SRAM is muxed to the VE by default so it "just works"?
Quoted 7 lines
Quoted 4 lines
I'll investigate on this side, also keeping in mind that the actual solution is to use the SRAM controller driver (but that won't make it to
v3).The SRAM driver is available on the A20, so you should really use that instead of a syscon.
The SRAM driver is indeed available for the A20, but still lacks support for the VE in particular as far as I can see.
Cheers,
Signature · 10 lines
Paul Kocialkowski, Bootlin (formerly Free Electrons) Embedded Linux and kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: This is a digitally signed message part URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180504/dd75265f/attachment-0001.sig>
Re: [PATCH v2 09/10] ARM: dts: sun7i-a20: Add Video Engine and reserved memory nodes
Quoted 6 lines · Paul Kocialkowski
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Don't you also need to map the SRAM on the A20?
That's a good point, there is currently no syscon handle for A20 (and
also A13). Maybe SRAM is muxed to the VE by default so it "just works"?
I just checked on the manual and it appears that SRAM Area C1 is muxed to the VE at reset, so we can probably keep things as-is until the SRAM driver is ready to handle explicitly muxing that area to the VE.
Signature · 10 lines
Paul Kocialkowski, Bootlin (formerly Free Electrons) Embedded Linux and kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: This is a digitally signed message part URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180504/ea0e5029/attachment.sig>
Re: [PATCH v2 09/10] ARM: dts: sun7i-a20: Add Video Engine and reserved memory nodes
In reply to Paul KocialkowskiQuoted 26 lines · Paul Kocialkowski
Quoted 19 lines
Quoted 19 lines
Quoted 8 lines
arch/arm/boot/dts/sun7i-a20.dtsi line 471
Quoted 2 lines
arch/arm/boot/dts/sun7i-a20.dtsi +2
-0+ reg = <0x01c0e000 0x1000>; + memory-region = <&ve_memory>;Since you made the CMA region the default one, you don't need to tie
it to that device in particular (and you can drop it being mandatory
from your binding as well).What if another driver (or the system) claims memory from that zone and
that the reserved memory ends up not being available for the VPU anymore?Acccording to the reserved-memory documentation, the reusable property
(that we need for dmabuf) puts a limitation that the device driver owning the region must be able to reclaim it back.Quoted 6 lines
Quoted 2 lines
How does that work out if the CMA region is not tied to a driver in particular?
I'm not sure to get what you're saying. You have the property linux,cma-default in your reserved region, so the behaviour you described is what you explicitly asked for.
Quoted 8 lines
My point is that I don't see how the driver can claim back (part of) the reserved area if the area is not explicitly attached to it.
Or is that mechanism made in a way that all drivers wishing to use the reserved memory area can claim it back from the system, but there is no priority (other than first-come first-served) for which drivers claims it back in case two want to use the same reserved region (in a scenario where there isn't enough memory to allow both drivers)?
This is indeed what happens. Reusable is to let the system use the reserved memory for things like caches that can easily be dropped when a driver wants to use the memory in that reserved area. Once that memory has been allocated, there's no claiming back, unless that memory segment was freed of course.
Maxime
Signature · 10 lines
Maxime Ripard, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180504/41c1fcef/attachment-0001.sig>
Re: [PATCH v2 09/10] ARM: dts: sun7i-a20: Add Video Engine and reserved memory nodes
Hi,
Quoted 45 lines · Maxime Ripard
Quoted 34 lines · Paul Kocialkowski
Quoted 22 lines
Quoted 22 lines
Quoted 9 lines
arch/arm/boot/dts/sun7i-a20.dtsi line 471
Quoted 2 lines
arch/arm/boot/dts/sun7i-a20.dtsi +2
-0+ reg = <0x01c0e000 0x1000>; + memory-region = <&ve_memory>;Since you made the CMA region the default one, you don't need to
tie
it to that device in particular (and you can drop it being mandatory
from your binding as well).What if another driver (or the system) claims memory from that zone
and
that the reserved memory ends up not being available for the VPU anymore?Acccording to the reserved-memory documentation, the reusable property
(that we need for dmabuf) puts a limitation that the device driver
owning the region must be able to reclaim it back.Quoted 7 lines
Quoted 3 lines
How does that work out if the CMA region is not tied to a driver in
particular?I'm not sure to get what you're saying. You have the property linux,cma-default in your reserved region, so the behaviour you described is what you explicitly asked for.
My point is that I don't see how the driver can claim back (part of) the
reserved area if the area is not explicitly attached to it.Quoted 9 lines
Or is that mechanism made in a way that all drivers wishing to use the
reserved memory area can claim it back from the system, but there is no
priority (other than first-come first-served) for which drivers claims
it back in case two want to use the same reserved region (in a scenario
where there isn't enough memory to allow both drivers)?
Quoted 5 lines
This is indeed what happens. Reusable is to let the system use the reserved memory for things like caches that can easily be dropped when a driver wants to use the memory in that reserved area. Once that memory has been allocated, there's no claiming back, unless that memory segment was freed of course.
Thanks for the clarification. So in our case, perhaps the best fit would be to make that area the default CMA pool so that we can be ensured that the whole 96 MiB is available for the VPU and that no other consumer of CMA will use it?
Cheers,
Signature · 10 lines
Paul Kocialkowski, Bootlin (formerly Free Electrons) Embedded Linux and kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: This is a digitally signed message part URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180504/dc8274eb/attachment-0001.sig>
Re: [PATCH v2 09/10] ARM: dts: sun7i-a20: Add Video Engine and reserved memory nodes
Quoted 52 lines · Paul Kocialkowski
Quoted 45 lines · Maxime Ripard
Quoted 34 lines · Paul Kocialkowski
Quoted 22 lines
Quoted 22 lines
Quoted 9 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ reg = <0x01c0e000 0x1000>; + memory-region = <&ve_memory>;Since you made the CMA region the default one, you don't need to
tie
it to that device in particular (and you can drop it being mandatory
from your binding as well).What if another driver (or the system) claims memory from that zone
and
that the reserved memory ends up not being available for the VPU anymore?Acccording to the reserved-memory documentation, the reusable property
(that we need for dmabuf) puts a limitation that the device driver
owning the region must be able to reclaim it back.Quoted 7 lines
Quoted 3 lines
How does that work out if the CMA region is not tied to a driver in
particular?I'm not sure to get what you're saying. You have the property linux,cma-default in your reserved region, so the behaviour you described is what you explicitly asked for.
My point is that I don't see how the driver can claim back (part of) the
reserved area if the area is not explicitly attached to it.Quoted 9 lines
Or is that mechanism made in a way that all drivers wishing to use the
reserved memory area can claim it back from the system, but there is no
priority (other than first-come first-served) for which drivers claims
it back in case two want to use the same reserved region (in a scenario
where there isn't enough memory to allow both drivers)?Quoted 5 lines
This is indeed what happens. Reusable is to let the system use the reserved memory for things like caches that can easily be dropped when a driver wants to use the memory in that reserved area. Once that memory has been allocated, there's no claiming back, unless that memory segment was freed of course.
Quoted 4 lines
Thanks for the clarification. So in our case, perhaps the best fit would be to make that area the default CMA pool so that we can be ensured that the whole 96 MiB is available for the VPU and that no other consumer of CMA will use it?
The best fit for what use case ? We already discussed this, and I don't see any point in having two separate CMA regions. If you have a reasonably sized region that will accomodate for both the VPU and display engine, why would we want to split them?
Or did you have any experience of running out of buffers?
Maxime
Signature · 10 lines
Maxime Ripard, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180504/d2d87aa3/attachment.sig>
Re: [PATCH v2 09/10] ARM: dts: sun7i-a20: Add Video Engine and reserved memory nodes
Quoted 71 lines · Maxime Ripard
Quoted 62 lines · Paul Kocialkowski
Quoted 54 lines · Maxime Ripard
Quoted 41 lines · Paul Kocialkowski
Quoted 31 lines
Quoted 26 lines
Quoted 10 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ reg = <0x01c0e000 0x1000>; + memory-region = <&ve_memory>;Since you made the CMA region the default one, you don't need
to
tie
it to that device in particular (and you can drop it being mandatory
from your binding as well).What if another driver (or the system) claims memory from that
zone
and
that the reserved memory ends up not being available for the VPU
anymore?Acccording to the reserved-memory documentation, the reusable
property
(that we need for dmabuf) puts a limitation that the device driver
owning the region must be able to reclaim it back.Quoted 4 lines
How does that work out if the CMA region is not tied to a driver
in
particular?Quoted 4 lines
I'm not sure to get what you're saying. You have the property linux,cma-default in your reserved region, so the behaviour you
described is what you explicitly asked for.My point is that I don't see how the driver can claim back (part of)
the
reserved area if the area is not explicitly attached to it.Quoted 11 lines
Or is that mechanism made in a way that all drivers wishing to use
the
reserved memory area can claim it back from the system, but there is
no
priority (other than first-come first-served) for which drivers claims
it back in case two want to use the same reserved region (in a scenario
where there isn't enough memory to allow both drivers)?Quoted 6 lines
This is indeed what happens. Reusable is to let the system use the reserved memory for things like caches that can easily be dropped when
a driver wants to use the memory in that reserved area. Once that memory has been allocated, there's no claiming back, unless that memory segment was freed of course.Quoted 7 lines
Thanks for the clarification. So in our case, perhaps the best fit would
be to make that area the default CMA pool so that we can be ensured that
the whole 96 MiB is available for the VPU and that no other consumer of
CMA will use it?
Quoted 4 lines
The best fit for what use case ? We already discussed this, and I don't see any point in having two separate CMA regions. If you have a reasonably sized region that will accomodate for both the VPU and display engine, why would we want to split them?
The use case I have in mind is boilerplate use of the VPU with the display engine, say with DMAbuf.
It wasn't exactly clear in my memory whether we had decided that the CMA pool we use for the VPU should also be used for other CMA consumers (I realize that this is what we've been doing all along by having linux,cma-default; though).
The fact that the memory region will accomodate for both the display engine and the VPU is not straightforward IMO and I think this has to be an explicit choice that we take. I was under the impression that we chose the 96 MiB because that's what the Allwinner reference code does. Does the reference code also use this pool for display?
I liked the idea of having 96 MiB fully reserved to the VPU because it allows us to provide a limit on the use case, such as "this guarantees N buffers for resolution foo in format bar". If the display engine also uses it, then the limit also depends on how many GEM buffers are allocated (unless I'm missing something).
Quoted 1 line
Or did you have any experience of running out of buffers?
Not yet, I haven't. I have no objection with making the reserved region the default CMA pool and have other consumers use it too.
Cheers,
Signature · 10 lines
Paul Kocialkowski, Bootlin (formerly Free Electrons) Embedded Linux and kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: This is a digitally signed message part URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180504/84c48205/attachment.sig>
Re: [PATCH v2 09/10] ARM: dts: sun7i-a20: Add Video Engine and reserved memory nodes
Quoted 85 lines · Paul Kocialkowski
Quoted 71 lines · Maxime Ripard
Quoted 62 lines · Paul Kocialkowski
Quoted 54 lines · Maxime Ripard
Quoted 41 lines · Paul Kocialkowski
Quoted 31 lines
Quoted 26 lines
Quoted 10 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ reg = <0x01c0e000 0x1000>; + memory-region = <&ve_memory>;Since you made the CMA region the default one, you don't need
to
tie
it to that device in particular (and you can drop it being mandatory
from your binding as well).What if another driver (or the system) claims memory from that
zone
and
that the reserved memory ends up not being available for the VPU
anymore?Acccording to the reserved-memory documentation, the reusable
property
(that we need for dmabuf) puts a limitation that the device driver
owning the region must be able to reclaim it back.Quoted 4 lines
How does that work out if the CMA region is not tied to a driver
in
particular?Quoted 4 lines
I'm not sure to get what you're saying. You have the property linux,cma-default in your reserved region, so the behaviour you
described is what you explicitly asked for.My point is that I don't see how the driver can claim back (part of)
the
reserved area if the area is not explicitly attached to it.Quoted 11 lines
Or is that mechanism made in a way that all drivers wishing to use
the
reserved memory area can claim it back from the system, but there is
no
priority (other than first-come first-served) for which drivers claims
it back in case two want to use the same reserved region (in a scenario
where there isn't enough memory to allow both drivers)?Quoted 6 lines
This is indeed what happens. Reusable is to let the system use the reserved memory for things like caches that can easily be dropped when
a driver wants to use the memory in that reserved area. Once that memory has been allocated, there's no claiming back, unless that memory segment was freed of course.Quoted 7 lines
Thanks for the clarification. So in our case, perhaps the best fit would
be to make that area the default CMA pool so that we can be ensured that
the whole 96 MiB is available for the VPU and that no other consumer of
CMA will use it?Quoted 4 lines
The best fit for what use case ? We already discussed this, and I don't see any point in having two separate CMA regions. If you have a reasonably sized region that will accomodate for both the VPU and display engine, why would we want to split them?
The use case I have in mind is boilerplate use of the VPU with the display engine, say with DMAbuf.
It wasn't exactly clear in my memory whether we had decided that the CMA pool we use for the VPU should also be used for other CMA consumers (I realize that this is what we've been doing all along by having linux,cma-default; though).
Quoted 5 lines
The fact that the memory region will accomodate for both the display engine and the VPU is not straightforward IMO and I think this has to be an explicit choice that we take. I was under the impression that we chose the 96 MiB because that's what the Allwinner reference code does. Does the reference code also use this pool for display?
Yes
Quoted 5 lines
I liked the idea of having 96 MiB fully reserved to the VPU because it allows us to provide a limit on the use case, such as "this guarantees N buffers for resolution foo in format bar". If the display engine also uses it, then the limit also depends on how many GEM buffers are allocated (unless I'm missing something).
This also guarantees that you take away a fifth of the RAM on some boards. If we had yet another CMA pool of 64MB as is the multi_v7 defconfig, that's a third of your RAM that's gone, possibly for no particular reason.
If we make the math, let's say that we are running a system with 4 planes used in 1080p, with 4 Bpp, in double buffering (which is already an unlikely setup). Let's add on top of that that we're decoding a 1080p video with 8 buffers pre-allocated with 2Bpp (in YUV422). Which really seems extreme now :)
And we're at 80MB. My guess is that your memory bus is going to be dead before you need to use all that memory.
Maxime
Signature · 10 lines
Maxime Ripard, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180504/dafc7cb2/attachment.sig>
PATCH v2 10/10 ARM: dts: sun8i-a33: Add Video Engine and reserved memory nodes
In reply to Paul KocialkowskiThis adds nodes for the Video Engine and the associated reserved memory for the Allwinner A33. Up to 96 MiB of memory are dedicated to the VPU.
The VPU can only map the first 256 MiB of DRAM, so the reserved memory pool has to be located in that area. Following Allwinner's decision in downstream software, the last 96 MiB of the first 256 MiB of RAM are reserved for this purpose.
--- arch/arm/boot/dts/sun8i-a33.dtsi | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
arch/arm/boot/dts/sun8i-a33.dtsi +38 -0
@@ -181,6 +181,20 @@ reg = <0x40000000 0x80000000>; }; + reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + /* Address must be kept in the lower 256 MiBs of DRAM for VE. */ + ve_memory: cma at 4a000000 { + compatible = "shared-dma-pool"; + reg = <0x4a000000 0x6000000>; + no-map; + linux,cma-default; + }; + }; + sound: sound { compatible = "simple-audio-card"; simple-audio-card,name = "sun8i-a33-audio";
@@ -204,6 +218,11 @@ }; soc at 1c00000 { + syscon: system-controller at 01c00000 { + compatible = "allwinner,sun8i-a33-syscon", "syscon"; + reg = <0x01c00000 0x1000>; + }; + tcon0: lcd-controller at 1c0c000 { compatible = "allwinner,sun8i-a33-tcon"; reg = <0x01c0c000 0x1000>;
@@ -240,6 +259,25 @@ }; }; + ve: video-engine at 01c0e000 { + compatible = "allwinner,sun4i-a10-video-engine"; + memory-region = <&ve_memory>; + syscon = <&syscon>; + + clocks = <&ccu CLK_BUS_VE>, <&ccu CLK_VE>, + <&ccu CLK_DRAM_VE>; + clock-names = "ahb", "mod", "ram"; + + assigned-clocks = <&ccu CLK_VE>; + assigned-clock-rates = <320000000>; + + resets = <&ccu RST_BUS_VE>; + + interrupts = <GIC_SPI 58 IRQ_TYPE_LEVEL_HIGH>; + + reg = <0x01c0e000 0x1000>; + }; + crypto: crypto-engine at 1c15000 { compatible = "allwinner,sun4i-a10-crypto"; reg = <0x01c15000 0x1000>;
Signature · 1 line
2.16.3