Re: [PATCH v2 3/8] media: vidc: decoder: add video decoder files

2016-11-03 Thread Stanimir Varbanov
Hi,

On 11/03/2016 12:55 PM, Hans Verkuil wrote:
> On 03/11/16 11:45, Stanimir Varbanov wrote:
>> Hi Hans,
>>
>> On 09/19/2016 01:04 PM, Hans Verkuil wrote:
>>> On 09/07/2016 01:37 PM, Stanimir Varbanov wrote:
 This consists of video decoder implementation plus decoder
 controls.

 Signed-off-by: Stanimir Varbanov 
 ---
  drivers/media/platform/qcom/vidc/vdec.c   | 1091
 +
  drivers/media/platform/qcom/vidc/vdec.h   |   29 +
  drivers/media/platform/qcom/vidc/vdec_ctrls.c |  200 +
  drivers/media/platform/qcom/vidc/vdec_ctrls.h |   21 +
  4 files changed, 1341 insertions(+)
  create mode 100644 drivers/media/platform/qcom/vidc/vdec.c
  create mode 100644 drivers/media/platform/qcom/vidc/vdec.h
  create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.c
  create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.h

>>
>> 
>>
 +
 +static int
 +vdec_g_selection(struct file *file, void *priv, struct
 v4l2_selection *s)
 +{
 +struct vidc_inst *inst = to_inst(file);
 +
 +if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
 +return -EINVAL;
 +
 +switch (s->target) {
 +case V4L2_SEL_TGT_CROP_DEFAULT:
 +case V4L2_SEL_TGT_CROP_BOUNDS:
 +case V4L2_SEL_TGT_CROP:
 +case V4L2_SEL_TGT_COMPOSE_DEFAULT:
 +case V4L2_SEL_TGT_COMPOSE_BOUNDS:
 +case V4L2_SEL_TGT_COMPOSE:
>>>
>>> This is almost certainly wrong.
>>>
>>> For capture I would expect that you can do compose, but not crop.
>>>
>>> This would likely explain that v4l2-compliance thinks that the driver
>>> can
>>> scale:
>>>
>>> test Scaling: OK
>>>
>>
>> Maybe I need some help to implement correctly g_selection.
>>
>> Lets say that the resolution of the compressed stream is 1280x720, and
>> that resolution is set with s_fmt(OUTPUT queue), then I calculate the
>> output resolution which I will return by g_fmt(CAPTURE queue) and it
>> will be 1280x736 (hardware wants height to be multiple of 32 lines). So
>> the result will be 16 lines of vertical padding which should be exposed
>> to client (think of gstreamer v4l2videodec element) via g_crop
>> (g_selection) as 1280x720 because this is the actual image.
>>
>> So from what I understood while read Selection API, I need to support
>> only composing on CAPTURE queue, no scaling and no cropping.
>>
>> OUTPUT buffer type, data source
>> TGT_CROP_BOUNDS = TGT_CROP_DEFAULT = TGT_CROP = 1280x720
>> TGT_COMPOSE_BOUNDS = TGT_COMPOSE_DEFAULT = TGT_COMPOSE = 1280x720
> 
> The output buffer type doesn't do composition, only crop. So you shouldn't
> support the compose targets.

OK I tried to return EINVAL for compose targets for output buffer type
and the result is :

test Cropping: OK
test Composing: OK
test Scaling: OK

Which is odd because now Scaling is supported.

> 
>>
>> CAPTURE buffer type, data sink
>> TGT_CROP_BOUNDS = TGT_CROP_DEFAULT = TGT_CROP = EINVAL
>> TGT_COMPOSE_BOUNDS = 1280x736
>> TGT_COMPOSE_DEFAULT = TGT_COMPOSE = 1280x720
> 
> This looks good.
> 
>>
>> With this logic in g_selection the output of v4l2-compliance test
>> application is:
>> test Cropping: OK
>> test Composing: OK
>> test Scaling: OK (Not Supported)
>>
>> So why v4l2-compliance still thinks that the driver supports Cropping?
> 
> Hmm, v4l2-compliance could be improved. The problem is that it doesn't
> show for m2m devices for which side (capture or output) cropping, composing
> or scaling is supported. It does test both sides, but you can't tell from
> the output.
> 
> It's a bit confusing in this case.

OK I will incorporate the above g_selection behavior and send a new
version of the patches, I do not waste time on that. The drawback is
that this padding will be displayed as green bar on bottom of the
displayed image, although the gstreamer master branch now use
g_selection so probably it should be fine there.

> 
> Regards,
> 
> Hans
> 
>>
 +break;
 +default:
 +return -EINVAL;
 +}
 +
 +s->r.top = 0;
 +s->r.left = 0;
 +s->r.width = inst->out_width;
 +s->r.height = inst->out_height;
 +
 +return 0;
 +}
>>
>> 
>>

-- 
regards,
Stan


Re: [PATCH v2 3/8] media: vidc: decoder: add video decoder files

2016-11-03 Thread Stanimir Varbanov
Hi,

On 11/03/2016 12:55 PM, Hans Verkuil wrote:
> On 03/11/16 11:45, Stanimir Varbanov wrote:
>> Hi Hans,
>>
>> On 09/19/2016 01:04 PM, Hans Verkuil wrote:
>>> On 09/07/2016 01:37 PM, Stanimir Varbanov wrote:
 This consists of video decoder implementation plus decoder
 controls.

 Signed-off-by: Stanimir Varbanov 
 ---
  drivers/media/platform/qcom/vidc/vdec.c   | 1091
 +
  drivers/media/platform/qcom/vidc/vdec.h   |   29 +
  drivers/media/platform/qcom/vidc/vdec_ctrls.c |  200 +
  drivers/media/platform/qcom/vidc/vdec_ctrls.h |   21 +
  4 files changed, 1341 insertions(+)
  create mode 100644 drivers/media/platform/qcom/vidc/vdec.c
  create mode 100644 drivers/media/platform/qcom/vidc/vdec.h
  create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.c
  create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.h

