Blame view
drivers/video/fb_ddc.c
2.6 KB
fc5891c8a [PATCH] fbdev: Ad... |
1 |
/* |
355b200ba video: Add module... |
2 |
* drivers/video/fb_ddc.c - DDC/EDID read support. |
fc5891c8a [PATCH] fbdev: Ad... |
3 4 5 6 7 8 9 10 11 12 |
* * Copyright (C) 2006 Dennis Munsie <dmunsie@cecropia.com> * * This file is subject to the terms and conditions of the GNU General Public * License. See the file COPYING in the main directory of this archive * for more details. */ #include <linux/delay.h> #include <linux/device.h> |
355b200ba video: Add module... |
13 |
#include <linux/module.h> |
fc5891c8a [PATCH] fbdev: Ad... |
14 15 |
#include <linux/fb.h> #include <linux/i2c-algo-bit.h> |
5a0e3ad6a include cleanup: ... |
16 |
#include <linux/slab.h> |
fc5891c8a [PATCH] fbdev: Ad... |
17 18 19 20 21 22 23 24 |
#include "edid.h" #define DDC_ADDR 0x50 static unsigned char *fb_do_probe_ddc_edid(struct i2c_adapter *adapter) { unsigned char start = 0x0; |
4be703906 Fix generic fb_dd... |
25 |
unsigned char *buf = kmalloc(EDID_LENGTH, GFP_KERNEL); |
fc5891c8a [PATCH] fbdev: Ad... |
26 27 28 |
struct i2c_msg msgs[] = { { .addr = DDC_ADDR, |
4be703906 Fix generic fb_dd... |
29 |
.flags = 0, |
fc5891c8a [PATCH] fbdev: Ad... |
30 31 32 33 34 35 |
.len = 1, .buf = &start, }, { .addr = DDC_ADDR, .flags = I2C_M_RD, .len = EDID_LENGTH, |
4be703906 Fix generic fb_dd... |
36 |
.buf = buf, |
fc5891c8a [PATCH] fbdev: Ad... |
37 38 |
} }; |
fc5891c8a [PATCH] fbdev: Ad... |
39 |
|
fc5891c8a [PATCH] fbdev: Ad... |
40 41 42 43 44 45 |
if (!buf) { dev_warn(&adapter->dev, "unable to allocate memory for EDID " "block. "); return NULL; } |
fc5891c8a [PATCH] fbdev: Ad... |
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
if (i2c_transfer(adapter, msgs, 2) == 2) return buf; dev_warn(&adapter->dev, "unable to read EDID block. "); kfree(buf); return NULL; } unsigned char *fb_ddc_read(struct i2c_adapter *adapter) { struct i2c_algo_bit_data *algo_data = adapter->algo_data; unsigned char *edid = NULL; int i, j; algo_data->setscl(algo_data->data, 1); |
fc5891c8a [PATCH] fbdev: Ad... |
63 64 65 66 67 |
for (i = 0; i < 3; i++) { /* For some old monitors we need the * following process to initialize/stop DDC */ |
b64d70825 fb_ddc: fix DDC l... |
68 |
algo_data->setsda(algo_data->data, 1); |
fc5891c8a [PATCH] fbdev: Ad... |
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
msleep(13); algo_data->setscl(algo_data->data, 1); for (j = 0; j < 5; j++) { msleep(10); if (algo_data->getscl(algo_data->data)) break; } if (j == 5) continue; algo_data->setsda(algo_data->data, 0); msleep(15); algo_data->setscl(algo_data->data, 0); msleep(15); algo_data->setsda(algo_data->data, 1); msleep(15); /* Do the real work */ edid = fb_do_probe_ddc_edid(adapter); algo_data->setsda(algo_data->data, 0); algo_data->setscl(algo_data->data, 0); msleep(15); algo_data->setscl(algo_data->data, 1); for (j = 0; j < 10; j++) { msleep(10); if (algo_data->getscl(algo_data->data)) break; } algo_data->setsda(algo_data->data, 1); msleep(15); algo_data->setscl(algo_data->data, 0); |
b64d70825 fb_ddc: fix DDC l... |
103 |
algo_data->setsda(algo_data->data, 0); |
fc5891c8a [PATCH] fbdev: Ad... |
104 105 106 107 108 109 |
if (edid) break; } /* Release the DDC lines when done or the Apple Cinema HD display * will switch off */ |
b64d70825 fb_ddc: fix DDC l... |
110 111 |
algo_data->setsda(algo_data->data, 1); algo_data->setscl(algo_data->data, 1); |
fc5891c8a [PATCH] fbdev: Ad... |
112 |
|
c1b6b4f23 i2c: Let framebuf... |
113 |
adapter->class |= I2C_CLASS_DDC; |
fc5891c8a [PATCH] fbdev: Ad... |
114 115 116 117 118 119 120 121 |
return edid; } EXPORT_SYMBOL_GPL(fb_ddc_read); MODULE_AUTHOR("Dennis Munsie <dmunsie@cecropia.com>"); MODULE_DESCRIPTION("DDC/EDID reading support"); MODULE_LICENSE("GPL"); |