[libcamera-devel,13/14] py: cam_kms: support multiplanar formats
diff mbox series

Message ID 20220516141022.96327-14-tomi.valkeinen@ideasonboard.com
State Superseded
Headers show
Series
  • Misc Python bindings patches
Related show

Commit Message

Tomi Valkeinen May 16, 2022, 2:10 p.m. UTC
Support multiplanar formats in the kms renderer. Tested with RPi and
NV12.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
 src/py/cam/cam_kms.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Comments

Laurent Pinchart May 17, 2022, 8:41 a.m. UTC | #1
Hi Tomi,

Thank you for the patch.

On Mon, May 16, 2022 at 05:10:21PM +0300, Tomi Valkeinen wrote:
> Support multiplanar formats in the kms renderer. Tested with RPi and
> NV12.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  src/py/cam/cam_kms.py | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/src/py/cam/cam_kms.py b/src/py/cam/cam_kms.py
> index da3dd4e0..90aac5f6 100644
> --- a/src/py/cam/cam_kms.py
> +++ b/src/py/cam/cam_kms.py
> @@ -127,10 +127,16 @@ class KMSRenderer:
>                  for fb in ctx['allocator'].buffers(stream):
>                      w = cfg.size.width
>                      h = cfg.size.height
> -                    stride = cfg.stride
> -                    fd = fb.fd(0)
> +                    fds = []
> +                    strides = []
> +                    offsets = []
> +                    for i in range(fb.num_planes):
> +                        fds.append(fb.fd(i))
> +                        strides.append(cfg.stride)
> +                        offsets.append(fb.offset(i))
> +
>                      drmfb = pykms.DmabufFramebuffer(self.card, w, h, fmt,
> -                                                    [fd], [stride], [0])
> +                                                    fds, strides, offsets)
>                      self.cam_2_drm[fb] = drmfb
>  
>                  idx += 1

Patch
diff mbox series

diff --git a/src/py/cam/cam_kms.py b/src/py/cam/cam_kms.py
index da3dd4e0..90aac5f6 100644
--- a/src/py/cam/cam_kms.py
+++ b/src/py/cam/cam_kms.py
@@ -127,10 +127,16 @@  class KMSRenderer:
                 for fb in ctx['allocator'].buffers(stream):
                     w = cfg.size.width
                     h = cfg.size.height
-                    stride = cfg.stride
-                    fd = fb.fd(0)
+                    fds = []
+                    strides = []
+                    offsets = []
+                    for i in range(fb.num_planes):
+                        fds.append(fb.fd(i))
+                        strides.append(cfg.stride)
+                        offsets.append(fb.offset(i))
+
                     drmfb = pykms.DmabufFramebuffer(self.card, w, h, fmt,
-                                                    [fd], [stride], [0])
+                                                    fds, strides, offsets)
                     self.cam_2_drm[fb] = drmfb
 
                 idx += 1