>>
>> 
>>
 +
 +static int
 +vdec_g_selection(struct file *file, void *priv, struct
 v4l2_selection *s)
 +{
 +struct vidc_inst *inst = to_inst(file);
 +
 +if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
 +return -EINVAL;
 +
 +switch (s->target) {
 +case V4L2_SEL_TGT_CROP_DEFAULT:
 +case V4L2_SEL_TGT_CROP_BOUNDS:
 +case V4L2_SEL_TGT_CROP:
 +case V4L2_SEL_TGT_COMPOSE_DEFAULT:
 +case V4L2_SEL_TGT_COMPOSE_BOUNDS:
 +case V4L2_SEL_TGT_COMPOSE:
>>>
>>> This is almost certainly wrong.
>>>
>>> For capture I would expect that you can do compose, but not crop.
>>>
>>> This would likely explain that v4l2-compliance thinks that the driver
>>> can
>>> scale:
>>>
>>> test Scaling: OK
>>>
>>
>> Maybe I need some help to implement correctly g_selection.
>>
>> Lets say that the resolution of the compressed stream is 1280x720, and
>> that resolution is set with s_fmt(OUTPUT queue), then I calculate the
>> output resolution which I will return by g_fmt(CAPTURE queue) and it
>> will be 1280x736 (hardware wants height to be multiple of 32 lines). So
>> the result will be 16 lines of vertical padding which should be exposed
>> to client (think of gstreamer v4l2videodec element) via g_crop
>> (g_selection) as 1280x720 because this is the actual image.
>>
>> So from what I understood while read Selection API, I need to support
>> only composing on CAPTURE queue, no scaling and no cropping.
>>
>> OUTPUT buffer type, data source
>> TGT_CROP_BOUNDS = TGT_CROP_DEFAULT = TGT_CROP = 1280x720
>> TGT_COMPOSE_BOUNDS = TGT_COMPOSE_DEFAULT = TGT_COMPOSE = 1280x720
> 
> The output buffer type doesn't do composition, only crop. So you shouldn't
> support the compose targets.

OK I tried to return EINVAL for compose targets for output buffer type
and the result is :

test Cropping: OK
test Composing: OK
test Scaling: OK

Which is odd because now Scaling is supported.

> 
>>
>> CAPTURE buffer type, data sink
>> TGT_CROP_BOUNDS = TGT_CROP_DEFAULT = TGT_CROP = EINVAL
>> TGT_COMPOSE_BOUNDS = 1280x736
>> TGT_COMPOSE_DEFAULT = TGT_COMPOSE = 1280x720
> 
> This looks good.
> 
>>
>> With this logic in g_selection the output of v4l2-compliance test
>> application is:
>> test Cropping: OK
>> test Composing: OK
>> test Scaling: OK (Not Supported)
>>
>> So why v4l2-compliance still thinks that the driver supports Cropping?
> 
> Hmm, v4l2-compliance could be improved. The problem is that it doesn't
> show for m2m devices for which side (capture or output) cropping, composing
> or scaling is supported. It does test both sides, but you can't tell from
> the output.
> 
> It's a bit confusing in this case.

OK I will incorporate the above g_selection behavior and send a new
version of the patches, I do not waste time on that. The drawback is
that this padding will be displayed as green bar on bottom of the
displayed image, although the gstreamer master branch now use
g_selection so probably it should be fine there.

> 
> Regards,
> 
> Hans
> 
>>
 +break;
 +default:
 +return -EINVAL;
 +}
 +
 +s->r.top = 0;
 +s->r.left = 0;
 +s->r.width = inst->out_width;
 +s->r.height = inst->out_height;
 +
 +return 0;
 +}
>>
>> 
>>

-- 
regards,
Stan


Re: [PATCH v2 3/8] media: vidc: decoder: add video decoder files

2016-11-03 Thread Hans Verkuil

On 03/11/16 11:45, Stanimir Varbanov wrote:

Hi Hans,

On 09/19/2016 01:04 PM, Hans Verkuil wrote:

On 09/07/2016 01:37 PM, Stanimir Varbanov wrote:

This consists of video decoder implementation plus decoder
controls.

Signed-off-by: Stanimir Varbanov 
---
 drivers/media/platform/qcom/vidc/vdec.c   | 1091 +
 drivers/media/platform/qcom/vidc/vdec.h   |   29 +
 drivers/media/platform/qcom/vidc/vdec_ctrls.c |  200 +
 drivers/media/platform/qcom/vidc/vdec_ctrls.h |   21 +
 4 files changed, 1341 insertions(+)
 create mode 100644 drivers/media/platform/qcom/vidc/vdec.c
 create mode 100644 drivers/media/platform/qcom/vidc/vdec.h
 create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.c
 create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.h






+
+static int
+vdec_g_selection(struct file *file, void *priv, struct v4l2_selection *s)
+{
+   struct vidc_inst *inst = to_inst(file);
+
+   if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
+   return -EINVAL;
+
+   switch (s->target) {
+   case V4L2_SEL_TGT_CROP_DEFAULT:
+   case V4L2_SEL_TGT_CROP_BOUNDS:
+   case V4L2_SEL_TGT_CROP:
+   case V4L2_SEL_TGT_COMPOSE_DEFAULT:
+   case V4L2_SEL_TGT_COMPOSE_BOUNDS:
+   case V4L2_SEL_TGT_COMPOSE:


This is almost certainly wrong.

For capture I would expect that you can do compose, but not crop.

This would likely explain that v4l2-compliance thinks that the driver can
scale:

test Scaling: OK



Maybe I need some help to implement correctly g_selection.

Lets say that the resolution of the compressed stream is 1280x720, and
that resolution is set with s_fmt(OUTPUT queue), then I calculate the
output resolution which I will return by g_fmt(CAPTURE queue) and it
will be 1280x736 (hardware wants height to be multiple of 32 lines). So
the result will be 16 lines of vertical padding which should be exposed
to client (think of gstreamer v4l2videodec element) via g_crop
(g_selection) as 1280x720 because this is the actual image.

So from what I understood while read Selection API, I need to support
only composing on CAPTURE queue, no scaling and no cropping.

OUTPUT buffer type, data source
TGT_CROP_BOUNDS = TGT_CROP_DEFAULT = TGT_CROP = 1280x720
TGT_COMPOSE_BOUNDS = TGT_COMPOSE_DEFAULT = TGT_COMPOSE = 1280x720


The output buffer type doesn't do composition, only crop. So you shouldn't
support the compose targets.



CAPTURE buffer type, data sink
TGT_CROP_BOUNDS = TGT_CROP_DEFAULT = TGT_CROP = EINVAL
TGT_COMPOSE_BOUNDS = 1280x736
TGT_COMPOSE_DEFAULT = TGT_COMPOSE = 1280x720


This looks good.



With this logic in g_selection the output of v4l2-compliance test
application is:
test Cropping: OK
test Composing: OK
test Scaling: OK (Not Supported)

So why v4l2-compliance still thinks that the driver supports Cropping?


Hmm, v4l2-compliance could be improved. The problem is that it doesn't
show for m2m devices for which side (capture or output) cropping, composing
or scaling is supported. It does test both sides, but you can't tell from
the output.

It's a bit confusing in this case.

Regards,

Hans




+   break;
+   default:
+   return -EINVAL;
+   }
+
+   s->r.top = 0;
+   s->r.left = 0;
+   s->r.width = inst->out_width;
+   s->r.height = inst->out_height;
+
+   return 0;
+}






Re: [PATCH v2 3/8] media: vidc: decoder: add video decoder files

2016-11-03 Thread Hans Verkuil

On 03/11/16 11:45, Stanimir Varbanov wrote:

Hi Hans,

On 09/19/2016 01:04 PM, Hans Verkuil wrote:

On 09/07/2016 01:37 PM, Stanimir Varbanov wrote:

This consists of video decoder implementation plus decoder
controls.

Signed-off-by: Stanimir Varbanov 
---
 drivers/media/platform/qcom/vidc/vdec.c   | 1091 +
 drivers/media/platform/qcom/vidc/vdec.h   |   29 +
 drivers/media/platform/qcom/vidc/vdec_ctrls.c |  200 +
 drivers/media/platform/qcom/vidc/vdec_ctrls.h |   21 +
 4 files changed, 1341 insertions(+)
 create mode 100644 drivers/media/platform/qcom/vidc/vdec.c
 create mode 100644 drivers/media/platform/qcom/vidc/vdec.h
 create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.c
 create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.h






+
+static int
+vdec_g_selection(struct file *file, void *priv, struct v4l2_selection *s)
+{
+   struct vidc_inst *inst = to_inst(file);
+
+   if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
+   return -EINVAL;
+
+   switch (s->target) {
+   case V4L2_SEL_TGT_CROP_DEFAULT:
+   case V4L2_SEL_TGT_CROP_BOUNDS:
+   case V4L2_SEL_TGT_CROP:
+   case V4L2_SEL_TGT_COMPOSE_DEFAULT:
+   case V4L2_SEL_TGT_COMPOSE_BOUNDS:
+   case V4L2_SEL_TGT_COMPOSE:


This is almost certainly wrong.

For capture I would expect that you can do compose, but not crop.

This would likely explain that v4l2-compliance thinks that the driver can
scale:

test Scaling: OK



Maybe I need some help to implement correctly g_selection.

Lets say that the resolution of the compressed stream is 1280x720, and
that resolution is set with s_fmt(OUTPUT queue), then I calculate the
output resolution which I will return by g_fmt(CAPTURE queue) and it
will be 1280x736 (hardware wants height to be multiple of 32 lines). So
the result will be 16 lines of vertical padding which should be exposed
to client (think of gstreamer v4l2videodec element) via g_crop
(g_selection) as 1280x720 because this is the actual image.

So from what I understood while read Selection API, I need to support
only composing on CAPTURE queue, no scaling and no cropping.

OUTPUT buffer type, data source
TGT_CROP_BOUNDS = TGT_CROP_DEFAULT = TGT_CROP = 1280x720
TGT_COMPOSE_BOUNDS = TGT_COMPOSE_DEFAULT = TGT_COMPOSE = 1280x720


The output buffer type doesn't do composition, only crop. So you shouldn't
support the compose targets.



CAPTURE buffer type, data sink
TGT_CROP_BOUNDS = TGT_CROP_DEFAULT = TGT_CROP = EINVAL
TGT_COMPOSE_BOUNDS = 1280x736
TGT_COMPOSE_DEFAULT = TGT_COMPOSE = 1280x720


This looks good.



With this logic in g_selection the output of v4l2-compliance test
application is:
test Cropping: OK
test Composing: OK
test Scaling: OK (Not Supported)

So why v4l2-compliance still thinks that the driver supports Cropping?


Hmm, v4l2-compliance could be improved. The problem is that it doesn't
show for m2m devices for which side (capture or output) cropping, composing
or scaling is supported. It does test both sides, but you can't tell from
the output.

It's a bit confusing in this case.

Regards,

Hans




+   break;
+   default:
+   return -EINVAL;
+   }
+
+   s->r.top = 0;
+   s->r.left = 0;
+   s->r.width = inst->out_width;
+   s->r.height = inst->out_height;
+
+   return 0;
+}






Re: [PATCH v2 3/8] media: vidc: decoder: add video decoder files

2016-11-03 Thread Stanimir Varbanov
Hi Hans,

On 09/19/2016 01:04 PM, Hans Verkuil wrote:
> On 09/07/2016 01:37 PM, Stanimir Varbanov wrote:
>> This consists of video decoder implementation plus decoder
>> controls.
>>
>> Signed-off-by: Stanimir Varbanov 
>> ---
>>  drivers/media/platform/qcom/vidc/vdec.c   | 1091 
>> +
>>  drivers/media/platform/qcom/vidc/vdec.h   |   29 +
>>  drivers/media/platform/qcom/vidc/vdec_ctrls.c |  200 +
>>  drivers/media/platform/qcom/vidc/vdec_ctrls.h |   21 +
>>  4 files changed, 1341 insertions(+)
>>  create mode 100644 drivers/media/platform/qcom/vidc/vdec.c
>>  create mode 100644 drivers/media/platform/qcom/vidc/vdec.h
>>  create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.c
>>  create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.h
>>



