Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 310328
b: refs/heads/master
c: 958f271
h: refs/heads/master
v: v3
  • Loading branch information
Tomi Valkeinen committed May 11, 2012
1 parent fd9373d commit 6685487
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 35 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3a028bb99d1f1e5c444060a176cbd4bf93530df3
refs/heads/master: 958f2717b84e88bf833d996997fda8f73276f2af
72 changes: 38 additions & 34 deletions trunk/drivers/video/omap2/displays/panel-tfp410.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,9 @@ struct panel_drv_data {
struct mutex lock;

int pd_gpio;
};

static inline struct tfp410_platform_data
*get_pdata(const struct omap_dss_device *dssdev)
{
return dssdev->data;
}
struct i2c_adapter *i2c_adapter;
};

static int tfp410_power_on(struct omap_dss_device *dssdev)
{
Expand Down Expand Up @@ -90,11 +86,11 @@ static void tfp410_power_off(struct omap_dss_device *dssdev)

static int tfp410_probe(struct omap_dss_device *dssdev)
{
struct tfp410_platform_data *pdata = get_pdata(dssdev);
struct panel_drv_data *ddata;
int r;
int i2c_bus_num;

ddata = kzalloc(sizeof(*ddata), GFP_KERNEL);
ddata = devm_kzalloc(&dssdev->dev, sizeof(*ddata), GFP_KERNEL);
if (!ddata)
return -ENOMEM;

Expand All @@ -104,24 +100,47 @@ static int tfp410_probe(struct omap_dss_device *dssdev)
ddata->dssdev = dssdev;
mutex_init(&ddata->lock);

if (pdata)
if (dssdev->data) {
struct tfp410_platform_data *pdata = dssdev->data;

ddata->pd_gpio = pdata->power_down_gpio;
else
i2c_bus_num = pdata->i2c_bus_num;
} else {
ddata->pd_gpio = -1;
i2c_bus_num = -1;
}

if (gpio_is_valid(ddata->pd_gpio)) {
r = gpio_request_one(ddata->pd_gpio, GPIOF_OUT_INIT_LOW,
"tfp410 pd");
if (r) {
dev_err(&dssdev->dev, "Failed to request PD GPIO %d\n",
ddata->pd_gpio);
ddata->pd_gpio = -1;
return r;
}
}

if (i2c_bus_num != -1) {
struct i2c_adapter *adapter;

adapter = i2c_get_adapter(i2c_bus_num);
if (!adapter) {
dev_err(&dssdev->dev, "Failed to get I2C adapter, bus %d\n",
i2c_bus_num);
r = -EINVAL;
goto err_i2c;
}

ddata->i2c_adapter = adapter;
}

dev_set_drvdata(&dssdev->dev, ddata);

return 0;
err_i2c:
if (gpio_is_valid(ddata->pd_gpio))
gpio_free(ddata->pd_gpio);
return r;
}

static void __exit tfp410_remove(struct omap_dss_device *dssdev)
Expand All @@ -130,14 +149,15 @@ static void __exit tfp410_remove(struct omap_dss_device *dssdev)

mutex_lock(&ddata->lock);

if (ddata->i2c_adapter)
i2c_put_adapter(ddata->i2c_adapter);

if (gpio_is_valid(ddata->pd_gpio))
gpio_free(ddata->pd_gpio);

dev_set_drvdata(&dssdev->dev, NULL);

mutex_unlock(&ddata->lock);

kfree(ddata);
}

static int tfp410_enable(struct omap_dss_device *dssdev)
Expand Down Expand Up @@ -269,27 +289,17 @@ static int tfp410_read_edid(struct omap_dss_device *dssdev,
u8 *edid, int len)
{
struct panel_drv_data *ddata = dev_get_drvdata(&dssdev->dev);
struct tfp410_platform_data *pdata = get_pdata(dssdev);
struct i2c_adapter *adapter;
int r, l, bytes_read;

mutex_lock(&ddata->lock);

if (pdata->i2c_bus_num == 0) {
if (!ddata->i2c_adapter) {
r = -ENODEV;
goto err;
}

adapter = i2c_get_adapter(pdata->i2c_bus_num);
if (!adapter) {
dev_err(&dssdev->dev, "Failed to get I2C adapter, bus %d\n",
pdata->i2c_bus_num);
r = -EINVAL;
goto err;
}

l = min(EDID_LENGTH, len);
r = tfp410_ddc_read(adapter, edid, l, 0);
r = tfp410_ddc_read(ddata->i2c_adapter, edid, l, 0);
if (r)
goto err;

Expand All @@ -299,7 +309,7 @@ static int tfp410_read_edid(struct omap_dss_device *dssdev,
if (len > EDID_LENGTH && edid[0x7e] > 0) {
l = min(EDID_LENGTH, len - EDID_LENGTH);

r = tfp410_ddc_read(adapter, edid + EDID_LENGTH,
r = tfp410_ddc_read(ddata->i2c_adapter, edid + EDID_LENGTH,
l, EDID_LENGTH);
if (r)
goto err;
Expand All @@ -319,21 +329,15 @@ static int tfp410_read_edid(struct omap_dss_device *dssdev,
static bool tfp410_detect(struct omap_dss_device *dssdev)
{
struct panel_drv_data *ddata = dev_get_drvdata(&dssdev->dev);
struct tfp410_platform_data *pdata = get_pdata(dssdev);
struct i2c_adapter *adapter;
unsigned char out;
int r;

mutex_lock(&ddata->lock);

if (pdata->i2c_bus_num == 0)
goto out;

adapter = i2c_get_adapter(pdata->i2c_bus_num);
if (!adapter)
if (!ddata->i2c_adapter)
goto out;

r = tfp410_ddc_read(adapter, &out, 1, 0);
r = tfp410_ddc_read(ddata->i2c_adapter, &out, 1, 0);

mutex_unlock(&ddata->lock);

Expand Down

0 comments on commit 6685487

Please sign in to comment.