linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: venus: add support for selection rectangles
@ 2018-10-09  7:53 Malathi Gottam
  2018-10-16  9:41 ` Stanimir Varbanov
  0 siblings, 1 reply; 6+ messages in thread
From: Malathi Gottam @ 2018-10-09  7:53 UTC (permalink / raw)
  To: stanimir.varbanov, hverkuil, mchehab
  Cc: linux-media, linux-kernel, linux-arm-msm, acourbot, vgarodia, mgottam

Handles target type crop by setting the new active rectangle
to hardware. The new rectangle should be within YUV size.

Signed-off-by: Malathi Gottam <mgottam@codeaurora.org>
---
 drivers/media/platform/qcom/venus/venc.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c
index 3f50cd0..754c19a 100644
--- a/drivers/media/platform/qcom/venus/venc.c
+++ b/drivers/media/platform/qcom/venus/venc.c
@@ -478,16 +478,31 @@ static int venc_g_fmt(struct file *file, void *fh, struct v4l2_format *f)
 venc_s_selection(struct file *file, void *fh, struct v4l2_selection *s)
 {
 	struct venus_inst *inst = to_inst(file);
+	int ret;
+	u32 buftype;
 
 	if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
 		return -EINVAL;
 
 	switch (s->target) {
 	case V4L2_SEL_TGT_CROP:
-		if (s->r.width != inst->out_width ||
-		    s->r.height != inst->out_height ||
+		if (s->r.width > inst->out_width ||
+		    s->r.height > inst->out_height ||
 		    s->r.top != 0 || s->r.left != 0)
 			return -EINVAL;
+		if (s->r.width != inst->width ||
+		    s->r.height != inst->height) {
+			buftype = HFI_BUFFER_OUTPUT;
+			ret = venus_helper_set_output_resolution(inst,
+								 s->r.width,
+								 s->r.height,
+								 buftype);
+			if (ret)
+				return ret;
+
+			inst->width = s->r.width;
+			inst->height = s->r.height;
+		}
 		break;
 	default:
 		return -EINVAL;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] media: venus: add support for selection rectangles
  2018-10-09  7:53 [PATCH] media: venus: add support for selection rectangles Malathi Gottam
@ 2018-10-16  9:41 ` Stanimir Varbanov
  2018-11-01 13:10   ` mgottam
  0 siblings, 1 reply; 6+ messages in thread
From: Stanimir Varbanov @ 2018-10-16  9:41 UTC (permalink / raw)
  To: Malathi Gottam, hverkuil, mchehab
  Cc: linux-media, linux-kernel, linux-arm-msm, acourbot, vgarodia

Hi Malathi,

On 10/09/2018 10:53 AM, Malathi Gottam wrote:
> Handles target type crop by setting the new active rectangle
> to hardware. The new rectangle should be within YUV size.
> 
> Signed-off-by: Malathi Gottam <mgottam@codeaurora.org>
> ---
>  drivers/media/platform/qcom/venus/venc.c | 19 +++++++++++++++++--
>  1 file changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c
> index 3f50cd0..754c19a 100644
> --- a/drivers/media/platform/qcom/venus/venc.c
> +++ b/drivers/media/platform/qcom/venus/venc.c
> @@ -478,16 +478,31 @@ static int venc_g_fmt(struct file *file, void *fh, struct v4l2_format *f)
>  venc_s_selection(struct file *file, void *fh, struct v4l2_selection *s)
>  {
>  	struct venus_inst *inst = to_inst(file);
> +	int ret;
> +	u32 buftype;
>  
>  	if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
>  		return -EINVAL;
>  
>  	switch (s->target) {
>  	case V4L2_SEL_TGT_CROP:
> -		if (s->r.width != inst->out_width ||
> -		    s->r.height != inst->out_height ||
> +		if (s->r.width > inst->out_width ||
> +		    s->r.height > inst->out_height ||
>  		    s->r.top != 0 || s->r.left != 0)
>  			return -EINVAL;
> +		if (s->r.width != inst->width ||
> +		    s->r.height != inst->height) {
> +			buftype = HFI_BUFFER_OUTPUT;
> +			ret = venus_helper_set_output_resolution(inst,
> +								 s->r.width,
> +								 s->r.height,
> +								 buftype);

I'm afraid that set_output_resolution cannot be called at any time. Do
you think we can set it after start_session?

-- 
regards,
Stan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] media: venus: add support for selection rectangles
  2018-10-16  9:41 ` Stanimir Varbanov