>> +
>> +static int
>> +vdec_g_selection(struct file *file, void *priv, struct v4l2_selection *s)
>> +{
>> +struct vidc_inst *inst = to_inst(file);
>> +
>> +if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
>> +return -EINVAL;
>> +
>> +switch (s->target) {
>> +case V4L2_SEL_TGT_CROP_DEFAULT:
>> +case V4L2_SEL_TGT_CROP_BOUNDS:
>> +case V4L2_SEL_TGT_CROP:
>> +case V4L2_SEL_TGT_COMPOSE_DEFAULT:
>> +case V4L2_SEL_TGT_COMPOSE_BOUNDS:
>> +case V4L2_SEL_TGT_COMPOSE:
> 
> This is almost certainly wrong.
> 
> For capture I would expect that you can do compose, but not crop.
> 
> This would likely explain that v4l2-compliance thinks that the driver can
> scale:
> 
> test Scaling: OK
> 

Maybe I need some help to implement correctly g_selection.

Lets say that the resolution of the compressed stream is 1280x720, and
that resolution is set with s_fmt(OUTPUT queue), then I calculate the
output resolution which I will return by g_fmt(CAPTURE queue) and it
will be 1280x736 (hardware wants height to be multiple of 32 lines). So
the result will be 16 lines of vertical padding which should be exposed
to client (think of gstreamer v4l2videodec element) via g_crop
(g_selection) as 1280x720 because this is the actual image.

So from what I understood while read Selection API, I need to support
only composing on CAPTURE queue, no scaling and no cropping.

OUTPUT buffer type, data source
TGT_CROP_BOUNDS = TGT_CROP_DEFAULT = TGT_CROP = 1280x720
TGT_COMPOSE_BOUNDS = TGT_COMPOSE_DEFAULT = TGT_COMPOSE = 1280x720

CAPTURE buffer type, data sink
TGT_CROP_BOUNDS = TGT_CROP_DEFAULT = TGT_CROP = EINVAL
TGT_COMPOSE_BOUNDS = 1280x736
TGT_COMPOSE_DEFAULT = TGT_COMPOSE = 1280x720

With this logic in g_selection the output of v4l2-compliance test
application is:
test Cropping: OK
test Composing: OK
test Scaling: OK (Not Supported)

So why v4l2-compliance still thinks that the driver supports Cropping?

>> +break;
>> +default:
>> +return -EINVAL;
>> +}
>> +
>> +s->r.top = 0;
>> +s->r.left = 0;
>> +s->r.width = inst->out_width;
>> +s->r.height = inst->out_height;
>> +
>> +return 0;
>> +}



-- 
regards,
Stan


Re: [PATCH v2 3/8] media: vidc: decoder: add video decoder files

2016-11-03 Thread Stanimir Varbanov
Hi Hans,

On 09/19/2016 01:04 PM, Hans Verkuil wrote:
> On 09/07/2016 01:37 PM, Stanimir Varbanov wrote:
>> This consists of video decoder implementation plus decoder
>> controls.
>>
>> Signed-off-by: Stanimir Varbanov 
>> ---
>>  drivers/media/platform/qcom/vidc/vdec.c   | 1091 
>> +
>>  drivers/media/platform/qcom/vidc/vdec.h   |   29 +
>>  drivers/media/platform/qcom/vidc/vdec_ctrls.c |  200 +
>>  drivers/media/platform/qcom/vidc/vdec_ctrls.h |   21 +
>>  4 files changed, 1341 insertions(+)
>>  create mode 100644 drivers/media/platform/qcom/vidc/vdec.c
>>  create mode 100644 drivers/media/platform/qcom/vidc/vdec.h
>>  create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.c
>>  create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.h
>>



>> +
>> +static int
>> +vdec_g_selection(struct file *file, void *priv, struct v4l2_selection *s)
>> +{
>> +struct vidc_inst *inst = to_inst(file);
>> +
>> +if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
>> +return -EINVAL;
>> +
>> +switch (s->target) {
>> +case V4L2_SEL_TGT_CROP_DEFAULT:
>> +case V4L2_SEL_TGT_CROP_BOUNDS:
>> +case V4L2_SEL_TGT_CROP:
>> +case V4L2_SEL_TGT_COMPOSE_DEFAULT:
>> +case V4L2_SEL_TGT_COMPOSE_BOUNDS:
>> +case V4L2_SEL_TGT_COMPOSE:
> 
> This is almost certainly wrong.
> 
> For capture I would expect that you can do compose, but not crop.
> 
> This would likely explain that v4l2-compliance thinks that the driver can
> scale:
> 
> test Scaling: OK
> 

Maybe I need some help to implement correctly g_selection.

Lets say that the resolution of the compressed stream is 1280x720, and
that resolution is set with s_fmt(OUTPUT queue), then I calculate the
output resolution which I will return by g_fmt(CAPTURE queue) and it
will be 1280x736 (hardware wants height to be multiple of 32 lines). So
the result will be 16 lines of vertical padding which should be exposed
to client (think of gstreamer v4l2videodec element) via g_crop
(g_selection) as 1280x720 because this is the actual image.

So from what I understood while read Selection API, I need to support
only composing on CAPTURE queue, no scaling and no cropping.

OUTPUT buffer type, data source
TGT_CROP_BOUNDS = TGT_CROP_DEFAULT = TGT_CROP = 1280x720
TGT_COMPOSE_BOUNDS = TGT_COMPOSE_DEFAULT = TGT_COMPOSE = 1280x720

CAPTURE buffer type, data sink
TGT_CROP_BOUNDS = TGT_CROP_DEFAULT = TGT_CROP = EINVAL
TGT_COMPOSE_BOUNDS = 1280x736
TGT_COMPOSE_DEFAULT = TGT_COMPOSE = 1280x720

With this logic in g_selection the output of v4l2-compliance test
application is:
test Cropping: OK
test Composing: OK
test Scaling: OK (Not Supported)

So why v4l2-compliance still thinks that the driver supports Cropping?

>> +break;
>> +default:
>> +return -EINVAL;
>> +}
>> +
>> +s->r.top = 0;
>> +s->r.left = 0;
>> +s->r.width = inst->out_width;
>> +s->r.height = inst->out_height;
>> +
>> +return 0;
>> +}



-- 
regards,
Stan


Re: [PATCH v2 3/8] media: vidc: decoder: add video decoder files

2016-09-28 Thread Stanimir Varbanov
Hi,

