Skip to content

Commit

Permalink
V4L/DVB: v4l: Add a v4l2_subdev host private data field
Browse files Browse the repository at this point in the history
The existing priv field stores subdev private data owned by the subdev
driver. Host (bridge) drivers might need to store per-subdev
host-specific data, such as a pointer to platform data.

Add a v4l2_subdev host_priv field to store host-specific data, and
rename the existing priv field to dev_priv.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Laurent Pinchart authored and Mauro Carvalho Chehab committed Oct 21, 2010
1 parent c4ce6d1 commit 692d552
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
5 changes: 5 additions & 0 deletions Documentation/video4linux/v4l2-framework.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ You also need a way to go from the low-level struct to v4l2_subdev. For the
common i2c_client struct the i2c_set_clientdata() call is used to store a
v4l2_subdev pointer, for other busses you may have to use other methods.

Bridges might also need to store per-subdev private data, such as a pointer to
bridge-specific per-subdev private data. The v4l2_subdev structure provides
host private data for that purpose that can be accessed with
v4l2_get_subdev_hostdata() and v4l2_set_subdev_hostdata().

From the bridge driver perspective you load the sub-device module and somehow
obtain the v4l2_subdev pointer. For i2c devices this is easy: you call
i2c_get_clientdata(). For other busses something similar needs to be done.
Expand Down
20 changes: 16 additions & 4 deletions include/media/v4l2-subdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,17 +438,28 @@ struct v4l2_subdev {
/* can be used to group similar subdevs, value is driver-specific */
u32 grp_id;
/* pointer to private data */
void *priv;
void *dev_priv;
void *host_priv;
};

static inline void v4l2_set_subdevdata(struct v4l2_subdev *sd, void *p)
{
sd->priv = p;
sd->dev_priv = p;
}

static inline void *v4l2_get_subdevdata(const struct v4l2_subdev *sd)
{
return sd->priv;
return sd->dev_priv;
}

static inline void v4l2_set_subdev_hostdata(struct v4l2_subdev *sd, void *p)
{
sd->host_priv = p;
}

static inline void *v4l2_get_subdev_hostdata(const struct v4l2_subdev *sd)
{
return sd->host_priv;
}

static inline void v4l2_subdev_init(struct v4l2_subdev *sd,
Expand All @@ -462,7 +473,8 @@ static inline void v4l2_subdev_init(struct v4l2_subdev *sd,
sd->flags = 0;
sd->name[0] = '\0';
sd->grp_id = 0;
sd->priv = NULL;
sd->dev_priv = NULL;
sd->host_priv = NULL;
}

/* Call an ops of a v4l2_subdev, doing the right checks against
Expand Down

0 comments on commit 692d552

Please sign in to comment.