diff mbox series

[v7,25/27] v4l: subdev: add routing & stream config to v4l2_subdev_state

Message ID 20210524104408.599645-26-tomi.valkeinen@ideasonboard.com
State New
Headers show
Series v4l: subdev internal routing and streams | expand

Commit Message

Tomi Valkeinen May 24, 2021, 10:44 a.m. UTC
Add routing and stream_configs to struct v4l2_subdev_state. This lets
the drivers to implement V4L2_SUBDEV_FORMAT_TRY support for routing and
the stream configurations.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
 drivers/media/v4l2-core/v4l2-subdev.c | 3 +++
 include/media/v4l2-subdev.h           | 4 ++++
 2 files changed, 7 insertions(+)

Comments

Laurent Pinchart June 6, 2021, 12:01 a.m. UTC | #1
Hi Tomi,

Thank you for the patch.

On Mon, May 24, 2021 at 01:44:06PM +0300, Tomi Valkeinen wrote:
> Add routing and stream_configs to struct v4l2_subdev_state. This lets

> the drivers to implement V4L2_SUBDEV_FORMAT_TRY support for routing and

> the stream configurations.

> 

> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

> ---

>  drivers/media/v4l2-core/v4l2-subdev.c | 3 +++

>  include/media/v4l2-subdev.h           | 4 ++++

>  2 files changed, 7 insertions(+)

> 

> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c

> index b30b456d8d99..13cffe9d9b89 100644

> --- a/drivers/media/v4l2-core/v4l2-subdev.c

> +++ b/drivers/media/v4l2-core/v4l2-subdev.c

> @@ -1227,6 +1227,9 @@ EXPORT_SYMBOL_GPL(v4l2_subdev_alloc_state);

>  

>  void v4l2_subdev_free_state(struct v4l2_subdev_state *state)

>  {

> +	v4l2_subdev_free_routing(&state->routing);

> +	v4l2_uninit_stream_configs(&state->stream_configs);

> +

>  	kvfree(state->pads);

>  	kvfree(state);

>  }

> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h

> index 39c6b811463a..973db58c2d9b 100644

> --- a/include/media/v4l2-subdev.h

> +++ b/include/media/v4l2-subdev.h

> @@ -712,6 +712,8 @@ struct v4l2_subdev_krouting {

>   * struct v4l2_subdev_state - Used for storing subdev information.

>   *

>   * @pads: &struct v4l2_subdev_pad_config array

> + * @routing: routing table for the subdev

> + * @stream_configs: stream configurations (only for V4L2_SUBDEV_FL_MULTIPLEXED)

>   *

>   * This structure only needs to be passed to the pad op if the 'which' field

>   * of the main argument is set to %V4L2_SUBDEV_FORMAT_TRY. For

> @@ -719,6 +721,8 @@ struct v4l2_subdev_krouting {

>   */

>  struct v4l2_subdev_state {

>  	struct v4l2_subdev_pad_config *pads;

> +	struct v4l2_subdev_krouting routing;

> +	struct v4l2_subdev_stream_configs stream_configs;


stream_configs duplicates the information contained in pads. This is
possibly acceptable for the time being, but needs to be abstracted from
drivers completely.

>  };

>  

>  /**


-- 
Regards,

Laurent Pinchart
Tomi Valkeinen July 2, 2021, 8:34 a.m. UTC | #2
Hi,

On 06/06/2021 03:01, Laurent Pinchart wrote:
> Hi Tomi,

> 

> Thank you for the patch.

> 

> On Mon, May 24, 2021 at 01:44:06PM +0300, Tomi Valkeinen wrote:

>> Add routing and stream_configs to struct v4l2_subdev_state. This lets

>> the drivers to implement V4L2_SUBDEV_FORMAT_TRY support for routing and

>> the stream configurations.

>>

>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

>> ---

>>   drivers/media/v4l2-core/v4l2-subdev.c | 3 +++

>>   include/media/v4l2-subdev.h           | 4 ++++

>>   2 files changed, 7 insertions(+)

>>

>> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c

>> index b30b456d8d99..13cffe9d9b89 100644

>> --- a/drivers/media/v4l2-core/v4l2-subdev.c

>> +++ b/drivers/media/v4l2-core/v4l2-subdev.c

>> @@ -1227,6 +1227,9 @@ EXPORT_SYMBOL_GPL(v4l2_subdev_alloc_state);

>>   

>>   void v4l2_subdev_free_state(struct v4l2_subdev_state *state)

>>   {

>> +	v4l2_subdev_free_routing(&state->routing);

>> +	v4l2_uninit_stream_configs(&state->stream_configs);

>> +

>>   	kvfree(state->pads);

>>   	kvfree(state);

>>   }

>> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h

>> index 39c6b811463a..973db58c2d9b 100644

>> --- a/include/media/v4l2-subdev.h

>> +++ b/include/media/v4l2-subdev.h

>> @@ -712,6 +712,8 @@ struct v4l2_subdev_krouting {

>>    * struct v4l2_subdev_state - Used for storing subdev information.

>>    *

>>    * @pads: &struct v4l2_subdev_pad_config array

>> + * @routing: routing table for the subdev

>> + * @stream_configs: stream configurations (only for V4L2_SUBDEV_FL_MULTIPLEXED)

>>    *

>>    * This structure only needs to be passed to the pad op if the 'which' field

>>    * of the main argument is set to %V4L2_SUBDEV_FORMAT_TRY. For

>> @@ -719,6 +721,8 @@ struct v4l2_subdev_krouting {

>>    */

>>   struct v4l2_subdev_state {

>>   	struct v4l2_subdev_pad_config *pads;

>> +	struct v4l2_subdev_krouting routing;

>> +	struct v4l2_subdev_stream_configs stream_configs;

> 

> stream_configs duplicates the information contained in pads. This is

> possibly acceptable for the time being, but needs to be abstracted from

> drivers completely.


Only one of them will be allocated, and a driver will only use one of 
them, so there's no duplication in practice.

Abstracting this from the drivers is possible but will be challenging, 
as many drivers use the pads array directly.

  Tomi
diff mbox series

Patch

diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index b30b456d8d99..13cffe9d9b89 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -1227,6 +1227,9 @@  EXPORT_SYMBOL_GPL(v4l2_subdev_alloc_state);
 
 void v4l2_subdev_free_state(struct v4l2_subdev_state *state)
 {
+	v4l2_subdev_free_routing(&state->routing);
+	v4l2_uninit_stream_configs(&state->stream_configs);
+
 	kvfree(state->pads);
 	kvfree(state);
 }
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 39c6b811463a..973db58c2d9b 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -712,6 +712,8 @@  struct v4l2_subdev_krouting {
  * struct v4l2_subdev_state - Used for storing subdev information.
  *
  * @pads: &struct v4l2_subdev_pad_config array
+ * @routing: routing table for the subdev
+ * @stream_configs: stream configurations (only for V4L2_SUBDEV_FL_MULTIPLEXED)
  *
  * This structure only needs to be passed to the pad op if the 'which' field
  * of the main argument is set to %V4L2_SUBDEV_FORMAT_TRY. For
@@ -719,6 +721,8 @@  struct v4l2_subdev_krouting {
  */
 struct v4l2_subdev_state {
 	struct v4l2_subdev_pad_config *pads;
+	struct v4l2_subdev_krouting routing;
+	struct v4l2_subdev_stream_configs stream_configs;
 };
 
 /**