aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau
diff options
context:
space:
mode:
authorRob Clark <robdclark@gmail.com>2013-01-08 20:19:13 -0500
committerRob Clark <robdclark@gmail.com>2013-02-17 17:55:43 -0500
commitb3d3de80133d32723224329f87edecaff230fefc (patch)
tree659bd091e4e7fb0f7a35cb27c902638faeab37e0 /drivers/gpu/drm/nouveau
parenta7c47d6dc4a201b811e847e5449c8cffdc556deb (diff)
drm/nouveau: use i2c encoder helper wrappers
Signed-off-by: Rob Clark <robdclark@gmail.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau')
-rw-r--r--drivers/gpu/drm/nouveau/nv04_tv.c39
1 files changed, 13 insertions, 26 deletions
diff --git a/drivers/gpu/drm/nouveau/nv04_tv.c b/drivers/gpu/drm/nouveau/nv04_tv.c
index 62e826a139b3..4a69ccdef9b4 100644
--- a/drivers/gpu/drm/nouveau/nv04_tv.c
+++ b/drivers/gpu/drm/nouveau/nv04_tv.c
@@ -184,14 +184,23 @@ static const struct drm_encoder_funcs nv04_tv_funcs = {
184 .destroy = nv04_tv_destroy, 184 .destroy = nv04_tv_destroy,
185}; 185};
186 186
187static const struct drm_encoder_helper_funcs nv04_tv_helper_funcs = {
188 .dpms = nv04_tv_dpms,
189 .save = drm_i2c_encoder_save,
190 .restore = drm_i2c_encoder_restore,
191 .mode_fixup = drm_i2c_encoder_mode_fixup,
192 .prepare = nv04_tv_prepare,
193 .commit = nv04_tv_commit,
194 .mode_set = nv04_tv_mode_set,
195 .detect = drm_i2c_encoder_detect,
196};
197
187int 198int
188nv04_tv_create(struct drm_connector *connector, struct dcb_output *entry) 199nv04_tv_create(struct drm_connector *connector, struct dcb_output *entry)
189{ 200{
190 struct nouveau_encoder *nv_encoder; 201 struct nouveau_encoder *nv_encoder;
191 struct drm_encoder *encoder; 202 struct drm_encoder *encoder;
192 struct drm_device *dev = connector->dev; 203 struct drm_device *dev = connector->dev;
193 struct drm_encoder_helper_funcs *hfuncs;
194 struct drm_encoder_slave_funcs *sfuncs;
195 struct nouveau_drm *drm = nouveau_drm(dev); 204 struct nouveau_drm *drm = nouveau_drm(dev);
196 struct nouveau_i2c *i2c = nouveau_i2c(drm->device); 205 struct nouveau_i2c *i2c = nouveau_i2c(drm->device);
197 struct nouveau_i2c_port *port = i2c->find(i2c, entry->i2c_index); 206 struct nouveau_i2c_port *port = i2c->find(i2c, entry->i2c_index);
@@ -207,17 +216,11 @@ nv04_tv_create(struct drm_connector *connector, struct dcb_output *entry)
207 if (!nv_encoder) 216 if (!nv_encoder)
208 return -ENOMEM; 217 return -ENOMEM;
209 218
210 hfuncs = kzalloc(sizeof(*hfuncs), GFP_KERNEL);
211 if (!hfuncs) {
212 ret = -ENOMEM;
213 goto fail_free;
214 }
215
216 /* Initialize the common members */ 219 /* Initialize the common members */
217 encoder = to_drm_encoder(nv_encoder); 220 encoder = to_drm_encoder(nv_encoder);
218 221
219 drm_encoder_init(dev, encoder, &nv04_tv_funcs, DRM_MODE_ENCODER_TVDAC); 222 drm_encoder_init(dev, encoder, &nv04_tv_funcs, DRM_MODE_ENCODER_TVDAC);
220 drm_encoder_helper_add(encoder, hfuncs); 223 drm_encoder_helper_add(encoder, &nv04_tv_helper_funcs);
221 224
222 encoder->possible_crtcs = entry->heads; 225 encoder->possible_crtcs = entry->heads;
223 encoder->possible_clones = 0; 226 encoder->possible_clones = 0;
@@ -230,30 +233,14 @@ nv04_tv_create(struct drm_connector *connector, struct dcb_output *entry)
230 if (ret < 0) 233 if (ret < 0)
231 goto fail_cleanup; 234 goto fail_cleanup;
232 235
233 /* Fill the function pointers */
234 sfuncs = get_slave_funcs(encoder);
235
236 *hfuncs = (struct drm_encoder_helper_funcs) {
237 .dpms = nv04_tv_dpms,
238 .save = sfuncs->save,
239 .restore = sfuncs->restore,
240 .mode_fixup = sfuncs->mode_fixup,
241 .prepare = nv04_tv_prepare,
242 .commit = nv04_tv_commit,
243 .mode_set = nv04_tv_mode_set,
244 .detect = sfuncs->detect,
245 };
246
247 /* Attach it to the specified connector. */ 236 /* Attach it to the specified connector. */
248 sfuncs->create_resources(encoder, connector); 237 get_slave_funcs(encoder)->create_resources(encoder, connector);
249 drm_mode_connector_attach_encoder(connector, encoder); 238 drm_mode_connector_attach_encoder(connector, encoder);
250 239
251 return 0; 240 return 0;
252 241
253fail_cleanup: 242fail_cleanup:
254 drm_encoder_cleanup(encoder); 243 drm_encoder_cleanup(encoder);
255 kfree(hfuncs);
256fail_free:
257 kfree(nv_encoder); 244 kfree(nv_encoder);
258 return ret; 245 return ret;
259} 246}