diff options
author | Eric Anholt <eric@anholt.net> | 2006-12-18 15:32:35 -0800 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2006-12-18 15:39:30 -0800 |
commit | fa4642048b183134544fc5ee47558446d27f6194 (patch) | |
tree | a46711c6bf8887a3e4cc66b38e27818896775efe /src | |
parent | dcb069a1da6b3300b0772843dd9b67efdf319637 (diff) |
Clean up i2c_vid interface, including de-StudlyCapsing and removing dead code.
The old Init() function is removed and the previous Detect() function is now
init(). This leaves us room in the namespace for a detect() like other
outputs have ("is the monitor connected?"). Also, Power() became dpms(),
taking a DPMSMode*. In general, the mode setting path now matches the intel
internal path, except for the lack of mode_fixup().
Diffstat (limited to 'src')
-rw-r--r-- | src/ch7xxx/ch7xxx.c | 31 | ||||
-rw-r--r-- | src/i2c_vid.h | 15 | ||||
-rw-r--r-- | src/i830_dvo.c | 19 | ||||
-rw-r--r-- | src/sil164/sil164.c | 53 |
4 files changed, 51 insertions, 67 deletions
diff --git a/src/ch7xxx/ch7xxx.c b/src/ch7xxx/ch7xxx.c index 61ab20d1..b1e8cbd7 100644 --- a/src/ch7xxx/ch7xxx.c +++ b/src/ch7xxx/ch7xxx.c @@ -32,6 +32,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "compiler.h" #include "miscstruct.h" #include "xf86i2c.h" +#define DPMS_SERVER +#include <X11/extensions/dpms.h> #include "../i2c_vid.h" #include "ch7xxx.h" @@ -112,7 +114,7 @@ ch7xxx_write(struct ch7xxx_priv *dev_priv, int addr, unsigned char ch) } static void * -ch7xxx_probe(I2CBusPtr b, I2CSlaveAddr addr) +ch7xxx_init(I2CBusPtr b, I2CSlaveAddr addr) { /* this will detect the CH7xxx chip on the specified i2c bus */ struct ch7xxx_priv *dev_priv; @@ -171,14 +173,6 @@ out: return NULL; } - -static Bool -ch7xxx_init(I2CDevPtr d) -{ - /* not much to do */ - return TRUE; -} - static ModeStatus ch7xxx_mode_valid(I2CDevPtr d, DisplayModePtr mode) { @@ -228,11 +222,11 @@ ch7xxx_mode_set(I2CDevPtr d, DisplayModePtr mode) /* set the CH7xxx power state */ static void -ch7xxx_power(I2CDevPtr d, Bool on) +ch7xxx_dpms(I2CDevPtr d, int mode) { struct ch7xxx_priv *dev_priv = d->DriverPrivate.ptr; - if (on) + if (mode == DPMSModeOn) ch7xxx_write(dev_priv, CH7xxx_PM, CH7xxx_PM_DVIL | CH7xxx_PM_DVIP); else ch7xxx_write(dev_priv, CH7xxx_PM, CH7xxx_PM_FPD); @@ -280,12 +274,11 @@ ch7xxx_restore(I2CDevPtr d) } I830I2CVidOutputRec CH7xxxVidOutput = { - ch7xxx_probe, - ch7xxx_init, - ch7xxx_mode_valid, - ch7xxx_mode_set, - ch7xxx_power, - ch7xxx_dump_regs, - ch7xxx_save, - ch7xxx_restore, + .init = ch7xxx_init, + .mode_valid = ch7xxx_mode_valid, + .mode_set = ch7xxx_mode_set, + .dpms = ch7xxx_dpms, + .dump_regs = ch7xxx_dump_regs, + .save = ch7xxx_save, + .restore = ch7xxx_restore, }; diff --git a/src/i2c_vid.h b/src/i2c_vid.h index 5a743d29..877122fd 100644 --- a/src/i2c_vid.h +++ b/src/i2c_vid.h @@ -3,14 +3,13 @@ #define I2C_VID_H typedef struct _I830I2CVidOutputRec { - void *(*Detect)(I2CBusPtr b, I2CSlaveAddr addr); - Bool (*Init)(I2CDevPtr d); - ModeStatus (*ModeValid)(I2CDevPtr d, DisplayModePtr mode); - void (*Mode)(I2CDevPtr d, DisplayModePtr mode); - void (*Power)(I2CDevPtr d, Bool On); - void (*PrintRegs)(I2CDevPtr d); - void (*SaveRegs)(I2CDevPtr d); - void (*RestoreRegs)(I2CDevPtr d); + void *(*init)(I2CBusPtr b, I2CSlaveAddr addr); + ModeStatus (*mode_valid)(I2CDevPtr d, DisplayModePtr mode); + void (*mode_set)(I2CDevPtr d, DisplayModePtr mode); + void (*dpms)(I2CDevPtr d, int mode); + void (*dump_regs)(I2CDevPtr d); + void (*save)(I2CDevPtr d); + void (*restore)(I2CDevPtr d); } I830I2CVidOutputRec, *I830I2CVidOutputPtr; #endif diff --git a/src/i830_dvo.c b/src/i830_dvo.c index 804f0fc1..c3ad4c08 100644 --- a/src/i830_dvo.c +++ b/src/i830_dvo.c @@ -62,12 +62,13 @@ i830_dvo_dpms(xf86OutputPtr output, int mode) ScrnInfoPtr pScrn = output->scrn; I830Ptr pI830 = I830PTR(pScrn); I830OutputPrivatePtr intel_output = output->driver_private; + void * dev_priv = intel_output->i2c_drv->dev_priv; if (mode == DPMSModeOn) { OUTREG(DVOC, INREG(DVOC) | DVO_ENABLE); - (*intel_output->i2c_drv->vid_rec->Power)(intel_output->i2c_drv->dev_priv, TRUE); + (*intel_output->i2c_drv->vid_rec->dpms)(dev_priv, mode); } else { - (*intel_output->i2c_drv->vid_rec->Power)(intel_output->i2c_drv->dev_priv, FALSE); + (*intel_output->i2c_drv->vid_rec->dpms)(dev_priv, mode); OUTREG(DVOC, INREG(DVOC) & ~DVO_ENABLE); } } @@ -78,6 +79,7 @@ i830_dvo_save(xf86OutputPtr output) ScrnInfoPtr pScrn = output->scrn; I830Ptr pI830 = I830PTR(pScrn); I830OutputPrivatePtr intel_output = output->driver_private; + void * dev_priv = intel_output->i2c_drv->dev_priv; /* Each output should probably just save the registers it touches, but for * now, use more overkill. @@ -86,7 +88,7 @@ i830_dvo_save(xf86OutputPtr output) pI830->saveDVOB = INREG(DVOB); pI830->saveDVOC = INREG(DVOC); - (*intel_output->i2c_drv->vid_rec->SaveRegs)(intel_output->i2c_drv->dev_priv); + (*intel_output->i2c_drv->vid_rec->save)(dev_priv); } static void @@ -95,12 +97,13 @@ i830_dvo_restore(xf86OutputPtr output) ScrnInfoPtr pScrn = output->scrn; I830Ptr pI830 = I830PTR(pScrn); I830OutputPrivatePtr intel_output = output->driver_private; + void * dev_priv = intel_output->i2c_drv->dev_priv; OUTREG(DVOA, pI830->saveDVOA); OUTREG(DVOB, pI830->saveDVOB); OUTREG(DVOC, pI830->saveDVOC); - (*intel_output->i2c_drv->vid_rec->RestoreRegs)(intel_output->i2c_drv->dev_priv); + (*intel_output->i2c_drv->vid_rec->restore)(dev_priv); } static int @@ -114,7 +117,7 @@ i830_dvo_mode_valid(xf86OutputPtr output, DisplayModePtr pMode) /* XXX: Validate clock range */ - return intel_output->i2c_drv->vid_rec->ModeValid(dev_priv, pMode); + return intel_output->i2c_drv->vid_rec->mode_valid(dev_priv, pMode); } static Bool @@ -139,8 +142,8 @@ i830_dvo_mode_set(xf86OutputPtr output, DisplayModePtr mode, CARD32 dvo; int dpll_reg = (pipe == 0) ? DPLL_A : DPLL_B; - intel_output->i2c_drv->vid_rec->Mode(intel_output->i2c_drv->dev_priv, - mode); + intel_output->i2c_drv->vid_rec->mode_set(intel_output->i2c_drv->dev_priv, + mode); /* Save the data order, since I don't know what it should be set to. */ dvo = INREG(DVOC) & (DVO_PRESERVE_MASK | DVO_DATA_ORDER_GBRG); @@ -196,7 +199,7 @@ I830I2CDetectDVOControllers(ScrnInfoPtr pScrn, I2CBusPtr pI2CBus, ret_ptr = NULL; drv->vid_rec = LoaderSymbol(drv->fntablename); if (drv->vid_rec != NULL) - ret_ptr = drv->vid_rec->Detect(pI2CBus, drv->address); + ret_ptr = drv->vid_rec->init(pI2CBus, drv->address); if (ret_ptr != NULL) { drv->dev_priv = ret_ptr; diff --git a/src/sil164/sil164.c b/src/sil164/sil164.c index 0a68d691..497336cc 100644 --- a/src/sil164/sil164.c +++ b/src/sil164/sil164.c @@ -32,16 +32,13 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "compiler.h" #include "miscstruct.h" #include "xf86i2c.h" +#define DPMS_SERVER +#include <X11/extensions/dpms.h> #include "../i2c_vid.h" #include "sil164.h" #include "sil164_reg.h" -static void -sil164PrintRegs(I2CDevPtr d); -static void -sil164Power(I2CDevPtr d, Bool On); - static Bool sil164ReadByte(SIL164Ptr sil, int addr, CARD8 *ch) { @@ -68,7 +65,7 @@ sil164WriteByte(SIL164Ptr sil, int addr, CARD8 ch) /* Silicon Image 164 driver for chip on i2c bus */ static void * -sil164Detect(I2CBusPtr b, I2CSlaveAddr addr) +sil164_init(I2CBusPtr b, I2CSlaveAddr addr) { /* this will detect the SIL164 chip on the specified i2c bus */ SIL164Ptr sil; @@ -120,26 +117,19 @@ out: return NULL; } - -static Bool -sil164Init(I2CDevPtr d) -{ - /* not much to do */ - return TRUE; -} - static ModeStatus -sil164ModeValid(I2CDevPtr d, DisplayModePtr mode) +sil164_mode_valid(I2CDevPtr d, DisplayModePtr mode) { return MODE_OK; } static void -sil164Mode(I2CDevPtr d, DisplayModePtr mode) +sil164_mode_set(I2CDevPtr d, DisplayModePtr mode) { - sil164Power(d, TRUE); - sil164PrintRegs(d); - + /* As long as the basics are set up, since we don't have clock dependencies + * in the mode setup, we can just leave the registers alone and everything + * will work fine. + */ /* recommended programming sequence from doc */ /*sil164WriteByte(sil, 0x08, 0x30); sil164WriteByte(sil, 0x09, 0x00); @@ -152,7 +142,7 @@ sil164Mode(I2CDevPtr d, DisplayModePtr mode) /* set the SIL164 power state */ static void -sil164Power(I2CDevPtr d, Bool On) +sil164_dpms(I2CDevPtr d, int mode) { SIL164Ptr sil = SILPTR(d); int ret; @@ -162,7 +152,7 @@ sil164Power(I2CDevPtr d, Bool On) if (ret == FALSE) return; - if (On) + if (mode == DPMSModeOn) ch |= SIL164_8_PD; else ch &= ~SIL164_8_PD; @@ -173,7 +163,7 @@ sil164Power(I2CDevPtr d, Bool On) } static void -sil164PrintRegs(I2CDevPtr d) +sil164_dump_regs(I2CDevPtr d) { SIL164Ptr sil = SILPTR(d); CARD8 val; @@ -193,7 +183,7 @@ sil164PrintRegs(I2CDevPtr d) } static void -sil164SaveRegs(I2CDevPtr d) +sil164_save(I2CDevPtr d) { SIL164Ptr sil = SILPTR(d); @@ -210,7 +200,7 @@ sil164SaveRegs(I2CDevPtr d) } static void -sil164RestoreRegs(I2CDevPtr d) +sil164_restore(I2CDevPtr d) { SIL164Ptr sil = SILPTR(d); @@ -224,12 +214,11 @@ sil164RestoreRegs(I2CDevPtr d) I830I2CVidOutputRec SIL164VidOutput = { - sil164Detect, - sil164Init, - sil164ModeValid, - sil164Mode, - sil164Power, - sil164PrintRegs, - sil164SaveRegs, - sil164RestoreRegs, + .init = sil164_init, + .mode_valid = sil164_mode_valid, + .mode_set = sil164_mode_set, + .dpms = sil164_dpms, + .dump_regs = sil164_dump_regs, + .save = sil164_save, + .restore = sil164_restore, }; |