[libcamera-devel,2/3] apps: cam: kms_sink: Drop unique_ptr<> from DRM::AtomicRequest
diff mbox series

Message ID 20230423203931.108022-3-umang.jain@ideasonboard.com
State Accepted
Headers show
Series
  • apps: cam: kms: Introduce requests tracking queue
Related show

Commit Message

Umang Jain April 23, 2023, 8:39 p.m. UTC
There is no need to wrap DRM::AtomicRequest in std::unique_ptr<>
in KMSSink::start(). Remove it so that the syntax becomes similar to
what we have in KMSSink::stop().

No functional changes intended.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
---
 src/apps/cam/kms_sink.cpp | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Comments

Laurent Pinchart April 24, 2023, 12:58 a.m. UTC | #1
Hi Umang,

Thank you for the patch.

On Mon, Apr 24, 2023 at 02:09:30AM +0530, Umang Jain via libcamera-devel wrote:
> There is no need to wrap DRM::AtomicRequest in std::unique_ptr<>
> in KMSSink::start(). Remove it so that the syntax becomes similar to
> what we have in KMSSink::stop().
> 
> No functional changes intended.
> 
> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
> ---
>  src/apps/cam/kms_sink.cpp | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/src/apps/cam/kms_sink.cpp b/src/apps/cam/kms_sink.cpp
> index a508977d..2aefec06 100644
> --- a/src/apps/cam/kms_sink.cpp
> +++ b/src/apps/cam/kms_sink.cpp
> @@ -302,24 +302,22 @@ int KMSSink::configurePipeline(const libcamera::PixelFormat &format)
>  
>  int KMSSink::start()
>  {
> -	std::unique_ptr<DRM::AtomicRequest> request;
> +	DRM::AtomicRequest request(&dev_);

While at it, I would move this..

>  
>  	int ret = FrameSink::start();
>  	if (ret < 0)
>  		return ret;
>  
>  	/* Disable all CRTCs and planes to start from a known valid state. */
> -	request = std::make_unique<DRM::AtomicRequest>(&dev_);

... here.

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

> -
>  	for (const DRM::Crtc &crtc : dev_.crtcs())
> -		request->addProperty(&crtc, "ACTIVE", 0);
> +		request.addProperty(&crtc, "ACTIVE", 0);
>  
>  	for (const DRM::Plane &plane : dev_.planes()) {
> -		request->addProperty(&plane, "CRTC_ID", 0);
> -		request->addProperty(&plane, "FB_ID", 0);
> +		request.addProperty(&plane, "CRTC_ID", 0);
> +		request.addProperty(&plane, "FB_ID", 0);
>  	}
>  
> -	ret = request->commit(DRM::AtomicRequest::FlagAllowModeset);
> +	ret = request.commit(DRM::AtomicRequest::FlagAllowModeset);
>  	if (ret < 0) {
>  		std::cerr
>  			<< "Failed to disable CRTCs and planes: "
Kieran Bingham April 24, 2023, 9:21 a.m. UTC | #2
Quoting Laurent Pinchart via libcamera-devel (2023-04-24 01:58:22)
> Hi Umang,
> 
> Thank you for the patch.
> 
> On Mon, Apr 24, 2023 at 02:09:30AM +0530, Umang Jain via libcamera-devel wrote:
> > There is no need to wrap DRM::AtomicRequest in std::unique_ptr<>
> > in KMSSink::start(). Remove it so that the syntax becomes similar to
> > what we have in KMSSink::stop().
> > 
> > No functional changes intended.
> > 
> > Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
> > ---
> >  src/apps/cam/kms_sink.cpp | 12 +++++-------
> >  1 file changed, 5 insertions(+), 7 deletions(-)
> > 
> > diff --git a/src/apps/cam/kms_sink.cpp b/src/apps/cam/kms_sink.cpp
> > index a508977d..2aefec06 100644
> > --- a/src/apps/cam/kms_sink.cpp
> > +++ b/src/apps/cam/kms_sink.cpp
> > @@ -302,24 +302,22 @@ int KMSSink::configurePipeline(const libcamera::PixelFormat &format)
> >  
> >  int KMSSink::start()
> >  {
> > -     std::unique_ptr<DRM::AtomicRequest> request;
> > +     DRM::AtomicRequest request(&dev_);
> 
> While at it, I would move this..
> 
> >  
> >       int ret = FrameSink::start();
> >       if (ret < 0)
> >               return ret;
> >  
> >       /* Disable all CRTCs and planes to start from a known valid state. */
> > -     request = std::make_unique<DRM::AtomicRequest>(&dev_);
> 
> ... here.
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>


Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

It looks like this patch could be merged independently too.

--
Kieran



> 
> > -
> >       for (const DRM::Crtc &crtc : dev_.crtcs())
> > -             request->addProperty(&crtc, "ACTIVE", 0);
> > +             request.addProperty(&crtc, "ACTIVE", 0);
> >  
> >       for (const DRM::Plane &plane : dev_.planes()) {
> > -             request->addProperty(&plane, "CRTC_ID", 0);
> > -             request->addProperty(&plane, "FB_ID", 0);
> > +             request.addProperty(&plane, "CRTC_ID", 0);
> > +             request.addProperty(&plane, "FB_ID", 0);
> >       }
> >  
> > -     ret = request->commit(DRM::AtomicRequest::FlagAllowModeset);
> > +     ret = request.commit(DRM::AtomicRequest::FlagAllowModeset);
> >       if (ret < 0) {
> >               std::cerr
> >                       << "Failed to disable CRTCs and planes: "
> 
> -- 
> Regards,
> 
> Laurent Pinchart

Patch
diff mbox series

diff --git a/src/apps/cam/kms_sink.cpp b/src/apps/cam/kms_sink.cpp
index a508977d..2aefec06 100644
--- a/src/apps/cam/kms_sink.cpp
+++ b/src/apps/cam/kms_sink.cpp
@@ -302,24 +302,22 @@  int KMSSink::configurePipeline(const libcamera::PixelFormat &format)
 
 int KMSSink::start()
 {
-	std::unique_ptr<DRM::AtomicRequest> request;
+	DRM::AtomicRequest request(&dev_);
 
 	int ret = FrameSink::start();
 	if (ret < 0)
 		return ret;
 
 	/* Disable all CRTCs and planes to start from a known valid state. */
-	request = std::make_unique<DRM::AtomicRequest>(&dev_);
-
 	for (const DRM::Crtc &crtc : dev_.crtcs())
-		request->addProperty(&crtc, "ACTIVE", 0);
+		request.addProperty(&crtc, "ACTIVE", 0);
 
 	for (const DRM::Plane &plane : dev_.planes()) {
-		request->addProperty(&plane, "CRTC_ID", 0);
-		request->addProperty(&plane, "FB_ID", 0);
+		request.addProperty(&plane, "CRTC_ID", 0);
+		request.addProperty(&plane, "FB_ID", 0);
 	}
 
-	ret = request->commit(DRM::AtomicRequest::FlagAllowModeset);
+	ret = request.commit(DRM::AtomicRequest::FlagAllowModeset);
 	if (ret < 0) {
 		std::cerr
 			<< "Failed to disable CRTCs and planes: "