Commit ba1677f7 authored by Patrik Jakobsson's avatar Patrik Jakobsson

drm/gma500: Make gma_i2c_chan a subclass of i2c_adapter

This makes it easier to get at the full gma_i2c_chan when having an
i2c_adapter from eg. drm_connector->ddc.
Signed-off-by: default avatarPatrik Jakobsson <patrik.r.jakobsson@gmail.com>
Acked-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20220601092311.22648-3-patrik.r.jakobsson@gmail.com
parent 04477e5e
......@@ -203,7 +203,7 @@ static int cdv_intel_crt_get_modes(struct drm_connector *connector)
{
struct gma_encoder *gma_encoder = gma_attached_encoder(connector);
return psb_intel_ddc_get_modes(connector,
&gma_encoder->ddc_bus->adapter);
&gma_encoder->ddc_bus->base);
}
static int cdv_intel_crt_set_property(struct drm_connector *connector,
......
......@@ -130,7 +130,7 @@ static enum drm_connector_status cdv_hdmi_detect(
struct edid *edid = NULL;
enum drm_connector_status status = connector_status_disconnected;
edid = drm_get_edid(connector, &gma_encoder->i2c_bus->adapter);
edid = drm_get_edid(connector, &gma_encoder->i2c_bus->base);
hdmi_priv->has_hdmi_sink = false;
hdmi_priv->has_hdmi_audio = false;
......@@ -212,7 +212,7 @@ static int cdv_hdmi_get_modes(struct drm_connector *connector)
struct edid *edid = NULL;
int ret = 0;
edid = drm_get_edid(connector, &gma_encoder->i2c_bus->adapter);
edid = drm_get_edid(connector, &gma_encoder->i2c_bus->base);
if (edid) {
drm_connector_update_edid_property(connector, edid);
ret = drm_add_edid_modes(connector, edid);
......@@ -350,7 +350,7 @@ void cdv_hdmi_init(struct drm_device *dev,
goto failed_ddc;
}
hdmi_priv->hdmi_i2c_adapter = &(gma_encoder->i2c_bus->adapter);
hdmi_priv->hdmi_i2c_adapter = &gma_encoder->i2c_bus->base;
hdmi_priv->dev = dev;
return;
......
......@@ -302,7 +302,7 @@ static int cdv_intel_lvds_get_modes(struct drm_connector *connector)
struct psb_intel_mode_device *mode_dev = &dev_priv->mode_dev;
int ret;
ret = psb_intel_ddc_get_modes(connector, &gma_encoder->i2c_bus->adapter);
ret = psb_intel_ddc_get_modes(connector, &gma_encoder->i2c_bus->base);
if (ret)
return ret;
......@@ -583,7 +583,7 @@ void cdv_intel_lvds_init(struct drm_device *dev,
*/
mutex_lock(&dev->mode_config.mutex);
psb_intel_ddc_get_modes(connector,
&gma_encoder->ddc_bus->adapter);
&gma_encoder->ddc_bus->base);
list_for_each_entry(scan, &connector->probed_modes, head) {
if (scan->type & DRM_MODE_TYPE_PREFERRED) {
mode_dev->panel_fixed_mode =
......
......@@ -113,10 +113,10 @@ struct gma_i2c_chan *gma_i2c_create(struct drm_device *dev, const u32 reg,
chan->drm_dev = dev;
chan->reg = reg;
snprintf(chan->adapter.name, I2C_NAME_SIZE, "intel drm %s", name);
chan->adapter.owner = THIS_MODULE;
chan->adapter.algo_data = &chan->algo;
chan->adapter.dev.parent = dev->dev;
snprintf(chan->base.name, I2C_NAME_SIZE, "intel drm %s", name);
chan->base.owner = THIS_MODULE;
chan->base.algo_data = &chan->algo;
chan->base.dev.parent = dev->dev;
chan->algo.setsda = set_data;
chan->algo.setscl = set_clock;
chan->algo.getsda = get_data;
......@@ -125,9 +125,9 @@ struct gma_i2c_chan *gma_i2c_create(struct drm_device *dev, const u32 reg,
chan->algo.timeout = usecs_to_jiffies(2200);
chan->algo.data = chan;
i2c_set_adapdata(&chan->adapter, chan);
i2c_set_adapdata(&chan->base, chan);
if (i2c_bit_add_bus(&chan->adapter))
if (i2c_bit_add_bus(&chan->base))
goto out_free;
/* JJJ: raise SCL and SDA? */
......@@ -153,6 +153,6 @@ void gma_i2c_destroy(struct gma_i2c_chan *chan)
if (!chan)
return;
i2c_del_adapter(&chan->adapter);
i2c_del_adapter(&chan->base);
kfree(chan);
}
......@@ -359,7 +359,7 @@ void oaktrail_lvds_init(struct drm_device *dev,
if (edid == NULL && dev_priv->lpc_gpio_base) {
oaktrail_lvds_i2c_init(encoder);
if (gma_encoder->ddc_bus != NULL) {
i2c_adap = &gma_encoder->ddc_bus->adapter;
i2c_adap = &gma_encoder->ddc_bus->base;
edid = drm_get_edid(connector, i2c_adap);
}
}
......
......@@ -142,10 +142,10 @@ void oaktrail_lvds_i2c_init(struct drm_encoder *encoder)
chan->drm_dev = dev;
chan->reg = dev_priv->lpc_gpio_base;
strncpy(chan->adapter.name, "gma500 LPC", I2C_NAME_SIZE - 1);
chan->adapter.owner = THIS_MODULE;
chan->adapter.algo_data = &chan->algo;
chan->adapter.dev.parent = dev->dev;
strncpy(chan->base.name, "gma500 LPC", I2C_NAME_SIZE - 1);
chan->base.owner = THIS_MODULE;
chan->base.algo_data = &chan->algo;
chan->base.dev.parent = dev->dev;
chan->algo.setsda = set_data;
chan->algo.setscl = set_clock;
chan->algo.getsda = get_data;
......@@ -154,13 +154,13 @@ void oaktrail_lvds_i2c_init(struct drm_encoder *encoder)
chan->algo.timeout = usecs_to_jiffies(2200);
chan->algo.data = chan;
i2c_set_adapdata(&chan->adapter, chan);
i2c_set_adapdata(&chan->base, chan);
set_data(chan, 1);
set_clock(chan, 1);
udelay(50);
if (i2c_bit_add_bus(&chan->adapter)) {
if (i2c_bit_add_bus(&chan->base)) {
kfree(chan);
return;
}
......
......@@ -79,12 +79,13 @@ struct psb_intel_mode_device {
};
struct gma_i2c_chan {
/* for getting at dev. private (mmio etc.) */
struct drm_device *drm_dev;
u32 reg; /* GPIO reg */
struct i2c_adapter adapter;
struct i2c_adapter base;
struct i2c_algo_bit_data algo;
u8 slave_addr;
/* for getting at dev. private (mmio etc.) */
struct drm_device *drm_dev;
u32 reg; /* GPIO reg */
};
struct gma_encoder {
......@@ -175,6 +176,8 @@ struct gma_crtc {
container_of(x, struct gma_encoder, base)
#define to_psb_intel_framebuffer(x) \
container_of(x, struct psb_intel_framebuffer, base)
#define to_gma_i2c_chan(x) \
container_of(x, struct gma_i2c_chan, base)
struct gma_i2c_chan *gma_i2c_create(struct drm_device *dev, const u32 reg,
const char *name);
......
......@@ -113,7 +113,7 @@ static int psb_lvds_i2c_set_brightness(struct drm_device *dev,
out_buf[0] = dev_priv->lvds_bl->brightnesscmd;
out_buf[1] = (u8)blc_i2c_brightness;
if (i2c_transfer(&lvds_i2c_bus->adapter, msgs, 1) == 1) {
if (i2c_transfer(&lvds_i2c_bus->base, msgs, 1) == 1) {
dev_dbg(dev->dev, "I2C set brightness.(command, value) (%d, %d)\n",
dev_priv->lvds_bl->brightnesscmd,
blc_i2c_brightness);
......@@ -497,7 +497,7 @@ static int psb_intel_lvds_get_modes(struct drm_connector *connector)
int ret = 0;
if (!IS_MRST(dev))
ret = psb_intel_ddc_get_modes(connector, &lvds_priv->i2c_bus->adapter);
ret = psb_intel_ddc_get_modes(connector, &lvds_priv->i2c_bus->base);
if (ret)
return ret;
......@@ -727,7 +727,7 @@ void psb_intel_lvds_init(struct drm_device *dev,
* preferred mode is the right one.
*/
mutex_lock(&dev->mode_config.mutex);
psb_intel_ddc_get_modes(connector, &lvds_priv->ddc_bus->adapter);
psb_intel_ddc_get_modes(connector, &lvds_priv->ddc_bus->base);
list_for_each_entry(scan, &connector->probed_modes, head) {
if (scan->type & DRM_MODE_TYPE_PREFERRED) {
mode_dev->panel_fixed_mode =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment