media: v4l2-core: move i2c helpers out of v4l2-common.c

Separate the i2c helpers to v4l2-i2c.c, in order to get rid
of the ifdefery. No functional changes intended, this is
just a cosmetic change to organize the code better.

Given I2C is a tristate symbol, a hidden boolean symbol
is introduced, to make the conditional build easier.

Signed-off-by: Ezequiel Garcia <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
This commit is contained in:
Ezequiel Garcia 2019-08-15 13:48:03 -03:00 • committed by Mauro Carvalho Chehab
commit 02283b98b1
5 changed files with 229 additions and 182 deletions

View file

@ -96,16 +96,45 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl,
/* ------------------------------------------------------------------------- */
/* I2C Helper functions */
struct i2c_driver;
struct i2c_adapter;
struct i2c_client;
struct i2c_device_id;
struct v4l2_device;
struct v4l2_subdev;
struct v4l2_subdev_ops;
/* I2C Helper functions */
#include <linux/i2c.h>
/**
* enum v4l2_i2c_tuner_type - specifies the range of tuner address that
* should be used when seeking for I2C devices.
*
* @ADDRS_RADIO: Radio tuner addresses.
* Represent the following I2C addresses:
* 0x10 (if compiled with tea5761 support)
* and 0x60.
* @ADDRS_DEMOD: Demod tuner addresses.
* Represent the following I2C addresses:
* 0x42, 0x43, 0x4a and 0x4b.
* @ADDRS_TV: TV tuner addresses.
* Represent the following I2C addresses:
* 0x42, 0x43, 0x4a, 0x4b, 0x60, 0x61, 0x62,
* 0x63 and 0x64.
* @ADDRS_TV_WITH_DEMOD: TV tuner addresses if demod is present, this
* excludes addresses used by the demodulator
* from the list of candidates.
* Represent the following I2C addresses:
* 0x60, 0x61, 0x62, 0x63 and 0x64.
*
* NOTE: All I2C addresses above use the 7-bit notation.
*/
enum v4l2_i2c_tuner_type {
ADDRS_RADIO,
ADDRS_DEMOD,
ADDRS_TV,
ADDRS_TV_WITH_DEMOD,
};
#if defined(CONFIG_VIDEO_V4L2_I2C)
/**
* v4l2_i2c_new_subdev - Load an i2c module and return an initialized
* &struct v4l2_subdev.
@ -123,8 +152,6 @@ struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev,
struct i2c_adapter *adapter, const char *client_type,
u8 addr, const unsigned short *probe_addrs);
struct i2c_board_info;
/**
* v4l2_i2c_new_subdev_board - Load an i2c module and return an initialized
* &struct v4l2_subdev.
@ -174,35 +201,6 @@ void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client,
*/
unsigned short v4l2_i2c_subdev_addr(struct v4l2_subdev *sd);
/**
* enum v4l2_i2c_tuner_type - specifies the range of tuner address that
* should be used when seeking for I2C devices.
*
* @ADDRS_RADIO: Radio tuner addresses.
* Represent the following I2C addresses:
* 0x10 (if compiled with tea5761 support)
* and 0x60.
* @ADDRS_DEMOD: Demod tuner addresses.
* Represent the following I2C addresses:
* 0x42, 0x43, 0x4a and 0x4b.
* @ADDRS_TV: TV tuner addresses.
* Represent the following I2C addresses:
* 0x42, 0x43, 0x4a, 0x4b, 0x60, 0x61, 0x62,
* 0x63 and 0x64.
* @ADDRS_TV_WITH_DEMOD: TV tuner addresses if demod is present, this
* excludes addresses used by the demodulator
* from the list of candidates.
* Represent the following I2C addresses:
* 0x60, 0x61, 0x62, 0x63 and 0x64.
*
* NOTE: All I2C addresses above use the 7-bit notation.
*/
enum v4l2_i2c_tuner_type {
ADDRS_RADIO,
ADDRS_DEMOD,
ADDRS_TV,
ADDRS_TV_WITH_DEMOD,
};
/**
* v4l2_i2c_tuner_addrs - Return a list of I2C tuner addresses to probe.
*
@ -213,6 +211,47 @@ enum v4l2_i2c_tuner_type {
*/
const unsigned short *v4l2_i2c_tuner_addrs(enum v4l2_i2c_tuner_type type);
#else
static inline struct v4l2_subdev *
v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev,
struct i2c_adapter *adapter, const char *client_type,
u8 addr, const unsigned short *probe_addrs)
{
return NULL;
}
static inline struct v4l2_subdev *
v4l2_i2c_new_subdev_board(struct v4l2_device *v4l2_dev,
struct i2c_adapter *adapter, struct i2c_board_info *info,
const unsigned short *probe_addrs)
{
return NULL;
}
static inline void
v4l2_i2c_subdev_set_name(struct v4l2_subdev *sd, struct i2c_client *client,
const char *devname, const char *postfix)
{}
static inline void
v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client,
const struct v4l2_subdev_ops *ops)
{}
static inline unsigned short v4l2_i2c_subdev_addr(struct v4l2_subdev *sd)
{
return I2C_CLIENT_END;
}
static inline const unsigned short *
v4l2_i2c_tuner_addrs(enum v4l2_i2c_tuner_type type)
{
return NULL;
}
#endif
/* ------------------------------------------------------------------------- */
/* SPI Helper functions */