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) ...@@ -203,7 +203,7 @@ static int cdv_intel_crt_get_modes(struct drm_connector *connector)
{ {
struct gma_encoder *gma_encoder = gma_attached_encoder(connector); struct gma_encoder *gma_encoder = gma_attached_encoder(connector);
return psb_intel_ddc_get_modes(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, static int cdv_intel_crt_set_property(struct drm_connector *connector,
......
...@@ -130,7 +130,7 @@ static enum drm_connector_status cdv_hdmi_detect( ...@@ -130,7 +130,7 @@ static enum drm_connector_status cdv_hdmi_detect(
struct edid *edid = NULL; struct edid *edid = NULL;
enum drm_connector_status status = connector_status_disconnected; 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_sink = false;
hdmi_priv->has_hdmi_audio = false; hdmi_priv->has_hdmi_audio = false;
...@@ -212,7 +212,7 @@ static int cdv_hdmi_get_modes(struct drm_connector *connector) ...@@ -212,7 +212,7 @@ static int cdv_hdmi_get_modes(struct drm_connector *connector)
struct edid *edid = NULL; struct edid *edid = NULL;
int ret = 0; 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) { if (edid) {
drm_connector_update_edid_property(connector, edid); drm_connector_update_edid_property(connector, edid);
ret = drm_add_edid_modes(connector, edid); ret = drm_add_edid_modes(connector, edid);
...@@ -350,7 +350,7 @@ void cdv_hdmi_init(struct drm_device *dev, ...@@ -350,7 +350,7 @@ void cdv_hdmi_init(struct drm_device *dev,
goto failed_ddc; 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; hdmi_priv->dev = dev;
return; return;
......
...@@ -302,7 +302,7 @@ static int cdv_intel_lvds_get_modes(struct drm_connector *connector) ...@@ -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; struct psb_intel_mode_device *mode_dev = &dev_priv->mode_dev;
int ret; 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) if (ret)
return ret; return ret;
...@@ -583,7 +583,7 @@ void cdv_intel_lvds_init(struct drm_device *dev, ...@@ -583,7 +583,7 @@ void cdv_intel_lvds_init(struct drm_device *dev,
*/ */
mutex_lock(&dev->mode_config.mutex); mutex_lock(&dev->mode_config.mutex);
psb_intel_ddc_get_modes(connector, 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) { list_for_each_entry(scan, &connector->probed_modes, head) {
if (scan->type & DRM_MODE_TYPE_PREFERRED) { if (scan->type & DRM_MODE_TYPE_PREFERRED) {
mode_dev->panel_fixed_mode = mode_dev->panel_fixed_mode =
......
...@@ -113,10 +113,10 @@ struct gma_i2c_chan *gma_i2c_create(struct drm_device *dev, const u32 reg, ...@@ -113,10 +113,10 @@ struct gma_i2c_chan *gma_i2c_create(struct drm_device *dev, const u32 reg,
chan->drm_dev = dev; chan->drm_dev = dev;
chan->reg = reg; chan->reg = reg;
snprintf(chan->adapter.name, I2C_NAME_SIZE, "intel drm %s", name); snprintf(chan->base.name, I2C_NAME_SIZE, "intel drm %s", name);
chan->adapter.owner = THIS_MODULE; chan->base.owner = THIS_MODULE;
chan->adapter.algo_data = &chan->algo; chan->base.algo_data = &chan->algo;
chan->adapter.dev.parent = dev->dev; chan->base.dev.parent = dev->dev;
chan->algo.setsda = set_data; chan->algo.setsda = set_data;
chan->algo.setscl = set_clock; chan->algo.setscl = set_clock;
chan->algo.getsda = get_data; chan->algo.getsda = get_data;
...@@ -125,9 +125,9 @@ struct gma_i2c_chan *gma_i2c_create(struct drm_device *dev, const u32 reg, ...@@ -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.timeout = usecs_to_jiffies(2200);
chan->algo.data = chan; 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; goto out_free;
/* JJJ: raise SCL and SDA? */ /* JJJ: raise SCL and SDA? */
...@@ -153,6 +153,6 @@ void gma_i2c_destroy(struct gma_i2c_chan *chan) ...@@ -153,6 +153,6 @@ void gma_i2c_destroy(struct gma_i2c_chan *chan)
if (!chan) if (!chan)
return; return;
i2c_del_adapter(&chan->adapter); i2c_del_adapter(&chan->base);
kfree(chan); kfree(chan);
} }
...@@ -359,7 +359,7 @@ void oaktrail_lvds_init(struct drm_device *dev, ...@@ -359,7 +359,7 @@ void oaktrail_lvds_init(struct drm_device *dev,
if (edid == NULL && dev_priv->lpc_gpio_base) { if (edid == NULL && dev_priv->lpc_gpio_base) {
oaktrail_lvds_i2c_init(encoder); oaktrail_lvds_i2c_init(encoder);
if (gma_encoder->ddc_bus != NULL) { 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); edid = drm_get_edid(connector, i2c_adap);
} }
} }
......
...@@ -142,10 +142,10 @@ void oaktrail_lvds_i2c_init(struct drm_encoder *encoder) ...@@ -142,10 +142,10 @@ void oaktrail_lvds_i2c_init(struct drm_encoder *encoder)
chan->drm_dev = dev; chan->drm_dev = dev;
chan->reg = dev_priv->lpc_gpio_base; chan->reg = dev_priv->lpc_gpio_base;
strncpy(chan->adapter.name, "gma500 LPC", I2C_NAME_SIZE - 1); strncpy(chan->base.name, "gma500 LPC", I2C_NAME_SIZE - 1);
chan->adapter.owner = THIS_MODULE; chan->base.owner = THIS_MODULE;
chan->adapter.algo_data = &chan->algo; chan->base.algo_data = &chan->algo;
chan->adapter.dev.parent = dev->dev; chan->base.dev.parent = dev->dev;
chan->algo.setsda = set_data; chan->algo.setsda = set_data;
chan->algo.setscl = set_clock; chan->algo.setscl = set_clock;
chan->algo.getsda = get_data; chan->algo.getsda = get_data;
...@@ -154,13 +154,13 @@ void oaktrail_lvds_i2c_init(struct drm_encoder *encoder) ...@@ -154,13 +154,13 @@ void oaktrail_lvds_i2c_init(struct drm_encoder *encoder)
chan->algo.timeout = usecs_to_jiffies(2200); chan->algo.timeout = usecs_to_jiffies(2200);
chan->algo.data = chan; chan->algo.data = chan;
i2c_set_adapdata(&chan->adapter, chan); i2c_set_adapdata(&chan->base, chan);
set_data(chan, 1); set_data(chan, 1);
set_clock(chan, 1); set_clock(chan, 1);
udelay(50); udelay(50);
if (i2c_bit_add_bus(&chan->adapter)) { if (i2c_bit_add_bus(&chan->base)) {
kfree(chan); kfree(chan);
return; return;
} }
......
...@@ -79,12 +79,13 @@ struct psb_intel_mode_device { ...@@ -79,12 +79,13 @@ struct psb_intel_mode_device {
}; };
struct gma_i2c_chan { struct gma_i2c_chan {
/* for getting at dev. private (mmio etc.) */ struct i2c_adapter base;
struct drm_device *drm_dev;
u32 reg; /* GPIO reg */
struct i2c_adapter adapter;
struct i2c_algo_bit_data algo; struct i2c_algo_bit_data algo;
u8 slave_addr; u8 slave_addr;
/* for getting at dev. private (mmio etc.) */
struct drm_device *drm_dev;
u32 reg; /* GPIO reg */
}; };
struct gma_encoder { struct gma_encoder {
...@@ -175,6 +176,8 @@ struct gma_crtc { ...@@ -175,6 +176,8 @@ struct gma_crtc {
container_of(x, struct gma_encoder, base) container_of(x, struct gma_encoder, base)
#define to_psb_intel_framebuffer(x) \ #define to_psb_intel_framebuffer(x) \
container_of(x, struct psb_intel_framebuffer, base) 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, struct gma_i2c_chan *gma_i2c_create(struct drm_device *dev, const u32 reg,
const char *name); const char *name);
......
...@@ -113,7 +113,7 @@ static int psb_lvds_i2c_set_brightness(struct drm_device *dev, ...@@ -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[0] = dev_priv->lvds_bl->brightnesscmd;
out_buf[1] = (u8)blc_i2c_brightness; 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_dbg(dev->dev, "I2C set brightness.(command, value) (%d, %d)\n",
dev_priv->lvds_bl->brightnesscmd, dev_priv->lvds_bl->brightnesscmd,
blc_i2c_brightness); blc_i2c_brightness);
...@@ -497,7 +497,7 @@ static int psb_intel_lvds_get_modes(struct drm_connector *connector) ...@@ -497,7 +497,7 @@ static int psb_intel_lvds_get_modes(struct drm_connector *connector)
int ret = 0; int ret = 0;
if (!IS_MRST(dev)) 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) if (ret)
return ret; return ret;
...@@ -727,7 +727,7 @@ void psb_intel_lvds_init(struct drm_device *dev, ...@@ -727,7 +727,7 @@ void psb_intel_lvds_init(struct drm_device *dev,
* preferred mode is the right one. * preferred mode is the right one.
*/ */
mutex_lock(&dev->mode_config.mutex); 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) { list_for_each_entry(scan, &connector->probed_modes, head) {
if (scan->type & DRM_MODE_TYPE_PREFERRED) { if (scan->type & DRM_MODE_TYPE_PREFERRED) {
mode_dev->panel_fixed_mode = 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