@ 2018-11-01 13:10   ` mgottam
  2018-11-01 15:02     ` Stanimir Varbanov
  0 siblings, 1 reply; 6+ messages in thread
From: mgottam @ 2018-11-01 13:10 UTC (permalink / raw)
  To: Stanimir Varbanov
  Cc: hverkuil, mchehab, linux-media, linux-kernel, linux-arm-msm,
	acourbot, vgarodia

On 2018-10-16 15:11, Stanimir Varbanov wrote:
> Hi Malathi,
> 
> On 10/09/2018 10:53 AM, Malathi Gottam wrote:
>> Handles target type crop by setting the new active rectangle
>> to hardware. The new rectangle should be within YUV size.
>> 
>> Signed-off-by: Malathi Gottam <mgottam@codeaurora.org>
>> ---
>>  drivers/media/platform/qcom/venus/venc.c | 19 +++++++++++++++++--
>>  1 file changed, 17 insertions(+), 2 deletions(-)
>> 
>> diff --git a/drivers/media/platform/qcom/venus/venc.c 
>> b/drivers/media/platform/qcom/venus/venc.c
>> index 3f50cd0..754c19a 100644
>> --- a/drivers/media/platform/qcom/venus/venc.c
>> +++ b/drivers/media/platform/qcom/venus/venc.c
>> @@ -478,16 +478,31 @@ static int venc_g_fmt(struct file *file, void 
>> *fh, struct v4l2_format *f)
>>  venc_s_selection(struct file *file, void *fh, struct v4l2_selection 
>> *s)
>>  {
>>  	struct venus_inst *inst = to_inst(file);
>> +	int ret;
>> +	u32 buftype;
>> 
>>  	if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
>>  		return -EINVAL;
>> 
>>  	switch (s->target) {
>>  	case V4L2_SEL_TGT_CROP:
>> -		if (s->r.width != inst->out_width ||
>> -		    s->r.height != inst->out_height ||
>> +		if (s->r.width > inst->out_width ||
>> +		    s->r.height > inst->out_height ||
>>  		    s->r.top != 0 || s->r.left != 0)
>>  			return -EINVAL;
>> +		if (s->r.width != inst->width ||
>> +		    s->r.height != inst->height) {
>> +			buftype = HFI_BUFFER_OUTPUT;
>> +			ret = venus_helper_set_output_resolution(inst,
>> +								 s->r.width,
>> +								 s->r.height,
>> +								 buftype);
> 
> I'm afraid that set_output_resolution cannot be called at any time. Do
> you think we can set it after start_session?

Yes Stan, we can set output_resolution after the session has been 
initialization.
As per the spec, this call s_selection is an optional step under 
Initialization
procedure of encoder even before we request buffers.

So I think setting output resolution in this api shouldn't cause any 
issue once
we are confident on the instance state.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] media: venus: add support for selection rectangles
  2018-11-01 13:10   ` mgottam
@ 2018-11-01 15:02     ` Stanimir Varbanov
  2018-11-02  3:16       ` Tomasz Figa
  0 siblings, 1 reply; 6+ messages in thread
From: Stanimir Varbanov @ 2018-11-01 15:02 UTC (permalink / raw)
  To: mgottam, Stanimir Varbanov
  Cc: hverkuil, mchehab, linux-media, linux-kernel, linux-arm-msm,
	acourbot, vgarodia

Hi Malathi,

On 11/1/18 3:10 PM, mgottam@codeaurora.org wrote:
> On 2018-10-16 15:11, Stanimir Varbanov wrote:
>> Hi Malathi,
>>
>> On 10/09/2018 10:53 AM, Malathi Gottam wrote:
>>> Handles target type crop by setting the new active rectangle
>>> to hardware. The new rectangle should be within YUV size.
>>>
>>> Signed-off-by: Malathi Gottam <mgottam@codeaurora.org>
>>> ---
>>>  drivers/media/platform/qcom/venus/venc.c | 19 +++++++++++++++++--
>>>  1 file changed, 17 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/media/platform/qcom/venus/venc.c
>>> b/drivers/media/platform/qcom/venus/venc.c
>>> index 3f50cd0..754c19a 100644
>>> --- a/drivers/media/platform/qcom/venus/venc.c
>>> +++ b/drivers/media/platform/qcom/venus/venc.c
>>> @@ -478,16 +478,31 @@ static int venc_g_fmt(struct file *file, void
>>> *fh, struct v4l2_format *f)
>>>  venc_s_selection(struct file *file, void *fh, struct v4l2_selection *s)
>>>  {
>>>      struct venus_inst *inst = to_inst(file);
>>> +    int ret;
>>> +    u32 buftype;
>>>
>>>      if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
>>>          return -EINVAL;
>>>
>>>      switch (s->target) {
>>>      case V4L2_SEL_TGT_CROP:
>>> -        if (s->r.width != inst->out_width ||
>>> -            s->r.height != inst->out_height ||
>>> +        if (s->r.width > inst->out_width ||
>>> +            s->r.height > inst->out_height ||
>>>              s->r.top != 0 || s->r.left != 0)
>>>              return -EINVAL;
>>> +        if (s->r.width != inst->width ||
>>> +            s->r.height != inst->height) {
>>> +            buftype = HFI_BUFFER_OUTPUT;
>>> +            ret = venus_helper_set_output_resolution(inst,
>>> +                                 s->r.width,
>>> +                                 s->r.height,
>>> +                                 buftype);
>>
>> I'm afraid that set_output_resolution cannot be called at any time. Do
>> you think we can set it after start_session?
> 
> Yes Stan, we can set output_resolution after the session has been
> initialization.
> As per the spec, this call s_selection is an optional step under
> Initialization
> procedure of encoder even before we request buffers.

What spec you are referring to? The spec for the encoders [1] or
something else.

> 
> So I think setting output resolution in this api shouldn't cause any
> issue once
> we are confident on the instance state.

OK, but I want to test that on v1 and v3 as well (usually the behavior
differs between versions).

-- 
regards,
Stan

[1] https://patchwork.linuxtv.org/patch/52624/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] media: venus: add support for selection rectangles
  2018-11-01 15:02     ` Stanimir Varbanov
@ 2018-11-02  3:16       ` Tomasz Figa
  2018-11-09  7:38         ` mgottam
  0 siblings, 1 reply; 6+ messages in thread
From: Tomasz Figa @ 2018-11-02  3:16 UTC (permalink / raw)
  To: Stanimir Varbanov
  Cc: mgottam, Hans Verkuil, Mauro Carvalho Chehab,
	Linux Media Mailing List, Linux Kernel Mailing List,
	linux-arm-msm, Alexandre Courbot, vgarodia

On Fri, Nov 2, 2018 at 12:02 AM Stanimir Varbanov
<stanimir.varbanov@linaro.org> wrote:
>
> Hi Malathi,
>
> On 11/1/18 3:10 PM, mgottam@codeaurora.org wrote:
> > On 2018-10-16 15:11, Stanimir Varbanov wrote:
> >> Hi Malathi,
> >>
> >> On 10/09/2018 10:53 AM, Malathi Gottam wrote:
> >>> Handles target type crop by setting the new active rectangle
> >>> to hardware. The new rectangle should be within YUV size.
> >>>
> >>> Signed-off-by: Malathi Gottam <mgottam@codeaurora.org>
> >>> ---
> >>>  drivers/media/platform/qcom/venus/venc.c | 19 +++++++++++++++++--
> >>>  1 file changed, 17 insertions(+), 2 deletions(-)
> >>>
> >>> diff --git a/drivers/media/platform/qcom/venus/venc.c
> >>> b/drivers/media/platform/qcom/venus/venc.c
> >>> index 3f50cd0..754c19a 100644
> >>> --- a/drivers/media/platform/qcom/venus/venc.c
> >>> +++ b/drivers/media/platform/qcom/venus/venc.c
> >>> @@ -478,16 +478,31 @@ static int venc_g_fmt(struct file *file, void
> >>> *fh, struct v4l2_format *f)
> >>>  venc_s_selection(struct file *file, void *fh, struct v4l2_selection *s)
> >>>  {
> >>>      struct venus_inst *inst = to_inst(file);
> >>> +    int ret;
> >>> +    u32 buftype;
> >>>
> >>>      if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
> >>>          return -EINVAL;
> >>>
> >>>      switch (s->target) {
> >>>      case V4L2_SEL_TGT_CROP:
> >>> -        if (s->r.width != inst->out_width ||
> >>> -            s->r.height != inst->out_height ||
> >>> +        if (s->r.width > inst->out_width ||
> >>> +            s->r.height > inst->out_height ||
> >>>              s->r.top != 0 || s->r.left != 0)
> >>>              return -EINVAL;

Note that returning -EINVAL is not what VIDIOC_S_SELECTION should do here.

As per the general V4L2 spec [1], VIDIOC_S_SELECTION is expected to
adjust the crop rectangle "as close as possible to the requested one".
In this case that would likely mean something like this:

if (s->r.left != 0) {
    s->r.width += s->r.left;
    s->r.left = 0;
}

if (s->r.top != 0) {
    s->r.height += s->r.top;
    s->r.top = 0;
}

if (s->r.width > inst->out_width)
    s->r.width = inst->out_width;

if (s->r.height > inst->out_height)
    s->r.height = inst->out_height;

[1] https://www.kernel.org/doc/html/latest/media/uapi/v4l/vidioc-g-selection.html

> >>> +        if (s->r.width != inst->width ||
> >>> +            s->r.height != inst->height) {
> >>> +            buftype = HFI_BUFFER_OUTPUT;
> >>> +            ret = venus_helper_set_output_resolution(inst,
> >>> +                                 s->r.width,
> >>> +                                 s->r.height,
> >>> +                                 buftype);
> >>
> >> I'm afraid that set_output_resolution cannot be called at any time. Do
> >> you think we can set it after start_session?
> >
> > Yes Stan, we can set output_resolution after the session has been
> > initialization.
> > As per the spec, this call s_selection is an optional step under
> > Initialization
> > procedure of encoder even before we request buffers.
>
> What spec you are referring to? The spec for the encoders [1] or
> something else.

For our convenience, Hans was nice enough to host a compiled version at:
https://hverkuil.home.xs4all.nl/request-api/uapi/v4l/dev-encoder.html

Best regards,
Tomasz

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] media: venus: add support for selection rectangles
  2018-11-02  3:16       ` Tomasz Figa
@ 2018-11-09  7:38         ` mgottam
  0 siblings, 0 replies; 6+ messages in thread
From: mgottam @ 2018-11-09  7:38 UTC (permalink / raw)
  To: Tomasz Figa
  Cc: Stanimir Varbanov, Hans Verkuil, Mauro Carvalho Chehab,
	Linux Media Mailing List, Linux Kernel Mailing List,
	linux-arm-msm, Alexandre Courbot, vgarodia

On 2018-11-02 03:16, Tomasz Figa wrote:
> On Fri, Nov 2, 2018 at 12:02 AM Stanimir Varbanov
> <stanimir.varbanov@linaro.org> wrote:
>> 
>> Hi Malathi,
>> 
>> On 11/1/18 3:10 PM, mgottam@codeaurora.org wrote:
>> > On 2018-10-16 15:11, Stanimir Varbanov wrote:
>> >> Hi Malathi,
>> >>
>> >> On 10/09/2018 10:53 AM, Malathi Gottam wrote:
>> >>> Handles target type crop by setting the new active rectangle
>> >>> to hardware. The new rectangle should be within YUV size.
>> >>>
>> >>> Signed-off-by: Malathi Gottam <mgottam@codeaurora.org>
>> >>> ---
>> >>>  drivers/media/platform/qcom/venus/venc.c | 19 +++++++++++++++++--
>> >>>  1 file changed, 17 insertions(+), 2 deletions(-)
>> >>>
>> >>> diff --git a/drivers/media/platform/qcom/venus/venc.c
>> >>> b/drivers/media/platform/qcom/venus/venc.c
>> >>> index 3f50cd0..754c19a 100644
>> >>> --- a/drivers/media/platform/qcom/venus/venc.c
>> >>> +++ b/drivers/media/platform/qcom/venus/venc.c
>> >>> @@ -478,16 +478,31 @@ static int venc_g_fmt(struct file *file, void
>> >>> *fh, struct v4l2_format *f)
>> >>>  venc_s_selection(struct file *file, void *fh, struct v4l2_selection *s)
>> >>>  {
>> >>>      struct venus_inst *inst = to_inst(file);
>> >>> +    int ret;
>> >>> +    u32 buftype;
>> >>>
>> >>>      if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
>> >>>          return -EINVAL;
>> >>>
>> >>>      switch (s->target) {
>> >>>      case V4L2_SEL_TGT_CROP:
>> >>> -        if (s->r.width != inst->out_width ||
>> >>> -            s->r.height != inst->out_height ||
>> >>> +        if (s->r.width > inst->out_width ||
>> >>> +            s->r.height > inst->out_height ||
>> >>>              s->r.top != 0 || s->r.left != 0)
>> >>>              return -EINVAL;
> 
> Note that returning -EINVAL is not what VIDIOC_S_SELECTION should do 
> here.
> 
> As per the general V4L2 spec [1], VIDIOC_S_SELECTION is expected to
> adjust the crop rectangle "as close as possible to the requested one".
> In this case that would likely mean something like this:
> 
> if (s->r.left != 0) {
>     s->r.width += s->r.left;
>     s->r.left = 0;
> }
> 
> if (s->r.top != 0) {
>     s->r.height += s->r.top;
>     s->r.top = 0;
> }
> 
> if (s->r.width > inst->out_width)
>     s->r.width = inst->out_width;
> 
> if (s->r.height > inst->out_height)
>     s->r.height = inst->out_height;
> 
> [1]
> https://www.kernel.org/doc/html/latest/media/uapi/v4l/vidioc-g-selection.html
> 

Yes Tomasz, I overlooked the spec that we cannot return EINVAL in this 
case.

I will make the necessary changes and update the new patch.
>> >>> +        if (s->r.width != inst->width ||
>> >>> +            s->r.height != inst->height) {
>> >>> +            buftype = HFI_BUFFER_OUTPUT;
>> >>> +            ret = venus_helper_set_output_resolution(inst,
>> >>> +                                 s->r.width,
>> >>> +                                 s->r.height,
>> >>> +                                 buftype);
>> >>
>> >> I'm afraid that set_output_resolution cannot be called at any time. Do
>> >> you think we can set it after start_session?
>> >
>> > Yes Stan, we can set output_resolution after the session has been
>> > initialization.
>> > As per the spec, this call s_selection is an optional step under
>> > Initialization
>> > procedure of encoder even before we request buffers.

Setting this output resolution here I feel it as a repetition as we
have this width and height set to firmware as a part of 
VIDIOC_REQBUFS().
So updating the selection rectangle would be sufficient in this case.

>> 
>> What spec you are referring to? The spec for the encoders [1] or
>> something else.
> 
> For our convenience, Hans was nice enough to host a compiled version 
> at:
> https://hverkuil.home.xs4all.nl/request-api/uapi/v4l/dev-encoder.html
> 
> Best regards,
> Tomasz

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-11-09  7:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-09  7:53 [PATCH] media: venus: add support for selection rectangles Malathi Gottam
2018-10-16  9:41 ` Stanimir Varbanov
2018-11-01 13:10   ` mgottam
2018-11-01 15:02     ` Stanimir Varbanov
2018-11-02  3:16       ` Tomasz Figa
2018-11-09  7:38         ` mgottam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).