Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: mc: entity: Add media_entity_pipeline() to access the media pipeline

Replace direct access to the pipe field in drivers with a new helper
function. This will allow easier refactoring of media pipeline handling
in the MC core behind the scenes without affecting drivers.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>

authored by

Laurent Pinchart and committed by
Mauro Carvalho Chehab
72b60335 612589a3

+57 -22
+6
drivers/media/mc/mc-entity.c
··· 994 994 } 995 995 EXPORT_SYMBOL_GPL(media_entity_get_fwnode_pad); 996 996 997 + struct media_pipeline *media_entity_pipeline(struct media_entity *entity) 998 + { 999 + return entity->pipe; 1000 + } 1001 + EXPORT_SYMBOL_GPL(media_entity_pipeline); 1002 + 997 1003 static void media_interface_init(struct media_device *mdev, 998 1004 struct media_interface *intf, 999 1005 u32 gobj_type,
+2 -3
drivers/media/platform/renesas/rcar-vin/rcar-core.c
··· 786 786 return 0; 787 787 788 788 /* 789 - * Don't allow link changes if any entity in the graph is 790 - * streaming, modifying the CHSEL register fields can disrupt 791 - * running streams. 789 + * Don't allow link changes if any stream in the graph is active as 790 + * modifying the CHSEL register fields can disrupt running streams. 792 791 */ 793 792 media_device_for_each_entity(entity, &group->mdev) 794 793 if (media_entity_is_streaming(entity))
+1 -1
drivers/media/platform/renesas/rcar-vin/rcar-dma.c
··· 1281 1281 */ 1282 1282 mdev = vin->vdev.entity.graph_obj.mdev; 1283 1283 mutex_lock(&mdev->graph_mutex); 1284 - pipe = sd->entity.pipe ? sd->entity.pipe : &vin->vdev.pipe; 1284 + pipe = media_entity_pipeline(&sd->entity) ? : &vin->vdev.pipe; 1285 1285 ret = __media_pipeline_start(&vin->vdev.entity, pipe); 1286 1286 mutex_unlock(&mdev->graph_mutex); 1287 1287 if (ret)
+1 -3
drivers/media/platform/ti/omap3isp/isp.c
··· 937 937 struct isp_pipeline *pipe; 938 938 struct media_pad *pad; 939 939 940 - if (!me->pipe) 941 - return 0; 942 940 pipe = to_isp_pipeline(me); 943 - if (pipe->stream_state == ISP_PIPELINE_STREAM_STOPPED) 941 + if (!pipe || pipe->stream_state == ISP_PIPELINE_STREAM_STOPPED) 944 942 return 0; 945 943 pad = media_pad_remote_pad_first(&pipe->output->pad); 946 944 return pad->entity == me;
+1 -2
drivers/media/platform/ti/omap3isp/ispvideo.c
··· 1093 1093 /* Start streaming on the pipeline. No link touching an entity in the 1094 1094 * pipeline can be activated or deactivated once streaming is started. 1095 1095 */ 1096 - pipe = video->video.entity.pipe 1097 - ? to_isp_pipeline(&video->video.entity) : &video->pipe; 1096 + pipe = to_isp_pipeline(&video->video.entity) ? : &video->pipe; 1098 1097 1099 1098 ret = media_entity_enum_init(&pipe->ent_enum, &video->isp->media_dev); 1100 1099 if (ret)
+9 -2
drivers/media/platform/ti/omap3isp/ispvideo.h
··· 99 99 unsigned int external_width; 100 100 }; 101 101 102 - #define to_isp_pipeline(__e) \ 103 - container_of((__e)->pipe, struct isp_pipeline, pipe) 102 + static inline struct isp_pipeline *to_isp_pipeline(struct media_entity *entity) 103 + { 104 + struct media_pipeline *pipe = media_entity_pipeline(entity); 105 + 106 + if (!pipe) 107 + return NULL; 108 + 109 + return container_of(pipe, struct isp_pipeline, pipe); 110 + } 104 111 105 112 static inline int isp_pipeline_ready(struct isp_pipeline *pipe) 106 113 {
+1 -2
drivers/media/platform/xilinx/xilinx-dma.c
··· 402 402 * Use the pipeline object embedded in the first DMA object that starts 403 403 * streaming. 404 404 */ 405 - pipe = dma->video.entity.pipe 406 - ? to_xvip_pipeline(&dma->video.entity) : &dma->pipe; 405 + pipe = to_xvip_pipeline(&dma->video.entity) ? : &dma->pipe; 407 406 408 407 ret = media_pipeline_start(&dma->video.entity, &pipe->pipe); 409 408 if (ret < 0)
+6 -1
drivers/media/platform/xilinx/xilinx-dma.h
··· 47 47 48 48 static inline struct xvip_pipeline *to_xvip_pipeline(struct media_entity *e) 49 49 { 50 - return container_of(e->pipe, struct xvip_pipeline, pipe); 50 + struct media_pipeline *pipe = media_entity_pipeline(e); 51 + 52 + if (!pipe) 53 + return NULL; 54 + 55 + return container_of(pipe, struct xvip_pipeline, pipe); 51 56 } 52 57 53 58 /**
+1 -1
drivers/staging/media/imx/imx-media-utils.c
··· 871 871 __media_pipeline_stop(entity); 872 872 } else { 873 873 v4l2_subdev_call(sd, video, s_stream, 0); 874 - if (entity->pipe) 874 + if (media_entity_pipeline(entity)) 875 875 __media_pipeline_stop(entity); 876 876 } 877 877
+1 -3
drivers/staging/media/omap4iss/iss.c
··· 548 548 struct iss_pipeline *pipe; 549 549 struct media_pad *pad; 550 550 551 - if (!me->pipe) 552 - return 0; 553 551 pipe = to_iss_pipeline(me); 554 - if (pipe->stream_state == ISS_PIPELINE_STREAM_STOPPED) 552 + if (!pipe || pipe->stream_state == ISS_PIPELINE_STREAM_STOPPED) 555 553 return 0; 556 554 pad = media_pad_remote_pad_first(&pipe->output->pad); 557 555 return pad->entity == me;
+1 -2
drivers/staging/media/omap4iss/iss_video.c
··· 870 870 * Start streaming on the pipeline. No link touching an entity in the 871 871 * pipeline can be activated or deactivated once streaming is started. 872 872 */ 873 - pipe = entity->pipe 874 - ? to_iss_pipeline(entity) : &video->pipe; 873 + pipe = to_iss_pipeline(&video->video.entity) ? : &video->pipe; 875 874 pipe->external = NULL; 876 875 pipe->external_rate = 0; 877 876 pipe->external_bpp = 0;
+9 -2
drivers/staging/media/omap4iss/iss_video.h
··· 90 90 int external_bpp; 91 91 }; 92 92 93 - #define to_iss_pipeline(__e) \ 94 - container_of((__e)->pipe, struct iss_pipeline, pipe) 93 + static inline struct iss_pipeline *to_iss_pipeline(struct media_entity *entity) 94 + { 95 + struct media_pipeline *pipe = media_entity_pipeline(entity); 96 + 97 + if (!pipe) 98 + return NULL; 99 + 100 + return container_of(pipe, struct iss_pipeline, pipe); 101 + } 95 102 96 103 static inline int iss_pipeline_ready(struct iss_pipeline *pipe) 97 104 {
+18
include/media/media-entity.h
··· 949 949 } 950 950 951 951 /** 952 + * media_entity_pipeline - Get the media pipeline an entity is part of 953 + * @entity: The entity 954 + * 955 + * This function returns the media pipeline that an entity has been associated 956 + * with when constructing the pipeline with media_pipeline_start(). The pointer 957 + * remains valid until media_pipeline_stop() is called. 958 + * 959 + * In general, entities can be part of multiple pipelines, when carrying 960 + * multiple streams (either on different pads, or on the same pad using 961 + * multiplexed streams). This function is to be used only for entities that 962 + * do not support multiple pipelines. 963 + * 964 + * Return: The media_pipeline the entity is part of, or NULL if the entity is 965 + * not part of any pipeline. 966 + */ 967 + struct media_pipeline *media_entity_pipeline(struct media_entity *entity); 968 + 969 + /** 952 970 * media_entity_get_fwnode_pad - Get pad number from fwnode 953 971 * 954 972 * @entity: The entity