]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/video/fb_ddc.c
2 * driver/vide/fb_ddc.c - DDC/EDID read support.
4 * Copyright (C) 2006 Dennis Munsie <dmunsie@cecropia.com>
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive
11 #include <linux/delay.h>
12 #include <linux/device.h>
14 #include <linux/i2c-algo-bit.h>
20 static unsigned char *fb_do_probe_ddc_edid(struct i2c_adapter
*adapter
)
22 unsigned char start
= 0x0;
23 unsigned char *buf
= kmalloc(EDID_LENGTH
, GFP_KERNEL
);
24 struct i2c_msg msgs
[] = {
39 dev_warn(&adapter
->dev
, "unable to allocate memory for EDID "
44 if (i2c_transfer(adapter
, msgs
, 2) == 2)
47 dev_warn(&adapter
->dev
, "unable to read EDID block.\n");
52 unsigned char *fb_ddc_read(struct i2c_adapter
*adapter
)
54 struct i2c_algo_bit_data
*algo_data
= adapter
->algo_data
;
55 unsigned char *edid
= NULL
;
58 algo_data
->setscl(algo_data
->data
, 1);
60 for (i
= 0; i
< 3; i
++) {
61 /* For some old monitors we need the
62 * following process to initialize/stop DDC
64 algo_data
->setsda(algo_data
->data
, 1);
67 algo_data
->setscl(algo_data
->data
, 1);
68 for (j
= 0; j
< 5; j
++) {
70 if (algo_data
->getscl(algo_data
->data
))
76 algo_data
->setsda(algo_data
->data
, 0);
78 algo_data
->setscl(algo_data
->data
, 0);
80 algo_data
->setsda(algo_data
->data
, 1);
83 /* Do the real work */
84 edid
= fb_do_probe_ddc_edid(adapter
);
85 algo_data
->setsda(algo_data
->data
, 0);
86 algo_data
->setscl(algo_data
->data
, 0);
89 algo_data
->setscl(algo_data
->data
, 1);
90 for (j
= 0; j
< 10; j
++) {
92 if (algo_data
->getscl(algo_data
->data
))
96 algo_data
->setsda(algo_data
->data
, 1);
98 algo_data
->setscl(algo_data
->data
, 0);
99 algo_data
->setsda(algo_data
->data
, 0);
103 /* Release the DDC lines when done or the Apple Cinema HD display
106 algo_data
->setsda(algo_data
->data
, 1);
107 algo_data
->setscl(algo_data
->data
, 1);
112 EXPORT_SYMBOL_GPL(fb_ddc_read
);
114 MODULE_AUTHOR("Dennis Munsie <dmunsie@cecropia.com>");
115 MODULE_DESCRIPTION("DDC/EDID reading support");
116 MODULE_LICENSE("GPL");