On 09/19/2016 01:12 PM, Hans Verkuil wrote:
> On 09/07/2016 01:37 PM, Stanimir Varbanov wrote:
>> This consists of video decoder implementation plus decoder
>> controls.
>>
>> Signed-off-by: Stanimir Varbanov 
>> ---
>>  drivers/media/platform/qcom/vidc/vdec.c   | 1091 
>> +
>>  drivers/media/platform/qcom/vidc/vdec.h   |   29 +
>>  drivers/media/platform/qcom/vidc/vdec_ctrls.c |  200 +
>>  drivers/media/platform/qcom/vidc/vdec_ctrls.h |   21 +
>>  4 files changed, 1341 insertions(+)
>>  create mode 100644 drivers/media/platform/qcom/vidc/vdec.c
>>  create mode 100644 drivers/media/platform/qcom/vidc/vdec.h
>>  create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.c
>>  create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.h
>>
> 
> 
> 
>> +static int vdec_event_notify(struct hfi_inst *hfi_inst, u32 event,
>> + struct hfi_event_data *data)
>> +{
>> +struct vidc_inst *inst = hfi_inst->ops_priv;
>> +struct device *dev = inst->core->dev;
>> +const struct v4l2_event ev = { .type = V4L2_EVENT_SOURCE_CHANGE };
> 
> 1) this can be static
> 2) set the u.src_change.changes as well.

Sure will do.

-- 
regards,
Stan


Re: [PATCH v2 3/8] media: vidc: decoder: add video decoder files

2016-09-28 Thread Stanimir Varbanov
Hi,

On 09/19/2016 01:12 PM, Hans Verkuil wrote:
> On 09/07/2016 01:37 PM, Stanimir Varbanov wrote:
>> This consists of video decoder implementation plus decoder
>> controls.
>>
>> Signed-off-by: Stanimir Varbanov 
>> ---
>>  drivers/media/platform/qcom/vidc/vdec.c   | 1091 
>> +
>>  drivers/media/platform/qcom/vidc/vdec.h   |   29 +
>>  drivers/media/platform/qcom/vidc/vdec_ctrls.c |  200 +
>>  drivers/media/platform/qcom/vidc/vdec_ctrls.h |   21 +
>>  4 files changed, 1341 insertions(+)
>>  create mode 100644 drivers/media/platform/qcom/vidc/vdec.c
>>  create mode 100644 drivers/media/platform/qcom/vidc/vdec.h
>>  create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.c
>>  create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.h
>>
> 
> 
> 
>> +static int vdec_event_notify(struct hfi_inst *hfi_inst, u32 event,
>> + struct hfi_event_data *data)
>> +{
>> +struct vidc_inst *inst = hfi_inst->ops_priv;
>> +struct device *dev = inst->core->dev;
>> +const struct v4l2_event ev = { .type = V4L2_EVENT_SOURCE_CHANGE };
> 
> 1) this can be static
> 2) set the u.src_change.changes as well.

Sure will do.

-- 
regards,
Stan


Re: [PATCH v2 3/8] media: vidc: decoder: add video decoder files

2016-09-28 Thread Stanimir Varbanov
Hi Hans,

Thanks for the comments!

