33 #define HDMI_READ(reg) readl(hdmi_dev->regs + (reg))
34 #define HDMI_WRITE(reg, val) writel(val, hdmi_dev->regs + (reg))
36 #define HDMI_HCR 0x1000
37 #define HCR_ENABLE_HDCP (1 << 5)
38 #define HCR_ENABLE_AUDIO (1 << 2)
39 #define HCR_ENABLE_PIXEL (1 << 1)
40 #define HCR_ENABLE_TMDS (1 << 0)
42 #define HDMI_HICR 0x1004
43 #define HDMI_HSR 0x1008
44 #define HDMI_HISR 0x100C
45 #define HDMI_DETECT_HDP (1 << 0)
47 #define HDMI_VIDEO_REG 0x3000
48 #define HDMI_UNIT_EN (1 << 7)
49 #define HDMI_MODE_OUTPUT (1 << 0)
50 #define HDMI_HBLANK_A 0x3100
52 #define HDMI_AUDIO_CTRL 0x4000
53 #define HDMI_ENABLE_AUDIO (1 << 0)
55 #define PCH_HTOTAL_B 0x3100
56 #define PCH_HBLANK_B 0x3104
57 #define PCH_HSYNC_B 0x3108
58 #define PCH_VTOTAL_B 0x310C
59 #define PCH_VBLANK_B 0x3110
60 #define PCH_VSYNC_B 0x3114
61 #define PCH_PIPEBSRC 0x311C
63 #define PCH_PIPEB_DSL 0x3800
64 #define PCH_PIPEB_SLC 0x3804
65 #define PCH_PIPEBCONF 0x3808
66 #define PCH_PIPEBSTAT 0x3824
68 #define CDVO_DFT 0x5000
69 #define CDVO_SLEWRATE 0x5004
70 #define CDVO_STRENGTH 0x5008
71 #define CDVO_RCOMP 0x500C
73 #define DPLL_CTRL 0x6000
74 #define DPLL_PDIV_SHIFT 16
75 #define DPLL_PDIV_MASK (0xf << 16)
76 #define DPLL_PWRDN (1 << 4)
77 #define DPLL_RESET (1 << 3)
78 #define DPLL_FASTEN (1 << 2)
79 #define DPLL_ENSTAT (1 << 1)
80 #define DPLL_DITHEN (1 << 0)
82 #define DPLL_DIV_CTRL 0x6004
83 #define DPLL_CLKF_MASK 0xffffffc0
84 #define DPLL_CLKR_MASK (0x3f)
86 #define DPLL_CLK_ENABLE 0x6008
87 #define DPLL_EN_DISP (1 << 31)
88 #define DPLL_SEL_HDMI (1 << 8)
89 #define DPLL_EN_HDMI (1 << 1)
90 #define DPLL_EN_VGA (1 << 0)
92 #define DPLL_ADJUST 0x600C
93 #define DPLL_STATUS 0x6010
94 #define DPLL_UPDATE 0x6014
95 #define DPLL_DFT 0x6020
112 #define VCO_MIN 320000
113 #define VCO_MAX 1650000
128 static void oaktrail_hdmi_audio_enable(
struct drm_device *
dev)
143 static void oaktrail_hdmi_audio_disable(
struct drm_device *
dev)
167 if (dpms_mode == mode)
182 if (mode->
clock > 165000)
184 if (mode->
clock < 20000)
193 static bool oaktrail_hdmi_mode_fixup(
struct drm_encoder *encoder,
210 DRM_DEBUG_KMS(
"HDMI_HSR %x\n", temp);
220 static const unsigned char raw_edid[] = {
221 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x10, 0xac, 0x2f, 0xa0,
222 0x53, 0x55, 0x33, 0x30, 0x16, 0x13, 0x01, 0x03, 0x0e, 0x3a, 0x24, 0x78,
223 0xea, 0xe9, 0xf5, 0xac, 0x51, 0x30, 0xb4, 0x25, 0x11, 0x50, 0x54, 0xa5,
224 0x4b, 0x00, 0x81, 0x80, 0xa9, 0x40, 0x71, 0x4f, 0xb3, 0x00, 0x01, 0x01,
225 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x28, 0x3c, 0x80, 0xa0, 0x70, 0xb0,
226 0x23, 0x40, 0x30, 0x20, 0x36, 0x00, 0x46, 0x6c, 0x21, 0x00, 0x00, 0x1a,
227 0x00, 0x00, 0x00, 0xff, 0x00, 0x47, 0x4e, 0x37, 0x32, 0x31, 0x39, 0x35,
228 0x52, 0x30, 0x33, 0x55, 0x53, 0x0a, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x44,
229 0x45, 0x4c, 0x4c, 0x20, 0x32, 0x37, 0x30, 0x39, 0x57, 0x0a, 0x20, 0x20,
230 0x00, 0x00, 0x00, 0xfd, 0x00, 0x38, 0x4c, 0x1e, 0x53, 0x11, 0x00, 0x0a,
231 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x8d
234 static int oaktrail_hdmi_get_modes(
struct drm_connector *connector)
244 if (i2c_adap ==
NULL) {
245 DRM_ERROR(
"No ddc adapter available!\n");
246 edid = (
struct edid *)raw_edid;
248 edid = (
struct edid *)raw_edid;
269 static void oaktrail_hdmi_mode_set(
struct drm_encoder *encoder,
275 oaktrail_hdmi_audio_enable(dev);
279 static void oaktrail_hdmi_destroy(
struct drm_connector *connector)
285 .dpms = oaktrail_hdmi_dpms,
286 .mode_fixup = oaktrail_hdmi_mode_fixup,
288 .mode_set = oaktrail_hdmi_mode_set,
293 oaktrail_hdmi_connector_helper_funcs = {
294 .get_modes = oaktrail_hdmi_get_modes,
295 .mode_valid = oaktrail_hdmi_mode_valid,
301 .detect = oaktrail_hdmi_detect,
303 .destroy = oaktrail_hdmi_destroy,
306 static void oaktrail_hdmi_enc_destroy(
struct drm_encoder *encoder)
312 .destroy = oaktrail_hdmi_enc_destroy,
323 psb_intel_encoder = kzalloc(
sizeof(
struct psb_intel_encoder),
GFP_KERNEL);
324 if (!psb_intel_encoder)
327 psb_intel_connector = kzalloc(
sizeof(
struct psb_intel_connector),
GFP_KERNEL);
328 if (!psb_intel_connector)
329 goto failed_connector;
331 connector = &psb_intel_connector->
base;
332 encoder = &psb_intel_encoder->
base;
334 &oaktrail_hdmi_connector_funcs,
338 &oaktrail_hdmi_enc_funcs,
345 drm_encoder_helper_add(encoder, &oaktrail_hdmi_helper_funcs);
346 drm_connector_helper_add(connector, &oaktrail_hdmi_connector_helper_funcs);
356 kfree(psb_intel_encoder);
377 dev_err(dev->dev,
"failed to allocate memory\n");
384 dev_err(dev->dev,
"failed to enable hdmi controller\n");
391 if (!hdmi_dev->
regs) {
392 dev_err(dev->dev,
"failed to map hdmi mmio\n");
396 hdmi_dev->
dev = pdev;
397 pci_set_drvdata(pdev, hdmi_dev);
402 dev_err(dev->dev,
"HDMI I2C initialization failed\n");
405 oaktrail_hdmi_audio_disable(dev);
421 pdev = hdmi_dev->
dev;
422 pci_set_drvdata(pdev,
NULL);
479 for (i = 0; i < 256; i++)
533 for (i = 0; i < 256; i++)