aty128fb: ddc support
PATCH 1/1 aty128fb: ddc support
This patch adds DDC support to the ATI Rage 128 driver. The code is tested on my Apple G4 Cube and detects the 1600x1024 resolution of my SGI SW1600 monitor. The patch breaks out the i2c code from the radeon driver and puts it in a shared file called aty_ddc.c. There are some issues, please comment:
1) The new file aty_ddc.c should be used by both the radeon and the rage code. The Makefile-patch works for built-in drivers, but that's all.
2) The code affects the radeon code, but I have not tested it on a radeon.
3) I got the register definitions from the gatos code, but that code only had one I2C channel. And that channel did not detect my monitor. So I did some guess work and figured out that another channel existed. I suspect that channel 0 is mapped to the ADC port and channel 1 is mapped to the VGA port on my board. And I have not idea how this affects other Rage-based boards.
4) The DDC support is default off, and when enabled it currently overrides the selected video mode if a DDC-monitor is connected.
5) I saw that some patches float around that improves the radeon ddc code. These patches should be ported to this patch.
drivers/video/aty/aty128fb.c +82 -1
@@ -29,10 +29,12 @@* - PCI ID update * - replace ROM BIOS search * +* Magnus Damm <[email protected]> +* - I2C/DDC probe support +* * Based off of Geert's atyfb.c and vfb.c. * * TODO: -* - monitor sensing (DDC) * - virtual display * - other platform support (only ppc/x86 supported) * - hardware cursor support
@@ -87,6 +89,11 @@#include <video/aty128.h> +#ifdef CONFIG_FB_ATY128_I2C +#include "aty_ddc.h" +#include "../edid.h" +#endif +/* Debug flag */ #undef DEBUG
@@ -1702,6 +1709,75 @@ int __init aty128fb_setup(char *options)return 0 ; } +#ifdef CONFIG_FB_ATY128_I2C + +static u32 aty128fb_read_ddc (void *vp) +{ +struct aty128fb_par *par = vp; +return aty_ld_le32 (GPIO_MONID ); +} + +static void aty128fb_write_ddc (void *vp,u32 data) +{ +struct aty128fb_par *par = vp; +aty_st_le32 (GPIO_MONID , data); +} + +static void aty128fb_init_ddc (struct aty128fb_par *par,int channel,struct aty_ddc_i2c_chan *ch) +{ +/* different bits... */ + +if (channel ==0 ) { + ch->clk_out_en =GPIO_MONID_EN_3 ; + ch->data_out_en =GPIO_MONID_EN_0 ; + ch->clk_input =GPIO_MONID_Y_3 ; + ch->data_input =GPIO_MONID_Y_0 ; + ch->clk_output =GPIO_MONID_A_3 ; + ch->data_output =GPIO_MONID_A_0 ; + } +else { + ch->clk_out_en =GPIO_MONID_EN_2 ; + ch->data_out_en =GPIO_MONID_EN_1 ; + ch->clk_input =GPIO_MONID_Y_2 ; + ch->data_input =GPIO_MONID_Y_1 ; + ch->clk_output =GPIO_MONID_A_2 ; + ch->data_output =GPIO_MONID_A_1 ; + } + + ch->data = par; + +/* ... same registers */ + + ch->read = aty128fb_read_ddc; + ch->write = aty128fb_write_ddc; + +aty_ddc_init (ch,"monid" , par->pdev); +} + +void aty128fb_probe_ddc (struct aty128fb_par *par,struct fb_var_screeninfo *vp) +{ +char edid[EDID_LENGTH ]; +int k, ret =-1 ; +struct aty_ddc_i2c_chan ch; + +for (k =0 ; k <2 ; k++) { +memset (&ch,0 ,sizeof (ch)); +memset (&edid,0 ,sizeof (edid)); + +aty128fb_init_ddc (par, k, &ch); + + ret =aty_ddc_probe (&ch, edid,sizeof (edid)); + +aty_ddc_cleanup (&ch); + +if (ret ==0 &&fb_parse_edid (edid, vp) ==0 ) { +printk (KERN_INFO "aty128fb: ddc monitor present at channel %d\n" , k); +return ; + } + } +} + +#endif /* CONFIG_FB_ATY128_I2C */ /* * Initialisation
@@ -1819,6 +1895,11 @@ static int __init aty128_init(struct pci var = default_var; } +#ifdef CONFIG_FB_ATY128_I2C + par->pdev = pdev; +aty128fb_probe_ddc (par, &var); +#endif /* CONFIG_FB_ATY128_I2C */ + var.accel_flags &= ~FB_ACCELF_TEXT ;// var.accel_flags |= FB_ACCELF_TEXT;/* FIXME Will add accel later */
drivers/video/aty/aty_ddc.c +208 -0
208 lines not on this page · raw message
drivers/video/aty/aty_ddc.h +30 -0
@@ -0,0 +1,30 @@ +#ifndef __ATY_DDC_H__ +#define __ATY_DDC_H__ + +#include <linux/i2c.h> +#include <linux/i2c-id.h> +#include <linux/i2c-algo-bit.h> + +struct aty_ddc_i2c_chan { +struct i2c_adapter adapter; +struct i2c_algo_bit_data algo; + +u32 clk_out_en; +u32 data_out_en; +u32 clk_input; +u32 data_input; +u32 clk_output; +u32 data_output; + +void *data; + +u32 (*read)(void *vp); +void (*write)(void *vp,u32 data); +}; + +int aty_ddc_init (struct aty_ddc_i2c_chan *chan,const char *name,struct pci_dev *pdev); +void aty_ddc_cleanup (struct aty_ddc_i2c_chan *ch); + +int aty_ddc_probe (struct aty_ddc_i2c_chan *ch,u8 *edid,int len); + +#endif /* ATY_DDC_H__ */
drivers/video/aty/Makefile +2 -2
@@ -1,6 +1,6 @@ obj-$(CONFIG_FB_ATY) += atyfb.o -obj-$(CONFIG_FB_ATY128) += aty128fb.o -obj-$(CONFIG_FB_RADEON) += radeonfb.o +obj-$(CONFIG_FB_ATY128) += aty128fb.o aty_ddc.o +obj-$(CONFIG_FB_RADEON) += radeonfb.o aty_ddc.o atyfb-y := atyfb_base.o mach64_accel.o mach64_cursor.o atyfb-$(CONFIG_FB_ATY_GX) += mach64_gx.o
drivers/video/aty/radeonfb.h +2 -7
@@ -255,12 +255,7 @@ struct panel_info {struct radeonfb_info ;#ifdef CONFIG_FB_RADEON_I2C -struct radeon_i2c_chan { -struct radeonfb_info *rinfo; -u32 ddc_reg; -struct i2c_adapter adapter; -struct i2c_algo_bit_data algo; -}; +#include "aty_ddc.h" #endif enum radeon_pm_mode {
@@ -345,7 +340,7 @@ struct radeonfb_info {u32 pending_lvds_gen_cntl;#ifdef CONFIG_FB_RADEON_I2C -struct radeon_i2c_chan i2c[4 ]; +struct aty_ddc_i2c_chan i2c[4 ];#endif u32 cfg_save[64 ];
drivers/video/aty/radeon_i2c.c +112 -207
354 lines not on this page · raw message
drivers/video/Kconfig +10 -0
@@ -723,6 +723,9 @@ config FB_RADEON_DEBUG config FB_ATY128 tristate "ATI Rage128 display support" depends on FB && PCI + select I2C_ALGOBIT if FB_ATY128_I2C + select I2C if FB_ATY128_I2C + select FB_MODE_HELPERS help This driver supports graphics boards with the ATI Rage128 chips. Say Y if you have such a graphics board and read
@@ -731,6 +734,13 @@ config FB_ATY128 To compile this driver as a module, choose M here: the module will be called aty128fb. +config FB_ATY128_I2C + bool "DDC/I2C for ATI Rage128 support" + depends on FB_ATY128 + default n + help + Say Y here if you want DDC/I2C support for your Rage128 board. + config FB_ATY tristate "ATI Mach64 display support" if PCI || ATARI depends on FB
include/video/aty128.h +22 -1
@@ -4,6 +4,7 @@* * Anthony Tong <[email protected]>, 1999 * Brad Douglas <[email protected]>, 2000 +* Magnus Damm <[email protected]>, 2005 */ #ifndef REG_RAGE128_H
@@ -18,6 +19,7 @@#define CRTC_GEN_CNTL 0x0050#define CRTC_EXT_CNTL 0x0054#define DAC_CNTL 0x0058 +#define GPIO_MONID 0x0068#define I2C_CNTL_1 0x0094#define PALETTE_INDEX 0x00b0#define PALETTE_DATA 0x00b4
@@ -415,7 +417,26 @@#define PWR_MGT_SLOWDOWN_MCLK 0x00002000#define PMI_PMSCR_REG 0x60 - + +/* MONID constants - used for ddc/edid probing */ + +#define GPIO_MONID_A_0 (1 << 0) +#define GPIO_MONID_A_1 (1 << 1) +#define GPIO_MONID_A_2 (1 << 2) +#define GPIO_MONID_A_3 (1 << 3) +#define GPIO_MONID_Y_0 (1 << 8) +#define GPIO_MONID_Y_1 (1 << 9) +#define GPIO_MONID_Y_2 (1 << 10) +#define GPIO_MONID_Y_3 (1 << 11) +#define GPIO_MONID_EN_0 (1 << 16) +#define GPIO_MONID_EN_1 (1 << 17) +#define GPIO_MONID_EN_2 (1 << 18) +#define GPIO_MONID_EN_3 (1 << 19) +#define GPIO_MONID_MASK_0 (1 << 24) +#define GPIO_MONID_MASK_1 (1 << 25) +#define GPIO_MONID_MASK_2 (1 << 26) +#define GPIO_MONID_MASK_3 (1 << 27) +/* used by ATI bug fix for hardware ROM */ #define RAGE128_MPP_TB_CONFIG 0x01c0
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click