summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b2afe74)
raw | patch | inline | side by side (parent: b2afe74)
author | Rakesh Movva <r-movva@ti.com> | |
Fri, 7 Aug 2015 06:39:09 +0000 (01:39 -0500) | ||
committer | Praneeth Bajjuri <praneeth@ti.com> | |
Mon, 10 Aug 2015 19:30:22 +0000 (14:30 -0500) |
added support to parse/configure/control the tvp5158 chip
after parsing the TVP5158 dt node for the gpios the driver
would set all the gpios as per the active high/low flags
specified by the dt node.
Change-Id: I6eff4f62d98642fbaf17c877bd978a33d96f2c8f
Signed-off-by: Rakesh Movva <r-movva@ti.com>
after parsing the TVP5158 dt node for the gpios the driver
would set all the gpios as per the active high/low flags
specified by the dt node.
Change-Id: I6eff4f62d98642fbaf17c877bd978a33d96f2c8f
Signed-off-by: Rakesh Movva <r-movva@ti.com>
drivers/media/i2c/tvp5158.c | patch | blob | history |
index 88bd7a653d4b0cbf1dc850ff93d7695a96aefffe..5151d78008870154a6a7ce5ae2aff222f09f59b4 100644 (file)
};
static bool vbus_prog = 1;
static int
-tvp5158_get_gpios(struct device_node *node, struct i2c_client *client);
-static int tvp5158_set_gpios(struct i2c_client *client);
+tvp5158_of_probe(struct i2c_client *client, struct device_node *node);
+static int
+tvp5158_init_gpios(struct i2c_client *client);
static int
tvp5158_set_default(struct i2c_client *client, unsigned char core);
static enum tvp5158_std
#define NTSC_NUM_ACTIVE_PIXELS (720)
#define NTSC_NUM_ACTIVE_LINES (480)
+#define MAX_NUM_GPIOS 3
+
struct tvp5158_color_format {
enum v4l2_mbus_pixelcode code;
enum v4l2_colorspace colorspace;
int width;
int height;
const char *sensor_name;
- int cam_fpd_mux_s0_gpio;
- int sel_tvp_fpd_s0;
enum tvp5158_std current_std;
enum tvp5158_signal_present signal_present;
const struct tvp5158_std_info *std_list;
const struct tvp5158_color_format *cfmt;
+
+ struct gpio mux_gpios[MAX_NUM_GPIOS];
+ int num_gpios;
};
static const struct tvp5158_std_info tvp5158_std_list[] = {
static int tvp5158_s_stream(struct v4l2_subdev *sd, int enable)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
+
+ tvp5158_init_gpios(client);
+
if (enable) {
if (vbus_prog == 1)
/* VBUS address value setting */
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct tvp5158_priv *priv = to_tvp5158(client);
- tvp5158_set_gpios(client);
v4l2_info(&priv->subdev, "Currently only D1 resolution is supported\n");
return 0;
return 0;
}
-static int tvp5158_get_gpios(struct device_node *node,
- struct i2c_client *client)
+static int tvp5158_of_probe(struct i2c_client *client,
+ struct device_node *node)
{
-
struct tvp5158_priv *priv = to_tvp5158(client);
- int gpio;
-
- gpio = of_get_gpio(node, 0);
- if (gpio_is_valid(gpio)) {
- priv->cam_fpd_mux_s0_gpio = gpio;
- } else {
- dev_err(&client->dev, "failed to parse CAM_FPD_MUX_S0 gpio\n");
- return -EINVAL;
+ struct gpio *gpios = &priv->mux_gpios[0];
+ unsigned int flags;
+ int i, gpio;
+
+ /* Iterate over all the gpios in the device tree
+ * ENOENT is returned when trying to access last + 1 gpio */
+ for (i = 0; i < MAX_NUM_GPIOS; i++) {
+ gpio = of_get_named_gpio_flags(node, "mux-gpios", i, &flags);
+ if (gpio_is_valid(gpio)) {
+ gpios[i].gpio = gpio;
+ gpios[i].flags = (flags & GPIO_ACTIVE_LOW) ?
+ GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH;
+ gpios[i].label = client->name;
+ } else if (gpio == -ENOENT) {
+ break;
+ } else {
+ return gpio;
+ }
}
- gpio = of_get_gpio(node, 1);
- if (gpio_is_valid(gpio)) {
- priv->sel_tvp_fpd_s0 = gpio;
- } else {
- dev_err(&client->dev, "failed to parse TVP_FPD_MUX_S0 gpio\n");
- return -EINVAL;
- }
-
+ priv->num_gpios = i;
return 0;
}
-static int tvp5158_set_gpios(struct i2c_client *client)
+static int tvp5158_init_gpios(struct i2c_client *client)
{
-
struct tvp5158_priv *priv = to_tvp5158(client);
- struct gpio gpios[] = {
- { priv->sel_tvp_fpd_s0, GPIOF_OUT_INIT_LOW,
- "tvp_fpd_mux_s0" },
- { priv->cam_fpd_mux_s0_gpio, GPIOF_OUT_INIT_HIGH,
- "cam_fpd_mux_s0" },
- };
- int ret = -1;
+ int ret = 0;
- ret = gpio_request_array(gpios, ARRAY_SIZE(gpios));
+ ret = gpio_request_array(priv->mux_gpios, priv->num_gpios);
if (ret)
- return ret;
-
- gpio_free_array(gpios, ARRAY_SIZE(gpios));
+ goto done;
+ gpio_free_array(priv->mux_gpios, priv->num_gpios);
- return 0;
+done:
+ return ret;
}
static struct v4l2_subdev_video_ops tvp5158_video_ops = {
v4l2_i2c_subdev_init(sd, client, &tvp5158_subdev_ops);
- ret = tvp5158_get_gpios(node, client);
+ ret = tvp5158_of_probe(client, node);
if (ret) {
- dev_err(&client->dev, "Unable to get gpios\n");
+ dev_err(&client->dev, "Unable to of_probe\n");
return ret;
}
- ret = tvp5158_set_gpios(client);
+ ret = tvp5158_init_gpios(client);
if (ret) {
- dev_err(&client->dev, "failed to set gpios ERR %d\n", ret);
+ dev_err(&client->dev, "failed to init gpios ERR %d\n", ret);
return ret;
}