27 #include <linux/i2c.h>
28 #include <linux/slab.h>
32 #include <drm/i915_drm.h>
36 #define SIL164_ADDR 0x38
37 #define CH7xxx_ADDR 0x76
38 #define TFP410_ADDR 0x38
39 #define NS2501_ADDR 0x38
107 static bool intel_dvo_connector_get_hw_state(
struct intel_connector *connector)
111 return intel_dvo->
dev.dev_ops->get_hw_state(&intel_dvo->
dev);
114 static bool intel_dvo_get_hw_state(
struct intel_encoder *encoder,
119 struct intel_dvo *intel_dvo = enc_to_intel_dvo(&encoder->
base);
135 struct intel_dvo *intel_dvo = enc_to_intel_dvo(&encoder->
base);
136 u32 dvo_reg = intel_dvo->
dev.dvo_reg;
139 intel_dvo->
dev.dev_ops->dpms(&intel_dvo->
dev,
false);
147 struct intel_dvo *intel_dvo = enc_to_intel_dvo(&encoder->
base);
148 u32 dvo_reg = intel_dvo->
dev.dvo_reg;
153 intel_dvo->
dev.dev_ops->dpms(&intel_dvo->
dev,
true);
158 struct intel_dvo *intel_dvo = intel_attached_dvo(connector);
165 if (mode == connector->
dpms)
171 crtc = intel_dvo->
base.base.crtc;
173 intel_dvo->
base.connectors_active =
false;
178 intel_dvo->
base.connectors_active =
true;
182 intel_dvo->
dev.dev_ops->dpms(&intel_dvo->
dev,
true);
184 intel_dvo->
dev.dev_ops->dpms(&intel_dvo->
dev,
false);
186 intel_dvo->
base.connectors_active =
false;
194 static int intel_dvo_mode_valid(
struct drm_connector *connector,
197 struct intel_dvo *intel_dvo = intel_attached_dvo(connector);
211 return intel_dvo->
dev.dev_ops->mode_valid(&intel_dvo->
dev, mode);
214 static bool intel_dvo_mode_fixup(
struct drm_encoder *encoder,
218 struct intel_dvo *intel_dvo = enc_to_intel_dvo(encoder);
226 #define C(x) adjusted_mode->x = intel_dvo->panel_fixed_mode->x
239 if (intel_dvo->
dev.dev_ops->mode_fixup)
240 return intel_dvo->
dev.dev_ops->mode_fixup(&intel_dvo->
dev, mode, adjusted_mode);
245 static void intel_dvo_mode_set(
struct drm_encoder *encoder,
252 struct intel_dvo *intel_dvo = enc_to_intel_dvo(encoder);
253 int pipe = intel_crtc->
pipe;
255 u32 dvo_reg = intel_dvo->
dev.dvo_reg, dvo_srcdim_reg;
256 int dpll_reg =
DPLL(pipe);
271 intel_dvo->
dev.dev_ops->mode_set(&intel_dvo->
dev, mode, adjusted_mode);
307 struct intel_dvo *intel_dvo = intel_attached_dvo(connector);
308 return intel_dvo->
dev.dev_ops->detect(&intel_dvo->
dev);
311 static int intel_dvo_get_modes(
struct drm_connector *connector)
313 struct intel_dvo *intel_dvo = intel_attached_dvo(connector);
338 static void intel_dvo_destroy(
struct drm_connector *connector)
346 .mode_fixup = intel_dvo_mode_fixup,
347 .mode_set = intel_dvo_mode_set,
352 .dpms = intel_dvo_dpms,
353 .detect = intel_dvo_detect,
354 .destroy = intel_dvo_destroy,
359 .mode_valid = intel_dvo_mode_valid,
360 .get_modes = intel_dvo_get_modes,
364 static void intel_dvo_enc_destroy(
struct drm_encoder *encoder)
366 struct intel_dvo *intel_dvo = enc_to_intel_dvo(encoder);
368 if (intel_dvo->
dev.dev_ops->destroy)
369 intel_dvo->
dev.dev_ops->destroy(&intel_dvo->
dev);
377 .destroy = intel_dvo_enc_destroy,
391 struct intel_dvo *intel_dvo = intel_attached_dvo(connector);
402 crtc = intel_get_crtc_for_pipe(dev, pipe);
422 struct intel_dvo *intel_dvo;
427 intel_dvo = kzalloc(
sizeof(
struct intel_dvo),
GFP_KERNEL);
431 intel_connector = kzalloc(
sizeof(
struct intel_connector),
GFP_KERNEL);
432 if (!intel_connector) {
437 intel_encoder = &intel_dvo->
base;
439 &intel_dvo_enc_funcs, encoder_type);
441 intel_encoder->
disable = intel_disable_dvo;
442 intel_encoder->
enable = intel_enable_dvo;
444 intel_connector->
get_hw_state = intel_dvo_connector_get_hw_state;
447 for (i = 0; i <
ARRAY_SIZE(intel_dvo_devices); i++) {
470 intel_dvo->
dev = *dvo;
471 if (!dvo->
dev_ops->init(&intel_dvo->
dev, i2c))
475 intel_encoder->
crtc_mask = (1 << 0) | (1 << 1);
480 &intel_dvo_connector_funcs,
487 &intel_dvo_connector_funcs,
493 drm_connector_helper_add(connector,
494 &intel_dvo_connector_helper_funcs);
499 drm_encoder_helper_add(&intel_encoder->
base,
500 &intel_dvo_helper_funcs);
512 intel_dvo_get_current_mode(connector);
522 kfree(intel_connector);