Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ab22e77c authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab
Browse files

[media] media framework: rename pads init function to media_entity_pads_init()



With the MC next gen rework, what's left for media_entity_init()
is to just initialize the PADs. However, certain devices, like
a FLASH led/light doesn't have any input or output PAD.

So, there's no reason why calling media_entity_init() would be
mandatory. Also, despite its name, what this function actually
does is to initialize the PADs data. So, rename it to
media_entity_pads_init() in order to reflect that.

The media entity actual init happens during entity register,
at media_device_register_entity(). We should move init of
num_links and num_backlinks to it.

Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent b83e2508
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -101,14 +101,18 @@ include/media/media-entity.h. The structure is usually embedded into a
higher-level structure, such as a v4l2_subdev or video_device instance,
although drivers can allocate entities directly.

Drivers initialize entities by calling
Drivers initialize entity pads by calling

	media_entity_init(struct media_entity *entity, u16 num_pads,
	media_entity_pads_init(struct media_entity *entity, u16 num_pads,
			  struct media_pad *pads);

The media_entity name, type, flags, revision and group_id fields can be
initialized before or after calling media_entity_init. Entities embedded in
higher-level standard structures can have some of those fields set by the
If no pads are needed, drivers could directly fill entity->num_pads
with 0 and entity->pads with NULL or to call the above function that
will do the same.

The media_entity name, type, flags, revision and group_id fields should be
initialized before calling media_device_register_entity(). Entities embedded
in higher-level standard structures can have some of those fields set by the
higher-level framework.

As the number of pads is known in advance, the pads array is not allocated
@@ -116,10 +120,10 @@ dynamically but is managed by the entity driver. Most drivers will embed the
pads array in a driver-specific structure, avoiding dynamic allocation.

Drivers must set the direction of every pad in the pads array before calling
media_entity_init. The function will initialize the other pads fields.
media_entity_pads_init. The function will initialize the other pads fields.

Unlike the number of pads, the total number of links isn't always known in
advance by the entity driver. As an initial estimate, media_entity_init
advance by the entity driver. As an initial estimate, media_entity_pads_init
pre-allocates a number of links equal to the number of pads. The links array
will be reallocated if it grows beyond the initial estimate.

+4 −4
Original line number Diff line number Diff line
@@ -295,12 +295,12 @@ module owner. This is done for you if you use the i2c helper functions.

If integration with the media framework is needed, you must initialize the
media_entity struct embedded in the v4l2_subdev struct (entity field) by
calling media_entity_init():
calling media_entity_pads_init(), if the entity has pads:

	struct media_pad *pads = &my_sd->pads;
	int err;

	err = media_entity_init(&sd->entity, npads, pads);
	err = media_entity_pads_init(&sd->entity, npads, pads);

The pads array must have been previously initialized. There is no need to
manually set the struct media_entity function and name fields, but the
@@ -695,12 +695,12 @@ difference is that the inode argument is omitted since it is never used.

If integration with the media framework is needed, you must initialize the
media_entity struct embedded in the video_device struct (entity field) by
calling media_entity_init():
calling media_entity_pads_init():

	struct media_pad *pad = &my_vdev->pad;
	int err;

	err = media_entity_init(&vdev->entity, 1, pad);
	err = media_entity_pads_init(&vdev->entity, 1, pad);

The pads array must have been previously initialized. There is no need to
manually set the struct media_entity type and name fields.
+4 −4
Original line number Diff line number Diff line
@@ -289,13 +289,13 @@ struct v4l2_subdev_ops {
然后,你必须用一个唯一的名字初始化 subdev->name,并初始化模块的
owner 域。若使用 i2c 辅助函数,这些都会帮你处理好。

若需同媒体框架整合,你必须调用 media_entity_init() 初始化 v4l2_subdev
若需同媒体框架整合,你必须调用 media_entity_pads_init() 初始化 v4l2_subdev
结构体中的 media_entity 结构体(entity 域):

	struct media_pad *pads = &my_sd->pads;
	int err;

	err = media_entity_init(&sd->entity, npads, pads);
	err = media_entity_pads_init(&sd->entity, npads, pads);

pads 数组必须预先初始化。无须手动设置 media_entity 的 type 和
name 域,但如有必要,revision 域必须初始化。
@@ -596,13 +596,13 @@ void v4l2_disable_ioctl(struct video_device *vdev, unsigned int cmd);
v4l2_file_operations 结构体是 file_operations 的一个子集。其主要
区别在于:因 inode 参数从未被使用,它将被忽略。

如果需要与媒体框架整合,你必须通过调用 media_entity_init() 初始化
如果需要与媒体框架整合,你必须通过调用 media_entity_pads_init() 初始化
嵌入在 video_device 结构体中的 media_entity(entity 域)结构体:

	struct media_pad *pad = &my_vdev->pad;
	int err;

	err = media_entity_init(&vdev->entity, 1, pad);
	err = media_entity_pads_init(&vdev->entity, 1, pad);

pads 数组必须预先初始化。没有必要手动设置 media_entity 的 type 和
name 域。
+2 −2
Original line number Diff line number Diff line
@@ -245,7 +245,7 @@ static int dvb_create_tsout_entity(struct dvb_device *dvbdev,
		entity->function = MEDIA_ENT_F_IO_DTV;
		pads->flags = MEDIA_PAD_FL_SINK;

		ret = media_entity_init(entity, 1, pads);
		ret = media_entity_pads_init(entity, 1, pads);
		if (ret < 0)
			return ret;

@@ -340,7 +340,7 @@ static int dvb_create_media_entity(struct dvb_device *dvbdev,
	}

	if (npads) {
		ret = media_entity_init(dvbdev->entity, npads, dvbdev->pads);
		ret = media_entity_pads_init(dvbdev->entity, npads, dvbdev->pads);
		if (ret)
			return ret;
	}
+1 −1
Original line number Diff line number Diff line
@@ -768,7 +768,7 @@ static int au8522_probe(struct i2c_client *client,
	state->pads[AU8522_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
	sd->entity.function = MEDIA_ENT_F_ATV_DECODER;

	ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads),
	ret = media_entity_pads_init(&sd->entity, ARRAY_SIZE(state->pads),
				state->pads);
	if (ret < 0) {
		v4l_info(client, "failed to initialize media entity!\n");
Loading