On 09/19/2016 01:04 PM, Hans Verkuil wrote:
> On 09/07/2016 01:37 PM, Stanimir Varbanov wrote:
>> This consists of video decoder implementation plus decoder
>> controls.
>>
>> Signed-off-by: Stanimir Varbanov 
>> ---
>>  drivers/media/platform/qcom/vidc/vdec.c   | 1091 
>> +
>>  drivers/media/platform/qcom/vidc/vdec.h   |   29 +
>>  drivers/media/platform/qcom/vidc/vdec_ctrls.c |  200 +
>>  drivers/media/platform/qcom/vidc/vdec_ctrls.h |   21 +
>>  4 files changed, 1341 insertions(+)
>>  create mode 100644 drivers/media/platform/qcom/vidc/vdec.c
>>  create mode 100644 drivers/media/platform/qcom/vidc/vdec.h
>>  create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.c
>>  create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.h
>>
>> diff --git a/drivers/media/platform/qcom/vidc/vdec.c 
>> b/drivers/media/platform/qcom/vidc/vdec.c
>> new file mode 100644
>> index ..433fe4f697d1
>> --- /dev/null
>> +++ b/drivers/media/platform/qcom/vidc/vdec.c
>> @@ -0,0 +1,1091 @@
>> +/*
>> + * Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
>> + * Copyright (C) 2016 Linaro Ltd.
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 and
>> + * only version 2 as published by the Free Software Foundation.
>> + *
>> + * 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.
>> + *
>> + */
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include "core.h"
>> +#include "helpers.h"
>> +#include "vdec_ctrls.h"
>> +
>> +#define MACROBLOCKS_PER_PIXEL   (16 * 16)
>> +
>> +static u32 get_framesize_nv12(int plane, u32 height, u32 width)
>> +{
>> +u32 y_stride, uv_stride, y_plane;
>> +u32 y_sclines, uv_sclines, uv_plane;
>> +u32 size;
>> +
>> +y_stride = ALIGN(width, 128);
>> +uv_stride = ALIGN(width, 128);
>> +y_sclines = ALIGN(height, 32);
>> +uv_sclines = ALIGN(((height + 1) >> 1), 16);
>> +
>> +y_plane = y_stride * y_sclines;
>> +uv_plane = uv_stride * uv_sclines + SZ_4K;
>> +size = y_plane + uv_plane + SZ_8K;
>> +
>> +return ALIGN(size, SZ_4K);
>> +}
>> +
>> +static u32 get_framesize_compressed(u32 mbs_per_frame)
>> +{
>> +return ((mbs_per_frame * MACROBLOCKS_PER_PIXEL * 3 / 2) / 2) + 128;
>> +}
>> +
>> +static const struct vidc_format vdec_formats[] = {
>> +{
>> +.pixfmt = V4L2_PIX_FMT_NV12,
>> +.num_planes = 1,
>> +.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
>> +}, {
>> +.pixfmt = V4L2_PIX_FMT_MPEG4,
>> +.num_planes = 1,
>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
>> +}, {
>> +.pixfmt = V4L2_PIX_FMT_MPEG2,
>> +.num_planes = 1,
>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
>> +}, {
>> +.pixfmt = V4L2_PIX_FMT_H263,
>> +.num_planes = 1,
>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
>> +}, {
>> +.pixfmt = V4L2_PIX_FMT_VC1_ANNEX_G,
>> +.num_planes = 1,
>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
>> +}, {
>> +.pixfmt = V4L2_PIX_FMT_VC1_ANNEX_L,
>> +.num_planes = 1,
>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
>> +}, {
>> +.pixfmt = V4L2_PIX_FMT_H264,
>> +.num_planes = 1,
>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
>> +}, {
>> +.pixfmt = V4L2_PIX_FMT_VP8,
>> +.num_planes = 1,
>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
>> +}, {
>> +.pixfmt = V4L2_PIX_FMT_XVID,
>> +.num_planes = 1,
>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
>> +},
>> +};
>> +
>> +static const struct vidc_format *find_format(u32 pixfmt, u32 type)
>> +{
>> +const struct vidc_format *fmt = vdec_formats;
>> +unsigned int size = ARRAY_SIZE(vdec_formats);
>> +unsigned int i;
>> +
>> +for (i = 0; i < size; i++) {
>> +if (fmt[i].pixfmt == pixfmt)
>> +break;
>> +}
>> +
>> +if (i == size || fmt[i].type != type)
>> +return NULL;
>> +
>> +return [i];
>> +}
>> +
>> +static const struct vidc_format *find_format_by_index(int index, u32 type)
>> +{
>> +const struct vidc_format *fmt = vdec_formats;
>> +unsigned int size = ARRAY_SIZE(vdec_formats);
>> +int i, k = 0;
>> +
>> +if (index < 0 || index > size)
>> +return NULL;
>> +
>> +for (i = 0; i < size; i++) {
>> +if (fmt[i].type != type)
>> +continue;
>> +if (k == index)
>> +

Re: [PATCH v2 3/8] media: vidc: decoder: add video decoder files

2016-09-28 Thread Stanimir Varbanov
Hi Hans,

Thanks for the comments!

On 09/19/2016 01:04 PM, Hans Verkuil wrote:
> On 09/07/2016 01:37 PM, Stanimir Varbanov wrote:
>> This consists of video decoder implementation plus decoder
>> controls.
>>
>> Signed-off-by: Stanimir Varbanov 
>> ---
>>  drivers/media/platform/qcom/vidc/vdec.c   | 1091 
>> +
>>  drivers/media/platform/qcom/vidc/vdec.h   |   29 +
>>  drivers/media/platform/qcom/vidc/vdec_ctrls.c |  200 +
>>  drivers/media/platform/qcom/vidc/vdec_ctrls.h |   21 +
>>  4 files changed, 1341 insertions(+)
>>  create mode 100644 drivers/media/platform/qcom/vidc/vdec.c
>>  create mode 100644 drivers/media/platform/qcom/vidc/vdec.h
>>  create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.c
>>  create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.h
>>
>> diff --git a/drivers/media/platform/qcom/vidc/vdec.c 
>> b/drivers/media/platform/qcom/vidc/vdec.c
>> new file mode 100644
>> index ..433fe4f697d1
>> --- /dev/null
>> +++ b/drivers/media/platform/qcom/vidc/vdec.c
>> @@ -0,0 +1,1091 @@
>> +/*
>> + * Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
>> + * Copyright (C) 2016 Linaro Ltd.
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 and
>> + * only version 2 as published by the Free Software Foundation.
>> + *
>> + * 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.
>> + *
>> + */
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include "core.h"
>> +#include "helpers.h"
>> +#include "vdec_ctrls.h"
>> +
>> +#define MACROBLOCKS_PER_PIXEL   (16 * 16)
>> +
>> +static u32 get_framesize_nv12(int plane, u32 height, u32 width)
>> +{
>> +u32 y_stride, uv_stride, y_plane;
>> +u32 y_sclines, uv_sclines, uv_plane;
>> +u32 size;
>> +
>> +y_stride = ALIGN(width, 128);
>> +uv_stride = ALIGN(width, 128);
>> +y_sclines = ALIGN(height, 32);
>> +uv_sclines = ALIGN(((height + 1) >> 1), 16);
>> +
>> +y_plane = y_stride * y_sclines;
>> +uv_plane = uv_stride * uv_sclines + SZ_4K;
>> +size = y_plane + uv_plane + SZ_8K;
>> +
>> +return ALIGN(size, SZ_4K);
>> +}
>> +
>> +static u32 get_framesize_compressed(u32 mbs_per_frame)
>> +{
>> +return ((mbs_per_frame * MACROBLOCKS_PER_PIXEL * 3 / 2) / 2) + 128;
>> +}
>> +
>> +static const struct vidc_format vdec_formats[] = {
>> +{
>> +.pixfmt = V4L2_PIX_FMT_NV12,
>> +.num_planes = 1,
>> +.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
>> +}, {
>> +.pixfmt = V4L2_PIX_FMT_MPEG4,
>> +.num_planes = 1,
>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
>> +}, {
>> +.pixfmt = V4L2_PIX_FMT_MPEG2,
>> +.num_planes = 1,
>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
>> +}, {
>> +.pixfmt = V4L2_PIX_FMT_H263,
>> +.num_planes = 1,
>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
>> +}, {
>> +.pixfmt = V4L2_PIX_FMT_VC1_ANNEX_G,
>> +.num_planes = 1,
>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
>> +}, {
>> +.pixfmt = V4L2_PIX_FMT_VC1_ANNEX_L,
>> +.num_planes = 1,
>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
>> +}, {
>> +.pixfmt = V4L2_PIX_FMT_H264,
>> +.num_planes = 1,
>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
>> +}, {
>> +.pixfmt = V4L2_PIX_FMT_VP8,
>> +.num_planes = 1,
>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
>> +}, {
>> +.pixfmt = V4L2_PIX_FMT_XVID,
>> +.num_planes = 1,
>> +.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
>> +},
>> +};
>> +
>> +static const struct vidc_format *find_format(u32 pixfmt, u32 type)
>> +{
>> +const struct vidc_format *fmt = vdec_formats;
>> +unsigned int size = ARRAY_SIZE(vdec_formats);
>> +unsigned int i;
>> +
>> +for (i = 0; i < size; i++) {
>> +if (fmt[i].pixfmt == pixfmt)
>> +break;
>> +}
>> +
>> +if (i == size || fmt[i].type != type)
>> +return NULL;
>> +
>> +return [i];
>> +}
>> +
>> +static const struct vidc_format *find_format_by_index(int index, u32 type)
>> +{
>> +const struct vidc_format *fmt = vdec_formats;
>> +unsigned int size = ARRAY_SIZE(vdec_formats);
>> +int i, k = 0;
>> +
>> +if (index < 0 || index > size)
>> +return NULL;
>> +
>> +for (i = 0; i < size; i++) {
>> +if (fmt[i].type != type)
>> +continue;
>> +if (k == index)
>> +break;
>> +   

Re: [PATCH v2 3/8] media: vidc: decoder: add video decoder files

2016-09-19 Thread Hans Verkuil
On 09/07/2016 01:37 PM, Stanimir Varbanov wrote:
> This consists of video decoder implementation plus decoder
> controls.
> 
> Signed-off-by: Stanimir Varbanov 
> ---
>  drivers/media/platform/qcom/vidc/vdec.c   | 1091 
> +
>  drivers/media/platform/qcom/vidc/vdec.h   |   29 +
>  drivers/media/platform/qcom/vidc/vdec_ctrls.c |  200 +
>  drivers/media/platform/qcom/vidc/vdec_ctrls.h |   21 +
>  4 files changed, 1341 insertions(+)
>  create mode 100644 drivers/media/platform/qcom/vidc/vdec.c
>  create mode 100644 drivers/media/platform/qcom/vidc/vdec.h
>  create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.c
>  create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.h
> 



> +static int vdec_event_notify(struct hfi_inst *hfi_inst, u32 event,
> +  struct hfi_event_data *data)
> +{
> + struct vidc_inst *inst = hfi_inst->ops_priv;
> + struct device *dev = inst->core->dev;
> + const struct v4l2_event ev = { .type = V4L2_EVENT_SOURCE_CHANGE };

1) this can be static
2) set the u.src_change.changes as well.




Re: [PATCH v2 3/8] media: vidc: decoder: add video decoder files

2016-09-19 Thread Hans Verkuil
On 09/07/2016 01:37 PM, Stanimir Varbanov wrote:
> This consists of video decoder implementation plus decoder
> controls.
> 
> Signed-off-by: Stanimir Varbanov 
> ---
>  drivers/media/platform/qcom/vidc/vdec.c   | 1091 
> +
>  drivers/media/platform/qcom/vidc/vdec.h   |   29 +
>  drivers/media/platform/qcom/vidc/vdec_ctrls.c |  200 +
>  drivers/media/platform/qcom/vidc/vdec_ctrls.h |   21 +
>  4 files changed, 1341 insertions(+)
>  create mode 100644 drivers/media/platform/qcom/vidc/vdec.c
>  create mode 100644 drivers/media/platform/qcom/vidc/vdec.h
>  create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.c
>  create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.h
> 



> +static int vdec_event_notify(struct hfi_inst *hfi_inst, u32 event,
> +  struct hfi_event_data *data)
> +{
> + struct vidc_inst *inst = hfi_inst->ops_priv;
> + struct device *dev = inst->core->dev;
> + const struct v4l2_event ev = { .type = V4L2_EVENT_SOURCE_CHANGE };

1) this can be static
2) set the u.src_change.changes as well.




Re: [PATCH v2 3/8] media: vidc: decoder: add video decoder files

2016-09-19 Thread Hans Verkuil
On 09/07/2016 01:37 PM, Stanimir Varbanov wrote:
> This consists of video decoder implementation plus decoder
> controls.
> 
> Signed-off-by: Stanimir Varbanov 
> ---
>  drivers/media/platform/qcom/vidc/vdec.c   | 1091 
> +
>  drivers/media/platform/qcom/vidc/vdec.h   |   29 +
>  drivers/media/platform/qcom/vidc/vdec_ctrls.c |  200 +
>  drivers/media/platform/qcom/vidc/vdec_ctrls.h |   21 +
>  4 files changed, 1341 insertions(+)
>  create mode 100644 drivers/media/platform/qcom/vidc/vdec.c
>  create mode 100644 drivers/media/platform/qcom/vidc/vdec.h
>  create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.c
>  create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.h
> 
> diff --git a/drivers/media/platform/qcom/vidc/vdec.c 
> b/drivers/media/platform/qcom/vidc/vdec.c
> new file mode 100644
> index ..433fe4f697d1
> --- /dev/null
> +++ b/drivers/media/platform/qcom/vidc/vdec.c
> @@ -0,0 +1,1091 @@
> +/*
> + * Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
> + * Copyright (C) 2016 Linaro Ltd.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 and
> + * only version 2 as published by the Free Software Foundation.
> + *
> + * 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.
> + *
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "core.h"
> +#include "helpers.h"
> +#include "vdec_ctrls.h"
> +
> +#define MACROBLOCKS_PER_PIXEL(16 * 16)
> +
> +static u32 get_framesize_nv12(int plane, u32 height, u32 width)
> +{
> + u32 y_stride, uv_stride, y_plane;
> + u32 y_sclines, uv_sclines, uv_plane;
> + u32 size;
> +
> + y_stride = ALIGN(width, 128);
> + uv_stride = ALIGN(width, 128);
> + y_sclines = ALIGN(height, 32);
> + uv_sclines = ALIGN(((height + 1) >> 1), 16);
> +
> + y_plane = y_stride * y_sclines;
> + uv_plane = uv_stride * uv_sclines + SZ_4K;
> + size = y_plane + uv_plane + SZ_8K;
> +
> + return ALIGN(size, SZ_4K);
> +}
> +
> +static u32 get_framesize_compressed(u32 mbs_per_frame)
> +{
> + return ((mbs_per_frame * MACROBLOCKS_PER_PIXEL * 3 / 2) / 2) + 128;
> +}
> +
> +static const struct vidc_format vdec_formats[] = {
> + {
> + .pixfmt = V4L2_PIX_FMT_NV12,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
> + }, {
> + .pixfmt = V4L2_PIX_FMT_MPEG4,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
> + }, {
> + .pixfmt = V4L2_PIX_FMT_MPEG2,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
> + }, {
> + .pixfmt = V4L2_PIX_FMT_H263,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
> + }, {
> + .pixfmt = V4L2_PIX_FMT_VC1_ANNEX_G,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
> + }, {
> + .pixfmt = V4L2_PIX_FMT_VC1_ANNEX_L,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
> + }, {
> + .pixfmt = V4L2_PIX_FMT_H264,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
> + }, {
> + .pixfmt = V4L2_PIX_FMT_VP8,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
> + }, {
> + .pixfmt = V4L2_PIX_FMT_XVID,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
> + },
> +};
> +
> +static const struct vidc_format *find_format(u32 pixfmt, u32 type)
> +{
> + const struct vidc_format *fmt = vdec_formats;
> + unsigned int size = ARRAY_SIZE(vdec_formats);
> + unsigned int i;
> +
> + for (i = 0; i < size; i++) {
> + if (fmt[i].pixfmt == pixfmt)
> + break;
> + }
> +
> + if (i == size || fmt[i].type != type)
> + return NULL;
> +
> + return [i];
> +}
> +
> +static const struct vidc_format *find_format_by_index(int index, u32 type)
> +{
> + const struct vidc_format *fmt = vdec_formats;
> + unsigned int size = ARRAY_SIZE(vdec_formats);
> + int i, k = 0;
> +
> + if (index < 0 || index > size)
> + return NULL;
> +
> + for (i = 0; i < size; i++) {
> + if (fmt[i].type != type)
> + continue;
> + if (k == index)
> + break;
> + k++;
> + }
> +
> + if (i == size)
> + return NULL;
> +
> + return [i];
> +}
> +
> +static int 

Re: [PATCH v2 3/8] media: vidc: decoder: add video decoder files

2016-09-19 Thread Hans Verkuil
On 09/07/2016 01:37 PM, Stanimir Varbanov wrote:
> This consists of video decoder implementation plus decoder
> controls.
> 
> Signed-off-by: Stanimir Varbanov 
> ---
>  drivers/media/platform/qcom/vidc/vdec.c   | 1091 
> +
>  drivers/media/platform/qcom/vidc/vdec.h   |   29 +
>  drivers/media/platform/qcom/vidc/vdec_ctrls.c |  200 +
>  drivers/media/platform/qcom/vidc/vdec_ctrls.h |   21 +
>  4 files changed, 1341 insertions(+)
>  create mode 100644 drivers/media/platform/qcom/vidc/vdec.c
>  create mode 100644 drivers/media/platform/qcom/vidc/vdec.h
>  create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.c
>  create mode 100644 drivers/media/platform/qcom/vidc/vdec_ctrls.h
> 
> diff --git a/drivers/media/platform/qcom/vidc/vdec.c 
> b/drivers/media/platform/qcom/vidc/vdec.c
> new file mode 100644
> index ..433fe4f697d1
> --- /dev/null
> +++ b/drivers/media/platform/qcom/vidc/vdec.c
> @@ -0,0 +1,1091 @@
> +/*
> + * Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
> + * Copyright (C) 2016 Linaro Ltd.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 and
> + * only version 2 as published by the Free Software Foundation.
> + *
> + * 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.
> + *
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "core.h"
> +#include "helpers.h"
> +#include "vdec_ctrls.h"
> +
> +#define MACROBLOCKS_PER_PIXEL(16 * 16)
> +
> +static u32 get_framesize_nv12(int plane, u32 height, u32 width)
> +{
> + u32 y_stride, uv_stride, y_plane;
> + u32 y_sclines, uv_sclines, uv_plane;
> + u32 size;
> +
> + y_stride = ALIGN(width, 128);
> + uv_stride = ALIGN(width, 128);
> + y_sclines = ALIGN(height, 32);
> + uv_sclines = ALIGN(((height + 1) >> 1), 16);
> +
> + y_plane = y_stride * y_sclines;
> + uv_plane = uv_stride * uv_sclines + SZ_4K;
> + size = y_plane + uv_plane + SZ_8K;
> +
> + return ALIGN(size, SZ_4K);
> +}
> +
> +static u32 get_framesize_compressed(u32 mbs_per_frame)
> +{
> + return ((mbs_per_frame * MACROBLOCKS_PER_PIXEL * 3 / 2) / 2) + 128;
> +}
> +
> +static const struct vidc_format vdec_formats[] = {
> + {
> + .pixfmt = V4L2_PIX_FMT_NV12,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
> + }, {
> + .pixfmt = V4L2_PIX_FMT_MPEG4,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
> + }, {
> + .pixfmt = V4L2_PIX_FMT_MPEG2,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
> + }, {
> + .pixfmt = V4L2_PIX_FMT_H263,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
> + }, {
> + .pixfmt = V4L2_PIX_FMT_VC1_ANNEX_G,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
> + }, {
> + .pixfmt = V4L2_PIX_FMT_VC1_ANNEX_L,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
> + }, {
> + .pixfmt = V4L2_PIX_FMT_H264,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
> + }, {
> + .pixfmt = V4L2_PIX_FMT_VP8,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
> + }, {
> + .pixfmt = V4L2_PIX_FMT_XVID,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
> + },
> +};
> +
> +static const struct vidc_format *find_format(u32 pixfmt, u32 type)
> +{
> + const struct vidc_format *fmt = vdec_formats;
> + unsigned int size = ARRAY_SIZE(vdec_formats);
> + unsigned int i;
> +
> + for (i = 0; i < size; i++) {
> + if (fmt[i].pixfmt == pixfmt)
> + break;
> + }
> +
> + if (i == size || fmt[i].type != type)
> + return NULL;
> +
> + return [i];
> +}
> +
> +static const struct vidc_format *find_format_by_index(int index, u32 type)
> +{
> + const struct vidc_format *fmt = vdec_formats;
> + unsigned int size = ARRAY_SIZE(vdec_formats);
> + int i, k = 0;
> +
> + if (index < 0 || index > size)
> + return NULL;
> +
> + for (i = 0; i < size; i++) {
> + if (fmt[i].type != type)
> + continue;
> + if (k == index)
> + break;
> + k++;
> + }
> +
> + if (i == size)
> + return NULL;
> +
> + return [i];
> +}
> +
> +static int vdec_set_properties(struct