2 * drivers/video/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>
13 #include <linux/module.h>
15 #include <linux/i2c-algo-bit.h>
16 #include <linux/slab.h>
22 static unsigned char *fb_do_probe_ddc_edid(struct i2c_adapter *adapter)
24 unsigned char start = 0x0;
25 unsigned char *buf = kmalloc(EDID_LENGTH, GFP_KERNEL);
26 struct i2c_msg msgs[] = {
41 dev_warn(&adapter->dev, "unable to allocate memory for EDID "
46 if (i2c_transfer(adapter, msgs, 2) == 2)
49 dev_warn(&adapter->dev, "unable to read EDID block.\n");
54 unsigned char *fb_ddc_read(struct i2c_adapter *adapter)
56 struct i2c_algo_bit_data *algo_data = adapter->algo_data;
57 unsigned char *edid = NULL;
60 algo_data->setscl(algo_data->data, 1);
62 for (i = 0; i < 3; i++) {
63 /* For some old monitors we need the
64 * following process to initialize/stop DDC
66 algo_data->setsda(algo_data->data, 1);
69 algo_data->setscl(algo_data->data, 1);
70 for (j = 0; j < 5; j++) {
72 if (algo_data->getscl(algo_data->data))
78 algo_data->setsda(algo_data->data, 0);
80 algo_data->setscl(algo_data->data, 0);
82 algo_data->setsda(algo_data->data, 1);
85 /* Do the real work */
86 edid = fb_do_probe_ddc_edid(adapter);
87 algo_data->setsda(algo_data->data, 0);
88 algo_data->setscl(algo_data->data, 0);
91 algo_data->setscl(algo_data->data, 1);
92 for (j = 0; j < 10; j++) {
94 if (algo_data->getscl(algo_data->data))
98 algo_data->setsda(algo_data->data, 1);
100 algo_data->setscl(algo_data->data, 0);
101 algo_data->setsda(algo_data->data, 0);
105 /* Release the DDC lines when done or the Apple Cinema HD display
108 algo_data->setsda(algo_data->data, 1);
109 algo_data->setscl(algo_data->data, 1);
111 adapter->class |= I2C_CLASS_DDC;
115 EXPORT_SYMBOL_GPL(fb_ddc_read);
117 MODULE_AUTHOR("Dennis Munsie <dmunsie@cecropia.com>");
118 MODULE_DESCRIPTION("DDC/EDID reading support");
119 MODULE_LICENSE("GPL");