Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

static int adv7180_probe ( struct i2c_client *  client,
const struct i2c_device_id *  id 
) [static]

ADV7180 I2C attach function.

Parameters:
*adapter struct i2c_adapter *.
Returns:
Error code indicating success or failure.
ADV7180 I2C probe function. Function set in i2c_driver struct. Called by insmod.

Parameters:
*adapter I2C adapter descriptor.
Returns:
Error code indicating success or failure.

Read the revision ID of the tvin chip

ADV7180 initialization.

Definition at line 801 of file adv7180.c.

References adv7180_data, adv7180_hard_reset(), ADV7180_NOT_LOCKED, adv7180_read(), gpio_sensor_active(), sensor::i2c_client, sensor::on, sensor::pix, video_fmt_t::raw_height, video_fmt_t::raw_width, sensor::std_id, and sensor::streamcap.

{
      int rev_id;
      int ret = 0;
      struct mxc_tvin_platform_data *plat_data = client->dev.platform_data;

      dev_dbg(&adv7180_data.i2c_client->dev, "In adv7180_probe\n");

      if (plat_data->dvddio_reg) {
            dvddio_regulator =
                regulator_get(&client->dev, plat_data->dvddio_reg);
            if (!IS_ERR_VALUE((unsigned long)dvddio_regulator)) {
                  regulator_set_voltage(dvddio_regulator, 3300000, 3300000);
                  if (regulator_enable(dvddio_regulator) != 0)
                        return -ENODEV;
            }
      }

      if (plat_data->dvdd_reg) {
            dvdd_regulator =
                regulator_get(&client->dev, plat_data->dvdd_reg);
            if (!IS_ERR_VALUE((unsigned long)dvdd_regulator)) {
                  regulator_set_voltage(dvdd_regulator, 1800000, 1800000);
                  if (regulator_enable(dvdd_regulator) != 0)
                        return -ENODEV;
            }
      }

      if (plat_data->avdd_reg) {
            avdd_regulator =
                regulator_get(&client->dev, plat_data->avdd_reg);
            if (!IS_ERR_VALUE((unsigned long)avdd_regulator)) {
                  regulator_set_voltage(avdd_regulator, 1800000, 1800000);
                  if (regulator_enable(avdd_regulator) != 0)
                        return -ENODEV;
            }
      }

      if (plat_data->pvdd_reg) {
            pvdd_regulator =
                regulator_get(&client->dev, plat_data->pvdd_reg);
            if (!IS_ERR_VALUE((unsigned long)pvdd_regulator)) {
                  regulator_set_voltage(pvdd_regulator, 1800000, 1800000);
                  if (regulator_enable(pvdd_regulator) != 0)
                        return -ENODEV;
            }
      }

      if (plat_data->reset)
            plat_data->reset();

      if (plat_data->pwdn)
            plat_data->pwdn(1);

      msleep(1);

      /* Set initial values for the sensor struct. */
      memset(&adv7180_data, 0, sizeof(adv7180_data));
      adv7180_data.i2c_client = client;
      adv7180_data.streamcap.timeperframe.denominator = 30;
      adv7180_data.streamcap.timeperframe.numerator = 1;
      adv7180_data.std_id = V4L2_STD_ALL;
      video_idx = ADV7180_NOT_LOCKED;
      adv7180_data.pix.width = video_fmts[video_idx].raw_width;
      adv7180_data.pix.height = video_fmts[video_idx].raw_height;
      adv7180_data.pix.pixelformat = V4L2_PIX_FMT_UYVY;  /* YUV422 */
      adv7180_data.pix.priv = 1;  /* 1 is used to indicate TV in */
      adv7180_data.on = true;

      gpio_sensor_active();

      dev_dbg(&adv7180_data.i2c_client->dev,
            "%s:adv7180 probe i2c address is 0x%02X \n",
            __func__, adv7180_data.i2c_client->addr);

      /*! Read the revision ID of the tvin chip */
      rev_id = adv7180_read(ADV7180_IDENT);
      dev_dbg(&adv7180_data.i2c_client->dev,
            "%s:Analog Device adv7%2X0 detected! \n", __func__,
            rev_id);

      /*! ADV7180 initialization. */
      adv7180_hard_reset();

      pr_debug("   type is %d (expect %d)\n",
             adv7180_int_device.type, v4l2_int_type_slave);
      pr_debug("   num ioctls is %d\n",
             adv7180_int_device.u.slave->num_ioctls);

      /* This function attaches this structure to the /dev/video0 device.
       * The pointer in priv points to the mt9v111_data structure here.*/
      adv7180_int_device.priv = &adv7180_data;
      ret = v4l2_int_device_register(&adv7180_int_device);

      return ret;
}


Generated by  Doxygen 1.6.0   Back to index