diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-09-14 11:46:59 -0400 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-09-14 16:08:36 -0400 |
commit | 890f3359f7b84d7015104360d647ccac5f515542 (patch) | |
tree | 88c65ad9638fd84d3921fbe9a9fbecb42816c1ec /drivers/gpu/drm/i915/intel_i2c.c | |
parent | 2cf34d7b7ee99c27c1a6bdd2f91344cbfa5fef5c (diff) |
drm/i915/i2c: Track the parent encoder rather than just the dev
The SDVO proxy i2c adapter wants to be able to use information stored in
the encoder, so pass that through intel_i2c rather than iterate over all
known encoders every time.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_i2c.c')
-rw-r--r-- | drivers/gpu/drm/i915/intel_i2c.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/drivers/gpu/drm/i915/intel_i2c.c b/drivers/gpu/drm/i915/intel_i2c.c index de03989d6df3..d3d65a9cfba1 100644 --- a/drivers/gpu/drm/i915/intel_i2c.c +++ b/drivers/gpu/drm/i915/intel_i2c.c | |||
@@ -58,25 +58,31 @@ void intel_i2c_quirk_set(struct drm_device *dev, bool enable) | |||
58 | 58 | ||
59 | #define I2C_RISEFALL_TIME 20 | 59 | #define I2C_RISEFALL_TIME 20 |
60 | 60 | ||
61 | static inline struct drm_i915_private * | ||
62 | get_dev_priv(struct intel_i2c_chan *chan) | ||
63 | { | ||
64 | return chan->encoder->base.dev->dev_private; | ||
65 | } | ||
66 | |||
61 | static int get_clock(void *data) | 67 | static int get_clock(void *data) |
62 | { | 68 | { |
63 | struct intel_i2c_chan *chan = data; | 69 | struct intel_i2c_chan *chan = data; |
64 | struct drm_i915_private *dev_priv = chan->drm_dev->dev_private; | 70 | struct drm_i915_private *dev_priv = get_dev_priv(chan); |
65 | return (I915_READ(chan->reg) & GPIO_CLOCK_VAL_IN) != 0; | 71 | return (I915_READ(chan->reg) & GPIO_CLOCK_VAL_IN) != 0; |
66 | } | 72 | } |
67 | 73 | ||
68 | static int get_data(void *data) | 74 | static int get_data(void *data) |
69 | { | 75 | { |
70 | struct intel_i2c_chan *chan = data; | 76 | struct intel_i2c_chan *chan = data; |
71 | struct drm_i915_private *dev_priv = chan->drm_dev->dev_private; | 77 | struct drm_i915_private *dev_priv = get_dev_priv(chan); |
72 | return (I915_READ(chan->reg) & GPIO_DATA_VAL_IN) != 0; | 78 | return (I915_READ(chan->reg) & GPIO_DATA_VAL_IN) != 0; |
73 | } | 79 | } |
74 | 80 | ||
75 | static void set_clock(void *data, int state_high) | 81 | static void set_clock(void *data, int state_high) |
76 | { | 82 | { |
77 | struct intel_i2c_chan *chan = data; | 83 | struct intel_i2c_chan *chan = data; |
78 | struct drm_device *dev = chan->drm_dev; | 84 | struct drm_i915_private *dev_priv = get_dev_priv(chan); |
79 | struct drm_i915_private *dev_priv = chan->drm_dev->dev_private; | 85 | struct drm_device *dev = dev_priv->dev; |
80 | u32 reserved = 0, clock_bits; | 86 | u32 reserved = 0, clock_bits; |
81 | 87 | ||
82 | /* On most chips, these bits must be preserved in software. */ | 88 | /* On most chips, these bits must be preserved in software. */ |
@@ -96,8 +102,8 @@ static void set_clock(void *data, int state_high) | |||
96 | static void set_data(void *data, int state_high) | 102 | static void set_data(void *data, int state_high) |
97 | { | 103 | { |
98 | struct intel_i2c_chan *chan = data; | 104 | struct intel_i2c_chan *chan = data; |
99 | struct drm_device *dev = chan->drm_dev; | 105 | struct drm_i915_private *dev_priv = get_dev_priv(chan); |
100 | struct drm_i915_private *dev_priv = chan->drm_dev->dev_private; | 106 | struct drm_device *dev = dev_priv->dev; |
101 | u32 reserved = 0, data_bits; | 107 | u32 reserved = 0, data_bits; |
102 | 108 | ||
103 | /* On most chips, these bits must be preserved in software. */ | 109 | /* On most chips, these bits must be preserved in software. */ |
@@ -153,16 +159,18 @@ intel_i2c_reset_gmbus(struct drm_device *dev) | |||
153 | * %GPIOH | 159 | * %GPIOH |
154 | * see PRM for details on how these different busses are used. | 160 | * see PRM for details on how these different busses are used. |
155 | */ | 161 | */ |
156 | struct i2c_adapter *intel_i2c_create(struct drm_device *dev, const u32 reg, | 162 | struct i2c_adapter *intel_i2c_create(struct intel_encoder *encoder, |
163 | const u32 reg, | ||
157 | const char *name) | 164 | const char *name) |
158 | { | 165 | { |
159 | struct intel_i2c_chan *chan; | 166 | struct intel_i2c_chan *chan; |
167 | struct drm_device *dev = encoder->base.dev; | ||
160 | 168 | ||
161 | chan = kzalloc(sizeof(struct intel_i2c_chan), GFP_KERNEL); | 169 | chan = kzalloc(sizeof(struct intel_i2c_chan), GFP_KERNEL); |
162 | if (!chan) | 170 | if (!chan) |
163 | goto out_free; | 171 | goto out_free; |
164 | 172 | ||
165 | chan->drm_dev = dev; | 173 | chan->encoder = encoder; |
166 | chan->reg = reg; | 174 | chan->reg = reg; |
167 | snprintf(chan->adapter.name, I2C_NAME_SIZE, "intel drm %s", name); | 175 | snprintf(chan->adapter.name, I2C_NAME_SIZE, "intel drm %s", name); |
168 | chan->adapter.owner = THIS_MODULE; | 176 | chan->adapter.owner = THIS_MODULE; |
@@ -178,7 +186,7 @@ struct i2c_adapter *intel_i2c_create(struct drm_device *dev, const u32 reg, | |||
178 | 186 | ||
179 | i2c_set_adapdata(&chan->adapter, chan); | 187 | i2c_set_adapdata(&chan->adapter, chan); |
180 | 188 | ||
181 | if(i2c_bit_add_bus(&chan->adapter)) | 189 | if (i2c_bit_add_bus(&chan->adapter)) |
182 | goto out_free; | 190 | goto out_free; |
183 | 191 | ||
184 | intel_i2c_reset_gmbus(dev); | 192 | intel_i2c_reset_gmbus(dev); |