summaryrefslogtreecommitdiff
path: root/src/cam/kms_sink.cpp
AgeCommit message (Collapse)Author
2022-09-30cam: kms_sink: Add color space supportLaurent Pinchart
KMS defines YCbCr encoding and quantization properties for planes. When supported by the device, set them to match the color space of the stream to render colors accurately. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Eric Curtin <ecurtin@redhat.com>
2022-08-09cam: kms_sink: Scale the frame buffer to full screen if supportedLaurent Pinchart
The KMS sink currently displays the frame buffer on the top-left corner of the screen, resulting in either a black area on the bottom and right sides (if the frame buffer is smaller than the display resolution) of in a restricted field of view (if the frame buffer is larger than the display resolution). Improve this by scaling the frame buffer to full screen if supported, and aligning the crop rectangle to the frame buffer center if the field of view needs to be restricted. The implementation test for possible composition options, from best to worst. The tests are performed when the camera is started, as testing atomic commits requires access to frame buffer objects, which are not available at configure time. Changing this would require either a large refactoring of the cam application to provide frame buffers earlier, or extending the KMS API to support testing commits with dummy buffer objects. Both are candidates for later development. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Eric Curtin <ecurtin@redhat.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-08-09cam: kms_sink: Make lifetime management of DRM request saferLaurent Pinchart
The drmRequest is KMSSink::processRequest() is created as a naked pointer, passed to the constructor of the KMSSink::Request object that stores it in a std::unique_ptr<>, and used later in the function. The current implementation is safe, but could be prone to both memory leaks and use-after-free bugs if modified. Improve it by replacing the naked pointer with a std::unique_ptr<>. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Eric Curtin <ecurtin@redhat.com> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-06-20cam: kms_sink: Remove limitation that camera and display must matchEric Curtin
There is a limitation that requires input and output to be pixel for pixel identical in terms of height and width. Remove this limitation to enable more hardware that doesn't match. Just start drawing from top left 0, 0 corner. Signed-off-by: Eric Curtin <ecurtin@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Eric Curtin <ecurtin@redhat.com>
2022-05-04libcamera: Replace toString with operator<<() for format classesLaurent Pinchart
Now that format classes implement the stream formatting operator<<(), use it instead of the toString() function. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-05-04libcamera: Replace toString with operator<<() for geometry classesLaurent Pinchart
Now that geometry classes implement the stream formatting operator<<(), use it instead of the toString() function. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-02-08cam: kms_sink: Use the first suitable pipeline foundEric Curtin
When searching for a suitable pipeline, we mistakenly only break from the inner loop. This results in the last suitable output being selected. Pick the first one instead. Fixes: 1de0f90dd432 ("cam: kms_sink: Print display pipelineconfiguration") Signed-off-by: Eric Curtin <ecurtin@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-10-05cam: kms_sink: Print display pipeline configurationLaurent Pinchart
It can be useful, for diagnosis purpose, to know what plane and CRTC the KMS sink auto-selects. Print the display pipeline configuration at start time. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2021-09-07cam: drm: Support per-plane stride valuesLaurent Pinchart
The stride is not always identical for all planes for multi-planar formats. Semi-planar YUV formats without horizontal subsampling often have a chroma stride equal to twice the luma stride, and tri-planar YUV formats with a 1/2 horizontal subsampling often have a chroma stride equal to half the luma stride. This isn't correctly taken into account when creating a DRM frame buffer, as the same stride is set for all planes. libcamera doesn't report per-plane stride values yet, but uses chroma strides that match the above description for all currently supported platforms. Calculation the chrome strides appropriately in the KMSSink class, and pass them to DRM::createFrameBuffer(). Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-08-05cam: kms_sink: Enable display on first frameLaurent Pinchart
Not all display controllers support enabling the display without any active plane. Delay display enabling to the first frame. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-08-05cam: Add KMS sink classLaurent Pinchart
Add a KMSSink class to display framebuffers through the DRM/KMS API. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>