diff options
author | Greg KH <gregkh@suse.de> | 2005-09-12 12:10:59 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-09-12 12:10:59 -0700 |
commit | ad2c10f8f00d3fe2e37dd8a107e7cf4ac0459489 (patch) | |
tree | 5571f6a5784f51efddf9c1ee0408894cd63a460f /drivers | |
parent | 6b7839007098a6b5612d31690e11277d4242e6ae (diff) | |
parent | 2ade81473636b33aaac64495f89a7dc572c529f0 (diff) |
Merge ../torvalds-2.6/
Diffstat (limited to 'drivers')
361 files changed, 29287 insertions, 23894 deletions
diff --git a/drivers/acorn/block/fd1772.c b/drivers/acorn/block/fd1772.c index c0a37d98b4f..04854234120 100644 --- a/drivers/acorn/block/fd1772.c +++ b/drivers/acorn/block/fd1772.c @@ -376,19 +376,15 @@ static void do_fd_request(request_queue_t *); /************************* End of Prototypes **************************/ -static struct timer_list motor_off_timer = - TIMER_INITIALIZER(fd_motor_off_timer, 0, 0); +static DEFINE_TIMER(motor_off_timer, fd_motor_off_timer, 0, 0); #ifdef TRACKBUFFER -static struct timer_list readtrack_timer = - TIMER_INITIALIZER(fd_readtrack_check, 0, 0); +static DEFINE_TIMER(readtrack_timer, fd_readtrack_check, 0, 0); #endif -static struct timer_list timeout_timer = - TIMER_INITIALIZER(fd_times_out, 0, 0); +static DEFINE_TIMER(timeout_timer, fd_times_out, 0, 0); -static struct timer_list fd_timer = - TIMER_INITIALIZER(check_change, 0, 0); +static DEFINE_TIMER(fd_timer, check_change, 0, 0); /* DAG: Haven't got a clue what this is? */ int stdma_islocked(void) diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c index 7249ba2b7a2..aee50b45326 100644 --- a/drivers/acpi/sleep/main.c +++ b/drivers/acpi/sleep/main.c @@ -23,7 +23,6 @@ u8 sleep_states[ACPI_S_STATE_COUNT]; static struct pm_ops acpi_pm_ops; -extern void do_suspend_lowlevel_s4bios(void); extern void do_suspend_lowlevel(void); static u32 acpi_suspend_states[] = { @@ -98,8 +97,6 @@ static int acpi_pm_enter(suspend_state_t pm_state) case PM_SUSPEND_DISK: if (acpi_pm_ops.pm_disk_mode == PM_DISK_PLATFORM) status = acpi_enter_sleep_state(acpi_state); - else - do_suspend_lowlevel_s4bios(); break; case PM_SUSPEND_MAX: acpi_power_off(); @@ -206,11 +203,6 @@ static int __init acpi_sleep_init(void) printk(" S%d", i); } if (i == ACPI_STATE_S4) { - if (acpi_gbl_FACS->S4bios_f) { - sleep_states[i] = 1; - printk(" S4bios"); - acpi_pm_ops.pm_disk_mode = PM_DISK_FIRMWARE; - } if (sleep_states[i]) acpi_pm_ops.pm_disk_mode = PM_DISK_PLATFORM; } diff --git a/drivers/acpi/sleep/poweroff.c b/drivers/acpi/sleep/poweroff.c index a5f947de879..af7935a95bc 100644 --- a/drivers/acpi/sleep/poweroff.c +++ b/drivers/acpi/sleep/poweroff.c @@ -21,9 +21,7 @@ int acpi_sleep_prepare(u32 acpi_state) { #ifdef CONFIG_ACPI_SLEEP /* do we have a wakeup address for S2 and S3? */ - /* Here, we support only S4BIOS, those we set the wakeup address */ - /* S4OS is only supported for now via swsusp.. */ - if (acpi_state == ACPI_STATE_S3 || acpi_state == ACPI_STATE_S4) { + if (acpi_state == ACPI_STATE_S3) { if (!acpi_wakeup_address) { return -EFAULT; } diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c index 09a603f3523..4696a85a98b 100644 --- a/drivers/acpi/sleep/proc.c +++ b/drivers/acpi/sleep/proc.c @@ -25,8 +25,6 @@ static int acpi_system_sleep_seq_show(struct seq_file *seq, void *offset) for (i = 0; i <= ACPI_STATE_S5; i++) { if (sleep_states[i]) { seq_printf(seq, "S%d ", i); - if (i == ACPI_STATE_S4 && acpi_gbl_FACS->S4bios_f) - seq_printf(seq, "S4bios "); } } diff --git a/drivers/atm/idt77105.c b/drivers/atm/idt77105.c index b8c260ed4b2..0aabfc2a59d 100644 --- a/drivers/atm/idt77105.c +++ b/drivers/atm/idt77105.c @@ -50,10 +50,8 @@ static void idt77105_stats_timer_func(unsigned long); static void idt77105_restart_timer_func(unsigned long); -static struct timer_list stats_timer = - TIMER_INITIALIZER(idt77105_stats_timer_func, 0, 0); -static struct timer_list restart_timer = - TIMER_INITIALIZER(idt77105_restart_timer_func, 0, 0); +static DEFINE_TIMER(stats_timer, idt77105_stats_timer_func, 0, 0); +static DEFINE_TIMER(restart_timer, idt77105_restart_timer_func, 0, 0); static int start_timer = 1; static struct idt77105_priv *idt77105_all = NULL; diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c index a43575acb2c..2e2e50e1167 100644 --- a/drivers/atm/iphase.c +++ b/drivers/atm/iphase.c @@ -79,7 +79,7 @@ static IADEV *ia_dev[8]; static struct atm_dev *_ia_dev[8]; static int iadev_count; static void ia_led_timer(unsigned long arg); -static struct timer_list ia_timer = TIMER_INITIALIZER(ia_led_timer, 0, 0); +static DEFINE_TIMER(ia_timer, ia_led_timer, 0, 0); static int IA_TX_BUF = DFL_TX_BUFFERS, IA_TX_BUF_SZ = DFL_TX_BUF_SZ; static int IA_RX_BUF = DFL_RX_BUFFERS, IA_RX_BUF_SZ = DFL_RX_BUF_SZ; static uint IADebugFlag = /* IF_IADBG_ERR | IF_IADBG_CBR| IF_IADBG_INIT_ADAPTER diff --git a/drivers/base/dmapool.c b/drivers/base/dmapool.c index c4aebf2f522..60a7ef6a201 100644 --- a/drivers/base/dmapool.c +++ b/drivers/base/dmapool.c @@ -262,7 +262,8 @@ dma_pool_destroy (struct dma_pool *pool) * If such a memory block can't be allocated, null is returned. */ void * -dma_pool_alloc (struct dma_pool *pool, int mem_flags, dma_addr_t *handle) +dma_pool_alloc (struct dma_pool *pool, unsigned int __nocast mem_flags, + dma_addr_t *handle) { unsigned long flags; struct dma_page *page; diff --git a/drivers/block/acsi.c b/drivers/block/acsi.c index ce933de4808..0e1f34fef0c 100644 --- a/drivers/block/acsi.c +++ b/drivers/block/acsi.c @@ -371,7 +371,7 @@ static int acsi_revalidate (struct gendisk *disk); /************************* End of Prototypes **************************/ -struct timer_list acsi_timer = TIMER_INITIALIZER(acsi_times_out, 0, 0); +DEFINE_TIMER(acsi_timer, acsi_times_out, 0, 0); #ifdef CONFIG_ATARI_SLM diff --git a/drivers/block/acsi_slm.c b/drivers/block/acsi_slm.c index e3be8c31a74..a5c1c8e871e 100644 --- a/drivers/block/acsi_slm.c +++ b/drivers/block/acsi_slm.c @@ -268,7 +268,7 @@ static int slm_get_pagesize( int device, int *w, int *h ); /************************* End of Prototypes **************************/ -static struct timer_list slm_timer = TIMER_INITIALIZER(slm_test_ready, 0, 0); +static DEFINE_TIMER(slm_timer, slm_test_ready, 0, 0); static struct file_operations slm_fops = { .owner = THIS_MODULE, diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c index db05a5a99f3..22bda05fc69 100644 --- a/drivers/block/ataflop.c +++ b/drivers/block/ataflop.c @@ -371,16 +371,10 @@ static int floppy_release( struct inode * inode, struct file * filp ); /************************* End of Prototypes **************************/ -static struct timer_list motor_off_timer = - TIMER_INITIALIZER(fd_motor_off_timer, 0, 0); -static struct timer_list readtrack_timer = - TIMER_INITIALIZER(fd_readtrack_check, 0, 0); - -static struct timer_list timeout_timer = - TIMER_INITIALIZER(fd_times_out, 0, 0); - -static struct timer_list fd_timer = - TIMER_INITIALIZER(check_change, 0, 0); +static DEFINE_TIMER(motor_off_timer, fd_motor_off_timer, 0, 0); +static DEFINE_TIMER(readtrack_timer, fd_readtrack_check, 0, 0); +static DEFINE_TIMER(timeout_timer, fd_times_out, 0, 0); +static DEFINE_TIMER(fd_timer, check_change, 0, 0); static inline void start_motor_off_timer(void) { diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 418b1469d75..28f2c177a54 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -1713,10 +1713,9 @@ static unsigned long pollcomplete(int ctlr) for (i = 20 * HZ; i > 0; i--) { done = hba[ctlr]->access.command_completed(hba[ctlr]); - if (done == FIFO_EMPTY) { - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(1); - } else + if (done == FIFO_EMPTY) + schedule_timeout_uninterruptible(1); + else return (done); } /* Invalid address to tell caller we ran out of time */ diff --git a/drivers/block/cfq-iosched.c b/drivers/block/cfq-iosched.c index 30c0903c7cd..cd056e7e64e 100644 --- a/drivers/block/cfq-iosched.c +++ b/drivers/block/cfq-iosched.c @@ -2260,6 +2260,8 @@ static void cfq_put_cfqd(struct cfq_data *cfqd) if (!atomic_dec_and_test(&cfqd->ref)) return; + blk_put_queue(q); + cfq_shutdown_timer_wq(cfqd); q->elevator->elevator_data = NULL; @@ -2316,6 +2318,7 @@ static int cfq_init_queue(request_queue_t *q, elevator_t *e) e->elevator_data = cfqd; cfqd->queue = q; + atomic_inc(&q->refcnt); cfqd->max_queued = q->nr_requests / 4; q->nr_batching = cfq_queued; diff --git a/drivers/block/deadline-iosched.c b/drivers/block/deadline-iosched.c index 24594c57c32..52a3ae5289a 100644 --- a/drivers/block/deadline-iosched.c +++ b/drivers/block/deadline-iosched.c @@ -512,7 +512,10 @@ static int deadline_dispatch_requests(struct deadline_data *dd) /* * batches are currently reads XOR writes */ - drq = dd->next_drq[WRITE] ? : dd->next_drq[READ]; + if (dd->next_drq[WRITE]) + drq = dd->next_drq[WRITE]; + else + drq = dd->next_drq[READ]; if (drq) { /* we have a "next request" */ diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 888dad5eef3..00895477155 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -628,7 +628,7 @@ static inline void debugt(const char *message) { } #endif /* DEBUGT */ typedef void (*timeout_fn) (unsigned long); -static struct timer_list fd_timeout = TIMER_INITIALIZER(floppy_shutdown, 0, 0); +static DEFINE_TIMER(fd_timeout, floppy_shutdown, 0, 0); static const char *timeout_message; @@ -1012,7 +1012,7 @@ static void schedule_bh(void (*handler) (void)) schedule_work(&floppy_work); } -static struct timer_list fd_timer = TIMER_INITIALIZER(NULL, 0, 0); +static DEFINE_TIMER(fd_timer, NULL, 0, 0); static void cancel_activity(void) { diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c index 7289f67e956..ac5ba462710 100644 --- a/drivers/block/paride/pcd.c +++ b/drivers/block/paride/pcd.c @@ -516,8 +516,7 @@ static int pcd_tray_move(struct cdrom_device_info *cdi, int position) static void pcd_sleep(int cs) { - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(cs); + schedule_timeout_interruptible(cs); } static int pcd_reset(struct pcd_unit *cd) diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c index 060b1f2a91d..711d2f314ac 100644 --- a/drivers/block/paride/pf.c +++ b/drivers/block/paride/pf.c @@ -507,8 +507,7 @@ static void pf_eject(struct pf_unit *pf) static void pf_sleep(int cs) { - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(cs); + schedule_timeout_interruptible(cs); } /* the ATAPI standard actually specifies the contents of all 7 registers diff --git a/drivers/block/paride/pg.c b/drivers/block/paride/pg.c index 84d8e291ed9..b3982395f22 100644 --- a/drivers/block/paride/pg.c +++ b/drivers/block/paride/pg.c @@ -276,8 +276,7 @@ static inline u8 DRIVE(struct pg *dev) static void pg_sleep(int cs) { - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(cs); + schedule_timeout_interruptible(cs); } static int pg_wait(struct pg *dev, int go, int stop, unsigned long tmo, char *msg) diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c index 5fe8ee86f09..d8d35233cf4 100644 --- a/drivers/block/paride/pt.c +++ b/drivers/block/paride/pt.c @@ -383,8 +383,7 @@ static int pt_atapi(struct pt_unit *tape, char *cmd, int dlen, char *buf, char * static void pt_sleep(int cs) { - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(cs); + schedule_timeout_interruptible(cs); } static int pt_poll_dsc(struct pt_unit *tape, int pause, int tmo, char *msg) diff --git a/drivers/block/ps2esdi.c b/drivers/block/ps2esdi.c index 29548784cb7..29d1518be72 100644 --- a/drivers/block/ps2esdi.c +++ b/drivers/block/ps2esdi.c @@ -99,8 +99,7 @@ static DECLARE_WAIT_QUEUE_HEAD(ps2esdi_int); static int no_int_yet; static int ps2esdi_drives; static u_short io_base; -static struct timer_list esdi_timer = - TIMER_INITIALIZER(ps2esdi_reset_timer, 0, 0); +static DEFINE_TIMER(esdi_timer, ps2esdi_reset_timer, 0, 0); static int reset_status; static int ps2esdi_slot = -1; static int tp720esdi = 0; /* Is it Integrated ESDI of ThinkPad-720? */ diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c index e5f7494c00e..e425ad3eebb 100644 --- a/drivers/block/swim3.c +++ b/drivers/block/swim3.c @@ -834,8 +834,7 @@ static int fd_eject(struct floppy_state *fs) break; } swim3_select(fs, RELAX); - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(1); + schedule_timeout_interruptible(1); if (swim3_readbit(fs, DISK_IN) == 0) break; } @@ -906,8 +905,7 @@ static int floppy_open(struct inode *inode, struct file *filp) break; } swim3_select(fs, RELAX); - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(1); + schedule_timeout_interruptible(1); } if (err == 0 && (swim3_readbit(fs, SEEK_COMPLETE) == 0 || swim3_readbit(fs, DISK_IN) == 0)) @@ -992,8 +990,7 @@ static int floppy_revalidate(struct gendisk *disk) if (signal_pending(current)) break; swim3_select(fs, RELAX); - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(1); + schedule_timeout_interruptible(1); } ret = swim3_readbit(fs, SEEK_COMPLETE) == 0 || swim3_readbit(fs, DISK_IN) == 0; diff --git a/drivers/block/swim_iop.c b/drivers/block/swim_iop.c index a1283f6dc01..89e3c2f8b77 100644 --- a/drivers/block/swim_iop.c +++ b/drivers/block/swim_iop.c @@ -338,8 +338,7 @@ static int swimiop_eject(struct floppy_state *fs) err = -EINTR; break; } - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(1); + schedule_timeout_interruptible(1); } release_drive(fs); return cmd->error; diff --git a/drivers/block/umem.c b/drivers/block/umem.c index 0c4c121d2e7..0f48301342d 100644 --- a/drivers/block/umem.c +++ b/drivers/block/umem.c @@ -34,6 +34,7 @@ * - set initialised bit then. */ +//#define DEBUG /* uncomment if you want debugging info (pr_debug) */ #include <linux/config.h> #include <linux/sched.h> #include <linux/fs.h> @@ -58,10 +59,6 @@ #include <asm/uaccess.h> #include <asm/io.h> -#define PRINTK(x...) do {} while (0) -#define dprintk(x...) do {} while (0) -/*#define dprintk(x...) printk(x) */ - #define MM_MAXCARDS 4 #define MM_RAHEAD 2 /* two sectors */ #define MM_BLKSIZE 1024 /* 1k blocks */ @@ -299,7 +296,7 @@ static void mm_start_io(struct cardinfo *card) /* make the last descriptor end the chain */ page = &card->mm_pages[card->Active]; - PRINTK("start_io: %d %d->%d\n", card->Active, page->headcnt, page->cnt-1); + pr_debug("start_io: %d %d->%d\n", card->Active, page->headcnt, page->cnt-1); desc = &page->desc[page->cnt-1]; desc->control_bits |= cpu_to_le32(DMASCR_CHAIN_COMP_EN); @@ -532,7 +529,7 @@ static void process_page(unsigned long data) activate(card); } else { /* haven't finished with this one yet */ - PRINTK("do some more\n"); + pr_debug("do some more\n"); mm_start_io(card); } out_unlock: @@ -555,7 +552,7 @@ static void process_page(unsigned long data) static int mm_make_request(request_queue_t *q, struct bio *bio) { struct cardinfo *card = q->queuedata; - PRINTK("mm_make_request %ld %d\n", bh->b_rsector, bh->b_size); + pr_debug("mm_make_request %ld %d\n", bh->b_rsector, bh->b_size); bio->bi_phys_segments = bio->bi_idx; /* count of completed segments*/ spin_lock_irq(&card->lock); diff --git a/drivers/block/xd.c b/drivers/block/xd.c index 1676033da6c..68b6d7b154c 100644 --- a/drivers/block/xd.c +++ b/drivers/block/xd.c @@ -47,6 +47,7 @@ #include <linux/wait.h> #include <linux/blkdev.h> #include <linux/blkpg.h> +#include <linux/delay.h> #include <asm/system.h> #include <asm/io.h> @@ -62,7 +63,7 @@ static int xd[5] = { -1,-1,-1,-1, }; #define XD_DONT_USE_DMA 0 /* Initial value. may be overriden using "nodma" module option */ -#define XD_INIT_DISK_DELAY (30*HZ/1000) /* 30 ms delay during disk initialization */ +#define XD_INIT_DISK_DELAY (30) /* 30 ms delay during disk initialization */ /* Above may need to be increased if a problem with the 2nd drive detection (ST11M controller) or resetting a controller (WD) appears */ @@ -529,10 +530,8 @@ static inline u_char xd_waitport (u_short port,u_char flags,u_char mask,u_long t int success; xdc_busy = 1; - while ((success = ((inb(port) & mask) != flags)) && time_before(jiffies, expiry)) { - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(1); - } + while ((success = ((inb(port) & mask) != flags)) && time_before(jiffies, expiry)) + schedule_timeout_uninterruptible(1); xdc_busy = 0; return (success); } @@ -633,14 +632,12 @@ static u_char __init xd_initdrives (void (*init_drive)(u_char drive)) for (i = 0; i < XD_MAXDRIVES; i++) { xd_build(cmdblk,CMD_TESTREADY,i,0,0,0,0,0); if (!xd_command(cmdblk,PIO_MODE,NULL,NULL,NULL,XD_TIMEOUT*8)) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(XD_INIT_DISK_DELAY); + msleep_interruptible(XD_INIT_DISK_DELAY); init_drive(count); count++; - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(XD_INIT_DISK_DELAY); + msleep_interruptible(XD_INIT_DISK_DELAY); } } return (count); @@ -761,8 +758,7 @@ static void __init xd_wd_init_controller (unsigned int address) outb(0,XD_RESET); /* reset the controller */ - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(XD_INIT_DISK_DELAY); + msleep(XD_INIT_DISK_DELAY); } static void __init xd_wd_init_drive (u_char drive) @@ -936,8 +932,7 @@ If you need non-standard settings use the xd=... command */ xd_maxsectors = 0x01; outb(0,XD_RESET); /* reset the controller */ - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(XD_INIT_DISK_DELAY); + msleep(XD_INIT_DISK_DELAY); } static void __init xd_xebec_init_drive (u_char drive) diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c index 007f6a66243..bb5e8d665a2 100644 --- a/drivers/block/z2ram.c +++ b/drivers/block/z2ram.c @@ -296,7 +296,7 @@ z2_open( struct inode *inode, struct file *filp ) return 0; err_out_kfree: - kfree( z2ram_map ); + kfree(z2ram_map); err_out: return rc; } diff --git a/drivers/cdrom/aztcd.c b/drivers/cdrom/aztcd.c index 43bf1e5dc38..ce4a1ce59d6 100644 --- a/drivers/cdrom/aztcd.c +++ b/drivers/cdrom/aztcd.c @@ -297,7 +297,7 @@ static char azt_auto_eject = AZT_AUTO_EJECT; static int AztTimeout, AztTries; static DECLARE_WAIT_QUEUE_HEAD(azt_waitq); -static struct timer_list delay_timer = TIMER_INITIALIZER(NULL, 0, 0); +static DEFINE_TIMER(delay_timer, NULL, 0, 0); static struct azt_DiskInfo DiskInfo; static struct azt_Toc Toc[MAX_TRACKS]; diff --git a/drivers/cdrom/gscd.c b/drivers/cdrom/gscd.c index 7eac10e63b2..ad5464ab99b 100644 --- a/drivers/cdrom/gscd.c +++ b/drivers/cdrom/gscd.c @@ -146,7 +146,7 @@ static int AudioStart_f; static int AudioEnd_m; static int AudioEnd_f; -static struct timer_list gscd_timer = TIMER_INITIALIZER(NULL, 0, 0); +static DEFINE_TIMER(gscd_timer, NULL, 0, 0); static DEFINE_SPINLOCK(gscd_lock); static struct request_queue *gscd_queue; diff --git a/drivers/cdrom/optcd.c b/drivers/cdrom/optcd.c index 351a01dd503..0b0eab4f40f 100644 --- a/drivers/cdrom/optcd.c +++ b/drivers/cdrom/optcd.c @@ -264,7 +264,7 @@ static inline int flag_low(int flag, unsigned long timeout) static int sleep_timeout; /* max # of ticks to sleep */ static DECLARE_WAIT_QUEUE_HEAD(waitq); static void sleep_timer(unsigned long data); -static struct timer_list delay_timer = TIMER_INITIALIZER(sleep_timer, 0, 0); +static DEFINE_TIMER(delay_timer, sleep_timer, 0, 0); static DEFINE_SPINLOCK(optcd_lock); static struct request_queue *opt_queue; diff --git a/drivers/cdrom/sbpcd.c b/drivers/cdrom/sbpcd.c index 452d3467515..466e9c2974b 100644 --- a/drivers/cdrom/sbpcd.c +++ b/drivers/cdrom/sbpcd.c @@ -742,13 +742,10 @@ static struct sbpcd_drive *current_drive = D_S; unsigned long cli_sti; /* for saving the processor flags */ #endif /*==========================================================================*/ -static struct timer_list delay_timer = - TIMER_INITIALIZER(mark_timeout_delay, 0, 0); -static struct timer_list data_timer = - TIMER_INITIALIZER(mark_timeout_data, 0, 0); +static DEFINE_TIMER(delay_timer, mark_timeout_delay, 0, 0); +static DEFINE_TIMER(data_timer, mark_timeout_data, 0, 0); #if 0 -static struct timer_list audio_timer = - TIMER_INITIALIZER(mark_timeout_audio, 0, 0); +static DEFINE_TIMER(audio_timer, mark_timeout_audio, 0, 0); #endif /*==========================================================================*/ /* @@ -830,8 +827,7 @@ static void mark_timeout_audio(u_long i) static void sbp_sleep(u_int time) { sti(); - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(time); + schedule_timeout_interruptible(time); sti(); } /*==========================================================================*/ @@ -4219,7 +4215,8 @@ static int sbpcd_dev_ioctl(struct cdrom_device_info *cdi, u_int cmd, case CDROMAUDIOBUFSIZ: /* configure the audio buffer size */ msg(DBG_IOC,"ioctl: CDROMAUDIOBUFSIZ entered.\n"); - if (current_drive->sbp_audsiz>0) vfree(current_drive->aud_buf); + if (current_drive->sbp_audsiz>0) + vfree(current_drive->aud_buf); current_drive->aud_buf=NULL; current_drive->sbp_audsiz=arg; @@ -5913,7 +5910,8 @@ static void sbpcd_exit(void) put_disk(D_S[j].disk); devfs_remove("sbp/c0t%d", j); vfree(D_S[j].sbp_buf); - if (D_S[j].sbp_audsiz>0) vfree(D_S[j].aud_buf); + if (D_S[j].sbp_audsiz>0) + vfree(D_S[j].aud_buf); if ((unregister_cdrom(D_S[j].sbpcd_infop) == -EINVAL)) { msg(DBG_INF, "What's that: can't unregister info %s.\n", major_name); diff --git a/drivers/cdrom/sjcd.c b/drivers/cdrom/sjcd.c index 4e7a342ec36..74b1cadbf16 100644 --- a/drivers/cdrom/sjcd.c +++ b/drivers/cdrom/sjcd.c @@ -151,7 +151,7 @@ static struct sjcd_stat statistic; /* * Timer. */ -static struct timer_list sjcd_delay_timer = TIMER_INITIALIZER(NULL, 0, 0); +static DEFINE_TIMER(sjcd_delay_timer, NULL, 0, 0); #define SJCD_SET_TIMER( func, tmout ) \ ( sjcd_delay_timer.expires = jiffies+tmout, \ diff --git a/drivers/cdrom/sonycd535.c b/drivers/cdrom/sonycd535.c index 9f22e8f1f6c..e6565992643 100644 --- a/drivers/cdrom/sonycd535.c +++ b/drivers/cdrom/sonycd535.c @@ -1478,8 +1478,7 @@ static int __init sony535_init(void) /* look for the CD-ROM, follows the procedure in the DOS driver */ inb(select_unit_reg); /* wait for 40 18 Hz ticks (reverse-engineered from DOS driver) */ - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout((HZ+17)*40/18); + schedule_timeout_interruptible((HZ+17)*40/18); inb(result_reg); outb(0, read_status_reg); /* does a reset? */ diff --git a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c index 4d4e602fdc7..82b43c541c8 100644 --- a/drivers/char/agp/backend.c +++ b/drivers/char/agp/backend.c @@ -206,10 +206,9 @@ static void agp_backend_cleanup(struct agp_bridge_data *bridge) bridge->driver->cleanup(); if (bridge->driver->free_gatt_table) bridge->driver->free_gatt_table(bridge); - if (bridge->key_list) { - vfree(bridge->key_list); - bridge->key_list = NULL; - } + + vfree(bridge->key_list); + bridge->key_list = NULL; if (bridge->driver->agp_destroy_page && bridge->driver->needs_scratch_page) diff --git a/drivers/char/applicom.c b/drivers/char/applicom.c index 11f9ee58112..927a5bbe112 100644 --- a/drivers/char/applicom.c +++ b/drivers/char/applicom.c @@ -172,7 +172,7 @@ static int ac_register_board(unsigned long physloc, void __iomem *loc, void cleanup_module(void) { - int i; + unsigned int i; misc_deregister(&ac_miscdev); @@ -195,7 +195,7 @@ int __init applicom_init(void) int i, numisa = 0; struct pci_dev *dev = NULL; void __iomem *RamIO; - int boardno; + int boardno, ret; printk(KERN_INFO "Applicom driver: $Id: ac.c,v 1.30 2000/03/22 16:03:57 dwmw2 Exp $\n"); @@ -294,7 +294,8 @@ int __init applicom_init(void) } if (!numisa) - printk(KERN_WARNING"ac.o: No valid ISA Applicom boards found at mem 0x%lx\n",mem); + printk(KERN_WARNING "ac.o: No valid ISA Applicom boards found " + "at mem 0x%lx\n", mem); fin: init_waitqueue_head(&FlagSleepRec); @@ -304,7 +305,11 @@ int __init applicom_init(void) DeviceErrorCount = 0; if (numboards) { - misc_register(&ac_miscdev); + ret = misc_register(&ac_miscdev); + if (ret) { + printk(KERN_WARNING "ac.o: Unable to register misc device\n"); + goto out; + } for (i = 0; i < MAX_BOARD; i++) { int serial; char boardname[(SERIAL_NUMBER - TYPE_CARD) + 1]; @@ -337,6 +342,17 @@ int __init applicom_init(void) else return -ENXIO; + +out: + for (i = 0; i < MAX_BOARD; i++) { + if (!apbs[i].RamIO) + continue; + if (apbs[i].irq) + free_irq(apbs[i].irq, &dummy); + iounmap(apbs[i].RamIO); + } + pci_disable_device(dev); + return ret; } diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c index 6a5337bf093..cf4c3648463 100644 --- a/drivers/char/cyclades.c +++ b/drivers/char/cyclades.c @@ -865,7 +865,7 @@ static void cyz_poll(unsigned long); static long cyz_polling_cycle = CZ_DEF_POLL; static int cyz_timeron = 0; -static struct timer_list cyz_timerlist = TIMER_INITIALIZER(cyz_poll, 0, 0); +static DEFINE_TIMER(cyz_timerlist, cyz_poll, 0, 0); #else /* CONFIG_CYZ_INTR */ static void cyz_rx_restart(unsigned long); diff --git a/drivers/char/ftape/lowlevel/fdc-io.c b/drivers/char/ftape/lowlevel/fdc-io.c index 1704a2a5704..b2e0928e842 100644 --- a/drivers/char/ftape/lowlevel/fdc-io.c +++ b/drivers/char/ftape/lowlevel/fdc-io.c @@ -387,10 +387,8 @@ int fdc_interrupt_wait(unsigned int time) set_current_state(TASK_INTERRUPTIBLE); add_wait_queue(&ftape_wait_intr, &wait); - while (!ft_interrupt_seen && timeout) { - set_current_state(TASK_INTERRUPTIBLE); - timeout = schedule_timeout(timeout); - } + while (!ft_interrupt_seen && timeout) + timeout = schedule_timeout_interruptible(timeout); spin_lock_irq(¤t->sighand->siglock); current->blocked = old_sigmask; diff --git a/drivers/char/hangcheck-timer.c b/drivers/char/hangcheck-timer.c index 81d811edf3c..a54bc93353a 100644 --- a/drivers/char/hangcheck-timer.c +++ b/drivers/char/hangcheck-timer.c @@ -149,8 +149,7 @@ static unsigned long long hangcheck_tsc, hangcheck_tsc_margin; static void hangcheck_fire(unsigned long); -static struct timer_list hangcheck_ticktock = - TIMER_INITIALIZER(hangcheck_fire, 0, 0); +static DEFINE_TIMER(hangcheck_ticktock, hangcheck_fire, 0, 0); static void hangcheck_fire(unsigned long data) diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c index 5fe8461271f..de0379b6d50 100644 --- a/drivers/char/hpet.c +++ b/drivers/char/hpet.c @@ -100,14 +100,14 @@ static struct hpets *hpets; #endif #ifndef readq -static unsigned long long __inline readq(void __iomem *addr) +static inline unsigned long long readq(void __iomem *addr) { return readl(addr) | (((unsigned long long)readl(addr + 4)) << 32LL); } #endif #ifndef writeq -static void __inline writeq(unsigned long long v, void __iomem *addr) +static inline void writeq(unsigned long long v, void __iomem *addr) { writel(v & 0xffffffff, addr); writel(v >> 32, addr + 4); diff --git a/drivers/char/hw_random.c b/drivers/char/hw_random.c index 3480535a09c..6f673d2de0b 100644 --- a/drivers/char/hw_random.c +++ b/drivers/char/hw_random.c @@ -513,10 +513,7 @@ static ssize_t rng_dev_read (struct file *filp, char __user *buf, size_t size, return ret ? : -EAGAIN; if(need_resched()) - { - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(1); - } + schedule_timeout_interruptible(1); else udelay(200); /* FIXME: We could poll for 250uS ?? */ diff --git a/drivers/char/ip2/i2lib.c b/drivers/char/ip2/i2lib.c index 82c5f30375a..ba85eb1b6ec 100644 --- a/drivers/char/ip2/i2lib.c +++ b/drivers/char/ip2/i2lib.c @@ -655,8 +655,7 @@ i2QueueCommands(int type, i2ChanStrPtr pCh, int timeout, int nCommands, timeout--; // So negative values == forever if (!in_interrupt()) { - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(1); // short nap + schedule_timeout_interruptible(1); // short nap } else { // we cannot sched/sleep in interrrupt silly return 0; @@ -1132,8 +1131,7 @@ i2Output(i2ChanStrPtr pCh, const char *pSource, int count, int user ) ip2trace (CHANN, ITRC_OUTPUT, 61, 0 ); - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(2); + schedule_timeout_interruptible(2); if (signal_pending(current)) { break; } diff --git a/drivers/char/ip2main.c b/drivers/char/ip2main.c index 066d7b5cb76..9e4e26aef94 100644 --- a/drivers/char/ip2main.c +++ b/drivers/char/ip2main.c @@ -254,7 +254,7 @@ static unsigned long bh_counter = 0; * selected, the board is serviced periodically to see if anything needs doing. */ #define POLL_TIMEOUT (jiffies + 1) -static struct timer_list PollTimer = TIMER_INITIALIZER(ip2_poll, 0, 0); +static DEFINE_TIMER(PollTimer, ip2_poll, 0, 0); static char TimerOn; #ifdef IP2DEBUG_TRACE diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c index 883ac4352be..a09ff108068 100644 --- a/drivers/char/ipmi/ipmi_devintf.c +++ b/drivers/char/ipmi/ipmi_devintf.c @@ -735,7 +735,8 @@ static long compat_ipmi_ioctl(struct file *filep, unsigned int cmd, case COMPAT_IPMICTL_RECEIVE_MSG: case COMPAT_IPMICTL_RECEIVE_MSG_TRUNC: { - struct ipmi_recv *precv64, recv64; + struct ipmi_recv __user *precv64; + struct ipmi_recv recv64; if (get_compat_ipmi_recv(&recv64, compat_ptr(arg))) return -EFAULT; @@ -748,7 +749,7 @@ static long compat_ipmi_ioctl(struct file *filep, unsigned int cmd, ((cmd == COMPAT_IPMICTL_RECEIVE_MSG) ? IPMICTL_RECEIVE_MSG : IPMICTL_RECEIVE_MSG_TRUNC), - (long) precv64); + (unsigned long) precv64); if (rc != 0) return rc; diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index 278f8410499..b6e5cbfb09f 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c @@ -1920,8 +1920,7 @@ static int try_get_dev_id(struct smi_info *smi_info) for (;;) { if (smi_result == SI_SM_CALL_WITH_DELAY) { - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(1); + schedule_timeout_uninterruptible(1); smi_result = smi_info->handlers->event( smi_info->si_sm, 100); } @@ -2256,10 +2255,8 @@ static int init_one_smi(int intf_num, struct smi_info **smi) /* Wait for the timer to stop. This avoids problems with race conditions removing the timer here. */ - while (! new_smi->timer_stopped) { - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(1); - } + while (!new_smi->timer_stopped) + schedule_timeout_uninterruptible(1); out_err: if (new_smi->intf) @@ -2379,17 +2376,14 @@ static void __exit cleanup_one_si(struct smi_info *to_clean) /* Wait for the timer to stop. This avoids problems with race conditions removing the timer here. */ - while (! to_clean->timer_stopped) { - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(1); - } + while (!to_clean->timer_stopped) + schedule_timeout_uninterruptible(1); /* Interrupts and timeouts are stopped, now make sure the interface is in a clean state. */ while (to_clean->curr_msg || (to_clean->si_state != SI_NORMAL)) { poll(to_clean); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(1); + schedule_timeout_uninterruptible(1); } rv = ipmi_unregister_smi(to_clean->intf); diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c index e71aaae855a..2da64bf7469 100644 --- a/drivers/char/ipmi/ipmi_watchdog.c +++ b/drivers/char/ipmi/ipmi_watchdog.c @@ -1037,10 +1037,8 @@ static __exit void ipmi_unregister_watchdog(void) /* Wait to make sure the message makes it out. The lower layer has pointers to our buffers, we want to make sure they are done before we release our memory. */ - while (atomic_read(&set_timeout_tofree)) { - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(1); - } + while (atomic_read(&set_timeout_tofree)) + schedule_timeout_uninterruptible(1); /* Disconnect from IPMI. */ rv = ipmi_destroy_user(watchdog_user); diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c index 52a073eee20..9c19e5435a1 100644 --- a/drivers/char/istallion.c +++ b/drivers/char/istallion.c @@ -780,7 +780,7 @@ static struct file_operations stli_fsiomem = { * much cheaper on host cpu than using interrupts. It turns out to * not increase character latency by much either... */ -static struct timer_list stli_timerlist = TIMER_INITIALIZER(stli_poll, 0, 0); +static DEFINE_TIMER(stli_timerlist, stli_poll, 0, 0); static int stli_timeron; diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c index 523fd3c8bba..449d029ad4f 100644 --- a/drivers/char/keyboard.c +++ b/drivers/char/keyboard.c @@ -14,7 +14,7 @@ * `Sticky' modifier keys, 951006. * * 11-11-96: SAK should now work in the raw mode (Martin Mares) - * + * * Modified to provide 'generic' keyboard support by Hamish Macdonald * Merge with the m68k keyboard driver and split-off of the PC low-level * parts by Geert Uytterhoeven, May 1997 @@ -52,7 +52,7 @@ extern void ctrl_alt_del(void); /* * Some laptops take the 789uiojklm,. keys as number pad when NumLock is on. * This seems a good reason to start with NumLock off. On HIL keyboards - * of PARISC machines however there is no NumLock key and everyone expects the keypad + * of PARISC machines however there is no NumLock key and everyone expects the keypad * to be used for numbers. */ @@ -76,17 +76,17 @@ void compute_shiftstate(void); k_meta, k_ascii, k_lock, k_lowercase,\ k_slock, k_dead2, k_ignore, k_ignore -typedef void (k_handler_fn)(struct vc_data *vc, unsigned char value, +typedef void (k_handler_fn)(struct vc_data *vc, unsigned char value, char up_flag, struct pt_regs *regs); static k_handler_fn K_HANDLERS; static k_handler_fn *k_handler[16] = { K_HANDLERS }; #define FN_HANDLERS\ - fn_null, fn_enter, fn_show_ptregs, fn_show_mem,\ - fn_show_state, fn_send_intr, fn_lastcons, fn_caps_toggle,\ - fn_num, fn_hold, fn_scroll_forw, fn_scroll_back,\ - fn_boot_it, fn_caps_on, fn_compose, fn_SAK,\ - fn_dec_console, fn_inc_console, fn_spawn_con, fn_bare_num + fn_null, fn_enter, fn_show_ptregs, fn_show_mem,\ + fn_show_state, fn_send_intr, fn_lastcons, fn_caps_toggle,\ + fn_num, fn_hold, fn_scroll_forw, fn_scroll_back,\ + fn_boot_it, fn_caps_on, fn_compose, fn_SAK,\ + fn_dec_console, fn_inc_console, fn_spawn_con, fn_bare_num typedef void (fn_handler_fn)(struct vc_data *vc, struct pt_regs *regs); static fn_handler_fn FN_HANDLERS; @@ -159,13 +159,13 @@ static int sysrq_alt; */ int getkeycode(unsigned int scancode) { - struct list_head * node; + struct list_head *node; struct input_dev *dev = NULL; - list_for_each(node,&kbd_handler.h_list) { - struct input_handle * handle = to_handle_h(node); - if (handle->dev->keycodesize) { - dev = handle->dev; + list_for_each(node, &kbd_handler.h_list) { + struct input_handle *handle = to_handle_h(node); + if (handle->dev->keycodesize) { + dev = handle->dev; break; } } @@ -181,15 +181,15 @@ int getkeycode(unsigned int scancode) int setkeycode(unsigned int scancode, unsigned int keycode) { - struct list_head * node; + struct list_head *node; struct input_dev *dev = NULL; unsigned int i, oldkey; - list_for_each(node,&kbd_handler.h_list) { + list_for_each(node, &kbd_handler.h_list) { struct input_handle *handle = to_handle_h(node); - if (handle->dev->keycodesize) { - dev = handle->dev; - break; + if (handle->dev->keycodesize) { + dev = handle->dev; + break; } } @@ -200,7 +200,7 @@ int setkeycode(unsigned int scancode, unsigned int keycode) return -EINVAL; if (keycode < 0 || keycode > KEY_MAX) return -EINVAL; - if (keycode >> (dev->keycodesize * 8)) + if (dev->keycodesize < sizeof(keycode) && (keycode >> (dev->keycodesize * 8))) return -EINVAL; oldkey = SET_INPUT_KEYCODE(dev, scancode, keycode); @@ -216,11 +216,11 @@ int setkeycode(unsigned int scancode, unsigned int keycode) } /* - * Making beeps and bells. + * Making beeps and bells. */ static void kd_nosound(unsigned long ignored) { - struct list_head * node; + struct list_head *node; list_for_each(node,&kbd_handler.h_list) { struct input_handle *handle = to_handle_h(node); @@ -233,17 +233,16 @@ static void kd_nosound(unsigned long ignored) } } -static struct timer_list kd_mksound_timer = - TIMER_INITIALIZER(kd_nosound, 0, 0); +static DEFINE_TIMER(kd_mksound_timer, kd_nosound, 0, 0); void kd_mksound(unsigned int hz, unsigned int ticks) { - struct list_head * node; + struct list_head *node; del_timer(&kd_mksound_timer); if (hz) { - list_for_each_prev(node,&kbd_handler.h_list) { + list_for_each_prev(node, &kbd_handler.h_list) { struct input_handle *handle = to_handle_h(node); if (test_bit(EV_SND, handle->dev->evbit)) { if (test_bit(SND_TONE, handle->dev->sndbit)) { @@ -338,19 +337,19 @@ static void to_utf8(struct vc_data *vc, ushort c) if (c < 0x80) /* 0******* */ put_queue(vc, c); - else if (c < 0x800) { + else if (c < 0x800) { /* 110***** 10****** */ - put_queue(vc, 0xc0 | (c >> 6)); + put_queue(vc, 0xc0 | (c >> 6)); put_queue(vc, 0x80 | (c & 0x3f)); - } else { + } else { /* 1110**** 10****** 10****** */ put_queue(vc, 0xe0 | (c >> 12)); put_queue(vc, 0x80 | ((c >> 6) & 0x3f)); put_queue(vc, 0x80 | (c & 0x3f)); - } + } } -/* +/* * Called after returning from RAW mode or when changing consoles - recompute * shift_down[] and shift_state from key_down[] maybe called when keymap is * undefined, so that shiftkey release is seen @@ -361,7 +360,7 @@ void compute_shiftstate(void) shift_state = 0; memset(shift_down, 0, sizeof(shift_down)); - + for (i = 0; i < ARRAY_SIZE(key_down); i++) { if (!key_down[i]) @@ -500,9 +499,9 @@ static void fn_dec_console(struct vc_data *vc, struct pt_regs *regs) if (want_console != -1) cur = want_console; - for (i = cur-1; i != cur; i--) { + for (i = cur - 1; i != cur; i--) { if (i == -1) - i = MAX_NR_CONSOLES-1; + i = MAX_NR_CONSOLES - 1; if (vc_cons_allocated(i)) break; } @@ -568,9 +567,9 @@ static void fn_compose(struct vc_data *vc, struct pt_regs *regs) static void fn_spawn_con(struct vc_data *vc, struct pt_regs *regs) { - if (spawnpid) - if(kill_proc(spawnpid, spawnsig, 1)) - spawnpid = 0; + if (spawnpid) + if (kill_proc(spawnpid, spawnsig, 1)) + spawnpid = 0; } static void fn_SAK(struct vc_data *vc, struct pt_regs *regs) @@ -604,8 +603,8 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag, struct return; if (value >= ARRAY_SIZE(fn_handler)) return; - if ((kbd->kbdmode == VC_RAW || - kbd->kbdmode == VC_MEDIUMRAW) && + if ((kbd->kbdmode == VC_RAW || + kbd->kbdmode == VC_MEDIUMRAW) && value != KVAL(K_SAK)) return; /* SAK is allowed even in raw mode */ fn_handler[value](vc, regs); @@ -895,11 +894,11 @@ static inline unsigned char getleds(void) static void kbd_bh(unsigned long dummy) { - struct list_head * node; + struct list_head *node; unsigned char leds = getleds(); if (leds != ledstate) { - list_for_each(node,&kbd_handler.h_list) { + list_for_each(node, &kbd_handler.h_list) { struct input_handle * handle = to_handle_h(node); input_event(handle->dev, EV_LED, LED_SCROLLL, !!(leds & 0x01)); input_event(handle->dev, EV_LED, LED_NUML, !!(leds & 0x02)); @@ -964,11 +963,11 @@ static int sparc_l1_a_state = 0; extern void sun_do_break(void); #endif -static int emulate_raw(struct vc_data *vc, unsigned int keycode, +static int emulate_raw(struct vc_data *vc, unsigned int keycode, unsigned char up_flag) { if (keycode > 255 || !x86_keycodes[keycode]) - return -1; + return -1; switch (keycode) { case KEY_PAUSE: @@ -982,7 +981,7 @@ static int emulate_raw(struct vc_data *vc, unsigned int keycode, case KEY_HANJA: if (!up_flag) put_queue(vc, 0xf2); return 0; - } + } if (keycode == KEY_SYSRQ && sysrq_alt) { put_queue(vc, 0x54 | up_flag); @@ -1105,11 +1104,12 @@ static void kbd_keycode(unsigned int keycode, int down, else clear_bit(keycode, key_down); - if (rep && (!vc_kbd_mode(kbd, VC_REPEAT) || (tty && - (!L_ECHO(tty) && tty->driver->chars_in_buffer(tty))))) { + if (rep && + (!vc_kbd_mode(kbd, VC_REPEAT) || + (tty && !L_ECHO(tty) && tty->driver->chars_in_buffer(tty)))) { /* * Don't repeat a key if the input buffers are not empty and the - * characters get aren't echoed locally. This makes key repeat + * characters get aren't echoed locally. This makes key repeat * usable with slow applications and under heavy loads. */ return; @@ -1131,7 +1131,8 @@ static void kbd_keycode(unsigned int keycode, int down, type = KTYP(keysym); if (type < 0xf0) { - if (down && !raw_mode) to_utf8(vc, keysym); + if (down && !raw_mode) + to_utf8(vc, keysym); return; } @@ -1155,7 +1156,7 @@ static void kbd_keycode(unsigned int keycode, int down, kbd->slockstate = 0; } -static void kbd_event(struct input_handle *handle, unsigned int event_type, +static void kbd_event(struct input_handle *handle, unsigned int event_type, unsigned int event_code, int value) { if (event_type == EV_MSC && event_code == MSC_RAW && HW_RAW(handle->dev)) @@ -1167,15 +1168,13 @@ static void kbd_event(struct input_handle *handle, unsigned int event_type, schedule_console_callback(); } -static char kbd_name[] = "kbd"; - /* * When a keyboard (or other input device) is found, the kbd_connect * function is called. The function then looks at the device, and if it * likes it, it can open it and get events from it. In this (kbd_connect) * function, we should decide which VT to bind that keyboard to initially. */ -static struct input_handle *kbd_connect(struct input_handler *handler, +static struct input_handle *kbd_connect(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id) { @@ -1183,18 +1182,19 @@ static struct input_handle *kbd_connect(struct input_handler *handler, int i; for (i = KEY_RESERVED; i < BTN_MISC; i++) - if (test_bit(i, dev->keybit)) break; + if (test_bit(i, dev->keybit)) + break; - if ((i == BTN_MISC) && !test_bit(EV_SND, dev->evbit)) + if (i == BTN_MISC && !test_bit(EV_SND, dev->evbit)) return NULL; - if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL))) + if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL))) return NULL; memset(handle, 0, sizeof(struct input_handle)); handle->dev = dev; handle->handler = handler; - handle->name = kbd_name; + handle->name = "kbd"; input_open_device(handle); kbd_refresh_leds(handle); @@ -1213,11 +1213,11 @@ static struct input_device_id kbd_ids[] = { .flags = INPUT_DEVICE_ID_MATCH_EVBIT, .evbit = { BIT(EV_KEY) }, }, - + { .flags = INPUT_DEVICE_ID_MATCH_EVBIT, .evbit = { BIT(EV_SND) }, - }, + }, { }, /* Terminating entry */ }; diff --git a/drivers/char/lcd.c b/drivers/char/lcd.c index cf01a720eb2..b7716114614 100644 --- a/drivers/char/lcd.c +++ b/drivers/char/lcd.c @@ -613,10 +613,15 @@ static struct miscdevice lcd_dev = { static int lcd_init(void) { + int ret; unsigned long data; pr_info("%s\n", LCD_DRIVER); - misc_register(&lcd_dev); + ret = misc_register(&lcd_dev); + if (ret) { + printk(KERN_WARNING LCD "Unable to register misc device.\n"); + return ret; + } /* Check region? Naaah! Just snarf it up. */ /* request_region(RTC_PORT(0), RTC_IO_EXTENT, "lcd");*/ diff --git a/drivers/char/lp.c b/drivers/char/lp.c index 59eebe5a035..2afb9038dbc 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c @@ -128,6 +128,7 @@ #include <linux/console.h> #include <linux/device.h> #include <linux/wait.h> +#include <linux/jiffies.h> #include <linux/parport.h> #undef LP_STATS @@ -307,7 +308,7 @@ static ssize_t lp_write(struct file * file, const char __user * buf, (LP_F(minor) & LP_ABORT)); #ifdef LP_STATS - if (jiffies-lp_table[minor].lastcall > LP_TIME(minor)) + if (time_after(jiffies, lp_table[minor].lastcall + LP_TIME(minor))) lp_table[minor].runchars = 0; lp_table[minor].lastcall = jiffies; diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c index d0ef1ae4129..45d012d85e8 100644 --- a/drivers/char/mxser.c +++ b/drivers/char/mxser.c @@ -1058,8 +1058,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp) */ timeout = jiffies + HZ; while (!(inb(info->base + UART_LSR) & UART_LSR_TEMT)) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(5); + schedule_timeout_interruptible(5); if (time_after(jiffies, timeout)) break; } @@ -1080,10 +1079,8 @@ static void mxser_close(struct tty_struct *tty, struct file *filp) info->event = 0; info->tty = NULL; if (info->blocked_open) { - if (info->close_delay) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(info->close_delay); - } + if (info->close_delay) + schedule_timeout_interruptible(info->close_delay); wake_up_interruptible(&info->open_wait); } @@ -1801,8 +1798,7 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout) #ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT printk("lsr = %d (jiff=%lu)...", lsr, jiffies); #endif - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(char_time); + schedule_timeout_interruptible(char_time); if (signal_pending(current)) break; if (timeout && time_after(jiffies, orig_jiffies + timeout)) diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c index 09103b3d8f0..c9bdf544ed2 100644 --- a/drivers/char/n_tty.c +++ b/drivers/char/n_tty.c @@ -62,7 +62,7 @@ static inline unsigned char *alloc_buf(void) { - int prio = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL; + unsigned int prio = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL; if (PAGE_SIZE != N_TTY_BUF_SIZE) return kmalloc(N_TTY_BUF_SIZE, prio); diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 7a0c7464812..02d7f046c10 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -1,7 +1,7 @@ /* * linux/drivers/char/pcmcia/synclink_cs.c * - * $Id: synclink_cs.c,v 4.26 2004/08/11 19:30:02 paulkf Exp $ + * $Id: synclink_cs.c,v 4.34 2005/09/08 13:20:54 paulkf Exp $ * * Device driver for Microgate SyncLink PC Card * multiprotocol serial adapter. @@ -472,7 +472,7 @@ module_param_array(dosyncppp, int, NULL, 0); MODULE_LICENSE("GPL"); static char *driver_name = "SyncLink PC Card driver"; -static char *driver_version = "$Revision: 4.26 $"; +static char *driver_version = "$Revision: 4.34 $"; static struct tty_driver *serial_driver; @@ -1457,6 +1457,8 @@ static int startup(MGSLPC_INFO * info) info->pending_bh = 0; + memset(&info->icount, 0, sizeof(info->icount)); + init_timer(&info->tx_timer); info->tx_timer.data = (unsigned long)info; info->tx_timer.function = tx_timeout; @@ -1946,9 +1948,13 @@ static int get_stats(MGSLPC_INFO * info, struct mgsl_icount __user *user_icount) int err; if (debug_level >= DEBUG_LEVEL_INFO) printk("get_params(%s)\n", info->device_name); - COPY_TO_USER(err,user_icount, &info->icount, sizeof(struct mgsl_icount)); - if (err) - return -EFAULT; + if (!user_icount) { + memset(&info->icount, 0, sizeof(info->icount)); + } else { + COPY_TO_USER(err, user_icount, &info->icount, sizeof(struct mgsl_icount)); + if (err) + return -EFAULT; + } return 0; } diff --git a/drivers/char/pty.c b/drivers/char/pty.c index da32889d22c..49f3997fd25 100644 --- a/drivers/char/pty.c +++ b/drivers/char/pty.c @@ -149,15 +149,14 @@ static int pty_write_room(struct tty_struct *tty) static int pty_chars_in_buffer(struct tty_struct *tty) { struct tty_struct *to = tty->link; - ssize_t (*chars_in_buffer)(struct tty_struct *); int count; /* We should get the line discipline lock for "tty->link" */ - if (!to || !(chars_in_buffer = to->ldisc.chars_in_buffer)) + if (!to || !to->ldisc.chars_in_buffer) return 0; /* The ldisc must report 0 if no characters available to be read */ - count = chars_in_buffer(to); + count = to->ldisc.chars_in_buffer(to); if (tty->driver->subtype == PTY_TYPE_SLAVE) return count; diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c index 37c8bea8e2b..ea2d54be484 100644 --- a/drivers/char/synclink.c +++ b/drivers/char/synclink.c @@ -1,7 +1,7 @@ /* * linux/drivers/char/synclink.c * - * $Id: synclink.c,v 4.28 2004/08/11 19:30:01 paulkf Exp $ + * $Id: synclink.c,v 4.37 2005/09/07 13:13:19 paulkf Exp $ * * Device driver for Microgate SyncLink ISA and PCI * high speed multiprotocol serial adapters. @@ -141,9 +141,9 @@ static MGSL_PARAMS default_params = { typedef struct _DMABUFFERENTRY { u32 phys_addr; /* 32-bit flat physical address of data buffer */ - u16 count; /* buffer size/data count */ - u16 status; /* Control/status field */ - u16 rcc; /* character count field */ + volatile u16 count; /* buffer size/data count */ + volatile u16 status; /* Control/status field */ + volatile u16 rcc; /* character count field */ u16 reserved; /* padding required by 16C32 */ u32 link; /* 32-bit flat link to next buffer entry */ char *virt_addr; /* virtual address of data buffer */ @@ -896,7 +896,7 @@ module_param_array(txdmabufs, int, NULL, 0); module_param_array(txholdbufs, int, NULL, 0); static char *driver_name = "SyncLink serial driver"; -static char *driver_version = "$Revision: 4.28 $"; +static char *driver_version = "$Revision: 4.37 $"; static int synclink_init_one (struct pci_dev *dev, const struct pci_device_id *ent); @@ -1814,6 +1814,8 @@ static int startup(struct mgsl_struct * info) info->pending_bh = 0; + memset(&info->icount, 0, sizeof(info->icount)); + init_timer(&info->tx_timer); info->tx_timer.data = (unsigned long)info; info->tx_timer.function = mgsl_tx_timeout; @@ -2470,12 +2472,12 @@ static int mgsl_get_stats(struct mgsl_struct * info, struct mgsl_icount __user * printk("%s(%d):mgsl_get_params(%s)\n", __FILE__,__LINE__, info->device_name); - COPY_TO_USER(err,user_icount, &info->icount, sizeof(struct mgsl_icount)); - if (err) { - if ( debug_level >= DEBUG_LEVEL_INFO ) - printk( "%s(%d):mgsl_get_stats(%s) user buffer copy failed\n", - __FILE__,__LINE__,info->device_name); - return -EFAULT; + if (!user_icount) { + memset(&info->icount, 0, sizeof(info->icount)); + } else { + COPY_TO_USER(err, user_icount, &info->icount, sizeof(struct mgsl_icount)); + if (err) + return -EFAULT; } return 0; @@ -6149,6 +6151,11 @@ static void usc_set_async_mode( struct mgsl_struct *info ) usc_OutReg(info, PCR, (u16)((usc_InReg(info, PCR) | BIT13) & ~BIT12)); } + if (info->params.loopback) { + info->loopback_bits = 0x300; + outw(0x0300, info->io_base + CCAR); + } + } /* end of usc_set_async_mode() */ /* usc_loopback_frame() diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c index 8982eafd0fb..6fb165cf8a6 100644 --- a/drivers/char/synclinkmp.c +++ b/drivers/char/synclinkmp.c @@ -1,5 +1,5 @@ /* - * $Id: synclinkmp.c,v 4.34 2005/03/04 15:07:10 paulkf Exp $ + * $Id: synclinkmp.c,v 4.38 2005/07/15 13:29:44 paulkf Exp $ * * Device driver for Microgate SyncLink Multiport * high speed multiprotocol serial adapter. @@ -486,7 +486,7 @@ module_param_array(maxframe, int, NULL, 0); module_param_array(dosyncppp, int, NULL, 0); static char *driver_name = "SyncLink MultiPort driver"; -static char *driver_version = "$Revision: 4.34 $"; +static char *driver_version = "$Revision: 4.38 $"; static int synclinkmp_init_one(struct pci_dev *dev,const struct pci_device_id *ent); static void synclinkmp_remove_one(struct pci_dev *dev); @@ -555,7 +555,6 @@ static int set_txidle(SLMP_INFO *info, int idle_mode); static int tx_enable(SLMP_INFO *info, int enable); static int tx_abort(SLMP_INFO *info); static int rx_enable(SLMP_INFO *info, int enable); -static int map_status(int signals); static int modem_input_wait(SLMP_INFO *info,int arg); static int wait_mgsl_event(SLMP_INFO *info, int __user *mask_ptr); static int tiocmget(struct tty_struct *tty, struct file *file); @@ -644,7 +643,7 @@ static unsigned char tx_active_fifo_level = 16; // tx request FIFO activation le static unsigned char tx_negate_fifo_level = 32; // tx request FIFO negation level in bytes static u32 misc_ctrl_value = 0x007e4040; -static u32 lcr1_brdr_value = 0x00800029; +static u32 lcr1_brdr_value = 0x00800028; static u32 read_ahead_count = 8; @@ -2749,6 +2748,8 @@ static int startup(SLMP_INFO * info) info->pending_bh = 0; + memset(&info->icount, 0, sizeof(info->icount)); + /* program hardware for current parameters */ reset_port(info); @@ -2952,12 +2953,12 @@ static int get_stats(SLMP_INFO * info, struct mgsl_icount __user *user_icount) printk("%s(%d):%s get_params()\n", __FILE__,__LINE__, info->device_name); - COPY_TO_USER(err,user_icount, &info->icount, sizeof(struct mgsl_icount)); - if (err) { - if ( debug_level >= DEBUG_LEVEL_INFO ) - printk( "%s(%d):%s get_stats() user buffer copy failed\n", - __FILE__,__LINE__,info->device_name); - return -EFAULT; + if (!user_icount) { + memset(&info->icount, 0, sizeof(info->icount)); + } else { + COPY_TO_USER(err, user_icount, &info->icount, sizeof(struct mgsl_icount)); + if (err) + return -EFAULT; } return 0; @@ -3108,16 +3109,6 @@ static int rx_enable(SLMP_INFO * info, int enable) return 0; } -static int map_status(int signals) -{ - /* Map status bits to API event bits */ - - return ((signals & SerialSignal_DSR) ? MgslEvent_DsrActive : MgslEvent_DsrInactive) + - ((signals & SerialSignal_CTS) ? MgslEvent_CtsActive : MgslEvent_CtsInactive) + - ((signals & SerialSignal_DCD) ? MgslEvent_DcdActive : MgslEvent_DcdInactive) + - ((signals & SerialSignal_RI) ? MgslEvent_RiActive : MgslEvent_RiInactive); -} - /* wait for specified event to occur */ static int wait_mgsl_event(SLMP_INFO * info, int __user *mask_ptr) @@ -3144,7 +3135,7 @@ static int wait_mgsl_event(SLMP_INFO * info, int __user *mask_ptr) /* return immediately if state matches requested events */ get_signals(info); - s = map_status(info->serial_signals); + s = info->serial_signals; events = mask & ( ((s & SerialSignal_DSR) ? MgslEvent_DsrActive:MgslEvent_DsrInactive) + @@ -4488,11 +4479,13 @@ void async_mode(SLMP_INFO *info) /* MD2, Mode Register 2 * * 07..02 Reserved, must be 0 - * 01..00 CNCT<1..0> Channel connection, 0=normal + * 01..00 CNCT<1..0> Channel connection, 00=normal 11=local loopback * * 0000 0000 */ RegValue = 0x00; + if (info->params.loopback) + RegValue |= (BIT1 + BIT0); write_reg(info, MD2, RegValue); /* RXS, Receive clock source @@ -4573,9 +4566,6 @@ void async_mode(SLMP_INFO *info) write_reg(info, IE2, info->ie2_value); set_rate( info, info->params.data_rate * 16 ); - - if (info->params.loopback) - enable_loopback(info,1); } /* Program the SCA for HDLC communications. diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 9d657127f31..e5953f3433f 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -469,21 +469,19 @@ static void tty_ldisc_enable(struct tty_struct *tty) static int tty_set_ldisc(struct tty_struct *tty, int ldisc) { - int retval = 0; - struct tty_ldisc o_ldisc; + int retval = 0; + struct tty_ldisc o_ldisc; char buf[64]; int work; unsigned long flags; struct tty_ldisc *ld; + struct tty_struct *o_tty; if ((ldisc < N_TTY) || (ldisc >= NR_LDISCS)) return -EINVAL; restart: - if (tty->ldisc.num == ldisc) - return 0; /* We are already in the desired discipline */ - ld = tty_ldisc_get(ldisc); /* Eduardo Blanco <ejbs@cs.cs.com.uy> */ /* Cyrus Durgin <cider@speakeasy.org> */ @@ -494,45 +492,74 @@ restart: if (ld == NULL) return -EINVAL; - o_ldisc = tty->ldisc; - tty_wait_until_sent(tty, 0); + if (tty->ldisc.num == ldisc) { + tty_ldisc_put(ldisc); + return 0; + } + + o_ldisc = tty->ldisc; + o_tty = tty->link; + /* * Make sure we don't change while someone holds a * reference to the line discipline. The TTY_LDISC bit * prevents anyone taking a reference once it is clear. * We need the lock to avoid racing reference takers. */ - + spin_lock_irqsave(&tty_ldisc_lock, flags); - if(tty->ldisc.refcount) - { - /* Free the new ldisc we grabbed. Must drop the lock - first. */ + if (tty->ldisc.refcount || (o_tty && o_tty->ldisc.refcount)) { + if(tty->ldisc.refcount) { + /* Free the new ldisc we grabbed. Must drop the lock + first. */ + spin_unlock_irqrestore(&tty_ldisc_lock, flags); + tty_ldisc_put(ldisc); + /* + * There are several reasons we may be busy, including + * random momentary I/O traffic. We must therefore + * retry. We could distinguish between blocking ops + * and retries if we made tty_ldisc_wait() smarter. That + * is up for discussion. + */ + if (wait_event_interruptible(tty_ldisc_wait, tty->ldisc.refcount == 0) < 0) + return -ERESTARTSYS; + goto restart; + } + if(o_tty && o_tty->ldisc.refcount) { + spin_unlock_irqrestore(&tty_ldisc_lock, flags); + tty_ldisc_put(ldisc); + if (wait_event_interruptible(tty_ldisc_wait, o_tty->ldisc.refcount == 0) < 0) + return -ERESTARTSYS; + goto restart; + } + } + + /* if the TTY_LDISC bit is set, then we are racing against another ldisc change */ + + if (!test_bit(TTY_LDISC, &tty->flags)) { spin_unlock_irqrestore(&tty_ldisc_lock, flags); tty_ldisc_put(ldisc); - /* - * There are several reasons we may be busy, including - * random momentary I/O traffic. We must therefore - * retry. We could distinguish between blocking ops - * and retries if we made tty_ldisc_wait() smarter. That - * is up for discussion. - */ - if(wait_event_interruptible(tty_ldisc_wait, tty->ldisc.refcount == 0) < 0) - return -ERESTARTSYS; + ld = tty_ldisc_ref_wait(tty); + tty_ldisc_deref(ld); goto restart; } - clear_bit(TTY_LDISC, &tty->flags); + + clear_bit(TTY_LDISC, &tty->flags); clear_bit(TTY_DONT_FLIP, &tty->flags); + if (o_tty) { + clear_bit(TTY_LDISC, &o_tty->flags); + clear_bit(TTY_DONT_FLIP, &o_tty->flags); + } spin_unlock_irqrestore(&tty_ldisc_lock, flags); - + /* * From this point on we know nobody has an ldisc * usage reference, nor can they obtain one until * we say so later on. */ - + work = cancel_delayed_work(&tty->flip.work); /* * Wait for ->hangup_work and ->flip.work handlers to terminate @@ -583,10 +610,12 @@ restart: */ tty_ldisc_enable(tty); + if (o_tty) + tty_ldisc_enable(o_tty); /* Restart it in case no characters kick it off. Safe if already running */ - if(work) + if (work) schedule_delayed_work(&tty->flip.work, 1); return retval; } @@ -2425,6 +2454,7 @@ static void __do_SAK(void *arg) int i; struct file *filp; struct tty_ldisc *disc; + struct fdtable *fdt; if (!tty) return; @@ -2450,8 +2480,9 @@ static void __do_SAK(void *arg) } task_lock(p); if (p->files) { - spin_lock(&p->files->file_lock); - for (i=0; i < p->files->max_fds; i++) { + rcu_read_lock(); + fdt = files_fdtable(p->files); + for (i=0; i < fdt->max_fds; i++) { filp = fcheck_files(p->files, i); if (!filp) continue; @@ -2464,7 +2495,7 @@ static void __do_SAK(void *arg) break; } } - spin_unlock(&p->files->file_lock); + rcu_read_unlock(); } task_unlock(p); } while_each_task_pid(session, PIDTYPE_SID, p); diff --git a/drivers/char/vt.c b/drivers/char/vt.c index b8d0c290b0d..1e33cb032e0 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c @@ -751,6 +751,7 @@ int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines) unsigned long old_origin, new_origin, new_scr_end, rlth, rrem, err = 0; unsigned int old_cols, old_rows, old_row_size, old_screen_size; unsigned int new_cols, new_rows, new_row_size, new_screen_size; + unsigned int end; unsigned short *newscreen; WARN_CONSOLE_UNLOCKED(); @@ -794,20 +795,44 @@ int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines) old_origin = vc->vc_origin; new_origin = (long) newscreen; new_scr_end = new_origin + new_screen_size; - if (new_rows < old_rows) - old_origin += (old_rows - new_rows) * old_row_size; + + if (vc->vc_y > new_rows) { + if (old_rows - vc->vc_y < new_rows) { + /* + * Cursor near the bottom, copy contents from the + * bottom of buffer + */ + old_origin += (old_rows - new_rows) * old_row_size; + end = vc->vc_scr_end; + } else { + /* + * Cursor is in no man's land, copy 1/2 screenful + * from the top and bottom of cursor position + */ + old_origin += (vc->vc_y - new_rows/2) * old_row_size; + end = old_origin + new_screen_size; + } + } else + /* + * Cursor near the top, copy contents from the top of buffer + */ + end = (old_rows > new_rows) ? old_origin + new_screen_size : + vc->vc_scr_end; update_attr(vc); - while (old_origin < vc->vc_scr_end) { - scr_memcpyw((unsigned short *) new_origin, (unsigned short *) old_origin, rlth); + while (old_origin < end) { + scr_memcpyw((unsigned short *) new_origin, + (unsigned short *) old_origin, rlth); if (rrem) - scr_memsetw((void *)(new_origin + rlth), vc->vc_video_erase_char, rrem); + scr_memsetw((void *)(new_origin + rlth), + vc->vc_video_erase_char, rrem); old_origin += old_row_size; new_origin += new_row_size; } if (new_scr_end > new_origin) - scr_memsetw((void *)new_origin, vc->vc_video_erase_char, new_scr_end - new_origin); + scr_memsetw((void *)new_origin, vc->vc_video_erase_char, + new_scr_end - new_origin); if (vc->vc_kmalloced) kfree(vc->vc_screenbuf); vc->vc_screenbuf = newscreen; diff --git a/drivers/char/watchdog/mixcomwd.c b/drivers/char/watchdog/mixcomwd.c index c9b301dccec..7fc2188386d 100644 --- a/drivers/char/watchdog/mixcomwd.c +++ b/drivers/char/watchdog/mixcomwd.c @@ -59,7 +59,7 @@ static unsigned long mixcomwd_opened; /* long req'd for setbit --RR */ static int watchdog_port; static int mixcomwd_timer_alive; -static struct timer_list mixcomwd_timer = TIMER_INITIALIZER(NULL, 0, 0); +static DEFINE_TIMER(mixcomwd_timer, NULL, 0, 0); static char expect_close; static int nowayout = WATCHDOG_NOWAYOUT; diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index f174aee659e..9e9cf140731 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -560,7 +560,7 @@ ide_startstop_t __ide_abort(ide_drive_t *drive, struct request *rq) EXPORT_SYMBOL_GPL(__ide_abort); /** - * ide_abort - abort pending IDE operatins + * ide_abort - abort pending IDE operations * @drive: drive the error occurred on * @msg: message to report * @@ -623,7 +623,7 @@ static void ide_cmd (ide_drive_t *drive, u8 cmd, u8 nsect, * @drive: drive the completion interrupt occurred on * * drive_cmd_intr() is invoked on completion of a special DRIVE_CMD. - * We do any necessary daya reading and then wait for the drive to + * We do any necessary data reading and then wait for the drive to * go non busy. At that point we may read the error data and complete * the request */ @@ -773,7 +773,7 @@ EXPORT_SYMBOL_GPL(ide_init_sg_cmd); /** * execute_drive_command - issue special drive command - * @drive: the drive to issue th command on + * @drive: the drive to issue the command on * @rq: the request structure holding the command * * execute_drive_cmd() issues a special drive command, usually diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 5a3dc46008e..ee38e6b143a 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c @@ -2903,8 +2903,7 @@ static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout) } else if (!(tape->sense_key == 2 && tape->asc == 4 && (tape->ascq == 1 || tape->ascq == 8))) return -EIO; - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(HZ / 10); + msleep(100); } return -EIO; } diff --git a/drivers/ide/ide-timing.h b/drivers/ide/ide-timing.h index c1196ce15b4..2fcfac6e967 100644 --- a/drivers/ide/ide-timing.h +++ b/drivers/ide/ide-timing.h @@ -27,6 +27,7 @@ * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic */ +#include <linux/kernel.h> #include <linux/hdreg.h> #define XFER_PIO_5 0x0d @@ -96,11 +97,9 @@ static struct ide_timing ide_timing[] = { #define IDE_TIMING_UDMA 0x80 #define IDE_TIMING_ALL 0xff -#define MIN(a,b) ((a)<(b)?(a):(b)) -#define MAX(a,b) ((a)>(b)?(a):(b)) -#define FIT(v,min,max) MAX(MIN(v,max),min) -#define ENOUGH(v,unit) (((v)-1)/(unit)+1) -#define EZ(v,unit) ((v)?ENOUGH(v,unit):0) +#define FIT(v,vmin,vmax) max_t(short,min_t(short,v,vmax),vmin) +#define ENOUGH(v,unit) (((v)-1)/(unit)+1) +#define EZ(v,unit) ((v)?ENOUGH(v,unit):0) #define XFER_MODE 0xf0 #define XFER_UDMA_133 0x48 @@ -188,14 +187,14 @@ static void ide_timing_quantize(struct ide_timing *t, struct ide_timing *q, int static void ide_timing_merge(struct ide_timing *a, struct ide_timing *b, struct ide_timing *m, unsigned int what) { - if (what & IDE_TIMING_SETUP ) m->setup = MAX(a->setup, b->setup); - if (what & IDE_TIMING_ACT8B ) m->act8b = MAX(a->act8b, b->act8b); - if (what & IDE_TIMING_REC8B ) m->rec8b = MAX(a->rec8b, b->rec8b); - if (what & IDE_TIMING_CYC8B ) m->cyc8b = MAX(a->cyc8b, b->cyc8b); - if (what & IDE_TIMING_ACTIVE ) m->active = MAX(a->active, b->active); - if (what & IDE_TIMING_RECOVER) m->recover = MAX(a->recover, b->recover); - if (what & IDE_TIMING_CYCLE ) m->cycle = MAX(a->cycle, b->cycle); - if (what & IDE_TIMING_UDMA ) m->udma = MAX(a->udma, b->udma); + if (what & IDE_TIMING_SETUP ) m->setup = max(a->setup, b->setup); + if (what & IDE_TIMING_ACT8B ) m->act8b = max(a->act8b, b->act8b); + if (what & IDE_TIMING_REC8B ) m->rec8b = max(a->rec8b, b->rec8b); + if (what & IDE_TIMING_CYC8B ) m->cyc8b = max(a->cyc8b, b->cyc8b); + if (what & IDE_TIMING_ACTIVE ) m->active = max(a->active, b->active); + if (what & IDE_TIMING_RECOVER) m->recover = max(a->recover, b->recover); + if (what & IDE_TIMING_CYCLE ) m->cycle = max(a->cycle, b->cycle); + if (what & IDE_TIMING_UDMA ) m->udma = max(a->udma, b->udma); } static struct ide_timing* ide_timing_find_mode(short speed) diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c index f1d1ec4e967..0ccf85fcee3 100644 --- a/drivers/ide/legacy/ide-cs.c +++ b/drivers/ide/legacy/ide-cs.c @@ -43,6 +43,7 @@ #include <linux/ide.h> #include <linux/hdreg.h> #include <linux/major.h> +#include <linux/delay.h> #include <asm/io.h> #include <asm/system.h> @@ -340,8 +341,7 @@ static void ide_config(dev_link_t *link) break; } } - __set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ/10); + msleep(100); } if (hd < 0) { @@ -454,9 +454,12 @@ int ide_event(event_t event, int priority, static struct pcmcia_device_id ide_ids[] = { PCMCIA_DEVICE_FUNC_ID(4), PCMCIA_DEVICE_MANF_CARD(0x0032, 0x0704), + PCMCIA_DEVICE_MANF_CARD(0x0045, 0x0401), + PCMCIA_DEVICE_MANF_CARD(0x0098, 0x0000), /* Toshiba */ PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x002d), + PCMCIA_DEVICE_MANF_CARD(0x00ce, 0x0000), /* Samsung */ PCMCIA_DEVICE_MANF_CARD(0x2080, 0x0001), - PCMCIA_DEVICE_MANF_CARD(0x0045, 0x0401), + PCMCIA_DEVICE_MANF_CARD(0x4e01, 0x0200), /* Lexar */ PCMCIA_DEVICE_PROD_ID123("Caravelle", "PSC-IDE ", "PSC000", 0x8c36137c, 0xd0693ab8, 0x2768a9f0), PCMCIA_DEVICE_PROD_ID123("CDROM", "IDE", "MCD-601p", 0x1b9179ca, 0xede88951, 0x0d902f74), PCMCIA_DEVICE_PROD_ID123("PCMCIA", "IDE CARD", "F1", 0x281f1c5d, 0x1907960c, 0xf7fde8b9), @@ -481,6 +484,7 @@ static struct pcmcia_device_id ide_ids[] = { PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003), PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852), PCMCIA_DEVICE_PROD_ID1("STI Flash", 0xe4a13209), + PCMCIA_DEVICE_PROD_ID12("STI", "Flash 5.0", 0xbf2df18d, 0x8cb57a0e), PCMCIA_MFC_DEVICE_PROD_ID12(1, "SanDisk", "ConnectPlus", 0x7a954bd9, 0x74be00c6), PCMCIA_DEVICE_NULL, }; diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index 7b64db10d1b..127619a109e 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c @@ -1334,9 +1334,13 @@ static int __devinit init_hpt366(struct pci_dev *dev) static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const char *name) { int ret = 0; - /* FIXME: Not portable */ + + /* + * FIXME: Not portable. Also, why do we enable the ROM in the first place? + * We don't seem to be using it. + */ if (dev->resource[PCI_ROM_RESOURCE].start) - pci_write_config_byte(dev, PCI_ROM_ADDRESS, + pci_write_config_dword(dev, PCI_ROM_ADDRESS, dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE); pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, (L1_CACHE_BYTES / 4)); diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c index 06759b36afe..9d6facf2f78 100644 --- a/drivers/ieee1394/video1394.c +++ b/drivers/ieee1394/video1394.c @@ -883,7 +883,7 @@ static int __video1394_ioctl(struct file *file, v.channel); } - if (copy_to_user((void *)arg, &v, sizeof(v))) { + if (copy_to_user(argp, &v, sizeof(v))) { /* FIXME : free allocated dma resources */ return -EFAULT; } diff --git a/drivers/infiniband/Kconfig b/drivers/infiniband/Kconfig index 32cdfb30e9b..325d502e25c 100644 --- a/drivers/infiniband/Kconfig +++ b/drivers/infiniband/Kconfig @@ -8,15 +8,26 @@ config INFINIBAND any protocols you wish to use as well as drivers for your InfiniBand hardware. -config INFINIBAND_USER_VERBS - tristate "InfiniBand userspace verbs support" +config INFINIBAND_USER_MAD + tristate "InfiniBand userspace MAD support" depends on INFINIBAND ---help--- - Userspace InfiniBand verbs support. This is the kernel side - of userspace verbs, which allows userspace processes to - directly access InfiniBand hardware for fast-path - operations. You will also need libibverbs and a hardware - driver library from <http://www.openib.org>. + Userspace InfiniBand Management Datagram (MAD) support. This + is the kernel side of the userspace MAD support, which allows + userspace processes to send and receive MADs. You will also + need libibumad from <http://www.openib.org>. + +config INFINIBAND_USER_ACCESS + tristate "InfiniBand userspace access (verbs and CM)" + depends on INFINIBAND + ---help--- + Userspace InfiniBand access support. This enables the + kernel side of userspace verbs and the userspace + communication manager (CM). This allows userspace processes + to set up connections and directly access InfiniBand + hardware for fast-path operations. You will also need + libibverbs, libibcm and a hardware driver library from + <http://www.openib.org>. source "drivers/infiniband/hw/mthca/Kconfig" diff --git a/drivers/infiniband/core/Makefile b/drivers/infiniband/core/Makefile index 678a7e097f3..ec3353f24b2 100644 --- a/drivers/infiniband/core/Makefile +++ b/drivers/infiniband/core/Makefile @@ -1,6 +1,7 @@ obj-$(CONFIG_INFINIBAND) += ib_core.o ib_mad.o ib_sa.o \ - ib_cm.o ib_umad.o ib_ucm.o -obj-$(CONFIG_INFINIBAND_USER_VERBS) += ib_uverbs.o + ib_cm.o +obj-$(CONFIG_INFINIBAND_USER_MAD) += ib_umad.o +obj-$(CONFIG_INFINIBAND_USER_ACCESS) += ib_uverbs.o ib_ucm.o ib_core-y := packer.o ud_header.o verbs.o sysfs.o \ device.o fmr_pool.o cache.o diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index 4de93ba274a..54db6d4831f 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c @@ -173,7 +173,8 @@ static int cm_alloc_msg(struct cm_id_private *cm_id_priv, if (IS_ERR(ah)) return PTR_ERR(ah); - m = ib_create_send_mad(mad_agent, 1, cm_id_priv->av.pkey_index, + m = ib_create_send_mad(mad_agent, cm_id_priv->id.remote_cm_qpn, + cm_id_priv->av.pkey_index, ah, 0, sizeof(struct ib_mad_hdr), sizeof(struct ib_mad)-sizeof(struct ib_mad_hdr), GFP_ATOMIC); @@ -536,6 +537,7 @@ struct ib_cm_id *ib_create_cm_id(ib_cm_handler cm_handler, cm_id_priv->id.state = IB_CM_IDLE; cm_id_priv->id.cm_handler = cm_handler; cm_id_priv->id.context = context; + cm_id_priv->id.remote_cm_qpn = 1; ret = cm_alloc_id(cm_id_priv); if (ret) goto error; @@ -1313,6 +1315,7 @@ error3: atomic_dec(&cm_id_priv->refcount); cm_deref_id(listen_cm_id_priv); cm_cleanup_timewait(cm_id_priv->timewait_info); error2: kfree(cm_id_priv->timewait_info); + cm_id_priv->timewait_info = NULL; error1: ib_destroy_cm_id(&cm_id_priv->id); return ret; } diff --git a/drivers/infiniband/core/mad_rmpp.c b/drivers/infiniband/core/mad_rmpp.c index 43fd805e026..2bd8b1cc57c 100644 --- a/drivers/infiniband/core/mad_rmpp.c +++ b/drivers/infiniband/core/mad_rmpp.c @@ -593,7 +593,8 @@ static int send_next_seg(struct ib_mad_send_wr_private *mad_send_wr) rmpp_mad->rmpp_hdr.paylen_newwin = cpu_to_be32(mad_send_wr->total_seg * (sizeof(struct ib_rmpp_mad) - - offsetof(struct ib_rmpp_mad, data))); + offsetof(struct ib_rmpp_mad, data)) - + mad_send_wr->pad); mad_send_wr->sg_list[0].length = sizeof(struct ib_rmpp_mad); } else { mad_send_wr->send_wr.num_sge = 2; @@ -602,6 +603,7 @@ static int send_next_seg(struct ib_mad_send_wr_private *mad_send_wr) mad_send_wr->sg_list[1].length = sizeof(struct ib_rmpp_mad) - mad_send_wr->data_offset; mad_send_wr->sg_list[1].lkey = mad_send_wr->sg_list[0].lkey; + rmpp_mad->rmpp_hdr.paylen_newwin = 0; } if (mad_send_wr->seg_num == mad_send_wr->total_seg) { diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c index 126ac80db7b..78de2dd1a4f 100644 --- a/drivers/infiniband/core/sa_query.c +++ b/drivers/infiniband/core/sa_query.c @@ -113,32 +113,6 @@ static DEFINE_IDR(query_idr); static spinlock_t tid_lock; static u32 tid; -enum { - IB_SA_ATTR_CLASS_PORTINFO = 0x01, - IB_SA_ATTR_NOTICE = 0x02, - IB_SA_ATTR_INFORM_INFO = 0x03, - IB_SA_ATTR_NODE_REC = 0x11, - IB_SA_ATTR_PORT_INFO_REC = 0x12, - IB_SA_ATTR_SL2VL_REC = 0x13, - IB_SA_ATTR_SWITCH_REC = 0x14, - IB_SA_ATTR_LINEAR_FDB_REC = 0x15, - IB_SA_ATTR_RANDOM_FDB_REC = 0x16, - IB_SA_ATTR_MCAST_FDB_REC = 0x17, - IB_SA_ATTR_SM_INFO_REC = 0x18, - IB_SA_ATTR_LINK_REC = 0x20, - IB_SA_ATTR_GUID_INFO_REC = 0x30, - IB_SA_ATTR_SERVICE_REC = 0x31, - IB_SA_ATTR_PARTITION_REC = 0x33, - IB_SA_ATTR_RANGE_REC = 0x34, - IB_SA_ATTR_PATH_REC = 0x35, - IB_SA_ATTR_VL_ARB_REC = 0x36, - IB_SA_ATTR_MC_GROUP_REC = 0x37, - IB_SA_ATTR_MC_MEMBER_REC = 0x38, - IB_SA_ATTR_TRACE_REC = 0x39, - IB_SA_ATTR_MULTI_PATH_REC = 0x3a, - IB_SA_ATTR_SERVICE_ASSOC_REC = 0x3b -}; - #define PATH_REC_FIELD(field) \ .struct_offset_bytes = offsetof(struct ib_sa_path_rec, field), \ .struct_size_bytes = sizeof ((struct ib_sa_path_rec *) 0)->field, \ @@ -431,8 +405,8 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event event->event == IB_EVENT_LID_CHANGE || event->event == IB_EVENT_PKEY_CHANGE || event->event == IB_EVENT_SM_CHANGE) { - struct ib_sa_device *sa_dev = - ib_get_client_data(event->device, &sa_client); + struct ib_sa_device *sa_dev; + sa_dev = container_of(handler, typeof(*sa_dev), event_handler); schedule_work(&sa_dev->port[event->element.port_num - sa_dev->start_port].update_task); diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c index 79595826ccc..d0f0b0a2edd 100644 --- a/drivers/infiniband/core/ucm.c +++ b/drivers/infiniband/core/ucm.c @@ -72,7 +72,6 @@ enum { static struct semaphore ctx_id_mutex; static struct idr ctx_id_table; -static int ctx_id_rover = 0; static struct ib_ucm_context *ib_ucm_ctx_get(struct ib_ucm_file *file, int id) { @@ -97,33 +96,16 @@ static void ib_ucm_ctx_put(struct ib_ucm_context *ctx) wake_up(&ctx->wait); } -static ssize_t ib_ucm_destroy_ctx(struct ib_ucm_file *file, int id) +static inline int ib_ucm_new_cm_id(int event) { - struct ib_ucm_context *ctx; - struct ib_ucm_event *uevent; - - down(&ctx_id_mutex); - ctx = idr_find(&ctx_id_table, id); - if (!ctx) - ctx = ERR_PTR(-ENOENT); - else if (ctx->file != file) - ctx = ERR_PTR(-EINVAL); - else - idr_remove(&ctx_id_table, ctx->id); - up(&ctx_id_mutex); - - if (IS_ERR(ctx)) - return PTR_ERR(ctx); - - atomic_dec(&ctx->ref); - wait_event(ctx->wait, !atomic_read(&ctx->ref)); + return event == IB_CM_REQ_RECEIVED || event == IB_CM_SIDR_REQ_RECEIVED; +} - /* No new events will be generated after destroying the cm_id. */ - if (!IS_ERR(ctx->cm_id)) - ib_destroy_cm_id(ctx->cm_id); +static void ib_ucm_cleanup_events(struct ib_ucm_context *ctx) +{ + struct ib_ucm_event *uevent; - /* Cleanup events not yet reported to the user. */ - down(&file->mutex); + down(&ctx->file->mutex); list_del(&ctx->file_list); while (!list_empty(&ctx->events)) { @@ -133,15 +115,12 @@ static ssize_t ib_ucm_destroy_ctx(struct ib_ucm_file *file, int id) list_del(&uevent->ctx_list); /* clear incoming connections. */ - if (uevent->cm_id) + if (ib_ucm_new_cm_id(uevent->resp.event)) ib_destroy_cm_id(uevent->cm_id); kfree(uevent); } - up(&file->mutex); - - kfree(ctx); - return 0; + up(&ctx->file->mutex); } static struct ib_ucm_context *ib_ucm_ctx_alloc(struct ib_ucm_file *file) @@ -153,36 +132,31 @@ static struct ib_ucm_context *ib_ucm_ctx_alloc(struct ib_ucm_file *file) if (!ctx) return NULL; + memset(ctx, 0, sizeof *ctx); atomic_set(&ctx->ref, 1); init_waitqueue_head(&ctx->wait); ctx->file = file; - INIT_LIST_HEAD(&ctx->events); - list_add_tail(&ctx->file_list, &file->ctxs); - - ctx_id_rover = (ctx_id_rover + 1) & INT_MAX; -retry: - result = idr_pre_get(&ctx_id_table, GFP_KERNEL); - if (!result) - goto error; + do { + result = idr_pre_get(&ctx_id_table, GFP_KERNEL); + if (!result) + goto error; - down(&ctx_id_mutex); - result = idr_get_new_above(&ctx_id_table, ctx, ctx_id_rover, &ctx->id); - up(&ctx_id_mutex); + down(&ctx_id_mutex); + result = idr_get_new(&ctx_id_table, ctx, &ctx->id); + up(&ctx_id_mutex); + } while (result == -EAGAIN); - if (result == -EAGAIN) - goto retry; if (result) goto error; + list_add_tail(&ctx->file_list, &file->ctxs); ucm_dbg("Allocated CM ID <%d>\n", ctx->id); - return ctx; + error: - list_del(&ctx->file_list); kfree(ctx); - return NULL; } /* @@ -219,12 +193,9 @@ static void ib_ucm_event_path_get(struct ib_ucm_path_rec *upath, kpath->packet_life_time_selector; } -static void ib_ucm_event_req_get(struct ib_ucm_context *ctx, - struct ib_ucm_req_event_resp *ureq, +static void ib_ucm_event_req_get(struct ib_ucm_req_event_resp *ureq, struct ib_cm_req_event_param *kreq) { - ureq->listen_id = ctx->id; - ureq->remote_ca_guid = kreq->remote_ca_guid; ureq->remote_qkey = kreq->remote_qkey; ureq->remote_qpn = kreq->remote_qpn; @@ -259,14 +230,6 @@ static void ib_ucm_event_rep_get(struct ib_ucm_rep_event_resp *urep, urep->srq = krep->srq; } -static void ib_ucm_event_sidr_req_get(struct ib_ucm_context *ctx, - struct ib_ucm_sidr_req_event_resp *ureq, - struct ib_cm_sidr_req_event_param *kreq) -{ - ureq->listen_id = ctx->id; - ureq->pkey = kreq->pkey; -} - static void ib_ucm_event_sidr_rep_get(struct ib_ucm_sidr_rep_event_resp *urep, struct ib_cm_sidr_rep_event_param *krep) { @@ -275,15 +238,14 @@ static void ib_ucm_event_sidr_rep_get(struct ib_ucm_sidr_rep_event_resp *urep, urep->qpn = krep->qpn; }; -static int ib_ucm_event_process(struct ib_ucm_context *ctx, - struct ib_cm_event *evt, +static int ib_ucm_event_process(struct ib_cm_event *evt, struct ib_ucm_event *uvt) { void *info = NULL; switch (evt->event) { case IB_CM_REQ_RECEIVED: - ib_ucm_event_req_get(ctx, &uvt->resp.u.req_resp, + ib_ucm_event_req_get(&uvt->resp.u.req_resp, &evt->param.req_rcvd); uvt->data_len = IB_CM_REQ_PRIVATE_DATA_SIZE; uvt->resp.present = IB_UCM_PRES_PRIMARY; @@ -331,8 +293,8 @@ static int ib_ucm_event_process(struct ib_ucm_context *ctx, info = evt->param.apr_rcvd.apr_info; break; case IB_CM_SIDR_REQ_RECEIVED: - ib_ucm_event_sidr_req_get(ctx, &uvt->resp.u.sidr_req_resp, - &evt->param.sidr_req_rcvd); + uvt->resp.u.sidr_req_resp.pkey = + evt->param.sidr_req_rcvd.pkey; uvt->data_len = IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE; break; case IB_CM_SIDR_REP_RECEIVED: @@ -378,31 +340,24 @@ static int ib_ucm_event_handler(struct ib_cm_id *cm_id, struct ib_ucm_event *uevent; struct ib_ucm_context *ctx; int result = 0; - int id; ctx = cm_id->context; - if (event->event == IB_CM_REQ_RECEIVED || - event->event == IB_CM_SIDR_REQ_RECEIVED) - id = IB_UCM_CM_ID_INVALID; - else - id = ctx->id; - uevent = kmalloc(sizeof(*uevent), GFP_KERNEL); if (!uevent) goto err1; memset(uevent, 0, sizeof(*uevent)); - uevent->resp.id = id; + uevent->ctx = ctx; + uevent->cm_id = cm_id; + uevent->resp.uid = ctx->uid; + uevent->resp.id = ctx->id; uevent->resp.event = event->event; - result = ib_ucm_event_process(ctx, event, uevent); + result = ib_ucm_event_process(event, uevent); if (result) goto err2; - uevent->ctx = ctx; - uevent->cm_id = (id == IB_UCM_CM_ID_INVALID) ? cm_id : NULL; - down(&ctx->file->mutex); list_add_tail(&uevent->file_list, &ctx->file->events); list_add_tail(&uevent->ctx_list, &ctx->events); @@ -414,7 +369,7 @@ err2: kfree(uevent); err1: /* Destroy new cm_id's */ - return (id == IB_UCM_CM_ID_INVALID); + return ib_ucm_new_cm_id(event->event); } static ssize_t ib_ucm_event(struct ib_ucm_file *file, @@ -423,7 +378,7 @@ static ssize_t ib_ucm_event(struct ib_ucm_file *file, { struct ib_ucm_context *ctx; struct ib_ucm_event_get cmd; - struct ib_ucm_event *uevent = NULL; + struct ib_ucm_event *uevent; int result = 0; DEFINE_WAIT(wait); @@ -436,7 +391,6 @@ static ssize_t ib_ucm_event(struct ib_ucm_file *file, * wait */ down(&file->mutex); - while (list_empty(&file->events)) { if (file->filp->f_flags & O_NONBLOCK) { @@ -463,21 +417,18 @@ static ssize_t ib_ucm_event(struct ib_ucm_file *file, uevent = list_entry(file->events.next, struct ib_ucm_event, file_list); - if (!uevent->cm_id) - goto user; + if (ib_ucm_new_cm_id(uevent->resp.event)) { + ctx = ib_ucm_ctx_alloc(file); + if (!ctx) { + result = -ENOMEM; + goto done; + } - ctx = ib_ucm_ctx_alloc(file); - if (!ctx) { - result = -ENOMEM; - goto done; + ctx->cm_id = uevent->cm_id; + ctx->cm_id->context = ctx; + uevent->resp.id = ctx->id; } - ctx->cm_id = uevent->cm_id; - ctx->cm_id->context = ctx; - - uevent->resp.id = ctx->id; - -user: if (copy_to_user((void __user *)(unsigned long)cmd.response, &uevent->resp, sizeof(uevent->resp))) { result = -EFAULT; @@ -485,12 +436,10 @@ user: } if (uevent->data) { - if (cmd.data_len < uevent->data_len) { result = -ENOMEM; goto done; } - if (copy_to_user((void __user *)(unsigned long)cmd.data, uevent->data, uevent->data_len)) { result = -EFAULT; @@ -499,12 +448,10 @@ user: } if (uevent->info) { - if (cmd.info_len < uevent->info_len) { result = -ENOMEM; goto done; } - if (copy_to_user((void __user *)(unsigned long)cmd.info, uevent->info, uevent->info_len)) { result = -EFAULT; @@ -514,6 +461,7 @@ user: list_del(&uevent->file_list); list_del(&uevent->ctx_list); + uevent->ctx->events_reported++; kfree(uevent->data); kfree(uevent->info); @@ -545,6 +493,7 @@ static ssize_t ib_ucm_create_id(struct ib_ucm_file *file, if (!ctx) return -ENOMEM; + ctx->uid = cmd.uid; ctx->cm_id = ib_create_cm_id(ib_ucm_event_handler, ctx); if (IS_ERR(ctx->cm_id)) { result = PTR_ERR(ctx->cm_id); @@ -561,7 +510,14 @@ static ssize_t ib_ucm_create_id(struct ib_ucm_file *file, return 0; err: - ib_ucm_destroy_ctx(file, ctx->id); + down(&ctx_id_mutex); + idr_remove(&ctx_id_table, ctx->id); + up(&ctx_id_mutex); + + if (!IS_ERR(ctx->cm_id)) + ib_destroy_cm_id(ctx->cm_id); + + kfree(ctx); return result; } @@ -570,11 +526,44 @@ static ssize_t ib_ucm_destroy_id(struct ib_ucm_file *file, int in_len, int out_len) { struct ib_ucm_destroy_id cmd; + struct ib_ucm_destroy_id_resp resp; + struct ib_ucm_context *ctx; + int result = 0; + + if (out_len < sizeof(resp)) + return -ENOSPC; if (copy_from_user(&cmd, inbuf, sizeof(cmd))) return -EFAULT; - return ib_ucm_destroy_ctx(file, cmd.id); + down(&ctx_id_mutex); + ctx = idr_find(&ctx_id_table, cmd.id); + if (!ctx) + ctx = ERR_PTR(-ENOENT); + else if (ctx->file != file) + ctx = ERR_PTR(-EINVAL); + else + idr_remove(&ctx_id_table, ctx->id); + up(&ctx_id_mutex); + + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + + atomic_dec(&ctx->ref); + wait_event(ctx->wait, !atomic_read(&ctx->ref)); + + /* No new events will be generated after destroying the cm_id. */ + ib_destroy_cm_id(ctx->cm_id); + /* Cleanup events not yet reported to the user. */ + ib_ucm_cleanup_events(ctx); + + resp.events_reported = ctx->events_reported; + if (copy_to_user((void __user *)(unsigned long)cmd.response, + &resp, sizeof(resp))) + result = -EFAULT; + + kfree(ctx); + return result; } static ssize_t ib_ucm_attr_id(struct ib_ucm_file *file, @@ -609,6 +598,98 @@ static ssize_t ib_ucm_attr_id(struct ib_ucm_file *file, return result; } +static void ib_ucm_copy_ah_attr(struct ib_ucm_ah_attr *dest_attr, + struct ib_ah_attr *src_attr) +{ + memcpy(dest_attr->grh_dgid, src_attr->grh.dgid.raw, + sizeof src_attr->grh.dgid); + dest_attr->grh_flow_label = src_attr->grh.flow_label; + dest_attr->grh_sgid_index = src_attr->grh.sgid_index; + dest_attr->grh_hop_limit = src_attr->grh.hop_limit; + dest_attr->grh_traffic_class = src_attr->grh.traffic_class; + + dest_attr->dlid = src_attr->dlid; + dest_attr->sl = src_attr->sl; + dest_attr->src_path_bits = src_attr->src_path_bits; + dest_attr->static_rate = src_attr->static_rate; + dest_attr->is_global = (src_attr->ah_flags & IB_AH_GRH); + dest_attr->port_num = src_attr->port_num; +} + +static void ib_ucm_copy_qp_attr(struct ib_ucm_init_qp_attr_resp *dest_attr, + struct ib_qp_attr *src_attr) +{ + dest_attr->cur_qp_state = src_attr->cur_qp_state; + dest_attr->path_mtu = src_attr->path_mtu; + dest_attr->path_mig_state = src_attr->path_mig_state; + dest_attr->qkey = src_attr->qkey; + dest_attr->rq_psn = src_attr->rq_psn; + dest_attr->sq_psn = src_attr->sq_psn; + dest_attr->dest_qp_num = src_attr->dest_qp_num; + dest_attr->qp_access_flags = src_attr->qp_access_flags; + + dest_attr->max_send_wr = src_attr->cap.max_send_wr; + dest_attr->max_recv_wr = src_attr->cap.max_recv_wr; + dest_attr->max_send_sge = src_attr->cap.max_send_sge; + dest_attr->max_recv_sge = src_attr->cap.max_recv_sge; + dest_attr->max_inline_data = src_attr->cap.max_inline_data; + + ib_ucm_copy_ah_attr(&dest_attr->ah_attr, &src_attr->ah_attr); + ib_ucm_copy_ah_attr(&dest_attr->alt_ah_attr, &src_attr->alt_ah_attr); + + dest_attr->pkey_index = src_attr->pkey_index; + dest_attr->alt_pkey_index = src_attr->alt_pkey_index; + dest_attr->en_sqd_async_notify = src_attr->en_sqd_async_notify; + dest_attr->sq_draining = src_attr->sq_draining; + dest_attr->max_rd_atomic = src_attr->max_rd_atomic; + dest_attr->max_dest_rd_atomic = src_attr->max_dest_rd_atomic; + dest_attr->min_rnr_timer = src_attr->min_rnr_timer; + dest_attr->port_num = src_attr->port_num; + dest_attr->timeout = src_attr->timeout; + dest_attr->retry_cnt = src_attr->retry_cnt; + dest_attr->rnr_retry = src_attr->rnr_retry; + dest_attr->alt_port_num = src_attr->alt_port_num; + dest_attr->alt_timeout = src_attr->alt_timeout; +} + +static ssize_t ib_ucm_init_qp_attr(struct ib_ucm_file *file, + const char __user *inbuf, + int in_len, int out_len) +{ + struct ib_ucm_init_qp_attr_resp resp; + struct ib_ucm_init_qp_attr cmd; + struct ib_ucm_context *ctx; + struct ib_qp_attr qp_attr; + int result = 0; + + if (out_len < sizeof(resp)) + return -ENOSPC; + + if (copy_from_user(&cmd, inbuf, sizeof(cmd))) + return -EFAULT; + + ctx = ib_ucm_ctx_get(file, cmd.id); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + + resp.qp_attr_mask = 0; + memset(&qp_attr, 0, sizeof qp_attr); + qp_attr.qp_state = cmd.qp_state; + result = ib_cm_init_qp_attr(ctx->cm_id, &qp_attr, &resp.qp_attr_mask); + if (result) + goto out; + + ib_ucm_copy_qp_attr(&resp, &qp_attr); + + if (copy_to_user((void __user *)(unsigned long)cmd.response, + &resp, sizeof(resp))) + result = -EFAULT; + +out: + ib_ucm_ctx_put(ctx); + return result; +} + static ssize_t ib_ucm_listen(struct ib_ucm_file *file, const char __user *inbuf, int in_len, int out_len) @@ -808,6 +889,7 @@ static ssize_t ib_ucm_send_rep(struct ib_ucm_file *file, ctx = ib_ucm_ctx_get(file, cmd.id); if (!IS_ERR(ctx)) { + ctx->uid = cmd.uid; result = ib_send_cm_rep(ctx->cm_id, ¶m); ib_ucm_ctx_put(ctx); } else @@ -1086,6 +1168,7 @@ static ssize_t (*ucm_cmd_table[])(struct ib_ucm_file *file, [IB_USER_CM_CMD_SEND_SIDR_REQ] = ib_ucm_send_sidr_req, [IB_USER_CM_CMD_SEND_SIDR_REP] = ib_ucm_send_sidr_rep, [IB_USER_CM_CMD_EVENT] = ib_ucm_event, + [IB_USER_CM_CMD_INIT_QP_ATTR] = ib_ucm_init_qp_attr, }; static ssize_t ib_ucm_write(struct file *filp, const char __user *buf, @@ -1161,12 +1244,18 @@ static int ib_ucm_close(struct inode *inode, struct file *filp) down(&file->mutex); while (!list_empty(&file->ctxs)) { - ctx = list_entry(file->ctxs.next, struct ib_ucm_context, file_list); - up(&file->mutex); - ib_ucm_destroy_ctx(file, ctx->id); + + down(&ctx_id_mutex); + idr_remove(&ctx_id_table, ctx->id); + up(&ctx_id_mutex); + + ib_destroy_cm_id(ctx->cm_id); + ib_ucm_cleanup_events(ctx); + kfree(ctx); + down(&file->mutex); } up(&file->mutex); diff --git a/drivers/infiniband/core/ucm.h b/drivers/infiniband/core/ucm.h index c8819b928a1..f46f37bc120 100644 --- a/drivers/infiniband/core/ucm.h +++ b/drivers/infiniband/core/ucm.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2005 Topspin Communications. All rights reserved. + * Copyright (c) 2005 Intel Corporation. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -43,8 +44,6 @@ #include <rdma/ib_cm.h> #include <rdma/ib_user_cm.h> -#define IB_UCM_CM_ID_INVALID 0xffffffff - struct ib_ucm_file { struct semaphore mutex; struct file *filp; @@ -58,9 +57,11 @@ struct ib_ucm_context { int id; wait_queue_head_t wait; atomic_t ref; + int events_reported; struct ib_ucm_file *file; struct ib_cm_id *cm_id; + __u64 uid; struct list_head events; /* list of pending events. */ struct list_head file_list; /* member in file ctx list */ @@ -71,16 +72,12 @@ struct ib_ucm_event { struct list_head file_list; /* member in file event list */ struct list_head ctx_list; /* member in ctx event list */ + struct ib_cm_id *cm_id; struct ib_ucm_event_resp resp; void *data; void *info; int data_len; int info_len; - /* - * new connection identifiers needs to be saved until - * userspace can get a handle on them. - */ - struct ib_cm_id *cm_id; }; #endif /* UCM_H */ diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h index 180b3d4765e..b1897bed14a 100644 --- a/drivers/infiniband/core/uverbs.h +++ b/drivers/infiniband/core/uverbs.h @@ -76,20 +76,28 @@ struct ib_uverbs_file { struct ib_uverbs_event_file comp_file[1]; }; -struct ib_uverbs_async_event { - struct ib_uverbs_async_event_desc desc; +struct ib_uverbs_event { + union { + struct ib_uverbs_async_event_desc async; + struct ib_uverbs_comp_event_desc comp; + } desc; struct list_head list; + struct list_head obj_list; + u32 *counter; }; -struct ib_uverbs_comp_event { - struct ib_uverbs_comp_event_desc desc; - struct list_head list; +struct ib_uevent_object { + struct ib_uobject uobject; + struct list_head event_list; + u32 events_reported; }; -struct ib_uobject_mr { - struct ib_uobject uobj; - struct page *page_list; - struct scatterlist *sg_list; +struct ib_ucq_object { + struct ib_uobject uobject; + struct list_head comp_list; + struct list_head async_list; + u32 comp_events_reported; + u32 async_events_reported; }; extern struct semaphore ib_uverbs_idr_mutex; diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index ebccf9f38af..e91ebde4648 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -590,7 +590,7 @@ ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file, struct ib_uverbs_create_cq cmd; struct ib_uverbs_create_cq_resp resp; struct ib_udata udata; - struct ib_uobject *uobj; + struct ib_ucq_object *uobj; struct ib_cq *cq; int ret; @@ -611,8 +611,12 @@ ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file, if (!uobj) return -ENOMEM; - uobj->user_handle = cmd.user_handle; - uobj->context = file->ucontext; + uobj->uobject.user_handle = cmd.user_handle; + uobj->uobject.context = file->ucontext; + uobj->comp_events_reported = 0; + uobj->async_events_reported = 0; + INIT_LIST_HEAD(&uobj->comp_list); + INIT_LIST_HEAD(&uobj->async_list); cq = file->device->ib_dev->create_cq(file->device->ib_dev, cmd.cqe, file->ucontext, &udata); @@ -622,7 +626,7 @@ ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file, } cq->device = file->device->ib_dev; - cq->uobject = uobj; + cq->uobject = &uobj->uobject; cq->comp_handler = ib_uverbs_comp_handler; cq->event_handler = ib_uverbs_cq_event_handler; cq->cq_context = file; @@ -635,7 +639,7 @@ retry: } down(&ib_uverbs_idr_mutex); - ret = idr_get_new(&ib_uverbs_cq_idr, cq, &uobj->id); + ret = idr_get_new(&ib_uverbs_cq_idr, cq, &uobj->uobject.id); up(&ib_uverbs_idr_mutex); if (ret == -EAGAIN) @@ -644,11 +648,11 @@ retry: goto err_cq; spin_lock_irq(&file->ucontext->lock); - list_add_tail(&uobj->list, &file->ucontext->cq_list); + list_add_tail(&uobj->uobject.list, &file->ucontext->cq_list); spin_unlock_irq(&file->ucontext->lock); memset(&resp, 0, sizeof resp); - resp.cq_handle = uobj->id; + resp.cq_handle = uobj->uobject.id; resp.cqe = cq->cqe; if (copy_to_user((void __user *) (unsigned long) cmd.response, @@ -661,11 +665,11 @@ retry: err_list: spin_lock_irq(&file->ucontext->lock); - list_del(&uobj->list); + list_del(&uobj->uobject.list); spin_unlock_irq(&file->ucontext->lock); down(&ib_uverbs_idr_mutex); - idr_remove(&ib_uverbs_cq_idr, uobj->id); + idr_remove(&ib_uverbs_cq_idr, uobj->uobject.id); up(&ib_uverbs_idr_mutex); err_cq: @@ -680,21 +684,27 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file, const char __user *buf, int in_len, int out_len) { - struct ib_uverbs_destroy_cq cmd; - struct ib_cq *cq; - struct ib_uobject *uobj; - int ret = -EINVAL; + struct ib_uverbs_destroy_cq cmd; + struct ib_uverbs_destroy_cq_resp resp; + struct ib_cq *cq; + struct ib_ucq_object *uobj; + struct ib_uverbs_event *evt, *tmp; + u64 user_handle; + int ret = -EINVAL; if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT; + memset(&resp, 0, sizeof resp); + down(&ib_uverbs_idr_mutex); cq = idr_find(&ib_uverbs_cq_idr, cmd.cq_handle); if (!cq || cq->uobject->context != file->ucontext) goto out; - uobj = cq->uobject; + user_handle = cq->uobject->user_handle; + uobj = container_of(cq->uobject, struct ib_ucq_object, uobject); ret = ib_destroy_cq(cq); if (ret) @@ -703,11 +713,32 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file, idr_remove(&ib_uverbs_cq_idr, cmd.cq_handle); spin_lock_irq(&file->ucontext->lock); - list_del(&uobj->list); + list_del(&uobj->uobject.list); spin_unlock_irq(&file->ucontext->lock); + spin_lock_irq(&file->comp_file[0].lock); + list_for_each_entry_safe(evt, tmp, &uobj->comp_list, obj_list) { + list_del(&evt->list); + kfree(evt); + } + spin_unlock_irq(&file->comp_file[0].lock); + + spin_lock_irq(&file->async_file.lock); + list_for_each_entry_safe(evt, tmp, &uobj->async_list, obj_list) { + list_del(&evt->list); + kfree(evt); + } + spin_unlock_irq(&file->async_file.lock); + + resp.comp_events_reported = uobj->comp_events_reported; + resp.async_events_reported = uobj->async_events_reported; + kfree(uobj); + if (copy_to_user((void __user *) (unsigned long) cmd.response, + &resp, sizeof resp)) + ret = -EFAULT; + out: up(&ib_uverbs_idr_mutex); @@ -721,7 +752,7 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file, struct ib_uverbs_create_qp cmd; struct ib_uverbs_create_qp_resp resp; struct ib_udata udata; - struct ib_uobject *uobj; + struct ib_uevent_object *uobj; struct ib_pd *pd; struct ib_cq *scq, *rcq; struct ib_srq *srq; @@ -772,8 +803,10 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file, attr.cap.max_recv_sge = cmd.max_recv_sge; attr.cap.max_inline_data = cmd.max_inline_data; - uobj->user_handle = cmd.user_handle; - uobj->context = file->ucontext; + uobj->uobject.user_handle = cmd.user_handle; + uobj->uobject.context = file->ucontext; + uobj->events_reported = 0; + INIT_LIST_HEAD(&uobj->event_list); qp = pd->device->create_qp(pd, &attr, &udata); if (IS_ERR(qp)) { @@ -786,7 +819,7 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file, qp->send_cq = attr.send_cq; qp->recv_cq = attr.recv_cq; qp->srq = attr.srq; - qp->uobject = uobj; + qp->uobject = &uobj->uobject; qp->event_handler = attr.event_handler; qp->qp_context = attr.qp_context; qp->qp_type = attr.qp_type; @@ -805,17 +838,17 @@ retry: goto err_destroy; } - ret = idr_get_new(&ib_uverbs_qp_idr, qp, &uobj->id); + ret = idr_get_new(&ib_uverbs_qp_idr, qp, &uobj->uobject.id); if (ret == -EAGAIN) goto retry; if (ret) goto err_destroy; - resp.qp_handle = uobj->id; + resp.qp_handle = uobj->uobject.id; spin_lock_irq(&file->ucontext->lock); - list_add_tail(&uobj->list, &file->ucontext->qp_list); + list_add_tail(&uobj->uobject.list, &file->ucontext->qp_list); spin_unlock_irq(&file->ucontext->lock); if (copy_to_user((void __user *) (unsigned long) cmd.response, @@ -830,7 +863,7 @@ retry: err_list: spin_lock_irq(&file->ucontext->lock); - list_del(&uobj->list); + list_del(&uobj->uobject.list); spin_unlock_irq(&file->ucontext->lock); err_destroy: @@ -930,21 +963,25 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file, const char __user *buf, int in_len, int out_len) { - struct ib_uverbs_destroy_qp cmd; - struct ib_qp *qp; - struct ib_uobject *uobj; - int ret = -EINVAL; + struct ib_uverbs_destroy_qp cmd; + struct ib_uverbs_destroy_qp_resp resp; + struct ib_qp *qp; + struct ib_uevent_object *uobj; + struct ib_uverbs_event *evt, *tmp; + int ret = -EINVAL; if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT; + memset(&resp, 0, sizeof resp); + down(&ib_uverbs_idr_mutex); qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); if (!qp || qp->uobject->context != file->ucontext) goto out; - uobj = qp->uobject; + uobj = container_of(qp->uobject, struct ib_uevent_object, uobject); ret = ib_destroy_qp(qp); if (ret) @@ -953,11 +990,24 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file, idr_remove(&ib_uverbs_qp_idr, cmd.qp_handle); spin_lock_irq(&file->ucontext->lock); - list_del(&uobj->list); + list_del(&uobj->uobject.list); spin_unlock_irq(&file->ucontext->lock); + spin_lock_irq(&file->async_file.lock); + list_for_each_entry_safe(evt, tmp, &uobj->event_list, obj_list) { + list_del(&evt->list); + kfree(evt); + } + spin_unlock_irq(&file->async_file.lock); + + resp.events_reported = uobj->events_reported; + kfree(uobj); + if (copy_to_user((void __user *) (unsigned long) cmd.response, + &resp, sizeof resp)) + ret = -EFAULT; + out: up(&ib_uverbs_idr_mutex); @@ -1015,7 +1065,7 @@ ssize_t ib_uverbs_create_srq(struct ib_uverbs_file *file, struct ib_uverbs_create_srq cmd; struct ib_uverbs_create_srq_resp resp; struct ib_udata udata; - struct ib_uobject *uobj; + struct ib_uevent_object *uobj; struct ib_pd *pd; struct ib_srq *srq; struct ib_srq_init_attr attr; @@ -1050,8 +1100,10 @@ ssize_t ib_uverbs_create_srq(struct ib_uverbs_file *file, attr.attr.max_sge = cmd.max_sge; attr.attr.srq_limit = cmd.srq_limit; - uobj->user_handle = cmd.user_handle; - uobj->context = file->ucontext; + uobj->uobject.user_handle = cmd.user_handle; + uobj->uobject.context = file->ucontext; + uobj->events_reported = 0; + INIT_LIST_HEAD(&uobj->event_list); srq = pd->device->create_srq(pd, &attr, &udata); if (IS_ERR(srq)) { @@ -1061,7 +1113,7 @@ ssize_t ib_uverbs_create_srq(struct ib_uverbs_file *file, srq->device = pd->device; srq->pd = pd; - srq->uobject = uobj; + srq->uobject = &uobj->uobject; srq->event_handler = attr.event_handler; srq->srq_context = attr.srq_context; atomic_inc(&pd->usecnt); @@ -1075,17 +1127,17 @@ retry: goto err_destroy; } - ret = idr_get_new(&ib_uverbs_srq_idr, srq, &uobj->id); + ret = idr_get_new(&ib_uverbs_srq_idr, srq, &uobj->uobject.id); if (ret == -EAGAIN) goto retry; if (ret) goto err_destroy; - resp.srq_handle = uobj->id; + resp.srq_handle = uobj->uobject.id; spin_lock_irq(&file->ucontext->lock); - list_add_tail(&uobj->list, &file->ucontext->srq_list); + list_add_tail(&uobj->uobject.list, &file->ucontext->srq_list); spin_unlock_irq(&file->ucontext->lock); if (copy_to_user((void __user *) (unsigned long) cmd.response, @@ -1100,7 +1152,7 @@ retry: err_list: spin_lock_irq(&file->ucontext->lock); - list_del(&uobj->list); + list_del(&uobj->uobject.list); spin_unlock_irq(&file->ucontext->lock); err_destroy: @@ -1149,21 +1201,25 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file, const char __user *buf, int in_len, int out_len) { - struct ib_uverbs_destroy_srq cmd; - struct ib_srq *srq; - struct ib_uobject *uobj; - int ret = -EINVAL; + struct ib_uverbs_destroy_srq cmd; + struct ib_uverbs_destroy_srq_resp resp; + struct ib_srq *srq; + struct ib_uevent_object *uobj; + struct ib_uverbs_event *evt, *tmp; + int ret = -EINVAL; if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT; down(&ib_uverbs_idr_mutex); + memset(&resp, 0, sizeof resp); + srq = idr_find(&ib_uverbs_srq_idr, cmd.srq_handle); if (!srq || srq->uobject->context != file->ucontext) goto out; - uobj = srq->uobject; + uobj = container_of(srq->uobject, struct ib_uevent_object, uobject); ret = ib_destroy_srq(srq); if (ret) @@ -1172,11 +1228,24 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file, idr_remove(&ib_uverbs_srq_idr, cmd.srq_handle); spin_lock_irq(&file->ucontext->lock); - list_del(&uobj->list); + list_del(&uobj->uobject.list); spin_unlock_irq(&file->ucontext->lock); + spin_lock_irq(&file->async_file.lock); + list_for_each_entry_safe(evt, tmp, &uobj->event_list, obj_list) { + list_del(&evt->list); + kfree(evt); + } + spin_unlock_irq(&file->async_file.lock); + + resp.events_reported = uobj->events_reported; + kfree(uobj); + if (copy_to_user((void __user *) (unsigned long) cmd.response, + &resp, sizeof resp)) + ret = -EFAULT; + out: up(&ib_uverbs_idr_mutex); diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index 09caf5b1ef3..ce5bdb7af30 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c @@ -120,7 +120,7 @@ static int ib_dealloc_ucontext(struct ib_ucontext *context) idr_remove(&ib_uverbs_qp_idr, uobj->id); ib_destroy_qp(qp); list_del(&uobj->list); - kfree(uobj); + kfree(container_of(uobj, struct ib_uevent_object, uobject)); } list_for_each_entry_safe(uobj, tmp, &context->cq_list, list) { @@ -128,7 +128,7 @@ static int ib_dealloc_ucontext(struct ib_ucontext *context) idr_remove(&ib_uverbs_cq_idr, uobj->id); ib_destroy_cq(cq); list_del(&uobj->list); - kfree(uobj); + kfree(container_of(uobj, struct ib_ucq_object, uobject)); } list_for_each_entry_safe(uobj, tmp, &context->srq_list, list) { @@ -136,7 +136,7 @@ static int ib_dealloc_ucontext(struct ib_ucontext *context) idr_remove(&ib_uverbs_srq_idr, uobj->id); ib_destroy_srq(srq); list_del(&uobj->list); - kfree(uobj); + kfree(container_of(uobj, struct ib_uevent_object, uobject)); } /* XXX Free MWs */ @@ -182,7 +182,7 @@ static ssize_t ib_uverbs_event_read(struct file *filp, char __user *buf, size_t count, loff_t *pos) { struct ib_uverbs_event_file *file = filp->private_data; - void *event; + struct ib_uverbs_event *event; int eventsz; int ret = 0; @@ -207,21 +207,23 @@ static ssize_t ib_uverbs_event_read(struct file *filp, char __user *buf, return -ENODEV; } - if (file->is_async) { - event = list_entry(file->event_list.next, - struct ib_uverbs_async_event, list); + event = list_entry(file->event_list.next, struct ib_uverbs_event, list); + + if (file->is_async) eventsz = sizeof (struct ib_uverbs_async_event_desc); - } else { - event = list_entry(file->event_list.next, - struct ib_uverbs_comp_event, list); + else eventsz = sizeof (struct ib_uverbs_comp_event_desc); - } if (eventsz > count) { ret = -EINVAL; event = NULL; - } else + } else { list_del(file->event_list.next); + if (event->counter) { + ++(*event->counter); + list_del(&event->obj_list); + } + } spin_unlock_irq(&file->lock); @@ -257,16 +259,13 @@ static unsigned int ib_uverbs_event_poll(struct file *filp, static void ib_uverbs_event_release(struct ib_uverbs_event_file *file) { - struct list_head *entry, *tmp; + struct ib_uverbs_event *entry, *tmp; spin_lock_irq(&file->lock); if (file->fd != -1) { file->fd = -1; - list_for_each_safe(entry, tmp, &file->event_list) - if (file->is_async) - kfree(list_entry(entry, struct ib_uverbs_async_event, list)); - else - kfree(list_entry(entry, struct ib_uverbs_comp_event, list)); + list_for_each_entry_safe(entry, tmp, &file->event_list, list) + kfree(entry); } spin_unlock_irq(&file->lock); } @@ -304,18 +303,23 @@ static struct file_operations uverbs_event_fops = { void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context) { - struct ib_uverbs_file *file = cq_context; - struct ib_uverbs_comp_event *entry; - unsigned long flags; + struct ib_uverbs_file *file = cq_context; + struct ib_ucq_object *uobj; + struct ib_uverbs_event *entry; + unsigned long flags; entry = kmalloc(sizeof *entry, GFP_ATOMIC); if (!entry) return; - entry->desc.cq_handle = cq->uobject->user_handle; + uobj = container_of(cq->uobject, struct ib_ucq_object, uobject); + + entry->desc.comp.cq_handle = cq->uobject->user_handle; + entry->counter = &uobj->comp_events_reported; spin_lock_irqsave(&file->comp_file[0].lock, flags); list_add_tail(&entry->list, &file->comp_file[0].event_list); + list_add_tail(&entry->obj_list, &uobj->comp_list); spin_unlock_irqrestore(&file->comp_file[0].lock, flags); wake_up_interruptible(&file->comp_file[0].poll_wait); @@ -323,20 +327,25 @@ void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context) } static void ib_uverbs_async_handler(struct ib_uverbs_file *file, - __u64 element, __u64 event) + __u64 element, __u64 event, + struct list_head *obj_list, + u32 *counter) { - struct ib_uverbs_async_event *entry; + struct ib_uverbs_event *entry; unsigned long flags; entry = kmalloc(sizeof *entry, GFP_ATOMIC); if (!entry) return; - entry->desc.element = element; - entry->desc.event_type = event; + entry->desc.async.element = element; + entry->desc.async.event_type = event; + entry->counter = counter; spin_lock_irqsave(&file->async_file.lock, flags); list_add_tail(&entry->list, &file->async_file.event_list); + if (obj_list) + list_add_tail(&entry->obj_list, obj_list); spin_unlock_irqrestore(&file->async_file.lock, flags); wake_up_interruptible(&file->async_file.poll_wait); @@ -345,23 +354,39 @@ static void ib_uverbs_async_handler(struct ib_uverbs_file *file, void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr) { - ib_uverbs_async_handler(context_ptr, - event->element.cq->uobject->user_handle, - event->event); + struct ib_ucq_object *uobj; + + uobj = container_of(event->element.cq->uobject, + struct ib_ucq_object, uobject); + + ib_uverbs_async_handler(context_ptr, uobj->uobject.user_handle, + event->event, &uobj->async_list, + &uobj->async_events_reported); + } void ib_uverbs_qp_event_handler(struct ib_event *event, void *context_ptr) { - ib_uverbs_async_handler(context_ptr, - event->element.qp->uobject->user_handle, - event->event); + struct ib_uevent_object *uobj; + + uobj = container_of(event->element.qp->uobject, + struct ib_uevent_object, uobject); + + ib_uverbs_async_handler(context_ptr, uobj->uobject.user_handle, + event->event, &uobj->event_list, + &uobj->events_reported); } void ib_uverbs_srq_event_handler(struct ib_event *event, void *context_ptr) { - ib_uverbs_async_handler(context_ptr, - event->element.srq->uobject->user_handle, - event->event); + struct ib_uevent_object *uobj; + + uobj = container_of(event->element.srq->uobject, + struct ib_uevent_object, uobject); + + ib_uverbs_async_handler(context_ptr, uobj->uobject.user_handle, + event->event, &uobj->event_list, + &uobj->events_reported); } static void ib_uverbs_event_handler(struct ib_event_handler *handler, @@ -370,7 +395,8 @@ static void ib_uverbs_event_handler(struct ib_event_handler *handler, struct ib_uverbs_file *file = container_of(handler, struct ib_uverbs_file, event_handler); - ib_uverbs_async_handler(file, event->element.port_num, event->event); + ib_uverbs_async_handler(file, event->element.port_num, event->event, + NULL, NULL); } static int ib_uverbs_event_init(struct ib_uverbs_event_file *file, diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c index 0164b84d4ec..bcef06bf15e 100644 --- a/drivers/infiniband/hw/mthca/mthca_qp.c +++ b/drivers/infiniband/hw/mthca/mthca_qp.c @@ -220,6 +220,16 @@ static void *get_send_wqe(struct mthca_qp *qp, int n) (PAGE_SIZE - 1)); } +static void mthca_wq_init(struct mthca_wq *wq) +{ + spin_lock_init(&wq->lock); + wq->next_ind = 0; + wq->last_comp = wq->max - 1; + wq->head = 0; + wq->tail = 0; + wq->last = NULL; +} + void mthca_qp_event(struct mthca_dev *dev, u32 qpn, enum ib_event_type event_type) { @@ -833,8 +843,8 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask) store_attrs(to_msqp(qp), attr, attr_mask); /* - * If we are moving QP0 to RTR, bring the IB link up; if we - * are moving QP0 to RESET or ERROR, bring the link back down. + * If we moved QP0 to RTR, bring the IB link up; if we moved + * QP0 to RESET or ERROR, bring the link back down. */ if (is_qp0(dev, qp)) { if (cur_state != IB_QPS_RTR && @@ -848,6 +858,26 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask) mthca_CLOSE_IB(dev, to_msqp(qp)->port, &status); } + /* + * If we moved a kernel QP to RESET, clean up all old CQ + * entries and reinitialize the QP. + */ + if (!err && new_state == IB_QPS_RESET && !qp->ibqp.uobject) { + mthca_cq_clean(dev, to_mcq(qp->ibqp.send_cq)->cqn, qp->qpn, + qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL); + if (qp->ibqp.send_cq != qp->ibqp.recv_cq) + mthca_cq_clean(dev, to_mcq(qp->ibqp.recv_cq)->cqn, qp->qpn, + qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL); + + mthca_wq_init(&qp->sq); + mthca_wq_init(&qp->rq); + + if (mthca_is_memfree(dev)) { + *qp->sq.db = 0; + *qp->rq.db = 0; + } + } + return err; } @@ -1003,16 +1033,6 @@ static void mthca_free_memfree(struct mthca_dev *dev, } } -static void mthca_wq_init(struct mthca_wq* wq) -{ - spin_lock_init(&wq->lock); - wq->next_ind = 0; - wq->last_comp = wq->max - 1; - wq->head = 0; - wq->tail = 0; - wq->last = NULL; -} - static int mthca_alloc_qp_common(struct mthca_dev *dev, struct mthca_pd *pd, struct mthca_cq *send_cq, @@ -1024,6 +1044,7 @@ static int mthca_alloc_qp_common(struct mthca_dev *dev, int i; atomic_set(&qp->refcount, 1); + init_waitqueue_head(&qp->wait); qp->state = IB_QPS_RESET; qp->atomic_rd_en = 0; qp->resp_depth = 0; diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 0e8ac138e35..49d120d2b92 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c @@ -1062,6 +1062,8 @@ static void ipoib_remove_one(struct ib_device *device) ipoib_dev_cleanup(priv->dev); free_netdev(priv->dev); } + + kfree(dev_list); } static int __init ipoib_init_module(void) diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index 19c14c4beb4..3738d173f9a 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c @@ -322,7 +322,7 @@ static long evdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (t < 0 || t >= dev->keycodemax || !dev->keycodesize) return -EINVAL; if (get_user(v, ip + 1)) return -EFAULT; if (v < 0 || v > KEY_MAX) return -EINVAL; - if (v >> (dev->keycodesize * 8)) return -EINVAL; + if (dev->keycodesize < sizeof(v) && (v >> (dev->keycodesize * 8))) return -EINVAL; u = SET_INPUT_KEYCODE(dev, t, v); clear_bit(u, dev->keybit); set_bit(v, dev->keybit); @@ -509,7 +509,7 @@ do { \ int len = NBITS_COMPAT((max)) * sizeof(compat_long_t); \ if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); \ for (i = 0; i < len / sizeof(compat_long_t); i++) \ - if (copy_to_user((compat_long_t*) p + i, \ + if (copy_to_user((compat_long_t __user *) p + i, \ (compat_long_t*) (bit) + i + 1 - ((i % 2) << 1), \ sizeof(compat_long_t))) \ return -EFAULT; \ diff --git a/drivers/input/joystick/iforce/iforce-packets.c b/drivers/input/joystick/iforce/iforce-packets.c index 58728ebaaf8..e5a31e55d3e 100644 --- a/drivers/input/joystick/iforce/iforce-packets.c +++ b/drivers/input/joystick/iforce/iforce-packets.c @@ -249,9 +249,6 @@ void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data, int iforce_get_id_packet(struct iforce *iforce, char *packet) { - DECLARE_WAITQUEUE(wait, current); - int timeout = HZ; /* 1 second */ - switch (iforce->bus) { case IFORCE_USB: @@ -260,22 +257,13 @@ int iforce_get_id_packet(struct iforce *iforce, char *packet) iforce->cr.bRequest = packet[0]; iforce->ctrl->dev = iforce->usbdev; - set_current_state(TASK_INTERRUPTIBLE); - add_wait_queue(&iforce->wait, &wait); - - if (usb_submit_urb(iforce->ctrl, GFP_ATOMIC)) { - set_current_state(TASK_RUNNING); - remove_wait_queue(&iforce->wait, &wait); + if (usb_submit_urb(iforce->ctrl, GFP_ATOMIC)) return -1; - } - while (timeout && iforce->ctrl->status == -EINPROGRESS) - timeout = schedule_timeout(timeout); + wait_event_interruptible_timeout(iforce->wait, + iforce->ctrl->status != -EINPROGRESS, HZ); - set_current_state(TASK_RUNNING); - remove_wait_queue(&iforce->wait, &wait); - - if (!timeout) { + if (iforce->ctrl->status != -EINPROGRESS) { usb_unlink_urb(iforce->ctrl); return -1; } @@ -290,16 +278,10 @@ int iforce_get_id_packet(struct iforce *iforce, char *packet) iforce->expect_packet = FF_CMD_QUERY; iforce_send_packet(iforce, FF_CMD_QUERY, packet); - set_current_state(TASK_INTERRUPTIBLE); - add_wait_queue(&iforce->wait, &wait); - - while (timeout && iforce->expect_packet) - timeout = schedule_timeout(timeout); - - set_current_state(TASK_RUNNING); - remove_wait_queue(&iforce->wait, &wait); + wait_event_interruptible_timeout(iforce->wait, + !iforce->expect_packet, HZ); - if (!timeout) { + if (iforce->expect_packet) { iforce->expect_packet = 0; return -1; } diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c index 6369a24684f..58600f91eff 100644 --- a/drivers/input/joystick/iforce/iforce-usb.c +++ b/drivers/input/joystick/iforce/iforce-usb.c @@ -95,6 +95,7 @@ static void iforce_usb_irq(struct urb *urb, struct pt_regs *regs) goto exit; } + wake_up(&iforce->wait); iforce_process_packet(iforce, (iforce->data[0] << 8) | (urb->actual_length - 1), iforce->data + 1, regs); diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index 4d4985b59ab..1ad8c2ee7db 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c @@ -208,6 +208,7 @@ struct atkbd { unsigned char resend; unsigned char release; unsigned char bat_xl; + unsigned char err_xl; unsigned int last; unsigned long time; }; @@ -296,15 +297,18 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, if (atkbd->emul || !(code == ATKBD_RET_EMUL0 || code == ATKBD_RET_EMUL1 || code == ATKBD_RET_HANGUEL || code == ATKBD_RET_HANJA || - code == ATKBD_RET_ERR || + (code == ATKBD_RET_ERR && !atkbd->err_xl) || (code == ATKBD_RET_BAT && !atkbd->bat_xl))) { atkbd->release = code >> 7; code &= 0x7f; } - if (!atkbd->emul && - (code & 0x7f) == (ATKBD_RET_BAT & 0x7f)) + if (!atkbd->emul) { + if ((code & 0x7f) == (ATKBD_RET_BAT & 0x7f)) atkbd->bat_xl = !atkbd->release; + if ((code & 0x7f) == (ATKBD_RET_ERR & 0x7f)) + atkbd->err_xl = !atkbd->release; + } } switch (code) { diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c index 596964ceb96..4bae5d89348 100644 --- a/drivers/input/keyboard/sunkbd.c +++ b/drivers/input/keyboard/sunkbd.c @@ -44,7 +44,7 @@ MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); static unsigned char sunkbd_keycode[128] = { - 0,128,114,129,115, 59, 60, 68, 61, 87, 62, 88, 63,100, 64, 0, + 0,128,114,129,115, 59, 60, 68, 61, 87, 62, 88, 63,100, 64,112, 65, 66, 67, 56,103,119, 99, 70,105,130,131,108,106, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 41, 14,110,113, 98, 55, 116,132, 83,133,102, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile index c4909b49337..82b330bbf06 100644 --- a/drivers/input/mouse/Makefile +++ b/drivers/input/mouse/Makefile @@ -15,4 +15,4 @@ obj-$(CONFIG_MOUSE_SERIAL) += sermouse.o obj-$(CONFIG_MOUSE_HIL) += hil_ptr.o obj-$(CONFIG_MOUSE_VSXXXAA) += vsxxxaa.o -psmouse-objs := psmouse-base.o alps.o logips2pp.o synaptics.o lifebook.o +psmouse-objs := psmouse-base.o alps.o logips2pp.o synaptics.o lifebook.o trackpoint.o diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index 0d68e5e0182..b20783f9748 100644 --- a/drivers/input/mouse/alps.c +++ b/drivers/input/mouse/alps.c @@ -170,7 +170,7 @@ static void alps_process_packet(struct psmouse *psmouse, struct pt_regs *regs) input_report_key(dev, BTN_TOOL_FINGER, z > 0); if (priv->i->flags & ALPS_WHEEL) - input_report_rel(dev, REL_WHEEL, ((packet[0] >> 4) & 0x07) | ((packet[2] >> 2) & 0x08)); + input_report_rel(dev, REL_WHEEL, ((packet[2] << 1) & 0x08) - ((packet[0] >> 4) & 0x07)); if (priv->i->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) { input_report_key(dev, BTN_FORWARD, forward); diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c index 48d2b20d264..7df96525222 100644 --- a/drivers/input/mouse/logips2pp.c +++ b/drivers/input/mouse/logips2pp.c @@ -150,12 +150,12 @@ static void ps2pp_set_smartscroll(struct psmouse *psmouse, unsigned int smartscr ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES); } -static ssize_t psmouse_attr_show_smartscroll(struct psmouse *psmouse, char *buf) +static ssize_t ps2pp_attr_show_smartscroll(struct psmouse *psmouse, void *data, char *buf) { return sprintf(buf, "%d\n", psmouse->smartscroll ? 1 : 0); } -static ssize_t psmouse_attr_set_smartscroll(struct psmouse *psmouse, const char *buf, size_t count) +static ssize_t ps2pp_attr_set_smartscroll(struct psmouse *psmouse, void *data, const char *buf, size_t count) { unsigned long value; char *rest; @@ -169,7 +169,8 @@ static ssize_t psmouse_attr_set_smartscroll(struct psmouse *psmouse, const char return count; } -PSMOUSE_DEFINE_ATTR(smartscroll); +PSMOUSE_DEFINE_ATTR(smartscroll, S_IWUSR | S_IRUGO, NULL, + ps2pp_attr_show_smartscroll, ps2pp_attr_set_smartscroll); /* * Support 800 dpi resolution _only_ if the user wants it (there are good @@ -194,7 +195,7 @@ static void ps2pp_set_resolution(struct psmouse *psmouse, unsigned int resolutio static void ps2pp_disconnect(struct psmouse *psmouse) { - device_remove_file(&psmouse->ps2dev.serio->dev, &psmouse_attr_smartscroll); + device_remove_file(&psmouse->ps2dev.serio->dev, &psmouse_attr_smartscroll.dattr); } static struct ps2pp_info *get_model_info(unsigned char model) @@ -222,6 +223,7 @@ static struct ps2pp_info *get_model_info(unsigned char model) { 80, PS2PP_KIND_WHEEL, PS2PP_SIDE_BTN | PS2PP_WHEEL }, { 81, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, { 83, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, + { 86, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, { 88, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, { 96, 0, 0 }, { 97, PS2PP_KIND_TP3, PS2PP_WHEEL | PS2PP_HWHEEL }, @@ -379,7 +381,8 @@ int ps2pp_init(struct psmouse *psmouse, int set_properties) psmouse->set_resolution = ps2pp_set_resolution; psmouse->disconnect = ps2pp_disconnect; - device_create_file(&psmouse->ps2dev.serio->dev, &psmouse_attr_smartscroll); + device_create_file(&psmouse->ps2dev.serio->dev, + &psmouse_attr_smartscroll.dattr); } } diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index 12bdd3eff92..af24313ff5b 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c @@ -25,6 +25,7 @@ #include "logips2pp.h" #include "alps.h" #include "lifebook.h" +#include "trackpoint.h" #define DRIVER_DESC "PS/2 mouse driver" @@ -57,10 +58,30 @@ static unsigned int psmouse_resetafter; module_param_named(resetafter, psmouse_resetafter, uint, 0644); MODULE_PARM_DESC(resetafter, "Reset device after so many bad packets (0 = never)."); -PSMOUSE_DEFINE_ATTR(protocol); -PSMOUSE_DEFINE_ATTR(rate); -PSMOUSE_DEFINE_ATTR(resolution); -PSMOUSE_DEFINE_ATTR(resetafter); +PSMOUSE_DEFINE_ATTR(protocol, S_IWUSR | S_IRUGO, + NULL, + psmouse_attr_show_protocol, psmouse_attr_set_protocol); +PSMOUSE_DEFINE_ATTR(rate, S_IWUSR | S_IRUGO, + (void *) offsetof(struct psmouse, rate), + psmouse_show_int_attr, psmouse_attr_set_rate); +PSMOUSE_DEFINE_ATTR(resolution, S_IWUSR | S_IRUGO, + (void *) offsetof(struct psmouse, resolution), + psmouse_show_int_attr, psmouse_attr_set_resolution); +PSMOUSE_DEFINE_ATTR(resetafter, S_IWUSR | S_IRUGO, + (void *) offsetof(struct psmouse, resetafter), + psmouse_show_int_attr, psmouse_set_int_attr); + +static struct attribute *psmouse_attributes[] = { + &psmouse_attr_protocol.dattr.attr, + &psmouse_attr_rate.dattr.attr, + &psmouse_attr_resolution.dattr.attr, + &psmouse_attr_resetafter.dattr.attr, + NULL +}; + +static struct attribute_group psmouse_attribute_group = { + .attrs = psmouse_attributes, +}; __obsolete_setup("psmouse_noext"); __obsolete_setup("psmouse_resolution="); @@ -520,6 +541,12 @@ static int psmouse_extensions(struct psmouse *psmouse, return PSMOUSE_IMPS; /* + * Try to initialize the IBM TrackPoint + */ + if (max_proto > PSMOUSE_IMEX && trackpoint_detect(psmouse, set_properties) == 0) + return PSMOUSE_TRACKPOINT; + +/* * Okay, all failed, we have a standard mouse here. The number of the buttons * is still a question, though. We assume 3. */ @@ -600,6 +627,12 @@ static struct psmouse_protocol psmouse_protocols[] = { .init = lifebook_init, }, { + .type = PSMOUSE_TRACKPOINT, + .name = "TPPS/2", + .alias = "trackpoint", + .detect = trackpoint_detect, + }, + { .type = PSMOUSE_AUTO, .name = "auto", .alias = "any", @@ -787,10 +820,7 @@ static void psmouse_disconnect(struct serio *serio) psmouse = serio_get_drvdata(serio); - device_remove_file(&serio->dev, &psmouse_attr_protocol); - device_remove_file(&serio->dev, &psmouse_attr_rate); - device_remove_file(&serio->dev, &psmouse_attr_resolution); - device_remove_file(&serio->dev, &psmouse_attr_resetafter); + sysfs_remove_group(&serio->dev.kobj, &psmouse_attribute_group); down(&psmouse_sem); @@ -927,10 +957,7 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv) if (parent && parent->pt_activate) parent->pt_activate(parent); - device_create_file(&serio->dev, &psmouse_attr_protocol); - device_create_file(&serio->dev, &psmouse_attr_rate); - device_create_file(&serio->dev, &psmouse_attr_resolution); - device_create_file(&serio->dev, &psmouse_attr_resetafter); + sysfs_create_group(&serio->dev.kobj, &psmouse_attribute_group); psmouse_activate(psmouse); @@ -1027,10 +1054,12 @@ static struct serio_driver psmouse_drv = { .cleanup = psmouse_cleanup, }; -ssize_t psmouse_attr_show_helper(struct device *dev, char *buf, - ssize_t (*handler)(struct psmouse *, char *)) +ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *devattr, + char *buf) { struct serio *serio = to_serio_port(dev); + struct psmouse_attribute *attr = to_psmouse_attr(devattr); + struct psmouse *psmouse; int retval; retval = serio_pin_driver(serio); @@ -1042,19 +1071,21 @@ ssize_t psmouse_attr_show_helper(struct device *dev, char *buf, goto out; } - retval = handler(serio_get_drvdata(serio), buf); + psmouse = serio_get_drvdata(serio); + + retval = attr->show(psmouse, attr->data, buf); out: serio_unpin_driver(serio); return retval; } -ssize_t psmouse_attr_set_helper(struct device *dev, const char *buf, size_t count, - ssize_t (*handler)(struct psmouse *, const char *, size_t)) +ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *devattr, + const char *buf, size_t count) { struct serio *serio = to_serio_port(dev); - struct psmouse *psmouse = serio_get_drvdata(serio); - struct psmouse *parent = NULL; + struct psmouse_attribute *attr = to_psmouse_attr(devattr); + struct psmouse *psmouse, *parent = NULL; int retval; retval = serio_pin_driver(serio); @@ -1070,6 +1101,8 @@ ssize_t psmouse_attr_set_helper(struct device *dev, const char *buf, size_t coun if (retval) goto out_unpin; + psmouse = serio_get_drvdata(serio); + if (psmouse->state == PSMOUSE_IGNORE) { retval = -ENODEV; goto out_up; @@ -1082,7 +1115,7 @@ ssize_t psmouse_attr_set_helper(struct device *dev, const char *buf, size_t coun psmouse_deactivate(psmouse); - retval = handler(psmouse, buf, count); + retval = attr->set(psmouse, attr->data, buf, count); if (retval != -ENODEV) psmouse_activate(psmouse); @@ -1097,12 +1130,34 @@ ssize_t psmouse_attr_set_helper(struct device *dev, const char *buf, size_t coun return retval; } -static ssize_t psmouse_attr_show_protocol(struct psmouse *psmouse, char *buf) +static ssize_t psmouse_show_int_attr(struct psmouse *psmouse, void *offset, char *buf) +{ + unsigned long *field = (unsigned long *)((char *)psmouse + (size_t)offset); + + return sprintf(buf, "%lu\n", *field); +} + +static ssize_t psmouse_set_int_attr(struct psmouse *psmouse, void *offset, const char *buf, size_t count) +{ + unsigned long *field = (unsigned long *)((char *)psmouse + (size_t)offset); + unsigned long value; + char *rest; + + value = simple_strtoul(buf, &rest, 10); + if (*rest) + return -EINVAL; + + *field = value; + + return count; +} + +static ssize_t psmouse_attr_show_protocol(struct psmouse *psmouse, void *data, char *buf) { return sprintf(buf, "%s\n", psmouse_protocol_by_type(psmouse->type)->name); } -static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, const char *buf, size_t count) +static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, const char *buf, size_t count) { struct serio *serio = psmouse->ps2dev.serio; struct psmouse *parent = NULL; @@ -1166,12 +1221,7 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, const char *bu return count; } -static ssize_t psmouse_attr_show_rate(struct psmouse *psmouse, char *buf) -{ - return sprintf(buf, "%d\n", psmouse->rate); -} - -static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, const char *buf, size_t count) +static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const char *buf, size_t count) { unsigned long value; char *rest; @@ -1184,12 +1234,7 @@ static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, const char *buf, s return count; } -static ssize_t psmouse_attr_show_resolution(struct psmouse *psmouse, char *buf) -{ - return sprintf(buf, "%d\n", psmouse->resolution); -} - -static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, const char *buf, size_t count) +static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, const char *buf, size_t count) { unsigned long value; char *rest; @@ -1202,23 +1247,6 @@ static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, const char * return count; } -static ssize_t psmouse_attr_show_resetafter(struct psmouse *psmouse, char *buf) -{ - return sprintf(buf, "%d\n", psmouse->resetafter); -} - -static ssize_t psmouse_attr_set_resetafter(struct psmouse *psmouse, const char *buf, size_t count) -{ - unsigned long value; - char *rest; - - value = simple_strtoul(buf, &rest, 10); - if (*rest) - return -EINVAL; - - psmouse->resetafter = value; - return count; -} static int psmouse_set_maxproto(const char *val, struct kernel_param *kp) { @@ -1234,7 +1262,7 @@ static int psmouse_set_maxproto(const char *val, struct kernel_param *kp) *((unsigned int *)kp->arg) = proto->type; - return 0; \ + return 0; } static int psmouse_get_maxproto(char *buffer, struct kernel_param *kp) diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h index 86691cf4343..45d2bd774f0 100644 --- a/drivers/input/mouse/psmouse.h +++ b/drivers/input/mouse/psmouse.h @@ -78,6 +78,7 @@ enum psmouse_type { PSMOUSE_SYNAPTICS, PSMOUSE_ALPS, PSMOUSE_LIFEBOOK, + PSMOUSE_TRACKPOINT, PSMOUSE_AUTO /* This one should always be last */ }; @@ -85,24 +86,37 @@ int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command); int psmouse_reset(struct psmouse *psmouse); void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution); -ssize_t psmouse_attr_show_helper(struct device *dev, char *buf, - ssize_t (*handler)(struct psmouse *, char *)); -ssize_t psmouse_attr_set_helper(struct device *dev, const char *buf, size_t count, - ssize_t (*handler)(struct psmouse *, const char *, size_t)); - -#define PSMOUSE_DEFINE_ATTR(_name) \ -static ssize_t psmouse_attr_show_##_name(struct psmouse *, char *); \ -static ssize_t psmouse_attr_set_##_name(struct psmouse *, const char *, size_t);\ -static ssize_t psmouse_do_show_##_name(struct device *d, struct device_attribute *attr, char *b) \ -{ \ - return psmouse_attr_show_helper(d, b, psmouse_attr_show_##_name); \ -} \ -static ssize_t psmouse_do_set_##_name(struct device *d, struct device_attribute *attr, const char *b, size_t s)\ -{ \ - return psmouse_attr_set_helper(d, b, s, psmouse_attr_set_##_name); \ -} \ -static struct device_attribute psmouse_attr_##_name = \ - __ATTR(_name, S_IWUSR | S_IRUGO, \ - psmouse_do_show_##_name, psmouse_do_set_##_name); + +struct psmouse_attribute { + struct device_attribute dattr; + void *data; + ssize_t (*show)(struct psmouse *psmouse, void *data, char *buf); + ssize_t (*set)(struct psmouse *psmouse, void *data, + const char *buf, size_t count); +}; +#define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr) + +ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr, + char *buf); +ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count); + +#define PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set) \ +static ssize_t _show(struct psmouse *, void *data, char *); \ +static ssize_t _set(struct psmouse *, void *data, const char *, size_t); \ +static struct psmouse_attribute psmouse_attr_##_name = { \ + .dattr = { \ + .attr = { \ + .name = __stringify(_name), \ + .mode = _mode, \ + .owner = THIS_MODULE, \ + }, \ + .show = psmouse_attr_show_helper, \ + .store = psmouse_attr_set_helper, \ + }, \ + .data = _data, \ + .show = _show, \ + .set = _set, \ +} #endif /* _PSMOUSE_H */ diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c new file mode 100644 index 00000000000..b4898d8a68e --- /dev/null +++ b/drivers/input/mouse/trackpoint.c @@ -0,0 +1,304 @@ +/* + * Stephen Evanchik <evanchsa@gmail.com> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * Trademarks are the property of their respective owners. + */ + +#include <linux/delay.h> +#include <linux/serio.h> +#include <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/input.h> +#include <linux/libps2.h> +#include <linux/proc_fs.h> +#include <asm/uaccess.h> +#include "psmouse.h" +#include "trackpoint.h" + +/* + * Device IO: read, write and toggle bit + */ +static int trackpoint_read(struct ps2dev *ps2dev, unsigned char loc, unsigned char *results) +{ + if (ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND)) || + ps2_command(ps2dev, results, MAKE_PS2_CMD(0, 1, loc))) { + return -1; + } + + return 0; +} + +static int trackpoint_write(struct ps2dev *ps2dev, unsigned char loc, unsigned char val) +{ + if (ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND)) || + ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_WRITE_MEM)) || + ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, loc)) || + ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, val))) { + return -1; + } + + return 0; +} + +static int trackpoint_toggle_bit(struct ps2dev *ps2dev, unsigned char loc, unsigned char mask) +{ + /* Bad things will happen if the loc param isn't in this range */ + if (loc < 0x20 || loc >= 0x2F) + return -1; + + if (ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND)) || + ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_TOGGLE)) || + ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, loc)) || + ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, mask))) { + return -1; + } + + return 0; +} + + +/* + * Trackpoint-specific attributes + */ +struct trackpoint_attr_data { + size_t field_offset; + unsigned char command; + unsigned char mask; +}; + +static ssize_t trackpoint_show_int_attr(struct psmouse *psmouse, void *data, char *buf) +{ + struct trackpoint_data *tp = psmouse->private; + struct trackpoint_attr_data *attr = data; + unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); + + return sprintf(buf, "%u\n", *field); +} + +static ssize_t trackpoint_set_int_attr(struct psmouse *psmouse, void *data, + const char *buf, size_t count) +{ + struct trackpoint_data *tp = psmouse->private; + struct trackpoint_attr_data *attr = data; + unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); + unsigned long value; + char *rest; + + value = simple_strtoul(buf, &rest, 10); + if (*rest || value > 255) + return -EINVAL; + + *field = value; + trackpoint_write(&psmouse->ps2dev, attr->command, value); + + return count; +} + +#define TRACKPOINT_INT_ATTR(_name, _command) \ + static struct trackpoint_attr_data trackpoint_attr_##_name = { \ + .field_offset = offsetof(struct trackpoint_data, _name), \ + .command = _command, \ + }; \ + PSMOUSE_DEFINE_ATTR(_name, S_IWUSR | S_IRUGO, \ + &trackpoint_attr_##_name, \ + trackpoint_show_int_attr, trackpoint_set_int_attr) + +static ssize_t trackpoint_set_bit_attr(struct psmouse *psmouse, void *data, + const char *buf, size_t count) +{ + struct trackpoint_data *tp = psmouse->private; + struct trackpoint_attr_data *attr = data; + unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); + unsigned long value; + char *rest; + + value = simple_strtoul(buf, &rest, 10); + if (*rest || value > 1) + return -EINVAL; + + if (*field != value) { + *field = value; + trackpoint_toggle_bit(&psmouse->ps2dev, attr->command, attr->mask); + } + + return count; +} + + +#define TRACKPOINT_BIT_ATTR(_name, _command, _mask) \ + static struct trackpoint_attr_data trackpoint_attr_##_name = { \ + .field_offset = offsetof(struct trackpoint_data, _name), \ + .command = _command, \ + .mask = _mask, \ + }; \ + PSMOUSE_DEFINE_ATTR(_name, S_IWUSR | S_IRUGO, \ + &trackpoint_attr_##_name, \ + trackpoint_show_int_attr, trackpoint_set_bit_attr) + +TRACKPOINT_INT_ATTR(sensitivity, TP_SENS); +TRACKPOINT_INT_ATTR(speed, TP_SPEED); +TRACKPOINT_INT_ATTR(inertia, TP_INERTIA); +TRACKPOINT_INT_ATTR(reach, TP_REACH); +TRACKPOINT_INT_ATTR(draghys, TP_DRAGHYS); +TRACKPOINT_INT_ATTR(mindrag, TP_MINDRAG); +TRACKPOINT_INT_ATTR(thresh, TP_THRESH); +TRACKPOINT_INT_ATTR(upthresh, TP_UP_THRESH); +TRACKPOINT_INT_ATTR(ztime, TP_Z_TIME); +TRACKPOINT_INT_ATTR(jenks, TP_JENKS_CURV); + +TRACKPOINT_BIT_ATTR(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON); +TRACKPOINT_BIT_ATTR(skipback, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK); +TRACKPOINT_BIT_ATTR(ext_dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV); + +static struct attribute *trackpoint_attrs[] = { + &psmouse_attr_sensitivity.dattr.attr, + &psmouse_attr_speed.dattr.attr, + &psmouse_attr_inertia.dattr.attr, + &psmouse_attr_reach.dattr.attr, + &psmouse_attr_draghys.dattr.attr, + &psmouse_attr_mindrag.dattr.attr, + &psmouse_attr_thresh.dattr.attr, + &psmouse_attr_upthresh.dattr.attr, + &psmouse_attr_ztime.dattr.attr, + &psmouse_attr_jenks.dattr.attr, + &psmouse_attr_press_to_select.dattr.attr, + &psmouse_attr_skipback.dattr.attr, + &psmouse_attr_ext_dev.dattr.attr, + NULL +}; + +static struct attribute_group trackpoint_attr_group = { + .attrs = trackpoint_attrs, +}; + +static void trackpoint_disconnect(struct psmouse *psmouse) +{ + sysfs_remove_group(&psmouse->ps2dev.serio->dev.kobj, &trackpoint_attr_group); + + kfree(psmouse->private); + psmouse->private = NULL; +} + +static int trackpoint_sync(struct psmouse *psmouse) +{ + unsigned char toggle; + struct trackpoint_data *tp = psmouse->private; + + if (!tp) + return -1; + + /* Disable features that may make device unusable with this driver */ + trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_TWOHAND, &toggle); + if (toggle & TP_MASK_TWOHAND) + trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_TWOHAND, TP_MASK_TWOHAND); + + trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_SOURCE_TAG, &toggle); + if (toggle & TP_MASK_SOURCE_TAG) + trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_SOURCE_TAG, TP_MASK_SOURCE_TAG); + + trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_MB, &toggle); + if (toggle & TP_MASK_MB) + trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_MB, TP_MASK_MB); + + /* Push the config to the device */ + trackpoint_write(&psmouse->ps2dev, TP_SENS, tp->sensitivity); + trackpoint_write(&psmouse->ps2dev, TP_INERTIA, tp->inertia); + trackpoint_write(&psmouse->ps2dev, TP_SPEED, tp->speed); + + trackpoint_write(&psmouse->ps2dev, TP_REACH, tp->reach); + trackpoint_write(&psmouse->ps2dev, TP_DRAGHYS, tp->draghys); + trackpoint_write(&psmouse->ps2dev, TP_MINDRAG, tp->mindrag); + + trackpoint_write(&psmouse->ps2dev, TP_THRESH, tp->thresh); + trackpoint_write(&psmouse->ps2dev, TP_UP_THRESH, tp->upthresh); + + trackpoint_write(&psmouse->ps2dev, TP_Z_TIME, tp->ztime); + trackpoint_write(&psmouse->ps2dev, TP_JENKS_CURV, tp->jenks); + + trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_PTSON, &toggle); + if (((toggle & TP_MASK_PTSON) == TP_MASK_PTSON) != tp->press_to_select) + trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_PTSON, TP_MASK_PTSON); + + trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_SKIPBACK, &toggle); + if (((toggle & TP_MASK_SKIPBACK) == TP_MASK_SKIPBACK) != tp->skipback) + trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK); + + trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_EXT_DEV, &toggle); + if (((toggle & TP_MASK_EXT_DEV) == TP_MASK_EXT_DEV) != tp->ext_dev) + trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV); + + return 0; +} + +static void trackpoint_defaults(struct trackpoint_data *tp) +{ + tp->press_to_select = TP_DEF_PTSON; + tp->sensitivity = TP_DEF_SENS; + tp->speed = TP_DEF_SPEED; + tp->reach = TP_DEF_REACH; + + tp->draghys = TP_DEF_DRAGHYS; + tp->mindrag = TP_DEF_MINDRAG; + + tp->thresh = TP_DEF_THRESH; + tp->upthresh = TP_DEF_UP_THRESH; + + tp->ztime = TP_DEF_Z_TIME; + tp->jenks = TP_DEF_JENKS_CURV; + + tp->inertia = TP_DEF_INERTIA; + tp->skipback = TP_DEF_SKIPBACK; + tp->ext_dev = TP_DEF_EXT_DEV; +} + +int trackpoint_detect(struct psmouse *psmouse, int set_properties) +{ + struct trackpoint_data *priv; + struct ps2dev *ps2dev = &psmouse->ps2dev; + unsigned char firmware_id; + unsigned char button_info; + unsigned char param[2]; + + param[0] = param[1] = 0; + + if (ps2_command(ps2dev, param, MAKE_PS2_CMD(0, 2, TP_READ_ID))) + return -1; + + if (param[0] != TP_MAGIC_IDENT) + return -1; + + if (!set_properties) + return 0; + + firmware_id = param[1]; + + if (trackpoint_read(&psmouse->ps2dev, TP_EXT_BTN, &button_info)) { + printk(KERN_WARNING "trackpoint.c: failed to get extended button data\n"); + button_info = 0; + } + + psmouse->private = priv = kcalloc(1, sizeof(struct trackpoint_data), GFP_KERNEL); + if (!priv) + return -1; + + psmouse->vendor = "IBM"; + psmouse->name = "TrackPoint"; + + psmouse->reconnect = trackpoint_sync; + psmouse->disconnect = trackpoint_disconnect; + + trackpoint_defaults(priv); + trackpoint_sync(psmouse); + + sysfs_create_group(&ps2dev->serio->dev.kobj, &trackpoint_attr_group); + + printk(KERN_INFO "IBM TrackPoint firmware: 0x%02x, buttons: %d/%d\n", + firmware_id, (button_info & 0xf0) >> 4, button_info & 0x0f); + + return 0; +} + diff --git a/drivers/input/mouse/trackpoint.h b/drivers/input/mouse/trackpoint.h new file mode 100644 index 00000000000..9857d8b6ad6 --- /dev/null +++ b/drivers/input/mouse/trackpoint.h @@ -0,0 +1,147 @@ +/* + * IBM TrackPoint PS/2 mouse driver + * + * Stephen Evanchik <evanchsa@gmail.com> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + */ + +#ifndef _TRACKPOINT_H +#define _TRACKPOINT_H + +/* + * These constants are from the TrackPoint System + * Engineering documentation Version 4 from IBM Watson + * research: + * http://wwwcssrv.almaden.ibm.com/trackpoint/download.html + */ + +#define TP_COMMAND 0xE2 /* Commands start with this */ + +#define TP_READ_ID 0xE1 /* Sent for device identification */ +#define TP_MAGIC_IDENT 0x01 /* Sent after a TP_READ_ID followed */ + /* by the firmware ID */ + + +/* + * Commands + */ +#define TP_RECALIB 0x51 /* Recalibrate */ +#define TP_POWER_DOWN 0x44 /* Can only be undone through HW reset */ +#define TP_EXT_DEV 0x21 /* Determines if external device is connected (RO) */ +#define TP_EXT_BTN 0x4B /* Read extended button status */ +#define TP_POR 0x7F /* Execute Power on Reset */ +#define TP_POR_RESULTS 0x25 /* Read Power on Self test results */ +#define TP_DISABLE_EXT 0x40 /* Disable external pointing device */ +#define TP_ENABLE_EXT 0x41 /* Enable external pointing device */ + +/* + * Mode manipulation + */ +#define TP_SET_SOFT_TRANS 0x4E /* Set mode */ +#define TP_CANCEL_SOFT_TRANS 0xB9 /* Cancel mode */ +#define TP_SET_HARD_TRANS 0x45 /* Mode can only be set */ + + +/* + * Register oriented commands/properties + */ +#define TP_WRITE_MEM 0x81 +#define TP_READ_MEM 0x80 /* Not used in this implementation */ + +/* +* RAM Locations for properties + */ +#define TP_SENS 0x4A /* Sensitivity */ +#define TP_MB 0x4C /* Read Middle Button Status (RO) */ +#define TP_INERTIA 0x4D /* Negative Inertia */ +#define TP_SPEED 0x60 /* Speed of TP Cursor */ +#define TP_REACH 0x57 /* Backup for Z-axis press */ +#define TP_DRAGHYS 0x58 /* Drag Hysteresis */ + /* (how hard it is to drag */ + /* with Z-axis pressed) */ + +#define TP_MINDRAG 0x59 /* Minimum amount of force needed */ + /* to trigger dragging */ + +#define TP_THRESH 0x5C /* Minimum value for a Z-axis press */ +#define TP_UP_THRESH 0x5A /* Used to generate a 'click' on Z-axis */ +#define TP_Z_TIME 0x5E /* How sharp of a press */ +#define TP_JENKS_CURV 0x5D /* Minimum curvature for double click */ + +/* + * Toggling Flag bits + */ +#define TP_TOGGLE 0x47 /* Toggle command */ + +#define TP_TOGGLE_MB 0x23 /* Disable/Enable Middle Button */ +#define TP_MASK_MB 0x01 +#define TP_TOGGLE_EXT_DEV 0x23 /* Toggle external device */ +#define TP_MASK_EXT_DEV 0x02 +#define TP_TOGGLE_DRIFT 0x23 /* Drift Correction */ +#define TP_MASK_DRIFT 0x80 +#define TP_TOGGLE_BURST 0x28 /* Burst Mode */ +#define TP_MASK_BURST 0x80 +#define TP_TOGGLE_PTSON 0x2C /* Press to Select */ +#define TP_MASK_PTSON 0x01 +#define TP_TOGGLE_HARD_TRANS 0x2C /* Alternate method to set Hard Transparency */ +#define TP_MASK_HARD_TRANS 0x80 +#define TP_TOGGLE_TWOHAND 0x2D /* Two handed */ +#define TP_MASK_TWOHAND 0x01 +#define TP_TOGGLE_STICKY_TWO 0x2D /* Sticky two handed */ +#define TP_MASK_STICKY_TWO 0x04 +#define TP_TOGGLE_SKIPBACK 0x2D /* Suppress movement after drag release */ +#define TP_MASK_SKIPBACK 0x08 +#define TP_TOGGLE_SOURCE_TAG 0x20 /* Bit 3 of the first packet will be set to + to the origin of the packet (external or TP) */ +#define TP_MASK_SOURCE_TAG 0x80 +#define TP_TOGGLE_EXT_TAG 0x22 /* Bit 3 of the first packet coming from the + external device will be forced to 1 */ +#define TP_MASK_EXT_TAG 0x04 + + +/* Power on Self Test Results */ +#define TP_POR_SUCCESS 0x3B + +/* + * Default power on values + */ +#define TP_DEF_SENS 0x80 +#define TP_DEF_INERTIA 0x06 +#define TP_DEF_SPEED 0x61 +#define TP_DEF_REACH 0x0A + +#define TP_DEF_DRAGHYS 0xFF +#define TP_DEF_MINDRAG 0x14 + +#define TP_DEF_THRESH 0x08 +#define TP_DEF_UP_THRESH 0xFF +#define TP_DEF_Z_TIME 0x26 +#define TP_DEF_JENKS_CURV 0x87 + +/* Toggles */ +#define TP_DEF_MB 0x00 +#define TP_DEF_PTSON 0x00 +#define TP_DEF_SKIPBACK 0x00 +#define TP_DEF_EXT_DEV 0x01 + +#define MAKE_PS2_CMD(params, results, cmd) ((params<<12) | (results<<8) | (cmd)) + +struct trackpoint_data +{ + unsigned char sensitivity, speed, inertia, reach; + unsigned char draghys, mindrag; + unsigned char thresh, upthresh; + unsigned char ztime, jenks; + + unsigned char press_to_select; + unsigned char skipback; + + unsigned char ext_dev; +}; + +extern int trackpoint_detect(struct psmouse *psmouse, int set_properties); + +#endif /* _TRACKPOINT_H */ diff --git a/drivers/input/serio/i8042-io.h b/drivers/input/serio/i8042-io.h index c9e633d21d9..9a922164425 100644 --- a/drivers/input/serio/i8042-io.h +++ b/drivers/input/serio/i8042-io.h @@ -69,16 +69,16 @@ static inline int i8042_platform_init(void) */ #if !defined(__sh__) && !defined(__alpha__) && !defined(__mips__) && !defined(CONFIG_PPC64) if (!request_region(I8042_DATA_REG, 16, "i8042")) - return -1; + return -EBUSY; #endif i8042_reset = 1; #if defined(CONFIG_PPC64) if (check_legacy_ioport(I8042_DATA_REG)) - return -1; + return -EBUSY; if (!request_region(I8042_DATA_REG, 16, "i8042")) - return -1; + return -EBUSY; #endif return 0; } diff --git a/drivers/input/serio/i8042-ip22io.h b/drivers/input/serio/i8042-ip22io.h index 863b9c95fbb..ee1ad27d6ed 100644 --- a/drivers/input/serio/i8042-ip22io.h +++ b/drivers/input/serio/i8042-ip22io.h @@ -58,7 +58,7 @@ static inline int i8042_platform_init(void) #if 0 /* XXX sgi_kh is a virtual address */ if (!request_mem_region(sgi_kh, sizeof(struct hpc_keyb), "i8042")) - return 1; + return -EBUSY; #endif i8042_reset = 1; diff --git a/drivers/input/serio/i8042-jazzio.h b/drivers/input/serio/i8042-jazzio.h index 5c20ab13148..13fd7108eb2 100644 --- a/drivers/input/serio/i8042-jazzio.h +++ b/drivers/input/serio/i8042-jazzio.h @@ -53,7 +53,7 @@ static inline int i8042_platform_init(void) #if 0 /* XXX JAZZ_KEYBOARD_ADDRESS is a virtual address */ if (!request_mem_region(JAZZ_KEYBOARD_ADDRESS, 2, "i8042")) - return 1; + return -EBUSY; #endif return 0; diff --git a/drivers/input/serio/i8042-sparcio.h b/drivers/input/serio/i8042-sparcio.h index da2a1981248..ed9446f6d7e 100644 --- a/drivers/input/serio/i8042-sparcio.h +++ b/drivers/input/serio/i8042-sparcio.h @@ -48,10 +48,10 @@ static inline void i8042_write_command(int val) #define OBP_PS2MS_NAME1 "kdmouse" #define OBP_PS2MS_NAME2 "mouse" -static int i8042_platform_init(void) +static int __init i8042_platform_init(void) { #ifndef CONFIG_PCI - return -1; + return -ENODEV; #else char prop[128]; int len; @@ -59,14 +59,14 @@ static int i8042_platform_init(void) len = prom_getproperty(prom_root_node, "name", prop, sizeof(prop)); if (len < 0) { printk("i8042: Cannot get name property of root OBP node.\n"); - return -1; + return -ENODEV; } if (strncmp(prop, "SUNW,JavaStation-1", len) == 0) { /* Hardcoded values for MrCoffee. */ i8042_kbd_irq = i8042_aux_irq = 13 | 0x20; kbd_iobase = ioremap(0x71300060, 8); if (!kbd_iobase) - return -1; + return -ENODEV; } else { struct linux_ebus *ebus; struct linux_ebus_device *edev; @@ -78,7 +78,7 @@ static int i8042_platform_init(void) goto edev_found; } } - return -1; + return -ENODEV; edev_found: for_each_edevchild(edev, child) { @@ -96,7 +96,7 @@ static int i8042_platform_init(void) i8042_aux_irq == -1) { printk("i8042: Error, 8042 device lacks both kbd and " "mouse nodes.\n"); - return -1; + return -ENODEV; } } diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h index 03877c84e6f..273bb3b08cf 100644 --- a/drivers/input/serio/i8042-x86ia64io.h +++ b/drivers/input/serio/i8042-x86ia64io.h @@ -138,6 +138,13 @@ static struct dmi_system_id __initdata i8042_dmi_nomux_table[] = { }, }, { + .ident = "Fujitsu-Siemens Lifebook E4010", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), + DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E4010"), + }, + }, + { .ident = "Toshiba P10", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), @@ -256,9 +263,10 @@ static void i8042_pnp_exit(void) } } -static int i8042_pnp_init(void) +static int __init i8042_pnp_init(void) { - int result_kbd, result_aux; + int result_kbd = 0, result_aux = 0; + char kbd_irq_str[4] = { 0 }, aux_irq_str[4] = { 0 }; if (i8042_nopnp) { printk(KERN_INFO "i8042: PNP detection disabled\n"); @@ -267,6 +275,7 @@ static int i8042_pnp_init(void) if ((result_kbd = pnp_register_driver(&i8042_pnp_kbd_driver)) >= 0) i8042_pnp_kbd_registered = 1; + if ((result_aux = pnp_register_driver(&i8042_pnp_aux_driver)) >= 0) i8042_pnp_aux_registered = 1; @@ -280,6 +289,27 @@ static int i8042_pnp_init(void) #endif } + if (result_kbd > 0) + snprintf(kbd_irq_str, sizeof(kbd_irq_str), + "%d", i8042_pnp_kbd_irq); + if (result_aux > 0) + snprintf(aux_irq_str, sizeof(aux_irq_str), + "%d", i8042_pnp_aux_irq); + + printk(KERN_INFO "PNP: PS/2 Controller [%s%s%s] at %#x,%#x irq %s%s%s\n", + i8042_pnp_kbd_name, (result_kbd > 0 && result_aux > 0) ? "," : "", + i8042_pnp_aux_name, + i8042_pnp_data_reg, i8042_pnp_command_reg, + kbd_irq_str, (result_kbd > 0 && result_aux > 0) ? "," : "", + aux_irq_str); + +#if defined(__ia64__) + if (result_kbd <= 0) + i8042_nokbd = 1; + if (result_aux <= 0) + i8042_noaux = 1; +#endif + if (((i8042_pnp_data_reg & ~0xf) == (i8042_data_reg & ~0xf) && i8042_pnp_data_reg != i8042_data_reg) || !i8042_pnp_data_reg) { printk(KERN_WARNING "PNP: PS/2 controller has invalid data port %#x; using default %#x\n", @@ -294,53 +324,47 @@ static int i8042_pnp_init(void) i8042_pnp_command_reg = i8042_command_reg; } - if (!i8042_pnp_kbd_irq) { - printk(KERN_WARNING "PNP: PS/2 controller doesn't have KBD irq; using default %#x\n", i8042_kbd_irq); + if (!i8042_nokbd && !i8042_pnp_kbd_irq) { + printk(KERN_WARNING "PNP: PS/2 controller doesn't have KBD irq; using default %d\n", i8042_kbd_irq); i8042_pnp_kbd_irq = i8042_kbd_irq; } - if (!i8042_pnp_aux_irq) { - printk(KERN_WARNING "PNP: PS/2 controller doesn't have AUX irq; using default %#x\n", i8042_aux_irq); + if (!i8042_noaux && !i8042_pnp_aux_irq) { + printk(KERN_WARNING "PNP: PS/2 controller doesn't have AUX irq; using default %d\n", i8042_aux_irq); i8042_pnp_aux_irq = i8042_aux_irq; } -#if defined(__ia64__) - if (result_aux <= 0) - i8042_noaux = 1; -#endif - i8042_data_reg = i8042_pnp_data_reg; i8042_command_reg = i8042_pnp_command_reg; i8042_kbd_irq = i8042_pnp_kbd_irq; i8042_aux_irq = i8042_pnp_aux_irq; - printk(KERN_INFO "PNP: PS/2 Controller [%s%s%s] at %#x,%#x irq %d%s%d\n", - i8042_pnp_kbd_name, (result_kbd > 0 && result_aux > 0) ? "," : "", i8042_pnp_aux_name, - i8042_data_reg, i8042_command_reg, i8042_kbd_irq, - (result_aux > 0) ? "," : "", i8042_aux_irq); - return 0; } +#else +static inline int i8042_pnp_init(void) { return 0; } +static inline void i8042_pnp_exit(void) { } #endif -static inline int i8042_platform_init(void) +static int __init i8042_platform_init(void) { + int retval; + /* * On ix86 platforms touching the i8042 data register region can do really * bad things. Because of this the region is always reserved on ix86 boxes. * * if (!request_region(I8042_DATA_REG, 16, "i8042")) - * return -1; + * return -EBUSY; */ i8042_kbd_irq = I8042_MAP_IRQ(1); i8042_aux_irq = I8042_MAP_IRQ(12); -#ifdef CONFIG_PNP - if (i8042_pnp_init()) - return -1; -#endif + retval = i8042_pnp_init(); + if (retval) + return retval; #if defined(__ia64__) i8042_reset = 1; @@ -354,14 +378,12 @@ static inline int i8042_platform_init(void) i8042_nomux = 1; #endif - return 0; + return retval; } static inline void i8042_platform_exit(void) { -#ifdef CONFIG_PNP i8042_pnp_exit(); -#endif } #endif /* _I8042_X86IA64IO_H */ diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c index 708a1d3beab..40d451ce07f 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c @@ -27,6 +27,10 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>"); MODULE_DESCRIPTION("i8042 keyboard and mouse controller driver"); MODULE_LICENSE("GPL"); +static unsigned int i8042_nokbd; +module_param_named(nokbd, i8042_nokbd, bool, 0); +MODULE_PARM_DESC(nokbd, "Do not probe or use KBD port."); + static unsigned int i8042_noaux; module_param_named(noaux, i8042_noaux, bool, 0); MODULE_PARM_DESC(noaux, "Do not probe or use AUX (mouse) port."); @@ -338,10 +342,10 @@ static int i8042_open(struct serio *serio) return 0; -activate_fail: + activate_fail: free_irq(port->irq, i8042_request_irq_cookie); -irq_fail: + irq_fail: serio_unregister_port_delayed(serio); return -1; @@ -485,7 +489,7 @@ static irqreturn_t i8042_interrupt(int irq, void *dev_id, struct pt_regs *regs) serio_interrupt(port->serio, data, dfl, regs); ret = 1; -out: + out: return IRQ_RETVAL(ret); } @@ -552,7 +556,7 @@ static int i8042_enable_mux_ports(void) * Enable all muxed ports. */ - for (i = 0; i < 4; i++) { + for (i = 0; i < I8042_NUM_MUX_PORTS; i++) { i8042_command(¶m, I8042_CMD_MUX_PFX + i); i8042_command(¶m, I8042_CMD_AUX_ENABLE); } @@ -682,7 +686,7 @@ static int __init i8042_port_register(struct i8042_port *port) kfree(port->serio); port->serio = NULL; i8042_ctr |= port->disable; - return -1; + return -EIO; } printk(KERN_INFO "serio: i8042 %s port at %#lx,%#lx irq %d\n", @@ -977,85 +981,88 @@ static struct device_driver i8042_driver = { .shutdown = i8042_shutdown, }; -static void __init i8042_create_kbd_port(void) +static int __init i8042_create_kbd_port(void) { struct serio *serio; struct i8042_port *port = &i8042_ports[I8042_KBD_PORT_NO]; - serio = kmalloc(sizeof(struct serio), GFP_KERNEL); - if (serio) { - memset(serio, 0, sizeof(struct serio)); - serio->id.type = i8042_direct ? SERIO_8042 : SERIO_8042_XL; - serio->write = i8042_dumbkbd ? NULL : i8042_kbd_write; - serio->open = i8042_open; - serio->close = i8042_close; - serio->start = i8042_start; - serio->stop = i8042_stop; - serio->port_data = port; - serio->dev.parent = &i8042_platform_device->dev; - strlcpy(serio->name, "i8042 Kbd Port", sizeof(serio->name)); - strlcpy(serio->phys, I8042_KBD_PHYS_DESC, sizeof(serio->phys)); - - port->serio = serio; - i8042_port_register(port); - } + serio = kzalloc(sizeof(struct serio), GFP_KERNEL); + if (!serio) + return -ENOMEM; + + serio->id.type = i8042_direct ? SERIO_8042 : SERIO_8042_XL; + serio->write = i8042_dumbkbd ? NULL : i8042_kbd_write; + serio->open = i8042_open; + serio->close = i8042_close; + serio->start = i8042_start; + serio->stop = i8042_stop; + serio->port_data = port; + serio->dev.parent = &i8042_platform_device->dev; + strlcpy(serio->name, "i8042 Kbd Port", sizeof(serio->name)); + strlcpy(serio->phys, I8042_KBD_PHYS_DESC, sizeof(serio->phys)); + + port->serio = serio; + + return i8042_port_register(port); } -static void __init i8042_create_aux_port(void) +static int __init i8042_create_aux_port(void) { struct serio *serio; struct i8042_port *port = &i8042_ports[I8042_AUX_PORT_NO]; - serio = kmalloc(sizeof(struct serio), GFP_KERNEL); - if (serio) { - memset(serio, 0, sizeof(struct serio)); - serio->id.type = SERIO_8042; - serio->write = i8042_aux_write; - serio->open = i8042_open; - serio->close = i8042_close; - serio->start = i8042_start; - serio->stop = i8042_stop; - serio->port_data = port; - serio->dev.parent = &i8042_platform_device->dev; - strlcpy(serio->name, "i8042 Aux Port", sizeof(serio->name)); - strlcpy(serio->phys, I8042_AUX_PHYS_DESC, sizeof(serio->phys)); - - port->serio = serio; - i8042_port_register(port); - } + serio = kzalloc(sizeof(struct serio), GFP_KERNEL); + if (!serio) + return -ENOMEM; + + serio->id.type = SERIO_8042; + serio->write = i8042_aux_write; + serio->open = i8042_open; + serio->close = i8042_close; + serio->start = i8042_start; + serio->stop = i8042_stop; + serio->port_data = port; + serio->dev.parent = &i8042_platform_device->dev; + strlcpy(serio->name, "i8042 Aux Port", sizeof(serio->name)); + strlcpy(serio->phys, I8042_AUX_PHYS_DESC, sizeof(serio->phys)); + + port->serio = serio; + + return i8042_port_register(port); } -static void __init i8042_create_mux_port(int index) +static int __init i8042_create_mux_port(int index) { struct serio *serio; struct i8042_port *port = &i8042_ports[I8042_MUX_PORT_NO + index]; - serio = kmalloc(sizeof(struct serio), GFP_KERNEL); - if (serio) { - memset(serio, 0, sizeof(struct serio)); - serio->id.type = SERIO_8042; - serio->write = i8042_aux_write; - serio->open = i8042_open; - serio->close = i8042_close; - serio->start = i8042_start; - serio->stop = i8042_stop; - serio->port_data = port; - serio->dev.parent = &i8042_platform_device->dev; - snprintf(serio->name, sizeof(serio->name), "i8042 Aux-%d Port", index); - snprintf(serio->phys, sizeof(serio->phys), I8042_MUX_PHYS_DESC, index + 1); - - *port = i8042_ports[I8042_AUX_PORT_NO]; - port->exists = 0; - snprintf(port->name, sizeof(port->name), "AUX%d", index); - port->mux = index; - port->serio = serio; - i8042_port_register(port); - } + serio = kzalloc(sizeof(struct serio), GFP_KERNEL); + if (!serio) + return -ENOMEM; + + serio->id.type = SERIO_8042; + serio->write = i8042_aux_write; + serio->open = i8042_open; + serio->close = i8042_close; + serio->start = i8042_start; + serio->stop = i8042_stop; + serio->port_data = port; + serio->dev.parent = &i8042_platform_device->dev; + snprintf(serio->name, sizeof(serio->name), "i8042 Aux-%d Port", index); + snprintf(serio->phys, sizeof(serio->phys), I8042_MUX_PHYS_DESC, index + 1); + + *port = i8042_ports[I8042_AUX_PORT_NO]; + port->exists = 0; + snprintf(port->name, sizeof(port->name), "AUX%d", index); + port->mux = index; + port->serio = serio; + + return i8042_port_register(port); } static int __init i8042_init(void) { - int i; + int i, have_ports = 0; int err; dbg_init(); @@ -1063,43 +1070,73 @@ static int __init i8042_init(void) init_timer(&i8042_timer); i8042_timer.function = i8042_timer_func; - if (i8042_platform_init()) - return -EBUSY; + err = i8042_platform_init(); + if (err) + return err; i8042_ports[I8042_AUX_PORT_NO].irq = I8042_AUX_IRQ; i8042_ports[I8042_KBD_PORT_NO].irq = I8042_KBD_IRQ; if (i8042_controller_init()) { - i8042_platform_exit(); - return -ENODEV; + err = -ENODEV; + goto err_platform_exit; } err = driver_register(&i8042_driver); - if (err) { - i8042_platform_exit(); - return err; - } + if (err) + goto err_controller_cleanup; i8042_platform_device = platform_device_register_simple("i8042", -1, NULL, 0); if (IS_ERR(i8042_platform_device)) { - driver_unregister(&i8042_driver); - i8042_platform_exit(); - return PTR_ERR(i8042_platform_device); + err = PTR_ERR(i8042_platform_device); + goto err_unregister_driver; } if (!i8042_noaux && !i8042_check_aux()) { - if (!i8042_nomux && !i8042_check_mux()) - for (i = 0; i < I8042_NUM_MUX_PORTS; i++) - i8042_create_mux_port(i); - else - i8042_create_aux_port(); + if (!i8042_nomux && !i8042_check_mux()) { + for (i = 0; i < I8042_NUM_MUX_PORTS; i++) { + err = i8042_create_mux_port(i); + if (err) + goto err_unregister_ports; + } + } else { + err = i8042_create_aux_port(); + if (err) + goto err_unregister_ports; + } + have_ports = 1; } - i8042_create_kbd_port(); + if (!i8042_nokbd) { + err = i8042_create_kbd_port(); + if (err) + goto err_unregister_ports; + have_ports = 1; + } + + if (!have_ports) { + err = -ENODEV; + goto err_unregister_device; + } mod_timer(&i8042_timer, jiffies + I8042_POLL_PERIOD); return 0; + + err_unregister_ports: + for (i = 0; i < I8042_NUM_PORTS; i++) + if (i8042_ports[i].serio) + serio_unregister_port(i8042_ports[i].serio); + err_unregister_device: + platform_device_unregister(i8042_platform_device); + err_unregister_driver: + driver_unregister(&i8042_driver); + err_controller_cleanup: + i8042_controller_cleanup(); + err_platform_exit: + i8042_platform_exit(); + + return err; } static void __exit i8042_exit(void) diff --git a/drivers/isdn/i4l/isdn_bsdcomp.c b/drivers/isdn/i4l/isdn_bsdcomp.c index baf4bcad9bf..0afe442db3b 100644 --- a/drivers/isdn/i4l/isdn_bsdcomp.c +++ b/drivers/isdn/i4l/isdn_bsdcomp.c @@ -283,23 +283,19 @@ static void bsd_free (void *state) /* * Release the dictionary */ - if (db->dict) { - vfree (db->dict); - db->dict = NULL; - } + vfree(db->dict); + db->dict = NULL; /* * Release the string buffer */ - if (db->lens) { - vfree (db->lens); - db->lens = NULL; - } + vfree(db->lens); + db->lens = NULL; /* * Finally release the structure itself. */ - kfree (db); + kfree(db); } } diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index eebcb0b97f0..8a7d54a5c97 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -1953,7 +1953,8 @@ isdn_add_channels(isdn_driver_t *d, int drvidx, int n, int adding) kfree(d->rcvcount); if (!(d->rcvcount = kmalloc(sizeof(int) * m, GFP_ATOMIC))) { printk(KERN_WARNING "register_isdn: Could not alloc rcvcount\n"); - if (!adding) kfree(d->rcverr); + if (!adding) + kfree(d->rcverr); return -1; } memset((char *) d->rcvcount, 0, sizeof(int) * m); diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index 41df4cda66e..2fba2bbe72d 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c @@ -270,19 +270,20 @@ static struct page *read_sb_page(mddev_t *mddev, long offset, unsigned long inde if (!page) return ERR_PTR(-ENOMEM); - do { - ITERATE_RDEV(mddev, rdev, tmp) - if (rdev->in_sync && !rdev->faulty) - goto found; - return ERR_PTR(-EIO); - found: + ITERATE_RDEV(mddev, rdev, tmp) { + if (! rdev->in_sync || rdev->faulty) + continue; + target = (rdev->sb_offset << 1) + offset + index * (PAGE_SIZE/512); - } while (!sync_page_io(rdev->bdev, target, PAGE_SIZE, page, READ)); + if (sync_page_io(rdev->bdev, target, PAGE_SIZE, page, READ)) { + page->index = index; + return page; + } + } + return ERR_PTR(-EIO); - page->index = index; - return page; } static int write_sb_page(mddev_t *mddev, long offset, struct page *page, int wait) @@ -437,6 +438,7 @@ void bitmap_print_sb(struct bitmap *bitmap) printk(KERN_DEBUG " daemon sleep: %ds\n", le32_to_cpu(sb->daemon_sleep)); printk(KERN_DEBUG " sync size: %llu KB\n", (unsigned long long)le64_to_cpu(sb->sync_size)/2); + printk(KERN_DEBUG "max write behind: %d\n", le32_to_cpu(sb->write_behind)); kunmap(bitmap->sb_page); } @@ -445,7 +447,7 @@ static int bitmap_read_sb(struct bitmap *bitmap) { char *reason = NULL; bitmap_super_t *sb; - unsigned long chunksize, daemon_sleep; + unsigned long chunksize, daemon_sleep, write_behind; unsigned long bytes_read; unsigned long long events; int err = -EINVAL; @@ -474,6 +476,7 @@ static int bitmap_read_sb(struct bitmap *bitmap) chunksize = le32_to_cpu(sb->chunksize); daemon_sleep = le32_to_cpu(sb->daemon_sleep); + write_behind = le32_to_cpu(sb->write_behind); /* verify that the bitmap-specific fields are valid */ if (sb->magic != cpu_to_le32(BITMAP_MAGIC)) @@ -485,7 +488,9 @@ static int bitmap_read_sb(struct bitmap *bitmap) else if ((1 << ffz(~chunksize)) != chunksize) reason = "bitmap chunksize not a power of 2"; else if (daemon_sleep < 1 || daemon_sleep > 15) - reason = "daemon sleep period out of range"; + reason = "daemon sleep period out of range (1-15s)"; + else if (write_behind > COUNTER_MAX) + reason = "write-behind limit out of range (0 - 16383)"; if (reason) { printk(KERN_INFO "%s: invalid bitmap file superblock: %s\n", bmname(bitmap), reason); @@ -518,8 +523,12 @@ success: /* assign fields using values from superblock */ bitmap->chunksize = chunksize; bitmap->daemon_sleep = daemon_sleep; + bitmap->daemon_lastrun = jiffies; + bitmap->max_write_behind = write_behind; bitmap->flags |= sb->state; bitmap->events_cleared = le64_to_cpu(sb->events_cleared); + if (sb->state & BITMAP_STALE) + bitmap->events_cleared = bitmap->mddev->events; err = 0; out: kunmap(bitmap->sb_page); @@ -617,7 +626,7 @@ static void bitmap_file_unmap(struct bitmap *bitmap) page_cache_release(sb_page); } -static void bitmap_stop_daemons(struct bitmap *bitmap); +static void bitmap_stop_daemon(struct bitmap *bitmap); /* dequeue the next item in a page list -- don't call from irq context */ static struct page_list *dequeue_page(struct bitmap *bitmap) @@ -659,7 +668,7 @@ static void bitmap_file_put(struct bitmap *bitmap) bitmap->file = NULL; spin_unlock_irqrestore(&bitmap->lock, flags); - bitmap_stop_daemons(bitmap); + bitmap_stop_daemon(bitmap); drain_write_queues(bitmap); @@ -818,7 +827,7 @@ int bitmap_unplug(struct bitmap *bitmap) return 0; } -static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset); +static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int needed); /* * bitmap_init_from_disk -- called at bitmap_create time to initialize * the in-memory bitmap from the on-disk bitmap -- also, sets up the * memory mapping of the bitmap file @@ -826,8 +835,11 @@ static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset); * if there's no bitmap file, or if the bitmap file had been * previously kicked from the array, we mark all the bits as * 1's in order to cause a full resync. + * + * We ignore all bits for sectors that end earlier than 'start'. + * This is used when reading an out-of-date bitmap... */ -static int bitmap_init_from_disk(struct bitmap *bitmap) +static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) { unsigned long i, chunks, index, oldindex, bit; struct page *page = NULL, *oldpage = NULL; @@ -914,7 +926,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap) * whole page and write it out */ memset(page_address(page) + offset, 0xff, - PAGE_SIZE - offset); + PAGE_SIZE - offset); ret = write_page(bitmap, page, 1); if (ret) { kunmap(page); @@ -928,8 +940,11 @@ static int bitmap_init_from_disk(struct bitmap *bitmap) } if (test_bit(bit, page_address(page))) { /* if the disk bit is set, set the memory bit */ - bitmap_set_memory_bits(bitmap, i << CHUNK_BLOCK_SHIFT(bitmap)); + bitmap_set_memory_bits(bitmap, i << CHUNK_BLOCK_SHIFT(bitmap), + ((i+1) << (CHUNK_BLOCK_SHIFT(bitmap)) >= start) + ); bit_cnt++; + set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN); } } @@ -1141,6 +1156,9 @@ static void bitmap_writeback_daemon(mddev_t *mddev) err = -EINTR; goto out; } + if (bitmap == NULL) + /* about to be stopped. */ + return; PRINTK("%s: bitmap writeback daemon woke up...\n", bmname(bitmap)); /* wait on bitmap page writebacks */ @@ -1170,21 +1188,12 @@ static void bitmap_writeback_daemon(mddev_t *mddev) } } -static int bitmap_start_daemon(struct bitmap *bitmap, mdk_thread_t **ptr, +static mdk_thread_t *bitmap_start_daemon(struct bitmap *bitmap, void (*func)(mddev_t *), char *name) { mdk_thread_t *daemon; - unsigned long flags; char namebuf[32]; - spin_lock_irqsave(&bitmap->lock, flags); - *ptr = NULL; - - if (!bitmap->file) /* no need for daemon if there's no backing file */ - goto out_unlock; - - spin_unlock_irqrestore(&bitmap->lock, flags); - #ifdef INJECT_FATAL_FAULT_2 daemon = NULL; #else @@ -1194,47 +1203,32 @@ static int bitmap_start_daemon(struct bitmap *bitmap, mdk_thread_t **ptr, if (!daemon) { printk(KERN_ERR "%s: failed to start bitmap daemon\n", bmname(bitmap)); - return -ECHILD; + return ERR_PTR(-ECHILD); } - spin_lock_irqsave(&bitmap->lock, flags); - *ptr = daemon; - md_wakeup_thread(daemon); /* start it running */ PRINTK("%s: %s daemon (pid %d) started...\n", bmname(bitmap), name, daemon->tsk->pid); -out_unlock: - spin_unlock_irqrestore(&bitmap->lock, flags); - return 0; -} -static int bitmap_start_daemons(struct bitmap *bitmap) -{ - int err = bitmap_start_daemon(bitmap, &bitmap->writeback_daemon, - bitmap_writeback_daemon, "bitmap_wb"); - return err; + return daemon; } -static void bitmap_stop_daemon(struct bitmap *bitmap, mdk_thread_t **ptr) +static void bitmap_stop_daemon(struct bitmap *bitmap) { - mdk_thread_t *daemon; - unsigned long flags; - - spin_lock_irqsave(&bitmap->lock, flags); - daemon = *ptr; - *ptr = NULL; - spin_unlock_irqrestore(&bitmap->lock, flags); - if (daemon) - md_unregister_thread(daemon); /* destroy the thread */ -} + /* the daemon can't stop itself... it'll just exit instead... */ + if (bitmap->writeback_daemon && ! IS_ERR(bitmap->writeback_daemon) && + current->pid != bitmap->writeback_daemon->tsk->pid) { + mdk_thread_t *daemon; + unsigned long flags; -static void bitmap_stop_daemons(struct bitmap *bitmap) -{ - /* the daemons can't stop themselves... they'll just exit instead... */ - if (bitmap->writeback_daemon && - current->pid != bitmap->writeback_daemon->tsk->pid) - bitmap_stop_daemon(bitmap, &bitmap->writeback_daemon); + spin_lock_irqsave(&bitmap->lock, flags); + daemon = bitmap->writeback_daemon; + bitmap->writeback_daemon = NULL; + spin_unlock_irqrestore(&bitmap->lock, flags); + if (daemon && ! IS_ERR(daemon)) + md_unregister_thread(daemon); /* destroy the thread */ + } } static bitmap_counter_t *bitmap_get_counter(struct bitmap *bitmap, @@ -1274,9 +1268,16 @@ static bitmap_counter_t *bitmap_get_counter(struct bitmap *bitmap, } } -int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors) +int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors, int behind) { if (!bitmap) return 0; + + if (behind) { + atomic_inc(&bitmap->behind_writes); + PRINTK(KERN_DEBUG "inc write-behind count %d/%d\n", + atomic_read(&bitmap->behind_writes), bitmap->max_write_behind); + } + while (sectors) { int blocks; bitmap_counter_t *bmc; @@ -1311,9 +1312,15 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect } void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors, - int success) + int success, int behind) { if (!bitmap) return; + if (behind) { + atomic_dec(&bitmap->behind_writes); + PRINTK(KERN_DEBUG "dec write-behind count %d/%d\n", + atomic_read(&bitmap->behind_writes), bitmap->max_write_behind); + } + while (sectors) { int blocks; unsigned long flags; @@ -1424,7 +1431,7 @@ void bitmap_close_sync(struct bitmap *bitmap) } } -static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset) +static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int needed) { /* For each chunk covered by any of these sectors, set the * counter to 1 and set resync_needed. They should all @@ -1441,7 +1448,7 @@ static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset) } if (! *bmc) { struct page *page; - *bmc = 1 | NEEDED_MASK; + *bmc = 1 | (needed?NEEDED_MASK:0); bitmap_count_page(bitmap, offset, 1); page = filemap_get_page(bitmap, offset >> CHUNK_BLOCK_SHIFT(bitmap)); set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN); @@ -1476,17 +1483,14 @@ void bitmap_flush(mddev_t *mddev) /* * free memory that was allocated */ -void bitmap_destroy(mddev_t *mddev) +static void bitmap_free(struct bitmap *bitmap) { unsigned long k, pages; struct bitmap_page *bp; - struct bitmap *bitmap = mddev->bitmap; if (!bitmap) /* there was no bitmap */ return; - mddev->bitmap = NULL; /* disconnect from the md device */ - /* release the bitmap file and kill the daemon */ bitmap_file_put(bitmap); @@ -1504,6 +1508,17 @@ void bitmap_destroy(mddev_t *mddev) kfree(bp); kfree(bitmap); } +void bitmap_destroy(mddev_t *mddev) +{ + struct bitmap *bitmap = mddev->bitmap; + + if (!bitmap) /* there was no bitmap */ + return; + + mddev->bitmap = NULL; /* disconnect from the md device */ + + bitmap_free(bitmap); +} /* * initialize the bitmap structure @@ -1517,6 +1532,7 @@ int bitmap_create(mddev_t *mddev) unsigned long pages; struct file *file = mddev->bitmap_file; int err; + sector_t start; BUG_ON(sizeof(bitmap_super_t) != 256); @@ -1533,15 +1549,15 @@ int bitmap_create(mddev_t *mddev) spin_lock_init(&bitmap->lock); bitmap->mddev = mddev; - mddev->bitmap = bitmap; spin_lock_init(&bitmap->write_lock); INIT_LIST_HEAD(&bitmap->complete_pages); init_waitqueue_head(&bitmap->write_wait); bitmap->write_pool = mempool_create(WRITE_POOL_SIZE, write_pool_alloc, write_pool_free, NULL); + err = -ENOMEM; if (!bitmap->write_pool) - return -ENOMEM; + goto error; bitmap->file = file; bitmap->offset = mddev->bitmap_offset; @@ -1549,7 +1565,7 @@ int bitmap_create(mddev_t *mddev) /* read superblock from bitmap file (this sets bitmap->chunksize) */ err = bitmap_read_sb(bitmap); if (err) - return err; + goto error; bitmap->chunkshift = find_first_bit(&bitmap->chunksize, sizeof(bitmap->chunksize)); @@ -1573,27 +1589,44 @@ int bitmap_create(mddev_t *mddev) #else bitmap->bp = kmalloc(pages * sizeof(*bitmap->bp), GFP_KERNEL); #endif + err = -ENOMEM; if (!bitmap->bp) - return -ENOMEM; + goto error; memset(bitmap->bp, 0, pages * sizeof(*bitmap->bp)); bitmap->flags |= BITMAP_ACTIVE; /* now that we have some pages available, initialize the in-memory * bitmap from the on-disk bitmap */ - err = bitmap_init_from_disk(bitmap); + start = 0; + if (mddev->degraded == 0 + || bitmap->events_cleared == mddev->events) + /* no need to keep dirty bits to optimise a re-add of a missing device */ + start = mddev->recovery_cp; + err = bitmap_init_from_disk(bitmap, start); if (err) - return err; + goto error; printk(KERN_INFO "created bitmap (%lu pages) for device %s\n", pages, bmname(bitmap)); - /* kick off the bitmap daemons */ - err = bitmap_start_daemons(bitmap); - if (err) - return err; + mddev->bitmap = bitmap; + + if (file) + /* kick off the bitmap writeback daemon */ + bitmap->writeback_daemon = + bitmap_start_daemon(bitmap, + bitmap_writeback_daemon, + "bitmap_wb"); + + if (IS_ERR(bitmap->writeback_daemon)) + return PTR_ERR(bitmap->writeback_daemon); return bitmap_update_sb(bitmap); + + error: + bitmap_free(bitmap); + return err; } /* the bitmap API -- for raid personalities */ diff --git a/drivers/md/dm-exception-store.c b/drivers/md/dm-exception-store.c index 17212b4201a..cc07bbebbb1 100644 --- a/drivers/md/dm-exception-store.c +++ b/drivers/md/dm-exception-store.c @@ -568,12 +568,9 @@ int dm_create_persistent(struct exception_store *store, uint32_t chunk_size) bad: dm_io_put(sectors_to_pages(chunk_size)); - if (ps) { - if (ps->area) - free_area(ps); - - kfree(ps); - } + if (ps && ps->area) + free_area(ps); + kfree(ps); return r; } diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c index b08df8b9b2c..86328251375 100644 --- a/drivers/md/dm-raid1.c +++ b/drivers/md/dm-raid1.c @@ -375,16 +375,18 @@ static void rh_inc(struct region_hash *rh, region_t region) read_lock(&rh->hash_lock); reg = __rh_find(rh, region); + + atomic_inc(®->pending); + + spin_lock_irq(&rh->region_lock); if (reg->state == RH_CLEAN) { rh->log->type->mark_region(rh->log, reg->key); - spin_lock_irq(&rh->region_lock); reg->state = RH_DIRTY; list_del_init(®->list); /* take off the clean list */ - spin_unlock_irq(&rh->region_lock); } + spin_unlock_irq(&rh->region_lock); - atomic_inc(®->pending); read_unlock(&rh->hash_lock); } @@ -408,6 +410,10 @@ static void rh_dec(struct region_hash *rh, region_t region) if (atomic_dec_and_test(®->pending)) { spin_lock_irqsave(&rh->region_lock, flags); + if (atomic_read(®->pending)) { /* check race */ + spin_unlock_irqrestore(&rh->region_lock, flags); + return; + } if (reg->state == RH_RECOVERING) { list_add_tail(®->list, &rh->quiesced_regions); } else { diff --git a/drivers/md/linear.c b/drivers/md/linear.c index 8d740013d74..bb279fad2fd 100644 --- a/drivers/md/linear.c +++ b/drivers/md/linear.c @@ -38,7 +38,8 @@ static inline dev_info_t *which_dev(mddev_t *mddev, sector_t sector) /* * sector_div(a,b) returns the remainer and sets a to a/b */ - (void)sector_div(block, conf->smallest->size); + block >>= conf->preshift; + (void)sector_div(block, conf->hash_spacing); hash = conf->hash_table[block]; while ((sector>>1) >= (hash->size + hash->offset)) @@ -47,7 +48,7 @@ static inline dev_info_t *which_dev(mddev_t *mddev, sector_t sector) } /** - * linear_mergeable_bvec -- tell bio layer if a two requests can be merged + * linear_mergeable_bvec -- tell bio layer if two requests can be merged * @q: request queue * @bio: the buffer head that's been built up so far * @biovec: the request that could be merged to it. @@ -116,7 +117,7 @@ static int linear_run (mddev_t *mddev) dev_info_t **table; mdk_rdev_t *rdev; int i, nb_zone, cnt; - sector_t start; + sector_t min_spacing; sector_t curr_offset; struct list_head *tmp; @@ -127,11 +128,6 @@ static int linear_run (mddev_t *mddev) memset(conf, 0, sizeof(*conf) + mddev->raid_disks*sizeof(dev_info_t)); mddev->private = conf; - /* - * Find the smallest device. - */ - - conf->smallest = NULL; cnt = 0; mddev->array_size = 0; @@ -159,8 +155,6 @@ static int linear_run (mddev_t *mddev) disk->size = rdev->size; mddev->array_size += rdev->size; - if (!conf->smallest || (disk->size < conf->smallest->size)) - conf->smallest = disk; cnt++; } if (cnt != mddev->raid_disks) { @@ -168,6 +162,36 @@ static int linear_run (mddev_t *mddev) goto out; } + min_spacing = mddev->array_size; + sector_div(min_spacing, PAGE_SIZE/sizeof(struct dev_info *)); + + /* min_spacing is the minimum spacing that will fit the hash + * table in one PAGE. This may be much smaller than needed. + * We find the smallest non-terminal set of consecutive devices + * that is larger than min_spacing as use the size of that as + * the actual spacing + */ + conf->hash_spacing = mddev->array_size; + for (i=0; i < cnt-1 ; i++) { + sector_t sz = 0; + int j; + for (j=i; i<cnt-1 && sz < min_spacing ; j++) + sz += conf->disks[j].size; + if (sz >= min_spacing && sz < conf->hash_spacing) + conf->hash_spacing = sz; + } + + /* hash_spacing may be too large for sector_div to work with, + * so we might need to pre-shift + */ + conf->preshift = 0; + if (sizeof(sector_t) > sizeof(u32)) { + sector_t space = conf->hash_spacing; + while (space > (sector_t)(~(u32)0)) { + space >>= 1; + conf->preshift++; + } + } /* * This code was restructured to work around a gcc-2.95.3 internal * compiler error. Alter it with care. @@ -177,39 +201,52 @@ static int linear_run (mddev_t *mddev) unsigned round; unsigned long base; - sz = mddev->array_size; - base = conf->smallest->size; + sz = mddev->array_size >> conf->preshift; + sz += 1; /* force round-up */ + base = conf->hash_spacing >> conf->preshift; round = sector_div(sz, base); - nb_zone = conf->nr_zones = sz + (round ? 1 : 0); + nb_zone = sz + (round ? 1 : 0); } - - conf->hash_table = kmalloc (sizeof (dev_info_t*) * nb_zone, + BUG_ON(nb_zone > PAGE_SIZE / sizeof(struct dev_info *)); + + conf->hash_table = kmalloc (sizeof (struct dev_info *) * nb_zone, GFP_KERNEL); if (!conf->hash_table) goto out; /* * Here we generate the linear hash table + * First calculate the device offsets. */ + conf->disks[0].offset = 0; + for (i=1; i<mddev->raid_disks; i++) + conf->disks[i].offset = + conf->disks[i-1].offset + + conf->disks[i-1].size; + table = conf->hash_table; - start = 0; curr_offset = 0; - for (i = 0; i < cnt; i++) { - dev_info_t *disk = conf->disks + i; + i = 0; + for (curr_offset = 0; + curr_offset < mddev->array_size; + curr_offset += conf->hash_spacing) { - disk->offset = curr_offset; - curr_offset += disk->size; + while (i < mddev->raid_disks-1 && + curr_offset >= conf->disks[i+1].offset) + i++; - /* 'curr_offset' is the end of this disk - * 'start' is the start of table + *table ++ = conf->disks + i; + } + + if (conf->preshift) { + conf->hash_spacing >>= conf->preshift; + /* round hash_spacing up so that when we divide by it, + * we err on the side of "too-low", which is safest. */ - while (start < curr_offset) { - *table++ = disk; - start += conf->smallest->size; - } + conf->hash_spacing++; } - if (table-conf->hash_table != nb_zone) - BUG(); + + BUG_ON(table - conf->hash_table > nb_zone); blk_queue_merge_bvec(mddev->queue, linear_mergeable_bvec); mddev->queue->unplug_fn = linear_unplug; @@ -238,6 +275,11 @@ static int linear_make_request (request_queue_t *q, struct bio *bio) dev_info_t *tmp_dev; sector_t block; + if (unlikely(bio_barrier(bio))) { + bio_endio(bio, bio->bi_size, -EOPNOTSUPP); + return 0; + } + if (bio_data_dir(bio)==WRITE) { disk_stat_inc(mddev->gendisk, writes); disk_stat_add(mddev->gendisk, write_sectors, bio_sectors(bio)); @@ -294,7 +336,7 @@ static void linear_status (struct seq_file *seq, mddev_t *mddev) sector_t s = 0; seq_printf(seq, " "); - for (j = 0; j < conf->nr_zones; j++) + for (j = 0; j < mddev->raid_disks; j++) { char b[BDEVNAME_SIZE]; s += conf->smallest_size; diff --git a/drivers/md/md.c b/drivers/md/md.c index 20ca80b7dc2..2897df90df4 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -34,6 +34,7 @@ #include <linux/module.h> #include <linux/config.h> +#include <linux/kthread.h> #include <linux/linkage.h> #include <linux/raid/md.h> #include <linux/raid/bitmap.h> @@ -73,7 +74,7 @@ static DEFINE_SPINLOCK(pers_lock); * Current RAID-1,4,5 parallel reconstruction 'guaranteed speed limit' * is 1000 KB/sec, so the extra system load does not show up that much. * Increase it if you want to have more _guaranteed_ speed. Note that - * the RAID driver will use the maximum available bandwith if the IO + * the RAID driver will use the maximum available bandwidth if the IO * subsystem is idle. There is also an 'absolute maximum' reconstruction * speed limit - in case reconstruction slows down your system despite * idle IO detection. @@ -393,7 +394,7 @@ int sync_page_io(struct block_device *bdev, sector_t sector, int size, return ret; } -static int read_disk_sb(mdk_rdev_t * rdev) +static int read_disk_sb(mdk_rdev_t * rdev, int size) { char b[BDEVNAME_SIZE]; if (!rdev->sb_page) { @@ -404,7 +405,7 @@ static int read_disk_sb(mdk_rdev_t * rdev) return 0; - if (!sync_page_io(rdev->bdev, rdev->sb_offset<<1, MD_SB_BYTES, rdev->sb_page, READ)) + if (!sync_page_io(rdev->bdev, rdev->sb_offset<<1, size, rdev->sb_page, READ)) goto fail; rdev->sb_loaded = 1; return 0; @@ -531,7 +532,7 @@ static int super_90_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version sb_offset = calc_dev_sboffset(rdev->bdev); rdev->sb_offset = sb_offset; - ret = read_disk_sb(rdev); + ret = read_disk_sb(rdev, MD_SB_BYTES); if (ret) return ret; ret = -EINVAL; @@ -564,6 +565,7 @@ static int super_90_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version rdev->preferred_minor = sb->md_minor; rdev->data_offset = 0; + rdev->sb_size = MD_SB_BYTES; if (sb->level == LEVEL_MULTIPATH) rdev->desc_nr = -1; @@ -623,6 +625,7 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev) mddev->size = sb->size; mddev->events = md_event(sb); mddev->bitmap_offset = 0; + mddev->default_bitmap_offset = MD_SB_BYTES >> 9; if (sb->state & (1<<MD_SB_CLEAN)) mddev->recovery_cp = MaxSector; @@ -643,12 +646,12 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev) if (sb->state & (1<<MD_SB_BITMAP_PRESENT) && mddev->bitmap_file == NULL) { - if (mddev->level != 1) { + if (mddev->level != 1 && mddev->level != 5 && mddev->level != 6) { /* FIXME use a better test */ printk(KERN_WARNING "md: bitmaps only support for raid1\n"); return -EINVAL; } - mddev->bitmap_offset = (MD_SB_BYTES >> 9); + mddev->bitmap_offset = mddev->default_bitmap_offset; } } else if (mddev->pers == NULL) { @@ -669,6 +672,7 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev) if (mddev->level != LEVEL_MULTIPATH) { rdev->faulty = 0; + rdev->flags = 0; desc = sb->disks + rdev->desc_nr; if (desc->state & (1<<MD_DISK_FAULTY)) @@ -678,6 +682,8 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev) rdev->in_sync = 1; rdev->raid_disk = desc->raid_disk; } + if (desc->state & (1<<MD_DISK_WRITEMOSTLY)) + set_bit(WriteMostly, &rdev->flags); } else /* MULTIPATH are always insync */ rdev->in_sync = 1; return 0; @@ -706,6 +712,8 @@ static void super_90_sync(mddev_t *mddev, mdk_rdev_t *rdev) int i; int active=0, working=0,failed=0,spare=0,nr_disks=0; + rdev->sb_size = MD_SB_BYTES; + sb = (mdp_super_t*)page_address(rdev->sb_page); memset(sb, 0, sizeof(*sb)); @@ -776,6 +784,8 @@ static void super_90_sync(mddev_t *mddev, mdk_rdev_t *rdev) spare++; working++; } + if (test_bit(WriteMostly, &rdev2->flags)) + d->state |= (1<<MD_DISK_WRITEMOSTLY); } /* now set the "removed" and "faulty" bits on any missing devices */ @@ -831,6 +841,7 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version) int ret; sector_t sb_offset; char b[BDEVNAME_SIZE], b2[BDEVNAME_SIZE]; + int bmask; /* * Calculate the position of the superblock. @@ -859,7 +870,10 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version) } rdev->sb_offset = sb_offset; - ret = read_disk_sb(rdev); + /* superblock is rarely larger than 1K, but it can be larger, + * and it is safe to read 4k, so we do that + */ + ret = read_disk_sb(rdev, 4096); if (ret) return ret; @@ -869,7 +883,7 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version) sb->major_version != cpu_to_le32(1) || le32_to_cpu(sb->max_dev) > (4096-256)/2 || le64_to_cpu(sb->super_offset) != (rdev->sb_offset<<1) || - sb->feature_map != 0) + (le32_to_cpu(sb->feature_map) & ~MD_FEATURE_ALL) != 0) return -EINVAL; if (calc_sb_1_csum(sb) != sb->sb_csum) { @@ -885,6 +899,11 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version) rdev->preferred_minor = 0xffff; rdev->data_offset = le64_to_cpu(sb->data_offset); + rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256; + bmask = queue_hardsect_size(rdev->bdev->bd_disk->queue)-1; + if (rdev->sb_size & bmask) + rdev-> sb_size = (rdev->sb_size | bmask)+1; + if (refdev == 0) return 1; else { @@ -939,13 +958,15 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev) mddev->size = le64_to_cpu(sb->size)/2; mddev->events = le64_to_cpu(sb->events); mddev->bitmap_offset = 0; + mddev->default_bitmap_offset = 0; + mddev->default_bitmap_offset = 1024; mddev->recovery_cp = le64_to_cpu(sb->resync_offset); memcpy(mddev->uuid, sb->set_uuid, 16); mddev->max_disks = (4096-256)/2; - if ((le32_to_cpu(sb->feature_map) & 1) && + if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_BITMAP_OFFSET) && mddev->bitmap_file == NULL ) { if (mddev->level != 1) { printk(KERN_WARNING "md: bitmaps only supported for raid1\n"); @@ -986,6 +1007,9 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev) rdev->raid_disk = role; break; } + rdev->flags = 0; + if (sb->devflags & WriteMostly1) + set_bit(WriteMostly, &rdev->flags); } else /* MULTIPATH are always insync */ rdev->in_sync = 1; @@ -1017,7 +1041,7 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev) if (mddev->bitmap && mddev->bitmap_file == NULL) { sb->bitmap_offset = cpu_to_le32((__u32)mddev->bitmap_offset); - sb->feature_map = cpu_to_le32(1); + sb->feature_map = cpu_to_le32(MD_FEATURE_BITMAP_OFFSET); } max_dev = 0; @@ -1363,7 +1387,7 @@ repeat: dprintk("%s ", bdevname(rdev->bdev,b)); if (!rdev->faulty) { md_super_write(mddev,rdev, - rdev->sb_offset<<1, MD_SB_BYTES, + rdev->sb_offset<<1, rdev->sb_size, rdev->sb_page); dprintk(KERN_INFO "(write) %s's sb offset: %llu\n", bdevname(rdev->bdev,b), @@ -2073,6 +2097,8 @@ static int get_array_info(mddev_t * mddev, void __user * arg) info.state = 0; if (mddev->in_sync) info.state = (1<<MD_SB_CLEAN); + if (mddev->bitmap && mddev->bitmap_offset) + info.state = (1<<MD_SB_BITMAP_PRESENT); info.active_disks = active; info.working_disks = working; info.failed_disks = failed; @@ -2087,7 +2113,7 @@ static int get_array_info(mddev_t * mddev, void __user * arg) return 0; } -static int get_bitmap_file(mddev_t * mddev, void * arg) +static int get_bitmap_file(mddev_t * mddev, void __user * arg) { mdu_bitmap_file_t *file = NULL; /* too big for stack allocation */ char *ptr, *buf = NULL; @@ -2146,6 +2172,8 @@ static int get_disk_info(mddev_t * mddev, void __user * arg) info.state |= (1<<MD_DISK_ACTIVE); info.state |= (1<<MD_DISK_SYNC); } + if (test_bit(WriteMostly, &rdev->flags)) + info.state |= (1<<MD_DISK_WRITEMOSTLY); } else { info.major = info.minor = 0; info.raid_disk = -1; @@ -2210,8 +2238,11 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info) mdname(mddev)); return -EINVAL; } - rdev = md_import_device(dev, mddev->major_version, - mddev->minor_version); + if (mddev->persistent) + rdev = md_import_device(dev, mddev->major_version, + mddev->minor_version); + else + rdev = md_import_device(dev, -1, -1); if (IS_ERR(rdev)) { printk(KERN_WARNING "md: md_import_device returned %ld\n", @@ -2231,6 +2262,9 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info) rdev->saved_raid_disk = rdev->raid_disk; rdev->in_sync = 0; /* just to be sure */ + if (info->state & (1<<MD_DISK_WRITEMOSTLY)) + set_bit(WriteMostly, &rdev->flags); + rdev->raid_disk = -1; err = bind_rdev_to_array(rdev, mddev); if (err) @@ -2271,6 +2305,9 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info) else rdev->in_sync = 0; + if (info->state & (1<<MD_DISK_WRITEMOSTLY)) + set_bit(WriteMostly, &rdev->flags); + err = bind_rdev_to_array(rdev, mddev); if (err) { export_rdev(rdev); @@ -2430,25 +2467,51 @@ static int set_bitmap_file(mddev_t *mddev, int fd) { int err; - if (mddev->pers) - return -EBUSY; + if (mddev->pers) { + if (!mddev->pers->quiesce) + return -EBUSY; + if (mddev->recovery || mddev->sync_thread) + return -EBUSY; + /* we should be able to change the bitmap.. */ + } - mddev->bitmap_file = fget(fd); - if (mddev->bitmap_file == NULL) { - printk(KERN_ERR "%s: error: failed to get bitmap file\n", - mdname(mddev)); - return -EBADF; - } + if (fd >= 0) { + if (mddev->bitmap) + return -EEXIST; /* cannot add when bitmap is present */ + mddev->bitmap_file = fget(fd); - err = deny_bitmap_write_access(mddev->bitmap_file); - if (err) { - printk(KERN_ERR "%s: error: bitmap file is already in use\n", - mdname(mddev)); - fput(mddev->bitmap_file); - mddev->bitmap_file = NULL; - } else + if (mddev->bitmap_file == NULL) { + printk(KERN_ERR "%s: error: failed to get bitmap file\n", + mdname(mddev)); + return -EBADF; + } + + err = deny_bitmap_write_access(mddev->bitmap_file); + if (err) { + printk(KERN_ERR "%s: error: bitmap file is already in use\n", + mdname(mddev)); + fput(mddev->bitmap_file); + mddev->bitmap_file = NULL; + return err; + } mddev->bitmap_offset = 0; /* file overrides offset */ + } else if (mddev->bitmap == NULL) + return -ENOENT; /* cannot remove what isn't there */ + err = 0; + if (mddev->pers) { + mddev->pers->quiesce(mddev, 1); + if (fd >= 0) + err = bitmap_create(mddev); + if (fd < 0 || err) + bitmap_destroy(mddev); + mddev->pers->quiesce(mddev, 0); + } else if (fd < 0) { + if (mddev->bitmap_file) + fput(mddev->bitmap_file); + mddev->bitmap_file = NULL; + } + return err; } @@ -2528,6 +2591,11 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info) { int rv = 0; int cnt = 0; + int state = 0; + + /* calculate expected state,ignoring low bits */ + if (mddev->bitmap && mddev->bitmap_offset) + state |= (1 << MD_SB_BITMAP_PRESENT); if (mddev->major_version != info->major_version || mddev->minor_version != info->minor_version || @@ -2536,12 +2604,16 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info) mddev->level != info->level || /* mddev->layout != info->layout || */ !mddev->persistent != info->not_persistent|| - mddev->chunk_size != info->chunk_size ) + mddev->chunk_size != info->chunk_size || + /* ignore bottom 8 bits of state, and allow SB_BITMAP_PRESENT to change */ + ((state^info->state) & 0xfffffe00) + ) return -EINVAL; /* Check there is only one change */ if (mddev->size != info->size) cnt++; if (mddev->raid_disks != info->raid_disks) cnt++; if (mddev->layout != info->layout) cnt++; + if ((state ^ info->state) & (1<<MD_SB_BITMAP_PRESENT)) cnt++; if (cnt == 0) return 0; if (cnt > 1) return -EINVAL; @@ -2620,6 +2692,35 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info) } } } + if ((state ^ info->state) & (1<<MD_SB_BITMAP_PRESENT)) { + if (mddev->pers->quiesce == NULL) + return -EINVAL; + if (mddev->recovery || mddev->sync_thread) + return -EBUSY; + if (info->state & (1<<MD_SB_BITMAP_PRESENT)) { + /* add the bitmap */ + if (mddev->bitmap) + return -EEXIST; + if (mddev->default_bitmap_offset == 0) + return -EINVAL; + mddev->bitmap_offset = mddev->default_bitmap_offset; + mddev->pers->quiesce(mddev, 1); + rv = bitmap_create(mddev); + if (rv) + bitmap_destroy(mddev); + mddev->pers->quiesce(mddev, 0); + } else { + /* remove the bitmap */ + if (!mddev->bitmap) + return -ENOENT; + if (mddev->bitmap->file) + return -EINVAL; + mddev->pers->quiesce(mddev, 1); + bitmap_destroy(mddev); + mddev->pers->quiesce(mddev, 0); + mddev->bitmap_offset = 0; + } + } md_update_sb(mddev); return rv; } @@ -2781,7 +2882,7 @@ static int md_ioctl(struct inode *inode, struct file *file, goto done_unlock; case GET_BITMAP_FILE: - err = get_bitmap_file(mddev, (void *)arg); + err = get_bitmap_file(mddev, argp); goto done_unlock; case GET_DISK_INFO: @@ -2950,18 +3051,6 @@ static int md_thread(void * arg) { mdk_thread_t *thread = arg; - lock_kernel(); - - /* - * Detach thread - */ - - daemonize(thread->name, mdname(thread->mddev)); - - current->exit_signal = SIGCHLD; - allow_signal(SIGKILL); - thread->tsk = current; - /* * md_thread is a 'system-thread', it's priority should be very * high. We avoid resource deadlocks individually in each @@ -2973,14 +3062,14 @@ static int md_thread(void * arg) * bdflush, otherwise bdflush will deadlock if there are too * many dirty RAID5 blocks. */ - unlock_kernel(); complete(thread->event); - while (thread->run) { + while (!kthread_should_stop()) { void (*run)(mddev_t *); wait_event_interruptible_timeout(thread->wqueue, - test_bit(THREAD_WAKEUP, &thread->flags), + test_bit(THREAD_WAKEUP, &thread->flags) + || kthread_should_stop(), thread->timeout); try_to_freeze(); @@ -2989,11 +3078,8 @@ static int md_thread(void * arg) run = thread->run; if (run) run(thread->mddev); - - if (signal_pending(current)) - flush_signals(current); } - complete(thread->event); + return 0; } @@ -3010,11 +3096,9 @@ mdk_thread_t *md_register_thread(void (*run) (mddev_t *), mddev_t *mddev, const char *name) { mdk_thread_t *thread; - int ret; struct completion event; - thread = (mdk_thread_t *) kmalloc - (sizeof(mdk_thread_t), GFP_KERNEL); + thread = kmalloc(sizeof(mdk_thread_t), GFP_KERNEL); if (!thread) return NULL; @@ -3027,8 +3111,8 @@ mdk_thread_t *md_register_thread(void (*run) (mddev_t *), mddev_t *mddev, thread->mddev = mddev; thread->name = name; thread->timeout = MAX_SCHEDULE_TIMEOUT; - ret = kernel_thread(md_thread, thread, 0); - if (ret < 0) { + thread->tsk = kthread_run(md_thread, thread, mdname(thread->mddev)); + if (IS_ERR(thread->tsk)) { kfree(thread); return NULL; } @@ -3038,21 +3122,9 @@ mdk_thread_t *md_register_thread(void (*run) (mddev_t *), mddev_t *mddev, void md_unregister_thread(mdk_thread_t *thread) { - struct completion event; - - init_completion(&event); - - thread->event = &event; - - /* As soon as ->run is set to NULL, the task could disappear, - * so we need to hold tasklist_lock until we have sent the signal - */ dprintk("interrupting MD-thread pid %d\n", thread->tsk->pid); - read_lock(&tasklist_lock); - thread->run = NULL; - send_sig(SIGKILL, thread->tsk, 1); - read_unlock(&tasklist_lock); - wait_for_completion(&event); + + kthread_stop(thread->tsk); kfree(thread); } @@ -3259,10 +3331,13 @@ static int md_seq_show(struct seq_file *seq, void *v) char b[BDEVNAME_SIZE]; seq_printf(seq, " %s[%d]", bdevname(rdev->bdev,b), rdev->desc_nr); + if (test_bit(WriteMostly, &rdev->flags)) + seq_printf(seq, "(W)"); if (rdev->faulty) { seq_printf(seq, "(F)"); continue; - } + } else if (rdev->raid_disk < 0) + seq_printf(seq, "(S)"); /* spare */ size += rdev->size; } @@ -3274,6 +3349,15 @@ static int md_seq_show(struct seq_file *seq, void *v) seq_printf(seq, "\n %llu blocks", (unsigned long long)size); } + if (mddev->persistent) { + if (mddev->major_version != 0 || + mddev->minor_version != 90) { + seq_printf(seq," super %d.%d", + mddev->major_version, + mddev->minor_version); + } + } else + seq_printf(seq, " super non-persistent"); if (mddev->pers) { mddev->pers->status (seq, mddev); @@ -3416,7 +3500,6 @@ void md_done_sync(mddev_t *mddev, int blocks, int ok) */ void md_write_start(mddev_t *mddev, struct bio *bi) { - DEFINE_WAIT(w); if (bio_data_dir(bi) != WRITE) return; @@ -3533,7 +3616,7 @@ static void md_do_sync(mddev_t *mddev) printk(KERN_INFO "md: syncing RAID array %s\n", mdname(mddev)); printk(KERN_INFO "md: minimum _guaranteed_ reconstruction speed:" " %d KB/sec/disc.\n", sysctl_speed_limit_min); - printk(KERN_INFO "md: using maximum available idle IO bandwith " + printk(KERN_INFO "md: using maximum available idle IO bandwidth " "(but not more than %d KB/sec) for reconstruction.\n", sysctl_speed_limit_max); diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c index 2d2ca7fa026..286342375fb 100644 --- a/drivers/md/multipath.c +++ b/drivers/md/multipath.c @@ -169,6 +169,11 @@ static int multipath_make_request (request_queue_t *q, struct bio * bio) struct multipath_bh * mp_bh; struct multipath_info *multipath; + if (unlikely(bio_barrier(bio))) { + bio_endio(bio, bio->bi_size, -EOPNOTSUPP); + return 0; + } + mp_bh = mempool_alloc(conf->pool, GFP_NOIO); mp_bh->master_bio = bio; diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index 2120710172c..f6757259ce7 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c @@ -404,6 +404,11 @@ static int raid0_make_request (request_queue_t *q, struct bio *bio) unsigned long chunk; sector_t block, rsect; + if (unlikely(bio_barrier(bio))) { + bio_endio(bio, bio->bi_size, -EOPNOTSUPP); + return 0; + } + if (bio_data_dir(bio)==WRITE) { disk_stat_inc(mddev->gendisk, writes); disk_stat_add(mddev->gendisk, write_sectors, bio_sectors(bio)); diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 51d9645ed09..a93ca478142 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -222,8 +222,17 @@ static void raid_end_bio_io(r1bio_t *r1_bio) { struct bio *bio = r1_bio->master_bio; - bio_endio(bio, bio->bi_size, - test_bit(R1BIO_Uptodate, &r1_bio->state) ? 0 : -EIO); + /* if nobody has done the final endio yet, do it now */ + if (!test_and_set_bit(R1BIO_Returned, &r1_bio->state)) { + PRINTK(KERN_DEBUG "raid1: sync end %s on sectors %llu-%llu\n", + (bio_data_dir(bio) == WRITE) ? "write" : "read", + (unsigned long long) bio->bi_sector, + (unsigned long long) bio->bi_sector + + (bio->bi_size >> 9) - 1); + + bio_endio(bio, bio->bi_size, + test_bit(R1BIO_Uptodate, &r1_bio->state) ? 0 : -EIO); + } free_r1bio(r1_bio); } @@ -292,7 +301,7 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int { int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); r1bio_t * r1_bio = (r1bio_t *)(bio->bi_private); - int mirror; + int mirror, behind; conf_t *conf = mddev_to_conf(r1_bio->mddev); if (bio->bi_size) @@ -323,16 +332,46 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int update_head_pos(mirror, r1_bio); + behind = test_bit(R1BIO_BehindIO, &r1_bio->state); + if (behind) { + if (test_bit(WriteMostly, &conf->mirrors[mirror].rdev->flags)) + atomic_dec(&r1_bio->behind_remaining); + + /* In behind mode, we ACK the master bio once the I/O has safely + * reached all non-writemostly disks. Setting the Returned bit + * ensures that this gets done only once -- we don't ever want to + * return -EIO here, instead we'll wait */ + + if (atomic_read(&r1_bio->behind_remaining) >= (atomic_read(&r1_bio->remaining)-1) && + test_bit(R1BIO_Uptodate, &r1_bio->state)) { + /* Maybe we can return now */ + if (!test_and_set_bit(R1BIO_Returned, &r1_bio->state)) { + struct bio *mbio = r1_bio->master_bio; + PRINTK(KERN_DEBUG "raid1: behind end write sectors %llu-%llu\n", + (unsigned long long) mbio->bi_sector, + (unsigned long long) mbio->bi_sector + + (mbio->bi_size >> 9) - 1); + bio_endio(mbio, mbio->bi_size, 0); + } + } + } /* * * Let's see if all mirrored write operations have finished * already. */ if (atomic_dec_and_test(&r1_bio->remaining)) { + if (test_bit(R1BIO_BehindIO, &r1_bio->state)) { + /* free extra copy of the data pages */ + int i = bio->bi_vcnt; + while (i--) + __free_page(bio->bi_io_vec[i].bv_page); + } /* clear the bitmap if all writes complete successfully */ bitmap_endwrite(r1_bio->mddev->bitmap, r1_bio->sector, r1_bio->sectors, - !test_bit(R1BIO_Degraded, &r1_bio->state)); + !test_bit(R1BIO_Degraded, &r1_bio->state), + behind); md_write_end(r1_bio->mddev); raid_end_bio_io(r1_bio); } @@ -360,13 +399,14 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio) { const unsigned long this_sector = r1_bio->sector; int new_disk = conf->last_used, disk = new_disk; + int wonly_disk = -1; const int sectors = r1_bio->sectors; sector_t new_distance, current_distance; - mdk_rdev_t *new_rdev, *rdev; + mdk_rdev_t *rdev; rcu_read_lock(); /* - * Check if it if we can balance. We can balance on the whole + * Check if we can balance. We can balance on the whole * device if no resync is going on, or below the resync window. * We take the first readable disk when above the resync window. */ @@ -376,11 +416,16 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio) /* Choose the first operation device, for consistancy */ new_disk = 0; - while ((new_rdev=conf->mirrors[new_disk].rdev) == NULL || - !new_rdev->in_sync) { - new_disk++; - if (new_disk == conf->raid_disks) { - new_disk = -1; + for (rdev = conf->mirrors[new_disk].rdev; + !rdev || !rdev->in_sync + || test_bit(WriteMostly, &rdev->flags); + rdev = conf->mirrors[++new_disk].rdev) { + + if (rdev && rdev->in_sync) + wonly_disk = new_disk; + + if (new_disk == conf->raid_disks - 1) { + new_disk = wonly_disk; break; } } @@ -389,16 +434,26 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio) /* make sure the disk is operational */ - while ((new_rdev=conf->mirrors[new_disk].rdev) == NULL || - !new_rdev->in_sync) { + for (rdev = conf->mirrors[new_disk].rdev; + !rdev || !rdev->in_sync || + test_bit(WriteMostly, &rdev->flags); + rdev = conf->mirrors[new_disk].rdev) { + + if (rdev && rdev->in_sync) + wonly_disk = new_disk; + if (new_disk <= 0) new_disk = conf->raid_disks; new_disk--; if (new_disk == disk) { - new_disk = -1; - goto rb_out; + new_disk = wonly_disk; + break; } } + + if (new_disk < 0) + goto rb_out; + disk = new_disk; /* now disk == new_disk == starting point for search */ @@ -419,37 +474,41 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio) disk = conf->raid_disks; disk--; - if ((rdev=conf->mirrors[disk].rdev) == NULL || - !rdev->in_sync) + rdev = conf->mirrors[disk].rdev; + + if (!rdev || + !rdev->in_sync || + test_bit(WriteMostly, &rdev->flags)) continue; if (!atomic_read(&rdev->nr_pending)) { new_disk = disk; - new_rdev = rdev; break; } new_distance = abs(this_sector - conf->mirrors[disk].head_position); if (new_distance < current_distance) { current_distance = new_distance; new_disk = disk; - new_rdev = rdev; } } while (disk != conf->last_used); -rb_out: + rb_out: if (new_disk >= 0) { - conf->next_seq_sect = this_sector + sectors; - conf->last_used = new_disk; - atomic_inc(&new_rdev->nr_pending); - if (!new_rdev->in_sync) { + rdev = conf->mirrors[new_disk].rdev; + if (!rdev) + goto retry; + atomic_inc(&rdev->nr_pending); + if (!rdev->in_sync) { /* cannot risk returning a device that failed * before we inc'ed nr_pending */ - atomic_dec(&new_rdev->nr_pending); + atomic_dec(&rdev->nr_pending); goto retry; } + conf->next_seq_sect = this_sector + sectors; + conf->last_used = new_disk; } rcu_read_unlock(); @@ -542,6 +601,39 @@ static void device_barrier(conf_t *conf, sector_t sect) spin_unlock_irq(&conf->resync_lock); } +/* duplicate the data pages for behind I/O */ +static struct page **alloc_behind_pages(struct bio *bio) +{ + int i; + struct bio_vec *bvec; + struct page **pages = kmalloc(bio->bi_vcnt * sizeof(struct page *), + GFP_NOIO); + if (unlikely(!pages)) + goto do_sync_io; + + memset(pages, 0, bio->bi_vcnt * sizeof(struct page *)); + + bio_for_each_segment(bvec, bio, i) { + pages[i] = alloc_page(GFP_NOIO); + if (unlikely(!pages[i])) + goto do_sync_io; + memcpy(kmap(pages[i]) + bvec->bv_offset, + kmap(bvec->bv_page) + bvec->bv_offset, bvec->bv_len); + kunmap(pages[i]); + kunmap(bvec->bv_page); + } + + return pages; + +do_sync_io: + if (pages) + for (i = 0; i < bio->bi_vcnt && pages[i]; i++) + __free_page(pages[i]); + kfree(pages); + PRINTK("%dB behind alloc failed, doing sync I/O\n", bio->bi_size); + return NULL; +} + static int make_request(request_queue_t *q, struct bio * bio) { mddev_t *mddev = q->queuedata; @@ -554,7 +646,12 @@ static int make_request(request_queue_t *q, struct bio * bio) struct bitmap *bitmap = mddev->bitmap; unsigned long flags; struct bio_list bl; + struct page **behind_pages = NULL; + if (unlikely(bio_barrier(bio))) { + bio_endio(bio, bio->bi_size, -EOPNOTSUPP); + return 0; + } /* * Register the new request and wait if the reconstruction @@ -589,8 +686,6 @@ static int make_request(request_queue_t *q, struct bio * bio) r1_bio->mddev = mddev; r1_bio->sector = bio->bi_sector; - r1_bio->state = 0; - if (bio_data_dir(bio) == READ) { /* * read balancing logic: @@ -651,13 +746,22 @@ static int make_request(request_queue_t *q, struct bio * bio) } rcu_read_unlock(); + BUG_ON(targets == 0); /* we never fail the last device */ + if (targets < conf->raid_disks) { /* array is degraded, we will not clear the bitmap * on I/O completion (see raid1_end_write_request) */ set_bit(R1BIO_Degraded, &r1_bio->state); } + /* do behind I/O ? */ + if (bitmap && + atomic_read(&bitmap->behind_writes) < bitmap->max_write_behind && + (behind_pages = alloc_behind_pages(bio)) != NULL) + set_bit(R1BIO_BehindIO, &r1_bio->state); + atomic_set(&r1_bio->remaining, 0); + atomic_set(&r1_bio->behind_remaining, 0); bio_list_init(&bl); for (i = 0; i < disks; i++) { @@ -674,12 +778,31 @@ static int make_request(request_queue_t *q, struct bio * bio) mbio->bi_rw = WRITE; mbio->bi_private = r1_bio; + if (behind_pages) { + struct bio_vec *bvec; + int j; + + /* Yes, I really want the '__' version so that + * we clear any unused pointer in the io_vec, rather + * than leave them unchanged. This is important + * because when we come to free the pages, we won't + * know the originial bi_idx, so we just free + * them all + */ + __bio_for_each_segment(bvec, mbio, j, 0) + bvec->bv_page = behind_pages[j]; + if (test_bit(WriteMostly, &conf->mirrors[i].rdev->flags)) + atomic_inc(&r1_bio->behind_remaining); + } + atomic_inc(&r1_bio->remaining); bio_list_add(&bl, mbio); } + kfree(behind_pages); /* the behind pages are attached to the bios now */ - bitmap_startwrite(bitmap, bio->bi_sector, r1_bio->sectors); + bitmap_startwrite(bitmap, bio->bi_sector, r1_bio->sectors, + test_bit(R1BIO_BehindIO, &r1_bio->state)); spin_lock_irqsave(&conf->device_lock, flags); bio_list_merge(&conf->pending_bio_list, &bl); bio_list_init(&bl); @@ -1105,6 +1228,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i sector_t max_sector, nr_sectors; int disk; int i; + int wonly; int write_targets = 0; int sync_blocks; int still_degraded = 0; @@ -1160,14 +1284,21 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i */ disk = conf->last_used; /* make sure disk is operational */ - + wonly = disk; while (conf->mirrors[disk].rdev == NULL || - !conf->mirrors[disk].rdev->in_sync) { + !conf->mirrors[disk].rdev->in_sync || + test_bit(WriteMostly, &conf->mirrors[disk].rdev->flags) + ) { + if (conf->mirrors[disk].rdev && + conf->mirrors[disk].rdev->in_sync) + wonly = disk; if (disk <= 0) disk = conf->raid_disks; disk--; - if (disk == conf->last_used) + if (disk == conf->last_used) { + disk = wonly; break; + } } conf->last_used = disk; atomic_inc(&conf->mirrors[disk].rdev->nr_pending); @@ -1439,6 +1570,17 @@ out: static int stop(mddev_t *mddev) { conf_t *conf = mddev_to_conf(mddev); + struct bitmap *bitmap = mddev->bitmap; + int behind_wait = 0; + + /* wait for behind writes to complete */ + while (bitmap && atomic_read(&bitmap->behind_writes) > 0) { + behind_wait++; + printk(KERN_INFO "raid1: behind writes in progress on device %s, waiting to stop (%d)\n", mdname(mddev), behind_wait); + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout(HZ); /* wait a second */ + /* need to kick something here to make sure I/O goes? */ + } md_unregister_thread(mddev->thread); mddev->thread = NULL; @@ -1561,6 +1703,35 @@ static int raid1_reshape(mddev_t *mddev, int raid_disks) return 0; } +static void raid1_quiesce(mddev_t *mddev, int state) +{ + conf_t *conf = mddev_to_conf(mddev); + + switch(state) { + case 1: + spin_lock_irq(&conf->resync_lock); + conf->barrier++; + wait_event_lock_irq(conf->wait_idle, !conf->nr_pending, + conf->resync_lock, raid1_unplug(mddev->queue)); + spin_unlock_irq(&conf->resync_lock); + break; + case 0: + spin_lock_irq(&conf->resync_lock); + conf->barrier--; + spin_unlock_irq(&conf->resync_lock); + wake_up(&conf->wait_resume); + wake_up(&conf->wait_idle); + break; + } + if (mddev->thread) { + if (mddev->bitmap) + mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ; + else + mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT; + md_wakeup_thread(mddev->thread); + } +} + static mdk_personality_t raid1_personality = { @@ -1577,6 +1748,7 @@ static mdk_personality_t raid1_personality = .sync_request = sync_request, .resize = raid1_resize, .reshape = raid1_reshape, + .quiesce = raid1_quiesce, }; static int __init raid_init(void) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 62ebb1bc72b..5bd1e9ec899 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -538,7 +538,8 @@ static int read_balance(conf_t *conf, r10bio_t *r10_bio) } - current_distance = abs(this_sector - conf->mirrors[disk].head_position); + current_distance = abs(r10_bio->devs[slot].addr - + conf->mirrors[disk].head_position); /* Find the disk whose head is closest */ @@ -668,6 +669,11 @@ static int make_request(request_queue_t *q, struct bio * bio) int i; int chunk_sects = conf->chunk_mask + 1; + if (unlikely(bio_barrier(bio))) { + bio_endio(bio, bio->bi_size, -EOPNOTSUPP); + return 0; + } + /* If this request crosses a chunk boundary, we need to * split it. This will only happen for 1 PAGE (or less) requests. */ @@ -900,6 +906,27 @@ static void close_sync(conf_t *conf) conf->r10buf_pool = NULL; } +/* check if there are enough drives for + * every block to appear on atleast one + */ +static int enough(conf_t *conf) +{ + int first = 0; + + do { + int n = conf->copies; + int cnt = 0; + while (n--) { + if (conf->mirrors[first].rdev) + cnt++; + first = (first+1) % conf->raid_disks; + } + if (cnt == 0) + return 0; + } while (first != 0); + return 1; +} + static int raid10_spare_active(mddev_t *mddev) { int i; @@ -938,6 +965,8 @@ static int raid10_add_disk(mddev_t *mddev, mdk_rdev_t *rdev) * very different from resync */ return 0; + if (!enough(conf)) + return 0; for (mirror=0; mirror < mddev->raid_disks; mirror++) if ( !(p=conf->mirrors+mirror)->rdev) { @@ -1445,7 +1474,13 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i } } if (j == conf->copies) { - BUG(); + /* Cannot recover, so abort the recovery */ + put_buf(r10_bio); + r10_bio = rb2; + if (!test_and_set_bit(MD_RECOVERY_ERR, &mddev->recovery)) + printk(KERN_INFO "raid10: %s: insufficient working devices for recovery.\n", + mdname(mddev)); + break; } } if (biolist == NULL) { @@ -1678,9 +1713,10 @@ static int run(mddev_t *mddev) init_waitqueue_head(&conf->wait_idle); init_waitqueue_head(&conf->wait_resume); - if (!conf->working_disks) { - printk(KERN_ERR "raid10: no operational mirrors for %s\n", - mdname(mddev)); + /* need to check that every block has at least one working mirror */ + if (!enough(conf)) { + printk(KERN_ERR "raid10: not enough operational mirrors for %s\n", + mdname(mddev)); goto out_free_conf; } diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 43f231a467d..4683ca24c04 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -24,6 +24,8 @@ #include <linux/bitops.h> #include <asm/atomic.h> +#include <linux/raid/bitmap.h> + /* * Stripe cache */ @@ -79,8 +81,13 @@ static inline void __release_stripe(raid5_conf_t *conf, struct stripe_head *sh) if (test_bit(STRIPE_HANDLE, &sh->state)) { if (test_bit(STRIPE_DELAYED, &sh->state)) list_add_tail(&sh->lru, &conf->delayed_list); - else + else if (test_bit(STRIPE_BIT_DELAY, &sh->state) && + conf->seq_write == sh->bm_seq) + list_add_tail(&sh->lru, &conf->bitmap_list); + else { + clear_bit(STRIPE_BIT_DELAY, &sh->state); list_add_tail(&sh->lru, &conf->handle_list); + } md_wakeup_thread(conf->mddev->thread); } else { if (test_and_clear_bit(STRIPE_PREREAD_ACTIVE, &sh->state)) { @@ -244,6 +251,9 @@ static struct stripe_head *get_active_stripe(raid5_conf_t *conf, sector_t sector spin_lock_irq(&conf->device_lock); do { + wait_event_lock_irq(conf->wait_for_stripe, + conf->quiesce == 0, + conf->device_lock, /* nothing */); sh = __find_stripe(conf, sector); if (!sh) { if (!conf->inactive_blocked) @@ -803,6 +813,7 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx, in { struct bio **bip; raid5_conf_t *conf = sh->raid_conf; + int firstwrite=0; PRINTK("adding bh b#%llu to stripe s#%llu\n", (unsigned long long)bi->bi_sector, @@ -811,9 +822,11 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx, in spin_lock(&sh->lock); spin_lock_irq(&conf->device_lock); - if (forwrite) + if (forwrite) { bip = &sh->dev[dd_idx].towrite; - else + if (*bip == NULL && sh->dev[dd_idx].written == NULL) + firstwrite = 1; + } else bip = &sh->dev[dd_idx].toread; while (*bip && (*bip)->bi_sector < bi->bi_sector) { if ((*bip)->bi_sector + ((*bip)->bi_size >> 9) > bi->bi_sector) @@ -836,6 +849,13 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx, in (unsigned long long)bi->bi_sector, (unsigned long long)sh->sector, dd_idx); + if (conf->mddev->bitmap && firstwrite) { + sh->bm_seq = conf->seq_write; + bitmap_startwrite(conf->mddev->bitmap, sh->sector, + STRIPE_SECTORS, 0); + set_bit(STRIPE_BIT_DELAY, &sh->state); + } + if (forwrite) { /* check if page is covered */ sector_t sector = sh->dev[dd_idx].sector; @@ -958,12 +978,13 @@ static void handle_stripe(struct stripe_head *sh) * need to be failed */ if (failed > 1 && to_read+to_write+written) { - spin_lock_irq(&conf->device_lock); for (i=disks; i--; ) { + int bitmap_end = 0; + spin_lock_irq(&conf->device_lock); /* fail all writes first */ bi = sh->dev[i].towrite; sh->dev[i].towrite = NULL; - if (bi) to_write--; + if (bi) { to_write--; bitmap_end = 1; } if (test_and_clear_bit(R5_Overlap, &sh->dev[i].flags)) wake_up(&conf->wait_for_overlap); @@ -981,6 +1002,7 @@ static void handle_stripe(struct stripe_head *sh) /* and fail all 'written' */ bi = sh->dev[i].written; sh->dev[i].written = NULL; + if (bi) bitmap_end = 1; while (bi && bi->bi_sector < sh->dev[i].sector + STRIPE_SECTORS) { struct bio *bi2 = r5_next_bio(bi, sh->dev[i].sector); clear_bit(BIO_UPTODATE, &bi->bi_flags); @@ -1009,8 +1031,11 @@ static void handle_stripe(struct stripe_head *sh) bi = nextbi; } } + spin_unlock_irq(&conf->device_lock); + if (bitmap_end) + bitmap_endwrite(conf->mddev->bitmap, sh->sector, + STRIPE_SECTORS, 0, 0); } - spin_unlock_irq(&conf->device_lock); } if (failed > 1 && syncing) { md_done_sync(conf->mddev, STRIPE_SECTORS,0); @@ -1038,6 +1063,7 @@ static void handle_stripe(struct stripe_head *sh) test_bit(R5_UPTODATE, &dev->flags) ) { /* We can return any write requests */ struct bio *wbi, *wbi2; + int bitmap_end = 0; PRINTK("Return write for disc %d\n", i); spin_lock_irq(&conf->device_lock); wbi = dev->written; @@ -1051,7 +1077,13 @@ static void handle_stripe(struct stripe_head *sh) } wbi = wbi2; } + if (dev->towrite == NULL) + bitmap_end = 1; spin_unlock_irq(&conf->device_lock); + if (bitmap_end) + bitmap_endwrite(conf->mddev->bitmap, sh->sector, + STRIPE_SECTORS, + !test_bit(STRIPE_DEGRADED, &sh->state), 0); } } } @@ -1175,7 +1207,8 @@ static void handle_stripe(struct stripe_head *sh) } } /* now if nothing is locked, and if we have enough data, we can start a write request */ - if (locked == 0 && (rcw == 0 ||rmw == 0)) { + if (locked == 0 && (rcw == 0 ||rmw == 0) && + !test_bit(STRIPE_BIT_DELAY, &sh->state)) { PRINTK("Computing parity...\n"); compute_parity(sh, rcw==0 ? RECONSTRUCT_WRITE : READ_MODIFY_WRITE); /* now every locked buffer is ready to be written */ @@ -1231,6 +1264,7 @@ static void handle_stripe(struct stripe_head *sh) dev = &sh->dev[failed_num]; set_bit(R5_LOCKED, &dev->flags); set_bit(R5_Wantwrite, &dev->flags); + clear_bit(STRIPE_DEGRADED, &sh->state); locked++; set_bit(STRIPE_INSYNC, &sh->state); set_bit(R5_Syncio, &dev->flags); @@ -1298,6 +1332,8 @@ static void handle_stripe(struct stripe_head *sh) bi->bi_next = NULL; generic_make_request(bi); } else { + if (rw == 1) + set_bit(STRIPE_DEGRADED, &sh->state); PRINTK("skip op %ld on disc %d for sector %llu\n", bi->bi_rw, i, (unsigned long long)sh->sector); clear_bit(R5_LOCKED, &sh->dev[i].flags); @@ -1322,6 +1358,20 @@ static inline void raid5_activate_delayed(raid5_conf_t *conf) } } +static inline void activate_bit_delay(raid5_conf_t *conf) +{ + /* device_lock is held */ + struct list_head head; + list_add(&head, &conf->bitmap_list); + list_del_init(&conf->bitmap_list); + while (!list_empty(&head)) { + struct stripe_head *sh = list_entry(head.next, struct stripe_head, lru); + list_del_init(&sh->lru); + atomic_inc(&sh->count); + __release_stripe(conf, sh); + } +} + static void unplug_slaves(mddev_t *mddev) { raid5_conf_t *conf = mddev_to_conf(mddev); @@ -1354,8 +1404,10 @@ static void raid5_unplug_device(request_queue_t *q) spin_lock_irqsave(&conf->device_lock, flags); - if (blk_remove_plug(q)) + if (blk_remove_plug(q)) { + conf->seq_flush++; raid5_activate_delayed(conf); + } md_wakeup_thread(mddev->thread); spin_unlock_irqrestore(&conf->device_lock, flags); @@ -1411,6 +1463,11 @@ static int make_request (request_queue_t *q, struct bio * bi) sector_t logical_sector, last_sector; struct stripe_head *sh; + if (unlikely(bio_barrier(bi))) { + bio_endio(bi, bi->bi_size, -EOPNOTSUPP); + return 0; + } + md_write_start(mddev, bi); if (bio_data_dir(bi)==WRITE) { @@ -1488,10 +1545,20 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i sector_t first_sector; int raid_disks = conf->raid_disks; int data_disks = raid_disks-1; + sector_t max_sector = mddev->size << 1; + int sync_blocks; - if (sector_nr >= mddev->size <<1) { + if (sector_nr >= max_sector) { /* just being told to finish up .. nothing much to do */ unplug_slaves(mddev); + + if (mddev->curr_resync < max_sector) /* aborted */ + bitmap_end_sync(mddev->bitmap, mddev->curr_resync, + &sync_blocks, 1); + else /* compelted sync */ + conf->fullsync = 0; + bitmap_close_sync(mddev->bitmap); + return 0; } /* if there is 1 or more failed drives and we are trying @@ -1503,6 +1570,13 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i *skipped = 1; return rv; } + if (!bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 1) && + !conf->fullsync && sync_blocks >= STRIPE_SECTORS) { + /* we can skip this block, and probably more */ + sync_blocks /= STRIPE_SECTORS; + *skipped = 1; + return sync_blocks * STRIPE_SECTORS; /* keep things rounded to whole stripes */ + } x = sector_nr; chunk_offset = sector_div(x, sectors_per_chunk); @@ -1520,6 +1594,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i set_current_state(TASK_UNINTERRUPTIBLE); schedule_timeout(1); } + bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 0); spin_lock(&sh->lock); set_bit(STRIPE_SYNCING, &sh->state); clear_bit(STRIPE_INSYNC, &sh->state); @@ -1553,6 +1628,13 @@ static void raid5d (mddev_t *mddev) while (1) { struct list_head *first; + if (conf->seq_flush - conf->seq_write > 0) { + int seq = conf->seq_flush; + bitmap_unplug(mddev->bitmap); + conf->seq_write = seq; + activate_bit_delay(conf); + } + if (list_empty(&conf->handle_list) && atomic_read(&conf->preread_active_stripes) < IO_THRESHOLD && !blk_queue_plugged(mddev->queue) && @@ -1586,7 +1668,7 @@ static void raid5d (mddev_t *mddev) PRINTK("--- raid5d inactive\n"); } -static int run (mddev_t *mddev) +static int run(mddev_t *mddev) { raid5_conf_t *conf; int raid_disk, memory; @@ -1616,6 +1698,7 @@ static int run (mddev_t *mddev) init_waitqueue_head(&conf->wait_for_overlap); INIT_LIST_HEAD(&conf->handle_list); INIT_LIST_HEAD(&conf->delayed_list); + INIT_LIST_HEAD(&conf->bitmap_list); INIT_LIST_HEAD(&conf->inactive_list); atomic_set(&conf->active_stripes, 0); atomic_set(&conf->preread_active_stripes, 0); @@ -1727,6 +1810,9 @@ memory = conf->max_nr_stripes * (sizeof(struct stripe_head) + /* Ok, everything is just fine now */ + if (mddev->bitmap) + mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ; + mddev->queue->unplug_fn = raid5_unplug_device; mddev->queue->issue_flush_fn = raid5_issue_flush; @@ -1907,6 +1993,8 @@ static int raid5_add_disk(mddev_t *mddev, mdk_rdev_t *rdev) rdev->in_sync = 0; rdev->raid_disk = disk; found = 1; + if (rdev->saved_raid_disk != disk) + conf->fullsync = 1; p->rdev = rdev; break; } @@ -1936,6 +2024,35 @@ static int raid5_resize(mddev_t *mddev, sector_t sectors) return 0; } +static void raid5_quiesce(mddev_t *mddev, int state) +{ + raid5_conf_t *conf = mddev_to_conf(mddev); + + switch(state) { + case 1: /* stop all writes */ + spin_lock_irq(&conf->device_lock); + conf->quiesce = 1; + wait_event_lock_irq(conf->wait_for_stripe, + atomic_read(&conf->active_stripes) == 0, + conf->device_lock, /* nothing */); + spin_unlock_irq(&conf->device_lock); + break; + + case 0: /* re-enable writes */ + spin_lock_irq(&conf->device_lock); + conf->quiesce = 0; + wake_up(&conf->wait_for_stripe); + spin_unlock_irq(&conf->device_lock); + break; + } + if (mddev->thread) { + if (mddev->bitmap) + mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ; + else + mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT; + md_wakeup_thread(mddev->thread); + } +} static mdk_personality_t raid5_personality= { .name = "raid5", @@ -1950,6 +2067,7 @@ static mdk_personality_t raid5_personality= .spare_active = raid5_spare_active, .sync_request = sync_request, .resize = raid5_resize, + .quiesce = raid5_quiesce, }; static int __init raid5_init (void) diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c index 495dee1d1e8..267eb1430c8 100644 --- a/drivers/md/raid6main.c +++ b/drivers/md/raid6main.c @@ -29,6 +29,8 @@ #include <asm/atomic.h> #include "raid6.h" +#include <linux/raid/bitmap.h> + /* * Stripe cache */ @@ -98,8 +100,13 @@ static inline void __release_stripe(raid6_conf_t *conf, struct stripe_head *sh) if (test_bit(STRIPE_HANDLE, &sh->state)) { if (test_bit(STRIPE_DELAYED, &sh->state)) list_add_tail(&sh->lru, &conf->delayed_list); - else + else if (test_bit(STRIPE_BIT_DELAY, &sh->state) && + conf->seq_write == sh->bm_seq) + list_add_tail(&sh->lru, &conf->bitmap_list); + else { + clear_bit(STRIPE_BIT_DELAY, &sh->state); list_add_tail(&sh->lru, &conf->handle_list); + } md_wakeup_thread(conf->mddev->thread); } else { if (test_and_clear_bit(STRIPE_PREREAD_ACTIVE, &sh->state)) { @@ -262,6 +269,9 @@ static struct stripe_head *get_active_stripe(raid6_conf_t *conf, sector_t sector spin_lock_irq(&conf->device_lock); do { + wait_event_lock_irq(conf->wait_for_stripe, + conf->quiesce == 0, + conf->device_lock, /* nothing */); sh = __find_stripe(conf, sector); if (!sh) { if (!conf->inactive_blocked) @@ -906,6 +916,7 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx, in { struct bio **bip; raid6_conf_t *conf = sh->raid_conf; + int firstwrite=0; PRINTK("adding bh b#%llu to stripe s#%llu\n", (unsigned long long)bi->bi_sector, @@ -914,9 +925,11 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx, in spin_lock(&sh->lock); spin_lock_irq(&conf->device_lock); - if (forwrite) + if (forwrite) { bip = &sh->dev[dd_idx].towrite; - else + if (*bip == NULL && sh->dev[dd_idx].written == NULL) + firstwrite = 1; + } else bip = &sh->dev[dd_idx].toread; while (*bip && (*bip)->bi_sector < bi->bi_sector) { if ((*bip)->bi_sector + ((*bip)->bi_size >> 9) > bi->bi_sector) @@ -939,6 +952,13 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx, in (unsigned long long)bi->bi_sector, (unsigned long long)sh->sector, dd_idx); + if (conf->mddev->bitmap && firstwrite) { + sh->bm_seq = conf->seq_write; + bitmap_startwrite(conf->mddev->bitmap, sh->sector, + STRIPE_SECTORS, 0); + set_bit(STRIPE_BIT_DELAY, &sh->state); + } + if (forwrite) { /* check if page is covered */ sector_t sector = sh->dev[dd_idx].sector; @@ -1066,12 +1086,13 @@ static void handle_stripe(struct stripe_head *sh) * need to be failed */ if (failed > 2 && to_read+to_write+written) { - spin_lock_irq(&conf->device_lock); for (i=disks; i--; ) { + int bitmap_end = 0; + spin_lock_irq(&conf->device_lock); /* fail all writes first */ bi = sh->dev[i].towrite; sh->dev[i].towrite = NULL; - if (bi) to_write--; + if (bi) { to_write--; bitmap_end = 1; } if (test_and_clear_bit(R5_Overlap, &sh->dev[i].flags)) wake_up(&conf->wait_for_overlap); @@ -1089,6 +1110,7 @@ static void handle_stripe(struct stripe_head *sh) /* and fail all 'written' */ bi = sh->dev[i].written; sh->dev[i].written = NULL; + if (bi) bitmap_end = 1; while (bi && bi->bi_sector < sh->dev[i].sector + STRIPE_SECTORS) { struct bio *bi2 = r5_next_bio(bi, sh->dev[i].sector); clear_bit(BIO_UPTODATE, &bi->bi_flags); @@ -1117,8 +1139,11 @@ static void handle_stripe(struct stripe_head *sh) bi = nextbi; } } + spin_unlock_irq(&conf->device_lock); + if (bitmap_end) + bitmap_endwrite(conf->mddev->bitmap, sh->sector, + STRIPE_SECTORS, 0, 0); } - spin_unlock_irq(&conf->device_lock); } if (failed > 2 && syncing) { md_done_sync(conf->mddev, STRIPE_SECTORS,0); @@ -1155,6 +1180,7 @@ static void handle_stripe(struct stripe_head *sh) if (!test_bit(R5_LOCKED, &dev->flags) && test_bit(R5_UPTODATE, &dev->flags) ) { /* We can return any write requests */ + int bitmap_end = 0; struct bio *wbi, *wbi2; PRINTK("Return write for stripe %llu disc %d\n", (unsigned long long)sh->sector, i); @@ -1170,7 +1196,13 @@ static void handle_stripe(struct stripe_head *sh) } wbi = wbi2; } + if (dev->towrite == NULL) + bitmap_end = 1; spin_unlock_irq(&conf->device_lock); + if (bitmap_end) + bitmap_endwrite(conf->mddev->bitmap, sh->sector, + STRIPE_SECTORS, + !test_bit(STRIPE_DEGRADED, &sh->state), 0); } } } @@ -1285,7 +1317,8 @@ static void handle_stripe(struct stripe_head *sh) } } /* now if nothing is locked, and if we have enough data, we can start a write request */ - if (locked == 0 && rcw == 0) { + if (locked == 0 && rcw == 0 && + !test_bit(STRIPE_BIT_DELAY, &sh->state)) { if ( must_compute > 0 ) { /* We have failed blocks and need to compute them */ switch ( failed ) { @@ -1388,6 +1421,7 @@ static void handle_stripe(struct stripe_head *sh) bdev = &sh->dev[failed_num[1]]; locked += !test_bit(R5_LOCKED, &bdev->flags); set_bit(R5_LOCKED, &bdev->flags); + clear_bit(STRIPE_DEGRADED, &sh->state); set_bit(R5_Wantwrite, &bdev->flags); set_bit(STRIPE_INSYNC, &sh->state); @@ -1457,6 +1491,8 @@ static void handle_stripe(struct stripe_head *sh) bi->bi_next = NULL; generic_make_request(bi); } else { + if (rw == 1) + set_bit(STRIPE_DEGRADED, &sh->state); PRINTK("skip op %ld on disc %d for sector %llu\n", bi->bi_rw, i, (unsigned long long)sh->sector); clear_bit(R5_LOCKED, &sh->dev[i].flags); @@ -1481,6 +1517,20 @@ static inline void raid6_activate_delayed(raid6_conf_t *conf) } } +static inline void activate_bit_delay(raid6_conf_t *conf) +{ + /* device_lock is held */ + struct list_head head; + list_add(&head, &conf->bitmap_list); + list_del_init(&conf->bitmap_list); + while (!list_empty(&head)) { + struct stripe_head *sh = list_entry(head.next, struct stripe_head, lru); + list_del_init(&sh->lru); + atomic_inc(&sh->count); + __release_stripe(conf, sh); + } +} + static void unplug_slaves(mddev_t *mddev) { raid6_conf_t *conf = mddev_to_conf(mddev); @@ -1513,8 +1563,10 @@ static void raid6_unplug_device(request_queue_t *q) spin_lock_irqsave(&conf->device_lock, flags); - if (blk_remove_plug(q)) + if (blk_remove_plug(q)) { + conf->seq_flush++; raid6_activate_delayed(conf); + } md_wakeup_thread(mddev->thread); spin_unlock_irqrestore(&conf->device_lock, flags); @@ -1570,6 +1622,11 @@ static int make_request (request_queue_t *q, struct bio * bi) sector_t logical_sector, last_sector; struct stripe_head *sh; + if (unlikely(bio_barrier(bi))) { + bio_endio(bi, bi->bi_size, -EOPNOTSUPP); + return 0; + } + md_write_start(mddev, bi); if (bio_data_dir(bi)==WRITE) { @@ -1647,10 +1704,20 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i sector_t first_sector; int raid_disks = conf->raid_disks; int data_disks = raid_disks - 2; + sector_t max_sector = mddev->size << 1; + int sync_blocks; - if (sector_nr >= mddev->size <<1) { + if (sector_nr >= max_sector) { /* just being told to finish up .. nothing much to do */ unplug_slaves(mddev); + + if (mddev->curr_resync < max_sector) /* aborted */ + bitmap_end_sync(mddev->bitmap, mddev->curr_resync, + &sync_blocks, 1); + else /* compelted sync */ + conf->fullsync = 0; + bitmap_close_sync(mddev->bitmap); + return 0; } /* if there are 2 or more failed drives and we are trying @@ -1662,6 +1729,13 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i *skipped = 1; return rv; } + if (!bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 1) && + !conf->fullsync && sync_blocks >= STRIPE_SECTORS) { + /* we can skip this block, and probably more */ + sync_blocks /= STRIPE_SECTORS; + *skipped = 1; + return sync_blocks * STRIPE_SECTORS; /* keep things rounded to whole stripes */ + } x = sector_nr; chunk_offset = sector_div(x, sectors_per_chunk); @@ -1679,6 +1753,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i set_current_state(TASK_UNINTERRUPTIBLE); schedule_timeout(1); } + bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 0); spin_lock(&sh->lock); set_bit(STRIPE_SYNCING, &sh->state); clear_bit(STRIPE_INSYNC, &sh->state); @@ -1712,6 +1787,13 @@ static void raid6d (mddev_t *mddev) while (1) { struct list_head *first; + if (conf->seq_flush - conf->seq_write > 0) { + int seq = conf->seq_flush; + bitmap_unplug(mddev->bitmap); + conf->seq_write = seq; + activate_bit_delay(conf); + } + if (list_empty(&conf->handle_list) && atomic_read(&conf->preread_active_stripes) < IO_THRESHOLD && !blk_queue_plugged(mddev->queue) && @@ -1745,7 +1827,7 @@ static void raid6d (mddev_t *mddev) PRINTK("--- raid6d inactive\n"); } -static int run (mddev_t *mddev) +static int run(mddev_t *mddev) { raid6_conf_t *conf; int raid_disk, memory; @@ -1775,6 +1857,7 @@ static int run (mddev_t *mddev) init_waitqueue_head(&conf->wait_for_overlap); INIT_LIST_HEAD(&conf->handle_list); INIT_LIST_HEAD(&conf->delayed_list); + INIT_LIST_HEAD(&conf->bitmap_list); INIT_LIST_HEAD(&conf->inactive_list); atomic_set(&conf->active_stripes, 0); atomic_set(&conf->preread_active_stripes, 0); @@ -1894,6 +1977,9 @@ static int run (mddev_t *mddev) /* Ok, everything is just fine now */ mddev->array_size = mddev->size * (mddev->raid_disks - 2); + if (mddev->bitmap) + mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ; + mddev->queue->unplug_fn = raid6_unplug_device; mddev->queue->issue_flush_fn = raid6_issue_flush; return 0; @@ -2071,6 +2157,8 @@ static int raid6_add_disk(mddev_t *mddev, mdk_rdev_t *rdev) rdev->in_sync = 0; rdev->raid_disk = disk; found = 1; + if (rdev->saved_raid_disk != disk) + conf->fullsync = 1; p->rdev = rdev; break; } @@ -2100,6 +2188,35 @@ static int raid6_resize(mddev_t *mddev, sector_t sectors) return 0; } +static void raid6_quiesce(mddev_t *mddev, int state) +{ + raid6_conf_t *conf = mddev_to_conf(mddev); + + switch(state) { + case 1: /* stop all writes */ + spin_lock_irq(&conf->device_lock); + conf->quiesce = 1; + wait_event_lock_irq(conf->wait_for_stripe, + atomic_read(&conf->active_stripes) == 0, + conf->device_lock, /* nothing */); + spin_unlock_irq(&conf->device_lock); + break; + + case 0: /* re-enable writes */ + spin_lock_irq(&conf->device_lock); + conf->quiesce = 0; + wake_up(&conf->wait_for_stripe); + spin_unlock_irq(&conf->device_lock); + break; + } + if (mddev->thread) { + if (mddev->bitmap) + mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ; + else + mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT; + md_wakeup_thread(mddev->thread); + } +} static mdk_personality_t raid6_personality= { .name = "raid6", @@ -2114,6 +2231,7 @@ static mdk_personality_t raid6_personality= .spare_active = raid6_spare_active, .sync_request = sync_request, .resize = raid6_resize, + .quiesce = raid6_quiesce, }; static int __init raid6_init (void) diff --git a/drivers/media/Makefile b/drivers/media/Makefile index 772d6112fb3..c578a529e7a 100644 --- a/drivers/media/Makefile +++ b/drivers/media/Makefile @@ -2,4 +2,7 @@ # Makefile for the kernel multimedia device drivers. # -obj-y := video/ radio/ dvb/ common/ +obj-y := common/ +obj-$(CONFIG_VIDEO_DEV) += video/ +obj-$(CONFIG_VIDEO_DEV) += radio/ +obj-$(CONFIG_DVB) += dvb/ diff --git a/drivers/media/common/ir-common.c b/drivers/media/common/ir-common.c index ab7a1fba442..a0e700d7a4a 100644 --- a/drivers/media/common/ir-common.c +++ b/drivers/media/common/ir-common.c @@ -1,5 +1,4 @@ /* - * $Id: ir-common.c,v 1.11 2005/07/07 14:44:43 mchehab Exp $ * * some common structs and functions to handle infrared remotes via * input layer ... @@ -335,6 +334,72 @@ int ir_dump_samples(u32 *samples, int count) return 0; } +/* decode raw samples, pulse distance coding used by NEC remotes */ +int ir_decode_pulsedistance(u32 *samples, int count, int low, int high) +{ + int i,last,bit,len; + u32 curBit; + u32 value; + + /* find start burst */ + for (i = len = 0; i < count * 32; i++) { + bit = getbit(samples,i); + if (bit) { + len++; + } else { + if (len >= 29) + break; + len = 0; + } + } + + /* start burst to short */ + if (len < 29) + return 0xffffffff; + + /* find start silence */ + for (len = 0; i < count * 32; i++) { + bit = getbit(samples,i); + if (bit) { + break; + } else { + len++; + } + } + + /* silence to short */ + if (len < 7) + return 0xffffffff; + + /* go decoding */ + len = 0; + last = 1; + value = 0; curBit = 1; + for (; i < count * 32; i++) { + bit = getbit(samples,i); + if (last) { + if(bit) { + continue; + } else { + len = 1; + } + } else { + if (bit) { + if (len > (low + high) /2) + value |= curBit; + curBit <<= 1; + if (curBit == 1) + break; + } else { + len++; + } + } + last = bit; + } + + return value; +} + /* decode raw samples, biphase coding, used by rc5 for example */ int ir_decode_biphase(u32 *samples, int count, int low, int high) { @@ -383,6 +448,7 @@ EXPORT_SYMBOL_GPL(ir_input_keydown); EXPORT_SYMBOL_GPL(ir_extract_bits); EXPORT_SYMBOL_GPL(ir_dump_samples); EXPORT_SYMBOL_GPL(ir_decode_biphase); +EXPORT_SYMBOL_GPL(ir_decode_pulsedistance); /* * Local variables: diff --git a/drivers/media/common/saa7146_core.c b/drivers/media/common/saa7146_core.c index cd5828b5e9e..206cc2f61f2 100644 --- a/drivers/media/common/saa7146_core.c +++ b/drivers/media/common/saa7146_core.c @@ -168,10 +168,8 @@ void saa7146_pgtable_free(struct pci_dev *pci, struct saa7146_pgtable *pt) return; pci_free_consistent(pci, pt->size, pt->cpu, pt->dma); pt->cpu = NULL; - if (NULL != pt->slist) { - kfree(pt->slist); - pt->slist = NULL; - } + kfree(pt->slist); + pt->slist = NULL; } int saa7146_pgtable_alloc(struct pci_dev *pci, struct saa7146_pgtable *pt) diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c index c04fd11526e..37888989ea2 100644 --- a/drivers/media/common/saa7146_fops.c +++ b/drivers/media/common/saa7146_fops.c @@ -1,5 +1,4 @@ #include <media/saa7146_vv.h> -#include <linux/version.h> #define BOARD_CAN_DO_VBI(dev) (dev->revision != 0 && dev->vv_data->vbi_minor != -1) diff --git a/drivers/media/common/saa7146_i2c.c b/drivers/media/common/saa7146_i2c.c index 6284894505c..fec6beab8c2 100644 --- a/drivers/media/common/saa7146_i2c.c +++ b/drivers/media/common/saa7146_i2c.c @@ -1,4 +1,3 @@ -#include <linux/version.h> #include <media/saa7146_vv.h> static u32 saa7146_i2c_func(struct i2c_adapter *adapter) @@ -402,12 +401,9 @@ int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c saa7146_i2c_reset(dev); if( NULL != i2c_adapter ) { -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) - i2c_adapter->data = dev; -#else BUG_ON(!i2c_adapter->class); i2c_set_adapdata(i2c_adapter,dev); -#endif + i2c_adapter->dev.parent = &dev->pci->dev; i2c_adapter->algo = &saa7146_algo; i2c_adapter->algo_data = NULL; i2c_adapter->id = I2C_HW_SAA7146; diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c index 0410cc96a48..47e28b0ee95 100644 --- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c +++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c @@ -164,12 +164,11 @@ static int samsung_tbmu24112_set_symbol_rate(struct dvb_frontend* fe, u32 srate, return 0; } -static int samsung_tbmu24112_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) +static int samsung_tbmu24112_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params) { u8 buf[4]; u32 div; struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) }; - struct flexcop_device *fc = fe->dvb->priv; div = params->frequency / 125; @@ -180,7 +179,7 @@ static int samsung_tbmu24112_pll_set(struct dvb_frontend* fe, struct dvb_fronten if (params->frequency < 1500000) buf[3] |= 0x10; - if (i2c_transfer(&fc->i2c_adap, &msg, 1) != 1) + if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; return 0; } @@ -335,8 +334,103 @@ static struct mt312_config skystar23_samsung_tbdu18132_config = { .pll_set = skystar23_samsung_tbdu18132_pll_set, }; + +static u8 alps_tdee4_stv0297_inittab[] = { + 0x80, 0x01, + 0x80, 0x00, + 0x81, 0x01, + 0x81, 0x00, + 0x00, 0x09, + 0x01, 0x69, + 0x03, 0x00, + 0x04, 0x00, + 0x07, 0x00, + 0x08, 0x00, + 0x20, 0x00, + 0x21, 0x40, + 0x22, 0x00, + 0x23, 0x00, + 0x24, 0x40, + 0x25, 0x88, + 0x30, 0xff, + 0x31, 0x00, + 0x32, 0xff, + 0x33, 0x00, + 0x34, 0x50, + 0x35, 0x7f, + 0x36, 0x00, + 0x37, 0x20, + 0x38, 0x00, + 0x40, 0x1c, + 0x41, 0xff, + 0x42, 0x29, + 0x43, 0x00, + 0x44, 0xff, + 0x45, 0x00, + 0x46, 0x00, + 0x49, 0x04, + 0x4a, 0x00, + 0x4b, 0xf8, + 0x52, 0x30, + 0x55, 0xae, + 0x56, 0x47, + 0x57, 0xe1, + 0x58, 0x3a, + 0x5a, 0x1e, + 0x5b, 0x34, + 0x60, 0x00, + 0x63, 0x00, + 0x64, 0x00, + 0x65, 0x00, + 0x66, 0x00, + 0x67, 0x00, + 0x68, 0x00, + 0x69, 0x00, + 0x6a, 0x02, + 0x6b, 0x00, + 0x70, 0xff, + 0x71, 0x00, + 0x72, 0x00, + 0x73, 0x00, + 0x74, 0x0c, + 0x80, 0x00, + 0x81, 0x00, + 0x82, 0x00, + 0x83, 0x00, + 0x84, 0x04, + 0x85, 0x80, + 0x86, 0x24, + 0x87, 0x78, + 0x88, 0x10, + 0x89, 0x00, + 0x90, 0x01, + 0x91, 0x01, + 0xa0, 0x04, + 0xa1, 0x00, + 0xa2, 0x00, + 0xb0, 0x91, + 0xb1, 0x0b, + 0xc0, 0x53, + 0xc1, 0x70, + 0xc2, 0x12, + 0xd0, 0x00, + 0xd1, 0x00, + 0xd2, 0x00, + 0xd3, 0x00, + 0xd4, 0x00, + 0xd5, 0x00, + 0xde, 0x00, + 0xdf, 0x00, + 0x61, 0x49, + 0x62, 0x0b, + 0x53, 0x08, + 0x59, 0x08, + 0xff, 0xff, +}; + static struct stv0297_config alps_tdee4_stv0297_config = { .demod_address = 0x1c, + .inittab = alps_tdee4_stv0297_inittab, // .invert = 1, // .pll_set = alps_tdee4_stv0297_pll_set, }; @@ -370,7 +464,7 @@ int flexcop_frontend_init(struct flexcop_device *fc) info("found the bcm3510 at i2c address: 0x%02x",air2pc_atsc_first_gen_config.demod_address); } else /* try the cable dvb (stv0297) */ - if ((fc->fe = stv0297_attach(&alps_tdee4_stv0297_config, &fc->i2c_adap, 0xf8)) != NULL) { + if ((fc->fe = stv0297_attach(&alps_tdee4_stv0297_config, &fc->i2c_adap)) != NULL) { fc->dev_type = FC_CABLE; info("found the stv0297 at i2c address: 0x%02x",alps_tdee4_stv0297_config.demod_address); } else diff --git a/drivers/media/dvb/bt8xx/bt878.c b/drivers/media/dvb/bt8xx/bt878.c index 3c5a8e273c4..f2957145003 100644 --- a/drivers/media/dvb/bt8xx/bt878.c +++ b/drivers/media/dvb/bt8xx/bt878.c @@ -1,7 +1,7 @@ /* * bt878.c: part of the driver for the Pinnacle PCTV Sat DVB PCI card * - * Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@t-online.de> + * Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@htp-tel.de> * * large parts based on the bttv driver * Copyright (C) 1996,97,98 Ralph Metzler (rjkm@metzlerbros.de) @@ -219,7 +219,7 @@ void bt878_start(struct bt878 *bt, u32 controlreg, u32 op_sync_orin, controlreg &= ~0x1f; controlreg |= 0x1b; - btwrite(cpu_to_le32(bt->risc_dma), BT878_ARISC_START); + btwrite(bt->risc_dma, BT878_ARISC_START); /* original int mask had : * 6 2 8 4 0 diff --git a/drivers/media/dvb/bt8xx/bt878.h b/drivers/media/dvb/bt8xx/bt878.h index 837623f7fcd..a73baf00ca3 100644 --- a/drivers/media/dvb/bt8xx/bt878.h +++ b/drivers/media/dvb/bt8xx/bt878.h @@ -1,7 +1,7 @@ /* bt878.h - Bt878 audio module (register offsets) - Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@t-online.de> + Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@htp-tel.de> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c index 07a0b0a968a..34a837a1abf 100644 --- a/drivers/media/dvb/bt8xx/dst.c +++ b/drivers/media/dvb/bt8xx/dst.c @@ -1,5 +1,4 @@ /* - Frontend/Card driver for TwinHan DST Frontend Copyright (C) 2003 Jamie Honan Copyright (C) 2004, 2005 Manu Abraham (manu@kromtek.com) @@ -19,7 +18,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include <linux/kernel.h> #include <linux/module.h> #include <linux/init.h> @@ -28,31 +26,45 @@ #include <linux/vmalloc.h> #include <linux/delay.h> #include <asm/div64.h> - #include "dvb_frontend.h" #include "dst_priv.h" #include "dst_common.h" - static unsigned int verbose = 1; module_param(verbose, int, 0644); MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)"); -static unsigned int debug = 1; -module_param(debug, int, 0644); -MODULE_PARM_DESC(debug, "debug messages, default is 0 (yes)"); - static unsigned int dst_addons; module_param(dst_addons, int, 0644); MODULE_PARM_DESC(dst_addons, "CA daughterboard, default is 0 (No addons)"); -#define dprintk if (debug) printk - -#define HAS_LOCK 1 -#define ATTEMPT_TUNE 2 -#define HAS_POWER 4 - -static void dst_packsize(struct dst_state* state, int psize) +#define HAS_LOCK 1 +#define ATTEMPT_TUNE 2 +#define HAS_POWER 4 + +#define DST_ERROR 0 +#define DST_NOTICE 1 +#define DST_INFO 2 +#define DST_DEBUG 3 + +#define dprintk(x, y, z, format, arg...) do { \ + if (z) { \ + if ((x > DST_ERROR) && (x > y)) \ + printk(KERN_ERR "%s: " format "\n", __FUNCTION__ , ##arg); \ + else if ((x > DST_NOTICE) && (x > y)) \ + printk(KERN_NOTICE "%s: " format "\n", __FUNCTION__ , ##arg); \ + else if ((x > DST_INFO) && (x > y)) \ + printk(KERN_INFO "%s: " format "\n", __FUNCTION__ , ##arg); \ + else if ((x > DST_DEBUG) && (x > y)) \ + printk(KERN_DEBUG "%s: " format "\n", __FUNCTION__ , ##arg); \ + } else { \ + if (x > y) \ + printk(format, ##arg); \ + } \ +} while(0) + + +static void dst_packsize(struct dst_state *state, int psize) { union dst_gpio_packet bits; @@ -60,7 +72,7 @@ static void dst_packsize(struct dst_state* state, int psize) bt878_device_control(state->bt, DST_IG_TS, &bits); } -int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhigh, int delay) +int dst_gpio_outb(struct dst_state *state, u32 mask, u32 enbb, u32 outhigh, int delay) { union dst_gpio_packet enb; union dst_gpio_packet bits; @@ -68,63 +80,55 @@ int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhigh, int enb.enb.mask = mask; enb.enb.enable = enbb; - if (verbose > 4) - dprintk("%s: mask=[%04x], enbb=[%04x], outhigh=[%04x]\n", __FUNCTION__, mask, enbb, outhigh); + dprintk(verbose, DST_INFO, 1, "mask=[%04x], enbb=[%04x], outhigh=[%04x]", mask, enbb, outhigh); if ((err = bt878_device_control(state->bt, DST_IG_ENABLE, &enb)) < 0) { - dprintk("%s: dst_gpio_enb error (err == %i, mask == %02x, enb == %02x)\n", __FUNCTION__, err, mask, enbb); + dprintk(verbose, DST_INFO, 1, "dst_gpio_enb error (err == %i, mask == %02x, enb == %02x)", err, mask, enbb); return -EREMOTEIO; } udelay(1000); /* because complete disabling means no output, no need to do output packet */ if (enbb == 0) return 0; - if (delay) msleep(10); - bits.outp.mask = enbb; bits.outp.highvals = outhigh; - if ((err = bt878_device_control(state->bt, DST_IG_WRITE, &bits)) < 0) { - dprintk("%s: dst_gpio_outb error (err == %i, enbb == %02x, outhigh == %02x)\n", __FUNCTION__, err, enbb, outhigh); + dprintk(verbose, DST_INFO, 1, "dst_gpio_outb error (err == %i, enbb == %02x, outhigh == %02x)", err, enbb, outhigh); return -EREMOTEIO; } + return 0; } EXPORT_SYMBOL(dst_gpio_outb); -int dst_gpio_inb(struct dst_state *state, u8 * result) +int dst_gpio_inb(struct dst_state *state, u8 *result) { union dst_gpio_packet rd_packet; int err; *result = 0; - if ((err = bt878_device_control(state->bt, DST_IG_READ, &rd_packet)) < 0) { - dprintk("%s: dst_gpio_inb error (err == %i)\n", __FUNCTION__, err); + dprintk(verbose, DST_ERROR, 1, "dst_gpio_inb error (err == %i)\n", err); return -EREMOTEIO; } - *result = (u8) rd_packet.rd.value; + return 0; } EXPORT_SYMBOL(dst_gpio_inb); int rdc_reset_state(struct dst_state *state) { - if (verbose > 1) - dprintk("%s: Resetting state machine\n", __FUNCTION__); - + dprintk(verbose, DST_INFO, 1, "Resetting state machine"); if (dst_gpio_outb(state, RDC_8820_INT, RDC_8820_INT, 0, NO_DELAY) < 0) { - dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); return -1; } - msleep(10); - if (dst_gpio_outb(state, RDC_8820_INT, RDC_8820_INT, RDC_8820_INT, NO_DELAY) < 0) { - dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); msleep(10); return -1; } @@ -135,16 +139,14 @@ EXPORT_SYMBOL(rdc_reset_state); int rdc_8820_reset(struct dst_state *state) { - if (verbose > 1) - dprintk("%s: Resetting DST\n", __FUNCTION__); - + dprintk(verbose, DST_DEBUG, 1, "Resetting DST"); if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, 0, NO_DELAY) < 0) { - dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); return -1; } udelay(1000); if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, RDC_8820_RESET, DELAY) < 0) { - dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); return -1; } @@ -155,10 +157,11 @@ EXPORT_SYMBOL(rdc_8820_reset); int dst_pio_enable(struct dst_state *state) { if (dst_gpio_outb(state, ~0, RDC_8820_PIO_0_ENABLE, 0, NO_DELAY) < 0) { - dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); return -1; } udelay(1000); + return 0; } EXPORT_SYMBOL(dst_pio_enable); @@ -166,7 +169,7 @@ EXPORT_SYMBOL(dst_pio_enable); int dst_pio_disable(struct dst_state *state) { if (dst_gpio_outb(state, ~0, RDC_8820_PIO_0_DISABLE, RDC_8820_PIO_0_DISABLE, NO_DELAY) < 0) { - dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); return -1; } if (state->type_flags & DST_TYPE_HAS_FW_1) @@ -183,19 +186,16 @@ int dst_wait_dst_ready(struct dst_state *state, u8 delay_mode) for (i = 0; i < 200; i++) { if (dst_gpio_inb(state, &reply) < 0) { - dprintk("%s: dst_gpio_inb ERROR !\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "dst_gpio_inb ERROR !"); return -1; } - if ((reply & RDC_8820_PIO_0_ENABLE) == 0) { - if (verbose > 4) - dprintk("%s: dst wait ready after %d\n", __FUNCTION__, i); + dprintk(verbose, DST_INFO, 1, "dst wait ready after %d", i); return 1; } msleep(10); } - if (verbose > 1) - dprintk("%s: dst wait NOT ready after %d\n", __FUNCTION__, i); + dprintk(verbose, DST_NOTICE, 1, "dst wait NOT ready after %d", i); return 0; } @@ -203,7 +203,7 @@ EXPORT_SYMBOL(dst_wait_dst_ready); int dst_error_recovery(struct dst_state *state) { - dprintk("%s: Trying to return from previous errors...\n", __FUNCTION__); + dprintk(verbose, DST_NOTICE, 1, "Trying to return from previous errors."); dst_pio_disable(state); msleep(10); dst_pio_enable(state); @@ -215,7 +215,7 @@ EXPORT_SYMBOL(dst_error_recovery); int dst_error_bailout(struct dst_state *state) { - dprintk("%s: Trying to bailout from previous error...\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "Trying to bailout from previous error."); rdc_8820_reset(state); dst_pio_disable(state); msleep(10); @@ -224,17 +224,15 @@ int dst_error_bailout(struct dst_state *state) } EXPORT_SYMBOL(dst_error_bailout); - -int dst_comm_init(struct dst_state* state) +int dst_comm_init(struct dst_state *state) { - if (verbose > 1) - dprintk ("%s: Initializing DST..\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "Initializing DST."); if ((dst_pio_enable(state)) < 0) { - dprintk("%s: PIO Enable Failed.\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "PIO Enable Failed"); return -1; } if ((rdc_reset_state(state)) < 0) { - dprintk("%s: RDC 8820 State RESET Failed.\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "RDC 8820 State RESET Failed."); return -1; } if (state->type_flags & DST_TYPE_HAS_FW_1) @@ -246,36 +244,33 @@ int dst_comm_init(struct dst_state* state) } EXPORT_SYMBOL(dst_comm_init); - int write_dst(struct dst_state *state, u8 *data, u8 len) { struct i2c_msg msg = { - .addr = state->config->demod_address,.flags = 0,.buf = data,.len = len + .addr = state->config->demod_address, + .flags = 0, + .buf = data, + .len = len }; int err; - int cnt; - if (debug && (verbose > 4)) { - u8 i; - if (verbose > 4) { - dprintk("%s writing [ ", __FUNCTION__); - for (i = 0; i < len; i++) - dprintk("%02x ", data[i]); - dprintk("]\n"); - } - } + u8 cnt, i; + + dprintk(verbose, DST_NOTICE, 0, "writing [ "); + for (i = 0; i < len; i++) + dprintk(verbose, DST_NOTICE, 0, "%02x ", data[i]); + dprintk(verbose, DST_NOTICE, 0, "]\n"); + for (cnt = 0; cnt < 2; cnt++) { if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) { - dprintk("%s: _write_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)\n", __FUNCTION__, err, len, data[0]); + dprintk(verbose, DST_INFO, 1, "_write_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)", err, len, data[0]); dst_error_recovery(state); continue; } else break; } - if (cnt >= 2) { - if (verbose > 1) - printk("%s: RDC 8820 RESET...\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "RDC 8820 RESET"); dst_error_bailout(state); return -1; @@ -285,36 +280,37 @@ int write_dst(struct dst_state *state, u8 *data, u8 len) } EXPORT_SYMBOL(write_dst); -int read_dst(struct dst_state *state, u8 * ret, u8 len) +int read_dst(struct dst_state *state, u8 *ret, u8 len) { - struct i2c_msg msg = {.addr = state->config->demod_address,.flags = I2C_M_RD,.buf = ret,.len = len }; + struct i2c_msg msg = { + .addr = state->config->demod_address, + .flags = I2C_M_RD, + .buf = ret, + .len = len + }; + int err; int cnt; for (cnt = 0; cnt < 2; cnt++) { if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) { - - dprintk("%s: read_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)\n", __FUNCTION__, err, len, ret[0]); + dprintk(verbose, DST_INFO, 1, "read_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)", err, len, ret[0]); dst_error_recovery(state); - continue; } else break; } if (cnt >= 2) { - if (verbose > 1) - printk("%s: RDC 8820 RESET...\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "RDC 8820 RESET"); dst_error_bailout(state); return -1; } - if (debug && (verbose > 4)) { - dprintk("%s reply is 0x%x\n", __FUNCTION__, ret[0]); - for (err = 1; err < len; err++) - dprintk(" 0x%x", ret[err]); - if (err > 1) - dprintk("\n"); - } + dprintk(verbose, DST_DEBUG, 1, "reply is 0x%x", ret[0]); + for (err = 1; err < len; err++) + dprintk(verbose, DST_DEBUG, 0, " 0x%x", ret[err]); + if (err > 1) + dprintk(verbose, DST_DEBUG, 0, "\n"); return 0; } @@ -323,19 +319,16 @@ EXPORT_SYMBOL(read_dst); static int dst_set_polarization(struct dst_state *state) { switch (state->voltage) { - case SEC_VOLTAGE_13: // vertical - printk("%s: Polarization=[Vertical]\n", __FUNCTION__); - state->tx_tuna[8] &= ~0x40; //1 - break; - - case SEC_VOLTAGE_18: // horizontal - printk("%s: Polarization=[Horizontal]\n", __FUNCTION__); - state->tx_tuna[8] |= 0x40; // 0 - break; - - case SEC_VOLTAGE_OFF: - - break; + case SEC_VOLTAGE_13: /* Vertical */ + dprintk(verbose, DST_INFO, 1, "Polarization=[Vertical]"); + state->tx_tuna[8] &= ~0x40; + break; + case SEC_VOLTAGE_18: /* Horizontal */ + dprintk(verbose, DST_INFO, 1, "Polarization=[Horizontal]"); + state->tx_tuna[8] |= 0x40; + break; + case SEC_VOLTAGE_OFF: + break; } return 0; @@ -344,14 +337,12 @@ static int dst_set_polarization(struct dst_state *state) static int dst_set_freq(struct dst_state *state, u32 freq) { state->frequency = freq; - if (debug > 4) - dprintk("%s: set Frequency %u\n", __FUNCTION__, freq); + dprintk(verbose, DST_INFO, 1, "set Frequency %u", freq); if (state->dst_type == DST_TYPE_IS_SAT) { freq = freq / 1000; if (freq < 950 || freq > 2150) return -EINVAL; - state->tx_tuna[2] = (freq >> 8); state->tx_tuna[3] = (u8) freq; state->tx_tuna[4] = 0x01; @@ -360,27 +351,25 @@ static int dst_set_freq(struct dst_state *state, u32 freq) if (freq < 1531) state->tx_tuna[8] |= 0x04; } - } else if (state->dst_type == DST_TYPE_IS_TERR) { freq = freq / 1000; if (freq < 137000 || freq > 858000) return -EINVAL; - state->tx_tuna[2] = (freq >> 16) & 0xff; state->tx_tuna[3] = (freq >> 8) & 0xff; state->tx_tuna[4] = (u8) freq; - } else if (state->dst_type == DST_TYPE_IS_CABLE) { + freq = freq / 1000; state->tx_tuna[2] = (freq >> 16) & 0xff; state->tx_tuna[3] = (freq >> 8) & 0xff; state->tx_tuna[4] = (u8) freq; - } else return -EINVAL; + return 0; } -static int dst_set_bandwidth(struct dst_state* state, fe_bandwidth_t bandwidth) +static int dst_set_bandwidth(struct dst_state *state, fe_bandwidth_t bandwidth) { state->bandwidth = bandwidth; @@ -388,103 +377,95 @@ static int dst_set_bandwidth(struct dst_state* state, fe_bandwidth_t bandwidth) return 0; switch (bandwidth) { - case BANDWIDTH_6_MHZ: - if (state->dst_hw_cap & DST_TYPE_HAS_CA) - state->tx_tuna[7] = 0x06; - else { - state->tx_tuna[6] = 0x06; - state->tx_tuna[7] = 0x00; - } - break; - - case BANDWIDTH_7_MHZ: - if (state->dst_hw_cap & DST_TYPE_HAS_CA) - state->tx_tuna[7] = 0x07; - else { - state->tx_tuna[6] = 0x07; - state->tx_tuna[7] = 0x00; - } - break; - - case BANDWIDTH_8_MHZ: - if (state->dst_hw_cap & DST_TYPE_HAS_CA) - state->tx_tuna[7] = 0x08; - else { - state->tx_tuna[6] = 0x08; - state->tx_tuna[7] = 0x00; - } - break; - - default: - return -EINVAL; + case BANDWIDTH_6_MHZ: + if (state->dst_hw_cap & DST_TYPE_HAS_CA) + state->tx_tuna[7] = 0x06; + else { + state->tx_tuna[6] = 0x06; + state->tx_tuna[7] = 0x00; + } + break; + case BANDWIDTH_7_MHZ: + if (state->dst_hw_cap & DST_TYPE_HAS_CA) + state->tx_tuna[7] = 0x07; + else { + state->tx_tuna[6] = 0x07; + state->tx_tuna[7] = 0x00; + } + break; + case BANDWIDTH_8_MHZ: + if (state->dst_hw_cap & DST_TYPE_HAS_CA) + state->tx_tuna[7] = 0x08; + else { + state->tx_tuna[6] = 0x08; + state->tx_tuna[7] = 0x00; + } + break; + default: + return -EINVAL; } + return 0; } -static int dst_set_inversion(struct dst_state* state, fe_spectral_inversion_t inversion) +static int dst_set_inversion(struct dst_state *state, fe_spectral_inversion_t inversion) { state->inversion = inversion; switch (inversion) { - case INVERSION_OFF: // Inversion = Normal - state->tx_tuna[8] &= ~0x80; - break; - - case INVERSION_ON: - state->tx_tuna[8] |= 0x80; - break; - default: - return -EINVAL; + case INVERSION_OFF: /* Inversion = Normal */ + state->tx_tuna[8] &= ~0x80; + break; + case INVERSION_ON: + state->tx_tuna[8] |= 0x80; + break; + default: + return -EINVAL; } + return 0; } -static int dst_set_fec(struct dst_state* state, fe_code_rate_t fec) +static int dst_set_fec(struct dst_state *state, fe_code_rate_t fec) { state->fec = fec; return 0; } -static fe_code_rate_t dst_get_fec(struct dst_state* state) +static fe_code_rate_t dst_get_fec(struct dst_state *state) { return state->fec; } -static int dst_set_symbolrate(struct dst_state* state, u32 srate) +static int dst_set_symbolrate(struct dst_state *state, u32 srate) { - u8 *val; u32 symcalc; u64 sval; state->symbol_rate = srate; - if (state->dst_type == DST_TYPE_IS_TERR) { return 0; } - if (debug > 4) - dprintk("%s: set symrate %u\n", __FUNCTION__, srate); + dprintk(verbose, DST_INFO, 1, "set symrate %u", srate); srate /= 1000; - val = &state->tx_tuna[0]; - if (state->type_flags & DST_TYPE_HAS_SYMDIV) { sval = srate; sval <<= 20; do_div(sval, 88000); symcalc = (u32) sval; - - if (debug > 4) - dprintk("%s: set symcalc %u\n", __FUNCTION__, symcalc); - - val[5] = (u8) (symcalc >> 12); - val[6] = (u8) (symcalc >> 4); - val[7] = (u8) (symcalc << 4); + dprintk(verbose, DST_INFO, 1, "set symcalc %u", symcalc); + state->tx_tuna[5] = (u8) (symcalc >> 12); + state->tx_tuna[6] = (u8) (symcalc >> 4); + state->tx_tuna[7] = (u8) (symcalc << 4); } else { - val[5] = (u8) (srate >> 16) & 0x7f; - val[6] = (u8) (srate >> 8); - val[7] = (u8) srate; + state->tx_tuna[5] = (u8) (srate >> 16) & 0x7f; + state->tx_tuna[6] = (u8) (srate >> 8); + state->tx_tuna[7] = (u8) srate; + } + state->tx_tuna[8] &= ~0x20; + if (state->type_flags & DST_TYPE_HAS_OBS_REGS) { + if (srate > 8000) + state->tx_tuna[8] |= 0x20; } - val[8] &= ~0x20; - if (srate > 8000) - val[8] |= 0x20; return 0; } @@ -496,32 +477,27 @@ static int dst_set_modulation(struct dst_state *state, fe_modulation_t modulatio state->modulation = modulation; switch (modulation) { - case QAM_16: - state->tx_tuna[8] = 0x10; - break; - - case QAM_32: - state->tx_tuna[8] = 0x20; - break; - - case QAM_64: - state->tx_tuna[8] = 0x40; - break; - - case QAM_128: - state->tx_tuna[8] = 0x80; - break; - - case QAM_256: - state->tx_tuna[8] = 0x00; - break; - - case QPSK: - case QAM_AUTO: - case VSB_8: - case VSB_16: - default: - return -EINVAL; + case QAM_16: + state->tx_tuna[8] = 0x10; + break; + case QAM_32: + state->tx_tuna[8] = 0x20; + break; + case QAM_64: + state->tx_tuna[8] = 0x40; + break; + case QAM_128: + state->tx_tuna[8] = 0x80; + break; + case QAM_256: + state->tx_tuna[8] = 0x00; + break; + case QPSK: + case QAM_AUTO: + case VSB_8: + case VSB_16: + default: + return -EINVAL; } @@ -534,7 +510,7 @@ static fe_modulation_t dst_get_modulation(struct dst_state *state) } -u8 dst_check_sum(u8 * buf, u32 len) +u8 dst_check_sum(u8 *buf, u32 len) { u32 i; u8 val = 0; @@ -549,26 +525,24 @@ EXPORT_SYMBOL(dst_check_sum); static void dst_type_flags_print(u32 type_flags) { - printk("DST type flags :"); + dprintk(verbose, DST_ERROR, 0, "DST type flags :"); if (type_flags & DST_TYPE_HAS_NEWTUNE) - printk(" 0x%x newtuner", DST_TYPE_HAS_NEWTUNE); + dprintk(verbose, DST_ERROR, 0, " 0x%x newtuner", DST_TYPE_HAS_NEWTUNE); if (type_flags & DST_TYPE_HAS_TS204) - printk(" 0x%x ts204", DST_TYPE_HAS_TS204); + dprintk(verbose, DST_ERROR, 0, " 0x%x ts204", DST_TYPE_HAS_TS204); if (type_flags & DST_TYPE_HAS_SYMDIV) - printk(" 0x%x symdiv", DST_TYPE_HAS_SYMDIV); + dprintk(verbose, DST_ERROR, 0, " 0x%x symdiv", DST_TYPE_HAS_SYMDIV); if (type_flags & DST_TYPE_HAS_FW_1) - printk(" 0x%x firmware version = 1", DST_TYPE_HAS_FW_1); + dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 1", DST_TYPE_HAS_FW_1); if (type_flags & DST_TYPE_HAS_FW_2) - printk(" 0x%x firmware version = 2", DST_TYPE_HAS_FW_2); + dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 2", DST_TYPE_HAS_FW_2); if (type_flags & DST_TYPE_HAS_FW_3) - printk(" 0x%x firmware version = 3", DST_TYPE_HAS_FW_3); -// if ((type_flags & DST_TYPE_HAS_FW_BUILD) && new_fw) - - printk("\n"); + dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 3", DST_TYPE_HAS_FW_3); + dprintk(verbose, DST_ERROR, 0, "\n"); } -static int dst_type_print (u8 type) +static int dst_type_print(u8 type) { char *otype; switch (type) { @@ -585,10 +559,10 @@ static int dst_type_print (u8 type) break; default: - printk("%s: invalid dst type %d\n", __FUNCTION__, type); + dprintk(verbose, DST_INFO, 1, "invalid dst type %d", type); return -EINVAL; } - printk("DST type : %s\n", otype); + dprintk(verbose, DST_INFO, 1, "DST type: %s", otype); return 0; } @@ -700,7 +674,7 @@ struct dst_types dst_tlist[] = { .offset = 1, .dst_type = DST_TYPE_IS_CABLE, .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_1 - | DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_FW_BUILD, + | DST_TYPE_HAS_FW_2, .dst_feature = DST_TYPE_HAS_CA }, @@ -708,7 +682,7 @@ struct dst_types dst_tlist[] = { .device_id = "DCTNEW", .offset = 1, .dst_type = DST_TYPE_IS_CABLE, - .type_flags = DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_3, + .type_flags = DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_3 | DST_TYPE_HAS_FW_BUILD, .dst_feature = 0 }, @@ -716,7 +690,7 @@ struct dst_types dst_tlist[] = { .device_id = "DTT-CI", .offset = 1, .dst_type = DST_TYPE_IS_TERR, - .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_FW_BUILD, + .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_FW_2, .dst_feature = 0 }, @@ -756,6 +730,71 @@ struct dst_types dst_tlist[] = { }; +static int dst_get_mac(struct dst_state *state) +{ + u8 get_mac[] = { 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + get_mac[7] = dst_check_sum(get_mac, 7); + if (dst_command(state, get_mac, 8) < 0) { + dprintk(verbose, DST_INFO, 1, "Unsupported Command"); + return -1; + } + memset(&state->mac_address, '\0', 8); + memcpy(&state->mac_address, &state->rxbuffer, 6); + dprintk(verbose, DST_ERROR, 1, "MAC Address=[%02x:%02x:%02x:%02x:%02x:%02x]", + state->mac_address[0], state->mac_address[1], state->mac_address[2], + state->mac_address[4], state->mac_address[5], state->mac_address[6]); + + return 0; +} + +static int dst_fw_ver(struct dst_state *state) +{ + u8 get_ver[] = { 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + get_ver[7] = dst_check_sum(get_ver, 7); + if (dst_command(state, get_ver, 8) < 0) { + dprintk(verbose, DST_INFO, 1, "Unsupported Command"); + return -1; + } + memset(&state->fw_version, '\0', 8); + memcpy(&state->fw_version, &state->rxbuffer, 8); + dprintk(verbose, DST_ERROR, 1, "Firmware Ver = %x.%x Build = %02x, on %x:%x, %x-%x-20%02x", + state->fw_version[0] >> 4, state->fw_version[0] & 0x0f, + state->fw_version[1], + state->fw_version[5], state->fw_version[6], + state->fw_version[4], state->fw_version[3], state->fw_version[2]); + + return 0; +} + +static int dst_card_type(struct dst_state *state) +{ + u8 get_type[] = { 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + get_type[7] = dst_check_sum(get_type, 7); + if (dst_command(state, get_type, 8) < 0) { + dprintk(verbose, DST_INFO, 1, "Unsupported Command"); + return -1; + } + memset(&state->card_info, '\0', 8); + memcpy(&state->card_info, &state->rxbuffer, 8); + dprintk(verbose, DST_ERROR, 1, "Device Model=[%s]", &state->card_info[0]); + + return 0; +} + +static int dst_get_vendor(struct dst_state *state) +{ + u8 get_vendor[] = { 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + get_vendor[7] = dst_check_sum(get_vendor, 7); + if (dst_command(state, get_vendor, 8) < 0) { + dprintk(verbose, DST_INFO, 1, "Unsupported Command"); + return -1; + } + memset(&state->vendor, '\0', 8); + memcpy(&state->vendor, &state->rxbuffer, 8); + dprintk(verbose, DST_ERROR, 1, "Vendor=[%s]", &state->vendor[0]); + + return 0; +} static int dst_get_device_id(struct dst_state *state) { @@ -772,53 +811,45 @@ static int dst_get_device_id(struct dst_state *state) if (write_dst(state, device_type, FIXED_COMM)) return -1; /* Write failed */ - if ((dst_pio_disable(state)) < 0) return -1; - if (read_dst(state, &reply, GET_ACK)) return -1; /* Read failure */ - if (reply != ACK) { - dprintk("%s: Write not Acknowledged! [Reply=0x%02x]\n", __FUNCTION__, reply); + dprintk(verbose, DST_INFO, 1, "Write not Acknowledged! [Reply=0x%02x]", reply); return -1; /* Unack'd write */ } - if (!dst_wait_dst_ready(state, DEVICE_INIT)) return -1; /* DST not ready yet */ - if (read_dst(state, state->rxbuffer, FIXED_COMM)) return -1; dst_pio_disable(state); - if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) { - dprintk("%s: Checksum failure! \n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "Checksum failure!"); return -1; /* Checksum failure */ } - state->rxbuffer[7] = '\0'; - for (i = 0, p_dst_type = dst_tlist; i < ARRAY_SIZE (dst_tlist); i++, p_dst_type++) { + for (i = 0, p_dst_type = dst_tlist; i < ARRAY_SIZE(dst_tlist); i++, p_dst_type++) { if (!strncmp (&state->rxbuffer[p_dst_type->offset], p_dst_type->device_id, strlen (p_dst_type->device_id))) { use_type_flags = p_dst_type->type_flags; use_dst_type = p_dst_type->dst_type; /* Card capabilities */ state->dst_hw_cap = p_dst_type->dst_feature; - printk ("%s: Recognise [%s]\n", __FUNCTION__, p_dst_type->device_id); + dprintk(verbose, DST_ERROR, 1, "Recognise [%s]\n", p_dst_type->device_id); break; } } if (i >= sizeof (dst_tlist) / sizeof (dst_tlist [0])) { - printk("%s: Unable to recognize %s or %s\n", __FUNCTION__, &state->rxbuffer[0], &state->rxbuffer[1]); - printk("%s: please email linux-dvb@linuxtv.org with this type in\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "Unable to recognize %s or %s", &state->rxbuffer[0], &state->rxbuffer[1]); + dprintk(verbose, DST_ERROR, 1, "please email linux-dvb@linuxtv.org with this type in"); use_dst_type = DST_TYPE_IS_SAT; use_type_flags = DST_TYPE_HAS_SYMDIV; } - dst_type_print(use_dst_type); state->type_flags = use_type_flags; state->dst_type = use_dst_type; @@ -834,7 +865,7 @@ static int dst_get_device_id(struct dst_state *state) static int dst_probe(struct dst_state *state) { if ((rdc_8820_reset(state)) < 0) { - dprintk("%s: RDC 8820 RESET Failed.\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "RDC 8820 RESET Failed."); return -1; } if (dst_addons & DST_TYPE_HAS_CA) @@ -843,80 +874,87 @@ static int dst_probe(struct dst_state *state) msleep(100); if ((dst_comm_init(state)) < 0) { - dprintk("%s: DST Initialization Failed.\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "DST Initialization Failed."); return -1; } msleep(100); if (dst_get_device_id(state) < 0) { - dprintk("%s: unknown device.\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "unknown device."); return -1; } + if (dst_get_mac(state) < 0) { + dprintk(verbose, DST_INFO, 1, "MAC: Unsupported command"); + return 0; + } + if (state->type_flags & DST_TYPE_HAS_FW_BUILD) { + if (dst_fw_ver(state) < 0) { + dprintk(verbose, DST_INFO, 1, "FW: Unsupported command"); + return 0; + } + if (dst_card_type(state) < 0) { + dprintk(verbose, DST_INFO, 1, "Card: Unsupported command"); + return 0; + } + if (dst_get_vendor(state) < 0) { + dprintk(verbose, DST_INFO, 1, "Vendor: Unsupported command"); + return 0; + } + } return 0; } -int dst_command(struct dst_state* state, u8 * data, u8 len) +int dst_command(struct dst_state *state, u8 *data, u8 len) { u8 reply; if ((dst_comm_init(state)) < 0) { - dprintk("%s: DST Communication Initialization Failed.\n", __FUNCTION__); + dprintk(verbose, DST_NOTICE, 1, "DST Communication Initialization Failed."); return -1; } - if (write_dst(state, data, len)) { - if (verbose > 1) - dprintk("%s: Tring to recover.. \n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "Tring to recover.. "); if ((dst_error_recovery(state)) < 0) { - dprintk("%s: Recovery Failed.\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "Recovery Failed."); return -1; } return -1; } if ((dst_pio_disable(state)) < 0) { - dprintk("%s: PIO Disable Failed.\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "PIO Disable Failed."); return -1; } if (state->type_flags & DST_TYPE_HAS_FW_1) udelay(3000); - if (read_dst(state, &reply, GET_ACK)) { - if (verbose > 1) - dprintk("%s: Trying to recover.. \n", __FUNCTION__); + dprintk(verbose, DST_DEBUG, 1, "Trying to recover.. "); if ((dst_error_recovery(state)) < 0) { - dprintk("%s: Recovery Failed.\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "Recovery Failed."); return -1; } return -1; } - if (reply != ACK) { - dprintk("%s: write not acknowledged 0x%02x \n", __FUNCTION__, reply); + dprintk(verbose, DST_INFO, 1, "write not acknowledged 0x%02x ", reply); return -1; } if (len >= 2 && data[0] == 0 && (data[1] == 1 || data[1] == 3)) return 0; - -// udelay(3000); if (state->type_flags & DST_TYPE_HAS_FW_1) udelay(3000); else udelay(2000); - if (!dst_wait_dst_ready(state, NO_DELAY)) return -1; - if (read_dst(state, state->rxbuffer, FIXED_COMM)) { - if (verbose > 1) - dprintk("%s: Trying to recover.. \n", __FUNCTION__); + dprintk(verbose, DST_DEBUG, 1, "Trying to recover.. "); if ((dst_error_recovery(state)) < 0) { - dprintk("%s: Recovery failed.\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "Recovery failed."); return -1; } return -1; } - if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) { - dprintk("%s: checksum failure\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "checksum failure"); return -1; } @@ -924,11 +962,11 @@ int dst_command(struct dst_state* state, u8 * data, u8 len) } EXPORT_SYMBOL(dst_command); -static int dst_get_signal(struct dst_state* state) +static int dst_get_signal(struct dst_state *state) { int retval; u8 get_signal[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb }; - dprintk("%s: Getting Signal strength and other parameters\n", __FUNCTION__); + //dprintk("%s: Getting Signal strength and other parameters\n", __FUNCTION__); if ((state->diseq_flags & ATTEMPT_TUNE) == 0) { state->decode_lock = state->decode_strength = state->decode_snr = 0; return 0; @@ -955,13 +993,12 @@ static int dst_get_signal(struct dst_state* state) return 0; } -static int dst_tone_power_cmd(struct dst_state* state) +static int dst_tone_power_cmd(struct dst_state *state) { u8 paket[8] = { 0x00, 0x09, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00 }; if (state->dst_type == DST_TYPE_IS_TERR) return 0; - paket[4] = state->tx_tuna[4]; paket[2] = state->tx_tuna[2]; paket[3] = state->tx_tuna[3]; @@ -971,61 +1008,53 @@ static int dst_tone_power_cmd(struct dst_state* state) return 0; } -static int dst_get_tuna(struct dst_state* state) +static int dst_get_tuna(struct dst_state *state) { int retval; if ((state->diseq_flags & ATTEMPT_TUNE) == 0) return 0; - state->diseq_flags &= ~(HAS_LOCK); if (!dst_wait_dst_ready(state, NO_DELAY)) return 0; - - if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { + if (state->type_flags & DST_TYPE_HAS_NEWTUNE) /* how to get variable length reply ???? */ retval = read_dst(state, state->rx_tuna, 10); - } else { + else retval = read_dst(state, &state->rx_tuna[2], FIXED_COMM); - } - if (retval < 0) { - dprintk("%s: read not successful\n", __FUNCTION__); + dprintk(verbose, DST_DEBUG, 1, "read not successful"); return 0; } - if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[0], 9)) { - dprintk("%s: checksum failure?\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "checksum failure ? "); return 0; } } else { if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[2], 7)) { - dprintk("%s: checksum failure?\n", __FUNCTION__); + dprintk(verbose, DST_INFO, 1, "checksum failure? "); return 0; } } if (state->rx_tuna[2] == 0 && state->rx_tuna[3] == 0) return 0; state->decode_freq = ((state->rx_tuna[2] & 0x7f) << 8) + state->rx_tuna[3]; - state->decode_lock = 1; state->diseq_flags |= HAS_LOCK; return 1; } -static int dst_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage); +static int dst_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage); -static int dst_write_tuna(struct dvb_frontend* fe) +static int dst_write_tuna(struct dvb_frontend *fe) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; int retval; u8 reply; - if (debug > 4) - dprintk("%s: type_flags 0x%x \n", __FUNCTION__, state->type_flags); - + dprintk(verbose, DST_INFO, 1, "type_flags 0x%x ", state->type_flags); state->decode_freq = 0; state->decode_lock = state->decode_strength = state->decode_snr = 0; if (state->dst_type == DST_TYPE_IS_SAT) { @@ -1035,35 +1064,31 @@ static int dst_write_tuna(struct dvb_frontend* fe) state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE); if ((dst_comm_init(state)) < 0) { - dprintk("%s: DST Communication initialization failed.\n", __FUNCTION__); + dprintk(verbose, DST_DEBUG, 1, "DST Communication initialization failed."); return -1; } - if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[0], 9); retval = write_dst(state, &state->tx_tuna[0], 10); - } else { state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[2], 7); retval = write_dst(state, &state->tx_tuna[2], FIXED_COMM); } if (retval < 0) { dst_pio_disable(state); - dprintk("%s: write not successful\n", __FUNCTION__); + dprintk(verbose, DST_DEBUG, 1, "write not successful"); return retval; } - if ((dst_pio_disable(state)) < 0) { - dprintk("%s: DST PIO disable failed !\n", __FUNCTION__); + dprintk(verbose, DST_DEBUG, 1, "DST PIO disable failed !"); return -1; } - if ((read_dst(state, &reply, GET_ACK) < 0)) { - dprintk("%s: read verify not successful.\n", __FUNCTION__); + dprintk(verbose, DST_DEBUG, 1, "read verify not successful."); return -1; } if (reply != ACK) { - dprintk("%s: write not acknowledged 0x%02x \n", __FUNCTION__, reply); + dprintk(verbose, DST_DEBUG, 1, "write not acknowledged 0x%02x ", reply); return 0; } state->diseq_flags |= ATTEMPT_TUNE; @@ -1085,14 +1110,13 @@ static int dst_write_tuna(struct dvb_frontend* fe) * Diseqc 4 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xfc, 0xe0 */ -static int dst_set_diseqc(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd) +static int dst_set_diseqc(struct dvb_frontend *fe, struct dvb_diseqc_master_cmd *cmd) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; u8 paket[8] = { 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf0, 0xec }; if (state->dst_type != DST_TYPE_IS_SAT) return 0; - if (cmd->msg_len == 0 || cmd->msg_len > 4) return -EINVAL; memcpy(&paket[3], cmd->msg, cmd->msg_len); @@ -1101,65 +1125,61 @@ static int dst_set_diseqc(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* return 0; } -static int dst_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) +static int dst_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) { int need_cmd; - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; state->voltage = voltage; - if (state->dst_type != DST_TYPE_IS_SAT) return 0; need_cmd = 0; - switch (voltage) { - case SEC_VOLTAGE_13: - case SEC_VOLTAGE_18: - if ((state->diseq_flags & HAS_POWER) == 0) - need_cmd = 1; - state->diseq_flags |= HAS_POWER; - state->tx_tuna[4] = 0x01; - break; - case SEC_VOLTAGE_OFF: + switch (voltage) { + case SEC_VOLTAGE_13: + case SEC_VOLTAGE_18: + if ((state->diseq_flags & HAS_POWER) == 0) need_cmd = 1; - state->diseq_flags &= ~(HAS_POWER | HAS_LOCK | ATTEMPT_TUNE); - state->tx_tuna[4] = 0x00; - break; - - default: - return -EINVAL; + state->diseq_flags |= HAS_POWER; + state->tx_tuna[4] = 0x01; + break; + case SEC_VOLTAGE_OFF: + need_cmd = 1; + state->diseq_flags &= ~(HAS_POWER | HAS_LOCK | ATTEMPT_TUNE); + state->tx_tuna[4] = 0x00; + break; + default: + return -EINVAL; } + if (need_cmd) dst_tone_power_cmd(state); return 0; } -static int dst_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) +static int dst_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; state->tone = tone; - if (state->dst_type != DST_TYPE_IS_SAT) return 0; switch (tone) { - case SEC_TONE_OFF: - if (state->type_flags & DST_TYPE_HAS_OBS_REGS) - state->tx_tuna[2] = 0x00; - else - state->tx_tuna[2] = 0xff; - - break; - - case SEC_TONE_ON: - state->tx_tuna[2] = 0x02; - break; + case SEC_TONE_OFF: + if (state->type_flags & DST_TYPE_HAS_OBS_REGS) + state->tx_tuna[2] = 0x00; + else + state->tx_tuna[2] = 0xff; + break; - default: - return -EINVAL; + case SEC_TONE_ON: + state->tx_tuna[2] = 0x02; + break; + default: + return -EINVAL; } dst_tone_power_cmd(state); @@ -1172,16 +1192,14 @@ static int dst_send_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t minicmd) if (state->dst_type != DST_TYPE_IS_SAT) return 0; - state->minicmd = minicmd; - switch (minicmd) { - case SEC_MINI_A: - state->tx_tuna[3] = 0x02; - break; - case SEC_MINI_B: - state->tx_tuna[3] = 0xff; - break; + case SEC_MINI_A: + state->tx_tuna[3] = 0x02; + break; + case SEC_MINI_B: + state->tx_tuna[3] = 0xff; + break; } dst_tone_power_cmd(state); @@ -1189,42 +1207,37 @@ static int dst_send_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t minicmd) } -static int dst_init(struct dvb_frontend* fe) +static int dst_init(struct dvb_frontend *fe) { - struct dst_state* state = fe->demodulator_priv; - static u8 ini_satci_tuna[] = { 9, 0, 3, 0xb6, 1, 0, 0x73, 0x21, 0, 0 }; - static u8 ini_satfta_tuna[] = { 0, 0, 3, 0xb6, 1, 0x55, 0xbd, 0x50, 0, 0 }; - static u8 ini_tvfta_tuna[] = { 0, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; - static u8 ini_tvci_tuna[] = { 9, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; - static u8 ini_cabfta_tuna[] = { 0, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; - static u8 ini_cabci_tuna[] = { 9, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; -// state->inversion = INVERSION_ON; + struct dst_state *state = fe->demodulator_priv; + + static u8 sat_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x00, 0x73, 0x21, 0x00, 0x00 }; + static u8 sat_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x55, 0xbd, 0x50, 0x00, 0x00 }; + static u8 ter_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 }; + static u8 ter_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 }; + static u8 cab_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 }; + static u8 cab_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 }; + state->inversion = INVERSION_OFF; state->voltage = SEC_VOLTAGE_13; state->tone = SEC_TONE_OFF; - state->symbol_rate = 29473000; - state->fec = FEC_AUTO; state->diseq_flags = 0; state->k22 = 0x02; state->bandwidth = BANDWIDTH_7_MHZ; state->cur_jiff = jiffies; - if (state->dst_type == DST_TYPE_IS_SAT) { - state->frequency = 950000; - memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ini_satci_tuna : ini_satfta_tuna), sizeof(ini_satfta_tuna)); - } else if (state->dst_type == DST_TYPE_IS_TERR) { - state->frequency = 137000000; - memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ini_tvci_tuna : ini_tvfta_tuna), sizeof(ini_tvfta_tuna)); - } else if (state->dst_type == DST_TYPE_IS_CABLE) { - state->frequency = 51000000; - memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ini_cabci_tuna : ini_cabfta_tuna), sizeof(ini_cabfta_tuna)); - } + if (state->dst_type == DST_TYPE_IS_SAT) + memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? sat_tuna_188 : sat_tuna_204), sizeof (sat_tuna_204)); + else if (state->dst_type == DST_TYPE_IS_TERR) + memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ter_tuna_188 : ter_tuna_204), sizeof (ter_tuna_204)); + else if (state->dst_type == DST_TYPE_IS_CABLE) + memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? cab_tuna_188 : cab_tuna_204), sizeof (cab_tuna_204)); return 0; } -static int dst_read_status(struct dvb_frontend* fe, fe_status_t* status) +static int dst_read_status(struct dvb_frontend *fe, fe_status_t *status) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; *status = 0; if (state->diseq_flags & HAS_LOCK) { @@ -1236,9 +1249,9 @@ static int dst_read_status(struct dvb_frontend* fe, fe_status_t* status) return 0; } -static int dst_read_signal_strength(struct dvb_frontend* fe, u16* strength) +static int dst_read_signal_strength(struct dvb_frontend *fe, u16 *strength) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; dst_get_signal(state); *strength = state->decode_strength; @@ -1246,9 +1259,9 @@ static int dst_read_signal_strength(struct dvb_frontend* fe, u16* strength) return 0; } -static int dst_read_snr(struct dvb_frontend* fe, u16* snr) +static int dst_read_snr(struct dvb_frontend *fe, u16 *snr) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; dst_get_signal(state); *snr = state->decode_snr; @@ -1256,28 +1269,24 @@ static int dst_read_snr(struct dvb_frontend* fe, u16* snr) return 0; } -static int dst_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) +static int dst_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; dst_set_freq(state, p->frequency); - if (verbose > 4) - dprintk("Set Frequency=[%d]\n", p->frequency); + dprintk(verbose, DST_DEBUG, 1, "Set Frequency=[%d]", p->frequency); -// dst_set_inversion(state, p->inversion); if (state->dst_type == DST_TYPE_IS_SAT) { if (state->type_flags & DST_TYPE_HAS_OBS_REGS) dst_set_inversion(state, p->inversion); - dst_set_fec(state, p->u.qpsk.fec_inner); dst_set_symbolrate(state, p->u.qpsk.symbol_rate); dst_set_polarization(state); - if (verbose > 4) - dprintk("Set Symbolrate=[%d]\n", p->u.qpsk.symbol_rate); + dprintk(verbose, DST_DEBUG, 1, "Set Symbolrate=[%d]", p->u.qpsk.symbol_rate); - } else if (state->dst_type == DST_TYPE_IS_TERR) { + } else if (state->dst_type == DST_TYPE_IS_TERR) dst_set_bandwidth(state, p->u.ofdm.bandwidth); - } else if (state->dst_type == DST_TYPE_IS_CABLE) { + else if (state->dst_type == DST_TYPE_IS_CABLE) { dst_set_fec(state, p->u.qam.fec_inner); dst_set_symbolrate(state, p->u.qam.symbol_rate); dst_set_modulation(state, p->u.qam.modulation); @@ -1287,16 +1296,14 @@ static int dst_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_paramet return 0; } -static int dst_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) +static int dst_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; p->frequency = state->decode_freq; -// p->inversion = state->inversion; if (state->dst_type == DST_TYPE_IS_SAT) { if (state->type_flags & DST_TYPE_HAS_OBS_REGS) p->inversion = state->inversion; - p->u.qpsk.symbol_rate = state->symbol_rate; p->u.qpsk.fec_inner = dst_get_fec(state); } else if (state->dst_type == DST_TYPE_IS_TERR) { @@ -1304,16 +1311,15 @@ static int dst_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_paramet } else if (state->dst_type == DST_TYPE_IS_CABLE) { p->u.qam.symbol_rate = state->symbol_rate; p->u.qam.fec_inner = dst_get_fec(state); -// p->u.qam.modulation = QAM_AUTO; p->u.qam.modulation = dst_get_modulation(state); } return 0; } -static void dst_release(struct dvb_frontend* fe) +static void dst_release(struct dvb_frontend *fe) { - struct dst_state* state = fe->demodulator_priv; + struct dst_state *state = fe->demodulator_priv; kfree(state); } @@ -1321,9 +1327,8 @@ static struct dvb_frontend_ops dst_dvbt_ops; static struct dvb_frontend_ops dst_dvbs_ops; static struct dvb_frontend_ops dst_dvbc_ops; -struct dst_state* dst_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter) +struct dst_state *dst_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter) { - /* check if the ASIC is there */ if (dst_probe(state) < 0) { if (state) @@ -1336,17 +1341,14 @@ struct dst_state* dst_attach(struct dst_state *state, struct dvb_adapter *dvb_ad case DST_TYPE_IS_TERR: memcpy(&state->ops, &dst_dvbt_ops, sizeof(struct dvb_frontend_ops)); break; - case DST_TYPE_IS_CABLE: memcpy(&state->ops, &dst_dvbc_ops, sizeof(struct dvb_frontend_ops)); break; - case DST_TYPE_IS_SAT: memcpy(&state->ops, &dst_dvbs_ops, sizeof(struct dvb_frontend_ops)); break; - default: - printk("%s: unknown DST type. please report to the LinuxTV.org DVB mailinglist.\n", __FUNCTION__); + dprintk(verbose, DST_ERROR, 1, "unknown DST type. please report to the LinuxTV.org DVB mailinglist."); if (state) kfree(state); @@ -1374,12 +1376,9 @@ static struct dvb_frontend_ops dst_dvbt_ops = { }, .release = dst_release, - .init = dst_init, - .set_frontend = dst_set_frontend, .get_frontend = dst_get_frontend, - .read_status = dst_read_status, .read_signal_strength = dst_read_signal_strength, .read_snr = dst_read_snr, @@ -1401,16 +1400,12 @@ static struct dvb_frontend_ops dst_dvbs_ops = { }, .release = dst_release, - .init = dst_init, - .set_frontend = dst_set_frontend, .get_frontend = dst_get_frontend, - .read_status = dst_read_status, .read_signal_strength = dst_read_signal_strength, .read_snr = dst_read_snr, - .diseqc_send_burst = dst_send_burst, .diseqc_send_master_cmd = dst_set_diseqc, .set_voltage = dst_set_voltage, @@ -1432,18 +1427,14 @@ static struct dvb_frontend_ops dst_dvbc_ops = { }, .release = dst_release, - .init = dst_init, - .set_frontend = dst_set_frontend, .get_frontend = dst_get_frontend, - .read_status = dst_read_status, .read_signal_strength = dst_read_signal_strength, .read_snr = dst_read_snr, }; - MODULE_DESCRIPTION("DST DVB-S/T/C Combo Frontend driver"); MODULE_AUTHOR("Jamie Honan, Manu Abraham"); MODULE_LICENSE("GPL"); diff --git a/drivers/media/dvb/bt8xx/dst_ca.c b/drivers/media/dvb/bt8xx/dst_ca.c index bfaacd5fc20..6776a592045 100644 --- a/drivers/media/dvb/bt8xx/dst_ca.c +++ b/drivers/media/dvb/bt8xx/dst_ca.c @@ -18,30 +18,42 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - - #include <linux/kernel.h> #include <linux/module.h> #include <linux/init.h> #include <linux/string.h> - #include <linux/dvb/ca.h> #include "dvbdev.h" #include "dvb_frontend.h" - #include "dst_ca.h" #include "dst_common.h" +#define DST_CA_ERROR 0 +#define DST_CA_NOTICE 1 +#define DST_CA_INFO 2 +#define DST_CA_DEBUG 3 + +#define dprintk(x, y, z, format, arg...) do { \ + if (z) { \ + if ((x > DST_CA_ERROR) && (x > y)) \ + printk(KERN_ERR "%s: " format "\n", __FUNCTION__ , ##arg); \ + else if ((x > DST_CA_NOTICE) && (x > y)) \ + printk(KERN_NOTICE "%s: " format "\n", __FUNCTION__ , ##arg); \ + else if ((x > DST_CA_INFO) && (x > y)) \ + printk(KERN_INFO "%s: " format "\n", __FUNCTION__ , ##arg); \ + else if ((x > DST_CA_DEBUG) && (x > y)) \ + printk(KERN_DEBUG "%s: " format "\n", __FUNCTION__ , ##arg); \ + } else { \ + if (x > y) \ + printk(format, ## arg); \ + } \ +} while(0) + + static unsigned int verbose = 5; module_param(verbose, int, 0644); MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)"); -static unsigned int debug = 1; -module_param(debug, int, 0644); -MODULE_PARM_DESC(debug, "debug messages, default is 1 (yes)"); - -#define dprintk if (debug) printk - /* Need some more work */ static int ca_set_slot_descr(void) { @@ -61,27 +73,20 @@ static int put_checksum(u8 *check_string, int length) { u8 i = 0, checksum = 0; - if (verbose > 3) { - dprintk("%s: ========================= Checksum calculation ===========================\n", __FUNCTION__); - dprintk("%s: String Length=[0x%02x]\n", __FUNCTION__, length); + dprintk(verbose, DST_CA_DEBUG, 1, " ========================= Checksum calculation ==========================="); + dprintk(verbose, DST_CA_DEBUG, 1, " String Length=[0x%02x]", length); + dprintk(verbose, DST_CA_DEBUG, 1, " String=["); - dprintk("%s: String=[", __FUNCTION__); - } while (i < length) { - if (verbose > 3) - dprintk(" %02x", check_string[i]); + dprintk(verbose, DST_CA_DEBUG, 0, " %02x", check_string[i]); checksum += check_string[i]; i++; } - if (verbose > 3) { - dprintk(" ]\n"); - dprintk("%s: Sum=[%02x]\n", __FUNCTION__, checksum); - } + dprintk(verbose, DST_CA_DEBUG, 0, " ]\n"); + dprintk(verbose, DST_CA_DEBUG, 1, "Sum=[%02x]\n", checksum); check_string[length] = ~checksum + 1; - if (verbose > 3) { - dprintk("%s: Checksum=[%02x]\n", __FUNCTION__, check_string[length]); - dprintk("%s: ==========================================================================\n", __FUNCTION__); - } + dprintk(verbose, DST_CA_DEBUG, 1, " Checksum=[%02x]", check_string[length]); + dprintk(verbose, DST_CA_DEBUG, 1, " =========================================================================="); return 0; } @@ -94,30 +99,26 @@ static int dst_ci_command(struct dst_state* state, u8 * data, u8 *ca_string, u8 msleep(65); if (write_dst(state, data, len)) { - dprintk("%s: Write not successful, trying to recover\n", __FUNCTION__); + dprintk(verbose, DST_CA_INFO, 1, " Write not successful, trying to recover"); dst_error_recovery(state); return -1; } - if ((dst_pio_disable(state)) < 0) { - dprintk("%s: DST PIO disable failed.\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " DST PIO disable failed."); return -1; } - if (read_dst(state, &reply, GET_ACK) < 0) { - dprintk("%s: Read not successful, trying to recover\n", __FUNCTION__); + dprintk(verbose, DST_CA_INFO, 1, " Read not successful, trying to recover"); dst_error_recovery(state); return -1; } - if (read) { if (! dst_wait_dst_ready(state, LONG_DELAY)) { - dprintk("%s: 8820 not ready\n", __FUNCTION__); + dprintk(verbose, DST_CA_NOTICE, 1, " 8820 not ready"); return -1; } - if (read_dst(state, ca_string, 128) < 0) { /* Try to make this dynamic */ - dprintk("%s: Read not successful, trying to recover\n", __FUNCTION__); + dprintk(verbose, DST_CA_INFO, 1, " Read not successful, trying to recover"); dst_error_recovery(state); return -1; } @@ -133,8 +134,7 @@ static int dst_put_ci(struct dst_state *state, u8 *data, int len, u8 *ca_string, while (dst_ca_comm_err < RETRIES) { dst_comm_init(state); - if (verbose > 2) - dprintk("%s: Put Command\n", __FUNCTION__); + dprintk(verbose, DST_CA_NOTICE, 1, " Put Command"); if (dst_ci_command(state, data, ca_string, len, read)) { // If error dst_error_recovery(state); dst_ca_comm_err++; // work required here. @@ -153,18 +153,15 @@ static int ca_get_app_info(struct dst_state *state) put_checksum(&command[0], command[0]); if ((dst_put_ci(state, command, sizeof(command), state->messages, GET_REPLY)) < 0) { - dprintk("%s: -->dst_put_ci FAILED !\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !"); return -1; } - if (verbose > 1) { - dprintk("%s: -->dst_put_ci SUCCESS !\n", __FUNCTION__); - - dprintk("%s: ================================ CI Module Application Info ======================================\n", __FUNCTION__); - dprintk("%s: Application Type=[%d], Application Vendor=[%d], Vendor Code=[%d]\n%s: Application info=[%s]\n", - __FUNCTION__, state->messages[7], (state->messages[8] << 8) | state->messages[9], - (state->messages[10] << 8) | state->messages[11], __FUNCTION__, (char *)(&state->messages[12])); - dprintk("%s: ==================================================================================================\n", __FUNCTION__); - } + dprintk(verbose, DST_CA_INFO, 1, " -->dst_put_ci SUCCESS !"); + dprintk(verbose, DST_CA_INFO, 1, " ================================ CI Module Application Info ======================================"); + dprintk(verbose, DST_CA_INFO, 1, " Application Type=[%d], Application Vendor=[%d], Vendor Code=[%d]\n%s: Application info=[%s]", + state->messages[7], (state->messages[8] << 8) | state->messages[9], + (state->messages[10] << 8) | state->messages[11], __FUNCTION__, (char *)(&state->messages[12])); + dprintk(verbose, DST_CA_INFO, 1, " =================================================================================================="); return 0; } @@ -177,31 +174,26 @@ static int ca_get_slot_caps(struct dst_state *state, struct ca_caps *p_ca_caps, put_checksum(&slot_command[0], slot_command[0]); if ((dst_put_ci(state, slot_command, sizeof (slot_command), slot_cap, GET_REPLY)) < 0) { - dprintk("%s: -->dst_put_ci FAILED !\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !"); return -1; } - if (verbose > 1) - dprintk("%s: -->dst_put_ci SUCCESS !\n", __FUNCTION__); + dprintk(verbose, DST_CA_NOTICE, 1, " -->dst_put_ci SUCCESS !"); /* Will implement the rest soon */ - if (verbose > 1) { - dprintk("%s: Slot cap = [%d]\n", __FUNCTION__, slot_cap[7]); - dprintk("===================================\n"); - for (i = 0; i < 8; i++) - dprintk(" %d", slot_cap[i]); - dprintk("\n"); - } + dprintk(verbose, DST_CA_INFO, 1, " Slot cap = [%d]", slot_cap[7]); + dprintk(verbose, DST_CA_INFO, 0, "===================================\n"); + for (i = 0; i < 8; i++) + dprintk(verbose, DST_CA_INFO, 0, " %d", slot_cap[i]); + dprintk(verbose, DST_CA_INFO, 0, "\n"); p_ca_caps->slot_num = 1; p_ca_caps->slot_type = 1; p_ca_caps->descr_num = slot_cap[7]; p_ca_caps->descr_type = 1; - - if (copy_to_user((struct ca_caps *)arg, p_ca_caps, sizeof (struct ca_caps))) { + if (copy_to_user((struct ca_caps *)arg, p_ca_caps, sizeof (struct ca_caps))) return -EFAULT; - } return 0; } @@ -222,46 +214,37 @@ static int ca_get_slot_info(struct dst_state *state, struct ca_slot_info *p_ca_s put_checksum(&slot_command[0], 7); if ((dst_put_ci(state, slot_command, sizeof (slot_command), slot_info, GET_REPLY)) < 0) { - dprintk("%s: -->dst_put_ci FAILED !\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !"); return -1; } - if (verbose > 1) - dprintk("%s: -->dst_put_ci SUCCESS !\n", __FUNCTION__); + dprintk(verbose, DST_CA_INFO, 1, " -->dst_put_ci SUCCESS !"); /* Will implement the rest soon */ - if (verbose > 1) { - dprintk("%s: Slot info = [%d]\n", __FUNCTION__, slot_info[3]); - dprintk("===================================\n"); - for (i = 0; i < 8; i++) - dprintk(" %d", slot_info[i]); - dprintk("\n"); - } + dprintk(verbose, DST_CA_INFO, 1, " Slot info = [%d]", slot_info[3]); + dprintk(verbose, DST_CA_INFO, 0, "===================================\n"); + for (i = 0; i < 8; i++) + dprintk(verbose, DST_CA_INFO, 0, " %d", slot_info[i]); + dprintk(verbose, DST_CA_INFO, 0, "\n"); if (slot_info[4] & 0x80) { p_ca_slot_info->flags = CA_CI_MODULE_PRESENT; p_ca_slot_info->num = 1; p_ca_slot_info->type = CA_CI; - } - else if (slot_info[4] & 0x40) { + } else if (slot_info[4] & 0x40) { p_ca_slot_info->flags = CA_CI_MODULE_READY; p_ca_slot_info->num = 1; p_ca_slot_info->type = CA_CI; - } - else { + } else p_ca_slot_info->flags = 0; - } - if (copy_to_user((struct ca_slot_info *)arg, p_ca_slot_info, sizeof (struct ca_slot_info))) { + if (copy_to_user((struct ca_slot_info *)arg, p_ca_slot_info, sizeof (struct ca_slot_info))) return -EFAULT; - } return 0; } - - static int ca_get_message(struct dst_state *state, struct ca_msg *p_ca_message, void *arg) { u8 i = 0; @@ -270,24 +253,21 @@ static int ca_get_message(struct dst_state *state, struct ca_msg *p_ca_message, if (copy_from_user(p_ca_message, (void *)arg, sizeof (struct ca_msg))) return -EFAULT; - if (p_ca_message->msg) { - if (verbose > 3) - dprintk("Message = [%02x %02x %02x]\n", p_ca_message->msg[0], p_ca_message->msg[1], p_ca_message->msg[2]); + dprintk(verbose, DST_CA_NOTICE, 1, " Message = [%02x %02x %02x]", p_ca_message->msg[0], p_ca_message->msg[1], p_ca_message->msg[2]); for (i = 0; i < 3; i++) { command = command | p_ca_message->msg[i]; if (i < 2) command = command << 8; } - if (verbose > 3) - dprintk("%s:Command=[0x%x]\n", __FUNCTION__, command); + dprintk(verbose, DST_CA_NOTICE, 1, " Command=[0x%x]", command); switch (command) { - case CA_APP_INFO: - memcpy(p_ca_message->msg, state->messages, 128); - if (copy_to_user((void *)arg, p_ca_message, sizeof (struct ca_msg)) ) - return -EFAULT; + case CA_APP_INFO: + memcpy(p_ca_message->msg, state->messages, 128); + if (copy_to_user((void *)arg, p_ca_message, sizeof (struct ca_msg)) ) + return -EFAULT; break; } } @@ -298,10 +278,13 @@ static int ca_get_message(struct dst_state *state, struct ca_msg *p_ca_message, static int handle_dst_tag(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer, u32 length) { if (state->dst_hw_cap & DST_TYPE_HAS_SESSION) { - hw_buffer->msg[2] = p_ca_message->msg[1]; /* MSB */ - hw_buffer->msg[3] = p_ca_message->msg[2]; /* LSB */ - } - else { + hw_buffer->msg[2] = p_ca_message->msg[1]; /* MSB */ + hw_buffer->msg[3] = p_ca_message->msg[2]; /* LSB */ + } else { + if (length > 247) { + dprintk(verbose, DST_CA_ERROR, 1, " Message too long ! *** Bailing Out *** !"); + return -1; + } hw_buffer->msg[0] = (length & 0xff) + 7; hw_buffer->msg[1] = 0x40; hw_buffer->msg[2] = 0x03; @@ -309,6 +292,11 @@ static int handle_dst_tag(struct dst_state *state, struct ca_msg *p_ca_message, hw_buffer->msg[4] = 0x03; hw_buffer->msg[5] = length & 0xff; hw_buffer->msg[6] = 0x00; + /* + * Need to compute length for EN50221 section 8.3.2, for the time being + * assuming 8.3.2 is not applicable + */ + memcpy(&hw_buffer->msg[7], &p_ca_message->msg[4], length); } return 0; } @@ -317,13 +305,12 @@ static int handle_dst_tag(struct dst_state *state, struct ca_msg *p_ca_message, static int write_to_8820(struct dst_state *state, struct ca_msg *hw_buffer, u8 length, u8 reply) { if ((dst_put_ci(state, hw_buffer->msg, length, hw_buffer->msg, reply)) < 0) { - dprintk("%s: DST-CI Command failed.\n", __FUNCTION__); - dprintk("%s: Resetting DST.\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " DST-CI Command failed."); + dprintk(verbose, DST_CA_NOTICE, 1, " Resetting DST."); rdc_reset_state(state); return -1; } - if (verbose > 2) - dprintk("%s: DST-CI Command succes.\n", __FUNCTION__); + dprintk(verbose, DST_CA_NOTICE, 1, " DST-CI Command succes."); return 0; } @@ -334,130 +321,47 @@ u32 asn_1_decode(u8 *asn_1_array) u32 length = 0; length_field = asn_1_array[0]; - dprintk("%s: Length field=[%02x]\n", __FUNCTION__, length_field); + dprintk(verbose, DST_CA_DEBUG, 1, " Length field=[%02x]", length_field); if (length_field < 0x80) { length = length_field & 0x7f; - dprintk("%s: Length=[%02x]\n", __FUNCTION__, length); + dprintk(verbose, DST_CA_DEBUG, 1, " Length=[%02x]\n", length); } else { word_count = length_field & 0x7f; for (count = 0; count < word_count; count++) { length = (length | asn_1_array[count + 1]) << 8; - dprintk("%s: Length=[%04x]\n", __FUNCTION__, length); + dprintk(verbose, DST_CA_DEBUG, 1, " Length=[%04x]", length); } } return length; } -static int init_buffer(u8 *buffer, u32 length) -{ - u32 i; - for (i = 0; i < length; i++) - buffer[i] = 0; - - return 0; -} - static int debug_string(u8 *msg, u32 length, u32 offset) { u32 i; - dprintk(" String=[ "); + dprintk(verbose, DST_CA_DEBUG, 0, " String=[ "); for (i = offset; i < length; i++) - dprintk("%02x ", msg[i]); - dprintk("]\n"); - - return 0; -} - -static int copy_string(u8 *destination, u8 *source, u32 dest_offset, u32 source_offset, u32 length) -{ - u32 i; - dprintk("%s: Copying [", __FUNCTION__); - for (i = 0; i < length; i++) { - destination[i + dest_offset] = source[i + source_offset]; - dprintk(" %02x", source[i + source_offset]); - } - dprintk("]\n"); - - return i; -} - -static int modify_4_bits(u8 *message, u32 pos) -{ - message[pos] &= 0x0f; + dprintk(verbose, DST_CA_DEBUG, 0, "%02x ", msg[i]); + dprintk(verbose, DST_CA_DEBUG, 0, "]\n"); return 0; } - - static int ca_set_pmt(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer, u8 reply, u8 query) { - u32 length = 0, count = 0; - u8 asn_1_words, program_header_length; - u16 program_info_length = 0, es_info_length = 0; - u32 hw_offset = 0, buf_offset = 0, i; - u8 dst_tag_length; + u32 length = 0; + u8 tag_length = 8; length = asn_1_decode(&p_ca_message->msg[3]); - dprintk("%s: CA Message length=[%d]\n", __FUNCTION__, length); - dprintk("%s: ASN.1 ", __FUNCTION__); - debug_string(&p_ca_message->msg[4], length, 0); // length does not include tag and length + dprintk(verbose, DST_CA_DEBUG, 1, " CA Message length=[%d]", length); + debug_string(&p_ca_message->msg[4], length, 0); /* length is excluding tag & length */ - init_buffer(hw_buffer->msg, length); + memset(hw_buffer->msg, '\0', length); handle_dst_tag(state, p_ca_message, hw_buffer, length); + put_checksum(hw_buffer->msg, hw_buffer->msg[0]); - hw_offset = 7; - asn_1_words = 1; // just a hack to test, should compute this one - buf_offset = 3; - program_header_length = 6; - dst_tag_length = 7; - -// debug_twinhan_ca_params(state, p_ca_message, hw_buffer, reply, query, length, hw_offset, buf_offset); -// dprintk("%s: Program Header(BUF)", __FUNCTION__); -// debug_string(&p_ca_message->msg[4], program_header_length, 0); -// dprintk("%s: Copying Program header\n", __FUNCTION__); - copy_string(hw_buffer->msg, p_ca_message->msg, hw_offset, (buf_offset + asn_1_words), program_header_length); - buf_offset += program_header_length, hw_offset += program_header_length; - modify_4_bits(hw_buffer->msg, (hw_offset - 2)); - if (state->type_flags & DST_TYPE_HAS_INC_COUNT) { // workaround - dprintk("%s: Probably an ASIC bug !!!\n", __FUNCTION__); - debug_string(hw_buffer->msg, (hw_offset + program_header_length), 0); - hw_buffer->msg[hw_offset - 1] += 1; - } - -// dprintk("%s: Program Header(HW), Count=[%d]", __FUNCTION__, count); -// debug_string(hw_buffer->msg, hw_offset, 0); - - program_info_length = ((program_info_length | (p_ca_message->msg[buf_offset - 1] & 0x0f)) << 8) | p_ca_message->msg[buf_offset]; - dprintk("%s: Program info length=[%02x]\n", __FUNCTION__, program_info_length); - if (program_info_length) { - count = copy_string(hw_buffer->msg, p_ca_message->msg, hw_offset, (buf_offset + 1), (program_info_length + 1) ); // copy next elem, not current - buf_offset += count, hw_offset += count; -// dprintk("%s: Program level ", __FUNCTION__); -// debug_string(hw_buffer->msg, hw_offset, 0); - } - - buf_offset += 1;// hw_offset += 1; - for (i = buf_offset; i < length; i++) { -// dprintk("%s: Stream Header ", __FUNCTION__); - count = copy_string(hw_buffer->msg, p_ca_message->msg, hw_offset, buf_offset, 5); - modify_4_bits(hw_buffer->msg, (hw_offset + 3)); - - hw_offset += 5, buf_offset += 5, i += 4; -// debug_string(hw_buffer->msg, hw_offset, (hw_offset - 5)); - es_info_length = ((es_info_length | (p_ca_message->msg[buf_offset - 1] & 0x0f)) << 8) | p_ca_message->msg[buf_offset]; - dprintk("%s: ES info length=[%02x]\n", __FUNCTION__, es_info_length); - if (es_info_length) { - // copy descriptors @ STREAM level - dprintk("%s: Descriptors @ STREAM level...!!! \n", __FUNCTION__); - } - - } - hw_buffer->msg[length + dst_tag_length] = dst_check_sum(hw_buffer->msg, (length + dst_tag_length)); -// dprintk("%s: Total length=[%d], Checksum=[%02x]\n", __FUNCTION__, (length + dst_tag_length), hw_buffer->msg[length + dst_tag_length]); - debug_string(hw_buffer->msg, (length + dst_tag_length + 1), 0); // dst tags also - write_to_8820(state, hw_buffer, (length + dst_tag_length + 1), reply); // checksum + debug_string(hw_buffer->msg, (length + tag_length), 0); /* tags too */ + write_to_8820(state, hw_buffer, (length + tag_length), reply); return 0; } @@ -471,26 +375,24 @@ static int dst_check_ca_pmt(struct dst_state *state, struct ca_msg *p_ca_message /* Do test board */ /* Not there yet but soon */ - /* CA PMT Reply capable */ if (ca_pmt_reply_test) { if ((ca_set_pmt(state, p_ca_message, hw_buffer, 1, GET_REPLY)) < 0) { - dprintk("%s: ca_set_pmt.. failed !\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " ca_set_pmt.. failed !"); return -1; } /* Process CA PMT Reply */ /* will implement soon */ - dprintk("%s: Not there yet\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " Not there yet"); } /* CA PMT Reply not capable */ if (!ca_pmt_reply_test) { if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, NO_REPLY)) < 0) { - dprintk("%s: ca_set_pmt.. failed !\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " ca_set_pmt.. failed !"); return -1; } - if (verbose > 3) - dprintk("%s: ca_set_pmt.. success !\n", __FUNCTION__); + dprintk(verbose, DST_CA_NOTICE, 1, " ca_set_pmt.. success !"); /* put a dummy message */ } @@ -506,11 +408,10 @@ static int ca_send_message(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer; if ((hw_buffer = (struct ca_msg *) kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) { - dprintk("%s: Memory allocation failure\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure"); return -ENOMEM; } - if (verbose > 3) - dprintk("%s\n", __FUNCTION__); + dprintk(verbose, DST_CA_DEBUG, 1, " "); if (copy_from_user(p_ca_message, (void *)arg, sizeof (struct ca_msg))) return -EFAULT; @@ -525,51 +426,35 @@ static int ca_send_message(struct dst_state *state, struct ca_msg *p_ca_message, if (i < 2) command = command << 8; } - if (verbose > 3) - dprintk("%s:Command=[0x%x]\n", __FUNCTION__, command); + dprintk(verbose, DST_CA_DEBUG, 1, " Command=[0x%x]\n", command); switch (command) { - case CA_PMT: - if (verbose > 3) -// dprintk("Command = SEND_CA_PMT\n"); - dprintk("Command = SEND_CA_PMT\n"); -// if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0)) < 0) { - if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0)) < 0) { // code simplification started - dprintk("%s: -->CA_PMT Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 3) - dprintk("%s: -->CA_PMT Success !\n", __FUNCTION__); -// retval = dummy_set_pmt(state, p_ca_message, hw_buffer, 0, 0); - - break; - - case CA_PMT_REPLY: - if (verbose > 3) - dprintk("Command = CA_PMT_REPLY\n"); - /* Have to handle the 2 basic types of cards here */ - if ((dst_check_ca_pmt(state, p_ca_message, hw_buffer)) < 0) { - dprintk("%s: -->CA_PMT_REPLY Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 3) - dprintk("%s: -->CA_PMT_REPLY Success !\n", __FUNCTION__); - - /* Certain boards do behave different ? */ -// retval = ca_set_pmt(state, p_ca_message, hw_buffer, 1, 1); - - case CA_APP_INFO_ENQUIRY: // only for debugging - if (verbose > 3) - dprintk("%s: Getting Cam Application information\n", __FUNCTION__); - - if ((ca_get_app_info(state)) < 0) { - dprintk("%s: -->CA_APP_INFO_ENQUIRY Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 3) - dprintk("%s: -->CA_APP_INFO_ENQUIRY Success !\n", __FUNCTION__); - - break; + case CA_PMT: + dprintk(verbose, DST_CA_DEBUG, 1, "Command = SEND_CA_PMT"); + if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0)) < 0) { // code simplification started + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_PMT Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_PMT Success !"); + break; + case CA_PMT_REPLY: + dprintk(verbose, DST_CA_INFO, 1, "Command = CA_PMT_REPLY"); + /* Have to handle the 2 basic types of cards here */ + if ((dst_check_ca_pmt(state, p_ca_message, hw_buffer)) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_PMT_REPLY Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_PMT_REPLY Success !"); + break; + case CA_APP_INFO_ENQUIRY: // only for debugging + dprintk(verbose, DST_CA_INFO, 1, " Getting Cam Application information"); + + if ((ca_get_app_info(state)) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_APP_INFO_ENQUIRY Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_APP_INFO_ENQUIRY Success !"); + break; } } return 0; @@ -584,121 +469,88 @@ static int dst_ca_ioctl(struct inode *inode, struct file *file, unsigned int cmd struct ca_msg *p_ca_message; if ((p_ca_message = (struct ca_msg *) kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) { - dprintk("%s: Memory allocation failure\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure"); return -ENOMEM; } - if ((p_ca_slot_info = (struct ca_slot_info *) kmalloc(sizeof (struct ca_slot_info), GFP_KERNEL)) == NULL) { - dprintk("%s: Memory allocation failure\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure"); return -ENOMEM; } - if ((p_ca_caps = (struct ca_caps *) kmalloc(sizeof (struct ca_caps), GFP_KERNEL)) == NULL) { - dprintk("%s: Memory allocation failure\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure"); return -ENOMEM; } - /* We have now only the standard ioctl's, the driver is upposed to handle internals. */ switch (cmd) { - case CA_SEND_MSG: - if (verbose > 1) - dprintk("%s: Sending message\n", __FUNCTION__); - if ((ca_send_message(state, p_ca_message, arg)) < 0) { - dprintk("%s: -->CA_SEND_MSG Failed !\n", __FUNCTION__); - return -1; - } - - break; - - case CA_GET_MSG: - if (verbose > 1) - dprintk("%s: Getting message\n", __FUNCTION__); - if ((ca_get_message(state, p_ca_message, arg)) < 0) { - dprintk("%s: -->CA_GET_MSG Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 1) - dprintk("%s: -->CA_GET_MSG Success !\n", __FUNCTION__); - - break; - - case CA_RESET: - if (verbose > 1) - dprintk("%s: Resetting DST\n", __FUNCTION__); - dst_error_bailout(state); - msleep(4000); - - break; - - case CA_GET_SLOT_INFO: - if (verbose > 1) - dprintk("%s: Getting Slot info\n", __FUNCTION__); - if ((ca_get_slot_info(state, p_ca_slot_info, arg)) < 0) { - dprintk("%s: -->CA_GET_SLOT_INFO Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 1) - dprintk("%s: -->CA_GET_SLOT_INFO Success !\n", __FUNCTION__); - - break; - - case CA_GET_CAP: - if (verbose > 1) - dprintk("%s: Getting Slot capabilities\n", __FUNCTION__); - if ((ca_get_slot_caps(state, p_ca_caps, arg)) < 0) { - dprintk("%s: -->CA_GET_CAP Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 1) - dprintk("%s: -->CA_GET_CAP Success !\n", __FUNCTION__); - - break; - - case CA_GET_DESCR_INFO: - if (verbose > 1) - dprintk("%s: Getting descrambler description\n", __FUNCTION__); - if ((ca_get_slot_descr(state, p_ca_message, arg)) < 0) { - dprintk("%s: -->CA_GET_DESCR_INFO Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 1) - dprintk("%s: -->CA_GET_DESCR_INFO Success !\n", __FUNCTION__); - - break; - - case CA_SET_DESCR: - if (verbose > 1) - dprintk("%s: Setting descrambler\n", __FUNCTION__); - if ((ca_set_slot_descr()) < 0) { - dprintk("%s: -->CA_SET_DESCR Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 1) - dprintk("%s: -->CA_SET_DESCR Success !\n", __FUNCTION__); - - break; - - case CA_SET_PID: - if (verbose > 1) - dprintk("%s: Setting PID\n", __FUNCTION__); - if ((ca_set_pid()) < 0) { - dprintk("%s: -->CA_SET_PID Failed !\n", __FUNCTION__); - return -1; - } - if (verbose > 1) - dprintk("%s: -->CA_SET_PID Success !\n", __FUNCTION__); - - default: - return -EOPNOTSUPP; - }; + case CA_SEND_MSG: + dprintk(verbose, DST_CA_INFO, 1, " Sending message"); + if ((ca_send_message(state, p_ca_message, arg)) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_SEND_MSG Failed !"); + return -1; + } + break; + case CA_GET_MSG: + dprintk(verbose, DST_CA_INFO, 1, " Getting message"); + if ((ca_get_message(state, p_ca_message, arg)) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_MSG Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_MSG Success !"); + break; + case CA_RESET: + dprintk(verbose, DST_CA_ERROR, 1, " Resetting DST"); + dst_error_bailout(state); + msleep(4000); + break; + case CA_GET_SLOT_INFO: + dprintk(verbose, DST_CA_INFO, 1, " Getting Slot info"); + if ((ca_get_slot_info(state, p_ca_slot_info, arg)) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_SLOT_INFO Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_SLOT_INFO Success !"); + break; + case CA_GET_CAP: + dprintk(verbose, DST_CA_INFO, 1, " Getting Slot capabilities"); + if ((ca_get_slot_caps(state, p_ca_caps, arg)) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_CAP Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_CAP Success !"); + break; + case CA_GET_DESCR_INFO: + dprintk(verbose, DST_CA_INFO, 1, " Getting descrambler description"); + if ((ca_get_slot_descr(state, p_ca_message, arg)) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_DESCR_INFO Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_DESCR_INFO Success !"); + break; + case CA_SET_DESCR: + dprintk(verbose, DST_CA_INFO, 1, " Setting descrambler"); + if ((ca_set_slot_descr()) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_SET_DESCR Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_SET_DESCR Success !"); + break; + case CA_SET_PID: + dprintk(verbose, DST_CA_INFO, 1, " Setting PID"); + if ((ca_set_pid()) < 0) { + dprintk(verbose, DST_CA_ERROR, 1, " -->CA_SET_PID Failed !"); + return -1; + } + dprintk(verbose, DST_CA_INFO, 1, " -->CA_SET_PID Success !"); + default: + return -EOPNOTSUPP; + }; return 0; } static int dst_ca_open(struct inode *inode, struct file *file) { - if (verbose > 4) - dprintk("%s:Device opened [%p]\n", __FUNCTION__, file); + dprintk(verbose, DST_CA_DEBUG, 1, " Device opened [%p] ", file); try_module_get(THIS_MODULE); return 0; @@ -706,27 +558,24 @@ static int dst_ca_open(struct inode *inode, struct file *file) static int dst_ca_release(struct inode *inode, struct file *file) { - if (verbose > 4) - dprintk("%s:Device closed.\n", __FUNCTION__); + dprintk(verbose, DST_CA_DEBUG, 1, " Device closed."); module_put(THIS_MODULE); return 0; } -static int dst_ca_read(struct file *file, char __user * buffer, size_t length, loff_t * offset) +static int dst_ca_read(struct file *file, char __user *buffer, size_t length, loff_t *offset) { int bytes_read = 0; - if (verbose > 4) - dprintk("%s:Device read.\n", __FUNCTION__); + dprintk(verbose, DST_CA_DEBUG, 1, " Device read."); return bytes_read; } -static int dst_ca_write(struct file *file, const char __user * buffer, size_t length, loff_t * offset) +static int dst_ca_write(struct file *file, const char __user *buffer, size_t length, loff_t *offset) { - if (verbose > 4) - dprintk("%s:Device write.\n", __FUNCTION__); + dprintk(verbose, DST_CA_DEBUG, 1, " Device write."); return 0; } @@ -751,8 +600,7 @@ static struct dvb_device dvbdev_ca = { int dst_ca_attach(struct dst_state *dst, struct dvb_adapter *dvb_adapter) { struct dvb_device *dvbdev; - if (verbose > 4) - dprintk("%s:registering DST-CA device\n", __FUNCTION__); + dprintk(verbose, DST_CA_ERROR, 1, "registering DST-CA device"); dvb_register_device(dvb_adapter, &dvbdev, &dvbdev_ca, dst, DVB_DEVICE_CA); return 0; } diff --git a/drivers/media/dvb/bt8xx/dst_common.h b/drivers/media/dvb/bt8xx/dst_common.h index ef532a6acea..3281a6ca368 100644 --- a/drivers/media/dvb/bt8xx/dst_common.h +++ b/drivers/media/dvb/bt8xx/dst_common.h @@ -61,7 +61,6 @@ #define DST_TYPE_HAS_ANALOG 64 /* Analog inputs */ #define DST_TYPE_HAS_SESSION 128 - #define RDC_8820_PIO_0_DISABLE 0 #define RDC_8820_PIO_0_ENABLE 1 #define RDC_8820_INT 2 @@ -114,6 +113,10 @@ struct dst_state { fe_sec_mini_cmd_t minicmd; fe_modulation_t modulation; u8 messages[256]; + u8 mac_address[8]; + u8 fw_version[8]; + u8 card_info[8]; + u8 vendor[8]; }; struct dst_types { @@ -124,15 +127,12 @@ struct dst_types { u32 dst_feature; }; - - struct dst_config { /* the ASIC i2c address */ u8 demod_address; }; - int rdc_reset_state(struct dst_state *state); int rdc_8820_reset(struct dst_state *state); diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c index 6f857c6091f..c5c7672cd53 100644 --- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c +++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c @@ -32,9 +32,7 @@ #include "dvbdev.h" #include "dvb_demux.h" #include "dvb_frontend.h" - #include "dvb-bt8xx.h" - #include "bt878.h" static int debug; @@ -43,9 +41,11 @@ module_param(debug, int, 0644); MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); #define dprintk( args... ) \ - do { \ + do \ if (debug) printk(KERN_DEBUG args); \ - } while (0) + while (0) + +#define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */ static void dvb_bt8xx_task(unsigned long data) { @@ -119,14 +119,12 @@ static struct bt878 __init *dvb_bt8xx_878_match(unsigned int bttv_nr, struct pci unsigned int card_nr; /* Hmm, n squared. Hope n is small */ - for (card_nr = 0; card_nr < bt878_num; card_nr++) { + for (card_nr = 0; card_nr < bt878_num; card_nr++) if (is_pci_slot_eq(bt878[card_nr].dev, bttv_pci_dev)) return &bt878[card_nr]; - } return NULL; } - static int thomson_dtt7579_demod_init(struct dvb_frontend* fe) { static u8 mt352_clock_config [] = { 0x89, 0x38, 0x38 }; @@ -154,16 +152,21 @@ static int thomson_dtt7579_pll_set(struct dvb_frontend* fe, struct dvb_frontend_ unsigned char bs = 0; unsigned char cp = 0; - #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */ div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; - if (params->frequency < 542000000) cp = 0xb4; - else if (params->frequency < 771000000) cp = 0xbc; - else cp = 0xf4; + if (params->frequency < 542000000) + cp = 0xb4; + else if (params->frequency < 771000000) + cp = 0xbc; + else + cp = 0xf4; - if (params->frequency == 0) bs = 0x03; - else if (params->frequency < 443250000) bs = 0x02; - else bs = 0x08; + if (params->frequency == 0) + bs = 0x03; + else if (params->frequency < 443250000) + bs = 0x02; + else + bs = 0x08; pllbuf[0] = 0xc0; // Note: non-linux standard PLL i2c address pllbuf[1] = div >> 8; @@ -175,7 +178,6 @@ static int thomson_dtt7579_pll_set(struct dvb_frontend* fe, struct dvb_frontend_ } static struct mt352_config thomson_dtt7579_config = { - .demod_address = 0x0f, .demod_init = thomson_dtt7579_demod_init, .pll_set = thomson_dtt7579_pll_set, @@ -183,25 +185,26 @@ static struct mt352_config thomson_dtt7579_config = { static int cx24108_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) { - u32 freq = params->frequency; - - int i, a, n, pump; - u32 band, pll; + u32 freq = params->frequency; + int i, a, n, pump; + u32 band, pll; - u32 osci[]={950000,1019000,1075000,1178000,1296000,1432000, - 1576000,1718000,1856000,2036000,2150000}; - u32 bandsel[]={0,0x00020000,0x00040000,0x00100800,0x00101000, - 0x00102000,0x00104000,0x00108000,0x00110000, - 0x00120000,0x00140000}; + u32 osci[]={950000,1019000,1075000,1178000,1296000,1432000, + 1576000,1718000,1856000,2036000,2150000}; + u32 bandsel[]={0,0x00020000,0x00040000,0x00100800,0x00101000, + 0x00102000,0x00104000,0x00108000,0x00110000, + 0x00120000,0x00140000}; -#define XTAL 1011100 /* Hz, really 1.0111 MHz and a /10 prescaler */ + #define XTAL 1011100 /* Hz, really 1.0111 MHz and a /10 prescaler */ printk("cx24108 debug: entering SetTunerFreq, freq=%d\n",freq); /* This is really the bit driving the tuner chip cx24108 */ - if(freq<950000) freq=950000; /* kHz */ - if(freq>2150000) freq=2150000; /* satellite IF is 950..2150MHz */ + if (freq<950000) + freq = 950000; /* kHz */ + else if (freq>2150000) + freq = 2150000; /* satellite IF is 950..2150MHz */ /* decide which VCO to use for the input frequency */ for(i=1;(i<sizeof(osci)/sizeof(osci[0]))&&(osci[i]<freq);i++); @@ -228,25 +231,22 @@ static int cx24108_pll_set(struct dvb_frontend* fe, struct dvb_frontend_paramete cx24110_pll_write(fe,0x500c0000); cx24110_pll_write(fe,0x83f1f800); cx24110_pll_write(fe,pll); -/* writereg(client,0x56,0x7f);*/ + //writereg(client,0x56,0x7f); return 0; } static int pinnsat_pll_init(struct dvb_frontend* fe) { - return 0; + return 0; } - static struct cx24110_config pctvsat_config = { - .demod_address = 0x55, .pll_init = pinnsat_pll_init, .pll_set = cx24108_pll_set, }; - static int microtune_mt7202dtf_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) { struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv; @@ -258,15 +258,23 @@ static int microtune_mt7202dtf_pll_set(struct dvb_frontend* fe, struct dvb_front div = (36000000 + params->frequency + 83333) / 166666; cfg = 0x88; - if (params->frequency < 175000000) cpump = 2; - else if (params->frequency < 390000000) cpump = 1; - else if (params->frequency < 470000000) cpump = 2; - else if (params->frequency < 750000000) cpump = 2; - else cpump = 3; + if (params->frequency < 175000000) + cpump = 2; + else if (params->frequency < 390000000) + cpump = 1; + else if (params->frequency < 470000000) + cpump = 2; + else if (params->frequency < 750000000) + cpump = 2; + else + cpump = 3; - if (params->frequency < 175000000) band_select = 0x0e; - else if (params->frequency < 470000000) band_select = 0x05; - else band_select = 0x03; + if (params->frequency < 175000000) + band_select = 0x0e; + else if (params->frequency < 470000000) + band_select = 0x05; + else + band_select = 0x03; data[0] = (div >> 8) & 0x7f; data[1] = div & 0xff; @@ -285,14 +293,11 @@ static int microtune_mt7202dtf_request_firmware(struct dvb_frontend* fe, const s } static struct sp887x_config microtune_mt7202dtf_config = { - .demod_address = 0x70, .pll_set = microtune_mt7202dtf_pll_set, .request_firmware = microtune_mt7202dtf_request_firmware, }; - - static int advbt771_samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe) { static u8 mt352_clock_config [] = { 0x89, 0x38, 0x2d }; @@ -303,7 +308,6 @@ static int advbt771_samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe) static u8 mt352_av771_extra[] = { 0xB5, 0x7A }; static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 }; - mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config)); udelay(2000); mt352_write(fe, mt352_reset, sizeof(mt352_reset)); @@ -323,28 +327,45 @@ static int advbt771_samsung_tdtc9251dh0_pll_set(struct dvb_frontend* fe, struct unsigned char bs = 0; unsigned char cp = 0; - #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */ div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; - if (params->frequency < 150000000) cp = 0xB4; - else if (params->frequency < 173000000) cp = 0xBC; - else if (params->frequency < 250000000) cp = 0xB4; - else if (params->frequency < 400000000) cp = 0xBC; - else if (params->frequency < 420000000) cp = 0xF4; - else if (params->frequency < 470000000) cp = 0xFC; - else if (params->frequency < 600000000) cp = 0xBC; - else if (params->frequency < 730000000) cp = 0xF4; - else cp = 0xFC; - - if (params->frequency < 150000000) bs = 0x01; - else if (params->frequency < 173000000) bs = 0x01; - else if (params->frequency < 250000000) bs = 0x02; - else if (params->frequency < 400000000) bs = 0x02; - else if (params->frequency < 420000000) bs = 0x02; - else if (params->frequency < 470000000) bs = 0x02; - else if (params->frequency < 600000000) bs = 0x08; - else if (params->frequency < 730000000) bs = 0x08; - else bs = 0x08; + if (params->frequency < 150000000) + cp = 0xB4; + else if (params->frequency < 173000000) + cp = 0xBC; + else if (params->frequency < 250000000) + cp = 0xB4; + else if (params->frequency < 400000000) + cp = 0xBC; + else if (params->frequency < 420000000) + cp = 0xF4; + else if (params->frequency < 470000000) + cp = 0xFC; + else if (params->frequency < 600000000) + cp = 0xBC; + else if (params->frequency < 730000000) + cp = 0xF4; + else + cp = 0xFC; + + if (params->frequency < 150000000) + bs = 0x01; + else if (params->frequency < 173000000) + bs = 0x01; + else if (params->frequency < 250000000) + bs = 0x02; + else if (params->frequency < 400000000) + bs = 0x02; + else if (params->frequency < 420000000) + bs = 0x02; + else if (params->frequency < 470000000) + bs = 0x02; + else if (params->frequency < 600000000) + bs = 0x08; + else if (params->frequency < 730000000) + bs = 0x08; + else + bs = 0x08; pllbuf[0] = 0xc2; // Note: non-linux standard PLL i2c address pllbuf[1] = div >> 8; @@ -356,19 +377,15 @@ static int advbt771_samsung_tdtc9251dh0_pll_set(struct dvb_frontend* fe, struct } static struct mt352_config advbt771_samsung_tdtc9251dh0_config = { - .demod_address = 0x0f, .demod_init = advbt771_samsung_tdtc9251dh0_demod_init, .pll_set = advbt771_samsung_tdtc9251dh0_pll_set, }; - static struct dst_config dst_config = { - .demod_address = 0x55, }; - static int or51211_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name) { struct dvb_bt8xx_card* bt = (struct dvb_bt8xx_card*) fe->dvb->priv; @@ -398,10 +415,8 @@ static void or51211_reset(struct dvb_frontend * fe) */ /* reset & PRM1,2&4 are outputs */ int ret = bttv_gpio_enable(bt->bttv_nr, 0x001F, 0x001F); - if (ret != 0) { - printk(KERN_WARNING "or51211: Init Error - Can't Reset DVR " - "(%i)\n", ret); - } + if (ret != 0) + printk(KERN_WARNING "or51211: Init Error - Can't Reset DVR (%i)\n", ret); bttv_write_gpio(bt->bttv_nr, 0x001F, 0x0000); /* Reset */ msleep(20); /* Now set for normal operation */ @@ -417,7 +432,6 @@ static void or51211_sleep(struct dvb_frontend * fe) } static struct or51211_config or51211_config = { - .demod_address = 0x15, .request_firmware = or51211_request_firmware, .setmode = or51211_setmode, @@ -425,7 +439,6 @@ static struct or51211_config or51211_config = { .sleep = or51211_sleep, }; - static int vp3021_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) { struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv; @@ -454,12 +467,84 @@ static int vp3021_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_fronten } static struct nxt6000_config vp3021_alps_tded4_config = { - .demod_address = 0x0a, .clock_inversion = 1, .pll_set = vp3021_alps_tded4_pll_set, }; +static int digitv_alps_tded4_demod_init(struct dvb_frontend* fe) +{ + static u8 mt352_clock_config [] = { 0x89, 0x38, 0x2d }; + static u8 mt352_reset [] = { 0x50, 0x80 }; + static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 }; + static u8 mt352_agc_cfg [] = { 0x67, 0x20, 0xa0 }; + static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 }; + + mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config)); + udelay(2000); + mt352_write(fe, mt352_reset, sizeof(mt352_reset)); + mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg)); + mt352_write(fe, mt352_agc_cfg,sizeof(mt352_agc_cfg)); + mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg)); + + return 0; +} + +static int digitv_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf) +{ + u32 div; + struct dvb_ofdm_parameters *op = ¶ms->u.ofdm; + + div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; + + pllbuf[0] = 0xc2; + pllbuf[1] = (div >> 8) & 0x7F; + pllbuf[2] = div & 0xFF; + pllbuf[3] = 0x85; + + dprintk("frequency %u, div %u\n", params->frequency, div); + + if (params->frequency < 470000000) + pllbuf[4] = 0x02; + else if (params->frequency > 823000000) + pllbuf[4] = 0x88; + else + pllbuf[4] = 0x08; + + if (op->bandwidth == 8) + pllbuf[4] |= 0x04; + + return 0; +} + +static void digitv_alps_tded4_reset(struct dvb_bt8xx_card *bt) +{ + /* + * Reset the frontend, must be called before trying + * to initialise the MT352 or mt352_attach + * will fail. + * + * Presumably not required for the NXT6000 frontend. + * + */ + + int ret = bttv_gpio_enable(bt->bttv_nr, 0x08, 0x08); + if (ret != 0) + printk(KERN_WARNING "digitv_alps_tded4: Init Error - Can't Reset DVR (%i)\n", ret); + + /* Pulse the reset line */ + bttv_write_gpio(bt->bttv_nr, 0x08, 0x08); /* High */ + bttv_write_gpio(bt->bttv_nr, 0x08, 0x00); /* Low */ + msleep(100); + + bttv_write_gpio(bt->bttv_nr, 0x08, 0x08); /* High */ +} + +static struct mt352_config digitv_alps_tded4_config = { + .demod_address = 0x0a, + .demod_init = digitv_alps_tded4_demod_init, + .pll_set = digitv_alps_tded4_pll_set, +}; static void frontend_init(struct dvb_bt8xx_card *card, u32 type) { @@ -473,7 +558,6 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) if (card->fe != NULL) { card->fe->ops->info.frequency_min = 174000000; card->fe->ops->info.frequency_max = 862000000; - break; } break; #endif @@ -483,17 +567,28 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) #else case BTTV_NEBULA_DIGITV: #endif + /* + * It is possible to determine the correct frontend using the I2C bus (see the Nebula SDK); + * this would be a cleaner solution than trying each frontend in turn. + */ + + /* Old Nebula (marked (c)2003 on high profile pci card) has nxt6000 demod */ card->fe = nxt6000_attach(&vp3021_alps_tded4_config, card->i2c_adapter); if (card->fe != NULL) { + dprintk ("dvb_bt8xx: an nxt6000 was detected on your digitv card\n"); break; } + + /* New Nebula (marked (c)2005 on low profile pci card) has mt352 demod */ + digitv_alps_tded4_reset(card); + card->fe = mt352_attach(&digitv_alps_tded4_config, card->i2c_adapter); + + if (card->fe != NULL) + dprintk ("dvb_bt8xx: an mt352 was detected on your digitv card\n"); break; case BTTV_AVDVBT_761: card->fe = sp887x_attach(µtune_mt7202dtf_config, card->i2c_adapter); - if (card->fe != NULL) { - break; - } break; case BTTV_AVDVBT_771: @@ -501,7 +596,6 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) if (card->fe != NULL) { card->fe->ops->info.frequency_min = 174000000; card->fe->ops->info.frequency_max = 862000000; - break; } break; @@ -522,54 +616,41 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) /* Attach other DST peripherals if any */ /* Conditional Access device */ - if (state->dst_hw_cap & DST_TYPE_HAS_CA) { + if (state->dst_hw_cap & DST_TYPE_HAS_CA) ret = dst_ca_attach(state, &card->dvb_adapter); - } - if (card->fe != NULL) { - break; - } break; case BTTV_PINNACLESAT: card->fe = cx24110_attach(&pctvsat_config, card->i2c_adapter); - if (card->fe != NULL) { - break; - } break; case BTTV_PC_HDTV: card->fe = or51211_attach(&or51211_config, card->i2c_adapter); - if (card->fe != NULL) { - break; - } break; } - if (card->fe == NULL) { + if (card->fe == NULL) printk("dvb-bt8xx: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n", card->bt->dev->vendor, card->bt->dev->device, card->bt->dev->subsystem_vendor, card->bt->dev->subsystem_device); - } else { + else if (dvb_register_frontend(&card->dvb_adapter, card->fe)) { printk("dvb-bt8xx: Frontend registration failed!\n"); if (card->fe->ops->release) card->fe->ops->release(card->fe); card->fe = NULL; } - } } static int __init dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type) { int result; - if ((result = dvb_register_adapter(&card->dvb_adapter, card->card_name, - THIS_MODULE)) < 0) { + if ((result = dvb_register_adapter(&card->dvb_adapter, card->card_name, THIS_MODULE)) < 0) { printk("dvb_bt8xx: dvb_register_adapter failed (errno = %d)\n", result); return result; - } card->dvb_adapter.priv = card; @@ -664,8 +745,7 @@ static int dvb_bt8xx_probe(struct device *dev) strncpy(card->card_name, sub->core->name, sizeof(sub->core->name)); card->i2c_adapter = &sub->core->i2c_adap; - switch(sub->core->type) - { + switch(sub->core->type) { case BTTV_PINNACLESAT: card->gpio_mode = 0x0400c060; /* should be: BT878_A_GAIN=0,BT878_A_PWRDN,BT878_DA_DPM,BT878_DA_SBR, @@ -751,7 +831,6 @@ static int dvb_bt8xx_probe(struct device *dev) kfree(card); return -EFAULT; - } init_MUTEX(&card->bt->gpio_lock); @@ -779,7 +858,8 @@ static int dvb_bt8xx_remove(struct device *dev) card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw); dvb_dmxdev_release(&card->dmxdev); dvb_dmx_release(&card->demux); - if (card->fe) dvb_unregister_frontend(card->fe); + if (card->fe) + dvb_unregister_frontend(card->fe); dvb_unregister_adapter(&card->dvb_adapter); kfree(card); diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.h b/drivers/media/dvb/bt8xx/dvb-bt8xx.h index 2923b3b0dd3..9ec8e5bd6c1 100644 --- a/drivers/media/dvb/bt8xx/dvb-bt8xx.h +++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.h @@ -2,7 +2,7 @@ * Bt8xx based DVB adapter driver * * Copyright (C) 2002,2003 Florian Schirmer <jolt@tuxbox.org> - * Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@t-online.de> + * Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@htp-tel.de> * Copyright (C) 1999-2001 Ralph Metzler & Marcus Metzler for convergence integrated media GmbH * Copyright (C) 1998,1999 Christian Theiss <mistert@rz.fh-augsburg.de> * diff --git a/drivers/media/dvb/cinergyT2/Kconfig b/drivers/media/dvb/cinergyT2/Kconfig index 226714085f5..7cf4c4a888e 100644 --- a/drivers/media/dvb/cinergyT2/Kconfig +++ b/drivers/media/dvb/cinergyT2/Kconfig @@ -77,7 +77,7 @@ config DVB_CINERGYT2_ENABLE_RC_INPUT_DEVICE config DVB_CINERGYT2_RC_QUERY_INTERVAL int "Infrared Remote Controller update interval [milliseconds]" depends on DVB_CINERGYT2_TUNING && DVB_CINERGYT2_ENABLE_RC_INPUT_DEVICE - default "100" + default "50" help If you have a very fast-repeating remote control you can try lower values, for normal consumer receivers the default value should be diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c index 9ea5747b121..6db0929ef53 100644 --- a/drivers/media/dvb/cinergyT2/cinergyT2.c +++ b/drivers/media/dvb/cinergyT2/cinergyT2.c @@ -25,7 +25,6 @@ #include <linux/config.h> #include <linux/init.h> #include <linux/module.h> -#include <linux/version.h> #include <linux/slab.h> #include <linux/usb.h> #include <linux/pci.h> @@ -36,7 +35,6 @@ #include "dvb_demux.h" #include "dvb_net.h" - #ifdef CONFIG_DVB_CINERGYT2_TUNING #define STREAM_URB_COUNT (CONFIG_DVB_CINERGYT2_STREAM_URB_COUNT) #define STREAM_BUF_SIZE (CONFIG_DVB_CINERGYT2_STREAM_BUF_SIZE) @@ -49,7 +47,7 @@ #define STREAM_URB_COUNT (32) #define STREAM_BUF_SIZE (512) /* bytes */ #define ENABLE_RC (1) - #define RC_QUERY_INTERVAL (100) /* milliseconds */ + #define RC_QUERY_INTERVAL (50) /* milliseconds */ #define QUERY_INTERVAL (333) /* milliseconds */ #endif @@ -142,6 +140,8 @@ struct cinergyt2 { struct input_dev rc_input_dev; struct work_struct rc_query_work; int rc_input_event; + u32 rc_last_code; + unsigned long last_event_jiffies; #endif }; @@ -156,7 +156,7 @@ struct cinergyt2_rc_event { uint32_t value; } __attribute__((packed)); -static const uint32_t rc_keys [] = { +static const uint32_t rc_keys[] = { CINERGYT2_RC_EVENT_TYPE_NEC, 0xfe01eb04, KEY_POWER, CINERGYT2_RC_EVENT_TYPE_NEC, 0xfd02eb04, KEY_1, CINERGYT2_RC_EVENT_TYPE_NEC, 0xfc03eb04, KEY_2, @@ -685,52 +685,68 @@ static struct dvb_device cinergyt2_fe_template = { #ifdef ENABLE_RC static void cinergyt2_query_rc (void *data) { - struct cinergyt2 *cinergyt2 = (struct cinergyt2 *) data; - char buf [1] = { CINERGYT2_EP1_GET_RC_EVENTS }; + struct cinergyt2 *cinergyt2 = data; + char buf[1] = { CINERGYT2_EP1_GET_RC_EVENTS }; struct cinergyt2_rc_event rc_events[12]; - int n, len; + int n, len, i; if (down_interruptible(&cinergyt2->sem)) return; len = cinergyt2_command(cinergyt2, buf, sizeof(buf), - (char *) rc_events, sizeof(rc_events)); - - for (n=0; len>0 && n<(len/sizeof(rc_events[0])); n++) { - int i; + (char *) rc_events, sizeof(rc_events)); + if (len < 0) + goto out; + if (len == 0) { + if (time_after(jiffies, cinergyt2->last_event_jiffies + + msecs_to_jiffies(150))) { + /* stop key repeat */ + if (cinergyt2->rc_input_event != KEY_MAX) { + dprintk(1, "rc_input_event=%d Up\n", cinergyt2->rc_input_event); + input_report_key(&cinergyt2->rc_input_dev, + cinergyt2->rc_input_event, 0); + cinergyt2->rc_input_event = KEY_MAX; + } + cinergyt2->rc_last_code = ~0; + } + goto out; + } + cinergyt2->last_event_jiffies = jiffies; -/* dprintk(1,"rc_events[%d].value = %x, type=%x\n",n,le32_to_cpu(rc_events[n].value),rc_events[n].type);*/ + for (n = 0; n < (len / sizeof(rc_events[0])); n++) { + dprintk(1, "rc_events[%d].value = %x, type=%x\n", + n, le32_to_cpu(rc_events[n].value), rc_events[n].type); if (rc_events[n].type == CINERGYT2_RC_EVENT_TYPE_NEC && - rc_events[n].value == ~0) - { - /** - * keyrepeat bit. If we would handle this properly - * we would need to emit down events as long the - * keyrepeat goes, a up event if no further - * repeat bits occur. Would need a timer to implement - * and no other driver does this, so we simply - * emit the last key up/down sequence again. - */ + rc_events[n].value == ~0) { + /* keyrepeat bit -> just repeat last rc_input_event */ } else { cinergyt2->rc_input_event = KEY_MAX; - for (i=0; i<sizeof(rc_keys)/sizeof(rc_keys[0]); i+=3) { - if (rc_keys[i+0] == rc_events[n].type && - rc_keys[i+1] == le32_to_cpu(rc_events[n].value)) - { - cinergyt2->rc_input_event = rc_keys[i+2]; + for (i = 0; i < sizeof(rc_keys) / sizeof(rc_keys[0]); i += 3) { + if (rc_keys[i + 0] == rc_events[n].type && + rc_keys[i + 1] == le32_to_cpu(rc_events[n].value)) { + cinergyt2->rc_input_event = rc_keys[i + 2]; break; } } } if (cinergyt2->rc_input_event != KEY_MAX) { - input_report_key(&cinergyt2->rc_input_dev, cinergyt2->rc_input_event, 1); - input_report_key(&cinergyt2->rc_input_dev, cinergyt2->rc_input_event, 0); - input_sync(&cinergyt2->rc_input_dev); + if (rc_events[n].value == cinergyt2->rc_last_code && + cinergyt2->rc_last_code != ~0) { + /* emit a key-up so the double event is recognized */ + dprintk(1, "rc_input_event=%d UP\n", cinergyt2->rc_input_event); + input_report_key(&cinergyt2->rc_input_dev, + cinergyt2->rc_input_event, 0); + } + dprintk(1, "rc_input_event=%d\n", cinergyt2->rc_input_event); + input_report_key(&cinergyt2->rc_input_dev, + cinergyt2->rc_input_event, 1); + cinergyt2->rc_last_code = rc_events[n].value; } } +out: schedule_delayed_work(&cinergyt2->rc_query_work, msecs_to_jiffies(RC_QUERY_INTERVAL)); @@ -772,7 +788,10 @@ static int cinergyt2_probe (struct usb_interface *intf, const struct usb_device_id *id) { struct cinergyt2 *cinergyt2; - int i, err; + int err; +#ifdef ENABLE_RC + int i; +#endif if (!(cinergyt2 = kmalloc (sizeof(struct cinergyt2), GFP_KERNEL))) { dprintk(1, "out of memory?!?\n"); @@ -828,19 +847,18 @@ static int cinergyt2_probe (struct usb_interface *intf, DVB_DEVICE_FRONTEND); #ifdef ENABLE_RC - init_input_dev(&cinergyt2->rc_input_dev); - - cinergyt2->rc_input_dev.evbit[0] = BIT(EV_KEY); - cinergyt2->rc_input_dev.keycodesize = sizeof(unsigned char); - cinergyt2->rc_input_dev.keycodemax = KEY_MAX; + cinergyt2->rc_input_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); + cinergyt2->rc_input_dev.keycodesize = 0; + cinergyt2->rc_input_dev.keycodemax = 0; cinergyt2->rc_input_dev.name = DRIVER_NAME " remote control"; - for (i=0; i<sizeof(rc_keys)/sizeof(rc_keys[0]); i+=3) - set_bit(rc_keys[i+2], cinergyt2->rc_input_dev.keybit); + for (i = 0; i < sizeof(rc_keys) / sizeof(rc_keys[0]); i += 3) + set_bit(rc_keys[i + 2], cinergyt2->rc_input_dev.keybit); input_register_device(&cinergyt2->rc_input_dev); cinergyt2->rc_input_event = KEY_MAX; + cinergyt2->rc_last_code = ~0; INIT_WORK(&cinergyt2->rc_query_work, cinergyt2_query_rc, cinergyt2); schedule_delayed_work(&cinergyt2->rc_query_work, HZ/2); diff --git a/drivers/media/dvb/dvb-core/demux.h b/drivers/media/dvb/dvb-core/demux.h index fb55eaa5c8e..9719a3b30f7 100644 --- a/drivers/media/dvb/dvb-core/demux.h +++ b/drivers/media/dvb/dvb-core/demux.h @@ -30,6 +30,7 @@ #include <linux/errno.h> #include <linux/list.h> #include <linux/time.h> +#include <linux/dvb/dmx.h> /*--------------------------------------------------------------------------*/ /* Common definitions */ @@ -124,9 +125,7 @@ struct dmx_ts_feed { u16 pid, int type, enum dmx_ts_pes pes_type, - size_t callback_length, size_t circular_buffer_size, - int descramble, struct timespec timeout); int (*start_filtering) (struct dmx_ts_feed* feed); int (*stop_filtering) (struct dmx_ts_feed* feed); @@ -159,7 +158,6 @@ struct dmx_section_feed { int (*set) (struct dmx_section_feed* feed, u16 pid, size_t circular_buffer_size, - int descramble, int check_crc); int (*allocate_filter) (struct dmx_section_feed* feed, struct dmx_section_filter** filter); @@ -207,7 +205,6 @@ struct dmx_frontend { struct list_head connectivity_list; /* List of front-ends that can be connected to a particular demux */ - void* priv; /* Pointer to private data of the API client */ enum dmx_frontend_source source; }; @@ -225,8 +222,6 @@ struct dmx_frontend { #define DMX_MEMORY_BASED_FILTERING 8 /* write() available */ #define DMX_CRC_CHECKING 16 #define DMX_TS_DESCRAMBLING 32 -#define DMX_SECTION_PAYLOAD_DESCRAMBLING 64 -#define DMX_MAC_ADDRESS_DESCRAMBLING 128 /* * Demux resource type identifier. @@ -244,9 +239,7 @@ struct dmx_frontend { struct dmx_demux { u32 capabilities; /* Bitfield of capability flags */ struct dmx_frontend* frontend; /* Front-end connected to the demux */ - struct list_head reg_list; /* List of registered demuxes */ void* priv; /* Pointer to private data of the API client */ - int users; /* Number of users */ int (*open) (struct dmx_demux* demux); int (*close) (struct dmx_demux* demux); int (*write) (struct dmx_demux* demux, const char* buf, size_t count); @@ -260,17 +253,6 @@ struct dmx_demux { dmx_section_cb callback); int (*release_section_feed) (struct dmx_demux* demux, struct dmx_section_feed* feed); - int (*descramble_mac_address) (struct dmx_demux* demux, - u8* buffer1, - size_t buffer1_length, - u8* buffer2, - size_t buffer2_length, - u16 pid); - int (*descramble_section_payload) (struct dmx_demux* demux, - u8* buffer1, - size_t buffer1_length, - u8* buffer2, size_t buffer2_length, - u16 pid); int (*add_frontend) (struct dmx_demux* demux, struct dmx_frontend* frontend); int (*remove_frontend) (struct dmx_demux* demux, @@ -282,20 +264,12 @@ struct dmx_demux { int (*get_pes_pids) (struct dmx_demux* demux, u16 *pids); + int (*get_caps) (struct dmx_demux* demux, struct dmx_caps *caps); + + int (*set_source) (struct dmx_demux* demux, const dmx_source_t *src); + int (*get_stc) (struct dmx_demux* demux, unsigned int num, u64 *stc, unsigned int *base); }; -/*--------------------------------------------------------------------------*/ -/* Demux directory */ -/*--------------------------------------------------------------------------*/ - -/* - * DMX_DIR_ENTRY(): Casts elements in the list of registered - * demuxes from the generic type struct list_head* to the type struct dmx_demux - *. - */ - -#define DMX_DIR_ENTRY(list) list_entry(list, struct dmx_demux, reg_list) - #endif /* #ifndef __DEMUX_H */ diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c index 68050cd527c..8028c3a5e28 100644 --- a/drivers/media/dvb/dvb-core/dmxdev.c +++ b/drivers/media/dvb/dvb-core/dmxdev.c @@ -571,7 +571,7 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter) return ret; } - ret=(*secfeed)->set(*secfeed, para->pid, 32768, 0, + ret=(*secfeed)->set(*secfeed, para->pid, 32768, (para->flags & DMX_CHECK_CRC) ? 1 : 0); if (ret<0) { @@ -654,7 +654,7 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter) (*tsfeed)->priv = (void *) filter; ret = (*tsfeed)->set(*tsfeed, para->pid, ts_type, ts_pes, - 188, 32768, 0, timeout); + 32768, timeout); if (ret < 0) { dmxdev->demux->release_ts_feed(dmxdev->demux, *tsfeed); @@ -929,6 +929,22 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file, dmxdev->demux->get_pes_pids(dmxdev->demux, (u16 *)parg); break; + case DMX_GET_CAPS: + if (!dmxdev->demux->get_caps) { + ret = -EINVAL; + break; + } + ret = dmxdev->demux->get_caps(dmxdev->demux, parg); + break; + + case DMX_SET_SOURCE: + if (!dmxdev->demux->set_source) { + ret = -EINVAL; + break; + } + ret = dmxdev->demux->set_source(dmxdev->demux, parg); + break; + case DMX_GET_STC: if (!dmxdev->demux->get_stc) { ret=-EINVAL; diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c index 0eb9aa711fb..88757e2634e 100644 --- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c +++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c @@ -47,7 +47,7 @@ MODULE_PARM_DESC(cam_debug, "enable verbose debug messages"); #define dprintk if (dvb_ca_en50221_debug) printk -#define INIT_TIMEOUT_SECS 5 +#define INIT_TIMEOUT_SECS 10 #define HOST_LINK_BUF_SIZE 0x200 diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c index ac9889d2228..dc476dda2b7 100644 --- a/drivers/media/dvb/dvb-core/dvb_demux.c +++ b/drivers/media/dvb/dvb-core/dvb_demux.c @@ -38,82 +38,52 @@ */ // #define DVB_DEMUX_SECTION_LOSS_LOG - -static LIST_HEAD(dmx_muxs); - - -static int dmx_register_demux(struct dmx_demux *demux) -{ - demux->users = 0; - list_add(&demux->reg_list, &dmx_muxs); - return 0; -} - -static int dmx_unregister_demux(struct dmx_demux* demux) -{ - struct list_head *pos, *n, *head=&dmx_muxs; - - list_for_each_safe (pos, n, head) { - if (DMX_DIR_ENTRY(pos) == demux) { - if (demux->users>0) - return -EINVAL; - list_del(pos); - return 0; - } - } - - return -ENODEV; -} - - /****************************************************************************** * static inlined helper functions ******************************************************************************/ - static inline u16 section_length(const u8 *buf) { - return 3+((buf[1]&0x0f)<<8)+buf[2]; + return 3 + ((buf[1] & 0x0f) << 8) + buf[2]; } - static inline u16 ts_pid(const u8 *buf) { - return ((buf[1]&0x1f)<<8)+buf[2]; + return ((buf[1] & 0x1f) << 8) + buf[2]; } - static inline u8 payload(const u8 *tsp) { - if (!(tsp[3] & 0x10)) // no payload? + if (!(tsp[3] & 0x10)) // no payload? return 0; - if (tsp[3] & 0x20) { // adaptation field? - if (tsp[4] > 183) // corrupted data? + + if (tsp[3] & 0x20) { // adaptation field? + if (tsp[4] > 183) // corrupted data? return 0; else - return 184-1-tsp[4]; + return 184 - 1 - tsp[4]; } + return 184; } - -static u32 dvb_dmx_crc32 (struct dvb_demux_feed *f, const u8 *src, size_t len) +static u32 dvb_dmx_crc32(struct dvb_demux_feed *f, const u8 *src, size_t len) { - return (f->feed.sec.crc_val = crc32_be (f->feed.sec.crc_val, src, len)); + return (f->feed.sec.crc_val = crc32_be(f->feed.sec.crc_val, src, len)); } - -static void dvb_dmx_memcopy (struct dvb_demux_feed *f, u8 *d, const u8 *s, size_t len) +static void dvb_dmx_memcopy(struct dvb_demux_feed *f, u8 *d, const u8 *s, + size_t len) { - memcpy (d, s, len); + memcpy(d, s, len); } - /****************************************************************************** * Software filter functions ******************************************************************************/ -static inline int dvb_dmx_swfilter_payload (struct dvb_demux_feed *feed, const u8 *buf) +static inline int dvb_dmx_swfilter_payload(struct dvb_demux_feed *feed, + const u8 *buf) { int count = payload(buf); int p; @@ -123,32 +93,31 @@ static inline int dvb_dmx_swfilter_payload (struct dvb_demux_feed *feed, const u if (count == 0) return -1; - p = 188-count; + p = 188 - count; /* - cc=buf[3]&0x0f; - ccok=((dvbdmxfeed->cc+1)&0x0f)==cc ? 1 : 0; - dvbdmxfeed->cc=cc; + cc = buf[3] & 0x0f; + ccok = ((feed->cc + 1) & 0x0f) == cc; + feed->cc = cc; if (!ccok) printk("missed packet!\n"); */ - if (buf[1] & 0x40) // PUSI ? + if (buf[1] & 0x40) // PUSI ? feed->peslen = 0xfffa; feed->peslen += count; - return feed->cb.ts (&buf[p], count, NULL, 0, &feed->feed.ts, DMX_OK); + return feed->cb.ts(&buf[p], count, NULL, 0, &feed->feed.ts, DMX_OK); } - -static int dvb_dmx_swfilter_sectionfilter (struct dvb_demux_feed *feed, - struct dvb_demux_filter *f) +static int dvb_dmx_swfilter_sectionfilter(struct dvb_demux_feed *feed, + struct dvb_demux_filter *f) { u8 neq = 0; int i; - for (i=0; i<DVB_DEMUX_MASK_MAX; i++) { + for (i = 0; i < DVB_DEMUX_MASK_MAX; i++) { u8 xor = f->filter.filter_value[i] ^ feed->feed.sec.secbuf[i]; if (f->maskandmode[i] & xor) @@ -160,12 +129,11 @@ static int dvb_dmx_swfilter_sectionfilter (struct dvb_demux_feed *feed, if (f->doneq && !neq) return 0; - return feed->cb.sec (feed->feed.sec.secbuf, feed->feed.sec.seclen, - NULL, 0, &f->filter, DMX_OK); + return feed->cb.sec(feed->feed.sec.secbuf, feed->feed.sec.seclen, + NULL, 0, &f->filter, DMX_OK); } - -static inline int dvb_dmx_swfilter_section_feed (struct dvb_demux_feed *feed) +static inline int dvb_dmx_swfilter_section_feed(struct dvb_demux_feed *feed) { struct dvb_demux *demux = feed->demux; struct dvb_demux_filter *f = feed->filter; @@ -195,26 +163,24 @@ static inline int dvb_dmx_swfilter_section_feed (struct dvb_demux_feed *feed) return 0; } - static void dvb_dmx_swfilter_section_new(struct dvb_demux_feed *feed) { struct dmx_section_feed *sec = &feed->feed.sec; #ifdef DVB_DEMUX_SECTION_LOSS_LOG - if(sec->secbufp < sec->tsfeedp) - { + if (sec->secbufp < sec->tsfeedp) { int i, n = sec->tsfeedp - sec->secbufp; - /* section padding is done with 0xff bytes entirely. - ** due to speed reasons, we won't check all of them - ** but just first and last - */ - if(sec->secbuf[0] != 0xff || sec->secbuf[n-1] != 0xff) - { + /* + * Section padding is done with 0xff bytes entirely. + * Due to speed reasons, we won't check all of them + * but just first and last. + */ + if (sec->secbuf[0] != 0xff || sec->secbuf[n - 1] != 0xff) { printk("dvb_demux.c section ts padding loss: %d/%d\n", n, sec->tsfeedp); printk("dvb_demux.c pad data:"); - for(i = 0; i < n; i++) + for (i = 0; i < n; i++) printk(" %02x", sec->secbuf[i]); printk("\n"); } @@ -226,82 +192,81 @@ static void dvb_dmx_swfilter_section_new(struct dvb_demux_feed *feed) } /* -** Losless Section Demux 1.4.1 by Emard -** Valsecchi Patrick: -** - middle of section A (no PUSI) -** - end of section A and start of section B -** (with PUSI pointing to the start of the second section) -** -** In this case, without feed->pusi_seen you'll receive a garbage section -** consisting of the end of section A. Basically because tsfeedp -** is incemented and the use=0 condition is not raised -** when the second packet arrives. -** -** Fix: -** when demux is started, let feed->pusi_seen = 0 to -** prevent initial feeding of garbage from the end of -** previous section. When you for the first time see PUSI=1 -** then set feed->pusi_seen = 1 -*/ -static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed, const u8 *buf, u8 len) + * Losless Section Demux 1.4.1 by Emard + * Valsecchi Patrick: + * - middle of section A (no PUSI) + * - end of section A and start of section B + * (with PUSI pointing to the start of the second section) + * + * In this case, without feed->pusi_seen you'll receive a garbage section + * consisting of the end of section A. Basically because tsfeedp + * is incemented and the use=0 condition is not raised + * when the second packet arrives. + * + * Fix: + * when demux is started, let feed->pusi_seen = 0 to + * prevent initial feeding of garbage from the end of + * previous section. When you for the first time see PUSI=1 + * then set feed->pusi_seen = 1 + */ +static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed, + const u8 *buf, u8 len) { struct dvb_demux *demux = feed->demux; struct dmx_section_feed *sec = &feed->feed.sec; u16 limit, seclen, n; - if(sec->tsfeedp >= DMX_MAX_SECFEED_SIZE) + if (sec->tsfeedp >= DMX_MAX_SECFEED_SIZE) return 0; - if(sec->tsfeedp + len > DMX_MAX_SECFEED_SIZE) - { + if (sec->tsfeedp + len > DMX_MAX_SECFEED_SIZE) { #ifdef DVB_DEMUX_SECTION_LOSS_LOG printk("dvb_demux.c section buffer full loss: %d/%d\n", - sec->tsfeedp + len - DMX_MAX_SECFEED_SIZE, DMX_MAX_SECFEED_SIZE); + sec->tsfeedp + len - DMX_MAX_SECFEED_SIZE, + DMX_MAX_SECFEED_SIZE); #endif len = DMX_MAX_SECFEED_SIZE - sec->tsfeedp; } - if(len <= 0) + if (len <= 0) return 0; demux->memcopy(feed, sec->secbuf_base + sec->tsfeedp, buf, len); sec->tsfeedp += len; - /* ----------------------------------------------------- - ** Dump all the sections we can find in the data (Emard) - */ - + /* + * Dump all the sections we can find in the data (Emard) + */ limit = sec->tsfeedp; - if(limit > DMX_MAX_SECFEED_SIZE) - return -1; /* internal error should never happen */ + if (limit > DMX_MAX_SECFEED_SIZE) + return -1; /* internal error should never happen */ /* to be sure always set secbuf */ sec->secbuf = sec->secbuf_base + sec->secbufp; - for(n = 0; sec->secbufp + 2 < limit; n++) - { + for (n = 0; sec->secbufp + 2 < limit; n++) { seclen = section_length(sec->secbuf); - if(seclen <= 0 || seclen > DMX_MAX_SECFEED_SIZE - || seclen + sec->secbufp > limit) + if (seclen <= 0 || seclen > DMX_MAX_SECFEED_SIZE + || seclen + sec->secbufp > limit) return 0; sec->seclen = seclen; sec->crc_val = ~0; /* dump [secbuf .. secbuf+seclen) */ - if(feed->pusi_seen) + if (feed->pusi_seen) dvb_dmx_swfilter_section_feed(feed); #ifdef DVB_DEMUX_SECTION_LOSS_LOG else printk("dvb_demux.c pusi not seen, discarding section data\n"); #endif - sec->secbufp += seclen; /* secbufp and secbuf moving together is */ - sec->secbuf += seclen; /* redundand but saves pointer arithmetic */ + sec->secbufp += seclen; /* secbufp and secbuf moving together is */ + sec->secbuf += seclen; /* redundant but saves pointer arithmetic */ } return 0; } - -static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 *buf) +static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, + const u8 *buf) { u8 p, count; int ccok, dc_i = 0; @@ -309,10 +274,10 @@ static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 count = payload(buf); - if (count == 0) /* count == 0 if no payload or out of range */ + if (count == 0) /* count == 0 if no payload or out of range */ return -1; - p = 188 - count; /* payload start */ + p = 188 - count; /* payload start */ cc = buf[3] & 0x0f; ccok = ((feed->cc + 1) & 0x0f) == cc; @@ -326,52 +291,53 @@ static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 if (!ccok || dc_i) { #ifdef DVB_DEMUX_SECTION_LOSS_LOG - printk("dvb_demux.c discontinuity detected %d bytes lost\n", count); - /* those bytes under sume circumstances will again be reported - ** in the following dvb_dmx_swfilter_section_new - */ + printk("dvb_demux.c discontinuity detected %d bytes lost\n", + count); + /* + * those bytes under sume circumstances will again be reported + * in the following dvb_dmx_swfilter_section_new + */ #endif - /* Discontinuity detected. Reset pusi_seen = 0 to - ** stop feeding of suspicious data until next PUSI=1 arrives - */ + /* + * Discontinuity detected. Reset pusi_seen = 0 to + * stop feeding of suspicious data until next PUSI=1 arrives + */ feed->pusi_seen = 0; dvb_dmx_swfilter_section_new(feed); - return 0; } if (buf[1] & 0x40) { - // PUSI=1 (is set), section boundary is here + /* PUSI=1 (is set), section boundary is here */ if (count > 1 && buf[p] < count) { - const u8 *before = buf+p+1; + const u8 *before = &buf[p + 1]; u8 before_len = buf[p]; - const u8 *after = before+before_len; - u8 after_len = count-1-before_len; + const u8 *after = &before[before_len]; + u8 after_len = count - 1 - before_len; - dvb_dmx_swfilter_section_copy_dump(feed, before, before_len); + dvb_dmx_swfilter_section_copy_dump(feed, before, + before_len); /* before start of new section, set pusi_seen = 1 */ feed->pusi_seen = 1; dvb_dmx_swfilter_section_new(feed); - dvb_dmx_swfilter_section_copy_dump(feed, after, after_len); + dvb_dmx_swfilter_section_copy_dump(feed, after, + after_len); } #ifdef DVB_DEMUX_SECTION_LOSS_LOG - else - if (count > 0) - printk("dvb_demux.c PUSI=1 but %d bytes lost\n", count); + else if (count > 0) + printk("dvb_demux.c PUSI=1 but %d bytes lost\n", count); #endif } else { - // PUSI=0 (is not set), no section boundary - const u8 *entire = buf+p; - u8 entire_len = count; - - dvb_dmx_swfilter_section_copy_dump(feed, entire, entire_len); + /* PUSI=0 (is not set), no section boundary */ + dvb_dmx_swfilter_section_copy_dump(feed, &buf[p], count); } + return 0; } - -static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, const u8 *buf) +static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, + const u8 *buf) { - switch(feed->type) { + switch (feed->type) { case DMX_TYPE_TS: if (!feed->feed.ts.is_filtering) break; @@ -379,7 +345,8 @@ static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, con if (feed->ts_type & TS_PAYLOAD_ONLY) dvb_dmx_swfilter_payload(feed, buf); else - feed->cb.ts(buf, 188, NULL, 0, &feed->feed.ts, DMX_OK); + feed->cb.ts(buf, 188, NULL, 0, &feed->feed.ts, + DMX_OK); } if (feed->ts_type & TS_DECODER) if (feed->demux->write_to_decoder) @@ -390,7 +357,7 @@ static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, con if (!feed->feed.sec.is_filtering) break; if (dvb_dmx_swfilter_section_packet(feed, buf) < 0) - feed->feed.sec.seclen = feed->feed.sec.secbufp=0; + feed->feed.sec.seclen = feed->feed.sec.secbufp = 0; break; default: @@ -406,7 +373,7 @@ static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, con static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf) { struct dvb_demux_feed *feed; - struct list_head *pos, *head=&demux->feed_list; + struct list_head *pos, *head = &demux->feed_list; u16 pid = ts_pid(buf); int dvr_done = 0; @@ -432,21 +399,21 @@ static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf) } } -void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf, size_t count) +void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf, + size_t count) { spin_lock(&demux->lock); while (count--) { - if(buf[0] == 0x47) { - dvb_dmx_swfilter_packet(demux, buf); - } + if (buf[0] == 0x47) + dvb_dmx_swfilter_packet(demux, buf); buf += 188; } spin_unlock(&demux->lock); } -EXPORT_SYMBOL(dvb_dmx_swfilter_packets); +EXPORT_SYMBOL(dvb_dmx_swfilter_packets); void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count) { @@ -454,8 +421,10 @@ void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count) spin_lock(&demux->lock); - if ((i = demux->tsbufp)) { - if (count < (j=188-i)) { + if (demux->tsbufp) { + i = demux->tsbufp; + j = 188 - i; + if (count < j) { memcpy(&demux->tsbuf[i], buf, count); demux->tsbufp += count; goto bailout; @@ -469,13 +438,13 @@ void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count) while (p < count) { if (buf[p] == 0x47) { - if (count-p >= 188) { - dvb_dmx_swfilter_packet(demux, buf+p); + if (count - p >= 188) { + dvb_dmx_swfilter_packet(demux, &buf[p]); p += 188; } else { - i = count-p; - memcpy(demux->tsbuf, buf+p, i); - demux->tsbufp=i; + i = count - p; + memcpy(demux->tsbuf, &buf[p], i); + demux->tsbufp = i; goto bailout; } } else @@ -485,24 +454,29 @@ void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count) bailout: spin_unlock(&demux->lock); } + EXPORT_SYMBOL(dvb_dmx_swfilter); void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count) { - int p = 0,i, j; + int p = 0, i, j; u8 tmppack[188]; + spin_lock(&demux->lock); - if ((i = demux->tsbufp)) { - if (count < (j=204-i)) { + if (demux->tsbufp) { + i = demux->tsbufp; + j = 204 - i; + if (count < j) { memcpy(&demux->tsbuf[i], buf, count); demux->tsbufp += count; goto bailout; } memcpy(&demux->tsbuf[i], buf, j); - if ((demux->tsbuf[0] == 0x47)|(demux->tsbuf[0]==0xB8)) { + if ((demux->tsbuf[0] == 0x47) | (demux->tsbuf[0] == 0xB8)) { memcpy(tmppack, demux->tsbuf, 188); - if (tmppack[0] == 0xB8) tmppack[0] = 0x47; + if (tmppack[0] == 0xB8) + tmppack[0] = 0x47; dvb_dmx_swfilter_packet(demux, tmppack); } demux->tsbufp = 0; @@ -510,16 +484,17 @@ void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count) } while (p < count) { - if ((buf[p] == 0x47)|(buf[p] == 0xB8)) { - if (count-p >= 204) { - memcpy(tmppack, buf+p, 188); - if (tmppack[0] == 0xB8) tmppack[0] = 0x47; + if ((buf[p] == 0x47) | (buf[p] == 0xB8)) { + if (count - p >= 204) { + memcpy(tmppack, &buf[p], 188); + if (tmppack[0] == 0xB8) + tmppack[0] = 0x47; dvb_dmx_swfilter_packet(demux, tmppack); p += 204; } else { - i = count-p; - memcpy(demux->tsbuf, buf+p, i); - demux->tsbufp=i; + i = count - p; + memcpy(demux->tsbuf, &buf[p], i); + demux->tsbufp = i; goto bailout; } } else { @@ -530,14 +505,14 @@ void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count) bailout: spin_unlock(&demux->lock); } -EXPORT_SYMBOL(dvb_dmx_swfilter_204); +EXPORT_SYMBOL(dvb_dmx_swfilter_204); -static struct dvb_demux_filter * dvb_dmx_filter_alloc(struct dvb_demux *demux) +static struct dvb_demux_filter *dvb_dmx_filter_alloc(struct dvb_demux *demux) { int i; - for (i=0; i<demux->filternum; i++) + for (i = 0; i < demux->filternum; i++) if (demux->filter[i].state == DMX_STATE_FREE) break; @@ -549,11 +524,11 @@ static struct dvb_demux_filter * dvb_dmx_filter_alloc(struct dvb_demux *demux) return &demux->filter[i]; } -static struct dvb_demux_feed * dvb_dmx_feed_alloc(struct dvb_demux *demux) +static struct dvb_demux_feed *dvb_dmx_feed_alloc(struct dvb_demux *demux) { int i; - for (i=0; i<demux->feednum; i++) + for (i = 0; i < demux->feednum; i++) if (demux->feed[i].state == DMX_STATE_FREE) break; @@ -581,7 +556,7 @@ static void dvb_demux_feed_add(struct dvb_demux_feed *feed) spin_lock_irq(&feed->demux->lock); if (dvb_demux_feed_find(feed)) { printk(KERN_ERR "%s: feed already in list (type=%x state=%x pid=%x)\n", - __FUNCTION__, feed->type, feed->state, feed->pid); + __FUNCTION__, feed->type, feed->state, feed->pid); goto out; } @@ -595,7 +570,7 @@ static void dvb_demux_feed_del(struct dvb_demux_feed *feed) spin_lock_irq(&feed->demux->lock); if (!(dvb_demux_feed_find(feed))) { printk(KERN_ERR "%s: feed not in list (type=%x state=%x pid=%x)\n", - __FUNCTION__, feed->type, feed->state, feed->pid); + __FUNCTION__, feed->type, feed->state, feed->pid); goto out; } @@ -604,18 +579,17 @@ out: spin_unlock_irq(&feed->demux->lock); } -static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type, - enum dmx_ts_pes pes_type, size_t callback_length, - size_t circular_buffer_size, int descramble, - struct timespec timeout) +static int dmx_ts_feed_set(struct dmx_ts_feed *ts_feed, u16 pid, int ts_type, + enum dmx_ts_pes pes_type, + size_t circular_buffer_size, struct timespec timeout) { - struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed; + struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed; struct dvb_demux *demux = feed->demux; if (pid > DMX_MAX_PID) return -EINVAL; - if (down_interruptible (&demux->mutex)) + if (down_interruptible(&demux->mutex)) return -ERESTARTSYS; if (ts_type & TS_DECODER) { @@ -638,20 +612,13 @@ static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type, feed->pid = pid; feed->buffer_size = circular_buffer_size; - feed->descramble = descramble; feed->timeout = timeout; - feed->cb_length = callback_length; feed->ts_type = ts_type; feed->pes_type = pes_type; - if (feed->descramble) { - up(&demux->mutex); - return -ENOSYS; - } - if (feed->buffer_size) { #ifdef NOBUFS - feed->buffer=NULL; + feed->buffer = NULL; #else feed->buffer = vmalloc(feed->buffer_size); if (!feed->buffer) { @@ -667,14 +634,13 @@ static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type, return 0; } - -static int dmx_ts_feed_start_filtering(struct dmx_ts_feed* ts_feed) +static int dmx_ts_feed_start_filtering(struct dmx_ts_feed *ts_feed) { - struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed; + struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed; struct dvb_demux *demux = feed->demux; int ret; - if (down_interruptible (&demux->mutex)) + if (down_interruptible(&demux->mutex)) return -ERESTARTSYS; if (feed->state != DMX_STATE_READY || feed->type != DMX_TYPE_TS) { @@ -701,13 +667,13 @@ static int dmx_ts_feed_start_filtering(struct dmx_ts_feed* ts_feed) return 0; } -static int dmx_ts_feed_stop_filtering(struct dmx_ts_feed* ts_feed) +static int dmx_ts_feed_stop_filtering(struct dmx_ts_feed *ts_feed) { - struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed; + struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed; struct dvb_demux *demux = feed->demux; int ret; - if (down_interruptible (&demux->mutex)) + if (down_interruptible(&demux->mutex)) return -ERESTARTSYS; if (feed->state < DMX_STATE_GO) { @@ -731,13 +697,14 @@ static int dmx_ts_feed_stop_filtering(struct dmx_ts_feed* ts_feed) return ret; } -static int dvbdmx_allocate_ts_feed (struct dmx_demux *dmx, struct dmx_ts_feed **ts_feed, - dmx_ts_cb callback) +static int dvbdmx_allocate_ts_feed(struct dmx_demux *dmx, + struct dmx_ts_feed **ts_feed, + dmx_ts_cb callback) { - struct dvb_demux *demux = (struct dvb_demux *) dmx; + struct dvb_demux *demux = (struct dvb_demux *)dmx; struct dvb_demux_feed *feed; - if (down_interruptible (&demux->mutex)) + if (down_interruptible(&demux->mutex)) return -ERESTARTSYS; if (!(feed = dvb_dmx_feed_alloc(demux))) { @@ -760,7 +727,6 @@ static int dvbdmx_allocate_ts_feed (struct dmx_demux *dmx, struct dmx_ts_feed ** (*ts_feed)->stop_filtering = dmx_ts_feed_stop_filtering; (*ts_feed)->set = dmx_ts_feed_set; - if (!(feed->filter = dvb_dmx_filter_alloc(demux))) { feed->state = DMX_STATE_FREE; up(&demux->mutex); @@ -776,22 +742,22 @@ static int dvbdmx_allocate_ts_feed (struct dmx_demux *dmx, struct dmx_ts_feed ** return 0; } -static int dvbdmx_release_ts_feed(struct dmx_demux *dmx, struct dmx_ts_feed *ts_feed) +static int dvbdmx_release_ts_feed(struct dmx_demux *dmx, + struct dmx_ts_feed *ts_feed) { - struct dvb_demux *demux = (struct dvb_demux *) dmx; - struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed; + struct dvb_demux *demux = (struct dvb_demux *)dmx; + struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed; - if (down_interruptible (&demux->mutex)) + if (down_interruptible(&demux->mutex)) return -ERESTARTSYS; if (feed->state == DMX_STATE_FREE) { up(&demux->mutex); return -EINVAL; } - #ifndef NOBUFS vfree(feed->buffer); - feed->buffer=0; + feed->buffer = NULL; #endif feed->state = DMX_STATE_FREE; @@ -808,19 +774,18 @@ static int dvbdmx_release_ts_feed(struct dmx_demux *dmx, struct dmx_ts_feed *ts_ return 0; } - /****************************************************************************** * dmx_section_feed API calls ******************************************************************************/ -static int dmx_section_feed_allocate_filter(struct dmx_section_feed* feed, - struct dmx_section_filter** filter) +static int dmx_section_feed_allocate_filter(struct dmx_section_feed *feed, + struct dmx_section_filter **filter) { - struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; + struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; struct dvb_demux *dvbdemux = dvbdmxfeed->demux; struct dvb_demux_filter *dvbdmxfilter; - if (down_interruptible (&dvbdemux->mutex)) + if (down_interruptible(&dvbdemux->mutex)) return -ERESTARTSYS; dvbdmxfilter = dvb_dmx_filter_alloc(dvbdemux); @@ -844,36 +809,29 @@ static int dmx_section_feed_allocate_filter(struct dmx_section_feed* feed, return 0; } - -static int dmx_section_feed_set(struct dmx_section_feed* feed, - u16 pid, size_t circular_buffer_size, - int descramble, int check_crc) +static int dmx_section_feed_set(struct dmx_section_feed *feed, + u16 pid, size_t circular_buffer_size, + int check_crc) { - struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; + struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; struct dvb_demux *dvbdmx = dvbdmxfeed->demux; if (pid > 0x1fff) return -EINVAL; - if (down_interruptible (&dvbdmx->mutex)) + if (down_interruptible(&dvbdmx->mutex)) return -ERESTARTSYS; dvb_demux_feed_add(dvbdmxfeed); dvbdmxfeed->pid = pid; dvbdmxfeed->buffer_size = circular_buffer_size; - dvbdmxfeed->descramble = descramble; - if (dvbdmxfeed->descramble) { - up(&dvbdmx->mutex); - return -ENOSYS; - } - dvbdmxfeed->feed.sec.check_crc = check_crc; #ifdef NOBUFS dvbdmxfeed->buffer = NULL; #else - dvbdmxfeed->buffer=vmalloc(dvbdmxfeed->buffer_size); + dvbdmxfeed->buffer = vmalloc(dvbdmxfeed->buffer_size); if (!dvbdmxfeed->buffer) { up(&dvbdmx->mutex); return -ENOMEM; @@ -885,7 +843,6 @@ static int dmx_section_feed_set(struct dmx_section_feed* feed, return 0; } - static void prepare_secfilters(struct dvb_demux_feed *dvbdmxfeed) { int i; @@ -893,12 +850,12 @@ static void prepare_secfilters(struct dvb_demux_feed *dvbdmxfeed) struct dmx_section_filter *sf; u8 mask, mode, doneq; - if (!(f=dvbdmxfeed->filter)) + if (!(f = dvbdmxfeed->filter)) return; do { sf = &f->filter; doneq = 0; - for (i=0; i<DVB_DEMUX_MASK_MAX; i++) { + for (i = 0; i < DVB_DEMUX_MASK_MAX; i++) { mode = sf->filter_mode[i]; mask = sf->filter_mask[i]; f->maskandmode[i] = mask & mode; @@ -908,14 +865,13 @@ static void prepare_secfilters(struct dvb_demux_feed *dvbdmxfeed) } while ((f = f->next)); } - static int dmx_section_feed_start_filtering(struct dmx_section_feed *feed) { - struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; + struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; struct dvb_demux *dvbdmx = dvbdmxfeed->demux; int ret; - if (down_interruptible (&dvbdmx->mutex)) + if (down_interruptible(&dvbdmx->mutex)) return -ERESTARTSYS; if (feed->is_filtering) { @@ -954,14 +910,13 @@ static int dmx_section_feed_start_filtering(struct dmx_section_feed *feed) return 0; } - -static int dmx_section_feed_stop_filtering(struct dmx_section_feed* feed) +static int dmx_section_feed_stop_filtering(struct dmx_section_feed *feed) { - struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; + struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; struct dvb_demux *dvbdmx = dvbdmxfeed->demux; int ret; - if (down_interruptible (&dvbdmx->mutex)) + if (down_interruptible(&dvbdmx->mutex)) return -ERESTARTSYS; if (!dvbdmx->stop_feed) { @@ -980,15 +935,14 @@ static int dmx_section_feed_stop_filtering(struct dmx_section_feed* feed) return ret; } - static int dmx_section_feed_release_filter(struct dmx_section_feed *feed, - struct dmx_section_filter* filter) + struct dmx_section_filter *filter) { - struct dvb_demux_filter *dvbdmxfilter = (struct dvb_demux_filter *) filter, *f; - struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; + struct dvb_demux_filter *dvbdmxfilter = (struct dvb_demux_filter *)filter, *f; + struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; struct dvb_demux *dvbdmx = dvbdmxfeed->demux; - if (down_interruptible (&dvbdmx->mutex)) + if (down_interruptible(&dvbdmx->mutex)) return -ERESTARTSYS; if (dvbdmxfilter->feed != dvbdmxfeed) { @@ -1005,7 +959,7 @@ static int dmx_section_feed_release_filter(struct dmx_section_feed *feed, if (f == dvbdmxfilter) { dvbdmxfeed->filter = dvbdmxfilter->next; } else { - while(f->next != dvbdmxfilter) + while (f->next != dvbdmxfilter) f = f->next; f->next = f->next->next; } @@ -1020,10 +974,10 @@ static int dvbdmx_allocate_section_feed(struct dmx_demux *demux, struct dmx_section_feed **feed, dmx_section_cb callback) { - struct dvb_demux *dvbdmx = (struct dvb_demux *) demux; + struct dvb_demux *dvbdmx = (struct dvb_demux *)demux; struct dvb_demux_feed *dvbdmxfeed; - if (down_interruptible (&dvbdmx->mutex)) + if (down_interruptible(&dvbdmx->mutex)) return -ERESTARTSYS; if (!(dvbdmxfeed = dvb_dmx_feed_alloc(dvbdmx))) { @@ -1041,7 +995,7 @@ static int dvbdmx_allocate_section_feed(struct dmx_demux *demux, dvbdmxfeed->filter = NULL; dvbdmxfeed->buffer = NULL; - (*feed)=&dvbdmxfeed->feed.sec; + (*feed) = &dvbdmxfeed->feed.sec; (*feed)->is_filtering = 0; (*feed)->parent = demux; (*feed)->priv = NULL; @@ -1059,21 +1013,21 @@ static int dvbdmx_allocate_section_feed(struct dmx_demux *demux, static int dvbdmx_release_section_feed(struct dmx_demux *demux, struct dmx_section_feed *feed) { - struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; - struct dvb_demux *dvbdmx = (struct dvb_demux *) demux; + struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; + struct dvb_demux *dvbdmx = (struct dvb_demux *)demux; - if (down_interruptible (&dvbdmx->mutex)) + if (down_interruptible(&dvbdmx->mutex)) return -ERESTARTSYS; - if (dvbdmxfeed->state==DMX_STATE_FREE) { + if (dvbdmxfeed->state == DMX_STATE_FREE) { up(&dvbdmx->mutex); return -EINVAL; } #ifndef NOBUFS vfree(dvbdmxfeed->buffer); - dvbdmxfeed->buffer=0; + dvbdmxfeed->buffer = NULL; #endif - dvbdmxfeed->state=DMX_STATE_FREE; + dvbdmxfeed->state = DMX_STATE_FREE; dvb_demux_feed_del(dvbdmxfeed); @@ -1083,14 +1037,13 @@ static int dvbdmx_release_section_feed(struct dmx_demux *demux, return 0; } - /****************************************************************************** * dvb_demux kernel data API calls ******************************************************************************/ static int dvbdmx_open(struct dmx_demux *demux) { - struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; if (dvbdemux->users >= MAX_DVB_DEMUX_USERS) return -EUSERS; @@ -1099,10 +1052,9 @@ static int dvbdmx_open(struct dmx_demux *demux) return 0; } - static int dvbdmx_close(struct dmx_demux *demux) { - struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; if (dvbdemux->users == 0) return -ENODEV; @@ -1112,15 +1064,14 @@ static int dvbdmx_close(struct dmx_demux *demux) return 0; } - static int dvbdmx_write(struct dmx_demux *demux, const char *buf, size_t count) { - struct dvb_demux *dvbdemux=(struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; if ((!demux->frontend) || (demux->frontend->source != DMX_MEMORY_FE)) return -EINVAL; - if (down_interruptible (&dvbdemux->mutex)) + if (down_interruptible(&dvbdemux->mutex)) return -ERESTARTSYS; dvb_dmx_swfilter(dvbdemux, buf, count); up(&dvbdemux->mutex); @@ -1130,10 +1081,10 @@ static int dvbdmx_write(struct dmx_demux *demux, const char *buf, size_t count) return count; } - -static int dvbdmx_add_frontend(struct dmx_demux *demux, struct dmx_frontend *frontend) +static int dvbdmx_add_frontend(struct dmx_demux *demux, + struct dmx_frontend *frontend) { - struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; struct list_head *head = &dvbdemux->frontend_list; list_add(&(frontend->connectivity_list), head); @@ -1141,13 +1092,13 @@ static int dvbdmx_add_frontend(struct dmx_demux *demux, struct dmx_frontend *fro return 0; } - -static int dvbdmx_remove_frontend(struct dmx_demux *demux, struct dmx_frontend *frontend) +static int dvbdmx_remove_frontend(struct dmx_demux *demux, + struct dmx_frontend *frontend) { - struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; struct list_head *pos, *n, *head = &dvbdemux->frontend_list; - list_for_each_safe (pos, n, head) { + list_for_each_safe(pos, n, head) { if (DMX_FE_ENTRY(pos) == frontend) { list_del(pos); return 0; @@ -1157,25 +1108,25 @@ static int dvbdmx_remove_frontend(struct dmx_demux *demux, struct dmx_frontend * return -ENODEV; } - -static struct list_head * dvbdmx_get_frontends(struct dmx_demux *demux) +static struct list_head *dvbdmx_get_frontends(struct dmx_demux *demux) { - struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; if (list_empty(&dvbdemux->frontend_list)) return NULL; + return &dvbdemux->frontend_list; } - -static int dvbdmx_connect_frontend(struct dmx_demux *demux, struct dmx_frontend *frontend) +static int dvbdmx_connect_frontend(struct dmx_demux *demux, + struct dmx_frontend *frontend) { - struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; if (demux->frontend) return -EINVAL; - if (down_interruptible (&dvbdemux->mutex)) + if (down_interruptible(&dvbdemux->mutex)) return -ERESTARTSYS; demux->frontend = frontend; @@ -1183,12 +1134,11 @@ static int dvbdmx_connect_frontend(struct dmx_demux *demux, struct dmx_frontend return 0; } - static int dvbdmx_disconnect_frontend(struct dmx_demux *demux) { - struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; - if (down_interruptible (&dvbdemux->mutex)) + if (down_interruptible(&dvbdemux->mutex)) return -ERESTARTSYS; demux->frontend = NULL; @@ -1196,44 +1146,42 @@ static int dvbdmx_disconnect_frontend(struct dmx_demux *demux) return 0; } - -static int dvbdmx_get_pes_pids(struct dmx_demux *demux, u16 *pids) +static int dvbdmx_get_pes_pids(struct dmx_demux *demux, u16 * pids) { - struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; + struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; - memcpy(pids, dvbdemux->pids, 5*sizeof(u16)); + memcpy(pids, dvbdemux->pids, 5 * sizeof(u16)); return 0; } - int dvb_dmx_init(struct dvb_demux *dvbdemux) { - int i, err; + int i; struct dmx_demux *dmx = &dvbdemux->dmx; dvbdemux->users = 0; - dvbdemux->filter = vmalloc(dvbdemux->filternum*sizeof(struct dvb_demux_filter)); + dvbdemux->filter = vmalloc(dvbdemux->filternum * sizeof(struct dvb_demux_filter)); if (!dvbdemux->filter) return -ENOMEM; - dvbdemux->feed = vmalloc(dvbdemux->feednum*sizeof(struct dvb_demux_feed)); + dvbdemux->feed = vmalloc(dvbdemux->feednum * sizeof(struct dvb_demux_feed)); if (!dvbdemux->feed) { vfree(dvbdemux->filter); return -ENOMEM; } - for (i=0; i<dvbdemux->filternum; i++) { + for (i = 0; i < dvbdemux->filternum; i++) { dvbdemux->filter[i].state = DMX_STATE_FREE; dvbdemux->filter[i].index = i; } - for (i=0; i<dvbdemux->feednum; i++) { + for (i = 0; i < dvbdemux->feednum; i++) { dvbdemux->feed[i].state = DMX_STATE_FREE; dvbdemux->feed[i].index = i; } - dvbdemux->frontend_list.next= - dvbdemux->frontend_list.prev= - &dvbdemux->frontend_list; - for (i=0; i<DMX_TS_PES_OTHER; i++) { + + INIT_LIST_HEAD(&dvbdemux->frontend_list); + + for (i = 0; i < DMX_TS_PES_OTHER; i++) { dvbdemux->pesfilter[i] = NULL; dvbdemux->pids[i] = 0xffff; } @@ -1247,12 +1195,11 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux) if (!dvbdemux->check_crc32) dvbdemux->check_crc32 = dvb_dmx_crc32; - if (!dvbdemux->memcopy) - dvbdemux->memcopy = dvb_dmx_memcopy; + if (!dvbdemux->memcopy) + dvbdemux->memcopy = dvb_dmx_memcopy; dmx->frontend = NULL; - dmx->reg_list.prev = dmx->reg_list.next = &dmx->reg_list; - dmx->priv = (void *) dvbdemux; + dmx->priv = dvbdemux; dmx->open = dvbdmx_open; dmx->close = dvbdmx_close; dmx->write = dvbdmx_write; @@ -1261,9 +1208,6 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux) dmx->allocate_section_feed = dvbdmx_allocate_section_feed; dmx->release_section_feed = dvbdmx_release_section_feed; - dmx->descramble_mac_address = NULL; - dmx->descramble_section_payload = NULL; - dmx->add_frontend = dvbdmx_add_frontend; dmx->remove_frontend = dvbdmx_remove_frontend; dmx->get_frontends = dvbdmx_get_frontends; @@ -1274,21 +1218,15 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux) sema_init(&dvbdemux->mutex, 1); spin_lock_init(&dvbdemux->lock); - if ((err = dmx_register_demux(dmx)) < 0) - return err; - return 0; } -EXPORT_SYMBOL(dvb_dmx_init); +EXPORT_SYMBOL(dvb_dmx_init); -int dvb_dmx_release(struct dvb_demux *dvbdemux) +void dvb_dmx_release(struct dvb_demux *dvbdemux) { - struct dmx_demux *dmx = &dvbdemux->dmx; - - dmx_unregister_demux(dmx); vfree(dvbdemux->filter); vfree(dvbdemux->feed); - return 0; } + EXPORT_SYMBOL(dvb_dmx_release); diff --git a/drivers/media/dvb/dvb-core/dvb_demux.h b/drivers/media/dvb/dvb-core/dvb_demux.h index c09beb39162..0cc888339d5 100644 --- a/drivers/media/dvb/dvb-core/dvb_demux.h +++ b/drivers/media/dvb/dvb-core/dvb_demux.h @@ -20,7 +20,6 @@ * */ - #ifndef _DVB_DEMUX_H_ #define _DVB_DEMUX_H_ @@ -44,103 +43,98 @@ #define DVB_DEMUX_MASK_MAX 18 struct dvb_demux_filter { - struct dmx_section_filter filter; - u8 maskandmode [DMX_MAX_FILTER_SIZE]; - u8 maskandnotmode [DMX_MAX_FILTER_SIZE]; + struct dmx_section_filter filter; + u8 maskandmode[DMX_MAX_FILTER_SIZE]; + u8 maskandnotmode[DMX_MAX_FILTER_SIZE]; int doneq; - struct dvb_demux_filter *next; - struct dvb_demux_feed *feed; - int index; - int state; - int type; - int pesto; - - u16 handle; - u16 hw_handle; - struct timer_list timer; - int ts_state; -}; + struct dvb_demux_filter *next; + struct dvb_demux_feed *feed; + int index; + int state; + int type; + u16 hw_handle; + struct timer_list timer; +}; #define DMX_FEED_ENTRY(pos) list_entry(pos, struct dvb_demux_feed, list_head) struct dvb_demux_feed { - union { - struct dmx_ts_feed ts; - struct dmx_section_feed sec; + union { + struct dmx_ts_feed ts; + struct dmx_section_feed sec; } feed; - union { - dmx_ts_cb ts; - dmx_section_cb sec; + union { + dmx_ts_cb ts; + dmx_section_cb sec; } cb; - struct dvb_demux *demux; + struct dvb_demux *demux; void *priv; - int type; - int state; - u16 pid; - u8 *buffer; - int buffer_size; - int descramble; + int type; + int state; + u16 pid; + u8 *buffer; + int buffer_size; - struct timespec timeout; - struct dvb_demux_filter *filter; - int cb_length; + struct timespec timeout; + struct dvb_demux_filter *filter; - int ts_type; - enum dmx_ts_pes pes_type; + int ts_type; + enum dmx_ts_pes pes_type; - int cc; - int pusi_seen; /* prevents feeding of garbage from previous section */ + int cc; + int pusi_seen; /* prevents feeding of garbage from previous section */ - u16 peslen; + u16 peslen; struct list_head list_head; - int index; /* a unique index for each feed (can be used as hardware pid filter index) */ + unsigned int index; /* a unique index for each feed (can be used as hardware pid filter index) */ }; struct dvb_demux { - struct dmx_demux dmx; - void *priv; - int filternum; - int feednum; - int (*start_feed) (struct dvb_demux_feed *feed); - int (*stop_feed) (struct dvb_demux_feed *feed); - int (*write_to_decoder) (struct dvb_demux_feed *feed, + struct dmx_demux dmx; + void *priv; + int filternum; + int feednum; + int (*start_feed)(struct dvb_demux_feed *feed); + int (*stop_feed)(struct dvb_demux_feed *feed); + int (*write_to_decoder)(struct dvb_demux_feed *feed, const u8 *buf, size_t len); - u32 (*check_crc32) (struct dvb_demux_feed *feed, + u32 (*check_crc32)(struct dvb_demux_feed *feed, const u8 *buf, size_t len); - void (*memcopy) (struct dvb_demux_feed *feed, u8 *dst, + void (*memcopy)(struct dvb_demux_feed *feed, u8 *dst, const u8 *src, size_t len); - int users; + int users; #define MAX_DVB_DEMUX_USERS 10 - struct dvb_demux_filter *filter; - struct dvb_demux_feed *feed; + struct dvb_demux_filter *filter; + struct dvb_demux_feed *feed; - struct list_head frontend_list; + struct list_head frontend_list; - struct dvb_demux_feed *pesfilter[DMX_TS_PES_OTHER]; - u16 pids[DMX_TS_PES_OTHER]; - int playing; - int recording; + struct dvb_demux_feed *pesfilter[DMX_TS_PES_OTHER]; + u16 pids[DMX_TS_PES_OTHER]; + int playing; + int recording; #define DMX_MAX_PID 0x2000 struct list_head feed_list; - u8 tsbuf[204]; - int tsbufp; + u8 tsbuf[204]; + int tsbufp; struct semaphore mutex; spinlock_t lock; }; - int dvb_dmx_init(struct dvb_demux *dvbdemux); -int dvb_dmx_release(struct dvb_demux *dvbdemux); -void dvb_dmx_swfilter_packets(struct dvb_demux *dvbdmx, const u8 *buf, size_t count); +void dvb_dmx_release(struct dvb_demux *dvbdemux); +void dvb_dmx_swfilter_packets(struct dvb_demux *dvbdmx, const u8 *buf, + size_t count); void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count); -void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count); +void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, + size_t count); #endif /* _DVB_DEMUX_H_ */ diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c index 6a968c346a3..87935490bfb 100644 --- a/drivers/media/dvb/dvb-core/dvb_net.c +++ b/drivers/media/dvb/dvb-core/dvb_net.c @@ -62,7 +62,6 @@ #include <linux/uio.h> #include <asm/uaccess.h> #include <linux/crc32.h> -#include <linux/version.h> #include "dvb_demux.h" #include "dvb_net.h" @@ -171,11 +170,7 @@ static unsigned short dvb_net_eth_type_trans(struct sk_buff *skb, skb->mac.raw=skb->data; skb_pull(skb,dev->hard_header_len); -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,8) - eth = skb->mac.ethernet; -#else eth = eth_hdr(skb); -#endif if (*eth->h_dest & 1) { if(memcmp(eth->h_dest,dev->broadcast, ETH_ALEN)==0) @@ -908,7 +903,7 @@ static int dvb_net_feed_start(struct net_device *dev) return ret; } - ret = priv->secfeed->set(priv->secfeed, priv->pid, 32768, 0, 1); + ret = priv->secfeed->set(priv->secfeed, priv->pid, 32768, 1); if (ret<0) { printk("%s: could not set section feed\n", dev->name); @@ -960,9 +955,7 @@ static int dvb_net_feed_start(struct net_device *dev) priv->tsfeed->priv = (void *)dev; ret = priv->tsfeed->set(priv->tsfeed, priv->pid, TS_PACKET, DMX_TS_PES_OTHER, - 188 * 100, /* nr. of bytes delivered per callback */ 32768, /* circular buffer size */ - 0, /* descramble */ timeout); if (ret < 0) { diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig index 612e5b087b1..54e2b29076b 100644 --- a/drivers/media/dvb/dvb-usb/Kconfig +++ b/drivers/media/dvb/dvb-usb/Kconfig @@ -93,13 +93,30 @@ config DVB_USB_DIGITV Say Y here to support the Nebula Electronics uDigitV USB2.0 DVB-T receiver. config DVB_USB_VP7045 - tristate "TwinhanDTV Alpha/MagicBoxII and DNTV tinyUSB2 DVB-T USB2.0 support" + tristate "TwinhanDTV Alpha/MagicBoxII, DNTV tinyUSB2, Beetle USB2.0 support" depends on DVB_USB help Say Y here to support the + TwinhanDTV Alpha (stick) (VP-7045), - TwinhanDTV MagicBox II (VP-7046) and - DigitalNow TinyUSB 2 DVB-t DVB-T USB2.0 receivers. + TwinhanDTV MagicBox II (VP-7046), + DigitalNow TinyUSB 2 DVB-t, + DigitalRise USB 2.0 Ter (Beetle) and + TYPHOON DVB-T USB DRIVE + + DVB-T USB2.0 receivers. + +config DVB_USB_VP702X + tristate "TwinhanDTV StarBox and clones DVB-S USB2.0 support" + depends on DVB_USB + help + Say Y here to support the + + TwinhanDTV StarBox, + DigitalRise USB Starbox and + TYPHOON DVB-S USB 2.0 BOX + + DVB-S USB2.0 receivers. config DVB_USB_NOVA_T_USB2 tristate "Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 support" diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile index 746d87ed6f3..2dc9aad9681 100644 --- a/drivers/media/dvb/dvb-usb/Makefile +++ b/drivers/media/dvb/dvb-usb/Makefile @@ -4,6 +4,9 @@ obj-$(CONFIG_DVB_USB) += dvb-usb.o dvb-usb-vp7045-objs = vp7045.o vp7045-fe.o obj-$(CONFIG_DVB_USB_VP7045) += dvb-usb-vp7045.o +dvb-usb-vp702x-objs = vp702x.o vp702x-fe.o +obj-$(CONFIG_DVB_USB_VP702X) += dvb-usb-vp702x.o + dvb-usb-dtt200u-objs = dtt200u.o dtt200u-fe.o obj-$(CONFIG_DVB_USB_DTT200U) += dvb-usb-dtt200u.o diff --git a/drivers/media/dvb/dvb-usb/a800.c b/drivers/media/dvb/dvb-usb/a800.c index f2fcc2f1f84..e55322ef76b 100644 --- a/drivers/media/dvb/dvb-usb/a800.c +++ b/drivers/media/dvb/dvb-usb/a800.c @@ -90,7 +90,7 @@ static struct dvb_usb_properties a800_properties; static int a800_probe(struct usb_interface *intf, const struct usb_device_id *id) { - return dvb_usb_device_init(intf,&a800_properties,THIS_MODULE); + return dvb_usb_device_init(intf,&a800_properties,THIS_MODULE,NULL); } /* do not change the order of the ID table */ diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c index 9e96a188f1e..3fe383f4bb4 100644 --- a/drivers/media/dvb/dvb-usb/cxusb.c +++ b/drivers/media/dvb/dvb-usb/cxusb.c @@ -48,35 +48,26 @@ static int cxusb_ctrl_msg(struct dvb_usb_device *d, return 0; } -/* I2C */ -static void cxusb_set_i2c_path(struct dvb_usb_device *d, enum cxusb_i2c_pathes path) +/* GPIO */ +static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff) { struct cxusb_state *st = d->priv; u8 o[2],i; - if (path == st->cur_i2c_path) + if (st->gpio_write_state[GPIO_TUNER] == onoff) return; - o[0] = IOCTL_SET_I2C_PATH; - switch (path) { - case PATH_CX22702: - o[1] = 0; - break; - case PATH_TUNER_OTHER: - o[1] = 1; - break; - default: - err("unkown i2c path"); - return; - } - cxusb_ctrl_msg(d,CMD_IOCTL,o,2,&i,1); + o[0] = GPIO_TUNER; + o[1] = onoff; + cxusb_ctrl_msg(d,CMD_GPIO_WRITE,o,2,&i,1); if (i != 0x01) - deb_info("i2c_path setting failed.\n"); + deb_info("gpio_write failed.\n"); - st->cur_i2c_path = path; + st->gpio_write_state[GPIO_TUNER] = onoff; } +/* I2C */ static int cxusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num) { struct dvb_usb_device *d = i2c_get_adapdata(adap); @@ -92,10 +83,10 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num) switch (msg[i].addr) { case 0x63: - cxusb_set_i2c_path(d,PATH_CX22702); + cxusb_gpio_tuner(d,0); break; default: - cxusb_set_i2c_path(d,PATH_TUNER_OTHER); + cxusb_gpio_tuner(d,1); break; } @@ -147,16 +138,20 @@ static struct i2c_algorithm cxusb_i2c_algo = { static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff) { - return 0; + u8 b = 0; + if (onoff) + return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0); + else + return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0); } static int cxusb_streaming_ctrl(struct dvb_usb_device *d, int onoff) { u8 buf[2] = { 0x03, 0x00 }; if (onoff) - cxusb_ctrl_msg(d,0x36, buf, 2, NULL, 0); + cxusb_ctrl_msg(d,CMD_STREAMING_ON, buf, 2, NULL, 0); else - cxusb_ctrl_msg(d,0x37, NULL, 0, NULL, 0); + cxusb_ctrl_msg(d,CMD_STREAMING_OFF, NULL, 0, NULL, 0); return 0; } @@ -182,22 +177,11 @@ static int cxusb_tuner_attach(struct dvb_usb_device *d) static int cxusb_frontend_attach(struct dvb_usb_device *d) { - u8 buf[2] = { 0x03, 0x00 }; - u8 b = 0; - - if (usb_set_interface(d->udev,0,0) < 0) - err("set interface to alts=0 failed"); - - cxusb_ctrl_msg(d,0xde,&b,0,NULL,0); - cxusb_set_i2c_path(d,PATH_TUNER_OTHER); - cxusb_ctrl_msg(d,CMD_POWER_OFF, NULL, 0, &b, 1); - + u8 b; if (usb_set_interface(d->udev,0,6) < 0) err("set interface failed"); - cxusb_ctrl_msg(d,0x36, buf, 2, NULL, 0); - cxusb_set_i2c_path(d,PATH_CX22702); - cxusb_ctrl_msg(d,CMD_POWER_ON, NULL, 0, &b, 1); + cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, &b, 1); if ((d->fe = cx22702_attach(&cxusb_cx22702_config, &d->i2c_adap)) != NULL) return 0; @@ -211,7 +195,7 @@ static struct dvb_usb_properties cxusb_properties; static int cxusb_probe(struct usb_interface *intf, const struct usb_device_id *id) { - return dvb_usb_device_init(intf,&cxusb_properties,THIS_MODULE); + return dvb_usb_device_init(intf,&cxusb_properties,THIS_MODULE,NULL); } static struct usb_device_id cxusb_table [] = { @@ -237,14 +221,12 @@ static struct dvb_usb_properties cxusb_properties = { .generic_bulk_ctrl_endpoint = 0x01, /* parameter for the MPEG2-data transfer */ .urb = { - .type = DVB_USB_ISOC, + .type = DVB_USB_BULK, .count = 5, .endpoint = 0x02, .u = { - .isoc = { - .framesperurb = 32, - .framesize = 940, - .interval = 5, + .bulk = { + .buffersize = 8192, } } }, diff --git a/drivers/media/dvb/dvb-usb/cxusb.h b/drivers/media/dvb/dvb-usb/cxusb.h index 1d79016e319..135c2a81f58 100644 --- a/drivers/media/dvb/dvb-usb/cxusb.h +++ b/drivers/media/dvb/dvb-usb/cxusb.h @@ -1,30 +1,31 @@ #ifndef _DVB_USB_CXUSB_H_ #define _DVB_USB_CXUSB_H_ -#define DVB_USB_LOG_PREFIX "digitv" +#define DVB_USB_LOG_PREFIX "cxusb" #include "dvb-usb.h" extern int dvb_usb_cxusb_debug; #define deb_info(args...) dprintk(dvb_usb_cxusb_debug,0x01,args) /* usb commands - some of it are guesses, don't have a reference yet */ -#define CMD_I2C_WRITE 0x08 -#define CMD_I2C_READ 0x09 +#define CMD_I2C_WRITE 0x08 +#define CMD_I2C_READ 0x09 -#define CMD_IOCTL 0x0e -#define IOCTL_SET_I2C_PATH 0x02 +#define CMD_GPIO_READ 0x0d +#define CMD_GPIO_WRITE 0x0e +#define GPIO_TUNER 0x02 -#define CMD_POWER_OFF 0x50 -#define CMD_POWER_ON 0x51 +#define CMD_POWER_OFF 0xdc +#define CMD_POWER_ON 0xde -enum cxusb_i2c_pathes { - PATH_UNDEF = 0x00, - PATH_CX22702 = 0x01, - PATH_TUNER_OTHER = 0x02, -}; +#define CMD_STREAMING_ON 0x36 +#define CMD_STREAMING_OFF 0x37 + +#define CMD_ANALOG 0x50 +#define CMD_DIGITAL 0x51 struct cxusb_state { - enum cxusb_i2c_pathes cur_i2c_path; + u8 gpio_write_state[3]; }; #endif diff --git a/drivers/media/dvb/dvb-usb/dibusb-mb.c b/drivers/media/dvb/dvb-usb/dibusb-mb.c index 828b5182e16..0058505634a 100644 --- a/drivers/media/dvb/dvb-usb/dibusb-mb.c +++ b/drivers/media/dvb/dvb-usb/dibusb-mb.c @@ -86,9 +86,9 @@ static struct dvb_usb_properties dibusb2_0b_properties; static int dibusb_probe(struct usb_interface *intf, const struct usb_device_id *id) { - if (dvb_usb_device_init(intf,&dibusb1_1_properties,THIS_MODULE) == 0 || - dvb_usb_device_init(intf,&dibusb1_1_an2235_properties,THIS_MODULE) == 0 || - dvb_usb_device_init(intf,&dibusb2_0b_properties,THIS_MODULE) == 0) + if (dvb_usb_device_init(intf,&dibusb1_1_properties,THIS_MODULE,NULL) == 0 || + dvb_usb_device_init(intf,&dibusb1_1_an2235_properties,THIS_MODULE,NULL) == 0 || + dvb_usb_device_init(intf,&dibusb2_0b_properties,THIS_MODULE,NULL) == 0) return 0; return -EINVAL; @@ -126,10 +126,12 @@ static struct usb_device_id dibusb_dib3000mb_table [] = { /* 25 */ { USB_DEVICE(USB_VID_KYE, USB_PID_KYE_DVB_T_COLD) }, /* 26 */ { USB_DEVICE(USB_VID_KYE, USB_PID_KYE_DVB_T_WARM) }, +/* 27 */ { USB_DEVICE(USB_VID_KWORLD, USB_PID_KWORLD_VSTREAM_COLD) }, + // #define DVB_USB_DIBUSB_MB_FAULTY_USB_IDs #ifdef DVB_USB_DIBUSB_MB_FAULTY_USB_IDs -/* 27 */ { USB_DEVICE(USB_VID_ANCHOR, USB_PID_ULTIMA_TVBOX_ANCHOR_COLD) }, +/* 28 */ { USB_DEVICE(USB_VID_ANCHOR, USB_PID_ULTIMA_TVBOX_ANCHOR_COLD) }, #endif { } /* Terminating entry */ }; @@ -262,7 +264,7 @@ static struct dvb_usb_properties dibusb1_1_an2235_properties = { }, #ifdef DVB_USB_DIBUSB_MB_FAULTY_USB_IDs { "Artec T1 USB1.1 TVBOX with AN2235 (faulty USB IDs)", - { &dibusb_dib3000mb_table[27], NULL }, + { &dibusb_dib3000mb_table[28], NULL }, { NULL }, }, #endif @@ -306,12 +308,16 @@ static struct dvb_usb_properties dibusb2_0b_properties = { } }, - .num_device_descs = 1, + .num_device_descs = 2, .devices = { - { "KWorld/ADSTech Instant DVB-T USB 2.0", + { "KWorld/ADSTech Instant DVB-T USB2.0", { &dibusb_dib3000mb_table[23], NULL }, { &dibusb_dib3000mb_table[24], NULL }, }, + { "KWorld Xpert DVB-T USB2.0", + { &dibusb_dib3000mb_table[27], NULL }, + { NULL } + }, } }; diff --git a/drivers/media/dvb/dvb-usb/dibusb-mc.c b/drivers/media/dvb/dvb-usb/dibusb-mc.c index e9dac430f37..6a0912eab39 100644 --- a/drivers/media/dvb/dvb-usb/dibusb-mc.c +++ b/drivers/media/dvb/dvb-usb/dibusb-mc.c @@ -20,7 +20,7 @@ static struct dvb_usb_properties dibusb_mc_properties; static int dibusb_mc_probe(struct usb_interface *intf, const struct usb_device_id *id) { - return dvb_usb_device_init(intf,&dibusb_mc_properties,THIS_MODULE); + return dvb_usb_device_init(intf,&dibusb_mc_properties,THIS_MODULE,NULL); } /* do not change the order of the ID table */ diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c index f70e0be0920..74545f82eff 100644 --- a/drivers/media/dvb/dvb-usb/digitv.c +++ b/drivers/media/dvb/dvb-usb/digitv.c @@ -111,31 +111,28 @@ static int digitv_mt352_demod_init(struct dvb_frontend *fe) } static struct mt352_config digitv_mt352_config = { - .demod_address = 0x0, /* ignored by the digitv anyway */ .demod_init = digitv_mt352_demod_init, .pll_set = dvb_usb_pll_set, }; -static struct nxt6000_config digitv_nxt6000_config = { - .demod_address = 0x0, /* ignored by the digitv anyway */ - .clock_inversion = 0x0, +static int digitv_nxt6000_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep) +{ + struct dvb_usb_device *d = fe->dvb->priv; + u8 b[5]; + dvb_usb_pll_set(fe,fep,b); + return digitv_ctrl_msg(d,USB_WRITE_TUNER,0,&b[1],4,NULL,0); +} - .pll_init = NULL, - .pll_set = NULL, +static struct nxt6000_config digitv_nxt6000_config = { + .clock_inversion = 1, + .pll_set = digitv_nxt6000_pll_set, }; static int digitv_frontend_attach(struct dvb_usb_device *d) { - if ((d->fe = mt352_attach(&digitv_mt352_config, &d->i2c_adap)) != NULL) + if ((d->fe = mt352_attach(&digitv_mt352_config, &d->i2c_adap)) != NULL || + (d->fe = nxt6000_attach(&digitv_nxt6000_config, &d->i2c_adap)) != NULL) return 0; - if ((d->fe = nxt6000_attach(&digitv_nxt6000_config, &d->i2c_adap)) != NULL) { - - warn("nxt6000 support is not done yet, in fact you are one of the first " - "person who wants to use this device in Linux. Please report to " - "linux-dvb@linuxtv.org"); - - return 0; - } return -EIO; } @@ -173,7 +170,18 @@ static struct dvb_usb_properties digitv_properties; static int digitv_probe(struct usb_interface *intf, const struct usb_device_id *id) { - return dvb_usb_device_init(intf,&digitv_properties,THIS_MODULE); + struct dvb_usb_device *d; + int ret; + if ((ret = dvb_usb_device_init(intf,&digitv_properties,THIS_MODULE,&d)) == 0) { + u8 b[4] = { 0 }; + + b[0] = 1; + digitv_ctrl_msg(d,USB_WRITE_REMOTE_TYPE,0,b,4,NULL,0); + + b[0] = 0; + digitv_ctrl_msg(d,USB_WRITE_REMOTE,0,b,4,NULL,0); + } + return ret; } static struct usb_device_id digitv_table [] = { diff --git a/drivers/media/dvb/dvb-usb/dtt200u-fe.c b/drivers/media/dvb/dvb-usb/dtt200u-fe.c index b032523b07b..0a94ec22aeb 100644 --- a/drivers/media/dvb/dvb-usb/dtt200u-fe.c +++ b/drivers/media/dvb/dvb-usb/dtt200u-fe.c @@ -18,6 +18,7 @@ struct dtt200u_fe_state { struct dvb_frontend_parameters fep; struct dvb_frontend frontend; + struct dvb_frontend_ops ops; }; static int dtt200u_fe_read_status(struct dvb_frontend* fe, fe_status_t *stat) @@ -163,8 +164,9 @@ struct dvb_frontend* dtt200u_fe_attach(struct dvb_usb_device *d) deb_info("attaching frontend dtt200u\n"); state->d = d; + memcpy(&state->ops,&dtt200u_fe_ops,sizeof(struct dvb_frontend_ops)); - state->frontend.ops = &dtt200u_fe_ops; + state->frontend.ops = &state->ops; state->frontend.demodulator_priv = state; goto success; diff --git a/drivers/media/dvb/dvb-usb/dtt200u.c b/drivers/media/dvb/dvb-usb/dtt200u.c index 47dba6e4596..5aa12ebab34 100644 --- a/drivers/media/dvb/dvb-usb/dtt200u.c +++ b/drivers/media/dvb/dvb-usb/dtt200u.c @@ -98,20 +98,19 @@ static struct dvb_usb_properties wt220u_properties; static int dtt200u_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) { - if (dvb_usb_device_init(intf,&dtt200u_properties,THIS_MODULE) == 0 || - dvb_usb_device_init(intf,&wt220u_properties,THIS_MODULE) == 0) + if (dvb_usb_device_init(intf,&dtt200u_properties,THIS_MODULE,NULL) == 0 || + dvb_usb_device_init(intf,&wt220u_properties,THIS_MODULE,NULL) == 0) return 0; return -ENODEV; } static struct usb_device_id dtt200u_usb_table [] = { -// { USB_DEVICE(0x04b4,0x8613) }, - { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_COLD) }, - { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_WARM) }, - { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_COLD) }, - { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_WARM) }, - { 0 }, + { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_COLD) }, + { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_WARM) }, + { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_COLD) }, + { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_WARM) }, + { 0 }, }; MODULE_DEVICE_TABLE(usb, dtt200u_usb_table); @@ -189,7 +188,7 @@ static struct dvb_usb_properties wt220u_properties = { .num_device_descs = 1, .devices = { - { .name = "WideView WT-220U PenType Receiver (and clones)", + { .name = "WideView WT-220U PenType Receiver (Typhoon/Freecom)", .cold_ids = { &dtt200u_usb_table[2], NULL }, .warm_ids = { &dtt200u_usb_table[3], NULL }, }, @@ -201,9 +200,9 @@ static struct dvb_usb_properties wt220u_properties = { static struct usb_driver dtt200u_usb_driver = { .owner = THIS_MODULE, .name = "dvb_usb_dtt200u", - .probe = dtt200u_usb_probe, + .probe = dtt200u_usb_probe, .disconnect = dvb_usb_device_exit, - .id_table = dtt200u_usb_table, + .id_table = dtt200u_usb_table, }; /* module stuff */ diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index 794d513a848..0818996bf15 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h @@ -24,8 +24,10 @@ #define USB_VID_HANFTEK 0x15f4 #define USB_VID_HAUPPAUGE 0x2040 #define USB_VID_HYPER_PALTEK 0x1025 +#define USB_VID_KWORLD 0xeb2a #define USB_VID_KYE 0x0458 #define USB_VID_MEDION 0x1660 +#define USB_VID_PINNACLE 0x2304 #define USB_VID_VISIONPLUS 0x13d3 #define USB_VID_TWINHAN 0x1822 #define USB_VID_ULTIMA_ELECTRONIC 0x05d8 @@ -52,12 +54,14 @@ #define USB_PID_KWORLD_VSTREAM_WARM 0x17df #define USB_PID_TWINHAN_VP7041_COLD 0x3201 #define USB_PID_TWINHAN_VP7041_WARM 0x3202 +#define USB_PID_TWINHAN_VP7020_COLD 0x3203 +#define USB_PID_TWINHAN_VP7020_WARM 0x3204 #define USB_PID_TWINHAN_VP7045_COLD 0x3205 #define USB_PID_TWINHAN_VP7045_WARM 0x3206 -#define USB_PID_DNTV_TINYUSB2_COLD 0x3223 -#define USB_PID_DNTV_TINYUSB2_WARM 0x3224 #define USB_PID_TWINHAN_VP7021_COLD 0x3207 #define USB_PID_TWINHAN_VP7021_WARM 0x3208 +#define USB_PID_DNTV_TINYUSB2_COLD 0x3223 +#define USB_PID_DNTV_TINYUSB2_WARM 0x3224 #define USB_PID_ULTIMA_TVBOX_COLD 0x8105 #define USB_PID_ULTIMA_TVBOX_WARM 0x8106 #define USB_PID_ULTIMA_TVBOX_AN2235_COLD 0x8107 @@ -85,5 +89,7 @@ #define USB_PID_MEDION_MD95700 0x0932 #define USB_PID_KYE_DVB_T_COLD 0x701e #define USB_PID_KYE_DVB_T_WARM 0x701f +#define USB_PID_PCTV_200E 0x020e +#define USB_PID_PCTV_400E 0x020f #endif diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-init.c b/drivers/media/dvb/dvb-usb/dvb-usb-init.c index 65f0c095abc..a902059812a 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-init.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-init.c @@ -128,7 +128,9 @@ static struct dvb_usb_device_description * dvb_usb_find_device(struct usb_device /* * USB */ -int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_properties *props, struct module *owner) + +int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_properties + *props, struct module *owner,struct dvb_usb_device **du) { struct usb_device *udev = interface_to_usbdev(intf); struct dvb_usb_device *d = NULL; @@ -170,6 +172,9 @@ int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_properties *p usb_set_intfdata(intf, d); + if (du != NULL) + *du = d; + ret = dvb_usb_init(d); } @@ -196,19 +201,6 @@ void dvb_usb_device_exit(struct usb_interface *intf) } EXPORT_SYMBOL(dvb_usb_device_exit); -/* module stuff */ -static int __init dvb_usb_module_init(void) -{ - return 0; -} - -static void __exit dvb_usb_module_exit(void) -{ -} - -module_init (dvb_usb_module_init); -module_exit (dvb_usb_module_exit); - MODULE_VERSION("0.3"); MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); MODULE_DESCRIPTION("A library module containing commonly used USB and DVB function USB DVB devices"); diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h index a80567caf50..0e4f1035b0d 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb.h @@ -127,7 +127,7 @@ struct dvb_usb_device; * helper functions. * * @urb: describes the kind of USB transfer used for MPEG2-TS-streaming. - * Currently only BULK is implemented + * (BULK or ISOC) * * @num_device_descs: number of struct dvb_usb_device_description in @devices * @devices: array of struct dvb_usb_device_description compatibles with these @@ -310,7 +310,7 @@ struct dvb_usb_device { void *priv; }; -extern int dvb_usb_device_init(struct usb_interface *, struct dvb_usb_properties *, struct module *); +extern int dvb_usb_device_init(struct usb_interface *, struct dvb_usb_properties *, struct module *, struct dvb_usb_device **); extern void dvb_usb_device_exit(struct usb_interface *); /* the generic read/write method for device control */ diff --git a/drivers/media/dvb/dvb-usb/nova-t-usb2.c b/drivers/media/dvb/dvb-usb/nova-t-usb2.c index 258a92bfbcc..1841a66427b 100644 --- a/drivers/media/dvb/dvb-usb/nova-t-usb2.c +++ b/drivers/media/dvb/dvb-usb/nova-t-usb2.c @@ -144,7 +144,7 @@ static struct dvb_usb_properties nova_t_properties; static int nova_t_probe(struct usb_interface *intf, const struct usb_device_id *id) { - return dvb_usb_device_init(intf,&nova_t_properties,THIS_MODULE); + return dvb_usb_device_init(intf,&nova_t_properties,THIS_MODULE,NULL); } /* do not change the order of the ID table */ diff --git a/drivers/media/dvb/dvb-usb/umt-010.c b/drivers/media/dvb/dvb-usb/umt-010.c index 2112ac3cf5e..6fd67657c26 100644 --- a/drivers/media/dvb/dvb-usb/umt-010.c +++ b/drivers/media/dvb/dvb-usb/umt-010.c @@ -77,7 +77,7 @@ static struct dvb_usb_properties umt_properties; static int umt_probe(struct usb_interface *intf, const struct usb_device_id *id) { - if (dvb_usb_device_init(intf,&umt_properties,THIS_MODULE) == 0) + if (dvb_usb_device_init(intf,&umt_properties,THIS_MODULE,NULL) == 0) return 0; return -EINVAL; } diff --git a/drivers/media/dvb/dvb-usb/vp702x-fe.c b/drivers/media/dvb/dvb-usb/vp702x-fe.c new file mode 100644 index 00000000000..f20d8dbd0be --- /dev/null +++ b/drivers/media/dvb/dvb-usb/vp702x-fe.c @@ -0,0 +1,339 @@ +/* DVB frontend part of the Linux driver for the TwinhanDTV StarBox USB2.0 + * DVB-S receiver. + * + * Copyright (C) 2005 Ralph Metzler <rjkm@metzlerbros.de> + * Metzler Brothers Systementwicklung GbR + * + * Copyright (C) 2005 Patrick Boettcher <patrick.boettcher@desy.de> + * + * Thanks to Twinhan who kindly provided hardware and information. + * + * This file can be removed soon, after the DST-driver is rewritten to provice + * the frontend-controlling separately. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, version 2. + * + * see Documentation/dvb/README.dvb-usb for more information + * + */ +#include "vp702x.h" + +struct vp702x_fe_state { + struct dvb_frontend fe; + struct dvb_usb_device *d; + + fe_sec_voltage_t voltage; + fe_sec_tone_mode_t tone_mode; + + u8 lnb_buf[8]; + + u8 lock; + u8 sig; + u8 snr; + + unsigned long next_status_check; + unsigned long status_check_interval; +}; + +static int vp702x_fe_refresh_state(struct vp702x_fe_state *st) +{ + u8 buf[10]; + if (time_after(jiffies,st->next_status_check)) { + vp702x_usb_in_op(st->d,READ_STATUS,0,0,buf,10); + + st->lock = buf[4]; + vp702x_usb_in_op(st->d,READ_TUNER_REG_REQ,0x11,0,&st->snr,1); + vp702x_usb_in_op(st->d,READ_TUNER_REG_REQ,0x15,0,&st->sig,1); + + st->next_status_check = jiffies + (st->status_check_interval*HZ)/1000; + } + return 0; +} + +static u8 vp702x_chksum(u8 *buf,int f, int count) +{ + u8 s = 0; + int i; + for (i = f; i < f+count; i++) + s += buf[i]; + return ~s+1; +} + +static int vp702x_fe_read_status(struct dvb_frontend* fe, fe_status_t *status) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + vp702x_fe_refresh_state(st); + deb_fe("%s\n",__FUNCTION__); + + if (st->lock == 0) + *status = FE_HAS_LOCK | FE_HAS_SYNC | FE_HAS_VITERBI | FE_HAS_SIGNAL | FE_HAS_CARRIER; + else + *status = 0; + + deb_fe("real state: %x\n",*status); + *status = 0x1f; + + if (*status & FE_HAS_LOCK) + st->status_check_interval = 1000; + else + st->status_check_interval = 250; + return 0; +} + +/* not supported by this Frontend */ +static int vp702x_fe_read_ber(struct dvb_frontend* fe, u32 *ber) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + vp702x_fe_refresh_state(st); + *ber = 0; + return 0; +} + +/* not supported by this Frontend */ +static int vp702x_fe_read_unc_blocks(struct dvb_frontend* fe, u32 *unc) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + vp702x_fe_refresh_state(st); + *unc = 0; + return 0; +} + +static int vp702x_fe_read_signal_strength(struct dvb_frontend* fe, u16 *strength) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + vp702x_fe_refresh_state(st); + + *strength = (st->sig << 8) | st->sig; + return 0; +} + +static int vp702x_fe_read_snr(struct dvb_frontend* fe, u16 *snr) +{ + u8 _snr; + struct vp702x_fe_state *st = fe->demodulator_priv; + vp702x_fe_refresh_state(st); + + _snr = (st->snr & 0x1f) * 0xff / 0x1f; + *snr = (_snr << 8) | _snr; + return 0; +} + +static int vp702x_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune) +{ + deb_fe("%s\n",__FUNCTION__); + tune->min_delay_ms = 2000; + return 0; +} + +static int vp702x_fe_set_frontend(struct dvb_frontend* fe, + struct dvb_frontend_parameters *fep) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + u32 freq = fep->frequency/1000; + /*CalFrequency*/ +/* u16 frequencyRef[16] = { 2, 4, 8, 16, 32, 64, 128, 256, 24, 5, 10, 20, 40, 80, 160, 320 }; */ + u64 sr; + u8 cmd[8] = { 0 },ibuf[10]; + + cmd[0] = (freq >> 8) & 0x7f; + cmd[1] = freq & 0xff; + cmd[2] = 1; /* divrate == 4 -> frequencyRef[1] -> 1 here */ + + sr = (u64) (fep->u.qpsk.symbol_rate/1000) << 20; + do_div(sr,88000); + cmd[3] = (sr >> 12) & 0xff; + cmd[4] = (sr >> 4) & 0xff; + cmd[5] = (sr << 4) & 0xf0; + + deb_fe("setting frontend to: %u -> %u (%x) LNB-based GHz, symbolrate: %d -> %Lu (%Lx)\n", + fep->frequency,freq,freq, fep->u.qpsk.symbol_rate, sr, sr); + +/* if (fep->inversion == INVERSION_ON) + cmd[6] |= 0x80; */ + + if (st->voltage == SEC_VOLTAGE_18) + cmd[6] |= 0x40; + +/* if (fep->u.qpsk.symbol_rate > 8000000) + cmd[6] |= 0x20; + + if (fep->frequency < 1531000) + cmd[6] |= 0x04; + + if (st->tone_mode == SEC_TONE_ON) + cmd[6] |= 0x01;*/ + + cmd[7] = vp702x_chksum(cmd,0,7); + + st->status_check_interval = 250; + st->next_status_check = jiffies; + + vp702x_usb_in_op(st->d, RESET_TUNER, 0, 0, NULL, 0); + msleep(30); + vp702x_usb_inout_op(st->d,cmd,8,ibuf,10,100); + + if (ibuf[2] == 0 && ibuf[3] == 0) + deb_fe("tuning failed.\n"); + else + deb_fe("tuning succeeded.\n"); + + return 0; +} + +static int vp702x_fe_get_frontend(struct dvb_frontend* fe, + struct dvb_frontend_parameters *fep) +{ + deb_fe("%s\n",__FUNCTION__); + return 0; +} + +static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe, + struct dvb_diseqc_master_cmd *m) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + u8 cmd[8],ibuf[10]; + memset(cmd,0,8); + + deb_fe("%s\n",__FUNCTION__); + + if (m->msg_len > 4) + return -EINVAL; + + cmd[1] = SET_DISEQC_CMD; + cmd[2] = m->msg_len; + memcpy(&cmd[3], m->msg, m->msg_len); + cmd[7] = vp702x_chksum(cmd,0,7); + + vp702x_usb_inout_op(st->d,cmd,8,ibuf,10,100); + + if (ibuf[2] == 0 && ibuf[3] == 0) + deb_fe("diseqc cmd failed.\n"); + else + deb_fe("diseqc cmd succeeded.\n"); + + return 0; +} + +static int vp702x_fe_send_diseqc_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) +{ + deb_fe("%s\n",__FUNCTION__); + return 0; +} + +static int vp702x_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + u8 ibuf[10]; + deb_fe("%s\n",__FUNCTION__); + + st->tone_mode = tone; + + if (tone == SEC_TONE_ON) + st->lnb_buf[2] = 0x02; + else + st->lnb_buf[2] = 0x00; + + st->lnb_buf[7] = vp702x_chksum(st->lnb_buf,0,7); + + vp702x_usb_inout_op(st->d,st->lnb_buf,8,ibuf,10,100); + if (ibuf[2] == 0 && ibuf[3] == 0) + deb_fe("set_tone cmd failed.\n"); + else + deb_fe("set_tone cmd succeeded.\n"); + + return 0; +} + +static int vp702x_fe_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t + voltage) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + u8 ibuf[10]; + deb_fe("%s\n",__FUNCTION__); + + st->voltage = voltage; + + if (voltage != SEC_VOLTAGE_OFF) + st->lnb_buf[4] = 0x01; + else + st->lnb_buf[4] = 0x00; + + st->lnb_buf[7] = vp702x_chksum(st->lnb_buf,0,7); + + vp702x_usb_inout_op(st->d,st->lnb_buf,8,ibuf,10,100); + if (ibuf[2] == 0 && ibuf[3] == 0) + deb_fe("set_voltage cmd failed.\n"); + else + deb_fe("set_voltage cmd succeeded.\n"); + + return 0; +} + +static void vp702x_fe_release(struct dvb_frontend* fe) +{ + struct vp702x_fe_state *st = fe->demodulator_priv; + kfree(st); +} + +static struct dvb_frontend_ops vp702x_fe_ops; + +struct dvb_frontend * vp702x_fe_attach(struct dvb_usb_device *d) +{ + struct vp702x_fe_state *s = kmalloc(sizeof(struct vp702x_fe_state), GFP_KERNEL); + if (s == NULL) + goto error; + memset(s,0,sizeof(struct vp702x_fe_state)); + + s->d = d; + s->fe.ops = &vp702x_fe_ops; + s->fe.demodulator_priv = s; + + s->lnb_buf[1] = SET_LNB_POWER; + s->lnb_buf[3] = 0xff; /* 0=tone burst, 2=data burst, ff=off */ + + goto success; +error: + return NULL; +success: + return &s->fe; +} + + +static struct dvb_frontend_ops vp702x_fe_ops = { + .info = { + .name = "Twinhan DST-like frontend (VP7021/VP7020) DVB-S", + .type = FE_QPSK, + .frequency_min = 950000, + .frequency_max = 2150000, + .frequency_stepsize = 1000, /* kHz for QPSK frontends */ + .frequency_tolerance = 0, + .symbol_rate_min = 1000000, + .symbol_rate_max = 45000000, + .symbol_rate_tolerance = 500, /* ppm */ + .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | + FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | + FE_CAN_QPSK | + FE_CAN_FEC_AUTO + }, + .release = vp702x_fe_release, + + .init = NULL, + .sleep = NULL, + + .set_frontend = vp702x_fe_set_frontend, + .get_frontend = vp702x_fe_get_frontend, + .get_tune_settings = vp702x_fe_get_tune_settings, + + .read_status = vp702x_fe_read_status, + .read_ber = vp702x_fe_read_ber, + .read_signal_strength = vp702x_fe_read_signal_strength, + .read_snr = vp702x_fe_read_snr, + .read_ucblocks = vp702x_fe_read_unc_blocks, + + .diseqc_send_master_cmd = vp702x_fe_send_diseqc_msg, + .diseqc_send_burst = vp702x_fe_send_diseqc_burst, + .set_tone = vp702x_fe_set_tone, + .set_voltage = vp702x_fe_set_voltage, +}; diff --git a/drivers/media/dvb/dvb-usb/vp702x.c b/drivers/media/dvb/dvb-usb/vp702x.c new file mode 100644 index 00000000000..de13c04e8e6 --- /dev/null +++ b/drivers/media/dvb/dvb-usb/vp702x.c @@ -0,0 +1,290 @@ +/* DVB USB compliant Linux driver for the TwinhanDTV StarBox USB2.0 DVB-S + * receiver. + * + * Copyright (C) 2005 Ralph Metzler <rjkm@metzlerbros.de> + * Metzler Brothers Systementwicklung GbR + * + * Copyright (C) 2005 Patrick Boettcher <patrick.boettcher@desy.de> + * + * Thanks to Twinhan who kindly provided hardware and information. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, version 2. + * + * see Documentation/dvb/README.dvb-usb for more information + */ +#include "vp702x.h" + +/* debug */ +int dvb_usb_vp702x_debug; +module_param_named(debug,dvb_usb_vp702x_debug, int, 0644); +MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." DVB_USB_DEBUG_STATUS); + +struct vp702x_state { + u8 pid_table[17]; /* [16] controls the pid_table state */ +}; + +/* check for mutex FIXME */ +int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen) +{ + int ret = 0,try = 0; + + while (ret >= 0 && ret != blen && try < 3) { + ret = usb_control_msg(d->udev, + usb_rcvctrlpipe(d->udev,0), + req, + USB_TYPE_VENDOR | USB_DIR_IN, + value,index,b,blen, + 2000); + deb_info("reading number %d (ret: %d)\n",try,ret); + try++; + } + + if (ret < 0 || ret != blen) { + warn("usb in operation failed."); + ret = -EIO; + } else + ret = 0; + + deb_xfer("in: req. %x, val: %x, ind: %x, buffer: ",req,value,index); + debug_dump(b,blen,deb_xfer); + + return ret; +} + +int vp702x_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen) +{ + deb_xfer("out: req. %x, val: %x, ind: %x, buffer: ",req,value,index); + debug_dump(b,blen,deb_xfer); + + if (usb_control_msg(d->udev, + usb_sndctrlpipe(d->udev,0), + req, + USB_TYPE_VENDOR | USB_DIR_OUT, + value,index,b,blen, + 2000) != blen) { + warn("usb out operation failed."); + return -EIO; + } else + return 0; +} + +int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int ilen, int msec) +{ + int ret; + + if ((ret = down_interruptible(&d->usb_sem))) + return ret; + + if ((ret = vp702x_usb_out_op(d,REQUEST_OUT,0,0,o,olen)) < 0) + goto unlock; + msleep(msec); + ret = vp702x_usb_in_op(d,REQUEST_IN,0,0,i,ilen); + +unlock: + up(&d->usb_sem); + + return ret; +} + +int vp702x_usb_inout_cmd(struct dvb_usb_device *d, u8 cmd, u8 *o, int olen, u8 *i, int ilen, int msec) +{ + u8 bout[olen+2]; + u8 bin[ilen+1]; + int ret = 0; + + bout[0] = 0x00; + bout[1] = cmd; + memcpy(&bout[2],o,olen); + + ret = vp702x_usb_inout_op(d, bout, olen+2, bin, ilen+1,msec); + + if (ret == 0) + memcpy(i,&bin[1],ilen); + + return ret; +} + +static int vp702x_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int onoff) +{ + struct vp702x_state *st = d->priv; + u8 buf[9]; + + if (onoff) { + st->pid_table[16] |= 1 << index; + st->pid_table[index*2] = (pid >> 8) & 0xff; + st->pid_table[index*2+1] = pid & 0xff; + } else { + st->pid_table[16] &= ~(1 << index); + st->pid_table[index*2] = st->pid_table[index*2+1] = 0; + } + + return vp702x_usb_inout_cmd(d,SET_PID_FILTER,st->pid_table,17,buf,9,10); +} + +static int vp702x_power_ctrl(struct dvb_usb_device *d, int onoff) +{ + vp702x_usb_in_op(d,RESET_TUNER,0,0,NULL,0); + + vp702x_usb_in_op(d,SET_TUNER_POWER_REQ,0,onoff,NULL,0); + return vp702x_usb_in_op(d,SET_TUNER_POWER_REQ,0,onoff,NULL,0); +} + +/* keys for the enclosed remote control */ +static struct dvb_usb_rc_key vp702x_rc_keys[] = { + { 0x00, 0x01, KEY_1 }, + { 0x00, 0x02, KEY_2 }, +}; + +/* remote control stuff (does not work with my box) */ +static int vp702x_rc_query(struct dvb_usb_device *d, u32 *event, int *state) +{ + u8 key[10]; + int i; + +/* remove the following return to enabled remote querying */ + return 0; + + vp702x_usb_in_op(d,READ_REMOTE_REQ,0,0,key,10); + + deb_rc("remote query key: %x %d\n",key[1],key[1]); + + if (key[1] == 0x44) { + *state = REMOTE_NO_KEY_PRESSED; + return 0; + } + + for (i = 0; i < ARRAY_SIZE(vp702x_rc_keys); i++) + if (vp702x_rc_keys[i].custom == key[1]) { + *state = REMOTE_KEY_PRESSED; + *event = vp702x_rc_keys[i].event; + break; + } + return 0; +} + +static int vp702x_read_mac_addr(struct dvb_usb_device *d,u8 mac[6]) +{ + u8 macb[9]; + if (vp702x_usb_inout_cmd(d, GET_MAC_ADDRESS, NULL, 0, macb, 9, 10)) + return -EIO; + memcpy(mac,&macb[3],6); + return 0; +} + +static int vp702x_frontend_attach(struct dvb_usb_device *d) +{ + u8 buf[9] = { 0 }; + + if (vp702x_usb_inout_cmd(d, GET_SYSTEM_STRING, NULL, 0, buf, 9, 10)) + return -EIO; + + buf[8] = '\0'; + info("system string: %s",&buf[1]); + + d->fe = vp702x_fe_attach(d); + return 0; +} + +static struct dvb_usb_properties vp702x_properties; + +static int vp702x_usb_probe(struct usb_interface *intf, + const struct usb_device_id *id) +{ + struct usb_device *udev = interface_to_usbdev(intf); + + usb_clear_halt(udev,usb_sndctrlpipe(udev,0)); + usb_clear_halt(udev,usb_rcvctrlpipe(udev,0)); + + return dvb_usb_device_init(intf,&vp702x_properties,THIS_MODULE,NULL); +} + +static struct usb_device_id vp702x_usb_table [] = { + { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7021_COLD) }, + { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7021_WARM) }, + { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7020_COLD) }, + { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7020_WARM) }, + { 0 }, +}; +MODULE_DEVICE_TABLE(usb, vp702x_usb_table); + +static struct dvb_usb_properties vp702x_properties = { + .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING, + .pid_filter_count = 8, /* !!! */ + + .usb_ctrl = CYPRESS_FX2, + .firmware = "dvb-usb-vp702x-01.fw", + + .pid_filter = vp702x_pid_filter, + .power_ctrl = vp702x_power_ctrl, + .frontend_attach = vp702x_frontend_attach, + .read_mac_address = vp702x_read_mac_addr, + + .rc_key_map = vp702x_rc_keys, + .rc_key_map_size = ARRAY_SIZE(vp702x_rc_keys), + .rc_interval = 400, + .rc_query = vp702x_rc_query, + + .size_of_priv = sizeof(struct vp702x_state), + + /* parameter for the MPEG2-data transfer */ + .urb = { + .type = DVB_USB_BULK, + .count = 7, + .endpoint = 0x02, + .u = { + .bulk = { + .buffersize = 4096, + } + } + }, + + .num_device_descs = 2, + .devices = { + { .name = "TwinhanDTV StarBox DVB-S USB2.0 (VP7021)", + .cold_ids = { &vp702x_usb_table[0], NULL }, + .warm_ids = { &vp702x_usb_table[1], NULL }, + }, + { .name = "TwinhanDTV StarBox DVB-S USB2.0 (VP7020)", + .cold_ids = { &vp702x_usb_table[2], NULL }, + .warm_ids = { &vp702x_usb_table[3], NULL }, + }, + { 0 }, + } +}; + +/* usb specific object needed to register this driver with the usb subsystem */ +static struct usb_driver vp702x_usb_driver = { + .owner = THIS_MODULE, + .name = "dvb-usb-vp702x", + .probe = vp702x_usb_probe, + .disconnect = dvb_usb_device_exit, + .id_table = vp702x_usb_table, +}; + +/* module stuff */ +static int __init vp702x_usb_module_init(void) +{ + int result; + if ((result = usb_register(&vp702x_usb_driver))) { + err("usb_register failed. (%d)",result); + return result; + } + + return 0; +} + +static void __exit vp702x_usb_module_exit(void) +{ + /* deregister this driver from the USB subsystem */ + usb_deregister(&vp702x_usb_driver); +} + +module_init(vp702x_usb_module_init); +module_exit(vp702x_usb_module_exit); + +MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); +MODULE_DESCRIPTION("Driver for Twinhan StarBox DVB-S USB2.0 and clones"); +MODULE_VERSION("1.0-alpha"); +MODULE_LICENSE("GPL"); diff --git a/drivers/media/dvb/dvb-usb/vp702x.h b/drivers/media/dvb/dvb-usb/vp702x.h new file mode 100644 index 00000000000..4a3e8c7eca2 --- /dev/null +++ b/drivers/media/dvb/dvb-usb/vp702x.h @@ -0,0 +1,109 @@ +#ifndef _DVB_USB_VP7021_H_ +#define _DVB_USB_VP7021_H_ + +#define DVB_USB_LOG_PREFIX "vp702x" +#include "dvb-usb.h" + +extern int dvb_usb_vp702x_debug; +#define deb_info(args...) dprintk(dvb_usb_vp702x_debug,0x01,args) +#define deb_xfer(args...) dprintk(dvb_usb_vp702x_debug,0x02,args) +#define deb_rc(args...) dprintk(dvb_usb_vp702x_debug,0x04,args) +#define deb_fe(args...) dprintk(dvb_usb_vp702x_debug,0x08,args) + +/* commands are read and written with USB control messages */ + +/* consecutive read/write operation */ +#define REQUEST_OUT 0xB2 +#define REQUEST_IN 0xB3 + +/* the out-buffer of these consecutive operations contain sub-commands when b[0] = 0 + * request: 0xB2; i: 0; v: 0; b[0] = 0, b[1] = subcmd, additional buffer + * the returning buffer looks as follows + * request: 0xB3; i: 0; v: 0; b[0] = 0xB3, additional buffer */ + +#define GET_TUNER_STATUS 0x05 +/* additional in buffer: + * 0 1 2 3 4 5 6 7 8 + * N/A N/A 0x05 signal-quality N/A N/A signal-strength lock==0 N/A */ + +#define GET_SYSTEM_STRING 0x06 +/* additional in buffer: + * 0 1 2 3 4 5 6 7 8 + * N/A 'U' 'S' 'B' '7' '0' '2' 'X' N/A */ + +#define SET_DISEQC_CMD 0x08 +/* additional out buffer: + * 0 1 2 3 4 + * len X1 X2 X3 X4 + * additional in buffer: + * 0 1 2 + * N/A 0 0 b[1] == b[2] == 0 -> success otherwise not */ + +#define SET_LNB_POWER 0x09 +/* additional out buffer: + * 0 1 2 + * 0x00 0xff 1 = on, 0 = off + * additional in buffer: + * 0 1 2 + * N/A 0 0 b[1] == b[2] == 0 -> success otherwise not */ + +#define GET_MAC_ADDRESS 0x0A +/* #define GET_MAC_ADDRESS 0x0B */ +/* additional in buffer: + * 0 1 2 3 4 5 6 7 8 + * N/A N/A 0x0A or 0x0B MAC0 MAC1 MAC2 MAC3 MAC4 MAC5 */ + +#define SET_PID_FILTER 0x11 +/* additional in buffer: + * 0 1 ... 14 15 16 + * PID0_MSB PID0_LSB ... PID7_MSB PID7_LSB PID_active (bits) */ + +/* request: 0xB2; i: 0; v: 0; + * b[0] != 0 -> tune and lock a channel + * 0 1 2 3 4 5 6 7 + * freq0 freq1 divstep srate0 srate1 srate2 flag chksum + */ + + +/* one direction requests */ +#define READ_REMOTE_REQ 0xB4 +/* IN i: 0; v: 0; b[0] == request, b[1] == key */ + +#define READ_PID_NUMBER_REQ 0xB5 +/* IN i: 0; v: 0; b[0] == request, b[1] == 0, b[2] = pid number */ + +#define WRITE_EEPROM_REQ 0xB6 +/* OUT i: offset; v: value to write; no extra buffer */ + +#define READ_EEPROM_REQ 0xB7 +/* IN i: bufferlen; v: offset; buffer with bufferlen bytes */ + +#define READ_STATUS 0xB8 +/* IN i: 0; v: 0; bufferlen 10 */ + +#define READ_TUNER_REG_REQ 0xB9 +/* IN i: 0; v: register; b[0] = value */ + +#define READ_FX2_REG_REQ 0xBA +/* IN i: offset; v: 0; b[0] = value */ + +#define WRITE_FX2_REG_REQ 0xBB +/* OUT i: offset; v: value to write; 1 byte extra buffer */ + +#define SET_TUNER_POWER_REQ 0xBC +/* IN i: 0 = power off, 1 = power on */ + +#define WRITE_TUNER_REG_REQ 0xBD +/* IN i: register, v: value to write, no extra buffer */ + +#define RESET_TUNER 0xBE +/* IN i: 0, v: 0, no extra buffer */ + +extern struct dvb_frontend * vp702x_fe_attach(struct dvb_usb_device *d); + +extern int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int ilen, int msec); +extern int vp702x_usb_inout_cmd(struct dvb_usb_device *d, u8 cmd, u8 *o, int olen, u8 *i, int ilen, int msec); +extern int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen); +extern int vp702x_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen); + +#endif diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c index 9ac95f54f9f..0f57abeb6d6 100644 --- a/drivers/media/dvb/dvb-usb/vp7045.c +++ b/drivers/media/dvb/dvb-usb/vp7045.c @@ -164,7 +164,6 @@ static int vp7045_read_eeprom(struct dvb_usb_device *d,u8 *buf, int len, int off return 0; } - static int vp7045_read_mac_addr(struct dvb_usb_device *d,u8 mac[6]) { return vp7045_read_eeprom(d,mac, 6, MAC_0_ADDR); @@ -199,7 +198,7 @@ static struct dvb_usb_properties vp7045_properties; static int vp7045_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) { - return dvb_usb_device_init(intf,&vp7045_properties,THIS_MODULE); + return dvb_usb_device_init(intf,&vp7045_properties,THIS_MODULE,NULL); } static struct usb_device_id vp7045_usb_table [] = { @@ -256,9 +255,9 @@ static struct dvb_usb_properties vp7045_properties = { static struct usb_driver vp7045_usb_driver = { .owner = THIS_MODULE, .name = "dvb_usb_vp7045", - .probe = vp7045_usb_probe, + .probe = vp7045_usb_probe, .disconnect = dvb_usb_device_exit, - .id_table = vp7045_usb_table, + .id_table = vp7045_usb_table, }; /* module stuff */ diff --git a/drivers/media/dvb/frontends/cx24110.c b/drivers/media/dvb/frontends/cx24110.c index 8222b88cb48..d4b97989e3e 100644 --- a/drivers/media/dvb/frontends/cx24110.c +++ b/drivers/media/dvb/frontends/cx24110.c @@ -1,7 +1,7 @@ /* cx24110 - Single Chip Satellite Channel Receiver driver module - Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@t-online.de> based on + Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@htp-tel.de> based on work Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de> @@ -387,8 +387,9 @@ static int cx24110_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltag static int cx24110_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) { - int rv, bit, i; + int rv, bit; struct cx24110_state *state = fe->demodulator_priv; + unsigned long timeout; if (burst == SEC_MINI_A) bit = 0x00; @@ -398,12 +399,14 @@ static int cx24110_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t return -EINVAL; rv = cx24110_readreg(state, 0x77); - cx24110_writereg(state, 0x77, rv|0x04); + if (!(rv & 0x04)) + cx24110_writereg(state, 0x77, rv | 0x04); rv = cx24110_readreg(state, 0x76); cx24110_writereg(state, 0x76, ((rv & 0x90) | 0x40 | bit)); - for (i = 500; i-- > 0 && !(cx24110_readreg(state,0x76)&0x40) ; ) - ; /* wait for LNB ready */ + timeout = jiffies + msecs_to_jiffies(100); + while (!time_after(jiffies, timeout) && !(cx24110_readreg(state, 0x76) & 0x40)) + ; /* wait for LNB ready */ return 0; } @@ -413,17 +416,22 @@ static int cx24110_send_diseqc_msg(struct dvb_frontend* fe, { int i, rv; struct cx24110_state *state = fe->demodulator_priv; + unsigned long timeout; for (i = 0; i < cmd->msg_len; i++) cx24110_writereg(state, 0x79 + i, cmd->msg[i]); rv = cx24110_readreg(state, 0x77); - cx24110_writereg(state, 0x77, rv|0x04); + if (rv & 0x04) { + cx24110_writereg(state, 0x77, rv & ~0x04); + msleep(30); /* reportedly fixes switching problems */ + } rv = cx24110_readreg(state, 0x76); cx24110_writereg(state, 0x76, ((rv & 0x90) | 0x40) | ((cmd->msg_len-3) & 3)); - for (i=500; i-- > 0 && !(cx24110_readreg(state,0x76)&0x40);) + timeout = jiffies + msecs_to_jiffies(100); + while (!time_after(jiffies, timeout) && !(cx24110_readreg(state, 0x76) & 0x40)) ; /* wait for LNB ready */ return 0; diff --git a/drivers/media/dvb/frontends/cx24110.h b/drivers/media/dvb/frontends/cx24110.h index 6b663f4744e..b63ecf26421 100644 --- a/drivers/media/dvb/frontends/cx24110.h +++ b/drivers/media/dvb/frontends/cx24110.h @@ -1,7 +1,7 @@ /* cx24110 - Single Chip Satellite Channel Receiver driver module - Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@t-online.de> based on + Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@htp-tel.de> based on work Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de> diff --git a/drivers/media/dvb/frontends/dib3000mb.c b/drivers/media/dvb/frontends/dib3000mb.c index cd434b7cf9d..21433e1831e 100644 --- a/drivers/media/dvb/frontends/dib3000mb.c +++ b/drivers/media/dvb/frontends/dib3000mb.c @@ -23,7 +23,6 @@ #include <linux/config.h> #include <linux/kernel.h> -#include <linux/version.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/init.h> diff --git a/drivers/media/dvb/frontends/dib3000mc.c b/drivers/media/dvb/frontends/dib3000mc.c index cd33705a432..441de665fec 100644 --- a/drivers/media/dvb/frontends/dib3000mc.c +++ b/drivers/media/dvb/frontends/dib3000mc.c @@ -22,7 +22,6 @@ */ #include <linux/config.h> #include <linux/kernel.h> -#include <linux/version.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/init.h> diff --git a/drivers/media/dvb/frontends/mt352.c b/drivers/media/dvb/frontends/mt352.c index d32dc4de9e7..cc1bc0edd65 100644 --- a/drivers/media/dvb/frontends/mt352.c +++ b/drivers/media/dvb/frontends/mt352.c @@ -462,9 +462,11 @@ static int mt352_read_signal_strength(struct dvb_frontend* fe, u16* strength) { struct mt352_state* state = fe->demodulator_priv; - u16 signal = ((mt352_read_register(state, AGC_GAIN_1) << 8) & 0x0f) | - (mt352_read_register(state, AGC_GAIN_0)); + /* align the 12 bit AGC gain with the most significant bits */ + u16 signal = ((mt352_read_register(state, AGC_GAIN_1) & 0x0f) << 12) | + (mt352_read_register(state, AGC_GAIN_0) << 4); + /* inverse of gain is signal strength */ *strength = ~signal; return 0; } diff --git a/drivers/media/dvb/frontends/nxt6000.c b/drivers/media/dvb/frontends/nxt6000.c index 966de9853d1..88a57b79111 100644 --- a/drivers/media/dvb/frontends/nxt6000.c +++ b/drivers/media/dvb/frontends/nxt6000.c @@ -482,6 +482,7 @@ static int nxt6000_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par if ((result = nxt6000_set_inversion(state, param->inversion)) < 0) return result; + msleep(500); return 0; } @@ -525,6 +526,12 @@ static int nxt6000_read_signal_strength(struct dvb_frontend* fe, u16* signal_str return 0; } +static int nxt6000_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune) +{ + tune->min_delay_ms = 500; + return 0; +} + static struct dvb_frontend_ops nxt6000_ops; struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config, @@ -578,6 +585,8 @@ static struct dvb_frontend_ops nxt6000_ops = { .init = nxt6000_init, + .get_tune_settings = nxt6000_fe_get_tune_settings, + .set_frontend = nxt6000_set_frontend, .read_status = nxt6000_read_status, diff --git a/drivers/media/dvb/frontends/or51132.c b/drivers/media/dvb/frontends/or51132.c index cc0a77c790f..b6d0eecc59e 100644 --- a/drivers/media/dvb/frontends/or51132.c +++ b/drivers/media/dvb/frontends/or51132.c @@ -370,22 +370,19 @@ static int or51132_set_parameters(struct dvb_frontend* fe, or51132_setmode(fe); } - /* Change only if we are actually changing the channel */ - if (state->current_frequency != param->frequency) { - dvb_pll_configure(state->config->pll_desc, buf, - param->frequency, 0); - dprintk("set_parameters tuner bytes: 0x%02x 0x%02x " - "0x%02x 0x%02x\n",buf[0],buf[1],buf[2],buf[3]); - if (i2c_writebytes(state, state->config->pll_address ,buf, 4)) - printk(KERN_WARNING "or51132: set_parameters error " - "writing to tuner\n"); - - /* Set to current mode */ - or51132_setmode(fe); - - /* Update current frequency */ - state->current_frequency = param->frequency; - } + dvb_pll_configure(state->config->pll_desc, buf, + param->frequency, 0); + dprintk("set_parameters tuner bytes: 0x%02x 0x%02x " + "0x%02x 0x%02x\n",buf[0],buf[1],buf[2],buf[3]); + if (i2c_writebytes(state, state->config->pll_address ,buf, 4)) + printk(KERN_WARNING "or51132: set_parameters error " + "writing to tuner\n"); + + /* Set to current mode */ + or51132_setmode(fe); + + /* Update current frequency */ + state->current_frequency = param->frequency; return 0; } diff --git a/drivers/media/dvb/frontends/s5h1420.c b/drivers/media/dvb/frontends/s5h1420.c index 4f396ac8de7..c7fe27fd530 100644 --- a/drivers/media/dvb/frontends/s5h1420.c +++ b/drivers/media/dvb/frontends/s5h1420.c @@ -48,7 +48,8 @@ struct s5h1420_state { }; static u32 s5h1420_getsymbolrate(struct s5h1420_state* state); -static int s5h1420_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings); +static int s5h1420_get_tune_settings(struct dvb_frontend* fe, + struct dvb_frontend_tune_settings* fesettings); static int debug = 0; @@ -91,7 +92,8 @@ static int s5h1420_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltag switch(voltage) { case SEC_VOLTAGE_13: - s5h1420_writereg(state, 0x3c, (s5h1420_readreg(state, 0x3c) & 0xfe) | 0x02); + s5h1420_writereg(state, 0x3c, + (s5h1420_readreg(state, 0x3c) & 0xfe) | 0x02); break; case SEC_VOLTAGE_18: @@ -112,18 +114,21 @@ static int s5h1420_set_tone (struct dvb_frontend* fe, fe_sec_tone_mode_t tone) switch(tone) { case SEC_TONE_ON: - s5h1420_writereg(state, 0x3b, (s5h1420_readreg(state, 0x3b) & 0x74) | 0x08); + s5h1420_writereg(state, 0x3b, + (s5h1420_readreg(state, 0x3b) & 0x74) | 0x08); break; case SEC_TONE_OFF: - s5h1420_writereg(state, 0x3b, (s5h1420_readreg(state, 0x3b) & 0x74) | 0x01); + s5h1420_writereg(state, 0x3b, + (s5h1420_readreg(state, 0x3b) & 0x74) | 0x01); break; } return 0; } -static int s5h1420_send_master_cmd (struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd) +static int s5h1420_send_master_cmd (struct dvb_frontend* fe, + struct dvb_diseqc_master_cmd* cmd) { struct s5h1420_state* state = fe->demodulator_priv; u8 val; @@ -131,6 +136,9 @@ static int s5h1420_send_master_cmd (struct dvb_frontend* fe, struct dvb_diseqc_m unsigned long timeout; int result = 0; + if (cmd->msg_len > 8) + return -EINVAL; + /* setup for DISEQC */ val = s5h1420_readreg(state, 0x3b); s5h1420_writereg(state, 0x3b, 0x02); @@ -138,16 +146,17 @@ static int s5h1420_send_master_cmd (struct dvb_frontend* fe, struct dvb_diseqc_m /* write the DISEQC command bytes */ for(i=0; i< cmd->msg_len; i++) { - s5h1420_writereg(state, 0x3c + i, cmd->msg[i]); + s5h1420_writereg(state, 0x3d + i, cmd->msg[i]); } /* kick off transmission */ - s5h1420_writereg(state, 0x3b, s5h1420_readreg(state, 0x3b) | ((cmd->msg_len-1) << 4) | 0x08); + s5h1420_writereg(state, 0x3b, s5h1420_readreg(state, 0x3b) | + ((cmd->msg_len-1) << 4) | 0x08); /* wait for transmission to complete */ timeout = jiffies + ((100*HZ) / 1000); while(time_before(jiffies, timeout)) { - if (s5h1420_readreg(state, 0x3b) & 0x08) + if (!(s5h1420_readreg(state, 0x3b) & 0x08)) break; msleep(5); @@ -161,7 +170,8 @@ static int s5h1420_send_master_cmd (struct dvb_frontend* fe, struct dvb_diseqc_m return result; } -static int s5h1420_recv_slave_reply (struct dvb_frontend* fe, struct dvb_diseqc_slave_reply* reply) +static int s5h1420_recv_slave_reply (struct dvb_frontend* fe, + struct dvb_diseqc_slave_reply* reply) { struct s5h1420_state* state = fe->demodulator_priv; u8 val; @@ -205,7 +215,7 @@ static int s5h1420_recv_slave_reply (struct dvb_frontend* fe, struct dvb_diseqc_ /* extract data */ for(i=0; i< length; i++) { - reply->msg[i] = s5h1420_readreg(state, 0x3c + i); + reply->msg[i] = s5h1420_readreg(state, 0x3d + i); } exit: @@ -236,7 +246,7 @@ static int s5h1420_send_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t minicm s5h1420_writereg(state, 0x3b, s5h1420_readreg(state, 0x3b) | 0x08); /* wait for transmission to complete */ - timeout = jiffies + ((20*HZ) / 1000); + timeout = jiffies + ((100*HZ) / 1000); while(time_before(jiffies, timeout)) { if (!(s5h1420_readreg(state, 0x3b) & 0x08)) break; @@ -259,9 +269,9 @@ static fe_status_t s5h1420_get_status_bits(struct s5h1420_state* state) val = s5h1420_readreg(state, 0x14); if (val & 0x02) - status |= FE_HAS_SIGNAL; // FIXME: not sure if this is right + status |= FE_HAS_SIGNAL; if (val & 0x01) - status |= FE_HAS_CARRIER; // FIXME: not sure if this is right + status |= FE_HAS_CARRIER; val = s5h1420_readreg(state, 0x36); if (val & 0x01) status |= FE_HAS_VITERBI; @@ -284,8 +294,8 @@ static int s5h1420_read_status(struct dvb_frontend* fe, fe_status_t* status) /* determine lock state */ *status = s5h1420_get_status_bits(state); - /* fix for FEC 5/6 inversion issue - if it doesn't quite lock, invert the inversion, - wait a bit and check again */ + /* fix for FEC 5/6 inversion issue - if it doesn't quite lock, invert + the inversion, wait a bit and check again */ if (*status == (FE_HAS_SIGNAL|FE_HAS_CARRIER|FE_HAS_VITERBI)) { val = s5h1420_readreg(state, 0x32); if ((val & 0x07) == 0x03) { @@ -330,6 +340,10 @@ static int s5h1420_read_status(struct dvb_frontend* fe, fe_status_t* status) tmp = (tmp * 2 * 7) / 8; break; } + if (tmp == 0) { + printk("s5h1420: avoided division by 0\n"); + tmp = 1; + } tmp = state->fclk / tmp; /* set the MPEG_CLK_INTL for the calculated data rate */ @@ -368,16 +382,21 @@ static int s5h1420_read_ber(struct dvb_frontend* fe, u32* ber) s5h1420_writereg(state, 0x46, 0x1d); mdelay(25); - return (s5h1420_readreg(state, 0x48) << 8) | s5h1420_readreg(state, 0x47); + + *ber = (s5h1420_readreg(state, 0x48) << 8) | s5h1420_readreg(state, 0x47); + + return 0; } static int s5h1420_read_signal_strength(struct dvb_frontend* fe, u16* strength) { struct s5h1420_state* state = fe->demodulator_priv; - u8 val = 0xff - s5h1420_readreg(state, 0x15); + u8 val = s5h1420_readreg(state, 0x15); - return (int) ((val << 8) | val); + *strength = (u16) ((val << 8) | val); + + return 0; } static int s5h1420_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) @@ -386,7 +405,10 @@ static int s5h1420_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) s5h1420_writereg(state, 0x46, 0x1f); mdelay(25); - return (s5h1420_readreg(state, 0x48) << 8) | s5h1420_readreg(state, 0x47); + + *ucblocks = (s5h1420_readreg(state, 0x48) << 8) | s5h1420_readreg(state, 0x47); + + return 0; } static void s5h1420_reset(struct s5h1420_state* state) @@ -396,11 +418,12 @@ static void s5h1420_reset(struct s5h1420_state* state) udelay(10); } -static void s5h1420_setsymbolrate(struct s5h1420_state* state, struct dvb_frontend_parameters *p) +static void s5h1420_setsymbolrate(struct s5h1420_state* state, + struct dvb_frontend_parameters *p) { u64 val; - val = (p->u.qpsk.symbol_rate / 1000) * (1<<24); + val = ((u64) p->u.qpsk.symbol_rate / 1000ULL) * (1ULL<<24); if (p->u.qpsk.symbol_rate <= 21000000) { val *= 2; } @@ -415,7 +438,7 @@ static void s5h1420_setsymbolrate(struct s5h1420_state* state, struct dvb_fronte static u32 s5h1420_getsymbolrate(struct s5h1420_state* state) { - u64 val; + u64 val = 0; int sampling = 2; if (s5h1420_readreg(state, 0x05) & 0x2) @@ -427,10 +450,10 @@ static u32 s5h1420_getsymbolrate(struct s5h1420_state* state) val |= s5h1420_readreg(state, 0x13); s5h1420_writereg(state, 0x06, s5h1420_readreg(state, 0x06) & 0xf7); - val *= (state->fclk / 1000); + val *= (state->fclk / 1000ULL); do_div(val, ((1<<24) * sampling)); - return (u32) (val * 1000); + return (u32) (val * 1000ULL); } static void s5h1420_setfreqoffset(struct s5h1420_state* state, int freqoffset) @@ -463,46 +486,55 @@ static int s5h1420_getfreqoffset(struct s5h1420_state* state) /* remember freqoffset is in kHz, but the chip wants the offset in Hz, so * divide fclk by 1000000 to get the correct value. */ - val = - ((val * (state->fclk/1000000)) / (1<<24)); + val = (((-val) * (state->fclk/1000000)) / (1<<24)); return val; } -static void s5h1420_setfec(struct s5h1420_state* state, struct dvb_frontend_parameters *p) +static void s5h1420_setfec_inversion(struct s5h1420_state* state, + struct dvb_frontend_parameters *p) { + u8 inversion = 0; + + if (p->inversion == INVERSION_OFF) { + inversion = state->config->invert ? 0x08 : 0; + } else if (p->inversion == INVERSION_ON) { + inversion = state->config->invert ? 0 : 0x08; + } + if ((p->u.qpsk.fec_inner == FEC_AUTO) || (p->inversion == INVERSION_AUTO)) { - s5h1420_writereg(state, 0x31, 0x00); s5h1420_writereg(state, 0x30, 0x3f); + s5h1420_writereg(state, 0x31, 0x00 | inversion); } else { switch(p->u.qpsk.fec_inner) { case FEC_1_2: - s5h1420_writereg(state, 0x31, 0x10); s5h1420_writereg(state, 0x30, 0x01); + s5h1420_writereg(state, 0x31, 0x10 | inversion); break; case FEC_2_3: - s5h1420_writereg(state, 0x31, 0x11); s5h1420_writereg(state, 0x30, 0x02); + s5h1420_writereg(state, 0x31, 0x11 | inversion); break; case FEC_3_4: - s5h1420_writereg(state, 0x31, 0x12); s5h1420_writereg(state, 0x30, 0x04); - break; + s5h1420_writereg(state, 0x31, 0x12 | inversion); + break; case FEC_5_6: - s5h1420_writereg(state, 0x31, 0x13); s5h1420_writereg(state, 0x30, 0x08); + s5h1420_writereg(state, 0x31, 0x13 | inversion); break; case FEC_6_7: - s5h1420_writereg(state, 0x31, 0x14); s5h1420_writereg(state, 0x30, 0x10); + s5h1420_writereg(state, 0x31, 0x14 | inversion); break; case FEC_7_8: - s5h1420_writereg(state, 0x31, 0x15); s5h1420_writereg(state, 0x30, 0x20); + s5h1420_writereg(state, 0x31, 0x15 | inversion); break; default: @@ -536,22 +568,6 @@ static fe_code_rate_t s5h1420_getfec(struct s5h1420_state* state) return FEC_NONE; } -static void s5h1420_setinversion(struct s5h1420_state* state, struct dvb_frontend_parameters *p) -{ - if ((p->u.qpsk.fec_inner == FEC_AUTO) || (p->inversion == INVERSION_AUTO)) { - s5h1420_writereg(state, 0x31, 0x00); - s5h1420_writereg(state, 0x30, 0x3f); - } else { - u8 tmp = s5h1420_readreg(state, 0x31) & 0xf7; - tmp |= 0x10; - - if (p->inversion == INVERSION_ON) - tmp |= 0x80; - - s5h1420_writereg(state, 0x31, tmp); - } -} - static fe_spectral_inversion_t s5h1420_getinversion(struct s5h1420_state* state) { if (s5h1420_readreg(state, 0x32) & 0x08) @@ -560,35 +576,35 @@ static fe_spectral_inversion_t s5h1420_getinversion(struct s5h1420_state* state) return INVERSION_OFF; } -static int s5h1420_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) +static int s5h1420_set_frontend(struct dvb_frontend* fe, + struct dvb_frontend_parameters *p) { struct s5h1420_state* state = fe->demodulator_priv; - u32 frequency_delta; + int frequency_delta; struct dvb_frontend_tune_settings fesettings; + u32 tmp; /* check if we should do a fast-tune */ memcpy(&fesettings.parameters, p, sizeof(struct dvb_frontend_parameters)); s5h1420_get_tune_settings(fe, &fesettings); frequency_delta = p->frequency - state->tunedfreq; - if ((frequency_delta > -fesettings.max_drift) && (frequency_delta < fesettings.max_drift) && + if ((frequency_delta > -fesettings.max_drift) && + (frequency_delta < fesettings.max_drift) && (frequency_delta != 0) && (state->fec_inner == p->u.qpsk.fec_inner) && (state->symbol_rate == p->u.qpsk.symbol_rate)) { - s5h1420_setfreqoffset(state, frequency_delta); + if (state->config->pll_set) { + s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) | 1); + state->config->pll_set(fe, p, &tmp); + s5h1420_setfreqoffset(state, p->frequency - tmp); + } return 0; } /* first of all, software reset */ s5h1420_reset(state); - /* set tuner PLL */ - if (state->config->pll_set) { - s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) | 1); - state->config->pll_set(fe, p, &state->tunedfreq); - s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) & 0xfe); - } - /* set s5h1420 fclk PLL according to desired symbol rate */ if (p->u.qpsk.symbol_rate > 28000000) { state->fclk = 88000000; @@ -609,8 +625,9 @@ static int s5h1420_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par /* set misc registers */ s5h1420_writereg(state, 0x02, 0x00); + s5h1420_writereg(state, 0x06, 0x00); s5h1420_writereg(state, 0x07, 0xb0); - s5h1420_writereg(state, 0x0a, 0x67); + s5h1420_writereg(state, 0x0a, 0xe7); s5h1420_writereg(state, 0x0b, 0x78); s5h1420_writereg(state, 0x0c, 0x48); s5h1420_writereg(state, 0x0d, 0x6b); @@ -626,21 +643,26 @@ static int s5h1420_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par /* start QPSK */ s5h1420_writereg(state, 0x05, s5h1420_readreg(state, 0x05) | 1); - /* set the frequency offset to adjust for PLL inaccuracy */ - s5h1420_setfreqoffset(state, p->frequency - state->tunedfreq); + /* set tuner PLL */ + if (state->config->pll_set) { + s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) | 1); + state->config->pll_set(fe, p, &tmp); + s5h1420_setfreqoffset(state, 0); + } /* set the reset of the parameters */ s5h1420_setsymbolrate(state, p); - s5h1420_setinversion(state, p); - s5h1420_setfec(state, p); + s5h1420_setfec_inversion(state, p); state->fec_inner = p->u.qpsk.fec_inner; state->symbol_rate = p->u.qpsk.symbol_rate; state->postlocked = 0; + state->tunedfreq = p->frequency; return 0; } -static int s5h1420_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) +static int s5h1420_get_frontend(struct dvb_frontend* fe, + struct dvb_frontend_parameters *p) { struct s5h1420_state* state = fe->demodulator_priv; @@ -652,7 +674,8 @@ static int s5h1420_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_par return 0; } -static int s5h1420_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings) +static int s5h1420_get_tune_settings(struct dvb_frontend* fe, + struct dvb_frontend_tune_settings* fesettings) { if (fesettings->parameters.u.qpsk.symbol_rate > 20000000) { fesettings->min_delay_ms = 50; @@ -717,7 +740,8 @@ static void s5h1420_release(struct dvb_frontend* fe) static struct dvb_frontend_ops s5h1420_ops; -struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config, struct i2c_adapter* i2c) +struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config, + struct i2c_adapter* i2c) { struct s5h1420_state* state = NULL; u8 identity; diff --git a/drivers/media/dvb/frontends/s5h1420.h b/drivers/media/dvb/frontends/s5h1420.h index b687fc77ceb..872028ddf2a 100644 --- a/drivers/media/dvb/frontends/s5h1420.h +++ b/drivers/media/dvb/frontends/s5h1420.h @@ -30,6 +30,9 @@ struct s5h1420_config /* the demodulator's i2c address */ u8 demod_address; + /* does the inversion require inversion? */ + u8 invert:1; + /* PLL maintenance */ int (*pll_init)(struct dvb_frontend* fe); int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u32* freqout); diff --git a/drivers/media/dvb/frontends/stv0297.c b/drivers/media/dvb/frontends/stv0297.c index 928aca052af..8d09afd7545 100644 --- a/drivers/media/dvb/frontends/stv0297.c +++ b/drivers/media/dvb/frontends/stv0297.c @@ -35,7 +35,6 @@ struct stv0297_state { struct dvb_frontend frontend; unsigned long base_freq; - u8 pwm; }; #if 1 @@ -46,94 +45,6 @@ struct stv0297_state { #define STV0297_CLOCK_KHZ 28900 -static u8 init_tab[] = { - 0x00, 0x09, - 0x01, 0x69, - 0x03, 0x00, - 0x04, 0x00, - 0x07, 0x00, - 0x08, 0x00, - 0x20, 0x00, - 0x21, 0x40, - 0x22, 0x00, - 0x23, 0x00, - 0x24, 0x40, - 0x25, 0x88, - 0x30, 0xff, - 0x31, 0x00, - 0x32, 0xff, - 0x33, 0x00, - 0x34, 0x50, - 0x35, 0x7f, - 0x36, 0x00, - 0x37, 0x20, - 0x38, 0x00, - 0x40, 0x1c, - 0x41, 0xff, - 0x42, 0x29, - 0x43, 0x00, - 0x44, 0xff, - 0x45, 0x00, - 0x46, 0x00, - 0x49, 0x04, - 0x4a, 0xff, - 0x4b, 0x7f, - 0x52, 0x30, - 0x55, 0xae, - 0x56, 0x47, - 0x57, 0xe1, - 0x58, 0x3a, - 0x5a, 0x1e, - 0x5b, 0x34, - 0x60, 0x00, - 0x63, 0x00, - 0x64, 0x00, - 0x65, 0x00, - 0x66, 0x00, - 0x67, 0x00, - 0x68, 0x00, - 0x69, 0x00, - 0x6a, 0x02, - 0x6b, 0x00, - 0x70, 0xff, - 0x71, 0x00, - 0x72, 0x00, - 0x73, 0x00, - 0x74, 0x0c, - 0x80, 0x00, - 0x81, 0x00, - 0x82, 0x00, - 0x83, 0x00, - 0x84, 0x04, - 0x85, 0x80, - 0x86, 0x24, - 0x87, 0x78, - 0x88, 0x00, - 0x89, 0x00, - 0x90, 0x01, - 0x91, 0x01, - 0xa0, 0x00, - 0xa1, 0x00, - 0xa2, 0x00, - 0xb0, 0x91, - 0xb1, 0x0b, - 0xc0, 0x53, - 0xc1, 0x70, - 0xc2, 0x12, - 0xd0, 0x00, - 0xd1, 0x00, - 0xd2, 0x00, - 0xd3, 0x00, - 0xd4, 0x00, - 0xd5, 0x00, - 0xde, 0x00, - 0xdf, 0x00, - 0x61, 0x49, - 0x62, 0x0b, - 0x53, 0x08, - 0x59, 0x08, -}; - static int stv0297_writereg(struct stv0297_state *state, u8 reg, u8 data) { @@ -378,34 +289,9 @@ static int stv0297_init(struct dvb_frontend *fe) struct stv0297_state *state = fe->demodulator_priv; int i; - /* soft reset */ - stv0297_writereg_mask(state, 0x80, 1, 1); - stv0297_writereg_mask(state, 0x80, 1, 0); - - /* reset deinterleaver */ - stv0297_writereg_mask(state, 0x81, 1, 1); - stv0297_writereg_mask(state, 0x81, 1, 0); - /* load init table */ - for (i = 0; i < sizeof(init_tab); i += 2) { - stv0297_writereg(state, init_tab[i], init_tab[i + 1]); - } - - /* set a dummy symbol rate */ - stv0297_set_symbolrate(state, 6900); - - /* invert AGC1 polarity */ - stv0297_writereg_mask(state, 0x88, 0x10, 0x10); - - /* setup bit error counting */ - stv0297_writereg_mask(state, 0xA0, 0x80, 0x00); - stv0297_writereg_mask(state, 0xA0, 0x10, 0x00); - stv0297_writereg_mask(state, 0xA0, 0x08, 0x00); - stv0297_writereg_mask(state, 0xA0, 0x07, 0x04); - - /* min + max PWM */ - stv0297_writereg(state, 0x4a, 0x00); - stv0297_writereg(state, 0x4b, state->pwm); + for (i=0; !(state->config->inittab[i] == 0xff && state->config->inittab[i+1] == 0xff); i+=2) + stv0297_writereg(state, state->config->inittab[i], state->config->inittab[i+1]); msleep(200); if (state->config->pll_init) @@ -606,7 +492,13 @@ static int stv0297_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par stv0297_set_inversion(state, inversion); /* kick off lock */ - stv0297_writereg_mask(state, 0x88, 0x08, 0x08); + /* Disable corner detection for higher QAMs */ + if (p->u.qam.modulation == QAM_128 || + p->u.qam.modulation == QAM_256) + stv0297_writereg_mask(state, 0x88, 0x08, 0x00); + else + stv0297_writereg_mask(state, 0x88, 0x08, 0x08); + stv0297_writereg_mask(state, 0x5a, 0x20, 0x00); stv0297_writereg_mask(state, 0x6a, 0x01, 0x01); stv0297_writereg_mask(state, 0x43, 0x40, 0x40); @@ -732,7 +624,7 @@ static void stv0297_release(struct dvb_frontend *fe) static struct dvb_frontend_ops stv0297_ops; struct dvb_frontend *stv0297_attach(const struct stv0297_config *config, - struct i2c_adapter *i2c, int pwm) + struct i2c_adapter *i2c) { struct stv0297_state *state = NULL; @@ -746,7 +638,6 @@ struct dvb_frontend *stv0297_attach(const struct stv0297_config *config, state->i2c = i2c; memcpy(&state->ops, &stv0297_ops, sizeof(struct dvb_frontend_ops)); state->base_freq = 0; - state->pwm = pwm; /* check if the demod is there */ if ((stv0297_readreg(state, 0x80) & 0x70) != 0x20) diff --git a/drivers/media/dvb/frontends/stv0297.h b/drivers/media/dvb/frontends/stv0297.h index 3be53598930..9e53f019db7 100644 --- a/drivers/media/dvb/frontends/stv0297.h +++ b/drivers/media/dvb/frontends/stv0297.h @@ -29,6 +29,12 @@ struct stv0297_config /* the demodulator's i2c address */ u8 demod_address; + /* inittab - array of pairs of values. + * First of each pair is the register, second is the value. + * List should be terminated with an 0xff, 0xff pair. + */ + u8* inittab; + /* does the "inversion" need inverted? */ u8 invert:1; @@ -38,7 +44,7 @@ struct stv0297_config }; extern struct dvb_frontend* stv0297_attach(const struct stv0297_config* config, - struct i2c_adapter* i2c, int pwm); + struct i2c_adapter* i2c); extern int stv0297_enable_plli2c(struct dvb_frontend* fe); #endif // STV0297_H diff --git a/drivers/media/dvb/frontends/stv0299.c b/drivers/media/dvb/frontends/stv0299.c index cfa3928bb48..2d62931f20b 100644 --- a/drivers/media/dvb/frontends/stv0299.c +++ b/drivers/media/dvb/frontends/stv0299.c @@ -63,12 +63,8 @@ struct stv0299_state { u32 tuner_frequency; u32 symbol_rate; fe_code_rate_t fec_inner; - int errmode; }; -#define STATUS_BER 0 -#define STATUS_UCBLOCKS 1 - static int debug; static int debug_legacy_dish_switch; #define dprintk(args...) \ @@ -481,7 +477,7 @@ static int stv0299_init (struct dvb_frontend* fe) if (state->config->pll_init) { stv0299_writeregI(state, 0x05, 0xb5); /* enable i2c repeater on stv0299 */ - state->config->pll_init(fe); + state->config->pll_init(fe, state->i2c); stv0299_writeregI(state, 0x05, 0x35); /* disable i2c repeater on stv0299 */ } @@ -520,7 +516,8 @@ static int stv0299_read_ber(struct dvb_frontend* fe, u32* ber) { struct stv0299_state* state = fe->demodulator_priv; - if (state->errmode != STATUS_BER) return 0; + stv0299_writeregI(state, 0x34, (stv0299_readreg(state, 0x34) & 0xcf) | 0x10); + msleep(100); *ber = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e); return 0; @@ -559,8 +556,9 @@ static int stv0299_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) { struct stv0299_state* state = fe->demodulator_priv; - if (state->errmode != STATUS_UCBLOCKS) *ucblocks = 0; - else *ucblocks = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e); + stv0299_writeregI(state, 0x34, (stv0299_readreg(state, 0x34) & 0xcf) | 0x30); + msleep(100); + *ucblocks = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e); return 0; } @@ -603,7 +601,7 @@ static int stv0299_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par } else { /* A "normal" tune is requested */ stv0299_writeregI(state, 0x05, 0xb5); /* enable i2c repeater on stv0299 */ - state->config->pll_set(fe, p); + state->config->pll_set(fe, state->i2c, p); stv0299_writeregI(state, 0x05, 0x35); /* disable i2c repeater on stv0299 */ stv0299_writeregI(state, 0x32, 0x80); @@ -615,7 +613,7 @@ static int stv0299_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par } } else { stv0299_writeregI(state, 0x05, 0xb5); /* enable i2c repeater on stv0299 */ - state->config->pll_set(fe, p); + state->config->pll_set(fe, state->i2c, p); stv0299_writeregI(state, 0x05, 0x35); /* disable i2c repeater on stv0299 */ stv0299_set_FEC (state, p->u.qpsk.fec_inner); @@ -709,7 +707,6 @@ struct dvb_frontend* stv0299_attach(const struct stv0299_config* config, state->tuner_frequency = 0; state->symbol_rate = 0; state->fec_inner = 0; - state->errmode = STATUS_BER; /* check if the demod is there */ stv0299_writeregI(state, 0x02, 0x34); /* standby off */ diff --git a/drivers/media/dvb/frontends/stv0299.h b/drivers/media/dvb/frontends/stv0299.h index 79457a80a11..d0c4484861e 100644 --- a/drivers/media/dvb/frontends/stv0299.h +++ b/drivers/media/dvb/frontends/stv0299.h @@ -92,8 +92,8 @@ struct stv0299_config int (*set_symbol_rate)(struct dvb_frontend* fe, u32 srate, u32 ratio); /* PLL maintenance */ - int (*pll_init)(struct dvb_frontend* fe); - int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); + int (*pll_init)(struct dvb_frontend *fe, struct i2c_adapter *i2c); + int (*pll_set)(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters *params); }; extern int stv0299_writereg (struct dvb_frontend* fe, u8 reg, u8 data); diff --git a/drivers/media/dvb/frontends/tda1004x.c b/drivers/media/dvb/frontends/tda1004x.c index ab0c032472c..74cea9f8d72 100644 --- a/drivers/media/dvb/frontends/tda1004x.c +++ b/drivers/media/dvb/frontends/tda1004x.c @@ -1046,8 +1046,7 @@ static int tda1004x_read_snr(struct dvb_frontend* fe, u16 * snr) tmp = tda1004x_read_byte(state, TDA1004X_SNR); if (tmp < 0) return -EIO; - if (tmp) - tmp = 255 - tmp; + tmp = 255 - tmp; *snr = ((tmp << 8) | tmp); dprintk("%s: snr=0x%x\n", __FUNCTION__, *snr); diff --git a/drivers/media/dvb/frontends/ves1820.c b/drivers/media/dvb/frontends/ves1820.c index 70fb44b391a..c6d276618e8 100644 --- a/drivers/media/dvb/frontends/ves1820.c +++ b/drivers/media/dvb/frontends/ves1820.c @@ -194,19 +194,18 @@ static int ves1820_init(struct dvb_frontend* fe) { struct ves1820_state* state = fe->demodulator_priv; int i; - int val; ves1820_writereg(state, 0, 0); - for (i = 0; i < 53; i++) { - val = ves1820_inittab[i]; - if ((i == 2) && (state->config->selagc)) val |= 0x08; - ves1820_writereg(state, i, val); - } + for (i = 0; i < sizeof(ves1820_inittab); i++) + ves1820_writereg(state, i, ves1820_inittab[i]); + if (state->config->selagc) + ves1820_writereg(state, 2, ves1820_inittab[2] | 0x08); ves1820_writereg(state, 0x34, state->pwm); - if (state->config->pll_init) state->config->pll_init(fe); + if (state->config->pll_init) + state->config->pll_init(fe); return 0; } @@ -234,7 +233,7 @@ static int ves1820_set_parameters(struct dvb_frontend* fe, struct dvb_frontend_p ves1820_writereg(state, 0x09, reg0x09[real_qam]); ves1820_setup_reg0(state, reg0x00[real_qam], p->inversion); - + ves1820_writereg(state, 2, ves1820_inittab[2] | (state->config->selagc ? 0x08 : 0)); return 0; } diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c index e4c6e87f6c5..22b203f8ff2 100644 --- a/drivers/media/dvb/ttpci/av7110.c +++ b/drivers/media/dvb/ttpci/av7110.c @@ -168,7 +168,9 @@ static void init_av7110_av(struct av7110 *av7110) if (ret < 0) printk("dvb-ttpci:cannot switch on SCART(AD):%d\n",ret); if (rgb_on && - (av7110->dev->pci->subsystem_vendor == 0x110a) && (av7110->dev->pci->subsystem_device == 0x0000)) { + ((av7110->dev->pci->subsystem_vendor == 0x110a) || + (av7110->dev->pci->subsystem_vendor == 0x13c2)) && + (av7110->dev->pci->subsystem_device == 0x0000)) { saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // RGB on, SCART pin 16 //saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); // SCARTpin 8 } @@ -177,9 +179,6 @@ static void init_av7110_av(struct av7110 *av7110) ret = av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right); if (ret < 0) printk("dvb-ttpci:cannot set volume :%d\n",ret); - ret = av7110_setup_irc_config(av7110, 0); - if (ret < 0) - printk("dvb-ttpci:cannot setup irc config :%d\n",ret); } static void recover_arm(struct av7110 *av7110) @@ -265,60 +264,6 @@ static int arm_thread(void *data) } -/** - * Hack! we save the last av7110 ptr. This should be ok, since - * you rarely will use more then one IR control. - * - * If we want to support multiple controls we would have to do much more... - */ -int av7110_setup_irc_config(struct av7110 *av7110, u32 ir_config) -{ - int ret = 0; - static struct av7110 *last; - - dprintk(4, "%p\n", av7110); - - if (!av7110) - av7110 = last; - else - last = av7110; - - if (av7110) { - ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, SetIR, 1, ir_config); - av7110->ir_config = ir_config; - } - return ret; -} - -static void (*irc_handler)(u32); - -void av7110_register_irc_handler(void (*func)(u32)) -{ - dprintk(4, "registering %p\n", func); - irc_handler = func; -} - -void av7110_unregister_irc_handler(void (*func)(u32)) -{ - dprintk(4, "unregistering %p\n", func); - irc_handler = NULL; -} - -static void run_handlers(unsigned long ircom) -{ - if (irc_handler != NULL) - (*irc_handler)((u32) ircom); -} - -static DECLARE_TASKLET(irtask, run_handlers, 0); - -static void IR_handle(struct av7110 *av7110, u32 ircom) -{ - dprintk(4, "ircommand = %08x\n", ircom); - irtask.data = (unsigned long) ircom; - tasklet_schedule(&irtask); -} - /**************************************************************************** * IRQ handling ****************************************************************************/ @@ -711,8 +656,9 @@ static void gpioirq(unsigned long data) return; case DATA_IRCOMMAND: - IR_handle(av7110, - swahw32(irdebi(av7110, DEBINOSWAP, Reserved, 0, 4))); + if (av7110->ir_handler) + av7110->ir_handler(av7110, + swahw32(irdebi(av7110, DEBINOSWAP, Reserved, 0, 4))); iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); break; @@ -1668,9 +1614,8 @@ static int alps_bsru6_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ra return 0; } -static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) +static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params) { - struct av7110* av7110 = (struct av7110*) fe->dvb->priv; int ret; u8 data[4]; u32 div; @@ -1687,7 +1632,7 @@ static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param if (params->frequency > 1530000) data[3] = 0xc0; - ret = i2c_transfer(&av7110->i2c_adap, &msg, 1); + ret = i2c_transfer(i2c, &msg, 1); if (ret != 1) return -EIO; return 0; @@ -1751,9 +1696,8 @@ static u8 alps_bsbe1_inittab[] = { 0xff, 0xff }; -static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) +static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params) { - struct av7110* av7110 = (struct av7110*) fe->dvb->priv; int ret; u8 data[4]; u32 div; @@ -1768,7 +1712,7 @@ static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param data[2] = 0x80 | ((div & 0x18000) >> 10) | 4; data[3] = (params->frequency > 1530000) ? 0xE0 : 0xE4; - ret = i2c_transfer(&av7110->i2c_adap, &msg, 1); + ret = i2c_transfer(i2c, &msg, 1); return (ret != 1) ? -EIO : 0; } @@ -1936,6 +1880,98 @@ static struct sp8870_config alps_tdlb7_config = { }; +static u8 nexusca_stv0297_inittab[] = { + 0x80, 0x01, + 0x80, 0x00, + 0x81, 0x01, + 0x81, 0x00, + 0x00, 0x09, + 0x01, 0x69, + 0x03, 0x00, + 0x04, 0x00, + 0x07, 0x00, + 0x08, 0x00, + 0x20, 0x00, + 0x21, 0x40, + 0x22, 0x00, + 0x23, 0x00, + 0x24, 0x40, + 0x25, 0x88, + 0x30, 0xff, + 0x31, 0x00, + 0x32, 0xff, + 0x33, 0x00, + 0x34, 0x50, + 0x35, 0x7f, + 0x36, 0x00, + 0x37, 0x20, + 0x38, 0x00, + 0x40, 0x1c, + 0x41, 0xff, + 0x42, 0x29, + 0x43, 0x00, + 0x44, 0xff, + 0x45, 0x00, + 0x46, 0x00, + 0x49, 0x04, + 0x4a, 0x00, + 0x4b, 0x7b, + 0x52, 0x30, + 0x55, 0xae, + 0x56, 0x47, + 0x57, 0xe1, + 0x58, 0x3a, + 0x5a, 0x1e, + 0x5b, 0x34, + 0x60, 0x00, + 0x63, 0x00, + 0x64, 0x00, + 0x65, 0x00, + 0x66, 0x00, + 0x67, 0x00, + 0x68, 0x00, + 0x69, 0x00, + 0x6a, 0x02, + 0x6b, 0x00, + 0x70, 0xff, + 0x71, 0x00, + 0x72, 0x00, + 0x73, 0x00, + 0x74, 0x0c, + 0x80, 0x00, + 0x81, 0x00, + 0x82, 0x00, + 0x83, 0x00, + 0x84, 0x04, + 0x85, 0x80, + 0x86, 0x24, + 0x87, 0x78, + 0x88, 0x10, + 0x89, 0x00, + 0x90, 0x01, + 0x91, 0x01, + 0xa0, 0x04, + 0xa1, 0x00, + 0xa2, 0x00, + 0xb0, 0x91, + 0xb1, 0x0b, + 0xc0, 0x53, + 0xc1, 0x70, + 0xc2, 0x12, + 0xd0, 0x00, + 0xd1, 0x00, + 0xd2, 0x00, + 0xd3, 0x00, + 0xd4, 0x00, + 0xd5, 0x00, + 0xde, 0x00, + 0xdf, 0x00, + 0x61, 0x49, + 0x62, 0x0b, + 0x53, 0x08, + 0x59, 0x08, + 0xff, 0xff, +}; static int nexusca_stv0297_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) { @@ -1984,6 +2020,7 @@ static int nexusca_stv0297_pll_set(struct dvb_frontend* fe, struct dvb_frontend_ static struct stv0297_config nexusca_stv0297_config = { .demod_address = 0x1C, + .inittab = nexusca_stv0297_inittab, .invert = 1, .pll_set = nexusca_stv0297_pll_set, }; @@ -2261,7 +2298,7 @@ static int frontend_init(struct av7110 *av7110) case 0x000A: // Hauppauge/TT Nexus-CA rev1.X - av7110->fe = stv0297_attach(&nexusca_stv0297_config, &av7110->i2c_adap, 0x7b); + av7110->fe = stv0297_attach(&nexusca_stv0297_config, &av7110->i2c_adap); if (av7110->fe) { /* set TDA9819 into DVB mode */ saa7146_setgpio(av7110->dev, 1, SAA7146_GPIO_OUTLO); // TDA9198 pin9(STD) @@ -2692,7 +2729,7 @@ static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_d goto err_av7110_exit_v4l_12; #if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE) - av7110_ir_init(); + av7110_ir_init(av7110); #endif printk(KERN_INFO "dvb-ttpci: found av7110-%d.\n", av7110_num); av7110_num++; @@ -2734,6 +2771,9 @@ static int av7110_detach(struct saa7146_dev* saa) struct av7110 *av7110 = saa->ext_priv; dprintk(4, "%p\n", av7110); +#if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE) + av7110_ir_exit(av7110); +#endif if (budgetpatch) { /* Disable RPS1 */ saa7146_write(saa, MC1, MASK_29); @@ -2830,7 +2870,7 @@ static struct saa7146_pci_extension_data x_var = { \ .ext_priv = x_name, \ .ext = &av7110_extension } -MAKE_AV7110_INFO(tts_1_X, "Technotrend/Hauppauge WinTV DVB-S rev1.X"); +MAKE_AV7110_INFO(tts_1_X_fsc,"Technotrend/Hauppauge WinTV DVB-S rev1.X or Fujitsu Siemens DVB-C"); MAKE_AV7110_INFO(ttt_1_X, "Technotrend/Hauppauge WinTV DVB-T rev1.X"); MAKE_AV7110_INFO(ttc_1_X, "Technotrend/Hauppauge WinTV Nexus-CA rev1.X"); MAKE_AV7110_INFO(ttc_2_X, "Technotrend/Hauppauge WinTV DVB-C rev2.X"); @@ -2842,16 +2882,16 @@ MAKE_AV7110_INFO(fsc, "Fujitsu Siemens DVB-C"); MAKE_AV7110_INFO(fss, "Fujitsu Siemens DVB-S rev1.6"); static struct pci_device_id pci_tbl[] = { - MAKE_EXTENSION_PCI(fsc, 0x110a, 0x0000), - MAKE_EXTENSION_PCI(tts_1_X, 0x13c2, 0x0000), - MAKE_EXTENSION_PCI(ttt_1_X, 0x13c2, 0x0001), - MAKE_EXTENSION_PCI(ttc_2_X, 0x13c2, 0x0002), - MAKE_EXTENSION_PCI(tts_2_X, 0x13c2, 0x0003), - MAKE_EXTENSION_PCI(fss, 0x13c2, 0x0006), - MAKE_EXTENSION_PCI(ttt, 0x13c2, 0x0008), - MAKE_EXTENSION_PCI(ttc_1_X, 0x13c2, 0x000a), - MAKE_EXTENSION_PCI(tts_2_3, 0x13c2, 0x000e), - MAKE_EXTENSION_PCI(tts_1_3se, 0x13c2, 0x1002), + MAKE_EXTENSION_PCI(fsc, 0x110a, 0x0000), + MAKE_EXTENSION_PCI(tts_1_X_fsc, 0x13c2, 0x0000), + MAKE_EXTENSION_PCI(ttt_1_X, 0x13c2, 0x0001), + MAKE_EXTENSION_PCI(ttc_2_X, 0x13c2, 0x0002), + MAKE_EXTENSION_PCI(tts_2_X, 0x13c2, 0x0003), + MAKE_EXTENSION_PCI(fss, 0x13c2, 0x0006), + MAKE_EXTENSION_PCI(ttt, 0x13c2, 0x0008), + MAKE_EXTENSION_PCI(ttc_1_X, 0x13c2, 0x000a), + MAKE_EXTENSION_PCI(tts_2_3, 0x13c2, 0x000e), + MAKE_EXTENSION_PCI(tts_1_3se, 0x13c2, 0x1002), /* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0004), UNDEFINED CARD */ // Galaxis DVB PC-Sat-Carte /* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0005), UNDEFINED CARD */ // Technisat SkyStar1 @@ -2889,9 +2929,6 @@ static int __init av7110_init(void) static void __exit av7110_exit(void) { -#if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE) - av7110_ir_exit(); -#endif saa7146_unregister_extension(&av7110_extension); } diff --git a/drivers/media/dvb/ttpci/av7110.h b/drivers/media/dvb/ttpci/av7110.h index 508b7739c60..cce00ef293e 100644 --- a/drivers/media/dvb/ttpci/av7110.h +++ b/drivers/media/dvb/ttpci/av7110.h @@ -228,7 +228,10 @@ struct av7110 { struct dvb_video_events video_events; video_size_t video_size; - u32 ir_config; + u32 ir_config; + u32 ir_command; + void (*ir_handler)(struct av7110 *av7110, u32 ircom); + struct tasklet_struct ir_tasklet; /* firmware stuff */ unsigned char *bin_fw; @@ -257,12 +260,10 @@ struct av7110 { extern int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid, u16 subpid, u16 pcrpid); -extern void av7110_register_irc_handler(void (*func)(u32)); -extern void av7110_unregister_irc_handler(void (*func)(u32)); extern int av7110_setup_irc_config (struct av7110 *av7110, u32 ir_config); -extern int av7110_ir_init (void); -extern void av7110_ir_exit (void); +extern int av7110_ir_init(struct av7110 *av7110); +extern void av7110_ir_exit(struct av7110 *av7110); /* msp3400 i2c subaddresses */ #define MSP_WR_DEM 0x10 diff --git a/drivers/media/dvb/ttpci/av7110_hw.c b/drivers/media/dvb/ttpci/av7110_hw.c index 1220826696c..7442f56a72e 100644 --- a/drivers/media/dvb/ttpci/av7110_hw.c +++ b/drivers/media/dvb/ttpci/av7110_hw.c @@ -41,6 +41,8 @@ #include "av7110.h" #include "av7110_hw.h" +#define _NOHANDSHAKE + /**************************************************************************** * DEBI functions ****************************************************************************/ @@ -364,7 +366,8 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length) msleep(1); } - wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0xffff, 2); + if (FW_VERSION(av7110->arm_app) <= 0x261f) + wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0xffff, 2); #ifndef _NOHANDSHAKE start = jiffies; @@ -437,7 +440,8 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length) wdebi(av7110, DEBINOSWAP, COMMAND, (u32) buf[0], 2); - wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0x0000, 2); + if (FW_VERSION(av7110->arm_app) <= 0x261f) + wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0x0000, 2); #ifdef COM_DEBUG start = jiffies; diff --git a/drivers/media/dvb/ttpci/av7110_ir.c b/drivers/media/dvb/ttpci/av7110_ir.c index 665cdb8a3f7..357a3728ec6 100644 --- a/drivers/media/dvb/ttpci/av7110_ir.c +++ b/drivers/media/dvb/ttpci/av7110_ir.c @@ -7,16 +7,16 @@ #include <asm/bitops.h> #include "av7110.h" +#include "av7110_hw.h" -#define UP_TIMEOUT (HZ/4) +#define UP_TIMEOUT (HZ*7/25) /* enable ir debugging by or'ing debug with 16 */ -static int ir_initialized; +static int av_cnt; +static struct av7110 *av_list[4]; static struct input_dev input_dev; -static u32 ir_config; - static u16 key_map [256] = { KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_BACK, 0, KEY_POWER, KEY_MUTE, 0, KEY_INFO, @@ -53,8 +53,11 @@ static void av7110_emit_keyup(unsigned long data) static struct timer_list keyup_timer = { .function = av7110_emit_keyup }; -static void av7110_emit_key(u32 ircom) +static void av7110_emit_key(unsigned long parm) { + struct av7110 *av7110 = (struct av7110 *) parm; + u32 ir_config = av7110->ir_config; + u32 ircom = av7110->ir_command; u8 data; u8 addr; static u16 old_toggle = 0; @@ -62,19 +65,33 @@ static void av7110_emit_key(u32 ircom) u16 keycode; /* extract device address and data */ - if (ir_config & 0x0001) { - /* TODO RCMM: ? bits device address, 8 bits data */ + switch (ir_config & 0x0003) { + case 0: /* RC5: 5 bits device address, 6 bits data */ + data = ircom & 0x3f; + addr = (ircom >> 6) & 0x1f; + break; + + case 1: /* RCMM: 8(?) bits device address, 8(?) bits data */ data = ircom & 0xff; addr = (ircom >> 8) & 0xff; - } else { - /* RC5: 5 bits device address, 6 bits data */ + break; + + case 2: /* extended RC5: 5 bits device address, 7 bits data */ data = ircom & 0x3f; addr = (ircom >> 6) & 0x1f; + /* invert 7th data bit for backward compatibility with RC5 keymaps */ + if (!(ircom & 0x1000)) + data |= 0x40; + break; + + default: + printk("invalid ir_config %x\n", ir_config); + return; } keycode = key_map[data]; - dprintk(16, "#########%08x######### addr %i data 0x%02x (keycode %i)\n", + dprintk(16, "code %08x -> addr %i data 0x%02x -> keycode %i\n", ircom, addr, data, keycode); /* check device address (if selected) */ @@ -87,10 +104,10 @@ static void av7110_emit_key(u32 ircom) return; } - if (ir_config & 0x0001) + if ((ir_config & 0x0003) == 1) new_toggle = 0; /* RCMM */ else - new_toggle = (ircom & 0x800); /* RC5 */ + new_toggle = (ircom & 0x800); /* RC5, extended RC5 */ if (timer_pending(&keyup_timer)) { del_timer(&keyup_timer); @@ -137,6 +154,8 @@ static int av7110_ir_write_proc(struct file *file, const char __user *buffer, { char *page; int size = 4 + 256 * sizeof(u16); + u32 ir_config; + int i; if (count < size) return -EINVAL; @@ -153,60 +172,95 @@ static int av7110_ir_write_proc(struct file *file, const char __user *buffer, memcpy(&ir_config, page, 4); memcpy(&key_map, page + 4, 256 * sizeof(u16)); vfree(page); - av7110_setup_irc_config(NULL, ir_config); + if (FW_VERSION(av_list[0]->arm_app) >= 0x2620 && !(ir_config & 0x0001)) + ir_config |= 0x0002; /* enable extended RC5 */ + for (i = 0; i < av_cnt; i++) + av7110_setup_irc_config(av_list[i], ir_config); input_register_keys(); return count; } -int __init av7110_ir_init(void) +int av7110_setup_irc_config(struct av7110 *av7110, u32 ir_config) { - static struct proc_dir_entry *e; + int ret = 0; - if (ir_initialized) - return 0; + dprintk(4, "%p\n", av7110); + if (av7110) { + ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, SetIR, 1, ir_config); + av7110->ir_config = ir_config; + } + return ret; +} - init_timer(&keyup_timer); - keyup_timer.data = 0; - input_dev.name = "DVB on-card IR receiver"; +static void ir_handler(struct av7110 *av7110, u32 ircom) +{ + dprintk(4, "ircommand = %08x\n", ircom); + av7110->ir_command = ircom; + tasklet_schedule(&av7110->ir_tasklet); +} - /** - * enable keys - */ - set_bit(EV_KEY, input_dev.evbit); - set_bit(EV_REP, input_dev.evbit); - input_register_keys(); +int __init av7110_ir_init(struct av7110 *av7110) +{ + static struct proc_dir_entry *e; - input_register_device(&input_dev); - input_dev.timer.function = input_repeat_key; + if (av_cnt >= sizeof av_list/sizeof av_list[0]) + return -ENOSPC; - av7110_setup_irc_config(NULL, 0x0001); - av7110_register_irc_handler(av7110_emit_key); + av7110_setup_irc_config(av7110, 0x0001); + av_list[av_cnt++] = av7110; - e = create_proc_entry("av7110_ir", S_IFREG | S_IRUGO | S_IWUSR, NULL); - if (e) { - e->write_proc = av7110_ir_write_proc; - e->size = 4 + 256 * sizeof(u16); + if (av_cnt == 1) { + init_timer(&keyup_timer); + keyup_timer.data = 0; + + input_dev.name = "DVB on-card IR receiver"; + set_bit(EV_KEY, input_dev.evbit); + set_bit(EV_REP, input_dev.evbit); + input_register_keys(); + input_register_device(&input_dev); + input_dev.timer.function = input_repeat_key; + + e = create_proc_entry("av7110_ir", S_IFREG | S_IRUGO | S_IWUSR, NULL); + if (e) { + e->write_proc = av7110_ir_write_proc; + e->size = 4 + 256 * sizeof(u16); + } } - ir_initialized = 1; + tasklet_init(&av7110->ir_tasklet, av7110_emit_key, (unsigned long) av7110); + av7110->ir_handler = ir_handler; + return 0; } -void __exit av7110_ir_exit(void) +void __exit av7110_ir_exit(struct av7110 *av7110) { - if (ir_initialized == 0) + int i; + + if (av_cnt == 0) return; - del_timer_sync(&keyup_timer); - remove_proc_entry("av7110_ir", NULL); - av7110_unregister_irc_handler(av7110_emit_key); - input_unregister_device(&input_dev); - ir_initialized = 0; + + av7110->ir_handler = NULL; + tasklet_kill(&av7110->ir_tasklet); + for (i = 0; i < av_cnt; i++) + if (av_list[i] == av7110) { + av_list[i] = av_list[av_cnt-1]; + av_list[av_cnt-1] = NULL; + break; + } + + if (av_cnt == 1) { + del_timer_sync(&keyup_timer); + remove_proc_entry("av7110_ir", NULL); + input_unregister_device(&input_dev); + } + + av_cnt--; } //MODULE_AUTHOR("Holger Waechtler <holger@convergence.de>"); //MODULE_LICENSE("GPL"); - diff --git a/drivers/media/dvb/ttpci/av7110_v4l.c b/drivers/media/dvb/ttpci/av7110_v4l.c index e65fc36e2ce..6af74f78b3e 100644 --- a/drivers/media/dvb/ttpci/av7110_v4l.c +++ b/drivers/media/dvb/ttpci/av7110_v4l.c @@ -70,7 +70,7 @@ static int msp_readreg(struct av7110 *av7110, u8 dev, u16 reg, u16 *val) return 0; } -static struct v4l2_input inputs[2] = { +static struct v4l2_input inputs[4] = { { .index = 0, .name = "DVB", @@ -87,6 +87,22 @@ static struct v4l2_input inputs[2] = { .tuner = 0, .std = V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, .status = 0, + }, { + .index = 2, + .name = "Video", + .type = V4L2_INPUT_TYPE_CAMERA, + .audioset = 0, + .tuner = 0, + .std = V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, + .status = 0, + }, { + .index = 3, + .name = "Y/C", + .type = V4L2_INPUT_TYPE_CAMERA, + .audioset = 0, + .tuner = 0, + .std = V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, + .status = 0, } }; @@ -212,24 +228,44 @@ static int av7110_dvb_c_switch(struct saa7146_fh *fh) } if (0 != av7110->current_input) { + dprintk(1, "switching to analog TV:\n"); adswitch = 1; source = SAA7146_HPS_SOURCE_PORT_B; sync = SAA7146_HPS_SYNC_PORT_B; memcpy(standard, analog_standard, sizeof(struct saa7146_standard) * 2); - dprintk(1, "switching to analog TV\n"); - msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0000); // loudspeaker source - msp_writereg(av7110, MSP_WR_DSP, 0x0009, 0x0000); // headphone source - msp_writereg(av7110, MSP_WR_DSP, 0x000a, 0x0000); // SCART 1 source - msp_writereg(av7110, MSP_WR_DSP, 0x000e, 0x3000); // FM matrix, mono - msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x4f00); // loudspeaker + headphone - msp_writereg(av7110, MSP_WR_DSP, 0x0007, 0x4f00); // SCART 1 volume - if (av7110->analog_tuner_flags & ANALOG_TUNER_VES1820) { - if (ves1820_writereg(dev, 0x09, 0x0f, 0x60)) - dprintk(1, "setting band in demodulator failed.\n"); - } else if (av7110->analog_tuner_flags & ANALOG_TUNER_STV0297) { - saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // TDA9198 pin9(STD) - saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI); // TDA9198 pin30(VIF) + switch (av7110->current_input) { + case 1: + dprintk(1, "switching SAA7113 to Analog Tuner Input.\n"); + msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0000); // loudspeaker source + msp_writereg(av7110, MSP_WR_DSP, 0x0009, 0x0000); // headphone source + msp_writereg(av7110, MSP_WR_DSP, 0x000a, 0x0000); // SCART 1 source + msp_writereg(av7110, MSP_WR_DSP, 0x000e, 0x3000); // FM matrix, mono + msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x4f00); // loudspeaker + headphone + msp_writereg(av7110, MSP_WR_DSP, 0x0007, 0x4f00); // SCART 1 volume + + if (av7110->analog_tuner_flags & ANALOG_TUNER_VES1820) { + if (ves1820_writereg(dev, 0x09, 0x0f, 0x60)) + dprintk(1, "setting band in demodulator failed.\n"); + } else if (av7110->analog_tuner_flags & ANALOG_TUNER_STV0297) { + saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // TDA9198 pin9(STD) + saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI); // TDA9198 pin30(VIF) + } + if (i2c_writereg(av7110, 0x48, 0x02, 0xd0) != 1) + dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num); + break; + case 2: + dprintk(1, "switching SAA7113 to Video AV CVBS Input.\n"); + if (i2c_writereg(av7110, 0x48, 0x02, 0xd2) != 1) + dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num); + break; + case 3: + dprintk(1, "switching SAA7113 to Video AV Y/C Input.\n"); + if (i2c_writereg(av7110, 0x48, 0x02, 0xd9) != 1) + dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num); + break; + default: + dprintk(1, "switching SAA7113 to Input: AV7110: SAA7113: invalid input.\n"); } } else { adswitch = 0; @@ -300,7 +336,6 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) // FIXME: standard / stereo detection is still broken msp_readreg(av7110, MSP_RD_DEM, 0x007e, &stereo_det); dprintk(1, "VIDIOC_G_TUNER: msp3400 TV standard detection: 0x%04x\n", stereo_det); - msp_readreg(av7110, MSP_RD_DSP, 0x0018, &stereo_det); dprintk(1, "VIDIOC_G_TUNER: msp3400 stereo detection: 0x%04x\n", stereo_det); stereo = (s8)(stereo_det >> 8); @@ -310,7 +345,7 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) t->audmode = V4L2_TUNER_MODE_STEREO; } else if (stereo < -0x10) { - /* bilingual*/ + /* bilingual */ t->rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; t->audmode = V4L2_TUNER_MODE_LANG1; } @@ -344,7 +379,7 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) fm_matrix = 0x3000; // mono src = 0x0010; break; - default: /* case V4L2_TUNER_MODE_MONO: {*/ + default: /* case V4L2_TUNER_MODE_MONO: */ dprintk(2, "VIDIOC_S_TUNER: TDA9840_SET_MONO\n"); fm_matrix = 0x3000; // mono src = 0x0030; @@ -406,7 +441,7 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) dprintk(2, "VIDIOC_ENUMINPUT: %d\n", i->index); if (av7110->analog_tuner_flags) { - if (i->index < 0 || i->index >= 2) + if (i->index < 0 || i->index >= 4) return -EINVAL; } else { if (i->index != 0) @@ -433,10 +468,9 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) if (!av7110->analog_tuner_flags) return 0; - if (input < 0 || input >= 2) + if (input < 0 || input >= 4) return -EINVAL; - /* FIXME: switch inputs here */ av7110->current_input = input; return av7110_dvb_c_switch(fh); } diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c index 9746d2bb916..7692cd23f83 100644 --- a/drivers/media/dvb/ttpci/budget-av.c +++ b/drivers/media/dvb/ttpci/budget-av.c @@ -192,7 +192,7 @@ static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot) { struct budget_av *budget_av = (struct budget_av *) ca->data; struct saa7146_dev *saa = budget_av->budget.dev; - int timeout = 50; // 5 seconds (4.4.6 Ready) + int timeout = 500; // 5 seconds (4.4.6 Ready) if (slot != 0) return -EINVAL; @@ -217,7 +217,6 @@ static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot) { printk(KERN_ERR "budget-av: cam reset failed (timeout).\n"); saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */ - saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI); /* Vcc off */ return -ETIMEDOUT; } @@ -276,7 +275,6 @@ static int ciintf_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open { printk(KERN_INFO "budget-av: cam ejected\n"); saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */ - saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI); /* Vcc off */ budget_av->slot_status = 0; } } @@ -453,9 +451,9 @@ static int philips_su1278_ty_ci_set_symbol_rate(struct dvb_frontend *fe, u32 sra } static int philips_su1278_ty_ci_pll_set(struct dvb_frontend *fe, + struct i2c_adapter *i2c, struct dvb_frontend_parameters *params) { - struct budget_av *budget_av = (struct budget_av *) fe->dvb->priv; u32 div; u8 buf[4]; struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) }; @@ -481,7 +479,7 @@ static int philips_su1278_ty_ci_pll_set(struct dvb_frontend *fe, else if (params->frequency < 2150000) buf[3] |= 0xC0; - if (i2c_transfer(&budget_av->budget.i2c_adap, &msg, 1) != 1) + if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; return 0; } @@ -745,6 +743,7 @@ static void frontend_init(struct budget_av *budget_av) case SUBID_DVBC_KNC1_PLUS: case SUBID_DVBT_KNC1_PLUS: // Enable / PowerON Frontend + saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO); saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTHI); break; } diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c index a1267054bc0..2980db3ef22 100644 --- a/drivers/media/dvb/ttpci/budget-ci.c +++ b/drivers/media/dvb/ttpci/budget-ci.c @@ -40,6 +40,7 @@ #include "dvb_ca_en50221.h" #include "stv0299.h" +#include "stv0297.h" #include "tda1004x.h" #define DEBIADDR_IR 0x1234 @@ -548,9 +549,8 @@ static int alps_bsru6_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ra return 0; } -static int alps_bsru6_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) +static int alps_bsru6_pll_set(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters *params) { - struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv; u8 buf[4]; u32 div; struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) }; @@ -567,7 +567,7 @@ static int alps_bsru6_pll_set(struct dvb_frontend *fe, struct dvb_frontend_param if (params->frequency > 1530000) buf[3] = 0xc0; - if (i2c_transfer(&budget_ci->budget.i2c_adap, &msg, 1) != 1) + if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; return 0; } @@ -669,9 +669,9 @@ static int philips_su1278_tt_set_symbol_rate(struct dvb_frontend *fe, u32 srate, } static int philips_su1278_tt_pll_set(struct dvb_frontend *fe, + struct i2c_adapter *i2c, struct dvb_frontend_parameters *params) { - struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv; u32 div; u8 buf[4]; struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = buf,.len = sizeof(buf) }; @@ -697,7 +697,7 @@ static int philips_su1278_tt_pll_set(struct dvb_frontend *fe, else if (params->frequency < 2150000) buf[3] |= 0xC0; - if (i2c_transfer(&budget_ci->budget.i2c_adap, &msg, 1) != 1) + if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; return 0; } @@ -848,6 +848,180 @@ static struct tda1004x_config philips_tdm1316l_config = { .request_firmware = philips_tdm1316l_request_firmware, }; +static int dvbc_philips_tdm1316l_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) +{ + struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv; + u8 tuner_buf[5]; + struct i2c_msg tuner_msg = {.addr = budget_ci->tuner_pll_address, + .flags = 0, + .buf = tuner_buf, + .len = sizeof(tuner_buf) }; + int tuner_frequency = 0; + u8 band, cp, filter; + + // determine charge pump + tuner_frequency = params->frequency + 36125000; + if (tuner_frequency < 87000000) + return -EINVAL; + else if (tuner_frequency < 130000000) { + cp = 3; + band = 1; + } else if (tuner_frequency < 160000000) { + cp = 5; + band = 1; + } else if (tuner_frequency < 200000000) { + cp = 6; + band = 1; + } else if (tuner_frequency < 290000000) { + cp = 3; + band = 2; + } else if (tuner_frequency < 420000000) { + cp = 5; + band = 2; + } else if (tuner_frequency < 480000000) { + cp = 6; + band = 2; + } else if (tuner_frequency < 620000000) { + cp = 3; + band = 4; + } else if (tuner_frequency < 830000000) { + cp = 5; + band = 4; + } else if (tuner_frequency < 895000000) { + cp = 7; + band = 4; + } else + return -EINVAL; + + // assume PLL filter should always be 8MHz for the moment. + filter = 1; + + // calculate divisor + tuner_frequency = (params->frequency + 36125000 + (62500/2)) / 62500; + + // setup tuner buffer + tuner_buf[0] = tuner_frequency >> 8; + tuner_buf[1] = tuner_frequency & 0xff; + tuner_buf[2] = 0xc8; + tuner_buf[3] = (cp << 5) | (filter << 3) | band; + tuner_buf[4] = 0x80; + + stv0297_enable_plli2c(fe); + if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1) + return -EIO; + + msleep(50); + + stv0297_enable_plli2c(fe); + if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1) + return -EIO; + + msleep(1); + + return 0; +} + +static u8 dvbc_philips_tdm1316l_inittab[] = { + 0x80, 0x01, + 0x80, 0x00, + 0x81, 0x01, + 0x81, 0x00, + 0x00, 0x09, + 0x01, 0x69, + 0x03, 0x00, + 0x04, 0x00, + 0x07, 0x00, + 0x08, 0x00, + 0x20, 0x00, + 0x21, 0x40, + 0x22, 0x00, + 0x23, 0x00, + 0x24, 0x40, + 0x25, 0x88, + 0x30, 0xff, + 0x31, 0x00, + 0x32, 0xff, + 0x33, 0x00, + 0x34, 0x50, + 0x35, 0x7f, + 0x36, 0x00, + 0x37, 0x20, + 0x38, 0x00, + 0x40, 0x1c, + 0x41, 0xff, + 0x42, 0x29, + 0x43, 0x20, + 0x44, 0xff, + 0x45, 0x00, + 0x46, 0x00, + 0x49, 0x04, + 0x4a, 0x00, + 0x4b, 0x7b, + 0x52, 0x30, + 0x55, 0xae, + 0x56, 0x47, + 0x57, 0xe1, + 0x58, 0x3a, + 0x5a, 0x1e, + 0x5b, 0x34, + 0x60, 0x00, + 0x63, 0x00, + 0x64, 0x00, + 0x65, 0x00, + 0x66, 0x00, + 0x67, 0x00, + 0x68, 0x00, + 0x69, 0x00, + 0x6a, 0x02, + 0x6b, 0x00, + 0x70, 0xff, + 0x71, 0x00, + 0x72, 0x00, + 0x73, 0x00, + 0x74, 0x0c, + 0x80, 0x00, + 0x81, 0x00, + 0x82, 0x00, + 0x83, 0x00, + 0x84, 0x04, + 0x85, 0x80, + 0x86, 0x24, + 0x87, 0x78, + 0x88, 0x10, + 0x89, 0x00, + 0x90, 0x01, + 0x91, 0x01, + 0xa0, 0x04, + 0xa1, 0x00, + 0xa2, 0x00, + 0xb0, 0x91, + 0xb1, 0x0b, + 0xc0, 0x53, + 0xc1, 0x70, + 0xc2, 0x12, + 0xd0, 0x00, + 0xd1, 0x00, + 0xd2, 0x00, + 0xd3, 0x00, + 0xd4, 0x00, + 0xd5, 0x00, + 0xde, 0x00, + 0xdf, 0x00, + 0x61, 0x38, + 0x62, 0x0a, + 0x53, 0x13, + 0x59, 0x08, + 0xff, 0xff, +}; + +static struct stv0297_config dvbc_philips_tdm1316l_config = { + .demod_address = 0x1c, + .inittab = dvbc_philips_tdm1316l_inittab, + .invert = 0, + .pll_set = dvbc_philips_tdm1316l_pll_set, +}; + + static void frontend_init(struct budget_ci *budget_ci) @@ -869,6 +1043,15 @@ static void frontend_init(struct budget_ci *budget_ci) } break; + case 0x1010: // TT DVB-C CI budget (stv0297/Philips tdm1316l(tda6651tt)) + budget_ci->tuner_pll_address = 0x61; + budget_ci->budget.dvb_frontend = + stv0297_attach(&dvbc_philips_tdm1316l_config, &budget_ci->budget.i2c_adap); + if (budget_ci->budget.dvb_frontend) { + break; + } + break; + case 0x1011: // Hauppauge/TT Nova-T budget (tda10045/Philips tdm1316l(tda6651tt) + TDA9889) budget_ci->tuner_pll_address = 0x63; budget_ci->budget.dvb_frontend = @@ -878,7 +1061,7 @@ static void frontend_init(struct budget_ci *budget_ci) } break; - case 0x1012: // Hauppauge/TT Nova-T CI budget (tda10045/Philips tdm1316l(tda6651tt) + TDA9889) + case 0x1012: // TT DVB-T CI budget (tda10046/Philips tdm1316l(tda6651tt)) budget_ci->tuner_pll_address = 0x60; budget_ci->budget.dvb_frontend = tda10046_attach(&philips_tdm1316l_config, &budget_ci->budget.i2c_adap); @@ -966,10 +1149,12 @@ static struct saa7146_extension budget_extension; MAKE_BUDGET_INFO(ttbci, "TT-Budget/WinTV-NOVA-CI PCI", BUDGET_TT_HW_DISEQC); MAKE_BUDGET_INFO(ttbt2, "TT-Budget/WinTV-NOVA-T PCI", BUDGET_TT); MAKE_BUDGET_INFO(ttbtci, "TT-Budget-T-CI PCI", BUDGET_TT); +MAKE_BUDGET_INFO(ttbcci, "TT-Budget-C-CI PCI", BUDGET_TT); static struct pci_device_id pci_tbl[] = { MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100c), MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100f), + MAKE_EXTENSION_PCI(ttbcci, 0x13c2, 0x1010), MAKE_EXTENSION_PCI(ttbt2, 0x13c2, 0x1011), MAKE_EXTENSION_PCI(ttbtci, 0x13c2, 0x1012), { diff --git a/drivers/media/dvb/ttpci/budget-patch.c b/drivers/media/dvb/ttpci/budget-patch.c index 8142e26b47f..b1f21ef0e3b 100644 --- a/drivers/media/dvb/ttpci/budget-patch.c +++ b/drivers/media/dvb/ttpci/budget-patch.c @@ -353,9 +353,8 @@ static int alps_bsru6_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ra return 0; } -static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) +static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params) { - struct budget_patch* budget = (struct budget_patch*) fe->dvb->priv; u8 data[4]; u32 div; struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; @@ -370,7 +369,7 @@ static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param if (params->frequency > 1530000) data[3] = 0xc0; - if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; + if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; return 0; } diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c index 9961917e8a7..43d6c826864 100644 --- a/drivers/media/dvb/ttpci/budget.c +++ b/drivers/media/dvb/ttpci/budget.c @@ -332,9 +332,8 @@ static int alps_bsru6_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ra return 0; } -static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) +static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params) { - struct budget* budget = (struct budget*) fe->dvb->priv; u8 data[4]; u32 div; struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; @@ -349,7 +348,7 @@ static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param if (params->frequency > 1530000) data[3] = 0xc0; - if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; + if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; return 0; } @@ -481,6 +480,7 @@ static int s5h1420_pll_set(struct dvb_frontend* fe, struct dvb_frontend_paramete static struct s5h1420_config s5h1420_config = { .demod_address = 0x53, + .invert = 1, .pll_set = s5h1420_pll_set, }; diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c index 7daf7b1598a..d200ab0ad9e 100644 --- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c +++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c @@ -18,6 +18,7 @@ #include <linux/delay.h> #include <linux/time.h> #include <linux/errno.h> +#include <linux/jiffies.h> #include <asm/semaphore.h> #include "dvb_frontend.h" @@ -570,7 +571,8 @@ static void ttusb_handle_sec_data(struct ttusb_channel *channel, const u8 * data, int len); #endif -static int numpkt = 0, lastj, numts, numstuff, numsec, numinvalid; +static int numpkt = 0, numts, numstuff, numsec, numinvalid; +static unsigned long lastj; static void ttusb_process_muxpack(struct ttusb *ttusb, const u8 * muxpack, int len) @@ -779,7 +781,7 @@ static void ttusb_iso_irq(struct urb *urb, struct pt_regs *ptregs) u8 *data; int len; numpkt++; - if ((jiffies - lastj) >= HZ) { + if (time_after_eq(jiffies, lastj + HZ)) { #if DEBUG > 2 printk ("frames/s: %d (ts: %d, stuff %d, sec: %d, invalid: %d, all: %d)\n", @@ -1299,7 +1301,7 @@ static int alps_stv0299_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 return 0; } -static int philips_tsa5059_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) +static int philips_tsa5059_pll_set(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters *params) { struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv; u8 buf[4]; @@ -1322,7 +1324,7 @@ static int philips_tsa5059_pll_set(struct dvb_frontend *fe, struct dvb_frontend_ if (ttusb->revision == TTUSB_REV_2_2) buf[3] |= 0x20; - if (i2c_transfer(&ttusb->i2c_adap, &msg, 1) != 1) + if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; return 0; diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c index 45c9a9a08e4..3d08fc83a75 100644 --- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c +++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c @@ -28,7 +28,6 @@ #include <linux/slab.h> #include <linux/spinlock.h> #include <linux/usb.h> -#include <linux/version.h> #include <linux/interrupt.h> #include <linux/firmware.h> #include <linux/crc32.h> diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index 16c85c081e6..93570355819 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -22,12 +22,21 @@ config VIDEO_BT848 the Miro, Hauppauge and STB boards. Please read the material in <file:Documentation/video4linux/bttv/> for more information. - If you say Y or M here, you need to say Y or M to "I2C support" and - "I2C bit-banging interfaces" in the device drivers section. - To compile this driver as a module, choose M here: the module will be called bttv. +config VIDEO_SAA6588 + tristate "SAA6588 Radio Chip RDS decoder support on BT848 cards" + depends on VIDEO_DEV && I2C && VIDEO_BT848 + + help + Support for Radio Data System (RDS) decoder. This allows seeing + radio station identification transmitted using this standard. + Currentlly, it works only with bt8x8 chips. + + To compile this driver as a module, choose M here: the + module will be called saa6588. + config VIDEO_PMS tristate "Mediavision Pro Movie Studio Video For Linux" depends on VIDEO_DEV && ISA diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index 3e6f5347da2..046b82de928 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile @@ -5,6 +5,7 @@ bttv-objs := bttv-driver.o bttv-cards.o bttv-if.o \ bttv-risc.o bttv-vbi.o bttv-i2c.o bttv-gpio.o zoran-objs := zr36120.o zr36120_i2c.o zr36120_mem.o +rds-objs := saa6588.o zr36067-objs := zoran_procfs.o zoran_device.o \ zoran_driver.o zoran_card.o tuner-objs := tuner-core.o tuner-simple.o mt20xx.o tda8290.o tea5767.o @@ -15,6 +16,7 @@ obj-$(CONFIG_VIDEO_BT848) += bttv.o msp3400.o tvaudio.o \ obj-$(CONFIG_SOUND_TVMIXER) += tvmixer.o obj-$(CONFIG_VIDEO_ZR36120) += zoran.o +obj-$(CONFIG_VIDEO_SAA6588) += rds.o obj-$(CONFIG_VIDEO_SAA5246A) += saa5246a.o obj-$(CONFIG_VIDEO_SAA5249) += saa5249.o obj-$(CONFIG_VIDEO_CQCAM) += c-qcam.o diff --git a/drivers/media/video/btcx-risc.c b/drivers/media/video/btcx-risc.c index 7f2d515d287..a48de3c0e3f 100644 --- a/drivers/media/video/btcx-risc.c +++ b/drivers/media/video/btcx-risc.c @@ -1,5 +1,4 @@ /* - $Id: btcx-risc.c,v 1.6 2005/02/21 13:57:59 kraxel Exp $ btcx-risc.c diff --git a/drivers/media/video/btcx-risc.h b/drivers/media/video/btcx-risc.h index 41f60395a52..503e6c6d7b6 100644 --- a/drivers/media/video/btcx-risc.h +++ b/drivers/media/video/btcx-risc.h @@ -1,5 +1,4 @@ /* - * $Id: btcx-risc.h,v 1.2 2004/09/15 16:15:24 kraxel Exp $ */ struct btcx_riscmem { unsigned int size; diff --git a/drivers/media/video/bttv-cards.c b/drivers/media/video/bttv-cards.c index a97b9b958ed..190977a1e54 100644 --- a/drivers/media/video/bttv-cards.c +++ b/drivers/media/video/bttv-cards.c @@ -1,5 +1,4 @@ /* - $Id: bttv-cards.c,v 1.54 2005/07/19 18:26:46 mkrufky Exp $ bttv-cards.c @@ -169,10 +168,10 @@ static struct CARD { { 0xd01810fc, BTTV_GVBCTV5PCI, "I-O Data Co. GV-BCTV5/PCI" }, { 0x001211bd, BTTV_PINNACLE, "Pinnacle PCTV" }, - // some cards ship with byteswapped IDs ... + /* some cards ship with byteswapped IDs ... */ { 0x1200bd11, BTTV_PINNACLE, "Pinnacle PCTV [bswap]" }, { 0xff00bd11, BTTV_PINNACLE, "Pinnacle PCTV [bswap]" }, - // this seems to happen as well ... + /* this seems to happen as well ... */ { 0xff1211bd, BTTV_PINNACLE, "Pinnacle PCTV" }, { 0x3000121a, BTTV_VOODOOTV_FM, "3Dfx VoodooTV FM/ VoodooTV 200" }, @@ -200,12 +199,12 @@ static struct CARD { { 0x1123153b, BTTV_TERRATVRADIO, "Terratec TV Radio+" }, { 0x1127153b, BTTV_TERRATV, "Terratec TV+ (V1.05)" }, - // clashes with FlyVideo - //{ 0x18521852, BTTV_TERRATV, "Terratec TV+ (V1.10)" }, + /* clashes with FlyVideo + *{ 0x18521852, BTTV_TERRATV, "Terratec TV+ (V1.10)" }, */ { 0x1134153b, BTTV_TERRATVALUE, "Terratec TValue (LR102)" }, - { 0x1135153b, BTTV_TERRATVALUER, "Terratec TValue Radio" }, // LR102 - { 0x5018153b, BTTV_TERRATVALUE, "Terratec TValue" }, // ?? - { 0xff3b153b, BTTV_TERRATVALUER, "Terratec TValue Radio" }, // ?? + { 0x1135153b, BTTV_TERRATVALUER, "Terratec TValue Radio" }, /* LR102 */ + { 0x5018153b, BTTV_TERRATVALUE, "Terratec TValue" }, /* ?? */ + { 0xff3b153b, BTTV_TERRATVALUER, "Terratec TValue Radio" }, /* ?? */ { 0x400015b0, BTTV_ZOLTRIX_GENIE, "Zoltrix Genie TV" }, { 0x400a15b0, BTTV_ZOLTRIX_GENIE, "Zoltrix Genie TV" }, @@ -287,10 +286,12 @@ static struct CARD { { 0x01071805, BTTV_PICOLO_TETRA_CHIP, "Picolo Tetra Chip #3" }, { 0x01081805, BTTV_PICOLO_TETRA_CHIP, "Picolo Tetra Chip #4" }, - // likely broken, vendor id doesn't match the other magic views ... - //{ 0xa0fca04f, BTTV_MAGICTVIEW063, "Guillemot Maxi TV Video 3" }, + { 0x15409511, BTTV_ACORP_Y878F, "Acorp Y878F" }, - // DVB cards (using pci function .1 for mpeg data xfer) + /* likely broken, vendor id doesn't match the other magic views ... + * { 0xa0fca04f, BTTV_MAGICTVIEW063, "Guillemot Maxi TV Video 3" }, */ + + /* DVB cards (using pci function .1 for mpeg data xfer) */ { 0x01010071, BTTV_NEBULA_DIGITV, "Nebula Electronics DigiTV" }, { 0x07611461, BTTV_AVDVBT_761, "AverMedia AverTV DVB-T 761" }, { 0x001c11bd, BTTV_PINNACLESAT, "Pinnacle PCTV Sat" }, @@ -298,7 +299,8 @@ static struct CARD { { 0x00011822, BTTV_TWINHAN_DST, "Twinhan VisionPlus DVB" }, { 0xfc00270f, BTTV_TWINHAN_DST, "ChainTech digitop DST-1000 DVB-S" }, { 0x07711461, BTTV_AVDVBT_771, "AVermedia AverTV DVB-T 771" }, - { 0xdb1018ac, BTTV_DVICO_DVBT_LITE, "DVICO FusionHDTV DVB-T Lite" }, + { 0xdb1018ac, BTTV_DVICO_DVBT_LITE, "DViCO FusionHDTV DVB-T Lite" }, + { 0xd50018ac, BTTV_DVICO_FUSIONHDTV_5_LITE, "DViCO FusionHDTV 5 Lite" }, { 0, -1, NULL } }; @@ -316,6 +318,7 @@ struct tvcard bttv_tvcards[] = { .svhs = 2, .muxsel = { 2, 3, 1, 0}, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "MIRO PCTV", .video_inputs = 4, @@ -327,6 +330,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 2, 0, 0, 0, 10}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Hauppauge (bt848)", .video_inputs = 4, @@ -338,6 +342,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 1, 2, 3, 4}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "STB, Gateway P/N 6000699 (bt848)", .video_inputs = 3, @@ -350,6 +355,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .needs_tvaudio = 1, .tuner_type = TUNER_PHILIPS_NTSC, + .tuner_addr = ADDR_UNSET, .pll = PLL_28, .has_radio = 1, },{ @@ -365,6 +371,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0 }, .needs_tvaudio = 0, .tuner_type = 4, + .tuner_addr = ADDR_UNSET, },{ .name = "Diamond DTV2000", .video_inputs = 4, @@ -376,6 +383,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 1, 0, 1, 3}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "AVerMedia TVPhone", .video_inputs = 3, @@ -388,6 +396,7 @@ struct tvcard bttv_tvcards[] = { /* 0x04 for some cards ?? */ .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .audio_hook = avermedia_tvphone_audio, .has_remote = 1, },{ @@ -401,6 +410,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = {0 }, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x08 ---------------------------------- */ @@ -415,6 +425,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "IMS/IXmicro TurboTV", .video_inputs = 3, @@ -427,6 +438,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 0, .pll = PLL_28, .tuner_type = TUNER_TEMIC_PAL, + .tuner_addr = ADDR_UNSET, },{ .name = "Hauppauge (bt878)", .video_inputs = 4, @@ -439,6 +451,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "MIRO PCTV pro", .video_inputs = 3, @@ -450,6 +463,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0x20001,0x10001, 0, 0,10}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x0c ---------------------------------- */ @@ -463,6 +477,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 13, 14, 11, 7, 0, 0}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "AVerMedia TVCapture 98", .video_inputs = 3, @@ -476,6 +491,7 @@ struct tvcard bttv_tvcards[] = { .msp34xx_alt = 1, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .audio_hook = avermedia_tv_stereo_audio, },{ .name = "Aimslab Video Highway Xtreme (VHX)", @@ -489,6 +505,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Zoltrix TV-Max", .video_inputs = 3, @@ -500,6 +517,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = {0 , 0, 1 , 0, 10}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x10 ---------------------------------- */ @@ -510,7 +528,7 @@ struct tvcard bttv_tvcards[] = { .svhs = 2, .gpiomask = 0x01fe00, .muxsel = { 2, 3, 1, 1}, - // 2003-10-20 by "Anton A. Arapov" <arapov@mail.ru> + /* 2003-10-20 by "Anton A. Arapov" <arapov@mail.ru> */ .audiomux = { 0x001e00, 0, 0x018000, 0x014000, 0x002000, 0 }, .needs_tvaudio = 1, .pll = PLL_28, @@ -526,6 +544,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0x4fa007,0xcfa007,0xcfa007,0xcfa007,0xcfa007,0xcfa007}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .audio_hook = winview_audio, .has_radio = 1, },{ @@ -539,6 +558,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = {1, 0, 0, 0, 0}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Lifeview FlyVideo II EZ /FlyKit LR38 Bt848 (capture only)", .video_inputs = 4, @@ -550,6 +570,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0 }, .no_msp34xx = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x14 ---------------------------------- */ @@ -560,10 +581,11 @@ struct tvcard bttv_tvcards[] = { .svhs = 2, .muxsel = {2, 3, 1, 1}, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Lifeview FlyVideo 98/ Lucky Star Image World ConferenceTV LR50", .video_inputs = 4, - .audio_inputs = 2, // tuner, line in + .audio_inputs = 2, /* tuner, line in */ .tuner = 0, .svhs = 2, .gpiomask = 0x1800, @@ -571,6 +593,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800}, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL_I, + .tuner_addr = ADDR_UNSET, },{ .name = "Askey CPH050/ Phoebe Tv Master + FM", .video_inputs = 3, @@ -583,6 +606,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Modular Technology MM201/MM202/MM205/MM210/MM215 PCTV, bt878", .video_inputs = 3, @@ -591,11 +615,12 @@ struct tvcard bttv_tvcards[] = { .svhs = -1, .gpiomask = 7, .muxsel = { 2, 3, -1 }, - .digital_mode = DIGITAL_MODE_CAMERA, + .digital_mode = DIGITAL_MODE_CAMERA, .audiomux = { 0, 0, 0, 0, 0 }, .no_msp34xx = 1, .pll = PLL_28, .tuner_type = TUNER_ALPS_TSBB5_PAL_I, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x18 ---------------------------------- */ @@ -610,6 +635,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .has_remote = 1, },{ .name = "Terratec TerraTV+ Version 1.0 (Bt848)/ Terra TValue Version 1.0/ Vobis TV-Boostar", @@ -622,6 +648,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0x20000, 0x30000, 0x10000, 0, 0x40000}, .needs_tvaudio = 0, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .audio_hook = terratv_audio, },{ .name = "Hauppauge WinCam newer (bt878)", @@ -634,6 +661,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 1, 2, 3, 4}, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Lifeview FlyVideo 98/ MAXI TV Video PCI2 LR50", .video_inputs = 4, @@ -645,6 +673,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800}, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_SECAM, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x1c ---------------------------------- */ @@ -658,37 +687,38 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0x20000, 0x30000, 0x10000, 0x00000, 0x40000}, .needs_tvaudio = 0, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .audio_hook = terratv_audio, /* GPIO wiring: - External 20 pin connector (for Active Radio Upgrade board) - gpio00: i2c-sda - gpio01: i2c-scl - gpio02: om5610-data - gpio03: om5610-clk - gpio04: om5610-wre - gpio05: om5610-stereo - gpio06: rds6588-davn - gpio07: Pin 7 n.c. - gpio08: nIOW - gpio09+10: nIOR, nSEL ?? (bt878) - gpio09: nIOR (bt848) - gpio10: nSEL (bt848) - Sound Routing: - gpio16: u2-A0 (1st 4052bt) - gpio17: u2-A1 - gpio18: u2-nEN - gpio19: u4-A0 (2nd 4052) - gpio20: u4-A1 - u4-nEN - GND - Btspy: - 00000 : Cdrom (internal audio input) + External 20 pin connector (for Active Radio Upgrade board) + gpio00: i2c-sda + gpio01: i2c-scl + gpio02: om5610-data + gpio03: om5610-clk + gpio04: om5610-wre + gpio05: om5610-stereo + gpio06: rds6588-davn + gpio07: Pin 7 n.c. + gpio08: nIOW + gpio09+10: nIOR, nSEL ?? (bt878) + gpio09: nIOR (bt848) + gpio10: nSEL (bt848) + Sound Routing: + gpio16: u2-A0 (1st 4052bt) + gpio17: u2-A1 + gpio18: u2-nEN + gpio19: u4-A0 (2nd 4052) + gpio20: u4-A1 + u4-nEN - GND + Btspy: + 00000 : Cdrom (internal audio input) 10000 : ext. Video audio input 20000 : TV Mono a0000 : TV Mono/2 - 1a0000 : TV Stereo + 1a0000 : TV Stereo 30000 : Radio 40000 : Mute - */ +*/ },{ /* Jannik Fritsch <jannik@techfak.uni-bielefeld.de> */ @@ -702,6 +732,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0 }, .needs_tvaudio = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .muxsel_hook = PXC200_muxsel, },{ @@ -710,11 +741,12 @@ struct tvcard bttv_tvcards[] = { .audio_inputs = 1, .tuner = 0, .svhs = 2, - .gpiomask = 0x1800, //0x8dfe00 + .gpiomask = 0x1800, /* 0x8dfe00 */ .muxsel = { 2, 3, 1, 1}, .audiomux = { 0, 0x0800, 0x1000, 0x1000, 0x1800, 0 }, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Formac iProTV, Formac ProTV I (bt848)", .video_inputs = 4, @@ -726,6 +758,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 1, 0, 0, 0, 0 }, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x20 ---------------------------------- */ @@ -739,6 +772,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0 }, .needs_tvaudio = 0, .tuner_type = 4, + .tuner_addr = ADDR_UNSET, },{ .name = "Terratec TerraTValue Version Bt878", .video_inputs = 3, @@ -751,31 +785,33 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, },{ .name = "Leadtek WinFast 2000/ WinFast 2000 XP", .video_inputs = 4, .audio_inputs = 1, .tuner = 0, .svhs = 2, - .muxsel = { 2, 3, 1, 1, 0}, // TV, CVid, SVid, CVid over SVid connector + .muxsel = { 2, 3, 1, 1, 0}, /* TV, CVid, SVid, CVid over SVid connector */ /* Alexander Varakin <avarakin@hotmail.com> [stereo version] */ .gpiomask = 0xb33000, .audiomux = { 0x122000,0x1000,0x0000,0x620000,0x800000 }, /* Audio Routing for "WinFast 2000 XP" (no tv stereo !) gpio23 -- hef4052:nEnable (0x800000) gpio12 -- hef4052:A1 - gpio13 -- hef4052:A0 - 0x0000: external audio - 0x1000: FM - 0x2000: TV - 0x3000: n.c. - Note: There exists another variant "Winfast 2000" with tv stereo !? - Note: eeprom only contains FF and pci subsystem id 107d:6606 - */ + gpio13 -- hef4052:A0 + 0x0000: external audio + 0x1000: FM + 0x2000: TV + 0x3000: n.c. + Note: There exists another variant "Winfast 2000" with tv stereo !? + Note: eeprom only contains FF and pci subsystem id 107d:6606 + */ .needs_tvaudio = 0, .pll = PLL_28, .has_radio = 1, - .tuner_type = 5, // default for now, gpio reads BFFF06 for Pal bg+dk + .tuner_type = 5, /* default for now, gpio reads BFFF06 for Pal bg+dk */ + .tuner_addr = ADDR_UNSET, .audio_hook = winfast2000_audio, .has_remote = 1, },{ @@ -789,6 +825,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800}, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x24 ---------------------------------- */ @@ -802,6 +839,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800, 0 }, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .has_radio = 1, },{ .name = "Prolink PixelView PlayTV pro", @@ -815,6 +853,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Askey CPH06X TView99", .video_inputs = 4, @@ -827,6 +866,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = 1, + .tuner_addr = ADDR_UNSET, .has_remote = 1, },{ .name = "Pinnacle PCTV Studio/Rave", @@ -840,6 +880,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 0, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x28 ---------------------------------- */ @@ -854,6 +895,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .needs_tvaudio = 1, .tuner_type = TUNER_PHILIPS_NTSC, + .tuner_addr = ADDR_UNSET, .pll = PLL_28, .has_radio = 1, },{ @@ -868,6 +910,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .has_radio = 1, .audio_hook = avermedia_tvphone_audio, },{ @@ -883,6 +926,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = 1, + .tuner_addr = ADDR_UNSET, },{ .name = "Little OnAir TV", .video_inputs = 3, @@ -894,6 +938,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = {0xff9ff6, 0xff9ff6, 0xff1ff7, 0, 0xff3ffc}, .no_msp34xx = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x2c ---------------------------------- */ @@ -908,6 +953,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_NONE, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "MATRIX-Vision MV-Delta 2", .video_inputs = 5, @@ -920,6 +966,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "Zoltrix Genie TV/FM", .video_inputs = 3, @@ -932,6 +979,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = 21, + .tuner_addr = ADDR_UNSET, },{ .name = "Terratec TV/Radio+", .video_inputs = 3, @@ -945,6 +993,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_35, .tuner_type = 1, + .tuner_addr = ADDR_UNSET, .has_radio = 1, },{ @@ -960,6 +1009,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "IODATA GV-BCTV3/PCI", .video_inputs = 3, @@ -972,6 +1022,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = TUNER_ALPS_TSHC6_NTSC, + .tuner_addr = ADDR_UNSET, .audio_hook = gvbctv3pci_audio, },{ .name = "Prolink PV-BT878P+4E / PixelView PlayTV PAK / Lenco MXTV-9578 CP", @@ -986,6 +1037,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL_I, + .tuner_addr = ADDR_UNSET, .has_remote = 1, /* GPIO wiring: (different from Rev.4C !) GPIO17: U4.A0 (first hef4052bt) @@ -994,8 +1046,8 @@ struct tvcard bttv_tvcards[] = { GPIO21: U4.nEN GPIO22: BT832 Reset Line GPIO23: A5,A0, U5,nEN - Note: At i2c=0x8a is a Bt832 chip, which changes to 0x88 after being reset via GPIO22 - */ + Note: At i2c=0x8a is a Bt832 chip, which changes to 0x88 after being reset via GPIO22 + */ },{ .name = "Eagle Wireless Capricorn2 (bt878A)", .video_inputs = 4, @@ -1007,6 +1059,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 1, 2, 3, 4}, .pll = PLL_28, .tuner_type = -1 /* TUNER_ALPS_TMDH2_NTSC */, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x34 ---------------------------------- */ @@ -1020,20 +1073,21 @@ struct tvcard bttv_tvcards[] = { .muxsel = { 2, 3, 1, 1}, .audiomux = { 1, 0xd0001, 0, 0, 10}, /* sound path (5 sources): - MUX1 (mask 0x03), Enable Pin 0x08 (0=enable, 1=disable) + MUX1 (mask 0x03), Enable Pin 0x08 (0=enable, 1=disable) 0= ext. Audio IN 1= from MUX2 2= Mono TV sound from Tuner 3= not connected - MUX2 (mask 0x30000): + MUX2 (mask 0x30000): 0,2,3= from MSP34xx 1= FM stereo Radio from Tuner */ .needs_tvaudio = 0, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* Claas Langbehn <claas@bigfoot.com>, - Sven Grothklags <sven@upb.de> */ + Sven Grothklags <sven@upb.de> */ .name = "Typhoon TView RDS + FM Stereo / KNC1 TV Station RDS", .video_inputs = 4, .audio_inputs = 3, @@ -1045,10 +1099,11 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .has_radio = 1, },{ /* Tim Röstermundt <rosterm@uni-muenster.de> - in de.comp.os.unix.linux.hardware: + in de.comp.os.unix.linux.hardware: options bttv card=0 pll=1 radio=1 gpiomask=0x18e0 audiomux=0x44c71f,0x44d71f,0,0x44d71f,0x44dfff options tuner type=5 */ @@ -1060,15 +1115,16 @@ struct tvcard bttv_tvcards[] = { .gpiomask = 0x18e0, .muxsel = { 2, 3, 1, 1}, .audiomux = { 0x0000,0x0800,0x1000,0x1000,0x18e0 }, - /* For cards with tda9820/tda9821: - 0x0000: Tuner normal stereo - 0x0080: Tuner A2 SAP (second audio program = Zweikanalton) - 0x0880: Tuner A2 stereo */ + /* For cards with tda9820/tda9821: + 0x0000: Tuner normal stereo + 0x0080: Tuner A2 SAP (second audio program = Zweikanalton) + 0x0880: Tuner A2 stereo */ .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* Miguel Angel Alvarez <maacruz@navegalia.com> - old Easy TV BT848 version (model CPH031) */ + old Easy TV BT848 version (model CPH031) */ .name = "Askey CPH031/ BESTBUY Easy TV", .video_inputs = 4, .audio_inputs = 1, @@ -1080,6 +1136,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 0, .pll = PLL_28, .tuner_type = TUNER_TEMIC_PAL, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x38 ---------------------------------- */ @@ -1094,10 +1151,11 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800, 0 }, .pll = PLL_28, .tuner_type = 5, + .tuner_addr = ADDR_UNSET, },{ /* This is the ultimate cheapo capture card - * just a BT848A on a small PCB! - * Steve Hosgood <steve@equiinet.com> */ + * just a BT848A on a small PCB! + * Steve Hosgood <steve@equiinet.com> */ .name = "GrandTec 'Grand Video Capture' (Bt848)", .video_inputs = 2, .audio_inputs = 0, @@ -1110,19 +1168,21 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_35, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ - /* Daniel Herrington <daniel.herrington@home.com> */ - .name = "Askey CPH060/ Phoebe TV Master Only (No FM)", - .video_inputs = 3, - .audio_inputs = 1, - .tuner = 0, - .svhs = 2, - .gpiomask = 0xe00, - .muxsel = { 2, 3, 1, 1}, - .audiomux = { 0x400, 0x400, 0x400, 0x400, 0x800, 0x400 }, - .needs_tvaudio = 1, - .pll = PLL_28, - .tuner_type = TUNER_TEMIC_4036FY5_NTSC, + /* Daniel Herrington <daniel.herrington@home.com> */ + .name = "Askey CPH060/ Phoebe TV Master Only (No FM)", + .video_inputs = 3, + .audio_inputs = 1, + .tuner = 0, + .svhs = 2, + .gpiomask = 0xe00, + .muxsel = { 2, 3, 1, 1}, + .audiomux = { 0x400, 0x400, 0x400, 0x400, 0x800, 0x400 }, + .needs_tvaudio = 1, + .pll = PLL_28, + .tuner_type = TUNER_TEMIC_4036FY5_NTSC, + .tuner_addr = ADDR_UNSET, },{ /* Matti Mottus <mottus@physic.ut.ee> */ .name = "Askey CPH03x TV Capturer", @@ -1130,11 +1190,12 @@ struct tvcard bttv_tvcards[] = { .audio_inputs = 1, .tuner = 0, .svhs = 2, - .gpiomask = 0x03000F, + .gpiomask = 0x03000F, .muxsel = { 2, 3, 1, 0}, - .audiomux = { 2,0,0,0,1 }, + .audiomux = { 2,0,0,0,1 }, .pll = PLL_28, .tuner_type = 0, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x3c ---------------------------------- */ @@ -1149,7 +1210,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 2, 0, 0, 1, 8}, .pll = PLL_35, .tuner_type = TUNER_TEMIC_PAL, - + .tuner_addr = ADDR_UNSET, },{ /* Adrian Cox <adrian@humboldt.co.uk */ .name = "AG Electronics GMV1", @@ -1164,10 +1225,11 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 0, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* Miguel Angel Alvarez <maacruz@navegalia.com> - new Easy TV BT878 version (model CPH061) - special thanks to Informatica Mieres for providing the card */ + new Easy TV BT878 version (model CPH061) + special thanks to Informatica Mieres for providing the card */ .name = "Askey CPH061/ BESTBUY Easy TV (bt878)", .video_inputs = 3, .audio_inputs = 2, @@ -1179,6 +1241,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 0, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, },{ /* Lukas Gebauer <geby@volny.cz> */ .name = "ATI TV-Wonder", @@ -1191,6 +1254,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0xbffe, 0, 0xbfff, 0, 0xbffe}, .pll = PLL_28, .tuner_type = TUNER_TEMIC_4006FN5_MULTI_PAL, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x40 ---------------------------------- */ @@ -1206,6 +1270,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = TUNER_TEMIC_4006FN5_MULTI_PAL, + .tuner_addr = ADDR_UNSET, },{ /* DeeJay <deejay@westel900.net (2000S) */ .name = "Lifeview FlyVideo 2000S LR90", @@ -1216,7 +1281,7 @@ struct tvcard bttv_tvcards[] = { .gpiomask = 0x18e0, .muxsel = { 2, 3, 0, 1}, /* Radio changed from 1e80 to 0x800 to make - FlyVideo2000S in .hu happy (gm)*/ + FlyVideo2000S in .hu happy (gm)*/ /* -dk-???: set mute=0x1800 for tda9874h daughterboard */ .audiomux = { 0x0000,0x0800,0x1000,0x1000,0x1800, 0x1080 }, .audio_hook = fv2000s_audio, @@ -1225,6 +1290,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = 5, + .tuner_addr = ADDR_UNSET, },{ .name = "Terratec TValueRadio", .video_inputs = 3, @@ -1237,6 +1303,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .has_radio = 1, },{ /* TANAKA Kei <peg00625@nifty.com> */ @@ -1251,25 +1318,27 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = TUNER_SHARP_2U5JF5540_NTSC, + .tuner_addr = ADDR_UNSET, .audio_hook = gvbctv3pci_audio, },{ /* ---- card 0x44 ---------------------------------- */ - .name = "3Dfx VoodooTV FM (Euro), VoodooTV 200 (USA)", - // try "insmod msp3400 simple=0" if you have - // sound problems with this card. - .video_inputs = 4, - .audio_inputs = 1, - .tuner = 0, - .svhs = -1, - .gpiomask = 0x4f8a00, - // 0x100000: 1=MSP enabled (0=disable again) - // 0x010000: Connected to "S0" on tda9880 (0=Pal/BG, 1=NTSC) - .audiomux = {0x947fff, 0x987fff,0x947fff,0x947fff, 0x947fff}, - // tvtuner, radio, external,internal, mute, stereo - /* tuner, Composit, SVid, Composit-on-Svid-adapter*/ - .muxsel = { 2, 3 ,0 ,1}, - .tuner_type = TUNER_MT2032, + .name = "3Dfx VoodooTV FM (Euro), VoodooTV 200 (USA)", + /* try "insmod msp3400 simple=0" if you have + * sound problems with this card. */ + .video_inputs = 4, + .audio_inputs = 1, + .tuner = 0, + .svhs = -1, + .gpiomask = 0x4f8a00, + /* 0x100000: 1=MSP enabled (0=disable again) + * 0x010000: Connected to "S0" on tda9880 (0=Pal/BG, 1=NTSC) */ + .audiomux = {0x947fff, 0x987fff,0x947fff,0x947fff, 0x947fff}, + /* tvtuner, radio, external,internal, mute, stereo + * tuner, Composit, SVid, Composit-on-Svid-adapter */ + .muxsel = { 2, 3 ,0 ,1}, + .tuner_type = TUNER_MT2032, + .tuner_addr = ADDR_UNSET, .pll = PLL_28, .has_radio = 1, },{ @@ -1279,22 +1348,24 @@ struct tvcard bttv_tvcards[] = { .audio_inputs = 0, .tuner = -1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .pll = PLL_28, .muxsel = { 2 }, .gpiomask = 0 },{ - /* Tomasz Pyra <hellfire@sedez.iq.pl> */ - .name = "Prolink Pixelview PV-BT878P+ (Rev.4C,8E)", - .video_inputs = 3, - .audio_inputs = 4, - .tuner = 0, - .svhs = 2, - .gpiomask = 15, - .muxsel = { 2, 3, 1, 1}, - .audiomux = { 0, 0, 11, 7, 13, 0}, // TV and Radio with same GPIO ! - .needs_tvaudio = 1, - .pll = PLL_28, - .tuner_type = 25, + /* Tomasz Pyra <hellfire@sedez.iq.pl> */ + .name = "Prolink Pixelview PV-BT878P+ (Rev.4C,8E)", + .video_inputs = 3, + .audio_inputs = 4, + .tuner = 0, + .svhs = 2, + .gpiomask = 15, + .muxsel = { 2, 3, 1, 1}, + .audiomux = { 0, 0, 11, 7, 13, 0}, /* TV and Radio with same GPIO ! */ + .needs_tvaudio = 1, + .pll = PLL_28, + .tuner_type = 25, + .tuner_addr = ADDR_UNSET, .has_remote = 1, /* GPIO wiring: GPIO0: U4.A0 (hef4052bt) @@ -1302,16 +1373,18 @@ struct tvcard bttv_tvcards[] = { GPIO2: U4.A1 (second hef4052bt) GPIO3: U4.nEN, U5.A0, A5.nEN GPIO8-15: vrd866b ? - */ + */ },{ .name = "Lifeview FlyVideo 98EZ (capture only) LR51", .video_inputs = 4, .audio_inputs = 0, .tuner = -1, .svhs = 2, - .muxsel = { 2, 3, 1, 1}, // AV1, AV2, SVHS, CVid adapter on SVHS + .muxsel = { 2, 3, 1, 1}, /* AV1, AV2, SVHS, CVid adapter on SVHS */ .pll = PLL_28, .no_msp34xx = 1, + .tuner_type = UNSET, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x48 ---------------------------------- */ @@ -1329,8 +1402,9 @@ struct tvcard bttv_tvcards[] = { .no_tda9875 = 1, .pll = PLL_28, .tuner_type = 5, - .audio_hook = pvbt878p9b_audio, // Note: not all cards have stereo - .has_radio = 1, // Note: not all cards have radio + .tuner_addr = ADDR_UNSET, + .audio_hook = pvbt878p9b_audio, /* Note: not all cards have stereo */ + .has_radio = 1, /* Note: not all cards have radio */ .has_remote = 1, /* GPIO wiring: GPIO0: A0 hef4052 @@ -1338,7 +1412,7 @@ struct tvcard bttv_tvcards[] = { GPIO3: nEN hef4052 GPIO8-15: vrd866b GPIO20,22,23: R30,R29,R28 - */ + */ },{ /* Clay Kunz <ckunz@mail.arc.nasa.gov> */ /* you must jumper JP5 for the card to work */ @@ -1352,6 +1426,7 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 0 }, .needs_tvaudio = 0, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* Miguel Freitas <miguel@cetuc.puc-rio.br> */ .name = "RemoteVision MX (RV605)", @@ -1362,71 +1437,78 @@ struct tvcard bttv_tvcards[] = { .gpiomask = 0x00, .gpiomask2 = 0x07ff, .muxsel = { 0x33, 0x13, 0x23, 0x43, 0xf3, 0x73, 0xe3, 0x03, - 0xd3, 0xb3, 0xc3, 0x63, 0x93, 0x53, 0x83, 0xa3 }, + 0xd3, 0xb3, 0xc3, 0x63, 0x93, 0x53, 0x83, 0xa3 }, .no_msp34xx = 1, .no_tda9875 = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .muxsel_hook = rv605_muxsel, },{ - .name = "Powercolor MTV878/ MTV878R/ MTV878F", - .video_inputs = 3, - .audio_inputs = 2, + .name = "Powercolor MTV878/ MTV878R/ MTV878F", + .video_inputs = 3, + .audio_inputs = 2, .tuner = 0, - .svhs = 2, - .gpiomask = 0x1C800F, // Bit0-2: Audio select, 8-12:remote control 14:remote valid 15:remote reset - .muxsel = { 2, 1, 1, }, - .audiomux = { 0, 1, 2, 2, 4 }, - .needs_tvaudio = 0, - .tuner_type = TUNER_PHILIPS_PAL, + .svhs = 2, + .gpiomask = 0x1C800F, /* Bit0-2: Audio select, 8-12:remote control 14:remote valid 15:remote reset */ + .muxsel = { 2, 1, 1, }, + .audiomux = { 0, 1, 2, 2, 4 }, + .needs_tvaudio = 0, + .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .pll = PLL_28, .has_radio = 1, },{ /* ---- card 0x4c ---------------------------------- */ - /* Masaki Suzuki <masaki@btree.org> */ - .name = "Canopus WinDVR PCI (COMPAQ Presario 3524JP, 5112JP)", - .video_inputs = 3, - .audio_inputs = 1, - .tuner = 0, - .svhs = 2, - .gpiomask = 0x140007, - .muxsel = { 2, 3, 1, 1 }, - .audiomux = { 0, 1, 2, 3, 4, 0 }, - .tuner_type = TUNER_PHILIPS_NTSC, - .audio_hook = windvr_audio, -},{ - .name = "GrandTec Multi Capture Card (Bt878)", - .video_inputs = 4, - .audio_inputs = 0, - .tuner = -1, - .svhs = -1, - .gpiomask = 0, - .muxsel = { 2, 3, 1, 0 }, - .audiomux = { 0 }, - .needs_tvaudio = 0, - .no_msp34xx = 1, - .pll = PLL_28, - .tuner_type = -1, -},{ - .name = "Jetway TV/Capture JW-TV878-FBK, Kworld KW-TV878RF", - .video_inputs = 4, - .audio_inputs = 3, - .tuner = 0, - .svhs = 2, - .gpiomask = 7, - .muxsel = { 2, 3, 1, 1 }, // Tuner, SVid, SVHS, SVid to SVHS connector - .audiomux = { 0 ,0 ,4, 4,4,4},// Yes, this tuner uses the same audio output for TV and FM radio! - // This card lacks external Audio In, so we mute it on Ext. & Int. - // The PCB can take a sbx1637/sbx1673, wiring unknown. - // This card lacks PCI subsystem ID, sigh. - // audiomux=1: lower volume, 2+3: mute - // btwincap uses 0x80000/0x80003 - .needs_tvaudio = 0, - .no_msp34xx = 1, - .pll = PLL_28, - .tuner_type = 5, // Samsung TCPA9095PC27A (BG+DK), philips compatible, w/FM, stereo and - // radio signal strength indicators work fine. - .has_radio = 1, + /* Masaki Suzuki <masaki@btree.org> */ + .name = "Canopus WinDVR PCI (COMPAQ Presario 3524JP, 5112JP)", + .video_inputs = 3, + .audio_inputs = 1, + .tuner = 0, + .svhs = 2, + .gpiomask = 0x140007, + .muxsel = { 2, 3, 1, 1 }, + .audiomux = { 0, 1, 2, 3, 4, 0 }, + .tuner_type = TUNER_PHILIPS_NTSC, + .tuner_addr = ADDR_UNSET, + .audio_hook = windvr_audio, +},{ + .name = "GrandTec Multi Capture Card (Bt878)", + .video_inputs = 4, + .audio_inputs = 0, + .tuner = -1, + .svhs = -1, + .gpiomask = 0, + .muxsel = { 2, 3, 1, 0 }, + .audiomux = { 0 }, + .needs_tvaudio = 0, + .no_msp34xx = 1, + .pll = PLL_28, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, +},{ + .name = "Jetway TV/Capture JW-TV878-FBK, Kworld KW-TV878RF", + .video_inputs = 4, + .audio_inputs = 3, + .tuner = 0, + .svhs = 2, + .gpiomask = 7, + .muxsel = { 2, 3, 1, 1 }, /* Tuner, SVid, SVHS, SVid to SVHS connector */ + .audiomux = { 0 ,0 ,4, 4,4,4},/* Yes, this tuner uses the same audio output for TV and FM radio! + * This card lacks external Audio In, so we mute it on Ext. & Int. + * The PCB can take a sbx1637/sbx1673, wiring unknown. + * This card lacks PCI subsystem ID, sigh. + * audiomux=1: lower volume, 2+3: mute + * btwincap uses 0x80000/0x80003 + */ + .needs_tvaudio = 0, + .no_msp34xx = 1, + .pll = PLL_28, + .tuner_type = 5, + .tuner_addr = ADDR_UNSET, + /* Samsung TCPA9095PC27A (BG+DK), philips compatible, w/FM, stereo and + radio signal strength indicators work fine. */ + .has_radio = 1, /* GPIO Info: GPIO0,1: HEF4052 A0,A1 GPIO2: HEF4052 nENABLE @@ -1437,25 +1519,27 @@ struct tvcard bttv_tvcards[] = { GPIO22,23: ?? ?? : mtu8b56ep microcontroller for IR (GPIO wiring unknown)*/ },{ - /* Arthur Tetzlaff-Deas, DSP Design Ltd <software@dspdesign.com> */ - .name = "DSP Design TCVIDEO", - .video_inputs = 4, - .svhs = -1, - .muxsel = { 2, 3, 1, 0}, - .pll = PLL_28, - .tuner_type = -1, + /* Arthur Tetzlaff-Deas, DSP Design Ltd <software@dspdesign.com> */ + .name = "DSP Design TCVIDEO", + .video_inputs = 4, + .svhs = -1, + .muxsel = { 2, 3, 1, 0}, + .pll = PLL_28, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ - /* ---- card 0x50 ---------------------------------- */ + /* ---- card 0x50 ---------------------------------- */ .name = "Hauppauge WinTV PVR", - .video_inputs = 4, - .audio_inputs = 1, - .tuner = 0, - .svhs = 2, - .muxsel = { 2, 0, 1, 1}, - .needs_tvaudio = 1, - .pll = PLL_28, - .tuner_type = -1, + .video_inputs = 4, + .audio_inputs = 1, + .tuner = 0, + .svhs = 2, + .muxsel = { 2, 0, 1, 1}, + .needs_tvaudio = 1, + .pll = PLL_28, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .gpiomask = 7, .audiomux = {7}, @@ -1471,6 +1555,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_NTSC_M, + .tuner_addr = ADDR_UNSET, .audio_hook = gvbctv5pci_audio, .has_radio = 1, },{ @@ -1482,9 +1567,10 @@ struct tvcard bttv_tvcards[] = { .muxsel = { 3, 2, 0, 1 }, .pll = PLL_28, .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ .name = "Osprey 100/150 (848)", /* 0x04-54C0-C1 & older boards */ .video_inputs = 3, @@ -1494,9 +1580,10 @@ struct tvcard bttv_tvcards[] = { .muxsel = { 2, 3, 1 }, .pll = PLL_28, .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ /* ---- card 0x54 ---------------------------------- */ @@ -1508,9 +1595,10 @@ struct tvcard bttv_tvcards[] = { .muxsel = { 3, 1 }, .pll = PLL_28, .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ .name = "Osprey 101/151", /* 0x1(4|5)-0004-C4 */ .video_inputs = 1, @@ -1520,9 +1608,10 @@ struct tvcard bttv_tvcards[] = { .muxsel = { 0 }, .pll = PLL_28, .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ .name = "Osprey 101/151 w/ svid", /* 0x(16|17|20)-00C4-C1 */ .video_inputs = 2, @@ -1532,9 +1621,10 @@ struct tvcard bttv_tvcards[] = { .muxsel = { 0, 1 }, .pll = PLL_28, .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ .name = "Osprey 200/201/250/251", /* 0x1(8|9|E|F)-0004-C4 */ .video_inputs = 1, @@ -1543,10 +1633,11 @@ struct tvcard bttv_tvcards[] = { .svhs = -1, .muxsel = { 0 }, .pll = PLL_28, - .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_type = UNSET, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ /* ---- card 0x58 ---------------------------------- */ @@ -1557,10 +1648,11 @@ struct tvcard bttv_tvcards[] = { .svhs = 1, .muxsel = { 0, 1 }, .pll = PLL_28, - .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_type = UNSET, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ .name = "Osprey 210/220", /* 0x1(A|B)-04C0-C1 */ .video_inputs = 2, @@ -1569,10 +1661,11 @@ struct tvcard bttv_tvcards[] = { .svhs = 1, .muxsel = { 2, 3 }, .pll = PLL_28, - .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_type = UNSET, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ .name = "Osprey 500", /* 500 */ .video_inputs = 2, @@ -1582,19 +1675,21 @@ struct tvcard bttv_tvcards[] = { .muxsel = { 2, 3 }, .pll = PLL_28, .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ - .name = "Osprey 540", /* 540 */ - .video_inputs = 4, - .audio_inputs = 1, - .tuner = -1, - .pll = PLL_28, - .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, + .name = "Osprey 540", /* 540 */ + .video_inputs = 4, + .audio_inputs = 1, + .tuner = -1, + .pll = PLL_28, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, },{ /* ---- card 0x5C ---------------------------------- */ @@ -1605,10 +1700,11 @@ struct tvcard bttv_tvcards[] = { .svhs = 1, .muxsel = { 2, 3 }, .pll = PLL_28, - .tuner_type = -1, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, /* must avoid, conflicts with the bt860 */ + .tuner_type = UNSET, + .tuner_addr = ADDR_UNSET, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, /* must avoid, conflicts with the bt860 */ },{ /* M G Berberich <berberic@forwiss.uni-passau.de> */ .name = "IDS Eagle", @@ -1616,6 +1712,7 @@ struct tvcard bttv_tvcards[] = { .audio_inputs = 0, .tuner = -1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .svhs = -1, .gpiomask = 0, .muxsel = { 0, 1, 2, 3 }, @@ -1630,6 +1727,7 @@ struct tvcard bttv_tvcards[] = { .svhs = 1, .tuner = -1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .no_msp34xx = 1, .no_tda9875 = 1, .no_tda7432 = 1, @@ -1641,38 +1739,40 @@ struct tvcard bttv_tvcards[] = { .no_gpioirq = 1, .has_dvb = 1, },{ - .name = "Formac ProTV II (bt878)", - .video_inputs = 4, - .audio_inputs = 1, - .tuner = 0, - .svhs = 3, - .gpiomask = 2, - // TV, Comp1, Composite over SVID con, SVID - .muxsel = { 2, 3, 1, 1}, - .audiomux = { 2, 2, 0, 0, 0 }, - .pll = PLL_28, + .name = "Formac ProTV II (bt878)", + .video_inputs = 4, + .audio_inputs = 1, + .tuner = 0, + .svhs = 3, + .gpiomask = 2, + /* TV, Comp1, Composite over SVID con, SVID */ + .muxsel = { 2, 3, 1, 1}, + .audiomux = { 2, 2, 0, 0, 0 }, + .pll = PLL_28, .has_radio = 1, - .tuner_type = TUNER_PHILIPS_PAL, - /* sound routing: - GPIO=0x00,0x01,0x03: mute (?) - 0x02: both TV and radio (tuner: FM1216/I) - The card has onboard audio connectors labeled "cdrom" and "board", - not soldered here, though unknown wiring. - Card lacks: external audio in, pci subsystem id. - */ + .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, +/* sound routing: + GPIO=0x00,0x01,0x03: mute (?) + 0x02: both TV and radio (tuner: FM1216/I) + The card has onboard audio connectors labeled "cdrom" and "board", + not soldered here, though unknown wiring. + Card lacks: external audio in, pci subsystem id. +*/ },{ /* ---- card 0x60 ---------------------------------- */ .name = "MachTV", - .video_inputs = 3, - .audio_inputs = 1, - .tuner = 0, - .svhs = -1, - .gpiomask = 7, - .muxsel = { 2, 3, 1, 1}, - .audiomux = { 0, 1, 2, 3, 4}, - .needs_tvaudio = 1, - .tuner_type = 5, + .video_inputs = 3, + .audio_inputs = 1, + .tuner = 0, + .svhs = -1, + .gpiomask = 7, + .muxsel = { 2, 3, 1, 1}, + .audiomux = { 0, 1, 2, 3, 4}, + .needs_tvaudio = 1, + .tuner_type = 5, + .tuner_addr = ADDR_UNSET, .pll = 1, },{ .name = "Euresys Picolo", @@ -1686,6 +1786,8 @@ struct tvcard bttv_tvcards[] = { .no_tda7432 = 1, .muxsel = { 2, 0, 1}, .pll = PLL_28, + .tuner_type = UNSET, + .tuner_addr = ADDR_UNSET, },{ /* Luc Van Hoeylandt <luc@e-magic.be> */ .name = "ProVideo PV150", /* 0x4f */ @@ -1699,7 +1801,8 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 0, .no_msp34xx = 1, .pll = PLL_28, - .tuner_type = -1, + .tuner_type = UNSET, + .tuner_addr = ADDR_UNSET, },{ /* Hiroshi Takekawa <sian@big.or.jp> */ /* This card lacks subsystem ID */ @@ -1716,78 +1819,85 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = 2, + .tuner_addr = ADDR_UNSET, .audio_hook = adtvk503_audio, },{ /* ---- card 0x64 ---------------------------------- */ - .name = "Hercules Smart TV Stereo", - .video_inputs = 4, - .audio_inputs = 1, - .tuner = 0, - .svhs = 2, - .gpiomask = 0x00, - .muxsel = { 2, 3, 1, 1 }, - .needs_tvaudio = 1, - .no_msp34xx = 1, - .pll = PLL_28, - .tuner_type = 5, + .name = "Hercules Smart TV Stereo", + .video_inputs = 4, + .audio_inputs = 1, + .tuner = 0, + .svhs = 2, + .gpiomask = 0x00, + .muxsel = { 2, 3, 1, 1 }, + .needs_tvaudio = 1, + .no_msp34xx = 1, + .pll = PLL_28, + .tuner_type = 5, + .tuner_addr = ADDR_UNSET, /* Notes: - - card lacks subsystem ID - - stereo variant w/ daughter board with tda9874a @0xb0 - - Audio Routing: + - card lacks subsystem ID + - stereo variant w/ daughter board with tda9874a @0xb0 + - Audio Routing: always from tda9874 independent of GPIO (?) external line in: unknown - - Other chips: em78p156elp @ 0x96 (probably IR remote control) - hef4053 (instead 4052) for unknown function + - Other chips: em78p156elp @ 0x96 (probably IR remote control) + hef4053 (instead 4052) for unknown function + */ +},{ + .name = "Pace TV & Radio Card", + .video_inputs = 4, + .audio_inputs = 1, + .tuner = 0, + .svhs = 2, + .muxsel = { 2, 3, 1, 1}, /* Tuner, CVid, SVid, CVid over SVid connector */ + .gpiomask = 0, + .no_tda9875 = 1, + .no_tda7432 = 1, + .tuner_type = 1, + .tuner_addr = ADDR_UNSET, + .has_radio = 1, + .pll = PLL_28, + /* Bt878, Bt832, FI1246 tuner; no pci subsystem id + only internal line out: (4pin header) RGGL + Radio must be decoded by msp3410d (not routed through)*/ + /* + .digital_mode = DIGITAL_MODE_CAMERA, todo! */ },{ - .name = "Pace TV & Radio Card", - .video_inputs = 4, - .audio_inputs = 1, - .tuner = 0, - .svhs = 2, - .muxsel = { 2, 3, 1, 1}, // Tuner, CVid, SVid, CVid over SVid connector - .gpiomask = 0, - .no_tda9875 = 1, - .no_tda7432 = 1, - .tuner_type = 1, - .has_radio = 1, - .pll = PLL_28, - /* Bt878, Bt832, FI1246 tuner; no pci subsystem id - only internal line out: (4pin header) RGGL - Radio must be decoded by msp3410d (not routed through)*/ - // .digital_mode = DIGITAL_MODE_CAMERA, // todo! -},{ - /* Chris Willing <chris@vislab.usyd.edu.au> */ - .name = "IVC-200", - .video_inputs = 1, - .audio_inputs = 0, - .tuner = -1, - .tuner_type = -1, - .svhs = -1, - .gpiomask = 0xdf, - .muxsel = { 2 }, - .pll = PLL_28, + /* Chris Willing <chris@vislab.usyd.edu.au> */ + .name = "IVC-200", + .video_inputs = 1, + .audio_inputs = 0, + .tuner = -1, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, + .svhs = -1, + .gpiomask = 0xdf, + .muxsel = { 2 }, + .pll = PLL_28, },{ .name = "Grand X-Guard / Trust 814PCI", .video_inputs = 16, - .audio_inputs = 0, - .tuner = -1, - .svhs = -1, + .audio_inputs = 0, + .tuner = -1, + .svhs = -1, .tuner_type = 4, - .gpiomask2 = 0xff, + .tuner_addr = ADDR_UNSET, + .gpiomask2 = 0xff, .muxsel = { 2,2,2,2, 3,3,3,3, 1,1,1,1, 0,0,0,0 }, .muxsel_hook = xguard_muxsel, .no_msp34xx = 1, .no_tda9875 = 1, - .no_tda7432 = 1, + .no_tda7432 = 1, .pll = PLL_28, },{ /* ---- card 0x68 ---------------------------------- */ .name = "Nebula Electronics DigiTV", .video_inputs = 1, - .tuner = -1, + .tuner = -1, .svhs = -1, .muxsel = { 2, 3, 1, 0}, .no_msp34xx = 1, @@ -1795,22 +1905,24 @@ struct tvcard bttv_tvcards[] = { .no_tda7432 = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .has_dvb = 1, .no_gpioirq = 1, },{ /* Jorge Boncompte - DTI2 <jorge@dti2.net> */ .name = "ProVideo PV143", - .video_inputs = 4, - .audio_inputs = 0, - .tuner = -1, - .svhs = -1, - .gpiomask = 0, - .muxsel = { 2, 3, 1, 0 }, - .audiomux = { 0 }, - .needs_tvaudio = 0, - .no_msp34xx = 1, - .pll = PLL_28, - .tuner_type = -1, + .video_inputs = 4, + .audio_inputs = 0, + .tuner = -1, + .svhs = -1, + .gpiomask = 0, + .muxsel = { 2, 3, 1, 0 }, + .audiomux = { 0 }, + .needs_tvaudio = 0, + .no_msp34xx = 1, + .pll = PLL_28, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* M.Klahr@phytec.de */ .name = "PHYTEC VD-009-X1 MiniDIN (bt878)", @@ -1824,6 +1936,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "PHYTEC VD-009-X1 Combi (bt878)", .video_inputs = 4, @@ -1836,6 +1949,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* ---- card 0x6c ---------------------------------- */ @@ -1846,13 +1960,14 @@ struct tvcard bttv_tvcards[] = { .svhs = 9, .gpiomask = 0x00, .gpiomask2 = 0x03, /* gpiomask2 defines the bits used to switch audio - via the upper nibble of muxsel. here: used for - xternal video-mux */ + via the upper nibble of muxsel. here: used for + xternal video-mux */ .muxsel = { 0x02, 0x12, 0x22, 0x32, 0x03, 0x13, 0x23, 0x33, 0x01, 0x00 }, .audiomux = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */ .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ .name = "PHYTEC VD-009 Combi (bt878)", .video_inputs = 10, @@ -1861,23 +1976,25 @@ struct tvcard bttv_tvcards[] = { .svhs = 9, .gpiomask = 0x00, .gpiomask2 = 0x03, /* gpiomask2 defines the bits used to switch audio - via the upper nibble of muxsel. here: used for - xternal video-mux */ + via the upper nibble of muxsel. here: used for + xternal video-mux */ .muxsel = { 0x02, 0x12, 0x22, 0x32, 0x03, 0x13, 0x23, 0x33, 0x01, 0x01 }, .audiomux = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */ .needs_tvaudio = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ - .name = "IVC-100", - .video_inputs = 4, - .audio_inputs = 0, - .tuner = -1, - .tuner_type = -1, - .svhs = -1, - .gpiomask = 0xdf, - .muxsel = { 2, 3, 1, 0 }, - .pll = PLL_28, + .name = "IVC-100", + .video_inputs = 4, + .audio_inputs = 0, + .tuner = -1, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, + .svhs = -1, + .gpiomask = 0xdf, + .muxsel = { 2, 3, 1, 0 }, + .pll = PLL_28, },{ /* IVC-120G - Alan Garfield <alan@fromorbit.com> */ .name = "IVC-120G", @@ -1885,6 +2002,7 @@ struct tvcard bttv_tvcards[] = { .audio_inputs = 0, /* card has no audio */ .tuner = -1, /* card has no tuner */ .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .svhs = -1, /* card has no svhs */ .needs_tvaudio = 0, .no_msp34xx = 1, @@ -1892,7 +2010,7 @@ struct tvcard bttv_tvcards[] = { .no_tda7432 = 1, .gpiomask = 0x00, .muxsel = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10 }, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10 }, .muxsel_hook = ivc120_muxsel, .pll = PLL_28, },{ @@ -1905,6 +2023,7 @@ struct tvcard bttv_tvcards[] = { .svhs = 2, .muxsel = { 2, 3, 1, 0}, .tuner_type = TUNER_PHILIPS_ATSC, + .tuner_addr = ADDR_UNSET, .has_dvb = 1, },{ .name = "Twinhan DST + clones", @@ -1912,19 +2031,21 @@ struct tvcard bttv_tvcards[] = { .no_tda9875 = 1, .no_tda7432 = 1, .tuner_type = TUNER_ABSENT, + .tuner_addr = ADDR_UNSET, .no_video = 1, .has_dvb = 1, },{ - .name = "Winfast VC100", + .name = "Winfast VC100", .video_inputs = 3, .audio_inputs = 0, .svhs = 1, - .tuner = -1, // no tuner - .muxsel = { 3, 1, 1, 3}, // Vid In, SVid In, Vid over SVid in connector - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, - .tuner_type = TUNER_ABSENT, + .tuner = -1, + .muxsel = { 3, 1, 1, 3}, /* Vid In, SVid In, Vid over SVid in connector */ + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, + .tuner_type = TUNER_ABSENT, + .tuner_addr = ADDR_UNSET, .pll = PLL_28, },{ .name = "Teppro TEV-560/InterVision IV-560", @@ -1937,44 +2058,49 @@ struct tvcard bttv_tvcards[] = { .audiomux = { 1, 1, 1, 1, 0}, .needs_tvaudio = 1, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .pll = PLL_35, },{ /* ---- card 0x74 ---------------------------------- */ - .name = "SIMUS GVC1100", - .video_inputs = 4, - .audio_inputs = 0, - .tuner = -1, - .svhs = -1, - .tuner_type = -1, - .pll = PLL_28, - .muxsel = { 2, 2, 2, 2}, - .gpiomask = 0x3F, + .name = "SIMUS GVC1100", + .video_inputs = 4, + .audio_inputs = 0, + .tuner = -1, + .svhs = -1, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, + .pll = PLL_28, + .muxsel = { 2, 2, 2, 2}, + .gpiomask = 0x3F, .muxsel_hook = gvc1100_muxsel, },{ - /* Carlos Silva r3pek@r3pek.homelinux.org || card 0x75 */ - .name = "NGS NGSTV+", - .video_inputs = 3, - .tuner = 0, - .svhs = 2, - .gpiomask = 0x008007, - .muxsel = {2, 3, 0, 0}, - .audiomux = {0, 0, 0, 0, 0x000003, 0}, - .pll = PLL_28, - .tuner_type = TUNER_PHILIPS_PAL, - .has_remote = 1, -},{ - /* http://linuxmedialabs.com */ - .name = "LMLBT4", - .video_inputs = 4, /* IN1,IN2,IN3,IN4 */ - .audio_inputs = 0, - .tuner = -1, - .svhs = -1, - .muxsel = { 2, 3, 1, 0 }, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, - .needs_tvaudio = 0, + /* Carlos Silva r3pek@r3pek.homelinux.org || card 0x75 */ + .name = "NGS NGSTV+", + .video_inputs = 3, + .tuner = 0, + .svhs = 2, + .gpiomask = 0x008007, + .muxsel = {2, 3, 0, 0}, + .audiomux = {0, 0, 0, 0, 0x000003, 0}, + .pll = PLL_28, + .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, + .has_remote = 1, +},{ + /* http://linuxmedialabs.com */ + .name = "LMLBT4", + .video_inputs = 4, /* IN1,IN2,IN3,IN4 */ + .audio_inputs = 0, + .tuner = -1, + .svhs = -1, + .muxsel = { 2, 3, 1, 0 }, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, + .needs_tvaudio = 0, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* Helmroos Harri <harri.helmroos@pp.inet.fi> */ .name = "Tekram M205 PRO", @@ -1982,6 +2108,7 @@ struct tvcard bttv_tvcards[] = { .audio_inputs = 1, .tuner = 0, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .svhs = 2, .needs_tvaudio = 0, .gpiomask = 0x68, @@ -2004,6 +2131,7 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 0, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .has_remote = 1, .has_radio = 1, },{ @@ -2026,6 +2154,8 @@ struct tvcard bttv_tvcards[] = { .pll = PLL_28, .needs_tvaudio = 0, .muxsel_hook = picolo_tetra_muxsel,/*Required as it doesn't follow the classic input selection policy*/ + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* Spirit TV Tuner from http://spiritmodems.com.au */ /* Stafford Goodsell <surge@goliath.homeunix.org> */ @@ -2038,23 +2168,25 @@ struct tvcard bttv_tvcards[] = { .muxsel = { 2, 1, 1 }, .audiomux = { 0x02, 0x00, 0x00, 0x00, 0x00}, .tuner_type = TUNER_TEMIC_PAL, + .tuner_addr = ADDR_UNSET, .no_msp34xx = 1, .no_tda9875 = 1, },{ /* Wolfram Joost <wojo@frokaschwei.de> */ - .name = "AVerMedia AVerTV DVB-T 771", - .video_inputs = 2, - .svhs = 1, - .tuner = -1, - .tuner_type = TUNER_ABSENT, - .muxsel = { 3 , 3 }, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, - .pll = PLL_28, - .has_dvb = 1, - .no_gpioirq = 1, - .has_remote = 1, + .name = "AVerMedia AVerTV DVB-T 771", + .video_inputs = 2, + .svhs = 1, + .tuner = -1, + .tuner_type = TUNER_ABSENT, + .tuner_addr = ADDR_UNSET, + .muxsel = { 3 , 3 }, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, + .pll = PLL_28, + .has_dvb = 1, + .no_gpioirq = 1, + .has_remote = 1, },{ /* ---- card 0x7c ---------------------------------- */ /* Matt Jesson <dvb@jesson.eclipse.co.uk> */ @@ -2069,6 +2201,7 @@ struct tvcard bttv_tvcards[] = { .no_tda7432 = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .has_dvb = 1, .no_gpioirq = 1, .has_remote = 1, @@ -2081,12 +2214,13 @@ struct tvcard bttv_tvcards[] = { .svhs = -1, .gpiomask = 0x0, .muxsel = { 2, 2, 2, 2, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, 3, 3 }, + 3, 3, 3, 3, 3, 3, 3, 3 }, .muxsel_hook = sigmaSQ_muxsel, .audiomux = { 0 }, .no_msp34xx = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* andre.schwarz@matrix-vision.de */ .name = "MATRIX Vision Sigma-SLC", @@ -2101,6 +2235,7 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* BTTV_APAC_VIEWCOMP */ /* Attila Kondoros <attila.kondoros@chello.hu> */ @@ -2116,13 +2251,14 @@ struct tvcard bttv_tvcards[] = { .needs_tvaudio = 0, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_PAL, + .tuner_addr = ADDR_UNSET, .has_remote = 1, /* miniremote works, see ir-kbd-gpio.c */ .has_radio = 1, /* not every card has radio */ },{ /* ---- card 0x80 ---------------------------------- */ /* Chris Pascoe <c.pascoe@itee.uq.edu.au> */ - .name = "DVICO FusionHDTV DVB-T Lite", + .name = "DViCO FusionHDTV DVB-T Lite", .tuner = -1, .no_msp34xx = 1, .no_tda9875 = 1, @@ -2131,6 +2267,7 @@ struct tvcard bttv_tvcards[] = { .no_video = 1, .has_dvb = 1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, },{ /* Steven <photon38@pchome.com.tw> */ .name = "V-Gear MyVCD", @@ -2144,62 +2281,65 @@ struct tvcard bttv_tvcards[] = { .no_msp34xx = 1, .pll = PLL_28, .tuner_type = TUNER_PHILIPS_NTSC_M, + .tuner_addr = ADDR_UNSET, .has_radio = 0, - // .has_remote = 1, },{ /* Rick C <cryptdragoon@gmail.com> */ - .name = "Super TV Tuner", - .video_inputs = 4, - .audio_inputs = 1, - .tuner = 0, - .svhs = 2, - .muxsel = { 2, 3, 1, 0}, - .tuner_type = TUNER_PHILIPS_NTSC, - .gpiomask = 0x008007, - .audiomux = { 0, 0x000001,0,0, 0}, - .needs_tvaudio = 1, - .has_radio = 1, -},{ - /* Chris Fanning <video4linux@haydon.net> */ - .name = "Tibet Systems 'Progress DVR' CS16", - .video_inputs = 16, - .audio_inputs = 0, - .tuner = -1, - .svhs = -1, - .muxsel = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, - .pll = PLL_28, - .no_msp34xx = 1, - .no_tda9875 = 1, - .no_tda7432 = 1, - .tuner_type = -1, - .muxsel_hook = tibetCS16_muxsel, + .name = "Super TV Tuner", + .video_inputs = 4, + .audio_inputs = 1, + .tuner = 0, + .svhs = 2, + .muxsel = { 2, 3, 1, 0}, + .tuner_type = TUNER_PHILIPS_NTSC, + .tuner_addr = ADDR_UNSET, + .gpiomask = 0x008007, + .audiomux = { 0, 0x000001,0,0, 0}, + .needs_tvaudio = 1, + .has_radio = 1, +},{ + /* Chris Fanning <video4linux@haydon.net> */ + .name = "Tibet Systems 'Progress DVR' CS16", + .video_inputs = 16, + .audio_inputs = 0, + .tuner = -1, + .svhs = -1, + .muxsel = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, + .pll = PLL_28, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, + .muxsel_hook = tibetCS16_muxsel, }, { /* Bill Brack <wbrack@mmm.com.hk> */ /* - * Note that, because of the card's wiring, the "master" - * BT878A chip (i.e. the one which controls the analog switch - * and must use this card type) is the 2nd one detected. The - * other 3 chips should use card type 0x85, whose description - * follows this one. There is a EEPROM on the card (which is - * connected to the I2C of one of those other chips), but is - * not currently handled. There is also a facility for a - * "monitor", which is also not currently implemented. - */ - .name = "Kodicom 4400R (master)", + * Note that, because of the card's wiring, the "master" + * BT878A chip (i.e. the one which controls the analog switch + * and must use this card type) is the 2nd one detected. The + * other 3 chips should use card type 0x85, whose description + * follows this one. There is a EEPROM on the card (which is + * connected to the I2C of one of those other chips), but is + * not currently handled. There is also a facility for a + * "monitor", which is also not currently implemented. + */ + .name = "Kodicom 4400R (master)", .video_inputs = 16, .audio_inputs = 0, .tuner = -1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .svhs = -1, /* GPIO bits 0-9 used for analog switch: - * 00 - 03: camera selector - * 04 - 06: channel (controller) selector - * 07: data (1->on, 0->off) - * 08: strobe - * 09: reset - * bit 16 is input from sync separator for the channel - */ + * 00 - 03: camera selector + * 04 - 06: channel (controller) selector + * 07: data (1->on, 0->off) + * 08: strobe + * 09: reset + * bit 16 is input from sync separator for the channel + */ .gpiomask = 0x0003ff, .no_gpioirq = 1, .muxsel = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, @@ -2212,15 +2352,16 @@ struct tvcard bttv_tvcards[] = { { /* Bill Brack <wbrack@mmm.com.hk> */ /* Note that, for reasons unknown, the "master" BT878A chip (i.e. the - * one which controls the analog switch, and must use the card type) - * is the 2nd one detected. The other 3 chips should use this card - * type - */ + * one which controls the analog switch, and must use the card type) + * is the 2nd one detected. The other 3 chips should use this card + * type + */ .name = "Kodicom 4400R (slave)", .video_inputs = 16, .audio_inputs = 0, .tuner = -1, .tuner_type = -1, + .tuner_addr = ADDR_UNSET, .svhs = -1, .gpiomask = 0x010000, .no_gpioirq = 1, @@ -2232,18 +2373,51 @@ struct tvcard bttv_tvcards[] = { .muxsel_hook = kodicom4400r_muxsel, }, { - /* ---- card 0x85---------------------------------- */ - /* Michael Henson <mhenson@clarityvi.com> */ - /* Adlink RTV24 with special unlock codes */ - .name = "Adlink RTV24", - .video_inputs = 4, - .audio_inputs = 1, - .tuner = 0, - .svhs = 2, - .muxsel = { 2, 3, 1, 0}, - .tuner_type = -1, - .pll = PLL_28, - + /* ---- card 0x86---------------------------------- */ + /* Michael Henson <mhenson@clarityvi.com> */ + /* Adlink RTV24 with special unlock codes */ + .name = "Adlink RTV24", + .video_inputs = 4, + .audio_inputs = 1, + .tuner = 0, + .svhs = 2, + .muxsel = { 2, 3, 1, 0}, + .tuner_type = -1, + .tuner_addr = ADDR_UNSET, + .pll = PLL_28, +}, +{ + /* ---- card 0x87---------------------------------- */ + /* Michael Krufky <mkrufky@m1k.net> */ + .name = "DViCO FusionHDTV 5 Lite", + .tuner = 0, + .tuner_type = TUNER_LG_TDVS_H062F, + .tuner_addr = ADDR_UNSET, + .video_inputs = 2, + .audio_inputs = 1, + .svhs = 2, + .muxsel = { 2, 3 }, + .gpiomask = 0x00e00007, + .audiomux = { 0x00400005, 0, 0, 0, 0, 0 }, + .no_msp34xx = 1, + .no_tda9875 = 1, + .no_tda7432 = 1, +},{ + /* ---- card 0x88---------------------------------- */ + /* Mauro Carvalho Chehab <mchehab@brturbo.com.br> */ + .name = "Acorp Y878F", + .video_inputs = 3, + .audio_inputs = 1, + .tuner = 0, + .svhs = 2, + .gpiomask = 0x01fe00, + .muxsel = { 2, 3, 1, 1}, + .audiomux = { 0x001e00, 0, 0x018000, 0x014000, 0x002000, 0 }, + .needs_tvaudio = 1, + .pll = PLL_28, + .tuner_type = TUNER_YMEC_TVF66T5_B_DFF, + .tuner_addr = 0xc1 >>1, + .has_radio = 1, }}; static const unsigned int bttv_num_tvcards = ARRAY_SIZE(bttv_tvcards); @@ -2355,32 +2529,32 @@ static void flyvideo_gpio(struct bttv *btv) int tuner=-1,ttype; gpio_inout(0xffffff, 0); - udelay(8); // without this we would see the 0x1800 mask + udelay(8); /* without this we would see the 0x1800 mask */ gpio = gpio_read(); /* FIXME: must restore OUR_EN ??? */ - // all cards provide GPIO info, some have an additional eeprom - // LR50: GPIO coding can be found lower right CP1 .. CP9 - // CP9=GPIO23 .. CP1=GPIO15; when OPEN, the corresponding GPIO reads 1. - // GPIO14-12: n.c. - // LR90: GP9=GPIO23 .. GP1=GPIO15 (right above the bt878) - - // lowest 3 bytes are remote control codes (no handshake needed) - // xxxFFF: No remote control chip soldered - // xxxF00(LR26/LR50), xxxFE0(LR90): Remote control chip (LVA001 or CF45) soldered - // Note: Some bits are Audio_Mask ! + /* all cards provide GPIO info, some have an additional eeprom + * LR50: GPIO coding can be found lower right CP1 .. CP9 + * CP9=GPIO23 .. CP1=GPIO15; when OPEN, the corresponding GPIO reads 1. + * GPIO14-12: n.c. + * LR90: GP9=GPIO23 .. GP1=GPIO15 (right above the bt878) + * lowest 3 bytes are remote control codes (no handshake needed) + * xxxFFF: No remote control chip soldered + * xxxF00(LR26/LR50), xxxFE0(LR90): Remote control chip (LVA001 or CF45) soldered + * Note: Some bits are Audio_Mask ! + */ ttype=(gpio&0x0f0000)>>16; switch(ttype) { - case 0x0: tuner=2; // NTSC, e.g. TPI8NSR11P + case 0x0: tuner=2; /* NTSC, e.g. TPI8NSR11P */ break; - case 0x2: tuner=39;// LG NTSC (newer TAPC series) TAPC-H701P + case 0x2: tuner=39;/* LG NTSC (newer TAPC series) TAPC-H701P */ break; - case 0x4: tuner=5; // Philips PAL TPI8PSB02P, TPI8PSB12P, TPI8PSB12D or FI1216, FM1216 + case 0x4: tuner=5; /* Philips PAL TPI8PSB02P, TPI8PSB12P, TPI8PSB12D or FI1216, FM1216 */ break; - case 0x6: tuner=37; // LG PAL (newer TAPC series) TAPC-G702P + case 0x6: tuner=37;/* LG PAL (newer TAPC series) TAPC-G702P */ break; - case 0xC: tuner=3; // Philips SECAM(+PAL) FQ1216ME or FI1216MF + case 0xC: tuner=3; /* Philips SECAM(+PAL) FQ1216ME or FI1216MF */ break; default: printk(KERN_INFO "bttv%d: FlyVideo_gpio: unknown tuner type.\n", btv->c.nr); @@ -2388,15 +2562,16 @@ static void flyvideo_gpio(struct bttv *btv) has_remote = gpio & 0x800000; has_radio = gpio & 0x400000; - // unknown 0x200000; - // unknown2 0x100000; - is_capture_only = !(gpio & 0x008000); //GPIO15 + /* unknown 0x200000; + * unknown2 0x100000; */ + is_capture_only = !(gpio & 0x008000); /* GPIO15 */ has_tda9820_tda9821 = !(gpio & 0x004000); - is_lr90 = !(gpio & 0x002000); // else LR26/LR50 (LR38/LR51 f. capture only) - // gpio & 0x001000 // output bit for audio routing + is_lr90 = !(gpio & 0x002000); /* else LR26/LR50 (LR38/LR51 f. capture only) */ + /* + * gpio & 0x001000 output bit for audio routing */ if(is_capture_only) - tuner=4; // No tuner present + tuner=4; /* No tuner present */ printk(KERN_INFO "bttv%d: FlyVideo Radio=%s RemoteControl=%s Tuner=%d gpio=0x%06x\n", btv->c.nr, has_radio? "yes":"no ", has_remote? "yes":"no ", tuner, gpio); @@ -2404,15 +2579,15 @@ static void flyvideo_gpio(struct bttv *btv) btv->c.nr, is_lr90?"yes":"no ", has_tda9820_tda9821?"yes":"no ", is_capture_only?"yes":"no "); - if(tuner!= -1) // only set if known tuner autodetected, else let insmod option through + if(tuner!= -1) /* only set if known tuner autodetected, else let insmod option through */ btv->tuner_type = tuner; btv->has_radio = has_radio; - // LR90 Audio Routing is done by 2 hef4052, so Audio_Mask has 4 bits: 0x001c80 - // LR26/LR50 only has 1 hef4052, Audio_Mask 0x000c00 - // Audio options: from tuner, from tda9821/tda9821(mono,stereo,sap), from tda9874, ext., mute + /* LR90 Audio Routing is done by 2 hef4052, so Audio_Mask has 4 bits: 0x001c80 + * LR26/LR50 only has 1 hef4052, Audio_Mask 0x000c00 + * Audio options: from tuner, from tda9821/tda9821(mono,stereo,sap), from tda9874, ext., mute */ if(has_tda9820_tda9821) btv->audio_hook = lt9415_audio; - //todo: if(has_tda9874) btv->audio_hook = fv2000s_audio; + /* todo: if(has_tda9874) btv->audio_hook = fv2000s_audio; */ } static int miro_tunermap[] = { 0,6,2,3, 4,5,6,0, 3,0,4,5, 5,2,16,1, @@ -2633,6 +2808,8 @@ void __devinit bttv_init_card1(struct bttv *btv) void __devinit bttv_init_card2(struct bttv *btv) { int tda9887; + int addr=ADDR_UNSET; + btv->tuner_type = -1; if (BTTV_UNKNOWN == btv->c.type) { @@ -2773,9 +2950,12 @@ void __devinit bttv_init_card2(struct bttv *btv) btv->pll.pll_current = -1; /* tuner configuration (from card list / autodetect / insmod option) */ - if (UNSET != bttv_tvcards[btv->c.type].tuner_type) + if (ADDR_UNSET != bttv_tvcards[btv->c.type].tuner_addr) + addr = bttv_tvcards[btv->c.type].tuner_addr; + + if (UNSET != bttv_tvcards[btv->c.type].tuner_type) if(UNSET == btv->tuner_type) - btv->tuner_type = bttv_tvcards[btv->c.type].tuner_type; + btv->tuner_type = bttv_tvcards[btv->c.type].tuner_type; if (UNSET != tuner[btv->c.nr]) btv->tuner_type = tuner[btv->c.nr]; printk("bttv%d: using tuner=%d\n",btv->c.nr,btv->tuner_type); @@ -2787,7 +2967,7 @@ void __devinit bttv_init_card2(struct bttv *btv) tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV; tun_setup.type = btv->tuner_type; - tun_setup.addr = ADDR_UNSET; + tun_setup.addr = addr; bttv_call_i2c_clients(btv, TUNER_SET_TYPE_ADDR, &tun_setup); } @@ -2880,7 +3060,7 @@ static void __devinit hauppauge_eeprom(struct bttv *btv) { struct tveeprom tv; - tveeprom_hauppauge_analog(&tv, eeprom_data); + tveeprom_hauppauge_analog(&btv->i2c_client, &tv, eeprom_data); btv->tuner_type = tv.tuner_type; btv->has_radio = tv.has_radio; } @@ -2902,7 +3082,7 @@ static int terratec_active_radio_upgrade(struct bttv *btv) btv->mbox_csel = 1 << 10; freq=88000/62.5; - tea5757_write(btv, 5 * freq + 0x358); // write 0x1ed8 + tea5757_write(btv, 5 * freq + 0x358); /* write 0x1ed8 */ if (0x1ed8 == tea5757_read(btv)) { printk("bttv%d: Terratec Active Radio Upgrade found.\n", btv->c.nr); @@ -3073,7 +3253,7 @@ static void __devinit osprey_eeprom(struct bttv *btv) case 0x0060: case 0x0070: btv->c.type = BTTV_OSPREY2x0; - //enable output on select control lines + /* enable output on select control lines */ gpio_inout(0xffffff,0x000303); break; default: @@ -3105,7 +3285,7 @@ static int tuner_1_table[] = { TUNER_TEMIC_NTSC, TUNER_TEMIC_PAL, TUNER_TEMIC_PAL, TUNER_TEMIC_PAL, TUNER_TEMIC_PAL, TUNER_TEMIC_PAL, - TUNER_TEMIC_4012FY5, TUNER_TEMIC_4012FY5, //TUNER_TEMIC_SECAM + TUNER_TEMIC_4012FY5, TUNER_TEMIC_4012FY5, /* TUNER_TEMIC_SECAM */ TUNER_TEMIC_4012FY5, TUNER_TEMIC_PAL}; static void __devinit avermedia_eeprom(struct bttv *btv) @@ -3126,7 +3306,7 @@ static void __devinit avermedia_eeprom(struct bttv *btv) if (tuner_make == 4) if(tuner_format == 0x09) - tuner = TUNER_LG_NTSC_NEW_TAPC; // TAPC-G702P + tuner = TUNER_LG_NTSC_NEW_TAPC; /* TAPC-G702P */ printk(KERN_INFO "bttv%d: Avermedia eeprom[0x%02x%02x]: tuner=", btv->c.nr,eeprom_data[0x41],eeprom_data[0x42]); @@ -3143,7 +3323,7 @@ static void __devinit avermedia_eeprom(struct bttv *btv) /* used on Voodoo TV/FM (Voodoo 200), S0 wired to 0x10000 */ void bttv_tda9880_setnorm(struct bttv *btv, int norm) { - // fix up our card entry + /* fix up our card entry */ if(norm==VIDEO_MODE_NTSC) { bttv_tvcards[BTTV_VOODOOTV_FM].audiomux[0]=0x957fff; bttv_tvcards[BTTV_VOODOOTV_FM].audiomux[4]=0x957fff; @@ -3154,7 +3334,7 @@ void bttv_tda9880_setnorm(struct bttv *btv, int norm) bttv_tvcards[BTTV_VOODOOTV_FM].audiomux[4]=0x947fff; dprintk("bttv_tda9880_setnorm to PAL\n"); } - // set GPIO according + /* set GPIO according */ gpio_bits(bttv_tvcards[btv->c.type].gpiomask, bttv_tvcards[btv->c.type].audiomux[btv->audio]); } @@ -3447,7 +3627,7 @@ static int tea5757_read(struct bttv *btv) udelay(10); timeout= jiffies + HZ; - // wait for DATA line to go low; error if it doesn't + /* wait for DATA line to go low; error if it doesn't */ while (bus_in(btv,btv->mbox_data) && time_before(jiffies, timeout)) schedule(); if (bus_in(btv,btv->mbox_data)) { @@ -3574,8 +3754,8 @@ gvbctv3pci_audio(struct bttv *btv, struct video_audio *v, int set) con = 0x300; if (v->mode & VIDEO_SOUND_STEREO) con = 0x200; -// if (v->mode & VIDEO_SOUND_MONO) -// con = 0x100; +/* if (v->mode & VIDEO_SOUND_MONO) + * con = 0x100; */ gpio_bits(0x300, con); } else { v->mode = VIDEO_SOUND_STEREO | @@ -3718,7 +3898,7 @@ lt9415_audio(struct bttv *btv, struct video_audio *v, int set) } } -// TDA9821 on TerraTV+ Bt848, Bt878 +/* TDA9821 on TerraTV+ Bt848, Bt878 */ static void terratv_audio(struct bttv *btv, struct video_audio *v, int set) { @@ -3818,7 +3998,7 @@ fv2000s_audio(struct bttv *btv, struct video_audio *v, int set) } if ((v->mode & (VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2)) || (v->mode & VIDEO_SOUND_STEREO)) { - val = 0x1080; //-dk-???: 0x0880, 0x0080, 0x1800 ... + val = 0x1080; /*-dk-???: 0x0880, 0x0080, 0x1800 ... */ } if (val != 0xffff) { gpio_bits(0x1800, val); @@ -3869,10 +4049,10 @@ adtvk503_audio(struct bttv *btv, struct video_audio *v, int set) { unsigned int con = 0xffffff; - //btaor(0x1e0000, ~0x1e0000, BT848_GPIO_OUT_EN); + /* btaor(0x1e0000, ~0x1e0000, BT848_GPIO_OUT_EN); */ if (set) { - //btor(***, BT848_GPIO_OUT_EN); + /* btor(***, BT848_GPIO_OUT_EN); */ if (v->mode & VIDEO_SOUND_LANG1) con = 0x00000000; if (v->mode & VIDEO_SOUND_LANG2) @@ -4079,14 +4259,14 @@ static void kodicom4400r_init(struct bttv *btv) master[btv->c.nr+2] = btv; } -// The Grandtec X-Guard framegrabber card uses two Dual 4-channel -// video multiplexers to provide up to 16 video inputs. These -// multiplexers are controlled by the lower 8 GPIO pins of the -// bt878. The multiplexers probably Pericom PI5V331Q or similar. - -// xxx0 is pin xxx of multiplexer U5, -// yyy1 is pin yyy of multiplexer U2 +/* The Grandtec X-Guard framegrabber card uses two Dual 4-channel + * video multiplexers to provide up to 16 video inputs. These + * multiplexers are controlled by the lower 8 GPIO pins of the + * bt878. The multiplexers probably Pericom PI5V331Q or similar. + * xxx0 is pin xxx of multiplexer U5, + * yyy1 is pin yyy of multiplexer U2 + */ #define ENA0 0x01 #define ENB0 0x02 #define ENA1 0x04 @@ -4157,14 +4337,14 @@ static void picolo_tetra_muxsel (struct bttv* btv, unsigned int input) static void ivc120_muxsel(struct bttv *btv, unsigned int input) { - // Simple maths + /* Simple maths */ int key = input % 4; int matrix = input / 4; dprintk("bttv%d: ivc120_muxsel: Input - %02d | TDA - %02d | In - %02d\n", btv->c.nr, input, matrix, key); - // Handles the input selection on the TDA8540's + /* Handles the input selection on the TDA8540's */ bttv_I2CWrite(btv, I2C_TDA8540_ALT3, 0x00, ((matrix == 3) ? (key | key << 2) : 0x00), 1); bttv_I2CWrite(btv, I2C_TDA8540_ALT4, 0x00, @@ -4174,17 +4354,17 @@ static void ivc120_muxsel(struct bttv *btv, unsigned int input) bttv_I2CWrite(btv, I2C_TDA8540_ALT6, 0x00, ((matrix == 2) ? (key | key << 2) : 0x00), 1); - // Handles the output enables on the TDA8540's + /* Handles the output enables on the TDA8540's */ bttv_I2CWrite(btv, I2C_TDA8540_ALT3, 0x02, - ((matrix == 3) ? 0x03 : 0x00), 1); // 13 - 16 + ((matrix == 3) ? 0x03 : 0x00), 1); /* 13 - 16 */ bttv_I2CWrite(btv, I2C_TDA8540_ALT4, 0x02, - ((matrix == 0) ? 0x03 : 0x00), 1); // 1-4 + ((matrix == 0) ? 0x03 : 0x00), 1); /* 1-4 */ bttv_I2CWrite(btv, I2C_TDA8540_ALT5, 0x02, - ((matrix == 1) ? 0x03 : 0x00), 1); // 5-8 + ((matrix == 1) ? 0x03 : 0x00), 1); /* 5-8 */ bttv_I2CWrite(btv, I2C_TDA8540_ALT6, 0x02, - ((matrix == 2) ? 0x03 : 0x00), 1); // 9-12 + ((matrix == 2) ? 0x03 : 0x00), 1); /* 9-12 */ - // Selects MUX0 for input on the 878 + /* Selects MUX0 for input on the 878 */ btaor((0)<<5, ~(3<<5), BT848_IFORM); } diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c index 087efb4dea0..a564321db2f 100644 --- a/drivers/media/video/bttv-driver.c +++ b/drivers/media/video/bttv-driver.c @@ -1,5 +1,4 @@ /* - $Id: bttv-driver.c,v 1.52 2005/08/04 00:55:16 mchehab Exp $ bttv - Bt848 frame grabber driver @@ -42,6 +41,9 @@ #include "bttvp.h" +#include "rds.h" + + unsigned int bttv_num; /* number of Bt848s in use */ struct bttv bttvs[BTTV_MAX]; @@ -3128,15 +3130,12 @@ static int radio_open(struct inode *inode, struct file *file) dprintk("bttv%d: open called (radio)\n",btv->c.nr); down(&btv->lock); - if (btv->radio_user) { - up(&btv->lock); - return -EBUSY; - } + btv->radio_user++; + file->private_data = btv; - i2c_vidiocschan(btv); - bttv_call_i2c_clients(btv,AUDC_SET_RADIO,&btv->tuner_type); + bttv_call_i2c_clients(btv,AUDC_SET_RADIO,&btv->tuner_type); audio_mux(btv,AUDIO_RADIO); up(&btv->lock); @@ -3145,9 +3144,13 @@ static int radio_open(struct inode *inode, struct file *file) static int radio_release(struct inode *inode, struct file *file) { - struct bttv *btv = file->private_data; + struct bttv *btv = file->private_data; + struct rds_command cmd; btv->radio_user--; + + bttv_call_i2c_clients(btv, RDS_CMD_CLOSE, &cmd); + return 0; } @@ -3203,13 +3206,42 @@ static int radio_ioctl(struct inode *inode, struct file *file, return video_usercopy(inode, file, cmd, arg, radio_do_ioctl); } +static ssize_t radio_read(struct file *file, char __user *data, + size_t count, loff_t *ppos) +{ + struct bttv *btv = file->private_data; + struct rds_command cmd; + cmd.block_count = count/3; + cmd.buffer = data; + cmd.instance = file; + cmd.result = -ENODEV; + + bttv_call_i2c_clients(btv, RDS_CMD_READ, &cmd); + + return cmd.result; +} + +static unsigned int radio_poll(struct file *file, poll_table *wait) +{ + struct bttv *btv = file->private_data; + struct rds_command cmd; + cmd.instance = file; + cmd.event_list = wait; + cmd.result = -ENODEV; + bttv_call_i2c_clients(btv, RDS_CMD_POLL, &cmd); + + return cmd.result; +} + static struct file_operations radio_fops = { .owner = THIS_MODULE, .open = radio_open, + .read = radio_read, .release = radio_release, .ioctl = radio_ioctl, .llseek = no_llseek, + .poll = radio_poll, }; static struct video_device radio_template = @@ -4047,6 +4079,7 @@ static int bttv_suspend(struct pci_dev *pci_dev, pm_message_t state) struct bttv_buffer_set idle; unsigned long flags; + dprintk("bttv%d: suspend %d\n", btv->c.nr, state.event); /* stop dma + irqs */ spin_lock_irqsave(&btv->s_lock,flags); @@ -4079,15 +4112,29 @@ static int bttv_resume(struct pci_dev *pci_dev) { struct bttv *btv = pci_get_drvdata(pci_dev); unsigned long flags; + int err; dprintk("bttv%d: resume\n", btv->c.nr); /* restore pci state */ if (btv->state.disabled) { - pci_enable_device(pci_dev); + err=pci_enable_device(pci_dev); + if (err) { + printk(KERN_WARNING "bttv%d: Can't enable device.\n", + btv->c.nr); + return err; + } btv->state.disabled = 0; } - pci_set_power_state(pci_dev, PCI_D0); + err=pci_set_power_state(pci_dev, PCI_D0); + if (err) { + pci_disable_device(pci_dev); + printk(KERN_WARNING "bttv%d: Can't enable device.\n", + btv->c.nr); + btv->state.disabled = 1; + return err; + } + pci_restore_state(pci_dev); /* restore bt878 state */ diff --git a/drivers/media/video/bttv-gpio.c b/drivers/media/video/bttv-gpio.c index 77320cdf205..6b280c03e39 100644 --- a/drivers/media/video/bttv-gpio.c +++ b/drivers/media/video/bttv-gpio.c @@ -1,5 +1,4 @@ /* - $Id: bttv-gpio.c,v 1.7 2005/02/16 12:14:10 kraxel Exp $ bttv-gpio.c -- gpio sub drivers diff --git a/drivers/media/video/bttv-i2c.c b/drivers/media/video/bttv-i2c.c index 706dc48df96..e684df37eb0 100644 --- a/drivers/media/video/bttv-i2c.c +++ b/drivers/media/video/bttv-i2c.c @@ -1,5 +1,4 @@ /* - $Id: bttv-i2c.c,v 1.25 2005/07/05 17:37:35 nsh Exp $ bttv-i2c.c -- all the i2c code is here @@ -381,6 +380,7 @@ void __devinit bttv_readee(struct bttv *btv, unsigned char *eedata, int addr) } static char *i2c_devs[128] = { + [ 0x1c >> 1 ] = "lgdt330x", [ 0x30 >> 1 ] = "IR (hauppauge)", [ 0x80 >> 1 ] = "msp34xx", [ 0x86 >> 1 ] = "tda9887", diff --git a/drivers/media/video/bttv-if.c b/drivers/media/video/bttv-if.c index f7b5543a96a..e8aada772b8 100644 --- a/drivers/media/video/bttv-if.c +++ b/drivers/media/video/bttv-if.c @@ -1,5 +1,4 @@ /* - $Id: bttv-if.c,v 1.4 2004/11/17 18:47:47 kraxel Exp $ bttv-if.c -- old gpio interface to other kernel modules don't use in new code, will go away in 2.7 diff --git a/drivers/media/video/bttv-risc.c b/drivers/media/video/bttv-risc.c index 9ed21fd190c..a5ed99b8944 100644 --- a/drivers/media/video/bttv-risc.c +++ b/drivers/media/video/bttv-risc.c @@ -1,5 +1,4 @@ /* - $Id: bttv-risc.c,v 1.10 2004/11/19 18:07:12 kraxel Exp $ bttv-risc.c -- interfaces to other kernel modules diff --git a/drivers/media/video/bttv-vbi.c b/drivers/media/video/bttv-vbi.c index 06f3e62b3e8..f4f58c60f15 100644 --- a/drivers/media/video/bttv-vbi.c +++ b/drivers/media/video/bttv-vbi.c @@ -1,5 +1,4 @@ /* - $Id: bttv-vbi.c,v 1.9 2005/01/13 17:22:33 kraxel Exp $ bttv - Bt848 frame grabber driver vbi interface diff --git a/drivers/media/video/bttv.h b/drivers/media/video/bttv.h index f2af9e1454f..d254e90e3bb 100644 --- a/drivers/media/video/bttv.h +++ b/drivers/media/video/bttv.h @@ -1,5 +1,4 @@ /* - * $Id: bttv.h,v 1.22 2005/07/28 18:41:21 mchehab Exp $ * * bttv - Bt848 frame grabber driver * @@ -218,6 +217,8 @@ struct tvcard #define PLL_35 2 unsigned int tuner_type; + unsigned int tuner_addr; + unsigned int has_radio; void (*audio_hook)(struct bttv *btv, struct video_audio *v, int set); void (*muxsel_hook)(struct bttv *btv, unsigned int input); diff --git a/drivers/media/video/bttvp.h b/drivers/media/video/bttvp.h index aab094bc243..9b0b7ca035f 100644 --- a/drivers/media/video/bttvp.h +++ b/drivers/media/video/bttvp.h @@ -1,5 +1,4 @@ /* - $Id: bttvp.h,v 1.21 2005/07/15 21:44:14 mchehab Exp $ bttv - Bt848 frame grabber driver diff --git a/drivers/media/video/cpia_usb.c b/drivers/media/video/cpia_usb.c index cdda423386c..9774e94d1e7 100644 --- a/drivers/media/video/cpia_usb.c +++ b/drivers/media/video/cpia_usb.c @@ -445,10 +445,8 @@ static void cpia_usb_free_resources(struct usb_cpia *ucpia, int try) ucpia->sbuf[1].urb = NULL; } - if (ucpia->sbuf[1].data) { - kfree(ucpia->sbuf[1].data); - ucpia->sbuf[1].data = NULL; - } + kfree(ucpia->sbuf[1].data); + ucpia->sbuf[1].data = NULL; if (ucpia->sbuf[0].urb) { usb_kill_urb(ucpia->sbuf[0].urb); @@ -456,10 +454,8 @@ static void cpia_usb_free_resources(struct usb_cpia *ucpia, int try) ucpia->sbuf[0].urb = NULL; } - if (ucpia->sbuf[0].data) { - kfree(ucpia->sbuf[0].data); - ucpia->sbuf[0].data = NULL; - } + kfree(ucpia->sbuf[0].data); + ucpia->sbuf[0].data = NULL; } static int cpia_usb_close(void *privdata) @@ -623,20 +619,14 @@ static void cpia_disconnect(struct usb_interface *intf) ucpia->curbuff = ucpia->workbuff = NULL; - if (ucpia->buffers[2]) { - vfree(ucpia->buffers[2]); - ucpia->buffers[2] = NULL; - } + vfree(ucpia->buffers[2]); + ucpia->buffers[2] = NULL; - if (ucpia->buffers[1]) { - vfree(ucpia->buffers[1]); - ucpia->buffers[1] = NULL; - } + vfree(ucpia->buffers[1]); + ucpia->buffers[1] = NULL; - if (ucpia->buffers[0]) { - vfree(ucpia->buffers[0]); - ucpia->buffers[0] = NULL; - } + vfree(ucpia->buffers[0]); + ucpia->buffers[0] = NULL; cam->lowlevel_data = NULL; kfree(ucpia); diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c index 4f39688f780..0c0c59e9477 100644 --- a/drivers/media/video/cx88/cx88-blackbird.c +++ b/drivers/media/video/cx88/cx88-blackbird.c @@ -1,5 +1,4 @@ /* - * $Id: cx88-blackbird.c,v 1.27 2005/06/03 13:31:50 mchehab Exp $ * * Support for a cx23416 mpeg encoder via cx2388x host port. * "blackbird" reference design. @@ -62,7 +61,6 @@ static LIST_HEAD(cx8802_devlist); #define IVTV_CMD_HW_BLOCKS_RST 0xFFFFFFFF /* Firmware API commands */ -/* #define IVTV_API_STD_TIMEOUT 0x00010000 // 65536, units?? */ #define IVTV_API_STD_TIMEOUT 500 #define BLACKBIRD_API_PING 0x80 @@ -696,7 +694,6 @@ static void blackbird_codec_settings(struct cx8802_dev *dev) /* assign stream type */ blackbird_api_cmd(dev, BLACKBIRD_API_SET_STREAM_TYPE, 1, 0, BLACKBIRD_STREAM_PROGRAM); - /* blackbird_api_cmd(dev, BLACKBIRD_API_SET_STREAM_TYPE, 1, 0, BLACKBIRD_STREAM_TRANSPORT); */ /* assign output port */ blackbird_api_cmd(dev, BLACKBIRD_API_SET_OUTPUT_PORT, 1, 0, BLACKBIRD_OUTPUT_PORT_STREAMING); /* Host */ @@ -824,7 +821,8 @@ static int blackbird_initialize_codec(struct cx8802_dev *dev) BLACKBIRD_CUSTOM_EXTENSION_USR_DATA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - blackbird_api_cmd(dev, BLACKBIRD_API_INIT_VIDEO_INPUT, 0, 0); /* initialize the video input */ + /* initialize the video input */ + blackbird_api_cmd(dev, BLACKBIRD_API_INIT_VIDEO_INPUT, 0, 0); msleep(1); @@ -833,11 +831,12 @@ static int blackbird_initialize_codec(struct cx8802_dev *dev) blackbird_api_cmd(dev, BLACKBIRD_API_MUTE_AUDIO, 1, 0, BLACKBIRD_UNMUTE); msleep(1); - /* blackbird_api_cmd(dev, BLACKBIRD_API_BEGIN_CAPTURE, 2, 0, 0, 0x13); // start capturing to the host interface */ + /* start capturing to the host interface */ + /* blackbird_api_cmd(dev, BLACKBIRD_API_BEGIN_CAPTURE, 2, 0, 0, 0x13); */ blackbird_api_cmd(dev, BLACKBIRD_API_BEGIN_CAPTURE, 2, 0, BLACKBIRD_MPEG_CAPTURE, BLACKBIRD_RAW_BITS_NONE - ); /* start capturing to the host interface */ + ); msleep(10); blackbird_api_cmd(dev, BLACKBIRD_API_REFRESH_INPUT, 0,0); @@ -851,8 +850,8 @@ static int bb_buf_setup(struct videobuf_queue *q, { struct cx8802_fh *fh = q->priv_data; - fh->dev->ts_packet_size = 512; - fh->dev->ts_packet_count = 100; + fh->dev->ts_packet_size = 188 * 4; /* was: 512 */ + fh->dev->ts_packet_count = 32; /* was: 100 */ *size = fh->dev->ts_packet_size * fh->dev->ts_packet_count; if (0 == *count) @@ -900,12 +899,36 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file, { struct cx8802_fh *fh = file->private_data; struct cx8802_dev *dev = fh->dev; + struct cx88_core *core = dev->core; if (debug > 1) - cx88_print_ioctl(dev->core->name,cmd); + cx88_print_ioctl(core->name,cmd); switch (cmd) { + /* --- capabilities ------------------------------------------ */ + case VIDIOC_QUERYCAP: + { + struct v4l2_capability *cap = arg; + + memset(cap,0,sizeof(*cap)); + strcpy(cap->driver, "cx88_blackbird"); + strlcpy(cap->card, cx88_boards[core->board].name,sizeof(cap->card)); + sprintf(cap->bus_info,"PCI:%s",pci_name(dev->pci)); + cap->version = CX88_VERSION_CODE; + cap->capabilities = + V4L2_CAP_VIDEO_CAPTURE | + V4L2_CAP_READWRITE | + V4L2_CAP_STREAMING | + V4L2_CAP_VBI_CAPTURE | + V4L2_CAP_VIDEO_OVERLAY | + 0; + if (UNSET != core->tuner_type) + cap->capabilities |= V4L2_CAP_TUNER; + + return 0; + } + /* --- capture ioctls ---------------------------------------- */ case VIDIOC_ENUM_FMT: { @@ -935,7 +958,11 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file, f->fmt.pix.width = dev->width; f->fmt.pix.height = dev->height; f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; - f->fmt.pix.sizeimage = 1024 * 512 /* FIXME: BUFFER_SIZE */; + f->fmt.pix.field = V4L2_FIELD_NONE; + f->fmt.pix.bytesperline = 0; + f->fmt.pix.sizeimage = 188 * 4 * 1024; /* 1024 * 512 */ /* FIXME: BUFFER_SIZE */; + f->fmt.pix.colorspace = 0; + return 0; } /* --- streaming capture ------------------------------------- */ @@ -959,15 +986,25 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file, return videobuf_streamoff(&fh->mpegq); default: - return -EINVAL; + return cx88_do_ioctl( inode, file, 0, dev->core, cmd, arg, cx88_ioctl_hook ); } return 0; } +int (*cx88_ioctl_hook)(struct inode *inode, struct file *file, + unsigned int cmd, void *arg); +unsigned int (*cx88_ioctl_translator)(unsigned int cmd); + +static unsigned int mpeg_translate_ioctl(unsigned int cmd) +{ + return cmd; +} + static int mpeg_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg) + unsigned int cmd, unsigned long arg) { - return video_usercopy(inode, file, cmd, arg, mpeg_do_ioctl); + cmd = cx88_ioctl_translator( cmd ); + return video_usercopy(inode, file, cmd, arg, cx88_ioctl_hook); } static int mpeg_open(struct inode *inode, struct file *file) @@ -1135,7 +1172,7 @@ static int __devinit blackbird_probe(struct pci_dev *pci_dev, dev->pci = pci_dev; dev->core = core; dev->width = 720; - dev->height = 480; + dev->height = 576; err = cx8802_init_common(dev); if (0 != err) @@ -1148,6 +1185,9 @@ static int __devinit blackbird_probe(struct pci_dev *pci_dev, list_add_tail(&dev->devlist,&cx8802_devlist); blackbird_register_video(dev); + + /* initial device configuration: needed ? */ + return 0; fail_free: @@ -1202,6 +1242,8 @@ static int blackbird_init(void) printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n", SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100); #endif + cx88_ioctl_hook = mpeg_do_ioctl; + cx88_ioctl_translator = mpeg_translate_ioctl; return pci_register_driver(&blackbird_pci_driver); } @@ -1213,6 +1255,9 @@ static void blackbird_fini(void) module_init(blackbird_init); module_exit(blackbird_fini); +EXPORT_SYMBOL(cx88_ioctl_hook); +EXPORT_SYMBOL(cx88_ioctl_translator); + /* ----------------------------------------------------------- */ /* * Local variables: diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c index ebf02a7f81e..4da91d535a5 100644 --- a/drivers/media/video/cx88/cx88-cards.c +++ b/drivers/media/video/cx88/cx88-cards.c @@ -1,5 +1,4 @@ /* - * $Id: cx88-cards.c,v 1.90 2005/07/28 02:47:42 mkrufky Exp $ * * device driver for Conexant 2388x based TV cards * card-specific stuff. @@ -499,9 +498,6 @@ struct cx88_board cx88_boards[] = { .input = {{ .type = CX88_VMUX_DVB, .vmux = 0, - },{ - .type = CX88_VMUX_SVIDEO, - .vmux = 2, }}, .dvb = 1, }, @@ -614,12 +610,12 @@ struct cx88_board cx88_boards[] = { .input = {{ .type = CX88_VMUX_TELEVISION, .vmux = 0, - .gpio0 = 0xed12, // internal decoder + .gpio0 = 0xed12, /* internal decoder */ .gpio2 = 0x00ff, },{ .type = CX88_VMUX_DEBUG, .vmux = 0, - .gpio0 = 0xff01, // mono from tuner chip + .gpio0 = 0xff01, /* mono from tuner chip */ },{ .type = CX88_VMUX_COMPOSITE1, .vmux = 1, @@ -715,19 +711,18 @@ struct cx88_board cx88_boards[] = { .radio_type = UNSET, .tuner_addr = ADDR_UNSET, .radio_addr = ADDR_UNSET, - /* See DViCO FusionHDTV 3 Gold-Q for GPIO documentation. */ .input = {{ .type = CX88_VMUX_TELEVISION, .vmux = 0, - .gpio0 = 0x0f0d, + .gpio0 = 0x97ed, },{ .type = CX88_VMUX_COMPOSITE1, .vmux = 1, - .gpio0 = 0x0f00, + .gpio0 = 0x97e9, },{ .type = CX88_VMUX_SVIDEO, .vmux = 2, - .gpio0 = 0x0f00, + .gpio0 = 0x97e9, }}, .dvb = 1, }, @@ -765,20 +760,21 @@ struct cx88_board cx88_boards[] = { .radio_type = UNSET, .tuner_addr = ADDR_UNSET, .radio_addr = ADDR_UNSET, - /* See DViCO FusionHDTV 3 Gold-Q for GPIO documentation. */ + .tda9887_conf = TDA9887_PRESENT, .input = {{ .type = CX88_VMUX_TELEVISION, .vmux = 0, - .gpio0 = 0x0f0d, + .gpio0 = 0x87fd, },{ .type = CX88_VMUX_COMPOSITE1, .vmux = 1, - .gpio0 = 0x0f00, + .gpio0 = 0x87f9, },{ .type = CX88_VMUX_SVIDEO, .vmux = 2, - .gpio0 = 0x0f00, + .gpio0 = 0x87f9, }}, + .dvb = 1, }, }; const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards); @@ -949,7 +945,7 @@ static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data) { struct tveeprom tv; - tveeprom_hauppauge_analog(&tv, eeprom_data); + tveeprom_hauppauge_analog(&core->i2c_client, &tv, eeprom_data); core->tuner_type = tv.tuner_type; core->has_radio = tv.has_radio; } diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c index 5e868f5cd0c..dc5c5c1f346 100644 --- a/drivers/media/video/cx88/cx88-core.c +++ b/drivers/media/video/cx88/cx88-core.c @@ -1,5 +1,4 @@ /* - * $Id: cx88-core.c,v 1.33 2005/07/07 14:17:47 mchehab Exp $ * * device driver for Conexant 2388x based TV cards * driver core @@ -876,7 +875,7 @@ static int set_tvaudio(struct cx88_core *core) cx_andor(MO_AFECFG_IO, 0x1f, 0x0); cx88_set_tvaudio(core); - // cx88_set_stereo(dev,V4L2_TUNER_MODE_STEREO); + /* cx88_set_stereo(dev,V4L2_TUNER_MODE_STEREO); */ cx_write(MO_AUDD_LNGTH, 128); /* fifo size */ cx_write(MO_AUDR_LNGTH, 128); /* fifo size */ @@ -1087,10 +1086,17 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci) core->pci_bus = pci->bus->number; core->pci_slot = PCI_SLOT(pci->devfn); core->pci_irqmask = 0x00fc00; + init_MUTEX(&core->lock); core->nr = cx88_devcount++; sprintf(core->name,"cx88[%d]",core->nr); if (0 != get_ressources(core,pci)) { + printk(KERN_ERR "CORE %s No more PCI ressources for " + "subsystem: %04x:%04x, board: %s\n", + core->name,pci->subsystem_vendor, + pci->subsystem_device, + cx88_boards[core->board].name); + cx88_devcount--; goto fail_free; } @@ -1114,11 +1120,11 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci) core->board = CX88_BOARD_UNKNOWN; cx88_card_list(core,pci); } - printk(KERN_INFO "%s: subsystem: %04x:%04x, board: %s [card=%d,%s]\n", - core->name,pci->subsystem_vendor, - pci->subsystem_device,cx88_boards[core->board].name, - core->board, card[core->nr] == core->board ? - "insmod option" : "autodetected"); + printk(KERN_INFO "CORE %s: subsystem: %04x:%04x, board: %s [card=%d,%s]\n", + core->name,pci->subsystem_vendor, + pci->subsystem_device,cx88_boards[core->board].name, + core->board, card[core->nr] == core->board ? + "insmod option" : "autodetected"); core->tuner_type = tuner[core->nr]; core->radio_type = radio[core->nr]; @@ -1202,4 +1208,5 @@ EXPORT_SYMBOL(cx88_core_put); * Local variables: * c-basic-offset: 8 * End: + * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off */ diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c index 78d223257a6..c9106b1d79d 100644 --- a/drivers/media/video/cx88/cx88-dvb.c +++ b/drivers/media/video/cx88/cx88-dvb.c @@ -1,5 +1,4 @@ /* - * $Id: cx88-dvb.c,v 1.58 2005/08/07 09:24:08 mkrufky Exp $ * * device driver for Conexant 2388x based TV cards * MPEG Transport Stream (DVB) routines @@ -29,7 +28,7 @@ #include <linux/kthread.h> #include <linux/file.h> #include <linux/suspend.h> -#include <linux/config.h> + #include "cx88.h" #include "dvb-pll.h" @@ -210,16 +209,26 @@ static struct or51132_config pchdtv_hd3000 = { static int lgdt330x_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) { + /* FIXME make this routine use the tuner-simple code. + * It could probably be shared with a number of ATSC + * frontends. Many share the same tuner with analog TV. */ + struct cx8802_dev *dev= fe->dvb->priv; + struct cx88_core *core = dev->core; u8 buf[4]; struct i2c_msg msg = { .addr = dev->core->pll_addr, .flags = 0, .buf = buf, .len = 4 }; int err; - dvb_pll_configure(dev->core->pll_desc, buf, params->frequency, 0); + /* Put the analog decoder in standby to keep it quiet */ + if (core->tda9887_conf) { + cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL); + } + + dvb_pll_configure(core->pll_desc, buf, params->frequency, 0); dprintk(1, "%s: tuner at 0x%02x bytes: 0x%02x 0x%02x 0x%02x 0x%02x\n", __FUNCTION__, msg.addr, buf[0],buf[1],buf[2],buf[3]); - if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) { + if ((err = i2c_transfer(&core->i2c_adap, &msg, 1)) != 1) { printk(KERN_WARNING "cx88-dvb: %s error " "(addr %02x <- %02x, err = %i)\n", __FUNCTION__, buf[0], buf[1], err); @@ -228,6 +237,13 @@ static int lgdt330x_pll_set(struct dvb_frontend* fe, else return -EREMOTEIO; } + if (core->tuner_type == TUNER_LG_TDVS_H062F) { + /* Set the Auxiliary Byte. */ + buf[2] &= ~0x20; + buf[2] |= 0x18; + buf[3] = 0x50; + i2c_transfer(&core->i2c_adap, &msg, 1); + } return 0; } @@ -261,6 +277,14 @@ static struct lgdt330x_config fusionhdtv_3_gold = { .pll_set = lgdt330x_pll_set, .set_ts_params = lgdt330x_set_ts_param, }; + +static struct lgdt330x_config fusionhdtv_5_gold = { + .demod_address = 0x0e, + .demod_chip = LGDT3303, + .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */ + .pll_set = lgdt330x_pll_set, + .set_ts_params = lgdt330x_set_ts_param, +}; #endif static int dvb_register(struct cx8802_dev *dev) @@ -346,6 +370,22 @@ static int dvb_register(struct cx8802_dev *dev) &dev->core->i2c_adap); } break; + case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD: + dev->ts_gen_cntrl = 0x08; + { + /* Do a hardware reset of chip before using it. */ + struct cx88_core *core = dev->core; + + cx_clear(MO_GP0_IO, 1); + mdelay(100); + cx_set(MO_GP0_IO, 1); + mdelay(200); + dev->core->pll_addr = 0x61; + dev->core->pll_desc = &dvb_pll_tdvs_tua6034; + dev->dvb.frontend = lgdt330x_attach(&fusionhdtv_5_gold, + &dev->core->i2c_adap); + } + break; #endif default: printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n", @@ -362,11 +402,6 @@ static int dvb_register(struct cx8802_dev *dev) dev->dvb.frontend->ops->info.frequency_max = dev->core->pll_desc->max; } - /* Copy the board name into the DVB structure */ - strlcpy(dev->dvb.frontend->ops->info.name, - cx88_boards[dev->core->board].name, - sizeof(dev->dvb.frontend->ops->info.name)); - /* register everything */ return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev); } diff --git a/drivers/media/video/cx88/cx88-i2c.c b/drivers/media/video/cx88/cx88-i2c.c index 7f598039e02..761cebd40db 100644 --- a/drivers/media/video/cx88/cx88-i2c.c +++ b/drivers/media/video/cx88/cx88-i2c.c @@ -1,5 +1,4 @@ /* - $Id: cx88-i2c.c,v 1.30 2005/07/25 05:10:13 mkrufky Exp $ cx88-i2c.c -- all the i2c code is here diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c index 21488779819..d81b21d6e05 100644 --- a/drivers/media/video/cx88/cx88-input.c +++ b/drivers/media/video/cx88/cx88-input.c @@ -1,5 +1,4 @@ /* - * $Id: cx88-input.c,v 1.15 2005/07/07 13:58:38 mchehab Exp $ * * Device driver for GPIO attached remote control interfaces * on Conexant 2388x based TV/DVB cards. @@ -212,6 +211,53 @@ static IR_KEYTAB_TYPE ir_codes_msi_tvanywhere[IR_KEYTAB_SIZE] = { /* ---------------------------------------------------------------------- */ +/* Cinergy 1400 DVB-T */ +static IR_KEYTAB_TYPE ir_codes_cinergy_1400[IR_KEYTAB_SIZE] = { + [0x01] = KEY_POWER, + [0x02] = KEY_1, + [0x03] = KEY_2, + [0x04] = KEY_3, + [0x05] = KEY_4, + [0x06] = KEY_5, + [0x07] = KEY_6, + [0x08] = KEY_7, + [0x09] = KEY_8, + [0x0a] = KEY_9, + [0x0c] = KEY_0, + + [0x0b] = KEY_VIDEO, + [0x0d] = KEY_REFRESH, + [0x0e] = KEY_SELECT, + [0x0f] = KEY_EPG, + [0x10] = KEY_UP, + [0x11] = KEY_LEFT, + [0x12] = KEY_OK, + [0x13] = KEY_RIGHT, + [0x14] = KEY_DOWN, + [0x15] = KEY_TEXT, + [0x16] = KEY_INFO, + + [0x17] = KEY_RED, + [0x18] = KEY_GREEN, + [0x19] = KEY_YELLOW, + [0x1a] = KEY_BLUE, + + [0x1b] = KEY_CHANNELUP, + [0x1c] = KEY_VOLUMEUP, + [0x1d] = KEY_MUTE, + [0x1e] = KEY_VOLUMEDOWN, + [0x1f] = KEY_CHANNELDOWN, + + [0x40] = KEY_PAUSE, + [0x4c] = KEY_PLAY, + [0x58] = KEY_RECORD, + [0x54] = KEY_PREVIOUS, + [0x48] = KEY_STOP, + [0x5c] = KEY_NEXT, +}; + +/* ---------------------------------------------------------------------- */ + struct cx88_IR { struct cx88_core *core; struct input_dev input; @@ -241,7 +287,7 @@ module_param(ir_debug, int, 0644); /* debug level [IR] */ MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]"); #define ir_dprintk(fmt, arg...) if (ir_debug) \ - printk(KERN_DEBUG "%s IR: " fmt , ir->core->name, ## arg) + printk(KERN_DEBUG "%s IR: " fmt , ir->core->name , ##arg) /* ---------------------------------------------------------------------- */ @@ -329,6 +375,11 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) ir->mask_keyup = 0x60; ir->polling = 50; /* ms */ break; + case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1: + ir_codes = ir_codes_cinergy_1400; + ir_type = IR_TYPE_PD; + ir->sampling = 1; + break; case CX88_BOARD_HAUPPAUGE: case CX88_BOARD_HAUPPAUGE_DVB_T1: ir_codes = ir_codes_hauppauge_new; @@ -394,6 +445,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) ir->input.id.vendor = pci->vendor; ir->input.id.product = pci->device; } + ir->input.dev = &pci->dev; /* record handles to ourself */ ir->core = core; @@ -445,7 +497,7 @@ int cx88_ir_fini(struct cx88_core *core) void cx88_ir_irq(struct cx88_core *core) { struct cx88_IR *ir = core->ir; - u32 samples, rc5; + u32 samples, ircode; int i; if (NULL == ir) @@ -477,13 +529,44 @@ void cx88_ir_irq(struct cx88_core *core) /* decode it */ switch (core->board) { + case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1: + ircode = ir_decode_pulsedistance(ir->samples, ir->scount, 1, 4); + + if (ircode == 0xffffffff) { /* decoding error */ + ir_dprintk("pulse distance decoding error\n"); + break; + } + + ir_dprintk("pulse distance decoded: %x\n", ircode); + + if (ircode == 0) { /* key still pressed */ + ir_dprintk("pulse distance decoded repeat code\n"); + ir->release = jiffies + msecs_to_jiffies(120); + break; + } + + if ((ircode & 0xffff) != 0xeb04) { /* wrong address */ + ir_dprintk("pulse distance decoded wrong address\n"); + break; + } + + if (((~ircode >> 24) & 0xff) != ((ircode >> 16) & 0xff)) { /* wrong checksum */ + ir_dprintk("pulse distance decoded wrong check sum\n"); + break; + } + + ir_dprintk("Key Code: %x\n", (ircode >> 16) & 0x7f); + + ir_input_keydown(&ir->input, &ir->ir, (ircode >> 16) & 0x7f, (ircode >> 16) & 0xff); + ir->release = jiffies + msecs_to_jiffies(120); + break; case CX88_BOARD_HAUPPAUGE: case CX88_BOARD_HAUPPAUGE_DVB_T1: - rc5 = ir_decode_biphase(ir->samples, ir->scount, 5, 7); - ir_dprintk("biphase decoded: %x\n", rc5); - if ((rc5 & 0xfffff000) != 0x3000) + ircode = ir_decode_biphase(ir->samples, ir->scount, 5, 7); + ir_dprintk("biphase decoded: %x\n", ircode); + if ((ircode & 0xfffff000) != 0x3000) break; - ir_input_keydown(&ir->input, &ir->ir, rc5 & 0x3f, rc5); + ir_input_keydown(&ir->input, &ir->ir, ircode & 0x3f, ircode); ir->release = jiffies + msecs_to_jiffies(120); break; } diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c index fe2767c0ff9..ee2300e1ae0 100644 --- a/drivers/media/video/cx88/cx88-mpeg.c +++ b/drivers/media/video/cx88/cx88-mpeg.c @@ -1,5 +1,4 @@ /* - * $Id: cx88-mpeg.c,v 1.31 2005/07/07 14:17:47 mchehab Exp $ * * Support for the mpeg transport stream transfers * PCI function #2 of the cx2388x. @@ -73,11 +72,15 @@ static int cx8802_start_dma(struct cx8802_dev *dev, udelay(100); cx_write(MO_PINMUX_IO, 0x00); cx_write(TS_HW_SOP_CNTRL,0x47<<16|188<<4|0x01); - if ((core->board == CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q) || - (core->board == CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T)) { + switch (core->board) { + case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q: + case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T: + case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD: cx_write(TS_SOP_STAT, 1<<13); - } else { + break; + default: cx_write(TS_SOP_STAT, 0x00); + break; } cx_write(TS_GEN_CNTRL, dev->ts_gen_cntrl); udelay(100); @@ -86,12 +89,10 @@ static int cx8802_start_dma(struct cx8802_dev *dev, if (cx88_boards[core->board].blackbird) { cx_write(MO_PINMUX_IO, 0x88); /* enable MPEG parallel IO */ - // cx_write(TS_F2_CMD_STAT_MM, 0x2900106); /* F2_CMD_STAT_MM defaults + master + memory space */ cx_write(TS_GEN_CNTRL, 0x46); /* punctured clock TS & posedge driven & software reset */ udelay(100); cx_write(TS_HW_SOP_CNTRL, 0x408); /* mpeg start byte */ - //cx_write(TS_HW_SOP_CNTRL, 0x2F0BC0); /* mpeg start byte ts: 0x2F0BC0 ? */ cx_write(TS_VALERR_CNTRL, 0x2000); cx_write(TS_GEN_CNTRL, 0x06); /* punctured clock TS & posedge driven */ @@ -106,7 +107,6 @@ static int cx8802_start_dma(struct cx8802_dev *dev, dprintk( 0, "setting the interrupt mask\n" ); cx_set(MO_PCI_INTMSK, core->pci_irqmask | 0x04); cx_set(MO_TS_INTMSK, 0x1f0011); - //cx_write(MO_TS_INTMSK, 0x0f0011); /* start dma */ cx_set(MO_DEV_CNTRL2, (1<<5)); @@ -206,7 +206,6 @@ void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf) mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); dprintk(0,"[%p/%d] %s - first active\n", buf, buf->vb.i, __FUNCTION__); - //udelay(100); } else { dprintk( 1, "queue is not empty - append to active\n" ); @@ -217,7 +216,6 @@ void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf) prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); dprintk( 1, "[%p/%d] %s - append to active\n", buf, buf->vb.i, __FUNCTION__); - //udelay(100); } } @@ -387,7 +385,6 @@ int cx8802_init_common(struct cx8802_dev *dev) dev->pci_lat,pci_resource_start(dev->pci,0)); /* initialize driver struct */ - init_MUTEX(&dev->lock); spin_lock_init(&dev->slock); /* init dma queue */ @@ -458,14 +455,28 @@ int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state) int cx8802_resume_common(struct pci_dev *pci_dev) { - struct cx8802_dev *dev = pci_get_drvdata(pci_dev); + struct cx8802_dev *dev = pci_get_drvdata(pci_dev); struct cx88_core *core = dev->core; + int err; if (dev->state.disabled) { - pci_enable_device(pci_dev); + err=pci_enable_device(pci_dev); + if (err) { + printk(KERN_ERR "%s: can't enable device\n", + dev->core->name); + return err; + } dev->state.disabled = 0; } - pci_set_power_state(pci_dev, PCI_D0); + err=pci_set_power_state(pci_dev, PCI_D0); + if (err) { + printk(KERN_ERR "%s: can't enable device\n", + dev->core->name); + pci_disable_device(pci_dev); + dev->state.disabled = 1; + + return err; + } pci_restore_state(pci_dev); /* FIXME: re-initialize hardware */ diff --git a/drivers/media/video/cx88/cx88-reg.h b/drivers/media/video/cx88/cx88-reg.h index 37f82662d26..0a3a62fc9bb 100644 --- a/drivers/media/video/cx88/cx88-reg.h +++ b/drivers/media/video/cx88/cx88-reg.h @@ -1,5 +1,4 @@ /* - $Id: cx88-reg.h,v 1.8 2005/07/07 13:58:38 mchehab Exp $ cx88x-hw.h - CX2388x register offsets @@ -40,6 +39,29 @@ #define CX88X_EN_TBFX 0x02 #define CX88X_EN_VSFX 0x04 +/* ---------------------------------------------------------------------- */ +/* PCI controller registers */ + +/* Command and Status Register */ +#define F0_CMD_STAT_MM 0x2f0004 +#define F1_CMD_STAT_MM 0x2f0104 +#define F2_CMD_STAT_MM 0x2f0204 +#define F3_CMD_STAT_MM 0x2f0304 +#define F4_CMD_STAT_MM 0x2f0404 + +/* Device Control #1 */ +#define F0_DEV_CNTRL1_MM 0x2f0040 +#define F1_DEV_CNTRL1_MM 0x2f0140 +#define F2_DEV_CNTRL1_MM 0x2f0240 +#define F3_DEV_CNTRL1_MM 0x2f0340 +#define F4_DEV_CNTRL1_MM 0x2f0440 + +/* Device Control #1 */ +#define F0_BAR0_MM 0x2f0010 +#define F1_BAR0_MM 0x2f0110 +#define F2_BAR0_MM 0x2f0210 +#define F3_BAR0_MM 0x2f0310 +#define F4_BAR0_MM 0x2f0410 /* ---------------------------------------------------------------------- */ /* DMA Controller registers */ diff --git a/drivers/media/video/cx88/cx88-tvaudio.c b/drivers/media/video/cx88/cx88-tvaudio.c index 91207f10bae..2765acee028 100644 --- a/drivers/media/video/cx88/cx88-tvaudio.c +++ b/drivers/media/video/cx88/cx88-tvaudio.c @@ -1,5 +1,4 @@ /* - $Id: cx88-tvaudio.c,v 1.37 2005/07/07 13:58:38 mchehab Exp $ cx88x-audio.c - Conexant CX23880/23881 audio downstream driver driver @@ -121,25 +120,19 @@ static void set_audio_registers(struct cx88_core *core, } static void set_audio_start(struct cx88_core *core, - u32 mode, u32 ctl) + u32 mode) { // mute cx_write(AUD_VOL_CTL, (1 << 6)); - // increase level of input by 12dB -// cx_write(AUD_AFE_12DB_EN, 0x0001); - cx_write(AUD_AFE_12DB_EN, 0x0000); - // start programming cx_write(AUD_CTL, 0x0000); cx_write(AUD_INIT, mode); cx_write(AUD_INIT_LD, 0x0001); cx_write(AUD_SOFT_RESET, 0x0001); - - cx_write(AUD_CTL, ctl); } -static void set_audio_finish(struct cx88_core *core) +static void set_audio_finish(struct cx88_core *core, u32 ctl) { u32 volume; @@ -154,25 +147,25 @@ static void set_audio_finish(struct cx88_core *core) cx_write(AUD_I2SOUTPUTCNTL, 1); cx_write(AUD_I2SCNTL, 0); //cx_write(AUD_APB_IN_RATE_ADJ, 0); + } else { + ctl |= EN_DAC_ENABLE; + cx_write(AUD_CTL, ctl); } - // finish programming + /* finish programming */ cx_write(AUD_SOFT_RESET, 0x0000); - // start audio processing - cx_set(AUD_CTL, EN_DAC_ENABLE); - - // unmute + /* unmute */ volume = cx_sread(SHADOW_AUD_VOL_CTL); cx_swrite(SHADOW_AUD_VOL_CTL, AUD_VOL_CTL, volume); } /* ----------------------------------------------------------- */ -static void set_audio_standard_BTSC(struct cx88_core *core, unsigned int sap) +static void set_audio_standard_BTSC(struct cx88_core *core, unsigned int sap, u32 mode) { static const struct rlist btsc[] = { - /* from dscaler */ + { AUD_AFE_12DB_EN, 0x00000001 }, { AUD_OUT1_SEL, 0x00000013 }, { AUD_OUT1_SHIFT, 0x00000000 }, { AUD_POLY0_DDS_CONSTANT, 0x0012010c }, @@ -206,9 +199,10 @@ static void set_audio_standard_BTSC(struct cx88_core *core, unsigned int sap) { AUD_RDSI_SHIFT, 0x00000000 }, { AUD_RDSQ_SHIFT, 0x00000000 }, { AUD_POLYPH80SCALEFAC, 0x00000003 }, - { /* end of list */ }, + { /* end of list */ }, }; static const struct rlist btsc_sap[] = { + { AUD_AFE_12DB_EN, 0x00000001 }, { AUD_DBX_IN_GAIN, 0x00007200 }, { AUD_DBX_WBE_GAIN, 0x00006200 }, { AUD_DBX_SE_GAIN, 0x00006200 }, @@ -259,371 +253,400 @@ static void set_audio_standard_BTSC(struct cx88_core *core, unsigned int sap) { AUD_RDSI_SHIFT, 0x00000000 }, { AUD_RDSQ_SHIFT, 0x00000000 }, { AUD_POLYPH80SCALEFAC, 0x00000003 }, - { /* end of list */ }, + { /* end of list */ }, }; - // dscaler: exactly taken from driver, - // dscaler: don't know why to set EN_FMRADIO_EN_RDS + mode |= EN_FMRADIO_EN_RDS; + if (sap) { dprintk("%s SAP (status: unknown)\n",__FUNCTION__); - set_audio_start(core, 0x0001, - EN_FMRADIO_EN_RDS | EN_BTSC_FORCE_SAP); + set_audio_start(core, SEL_SAP); set_audio_registers(core, btsc_sap); + set_audio_finish(core, mode); } else { dprintk("%s (status: known-good)\n",__FUNCTION__); - set_audio_start(core, 0x0001, - EN_FMRADIO_EN_RDS | EN_BTSC_AUTO_STEREO); + set_audio_start(core, SEL_BTSC); set_audio_registers(core, btsc); + set_audio_finish(core, mode); } - set_audio_finish(core); } static void set_audio_standard_NICAM_L(struct cx88_core *core, int stereo) { - /* This is probably weird.. - * Let's operate and find out. */ - - static const struct rlist nicam_l_mono[] = { - { AUD_ERRLOGPERIOD_R, 0x00000064 }, - { AUD_ERRINTRPTTHSHLD1_R, 0x00000FFF }, - { AUD_ERRINTRPTTHSHLD2_R, 0x0000001F }, - { AUD_ERRINTRPTTHSHLD3_R, 0x0000000F }, - - { AUD_PDF_DDS_CNST_BYTE2, 0x48 }, - { AUD_PDF_DDS_CNST_BYTE1, 0x3D }, - { AUD_QAM_MODE, 0x00 }, - { AUD_PDF_DDS_CNST_BYTE0, 0xf5 }, - { AUD_PHACC_FREQ_8MSB, 0x3a }, - { AUD_PHACC_FREQ_8LSB, 0x4a }, - - { AUD_DEEMPHGAIN_R, 0x6680 }, - { AUD_DEEMPHNUMER1_R, 0x353DE }, - { AUD_DEEMPHNUMER2_R, 0x1B1 }, - { AUD_DEEMPHDENOM1_R, 0x0F3D0 }, - { AUD_DEEMPHDENOM2_R, 0x0 }, - { AUD_FM_MODE_ENABLE, 0x7 }, - { AUD_POLYPH80SCALEFAC, 0x3 }, - { AUD_AFE_12DB_EN, 0x1 }, - { AAGC_GAIN, 0x0 }, - { AAGC_HYST, 0x18 }, - { AAGC_DEF, 0x20 }, - { AUD_DN0_FREQ, 0x0 }, - { AUD_POLY0_DDS_CONSTANT, 0x0E4DB2 }, - { AUD_DCOC_0_SRC, 0x21 }, - { AUD_IIR1_0_SEL, 0x0 }, - { AUD_IIR1_0_SHIFT, 0x7 }, - { AUD_IIR1_1_SEL, 0x2 }, - { AUD_IIR1_1_SHIFT, 0x0 }, - { AUD_DCOC_1_SRC, 0x3 }, - { AUD_DCOC1_SHIFT, 0x0 }, - { AUD_DCOC_PASS_IN, 0x0 }, - { AUD_IIR1_2_SEL, 0x23 }, - { AUD_IIR1_2_SHIFT, 0x0 }, - { AUD_IIR1_3_SEL, 0x4 }, - { AUD_IIR1_3_SHIFT, 0x7 }, - { AUD_IIR1_4_SEL, 0x5 }, - { AUD_IIR1_4_SHIFT, 0x7 }, - { AUD_IIR3_0_SEL, 0x7 }, - { AUD_IIR3_0_SHIFT, 0x0 }, - { AUD_DEEMPH0_SRC_SEL, 0x11 }, - { AUD_DEEMPH0_SHIFT, 0x0 }, - { AUD_DEEMPH0_G0, 0x7000 }, - { AUD_DEEMPH0_A0, 0x0 }, - { AUD_DEEMPH0_B0, 0x0 }, - { AUD_DEEMPH0_A1, 0x0 }, - { AUD_DEEMPH0_B1, 0x0 }, - { AUD_DEEMPH1_SRC_SEL, 0x11 }, - { AUD_DEEMPH1_SHIFT, 0x0 }, - { AUD_DEEMPH1_G0, 0x7000 }, - { AUD_DEEMPH1_A0, 0x0 }, - { AUD_DEEMPH1_B0, 0x0 }, - { AUD_DEEMPH1_A1, 0x0 }, - { AUD_DEEMPH1_B1, 0x0 }, - { AUD_OUT0_SEL, 0x3F }, - { AUD_OUT1_SEL, 0x3F }, - { AUD_DMD_RA_DDS, 0x0F5C285 }, - { AUD_PLL_INT, 0x1E }, - { AUD_PLL_DDS, 0x0 }, - { AUD_PLL_FRAC, 0x0E542 }, - - // setup QAM registers - { AUD_RATE_ADJ1, 0x00000100 }, - { AUD_RATE_ADJ2, 0x00000200 }, - { AUD_RATE_ADJ3, 0x00000300 }, - { AUD_RATE_ADJ4, 0x00000400 }, - { AUD_RATE_ADJ5, 0x00000500 }, - { AUD_RATE_THRES_DMD, 0x000000C0 }, - { /* end of list */ }, - }; - - static const struct rlist nicam_l[] = { - // setup QAM registers - { AUD_RATE_ADJ1, 0x00000060 }, - { AUD_RATE_ADJ2, 0x000000F9 }, - { AUD_RATE_ADJ3, 0x000001CC }, - { AUD_RATE_ADJ4, 0x000002B3 }, - { AUD_RATE_ADJ5, 0x00000726 }, - { AUD_DEEMPHDENOM1_R, 0x0000F3D0 }, - { AUD_DEEMPHDENOM2_R, 0x00000000 }, - { AUD_ERRLOGPERIOD_R, 0x00000064 }, - { AUD_ERRINTRPTTHSHLD1_R, 0x00000FFF }, - { AUD_ERRINTRPTTHSHLD2_R, 0x0000001F }, - { AUD_ERRINTRPTTHSHLD3_R, 0x0000000F }, - { AUD_POLYPH80SCALEFAC, 0x00000003 }, - { AUD_DMD_RA_DDS, 0x00C00000 }, - { AUD_PLL_INT, 0x0000001E }, - { AUD_PLL_DDS, 0x00000000 }, - { AUD_PLL_FRAC, 0x0000E542 }, - { AUD_START_TIMER, 0x00000000 }, - { AUD_DEEMPHNUMER1_R, 0x000353DE }, - { AUD_DEEMPHNUMER2_R, 0x000001B1 }, - { AUD_PDF_DDS_CNST_BYTE2, 0x06 }, - { AUD_PDF_DDS_CNST_BYTE1, 0x82 }, - { AUD_QAM_MODE, 0x05 }, - { AUD_PDF_DDS_CNST_BYTE0, 0x12 }, - { AUD_PHACC_FREQ_8MSB, 0x34 }, - { AUD_PHACC_FREQ_8LSB, 0x4C }, - { AUD_DEEMPHGAIN_R, 0x00006680 }, - { AUD_RATE_THRES_DMD, 0x000000C0 }, - { /* end of list */ }, - } ; - dprintk("%s (status: devel), stereo : %d\n",__FUNCTION__,stereo); - - if (!stereo) { - /* AM mono sound */ - set_audio_start(core, 0x0004, - 0x100c /* FIXME again */); - set_audio_registers(core, nicam_l_mono); - } else { - set_audio_start(core, 0x0010, - 0x1924 /* FIXME again */); - set_audio_registers(core, nicam_l); - } - set_audio_finish(core); + /* This is probably weird.. + * Let's operate and find out. */ + + static const struct rlist nicam_l_mono[] = { + { AUD_ERRLOGPERIOD_R, 0x00000064 }, + { AUD_ERRINTRPTTHSHLD1_R, 0x00000FFF }, + { AUD_ERRINTRPTTHSHLD2_R, 0x0000001F }, + { AUD_ERRINTRPTTHSHLD3_R, 0x0000000F }, + + { AUD_PDF_DDS_CNST_BYTE2, 0x48 }, + { AUD_PDF_DDS_CNST_BYTE1, 0x3D }, + { AUD_QAM_MODE, 0x00 }, + { AUD_PDF_DDS_CNST_BYTE0, 0xf5 }, + { AUD_PHACC_FREQ_8MSB, 0x3a }, + { AUD_PHACC_FREQ_8LSB, 0x4a }, + + { AUD_DEEMPHGAIN_R, 0x6680 }, + { AUD_DEEMPHNUMER1_R, 0x353DE }, + { AUD_DEEMPHNUMER2_R, 0x1B1 }, + { AUD_DEEMPHDENOM1_R, 0x0F3D0 }, + { AUD_DEEMPHDENOM2_R, 0x0 }, + { AUD_FM_MODE_ENABLE, 0x7 }, + { AUD_POLYPH80SCALEFAC, 0x3 }, + { AUD_AFE_12DB_EN, 0x1 }, + { AAGC_GAIN, 0x0 }, + { AAGC_HYST, 0x18 }, + { AAGC_DEF, 0x20 }, + { AUD_DN0_FREQ, 0x0 }, + { AUD_POLY0_DDS_CONSTANT, 0x0E4DB2 }, + { AUD_DCOC_0_SRC, 0x21 }, + { AUD_IIR1_0_SEL, 0x0 }, + { AUD_IIR1_0_SHIFT, 0x7 }, + { AUD_IIR1_1_SEL, 0x2 }, + { AUD_IIR1_1_SHIFT, 0x0 }, + { AUD_DCOC_1_SRC, 0x3 }, + { AUD_DCOC1_SHIFT, 0x0 }, + { AUD_DCOC_PASS_IN, 0x0 }, + { AUD_IIR1_2_SEL, 0x23 }, + { AUD_IIR1_2_SHIFT, 0x0 }, + { AUD_IIR1_3_SEL, 0x4 }, + { AUD_IIR1_3_SHIFT, 0x7 }, + { AUD_IIR1_4_SEL, 0x5 }, + { AUD_IIR1_4_SHIFT, 0x7 }, + { AUD_IIR3_0_SEL, 0x7 }, + { AUD_IIR3_0_SHIFT, 0x0 }, + { AUD_DEEMPH0_SRC_SEL, 0x11 }, + { AUD_DEEMPH0_SHIFT, 0x0 }, + { AUD_DEEMPH0_G0, 0x7000 }, + { AUD_DEEMPH0_A0, 0x0 }, + { AUD_DEEMPH0_B0, 0x0 }, + { AUD_DEEMPH0_A1, 0x0 }, + { AUD_DEEMPH0_B1, 0x0 }, + { AUD_DEEMPH1_SRC_SEL, 0x11 }, + { AUD_DEEMPH1_SHIFT, 0x0 }, + { AUD_DEEMPH1_G0, 0x7000 }, + { AUD_DEEMPH1_A0, 0x0 }, + { AUD_DEEMPH1_B0, 0x0 }, + { AUD_DEEMPH1_A1, 0x0 }, + { AUD_DEEMPH1_B1, 0x0 }, + { AUD_OUT0_SEL, 0x3F }, + { AUD_OUT1_SEL, 0x3F }, + { AUD_DMD_RA_DDS, 0x0F5C285 }, + { AUD_PLL_INT, 0x1E }, + { AUD_PLL_DDS, 0x0 }, + { AUD_PLL_FRAC, 0x0E542 }, + + // setup QAM registers + { AUD_RATE_ADJ1, 0x00000100 }, + { AUD_RATE_ADJ2, 0x00000200 }, + { AUD_RATE_ADJ3, 0x00000300 }, + { AUD_RATE_ADJ4, 0x00000400 }, + { AUD_RATE_ADJ5, 0x00000500 }, + { AUD_RATE_THRES_DMD, 0x000000C0 }, + { /* end of list */ }, + }; + static const struct rlist nicam_l[] = { + // setup QAM registers + { AUD_RATE_ADJ1, 0x00000060 }, + { AUD_RATE_ADJ2, 0x000000F9 }, + { AUD_RATE_ADJ3, 0x000001CC }, + { AUD_RATE_ADJ4, 0x000002B3 }, + { AUD_RATE_ADJ5, 0x00000726 }, + { AUD_DEEMPHDENOM1_R, 0x0000F3D0 }, + { AUD_DEEMPHDENOM2_R, 0x00000000 }, + { AUD_ERRLOGPERIOD_R, 0x00000064 }, + { AUD_ERRINTRPTTHSHLD1_R, 0x00000FFF }, + { AUD_ERRINTRPTTHSHLD2_R, 0x0000001F }, + { AUD_ERRINTRPTTHSHLD3_R, 0x0000000F }, + { AUD_POLYPH80SCALEFAC, 0x00000003 }, + { AUD_DMD_RA_DDS, 0x00C00000 }, + { AUD_PLL_INT, 0x0000001E }, + { AUD_PLL_DDS, 0x00000000 }, + { AUD_PLL_FRAC, 0x0000E542 }, + { AUD_START_TIMER, 0x00000000 }, + { AUD_DEEMPHNUMER1_R, 0x000353DE }, + { AUD_DEEMPHNUMER2_R, 0x000001B1 }, + { AUD_PDF_DDS_CNST_BYTE2, 0x06 }, + { AUD_PDF_DDS_CNST_BYTE1, 0x82 }, + { AUD_QAM_MODE, 0x05 }, + { AUD_PDF_DDS_CNST_BYTE0, 0x12 }, + { AUD_PHACC_FREQ_8MSB, 0x34 }, + { AUD_PHACC_FREQ_8LSB, 0x4C }, + { AUD_DEEMPHGAIN_R, 0x00006680 }, + { AUD_RATE_THRES_DMD, 0x000000C0 }, + { /* end of list */ }, + } ; + dprintk("%s (status: devel), stereo : %d\n",__FUNCTION__,stereo); + + if (!stereo) { + /* AM Mono */ + set_audio_start(core, SEL_A2); + set_audio_registers(core, nicam_l_mono); + set_audio_finish(core, EN_A2_FORCE_MONO1); + } else { + /* Nicam Stereo */ + set_audio_start(core, SEL_NICAM); + set_audio_registers(core, nicam_l); + set_audio_finish(core, 0x1924); /* FIXME */ + } } static void set_audio_standard_PAL_I(struct cx88_core *core, int stereo) { static const struct rlist pal_i_fm_mono[] = { - {AUD_ERRLOGPERIOD_R, 0x00000064}, - {AUD_ERRINTRPTTHSHLD1_R, 0x00000fff}, - {AUD_ERRINTRPTTHSHLD2_R, 0x0000001f}, - {AUD_ERRINTRPTTHSHLD3_R, 0x0000000f}, - {AUD_PDF_DDS_CNST_BYTE2, 0x06}, - {AUD_PDF_DDS_CNST_BYTE1, 0x82}, - {AUD_PDF_DDS_CNST_BYTE0, 0x12}, - {AUD_QAM_MODE, 0x05}, - {AUD_PHACC_FREQ_8MSB, 0x3a}, - {AUD_PHACC_FREQ_8LSB, 0x93}, - {AUD_DMD_RA_DDS, 0x002a4f2f}, - {AUD_PLL_INT, 0x0000001e}, - {AUD_PLL_DDS, 0x00000004}, - {AUD_PLL_FRAC, 0x0000e542}, - {AUD_RATE_ADJ1, 0x00000100}, - {AUD_RATE_ADJ2, 0x00000200}, - {AUD_RATE_ADJ3, 0x00000300}, - {AUD_RATE_ADJ4, 0x00000400}, - {AUD_RATE_ADJ5, 0x00000500}, - {AUD_THR_FR, 0x00000000}, - {AUD_PILOT_BQD_1_K0, 0x0000755b}, - {AUD_PILOT_BQD_1_K1, 0x00551340}, - {AUD_PILOT_BQD_1_K2, 0x006d30be}, - {AUD_PILOT_BQD_1_K3, 0xffd394af}, - {AUD_PILOT_BQD_1_K4, 0x00400000}, - {AUD_PILOT_BQD_2_K0, 0x00040000}, - {AUD_PILOT_BQD_2_K1, 0x002a4841}, - {AUD_PILOT_BQD_2_K2, 0x00400000}, - {AUD_PILOT_BQD_2_K3, 0x00000000}, - {AUD_PILOT_BQD_2_K4, 0x00000000}, - {AUD_MODE_CHG_TIMER, 0x00000060}, - {AUD_AFE_12DB_EN, 0x00000001}, - {AAGC_HYST, 0x0000000a}, - {AUD_CORDIC_SHIFT_0, 0x00000007}, - {AUD_CORDIC_SHIFT_1, 0x00000007}, - {AUD_C1_UP_THR, 0x00007000}, - {AUD_C1_LO_THR, 0x00005400}, - {AUD_C2_UP_THR, 0x00005400}, - {AUD_C2_LO_THR, 0x00003000}, - {AUD_DCOC_0_SRC, 0x0000001a}, - {AUD_DCOC0_SHIFT, 0x00000000}, - {AUD_DCOC_0_SHIFT_IN0, 0x0000000a}, - {AUD_DCOC_0_SHIFT_IN1, 0x00000008}, - {AUD_DCOC_PASS_IN, 0x00000003}, - {AUD_IIR3_0_SEL, 0x00000021}, - {AUD_DN2_AFC, 0x00000002}, - {AUD_DCOC_1_SRC, 0x0000001b}, - {AUD_DCOC1_SHIFT, 0x00000000}, - {AUD_DCOC_1_SHIFT_IN0, 0x0000000a}, - {AUD_DCOC_1_SHIFT_IN1, 0x00000008}, - {AUD_IIR3_1_SEL, 0x00000023}, - {AUD_DN0_FREQ, 0x000035a3}, - {AUD_DN2_FREQ, 0x000029c7}, - {AUD_CRDC0_SRC_SEL, 0x00000511}, - {AUD_IIR1_0_SEL, 0x00000001}, - {AUD_IIR1_1_SEL, 0x00000000}, - {AUD_IIR3_2_SEL, 0x00000003}, - {AUD_IIR3_2_SHIFT, 0x00000000}, - {AUD_IIR3_0_SEL, 0x00000002}, - {AUD_IIR2_0_SEL, 0x00000021}, - {AUD_IIR2_0_SHIFT, 0x00000002}, - {AUD_DEEMPH0_SRC_SEL, 0x0000000b}, - {AUD_DEEMPH1_SRC_SEL, 0x0000000b}, - {AUD_POLYPH80SCALEFAC, 0x00000001}, - {AUD_START_TIMER, 0x00000000}, - { /* end of list */ }, + {AUD_ERRLOGPERIOD_R, 0x00000064}, + {AUD_ERRINTRPTTHSHLD1_R, 0x00000fff}, + {AUD_ERRINTRPTTHSHLD2_R, 0x0000001f}, + {AUD_ERRINTRPTTHSHLD3_R, 0x0000000f}, + {AUD_PDF_DDS_CNST_BYTE2, 0x06}, + {AUD_PDF_DDS_CNST_BYTE1, 0x82}, + {AUD_PDF_DDS_CNST_BYTE0, 0x12}, + {AUD_QAM_MODE, 0x05}, + {AUD_PHACC_FREQ_8MSB, 0x3a}, + {AUD_PHACC_FREQ_8LSB, 0x93}, + {AUD_DMD_RA_DDS, 0x002a4f2f}, + {AUD_PLL_INT, 0x0000001e}, + {AUD_PLL_DDS, 0x00000004}, + {AUD_PLL_FRAC, 0x0000e542}, + {AUD_RATE_ADJ1, 0x00000100}, + {AUD_RATE_ADJ2, 0x00000200}, + {AUD_RATE_ADJ3, 0x00000300}, + {AUD_RATE_ADJ4, 0x00000400}, + {AUD_RATE_ADJ5, 0x00000500}, + {AUD_THR_FR, 0x00000000}, + {AUD_PILOT_BQD_1_K0, 0x0000755b}, + {AUD_PILOT_BQD_1_K1, 0x00551340}, + {AUD_PILOT_BQD_1_K2, 0x006d30be}, + {AUD_PILOT_BQD_1_K3, 0xffd394af}, + {AUD_PILOT_BQD_1_K4, 0x00400000}, + {AUD_PILOT_BQD_2_K0, 0x00040000}, + {AUD_PILOT_BQD_2_K1, 0x002a4841}, + {AUD_PILOT_BQD_2_K2, 0x00400000}, + {AUD_PILOT_BQD_2_K3, 0x00000000}, + {AUD_PILOT_BQD_2_K4, 0x00000000}, + {AUD_MODE_CHG_TIMER, 0x00000060}, + {AUD_AFE_12DB_EN, 0x00000001}, + {AAGC_HYST, 0x0000000a}, + {AUD_CORDIC_SHIFT_0, 0x00000007}, + {AUD_CORDIC_SHIFT_1, 0x00000007}, + {AUD_C1_UP_THR, 0x00007000}, + {AUD_C1_LO_THR, 0x00005400}, + {AUD_C2_UP_THR, 0x00005400}, + {AUD_C2_LO_THR, 0x00003000}, + {AUD_DCOC_0_SRC, 0x0000001a}, + {AUD_DCOC0_SHIFT, 0x00000000}, + {AUD_DCOC_0_SHIFT_IN0, 0x0000000a}, + {AUD_DCOC_0_SHIFT_IN1, 0x00000008}, + {AUD_DCOC_PASS_IN, 0x00000003}, + {AUD_IIR3_0_SEL, 0x00000021}, + {AUD_DN2_AFC, 0x00000002}, + {AUD_DCOC_1_SRC, 0x0000001b}, + {AUD_DCOC1_SHIFT, 0x00000000}, + {AUD_DCOC_1_SHIFT_IN0, 0x0000000a}, + {AUD_DCOC_1_SHIFT_IN1, 0x00000008}, + {AUD_IIR3_1_SEL, 0x00000023}, + {AUD_DN0_FREQ, 0x000035a3}, + {AUD_DN2_FREQ, 0x000029c7}, + {AUD_CRDC0_SRC_SEL, 0x00000511}, + {AUD_IIR1_0_SEL, 0x00000001}, + {AUD_IIR1_1_SEL, 0x00000000}, + {AUD_IIR3_2_SEL, 0x00000003}, + {AUD_IIR3_2_SHIFT, 0x00000000}, + {AUD_IIR3_0_SEL, 0x00000002}, + {AUD_IIR2_0_SEL, 0x00000021}, + {AUD_IIR2_0_SHIFT, 0x00000002}, + {AUD_DEEMPH0_SRC_SEL, 0x0000000b}, + {AUD_DEEMPH1_SRC_SEL, 0x0000000b}, + {AUD_POLYPH80SCALEFAC, 0x00000001}, + {AUD_START_TIMER, 0x00000000}, + { /* end of list */ }, }; static const struct rlist pal_i_nicam[] = { - { AUD_RATE_ADJ1, 0x00000010 }, - { AUD_RATE_ADJ2, 0x00000040 }, - { AUD_RATE_ADJ3, 0x00000100 }, - { AUD_RATE_ADJ4, 0x00000400 }, - { AUD_RATE_ADJ5, 0x00001000 }, - // { AUD_DMD_RA_DDS, 0x00c0d5ce }, - { AUD_DEEMPHGAIN_R, 0x000023c2 }, - { AUD_DEEMPHNUMER1_R, 0x0002a7bc }, - { AUD_DEEMPHNUMER2_R, 0x0003023e }, - { AUD_DEEMPHDENOM1_R, 0x0000f3d0 }, - { AUD_DEEMPHDENOM2_R, 0x00000000 }, - { AUD_DEEMPHDENOM2_R, 0x00000000 }, - { AUD_ERRLOGPERIOD_R, 0x00000fff }, - { AUD_ERRINTRPTTHSHLD1_R, 0x000003ff }, - { AUD_ERRINTRPTTHSHLD2_R, 0x000000ff }, - { AUD_ERRINTRPTTHSHLD3_R, 0x0000003f }, - { AUD_POLYPH80SCALEFAC, 0x00000003 }, - { AUD_PDF_DDS_CNST_BYTE2, 0x06 }, - { AUD_PDF_DDS_CNST_BYTE1, 0x82 }, - { AUD_PDF_DDS_CNST_BYTE0, 0x16 }, - { AUD_QAM_MODE, 0x05 }, - { AUD_PDF_DDS_CNST_BYTE0, 0x12 }, - { AUD_PHACC_FREQ_8MSB, 0x3a }, - { AUD_PHACC_FREQ_8LSB, 0x93 }, - { /* end of list */ }, - }; - - dprintk("%s (status: devel), stereo : %d\n",__FUNCTION__,stereo); - - if (!stereo) { - // FM mono - set_audio_start(core, 0x0004, EN_DMTRX_SUMDIFF | EN_A2_FORCE_MONO1); + { AUD_RATE_ADJ1, 0x00000010 }, + { AUD_RATE_ADJ2, 0x00000040 }, + { AUD_RATE_ADJ3, 0x00000100 }, + { AUD_RATE_ADJ4, 0x00000400 }, + { AUD_RATE_ADJ5, 0x00001000 }, + // { AUD_DMD_RA_DDS, 0x00c0d5ce }, + { AUD_DEEMPHGAIN_R, 0x000023c2 }, + { AUD_DEEMPHNUMER1_R, 0x0002a7bc }, + { AUD_DEEMPHNUMER2_R, 0x0003023e }, + { AUD_DEEMPHDENOM1_R, 0x0000f3d0 }, + { AUD_DEEMPHDENOM2_R, 0x00000000 }, + { AUD_DEEMPHDENOM2_R, 0x00000000 }, + { AUD_ERRLOGPERIOD_R, 0x00000fff }, + { AUD_ERRINTRPTTHSHLD1_R, 0x000003ff }, + { AUD_ERRINTRPTTHSHLD2_R, 0x000000ff }, + { AUD_ERRINTRPTTHSHLD3_R, 0x0000003f }, + { AUD_POLYPH80SCALEFAC, 0x00000003 }, + { AUD_PDF_DDS_CNST_BYTE2, 0x06 }, + { AUD_PDF_DDS_CNST_BYTE1, 0x82 }, + { AUD_PDF_DDS_CNST_BYTE0, 0x16 }, + { AUD_QAM_MODE, 0x05 }, + { AUD_PDF_DDS_CNST_BYTE0, 0x12 }, + { AUD_PHACC_FREQ_8MSB, 0x3a }, + { AUD_PHACC_FREQ_8LSB, 0x93 }, + { /* end of list */ }, + }; + + dprintk("%s (status: devel), stereo : %d\n",__FUNCTION__,stereo); + + if (!stereo) { + /* FM Mono */ + set_audio_start(core, SEL_A2); set_audio_registers(core, pal_i_fm_mono); - } else { - // Nicam Stereo - set_audio_start(core, 0x0010, EN_DMTRX_LR | EN_DMTRX_BYPASS | EN_NICAM_AUTO_STEREO); + set_audio_finish(core, EN_DMTRX_SUMDIFF | EN_A2_FORCE_MONO1); + } else { + /* Nicam Stereo */ + set_audio_start(core, SEL_NICAM); set_audio_registers(core, pal_i_nicam); - } - set_audio_finish(core); + set_audio_finish(core, EN_DMTRX_LR | EN_DMTRX_BYPASS | EN_NICAM_AUTO_STEREO); + } } -static void set_audio_standard_A2(struct cx88_core *core) +static void set_audio_standard_A2(struct cx88_core *core, u32 mode) { - /* from dscaler cvs */ static const struct rlist a2_common[] = { - { AUD_PDF_DDS_CNST_BYTE2, 0x06 }, - { AUD_PDF_DDS_CNST_BYTE1, 0x82 }, - { AUD_PDF_DDS_CNST_BYTE0, 0x12 }, - { AUD_QAM_MODE, 0x05 }, - { AUD_PHACC_FREQ_8MSB, 0x34 }, - { AUD_PHACC_FREQ_8LSB, 0x4c }, - - { AUD_RATE_ADJ1, 0x00001000 }, - { AUD_RATE_ADJ2, 0x00002000 }, - { AUD_RATE_ADJ3, 0x00003000 }, - { AUD_RATE_ADJ4, 0x00004000 }, - { AUD_RATE_ADJ5, 0x00005000 }, - { AUD_THR_FR, 0x00000000 }, - { AAGC_HYST, 0x0000001a }, - { AUD_PILOT_BQD_1_K0, 0x0000755b }, - { AUD_PILOT_BQD_1_K1, 0x00551340 }, - { AUD_PILOT_BQD_1_K2, 0x006d30be }, - { AUD_PILOT_BQD_1_K3, 0xffd394af }, - { AUD_PILOT_BQD_1_K4, 0x00400000 }, - { AUD_PILOT_BQD_2_K0, 0x00040000 }, - { AUD_PILOT_BQD_2_K1, 0x002a4841 }, - { AUD_PILOT_BQD_2_K2, 0x00400000 }, - { AUD_PILOT_BQD_2_K3, 0x00000000 }, - { AUD_PILOT_BQD_2_K4, 0x00000000 }, - { AUD_MODE_CHG_TIMER, 0x00000040 }, - { AUD_START_TIMER, 0x00000200 }, - { AUD_AFE_12DB_EN, 0x00000000 }, - { AUD_CORDIC_SHIFT_0, 0x00000007 }, - { AUD_CORDIC_SHIFT_1, 0x00000007 }, - { AUD_DEEMPH0_G0, 0x00000380 }, - { AUD_DEEMPH1_G0, 0x00000380 }, - { AUD_DCOC_0_SRC, 0x0000001a }, - { AUD_DCOC0_SHIFT, 0x00000000 }, - { AUD_DCOC_0_SHIFT_IN0, 0x0000000a }, - { AUD_DCOC_0_SHIFT_IN1, 0x00000008 }, - { AUD_DCOC_PASS_IN, 0x00000003 }, - { AUD_IIR3_0_SEL, 0x00000021 }, - { AUD_DN2_AFC, 0x00000002 }, - { AUD_DCOC_1_SRC, 0x0000001b }, - { AUD_DCOC1_SHIFT, 0x00000000 }, - { AUD_DCOC_1_SHIFT_IN0, 0x0000000a }, - { AUD_DCOC_1_SHIFT_IN1, 0x00000008 }, - { AUD_IIR3_1_SEL, 0x00000023 }, - { AUD_RDSI_SEL, 0x00000017 }, - { AUD_RDSI_SHIFT, 0x00000000 }, - { AUD_RDSQ_SEL, 0x00000017 }, - { AUD_RDSQ_SHIFT, 0x00000000 }, - { AUD_POLYPH80SCALEFAC, 0x00000001 }, + {AUD_ERRLOGPERIOD_R, 0x00000064}, + {AUD_ERRINTRPTTHSHLD1_R, 0x00000fff}, + {AUD_ERRINTRPTTHSHLD2_R, 0x0000001f}, + {AUD_ERRINTRPTTHSHLD3_R, 0x0000000f}, + {AUD_PDF_DDS_CNST_BYTE2, 0x06}, + {AUD_PDF_DDS_CNST_BYTE1, 0x82}, + {AUD_PDF_DDS_CNST_BYTE0, 0x12}, + {AUD_QAM_MODE, 0x05}, + {AUD_PHACC_FREQ_8MSB, 0x34}, + {AUD_PHACC_FREQ_8LSB, 0x4c}, + {AUD_RATE_ADJ1, 0x00000100}, + {AUD_RATE_ADJ2, 0x00000200}, + {AUD_RATE_ADJ3, 0x00000300}, + {AUD_RATE_ADJ4, 0x00000400}, + {AUD_RATE_ADJ5, 0x00000500}, + {AUD_THR_FR, 0x00000000}, + {AAGC_HYST, 0x0000001a}, + {AUD_PILOT_BQD_1_K0, 0x0000755b}, + {AUD_PILOT_BQD_1_K1, 0x00551340}, + {AUD_PILOT_BQD_1_K2, 0x006d30be}, + {AUD_PILOT_BQD_1_K3, 0xffd394af}, + {AUD_PILOT_BQD_1_K4, 0x00400000}, + {AUD_PILOT_BQD_2_K0, 0x00040000}, + {AUD_PILOT_BQD_2_K1, 0x002a4841}, + {AUD_PILOT_BQD_2_K2, 0x00400000}, + {AUD_PILOT_BQD_2_K3, 0x00000000}, + {AUD_PILOT_BQD_2_K4, 0x00000000}, + {AUD_MODE_CHG_TIMER, 0x00000040}, + {AUD_AFE_12DB_EN, 0x00000001}, + {AUD_CORDIC_SHIFT_0, 0x00000007}, + {AUD_CORDIC_SHIFT_1, 0x00000007}, + {AUD_DEEMPH0_G0, 0x00000380}, + {AUD_DEEMPH1_G0, 0x00000380}, + {AUD_DCOC_0_SRC, 0x0000001a}, + {AUD_DCOC0_SHIFT, 0x00000000}, + {AUD_DCOC_0_SHIFT_IN0, 0x0000000a}, + {AUD_DCOC_0_SHIFT_IN1, 0x00000008}, + {AUD_DCOC_PASS_IN, 0x00000003}, + {AUD_IIR3_0_SEL, 0x00000021}, + {AUD_DN2_AFC, 0x00000002}, + {AUD_DCOC_1_SRC, 0x0000001b}, + {AUD_DCOC1_SHIFT, 0x00000000}, + {AUD_DCOC_1_SHIFT_IN0, 0x0000000a}, + {AUD_DCOC_1_SHIFT_IN1, 0x00000008}, + {AUD_IIR3_1_SEL, 0x00000023}, + {AUD_RDSI_SEL, 0x00000017}, + {AUD_RDSI_SHIFT, 0x00000000}, + {AUD_RDSQ_SEL, 0x00000017}, + {AUD_RDSQ_SHIFT, 0x00000000}, + {AUD_PLL_INT, 0x0000001e}, + {AUD_PLL_DDS, 0x00000000}, + {AUD_PLL_FRAC, 0x0000e542}, + {AUD_POLYPH80SCALEFAC, 0x00000001}, + {AUD_START_TIMER, 0x00000000}, + { /* end of list */ }, + }; + static const struct rlist a2_bg[] = { + {AUD_DMD_RA_DDS, 0x002a4f2f}, + {AUD_C1_UP_THR, 0x00007000}, + {AUD_C1_LO_THR, 0x00005400}, + {AUD_C2_UP_THR, 0x00005400}, + {AUD_C2_LO_THR, 0x00003000}, { /* end of list */ }, }; - static const struct rlist a2_table1[] = { - // PAL-BG - { AUD_DMD_RA_DDS, 0x002a73bd }, - { AUD_C1_UP_THR, 0x00007000 }, - { AUD_C1_LO_THR, 0x00005400 }, - { AUD_C2_UP_THR, 0x00005400 }, - { AUD_C2_LO_THR, 0x00003000 }, + static const struct rlist a2_dk[] = { + {AUD_DMD_RA_DDS, 0x002a4f2f}, + {AUD_C1_UP_THR, 0x00007000}, + {AUD_C1_LO_THR, 0x00005400}, + {AUD_C2_UP_THR, 0x00005400}, + {AUD_C2_LO_THR, 0x00003000}, + {AUD_DN0_FREQ, 0x00003a1c}, + {AUD_DN2_FREQ, 0x0000d2e0}, { /* end of list */ }, }; - static const struct rlist a2_table2[] = { - // PAL-DK - { AUD_DMD_RA_DDS, 0x002a73bd }, - { AUD_C1_UP_THR, 0x00007000 }, - { AUD_C1_LO_THR, 0x00005400 }, - { AUD_C2_UP_THR, 0x00005400 }, - { AUD_C2_LO_THR, 0x00003000 }, - { AUD_DN0_FREQ, 0x00003a1c }, - { AUD_DN2_FREQ, 0x0000d2e0 }, +/* unknown, probably NTSC-M */ + static const struct rlist a2_m[] = { + {AUD_DMD_RA_DDS, 0x002a0425}, + {AUD_C1_UP_THR, 0x00003c00}, + {AUD_C1_LO_THR, 0x00003000}, + {AUD_C2_UP_THR, 0x00006000}, + {AUD_C2_LO_THR, 0x00003c00}, + {AUD_DEEMPH0_A0, 0x00007a80}, + {AUD_DEEMPH1_A0, 0x00007a80}, + {AUD_DEEMPH0_G0, 0x00001200}, + {AUD_DEEMPH1_G0, 0x00001200}, + {AUD_DN0_FREQ, 0x0000283b}, + {AUD_DN1_FREQ, 0x00003418}, + {AUD_DN2_FREQ, 0x000029c7}, + {AUD_POLY0_DDS_CONSTANT, 0x000a7540}, { /* end of list */ }, }; - static const struct rlist a2_table3[] = { - // unknown, probably NTSC-M - { AUD_DMD_RA_DDS, 0x002a2873 }, - { AUD_C1_UP_THR, 0x00003c00 }, - { AUD_C1_LO_THR, 0x00003000 }, - { AUD_C2_UP_THR, 0x00006000 }, - { AUD_C2_LO_THR, 0x00003c00 }, - { AUD_DN0_FREQ, 0x00002836 }, - { AUD_DN1_FREQ, 0x00003418 }, - { AUD_DN2_FREQ, 0x000029c7 }, - { AUD_POLY0_DDS_CONSTANT, 0x000a7540 }, + + static const struct rlist a2_deemph50[] = { + {AUD_DEEMPH0_G0, 0x00000380}, + {AUD_DEEMPH1_G0, 0x00000380}, + {AUD_DEEMPHGAIN_R, 0x000011e1}, + {AUD_DEEMPHNUMER1_R, 0x0002a7bc}, + {AUD_DEEMPHNUMER2_R, 0x0003023c}, + { /* end of list */ }, + }; + + static const struct rlist a2_deemph75[] = { + {AUD_DEEMPH0_G0, 0x00000480}, + {AUD_DEEMPH1_G0, 0x00000480}, + {AUD_DEEMPHGAIN_R, 0x00009000}, + {AUD_DEEMPHNUMER1_R, 0x000353de}, + {AUD_DEEMPHNUMER2_R, 0x000001b1}, { /* end of list */ }, }; - set_audio_start(core, 0x0004, EN_DMTRX_SUMDIFF | EN_A2_AUTO_STEREO); + set_audio_start(core, SEL_A2); set_audio_registers(core, a2_common); switch (core->tvaudio) { case WW_A2_BG: dprintk("%s PAL-BG A2 (status: known-good)\n",__FUNCTION__); - set_audio_registers(core, a2_table1); + set_audio_registers(core, a2_bg); + set_audio_registers(core, a2_deemph50); break; case WW_A2_DK: dprintk("%s PAL-DK A2 (status: known-good)\n",__FUNCTION__); - set_audio_registers(core, a2_table2); + set_audio_registers(core, a2_dk); + set_audio_registers(core, a2_deemph50); break; case WW_A2_M: dprintk("%s NTSC-M A2 (status: unknown)\n",__FUNCTION__); - set_audio_registers(core, a2_table3); + set_audio_registers(core, a2_m); + set_audio_registers(core, a2_deemph75); break; }; - set_audio_finish(core); + + mode |= EN_FMRADIO_EN_RDS | EN_DMTRX_SUMDIFF; + set_audio_finish(core, mode); } static void set_audio_standard_EIAJ(struct cx88_core *core) @@ -635,9 +658,9 @@ static void set_audio_standard_EIAJ(struct cx88_core *core) }; dprintk("%s (status: unknown)\n",__FUNCTION__); - set_audio_start(core, 0x0002, EN_EIAJ_AUTO_STEREO); + set_audio_start(core, SEL_EIAJ); set_audio_registers(core, eiaj); - set_audio_finish(core); + set_audio_finish(core, EN_EIAJ_AUTO_STEREO); } static void set_audio_standard_FM(struct cx88_core *core, enum cx88_deemph_type deemph) @@ -683,7 +706,7 @@ static void set_audio_standard_FM(struct cx88_core *core, enum cx88_deemph_type }; dprintk("%s (status: unknown)\n",__FUNCTION__); - set_audio_start(core, 0x0020, EN_FMRADIO_AUTO_STEREO); + set_audio_start(core, SEL_FMRADIO); switch (deemph) { @@ -700,7 +723,7 @@ static void set_audio_standard_FM(struct cx88_core *core, enum cx88_deemph_type break; } - set_audio_finish(core); + set_audio_finish(core, EN_FMRADIO_AUTO_STEREO); } /* ----------------------------------------------------------- */ @@ -709,7 +732,7 @@ void cx88_set_tvaudio(struct cx88_core *core) { switch (core->tvaudio) { case WW_BTSC: - set_audio_standard_BTSC(core,0); + set_audio_standard_BTSC(core, 0, EN_BTSC_AUTO_STEREO); break; case WW_NICAM_BGDKL: set_audio_standard_NICAM_L(core,0); @@ -720,7 +743,7 @@ void cx88_set_tvaudio(struct cx88_core *core) case WW_A2_BG: case WW_A2_DK: case WW_A2_M: - set_audio_standard_A2(core); + set_audio_standard_A2(core, EN_A2_FORCE_MONO1); break; case WW_EIAJ: set_audio_standard_EIAJ(core); @@ -734,7 +757,7 @@ void cx88_set_tvaudio(struct cx88_core *core) case WW_NONE: default: printk("%s/0: unknown tv audio mode [%d]\n", - core->name, core->tvaudio); + core->name, core->tvaudio); break; } return; @@ -769,6 +792,13 @@ void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t) aud_ctl_names[cx_read(AUD_CTL) & 63]); core->astat = reg; +/* TODO + Reading from AUD_STATUS is not enough + for auto-detecting sap/dual-fm/nicam. + Add some code here later. +*/ + +# if 0 t->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_SAP | V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2; t->rxsubchans = V4L2_TUNER_SUB_MONO; @@ -779,7 +809,7 @@ void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t) t->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_SAP; t->rxsubchans = V4L2_TUNER_SUB_STEREO; - if (1 == pilot) { + if (1 == pilot) { /* SAP */ t->rxsubchans |= V4L2_TUNER_SUB_SAP; } @@ -787,13 +817,13 @@ void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t) case WW_A2_BG: case WW_A2_DK: case WW_A2_M: - if (1 == pilot) { + if (1 == pilot) { /* stereo */ t->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; if (0 == mode) t->audmode = V4L2_TUNER_MODE_STEREO; } - if (2 == pilot) { + if (2 == pilot) { /* dual language -- FIXME */ t->rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; t->audmode = V4L2_TUNER_MODE_LANG1; @@ -805,16 +835,17 @@ void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t) t->rxsubchans |= V4L2_TUNER_SUB_STEREO; } break; - case WW_SYSTEM_L_AM: - if (0x0 == mode && !(cx_read(AUD_INIT) & 0x04)) { - t->audmode = V4L2_TUNER_MODE_STEREO; + case WW_SYSTEM_L_AM: + if (0x0 == mode && !(cx_read(AUD_INIT) & 0x04)) { + t->audmode = V4L2_TUNER_MODE_STEREO; t->rxsubchans |= V4L2_TUNER_SUB_STEREO; } - break ; + break ; default: /* nothing */ break; } +# endif return; } @@ -835,16 +866,16 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual) case WW_BTSC: switch (mode) { case V4L2_TUNER_MODE_MONO: - ctl = EN_BTSC_FORCE_MONO; - mask = 0x3f; + set_audio_standard_BTSC(core, 0, EN_BTSC_FORCE_MONO); break; - case V4L2_TUNER_MODE_SAP: - ctl = EN_BTSC_FORCE_SAP; - mask = 0x3f; + case V4L2_TUNER_MODE_LANG1: + set_audio_standard_BTSC(core, 0, EN_BTSC_AUTO_STEREO); + break; + case V4L2_TUNER_MODE_LANG2: + set_audio_standard_BTSC(core, 1, EN_BTSC_FORCE_SAP); break; case V4L2_TUNER_MODE_STEREO: - ctl = EN_BTSC_AUTO_STEREO; - mask = 0x3f; + set_audio_standard_BTSC(core, 0, EN_BTSC_FORCE_STEREO); break; } break; @@ -854,16 +885,13 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual) switch (mode) { case V4L2_TUNER_MODE_MONO: case V4L2_TUNER_MODE_LANG1: - ctl = EN_A2_FORCE_MONO1; - mask = 0x3f; + set_audio_standard_A2(core, EN_A2_FORCE_MONO1); break; case V4L2_TUNER_MODE_LANG2: - ctl = EN_A2_AUTO_MONO2; - mask = 0x3f; + set_audio_standard_A2(core, EN_A2_FORCE_MONO2); break; case V4L2_TUNER_MODE_STEREO: - ctl = EN_A2_AUTO_STEREO | EN_DMTRX_SUMR; - mask = 0x8bf; + set_audio_standard_A2(core, EN_A2_FORCE_STEREO); break; } break; diff --git a/drivers/media/video/cx88/cx88-vbi.c b/drivers/media/video/cx88/cx88-vbi.c index 320d57888bb..9bc6c899558 100644 --- a/drivers/media/video/cx88/cx88-vbi.c +++ b/drivers/media/video/cx88/cx88-vbi.c @@ -1,5 +1,4 @@ /* - * $Id: cx88-vbi.c,v 1.17 2005/06/12 04:19:19 mchehab Exp $ */ #include <linux/kernel.h> #include <linux/module.h> diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c index 5f58c103198..3dbc074fb51 100644 --- a/drivers/media/video/cx88/cx88-video.c +++ b/drivers/media/video/cx88/cx88-video.c @@ -1,5 +1,4 @@ /* - * $Id: cx88-video.c,v 1.82 2005/07/22 05:13:34 mkrufky Exp $ * * device driver for Conexant 2388x based TV cards * video4linux video interface @@ -66,7 +65,7 @@ module_param(vid_limit,int,0644); MODULE_PARM_DESC(vid_limit,"capture memory limit in megabytes"); #define dprintk(level,fmt, arg...) if (video_debug >= level) \ - printk(KERN_DEBUG "%s/0: " fmt, dev->core->name , ## arg) + printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg) /* ------------------------------------------------------------------ */ @@ -326,22 +325,23 @@ static const int CX8800_CTLS = ARRAY_SIZE(cx8800_ctls); static int res_get(struct cx8800_dev *dev, struct cx8800_fh *fh, unsigned int bit) { + struct cx88_core *core = dev->core; if (fh->resources & bit) /* have it already allocated */ return 1; /* is it free? */ - down(&dev->lock); + down(&core->lock); if (dev->resources & bit) { /* no, someone else uses it */ - up(&dev->lock); + up(&core->lock); return 0; } /* it's free, grab it */ fh->resources |= bit; dev->resources |= bit; dprintk(1,"res: get %d\n",bit); - up(&dev->lock); + up(&core->lock); return 1; } @@ -360,27 +360,29 @@ int res_locked(struct cx8800_dev *dev, unsigned int bit) static void res_free(struct cx8800_dev *dev, struct cx8800_fh *fh, unsigned int bits) { + struct cx88_core *core = dev->core; if ((fh->resources & bits) != bits) BUG(); - down(&dev->lock); + down(&core->lock); fh->resources &= ~bits; dev->resources &= ~bits; dprintk(1,"res: put %d\n",bits); - up(&dev->lock); + up(&core->lock); } /* ------------------------------------------------------------------ */ -static int video_mux(struct cx8800_dev *dev, unsigned int input) +/* static int video_mux(struct cx8800_dev *dev, unsigned int input) */ +static int video_mux(struct cx88_core *core, unsigned int input) { - struct cx88_core *core = dev->core; + /* struct cx88_core *core = dev->core; */ dprintk(1,"video_mux: %d [vmux=%d,gpio=0x%x,0x%x,0x%x,0x%x]\n", input, INPUT(input)->vmux, INPUT(input)->gpio0,INPUT(input)->gpio1, INPUT(input)->gpio2,INPUT(input)->gpio3); - dev->core->input = input; + core->input = input; cx_andor(MO_INPUT_FORMAT, 0x03 << 14, INPUT(input)->vmux << 14); cx_write(MO_GP3_IO, INPUT(input)->gpio3); cx_write(MO_GP0_IO, INPUT(input)->gpio0); @@ -413,9 +415,9 @@ static int start_video_dma(struct cx8800_dev *dev, struct cx88_core *core = dev->core; /* setup fifo + format */ - cx88_sram_channel_setup(dev->core, &cx88_sram_channels[SRAM_CH21], + cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH21], buf->bpl, buf->risc.dma); - cx88_set_scale(dev->core, buf->vb.width, buf->vb.height, buf->vb.field); + cx88_set_scale(core, buf->vb.width, buf->vb.height, buf->vb.field); cx_write(MO_COLOR_CTRL, buf->fmt->cxformat | ColorFormatGamma); /* reset counter */ @@ -424,6 +426,14 @@ static int start_video_dma(struct cx8800_dev *dev, /* enable irqs */ cx_set(MO_PCI_INTMSK, core->pci_irqmask | 0x01); + + /* Enables corresponding bits at PCI_INT_STAT: + bits 0 to 4: video, audio, transport stream, VIP, Host + bit 7: timer + bits 8 and 9: DMA complete for: SRC, DST + bits 10 and 11: BERR signal asserted for RISC: RD, WR + bits 12 to 15: BERR signal asserted for: BRDG, SRC, DST, IPB + */ cx_set(MO_VID_INTMSK, 0x0f0011); /* enable capture */ @@ -431,7 +441,7 @@ static int start_video_dma(struct cx8800_dev *dev, /* start dma */ cx_set(MO_DEV_CNTRL2, (1<<5)); - cx_set(MO_VID_DMACNTRL, 0x11); + cx_set(MO_VID_DMACNTRL, 0x11); /* Planar Y and packed FIFO and RISC enable */ return 0; } @@ -455,6 +465,7 @@ static int stop_video_dma(struct cx8800_dev *dev) static int restart_video_queue(struct cx8800_dev *dev, struct cx88_dmaqueue *q) { + struct cx88_core *core = dev->core; struct cx88_buffer *buf, *prev; struct list_head *item; @@ -524,12 +535,13 @@ buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, { struct cx8800_fh *fh = q->priv_data; struct cx8800_dev *dev = fh->dev; + struct cx88_core *core = dev->core; struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb); int rc, init_buffer = 0; BUG_ON(NULL == fh->fmt); - if (fh->width < 48 || fh->width > norm_maxw(dev->core->tvnorm) || - fh->height < 32 || fh->height > norm_maxh(dev->core->tvnorm)) + if (fh->width < 48 || fh->width > norm_maxw(core->tvnorm) || + fh->height < 32 || fh->height > norm_maxh(core->tvnorm)) return -EINVAL; buf->vb.size = (fh->width * fh->height * fh->fmt->depth) >> 3; if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) @@ -609,6 +621,7 @@ buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) struct cx88_buffer *prev; struct cx8800_fh *fh = vq->priv_data; struct cx8800_dev *dev = fh->dev; + struct cx88_core *core = dev->core; struct cx88_dmaqueue *q = &dev->vidq; /* add jump to stopper */ @@ -701,6 +714,7 @@ static int video_open(struct inode *inode, struct file *file) { int minor = iminor(inode); struct cx8800_dev *h,*dev = NULL; + struct cx88_core *core; struct cx8800_fh *fh; struct list_head *list; enum v4l2_buf_type type = 0; @@ -725,6 +739,8 @@ static int video_open(struct inode *inode, struct file *file) if (NULL == dev) return -ENODEV; + core = dev->core; + dprintk(1,"open minor=%d radio=%d type=%s\n", minor,radio,v4l2_type_names[type]); @@ -755,17 +771,16 @@ static int video_open(struct inode *inode, struct file *file) fh); if (fh->radio) { - struct cx88_core *core = dev->core; int board = core->board; dprintk(1,"video_open: setting radio device\n"); cx_write(MO_GP3_IO, cx88_boards[board].radio.gpio3); cx_write(MO_GP0_IO, cx88_boards[board].radio.gpio0); cx_write(MO_GP1_IO, cx88_boards[board].radio.gpio1); cx_write(MO_GP2_IO, cx88_boards[board].radio.gpio2); - dev->core->tvaudio = WW_FM; + core->tvaudio = WW_FM; cx88_set_tvaudio(core); cx88_set_stereo(core,V4L2_TUNER_MODE_STEREO,1); - cx88_call_i2c_clients(dev->core,AUDC_SET_RADIO,NULL); + cx88_call_i2c_clients(core,AUDC_SET_RADIO,NULL); } return 0; @@ -857,6 +872,9 @@ static int video_release(struct inode *inode, struct file *file) videobuf_mmap_free(&fh->vbiq); file->private_data = NULL; kfree(fh); + + cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL); + return 0; } @@ -870,9 +888,10 @@ video_mmap(struct file *file, struct vm_area_struct * vma) /* ------------------------------------------------------------------ */ -static int get_control(struct cx8800_dev *dev, struct v4l2_control *ctl) +/* static int get_control(struct cx8800_dev *dev, struct v4l2_control *ctl) */ +static int get_control(struct cx88_core *core, struct v4l2_control *ctl) { - struct cx88_core *core = dev->core; + /* struct cx88_core *core = dev->core; */ struct cx88_ctrl *c = NULL; u32 value; int i; @@ -898,9 +917,10 @@ static int get_control(struct cx8800_dev *dev, struct v4l2_control *ctl) return 0; } -static int set_control(struct cx8800_dev *dev, struct v4l2_control *ctl) +/* static int set_control(struct cx8800_dev *dev, struct v4l2_control *ctl) */ +static int set_control(struct cx88_core *core, struct v4l2_control *ctl) { - struct cx88_core *core = dev->core; + /* struct cx88_core *core = dev->core; */ struct cx88_ctrl *c = NULL; u32 v_sat_value; u32 value; @@ -913,9 +933,9 @@ static int set_control(struct cx8800_dev *dev, struct v4l2_control *ctl) return -EINVAL; if (ctl->value < c->v.minimum) - return -ERANGE; + ctl->value = c->v.minimum; if (ctl->value > c->v.maximum) - return -ERANGE; + ctl->value = c->v.maximum; switch (ctl->id) { case V4L2_CID_AUDIO_BALANCE: value = (ctl->value < 0x40) ? (0x40 - ctl->value) : ctl->value; @@ -946,7 +966,8 @@ static int set_control(struct cx8800_dev *dev, struct v4l2_control *ctl) return 0; } -static void init_controls(struct cx8800_dev *dev) +/* static void init_controls(struct cx8800_dev *dev) */ +static void init_controls(struct cx88_core *core) { static struct v4l2_control mute = { .id = V4L2_CID_AUDIO_MUTE, @@ -969,11 +990,11 @@ static void init_controls(struct cx8800_dev *dev) .value = 0x80, }; - set_control(dev,&mute); - set_control(dev,&volume); - set_control(dev,&hue); - set_control(dev,&contrast); - set_control(dev,&brightness); + set_control(core,&mute); + set_control(core,&volume); + set_control(core,&hue); + set_control(core,&contrast); + set_control(core,&brightness); } /* ------------------------------------------------------------------ */ @@ -1004,6 +1025,8 @@ static int cx8800_g_fmt(struct cx8800_dev *dev, struct cx8800_fh *fh, static int cx8800_try_fmt(struct cx8800_dev *dev, struct cx8800_fh *fh, struct v4l2_format *f) { + struct cx88_core *core = dev->core; + switch (f->type) { case V4L2_BUF_TYPE_VIDEO_CAPTURE: { @@ -1016,8 +1039,8 @@ static int cx8800_try_fmt(struct cx8800_dev *dev, struct cx8800_fh *fh, return -EINVAL; field = f->fmt.pix.field; - maxw = norm_maxw(dev->core->tvnorm); - maxh = norm_maxh(dev->core->tvnorm); + maxw = norm_maxw(core->tvnorm); + maxh = norm_maxh(core->tvnorm); if (V4L2_FIELD_ANY == field) { field = (f->fmt.pix.height > maxh/2) @@ -1101,12 +1124,14 @@ static int video_do_ioctl(struct inode *inode, struct file *file, if (video_debug > 1) cx88_print_ioctl(core->name,cmd); switch (cmd) { + + /* --- capabilities ------------------------------------------ */ case VIDIOC_QUERYCAP: { struct v4l2_capability *cap = arg; memset(cap,0,sizeof(*cap)); - strcpy(cap->driver, "cx8800"); + strcpy(cap->driver, "cx8800"); strlcpy(cap->card, cx88_boards[core->board].name, sizeof(cap->card)); sprintf(cap->bus_info,"PCI:%s",pci_name(dev->pci)); @@ -1116,12 +1141,128 @@ static int video_do_ioctl(struct inode *inode, struct file *file, V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | V4L2_CAP_VBI_CAPTURE | + V4L2_CAP_VIDEO_OVERLAY | 0; if (UNSET != core->tuner_type) cap->capabilities |= V4L2_CAP_TUNER; return 0; } + /* --- capture ioctls ---------------------------------------- */ + case VIDIOC_ENUM_FMT: + { + struct v4l2_fmtdesc *f = arg; + enum v4l2_buf_type type; + unsigned int index; + + index = f->index; + type = f->type; + switch (type) { + case V4L2_BUF_TYPE_VIDEO_CAPTURE: + if (index >= ARRAY_SIZE(formats)) + return -EINVAL; + memset(f,0,sizeof(*f)); + f->index = index; + f->type = type; + strlcpy(f->description,formats[index].name,sizeof(f->description)); + f->pixelformat = formats[index].fourcc; + break; + default: + return -EINVAL; + } + return 0; + } + case VIDIOC_G_FMT: + { + struct v4l2_format *f = arg; + return cx8800_g_fmt(dev,fh,f); + } + case VIDIOC_S_FMT: + { + struct v4l2_format *f = arg; + return cx8800_s_fmt(dev,fh,f); + } + case VIDIOC_TRY_FMT: + { + struct v4l2_format *f = arg; + return cx8800_try_fmt(dev,fh,f); + } + + /* --- streaming capture ------------------------------------- */ + case VIDIOCGMBUF: + { + struct video_mbuf *mbuf = arg; + struct videobuf_queue *q; + struct v4l2_requestbuffers req; + unsigned int i; + + q = get_queue(fh); + memset(&req,0,sizeof(req)); + req.type = q->type; + req.count = 8; + req.memory = V4L2_MEMORY_MMAP; + err = videobuf_reqbufs(q,&req); + if (err < 0) + return err; + memset(mbuf,0,sizeof(*mbuf)); + mbuf->frames = req.count; + mbuf->size = 0; + for (i = 0; i < mbuf->frames; i++) { + mbuf->offsets[i] = q->bufs[i]->boff; + mbuf->size += q->bufs[i]->bsize; + } + return 0; + } + case VIDIOC_REQBUFS: + return videobuf_reqbufs(get_queue(fh), arg); + + case VIDIOC_QUERYBUF: + return videobuf_querybuf(get_queue(fh), arg); + + case VIDIOC_QBUF: + return videobuf_qbuf(get_queue(fh), arg); + + case VIDIOC_DQBUF: + return videobuf_dqbuf(get_queue(fh), arg, + file->f_flags & O_NONBLOCK); + + case VIDIOC_STREAMON: + { + int res = get_ressource(fh); + + if (!res_get(dev,fh,res)) + return -EBUSY; + return videobuf_streamon(get_queue(fh)); + } + case VIDIOC_STREAMOFF: + { + int res = get_ressource(fh); + + err = videobuf_streamoff(get_queue(fh)); + if (err < 0) + return err; + res_free(dev,fh,res); + return 0; + } + + default: + return cx88_do_ioctl( inode, file, fh->radio, core, cmd, arg, video_do_ioctl ); + } + return 0; +} + +int cx88_do_ioctl(struct inode *inode, struct file *file, int radio, + struct cx88_core *core, unsigned int cmd, void *arg, v4l2_kioctl driver_ioctl) +{ + int err; + + if (video_debug > 1) + cx88_print_ioctl(core->name,cmd); + printk( KERN_INFO "CORE IOCTL: 0x%x\n", cmd ); + cx88_print_ioctl(core->name,cmd); + dprintk( 1, "CORE IOCTL: 0x%x\n", cmd ); + + switch (cmd) { /* ---------- tv norms ---------- */ case VIDIOC_ENUMSTD: { @@ -1156,9 +1297,9 @@ static int video_do_ioctl(struct inode *inode, struct file *file, if (i == ARRAY_SIZE(tvnorms)) return -EINVAL; - down(&dev->lock); - cx88_set_tvnorm(dev->core,&tvnorms[i]); - up(&dev->lock); + down(&core->lock); + cx88_set_tvnorm(core,&tvnorms[i]); + up(&core->lock); return 0; } @@ -1199,7 +1340,7 @@ static int video_do_ioctl(struct inode *inode, struct file *file, { unsigned int *i = arg; - *i = dev->core->input; + *i = core->input; return 0; } case VIDIOC_S_INPUT: @@ -1208,55 +1349,15 @@ static int video_do_ioctl(struct inode *inode, struct file *file, if (*i >= 4) return -EINVAL; - down(&dev->lock); + down(&core->lock); cx88_newstation(core); - video_mux(dev,*i); - up(&dev->lock); + video_mux(core,*i); + up(&core->lock); return 0; } - /* --- capture ioctls ---------------------------------------- */ - case VIDIOC_ENUM_FMT: - { - struct v4l2_fmtdesc *f = arg; - enum v4l2_buf_type type; - unsigned int index; - - index = f->index; - type = f->type; - switch (type) { - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - if (index >= ARRAY_SIZE(formats)) - return -EINVAL; - memset(f,0,sizeof(*f)); - f->index = index; - f->type = type; - strlcpy(f->description,formats[index].name,sizeof(f->description)); - f->pixelformat = formats[index].fourcc; - break; - default: - return -EINVAL; - } - return 0; - } - case VIDIOC_G_FMT: - { - struct v4l2_format *f = arg; - return cx8800_g_fmt(dev,fh,f); - } - case VIDIOC_S_FMT: - { - struct v4l2_format *f = arg; - return cx8800_s_fmt(dev,fh,f); - } - case VIDIOC_TRY_FMT: - { - struct v4l2_format *f = arg; - return cx8800_try_fmt(dev,fh,f); - } - /* --- controls ---------------------------------------------- */ case VIDIOC_QUERYCTRL: { @@ -1277,9 +1378,9 @@ static int video_do_ioctl(struct inode *inode, struct file *file, return 0; } case VIDIOC_G_CTRL: - return get_control(dev,arg); + return get_control(core,arg); case VIDIOC_S_CTRL: - return set_control(dev,arg); + return set_control(core,arg); /* --- tuner ioctls ------------------------------------------ */ case VIDIOC_G_TUNER: @@ -1323,10 +1424,11 @@ static int video_do_ioctl(struct inode *inode, struct file *file, if (UNSET == core->tuner_type) return -EINVAL; - f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; - f->frequency = dev->freq; + /* f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; */ + f->type = radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; + f->frequency = core->freq; - cx88_call_i2c_clients(dev->core,VIDIOC_G_FREQUENCY,f); + cx88_call_i2c_clients(core,VIDIOC_G_FREQUENCY,f); return 0; } @@ -1338,83 +1440,26 @@ static int video_do_ioctl(struct inode *inode, struct file *file, return -EINVAL; if (f->tuner != 0) return -EINVAL; - if (0 == fh->radio && f->type != V4L2_TUNER_ANALOG_TV) + if (0 == radio && f->type != V4L2_TUNER_ANALOG_TV) return -EINVAL; - if (1 == fh->radio && f->type != V4L2_TUNER_RADIO) + if (1 == radio && f->type != V4L2_TUNER_RADIO) return -EINVAL; - down(&dev->lock); - dev->freq = f->frequency; + down(&core->lock); + core->freq = f->frequency; cx88_newstation(core); - cx88_call_i2c_clients(dev->core,VIDIOC_S_FREQUENCY,f); + cx88_call_i2c_clients(core,VIDIOC_S_FREQUENCY,f); /* When changing channels it is required to reset TVAUDIO */ msleep (10); cx88_set_tvaudio(core); - up(&dev->lock); - return 0; - } - - /* --- streaming capture ------------------------------------- */ - case VIDIOCGMBUF: - { - struct video_mbuf *mbuf = arg; - struct videobuf_queue *q; - struct v4l2_requestbuffers req; - unsigned int i; - - q = get_queue(fh); - memset(&req,0,sizeof(req)); - req.type = q->type; - req.count = 8; - req.memory = V4L2_MEMORY_MMAP; - err = videobuf_reqbufs(q,&req); - if (err < 0) - return err; - memset(mbuf,0,sizeof(*mbuf)); - mbuf->frames = req.count; - mbuf->size = 0; - for (i = 0; i < mbuf->frames; i++) { - mbuf->offsets[i] = q->bufs[i]->boff; - mbuf->size += q->bufs[i]->bsize; - } - return 0; - } - case VIDIOC_REQBUFS: - return videobuf_reqbufs(get_queue(fh), arg); - - case VIDIOC_QUERYBUF: - return videobuf_querybuf(get_queue(fh), arg); - - case VIDIOC_QBUF: - return videobuf_qbuf(get_queue(fh), arg); - - case VIDIOC_DQBUF: - return videobuf_dqbuf(get_queue(fh), arg, - file->f_flags & O_NONBLOCK); - - case VIDIOC_STREAMON: - { - int res = get_ressource(fh); - - if (!res_get(dev,fh,res)) - return -EBUSY; - return videobuf_streamon(get_queue(fh)); - } - case VIDIOC_STREAMOFF: - { - int res = get_ressource(fh); - - err = videobuf_streamoff(get_queue(fh)); - if (err < 0) - return err; - res_free(dev,fh,res); + up(&core->lock); return 0; } default: return v4l_compat_translate_ioctl(inode,file,cmd,arg, - video_do_ioctl); + driver_ioctl); } return 0; } @@ -1461,7 +1506,7 @@ static int radio_do_ioctl(struct inode *inode, struct file *file, memset(t,0,sizeof(*t)); strcpy(t->name, "Radio"); - cx88_call_i2c_clients(dev->core,VIDIOC_G_TUNER,t); + cx88_call_i2c_clients(core,VIDIOC_G_TUNER,t); return 0; } case VIDIOC_ENUMINPUT: @@ -1501,8 +1546,8 @@ static int radio_do_ioctl(struct inode *inode, struct file *file, if (v->tuner) /* Only tuner 0 */ return -EINVAL; - cx88_call_i2c_clients(dev->core,VIDIOCSTUNER,v); - return 0; + cx88_call_i2c_clients(core,VIDIOCSTUNER,v); + return 0; } case VIDIOC_S_TUNER: { @@ -1511,7 +1556,7 @@ static int radio_do_ioctl(struct inode *inode, struct file *file, if (0 != t->index) return -EINVAL; - cx88_call_i2c_clients(dev->core,VIDIOC_S_TUNER,t); + cx88_call_i2c_clients(core,VIDIOC_S_TUNER,t); return 0; } @@ -1569,7 +1614,7 @@ static void cx8800_vid_timeout(unsigned long data) struct cx88_buffer *buf; unsigned long flags; - cx88_sram_channel_dump(dev->core, &cx88_sram_channels[SRAM_CH21]); + cx88_sram_channel_dump(core, &cx88_sram_channels[SRAM_CH21]); cx_clear(MO_VID_DMACNTRL, 0x11); cx_clear(VID_CAPTURE_CONTROL, 0x06); @@ -1614,14 +1659,14 @@ static void cx8800_vid_irq(struct cx8800_dev *dev) printk(KERN_WARNING "%s/0: video risc op code error\n",core->name); cx_clear(MO_VID_DMACNTRL, 0x11); cx_clear(VID_CAPTURE_CONTROL, 0x06); - cx88_sram_channel_dump(dev->core, &cx88_sram_channels[SRAM_CH21]); + cx88_sram_channel_dump(core, &cx88_sram_channels[SRAM_CH21]); } /* risc1 y */ if (status & 0x01) { spin_lock(&dev->slock); count = cx_read(MO_VIDY_GPCNT); - cx88_wakeup(dev->core, &dev->vidq, count); + cx88_wakeup(core, &dev->vidq, count); spin_unlock(&dev->slock); } @@ -1629,7 +1674,7 @@ static void cx8800_vid_irq(struct cx8800_dev *dev) if (status & 0x08) { spin_lock(&dev->slock); count = cx_read(MO_VBI_GPCNT); - cx88_wakeup(dev->core, &dev->vbiq, count); + cx88_wakeup(core, &dev->vbiq, count); spin_unlock(&dev->slock); } @@ -1798,7 +1843,6 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, } /* initialize driver struct */ - init_MUTEX(&dev->lock); spin_lock_init(&dev->slock); core->tvnorm = tvnorms; @@ -1835,6 +1879,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, request_module("tuner"); if (core->tda9887_conf) request_module("tda9887"); + /* register v4l devices */ dev->video_dev = cx88_vdev_init(core,dev->pci, &cx8800_video_template,"video"); @@ -1878,11 +1923,11 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, pci_set_drvdata(pci_dev,dev); /* initial device configuration */ - down(&dev->lock); - init_controls(dev); - cx88_set_tvnorm(dev->core,tvnorms); - video_mux(dev,0); - up(&dev->lock); + down(&core->lock); + init_controls(core); + cx88_set_tvnorm(core,tvnorms); + video_mux(core,0); + up(&core->lock); /* start tvaudio thread */ if (core->tuner_type != TUNER_ABSENT) @@ -1902,14 +1947,15 @@ fail_free: static void __devexit cx8800_finidev(struct pci_dev *pci_dev) { struct cx8800_dev *dev = pci_get_drvdata(pci_dev); + struct cx88_core *core = dev->core; /* stop thread */ - if (dev->core->kthread) { - kthread_stop(dev->core->kthread); - dev->core->kthread = NULL; + if (core->kthread) { + kthread_stop(core->kthread); + core->kthread = NULL; } - cx88_shutdown(dev->core); /* FIXME */ + cx88_shutdown(core); /* FIXME */ pci_disable_device(pci_dev); /* unregister stuff */ @@ -1921,7 +1967,7 @@ static void __devexit cx8800_finidev(struct pci_dev *pci_dev) /* free memory */ btcx_riscmem_free(dev->pci,&dev->vidq.stopper); list_del(&dev->devlist); - cx88_core_put(dev->core,dev->pci); + cx88_core_put(core,dev->pci); kfree(dev); } @@ -1945,7 +1991,7 @@ static int cx8800_suspend(struct pci_dev *pci_dev, pm_message_t state) spin_unlock(&dev->slock); /* FIXME -- shutdown device */ - cx88_shutdown(dev->core); + cx88_shutdown(core); pci_save_state(pci_dev); if (0 != pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state))) { @@ -1959,16 +2005,32 @@ static int cx8800_resume(struct pci_dev *pci_dev) { struct cx8800_dev *dev = pci_get_drvdata(pci_dev); struct cx88_core *core = dev->core; + int err; if (dev->state.disabled) { - pci_enable_device(pci_dev); + err=pci_enable_device(pci_dev); + if (err) { + printk(KERN_ERR "%s: can't enable device\n", + core->name); + return err; + } + dev->state.disabled = 0; } - pci_set_power_state(pci_dev, PCI_D0); + err= pci_set_power_state(pci_dev, PCI_D0); + if (err) { + printk(KERN_ERR "%s: can't enable device\n", + core->name); + + pci_disable_device(pci_dev); + dev->state.disabled = 1; + + return err; + } pci_restore_state(pci_dev); /* FIXME: re-initialize hardware */ - cx88_reset(dev->core); + cx88_reset(core); /* restart video+vbi capture */ spin_lock(&dev->slock); @@ -2030,6 +2092,8 @@ static void cx8800_fini(void) module_init(cx8800_init); module_exit(cx8800_fini); +EXPORT_SYMBOL(cx88_do_ioctl); + /* ----------------------------------------------------------- */ /* * Local variables: diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h index da65dc92787..f48dd435356 100644 --- a/drivers/media/video/cx88/cx88.h +++ b/drivers/media/video/cx88/cx88.h @@ -1,5 +1,4 @@ /* - * $Id: cx88.h,v 1.70 2005/07/24 17:44:09 mkrufky Exp $ * * v4l2 device driver for cx2388x based TV cards * @@ -35,7 +34,7 @@ #include "btcx-risc.h" #include "cx88-reg.h" -#include <linux/utsname.h> +#include <linux/version.h> #define CX88_VERSION_CODE KERNEL_VERSION(0,0,5) #ifndef TRUE @@ -48,6 +47,9 @@ #define CX88_MAXBOARDS 8 +/* Max number of inputs by card */ +#define MAX_CX88_INPUT 8 + /* ----------------------------------------------------------- */ /* defines and enums */ @@ -199,7 +201,7 @@ struct cx88_board { unsigned char tuner_addr; unsigned char radio_addr; int tda9887_conf; - struct cx88_input input[8]; + struct cx88_input input[MAX_CX88_INPUT]; struct cx88_input radio; int blackbird:1; int dvb:1; @@ -288,6 +290,11 @@ struct cx88_core { /* IR remote control state */ struct cx88_IR *ir; + + struct semaphore lock; + + /* various v4l controls */ + u32 freq; }; struct cx8800_dev; @@ -323,8 +330,7 @@ struct cx8800_suspend_state { struct cx8800_dev { struct cx88_core *core; struct list_head devlist; - struct semaphore lock; - spinlock_t slock; + spinlock_t slock; /* various device info */ unsigned int resources; @@ -342,7 +348,6 @@ struct cx8800_dev { struct cx88_dmaqueue vbiq; /* various v4l controls */ - u32 freq; /* other global state info */ struct cx8800_suspend_state state; @@ -350,14 +355,8 @@ struct cx8800_dev { /* ----------------------------------------------------------- */ /* function 1: audio/alsa stuff */ +/* =============> moved to cx88-alsa.c <====================== */ -struct cx8801_dev { - struct cx88_core *core; - - /* pci i/o */ - struct pci_dev *pci; - unsigned char pci_rev,pci_lat; -}; /* ----------------------------------------------------------- */ /* function 2: mpeg stuff */ @@ -373,8 +372,7 @@ struct cx8802_suspend_state { struct cx8802_dev { struct cx88_core *core; - struct semaphore lock; - spinlock_t slock; + spinlock_t slock; /* pci i/o */ struct pci_dev *pci; @@ -553,8 +551,21 @@ void cx8802_fini_common(struct cx8802_dev *dev); int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state); int cx8802_resume_common(struct pci_dev *pci_dev); +/* ----------------------------------------------------------- */ +/* cx88-video.c */ +extern int cx88_do_ioctl(struct inode *inode, struct file *file, int radio, + struct cx88_core *core, unsigned int cmd, + void *arg, v4l2_kioctl driver_ioctl); + +/* ----------------------------------------------------------- */ +/* cx88-blackbird.c */ +extern int (*cx88_ioctl_hook)(struct inode *inode, struct file *file, + unsigned int cmd, void *arg); +extern unsigned int (*cx88_ioctl_translator)(unsigned int cmd); + /* * Local variables: * c-basic-offset: 8 * End: + * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off */ diff --git a/drivers/media/video/ir-kbd-gpio.c b/drivers/media/video/ir-kbd-gpio.c index a565823330a..cf292da8fdd 100644 --- a/drivers/media/video/ir-kbd-gpio.c +++ b/drivers/media/video/ir-kbd-gpio.c @@ -1,5 +1,4 @@ /* - * $Id: ir-kbd-gpio.c,v 1.13 2005/05/15 19:01:26 mchehab Exp $ * * Copyright (c) 2003 Gerd Knorr * Copyright (c) 2003 Pavel Machek @@ -354,6 +353,7 @@ static int ir_probe(struct device *dev) ir->input.id.vendor = sub->core->pci->vendor; ir->input.id.product = sub->core->pci->device; } + ir->input.dev = &sub->core->pci->dev; if (ir->polling) { INIT_WORK(&ir->work, ir_work, ir); diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c index 1e273ff3f95..67105b9804a 100644 --- a/drivers/media/video/ir-kbd-i2c.c +++ b/drivers/media/video/ir-kbd-i2c.c @@ -1,5 +1,4 @@ /* - * $Id: ir-kbd-i2c.c,v 1.11 2005/07/07 16:42:11 mchehab Exp $ * * keyboard input driver for i2c IR remote controls * diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c index ca02f6f14b0..f0d43fc2632 100644 --- a/drivers/media/video/msp3400.c +++ b/drivers/media/video/msp3400.c @@ -124,10 +124,14 @@ module_param(standard, int, 0644); module_param(amsound, int, 0644); module_param(dolby, int, 0644); +MODULE_PARM_DESC(opmode, "Forces a MSP3400 opmode. 0=Manual, 1=Simple, 2=Simpler"); MODULE_PARM_DESC(once, "No continuous stereo monitoring"); MODULE_PARM_DESC(debug, "Enable debug messages"); +MODULE_PARM_DESC(stereo_threshold, "Sets signal threshold to activate stereo"); MODULE_PARM_DESC(standard, "Specify audio standard: 32 = NTSC, 64 = radio, Default: Autodetect"); MODULE_PARM_DESC(amsound, "Hardwire AM sound at 6.5Hz (France), FM can autoscan"); +MODULE_PARM_DESC(dolby, "Activates Dolby processsing"); + MODULE_DESCRIPTION("device driver for msp34xx TV sound processor"); MODULE_AUTHOR("Gerd Knorr"); @@ -1452,7 +1456,7 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind) client_template.addr = addr; if (-1 == msp3400c_reset(&client_template)) { - dprintk("msp3400: no chip found\n"); + dprintk("msp34xx: no chip found\n"); return -1; } @@ -1478,7 +1482,7 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind) if (-1 == msp3400c_reset(c)) { kfree(msp); kfree(c); - dprintk("msp3400: no chip found\n"); + dprintk("msp34xx: no chip found\n"); return -1; } @@ -1488,7 +1492,7 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind) if ((-1 == msp->rev1) || (0 == msp->rev1 && 0 == msp->rev2)) { kfree(msp); kfree(c); - printk("msp3400: error while reading chip version\n"); + dprintk("msp34xx: error while reading chip version\n"); return -1; } diff --git a/drivers/media/video/msp3400.h b/drivers/media/video/msp3400.h index 023f33056a4..2d9ff40f0b0 100644 --- a/drivers/media/video/msp3400.h +++ b/drivers/media/video/msp3400.h @@ -1,5 +1,4 @@ /* - * $Id: msp3400.h,v 1.3 2005/06/12 04:19:19 mchehab Exp $ */ #ifndef MSP3400_H diff --git a/drivers/media/video/mt20xx.c b/drivers/media/video/mt20xx.c index 2fb7c2d1787..972aa5e0aee 100644 --- a/drivers/media/video/mt20xx.c +++ b/drivers/media/video/mt20xx.c @@ -1,5 +1,4 @@ /* - * $Id: mt20xx.c,v 1.5 2005/06/16 08:29:49 nsh Exp $ * * i2c tv tuner chip device driver * controls microtune tuners, mt2032 + mt2050 at the moment. @@ -494,6 +493,7 @@ int microtune_init(struct i2c_client *c) memset(buf,0,sizeof(buf)); t->tv_freq = NULL; t->radio_freq = NULL; + t->standby = NULL; name = "unknown"; i2c_master_send(c,buf,1); diff --git a/drivers/media/video/rds.h b/drivers/media/video/rds.h new file mode 100644 index 00000000000..30337d0f1a8 --- /dev/null +++ b/drivers/media/video/rds.h @@ -0,0 +1,48 @@ +/* + + Types and defines needed for RDS. This is included by + saa6588.c and every driver (e.g. bttv-driver.c) that wants + to use the saa6588 module. + + Instead of having a seperate rds.h, I'd prefer to include + this stuff in one of the already existing files like tuner.h + + (c) 2005 by Hans J. Koch + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef _RDS_H +#define _RDS_H + +struct rds_command { + unsigned int block_count; + int result; + unsigned char *buffer; + struct file *instance; + poll_table *event_list; +}; + +#define RDS_CMD_OPEN _IOW('R',1,int) +#define RDS_CMD_CLOSE _IOW('R',2,int) +#define RDS_CMD_READ _IOR('R',3,int) +#define RDS_CMD_POLL _IOR('R',4,int) + +#endif + + + + diff --git a/drivers/media/video/saa6588.c b/drivers/media/video/saa6588.c new file mode 100644 index 00000000000..1a657a70ff4 --- /dev/null +++ b/drivers/media/video/saa6588.c @@ -0,0 +1,534 @@ +/* + Driver for SAA6588 RDS decoder + + (c) 2005 Hans J. Koch + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + + +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/i2c.h> +#include <linux/types.h> +#include <linux/videodev.h> +#include <linux/init.h> +#include <linux/errno.h> +#include <linux/slab.h> +#include <linux/poll.h> +#include <linux/wait.h> +#include <asm/uaccess.h> + +#include <media/id.h> + +#include "rds.h" + +/* Addresses to scan */ +static unsigned short normal_i2c[] = { + 0x20 >> 1, + 0x22 >> 1, + I2C_CLIENT_END, +}; + +I2C_CLIENT_INSMOD; + +/* insmod options */ +static unsigned int debug = 0; +static unsigned int xtal = 0; +static unsigned int rbds = 0; +static unsigned int plvl = 0; +static unsigned int bufblocks = 100; + +MODULE_PARM(debug, "i"); +MODULE_PARM_DESC(debug, "enable debug messages"); +MODULE_PARM(xtal, "i"); +MODULE_PARM_DESC(xtal, "select oscillator frequency (0..3), default 0"); +MODULE_PARM(rbds, "i"); +MODULE_PARM_DESC(rbds, "select mode, 0=RDS, 1=RBDS, default 0"); +MODULE_PARM(plvl, "i"); +MODULE_PARM_DESC(plvl, "select pause level (0..3), default 0"); +MODULE_PARM(bufblocks, "i"); +MODULE_PARM_DESC(bufblocks, "number of buffered blocks, default 100"); + +MODULE_DESCRIPTION("v4l2 driver module for SAA6588 RDS decoder"); +MODULE_AUTHOR("Hans J. Koch <koch@hjk-az.de>"); + +MODULE_LICENSE("GPL"); + +/* ---------------------------------------------------------------------- */ + +#define UNSET (-1U) +#define PREFIX "saa6588: " +#define dprintk if (debug) printk + +struct saa6588 { + struct i2c_client client; + struct work_struct work; + struct timer_list timer; + spinlock_t lock; + unsigned char *buffer; + unsigned int buf_size; + unsigned int rd_index; + unsigned int wr_index; + unsigned int block_count; + unsigned char last_blocknum; + wait_queue_head_t read_queue; + int data_available_for_read; +}; + +static struct i2c_driver driver; +static struct i2c_client client_template; + +/* ---------------------------------------------------------------------- */ + +/* + * SAA6588 defines + */ + +/* Initialization and mode control byte (0w) */ + +/* bit 0+1 (DAC0/DAC1) */ +#define cModeStandard 0x00 +#define cModeFastPI 0x01 +#define cModeReducedRequest 0x02 +#define cModeInvalid 0x03 + +/* bit 2 (RBDS) */ +#define cProcessingModeRDS 0x00 +#define cProcessingModeRBDS 0x04 + +/* bit 3+4 (SYM0/SYM1) */ +#define cErrCorrectionNone 0x00 +#define cErrCorrection2Bits 0x08 +#define cErrCorrection5Bits 0x10 +#define cErrCorrectionNoneRBDS 0x18 + +/* bit 5 (NWSY) */ +#define cSyncNormal 0x00 +#define cSyncRestart 0x20 + +/* bit 6 (TSQD) */ +#define cSigQualityDetectOFF 0x00 +#define cSigQualityDetectON 0x40 + +/* bit 7 (SQCM) */ +#define cSigQualityTriggered 0x00 +#define cSigQualityContinous 0x80 + +/* Pause level and flywheel control byte (1w) */ + +/* bits 0..5 (FEB0..FEB5) */ +#define cFlywheelMaxBlocksMask 0x3F +#define cFlywheelDefault 0x20 + +/* bits 6+7 (PL0/PL1) */ +#define cPauseLevel_11mV 0x00 +#define cPauseLevel_17mV 0x40 +#define cPauseLevel_27mV 0x80 +#define cPauseLevel_43mV 0xC0 + +/* Pause time/oscillator frequency/quality detector control byte (1w) */ + +/* bits 0..4 (SQS0..SQS4) */ +#define cQualityDetectSensMask 0x1F +#define cQualityDetectDefault 0x0F + +/* bit 5 (SOSC) */ +#define cSelectOscFreqOFF 0x00 +#define cSelectOscFreqON 0x20 + +/* bit 6+7 (PTF0/PTF1) */ +#define cOscFreq_4332kHz 0x00 +#define cOscFreq_8664kHz 0x40 +#define cOscFreq_12996kHz 0x80 +#define cOscFreq_17328kHz 0xC0 + +/* ---------------------------------------------------------------------- */ + +static int block_to_user_buf(struct saa6588 *s, unsigned char *user_buf) +{ + int i; + + if (s->rd_index == s->wr_index) { + if (debug > 2) + dprintk(PREFIX "Read: buffer empty.\n"); + return 0; + } + + if (debug > 2) { + dprintk(PREFIX "Read: "); + for (i = s->rd_index; i < s->rd_index + 3; i++) + dprintk("0x%02x ", s->buffer[i]); + } + + if (copy_to_user(user_buf, &s->buffer[s->rd_index], 3)) + return -EFAULT; + + s->rd_index += 3; + if (s->rd_index >= s->buf_size) + s->rd_index = 0; + s->block_count--; + + if (debug > 2) + dprintk("%d blocks total.\n", s->block_count); + + return 1; +} + +static void read_from_buf(struct saa6588 *s, struct rds_command *a) +{ + unsigned long flags; + + unsigned char *buf_ptr = a->buffer; /* This is a user space buffer! */ + unsigned int i; + unsigned int rd_blocks; + + a->result = 0; + if (!a->buffer) + return; + + while (!s->data_available_for_read) { + int ret = wait_event_interruptible(s->read_queue, + s->data_available_for_read); + if (ret == -ERESTARTSYS) { + a->result = -EINTR; + return; + } + } + + spin_lock_irqsave(&s->lock, flags); + rd_blocks = a->block_count; + if (rd_blocks > s->block_count) + rd_blocks = s->block_count; + + if (!rd_blocks) + return; + + for (i = 0; i < rd_blocks; i++) { + if (block_to_user_buf(s, buf_ptr)) { + buf_ptr += 3; + a->result++; + } else + break; + } + a->result *= 3; + s->data_available_for_read = (s->block_count > 0); + spin_unlock_irqrestore(&s->lock, flags); +} + +static void block_to_buf(struct saa6588 *s, unsigned char *blockbuf) +{ + unsigned int i; + + if (debug > 3) + dprintk(PREFIX "New block: "); + + for (i = 0; i < 3; ++i) { + if (debug > 3) + dprintk("0x%02x ", blockbuf[i]); + s->buffer[s->wr_index] = blockbuf[i]; + s->wr_index++; + } + + if (s->wr_index >= s->buf_size) + s->wr_index = 0; + + if (s->wr_index == s->rd_index) { + s->rd_index++; + if (s->rd_index >= s->buf_size) + s->rd_index = 0; + } else + s->block_count++; + + if (debug > 3) + dprintk("%d blocks total.\n", s->block_count); +} + +static void saa6588_i2c_poll(struct saa6588 *s) +{ + unsigned long flags; + unsigned char tmpbuf[6]; + unsigned char blocknum; + unsigned char tmp; + + /* Although we only need 3 bytes, we have to read at least 6. + SAA6588 returns garbage otherwise */ + if (6 != i2c_master_recv(&s->client, &tmpbuf[0], 6)) { + if (debug > 1) + dprintk(PREFIX "read error!\n"); + return; + } + + blocknum = tmpbuf[0] >> 5; + if (blocknum == s->last_blocknum) { + if (debug > 3) + dprintk("Saw block %d again.\n", blocknum); + return; + } + + s->last_blocknum = blocknum; + + /* + Byte order according to v4l2 specification: + + Byte 0: Least Significant Byte of RDS Block + Byte 1: Most Significant Byte of RDS Block + Byte 2 Bit 7: Error bit. Indicates that an uncorrectable error + occurred during reception of this block. + Bit 6: Corrected bit. Indicates that an error was + corrected for this data block. + Bits 5-3: Received Offset. Indicates the offset received + by the sync system. + Bits 2-0: Offset Name. Indicates the offset applied to this data. + + SAA6588 byte order is Status-MSB-LSB, so we have to swap the + first and the last of the 3 bytes block. + */ + + tmp = tmpbuf[2]; + tmpbuf[2] = tmpbuf[0]; + tmpbuf[0] = tmp; + + tmp = blocknum; + tmp |= blocknum << 3; /* Received offset == Offset Name (OK ?) */ + if ((tmpbuf[2] & 0x03) == 0x03) + tmp |= 0x80; /* uncorrectable error */ + else if ((tmpbuf[2] & 0x03) != 0x00) + tmp |= 0x40; /* corrected error */ + tmpbuf[2] = tmp; /* Is this enough ? Should we also check other bits ? */ + + spin_lock_irqsave(&s->lock, flags); + block_to_buf(s, tmpbuf); + spin_unlock_irqrestore(&s->lock, flags); + s->data_available_for_read = 1; + wake_up_interruptible(&s->read_queue); +} + +static void saa6588_timer(unsigned long data) +{ + struct saa6588 *s = (struct saa6588 *)data; + + schedule_work(&s->work); +} + +static void saa6588_work(void *data) +{ + struct saa6588 *s = (struct saa6588 *)data; + + saa6588_i2c_poll(s); + mod_timer(&s->timer, jiffies + HZ / 50); /* 20 msec */ +} + +static int saa6588_configure(struct saa6588 *s) +{ + unsigned char buf[3]; + int rc; + + buf[0] = cSyncRestart; + if (rbds) + buf[0] |= cProcessingModeRBDS; + + buf[1] = cFlywheelDefault; + switch (plvl) { + case 0: + buf[1] |= cPauseLevel_11mV; + break; + case 1: + buf[1] |= cPauseLevel_17mV; + break; + case 2: + buf[1] |= cPauseLevel_27mV; + break; + case 3: + buf[1] |= cPauseLevel_43mV; + break; + default: /* nothing */ + break; + } + + buf[2] = cQualityDetectDefault | cSelectOscFreqON; + + switch (xtal) { + case 0: + buf[2] |= cOscFreq_4332kHz; + break; + case 1: + buf[2] |= cOscFreq_8664kHz; + break; + case 2: + buf[2] |= cOscFreq_12996kHz; + break; + case 3: + buf[2] |= cOscFreq_17328kHz; + break; + default: /* nothing */ + break; + } + + dprintk(PREFIX "writing: 0w=0x%02x 1w=0x%02x 2w=0x%02x\n", + buf[0], buf[1], buf[2]); + + if (3 != (rc = i2c_master_send(&s->client, buf, 3))) + printk(PREFIX "i2c i/o error: rc == %d (should be 3)\n", rc); + + return 0; +} + +/* ---------------------------------------------------------------------- */ + +static int saa6588_attach(struct i2c_adapter *adap, int addr, int kind) +{ + struct saa6588 *s; + client_template.adapter = adap; + client_template.addr = addr; + + printk(PREFIX "chip found @ 0x%x\n", addr << 1); + + if (NULL == (s = kmalloc(sizeof(*s), GFP_KERNEL))) + return -ENOMEM; + + s->buf_size = bufblocks * 3; + + if (NULL == (s->buffer = kmalloc(s->buf_size, GFP_KERNEL))) { + kfree(s); + return -ENOMEM; + } + s->client = client_template; + s->block_count = 0; + s->wr_index = 0; + s->rd_index = 0; + s->last_blocknum = 0xff; + init_waitqueue_head(&s->read_queue); + s->data_available_for_read = 0; + i2c_set_clientdata(&s->client, s); + i2c_attach_client(&s->client); + + saa6588_configure(s); + + /* start polling via eventd */ + INIT_WORK(&s->work, saa6588_work, s); + init_timer(&s->timer); + s->timer.function = saa6588_timer; + s->timer.data = (unsigned long)s; + schedule_work(&s->work); + + return 0; +} + +static int saa6588_probe(struct i2c_adapter *adap) +{ +#ifdef I2C_CLASS_TV_ANALOG + if (adap->class & I2C_CLASS_TV_ANALOG) + return i2c_probe(adap, &addr_data, saa6588_attach); +#else + switch (adap->id) { + case I2C_ALGO_BIT | I2C_HW_B_BT848: + case I2C_ALGO_BIT | I2C_HW_B_RIVA: + case I2C_ALGO_SAA7134: + return i2c_probe(adap, &addr_data, saa6588_attach); + break; + } +#endif + return 0; +} + +static int saa6588_detach(struct i2c_client *client) +{ + struct saa6588 *s = i2c_get_clientdata(client); + + del_timer_sync(&s->timer); + flush_scheduled_work(); + + i2c_detach_client(client); + kfree(s->buffer); + kfree(s); + return 0; +} + +static int saa6588_command(struct i2c_client *client, unsigned int cmd, + void *arg) +{ + struct saa6588 *s = i2c_get_clientdata(client); + struct rds_command *a = (struct rds_command *)arg; + + switch (cmd) { + /* --- open() for /dev/radio --- */ + case RDS_CMD_OPEN: + a->result = 0; /* return error if chip doesn't work ??? */ + break; + /* --- close() for /dev/radio --- */ + case RDS_CMD_CLOSE: + s->data_available_for_read = 1; + wake_up_interruptible(&s->read_queue); + a->result = 0; + break; + /* --- read() for /dev/radio --- */ + case RDS_CMD_READ: + read_from_buf(s, a); + break; + /* --- poll() for /dev/radio --- */ + case RDS_CMD_POLL: + a->result = 0; + if (s->data_available_for_read) { + a->result |= POLLIN | POLLRDNORM; + } + poll_wait(a->instance, &s->read_queue, a->event_list); + break; + + default: + /* nothing */ + break; + } + return 0; +} + +/* ----------------------------------------------------------------------- */ + +static struct i2c_driver driver = { + .owner = THIS_MODULE, + .name = "i2c saa6588 driver", + .id = -1, /* FIXME */ + .flags = I2C_DF_NOTIFY, + .attach_adapter = saa6588_probe, + .detach_client = saa6588_detach, + .command = saa6588_command, +}; + +static struct i2c_client client_template = { + .name = "saa6588", + .flags = I2C_CLIENT_ALLOW_USE, + .driver = &driver, +}; + +static int __init saa6588_init_module(void) +{ + return i2c_add_driver(&driver); +} + +static void __exit saa6588_cleanup_module(void) +{ + i2c_del_driver(&driver); +} + +module_init(saa6588_init_module); +module_exit(saa6588_cleanup_module); + +/* + * Overrides for Emacs so that we follow Linus's tabbing style. + * --------------------------------------------------------------------------- + * Local variables: + * c-basic-offset: 8 + * End: + */ diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index 88b71a20b60..acc7a4335e2 100644 --- a/drivers/media/video/saa7134/saa7134-cards.c +++ b/drivers/media/video/saa7134/saa7134-cards.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-cards.c,v 1.80 2005/07/07 01:49:30 mkrufky Exp $ * * device driver for philips saa7134 based TV cards * card-specific stuff. @@ -1373,7 +1372,7 @@ struct saa7134_board saa7134_boards[] = { .inputs = {{ .name = name_comp1, .vmux = 1, - .amux = LINE2, + .amux = LINE1, },{ .name = name_tv, .vmux = 3, @@ -1382,7 +1381,7 @@ struct saa7134_board saa7134_boards[] = { },{ .name = name_svideo, .vmux = 8, - .amux = LINE2, + .amux = LINE1, }}, .radio = { .name = name_radio, @@ -2001,6 +2000,115 @@ struct saa7134_board saa7134_boards[] = { .gpio = 0x000, }, }, + [SAA7134_BOARD_FLYTV_DIGIMATRIX] = { + .name = "FlyTV mini Asus Digimatrix", + .audio_clock = 0x00200000, + .tuner_type = TUNER_LG_NTSC_TALN_MINI, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, + .inputs = {{ + .name = name_tv, + .vmux = 1, + .amux = TV, + .tv = 1, + },{ + .name = name_tv_mono, + .vmux = 1, + .amux = LINE2, + .tv = 1, + },{ + .name = name_comp1, + .vmux = 0, + .amux = LINE2, + },{ + .name = name_comp2, + .vmux = 3, + .amux = LINE2, + },{ + .name = name_svideo, + .vmux = 8, + .amux = LINE2, + }}, + .radio = { + .name = name_radio, /* radio unconfirmed */ + .amux = LINE2, + }, + }, + [SAA7134_BOARD_KWORLD_TERMINATOR] = { + /* Kworld V-Stream Studio TV Terminator */ + /* "James Webb <jrwebb@qwest.net> */ + .name = "V-Stream Studio TV Terminator", + .audio_clock = 0x00187de7, + .tuner_type = TUNER_PHILIPS_TDA8290, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, + .gpiomask = 1 << 21, + .inputs = {{ + .name = name_tv, + .vmux = 1, + .amux = TV, + .gpio = 0x0000000, + .tv = 1, + },{ + .name = name_comp1, /* Composite input */ + .vmux = 3, + .amux = LINE2, + .gpio = 0x0000000, + },{ + .name = name_svideo, /* S-Video input */ + .vmux = 8, + .amux = LINE2, + .gpio = 0x0000000, + }}, + .radio = { + .name = name_radio, + .amux = TV, + .gpio = 0x0200000, + }, + }, + [SAA7134_BOARD_YUAN_TUN900] = { + /* FIXME: + * S-Video and composite sources untested. + * Radio not working. + * Remote control not yet implemented. + * From : codemaster@webgeeks.be */ + .name = "Yuan TUN-900 (saa7135)", + .audio_clock = 0x00187de7, + .tuner_type = TUNER_PHILIPS_TDA8290, + .radio_type = UNSET, + .tuner_addr= ADDR_UNSET, + .radio_addr= ADDR_UNSET, + .gpiomask = 0x00010003, + .inputs = {{ + .name = name_tv, + .vmux = 1, + .amux = TV, + .tv = 1, + .gpio = 0x01, + },{ + .name = name_comp1, + .vmux = 0, + .amux = LINE2, + .gpio = 0x02, + },{ + .name = name_svideo, + .vmux = 6, + .amux = LINE2, + .gpio = 0x02, + }}, + .radio = { + .name = name_radio, + .amux = LINE1, + .gpio = 0x00010003, + }, + .mute = { + .name = name_mute, + .amux = TV, + .gpio = 0x01, + }, + }, }; @@ -2272,12 +2380,6 @@ struct pci_device_id saa7134_pci_tbl[] = { .driver_data = SAA7134_BOARD_VIDEOMATE_TV_PVR, },{ .vendor = PCI_VENDOR_ID_PHILIPS, - .device = PCI_DEVICE_ID_PHILIPS_SAA7130, - .subvendor = 0x1131, - .subdevice = 0, - .driver_data = SAA7134_BOARD_SABRENT_SBTTVFM, - },{ - .vendor = PCI_VENDOR_ID_PHILIPS, .device = PCI_DEVICE_ID_PHILIPS_SAA7134, .subvendor = 0x1461, /* Avermedia Technologies Inc */ .subdevice = 0x9715, @@ -2346,6 +2448,18 @@ struct pci_device_id saa7134_pci_tbl[] = { .subvendor = 0x4e42, .subdevice = 0x0502, .driver_data = SAA7134_BOARD_THYPHOON_DVBT_DUO_CARDBUS, + },{ + .vendor = PCI_VENDOR_ID_PHILIPS, + .device = PCI_DEVICE_ID_PHILIPS_SAA7133, + .subvendor = 0x1043, + .subdevice = 0x0210, /* mini pci NTSC version */ + .driver_data = SAA7134_BOARD_FLYTV_DIGIMATRIX, + },{ + .vendor = PCI_VENDOR_ID_PHILIPS, + .device = PCI_DEVICE_ID_PHILIPS_SAA7134, + .subvendor = 0x1043, + .subdevice = 0x0210, /* mini pci PAL/SECAM version */ + .driver_data = SAA7134_BOARD_FLYTV_DIGIMATRIX, },{ /* --- boards without eeprom + subsystem ID --- */ diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c index 1dbe61755e9..e5e36f3c625 100644 --- a/drivers/media/video/saa7134/saa7134-core.c +++ b/drivers/media/video/saa7134/saa7134-core.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-core.c,v 1.39 2005/07/05 17:37:35 nsh Exp $ * * device driver for philips saa7134 based TV cards * driver core diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c index 8be6a90358c..639ae51a052 100644 --- a/drivers/media/video/saa7134/saa7134-dvb.c +++ b/drivers/media/video/saa7134/saa7134-dvb.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-dvb.c,v 1.23 2005/07/24 22:12:47 mkrufky Exp $ * * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs] * @@ -29,7 +28,6 @@ #include <linux/delay.h> #include <linux/kthread.h> #include <linux/suspend.h> -#include <linux/config.h> #include "saa7134-reg.h" diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c index c85348d0239..77b627eb648 100644 --- a/drivers/media/video/saa7134/saa7134-empress.c +++ b/drivers/media/video/saa7134/saa7134-empress.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-empress.c,v 1.11 2005/05/22 19:23:39 nsh Exp $ * * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs] * diff --git a/drivers/media/video/saa7134/saa7134-i2c.c b/drivers/media/video/saa7134/saa7134-i2c.c index eae6b529713..711aa8e85fa 100644 --- a/drivers/media/video/saa7134/saa7134-i2c.c +++ b/drivers/media/video/saa7134/saa7134-i2c.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-i2c.c,v 1.22 2005/07/22 04:09:41 mkrufky Exp $ * * device driver for philips saa7134 based TV cards * i2c interface support diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c index 213740122fe..1f456c4d76f 100644 --- a/drivers/media/video/saa7134/saa7134-input.c +++ b/drivers/media/video/saa7134/saa7134-input.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-input.c,v 1.21 2005/06/22 23:37:34 nsh Exp $ * * handle saa7134 IR remotes via linux kernel input layer. * @@ -565,6 +564,7 @@ int saa7134_input_init1(struct saa7134_dev *dev) ir->dev.id.vendor = dev->pci->vendor; ir->dev.id.product = dev->pci->device; } + ir->dev.dev = &dev->pci->dev; /* all done */ dev->remote = ir; diff --git a/drivers/media/video/saa7134/saa7134-oss.c b/drivers/media/video/saa7134/saa7134-oss.c index b5bede95dbf..c20630c82f1 100644 --- a/drivers/media/video/saa7134/saa7134-oss.c +++ b/drivers/media/video/saa7134/saa7134-oss.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-oss.c,v 1.17 2005/06/28 23:41:47 mkrufky Exp $ * * device driver for philips saa7134 based TV cards * oss dsp interface diff --git a/drivers/media/video/saa7134/saa7134-reg.h b/drivers/media/video/saa7134/saa7134-reg.h index 87734f22af7..ae0c7a16539 100644 --- a/drivers/media/video/saa7134/saa7134-reg.h +++ b/drivers/media/video/saa7134/saa7134-reg.h @@ -1,5 +1,4 @@ /* - * $Id: saa7134-reg.h,v 1.2 2004/09/15 16:15:24 kraxel Exp $ * * philips saa7134 registers */ diff --git a/drivers/media/video/saa7134/saa7134-ts.c b/drivers/media/video/saa7134/saa7134-ts.c index 4dd9f1b2392..463885601ab 100644 --- a/drivers/media/video/saa7134/saa7134-ts.c +++ b/drivers/media/video/saa7134/saa7134-ts.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-ts.c,v 1.15 2005/06/14 22:48:18 hhackmann Exp $ * * device driver for philips saa7134 based TV cards * video4linux video interface diff --git a/drivers/media/video/saa7134/saa7134-tvaudio.c b/drivers/media/video/saa7134/saa7134-tvaudio.c index eeafa5a71d2..badf2f9e307 100644 --- a/drivers/media/video/saa7134/saa7134-tvaudio.c +++ b/drivers/media/video/saa7134/saa7134-tvaudio.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-tvaudio.c,v 1.30 2005/06/28 23:41:47 mkrufky Exp $ * * device driver for philips saa7134 based TV cards * tv audio decoder (fm stereo, nicam, ...) diff --git a/drivers/media/video/saa7134/saa7134-vbi.c b/drivers/media/video/saa7134/saa7134-vbi.c index 29e51cad2aa..f4aee0af80e 100644 --- a/drivers/media/video/saa7134/saa7134-vbi.c +++ b/drivers/media/video/saa7134/saa7134-vbi.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-vbi.c,v 1.7 2005/05/24 23:13:06 nsh Exp $ * * device driver for philips saa7134 based TV cards * video4linux video interface diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c index a4c2f751d09..35e5e85f669 100644 --- a/drivers/media/video/saa7134/saa7134-video.c +++ b/drivers/media/video/saa7134/saa7134-video.c @@ -1,5 +1,4 @@ /* - * $Id: saa7134-video.c,v 1.36 2005/06/28 23:41:47 mkrufky Exp $ * * device driver for philips saa7134 based TV cards * video4linux video interface @@ -1368,29 +1367,7 @@ static int video_release(struct inode *inode, struct file *file) saa_andorb(SAA7134_OFMT_DATA_A, 0x1f, 0); saa_andorb(SAA7134_OFMT_DATA_B, 0x1f, 0); - if (dev->tuner_type == TUNER_PHILIPS_TDA8290) { - u8 data[2]; - int ret; - struct i2c_msg msg = {.addr=I2C_ADDR_TDA8290, .flags=0, .buf=data, .len = 2}; - data[0] = 0x21; - data[1] = 0xc0; - ret = i2c_transfer(&dev->i2c_adap, &msg, 1); - if (ret != 1) - printk(KERN_ERR "TDA8290 access failure\n"); - msg.addr = I2C_ADDR_TDA8275; - data[0] = 0x30; - data[1] = 0xd0; - ret = i2c_transfer(&dev->i2c_adap, &msg, 1); - if (ret != 1) - printk(KERN_ERR "TDA8275 access failure\n"); - msg.addr = I2C_ADDR_TDA8290; - data[0] = 0x21; - data[1] = 0x80; - i2c_transfer(&dev->i2c_adap, &msg, 1); - data[0] = 0x00; - data[1] = 0x02; - i2c_transfer(&dev->i2c_adap, &msg, 1); - } + saa7134_i2c_call_clients(dev, TUNER_SET_STANDBY, NULL); /* free stuff */ videobuf_mmap_free(&fh->cap); diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index 2af0cb2a731..3ea09142ec9 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h @@ -1,5 +1,4 @@ /* - * $Id: saa7134.h,v 1.49 2005/07/13 17:25:25 mchehab Exp $ * * v4l2 device driver for philips saa7134 based TV cards * @@ -185,6 +184,9 @@ struct saa7134_format { #define SAA7134_BOARD_PHILIPS_TOUGH 61 #define SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII 62 #define SAA7134_BOARD_KWORLD_XPERT 63 +#define SAA7134_BOARD_FLYTV_DIGIMATRIX 64 +#define SAA7134_BOARD_KWORLD_TERMINATOR 65 +#define SAA7134_BOARD_YUAN_TUN900 66 #define SAA7134_MAXBOARDS 8 #define SAA7134_INPUT_MAX 8 diff --git a/drivers/media/video/stradis.c b/drivers/media/video/stradis.c index b5774357108..d4497dbae05 100644 --- a/drivers/media/video/stradis.c +++ b/drivers/media/video/stradis.c @@ -2184,30 +2184,18 @@ static void release_saa(void) vfree(saa->vidbuf); vfree(saa->audbuf); vfree(saa->osdbuf); - if (saa->dmavid2) - kfree((void *) saa->dmavid2); + kfree(saa->dmavid2); saa->audbuf = saa->vidbuf = saa->osdbuf = NULL; saa->dmavid2 = NULL; - if (saa->dmadebi) - kfree((void *) saa->dmadebi); - if (saa->dmavid1) - kfree((void *) saa->dmavid1); - if (saa->dmavid2) - kfree((void *) saa->dmavid2); - if (saa->dmavid3) - kfree((void *) saa->dmavid3); - if (saa->dmaa1in) - kfree((void *) saa->dmaa1in); - if (saa->dmaa1out) - kfree((void *) saa->dmaa1out); - if (saa->dmaa2in) - kfree((void *) saa->dmaa2in); - if (saa->dmaa2out) - kfree((void *) saa->dmaa2out); - if (saa->dmaRPS1) - kfree((void *) saa->dmaRPS1); - if (saa->dmaRPS2) - kfree((void *) saa->dmaRPS2); + kfree(saa->dmadebi); + kfree(saa->dmavid1); + kfree(saa->dmavid3); + kfree(saa->dmaa1in); + kfree(saa->dmaa1out); + kfree(saa->dmaa2in); + kfree(saa->dmaa2out); + kfree(saa->dmaRPS1); + kfree(saa->dmaRPS2); free_irq(saa->irq, saa); if (saa->saa7146_mem) iounmap(saa->saa7146_mem); diff --git a/drivers/media/video/tda8290.c b/drivers/media/video/tda8290.c index a8b6a8df510..c65f0c7680a 100644 --- a/drivers/media/video/tda8290.c +++ b/drivers/media/video/tda8290.c @@ -1,5 +1,4 @@ /* - * $Id: tda8290.c,v 1.15 2005/07/08 20:21:33 mchehab Exp $ * * i2c tv tuner chip device driver * controls the philips tda8290+75 tuner chip combo. @@ -9,6 +8,9 @@ #include <linux/delay.h> #include <media/tuner.h> +#define I2C_ADDR_TDA8290 0x4b +#define I2C_ADDR_TDA8275 0x61 + /* ---------------------------------------------------------------------- */ struct freq_entry { @@ -75,10 +77,12 @@ static unsigned char i2c_init_tda8275[14] = { 0x00, 0x00, 0x00, 0x00, static unsigned char i2c_set_VS[2] = { 0x30, 0x6F }; static unsigned char i2c_set_GP01_CF[2] = { 0x20, 0x0B }; static unsigned char i2c_tda8290_reset[2] = { 0x00, 0x00 }; +static unsigned char i2c_tda8290_standby[2] = { 0x00, 0x02 }; static unsigned char i2c_gainset_off[2] = { 0x28, 0x14 }; static unsigned char i2c_gainset_on[2] = { 0x28, 0x54 }; static unsigned char i2c_agc3_00[2] = { 0x80, 0x00 }; static unsigned char i2c_agc2_BF[2] = { 0x60, 0xBF }; +static unsigned char i2c_cb1_D0[2] = { 0x30, 0xD0 }; static unsigned char i2c_cb1_D2[2] = { 0x30, 0xD2 }; static unsigned char i2c_cb1_56[2] = { 0x30, 0x56 }; static unsigned char i2c_cb1_52[2] = { 0x30, 0x52 }; @@ -117,6 +121,13 @@ static struct i2c_msg i2c_msg_epilog[] = { { I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_gainset_on), i2c_gainset_on }, }; +static struct i2c_msg i2c_msg_standby[] = { + { I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_enable_bridge), i2c_enable_bridge }, + { I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_cb1_D0), i2c_cb1_D0 }, + { I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_disable_bridge), i2c_disable_bridge }, + { I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_tda8290_standby), i2c_tda8290_standby }, +}; + static int tda8290_tune(struct i2c_client *c) { struct tuner *t = i2c_get_clientdata(c); @@ -205,6 +216,11 @@ static int has_signal(struct i2c_client *c) return (afc & 0x80)? 65535:0; } +static void standby(struct i2c_client *c) +{ + i2c_transfer(c->adapter, i2c_msg_standby, ARRAY_SIZE(i2c_msg_standby)); +} + int tda8290_init(struct i2c_client *c) { struct tuner *t = i2c_get_clientdata(c); @@ -214,6 +230,7 @@ int tda8290_init(struct i2c_client *c) t->tv_freq = set_tv_freq; t->radio_freq = set_radio_freq; t->has_signal = has_signal; + t->standby = standby; i2c_master_send(c, i2c_enable_bridge, ARRAY_SIZE(i2c_enable_bridge)); i2c_transfer(c->adapter, i2c_msg_init, ARRAY_SIZE(i2c_msg_init)); diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c index d60fc562aec..0456dda2624 100644 --- a/drivers/media/video/tda9887.c +++ b/drivers/media/video/tda9887.c @@ -23,6 +23,7 @@ TDA9887 (world), TDA9885 (USA) Note: OP2 of tda988x must be set to 1, else MT2032 is disabled! - KNC One TV-Station RDS (saa7134) + - Hauppauge PVR-150/500 (possibly more) */ @@ -49,7 +50,7 @@ MODULE_LICENSE("GPL"); struct tda9887 { struct i2c_client client; v4l2_std_id std; - unsigned int radio; + enum tuner_mode mode; unsigned int config; unsigned int pinnacle_id; unsigned int using_v4l2; @@ -196,7 +197,7 @@ static struct tvnorm tvnorms[] = { .b = ( cNegativeFmTV | cQSS ), .c = ( cDeemphasisON | - cDeemphasis50 ), + cDeemphasis75 ), .e = ( cGating_36 | cAudioIF_4_5 | cVideoIF_45_75 ), @@ -364,7 +365,7 @@ static int tda9887_set_tvnorm(struct tda9887 *t, char *buf) struct tvnorm *norm = NULL; int i; - if (t->radio) { + if (t->mode == T_RADIO) { if (t->radio_mode == V4L2_TUNER_MODE_MONO) norm = &radio_mono; else @@ -378,7 +379,7 @@ static int tda9887_set_tvnorm(struct tda9887 *t, char *buf) } } if (NULL == norm) { - dprintk(PREFIX "Oops: no tvnorm entry found\n"); + dprintk(PREFIX "Unsupported tvnorm entry - audio muted\n"); return -1; } @@ -519,6 +520,12 @@ static int tda9887_fixup_std(struct tda9887 *t) dprintk(PREFIX "insmod fixup: PAL => PAL-DK\n"); t->std = V4L2_STD_PAL_DK; break; + case '-': + /* default parameter, do nothing */ + break; + default: + printk(PREFIX "pal= argument not recognised\n"); + break; } } if ((t->std & V4L2_STD_SECAM) == V4L2_STD_SECAM) { @@ -535,6 +542,12 @@ static int tda9887_fixup_std(struct tda9887 *t) dprintk(PREFIX "insmod fixup: SECAM => SECAM-L\n"); t->std = V4L2_STD_SECAM_L; break; + case '-': + /* default parameter, do nothing */ + break; + default: + printk(PREFIX "secam= argument not recognised\n"); + break; } } return 0; @@ -569,6 +582,10 @@ static int tda9887_configure(struct tda9887 *t) tda9887_set_config(t,buf); tda9887_set_insmod(t,buf); + if (t->mode == T_STANDBY) { + buf[1] |= cForcedMuteAudioON; + } + dprintk(PREFIX "writing: b=0x%02x c=0x%02x e=0x%02x\n", buf[1],buf[2],buf[3]); @@ -653,10 +670,17 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg) /* --- configuration --- */ case AUDC_SET_RADIO: - t->radio = 1; + { + t->mode = T_RADIO; tda9887_configure(t); break; - + } + case TUNER_SET_STANDBY: + { + t->mode = T_STANDBY; + tda9887_configure(t); + break; + } case AUDC_CONFIG_PINNACLE: { int *i = arg; @@ -689,7 +713,7 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg) struct video_channel *vc = arg; CHECK_V4L2; - t->radio = 0; + t->mode = T_ANALOG_TV; if (vc->norm < ARRAY_SIZE(map)) t->std = map[vc->norm]; tda9887_fixup_std(t); @@ -701,7 +725,7 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg) v4l2_std_id *id = arg; SWITCH_V4L2; - t->radio = 0; + t->mode = T_ANALOG_TV; t->std = *id; tda9887_fixup_std(t); tda9887_configure(t); @@ -713,14 +737,14 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg) SWITCH_V4L2; if (V4L2_TUNER_ANALOG_TV == f->type) { - if (t->radio == 0) + if (t->mode == T_ANALOG_TV) return 0; - t->radio = 0; + t->mode = T_ANALOG_TV; } if (V4L2_TUNER_RADIO == f->type) { - if (t->radio == 1) + if (t->mode == T_RADIO) return 0; - t->radio = 1; + t->mode = T_RADIO; } tda9887_configure(t); break; @@ -735,7 +759,7 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg) }; struct v4l2_tuner* tuner = arg; - if (t->radio) { + if (t->mode == T_RADIO) { __u8 reg = 0; tuner->afc=0; if (1 == i2c_master_recv(&t->client,®,1)) @@ -747,7 +771,7 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg) { struct v4l2_tuner* tuner = arg; - if (t->radio) { + if (t->mode == T_RADIO) { t->radio_mode = tuner->audmode; tda9887_configure (t); } diff --git a/drivers/media/video/tea5767.c b/drivers/media/video/tea5767.c index cebcc1fa68d..38bf5094379 100644 --- a/drivers/media/video/tea5767.c +++ b/drivers/media/video/tea5767.c @@ -2,7 +2,6 @@ * For Philips TEA5767 FM Chip used on some TV Cards like Prolink Pixelview * I2C address is allways 0xC0. * - * $Id: tea5767.c,v 1.27 2005/07/31 12:10:56 mchehab Exp $ * * Copyright (c) 2005 Mauro Carvalho Chehab (mchehab@brturbo.com.br) * This code is placed under the terms of the GNU General Public License @@ -205,11 +204,6 @@ static void set_radio_freq(struct i2c_client *c, unsigned int frq) TEA5767_ST_NOISE_CTL | TEA5767_JAPAN_BAND; buffer[4] = 0; - if (t->mode == T_STANDBY) { - tuner_dbg("TEA5767 set to standby mode\n"); - buffer[3] |= TEA5767_STDBY; - } - if (t->audmode == V4L2_TUNER_MODE_MONO) { tuner_dbg("TEA5767 set to mono\n"); buffer[2] |= TEA5767_MONO; @@ -290,13 +284,31 @@ static int tea5767_stereo(struct i2c_client *c) return ((buffer[2] & TEA5767_STEREO_MASK) ? V4L2_TUNER_SUB_STEREO : 0); } +static void tea5767_standby(struct i2c_client *c) +{ + unsigned char buffer[5]; + struct tuner *t = i2c_get_clientdata(c); + unsigned div, rc; + + div = (87500 * 4 + 700 + 225 + 25) / 50; /* Set frequency to 87.5 MHz */ + buffer[0] = (div >> 8) & 0x3f; + buffer[1] = div & 0xff; + buffer[2] = TEA5767_PORT1_HIGH; + buffer[3] = TEA5767_PORT2_HIGH | TEA5767_HIGH_CUT_CTRL | + TEA5767_ST_NOISE_CTL | TEA5767_JAPAN_BAND | TEA5767_STDBY; + buffer[4] = 0; + + if (5 != (rc = i2c_master_send(c, buffer, 5))) + tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc); +} + int tea5767_autodetection(struct i2c_client *c) { unsigned char buffer[7] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; int rc; struct tuner *t = i2c_get_clientdata(c); - if (7 != (rc = i2c_master_recv(c, buffer, 7))) { + if ((rc = i2c_master_recv(c, buffer, 7))< 5) { tuner_warn("It is not a TEA5767. Received %i bytes.\n", rc); return EINVAL; } @@ -313,15 +325,10 @@ int tea5767_autodetection(struct i2c_client *c) * bit 0 : internally set to 0 * Byte 5: bit 7:0 : == 0 */ - if (!((buffer[3] & 0x0f) == 0x00) && (buffer[4] == 0x00)) { + if (((buffer[3] & 0x0f) != 0x00) || (buffer[4] != 0x00)) { tuner_warn("Chip ID is not zero. It is not a TEA5767\n"); return EINVAL; } - /* It seems that tea5767 returns 0xff after the 5th byte */ - if ((buffer[5] != 0xff) || (buffer[6] != 0xff)) { - tuner_warn("Returned more than 5 bytes. It is not a TEA5767\n"); - return EINVAL; - } /* It seems that tea5767 returns 0xff after the 5th byte */ if ((buffer[5] != 0xff) || (buffer[6] != 0xff)) { @@ -337,14 +344,14 @@ int tea5767_tuner_init(struct i2c_client *c) { struct tuner *t = i2c_get_clientdata(c); - tuner_info("type set to %d (%s)\n", t->type, - "Philips TEA5767HN FM Radio"); + tuner_info("type set to %d (%s)\n", t->type, "Philips TEA5767HN FM Radio"); strlcpy(c->name, "tea5767", sizeof(c->name)); t->tv_freq = set_tv_freq; t->radio_freq = set_radio_freq; t->has_signal = tea5767_signal; t->is_stereo = tea5767_stereo; + t->standby = tea5767_standby; return (0); } diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index 3b1893c2ae3..05572020af4 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c @@ -1,5 +1,4 @@ /* - * $Id: tuner-core.c,v 1.63 2005/07/28 18:19:55 mchehab Exp $ * * i2c tv tuner chip device driver * core core, i.e. kernel interfaces, registering and so on @@ -182,6 +181,14 @@ static void set_type(struct i2c_client *c, unsigned int type, i2c_master_send(c, buffer, 4); default_tuner_init(c); break; + case TUNER_LG_TDVS_H062F: + /* Set the Auxiliary Byte. */ + buffer[2] &= ~0x20; + buffer[2] |= 0x18; + buffer[3] = 0x20; + i2c_master_send(c, buffer, 4); + default_tuner_init(c); + break; default: default_tuner_init(c); break; @@ -208,31 +215,31 @@ static void set_addr(struct i2c_client *c, struct tuner_setup *tun_setup) { struct tuner *t = i2c_get_clientdata(c); - if (tun_setup->addr == ADDR_UNSET) { - if (t->mode_mask & tun_setup->mode_mask) + if ((tun_setup->addr == ADDR_UNSET && + (t->mode_mask & tun_setup->mode_mask)) || + tun_setup->addr == c->addr) { set_type(c, tun_setup->type, tun_setup->mode_mask); - } else if (tun_setup->addr == c->addr) { - set_type(c, tun_setup->type, tun_setup->mode_mask); } } static inline int check_mode(struct tuner *t, char *cmd) { - if (1 << t->mode & t->mode_mask) { - switch (t->mode) { - case V4L2_TUNER_RADIO: - tuner_dbg("Cmd %s accepted for radio\n", cmd); - break; - case V4L2_TUNER_ANALOG_TV: - tuner_dbg("Cmd %s accepted for analog TV\n", cmd); - break; - case V4L2_TUNER_DIGITAL_TV: - tuner_dbg("Cmd %s accepted for digital TV\n", cmd); - break; - } - return 0; + if ((1 << t->mode & t->mode_mask) == 0) { + return EINVAL; + } + + switch (t->mode) { + case V4L2_TUNER_RADIO: + tuner_dbg("Cmd %s accepted for radio\n", cmd); + break; + case V4L2_TUNER_ANALOG_TV: + tuner_dbg("Cmd %s accepted for analog TV\n", cmd); + break; + case V4L2_TUNER_DIGITAL_TV: + tuner_dbg("Cmd %s accepted for digital TV\n", cmd); + break; } - return EINVAL; + return 0; } static char pal[] = "-"; @@ -274,6 +281,12 @@ static int tuner_fixup_std(struct tuner *t) tuner_dbg ("insmod fixup: PAL => PAL-N\n"); t->std = V4L2_STD_PAL_N; break; + case '-': + /* default parameter, do nothing */ + break; + default: + tuner_warn ("pal= argument not recognised\n"); + break; } } if ((t->std & V4L2_STD_SECAM) == V4L2_STD_SECAM) { @@ -290,6 +303,12 @@ static int tuner_fixup_std(struct tuner *t) tuner_dbg ("insmod fixup: SECAM => SECAM-L\n"); t->std = V4L2_STD_SECAM_L; break; + case '-': + /* default parameter, do nothing */ + break; + default: + tuner_warn ("secam= argument not recognised\n"); + break; } } @@ -406,20 +425,18 @@ static int tuner_detach(struct i2c_client *client) static inline int set_mode(struct i2c_client *client, struct tuner *t, int mode, char *cmd) { - if (mode != t->mode) { - - t->mode = mode; - if (check_mode(t, cmd) == EINVAL) { - t->mode = T_STANDBY; - if (V4L2_TUNER_RADIO == mode) { - set_tv_freq(client, 400 * 16); - } else { - set_radio_freq(client, 87.5 * 16000); - } - return EINVAL; - } - } - return 0; + if (mode == t->mode) + return 0; + + t->mode = mode; + + if (check_mode(t, cmd) == EINVAL) { + t->mode = T_STANDBY; + if (t->standby) + t->standby (client); + return EINVAL; + } + return 0; } #define switch_v4l2() if (!t->using_v4l2) \ @@ -453,6 +470,14 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) case AUDC_SET_RADIO: set_mode(client,t,V4L2_TUNER_RADIO, "AUDC_SET_RADIO"); break; + case TUNER_SET_STANDBY: + { + if (check_mode(t, "TUNER_SET_STANDBY") == EINVAL) + return 0; + if (t->standby) + t->standby (client); + break; + } case AUDC_CONFIG_PINNACLE: if (check_mode(t, "AUDC_CONFIG_PINNACLE") == EINVAL) return 0; diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c index de0c93aeb75..8edd73abe1d 100644 --- a/drivers/media/video/tuner-simple.c +++ b/drivers/media/video/tuner-simple.c @@ -1,5 +1,4 @@ /* - * $Id: tuner-simple.c,v 1.43 2005/07/28 18:41:21 mchehab Exp $ * * i2c tv tuner chip device driver * controls all those simple 4-control-bytes style tuners. @@ -102,6 +101,7 @@ struct tunertype * "no float in kernel" rule. */ static struct tunertype tuners[] = { + /* 0-9 */ { "Temic PAL (4002 FH5)", TEMIC, PAL, 16*140.25,16*463.25,0x02,0x04,0x01,0x8e,623}, { "Philips PAL_I (FI1246 and compatibles)", Philips, PAL_I, @@ -110,7 +110,6 @@ static struct tunertype tuners[] = { 16*157.25,16*451.25,0xA0,0x90,0x30,0x8e,732}, { "Philips (SECAM+PAL_BG) (FI1216MF, FM1216MF, FR1216MF)", Philips, SECAM, 16*168.25,16*447.25,0xA7,0x97,0x37,0x8e,623}, - { "NoTuner", NoTuner, NOTUNER, 0,0,0x00,0x00,0x00,0x00,0x00}, { "Philips PAL_BG (FI1216 and compatibles)", Philips, PAL, @@ -119,34 +118,34 @@ static struct tunertype tuners[] = { 16*157.25,16*463.25,0x02,0x04,0x01,0x8e,732}, { "Temic PAL_I (4062 FY5)", TEMIC, PAL_I, 16*170.00,16*450.00,0x02,0x04,0x01,0x8e,623}, - { "Temic NTSC (4036 FY5)", TEMIC, NTSC, 16*157.25,16*463.25,0xa0,0x90,0x30,0x8e,732}, { "Alps HSBH1", TEMIC, NTSC, 16*137.25,16*385.25,0x01,0x02,0x08,0x8e,732}, - { "Alps TSBE1",TEMIC,PAL, + + /* 10-19 */ + { "Alps TSBE1", TEMIC, PAL, 16*137.25,16*385.25,0x01,0x02,0x08,0x8e,732}, { "Alps TSBB5", Alps, PAL_I, /* tested (UK UHF) with Modulartech MM205 */ 16*133.25,16*351.25,0x01,0x02,0x08,0x8e,632}, - { "Alps TSBE5", Alps, PAL, /* untested - data sheet guess. Only IF differs. */ 16*133.25,16*351.25,0x01,0x02,0x08,0x8e,622}, { "Alps TSBC5", Alps, PAL, /* untested - data sheet guess. Only IF differs. */ 16*133.25,16*351.25,0x01,0x02,0x08,0x8e,608}, { "Temic PAL_BG (4006FH5)", TEMIC, PAL, 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623}, - { "Alps TSCH6",Alps,NTSC, + { "Alps TSCH6", Alps, NTSC, 16*137.25,16*385.25,0x14,0x12,0x11,0x8e,732}, - - { "Temic PAL_DK (4016 FY5)",TEMIC,PAL, + { "Temic PAL_DK (4016 FY5)", TEMIC, PAL, 16*168.25,16*456.25,0xa0,0x90,0x30,0x8e,623}, - { "Philips NTSC_M (MK2)",Philips,NTSC, + { "Philips NTSC_M (MK2)", Philips, NTSC, 16*160.00,16*454.00,0xa0,0x90,0x30,0x8e,732}, { "Temic PAL_I (4066 FY5)", TEMIC, PAL_I, 16*169.00, 16*454.00, 0xa0,0x90,0x30,0x8e,623}, { "Temic PAL* auto (4006 FN5)", TEMIC, PAL, 16*169.00, 16*454.00, 0xa0,0x90,0x30,0x8e,623}, + /* 20-29 */ { "Temic PAL_BG (4009 FR5) or PAL_I (4069 FR5)", TEMIC, PAL, 16*141.00, 16*464.00, 0xa0,0x90,0x30,0x8e,623}, { "Temic NTSC (4039 FR5)", TEMIC, NTSC, @@ -155,7 +154,6 @@ static struct tunertype tuners[] = { 16*169.00, 16*454.00, 0xa0,0x90,0x30,0x8e,623}, { "Philips PAL_DK (FI1256 and compatibles)", Philips, PAL, 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623}, - { "Philips PAL/SECAM multi (FQ1216ME)", Philips, PAL, 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623}, { "LG PAL_I+FM (TAPC-I001D)", LGINNOTEK, PAL_I, @@ -164,25 +162,24 @@ static struct tunertype tuners[] = { 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623}, { "LG NTSC+FM (TPI8NSR01F)", LGINNOTEK, NTSC, 16*210.00,16*497.00,0xa0,0x90,0x30,0x8e,732}, - { "LG PAL_BG+FM (TPI8PSB01D)", LGINNOTEK, PAL, 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623}, { "LG PAL_BG (TPI8PSB11D)", LGINNOTEK, PAL, 16*170.00,16*450.00,0xa0,0x90,0x30,0x8e,623}, + + /* 30-39 */ { "Temic PAL* auto + FM (4009 FN5)", TEMIC, PAL, 16*141.00, 16*464.00, 0xa0,0x90,0x30,0x8e,623}, { "SHARP NTSC_JP (2U5JF5540)", SHARP, NTSC, /* 940=16*58.75 NTSC@Japan */ 16*137.25,16*317.25,0x01,0x02,0x08,0x8e,940 }, - - { "Samsung PAL TCPM9091PD27", Samsung, PAL, /* from sourceforge v3tv */ + { "Samsung PAL TCPM9091PD27", Samsung, PAL, /* from sourceforge v3tv */ 16*169,16*464,0xA0,0x90,0x30,0x8e,623}, - { "MT20xx universal", Microtune,PAL|NTSC, + { "MT20xx universal", Microtune, PAL|NTSC, /* see mt20xx.c for details */ }, { "Temic PAL_BG (4106 FH5)", TEMIC, PAL, 16*141.00, 16*464.00, 0xa0,0x90,0x30,0x8e,623}, { "Temic PAL_DK/SECAM_L (4012 FY5)", TEMIC, PAL, 16*140.25, 16*463.25, 0x02,0x04,0x01,0x8e,623}, - { "Temic NTSC (4136 FY5)", TEMIC, NTSC, 16*158.00, 16*453.00, 0xa0,0x90,0x30,0x8e,732}, { "LG PAL (newer TAPC series)", LGINNOTEK, PAL, @@ -192,42 +189,41 @@ static struct tunertype tuners[] = { { "LG NTSC (newer TAPC series)", LGINNOTEK, NTSC, 16*170.00, 16*450.00, 0x01,0x02,0x08,0x8e,732}, + /* 40-49 */ { "HITACHI V7-J180AT", HITACHI, NTSC, 16*170.00, 16*450.00, 0x01,0x02,0x08,0x8e,940 }, { "Philips PAL_MK (FI1216 MK)", Philips, PAL, 16*140.25,16*463.25,0x01,0xc2,0xcf,0x8e,623}, - { "Philips 1236D ATSC/NTSC daul in",Philips,ATSC, + { "Philips 1236D ATSC/NTSC daul in", Philips, ATSC, 16*157.25,16*454.00,0xa0,0x90,0x30,0x8e,732}, { "Philips NTSC MK3 (FM1236MK3 or FM1236/F)", Philips, NTSC, 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732}, - { "Philips 4 in 1 (ATI TV Wonder Pro/Conexant)", Philips, NTSC, 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732}, - { "Microtune 4049 FM5",Microtune,PAL, + { "Microtune 4049 FM5", Microtune, PAL, 16*141.00,16*464.00,0xa0,0x90,0x30,0x8e,623}, { "Panasonic VP27s/ENGE4324D", Panasonic, NTSC, 16*160.00,16*454.00,0x01,0x02,0x08,0xce,940}, { "LG NTSC (TAPE series)", LGINNOTEK, NTSC, 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732 }, - { "Tenna TNF 8831 BGFF)", Philips, PAL, 16*161.25,16*463.25,0xa0,0x90,0x30,0x8e,623}, { "Microtune 4042 FI5 ATSC/NTSC dual in", Microtune, NTSC, 16*162.00,16*457.00,0xa2,0x94,0x31,0x8e,732}, + + /* 50-59 */ { "TCL 2002N", TCL, NTSC, 16*172.00,16*448.00,0x01,0x02,0x08,0x8e,732}, { "Philips PAL/SECAM_D (FM 1256 I-H3)", Philips, PAL, 16*160.00,16*442.00,0x01,0x02,0x04,0x8e,623 }, - { "Thomson DDT 7610 (ATSC/NTSC)", THOMSON, ATSC, 16*157.25,16*454.00,0x39,0x3a,0x3c,0x8e,732}, { "Philips FQ1286", Philips, NTSC, - 16*160.00,16*454.00,0x41,0x42,0x04,0x8e,940}, // UHF band untested - { "tda8290+75", Philips,PAL|NTSC, + 16*160.00,16*454.00,0x41,0x42,0x04,0x8e,940}, /* UHF band untested */ + { "tda8290+75", Philips, PAL|NTSC, /* see tda8290.c for details */ }, { "LG PAL (TAPE series)", LGINNOTEK, PAL, 16*170.00, 16*450.00, 0x01,0x02,0x08,0xce,623}, - { "Philips PAL/SECAM multi (FQ1216AME MK4)", Philips, PAL, 16*160.00,16*442.00,0x01,0x02,0x04,0xce,623 }, { "Philips FQ1236A MK4", Philips, NTSC, @@ -237,6 +233,7 @@ static struct tunertype tuners[] = { { "Ymec TVision TVF-5533MF", Philips, NTSC, 16*160.00,16*454.00,0x01,0x02,0x04,0x8e,732}, + /* 60-66 */ { "Thomson DDT 7611 (ATSC/NTSC)", THOMSON, ATSC, 16*157.25,16*454.00,0x39,0x3a,0x3c,0x8e,732}, { "Tena TNF9533-D/IF/TNF9533-B/DF", Philips, PAL, @@ -245,12 +242,12 @@ static struct tunertype tuners[] = { /* see tea5767.c for details */}, { "Philips FMD1216ME MK3 Hybrid Tuner", Philips, PAL, 16*160.00,16*442.00,0x51,0x52,0x54,0x86,623 }, - - { "LG TDVS-H062F/TUA6034", LGINNOTEK, NTSC, + { "LG TDVS-H062F/TUA6034", LGINNOTEK, ATSC, 16*160.00,16*455.00,0x01,0x02,0x04,0x8e,732}, - { "Ymec TVF66T5-B/DFF", Philips, PAL, 16*160.25,16*464.25,0x01,0x02,0x08,0x8e,623}, + { "LG NTSC (TALN mini series)", LGINNOTEK, NTSC, + 16*137.25,16*373.25,0x01,0x02,0x08,0x8e,732 }, }; unsigned const int tuner_count = ARRAY_SIZE(tuners); @@ -471,6 +468,10 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq) case TUNER_LG_PAL_FM: buffer[3] = 0xa5; break; + case TUNER_MICROTUNE_4049FM5: + div = (20 * freq) / 16000 + (int)(33.3 * 20); /* IF 33.3 MHz */ + buffer[3] = 0xa4; + break; default: buffer[3] = 0xa4; break; @@ -497,6 +498,7 @@ int default_tuner_init(struct i2c_client *c) t->radio_freq = default_set_radio_freq; t->has_signal = tuner_signal; t->is_stereo = tuner_stereo; + t->standby = NULL; return 0; } diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index 258724b2d6d..1c31ef52f86 100644 --- a/drivers/media/video/tvaudio.c +++ b/drivers/media/video/tvaudio.c @@ -46,7 +46,17 @@ MODULE_AUTHOR("Eric Sandeen, Steve VanDeBogart, Greg Alexander, Gerd Knorr"); MODULE_LICENSE("GPL"); #define UNSET (-1U) -#define dprintk if (debug) printk + +#define tvaudio_info(fmt, arg...) do {\ + printk(KERN_INFO "tvaudio %d-%04x: " fmt, \ + chip->c.adapter->nr, chip->c.addr , ##arg); } while (0) +#define tvaudio_warn(fmt, arg...) do {\ + printk(KERN_WARNING "tvaudio %d-%04x: " fmt, \ + chip->c.adapter->nr, chip->c.addr , ##arg); } while (0) +#define tvaudio_dbg(fmt, arg...) do {\ + if (debug) \ + printk(KERN_INFO "tvaudio %d-%04x: " fmt, \ + chip->c.adapter->nr, chip->c.addr , ##arg); } while (0) /* ---------------------------------------------------------------------- */ /* our structs */ @@ -162,23 +172,24 @@ static int chip_write(struct CHIPSTATE *chip, int subaddr, int val) unsigned char buffer[2]; if (-1 == subaddr) { - dprintk("%s: chip_write: 0x%x\n", chip->c.name, val); + tvaudio_dbg("%s: chip_write: 0x%x\n", + chip->c.name, val); chip->shadow.bytes[1] = val; buffer[0] = val; if (1 != i2c_master_send(&chip->c,buffer,1)) { - printk(KERN_WARNING "%s: I/O error (write 0x%x)\n", - chip->c.name, val); + tvaudio_warn("%s: I/O error (write 0x%x)\n", + chip->c.name, val); return -1; } } else { - dprintk("%s: chip_write: reg%d=0x%x\n", + tvaudio_dbg("%s: chip_write: reg%d=0x%x\n", chip->c.name, subaddr, val); chip->shadow.bytes[subaddr+1] = val; buffer[0] = subaddr; buffer[1] = val; if (2 != i2c_master_send(&chip->c,buffer,2)) { - printk(KERN_WARNING "%s: I/O error (write reg%d=0x%x)\n", - chip->c.name, subaddr, val); + tvaudio_warn("%s: I/O error (write reg%d=0x%x)\n", + chip->c.name, subaddr, val); return -1; } } @@ -202,29 +213,30 @@ static int chip_read(struct CHIPSTATE *chip) unsigned char buffer; if (1 != i2c_master_recv(&chip->c,&buffer,1)) { - printk(KERN_WARNING "%s: I/O error (read)\n", chip->c.name); + tvaudio_warn("%s: I/O error (read)\n", + chip->c.name); return -1; } - dprintk("%s: chip_read: 0x%x\n", chip->c.name, buffer); + tvaudio_dbg("%s: chip_read: 0x%x\n",chip->c.name,buffer); return buffer; } static int chip_read2(struct CHIPSTATE *chip, int subaddr) { - unsigned char write[1]; - unsigned char read[1]; - struct i2c_msg msgs[2] = { - { chip->c.addr, 0, 1, write }, - { chip->c.addr, I2C_M_RD, 1, read } - }; - write[0] = subaddr; + unsigned char write[1]; + unsigned char read[1]; + struct i2c_msg msgs[2] = { + { chip->c.addr, 0, 1, write }, + { chip->c.addr, I2C_M_RD, 1, read } + }; + write[0] = subaddr; if (2 != i2c_transfer(chip->c.adapter,msgs,2)) { - printk(KERN_WARNING "%s: I/O error (read2)\n", chip->c.name); + tvaudio_warn("%s: I/O error (read2)\n", chip->c.name); return -1; } - dprintk("%s: chip_read2: reg%d=0x%x\n", - chip->c.name, subaddr, read[0]); + tvaudio_dbg("%s: chip_read2: reg%d=0x%x\n", + chip->c.name,subaddr,read[0]); return read[0]; } @@ -236,17 +248,19 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd) return 0; /* update our shadow register set; print bytes if (debug > 0) */ - dprintk("%s: chip_cmd(%s): reg=%d, data:", - chip->c.name, name, cmd->bytes[0]); + tvaudio_dbg("%s: chip_cmd(%s): reg=%d, data:", + chip->c.name,name,cmd->bytes[0]); for (i = 1; i < cmd->count; i++) { - dprintk(" 0x%x",cmd->bytes[i]); + if (debug) + printk(" 0x%x",cmd->bytes[i]); chip->shadow.bytes[i+cmd->bytes[0]] = cmd->bytes[i]; } - dprintk("\n"); + if (debug) + printk("\n"); /* send data to the chip */ if (cmd->count != i2c_master_send(&chip->c,cmd->bytes,cmd->count)) { - printk(KERN_WARNING "%s: I/O error (%s)\n", chip->c.name, name); + tvaudio_warn("%s: I/O error (%s)\n", chip->c.name, name); return -1; } return 0; @@ -261,19 +275,19 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd) static void chip_thread_wake(unsigned long data) { - struct CHIPSTATE *chip = (struct CHIPSTATE*)data; + struct CHIPSTATE *chip = (struct CHIPSTATE*)data; wake_up_interruptible(&chip->wq); } static int chip_thread(void *data) { DECLARE_WAITQUEUE(wait, current); - struct CHIPSTATE *chip = data; + struct CHIPSTATE *chip = data; struct CHIPDESC *desc = chiplist + chip->type; daemonize("%s", chip->c.name); allow_signal(SIGTERM); - dprintk("%s: thread started\n", chip->c.name); + tvaudio_dbg("%s: thread started\n", chip->c.name); for (;;) { add_wait_queue(&chip->wq, &wait); @@ -285,7 +299,7 @@ static int chip_thread(void *data) try_to_freeze(); if (chip->done || signal_pending(current)) break; - dprintk("%s: thread wakeup\n", chip->c.name); + tvaudio_dbg("%s: thread wakeup\n", chip->c.name); /* don't do anything for radio or if mode != auto */ if (chip->norm == VIDEO_MODE_RADIO || chip->mode != 0) @@ -298,8 +312,8 @@ static int chip_thread(void *data) mod_timer(&chip->wt, jiffies+2*HZ); } - dprintk("%s: thread exiting\n", chip->c.name); - complete_and_exit(&chip->texit, 0); + tvaudio_dbg("%s: thread exiting\n", chip->c.name); + complete_and_exit(&chip->texit, 0); return 0; } @@ -309,9 +323,9 @@ static void generic_checkmode(struct CHIPSTATE *chip) int mode = desc->getmode(chip); if (mode == chip->prevmode) - return; + return; - dprintk("%s: thread checkmode\n", chip->c.name); + tvaudio_dbg("%s: thread checkmode\n", chip->c.name); chip->prevmode = mode; if (mode & VIDEO_SOUND_STEREO) @@ -358,8 +372,8 @@ static int tda9840_getmode(struct CHIPSTATE *chip) if (val & TDA9840_ST_STEREO) mode |= VIDEO_SOUND_STEREO; - dprintk ("tda9840_getmode(): raw chip read: %d, return: %d\n", - val, mode); + tvaudio_dbg ("tda9840_getmode(): raw chip read: %d, return: %d\n", + val, mode); return mode; } @@ -654,8 +668,8 @@ static int tda9873_getmode(struct CHIPSTATE *chip) mode |= VIDEO_SOUND_STEREO; if (val & TDA9873_DUAL) mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; - dprintk ("tda9873_getmode(): raw chip read: %d, return: %d\n", - val, mode); + tvaudio_dbg ("tda9873_getmode(): raw chip read: %d, return: %d\n", + val, mode); return mode; } @@ -665,12 +679,12 @@ static void tda9873_setmode(struct CHIPSTATE *chip, int mode) /* int adj_data = chip->shadow.bytes[TDA9873_AD+1] ; */ if ((sw_data & TDA9873_INP_MASK) != TDA9873_INTERNAL) { - dprintk("tda9873_setmode(): external input\n"); + tvaudio_dbg("tda9873_setmode(): external input\n"); return; } - dprintk("tda9873_setmode(): chip->shadow.bytes[%d] = %d\n", TDA9873_SW+1, chip->shadow.bytes[TDA9873_SW+1]); - dprintk("tda9873_setmode(): sw_data = %d\n", sw_data); + tvaudio_dbg("tda9873_setmode(): chip->shadow.bytes[%d] = %d\n", TDA9873_SW+1, chip->shadow.bytes[TDA9873_SW+1]); + tvaudio_dbg("tda9873_setmode(): sw_data = %d\n", sw_data); switch (mode) { case VIDEO_SOUND_MONO: @@ -691,7 +705,7 @@ static void tda9873_setmode(struct CHIPSTATE *chip, int mode) } chip_write(chip, TDA9873_SW, sw_data); - dprintk("tda9873_setmode(): req. mode %d; chip_write: %d\n", + tvaudio_dbg("tda9873_setmode(): req. mode %d; chip_write: %d\n", mode, sw_data); } @@ -828,9 +842,9 @@ static int tda9874a_setup(struct CHIPSTATE *chip) } else { /* dic == 0x07 */ chip_write(chip, TDA9874A_AMCONR, 0xfb); chip_write(chip, TDA9874A_SDACOSR, (tda9874a_mode) ? 0x81:0x80); - chip_write(chip, TDA9874A_AOSR, 0x00); // or 0x10 + chip_write(chip, TDA9874A_AOSR, 0x00); /* or 0x10 */ } - dprintk("tda9874a_setup(): %s [0x%02X].\n", + tvaudio_dbg("tda9874a_setup(): %s [0x%02X].\n", tda9874a_modelist[tda9874a_STD].name,tda9874a_STD); return 1; } @@ -873,7 +887,7 @@ static int tda9874a_getmode(struct CHIPSTATE *chip) mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; } - dprintk("tda9874a_getmode(): DSR=0x%X, NSR=0x%X, NECR=0x%X, return: %d.\n", + tvaudio_dbg("tda9874a_getmode(): DSR=0x%X, NSR=0x%X, NECR=0x%X, return: %d.\n", dsr, nsr, necr, mode); return mode; } @@ -919,7 +933,7 @@ static void tda9874a_setmode(struct CHIPSTATE *chip, int mode) chip_write(chip, TDA9874A_AOSR, aosr); chip_write(chip, TDA9874A_MDACOSR, mdacosr); - dprintk("tda9874a_setmode(): req. mode %d; AOSR=0x%X, MDACOSR=0x%X.\n", + tvaudio_dbg("tda9874a_setmode(): req. mode %d; AOSR=0x%X, MDACOSR=0x%X.\n", mode, aosr, mdacosr); } else { /* dic == 0x07 */ @@ -954,7 +968,7 @@ static void tda9874a_setmode(struct CHIPSTATE *chip, int mode) chip_write(chip, TDA9874A_FMMR, fmmr); chip_write(chip, TDA9874A_AOSR, aosr); - dprintk("tda9874a_setmode(): req. mode %d; FMMR=0x%X, AOSR=0x%X.\n", + tvaudio_dbg("tda9874a_setmode(): req. mode %d; FMMR=0x%X, AOSR=0x%X.\n", mode, fmmr, aosr); } } @@ -968,10 +982,10 @@ static int tda9874a_checkit(struct CHIPSTATE *chip) if(-1 == (sic = chip_read2(chip,TDA9874A_SIC))) return 0; - dprintk("tda9874a_checkit(): DIC=0x%X, SIC=0x%X.\n", dic, sic); + tvaudio_dbg("tda9874a_checkit(): DIC=0x%X, SIC=0x%X.\n", dic, sic); if((dic == 0x11)||(dic == 0x07)) { - printk("tvaudio: found tda9874%s.\n", (dic == 0x11) ? "a":"h"); + tvaudio_info("found tda9874%s.\n", (dic == 0x11) ? "a":"h"); tda9874a_dic = dic; /* remember device id. */ return 1; } @@ -1146,7 +1160,7 @@ static void tda8425_setmode(struct CHIPSTATE *chip, int mode) /* ---------------------------------------------------------------------- */ /* audio chip descriptions - defines+functions for TA8874Z */ -// write 1st byte +/* write 1st byte */ #define TA8874Z_LED_STE 0x80 #define TA8874Z_LED_BIL 0x40 #define TA8874Z_LED_EXT 0x20 @@ -1156,21 +1170,22 @@ static void tda8425_setmode(struct CHIPSTATE *chip, int mode) #define TA8874Z_MODE_SUB 0x02 #define TA8874Z_MODE_MAIN 0x01 -// write 2nd byte -//#define TA8874Z_TI 0x80 // test mode +/* write 2nd byte */ +/*#define TA8874Z_TI 0x80 */ /* test mode */ #define TA8874Z_SEPARATION 0x3f #define TA8874Z_SEPARATION_DEFAULT 0x10 -// read +/* read */ #define TA8874Z_B1 0x80 #define TA8874Z_B0 0x40 #define TA8874Z_CHAG_FLAG 0x20 -// B1 B0 -// mono L H -// stereo L L -// BIL H L - +/* + * B1 B0 + * mono L H + * stereo L L + * BIL H L + */ static int ta8874z_getmode(struct CHIPSTATE *chip) { int val, mode; @@ -1182,7 +1197,7 @@ static int ta8874z_getmode(struct CHIPSTATE *chip) }else if (!(val & TA8874Z_B0)){ mode |= VIDEO_SOUND_STEREO; } - //dprintk ("ta8874z_getmode(): raw chip read: 0x%02x, return: 0x%02x\n", val, mode); + /* tvaudio_dbg ("ta8874z_getmode(): raw chip read: 0x%02x, return: 0x%02x\n", val, mode); */ return mode; } @@ -1195,7 +1210,7 @@ static void ta8874z_setmode(struct CHIPSTATE *chip, int mode) { int update = 1; audiocmd *t = NULL; - dprintk("ta8874z_setmode(): mode: 0x%02x\n", mode); + tvaudio_dbg("ta8874z_setmode(): mode: 0x%02x\n", mode); switch(mode){ case VIDEO_SOUND_MONO: @@ -1235,11 +1250,11 @@ static int tda9850 = 1; static int tda9855 = 1; static int tda9873 = 1; static int tda9874a = 1; -static int tea6300 = 0; // address clash with msp34xx -static int tea6320 = 0; // address clash with msp34xx +static int tea6300 = 0; /* address clash with msp34xx */ +static int tea6320 = 0; /* address clash with msp34xx */ static int tea6420 = 1; static int pic16c54 = 1; -static int ta8874z = 0; // address clash with tda9840 +static int ta8874z = 0; /* address clash with tda9840 */ module_param(tda8425, int, 0444); module_param(tda9840, int, 0444); @@ -1441,7 +1456,7 @@ static struct CHIPDESC chiplist[] = { { .name = "ta8874z", .id = -1, - //.id = I2C_DRIVERID_TA8874Z, + /*.id = I2C_DRIVERID_TA8874Z, */ .checkit = ta8874z_checkit, .insmodopt = &ta8874z, .addr_lo = I2C_TDA9840 >> 1, @@ -1476,7 +1491,7 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind) i2c_set_clientdata(&chip->c, chip); /* find description for the chip */ - dprintk("tvaudio: chip found @ i2c-addr=0x%x\n", addr<<1); + tvaudio_dbg("chip found @ 0x%x\n", addr<<1); for (desc = chiplist; desc->name != NULL; desc++) { if (0 == *(desc->insmodopt)) continue; @@ -1488,17 +1503,19 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind) break; } if (desc->name == NULL) { - dprintk("tvaudio: no matching chip description found\n"); + tvaudio_dbg("no matching chip description found\n"); return -EIO; } - printk("tvaudio: found %s @ 0x%x\n", desc->name, addr<<1); - dprintk("tvaudio: matches:%s%s%s.\n", - (desc->flags & CHIP_HAS_VOLUME) ? " volume" : "", - (desc->flags & CHIP_HAS_BASSTREBLE) ? " bass/treble" : "", - (desc->flags & CHIP_HAS_INPUTSEL) ? " audiomux" : ""); + tvaudio_info("%s found @ 0x%x (%s)\n", desc->name, addr<<1, adap->name); + if (desc->flags) { + tvaudio_dbg("matches:%s%s%s.\n", + (desc->flags & CHIP_HAS_VOLUME) ? " volume" : "", + (desc->flags & CHIP_HAS_BASSTREBLE) ? " bass/treble" : "", + (desc->flags & CHIP_HAS_INPUTSEL) ? " audiomux" : ""); + } /* fill required data structures */ - strcpy(chip->c.name, desc->name); + strcpy(chip->c.name,desc->name); chip->type = desc-chiplist; chip->shadow.count = desc->registers+1; chip->prevmode = -1; @@ -1534,7 +1551,7 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind) init_completion(&chip->texit); chip->tpid = kernel_thread(chip_thread,(void *)chip,0); if (chip->tpid < 0) - printk(KERN_WARNING "%s: kernel_thread() failed\n", + tvaudio_warn("%s: kernel_thread() failed\n", chip->c.name); wake_up_interruptible(&chip->wq); } @@ -1545,7 +1562,7 @@ static int chip_probe(struct i2c_adapter *adap) { /* don't attach on saa7146 based cards, because dedicated drivers are used */ - if (adap->id == I2C_HW_SAA7146) + if ((adap->id == I2C_HW_SAA7146)) return 0; #ifdef I2C_CLASS_TV_ANALOG if (adap->class & I2C_CLASS_TV_ANALOG) @@ -1584,11 +1601,11 @@ static int chip_detach(struct i2c_client *client) static int chip_command(struct i2c_client *client, unsigned int cmd, void *arg) { - __u16 *sarg = arg; + __u16 *sarg = arg; struct CHIPSTATE *chip = i2c_get_clientdata(client); struct CHIPDESC *desc = chiplist + chip->type; - dprintk("%s: chip_command 0x%x\n", chip->c.name, cmd); + tvaudio_dbg("%s: chip_command 0x%x\n",chip->c.name,cmd); switch (cmd) { case AUDC_SET_INPUT: @@ -1601,7 +1618,6 @@ static int chip_command(struct i2c_client *client, break; case AUDC_SET_RADIO: - dprintk(KERN_DEBUG "tvaudio: AUDC_SET_RADIO\n"); chip->norm = VIDEO_MODE_RADIO; chip->watch_stereo = 0; /* del_timer(&chip->wt); */ @@ -1609,7 +1625,7 @@ static int chip_command(struct i2c_client *client, /* --- v4l ioctls --- */ /* take care: bttv does userspace copying, we'll get a - kernel pointer here... */ + kernel pointer here... */ case VIDIOCGAUDIO: { struct video_audio *va = arg; @@ -1643,9 +1659,9 @@ static int chip_command(struct i2c_client *client, if (desc->flags & CHIP_HAS_VOLUME) { chip->left = (min(65536 - va->balance,32768) * - va->volume) / 32768; + va->volume) / 32768; chip->right = (min(va->balance,(__u16)32768) * - va->volume) / 32768; + va->volume) / 32768; chip_write(chip,desc->leftreg,desc->volfunc(chip->left)); chip_write(chip,desc->rightreg,desc->volfunc(chip->right)); } @@ -1667,17 +1683,16 @@ static int chip_command(struct i2c_client *client, { struct video_channel *vc = arg; - dprintk(KERN_DEBUG "tvaudio: VIDIOCSCHAN\n"); chip->norm = vc->norm; break; } case VIDIOCSFREQ: { - chip->mode = 0; /* automatic */ + chip->mode = 0; /* automatic */ if (desc->checkmode) { desc->setmode(chip,VIDEO_SOUND_MONO); - if (chip->prevmode != VIDEO_SOUND_MONO) - chip->prevmode = -1; /* reset previous mode */ + if (chip->prevmode != VIDEO_SOUND_MONO) + chip->prevmode = -1; /* reset previous mode */ mod_timer(&chip->wt, jiffies+2*HZ); /* the thread will call checkmode() later */ } @@ -1689,29 +1704,32 @@ static int chip_command(struct i2c_client *client, static struct i2c_driver driver = { .owner = THIS_MODULE, - .name = "generic i2c audio driver", - .id = I2C_DRIVERID_TVAUDIO, - .flags = I2C_DF_NOTIFY, - .attach_adapter = chip_probe, - .detach_client = chip_detach, - .command = chip_command, + .name = "generic i2c audio driver", + .id = I2C_DRIVERID_TVAUDIO, + .flags = I2C_DF_NOTIFY, + .attach_adapter = chip_probe, + .detach_client = chip_detach, + .command = chip_command, }; static struct i2c_client client_template = { .name = "(unset)", .flags = I2C_CLIENT_ALLOW_USE, - .driver = &driver, + .driver = &driver, }; static int __init audiochip_init_module(void) { struct CHIPDESC *desc; - printk(KERN_INFO "tvaudio: TV audio decoder + audio/video mux driver\n"); - printk(KERN_INFO "tvaudio: known chips: "); - for (desc = chiplist; desc->name != NULL; desc++) - printk("%s%s", (desc == chiplist) ? "" : ",",desc->name); - printk("\n"); + + if (debug) { + printk(KERN_INFO "tvaudio: TV audio decoder + audio/video mux driver\n"); + printk(KERN_INFO "tvaudio: known chips: "); + for (desc = chiplist; desc->name != NULL; desc++) + printk("%s%s", (desc == chiplist) ? "" : ", ", desc->name); + printk("\n"); + } return i2c_add_driver(&driver); } diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c index 3c3356a01cc..5344d559219 100644 --- a/drivers/media/video/tveeprom.c +++ b/drivers/media/video/tveeprom.c @@ -47,18 +47,21 @@ MODULE_LICENSE("GPL"); static int debug = 0; module_param(debug, int, 0644); -MODULE_PARM_DESC(debug, "Debug level (0-2)"); +MODULE_PARM_DESC(debug, "Debug level (0-1)"); #define STRM(array,i) (i < sizeof(array)/sizeof(char*) ? array[i] : "unknown") -#define dprintk(num, args...) \ - do { \ - if (debug >= num) \ - printk(KERN_INFO "tveeprom: " args); \ - } while (0) +#define tveeprom_info(fmt, arg...) do {\ + printk(KERN_INFO "tveeprom %d-%04x: " fmt, \ + c->adapter->nr, c->addr , ##arg); } while (0) +#define tveeprom_warn(fmt, arg...) do {\ + printk(KERN_WARNING "tveeprom %d-%04x: " fmt, \ + c->adapter->nr, c->addr , ##arg); } while (0) +#define tveeprom_dbg(fmt, arg...) do {\ + if (debug) \ + printk(KERN_INFO "tveeprom %d-%04x: " fmt, \ + c->adapter->nr, c->addr , ##arg); } while (0) -#define TVEEPROM_KERN_ERR(args...) printk(KERN_ERR "tveeprom: " args); -#define TVEEPROM_KERN_INFO(args...) printk(KERN_INFO "tveeprom: " args); /* ----------------------------------------------------------------------- */ /* some hauppauge specific stuff */ @@ -70,14 +73,14 @@ static struct HAUPPAUGE_TUNER_FMT } hauppauge_tuner_fmt[] = { - { 0x00000000, "unknown1" }, - { 0x00000000, "unknown2" }, - { 0x00000007, "PAL(B/G)" }, - { 0x00001000, "NTSC(M)" }, - { 0x00000010, "PAL(I)" }, - { 0x00400000, "SECAM(L/L´)" }, - { 0x00000e00, "PAL(D/K)" }, - { 0x03000000, "ATSC Digital" }, + { 0x00000000, " unknown1" }, + { 0x00000000, " unknown2" }, + { 0x00000007, " PAL(B/G)" }, + { 0x00001000, " NTSC(M)" }, + { 0x00000010, " PAL(I)" }, + { 0x00400000, " SECAM(L/L')" }, + { 0x00000e00, " PAL(D/K)" }, + { 0x03000000, " ATSC Digital" }, }; /* This is the full list of possible tuners. Many thanks to Hauppauge for @@ -152,13 +155,13 @@ hauppauge_tuner[] = { TUNER_MICROTUNE_4049FM5, "Microtune 4049 FM5"}, { TUNER_ABSENT, "LG TPI8NSR11F"}, { TUNER_ABSENT, "Microtune 4049 FM5 Alt I2C"}, - { TUNER_ABSENT, "Philips FQ1216ME MK3"}, + { TUNER_PHILIPS_FM1216ME_MK3, "Philips FQ1216ME MK3"}, { TUNER_ABSENT, "Philips FI1236 MK3"}, { TUNER_PHILIPS_FM1216ME_MK3, "Philips FM1216 ME MK3"}, - { TUNER_ABSENT, "Philips FM1236 MK3"}, + { TUNER_PHILIPS_FM1236_MK3, "Philips FM1236 MK3"}, { TUNER_ABSENT, "Philips FM1216MP MK3"}, /* 60-69 */ - { TUNER_ABSENT, "LG S001D MK3"}, + { TUNER_PHILIPS_FM1216ME_MK3, "LG S001D MK3"}, { TUNER_ABSENT, "LG M001D MK3"}, { TUNER_ABSENT, "LG S701D MK3"}, { TUNER_ABSENT, "LG M701D MK3"}, @@ -167,7 +170,7 @@ hauppauge_tuner[] = { TUNER_ABSENT, "Temic 4106FH5"}, { TUNER_ABSENT, "Philips FQ1216LMP MK3"}, { TUNER_LG_NTSC_TAPE, "LG TAPE H001F MK3"}, - { TUNER_ABSENT, "LG TAPE H701F MK3"}, + { TUNER_LG_NTSC_TAPE, "LG TAPE H701F MK3"}, /* 70-79 */ { TUNER_ABSENT, "LG TALN H200T"}, { TUNER_ABSENT, "LG TALN H250T"}, @@ -183,8 +186,8 @@ hauppauge_tuner[] = { TUNER_ABSENT, "Philips FQ1216LME MK3"}, { TUNER_ABSENT, "LG TAPC G701D"}, { TUNER_LG_NTSC_NEW_TAPC, "LG TAPC H791F"}, - { TUNER_ABSENT, "TCL 2002MB 3"}, - { TUNER_ABSENT, "TCL 2002MI 3"}, + { TUNER_LG_PAL_NEW_TAPC, "TCL 2002MB 3"}, + { TUNER_LG_PAL_NEW_TAPC, "TCL 2002MI 3"}, { TUNER_TCL_2002N, "TCL 2002N 6A"}, { TUNER_ABSENT, "Philips FQ1236 MK3"}, { TUNER_ABSENT, "Samsung TCPN 2121P30A"}, @@ -199,17 +202,51 @@ hauppauge_tuner[] = { TUNER_ABSENT, "Philips FQ1236 MK5"}, { TUNER_ABSENT, "Unspecified"}, { TUNER_LG_PAL_TAPE, "LG PAL (TAPE Series)"}, + { TUNER_ABSENT, "Unspecified"}, + { TUNER_TCL_2002N, "TCL 2002N 5H"}, + /* 100-103 */ + { TUNER_ABSENT, "Unspecified"}, + { TUNER_TEA5767, "Philips TEA5767HN FM Radio"}, + { TUNER_ABSENT, "Unspecified"}, + { TUNER_PHILIPS_FM1236_MK3, "TCL MFNM05 4"}, }; -static char *sndtype[] = { - "None", "TEA6300", "TEA6320", "TDA9850", "MSP3400C", "MSP3410D", - "MSP3415", "MSP3430", "MSP3438", "CS5331", "MSP3435", "MSP3440", - "MSP3445", "MSP3411", "MSP3416", "MSP3425", +/* This list is supplied by Hauppauge. Thanks! */ +static const char *audioIC[] = { + /* 0-4 */ + "None", "TEA6300", "TEA6320", "TDA9850", "MSP3400C", + /* 5-9 */ + "MSP3410D", "MSP3415", "MSP3430", "MSP3438", "CS5331", + /* 10-14 */ + "MSP3435", "MSP3440", "MSP3445", "MSP3411", "MSP3416", + /* 15-19 */ + "MSP3425", "MSP3451", "MSP3418", "Type 0x12", "OKI7716", + /* 20-24 */ + "MSP4410", "MSP4420", "MSP4440", "MSP4450", "MSP4408", + /* 25-29 */ + "MSP4418", "MSP4428", "MSP4448", "MSP4458", "Type 0x1d", + /* 30-34 */ + "CX880", "CX881", "CX883", "CX882", "CX25840", + /* 35-38 */ + "CX25841", "CX25842", "CX25843", "CX23418", +}; - "Type 0x10","Type 0x11","Type 0x12","Type 0x13", - "Type 0x14","Type 0x15","Type 0x16","Type 0x17", - "Type 0x18","MSP4418","Type 0x1a","MSP4448", - "Type 0x1c","Type 0x1d","Type 0x1e","Type 0x1f", +/* This list is supplied by Hauppauge. Thanks! */ +static const char *decoderIC[] = { + /* 0-4 */ + "None", "BT815", "BT817", "BT819", "BT815A", + /* 5-9 */ + "BT817A", "BT819A", "BT827", "BT829", "BT848", + /* 10-14 */ + "BT848A", "BT849A", "BT829A", "BT827A", "BT878", + /* 15-19 */ + "BT879", "BT880", "VPX3226E", "SAA7114", "SAA7115", + /* 20-24 */ + "CX880", "CX881", "CX883", "SAA7111", "SAA7113", + /* 25-29 */ + "CX882", "TVP5150A", "CX25840", "CX25841", "CX25842", + /* 30-31 */ + "CX25843", "CX23418", }; static int hasRadioTuner(int tunerType) @@ -250,7 +287,8 @@ static int hasRadioTuner(int tunerType) return 0; } -void tveeprom_hauppauge_analog(struct tveeprom *tvee, unsigned char *eeprom_data) +void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee, + unsigned char *eeprom_data) { /* ---------------------------------------------- ** The hauppauge eeprom format is tagged @@ -260,10 +298,11 @@ void tveeprom_hauppauge_analog(struct tveeprom *tvee, unsigned char *eeprom_data ** if packet[0] & f8 == f8, then EOD and packet[1] == checksum ** ** In our (ivtv) case we're interested in the following: - ** tuner type: tag [00].05 or [0a].01 (index into hauppauge_tuner) - ** tuner fmts: tag [00].04 or [0a].00 (bitmask index into hauppauge_tuner_fmt) - ** radio: tag [00].{last} or [0e].00 (bitmask. bit2=FM) - ** audio proc: tag [02].01 or [05].00 (lower nibble indexes lut?) + ** tuner type: tag [00].05 or [0a].01 (index into hauppauge_tuner) + ** tuner fmts: tag [00].04 or [0a].00 (bitmask index into hauppauge_tuner_fmt) + ** radio: tag [00].{last} or [0e].00 (bitmask. bit2=FM) + ** audio proc: tag [02].01 or [05].00 (mask with 0x7f) + ** decoder proc: tag [09].01) ** Fun info: ** model: tag [00].07-08 or [06].00-01 @@ -273,20 +312,24 @@ void tveeprom_hauppauge_analog(struct tveeprom *tvee, unsigned char *eeprom_data ** # of inputs/outputs ??? */ - int i, j, len, done, beenhere, tag, tuner = 0, t_format = 0; - char *t_name = NULL, *t_fmt_name = NULL; + int i, j, len, done, beenhere, tag; - dprintk(1, "%s\n",__FUNCTION__); - tvee->revision = done = len = beenhere = 0; - for (i = 0; !done && i < 256; i += len) { - dprintk(2, "processing pos = %02x (%02x, %02x)\n", - i, eeprom_data[i], eeprom_data[i + 1]); + int tuner1 = 0, t_format1 = 0; + char *t_name1 = NULL; + const char *t_fmt_name1[8] = { " none", "", "", "", "", "", "", "" }; + int tuner2 = 0, t_format2 = 0; + char *t_name2 = NULL; + const char *t_fmt_name2[8] = { " none", "", "", "", "", "", "", "" }; + + memset(tvee, 0, sizeof(*tvee)); + done = len = beenhere = 0; + for (i = 0; !done && i < 256; i += len) { if (eeprom_data[i] == 0x84) { len = eeprom_data[i + 1] + (eeprom_data[i + 2] << 8); - i+=3; + i += 3; } else if ((eeprom_data[i] & 0xf0) == 0x70) { - if ((eeprom_data[i] & 0x08)) { + if (eeprom_data[i] & 0x08) { /* verify checksum! */ done = 1; break; @@ -294,24 +337,30 @@ void tveeprom_hauppauge_analog(struct tveeprom *tvee, unsigned char *eeprom_data len = eeprom_data[i] & 0x07; ++i; } else { - TVEEPROM_KERN_ERR("Encountered bad packet header [%02x]. " + tveeprom_warn("Encountered bad packet header [%02x]. " "Corrupt or not a Hauppauge eeprom.\n", eeprom_data[i]); return; } - dprintk(1, "%3d [%02x] ", len, eeprom_data[i]); - for(j = 1; j < len; j++) { - dprintk(1, "%02x ", eeprom_data[i + j]); - } - dprintk(1, "\n"); + if (debug) { + tveeprom_info("Tag [%02x] + %d bytes:", eeprom_data[i], len - 1); + for(j = 1; j < len; j++) { + printk(" %02x", eeprom_data[i + j]); + } + printk("\n"); + } /* process by tag */ tag = eeprom_data[i]; switch (tag) { case 0x00: - tuner = eeprom_data[i+6]; - t_format = eeprom_data[i+5]; + /* tag: 'Comprehensive' */ + tuner1 = eeprom_data[i+6]; + t_format1 = eeprom_data[i+5]; tvee->has_radio = eeprom_data[i+len-1]; + /* old style tag, don't know how to detect + IR presence, mark as unknown. */ + tvee->has_ir = 2; tvee->model = eeprom_data[i+8] + (eeprom_data[i+9] << 8); @@ -319,25 +368,43 @@ void tveeprom_hauppauge_analog(struct tveeprom *tvee, unsigned char *eeprom_data (eeprom_data[i+11] << 8) + (eeprom_data[i+12] << 16); break; + case 0x01: + /* tag: 'SerialID' */ tvee->serial_number = eeprom_data[i+6] + (eeprom_data[i+7] << 8) + (eeprom_data[i+8] << 16); break; + case 0x02: - tvee->audio_processor = eeprom_data[i+2] & 0x0f; + /* tag 'AudioInfo' + Note mask with 0x7F, high bit used on some older models + to indicate 4052 mux was removed in favor of using MSP + inputs directly. */ + tvee->audio_processor = eeprom_data[i+2] & 0x7f; break; + + /* case 0x03: tag 'EEInfo' */ + case 0x04: + /* tag 'SerialID2' */ tvee->serial_number = eeprom_data[i+5] + (eeprom_data[i+6] << 8) + (eeprom_data[i+7] << 16); break; + case 0x05: - tvee->audio_processor = eeprom_data[i+1] & 0x0f; + /* tag 'Audio2' + Note mask with 0x7F, high bit used on some older models + to indicate 4052 mux was removed in favor of using MSP + inputs directly. */ + tvee->audio_processor = eeprom_data[i+1] & 0x7f; break; + case 0x06: + /* tag 'ModelRev' */ tvee->model = eeprom_data[i+1] + (eeprom_data[i+2] << 8); @@ -345,27 +412,66 @@ void tveeprom_hauppauge_analog(struct tveeprom *tvee, unsigned char *eeprom_data (eeprom_data[i+6] << 8) + (eeprom_data[i+7] << 16); break; + + case 0x07: + /* tag 'Details': according to Hauppauge not interesting + on any PCI-era or later boards. */ + break; + + /* there is no tag 0x08 defined */ + + case 0x09: + /* tag 'Video' */ + tvee->decoder_processor = eeprom_data[i + 1]; + break; + case 0x0a: - if(beenhere == 0) { - tuner = eeprom_data[i+2]; - t_format = eeprom_data[i+1]; + /* tag 'Tuner' */ + if (beenhere == 0) { + tuner1 = eeprom_data[i+2]; + t_format1 = eeprom_data[i+1]; beenhere = 1; - break; } else { - break; - } + /* a second (radio) tuner may be present */ + tuner2 = eeprom_data[i+2]; + t_format2 = eeprom_data[i+1]; + if (t_format2 == 0) { /* not a TV tuner? */ + tvee->has_radio = 1; /* must be radio */ + } + } + break; + + case 0x0b: + /* tag 'Inputs': according to Hauppauge this is specific + to each driver family, so no good assumptions can be + made. */ + break; + + /* case 0x0c: tag 'Balun' */ + /* case 0x0d: tag 'Teletext' */ + case 0x0e: + /* tag: 'Radio' */ tvee->has_radio = eeprom_data[i+1]; break; + + case 0x0f: + /* tag 'IRInfo' */ + tvee->has_ir = eeprom_data[i+1]; + break; + + /* case 0x10: tag 'VBIInfo' */ + /* case 0x11: tag 'QCInfo' */ + /* case 0x12: tag 'InfoBits' */ + default: - dprintk(1, "Not sure what to do with tag [%02x]\n", tag); + tveeprom_dbg("Not sure what to do with tag [%02x]\n", tag); /* dump the rest of the packet? */ } - } if (!done) { - TVEEPROM_KERN_ERR("Ran out of data!\n"); + tveeprom_warn("Ran out of data!\n"); return; } @@ -377,47 +483,72 @@ void tveeprom_hauppauge_analog(struct tveeprom *tvee, unsigned char *eeprom_data tvee->rev_str[4] = 0; } - if (hasRadioTuner(tuner) && !tvee->has_radio) { - TVEEPROM_KERN_INFO("The eeprom says no radio is present, but the tuner type\n"); - TVEEPROM_KERN_INFO("indicates otherwise. I will assume that radio is present.\n"); + if (hasRadioTuner(tuner1) && !tvee->has_radio) { + tveeprom_info("The eeprom says no radio is present, but the tuner type\n"); + tveeprom_info("indicates otherwise. I will assume that radio is present.\n"); tvee->has_radio = 1; } - if (tuner < sizeof(hauppauge_tuner)/sizeof(struct HAUPPAUGE_TUNER)) { - tvee->tuner_type = hauppauge_tuner[tuner].id; - t_name = hauppauge_tuner[tuner].name; + if (tuner1 < sizeof(hauppauge_tuner)/sizeof(struct HAUPPAUGE_TUNER)) { + tvee->tuner_type = hauppauge_tuner[tuner1].id; + t_name1 = hauppauge_tuner[tuner1].name; } else { - t_name = "<unknown>"; + t_name1 = "unknown"; + } + + if (tuner2 < sizeof(hauppauge_tuner)/sizeof(struct HAUPPAUGE_TUNER)) { + tvee->tuner2_type = hauppauge_tuner[tuner2].id; + t_name2 = hauppauge_tuner[tuner2].name; + } else { + t_name2 = "unknown"; } tvee->tuner_formats = 0; - t_fmt_name = "<none>"; - for (i = 0; i < 8; i++) { - if (t_format & (1<<i)) { + tvee->tuner2_formats = 0; + for (i = j = 0; i < 8; i++) { + if (t_format1 & (1 << i)) { tvee->tuner_formats |= hauppauge_tuner_fmt[i].id; - /* yuck */ - t_fmt_name = hauppauge_tuner_fmt[i].name; + t_fmt_name1[j++] = hauppauge_tuner_fmt[i].name; } + if (t_format2 & (1 << i)) { + tvee->tuner2_formats |= hauppauge_tuner_fmt[i].id; + t_fmt_name2[j++] = hauppauge_tuner_fmt[i].name; + } } - - TVEEPROM_KERN_INFO("Hauppauge: model = %d, rev = %s, serial# = %d\n", - tvee->model, - tvee->rev_str, - tvee->serial_number); - TVEEPROM_KERN_INFO("tuner = %s (idx = %d, type = %d)\n", - t_name, - tuner, - tvee->tuner_type); - TVEEPROM_KERN_INFO("tuner fmt = %s (eeprom = 0x%02x, v4l2 = 0x%08x)\n", - t_fmt_name, - t_format, - tvee->tuner_formats); - - TVEEPROM_KERN_INFO("audio_processor = %s (type = %d)\n", - STRM(sndtype,tvee->audio_processor), + tveeprom_info("Hauppauge model %d, rev %s, serial# %d\n", + tvee->model, tvee->rev_str, tvee->serial_number); + tveeprom_info("tuner model is %s (idx %d, type %d)\n", + t_name1, tuner1, tvee->tuner_type); + tveeprom_info("TV standards%s%s%s%s%s%s%s%s (eeprom 0x%02x)\n", + t_fmt_name1[0], t_fmt_name1[1], t_fmt_name1[2], t_fmt_name1[3], + t_fmt_name1[4], t_fmt_name1[5], t_fmt_name1[6], t_fmt_name1[7], + t_format1); + if (tuner2) { + tveeprom_info("second tuner model is %s (idx %d, type %d)\n", + t_name2, tuner2, tvee->tuner2_type); + } + if (t_format2) { + tveeprom_info("TV standards%s%s%s%s%s%s%s%s (eeprom 0x%02x)\n", + t_fmt_name2[0], t_fmt_name2[1], t_fmt_name2[2], t_fmt_name2[3], + t_fmt_name2[4], t_fmt_name2[5], t_fmt_name2[6], t_fmt_name2[7], + t_format2); + } + tveeprom_info("audio processor is %s (idx %d)\n", + STRM(audioIC, tvee->audio_processor), tvee->audio_processor); - + if (tvee->decoder_processor) { + tveeprom_info("decoder processor is %s (idx %d)\n", + STRM(decoderIC, tvee->decoder_processor), + tvee->decoder_processor); + } + if (tvee->has_ir == 2) + tveeprom_info("has %sradio\n", + tvee->has_radio ? "" : "no "); + else + tveeprom_info("has %sradio, has %sIR remote\n", + tvee->has_radio ? "" : "no ", + tvee->has_ir ? "" : "no "); } EXPORT_SYMBOL(tveeprom_hauppauge_analog); @@ -429,40 +560,31 @@ int tveeprom_read(struct i2c_client *c, unsigned char *eedata, int len) unsigned char buf; int err; - dprintk(1, "%s\n",__FUNCTION__); buf = 0; - if (1 != (err = i2c_master_send(c,&buf,1))) { - printk(KERN_INFO "tveeprom(%s): Huh, no eeprom present (err=%d)?\n", - c->name,err); + if (1 != (err = i2c_master_send(c, &buf, 1))) { + tveeprom_info("Huh, no eeprom present (err=%d)?\n", err); return -1; } - if (len != (err = i2c_master_recv(c,eedata,len))) { - printk(KERN_WARNING "tveeprom(%s): i2c eeprom read error (err=%d)\n", - c->name,err); + if (len != (err = i2c_master_recv(c, eedata, len))) { + tveeprom_warn("i2c eeprom read error (err=%d)\n", err); return -1; } + if (debug) { + int i; + + tveeprom_info("full 256-byte eeprom dump:\n"); + for (i = 0; i < len; i++) { + if (0 == (i % 16)) + tveeprom_info("%02x:", i); + printk(" %02x", eedata[i]); + if (15 == (i % 16)) + printk("\n"); + } + } return 0; } EXPORT_SYMBOL(tveeprom_read); -#if 0 -int tveeprom_dump(unsigned char *eedata, int len) -{ - int i; - - dprintk(1, "%s\n",__FUNCTION__); - for (i = 0; i < len; i++) { - if (0 == (i % 16)) - printk(KERN_INFO "tveeprom: %02x:",i); - printk(" %02x",eedata[i]); - if (15 == (i % 16)) - printk("\n"); - } - return 0; -} -EXPORT_SYMBOL(tveeprom_dump); -#endif /* 0 */ - /* ----------------------------------------------------------------------- */ /* needed for ivtv.sf.net at the moment. Should go away in the long */ /* run, just call the exported tveeprom_* directly, there is no point in */ @@ -495,12 +617,13 @@ tveeprom_command(struct i2c_client *client, buf = kmalloc(256,GFP_KERNEL); memset(buf,0,256); tveeprom_read(client,buf,256); - tveeprom_hauppauge_analog(&eeprom,buf); + tveeprom_hauppauge_analog(client, &eeprom,buf); kfree(buf); eeprom_props[0] = eeprom.tuner_type; eeprom_props[1] = eeprom.tuner_formats; eeprom_props[2] = eeprom.model; eeprom_props[3] = eeprom.revision; + eeprom_props[4] = eeprom.has_radio; break; default: return -EINVAL; @@ -515,8 +638,6 @@ tveeprom_detect_client(struct i2c_adapter *adapter, { struct i2c_client *client; - dprintk(1,"%s: id 0x%x @ 0x%x\n",__FUNCTION__, - adapter->id, address << 1); client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); if (NULL == client) return -ENOMEM; @@ -533,7 +654,6 @@ tveeprom_detect_client(struct i2c_adapter *adapter, static int tveeprom_attach_adapter (struct i2c_adapter *adapter) { - dprintk(1,"%s: id 0x%x\n",__FUNCTION__,adapter->id); if (adapter->id != I2C_HW_B_BT848) return 0; return i2c_probe(adapter, &addr_data, tveeprom_detect_client); diff --git a/drivers/media/video/tvmixer.c b/drivers/media/video/tvmixer.c index a43301a154a..d86e08ebddf 100644 --- a/drivers/media/video/tvmixer.c +++ b/drivers/media/video/tvmixer.c @@ -1,5 +1,4 @@ /* - * $Id: tvmixer.c,v 1.8 2005/06/12 04:19:19 mchehab Exp $ */ #include <linux/module.h> diff --git a/drivers/media/video/v4l1-compat.c b/drivers/media/video/v4l1-compat.c index 70ecbdb8027..59bb71381a1 100644 --- a/drivers/media/video/v4l1-compat.c +++ b/drivers/media/video/v4l1-compat.c @@ -1,5 +1,4 @@ /* - * $Id: v4l1-compat.c,v 1.9 2005/06/12 04:19:19 mchehab Exp $ * * Video for Linux Two * Backward Compatibility Layer @@ -604,9 +603,6 @@ v4l_compat_translate_ioctl(struct inode *inode, dprintk("VIDIOCGPICT / VIDIOC_G_FMT: %d\n",err); break; } -#if 0 /* FIXME */ - pict->depth = fmt2->fmt.pix.depth; -#endif pict->palette = pixelformat_to_palette( fmt2->fmt.pix.pixelformat); break; @@ -707,13 +703,7 @@ v4l_compat_translate_ioctl(struct inode *inode, } case VIDIOCSTUNER: /* select a tuner input */ { -#if 0 /* FIXME */ - err = drv(inode, file, VIDIOC_S_INPUT, &i); - if (err < 0) - dprintk("VIDIOCSTUNER / VIDIOC_S_INPUT: %d\n",err); -#else err = 0; -#endif break; } case VIDIOCGFREQ: /* get frequency */ @@ -852,12 +842,6 @@ v4l_compat_translate_ioctl(struct inode *inode, err = 0; break; } -#if 0 - case VIDIOCGMBUF: - /* v4l2 drivers must implement that themself. The - mmap() differences can't be translated fully - transparent, thus there is no point to try that */ -#endif case VIDIOCMCAPTURE: /* capture a frame */ { struct video_mmap *mm = arg; diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c index b5e0cf3448f..597b8db35a1 100644 --- a/drivers/media/video/v4l2-common.c +++ b/drivers/media/video/v4l2-common.c @@ -84,20 +84,6 @@ MODULE_LICENSE("GPL"); * Video Standard Operations (contributed by Michael Schimek) */ -#if 0 /* seems to have no users */ -/* This is the recommended method to deal with the framerate fields. More - sophisticated drivers will access the fields directly. */ -unsigned int -v4l2_video_std_fps(struct v4l2_standard *vs) -{ - if (vs->frameperiod.numerator > 0) - return (((vs->frameperiod.denominator << 8) / - vs->frameperiod.numerator) + - (1 << 7)) / (1 << 8); - return 0; -} -EXPORT_SYMBOL(v4l2_video_std_fps); -#endif /* Fill in the fields of a v4l2_standard structure according to the 'id' and 'transmission' parameters. Returns negative on error. */ @@ -213,10 +199,6 @@ char *v4l2_ioctl_names[256] = { [_IOC_NR(VIDIOC_ENUM_FMT)] = "VIDIOC_ENUM_FMT", [_IOC_NR(VIDIOC_G_FMT)] = "VIDIOC_G_FMT", [_IOC_NR(VIDIOC_S_FMT)] = "VIDIOC_S_FMT", -#if 0 - [_IOC_NR(VIDIOC_G_COMP)] = "VIDIOC_G_COMP", - [_IOC_NR(VIDIOC_S_COMP)] = "VIDIOC_S_COMP", -#endif [_IOC_NR(VIDIOC_REQBUFS)] = "VIDIOC_REQBUFS", [_IOC_NR(VIDIOC_QUERYBUF)] = "VIDIOC_QUERYBUF", [_IOC_NR(VIDIOC_G_FBUF)] = "VIDIOC_G_FBUF", diff --git a/drivers/media/video/video-buf-dvb.c b/drivers/media/video/video-buf-dvb.c index 15f5bb48696..55f129e964e 100644 --- a/drivers/media/video/video-buf-dvb.c +++ b/drivers/media/video/video-buf-dvb.c @@ -1,5 +1,4 @@ /* - * $Id: video-buf-dvb.c,v 1.7 2004/12/09 12:51:35 kraxel Exp $ * * some helper function for simple DVB cards which simply DMA the * complete transport stream and let the computer sort everything else diff --git a/drivers/media/video/video-buf.c b/drivers/media/video/video-buf.c index 5afdc785261..574b8e36f3c 100644 --- a/drivers/media/video/video-buf.c +++ b/drivers/media/video/video-buf.c @@ -1,5 +1,4 @@ /* - * $Id: video-buf.c,v 1.18 2005/02/24 13:32:30 kraxel Exp $ * * generic helper functions for video4linux capture buffers, to handle * memory management and PCI DMA. Right now bttv + saa7134 use it. @@ -268,10 +267,10 @@ int videobuf_dma_free(struct videobuf_dmabuf *dma) kfree(dma->pages); dma->pages = NULL; } - if (dma->vmalloc) { - vfree(dma->vmalloc); - dma->vmalloc = NULL; - } + + vfree(dma->vmalloc); + dma->vmalloc = NULL; + if (dma->bus_addr) { dma->bus_addr = 0; } diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c index ba838a42ec8..53adeb70f2c 100644 --- a/drivers/media/video/zoran_driver.c +++ b/drivers/media/video/zoran_driver.c @@ -650,7 +650,7 @@ jpg_fbuffer_free (struct file *file) off += PAGE_SIZE) ClearPageReserved(MAP_NR (mem + off)); - kfree((void *) mem); + kfree(mem); fh->jpg_buffers.buffer[i].frag_tab[0] = 0; fh->jpg_buffers.buffer[i].frag_tab[1] = 0; } diff --git a/drivers/media/video/zr36120.c b/drivers/media/video/zr36120.c index c33533155cc..07286816d7d 100644 --- a/drivers/media/video/zr36120.c +++ b/drivers/media/video/zr36120.c @@ -820,11 +820,9 @@ void zoran_close(struct video_device* dev) msleep(100); /* Wait 1/10th of a second */ /* free the allocated framebuffer */ - if (ztv->fbuffer) - bfree( ztv->fbuffer, ZORAN_MAX_FBUFSIZE ); + bfree(ztv->fbuffer, ZORAN_MAX_FBUFSIZE); ztv->fbuffer = 0; - if (ztv->overinfo.overlay) - kfree( ztv->overinfo.overlay ); + kfree(ztv->overinfo.overlay); ztv->overinfo.overlay = 0; } diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 1588a59e376..550f2974481 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -13,4 +13,13 @@ config MCP_SA11X0 depends on ARCH_SA1100 select MCP +# Chip drivers +config MCP_UCB1200 + tristate "Support for UCB1200 / UCB1300" + depends on MCP + +config MCP_UCB1200_TS + tristate "Touchscreen interface support" + depends on MCP_UCB1200 && INPUT + endmenu diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 98bdd6a4218..adb29b5368a 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -4,3 +4,9 @@ obj-$(CONFIG_MCP) += mcp-core.o obj-$(CONFIG_MCP_SA11X0) += mcp-sa11x0.o +obj-$(CONFIG_MCP_UCB1200) += ucb1x00-core.o +obj-$(CONFIG_MCP_UCB1200_TS) += ucb1x00-ts.o + +ifeq ($(CONFIG_SA1100_ASSABET),y) +obj-$(CONFIG_MCP_UCB1200) += ucb1x00-assabet.o +endif diff --git a/drivers/mfd/ucb1x00-assabet.c b/drivers/mfd/ucb1x00-assabet.c new file mode 100644 index 00000000000..e325fa71f38 --- /dev/null +++ b/drivers/mfd/ucb1x00-assabet.c @@ -0,0 +1,73 @@ +/* + * linux/drivers/mfd/ucb1x00-assabet.c + * + * Copyright (C) 2001-2003 Russell King, All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License. + * + * We handle the machine-specific bits of the UCB1x00 driver here. + */ +#include <linux/module.h> +#include <linux/init.h> +#include <linux/fs.h> +#include <linux/proc_fs.h> +#include <linux/device.h> + +#include <asm/dma.h> + +#include "ucb1x00.h" + +#define UCB1X00_ATTR(name,input)\ +static ssize_t name##_show(struct class_device *dev, char *buf) \ +{ \ + struct ucb1x00 *ucb = classdev_to_ucb1x00(dev); \ + int val; \ + ucb1x00_adc_enable(ucb); \ + val = ucb1x00_adc_read(ucb, input, UCB_NOSYNC); \ + ucb1x00_adc_disable(ucb); \ + return sprintf(buf, "%d\n", val); \ +} \ +static CLASS_DEVICE_ATTR(name,0444,name##_show,NULL) + +UCB1X00_ATTR(vbatt, UCB_ADC_INP_AD1); +UCB1X00_ATTR(vcharger, UCB_ADC_INP_AD0); +UCB1X00_ATTR(batt_temp, UCB_ADC_INP_AD2); + +static int ucb1x00_assabet_add(struct ucb1x00_dev *dev) +{ + class_device_create_file(&dev->ucb->cdev, &class_device_attr_vbatt); + class_device_create_file(&dev->ucb->cdev, &class_device_attr_vcharger); + class_device_create_file(&dev->ucb->cdev, &class_device_attr_batt_temp); + return 0; +} + +static void ucb1x00_assabet_remove(struct ucb1x00_dev *dev) +{ + class_device_remove_file(&dev->ucb->cdev, &class_device_attr_batt_temp); + class_device_remove_file(&dev->ucb->cdev, &class_device_attr_vcharger); + class_device_remove_file(&dev->ucb->cdev, &class_device_attr_vbatt); +} + +static struct ucb1x00_driver ucb1x00_assabet_driver = { + .add = ucb1x00_assabet_add, + .remove = ucb1x00_assabet_remove, +}; + +static int __init ucb1x00_assabet_init(void) +{ + return ucb1x00_register_driver(&ucb1x00_assabet_driver); +} + +static void __exit ucb1x00_assabet_exit(void) +{ + ucb1x00_unregister_driver(&ucb1x00_assabet_driver); +} + +module_init(ucb1x00_assabet_init); +module_exit(ucb1x00_assabet_exit); + +MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>"); +MODULE_DESCRIPTION("Assabet noddy testing only example ADC driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/mfd/ucb1x00-core.c b/drivers/mfd/ucb1x00-core.c new file mode 100644 index 00000000000..10f6ce1bc0a --- /dev/null +++ b/drivers/mfd/ucb1x00-core.c @@ -0,0 +1,665 @@ +/* + * linux/drivers/mfd/ucb1x00-core.c + * + * Copyright (C) 2001 Russell King, All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License. + * + * The UCB1x00 core driver provides basic services for handling IO, + * the ADC, interrupts, and accessing registers. It is designed + * such that everything goes through this layer, thereby providing + * a consistent locking methodology, as well as allowing the drivers + * to be used on other non-MCP-enabled hardware platforms. + * + * Note that all locks are private to this file. Nothing else may + * touch them. + */ +#include <linux/config.h> +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/slab.h> +#include <linux/init.h> +#include <linux/errno.h> +#include <linux/interrupt.h> +#include <linux/device.h> + +#include <asm/dma.h> +#include <asm/hardware.h> +#include <asm/irq.h> + +#include "ucb1x00.h" + +static DECLARE_MUTEX(ucb1x00_sem); +static LIST_HEAD(ucb1x00_drivers); +static LIST_HEAD(ucb1x00_devices); + +/** + * ucb1x00_io_set_dir - set IO direction + * @ucb: UCB1x00 structure describing chip + * @in: bitfield of IO pins to be set as inputs + * @out: bitfield of IO pins to be set as outputs + * + * Set the IO direction of the ten general purpose IO pins on + * the UCB1x00 chip. The @in bitfield has priority over the + * @out bitfield, in that if you specify a pin as both input + * and output, it will end up as an input. + * + * ucb1x00_enable must have been called to enable the comms + * before using this function. + * + * This function takes a spinlock, disabling interrupts. + */ +void ucb1x00_io_set_dir(struct ucb1x00 *ucb, unsigned int in, unsigned int out) +{ + unsigned long flags; + + spin_lock_irqsave(&ucb->io_lock, flags); + ucb->io_dir |= out; + ucb->io_dir &= ~in; + + ucb1x00_reg_write(ucb, UCB_IO_DIR, ucb->io_dir); + spin_unlock_irqrestore(&ucb->io_lock, flags); +} + +/** + * ucb1x00_io_write - set or clear IO outputs + * @ucb: UCB1x00 structure describing chip + * @set: bitfield of IO pins to set to logic '1' + * @clear: bitfield of IO pins to set to logic '0' + * + * Set the IO output state of the specified IO pins. The value + * is retained if the pins are subsequently configured as inputs. + * The @clear bitfield has priority over the @set bitfield - + * outputs will be cleared. + * + * ucb1x00_enable must have been called to enable the comms + * before using this function. + * + * This function takes a spinlock, disabling interrupts. + */ +void ucb1x00_io_write(struct ucb1x00 *ucb, unsigned int set, unsigned int clear) +{ + unsigned long flags; + + spin_lock_irqsave(&ucb->io_lock, flags); + ucb->io_out |= set; + ucb->io_out &= ~clear; + + ucb1x00_reg_write(ucb, UCB_IO_DATA, ucb->io_out); + spin_unlock_irqrestore(&ucb->io_lock, flags); +} + +/** + * ucb1x00_io_read - read the current state of the IO pins + * @ucb: UCB1x00 structure describing chip + * + * Return a bitfield describing the logic state of the ten + * general purpose IO pins. + * + * ucb1x00_enable must have been called to enable the comms + * before using this function. + * + * This function does not take any semaphores or spinlocks. + */ +unsigned int ucb1x00_io_read(struct ucb1x00 *ucb) +{ + return ucb1x00_reg_read(ucb, UCB_IO_DATA); +} + +/* + * UCB1300 data sheet says we must: + * 1. enable ADC => 5us (including reference startup time) + * 2. select input => 51*tsibclk => 4.3us + * 3. start conversion => 102*tsibclk => 8.5us + * (tsibclk = 1/11981000) + * Period between SIB 128-bit frames = 10.7us + */ + +/** + * ucb1x00_adc_enable - enable the ADC converter + * @ucb: UCB1x00 structure describing chip + * + * Enable the ucb1x00 and ADC converter on the UCB1x00 for use. + * Any code wishing to use the ADC converter must call this + * function prior to using it. + * + * This function takes the ADC semaphore to prevent two or more + * concurrent uses, and therefore may sleep. As a result, it + * can only be called from process context, not interrupt + * context. + * + * You should release the ADC as soon as possible using + * ucb1x00_adc_disable. + */ +void ucb1x00_adc_enable(struct ucb1x00 *ucb) +{ + down(&ucb->adc_sem); + + ucb->adc_cr |= UCB_ADC_ENA; + + ucb1x00_enable(ucb); + ucb1x00_reg_write(ucb, UCB_ADC_CR, ucb->adc_cr); +} + +/** + * ucb1x00_adc_read - read the specified ADC channel + * @ucb: UCB1x00 structure describing chip + * @adc_channel: ADC channel mask + * @sync: wait for syncronisation pulse. + * + * Start an ADC conversion and wait for the result. Note that + * synchronised ADC conversions (via the ADCSYNC pin) must wait + * until the trigger is asserted and the conversion is finished. + * + * This function currently spins waiting for the conversion to + * complete (2 frames max without sync). + * + * If called for a synchronised ADC conversion, it may sleep + * with the ADC semaphore held. + */ +unsigned int ucb1x00_adc_read(struct ucb1x00 *ucb, int adc_channel, int sync) +{ + unsigned int val; + + if (sync) + adc_channel |= UCB_ADC_SYNC_ENA; + + ucb1x00_reg_write(ucb, UCB_ADC_CR, ucb->adc_cr | adc_channel); + ucb1x00_reg_write(ucb, UCB_ADC_CR, ucb->adc_cr | adc_channel | UCB_ADC_START); + + for (;;) { + val = ucb1x00_reg_read(ucb, UCB_ADC_DATA); + if (val & UCB_ADC_DAT_VAL) + break; + /* yield to other processes */ + set_current_state(TASK_INTERRUPTIBLE); + schedule_timeout(1); + } + + return UCB_ADC_DAT(val); +} + +/** + * ucb1x00_adc_disable - disable the ADC converter + * @ucb: UCB1x00 structure describing chip + * + * Disable the ADC converter and release the ADC semaphore. + */ +void ucb1x00_adc_disable(struct ucb1x00 *ucb) +{ + ucb->adc_cr &= ~UCB_ADC_ENA; + ucb1x00_reg_write(ucb, UCB_ADC_CR, ucb->adc_cr); + ucb1x00_disable(ucb); + + up(&ucb->adc_sem); +} + +/* + * UCB1x00 Interrupt handling. + * + * The UCB1x00 can generate interrupts when the SIBCLK is stopped. + * Since we need to read an internal register, we must re-enable + * SIBCLK to talk to the chip. We leave the clock running until + * we have finished processing all interrupts from the chip. + */ +static irqreturn_t ucb1x00_irq(int irqnr, void *devid, struct pt_regs *regs) +{ + struct ucb1x00 *ucb = devid; + struct ucb1x00_irq *irq; + unsigned int isr, i; + + ucb1x00_enable(ucb); + isr = ucb1x00_reg_read(ucb, UCB_IE_STATUS); + ucb1x00_reg_write(ucb, UCB_IE_CLEAR, isr); + ucb1x00_reg_write(ucb, UCB_IE_CLEAR, 0); + + for (i = 0, irq = ucb->irq_handler; i < 16 && isr; i++, isr >>= 1, irq++) + if (isr & 1 && irq->fn) + irq->fn(i, irq->devid); + ucb1x00_disable(ucb); + + return IRQ_HANDLED; +} + +/** + * ucb1x00_hook_irq - hook a UCB1x00 interrupt + * @ucb: UCB1x00 structure describing chip + * @idx: interrupt index + * @fn: function to call when interrupt is triggered + * @devid: device id to pass to interrupt handler + * + * Hook the specified interrupt. You can only register one handler + * for each interrupt source. The interrupt source is not enabled + * by this function; use ucb1x00_enable_irq instead. + * + * Interrupt handlers will be called with other interrupts enabled. + * + * Returns zero on success, or one of the following errors: + * -EINVAL if the interrupt index is invalid + * -EBUSY if the interrupt has already been hooked + */ +int ucb1x00_hook_irq(struct ucb1x00 *ucb, unsigned int idx, void (*fn)(int, void *), void *devid) +{ + struct ucb1x00_irq *irq; + int ret = -EINVAL; + + if (idx < 16) { + irq = ucb->irq_handler + idx; + ret = -EBUSY; + + spin_lock_irq(&ucb->lock); + if (irq->fn == NULL) { + irq->devid = devid; + irq->fn = fn; + ret = 0; + } + spin_unlock_irq(&ucb->lock); + } + return ret; +} + +/** + * ucb1x00_enable_irq - enable an UCB1x00 interrupt source + * @ucb: UCB1x00 structure describing chip + * @idx: interrupt index + * @edges: interrupt edges to enable + * + * Enable the specified interrupt to trigger on %UCB_RISING, + * %UCB_FALLING or both edges. The interrupt should have been + * hooked by ucb1x00_hook_irq. + */ +void ucb1x00_enable_irq(struct ucb1x00 *ucb, unsigned int idx, int edges) +{ + unsigned long flags; + + if (idx < 16) { + spin_lock_irqsave(&ucb->lock, flags); + + ucb1x00_enable(ucb); + if (edges & UCB_RISING) { + ucb->irq_ris_enbl |= 1 << idx; + ucb1x00_reg_write(ucb, UCB_IE_RIS, ucb->irq_ris_enbl); + } + if (edges & UCB_FALLING) { + ucb->irq_fal_enbl |= 1 << idx; + ucb1x00_reg_write(ucb, UCB_IE_FAL, ucb->irq_fal_enbl); + } + ucb1x00_disable(ucb); + spin_unlock_irqrestore(&ucb->lock, flags); + } +} + +/** + * ucb1x00_disable_irq - disable an UCB1x00 interrupt source + * @ucb: UCB1x00 structure describing chip + * @edges: interrupt edges to disable + * + * Disable the specified interrupt triggering on the specified + * (%UCB_RISING, %UCB_FALLING or both) edges. + */ +void ucb1x00_disable_irq(struct ucb1x00 *ucb, unsigned int idx, int edges) +{ + unsigned long flags; + + if (idx < 16) { + spin_lock_irqsave(&ucb->lock, flags); + + ucb1x00_enable(ucb); + if (edges & UCB_RISING) { + ucb->irq_ris_enbl &= ~(1 << idx); + ucb1x00_reg_write(ucb, UCB_IE_RIS, ucb->irq_ris_enbl); + } + if (edges & UCB_FALLING) { + ucb->irq_fal_enbl &= ~(1 << idx); + ucb1x00_reg_write(ucb, UCB_IE_FAL, ucb->irq_fal_enbl); + } + ucb1x00_disable(ucb); + spin_unlock_irqrestore(&ucb->lock, flags); + } +} + +/** + * ucb1x00_free_irq - disable and free the specified UCB1x00 interrupt + * @ucb: UCB1x00 structure describing chip + * @idx: interrupt index + * @devid: device id. + * + * Disable the interrupt source and remove the handler. devid must + * match the devid passed when hooking the interrupt. + * + * Returns zero on success, or one of the following errors: + * -EINVAL if the interrupt index is invalid + * -ENOENT if devid does not match + */ +int ucb1x00_free_irq(struct ucb1x00 *ucb, unsigned int idx, void *devid) +{ + struct ucb1x00_irq *irq; + int ret; + + if (idx >= 16) + goto bad; + + irq = ucb->irq_handler + idx; + ret = -ENOENT; + + spin_lock_irq(&ucb->lock); + if (irq->devid == devid) { + ucb->irq_ris_enbl &= ~(1 << idx); + ucb->irq_fal_enbl &= ~(1 << idx); + + ucb1x00_enable(ucb); + ucb1x00_reg_write(ucb, UCB_IE_RIS, ucb->irq_ris_enbl); + ucb1x00_reg_write(ucb, UCB_IE_FAL, ucb->irq_fal_enbl); + ucb1x00_disable(ucb); + + irq->fn = NULL; + irq->devid = NULL; + ret = 0; + } + spin_unlock_irq(&ucb->lock); + return ret; + +bad: + printk(KERN_ERR "Freeing bad UCB1x00 irq %d\n", idx); + return -EINVAL; +} + +static int ucb1x00_add_dev(struct ucb1x00 *ucb, struct ucb1x00_driver *drv) +{ + struct ucb1x00_dev *dev; + int ret = -ENOMEM; + + dev = kmalloc(sizeof(struct ucb1x00_dev), GFP_KERNEL); + if (dev) { + dev->ucb = ucb; + dev->drv = drv; + + ret = drv->add(dev); + + if (ret == 0) { + list_add(&dev->dev_node, &ucb->devs); + list_add(&dev->drv_node, &drv->devs); + } else { + kfree(dev); + } + } + return ret; +} + +static void ucb1x00_remove_dev(struct ucb1x00_dev *dev) +{ + dev->drv->remove(dev); + list_del(&dev->dev_node); + list_del(&dev->drv_node); + kfree(dev); +} + +/* + * Try to probe our interrupt, rather than relying on lots of + * hard-coded machine dependencies. For reference, the expected + * IRQ mappings are: + * + * Machine Default IRQ + * adsbitsy IRQ_GPCIN4 + * cerf IRQ_GPIO_UCB1200_IRQ + * flexanet IRQ_GPIO_GUI + * freebird IRQ_GPIO_FREEBIRD_UCB1300_IRQ + * graphicsclient ADS_EXT_IRQ(8) + * graphicsmaster ADS_EXT_IRQ(8) + * lart LART_IRQ_UCB1200 + * omnimeter IRQ_GPIO23 + * pfs168 IRQ_GPIO_UCB1300_IRQ + * simpad IRQ_GPIO_UCB1300_IRQ + * shannon SHANNON_IRQ_GPIO_IRQ_CODEC + * yopy IRQ_GPIO_UCB1200_IRQ + */ +static int ucb1x00_detect_irq(struct ucb1x00 *ucb) +{ + unsigned long mask; + + mask = probe_irq_on(); + if (!mask) + return NO_IRQ; + + /* + * Enable the ADC interrupt. + */ + ucb1x00_reg_write(ucb, UCB_IE_RIS, UCB_IE_ADC); + ucb1x00_reg_write(ucb, UCB_IE_FAL, UCB_IE_ADC); + ucb1x00_reg_write(ucb, UCB_IE_CLEAR, 0xffff); + ucb1x00_reg_write(ucb, UCB_IE_CLEAR, 0); + + /* + * Cause an ADC interrupt. + */ + ucb1x00_reg_write(ucb, UCB_ADC_CR, UCB_ADC_ENA); + ucb1x00_reg_write(ucb, UCB_ADC_CR, UCB_ADC_ENA | UCB_ADC_START); + + /* + * Wait for the conversion to complete. + */ + while ((ucb1x00_reg_read(ucb, UCB_ADC_DATA) & UCB_ADC_DAT_VAL) == 0); + ucb1x00_reg_write(ucb, UCB_ADC_CR, 0); + + /* + * Disable and clear interrupt. + */ + ucb1x00_reg_write(ucb, UCB_IE_RIS, 0); + ucb1x00_reg_write(ucb, UCB_IE_FAL, 0); + ucb1x00_reg_write(ucb, UCB_IE_CLEAR, 0xffff); + ucb1x00_reg_write(ucb, UCB_IE_CLEAR, 0); + + /* + * Read triggered interrupt. + */ + return probe_irq_off(mask); +} + +static int ucb1x00_probe(struct mcp *mcp) +{ + struct ucb1x00 *ucb; + struct ucb1x00_driver *drv; + unsigned int id; + int ret = -ENODEV; + + mcp_enable(mcp); + id = mcp_reg_read(mcp, UCB_ID); + + if (id != UCB_ID_1200 && id != UCB_ID_1300) { + printk(KERN_WARNING "UCB1x00 ID not found: %04x\n", id); + goto err_disable; + } + + ucb = kmalloc(sizeof(struct ucb1x00), GFP_KERNEL); + ret = -ENOMEM; + if (!ucb) + goto err_disable; + + memset(ucb, 0, sizeof(struct ucb1x00)); + + ucb->cdev.class = &ucb1x00_class; + ucb->cdev.dev = &mcp->attached_device; + strlcpy(ucb->cdev.class_id, "ucb1x00", sizeof(ucb->cdev.class_id)); + + spin_lock_init(&ucb->lock); + spin_lock_init(&ucb->io_lock); + sema_init(&ucb->adc_sem, 1); + + ucb->id = id; + ucb->mcp = mcp; + ucb->irq = ucb1x00_detect_irq(ucb); + if (ucb->irq == NO_IRQ) { + printk(KERN_ERR "UCB1x00: IRQ probe failed\n"); + ret = -ENODEV; + goto err_free; + } + + ret = request_irq(ucb->irq, ucb1x00_irq, 0, "UCB1x00", ucb); + if (ret) { + printk(KERN_ERR "ucb1x00: unable to grab irq%d: %d\n", + ucb->irq, ret); + goto err_free; + } + + set_irq_type(ucb->irq, IRQT_RISING); + mcp_set_drvdata(mcp, ucb); + + ret = class_device_register(&ucb->cdev); + if (ret) + goto err_irq; + + INIT_LIST_HEAD(&ucb->devs); + down(&ucb1x00_sem); + list_add(&ucb->node, &ucb1x00_devices); + list_for_each_entry(drv, &ucb1x00_drivers, node) { + ucb1x00_add_dev(ucb, drv); + } + up(&ucb1x00_sem); + goto out; + + err_irq: + free_irq(ucb->irq, ucb); + err_free: + kfree(ucb); + err_disable: + mcp_disable(mcp); + out: + return ret; +} + +static void ucb1x00_remove(struct mcp *mcp) +{ + struct ucb1x00 *ucb = mcp_get_drvdata(mcp); + struct list_head *l, *n; + + down(&ucb1x00_sem); + list_del(&ucb->node); + list_for_each_safe(l, n, &ucb->devs) { + struct ucb1x00_dev *dev = list_entry(l, struct ucb1x00_dev, dev_node); + ucb1x00_remove_dev(dev); + } + up(&ucb1x00_sem); + + free_irq(ucb->irq, ucb); + class_device_unregister(&ucb->cdev); +} + +static void ucb1x00_release(struct class_device *dev) +{ + struct ucb1x00 *ucb = classdev_to_ucb1x00(dev); + kfree(ucb); +} + +static struct class ucb1x00_class = { + .name = "ucb1x00", + .release = ucb1x00_release, +}; + +int ucb1x00_register_driver(struct ucb1x00_driver *drv) +{ + struct ucb1x00 *ucb; + + INIT_LIST_HEAD(&drv->devs); + down(&ucb1x00_sem); + list_add(&drv->node, &ucb1x00_drivers); + list_for_each_entry(ucb, &ucb1x00_devices, node) { + ucb1x00_add_dev(ucb, drv); + } + up(&ucb1x00_sem); + return 0; +} + +void ucb1x00_unregister_driver(struct ucb1x00_driver *drv) +{ + struct list_head *n, *l; + + down(&ucb1x00_sem); + list_del(&drv->node); + list_for_each_safe(l, n, &drv->devs) { + struct ucb1x00_dev *dev = list_entry(l, struct ucb1x00_dev, drv_node); + ucb1x00_remove_dev(dev); + } + up(&ucb1x00_sem); +} + +static int ucb1x00_suspend(struct mcp *mcp, pm_message_t state) +{ + struct ucb1x00 *ucb = mcp_get_drvdata(mcp); + struct ucb1x00_dev *dev; + + down(&ucb1x00_sem); + list_for_each_entry(dev, &ucb->devs, dev_node) { + if (dev->drv->suspend) + dev->drv->suspend(dev, state); + } + up(&ucb1x00_sem); + return 0; +} + +static int ucb1x00_resume(struct mcp *mcp) +{ + struct ucb1x00 *ucb = mcp_get_drvdata(mcp); + struct ucb1x00_dev *dev; + + down(&ucb1x00_sem); + list_for_each_entry(dev, &ucb->devs, dev_node) { + if (dev->drv->resume) + dev->drv->resume(dev); + } + up(&ucb1x00_sem); + return 0; +} + +static struct mcp_driver ucb1x00_driver = { + .drv = { + .name = "ucb1x00", + }, + .probe = ucb1x00_probe, + .remove = ucb1x00_remove, + .suspend = ucb1x00_suspend, + .resume = ucb1x00_resume, +}; + +static int __init ucb1x00_init(void) +{ + int ret = class_register(&ucb1x00_class); + if (ret == 0) { + ret = mcp_driver_register(&ucb1x00_driver); + if (ret) + class_unregister(&ucb1x00_class); + } + return ret; +} + +static void __exit ucb1x00_exit(void) +{ + mcp_driver_unregister(&ucb1x00_driver); + class_unregister(&ucb1x00_class); +} + +module_init(ucb1x00_init); +module_exit(ucb1x00_exit); + +EXPORT_SYMBOL(ucb1x00_class); + +EXPORT_SYMBOL(ucb1x00_io_set_dir); +EXPORT_SYMBOL(ucb1x00_io_write); +EXPORT_SYMBOL(ucb1x00_io_read); + +EXPORT_SYMBOL(ucb1x00_adc_enable); +EXPORT_SYMBOL(ucb1x00_adc_read); +EXPORT_SYMBOL(ucb1x00_adc_disable); + +EXPORT_SYMBOL(ucb1x00_hook_irq); +EXPORT_SYMBOL(ucb1x00_free_irq); +EXPORT_SYMBOL(ucb1x00_enable_irq); +EXPORT_SYMBOL(ucb1x00_disable_irq); + +EXPORT_SYMBOL(ucb1x00_register_driver); +EXPORT_SYMBOL(ucb1x00_unregister_driver); + +MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>"); +MODULE_DESCRIPTION("UCB1x00 core driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/mfd/ucb1x00-ts.c b/drivers/mfd/ucb1x00-ts.c new file mode 100644 index 00000000000..a851d65c7cf --- /dev/null +++ b/drivers/mfd/ucb1x00-ts.c @@ -0,0 +1,399 @@ +/* + * Touchscreen driver for UCB1x00-based touchscreens + * + * Copyright (C) 2001 Russell King, All Rights Reserved. + * Copyright (C) 2005 Pavel Machek + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 21-Jan-2002 <jco@ict.es> : + * + * Added support for synchronous A/D mode. This mode is useful to + * avoid noise induced in the touchpanel by the LCD, provided that + * the UCB1x00 has a valid LCD sync signal routed to its ADCSYNC pin. + * It is important to note that the signal connected to the ADCSYNC + * pin should provide pulses even when the LCD is blanked, otherwise + * a pen touch needed to unblank the LCD will never be read. + */ +#include <linux/config.h> +#include <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/init.h> +#include <linux/smp.h> +#include <linux/smp_lock.h> +#include <linux/sched.h> +#include <linux/completion.h> +#include <linux/delay.h> +#include <linux/string.h> +#include <linux/input.h> +#include <linux/device.h> +#include <linux/suspend.h> +#include <linux/slab.h> +#include <linux/kthread.h> + +#include <asm/dma.h> +#include <asm/semaphore.h> + +#include "ucb1x00.h" + + +struct ucb1x00_ts { + struct input_dev idev; + struct ucb1x00 *ucb; + + wait_queue_head_t irq_wait; + struct task_struct *rtask; + u16 x_res; + u16 y_res; + + int restart:1; + int adcsync:1; +}; + +static int adcsync; + +static inline void ucb1x00_ts_evt_add(struct ucb1x00_ts *ts, u16 pressure, u16 x, u16 y) +{ + input_report_abs(&ts->idev, ABS_X, x); + input_report_abs(&ts->idev, ABS_Y, y); + input_report_abs(&ts->idev, ABS_PRESSURE, pressure); + input_sync(&ts->idev); +} + +static inline void ucb1x00_ts_event_release(struct ucb1x00_ts *ts) +{ + input_report_abs(&ts->idev, ABS_PRESSURE, 0); + input_sync(&ts->idev); +} + +/* + * Switch to interrupt mode. + */ +static inline void ucb1x00_ts_mode_int(struct ucb1x00_ts *ts) +{ + ucb1x00_reg_write(ts->ucb, UCB_TS_CR, + UCB_TS_CR_TSMX_POW | UCB_TS_CR_TSPX_POW | + UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_GND | + UCB_TS_CR_MODE_INT); +} + +/* + * Switch to pressure mode, and read pressure. We don't need to wait + * here, since both plates are being driven. + */ +static inline unsigned int ucb1x00_ts_read_pressure(struct ucb1x00_ts *ts) +{ + ucb1x00_reg_write(ts->ucb, UCB_TS_CR, + UCB_TS_CR_TSMX_POW | UCB_TS_CR_TSPX_POW | + UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_GND | + UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA); + + return ucb1x00_adc_read(ts->ucb, UCB_ADC_INP_TSPY, ts->adcsync); +} + +/* + * Switch to X position mode and measure Y plate. We switch the plate + * configuration in pressure mode, then switch to position mode. This + * gives a faster response time. Even so, we need to wait about 55us + * for things to stabilise. + */ +static inline unsigned int ucb1x00_ts_read_xpos(struct ucb1x00_ts *ts) +{ + ucb1x00_reg_write(ts->ucb, UCB_TS_CR, + UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW | + UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA); + ucb1x00_reg_write(ts->ucb, UCB_TS_CR, + UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW | + UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA); + ucb1x00_reg_write(ts->ucb, UCB_TS_CR, + UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW | + UCB_TS_CR_MODE_POS | UCB_TS_CR_BIAS_ENA); + + udelay(55); + + return ucb1x00_adc_read(ts->ucb, UCB_ADC_INP_TSPY, ts->adcsync); +} + +/* + * Switch to Y position mode and measure X plate. We switch the plate + * configuration in pressure mode, then switch to position mode. This + * gives a faster response time. Even so, we need to wait about 55us + * for things to stabilise. + */ +static inline unsigned int ucb1x00_ts_read_ypos(struct ucb1x00_ts *ts) +{ + ucb1x00_reg_write(ts->ucb, UCB_TS_CR, + UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW | + UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA); + ucb1x00_reg_write(ts->ucb, UCB_TS_CR, + UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW | + UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA); + ucb1x00_reg_write(ts->ucb, UCB_TS_CR, + UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW | + UCB_TS_CR_MODE_POS | UCB_TS_CR_BIAS_ENA); + + udelay(55); + + return ucb1x00_adc_read(ts->ucb, UCB_ADC_INP_TSPX, ts->adcsync); +} + +/* + * Switch to X plate resistance mode. Set MX to ground, PX to + * supply. Measure current. + */ +static inline unsigned int ucb1x00_ts_read_xres(struct ucb1x00_ts *ts) +{ + ucb1x00_reg_write(ts->ucb, UCB_TS_CR, + UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW | + UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA); + return ucb1x00_adc_read(ts->ucb, 0, ts->adcsync); +} + +/* + * Switch to Y plate resistance mode. Set MY to ground, PY to + * supply. Measure current. + */ +static inline unsigned int ucb1x00_ts_read_yres(struct ucb1x00_ts *ts) +{ + ucb1x00_reg_write(ts->ucb, UCB_TS_CR, + UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW | + UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA); + return ucb1x00_adc_read(ts->ucb, 0, ts->adcsync); +} + +/* + * This is a RT kernel thread that handles the ADC accesses + * (mainly so we can use semaphores in the UCB1200 core code + * to serialise accesses to the ADC). + */ +static int ucb1x00_thread(void *_ts) +{ + struct ucb1x00_ts *ts = _ts; + struct task_struct *tsk = current; + DECLARE_WAITQUEUE(wait, tsk); + int valid; + + /* + * We could run as a real-time thread. However, thus far + * this doesn't seem to be necessary. + */ +// tsk->policy = SCHED_FIFO; +// tsk->rt_priority = 1; + + valid = 0; + + add_wait_queue(&ts->irq_wait, &wait); + while (!kthread_should_stop()) { + unsigned int x, y, p, val; + signed long timeout; + + ts->restart = 0; + + ucb1x00_adc_enable(ts->ucb); + + x = ucb1x00_ts_read_xpos(ts); + y = ucb1x00_ts_read_ypos(ts); + p = ucb1x00_ts_read_pressure(ts); + + /* + * Switch back to interrupt mode. + */ + ucb1x00_ts_mode_int(ts); + ucb1x00_adc_disable(ts->ucb); + + msleep(10); + + ucb1x00_enable(ts->ucb); + val = ucb1x00_reg_read(ts->ucb, UCB_TS_CR); + + if (val & (UCB_TS_CR_TSPX_LOW | UCB_TS_CR_TSMX_LOW)) { + set_task_state(tsk, TASK_INTERRUPTIBLE); + + ucb1x00_enable_irq(ts->ucb, UCB_IRQ_TSPX, UCB_FALLING); + ucb1x00_disable(ts->ucb); + + /* + * If we spat out a valid sample set last time, + * spit out a "pen off" sample here. + */ + if (valid) { + ucb1x00_ts_event_release(ts); + valid = 0; + } + + timeout = MAX_SCHEDULE_TIMEOUT; + } else { + ucb1x00_disable(ts->ucb); + + /* + * Filtering is policy. Policy belongs in user + * space. We therefore leave it to user space + * to do any filtering they please. + */ + if (!ts->restart) { + ucb1x00_ts_evt_add(ts, p, x, y); + valid = 1; + } + + set_task_state(tsk, TASK_INTERRUPTIBLE); + timeout = HZ / 100; + } + + try_to_freeze(); + + schedule_timeout(timeout); + } + + remove_wait_queue(&ts->irq_wait, &wait); + + ts->rtask = NULL; + return 0; +} + +/* + * We only detect touch screen _touches_ with this interrupt + * handler, and even then we just schedule our task. + */ +static void ucb1x00_ts_irq(int idx, void *id) +{ + struct ucb1x00_ts *ts = id; + ucb1x00_disable_irq(ts->ucb, UCB_IRQ_TSPX, UCB_FALLING); + wake_up(&ts->irq_wait); +} + +static int ucb1x00_ts_open(struct input_dev *idev) +{ + struct ucb1x00_ts *ts = (struct ucb1x00_ts *)idev; + int ret = 0; + + BUG_ON(ts->rtask); + + init_waitqueue_head(&ts->irq_wait); + ret = ucb1x00_hook_irq(ts->ucb, UCB_IRQ_TSPX, ucb1x00_ts_irq, ts); + if (ret < 0) + goto out; + + /* + * If we do this at all, we should allow the user to + * measure and read the X and Y resistance at any time. + */ + ucb1x00_adc_enable(ts->ucb); + ts->x_res = ucb1x00_ts_read_xres(ts); + ts->y_res = ucb1x00_ts_read_yres(ts); + ucb1x00_adc_disable(ts->ucb); + + ts->rtask = kthread_run(ucb1x00_thread, ts, "ktsd"); + if (!IS_ERR(ts->rtask)) { + ret = 0; + } else { + ucb1x00_free_irq(ts->ucb, UCB_IRQ_TSPX, ts); + ts->rtask = NULL; + ret = -EFAULT; + } + + out: + return ret; +} + +/* + * Release touchscreen resources. Disable IRQs. + */ +static void ucb1x00_ts_close(struct input_dev *idev) +{ + struct ucb1x00_ts *ts = (struct ucb1x00_ts *)idev; + + if (ts->rtask) + kthread_stop(ts->rtask); + + ucb1x00_enable(ts->ucb); + ucb1x00_free_irq(ts->ucb, UCB_IRQ_TSPX, ts); + ucb1x00_reg_write(ts->ucb, UCB_TS_CR, 0); + ucb1x00_disable(ts->ucb); +} + +#ifdef CONFIG_PM +static int ucb1x00_ts_resume(struct ucb1x00_dev *dev) +{ + struct ucb1x00_ts *ts = dev->priv; + + if (ts->rtask != NULL) { + /* + * Restart the TS thread to ensure the + * TS interrupt mode is set up again + * after sleep. + */ + ts->restart = 1; + wake_up(&ts->irq_wait); + } + return 0; +} +#else +#define ucb1x00_ts_resume NULL +#endif + + +/* + * Initialisation. + */ +static int ucb1x00_ts_add(struct ucb1x00_dev *dev) +{ + struct ucb1x00_ts *ts; + + ts = kmalloc(sizeof(struct ucb1x00_ts), GFP_KERNEL); + if (!ts) + return -ENOMEM; + + memset(ts, 0, sizeof(struct ucb1x00_ts)); + + ts->ucb = dev->ucb; + ts->adcsync = adcsync ? UCB_SYNC : UCB_NOSYNC; + + ts->idev.name = "Touchscreen panel"; + ts->idev.id.product = ts->ucb->id; + ts->idev.open = ucb1x00_ts_open; + ts->idev.close = ucb1x00_ts_close; + + __set_bit(EV_ABS, ts->idev.evbit); + __set_bit(ABS_X, ts->idev.absbit); + __set_bit(ABS_Y, ts->idev.absbit); + __set_bit(ABS_PRESSURE, ts->idev.absbit); + + input_register_device(&ts->idev); + + dev->priv = ts; + + return 0; +} + +static void ucb1x00_ts_remove(struct ucb1x00_dev *dev) +{ + struct ucb1x00_ts *ts = dev->priv; + input_unregister_device(&ts->idev); + kfree(ts); +} + +static struct ucb1x00_driver ucb1x00_ts_driver = { + .add = ucb1x00_ts_add, + .remove = ucb1x00_ts_remove, + .resume = ucb1x00_ts_resume, +}; + +static int __init ucb1x00_ts_init(void) +{ + return ucb1x00_register_driver(&ucb1x00_ts_driver); +} + +static void __exit ucb1x00_ts_exit(void) +{ + ucb1x00_unregister_driver(&ucb1x00_ts_driver); +} + +module_param(adcsync, int, 0444); +module_init(ucb1x00_ts_init); +module_exit(ucb1x00_ts_exit); + +MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>"); +MODULE_DESCRIPTION("UCB1x00 touchscreen driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/mfd/ucb1x00.h b/drivers/mfd/ucb1x00.h new file mode 100644 index 00000000000..6b632644f59 --- /dev/null +++ b/drivers/mfd/ucb1x00.h @@ -0,0 +1,256 @@ +/* + * linux/drivers/mfd/ucb1x00.h + * + * Copyright (C) 2001 Russell King, All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License. + */ +#ifndef UCB1200_H +#define UCB1200_H + +#define UCB_IO_DATA 0x00 +#define UCB_IO_DIR 0x01 + +#define UCB_IO_0 (1 << 0) +#define UCB_IO_1 (1 << 1) +#define UCB_IO_2 (1 << 2) +#define UCB_IO_3 (1 << 3) +#define UCB_IO_4 (1 << 4) +#define UCB_IO_5 (1 << 5) +#define UCB_IO_6 (1 << 6) +#define UCB_IO_7 (1 << 7) +#define UCB_IO_8 (1 << 8) +#define UCB_IO_9 (1 << 9) + +#define UCB_IE_RIS 0x02 +#define UCB_IE_FAL 0x03 +#define UCB_IE_STATUS 0x04 +#define UCB_IE_CLEAR 0x04 +#define UCB_IE_ADC (1 << 11) +#define UCB_IE_TSPX (1 << 12) +#define UCB_IE_TSMX (1 << 13) +#define UCB_IE_TCLIP (1 << 14) +#define UCB_IE_ACLIP (1 << 15) + +#define UCB_IRQ_TSPX 12 + +#define UCB_TC_A 0x05 +#define UCB_TC_A_LOOP (1 << 7) /* UCB1200 */ +#define UCB_TC_A_AMPL (1 << 7) /* UCB1300 */ + +#define UCB_TC_B 0x06 +#define UCB_TC_B_VOICE_ENA (1 << 3) +#define UCB_TC_B_CLIP (1 << 4) +#define UCB_TC_B_ATT (1 << 6) +#define UCB_TC_B_SIDE_ENA (1 << 11) +#define UCB_TC_B_MUTE (1 << 13) +#define UCB_TC_B_IN_ENA (1 << 14) +#define UCB_TC_B_OUT_ENA (1 << 15) + +#define UCB_AC_A 0x07 +#define UCB_AC_B 0x08 +#define UCB_AC_B_LOOP (1 << 8) +#define UCB_AC_B_MUTE (1 << 13) +#define UCB_AC_B_IN_ENA (1 << 14) +#define UCB_AC_B_OUT_ENA (1 << 15) + +#define UCB_TS_CR 0x09 +#define UCB_TS_CR_TSMX_POW (1 << 0) +#define UCB_TS_CR_TSPX_POW (1 << 1) +#define UCB_TS_CR_TSMY_POW (1 << 2) +#define UCB_TS_CR_TSPY_POW (1 << 3) +#define UCB_TS_CR_TSMX_GND (1 << 4) +#define UCB_TS_CR_TSPX_GND (1 << 5) +#define UCB_TS_CR_TSMY_GND (1 << 6) +#define UCB_TS_CR_TSPY_GND (1 << 7) +#define UCB_TS_CR_MODE_INT (0 << 8) +#define UCB_TS_CR_MODE_PRES (1 << 8) +#define UCB_TS_CR_MODE_POS (2 << 8) +#define UCB_TS_CR_BIAS_ENA (1 << 11) +#define UCB_TS_CR_TSPX_LOW (1 << 12) +#define UCB_TS_CR_TSMX_LOW (1 << 13) + +#define UCB_ADC_CR 0x0a +#define UCB_ADC_SYNC_ENA (1 << 0) +#define UCB_ADC_VREFBYP_CON (1 << 1) +#define UCB_ADC_INP_TSPX (0 << 2) +#define UCB_ADC_INP_TSMX (1 << 2) +#define UCB_ADC_INP_TSPY (2 << 2) +#define UCB_ADC_INP_TSMY (3 << 2) +#define UCB_ADC_INP_AD0 (4 << 2) +#define UCB_ADC_INP_AD1 (5 << 2) +#define UCB_ADC_INP_AD2 (6 << 2) +#define UCB_ADC_INP_AD3 (7 << 2) +#define UCB_ADC_EXT_REF (1 << 5) +#define UCB_ADC_START (1 << 7) +#define UCB_ADC_ENA (1 << 15) + +#define UCB_ADC_DATA 0x0b +#define UCB_ADC_DAT_VAL (1 << 15) +#define UCB_ADC_DAT(x) (((x) & 0x7fe0) >> 5) + +#define UCB_ID 0x0c +#define UCB_ID_1200 0x1004 +#define UCB_ID_1300 0x1005 + +#define UCB_MODE 0x0d +#define UCB_MODE_DYN_VFLAG_ENA (1 << 12) +#define UCB_MODE_AUD_OFF_CAN (1 << 13) + +#include "mcp.h" + +struct ucb1x00_irq { + void *devid; + void (*fn)(int, void *); +}; + +extern struct class ucb1x00_class; + +struct ucb1x00 { + spinlock_t lock; + struct mcp *mcp; + unsigned int irq; + struct semaphore adc_sem; + spinlock_t io_lock; + u16 id; + u16 io_dir; + u16 io_out; + u16 adc_cr; + u16 irq_fal_enbl; + u16 irq_ris_enbl; + struct ucb1x00_irq irq_handler[16]; + struct class_device cdev; + struct list_head node; + struct list_head devs; +}; + +struct ucb1x00_driver; + +struct ucb1x00_dev { + struct list_head dev_node; + struct list_head drv_node; + struct ucb1x00 *ucb; + struct ucb1x00_driver *drv; + void *priv; +}; + +struct ucb1x00_driver { + struct list_head node; + struct list_head devs; + int (*add)(struct ucb1x00_dev *dev); + void (*remove)(struct ucb1x00_dev *dev); + int (*suspend)(struct ucb1x00_dev *dev, pm_message_t state); + int (*resume)(struct ucb1x00_dev *dev); +}; + +#define classdev_to_ucb1x00(cd) container_of(cd, struct ucb1x00, cdev) + +int ucb1x00_register_driver(struct ucb1x00_driver *); +void ucb1x00_unregister_driver(struct ucb1x00_driver *); + +/** + * ucb1x00_clkrate - return the UCB1x00 SIB clock rate + * @ucb: UCB1x00 structure describing chip + * + * Return the SIB clock rate in Hz. + */ +static inline unsigned int ucb1x00_clkrate(struct ucb1x00 *ucb) +{ + return mcp_get_sclk_rate(ucb->mcp); +} + +/** + * ucb1x00_enable - enable the UCB1x00 SIB clock + * @ucb: UCB1x00 structure describing chip + * + * Enable the SIB clock. This can be called multiple times. + */ +static inline void ucb1x00_enable(struct ucb1x00 *ucb) +{ + mcp_enable(ucb->mcp); +} + +/** + * ucb1x00_disable - disable the UCB1x00 SIB clock + * @ucb: UCB1x00 structure describing chip + * + * Disable the SIB clock. The SIB clock will only be disabled + * when the number of ucb1x00_enable calls match the number of + * ucb1x00_disable calls. + */ +static inline void ucb1x00_disable(struct ucb1x00 *ucb) +{ + mcp_disable(ucb->mcp); +} + +/** + * ucb1x00_reg_write - write a UCB1x00 register + * @ucb: UCB1x00 structure describing chip + * @reg: UCB1x00 4-bit register index to write + * @val: UCB1x00 16-bit value to write + * + * Write the UCB1x00 register @reg with value @val. The SIB + * clock must be running for this function to return. + */ +static inline void ucb1x00_reg_write(struct ucb1x00 *ucb, unsigned int reg, unsigned int val) +{ + mcp_reg_write(ucb->mcp, reg, val); +} + +/** + * ucb1x00_reg_read - read a UCB1x00 register + * @ucb: UCB1x00 structure describing chip + * @reg: UCB1x00 4-bit register index to write + * + * Read the UCB1x00 register @reg and return its value. The SIB + * clock must be running for this function to return. + */ +static inline unsigned int ucb1x00_reg_read(struct ucb1x00 *ucb, unsigned int reg) +{ + return mcp_reg_read(ucb->mcp, reg); +} +/** + * ucb1x00_set_audio_divisor - + * @ucb: UCB1x00 structure describing chip + * @div: SIB clock divisor + */ +static inline void ucb1x00_set_audio_divisor(struct ucb1x00 *ucb, unsigned int div) +{ + mcp_set_audio_divisor(ucb->mcp, div); +} + +/** + * ucb1x00_set_telecom_divisor - + * @ucb: UCB1x00 structure describing chip + * @div: SIB clock divisor + */ +static inline void ucb1x00_set_telecom_divisor(struct ucb1x00 *ucb, unsigned int div) +{ + mcp_set_telecom_divisor(ucb->mcp, div); +} + +void ucb1x00_io_set_dir(struct ucb1x00 *ucb, unsigned int, unsigned int); +void ucb1x00_io_write(struct ucb1x00 *ucb, unsigned int, unsigned int); +unsigned int ucb1x00_io_read(struct ucb1x00 *ucb); + +#define UCB_NOSYNC (0) +#define UCB_SYNC (1) + +unsigned int ucb1x00_adc_read(struct ucb1x00 *ucb, int adc_channel, int sync); +void ucb1x00_adc_enable(struct ucb1x00 *ucb); +void ucb1x00_adc_disable(struct ucb1x00 *ucb); + +/* + * Which edges of the IRQ do you want to control today? + */ +#define UCB_RISING (1 << 0) +#define UCB_FALLING (1 << 1) + +int ucb1x00_hook_irq(struct ucb1x00 *ucb, unsigned int idx, void (*fn)(int, void *), void *devid); +void ucb1x00_enable_irq(struct ucb1x00 *ucb, unsigned int idx, int edges); +void ucb1x00_disable_irq(struct ucb1x00 *ucb, unsigned int idx, int edges); +int ucb1x00_free_irq(struct ucb1x00 *ucb, unsigned int idx, void *devid); + +#endif diff --git a/drivers/misc/hdpuftrs/hdpu_cpustate.c b/drivers/misc/hdpuftrs/hdpu_cpustate.c index 7501fab349e..46de5c94055 100644 --- a/drivers/misc/hdpuftrs/hdpu_cpustate.c +++ b/drivers/misc/hdpuftrs/hdpu_cpustate.c @@ -192,22 +192,37 @@ static int hdpu_cpustate_probe(struct device *ddev) { struct platform_device *pdev = to_platform_device(ddev); struct resource *res; + struct proc_dir_entry *proc_de; + int ret; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); cpustate.set_addr = (unsigned long *)res->start; cpustate.clr_addr = (unsigned long *)res->end - 1; - misc_register(&cpustate_dev); - create_proc_read_entry("sky_cpustate", 0, 0, cpustate_read_proc, NULL); + ret = misc_register(&cpustate_dev); + if (ret) { + printk(KERN_WARNING "sky_cpustate: Unable to register misc " + "device.\n"); + cpustate.set_addr = NULL; + cpustate.clr_addr = NULL; + return ret; + } + + proc_de = create_proc_read_entry("sky_cpustate", 0, 0, + cpustate_read_proc, NULL); + if (proc_de == NULL) + printk(KERN_WARNING "sky_cpustate: Unable to create proc " + "dir entry\n"); printk(KERN_INFO "Sky CPU State Driver v" SKY_CPUSTATE_VERSION "\n"); return 0; } + static int hdpu_cpustate_remove(struct device *ddev) { - cpustate.set_addr = 0; - cpustate.clr_addr = 0; + cpustate.set_addr = NULL; + cpustate.clr_addr = NULL; remove_proc_entry("sky_cpustate", NULL); misc_deregister(&cpustate_dev); diff --git a/drivers/mmc/wbsd.c b/drivers/mmc/wbsd.c index a62c86fef5c..e11e55dc892 100644 --- a/drivers/mmc/wbsd.c +++ b/drivers/mmc/wbsd.c @@ -1112,20 +1112,6 @@ static void wbsd_reset_ignore(unsigned long data) } /* - * Helper function for card detection - */ -static void wbsd_detect_card(unsigned long data) -{ - struct wbsd_host *host = (struct wbsd_host*)data; - - BUG_ON(host == NULL); - - DBG("Executing card detection\n"); - - mmc_detect_change(host->mmc, 0); -} - -/* * Tasklets */ @@ -1169,14 +1155,16 @@ static void wbsd_tasklet_card(unsigned long param) DBG("Card inserted\n"); host->flags |= WBSD_FCARD_PRESENT; + spin_unlock(&host->lock); + /* * Delay card detection to allow electrical connections * to stabilise. */ - mod_timer(&host->detect_timer, jiffies + HZ/2); + mmc_detect_change(host->mmc, msecs_to_jiffies(500)); } - - spin_unlock(&host->lock); + else + spin_unlock(&host->lock); } else if (host->flags & WBSD_FCARD_PRESENT) { @@ -1409,10 +1397,6 @@ static int __devinit wbsd_alloc_mmc(struct device* dev) /* * Set up timers */ - init_timer(&host->detect_timer); - host->detect_timer.data = (unsigned long)host; - host->detect_timer.function = wbsd_detect_card; - init_timer(&host->ignore_timer); host->ignore_timer.data = (unsigned long)host; host->ignore_timer.function = wbsd_reset_ignore; @@ -1454,7 +1438,6 @@ static void __devexit wbsd_free_mmc(struct device* dev) BUG_ON(host == NULL); del_timer_sync(&host->ignore_timer); - del_timer_sync(&host->detect_timer); mmc_free_host(mmc); diff --git a/drivers/mtd/devices/mtdram.c b/drivers/mtd/devices/mtdram.c index bb713fed2f3..1443117fd8f 100644 --- a/drivers/mtd/devices/mtdram.c +++ b/drivers/mtd/devices/mtdram.c @@ -91,8 +91,7 @@ static void __exit cleanup_mtdram(void) { if (mtd_info) { del_mtd_device(mtd_info); - if (mtd_info->priv) - vfree(mtd_info->priv); + vfree(mtd_info->priv); kfree(mtd_info); } } diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c index d9ab60b36fd..d32c1b3a8ce 100644 --- a/drivers/mtd/ftl.c +++ b/drivers/mtd/ftl.c @@ -1017,27 +1017,16 @@ static int ftl_writesect(struct mtd_blktrans_dev *dev, void ftl_freepart(partition_t *part) { - if (part->VirtualBlockMap) { vfree(part->VirtualBlockMap); part->VirtualBlockMap = NULL; - } - if (part->VirtualPageMap) { kfree(part->VirtualPageMap); part->VirtualPageMap = NULL; - } - if (part->EUNInfo) { kfree(part->EUNInfo); part->EUNInfo = NULL; - } - if (part->XferInfo) { kfree(part->XferInfo); part->XferInfo = NULL; - } - if (part->bam_cache) { kfree(part->bam_cache); part->bam_cache = NULL; - } - } /* ftl_freepart */ static void ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) diff --git a/drivers/mtd/maps/uclinux.c b/drivers/mtd/maps/uclinux.c index 811d92e5f5b..cc372136e85 100644 --- a/drivers/mtd/maps/uclinux.c +++ b/drivers/mtd/maps/uclinux.c @@ -25,9 +25,6 @@ /****************************************************************************/ - -/****************************************************************************/ - struct map_info uclinux_ram_map = { .name = "RAM", }; @@ -60,14 +57,15 @@ int __init uclinux_mtd_init(void) struct mtd_info *mtd; struct map_info *mapp; extern char _ebss; + unsigned long addr = (unsigned long) &_ebss; mapp = &uclinux_ram_map; - mapp->phys = (unsigned long) &_ebss; - mapp->size = PAGE_ALIGN(*((unsigned long *)((&_ebss) + 8))); + mapp->phys = addr; + mapp->size = PAGE_ALIGN(ntohl(*((unsigned long *)(addr + 8)))); mapp->bankwidth = 4; printk("uclinux[mtd]: RAM probe address=0x%x size=0x%x\n", - (int) mapp->map_priv_2, (int) mapp->size); + (int) mapp->phys, (int) mapp->size); mapp->virt = ioremap_nocache(mapp->phys, mapp->size); @@ -95,7 +93,6 @@ int __init uclinux_mtd_init(void) printk("uclinux[mtd]: set %s to be root filesystem\n", uclinux_romfs[0].name); ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, 0); - put_mtd_device(mtd); return(0); } @@ -109,7 +106,7 @@ void __exit uclinux_mtd_cleanup(void) map_destroy(uclinux_ram_mtdinfo); uclinux_ram_mtdinfo = NULL; } - if (uclinux_ram_map.map_priv_1) { + if (uclinux_ram_map.virt) { iounmap((void *) uclinux_ram_map.virt); uclinux_ram_map.virt = 0; } diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 6bb9232514b..54fff9c2e80 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -1738,11 +1738,18 @@ config 68360_ENET the Motorola 68360 processor. config FEC - bool "FEC ethernet controller (of ColdFire 5272)" - depends on M5272 || M5282 + bool "FEC ethernet controller (of ColdFire CPUs)" + depends on M523x || M527x || M5272 || M528x help Say Y here if you want to use the built-in 10/100 Fast ethernet - controller on the Motorola ColdFire 5272 processor. + controller on some Motorola ColdFire processors. + +config FEC2 + bool "Second FEC ethernet controller (on some ColdFire CPUs)" + depends on FEC + help + Say Y here if you want to use the second built-in 10/100 Fast + ethernet controller on some Motorola ColdFire processors. config NE_H8300 tristate "NE2000 compatible support for H8/300" diff --git a/drivers/net/atari_bionet.c b/drivers/net/atari_bionet.c index 1798ce7262c..0095384ff45 100644 --- a/drivers/net/atari_bionet.c +++ b/drivers/net/atari_bionet.c @@ -155,7 +155,7 @@ static int bionet_close(struct net_device *dev); static struct net_device_stats *net_get_stats(struct net_device *dev); static void bionet_tick(unsigned long); -static struct timer_list bionet_timer = TIMER_INITIALIZER(bionet_tick, 0, 0); +static DEFINE_TIMER(bionet_timer, bionet_tick, 0, 0); #define STRAM_ADDR(a) (((a) & 0xff000000) == 0) diff --git a/drivers/net/atari_pamsnet.c b/drivers/net/atari_pamsnet.c index 81c362c8cb9..8b997809f9d 100644 --- a/drivers/net/atari_pamsnet.c +++ b/drivers/net/atari_pamsnet.c @@ -165,7 +165,7 @@ static void pamsnet_tick(unsigned long); static irqreturn_t pamsnet_intr(int irq, void *data, struct pt_regs *fp); -static struct timer_list pamsnet_timer = TIMER_INITIALIZER(pamsnet_tick, 0, 0); +static DEFINE_TIMER(pamsnet_timer, pamsnet_tick, 0, 0); #define STRAM_ADDR(a) (((a) & 0xff000000) == 0) diff --git a/drivers/net/bsd_comp.c b/drivers/net/bsd_comp.c index 3d88ad622bd..fb4098ed469 100644 --- a/drivers/net/bsd_comp.c +++ b/drivers/net/bsd_comp.c @@ -323,33 +323,27 @@ static void bsd_reset (void *state) */ static void bsd_free (void *state) - { - struct bsd_db *db = (struct bsd_db *) state; +{ + struct bsd_db *db = state; - if (db) - { + if (!db) + return; + /* * Release the dictionary */ - if (db->dict) - { - vfree (db->dict); - db->dict = NULL; - } + vfree(db->dict); + db->dict = NULL; /* * Release the string buffer */ - if (db->lens) - { - vfree (db->lens); - db->lens = NULL; - } + vfree(db->lens); + db->lens = NULL; /* * Finally release the structure itself. */ - kfree (db); - } - } + kfree(db); +} /* * Allocate space for a (de) compressor. diff --git a/drivers/net/cris/eth_v10.c b/drivers/net/cris/eth_v10.c index 442670860fc..b68b9cad76e 100644 --- a/drivers/net/cris/eth_v10.c +++ b/drivers/net/cris/eth_v10.c @@ -384,8 +384,8 @@ static unsigned int mdio_phy_addr; /* Transciever address */ static unsigned int network_tr_ctrl_shadow = 0; /* Network speed indication. */ -static struct timer_list speed_timer = TIMER_INITIALIZER(NULL, 0, 0); -static struct timer_list clear_led_timer = TIMER_INITIALIZER(NULL, 0, 0); +static DEFINE_TIMER(speed_timer, NULL, 0, 0); +static DEFINE_TIMER(clear_led_timer, NULL, 0, 0); static int current_speed; /* Speed read from transceiver */ static int current_speed_selection; /* Speed selected by user */ static unsigned long led_next_time; @@ -393,7 +393,7 @@ static int led_active; static int rx_queue_len; /* Duplex */ -static struct timer_list duplex_timer = TIMER_INITIALIZER(NULL, 0, 0); +static DEFINE_TIMER(duplex_timer, NULL, 0, 0); static int full_duplex; static enum duplex current_duplex; diff --git a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c index b780307093e..cdc07ccd733 100644 --- a/drivers/net/cs89x0.c +++ b/drivers/net/cs89x0.c @@ -247,6 +247,9 @@ static int get_eeprom_data(struct net_device *dev, int off, int len, int *buffer static int get_eeprom_cksum(int off, int len, int *buffer); static int set_mac_address(struct net_device *dev, void *addr); static void count_rx_errors(int status, struct net_local *lp); +#ifdef CONFIG_NET_POLL_CONTROLLER +static void net_poll_controller(struct net_device *dev); +#endif #if ALLOW_DMA static void get_dma_channel(struct net_device *dev); static void release_dma_buff(struct net_local *lp); @@ -405,6 +408,19 @@ get_eeprom_cksum(int off, int len, int *buffer) return -1; } +#ifdef CONFIG_NET_POLL_CONTROLLER +/* + * Polling receive - used by netconsole and other diagnostic tools + * to allow network i/o with interrupts disabled. + */ +static void net_poll_controller(struct net_device *dev) +{ + disable_irq(dev->irq); + net_interrupt(dev->irq, dev, NULL); + enable_irq(dev->irq); +} +#endif + /* This is the real probe routine. Linux has a history of friendly device probes on the ISA bus. A good device probes avoids doing writes, and verifies that the correct device exists and functions. @@ -760,6 +776,9 @@ cs89x0_probe1(struct net_device *dev, int ioaddr, int modular) dev->get_stats = net_get_stats; dev->set_multicast_list = set_multicast_list; dev->set_mac_address = set_mac_address; +#ifdef CONFIG_NET_POLL_CONTROLLER + dev->poll_controller = net_poll_controller; +#endif printk("\n"); if (net_debug) diff --git a/drivers/net/fec.c b/drivers/net/fec.c index 2c700849137..85504fb900d 100644 --- a/drivers/net/fec.c +++ b/drivers/net/fec.c @@ -8,7 +8,7 @@ * describes connections using the internal parallel port I/O, which * is basically all of Port D. * - * Right now, I am very watseful with the buffers. I allocate memory + * Right now, I am very wasteful with the buffers. I allocate memory * pages and then divide them into 2K frame buffers. This way I know I * have buffers large enough to hold one frame within one buffer descriptor. * Once I get this working, I will use 64 or 128 byte CPM buffers, which @@ -19,7 +19,10 @@ * Copyright (c) 2000 Ericsson Radio Systems AB. * * Support for FEC controller of ColdFire/5270/5271/5272/5274/5275/5280/5282. - * Copyrught (c) 2001-2004 Greg Ungerer (gerg@snapgear.com) + * Copyright (c) 2001-2004 Greg Ungerer (gerg@snapgear.com) + * + * Bug fixes and cleanup by Philippe De Muyter (phdm@macqel.be) + * Copyright (c) 2004-2005 Macq Electronique SA. */ #include <linux/config.h> @@ -46,7 +49,8 @@ #include <asm/io.h> #include <asm/pgtable.h> -#if defined(CONFIG_M527x) || defined(CONFIG_M5272) || defined(CONFIG_M528x) +#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || \ + defined(CONFIG_M5272) || defined(CONFIG_M528x) #include <asm/coldfire.h> #include <asm/mcfsim.h> #include "fec.h" @@ -71,7 +75,7 @@ static unsigned int fec_hw[] = { #elif defined(CONFIG_M527x) (MCF_MBAR + 0x1000), (MCF_MBAR + 0x1800), -#elif defined(CONFIG_M528x) +#elif defined(CONFIG_M523x) || defined(CONFIG_M528x) (MCF_MBAR + 0x1000), #else &(((immap_t *)IMAP_ADDR)->im_cpm.cp_fec), @@ -94,12 +98,14 @@ static unsigned char fec_mac_default[] = { #define FEC_FLASHMAC 0xffe04000 #elif defined(CONFIG_CANCam) #define FEC_FLASHMAC 0xf0020000 +#elif defined (CONFIG_M5272C3) +#define FEC_FLASHMAC (0xffe04000 + 4) +#elif defined(CONFIG_MOD5272) +#define FEC_FLASHMAC 0xffc0406b #else #define FEC_FLASHMAC 0 #endif -unsigned char *fec_flashmac = (unsigned char *) FEC_FLASHMAC; - /* Forward declarations of some structures to support different PHYs */ @@ -158,7 +164,7 @@ typedef struct { * size bits. Other FEC hardware does not, so we need to take that into * account when setting it. */ -#if defined(CONFIG_M527x) || defined(CONFIG_M528x) +#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) #define OPT_FRAME_SIZE (PKT_MAXBUF_SIZE << 16) #else #define OPT_FRAME_SIZE 0 @@ -196,7 +202,7 @@ struct fec_enet_private { uint phy_id_done; uint phy_status; uint phy_speed; - phy_info_t *phy; + phy_info_t const *phy; struct work_struct phy_task; uint sequence_done; @@ -209,7 +215,6 @@ struct fec_enet_private { int link; int old_link; int full_duplex; - unsigned char mac_addr[ETH_ALEN]; }; static int fec_enet_open(struct net_device *dev); @@ -237,10 +242,10 @@ typedef struct mii_list { } mii_list_t; #define NMII 20 -mii_list_t mii_cmds[NMII]; -mii_list_t *mii_free; -mii_list_t *mii_head; -mii_list_t *mii_tail; +static mii_list_t mii_cmds[NMII]; +static mii_list_t *mii_free; +static mii_list_t *mii_head; +static mii_list_t *mii_tail; static int mii_queue(struct net_device *dev, int request, void (*func)(uint, struct net_device *)); @@ -425,7 +430,7 @@ fec_timeout(struct net_device *dev) } } #endif - fec_restart(dev, 0); + fec_restart(dev, fep->full_duplex); netif_wake_queue(dev); } @@ -757,45 +762,52 @@ static void mii_parse_sr(uint mii_reg, struct net_device *dev) { struct fec_enet_private *fep = netdev_priv(dev); volatile uint *s = &(fep->phy_status); + uint status; - *s &= ~(PHY_STAT_LINK | PHY_STAT_FAULT | PHY_STAT_ANC); + status = *s & ~(PHY_STAT_LINK | PHY_STAT_FAULT | PHY_STAT_ANC); if (mii_reg & 0x0004) - *s |= PHY_STAT_LINK; + status |= PHY_STAT_LINK; if (mii_reg & 0x0010) - *s |= PHY_STAT_FAULT; + status |= PHY_STAT_FAULT; if (mii_reg & 0x0020) - *s |= PHY_STAT_ANC; + status |= PHY_STAT_ANC; + + *s = status; } static void mii_parse_cr(uint mii_reg, struct net_device *dev) { struct fec_enet_private *fep = netdev_priv(dev); volatile uint *s = &(fep->phy_status); + uint status; - *s &= ~(PHY_CONF_ANE | PHY_CONF_LOOP); + status = *s & ~(PHY_CONF_ANE | PHY_CONF_LOOP); if (mii_reg & 0x1000) - *s |= PHY_CONF_ANE; + status |= PHY_CONF_ANE; if (mii_reg & 0x4000) - *s |= PHY_CONF_LOOP; + status |= PHY_CONF_LOOP; + *s = status; } static void mii_parse_anar(uint mii_reg, struct net_device *dev) { struct fec_enet_private *fep = netdev_priv(dev); volatile uint *s = &(fep->phy_status); + uint status; - *s &= ~(PHY_CONF_SPMASK); + status = *s & ~(PHY_CONF_SPMASK); if (mii_reg & 0x0020) - *s |= PHY_CONF_10HDX; + status |= PHY_CONF_10HDX; if (mii_reg & 0x0040) - *s |= PHY_CONF_10FDX; + status |= PHY_CONF_10FDX; if (mii_reg & 0x0080) - *s |= PHY_CONF_100HDX; + status |= PHY_CONF_100HDX; if (mii_reg & 0x00100) - *s |= PHY_CONF_100FDX; + status |= PHY_CONF_100FDX; + *s = status; } /* ------------------------------------------------------------------------- */ @@ -811,37 +823,34 @@ static void mii_parse_lxt970_csr(uint mii_reg, struct net_device *dev) { struct fec_enet_private *fep = netdev_priv(dev); volatile uint *s = &(fep->phy_status); + uint status; - *s &= ~(PHY_STAT_SPMASK); - + status = *s & ~(PHY_STAT_SPMASK); if (mii_reg & 0x0800) { if (mii_reg & 0x1000) - *s |= PHY_STAT_100FDX; + status |= PHY_STAT_100FDX; else - *s |= PHY_STAT_100HDX; + status |= PHY_STAT_100HDX; } else { if (mii_reg & 0x1000) - *s |= PHY_STAT_10FDX; + status |= PHY_STAT_10FDX; else - *s |= PHY_STAT_10HDX; + status |= PHY_STAT_10HDX; } + *s = status; } -static phy_info_t phy_info_lxt970 = { - 0x07810000, - "LXT970", - - (const phy_cmd_t []) { /* config */ +static phy_cmd_t const phy_cmd_lxt970_config[] = { { mk_mii_read(MII_REG_CR), mii_parse_cr }, { mk_mii_read(MII_REG_ANAR), mii_parse_anar }, { mk_mii_end, } - }, - (const phy_cmd_t []) { /* startup - enable interrupts */ + }; +static phy_cmd_t const phy_cmd_lxt970_startup[] = { /* enable interrupts */ { mk_mii_write(MII_LXT970_IER, 0x0002), NULL }, { mk_mii_write(MII_REG_CR, 0x1200), NULL }, /* autonegotiate */ { mk_mii_end, } - }, - (const phy_cmd_t []) { /* ack_int */ + }; +static phy_cmd_t const phy_cmd_lxt970_ack_int[] = { /* read SR and ISR to acknowledge */ { mk_mii_read(MII_REG_SR), mii_parse_sr }, { mk_mii_read(MII_LXT970_ISR), NULL }, @@ -849,11 +858,18 @@ static phy_info_t phy_info_lxt970 = { /* find out the current status */ { mk_mii_read(MII_LXT970_CSR), mii_parse_lxt970_csr }, { mk_mii_end, } - }, - (const phy_cmd_t []) { /* shutdown - disable interrupts */ + }; +static phy_cmd_t const phy_cmd_lxt970_shutdown[] = { /* disable interrupts */ { mk_mii_write(MII_LXT970_IER, 0x0000), NULL }, { mk_mii_end, } - }, + }; +static phy_info_t const phy_info_lxt970 = { + .id = 0x07810000, + .name = "LXT970", + .config = phy_cmd_lxt970_config, + .startup = phy_cmd_lxt970_startup, + .ack_int = phy_cmd_lxt970_ack_int, + .shutdown = phy_cmd_lxt970_shutdown }; /* ------------------------------------------------------------------------- */ @@ -878,45 +894,44 @@ static void mii_parse_lxt971_sr2(uint mii_reg, struct net_device *dev) { struct fec_enet_private *fep = netdev_priv(dev); volatile uint *s = &(fep->phy_status); + uint status; - *s &= ~(PHY_STAT_SPMASK | PHY_STAT_LINK | PHY_STAT_ANC); + status = *s & ~(PHY_STAT_SPMASK | PHY_STAT_LINK | PHY_STAT_ANC); if (mii_reg & 0x0400) { fep->link = 1; - *s |= PHY_STAT_LINK; + status |= PHY_STAT_LINK; } else { fep->link = 0; } if (mii_reg & 0x0080) - *s |= PHY_STAT_ANC; + status |= PHY_STAT_ANC; if (mii_reg & 0x4000) { if (mii_reg & 0x0200) - *s |= PHY_STAT_100FDX; + status |= PHY_STAT_100FDX; else - *s |= PHY_STAT_100HDX; + status |= PHY_STAT_100HDX; } else { if (mii_reg & 0x0200) - *s |= PHY_STAT_10FDX; + status |= PHY_STAT_10FDX; else - *s |= PHY_STAT_10HDX; + status |= PHY_STAT_10HDX; } if (mii_reg & 0x0008) - *s |= PHY_STAT_FAULT; -} + status |= PHY_STAT_FAULT; -static phy_info_t phy_info_lxt971 = { - 0x0001378e, - "LXT971", + *s = status; +} - (const phy_cmd_t []) { /* config */ - /* limit to 10MBit because my protorype board +static phy_cmd_t const phy_cmd_lxt971_config[] = { + /* limit to 10MBit because my prototype board * doesn't work with 100. */ { mk_mii_read(MII_REG_CR), mii_parse_cr }, { mk_mii_read(MII_REG_ANAR), mii_parse_anar }, { mk_mii_read(MII_LXT971_SR2), mii_parse_lxt971_sr2 }, { mk_mii_end, } - }, - (const phy_cmd_t []) { /* startup - enable interrupts */ + }; +static phy_cmd_t const phy_cmd_lxt971_startup[] = { /* enable interrupts */ { mk_mii_write(MII_LXT971_IER, 0x00f2), NULL }, { mk_mii_write(MII_REG_CR, 0x1200), NULL }, /* autonegotiate */ { mk_mii_write(MII_LXT971_LCR, 0xd422), NULL }, /* LED config */ @@ -925,19 +940,26 @@ static phy_info_t phy_info_lxt971 = { * read here to get a valid value in ack_int */ { mk_mii_read(MII_REG_SR), mii_parse_sr }, { mk_mii_end, } - }, - (const phy_cmd_t []) { /* ack_int */ + }; +static phy_cmd_t const phy_cmd_lxt971_ack_int[] = { + /* acknowledge the int before reading status ! */ + { mk_mii_read(MII_LXT971_ISR), NULL }, /* find out the current status */ { mk_mii_read(MII_REG_SR), mii_parse_sr }, { mk_mii_read(MII_LXT971_SR2), mii_parse_lxt971_sr2 }, - /* we only need to read ISR to acknowledge */ - { mk_mii_read(MII_LXT971_ISR), NULL }, { mk_mii_end, } - }, - (const phy_cmd_t []) { /* shutdown - disable interrupts */ + }; +static phy_cmd_t const phy_cmd_lxt971_shutdown[] = { /* disable interrupts */ { mk_mii_write(MII_LXT971_IER, 0x0000), NULL }, { mk_mii_end, } - }, + }; +static phy_info_t const phy_info_lxt971 = { + .id = 0x0001378e, + .name = "LXT971", + .config = phy_cmd_lxt971_config, + .startup = phy_cmd_lxt971_startup, + .ack_int = phy_cmd_lxt971_ack_int, + .shutdown = phy_cmd_lxt971_shutdown }; /* ------------------------------------------------------------------------- */ @@ -956,22 +978,21 @@ static void mii_parse_qs6612_pcr(uint mii_reg, struct net_device *dev) { struct fec_enet_private *fep = netdev_priv(dev); volatile uint *s = &(fep->phy_status); + uint status; - *s &= ~(PHY_STAT_SPMASK); + status = *s & ~(PHY_STAT_SPMASK); switch((mii_reg >> 2) & 7) { - case 1: *s |= PHY_STAT_10HDX; break; - case 2: *s |= PHY_STAT_100HDX; break; - case 5: *s |= PHY_STAT_10FDX; break; - case 6: *s |= PHY_STAT_100FDX; break; - } + case 1: status |= PHY_STAT_10HDX; break; + case 2: status |= PHY_STAT_100HDX; break; + case 5: status |= PHY_STAT_10FDX; break; + case 6: status |= PHY_STAT_100FDX; break; } -static phy_info_t phy_info_qs6612 = { - 0x00181440, - "QS6612", - - (const phy_cmd_t []) { /* config */ + *s = status; +} + +static phy_cmd_t const phy_cmd_qs6612_config[] = { /* The PHY powers up isolated on the RPX, * so send a command to allow operation. */ @@ -981,13 +1002,13 @@ static phy_info_t phy_info_qs6612 = { { mk_mii_read(MII_REG_CR), mii_parse_cr }, { mk_mii_read(MII_REG_ANAR), mii_parse_anar }, { mk_mii_end, } - }, - (const phy_cmd_t []) { /* startup - enable interrupts */ + }; +static phy_cmd_t const phy_cmd_qs6612_startup[] = { /* enable interrupts */ { mk_mii_write(MII_QS6612_IMR, 0x003a), NULL }, { mk_mii_write(MII_REG_CR, 0x1200), NULL }, /* autonegotiate */ { mk_mii_end, } - }, - (const phy_cmd_t []) { /* ack_int */ + }; +static phy_cmd_t const phy_cmd_qs6612_ack_int[] = { /* we need to read ISR, SR and ANER to acknowledge */ { mk_mii_read(MII_QS6612_ISR), NULL }, { mk_mii_read(MII_REG_SR), mii_parse_sr }, @@ -996,11 +1017,18 @@ static phy_info_t phy_info_qs6612 = { /* read pcr to get info */ { mk_mii_read(MII_QS6612_PCR), mii_parse_qs6612_pcr }, { mk_mii_end, } - }, - (const phy_cmd_t []) { /* shutdown - disable interrupts */ + }; +static phy_cmd_t const phy_cmd_qs6612_shutdown[] = { /* disable interrupts */ { mk_mii_write(MII_QS6612_IMR, 0x0000), NULL }, { mk_mii_end, } - }, + }; +static phy_info_t const phy_info_qs6612 = { + .id = 0x00181440, + .name = "QS6612", + .config = phy_cmd_qs6612_config, + .startup = phy_cmd_qs6612_startup, + .ack_int = phy_cmd_qs6612_ack_int, + .shutdown = phy_cmd_qs6612_shutdown }; /* ------------------------------------------------------------------------- */ @@ -1020,49 +1048,54 @@ static void mii_parse_am79c874_dr(uint mii_reg, struct net_device *dev) { struct fec_enet_private *fep = netdev_priv(dev); volatile uint *s = &(fep->phy_status); + uint status; - *s &= ~(PHY_STAT_SPMASK | PHY_STAT_ANC); + status = *s & ~(PHY_STAT_SPMASK | PHY_STAT_ANC); if (mii_reg & 0x0080) - *s |= PHY_STAT_ANC; + status |= PHY_STAT_ANC; if (mii_reg & 0x0400) - *s |= ((mii_reg & 0x0800) ? PHY_STAT_100FDX : PHY_STAT_100HDX); + status |= ((mii_reg & 0x0800) ? PHY_STAT_100FDX : PHY_STAT_100HDX); else - *s |= ((mii_reg & 0x0800) ? PHY_STAT_10FDX : PHY_STAT_10HDX); + status |= ((mii_reg & 0x0800) ? PHY_STAT_10FDX : PHY_STAT_10HDX); + + *s = status; } -static phy_info_t phy_info_am79c874 = { - 0x00022561, - "AM79C874", - - (const phy_cmd_t []) { /* config */ - /* limit to 10MBit because my protorype board - * doesn't work with 100. */ +static phy_cmd_t const phy_cmd_am79c874_config[] = { { mk_mii_read(MII_REG_CR), mii_parse_cr }, { mk_mii_read(MII_REG_ANAR), mii_parse_anar }, { mk_mii_read(MII_AM79C874_DR), mii_parse_am79c874_dr }, { mk_mii_end, } - }, - (const phy_cmd_t []) { /* startup - enable interrupts */ + }; +static phy_cmd_t const phy_cmd_am79c874_startup[] = { /* enable interrupts */ { mk_mii_write(MII_AM79C874_ICSR, 0xff00), NULL }, { mk_mii_write(MII_REG_CR, 0x1200), NULL }, /* autonegotiate */ { mk_mii_read(MII_REG_SR), mii_parse_sr }, { mk_mii_end, } - }, - (const phy_cmd_t []) { /* ack_int */ + }; +static phy_cmd_t const phy_cmd_am79c874_ack_int[] = { /* find out the current status */ { mk_mii_read(MII_REG_SR), mii_parse_sr }, { mk_mii_read(MII_AM79C874_DR), mii_parse_am79c874_dr }, /* we only need to read ISR to acknowledge */ { mk_mii_read(MII_AM79C874_ICSR), NULL }, { mk_mii_end, } - }, - (const phy_cmd_t []) { /* shutdown - disable interrupts */ + }; +static phy_cmd_t const phy_cmd_am79c874_shutdown[] = { /* disable interrupts */ { mk_mii_write(MII_AM79C874_ICSR, 0x0000), NULL }, { mk_mii_end, } - }, + }; +static phy_info_t const phy_info_am79c874 = { + .id = 0x00022561, + .name = "AM79C874", + .config = phy_cmd_am79c874_config, + .startup = phy_cmd_am79c874_startup, + .ack_int = phy_cmd_am79c874_ack_int, + .shutdown = phy_cmd_am79c874_shutdown }; + /* ------------------------------------------------------------------------- */ /* Kendin KS8721BL phy */ @@ -1072,37 +1105,40 @@ static phy_info_t phy_info_am79c874 = { #define MII_KS8721BL_ICSR 22 #define MII_KS8721BL_PHYCR 31 -static phy_info_t phy_info_ks8721bl = { - 0x00022161, - "KS8721BL", - - (const phy_cmd_t []) { /* config */ +static phy_cmd_t const phy_cmd_ks8721bl_config[] = { { mk_mii_read(MII_REG_CR), mii_parse_cr }, { mk_mii_read(MII_REG_ANAR), mii_parse_anar }, { mk_mii_end, } - }, - (const phy_cmd_t []) { /* startup */ + }; +static phy_cmd_t const phy_cmd_ks8721bl_startup[] = { /* enable interrupts */ { mk_mii_write(MII_KS8721BL_ICSR, 0xff00), NULL }, { mk_mii_write(MII_REG_CR, 0x1200), NULL }, /* autonegotiate */ { mk_mii_read(MII_REG_SR), mii_parse_sr }, { mk_mii_end, } - }, - (const phy_cmd_t []) { /* ack_int */ + }; +static phy_cmd_t const phy_cmd_ks8721bl_ack_int[] = { /* find out the current status */ { mk_mii_read(MII_REG_SR), mii_parse_sr }, /* we only need to read ISR to acknowledge */ { mk_mii_read(MII_KS8721BL_ICSR), NULL }, { mk_mii_end, } - }, - (const phy_cmd_t []) { /* shutdown */ + }; +static phy_cmd_t const phy_cmd_ks8721bl_shutdown[] = { /* disable interrupts */ { mk_mii_write(MII_KS8721BL_ICSR, 0x0000), NULL }, { mk_mii_end, } - }, + }; +static phy_info_t const phy_info_ks8721bl = { + .id = 0x00022161, + .name = "KS8721BL", + .config = phy_cmd_ks8721bl_config, + .startup = phy_cmd_ks8721bl_startup, + .ack_int = phy_cmd_ks8721bl_ack_int, + .shutdown = phy_cmd_ks8721bl_shutdown }; /* ------------------------------------------------------------------------- */ -static phy_info_t *phy_info[] = { +static phy_info_t const * const phy_info[] = { &phy_info_lxt970, &phy_info_lxt971, &phy_info_qs6612, @@ -1129,16 +1165,23 @@ mii_link_interrupt(int irq, void * dev_id, struct pt_regs * regs); static void __inline__ fec_request_intrs(struct net_device *dev) { volatile unsigned long *icrp; + static const struct idesc { + char *name; + unsigned short irq; + irqreturn_t (*handler)(int, void *, struct pt_regs *); + } *idp, id[] = { + { "fec(RX)", 86, fec_enet_interrupt }, + { "fec(TX)", 87, fec_enet_interrupt }, + { "fec(OTHER)", 88, fec_enet_interrupt }, + { "fec(MII)", 66, mii_link_interrupt }, + { NULL }, + }; /* Setup interrupt handlers. */ - if (request_irq(86, fec_enet_interrupt, 0, "fec(RX)", dev) != 0) - printk("FEC: Could not allocate FEC(RC) IRQ(86)!\n"); - if (request_irq(87, fec_enet_interrupt, 0, "fec(TX)", dev) != 0) - printk("FEC: Could not allocate FEC(RC) IRQ(87)!\n"); - if (request_irq(88, fec_enet_interrupt, 0, "fec(OTHER)", dev) != 0) - printk("FEC: Could not allocate FEC(OTHER) IRQ(88)!\n"); - if (request_irq(66, mii_link_interrupt, 0, "fec(MII)", dev) != 0) - printk("FEC: Could not allocate MII IRQ(66)!\n"); + for (idp = id; idp->name; idp++) { + if (request_irq(idp->irq, idp->handler, 0, idp->name, dev) != 0) + printk("FEC: Could not allocate %s IRQ(%d)!\n", idp->name, idp->irq); + } /* Unmask interrupt at ColdFire 5272 SIM */ icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR3); @@ -1169,17 +1212,16 @@ static void __inline__ fec_get_mac(struct net_device *dev) { struct fec_enet_private *fep = netdev_priv(dev); volatile fec_t *fecp; - unsigned char *iap, tmpaddr[6]; - int i; + unsigned char *iap, tmpaddr[ETH_ALEN]; fecp = fep->hwp; - if (fec_flashmac) { + if (FEC_FLASHMAC) { /* * Get MAC address from FLASH. * If it is all 1's or 0's, use the default. */ - iap = fec_flashmac; + iap = (unsigned char *)FEC_FLASHMAC; if ((iap[0] == 0) && (iap[1] == 0) && (iap[2] == 0) && (iap[3] == 0) && (iap[4] == 0) && (iap[5] == 0)) iap = fec_mac_default; @@ -1192,14 +1234,11 @@ static void __inline__ fec_get_mac(struct net_device *dev) iap = &tmpaddr[0]; } - for (i=0; i<ETH_ALEN; i++) - dev->dev_addr[i] = fep->mac_addr[i] = *iap++; + memcpy(dev->dev_addr, iap, ETH_ALEN); /* Adjust MAC if using default MAC address */ - if (iap == fec_mac_default) { - dev->dev_addr[ETH_ALEN-1] = fep->mac_addr[ETH_ALEN-1] = - iap[ETH_ALEN-1] + fep->index; - } + if (iap == fec_mac_default) + dev->dev_addr[ETH_ALEN-1] = fec_mac_default[ETH_ALEN-1] + fep->index; } static void __inline__ fec_enable_phy_intr(void) @@ -1234,48 +1273,44 @@ static void __inline__ fec_uncache(unsigned long addr) /* ------------------------------------------------------------------------- */ -#elif defined(CONFIG_M527x) || defined(CONFIG_M528x) +#elif defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) /* - * Code specific to Coldfire 5270/5271/5274/5275 and 5280/5282 setups. + * Code specific to Coldfire 5230/5231/5232/5234/5235, + * the 5270/5271/5274/5275 and 5280/5282 setups. */ static void __inline__ fec_request_intrs(struct net_device *dev) { struct fec_enet_private *fep; int b; + static const struct idesc { + char *name; + unsigned short irq; + } *idp, id[] = { + { "fec(TXF)", 23 }, + { "fec(TXB)", 24 }, + { "fec(TXFIFO)", 25 }, + { "fec(TXCR)", 26 }, + { "fec(RXF)", 27 }, + { "fec(RXB)", 28 }, + { "fec(MII)", 29 }, + { "fec(LC)", 30 }, + { "fec(HBERR)", 31 }, + { "fec(GRA)", 32 }, + { "fec(EBERR)", 33 }, + { "fec(BABT)", 34 }, + { "fec(BABR)", 35 }, + { NULL }, + }; fep = netdev_priv(dev); b = (fep->index) ? 128 : 64; /* Setup interrupt handlers. */ - if (request_irq(b+23, fec_enet_interrupt, 0, "fec(TXF)", dev) != 0) - printk("FEC: Could not allocate FEC(TXF) IRQ(%d+23)!\n", b); - if (request_irq(b+24, fec_enet_interrupt, 0, "fec(TXB)", dev) != 0) - printk("FEC: Could not allocate FEC(TXB) IRQ(%d+24)!\n", b); - if (request_irq(b+25, fec_enet_interrupt, 0, "fec(TXFIFO)", dev) != 0) - printk("FEC: Could not allocate FEC(TXFIFO) IRQ(%d+25)!\n", b); - if (request_irq(b+26, fec_enet_interrupt, 0, "fec(TXCR)", dev) != 0) - printk("FEC: Could not allocate FEC(TXCR) IRQ(%d+26)!\n", b); - - if (request_irq(b+27, fec_enet_interrupt, 0, "fec(RXF)", dev) != 0) - printk("FEC: Could not allocate FEC(RXF) IRQ(%d+27)!\n", b); - if (request_irq(b+28, fec_enet_interrupt, 0, "fec(RXB)", dev) != 0) - printk("FEC: Could not allocate FEC(RXB) IRQ(%d+28)!\n", b); - - if (request_irq(b+29, fec_enet_interrupt, 0, "fec(MII)", dev) != 0) - printk("FEC: Could not allocate FEC(MII) IRQ(%d+29)!\n", b); - if (request_irq(b+30, fec_enet_interrupt, 0, "fec(LC)", dev) != 0) - printk("FEC: Could not allocate FEC(LC) IRQ(%d+30)!\n", b); - if (request_irq(b+31, fec_enet_interrupt, 0, "fec(HBERR)", dev) != 0) - printk("FEC: Could not allocate FEC(HBERR) IRQ(%d+31)!\n", b); - if (request_irq(b+32, fec_enet_interrupt, 0, "fec(GRA)", dev) != 0) - printk("FEC: Could not allocate FEC(GRA) IRQ(%d+32)!\n", b); - if (request_irq(b+33, fec_enet_interrupt, 0, "fec(EBERR)", dev) != 0) - printk("FEC: Could not allocate FEC(EBERR) IRQ(%d+33)!\n", b); - if (request_irq(b+34, fec_enet_interrupt, 0, "fec(BABT)", dev) != 0) - printk("FEC: Could not allocate FEC(BABT) IRQ(%d+34)!\n", b); - if (request_irq(b+35, fec_enet_interrupt, 0, "fec(BABR)", dev) != 0) - printk("FEC: Could not allocate FEC(BABR) IRQ(%d+35)!\n", b); + for (idp = id; idp->name; idp++) { + if (request_irq(b+idp->irq, fec_enet_interrupt, 0, idp->name, dev) != 0) + printk("FEC: Could not allocate %s IRQ(%d)!\n", idp->name, b+idp->irq); + } /* Unmask interrupts at ColdFire 5280/5282 interrupt controller */ { @@ -1300,11 +1335,13 @@ static void __inline__ fec_request_intrs(struct net_device *dev) #if defined(CONFIG_M528x) /* Set up gpio outputs for MII lines */ { - volatile unsigned short *gpio_paspar; + volatile u16 *gpio_paspar; + volatile u8 *gpio_pehlpar; - gpio_paspar = (volatile unsigned short *) (MCF_IPSBAR + - 0x100056); - *gpio_paspar = 0x0f00; + gpio_paspar = (volatile u16 *) (MCF_IPSBAR + 0x100056); + gpio_pehlpar = (volatile u16 *) (MCF_IPSBAR + 0x100058); + *gpio_paspar |= 0x0f00; + *gpio_pehlpar = 0xc0; } #endif } @@ -1331,17 +1368,16 @@ static void __inline__ fec_get_mac(struct net_device *dev) { struct fec_enet_private *fep = netdev_priv(dev); volatile fec_t *fecp; - unsigned char *iap, tmpaddr[6]; - int i; + unsigned char *iap, tmpaddr[ETH_ALEN]; fecp = fep->hwp; - if (fec_flashmac) { + if (FEC_FLASHMAC) { /* * Get MAC address from FLASH. * If it is all 1's or 0's, use the default. */ - iap = fec_flashmac; + iap = FEC_FLASHMAC; if ((iap[0] == 0) && (iap[1] == 0) && (iap[2] == 0) && (iap[3] == 0) && (iap[4] == 0) && (iap[5] == 0)) iap = fec_mac_default; @@ -1354,14 +1390,11 @@ static void __inline__ fec_get_mac(struct net_device *dev) iap = &tmpaddr[0]; } - for (i=0; i<ETH_ALEN; i++) - dev->dev_addr[i] = fep->mac_addr[i] = *iap++; + memcpy(dev->dev_addr, iap, ETH_ALEN); /* Adjust MAC if using default MAC address */ - if (iap == fec_mac_default) { - dev->dev_addr[ETH_ALEN-1] = fep->mac_addr[ETH_ALEN-1] = - iap[ETH_ALEN-1] + fep->index; - } + if (iap == fec_mac_default) + dev->dev_addr[ETH_ALEN-1] = fec_mac_default[ETH_ALEN-1] + fep->index; } static void __inline__ fec_enable_phy_intr(void) @@ -1392,7 +1425,7 @@ static void __inline__ fec_uncache(unsigned long addr) #else /* - * Code sepcific to the MPC860T setup. + * Code specific to the MPC860T setup. */ static void __inline__ fec_request_intrs(struct net_device *dev) { @@ -1424,13 +1457,10 @@ static void __inline__ fec_request_intrs(struct net_device *dev) static void __inline__ fec_get_mac(struct net_device *dev) { - struct fec_enet_private *fep = netdev_priv(dev); - unsigned char *iap, tmpaddr[6]; bd_t *bd; - int i; - iap = bd->bi_enetaddr; bd = (bd_t *)__res; + memcpy(dev->dev_addr, bd->bi_enetaddr, ETH_ALEN); #ifdef CONFIG_RPXCLASSIC /* The Embedded Planet boards have only one MAC address in @@ -1439,14 +1469,8 @@ static void __inline__ fec_get_mac(struct net_device *dev) * the address bits above something that would have (up to * now) been allocated. */ - for (i=0; i<6; i++) - tmpaddr[i] = *iap++; - tmpaddr[3] |= 0x80; - iap = tmpaddr; + dev->dev_adrd[3] |= 0x80; #endif - - for (i=0; i<6; i++) - dev->dev_addr[i] = fep->mac_addr[i] = *iap++; } static void __inline__ fec_set_mii(struct net_device *dev, struct fec_enet_private *fep) @@ -1556,7 +1580,7 @@ static void mii_display_status(struct net_device *dev) static void mii_display_config(struct net_device *dev) { struct fec_enet_private *fep = netdev_priv(dev); - volatile uint *s = &(fep->phy_status); + uint status = fep->phy_status; /* ** When we get here, phy_task is already removed from @@ -1565,23 +1589,23 @@ static void mii_display_config(struct net_device *dev) fep->mii_phy_task_queued = 0; printk("%s: config: auto-negotiation ", dev->name); - if (*s & PHY_CONF_ANE) + if (status & PHY_CONF_ANE) printk("on"); else printk("off"); - if (*s & PHY_CONF_100FDX) + if (status & PHY_CONF_100FDX) printk(", 100FDX"); - if (*s & PHY_CONF_100HDX) + if (status & PHY_CONF_100HDX) printk(", 100HDX"); - if (*s & PHY_CONF_10FDX) + if (status & PHY_CONF_10FDX) printk(", 10FDX"); - if (*s & PHY_CONF_10HDX) + if (status & PHY_CONF_10HDX) printk(", 10HDX"); - if (!(*s & PHY_CONF_SPMASK)) + if (!(status & PHY_CONF_SPMASK)) printk(", No speed/duplex selected?"); - if (*s & PHY_CONF_LOOP) + if (status & PHY_CONF_LOOP) printk(", loopback enabled"); printk(".\n"); @@ -1639,7 +1663,7 @@ static void mii_queue_relink(uint mii_reg, struct net_device *dev) schedule_work(&fep->phy_task); } -/* mii_queue_config is called in user context from fec_enet_open */ +/* mii_queue_config is called in interrupt context from fec_enet_mii */ static void mii_queue_config(uint mii_reg, struct net_device *dev) { struct fec_enet_private *fep = netdev_priv(dev); @@ -1652,14 +1676,14 @@ static void mii_queue_config(uint mii_reg, struct net_device *dev) schedule_work(&fep->phy_task); } - - -phy_cmd_t phy_cmd_relink[] = { { mk_mii_read(MII_REG_CR), mii_queue_relink }, - { mk_mii_end, } }; -phy_cmd_t phy_cmd_config[] = { { mk_mii_read(MII_REG_CR), mii_queue_config }, - { mk_mii_end, } }; - - +phy_cmd_t const phy_cmd_relink[] = { + { mk_mii_read(MII_REG_CR), mii_queue_relink }, + { mk_mii_end, } + }; +phy_cmd_t const phy_cmd_config[] = { + { mk_mii_read(MII_REG_CR), mii_queue_config }, + { mk_mii_end, } + }; /* Read remainder of PHY ID. */ @@ -1897,17 +1921,15 @@ static void set_multicast_list(struct net_device *dev) static void fec_set_mac_address(struct net_device *dev) { - struct fec_enet_private *fep; volatile fec_t *fecp; - fep = netdev_priv(dev); - fecp = fep->hwp; + fecp = ((struct fec_enet_private *)netdev_priv(dev))->hwp; /* Set station address. */ - fecp->fec_addr_low = fep->mac_addr[3] | (fep->mac_addr[2] << 8) | - (fep->mac_addr[1] << 16) | (fep->mac_addr[0] << 24); - fecp->fec_addr_high = (fep->mac_addr[5] << 16) | - (fep->mac_addr[4] << 24); + fecp->fec_addr_low = dev->dev_addr[3] | (dev->dev_addr[2] << 8) | + (dev->dev_addr[1] << 16) | (dev->dev_addr[0] << 24); + fecp->fec_addr_high = (dev->dev_addr[5] << 16) | + (dev->dev_addr[4] << 24); } @@ -1943,7 +1965,7 @@ int __init fec_enet_init(struct net_device *dev) udelay(10); /* Clear and enable interrupts */ - fecp->fec_ievent = 0xffc0; + fecp->fec_ievent = 0xffc00000; fecp->fec_imask = (FEC_ENET_TXF | FEC_ENET_TXB | FEC_ENET_RXF | FEC_ENET_RXB | FEC_ENET_MII); fecp->fec_hash_table_high = 0; @@ -2063,11 +2085,6 @@ int __init fec_enet_init(struct net_device *dev) /* setup MII interface */ fec_set_mii(dev, fep); - printk("%s: FEC ENET Version 0.2, ", dev->name); - for (i=0; i<5; i++) - printk("%02x:", dev->dev_addr[i]); - printk("%02x\n", dev->dev_addr[5]); - /* Queue up command to detect the PHY and initialize the * remainder of the interface. */ @@ -2106,18 +2123,12 @@ fec_restart(struct net_device *dev, int duplex) /* Clear any outstanding interrupt. */ - fecp->fec_ievent = 0xffc0; + fecp->fec_ievent = 0xffc00000; fec_enable_phy_intr(); /* Set station address. */ - fecp->fec_addr_low = fep->mac_addr[3] | (fep->mac_addr[2] << 8) | - (fep->mac_addr[1] << 16) | (fep->mac_addr[0] << 24); - fecp->fec_addr_high = (fep->mac_addr[5] << 16) | - (fep->mac_addr[4] << 24); - - for (i=0; i<ETH_ALEN; i++) - dev->dev_addr[i] = fep->mac_addr[i]; + fec_set_mac_address(dev); /* Reset all multicast. */ @@ -2215,7 +2226,7 @@ fec_stop(struct net_device *dev) fecp->fec_x_cntrl = 0x01; /* Graceful transmit stop */ - while(!(fecp->fec_ievent & 0x10000000)); + while(!(fecp->fec_ievent & FEC_ENET_GRA)); /* Whack a reset. We should wait for this. */ @@ -2234,7 +2245,9 @@ fec_stop(struct net_device *dev) static int __init fec_enet_module_init(void) { struct net_device *dev; - int i, err; + int i, j, err; + + printk("FEC ENET Version 0.2\n"); for (i = 0; (i < FEC_MAX_PORTS); i++) { dev = alloc_etherdev(sizeof(struct fec_enet_private)); @@ -2250,6 +2263,11 @@ static int __init fec_enet_module_init(void) free_netdev(dev); return -EIO; } + + printk("%s: ethernet ", dev->name); + for (j = 0; (j < 5); j++) + printk("%02x:", dev->dev_addr[j]); + printk("%02x\n", dev->dev_addr[5]); } return 0; } diff --git a/drivers/net/fec.h b/drivers/net/fec.h index c6e4f979ff5..045761b8a60 100644 --- a/drivers/net/fec.h +++ b/drivers/net/fec.h @@ -1,8 +1,9 @@ /****************************************************************************/ /* - * fec.h -- Fast Ethernet Controller for Motorola ColdFire 5270, - 5271, 5272, 5274, 5275, 5280 and 5282. + * fec.h -- Fast Ethernet Controller for Motorola ColdFire 5230, + * 5231, 5232, 5234, 5235, 5270, 5271, 5272, 5274, 5275, + * 5280 and 5282. * * (C) Copyright 2000-2003, Greg Ungerer (gerg@snapgear.com) * (C) Copyright 2000-2001, Lineo (www.lineo.com) @@ -13,7 +14,7 @@ #define FEC_H /****************************************************************************/ -#if defined(CONFIG_M527x) || defined(CONFIG_M528x) +#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) /* * Just figures, Motorola would have to change the offsets for * registers in the same peripheral device on different models diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c index 41213ef602d..f52ee3162c5 100644 --- a/drivers/net/hamradio/yam.c +++ b/drivers/net/hamradio/yam.c @@ -170,7 +170,7 @@ static char ax25_bcast[7] = static char ax25_test[7] = {'L' << 1, 'I' << 1, 'N' << 1, 'U' << 1, 'X' << 1, ' ' << 1, '1' << 1}; -static struct timer_list yam_timer = TIMER_INITIALIZER(NULL, 0, 0); +static DEFINE_TIMER(yam_timer, NULL, 0, 0); /* --------------------------------------------------------------------- */ diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c index 7c9dbc8c942..25c9a99c377 100644 --- a/drivers/net/mv643xx_eth.c +++ b/drivers/net/mv643xx_eth.c @@ -94,7 +94,7 @@ static char mv643xx_driver_version[] = "1.0"; static void __iomem *mv643xx_eth_shared_base; /* used to protect MV643XX_ETH_SMI_REG, which is shared across ports */ -static spinlock_t mv643xx_eth_phy_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(mv643xx_eth_phy_lock); static inline u32 mv_read(int offset) { diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c index bb71638a7c4..0df7e92b0bf 100644 --- a/drivers/net/ppp_generic.c +++ b/drivers/net/ppp_generic.c @@ -1232,9 +1232,7 @@ static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb) navail = 0; /* total # of usable channels (not deregistered) */ hdrlen = (ppp->flags & SC_MP_XSHORTSEQ)? MPHDRLEN_SSN: MPHDRLEN; i = 0; - list = &ppp->channels; - while ((list = list->next) != &ppp->channels) { - pch = list_entry(list, struct channel, clist); + list_for_each_entry(pch, &ppp->channels, clist) { navail += pch->avail = (pch->chan != NULL); if (pch->avail) { if (skb_queue_empty(&pch->file.xq) || @@ -1280,6 +1278,7 @@ static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb) /* skip to the channel after the one we last used and start at that one */ + list = &ppp->channels; for (i = 0; i < ppp->nxchan; ++i) { list = list->next; if (list == &ppp->channels) { @@ -1730,7 +1729,7 @@ static void ppp_receive_mp_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch) { u32 mask, seq; - struct list_head *l; + struct channel *ch; int mphdrlen = (ppp->flags & SC_MP_SHORTSEQ)? MPHDRLEN_SSN: MPHDRLEN; if (!pskb_may_pull(skb, mphdrlen) || ppp->mrru == 0) @@ -1784,8 +1783,7 @@ ppp_receive_mp_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch) * The list of channels can't change because we have the receive * side of the ppp unit locked. */ - for (l = ppp->channels.next; l != &ppp->channels; l = l->next) { - struct channel *ch = list_entry(l, struct channel, clist); + list_for_each_entry(ch, &ppp->channels, clist) { if (seq_before(ch->lastseq, seq)) seq = ch->lastseq; } @@ -2271,10 +2269,8 @@ static struct compressor_entry * find_comp_entry(int proto) { struct compressor_entry *ce; - struct list_head *list = &compressor_list; - while ((list = list->next) != &compressor_list) { - ce = list_entry(list, struct compressor_entry, list); + list_for_each_entry(ce, &compressor_list, list) { if (ce->comp->compress_proto == proto) return ce; } @@ -2540,20 +2536,15 @@ static struct channel * ppp_find_channel(int unit) { struct channel *pch; - struct list_head *list; - list = &new_channels; - while ((list = list->next) != &new_channels) { - pch = list_entry(list, struct channel, list); + list_for_each_entry(pch, &new_channels, list) { if (pch->file.index == unit) { list_del(&pch->list); list_add(&pch->list, &all_channels); return pch; } } - list = &all_channels; - while ((list = list->next) != &all_channels) { - pch = list_entry(list, struct channel, list); + list_for_each_entry(pch, &all_channels, list) { if (pch->file.index == unit) return pch; } diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c index 3f67a42e850..de399563a9d 100644 --- a/drivers/net/sungem.c +++ b/drivers/net/sungem.c @@ -2817,7 +2817,7 @@ static int gem_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) #if (!defined(__sparc__) && !defined(CONFIG_PPC_PMAC)) /* Fetch MAC address from vital product data of PCI ROM. */ -static void find_eth_addr_in_vpd(void __iomem *rom_base, int len, unsigned char *dev_addr) +static int find_eth_addr_in_vpd(void __iomem *rom_base, int len, unsigned char *dev_addr) { int this_offset; @@ -2838,35 +2838,27 @@ static void find_eth_addr_in_vpd(void __iomem *rom_base, int len, unsigned char for (i = 0; i < 6; i++) dev_addr[i] = readb(p + i); - break; + return 1; } + return 0; } static void get_gem_mac_nonobp(struct pci_dev *pdev, unsigned char *dev_addr) { - u32 rom_reg_orig; - void __iomem *p; - - if (pdev->resource[PCI_ROM_RESOURCE].parent == NULL) { - if (pci_assign_resource(pdev, PCI_ROM_RESOURCE) < 0) - goto use_random; - } + size_t size; + void __iomem *p = pci_map_rom(pdev, &size); - pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_reg_orig); - pci_write_config_dword(pdev, pdev->rom_base_reg, - rom_reg_orig | PCI_ROM_ADDRESS_ENABLE); + if (p) { + int found; - p = ioremap(pci_resource_start(pdev, PCI_ROM_RESOURCE), (64 * 1024)); - if (p != NULL && readb(p) == 0x55 && readb(p + 1) == 0xaa) - find_eth_addr_in_vpd(p, (64 * 1024), dev_addr); - - if (p != NULL) - iounmap(p); - - pci_write_config_dword(pdev, pdev->rom_base_reg, rom_reg_orig); - return; + found = readb(p) == 0x55 && + readb(p + 1) == 0xaa && + find_eth_addr_in_vpd(p, (64 * 1024), dev_addr); + pci_unmap_rom(pdev, p); + if (found) + return; + } -use_random: /* Sun MAC prefix then 3 random bytes. */ dev_addr[0] = 0x08; dev_addr[1] = 0x00; diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c index f02fe4119b2..9f046cae2f7 100644 --- a/drivers/net/sunhme.c +++ b/drivers/net/sunhme.c @@ -2954,7 +2954,7 @@ static int is_quattro_p(struct pci_dev *pdev) } /* Fetch MAC address from vital product data of PCI ROM. */ -static void find_eth_addr_in_vpd(void __iomem *rom_base, int len, int index, unsigned char *dev_addr) +static int find_eth_addr_in_vpd(void __iomem *rom_base, int len, int index, unsigned char *dev_addr) { int this_offset; @@ -2977,42 +2977,33 @@ static void find_eth_addr_in_vpd(void __iomem *rom_base, int len, int index, uns for (i = 0; i < 6; i++) dev_addr[i] = readb(p + i); - break; + return 1; } index--; } + return 0; } static void get_hme_mac_nonsparc(struct pci_dev *pdev, unsigned char *dev_addr) { - u32 rom_reg_orig; - void __iomem *p; - int index; + size_t size; + void __iomem *p = pci_map_rom(pdev, &size); - index = 0; - if (is_quattro_p(pdev)) - index = PCI_SLOT(pdev->devfn); - - if (pdev->resource[PCI_ROM_RESOURCE].parent == NULL) { - if (pci_assign_resource(pdev, PCI_ROM_RESOURCE) < 0) - goto use_random; - } + if (p) { + int index = 0; + int found; - pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_reg_orig); - pci_write_config_dword(pdev, pdev->rom_base_reg, - rom_reg_orig | PCI_ROM_ADDRESS_ENABLE); + if (is_quattro_p(pdev)) + index = PCI_SLOT(pdev->devfn); - p = ioremap(pci_resource_start(pdev, PCI_ROM_RESOURCE), (64 * 1024)); - if (p != NULL && readb(p) == 0x55 && readb(p + 1) == 0xaa) - find_eth_addr_in_vpd(p, (64 * 1024), index, dev_addr); - - if (p != NULL) - iounmap(p); - - pci_write_config_dword(pdev, pdev->rom_base_reg, rom_reg_orig); - return; + found = readb(p) == 0x55 && + readb(p + 1) == 0xaa && + find_eth_addr_in_vpd(p, (64 * 1024), index, dev_addr); + pci_unmap_rom(pdev, p); + if (found) + return; + } -use_random: /* Sun MAC prefix then 3 random bytes. */ dev_addr[0] = 0x08; dev_addr[1] = 0x00; diff --git a/drivers/net/tulip/de4x5.c b/drivers/net/tulip/de4x5.c index 93800c126e8..ee48bfd6734 100644 --- a/drivers/net/tulip/de4x5.c +++ b/drivers/net/tulip/de4x5.c @@ -2144,9 +2144,9 @@ srom_search(struct net_device *dev, struct pci_dev *pdev) u_long iobase = 0; /* Clear upper 32 bits in Alphas */ int i, j, cfrv; struct de4x5_private *lp = netdev_priv(dev); - struct list_head *walk = &pdev->bus_list; + struct list_head *walk; - for (walk = walk->next; walk != &pdev->bus_list; walk = walk->next) { + list_for_each(walk, &pdev->bus_list) { struct pci_dev *this_dev = pci_dev_b(walk); /* Skip the pci_bus list entry */ diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c index 91df0bf181d..7a57c1b8373 100644 --- a/drivers/parisc/iosapic.c +++ b/drivers/parisc/iosapic.c @@ -215,7 +215,7 @@ static inline void iosapic_write(void __iomem *iosapic, unsigned int reg, u32 va #define IOSAPIC_IRDT_ID_EID_SHIFT 0x10 -static spinlock_t iosapic_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(iosapic_lock); static inline void iosapic_eoi(void __iomem *addr, unsigned int data) { diff --git a/drivers/parisc/lasi.c b/drivers/parisc/lasi.c index 73185505339..cb84a4e84a2 100644 --- a/drivers/parisc/lasi.c +++ b/drivers/parisc/lasi.c @@ -20,7 +20,6 @@ #include <linux/slab.h> #include <linux/module.h> #include <linux/pm.h> -#include <linux/slab.h> #include <linux/types.h> #include <asm/io.h> diff --git a/drivers/parport/ieee1284.c b/drivers/parport/ieee1284.c index 694bae162fe..5b887ba5aaf 100644 --- a/drivers/parport/ieee1284.c +++ b/drivers/parport/ieee1284.c @@ -196,7 +196,7 @@ int parport_wait_peripheral(struct parport *port, return 1; /* 40ms of slow polling. */ - deadline = jiffies + (HZ + 24) / 25; + deadline = jiffies + msecs_to_jiffies(40); while (time_before (jiffies, deadline)) { int ret; @@ -205,7 +205,7 @@ int parport_wait_peripheral(struct parport *port, /* Wait for 10ms (or until an interrupt occurs if * the handler is set) */ - if ((ret = parport_wait_event (port, (HZ + 99) / 100)) < 0) + if ((ret = parport_wait_event (port, msecs_to_jiffies(10))) < 0) return ret; status = parport_read_status (port); @@ -216,8 +216,7 @@ int parport_wait_peripheral(struct parport *port, /* parport_wait_event didn't time out, but the * peripheral wasn't actually ready either. * Wait for another 10ms. */ - __set_current_state (TASK_INTERRUPTIBLE); - schedule_timeout ((HZ+ 99) / 100); + schedule_timeout_interruptible(msecs_to_jiffies(10)); } } diff --git a/drivers/parport/ieee1284_ops.c b/drivers/parport/ieee1284_ops.c index 6624278c6ed..ce1e2aad8b1 100644 --- a/drivers/parport/ieee1284_ops.c +++ b/drivers/parport/ieee1284_ops.c @@ -60,7 +60,7 @@ size_t parport_ieee1284_write_compat (struct parport *port, parport_data_forward (port); while (count < len) { unsigned long expire = jiffies + dev->timeout; - long wait = (HZ + 99) / 100; + long wait = msecs_to_jiffies(10); unsigned char mask = (PARPORT_STATUS_ERROR | PARPORT_STATUS_BUSY); unsigned char val = (PARPORT_STATUS_ERROR @@ -97,8 +97,7 @@ size_t parport_ieee1284_write_compat (struct parport *port, our interrupt handler called. */ if (count && no_irq) { parport_release (dev); - __set_current_state (TASK_INTERRUPTIBLE); - schedule_timeout (wait); + schedule_timeout_interruptible(wait); parport_claim_or_block (dev); } else @@ -542,13 +541,12 @@ size_t parport_ieee1284_ecp_read_data (struct parport *port, /* Yield the port for a while. */ if (count && dev->port->irq != PARPORT_IRQ_NONE) { parport_release (dev); - __set_current_state (TASK_INTERRUPTIBLE); - schedule_timeout ((HZ + 24) / 25); + schedule_timeout_interruptible(msecs_to_jiffies(40)); parport_claim_or_block (dev); } else /* We must have the device claimed here. */ - parport_wait_event (port, (HZ + 24) / 25); + parport_wait_event (port, msecs_to_jiffies(40)); /* Is there a signal pending? */ if (signal_pending (current)) diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c index 1b938bb9be3..c6493ad7c0c 100644 --- a/drivers/parport/parport_pc.c +++ b/drivers/parport/parport_pc.c @@ -173,8 +173,7 @@ static int change_mode(struct parport *p, int m) if (time_after_eq (jiffies, expire)) /* The FIFO is stuck. */ return -EBUSY; - __set_current_state (TASK_INTERRUPTIBLE); - schedule_timeout ((HZ + 99) / 100); + schedule_timeout_interruptible(msecs_to_jiffies(10)); if (signal_pending (current)) break; } diff --git a/drivers/pci/hotplug.c b/drivers/pci/hotplug.c index b844bc97232..10444988a10 100644 --- a/drivers/pci/hotplug.c +++ b/drivers/pci/hotplug.c @@ -20,46 +20,35 @@ int pci_hotplug (struct device *dev, char **envp, int num_envp, scratch = buffer; - /* stuff we want to pass to /sbin/hotplug */ - envp[i++] = scratch; - length += scnprintf (scratch, buffer_size - length, "PCI_CLASS=%04X", - pdev->class); - if ((buffer_size - length <= 0) || (i >= num_envp)) + + if (add_hotplug_env_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "PCI_CLASS=%04X", pdev->class)) return -ENOMEM; - ++length; - scratch += length; - envp[i++] = scratch; - length += scnprintf (scratch, buffer_size - length, "PCI_ID=%04X:%04X", - pdev->vendor, pdev->device); - if ((buffer_size - length <= 0) || (i >= num_envp)) + if (add_hotplug_env_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "PCI_ID=%04X:%04X", pdev->vendor, pdev->device)) return -ENOMEM; - ++length; - scratch += length; - envp[i++] = scratch; - length += scnprintf (scratch, buffer_size - length, - "PCI_SUBSYS_ID=%04X:%04X", pdev->subsystem_vendor, - pdev->subsystem_device); - if ((buffer_size - length <= 0) || (i >= num_envp)) + if (add_hotplug_env_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "PCI_SUBSYS_ID=%04X:%04X", pdev->subsystem_vendor, + pdev->subsystem_device)) return -ENOMEM; - ++length; - scratch += length; - envp[i++] = scratch; - length += scnprintf (scratch, buffer_size - length, "PCI_SLOT_NAME=%s", - pci_name(pdev)); - if ((buffer_size - length <= 0) || (i >= num_envp)) + if (add_hotplug_env_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "PCI_SLOT_NAME=%s", pci_name(pdev))) return -ENOMEM; - envp[i++] = scratch; - length += scnprintf (scratch, buffer_size - length, - "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x", - pdev->vendor, pdev->device, - pdev->subsystem_vendor, pdev->subsystem_device, - (u8)(pdev->class >> 16), (u8)(pdev->class >> 8), - (u8)(pdev->class)); - if ((buffer_size - length <= 0) || (i >= num_envp)) + if (add_hotplug_env_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x", + pdev->vendor, pdev->device, + pdev->subsystem_vendor, pdev->subsystem_device, + (u8)(pdev->class >> 16), (u8)(pdev->class >> 8), + (u8)(pdev->class))) return -ENOMEM; envp[i] = NULL; diff --git a/drivers/pci/hotplug/pciehprm_acpi.c b/drivers/pci/hotplug/pciehprm_acpi.c index 305b47ec2f2..1406db35b08 100644 --- a/drivers/pci/hotplug/pciehprm_acpi.c +++ b/drivers/pci/hotplug/pciehprm_acpi.c @@ -1696,15 +1696,15 @@ void pciehprm_enable_card( pci_bus->number = func->bus; devfn = PCI_DEVFN(func->device, func->function); - rc = pci_bus_read_config_word(pci_bus, devfn, PCI_COMMAND, &command); + rc = pci_bus_read_config_word(pci_bus, devfn, PCI_COMMAND, &cmd); if (card_type == PCI_HEADER_TYPE_BRIDGE) { - rc = pci_bus_read_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, &bcommand); + rc = pci_bus_read_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, &bcmd); } - cmd = command = command | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE + command = cmd | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE | PCI_COMMAND_IO | PCI_COMMAND_MEMORY; - bcmd = bcommand = bcommand | PCI_BRIDGE_CTL_NO_ISA; + bcommand = bcmd | PCI_BRIDGE_CTL_NO_ISA; ab = find_acpi_bridge_by_bus(acpi_bridges_head, ctrl->seg, ctrl->bus); if (ab) { diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index cc9d65388e6..56a3b397efe 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -44,10 +44,14 @@ pci_config_attr(subsystem_device, "0x%04x\n"); pci_config_attr(class, "0x%06x\n"); pci_config_attr(irq, "%u\n"); -static ssize_t local_cpus_show(struct device *dev, struct device_attribute *attr, char *buf) +static ssize_t local_cpus_show(struct device *dev, + struct device_attribute *attr, char *buf) { - cpumask_t mask = pcibus_to_cpumask(to_pci_dev(dev)->bus); - int len = cpumask_scnprintf(buf, PAGE_SIZE-2, mask); + cpumask_t mask; + int len; + + mask = pcibus_to_cpumask(to_pci_dev(dev)->bus); + len = cpumask_scnprintf(buf, PAGE_SIZE-2, mask); strcat(buf,"\n"); return 1+len; } diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index d00168b1f66..d3f3dd42240 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -29,7 +29,6 @@ static inline int pci_proc_detach_bus(struct pci_bus *bus) { return 0; } #endif /* Functions for PCI Hotplug drivers to use */ -extern struct pci_bus * pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, int busnr); extern unsigned int pci_do_scan_bus(struct pci_bus *bus); extern int pci_remove_device_safe(struct pci_dev *dev); extern unsigned char pci_max_busnr(void); diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index b9c9b03919d..26a55d08b50 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -72,11 +72,13 @@ void pci_remove_legacy_files(struct pci_bus *bus) { return; } /* * PCI Bus Class Devices */ -static ssize_t pci_bus_show_cpuaffinity(struct class_device *class_dev, char *buf) +static ssize_t pci_bus_show_cpuaffinity(struct class_device *class_dev, + char *buf) { - cpumask_t cpumask = pcibus_to_cpumask(to_pci_bus(class_dev)); int ret; + cpumask_t cpumask; + cpumask = pcibus_to_cpumask(to_pci_bus(class_dev)); ret = cpumask_scnprintf(buf, PAGE_SIZE, cpumask); if (ret < PAGE_SIZE) buf[ret++] = '\n'; @@ -753,27 +755,19 @@ pci_scan_device(struct pci_bus *bus, int devfn) kfree(dev); return NULL; } - device_initialize(&dev->dev); - dev->dev.release = pci_release_dev; - pci_dev_get(dev); - - dev->dev.dma_mask = &dev->dma_mask; - dev->dev.coherent_dma_mask = 0xffffffffull; return dev; } -struct pci_dev * __devinit -pci_scan_single_device(struct pci_bus *bus, int devfn) +void __devinit pci_device_add(struct pci_dev *dev, struct pci_bus *bus) { - struct pci_dev *dev; + device_initialize(&dev->dev); + dev->dev.release = pci_release_dev; + pci_dev_get(dev); - dev = pci_scan_device(bus, devfn); - pci_scan_msi_device(dev); + dev->dev.dma_mask = &dev->dma_mask; + dev->dev.coherent_dma_mask = 0xffffffffull; - if (!dev) - return NULL; - /* Fix up broken headers */ pci_fixup_device(pci_fixup_header, dev); @@ -785,6 +779,19 @@ pci_scan_single_device(struct pci_bus *bus, int devfn) spin_lock(&pci_bus_lock); list_add_tail(&dev->bus_list, &bus->devices); spin_unlock(&pci_bus_lock); +} + +struct pci_dev * __devinit +pci_scan_single_device(struct pci_bus *bus, int devfn) +{ + struct pci_dev *dev; + + dev = pci_scan_device(bus, devfn); + if (!dev) + return NULL; + + pci_device_add(dev, bus); + pci_scan_msi_device(dev); return dev; } @@ -881,7 +888,8 @@ unsigned int __devinit pci_do_scan_bus(struct pci_bus *bus) return max; } -struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent, int bus, struct pci_ops *ops, void *sysdata) +struct pci_bus * __devinit pci_create_bus(struct device *parent, + int bus, struct pci_ops *ops, void *sysdata) { int error; struct pci_bus *b; @@ -938,8 +946,6 @@ struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent, int bus, b->resource[0] = &ioport_resource; b->resource[1] = &iomem_resource; - b->subordinate = pci_scan_child_bus(b); - return b; sys_create_link_err: @@ -957,6 +963,18 @@ err_out: kfree(b); return NULL; } +EXPORT_SYMBOL_GPL(pci_create_bus); + +struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent, + int bus, struct pci_ops *ops, void *sysdata) +{ + struct pci_bus *b; + + b = pci_create_bus(parent, bus, ops, sysdata); + if (b) + b->subordinate = pci_scan_child_bus(b); + return b; +} EXPORT_SYMBOL(pci_scan_bus_parented); #ifdef CONFIG_HOTPLUG diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 4f0c1bd3674..11ca44387cb 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -876,6 +876,12 @@ static void __init asus_hides_smbus_hostbridge(struct pci_dev *dev) case 0xC00C: /* Samsung P35 notebook */ asus_hides_smbus = 1; } + } else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_COMPAQ)) { + if (dev->device == PCI_DEVICE_ID_INTEL_82855PM_HB) + switch(dev->subsystem_device) { + case 0x0058: /* Compaq Evo N620c */ + asus_hides_smbus = 1; + } } } DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82845_HB, asus_hides_smbus_hostbridge ); diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 6b0e6464eb3..657be948baf 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -77,8 +77,7 @@ pbus_assign_resources_sorted(struct pci_bus *bus) } } -static void __devinit -pci_setup_cardbus(struct pci_bus *bus) +void pci_setup_cardbus(struct pci_bus *bus) { struct pci_dev *bridge = bus->self; struct pci_bus_region region; @@ -130,6 +129,7 @@ pci_setup_cardbus(struct pci_bus *bus) region.end); } } +EXPORT_SYMBOL(pci_setup_cardbus); /* Initialize bridges with base/limit values we have collected. PCI-to-PCI Bridge Architecture Specification rev. 1.1 (1998) diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index 6485f75d2fb..ddc741e6ecb 100644 --- a/drivers/pcmcia/Kconfig +++ b/drivers/pcmcia/Kconfig @@ -221,6 +221,13 @@ config PCMCIA_VRC4173 tristate "NEC VRC4173 CARDU support" depends on CPU_VR41XX && PCI && PCMCIA +config OMAP_CF + tristate "OMAP CompactFlash Controller" + depends on PCMCIA && ARCH_OMAP16XX + help + Say Y here to support the CompactFlash controller on OMAP. + Note that this doesn't support "True IDE" mode. + config PCCARD_NONSTATIC tristate diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile index ef694c74dfb..a41fbb38fdc 100644 --- a/drivers/pcmcia/Makefile +++ b/drivers/pcmcia/Makefile @@ -34,6 +34,7 @@ obj-$(CONFIG_M32R_CFC) += m32r_cfc.o obj-$(CONFIG_PCMCIA_AU1X00) += au1x00_ss.o obj-$(CONFIG_PCMCIA_VRC4171) += vrc4171_card.o obj-$(CONFIG_PCMCIA_VRC4173) += vrc4173_cardu.o +obj-$(CONFIG_OMAP_CF) += omap_cf.o sa11xx_core-y += soc_common.o sa11xx_base.o pxa2xx_core-y += soc_common.o pxa2xx_base.o diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index e39178fc59d..fabd3529ceb 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -654,9 +654,10 @@ static int pccardd(void *__skt) skt->thread = NULL; complete_and_exit(&skt->thread_done, 0); } - complete(&skt->thread_done); add_wait_queue(&skt->thread_wait, &wait); + complete(&skt->thread_done); + for (;;) { unsigned long flags; unsigned int events; @@ -682,11 +683,11 @@ static int pccardd(void *__skt) continue; } - schedule(); - try_to_freeze(); - if (!skt->thread) break; + + schedule(); + try_to_freeze(); } remove_wait_queue(&skt->thread_wait, &wait); diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h index 6bbfbd0e02a..55867bc7f19 100644 --- a/drivers/pcmcia/cs_internal.h +++ b/drivers/pcmcia/cs_internal.h @@ -17,9 +17,6 @@ #include <linux/config.h> -#define CLIENT_MAGIC 0x51E6 -typedef struct client_t client_t; - /* Flags in client state */ #define CLIENT_CONFIG_LOCKED 0x0001 #define CLIENT_IRQ_REQ 0x0002 @@ -45,7 +42,6 @@ typedef struct region_t { typedef struct config_t { u_int state; u_int Attributes; - u_int Vcc, Vpp1, Vpp2; u_int IntType; u_int ConfigBase; u_char Status, Pin, Copy, Option, ExtStatus; diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 43da2e92d50..080608c7381 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -354,6 +354,7 @@ static void pcmcia_release_dev(struct device *dev) struct pcmcia_device *p_dev = to_pcmcia_dev(dev); ds_dbg(1, "releasing dev %p\n", p_dev); pcmcia_put_socket(p_dev->socket); + kfree(p_dev->devname); kfree(p_dev); } @@ -424,9 +425,13 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev) { cistpl_manfid_t manf_id; cistpl_funcid_t func_id; - cistpl_vers_1_t vers1; + cistpl_vers_1_t *vers1; unsigned int i; + vers1 = kmalloc(sizeof(*vers1), GFP_KERNEL); + if (!vers1) + return -ENOMEM; + if (!pccard_read_tuple(p_dev->socket, p_dev->func, CISTPL_MANFID, &manf_id)) { p_dev->manf_id = manf_id.manf; @@ -443,23 +448,30 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev) /* rule of thumb: cards with no FUNCID, but with * common memory device geometry information, are * probably memory cards (from pcmcia-cs) */ - cistpl_device_geo_t devgeo; + cistpl_device_geo_t *devgeo; + + devgeo = kmalloc(sizeof(*devgeo), GFP_KERNEL); + if (!devgeo) { + kfree(vers1); + return -ENOMEM; + } if (!pccard_read_tuple(p_dev->socket, p_dev->func, - CISTPL_DEVICE_GEO, &devgeo)) { + CISTPL_DEVICE_GEO, devgeo)) { ds_dbg(0, "mem device geometry probably means " "FUNCID_MEMORY\n"); p_dev->func_id = CISTPL_FUNCID_MEMORY; p_dev->has_func_id = 1; } + kfree(devgeo); } if (!pccard_read_tuple(p_dev->socket, p_dev->func, CISTPL_VERS_1, - &vers1)) { - for (i=0; i < vers1.ns; i++) { + vers1)) { + for (i=0; i < vers1->ns; i++) { char *tmp; unsigned int length; - tmp = vers1.str + vers1.ofs[i]; + tmp = vers1->str + vers1->ofs[i]; length = strlen(tmp) + 1; if ((length < 3) || (length > 255)) @@ -475,6 +487,7 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev) } } + kfree(vers1); return 0; } @@ -492,6 +505,7 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f { struct pcmcia_device *p_dev; unsigned long flags; + int bus_id_len; s = pcmcia_get_socket(s); if (!s) @@ -515,7 +529,12 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f p_dev->dev.bus = &pcmcia_bus_type; p_dev->dev.parent = s->dev.dev; p_dev->dev.release = pcmcia_release_dev; - sprintf (p_dev->dev.bus_id, "%d.%d", p_dev->socket->sock, p_dev->device_no); + bus_id_len = sprintf (p_dev->dev.bus_id, "%d.%d", p_dev->socket->sock, p_dev->device_no); + + p_dev->devname = kmalloc(6 + bus_id_len + 1, GFP_KERNEL); + if (!p_dev->devname) + goto err_free; + sprintf (p_dev->devname, "pcmcia%s", p_dev->dev.bus_id); /* compat */ p_dev->state = CLIENT_UNBOUND; @@ -540,6 +559,7 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f return p_dev; err_free: + kfree(p_dev->devname); kfree(p_dev); s->device_count--; err_put: diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c new file mode 100644 index 00000000000..08d1c928826 --- /dev/null +++ b/drivers/pcmcia/omap_cf.c @@ -0,0 +1,373 @@ +/* + * omap_cf.c -- OMAP 16xx CompactFlash controller driver + * + * Copyright (c) 2005 David Brownell + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/sched.h> +#include <linux/device.h> +#include <linux/errno.h> +#include <linux/init.h> +#include <linux/delay.h> +#include <linux/interrupt.h> + +#include <pcmcia/ss.h> + +#include <asm/hardware.h> +#include <asm/io.h> +#include <asm/mach-types.h> +#include <asm/sizes.h> + +#include <asm/arch/mux.h> +#include <asm/arch/tc.h> + + +/* NOTE: don't expect this to support many I/O cards. The 16xx chips have + * hard-wired timings to support Compact Flash memory cards; they won't work + * with various other devices (like WLAN adapters) without some external + * logic to help out. + * + * NOTE: CF controller docs disagree with address space docs as to where + * CF_BASE really lives; this is a doc erratum. + */ +#define CF_BASE 0xfffe2800 + +/* status; read after IRQ */ +#define CF_STATUS_REG __REG16(CF_BASE + 0x00) +# define CF_STATUS_BAD_READ (1 << 2) +# define CF_STATUS_BAD_WRITE (1 << 1) +# define CF_STATUS_CARD_DETECT (1 << 0) + +/* which chipselect (CS0..CS3) is used for CF (active low) */ +#define CF_CFG_REG __REG16(CF_BASE + 0x02) + +/* card reset */ +#define CF_CONTROL_REG __REG16(CF_BASE + 0x04) +# define CF_CONTROL_RESET (1 << 0) + +#define omap_cf_present() (!(CF_STATUS_REG & CF_STATUS_CARD_DETECT)) + +/*--------------------------------------------------------------------------*/ + +static const char driver_name[] = "omap_cf"; + +struct omap_cf_socket { + struct pcmcia_socket socket; + + struct timer_list timer; + unsigned present:1; + unsigned active:1; + + struct platform_device *pdev; + unsigned long phys_cf; + u_int irq; +}; + +#define POLL_INTERVAL (2 * HZ) + +#define SZ_2K (2 * SZ_1K) + +/*--------------------------------------------------------------------------*/ + +static int omap_cf_ss_init(struct pcmcia_socket *s) +{ + return 0; +} + +/* the timer is primarily to kick this socket's pccardd */ +static void omap_cf_timer(unsigned long _cf) +{ + struct omap_cf_socket *cf = (void *) _cf; + unsigned present = omap_cf_present(); + + if (present != cf->present) { + cf->present = present; + pr_debug("%s: card %s\n", driver_name, + present ? "present" : "gone"); + pcmcia_parse_events(&cf->socket, SS_DETECT); + } + + if (cf->active) + mod_timer(&cf->timer, jiffies + POLL_INTERVAL); +} + +/* This irq handler prevents "irqNNN: nobody cared" messages as drivers + * claim the card's IRQ. It may also detect some card insertions, but + * not removals; it can't always eliminate timer irqs. + */ +static irqreturn_t omap_cf_irq(int irq, void *_cf, struct pt_regs *r) +{ + omap_cf_timer((unsigned long)_cf); + return IRQ_HANDLED; +} + +static int omap_cf_get_status(struct pcmcia_socket *s, u_int *sp) +{ + if (!sp) + return -EINVAL; + + /* FIXME power management should probably be board-specific: + * - 3VCARD vs XVCARD (OSK only handles 3VCARD) + * - POWERON (switched on/off by set_socket) + */ + if (omap_cf_present()) { + struct omap_cf_socket *cf; + + *sp = SS_READY | SS_DETECT | SS_POWERON | SS_3VCARD; + cf = container_of(s, struct omap_cf_socket, socket); + s->irq.AssignedIRQ = cf->irq; + } else + *sp = 0; + return 0; +} + +static int +omap_cf_set_socket(struct pcmcia_socket *sock, struct socket_state_t *s) +{ + u16 control; + + /* FIXME some non-OSK boards will support power switching */ + switch (s->Vcc) { + case 0: + case 33: + break; + default: + return -EINVAL; + } + + control = CF_CONTROL_REG; + if (s->flags & SS_RESET) + CF_CONTROL_REG = CF_CONTROL_RESET; + else + CF_CONTROL_REG = 0; + + pr_debug("%s: Vcc %d, io_irq %d, flags %04x csc %04x\n", + driver_name, s->Vcc, s->io_irq, s->flags, s->csc_mask); + + return 0; +} + +static int omap_cf_ss_suspend(struct pcmcia_socket *s) +{ + pr_debug("%s: %s\n", driver_name, __FUNCTION__); + return omap_cf_set_socket(s, &dead_socket); +} + +/* regions are 2K each: mem, attrib, io (and reserved-for-ide) */ + +static int +omap_cf_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io) +{ + struct omap_cf_socket *cf; + + cf = container_of(s, struct omap_cf_socket, socket); + io->flags &= MAP_ACTIVE|MAP_ATTRIB|MAP_16BIT; + io->start = cf->phys_cf + SZ_4K; + io->stop = io->start + SZ_2K - 1; + return 0; +} + +static int +omap_cf_set_mem_map(struct pcmcia_socket *s, struct pccard_mem_map *map) +{ + struct omap_cf_socket *cf; + + if (map->card_start) + return -EINVAL; + cf = container_of(s, struct omap_cf_socket, socket); + map->static_start = cf->phys_cf; + map->flags &= MAP_ACTIVE|MAP_ATTRIB|MAP_16BIT; + if (map->flags & MAP_ATTRIB) + map->static_start += SZ_2K; + return 0; +} + +static struct pccard_operations omap_cf_ops = { + .init = omap_cf_ss_init, + .suspend = omap_cf_ss_suspend, + .get_status = omap_cf_get_status, + .set_socket = omap_cf_set_socket, + .set_io_map = omap_cf_set_io_map, + .set_mem_map = omap_cf_set_mem_map, +}; + +/*--------------------------------------------------------------------------*/ + +/* + * NOTE: right now the only board-specific platform_data is + * "what chipselect is used". Boards could want more. + */ + +static int __init omap_cf_probe(struct device *dev) +{ + unsigned seg; + struct omap_cf_socket *cf; + struct platform_device *pdev = to_platform_device(dev); + int irq; + int status; + + seg = (int) dev->platform_data; + if (seg == 0 || seg > 3) + return -ENODEV; + + /* either CFLASH.IREQ (INT_1610_CF) or some GPIO */ + irq = platform_get_irq(pdev, 0); + if (!irq) + return -EINVAL; + + cf = kcalloc(1, sizeof *cf, GFP_KERNEL); + if (!cf) + return -ENOMEM; + init_timer(&cf->timer); + cf->timer.function = omap_cf_timer; + cf->timer.data = (unsigned long) cf; + + cf->pdev = pdev; + dev_set_drvdata(dev, cf); + + /* this primarily just shuts up irq handling noise */ + status = request_irq(irq, omap_cf_irq, SA_SHIRQ, + driver_name, cf); + if (status < 0) + goto fail0; + cf->irq = irq; + cf->socket.pci_irq = irq; + + switch (seg) { + /* NOTE: CS0 could be configured too ... */ + case 1: + cf->phys_cf = OMAP_CS1_PHYS; + break; + case 2: + cf->phys_cf = OMAP_CS2_PHYS; + break; + case 3: + cf->phys_cf = omap_cs3_phys(); + break; + default: + goto fail1; + } + + /* pcmcia layer only remaps "real" memory */ + cf->socket.io_offset = (unsigned long) + ioremap(cf->phys_cf + SZ_4K, SZ_2K); + if (!cf->socket.io_offset) + goto fail1; + + if (!request_mem_region(cf->phys_cf, SZ_8K, driver_name)) + goto fail1; + + /* NOTE: CF conflicts with MMC1 */ + omap_cfg_reg(W11_1610_CF_CD1); + omap_cfg_reg(P11_1610_CF_CD2); + omap_cfg_reg(R11_1610_CF_IOIS16); + omap_cfg_reg(V10_1610_CF_IREQ); + omap_cfg_reg(W10_1610_CF_RESET); + + CF_CFG_REG = ~(1 << seg); + + pr_info("%s: cs%d on irq %d\n", driver_name, seg, irq); + + /* NOTE: better EMIFS setup might support more cards; but the + * TRM only shows how to affect regular flash signals, not their + * CF/PCMCIA variants... + */ + pr_debug("%s: cs%d, previous ccs %08x acs %08x\n", driver_name, + seg, EMIFS_CCS(seg), EMIFS_ACS(seg)); + EMIFS_CCS(seg) = 0x0004a1b3; /* synch mode 4 etc */ + EMIFS_ACS(seg) = 0x00000000; /* OE hold/setup */ + + /* CF uses armxor_ck, which is "always" available */ + + pr_debug("%s: sts %04x cfg %04x control %04x %s\n", driver_name, + CF_STATUS_REG, CF_CFG_REG, CF_CONTROL_REG, + omap_cf_present() ? "present" : "(not present)"); + + cf->socket.owner = THIS_MODULE; + cf->socket.dev.dev = dev; + cf->socket.ops = &omap_cf_ops; + cf->socket.resource_ops = &pccard_static_ops; + cf->socket.features = SS_CAP_PCCARD | SS_CAP_STATIC_MAP + | SS_CAP_MEM_ALIGN; + cf->socket.map_size = SZ_2K; + + status = pcmcia_register_socket(&cf->socket); + if (status < 0) + goto fail2; + + cf->active = 1; + mod_timer(&cf->timer, jiffies + POLL_INTERVAL); + return 0; + +fail2: + iounmap((void __iomem *) cf->socket.io_offset); + release_mem_region(cf->phys_cf, SZ_8K); +fail1: + free_irq(irq, cf); +fail0: + kfree(cf); + return status; +} + +static int __devexit omap_cf_remove(struct device *dev) +{ + struct omap_cf_socket *cf = dev_get_drvdata(dev); + + cf->active = 0; + pcmcia_unregister_socket(&cf->socket); + del_timer_sync(&cf->timer); + iounmap((void __iomem *) cf->socket.io_offset); + release_mem_region(cf->phys_cf, SZ_8K); + free_irq(cf->irq, cf); + kfree(cf); + return 0; +} + +static int omap_cf_suspend(struct device *dev, pm_message_t mesg, u32 level) +{ + if (level != SUSPEND_SAVE_STATE) + return 0; + return pcmcia_socket_dev_suspend(dev, mesg); +} + +static int omap_cf_resume(struct device *dev, u32 level) +{ + if (level != RESUME_RESTORE_STATE) + return 0; + return pcmcia_socket_dev_resume(dev); +} + +static struct device_driver omap_cf_driver = { + .name = (char *) driver_name, + .bus = &platform_bus_type, + .probe = omap_cf_probe, + .remove = __devexit_p(omap_cf_remove), + .suspend = omap_cf_suspend, + .resume = omap_cf_resume, +}; + +static int __init omap_cf_init(void) +{ + if (cpu_is_omap16xx()) + driver_register(&omap_cf_driver); + return 0; +} + +static void __exit omap_cf_exit(void) +{ + if (cpu_is_omap16xx()) + driver_unregister(&omap_cf_driver); +} + +module_init(omap_cf_init); +module_exit(omap_cf_exit); + +MODULE_DESCRIPTION("OMAP CF Driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 599b116d974..89022ad5b52 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -447,7 +447,7 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev, (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { if (mod->Vpp1 != mod->Vpp2) return CS_BAD_VPP; - c->Vpp1 = c->Vpp2 = s->socket.Vpp = mod->Vpp1; + s->socket.Vpp = mod->Vpp1; if (s->ops->set_socket(s, &s->socket)) return CS_BAD_VPP; } else if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) || @@ -623,8 +623,6 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev, if (s->ops->set_socket(s, &s->socket)) return CS_BAD_VPP; - c->Vcc = req->Vcc; c->Vpp1 = c->Vpp2 = req->Vpp1; - /* Pick memory or I/O card, DMA mode, interrupt */ c->IntType = req->IntType; c->Attributes = req->Attributes; @@ -822,7 +820,7 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req) ((req->Attributes & IRQ_TYPE_DYNAMIC_SHARING) || (s->functions > 1) || (irq == s->pci_irq)) ? SA_SHIRQ : 0, - p_dev->dev.bus_id, + p_dev->devname, (req->Attributes & IRQ_HANDLE_PRESENT) ? req->Instance : data); if (!ret) { if (!(req->Attributes & IRQ_HANDLE_PRESENT)) @@ -832,7 +830,8 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req) } } #endif - if (ret) { + /* only assign PCI irq if no IRQ already assigned */ + if (ret && !s->irq.AssignedIRQ) { if (!s->pci_irq) return ret; irq = s->pci_irq; @@ -843,7 +842,7 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req) ((req->Attributes & IRQ_TYPE_DYNAMIC_SHARING) || (s->functions > 1) || (irq == s->pci_irq)) ? SA_SHIRQ : 0, - p_dev->dev.bus_id, req->Instance)) + p_dev->devname, req->Instance)) return CS_IN_USE; } diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c index 0347a29f297..f0997c36c9b 100644 --- a/drivers/pcmcia/yenta_socket.c +++ b/drivers/pcmcia/yenta_socket.c @@ -72,6 +72,7 @@ static inline void cb_writel(struct yenta_socket *socket, unsigned reg, u32 val) { debug("%p %04x %08x\n", socket, reg, val); writel(val, socket->base + reg); + readl(socket->base + reg); /* avoid problems with PCI write posting */ } static inline u8 config_readb(struct yenta_socket *socket, unsigned offset) @@ -136,6 +137,7 @@ static inline void exca_writeb(struct yenta_socket *socket, unsigned reg, u8 val { debug("%p %04x %02x\n", socket, reg, val); writeb(val, socket->base + 0x800 + reg); + readb(socket->base + 0x800 + reg); /* PCI write posting... */ } static void exca_writew(struct yenta_socket *socket, unsigned reg, u16 val) @@ -143,6 +145,10 @@ static void exca_writew(struct yenta_socket *socket, unsigned reg, u16 val) debug("%p %04x %04x\n", socket, reg, val); writeb(val, socket->base + 0x800 + reg); writeb(val >> 8, socket->base + 0x800 + reg + 1); + + /* PCI write posting... */ + readb(socket->base + 0x800 + reg); + readb(socket->base + 0x800 + reg + 1); } /* @@ -667,7 +673,7 @@ static int yenta_search_res(struct yenta_socket *socket, struct resource *res, return 0; } -static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type, int addr_start, int addr_end) +static int yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type, int addr_start, int addr_end) { struct resource *root, *res; struct pci_bus_region region; @@ -676,7 +682,7 @@ static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned typ res = socket->dev->resource + PCI_BRIDGE_RESOURCES + nr; /* Already allocated? */ if (res->parent) - return; + return 0; /* The granularity of the memory limit is 4kB, on IO it's 4 bytes */ mask = ~0xfff; @@ -692,7 +698,7 @@ static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned typ pcibios_bus_to_resource(socket->dev, res, ®ion); root = pci_find_parent_resource(socket->dev, res); if (root && (request_resource(root, res) == 0)) - return; + return 0; printk(KERN_INFO "yenta %s: Preassigned resource %d busy or not available, reconfiguring...\n", pci_name(socket->dev), nr); } @@ -700,35 +706,27 @@ static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned typ if (type & IORESOURCE_IO) { if ((yenta_search_res(socket, res, BRIDGE_IO_MAX)) || (yenta_search_res(socket, res, BRIDGE_IO_ACC)) || - (yenta_search_res(socket, res, BRIDGE_IO_MIN))) { - config_writel(socket, addr_start, res->start); - config_writel(socket, addr_end, res->end); - return; - } + (yenta_search_res(socket, res, BRIDGE_IO_MIN))) + return 1; } else { if (type & IORESOURCE_PREFETCH) { if ((yenta_search_res(socket, res, BRIDGE_MEM_MAX)) || (yenta_search_res(socket, res, BRIDGE_MEM_ACC)) || - (yenta_search_res(socket, res, BRIDGE_MEM_MIN))) { - config_writel(socket, addr_start, res->start); - config_writel(socket, addr_end, res->end); - return; - } + (yenta_search_res(socket, res, BRIDGE_MEM_MIN))) + return 1; /* Approximating prefetchable by non-prefetchable */ res->flags = IORESOURCE_MEM; } if ((yenta_search_res(socket, res, BRIDGE_MEM_MAX)) || (yenta_search_res(socket, res, BRIDGE_MEM_ACC)) || - (yenta_search_res(socket, res, BRIDGE_MEM_MIN))) { - config_writel(socket, addr_start, res->start); - config_writel(socket, addr_end, res->end); - return; - } + (yenta_search_res(socket, res, BRIDGE_MEM_MIN))) + return 1; } printk(KERN_INFO "yenta %s: no resource of type %x available, trying to continue...\n", pci_name(socket->dev), type); res->start = res->end = res->flags = 0; + return 0; } /* @@ -736,14 +734,17 @@ static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned typ */ static void yenta_allocate_resources(struct yenta_socket *socket) { - yenta_allocate_res(socket, 0, IORESOURCE_IO, + int program = 0; + program += yenta_allocate_res(socket, 0, IORESOURCE_IO, PCI_CB_IO_BASE_0, PCI_CB_IO_LIMIT_0); - yenta_allocate_res(socket, 1, IORESOURCE_IO, + program += yenta_allocate_res(socket, 1, IORESOURCE_IO, PCI_CB_IO_BASE_1, PCI_CB_IO_LIMIT_1); - yenta_allocate_res(socket, 2, IORESOURCE_MEM|IORESOURCE_PREFETCH, + program += yenta_allocate_res(socket, 2, IORESOURCE_MEM|IORESOURCE_PREFETCH, PCI_CB_MEMORY_BASE_0, PCI_CB_MEMORY_LIMIT_0); - yenta_allocate_res(socket, 3, IORESOURCE_MEM, + program += yenta_allocate_res(socket, 3, IORESOURCE_MEM, PCI_CB_MEMORY_BASE_1, PCI_CB_MEMORY_LIMIT_1); + if (program) + pci_setup_cardbus(socket->dev->subordinate); } @@ -758,7 +759,7 @@ static void yenta_free_resources(struct yenta_socket *socket) res = socket->dev->resource + PCI_BRIDGE_RESOURCES + i; if (res->start != 0 && res->end != 0) release_resource(res); - res->start = res->end = 0; + res->start = res->end = res->flags = 0; } } diff --git a/drivers/sbus/char/aurora.c b/drivers/sbus/char/aurora.c index d96cc47de56..672f9f2b216 100644 --- a/drivers/sbus/char/aurora.c +++ b/drivers/sbus/char/aurora.c @@ -871,8 +871,7 @@ static irqreturn_t aurora_interrupt(int irq, void * dev_id, struct pt_regs * reg #ifdef AURORA_INT_DEBUG static void aurora_timer (unsigned long ignored); -static struct timer_list aurora_poll_timer = - TIMER_INITIALIZER(aurora_timer, 0, 0); +static DEFINE_TIMER(aurora_poll_timer, aurora_timer, 0, 0); static void aurora_timer (unsigned long ignored) diff --git a/drivers/sbus/char/bbc_envctrl.c b/drivers/sbus/char/bbc_envctrl.c index d44205d52bf..d89f83f769f 100644 --- a/drivers/sbus/char/bbc_envctrl.c +++ b/drivers/sbus/char/bbc_envctrl.c @@ -5,6 +5,7 @@ */ #define __KERNEL_SYSCALLS__ +static int errno; #include <linux/kernel.h> #include <linux/kthread.h> @@ -13,8 +14,6 @@ #include <linux/delay.h> #include <asm/oplib.h> #include <asm/ebus.h> -static int errno; -#include <asm/unistd.h> #include "bbc_i2c.h" #include "max1617.h" diff --git a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c index d765cc1bf06..b0cc3c2588f 100644 --- a/drivers/sbus/char/envctrl.c +++ b/drivers/sbus/char/envctrl.c @@ -20,6 +20,7 @@ */ #define __KERNEL_SYSCALLS__ +static int errno; #include <linux/config.h> #include <linux/module.h> @@ -38,9 +39,6 @@ #include <asm/uaccess.h> #include <asm/envctrl.h> -static int errno; -#include <asm/unistd.h> - #define ENVCTRL_MINOR 162 #define PCF8584_ADDRESS 0x55 diff --git a/drivers/scsi/53c7xx.c b/drivers/scsi/53c7xx.c index 2341d27ceed..7a33c708f5b 100644 --- a/drivers/scsi/53c7xx.c +++ b/drivers/scsi/53c7xx.c @@ -6090,8 +6090,8 @@ NCR53c7x0_release(struct Scsi_Host *host) { if (hostdata->num_cmds) printk ("scsi%d : leaked %d NCR53c7x0_cmd structures\n", host->host_no, hostdata->num_cmds); - if (hostdata->events) - vfree ((void *)hostdata->events); + + vfree(hostdata->events); /* XXX This assumes default cache mode to be IOMAP_FULL_CACHING, which * XXX may be invalid (CONFIG_060_WRITETHROUGH) diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index bd0e1b6be1e..da6e51c7fe6 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c @@ -116,7 +116,7 @@ typedef struct { } scsi_changer; static LIST_HEAD(ch_devlist); -static spinlock_t ch_devlist_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(ch_devlist_lock); static int ch_devcount; static struct scsi_driver ch_template = @@ -560,7 +560,7 @@ ch_set_voltag(scsi_changer *ch, u_int elem, return result; } -static int ch_gstatus(scsi_changer *ch, int type, unsigned char *dest) +static int ch_gstatus(scsi_changer *ch, int type, unsigned char __user *dest) { int retval = 0; u_char data[16]; @@ -634,6 +634,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, { scsi_changer *ch = file->private_data; int retval; + void __user *argp = (void __user *)arg; switch (cmd) { case CHIOGPARAMS: @@ -646,7 +647,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, params.cp_nportals = ch->counts[CHET_IE]; params.cp_ndrives = ch->counts[CHET_DT]; - if (copy_to_user((void *) arg, ¶ms, sizeof(params))) + if (copy_to_user(argp, ¶ms, sizeof(params))) return -EFAULT; return 0; } @@ -671,7 +672,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, vparams.cvp_n4 = ch->counts[CHET_V4]; strncpy(vparams.cvp_label4,vendor_labels[3],16); } - if (copy_to_user((void *) arg, &vparams, sizeof(vparams))) + if (copy_to_user(argp, &vparams, sizeof(vparams))) return -EFAULT; return 0; } @@ -680,7 +681,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, { struct changer_position pos; - if (copy_from_user(&pos, (void*)arg, sizeof (pos))) + if (copy_from_user(&pos, argp, sizeof (pos))) return -EFAULT; if (0 != ch_checkrange(ch, pos.cp_type, pos.cp_unit)) { @@ -699,7 +700,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, { struct changer_move mv; - if (copy_from_user(&mv, (void*)arg, sizeof (mv))) + if (copy_from_user(&mv, argp, sizeof (mv))) return -EFAULT; if (0 != ch_checkrange(ch, mv.cm_fromtype, mv.cm_fromunit) || @@ -721,7 +722,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, { struct changer_exchange mv; - if (copy_from_user(&mv, (void*)arg, sizeof (mv))) + if (copy_from_user(&mv, argp, sizeof (mv))) return -EFAULT; if (0 != ch_checkrange(ch, mv.ce_srctype, mv.ce_srcunit ) || @@ -746,7 +747,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, { struct changer_element_status ces; - if (copy_from_user(&ces, (void*)arg, sizeof (ces))) + if (copy_from_user(&ces, argp, sizeof (ces))) return -EFAULT; if (ces.ces_type < 0 || ces.ces_type >= CH_TYPES) return -EINVAL; @@ -762,7 +763,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, unsigned int elem; int result,i; - if (copy_from_user(&cge, (void*)arg, sizeof (cge))) + if (copy_from_user(&cge, argp, sizeof (cge))) return -EFAULT; if (0 != ch_checkrange(ch, cge.cge_type, cge.cge_unit)) @@ -825,7 +826,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, kfree(buffer); up(&ch->lock); - if (copy_to_user((void*)arg, &cge, sizeof (cge))) + if (copy_to_user(argp, &cge, sizeof (cge))) return -EFAULT; return result; } @@ -843,7 +844,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, struct changer_set_voltag csv; int elem; - if (copy_from_user(&csv, (void*)arg, sizeof(csv))) + if (copy_from_user(&csv, argp, sizeof(csv))) return -EFAULT; if (0 != ch_checkrange(ch, csv.csv_type, csv.csv_unit)) { @@ -861,7 +862,7 @@ static int ch_ioctl(struct inode * inode, struct file * file, } default: - return scsi_ioctl(ch->device, cmd, (void*)arg); + return scsi_ioctl(ch->device, cmd, argp); } } @@ -894,9 +895,9 @@ static long ch_ioctl_compat(struct file * file, case CHIOGSTATUS32: { struct changer_element_status32 ces32; - unsigned char *data; + unsigned char __user *data; - if (copy_from_user(&ces32, (void*)arg, sizeof (ces32))) + if (copy_from_user(&ces32, (void __user *)arg, sizeof (ces32))) return -EFAULT; if (ces32.ces_type < 0 || ces32.ces_type >= CH_TYPES) return -EINVAL; diff --git a/drivers/scsi/cpqfcTSinit.c b/drivers/scsi/cpqfcTSinit.c index d72be0ce89c..3fda8d455c5 100644 --- a/drivers/scsi/cpqfcTSinit.c +++ b/drivers/scsi/cpqfcTSinit.c @@ -691,8 +691,7 @@ int cpqfcTS_ioctl( struct scsi_device *ScsiDev, int Cmnd, void *arg) if( copy_to_user( vendor_cmd->bufp, buf, vendor_cmd->len)) result = -EFAULT; - if( buf) - kfree( buf); + kfree(buf); return result; } diff --git a/drivers/scsi/ibmmca.c b/drivers/scsi/ibmmca.c index b5dc3535557..6e54c7d9b33 100644 --- a/drivers/scsi/ibmmca.c +++ b/drivers/scsi/ibmmca.c @@ -36,7 +36,6 @@ #include <linux/proc_fs.h> #include <linux/stat.h> #include <linux/mca.h> -#include <linux/string.h> #include <linux/spinlock.h> #include <linux/init.h> #include <linux/mca-legacy.h> diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c index 89a4a0615c2..3f2f2464fa6 100644 --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c @@ -1377,7 +1377,7 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct scsi if ((STp->buffer)->syscall_result || !SRpnt) { printk(KERN_ERR "%s:E: Failed to read frame back from OnStream buffer\n", name); - vfree((void *)buffer); + vfree(buffer); *aSRpnt = SRpnt; return (-EIO); } @@ -1419,7 +1419,7 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct scsi if (new_frame > frame + 1000) { printk(KERN_ERR "%s:E: Failed to find writable tape media\n", name); - vfree((void *)buffer); + vfree(buffer); return (-EIO); } if ( i >= nframes + pending ) break; @@ -1500,7 +1500,7 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct scsi SRpnt->sr_sense_buffer[12] == 0 && SRpnt->sr_sense_buffer[13] == 2) { printk(KERN_ERR "%s:E: Volume overflow in write error recovery\n", name); - vfree((void *)buffer); + vfree(buffer); return (-EIO); /* hit end of tape = fail */ } i = ((SRpnt->sr_sense_buffer[3] << 24) | @@ -1525,7 +1525,7 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct scsi } if (!pending) osst_copy_to_buffer(STp->buffer, p); /* so buffer content == at entry in all cases */ - vfree((void *)buffer); + vfree(buffer); return 0; } @@ -5852,7 +5852,7 @@ static int osst_remove(struct device *dev) os_scsi_tapes[i] = NULL; osst_nr_dev--; write_unlock(&os_scsi_tapes_lock); - if (tpnt->header_cache != NULL) vfree(tpnt->header_cache); + vfree(tpnt->header_cache); if (tpnt->buffer) { normalize_buffer(tpnt->buffer); kfree(tpnt->buffer); @@ -5896,8 +5896,7 @@ static void __exit exit_osst (void) for (i=0; i < osst_max_dev; ++i) { if (!(STp = os_scsi_tapes[i])) continue; /* This is defensive, supposed to happen during detach */ - if (STp->header_cache) - vfree(STp->header_cache); + vfree(STp->header_cache); if (STp->buffer) { normalize_buffer(STp->buffer); kfree(STp->buffer); diff --git a/drivers/scsi/pluto.c b/drivers/scsi/pluto.c index 623082d3a83..c89da7d5b6d 100644 --- a/drivers/scsi/pluto.c +++ b/drivers/scsi/pluto.c @@ -95,8 +95,7 @@ int __init pluto_detect(Scsi_Host_Template *tpnt) int i, retry, nplutos; fc_channel *fc; Scsi_Device dev; - struct timer_list fc_timer = - TIMER_INITIALIZER(pluto_detect_timeout, 0, 0); + DEFINE_TIMER(fc_timer, pluto_detect_timeout, 0, 0); tpnt->proc_name = "pluto"; fcscount = 0; diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c index 72bbaa91dc7..9791496fa78 100644 --- a/drivers/scsi/qla2xxx/qla_dbg.c +++ b/drivers/scsi/qla2xxx/qla_dbg.c @@ -1334,7 +1334,7 @@ qla24xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked) dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0); WRT_REG_DWORD(dmp_reg, 0xB0200000); - dmp_reg = (uint32_t *)((uint8_t *)reg + 0xFC); + dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC); fw->shadow_reg[2] = RD_REG_DWORD(dmp_reg); dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0); diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index 5b65e208893..4d75cdfa0a0 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c @@ -864,7 +864,7 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags) /* * We're pretty sure there's a port here. Lets find out what * type of port it is. The IIR top two bits allows us to find - * out if its 8250 or 16450, 16550, 16550A or later. This + * out if it's 8250 or 16450, 16550, 16550A or later. This * determines what we test for next. * * We also initialise the EFR (if any) to zero for later. The diff --git a/drivers/serial/mcfserial.c b/drivers/serial/mcfserial.c index 43b03c55f45..e2ebdcad553 100644 --- a/drivers/serial/mcfserial.c +++ b/drivers/serial/mcfserial.c @@ -63,8 +63,13 @@ struct timer_list mcfrs_timer_struct; #endif #if defined(CONFIG_HW_FEITH) - #define CONSOLE_BAUD_RATE 38400 - #define DEFAULT_CBAUD B38400 +#define CONSOLE_BAUD_RATE 38400 +#define DEFAULT_CBAUD B38400 +#endif + +#if defined(CONFIG_MOD5272) +#define CONSOLE_BAUD_RATE 115200 +#define DEFAULT_CBAUD B115200 #endif #ifndef CONSOLE_BAUD_RATE @@ -90,7 +95,7 @@ static struct tty_driver *mcfrs_serial_driver; #undef SERIAL_DEBUG_OPEN #undef SERIAL_DEBUG_FLOW -#if defined(CONFIG_M527x) || defined(CONFIG_M528x) +#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) #define IRQBASE (MCFINT_VECBASE+MCFINT_UART0) #else #define IRQBASE 73 @@ -1510,7 +1515,7 @@ static void mcfrs_irqinit(struct mcf_serial *info) *portp = (*portp & ~0x000000ff) | 0x00000055; portp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_PDCNT); *portp = (*portp & ~0x000003fc) | 0x000002a8; -#elif defined(CONFIG_M527x) || defined(CONFIG_M528x) +#elif defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) volatile unsigned char *icrp, *uartp; volatile unsigned long *imrp; diff --git a/drivers/serial/serial_txx9.c b/drivers/serial/serial_txx9.c index 49afadbe461..f10c86d60b6 100644 --- a/drivers/serial/serial_txx9.c +++ b/drivers/serial/serial_txx9.c @@ -31,6 +31,8 @@ * 1.01 Set fifosize to make tx_empry called properly. * Use standard uart_get_divisor. * 1.02 Cleanup. (import 8250.c changes) + * 1.03 Fix low-latency mode. (import 8250.c changes) + * 1.04 Remove usage of deprecated functions, cleanup. */ #include <linux/config.h> @@ -54,7 +56,7 @@ #include <asm/io.h> #include <asm/irq.h> -static char *serial_version = "1.02"; +static char *serial_version = "1.04"; static char *serial_name = "TX39/49 Serial driver"; #define PASS_LIMIT 256 @@ -86,9 +88,9 @@ static char *serial_name = "TX39/49 Serial driver"; */ #ifdef ENABLE_SERIAL_TXX9_PCI #define NR_PCI_BOARDS 4 -#define UART_NR (2 + NR_PCI_BOARDS) +#define UART_NR (4 + NR_PCI_BOARDS) #else -#define UART_NR 2 +#define UART_NR 4 #endif struct uart_txx9_port { @@ -304,8 +306,11 @@ receive_chars(struct uart_txx9_port *up, unsigned int *status, struct pt_regs *r /* The following is not allowed by the tty layer and unsafe. It should be fixed ASAP */ if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) { - if(tty->low_latency) + if (tty->low_latency) { + spin_unlock(&up->port.lock); tty_flip_buffer_push(tty); + spin_lock(&up->port.lock); + } /* If this failed then we will throw away the bytes but must do so to clear interrupts */ } @@ -356,7 +361,9 @@ receive_chars(struct uart_txx9_port *up, unsigned int *status, struct pt_regs *r ignore_char: disr = sio_in(up, TXX9_SIDISR); } while (!(disr & TXX9_SIDISR_UVALID) && (max_count-- > 0)); + spin_unlock(&up->port.lock); tty_flip_buffer_push(tty); + spin_lock(&up->port.lock); *status = disr; } @@ -667,17 +674,8 @@ serial_txx9_pm(struct uart_port *port, unsigned int state, unsigned int oldstate) { struct uart_txx9_port *up = (struct uart_txx9_port *)port; - if (state) { - /* sleep */ - - if (up->pm) - up->pm(port, state, oldstate); - } else { - /* wake */ - - if (up->pm) - up->pm(port, state, oldstate); - } + if (up->pm) + up->pm(port, state, oldstate); } static int serial_txx9_request_resource(struct uart_txx9_port *up) @@ -979,14 +977,6 @@ static int __init serial_txx9_console_init(void) } console_initcall(serial_txx9_console_init); -static int __init serial_txx9_late_console_init(void) -{ - if (!(serial_txx9_console.flags & CON_ENABLED)) - register_console(&serial_txx9_console); - return 0; -} -late_initcall(serial_txx9_late_console_init); - #define SERIAL_TXX9_CONSOLE &serial_txx9_console #else #define SERIAL_TXX9_CONSOLE NULL @@ -1039,6 +1029,73 @@ static void serial_txx9_resume_port(int line) uart_resume_port(&serial_txx9_reg, &serial_txx9_ports[line].port); } +static DECLARE_MUTEX(serial_txx9_sem); + +/** + * serial_txx9_register_port - register a serial port + * @port: serial port template + * + * Configure the serial port specified by the request. + * + * The port is then probed and if necessary the IRQ is autodetected + * If this fails an error is returned. + * + * On success the port is ready to use and the line number is returned. + */ +static int __devinit serial_txx9_register_port(struct uart_port *port) +{ + int i; + struct uart_txx9_port *uart; + int ret = -ENOSPC; + + down(&serial_txx9_sem); + for (i = 0; i < UART_NR; i++) { + uart = &serial_txx9_ports[i]; + if (uart->port.type == PORT_UNKNOWN) + break; + } + if (i < UART_NR) { + uart_remove_one_port(&serial_txx9_reg, &uart->port); + uart->port.iobase = port->iobase; + uart->port.membase = port->membase; + uart->port.irq = port->irq; + uart->port.uartclk = port->uartclk; + uart->port.iotype = port->iotype; + uart->port.flags = port->flags | UPF_BOOT_AUTOCONF; + uart->port.mapbase = port->mapbase; + if (port->dev) + uart->port.dev = port->dev; + ret = uart_add_one_port(&serial_txx9_reg, &uart->port); + if (ret == 0) + ret = uart->port.line; + } + up(&serial_txx9_sem); + return ret; +} + +/** + * serial_txx9_unregister_port - remove a txx9 serial port at runtime + * @line: serial line number + * + * Remove one serial port. This may not be called from interrupt + * context. We hand the port back to the our control. + */ +static void __devexit serial_txx9_unregister_port(int line) +{ + struct uart_txx9_port *uart = &serial_txx9_ports[line]; + + down(&serial_txx9_sem); + uart_remove_one_port(&serial_txx9_reg, &uart->port); + uart->port.flags = 0; + uart->port.type = PORT_UNKNOWN; + uart->port.iobase = 0; + uart->port.mapbase = 0; + uart->port.membase = 0; + uart->port.dev = NULL; + uart_add_one_port(&serial_txx9_reg, &uart->port); + up(&serial_txx9_sem); +} + /* * Probe one serial board. Unfortunately, there is no rhyme nor reason * to the arrangement of serial ports on a PCI card. @@ -1056,13 +1113,13 @@ pciserial_txx9_init_one(struct pci_dev *dev, const struct pci_device_id *ent) memset(&port, 0, sizeof(port)); port.ops = &serial_txx9_pops; - port.flags |= UPF_BOOT_AUTOCONF; /* uart_ops.config_port will be called */ port.flags |= UPF_TXX9_HAVE_CTS_LINE; port.uartclk = 66670000; port.irq = dev->irq; port.iotype = UPIO_PORT; port.iobase = pci_resource_start(dev, 1); - line = uart_register_port(&serial_txx9_reg, &port); + port.dev = &dev->dev; + line = serial_txx9_register_port(&port); if (line < 0) { printk(KERN_WARNING "Couldn't register serial port %s: %d\n", pci_name(dev), line); } @@ -1078,7 +1135,7 @@ static void __devexit pciserial_txx9_remove_one(struct pci_dev *dev) pci_set_drvdata(dev, NULL); if (line) { - uart_unregister_port(&serial_txx9_reg, line); + serial_txx9_unregister_port(line); pci_disable_device(dev); } } @@ -1089,6 +1146,8 @@ static int pciserial_txx9_suspend_one(struct pci_dev *dev, pm_message_t state) if (line) serial_txx9_suspend_port(line); + pci_save_state(dev); + pci_set_power_state(dev, pci_choose_state(dev, state)); return 0; } @@ -1096,8 +1155,13 @@ static int pciserial_txx9_resume_one(struct pci_dev *dev) { int line = (int)(long)pci_get_drvdata(dev); - if (line) + pci_set_power_state(dev, PCI_D0); + pci_restore_state(dev); + + if (line) { + pci_enable_device(dev); serial_txx9_resume_port(line); + } return 0; } diff --git a/drivers/telephony/ixj.c b/drivers/telephony/ixj.c index f2c9fa423d4..f6704688ee8 100644 --- a/drivers/telephony/ixj.c +++ b/drivers/telephony/ixj.c @@ -774,10 +774,7 @@ static int ixj_wink(IXJ *j) j->pots_winkstart = jiffies; SLIC_SetState(PLD_SLIC_STATE_OC, j); - while (time_before(jiffies, j->pots_winkstart + j->winktime)) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } + msleep(jiffies_to_msecs(j->winktime)); SLIC_SetState(slicnow, j); return 0; @@ -1912,7 +1909,6 @@ static int ixj_pcmcia_cable_check(IXJ *j) static int ixj_hookstate(IXJ *j) { - unsigned long det; int fOffHook = 0; switch (j->cardtype) { @@ -1943,11 +1939,7 @@ static int ixj_hookstate(IXJ *j) j->pld_slicr.bits.state == PLD_SLIC_STATE_STANDBY) { if (j->flags.ringing || j->flags.cringing) { if (!in_interrupt()) { - det = jiffies + (hertz / 50); - while (time_before(jiffies, det)) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } + msleep(20); } SLIC_GetState(j); if (j->pld_slicr.bits.state == PLD_SLIC_STATE_RINGING) { @@ -2062,7 +2054,7 @@ static void ixj_ring_start(IXJ *j) static int ixj_ring(IXJ *j) { char cntr; - unsigned long jif, det; + unsigned long jif; j->flags.ringing = 1; if (ixj_hookstate(j) & 1) { @@ -2070,7 +2062,6 @@ static int ixj_ring(IXJ *j) j->flags.ringing = 0; return 1; } - det = 0; for (cntr = 0; cntr < j->maxrings; cntr++) { jif = jiffies + (1 * hertz); ixj_ring_on(j); @@ -2080,8 +2071,7 @@ static int ixj_ring(IXJ *j) j->flags.ringing = 0; return 1; } - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); + schedule_timeout_interruptible(1); if (signal_pending(current)) break; } @@ -2089,20 +2079,13 @@ static int ixj_ring(IXJ *j) ixj_ring_off(j); while (time_before(jiffies, jif)) { if (ixj_hookstate(j) & 1) { - det = jiffies + (hertz / 100); - while (time_before(jiffies, det)) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - if (signal_pending(current)) - break; - } + msleep(10); if (ixj_hookstate(j) & 1) { j->flags.ringing = 0; return 1; } } - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); + schedule_timeout_interruptible(1); if (signal_pending(current)) break; } @@ -2168,10 +2151,8 @@ static int ixj_release(struct inode *inode, struct file *file_p) * Set up locks to ensure that only one process is talking to the DSP at a time. * This is necessary to keep the DSP from locking up. */ - while(test_and_set_bit(board, (void *)&j->busyflags) != 0) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } + while(test_and_set_bit(board, (void *)&j->busyflags) != 0) + schedule_timeout_interruptible(1); if (ixjdebug & 0x0002) printk(KERN_INFO "Closing board %d\n", NUM(inode)); @@ -3301,14 +3282,10 @@ static void ixj_write_cidcw(IXJ *j) ixj_play_tone(j, 23); clear_bit(j->board, &j->busyflags); - while(j->tone_state) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } - while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } + while(j->tone_state) + schedule_timeout_interruptible(1); + while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) + schedule_timeout_interruptible(1); if(ixjdebug & 0x0200) { printk("IXJ cidcw phone%d first tone end at %ld\n", j->board, jiffies); } @@ -3328,14 +3305,10 @@ static void ixj_write_cidcw(IXJ *j) ixj_play_tone(j, 24); clear_bit(j->board, &j->busyflags); - while(j->tone_state) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } - while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } + while(j->tone_state) + schedule_timeout_interruptible(1); + while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) + schedule_timeout_interruptible(1); if(ixjdebug & 0x0200) { printk("IXJ cidcw phone%d sent second tone at %ld\n", j->board, jiffies); } @@ -3343,14 +3316,10 @@ static void ixj_write_cidcw(IXJ *j) j->cidcw_wait = jiffies + ((50 * hertz) / 100); clear_bit(j->board, &j->busyflags); - while(!j->flags.cidcw_ack && time_before(jiffies, j->cidcw_wait)) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } - while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } + while(!j->flags.cidcw_ack && time_before(jiffies, j->cidcw_wait)) + schedule_timeout_interruptible(1); + while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) + schedule_timeout_interruptible(1); j->cidcw_wait = 0; if(!j->flags.cidcw_ack) { if(ixjdebug & 0x0200) { @@ -6125,10 +6094,8 @@ static int ixj_ioctl(struct inode *inode, struct file *file_p, unsigned int cmd, * Set up locks to ensure that only one process is talking to the DSP at a time. * This is necessary to keep the DSP from locking up. */ - while(test_and_set_bit(board, (void *)&j->busyflags) != 0) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } + while(test_and_set_bit(board, (void *)&j->busyflags) != 0) + schedule_timeout_interruptible(1); if (ixjdebug & 0x0040) printk("phone%d ioctl, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg); if (minor >= IXJMAX) { @@ -6694,8 +6661,6 @@ static struct file_operations ixj_fops = static int ixj_linetest(IXJ *j) { - unsigned long jifwait; - j->flags.pstncheck = 1; /* Testing */ j->flags.pstn_present = 0; /* Assume the line is not there */ @@ -6726,11 +6691,7 @@ static int ixj_linetest(IXJ *j) outb_p(j->pld_scrw.byte, j->XILINXbase); daa_set_mode(j, SOP_PU_CONVERSATION); - jifwait = jiffies + hertz; - while (time_before(jiffies, jifwait)) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } + msleep(1000); daa_int_read(j); daa_set_mode(j, SOP_PU_RESET); if (j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK) { @@ -6750,11 +6711,7 @@ static int ixj_linetest(IXJ *j) j->pld_slicw.bits.rly3 = 0; outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); daa_set_mode(j, SOP_PU_CONVERSATION); - jifwait = jiffies + hertz; - while (time_before(jiffies, jifwait)) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } + msleep(1000); daa_int_read(j); daa_set_mode(j, SOP_PU_RESET); if (j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK) { @@ -6783,7 +6740,6 @@ static int ixj_linetest(IXJ *j) static int ixj_selfprobe(IXJ *j) { unsigned short cmd; - unsigned long jif; int cnt; BYTES bytes; @@ -6933,29 +6889,13 @@ static int ixj_selfprobe(IXJ *j) } else { if (j->cardtype == QTI_LINEJACK) { LED_SetState(0x1, j); - jif = jiffies + (hertz / 10); - while (time_before(jiffies, jif)) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } + msleep(100); LED_SetState(0x2, j); - jif = jiffies + (hertz / 10); - while (time_before(jiffies, jif)) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } + msleep(100); LED_SetState(0x4, j); - jif = jiffies + (hertz / 10); - while (time_before(jiffies, jif)) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } + msleep(100); LED_SetState(0x8, j); - jif = jiffies + (hertz / 10); - while (time_before(jiffies, jif)) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } + msleep(100); LED_SetState(0x0, j); daa_get_version(j); if (ixjdebug & 0x0002) diff --git a/drivers/usb/host/hc_crisv10.c b/drivers/usb/host/hc_crisv10.c index 81f8f6b7fdc..a8267cf17db 100644 --- a/drivers/usb/host/hc_crisv10.c +++ b/drivers/usb/host/hc_crisv10.c @@ -178,8 +178,8 @@ static __u8 root_hub_hub_des[] = 0xff /* __u8 PortPwrCtrlMask; *** 7 ports max *** */ }; -static struct timer_list bulk_start_timer = TIMER_INITIALIZER(NULL, 0, 0); -static struct timer_list bulk_eot_timer = TIMER_INITIALIZER(NULL, 0, 0); +static DEFINE_TIMER(bulk_start_timer, NULL, 0, 0); +static DEFINE_TIMER(bulk_eot_timer, NULL, 0, 0); /* We want the start timer to expire before the eot timer, because the former might start traffic, thus making it unnecessary for the latter to time out. */ diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 1ab95d24c5e..e108e0a36b7 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c @@ -2,7 +2,8 @@ * USB HID support for Linux * * Copyright (c) 1999 Andreas Gal - * Copyright (c) 2000-2001 Vojtech Pavlik <vojtech@suse.cz> + * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> + * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc */ /* @@ -38,7 +39,7 @@ * Version Information */ -#define DRIVER_VERSION "v2.01" +#define DRIVER_VERSION "v2.6" #define DRIVER_AUTHOR "Andreas Gal, Vojtech Pavlik" #define DRIVER_DESC "USB HID core driver" #define DRIVER_LICENSE "GPL" @@ -1058,8 +1059,8 @@ static int hid_submit_ctrl(struct hid_device *hid) if (maxpacket > 0) { padlen = (len + maxpacket - 1) / maxpacket; padlen *= maxpacket; - if (padlen > HID_BUFFER_SIZE) - padlen = HID_BUFFER_SIZE; + if (padlen > hid->bufsize) + padlen = hid->bufsize; } else padlen = 0; hid->urbctrl->transfer_buffer_length = padlen; @@ -1096,6 +1097,7 @@ static void hid_irq_out(struct urb *urb, struct pt_regs *regs) switch (urb->status) { case 0: /* success */ + break; case -ESHUTDOWN: /* unplug */ case -EILSEQ: /* unplug timeout on uhci */ unplug = 1; @@ -1143,6 +1145,7 @@ static void hid_ctrl(struct urb *urb, struct pt_regs *regs) case 0: /* success */ if (hid->ctrl[hid->ctrltail].dir == USB_DIR_IN) hid_input_report(hid->ctrl[hid->ctrltail].report->type, urb, 0, regs); + break; case -ESHUTDOWN: /* unplug */ case -EILSEQ: /* unplug timectrl on uhci */ unplug = 1; @@ -1284,13 +1287,8 @@ void hid_init_reports(struct hid_device *hid) struct hid_report *report; int err, ret; - list_for_each_entry(report, &hid->report_enum[HID_INPUT_REPORT].report_list, list) { - int size = ((report->size - 1) >> 3) + 1 + hid->report_enum[HID_INPUT_REPORT].numbered; - if (size > HID_BUFFER_SIZE) size = HID_BUFFER_SIZE; - if (size > hid->urbin->transfer_buffer_length) - hid->urbin->transfer_buffer_length = size; + list_for_each_entry(report, &hid->report_enum[HID_INPUT_REPORT].report_list, list) hid_submit_report(hid, report, USB_DIR_IN); - } list_for_each_entry(report, &hid->report_enum[HID_FEATURE_REPORT].report_list, list) hid_submit_report(hid, report, USB_DIR_IN); @@ -1372,12 +1370,14 @@ void hid_init_reports(struct hid_device *hid) #define USB_VENDOR_ID_A4TECH 0x09da #define USB_DEVICE_ID_A4TECH_WCP32PU 0x0006 -#define USB_VENDOR_ID_AASHIMA 0x06D6 +#define USB_VENDOR_ID_AASHIMA 0x06d6 #define USB_DEVICE_ID_AASHIMA_GAMEPAD 0x0025 +#define USB_DEVICE_ID_AASHIMA_PREDATOR 0x0026 #define USB_VENDOR_ID_CYPRESS 0x04b4 #define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001 #define USB_DEVICE_ID_CYPRESS_HIDCOM 0x5500 +#define USB_DEVICE_ID_CYPRESS_ULTRAMOUSE 0x7417 #define USB_VENDOR_ID_BERKSHIRE 0x0c98 #define USB_DEVICE_ID_BERKSHIRE_PCWD 0x1140 @@ -1432,7 +1432,7 @@ void hid_init_reports(struct hid_device *hid) #define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004 #define USB_VENDOR_ID_LD 0x0f11 -#define USB_DEVICE_ID_CASSY 0x1000 +#define USB_DEVICE_ID_CASSY 0x1000 #define USB_DEVICE_ID_POCKETCASSY 0x1010 #define USB_DEVICE_ID_MOBILECASSY 0x1020 #define USB_DEVICE_ID_JWM 0x1080 @@ -1445,7 +1445,8 @@ void hid_init_reports(struct hid_device *hid) #define USB_DEVICE_ID_POWERCONTROL 0x2030 #define USB_VENDOR_ID_APPLE 0x05ac -#define USB_DEVICE_ID_APPLE_BLUETOOTH 0x1000 +#define USB_DEVICE_ID_APPLE_POWERMOUSE 0x0304 +#define USB_DEVICE_ID_APPLE_BLUETOOTH 0x1000 /* * Alphabetically sorted blacklist by quirk type. @@ -1471,6 +1472,7 @@ static struct hid_blacklist { { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW48, HID_QUIRK_IGNORE }, { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW28, HID_QUIRK_IGNORE }, { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM, HID_QUIRK_IGNORE }, + { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE, HID_QUIRK_IGNORE }, { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE, HID_QUIRK_IGNORE }, { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20, HID_QUIRK_IGNORE }, { USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5, HID_QUIRK_IGNORE }, @@ -1551,10 +1553,12 @@ static struct hid_blacklist { { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_USBHUB_KB, HID_QUIRK_NOGET}, { USB_VENDOR_ID_TANGTOP, USB_DEVICE_ID_TANGTOP_USBPS2, HID_QUIRK_NOGET }, + { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_POWERMOUSE, HID_QUIRK_2WHEEL_POWERMOUSE }, { USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU, HID_QUIRK_2WHEEL_MOUSE_HACK_7 }, { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE, HID_QUIRK_2WHEEL_MOUSE_HACK_5 }, { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_GAMEPAD, HID_QUIRK_BADPAD }, + { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_PREDATOR, HID_QUIRK_BADPAD }, { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD }, { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD }, { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, @@ -1567,15 +1571,32 @@ static struct hid_blacklist { { 0, 0 } }; +/* + * Traverse the supplied list of reports and find the longest + */ +static void hid_find_max_report(struct hid_device *hid, unsigned int type, int *max) +{ + struct hid_report *report; + int size; + + list_for_each_entry(report, &hid->report_enum[type].report_list, list) { + size = ((report->size - 1) >> 3) + 1; + if (type == HID_INPUT_REPORT && hid->report_enum[type].numbered) + size++; + if (*max < size) + *max = size; + } +} + static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid) { - if (!(hid->inbuf = usb_buffer_alloc(dev, HID_BUFFER_SIZE, SLAB_ATOMIC, &hid->inbuf_dma))) + if (!(hid->inbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->inbuf_dma))) return -1; - if (!(hid->outbuf = usb_buffer_alloc(dev, HID_BUFFER_SIZE, SLAB_ATOMIC, &hid->outbuf_dma))) + if (!(hid->outbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->outbuf_dma))) return -1; if (!(hid->cr = usb_buffer_alloc(dev, sizeof(*(hid->cr)), SLAB_ATOMIC, &hid->cr_dma))) return -1; - if (!(hid->ctrlbuf = usb_buffer_alloc(dev, HID_BUFFER_SIZE, SLAB_ATOMIC, &hid->ctrlbuf_dma))) + if (!(hid->ctrlbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->ctrlbuf_dma))) return -1; return 0; @@ -1584,13 +1605,13 @@ static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid) static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid) { if (hid->inbuf) - usb_buffer_free(dev, HID_BUFFER_SIZE, hid->inbuf, hid->inbuf_dma); + usb_buffer_free(dev, hid->bufsize, hid->inbuf, hid->inbuf_dma); if (hid->outbuf) - usb_buffer_free(dev, HID_BUFFER_SIZE, hid->outbuf, hid->outbuf_dma); + usb_buffer_free(dev, hid->bufsize, hid->outbuf, hid->outbuf_dma); if (hid->cr) usb_buffer_free(dev, sizeof(*(hid->cr)), hid->cr, hid->cr_dma); if (hid->ctrlbuf) - usb_buffer_free(dev, HID_BUFFER_SIZE, hid->ctrlbuf, hid->ctrlbuf_dma); + usb_buffer_free(dev, hid->bufsize, hid->ctrlbuf, hid->ctrlbuf_dma); } static struct hid_device *usb_hid_configure(struct usb_interface *intf) @@ -1601,7 +1622,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) struct hid_device *hid; unsigned quirks = 0, rsize = 0; char *buf, *rdesc; - int n; + int n, insize = 0; for (n = 0; hid_blacklist[n].idVendor; n++) if ((hid_blacklist[n].idVendor == le16_to_cpu(dev->descriptor.idVendor)) && @@ -1655,6 +1676,19 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) kfree(rdesc); hid->quirks = quirks; + hid->bufsize = HID_MIN_BUFFER_SIZE; + hid_find_max_report(hid, HID_INPUT_REPORT, &hid->bufsize); + hid_find_max_report(hid, HID_OUTPUT_REPORT, &hid->bufsize); + hid_find_max_report(hid, HID_FEATURE_REPORT, &hid->bufsize); + + if (hid->bufsize > HID_MAX_BUFFER_SIZE) + hid->bufsize = HID_MAX_BUFFER_SIZE; + + hid_find_max_report(hid, HID_INPUT_REPORT, &insize); + + if (insize > HID_MAX_BUFFER_SIZE) + insize = HID_MAX_BUFFER_SIZE; + if (hid_alloc_buffers(dev, hid)) { hid_free_buffers(dev, hid); goto fail; @@ -1685,7 +1719,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) if (!(hid->urbin = usb_alloc_urb(0, GFP_KERNEL))) goto fail; pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); - usb_fill_int_urb(hid->urbin, dev, pipe, hid->inbuf, 0, + usb_fill_int_urb(hid->urbin, dev, pipe, hid->inbuf, insize, hid_irq_in, hid, interval); hid->urbin->transfer_dma = hid->inbuf_dma; hid->urbin->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; diff --git a/drivers/usb/input/hid-debug.h b/drivers/usb/input/hid-debug.h index 52437e5e2e7..ceebab99eff 100644 --- a/drivers/usb/input/hid-debug.h +++ b/drivers/usb/input/hid-debug.h @@ -85,6 +85,23 @@ static const struct hid_usage_entry hid_usage_table[] = { {0, 0x91, "D-PadDown"}, {0, 0x92, "D-PadRight"}, {0, 0x93, "D-PadLeft"}, + { 2, 0, "Simulation" }, + {0, 0xb0, "Aileron"}, + {0, 0xb1, "AileronTrim"}, + {0, 0xb2, "Anti-Torque"}, + {0, 0xb3, "Autopilot"}, + {0, 0xb4, "Chaff"}, + {0, 0xb5, "Collective"}, + {0, 0xb6, "DiveBrake"}, + {0, 0xb7, "ElectronicCountermeasures"}, + {0, 0xb8, "Elevator"}, + {0, 0xb9, "ElevatorTrim"}, + {0, 0xba, "Rudder"}, + {0, 0xbb, "Throttle"}, + {0, 0xbc, "FlightCommunications"}, + {0, 0xbd, "FlareRelease"}, + {0, 0xbe, "LandingGear"}, + {0, 0xbf, "ToeBrake"}, { 7, 0, "Keyboard" }, { 8, 0, "LED" }, {0, 0x01, "NumLock"}, @@ -92,6 +109,7 @@ static const struct hid_usage_entry hid_usage_table[] = { {0, 0x03, "ScrollLock"}, {0, 0x04, "Compose"}, {0, 0x05, "Kana"}, + {0, 0x4b, "GenericIndicator"}, { 9, 0, "Button" }, { 10, 0, "Ordinal" }, { 12, 0, "Consumer" }, @@ -574,7 +592,8 @@ static char *keys[KEY_MAX + 1] = { [KEY_EXIT] = "Exit", [KEY_MOVE] = "Move", [KEY_EDIT] = "Edit", [KEY_SCROLLUP] = "ScrollUp", [KEY_SCROLLDOWN] = "ScrollDown", [KEY_KPLEFTPAREN] = "KPLeftParenthesis", - [KEY_KPRIGHTPAREN] = "KPRightParenthesis", [KEY_F13] = "F13", + [KEY_KPRIGHTPAREN] = "KPRightParenthesis", [KEY_NEW] = "New", + [KEY_REDO] = "Redo", [KEY_F13] = "F13", [KEY_F14] = "F14", [KEY_F15] = "F15", [KEY_F16] = "F16", [KEY_F17] = "F17", [KEY_F18] = "F18", [KEY_F19] = "F19", @@ -584,15 +603,15 @@ static char *keys[KEY_MAX + 1] = { [KEY_PAUSECD] = "PauseCD", [KEY_PROG3] = "Prog3", [KEY_PROG4] = "Prog4", [KEY_SUSPEND] = "Suspend", [KEY_CLOSE] = "Close", [KEY_PLAY] = "Play", - [KEY_FASTFORWARD] = "Fast Forward", [KEY_BASSBOOST] = "Bass Boost", + [KEY_FASTFORWARD] = "FastForward", [KEY_BASSBOOST] = "BassBoost", [KEY_PRINT] = "Print", [KEY_HP] = "HP", [KEY_CAMERA] = "Camera", [KEY_SOUND] = "Sound", [KEY_QUESTION] = "Question", [KEY_EMAIL] = "Email", [KEY_CHAT] = "Chat", [KEY_SEARCH] = "Search", [KEY_CONNECT] = "Connect", [KEY_FINANCE] = "Finance", [KEY_SPORT] = "Sport", [KEY_SHOP] = "Shop", - [KEY_ALTERASE] = "Alternate Erase", [KEY_CANCEL] = "Cancel", - [KEY_BRIGHTNESSDOWN] = "Brightness down", [KEY_BRIGHTNESSUP] = "Brightness up", + [KEY_ALTERASE] = "AlternateErase", [KEY_CANCEL] = "Cancel", + [KEY_BRIGHTNESSDOWN] = "BrightnessDown", [KEY_BRIGHTNESSUP] = "BrightnessUp", [KEY_MEDIA] = "Media", [KEY_UNKNOWN] = "Unknown", [BTN_0] = "Btn0", [BTN_1] = "Btn1", [BTN_2] = "Btn2", [BTN_3] = "Btn3", @@ -622,8 +641,8 @@ static char *keys[KEY_MAX + 1] = { [BTN_TOOL_AIRBRUSH] = "ToolAirbrush", [BTN_TOOL_FINGER] = "ToolFinger", [BTN_TOOL_MOUSE] = "ToolMouse", [BTN_TOOL_LENS] = "ToolLens", [BTN_TOUCH] = "Touch", [BTN_STYLUS] = "Stylus", - [BTN_STYLUS2] = "Stylus2", [BTN_TOOL_DOUBLETAP] = "Tool Doubletap", - [BTN_TOOL_TRIPLETAP] = "Tool Tripletap", [BTN_GEAR_DOWN] = "WheelBtn", + [BTN_STYLUS2] = "Stylus2", [BTN_TOOL_DOUBLETAP] = "ToolDoubleTap", + [BTN_TOOL_TRIPLETAP] = "ToolTripleTap", [BTN_GEAR_DOWN] = "WheelBtn", [BTN_GEAR_UP] = "Gear up", [KEY_OK] = "Ok", [KEY_SELECT] = "Select", [KEY_GOTO] = "Goto", [KEY_CLEAR] = "Clear", [KEY_POWER2] = "Power2", @@ -659,6 +678,9 @@ static char *keys[KEY_MAX + 1] = { [KEY_TWEN] = "TWEN", [KEY_DEL_EOL] = "DeleteEOL", [KEY_DEL_EOS] = "DeleteEOS", [KEY_INS_LINE] = "InsertLine", [KEY_DEL_LINE] = "DeleteLine", + [KEY_SEND] = "Send", [KEY_REPLY] = "Reply", + [KEY_FORWARDMAIL] = "ForwardMail", [KEY_SAVE] = "Save", + [KEY_DOCUMENTS] = "Documents", }; static char *relatives[REL_MAX + 1] = { diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c index 63a4db721f7..0b6452248a3 100644 --- a/drivers/usb/input/hid-input.c +++ b/drivers/usb/input/hid-input.c @@ -78,8 +78,8 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel { struct input_dev *input = &hidinput->input; struct hid_device *device = hidinput->input.private; - int max, code; - unsigned long *bit; + int max = 0, code; + unsigned long *bit = NULL; field->hidinput = hidinput; @@ -131,6 +131,15 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel map_key(code); break; + + case HID_UP_SIMULATION: + + switch (usage->hid & 0xffff) { + case 0xba: map_abs(ABS_RUDDER); break; + case 0xbb: map_abs(ABS_THROTTLE); break; + } + break; + case HID_UP_GENDESK: if ((usage->hid & 0xf0) == 0x80) { /* SystemControl */ @@ -238,8 +247,12 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel case 0x000: goto ignore; case 0x034: map_key_clear(KEY_SLEEP); break; case 0x036: map_key_clear(BTN_MISC); break; + case 0x045: map_key_clear(KEY_RADIO); break; case 0x08a: map_key_clear(KEY_WWW); break; + case 0x08d: map_key_clear(KEY_PROGRAM); break; case 0x095: map_key_clear(KEY_HELP); break; + case 0x09c: map_key_clear(KEY_CHANNELUP); break; + case 0x09d: map_key_clear(KEY_CHANNELDOWN); break; case 0x0b0: map_key_clear(KEY_PLAY); break; case 0x0b1: map_key_clear(KEY_PAUSE); break; case 0x0b2: map_key_clear(KEY_RECORD); break; @@ -259,6 +272,11 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel case 0x18a: map_key_clear(KEY_MAIL); break; case 0x192: map_key_clear(KEY_CALC); break; case 0x194: map_key_clear(KEY_FILE); break; + case 0x1a7: map_key_clear(KEY_DOCUMENTS); break; + case 0x201: map_key_clear(KEY_NEW); break; + case 0x207: map_key_clear(KEY_SAVE); break; + case 0x208: map_key_clear(KEY_PRINT); break; + case 0x209: map_key_clear(KEY_PROPS); break; case 0x21a: map_key_clear(KEY_UNDO); break; case 0x21b: map_key_clear(KEY_COPY); break; case 0x21c: map_key_clear(KEY_CUT); break; @@ -271,7 +289,11 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel case 0x227: map_key_clear(KEY_REFRESH); break; case 0x22a: map_key_clear(KEY_BOOKMARKS); break; case 0x238: map_rel(REL_HWHEEL); break; - default: goto unknown; + case 0x279: map_key_clear(KEY_REDO); break; + case 0x289: map_key_clear(KEY_REPLY); break; + case 0x28b: map_key_clear(KEY_FORWARDMAIL); break; + case 0x28c: map_key_clear(KEY_SEND); break; + default: goto ignore; } break; @@ -296,9 +318,42 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel break; case HID_UP_MSVENDOR: - goto ignore; + case HID_UP_CUSTOM: /* Reported on Logitech and Powerbook USB keyboards */ + + set_bit(EV_REP, input->evbit); + switch(usage->hid & HID_USAGE) { + case 0x003: map_key_clear(KEY_FN); break; + default: goto ignore; + } + break; + + case HID_UP_LOGIVENDOR: /* Reported on Logitech Ultra X Media Remote */ + + set_bit(EV_REP, input->evbit); + switch(usage->hid & HID_USAGE) { + case 0x004: map_key_clear(KEY_AGAIN); break; + case 0x00d: map_key_clear(KEY_HOME); break; + case 0x024: map_key_clear(KEY_SHUFFLE); break; + case 0x025: map_key_clear(KEY_TV); break; + case 0x026: map_key_clear(KEY_MENU); break; + case 0x031: map_key_clear(KEY_AUDIO); break; + case 0x032: map_key_clear(KEY_SUBTITLE); break; + case 0x033: map_key_clear(KEY_LAST); break; + case 0x047: map_key_clear(KEY_MP3); break; + case 0x048: map_key_clear(KEY_DVD); break; + case 0x049: map_key_clear(KEY_MEDIA); break; + case 0x04a: map_key_clear(KEY_VIDEO); break; + case 0x04b: map_key_clear(KEY_ANGLE); break; + case 0x04c: map_key_clear(KEY_LANGUAGE); break; + case 0x04d: map_key_clear(KEY_SUBTITLE); break; + case 0x051: map_key_clear(KEY_RED); break; + case 0x052: map_key_clear(KEY_CLOSE); break; + default: goto ignore; + } + break; + case HID_UP_PID: set_bit(EV_FF, input->evbit); @@ -349,6 +404,9 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel if (usage->code > max) goto ignore; + if (((device->quirks & (HID_QUIRK_2WHEEL_POWERMOUSE)) && (usage->hid == 0x00010032))) + map_rel(REL_HWHEEL); + if ((device->quirks & (HID_QUIRK_2WHEEL_MOUSE_HACK_7 | HID_QUIRK_2WHEEL_MOUSE_HACK_5)) && (usage->type == EV_REL) && (usage->code == REL_WHEEL)) set_bit(REL_HWHEEL, bit); diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h index c1b6b69bc4a..ec2412c42f1 100644 --- a/drivers/usb/input/hid.h +++ b/drivers/usb/input/hid.h @@ -173,6 +173,7 @@ struct hid_item { #define HID_UP_UNDEFINED 0x00000000 #define HID_UP_GENDESK 0x00010000 +#define HID_UP_SIMULATION 0x00020000 #define HID_UP_KEYBOARD 0x00070000 #define HID_UP_LED 0x00080000 #define HID_UP_BUTTON 0x00090000 @@ -182,6 +183,8 @@ struct hid_item { #define HID_UP_PID 0x000f0000 #define HID_UP_HPVENDOR 0xff7f0000 #define HID_UP_MSVENDOR 0xff000000 +#define HID_UP_CUSTOM 0x00ff0000 +#define HID_UP_LOGIVENDOR 0xffbc0000 #define HID_USAGE 0x0000ffff @@ -242,6 +245,7 @@ struct hid_item { #define HID_QUIRK_2WHEEL_MOUSE_HACK_7 0x080 #define HID_QUIRK_2WHEEL_MOUSE_HACK_5 0x100 #define HID_QUIRK_2WHEEL_MOUSE_HACK_ON 0x200 +#define HID_QUIRK_2WHEEL_POWERMOUSE 0x400 /* * This is the global environment of the parser. This information is @@ -348,7 +352,8 @@ struct hid_report_enum { #define HID_REPORT_TYPES 3 -#define HID_BUFFER_SIZE 64 /* use 64 for compatibility with all possible packetlen */ +#define HID_MIN_BUFFER_SIZE 64 /* make sure there is at least a packet size of space */ +#define HID_MAX_BUFFER_SIZE 4096 /* 4kb */ #define HID_CONTROL_FIFO_SIZE 256 /* to init devices with >100 reports */ #define HID_OUTPUT_FIFO_SIZE 64 @@ -386,6 +391,8 @@ struct hid_device { /* device report descriptor */ unsigned long iofl; /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */ + unsigned int bufsize; /* URB buffer size */ + struct urb *urbin; /* Input URB */ char *inbuf; /* Input buffer */ dma_addr_t inbuf_dma; /* Input buffer dma */ diff --git a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c index 4c13331b5f4..d32427818af 100644 --- a/drivers/usb/input/hiddev.c +++ b/drivers/usb/input/hiddev.c @@ -507,6 +507,7 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd return -EINVAL; hid_submit_report(hid, report, USB_DIR_OUT); + hid_wait_io(hid); return 0; diff --git a/drivers/usb/media/stv680.c b/drivers/usb/media/stv680.c index 7398a7f19c1..0fd0fa9fec2 100644 --- a/drivers/usb/media/stv680.c +++ b/drivers/usb/media/stv680.c @@ -260,7 +260,7 @@ static int stv_stop_video (struct usb_stv *dev) PDEBUG (0, "STV(i): Camera set to original resolution"); } /* origMode */ - kfree (buf); + kfree(buf); return i; } @@ -276,7 +276,7 @@ static int stv_set_video_mode (struct usb_stv *dev) } if ((i = stv_set_config (dev, 1, 0, 0)) < 0) { - kfree (buf); + kfree(buf); return i; } @@ -301,13 +301,13 @@ static int stv_set_video_mode (struct usb_stv *dev) goto exit; error: - kfree (buf); + kfree(buf); if (stop_video == 1) stv_stop_video (dev); return -1; exit: - kfree (buf); + kfree(buf); return 0; } @@ -327,7 +327,7 @@ static int stv_init (struct usb_stv *stv680) /* set config 1, interface 0, alternate 0 */ if ((i = stv_set_config (stv680, 1, 0, 0)) < 0) { - kfree (buffer); + kfree(buffer); PDEBUG (0, "STV(e): set config 1,0,0 failed"); return -1; } @@ -435,11 +435,11 @@ static int stv_init (struct usb_stv *stv680) error: i = stv_sndctrl (0, stv680, 0x80, 0, buffer, 0x02); /* Get Last Error */ PDEBUG (1, "STV(i): last error: %i, command = 0x%x", buffer[0], buffer[1]); - kfree (buffer); + kfree(buffer); return -1; exit: - kfree (buffer); + kfree(buffer); /* video = 320x240, 352x288 */ if (stv680->CIF == 1) { @@ -708,10 +708,10 @@ static int stv680_stop_stream (struct usb_stv *stv680) usb_kill_urb (stv680->urb[i]); usb_free_urb (stv680->urb[i]); stv680->urb[i] = NULL; - kfree (stv680->sbuf[i].data); + kfree(stv680->sbuf[i].data); } for (i = 0; i < STV680_NUMSCRATCH; i++) { - kfree (stv680->scratch[i].data); + kfree(stv680->scratch[i].data); stv680->scratch[i].data = NULL; } @@ -1068,7 +1068,7 @@ static int stv_close (struct inode *inode, struct file *file) stv680->user = 0; if (stv680->removed) { - kfree (stv680); + kfree(stv680); stv680 = NULL; PDEBUG (0, "STV(i): device unregistered"); } @@ -1445,14 +1445,14 @@ static inline void usb_stv680_remove_disconnected (struct usb_stv *stv680) usb_kill_urb (stv680->urb[i]); usb_free_urb (stv680->urb[i]); stv680->urb[i] = NULL; - kfree (stv680->sbuf[i].data); + kfree(stv680->sbuf[i].data); } for (i = 0; i < STV680_NUMSCRATCH; i++) - kfree (stv680->scratch[i].data); + kfree(stv680->scratch[i].data); PDEBUG (0, "STV(i): %s disconnected", stv680->camera_name); /* Free the memory */ - kfree (stv680); + kfree(stv680); } static void stv680_disconnect (struct usb_interface *intf) diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index cde0ed097af..615874e03ce 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -650,7 +650,6 @@ config FB_NVIDIA select FB_CFB_FILLRECT select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT - select FB_SOFT_CURSOR help This driver supports graphics boards with the nVidia chips, TNT and newer. For very old chipsets, such as the RIVA128, then use @@ -681,7 +680,6 @@ config FB_RIVA select FB_CFB_FILLRECT select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT - select FB_SOFT_CURSOR help This driver supports graphics boards with the nVidia Riva/Geforce chips. @@ -720,7 +718,6 @@ config FB_I810 select FB_CFB_FILLRECT select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT - select FB_SOFT_CURSOR help This driver supports the on-board graphics built in to the Intel 810 and 815 chipsets. Say Y if you have and plan to use such a board. @@ -754,6 +751,12 @@ config FB_I810_GTF If unsure, say N. +config FB_I810_I2C + bool "Enable DDC Support" + depends on FB_I810 && I2C && FB_I810_GTF + select I2C_ALGOBIT + help + config FB_INTEL tristate "Intel 830M/845G/852GM/855GM/865G support (EXPERIMENTAL)" depends on FB && EXPERIMENTAL && PCI && X86 && !X86_64 @@ -763,7 +766,6 @@ config FB_INTEL select FB_CFB_FILLRECT select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT - select FB_SOFT_CURSOR help This driver supports the on-board graphics built in to the Intel 830M/845G/852GM/855GM/865G chipsets. @@ -960,8 +962,7 @@ config FB_RADEON can be build either as modules or built-in. There is a product page at - <http://www.ati.com/na/pages/products/pc/radeon32/index.html>. - + http://apps.ati.com/ATIcompare/ config FB_RADEON_I2C bool "DDC/I2C for ATI Radeon support" depends on FB_RADEON @@ -1084,15 +1085,16 @@ config FB_SAVAGE_ACCEL choose N here. config FB_SIS - tristate "SiS acceleration" + tristate "SiS/XGI display support" depends on FB && PCI select FB_CFB_FILLRECT select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT select FB_SOFT_CURSOR help - This is the frame buffer device driver for the SiS 300, 315 and - 330 series VGA chipsets. Specs available at <http://www.sis.com> + This is the frame buffer device driver for the SiS 300, 315, 330 + and 340 series as well as XGI V3XT, V5, V8, Z7 graphics chipsets. + Specs available at <http://www.sis.com> and <http://www.xgitech.com>. To compile this driver as a module, choose M here; the module will be called sisfb. @@ -1104,11 +1106,12 @@ config FB_SIS_300 Say Y here to support use of the SiS 300/305, 540, 630 and 730. config FB_SIS_315 - bool "SiS 315/330 series support" + bool "SiS 315/330/340 series and XGI support" depends on FB_SIS help - Say Y here to support use of the SiS 315 and 330 series - (315/H/PRO, 55x, 650, 651, 740, 330, 661, 741, 760). + Say Y here to support use of the SiS 315, 330 and 340 series + (315/H/PRO, 55x, 650, 651, 740, 330, 661, 741, 760, 761) as well + as XGI V3XT, V5, V8 and Z7. config FB_NEOMAGIC tristate "NeoMagic display support" @@ -1180,6 +1183,32 @@ config FB_VOODOO1 Please read the <file:Documentation/fb/README-sstfb.txt> for supported options and other important info support. +config FB_CYBLA + tristate "Cyberblade/i1 support" + depends on FB && PCI + select FB_CFB_IMAGEBLIT + select FB_SOFT_CURSOR + select VIDEO_SELECT + ---help--- + This driver is supposed to support the Trident Cyberblade/i1 + graphics core integrated in the VIA VT8601A North Bridge, + also known as VIA Apollo PLE133. + + Status: + - Developed, tested and working on EPIA 5000 and EPIA 800. + - Does work reliable on all systems with CRT/LCD connected to + normal VGA ports. + - Should work on systems that do use the internal LCD port, but + this is absolutely not tested. + + Character imageblit, copyarea and rectangle fill are hw accelerated, + ypan scrolling is used by default. + + Please do read <file:Documentation/fb/cyblafb/*>. + + To compile this driver as a module, choose M here: the + module will be called cyblafb. + config FB_TRIDENT tristate "Trident support" depends on FB && PCI @@ -1193,8 +1222,12 @@ config FB_TRIDENT but also on some motherboards. For more information, read <file:Documentation/fb/tridentfb.txt> + Cyberblade/i1 support will be removed soon, use the cyblafb driver + instead. + Say Y if you have such a graphics board. + To compile this driver as a module, choose M here: the module will be called tridentfb. @@ -1205,7 +1238,6 @@ config FB_TRIDENT_ACCEL This will compile the Trident frame buffer device with acceleration functions. - config FB_PM3 tristate "Permedia3 support" depends on FB && PCI && BROKEN @@ -1484,6 +1516,30 @@ config FB_S1D13XXX working with S1D13806). Product specs at <http://www.erd.epson.com/vdc/html/legacy_13xxx.htm> +config FB_S3C2410 + tristate "S3C2410 LCD framebuffer support" + depends on FB && ARCH_S3C2410 + select FB_CFB_FILLRECT + select FB_CFB_COPYAREA + select FB_CFB_IMAGEBLIT + select FB_SOFT_CURSOR + ---help--- + Frame buffer driver for the built-in LCD controller in the Samsung + S3C2410 processor. + + This driver is also available as a module ( = code which can be + inserted and removed from the running kernel whenever you want). The + module will be called s3c2410fb. If you want to compile it as a module, + say M here and read <file:Documentation/modules.txt>. + + If unsure, say N. +config FB_S3C2410_DEBUG + bool "S3C2410 lcd debug messages" + depends on FB_S3C2410 + help + Turn on debugging messages. Note that you can set/unset at run time + through sysfs + config FB_VIRTUAL tristate "Virtual Frame Buffer support (ONLY FOR TESTING!)" depends on FB diff --git a/drivers/video/Makefile b/drivers/video/Makefile index b018df4e95c..1fff29f48ca 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile @@ -9,7 +9,8 @@ obj-$(CONFIG_LOGO) += logo/ obj-$(CONFIG_SYSFS) += backlight/ obj-$(CONFIG_FB) += fb.o -fb-y := fbmem.o fbmon.o fbcmap.o fbsysfs.o modedb.o +fb-y := fbmem.o fbmon.o fbcmap.o fbsysfs.o \ + modedb.o fbcvt.o fb-objs := $(fb-y) obj-$(CONFIG_FB_CFB_FILLRECT) += cfbfillrect.o @@ -50,7 +51,8 @@ obj-$(CONFIG_FB_CT65550) += chipsfb.o obj-$(CONFIG_FB_IMSTT) += imsttfb.o obj-$(CONFIG_FB_S3TRIO) += S3triofb.o obj-$(CONFIG_FB_FM2) += fm2fb.o -obj-$(CONFIG_FB_TRIDENT) += tridentfb.o +obj-$(CONFIG_FB_CYBLA) += cyblafb.o +obj-$(CONFIG_FB_TRIDENT) += tridentfb.o obj-$(CONFIG_FB_STI) += stifb.o obj-$(CONFIG_FB_FFB) += ffb.o sbuslib.o obj-$(CONFIG_FB_CG6) += cg6.o sbuslib.o @@ -92,6 +94,7 @@ obj-$(CONFIG_FB_MAXINE) += maxinefb.o obj-$(CONFIG_FB_TX3912) += tx3912fb.o obj-$(CONFIG_FB_S1D13XXX) += s1d13xxxfb.o obj-$(CONFIG_FB_IMX) += imxfb.o +obj-$(CONFIG_FB_S3C2410) += s3c2410fb.o # Platform or fallback drivers go here obj-$(CONFIG_FB_VESA) += vesafb.o diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c index b0eba3ac642..e380ee8b024 100644 --- a/drivers/video/aty/aty128fb.c +++ b/drivers/video/aty/aty128fb.c @@ -806,8 +806,8 @@ static void __iomem * __init aty128_map_ROM(const struct aty128fb_par *par, stru /* Very simple test to make sure it appeared */ if (BIOS_IN16(0) != 0xaa55) { - printk(KERN_ERR "aty128fb: Invalid ROM signature %x should be 0xaa55\n", - BIOS_IN16(0)); + printk(KERN_DEBUG "aty128fb: Invalid ROM signature %x should " + " be 0xaa55\n", BIOS_IN16(0)); goto failed; } diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c index 3e10bd837d9..037fe9d32fe 100644 --- a/drivers/video/aty/atyfb_base.c +++ b/drivers/video/aty/atyfb_base.c @@ -911,20 +911,6 @@ static int aty_var_to_crtc(const struct fb_info *info, vdisplay = par->lcd_height; #endif - if(vdisplay < 400) { - h_sync_pol = 1; - v_sync_pol = 0; - } else if(vdisplay < 480) { - h_sync_pol = 0; - v_sync_pol = 1; - } else if(vdisplay < 768) { - h_sync_pol = 0; - v_sync_pol = 0; - } else { - h_sync_pol = 1; - v_sync_pol = 1; - } - v_disp--; v_sync_strt--; v_sync_end--; diff --git a/drivers/video/aty/radeon_base.c b/drivers/video/aty/radeon_base.c index e7e8b52014c..046b4786026 100644 --- a/drivers/video/aty/radeon_base.c +++ b/drivers/video/aty/radeon_base.c @@ -329,8 +329,9 @@ static int __devinit radeon_map_ROM(struct radeonfb_info *rinfo, struct pci_dev /* Very simple test to make sure it appeared */ if (BIOS_IN16(0) != 0xaa55) { - printk(KERN_ERR "radeonfb (%s): Invalid ROM signature %x should be" - "0xaa55\n", pci_name(rinfo->pdev), BIOS_IN16(0)); + printk(KERN_DEBUG "radeonfb (%s): Invalid ROM signature %x " + "should be 0xaa55\n", + pci_name(rinfo->pdev), BIOS_IN16(0)); goto failed; } /* Look for the PCI data to check the ROM type */ @@ -2312,19 +2313,27 @@ static int radeonfb_pci_register (struct pci_dev *pdev, rinfo->mmio_base_phys = pci_resource_start (pdev, 2); /* request the mem regions */ - ret = pci_request_regions(pdev, "radeonfb"); + ret = pci_request_region(pdev, 0, "radeonfb framebuffer"); if (ret < 0) { - printk( KERN_ERR "radeonfb (%s): cannot reserve PCI regions." - " Someone already got them?\n", pci_name(rinfo->pdev)); + printk( KERN_ERR "radeonfb (%s): cannot request region 0.\n", + pci_name(rinfo->pdev)); goto err_release_fb; } + ret = pci_request_region(pdev, 2, "radeonfb mmio"); + if (ret < 0) { + printk( KERN_ERR "radeonfb (%s): cannot request region 2.\n", + pci_name(rinfo->pdev)); + goto err_release_pci0; + } + /* map the regions */ rinfo->mmio_base = ioremap(rinfo->mmio_base_phys, RADEON_REGSIZE); if (!rinfo->mmio_base) { - printk(KERN_ERR "radeonfb (%s): cannot map MMIO\n", pci_name(rinfo->pdev)); + printk(KERN_ERR "radeonfb (%s): cannot map MMIO\n", + pci_name(rinfo->pdev)); ret = -EIO; - goto err_release_pci; + goto err_release_pci2; } rinfo->fb_local_base = INREG(MC_FB_LOCATION) << 16; @@ -2499,10 +2508,12 @@ err_unmap_rom: if (rinfo->bios_seg) radeon_unmap_ROM(rinfo, pdev); iounmap(rinfo->mmio_base); -err_release_pci: - pci_release_regions(pdev); +err_release_pci2: + pci_release_region(pdev, 2); +err_release_pci0: + pci_release_region(pdev, 0); err_release_fb: - framebuffer_release(info); + framebuffer_release(info); err_disable: pci_disable_device(pdev); err_out: @@ -2548,7 +2559,8 @@ static void __devexit radeonfb_pci_unregister (struct pci_dev *pdev) iounmap(rinfo->mmio_base); iounmap(rinfo->fb_base); - pci_release_regions(pdev); + pci_release_region(pdev, 2); + pci_release_region(pdev, 0); kfree(rinfo->mon1_EDID); kfree(rinfo->mon2_EDID); diff --git a/drivers/video/console/bitblit.c b/drivers/video/console/bitblit.c index 3c731577fed..9f70e512b88 100644 --- a/drivers/video/console/bitblit.c +++ b/drivers/video/console/bitblit.c @@ -39,7 +39,7 @@ static inline int get_attribute(struct fb_info *info, u16 c) { int attribute = 0; - if (fb_get_color_depth(&info->var) == 1) { + if (fb_get_color_depth(&info->var, &info->fix) == 1) { if (attr_underline(c)) attribute |= FBCON_ATTRIBUTE_UNDERLINE; if (attr_reverse(c)) @@ -103,42 +103,104 @@ static void bit_clear(struct vc_data *vc, struct fb_info *info, int sy, info->fbops->fb_fillrect(info, ®ion); } +static inline void bit_putcs_aligned(struct vc_data *vc, struct fb_info *info, + const u16 *s, u32 attr, u32 cnt, + u32 d_pitch, u32 s_pitch, u32 cellsize, + struct fb_image *image, u8 *buf, u8 *dst) +{ + u16 charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; + u32 idx = vc->vc_font.width >> 3; + u8 *src; + + while (cnt--) { + src = vc->vc_font.data + (scr_readw(s++)& + charmask)*cellsize; + + if (attr) { + update_attr(buf, src, attr, vc); + src = buf; + } + + if (likely(idx == 1)) + __fb_pad_aligned_buffer(dst, d_pitch, src, idx, + image->height); + else + fb_pad_aligned_buffer(dst, d_pitch, src, idx, + image->height); + + dst += s_pitch; + } + + info->fbops->fb_imageblit(info, image); +} + +static inline void bit_putcs_unaligned(struct vc_data *vc, + struct fb_info *info, const u16 *s, + u32 attr, u32 cnt, u32 d_pitch, + u32 s_pitch, u32 cellsize, + struct fb_image *image, u8 *buf, + u8 *dst) +{ + u16 charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; + u32 shift_low = 0, mod = vc->vc_font.width % 8; + u32 shift_high = 8; + u32 idx = vc->vc_font.width >> 3; + u8 *src; + + while (cnt--) { + src = vc->vc_font.data + (scr_readw(s++)& + charmask)*cellsize; + + if (attr) { + update_attr(buf, src, attr, vc); + src = buf; + } + + fb_pad_unaligned_buffer(dst, d_pitch, src, idx, + image->height, shift_high, + shift_low, mod); + shift_low += mod; + dst += (shift_low >= 8) ? s_pitch : s_pitch - 1; + shift_low &= 7; + shift_high = 8 - shift_low; + } + + info->fbops->fb_imageblit(info, image); + +} + static void bit_putcs(struct vc_data *vc, struct fb_info *info, const unsigned short *s, int count, int yy, int xx, int fg, int bg) { - unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; - unsigned int width = (vc->vc_font.width + 7) >> 3; - unsigned int cellsize = vc->vc_font.height * width; - unsigned int maxcnt = info->pixmap.size/cellsize; - unsigned int scan_align = info->pixmap.scan_align - 1; - unsigned int buf_align = info->pixmap.buf_align - 1; - unsigned int shift_low = 0, mod = vc->vc_font.width % 8; - unsigned int shift_high = 8, pitch, cnt, size, k; - unsigned int idx = vc->vc_font.width >> 3; - unsigned int attribute = get_attribute(info, scr_readw(s)); struct fb_image image; - u8 *src, *dst, *buf = NULL; - - if (attribute) { - buf = kmalloc(cellsize, GFP_KERNEL); - if (!buf) - return; - } + u32 width = (vc->vc_font.width + 7)/8; + u32 cellsize = width * vc->vc_font.height; + u32 maxcnt = info->pixmap.size/cellsize; + u32 scan_align = info->pixmap.scan_align - 1; + u32 buf_align = info->pixmap.buf_align - 1; + u32 mod = vc->vc_font.width % 8, cnt, pitch, size; + u32 attribute = get_attribute(info, scr_readw(s)); + u8 *dst, *buf = NULL; image.fg_color = fg; image.bg_color = bg; - image.dx = xx * vc->vc_font.width; image.dy = yy * vc->vc_font.height; image.height = vc->vc_font.height; image.depth = 1; + if (attribute) { + buf = kmalloc(cellsize, GFP_KERNEL); + if (!buf) + return; + } + while (count) { if (count > maxcnt) - cnt = k = maxcnt; + cnt = maxcnt; else - cnt = k = count; + cnt = count; image.width = vc->vc_font.width * cnt; pitch = ((image.width + 7) >> 3) + scan_align; @@ -147,41 +209,18 @@ static void bit_putcs(struct vc_data *vc, struct fb_info *info, size &= ~buf_align; dst = fb_get_buffer_offset(info, &info->pixmap, size); image.data = dst; - if (mod) { - while (k--) { - src = vc->vc_font.data + (scr_readw(s++)& - charmask)*cellsize; - - if (attribute) { - update_attr(buf, src, attribute, vc); - src = buf; - } - - fb_pad_unaligned_buffer(dst, pitch, src, idx, - image.height, shift_high, - shift_low, mod); - shift_low += mod; - dst += (shift_low >= 8) ? width : width - 1; - shift_low &= 7; - shift_high = 8 - shift_low; - } - } else { - while (k--) { - src = vc->vc_font.data + (scr_readw(s++)& - charmask)*cellsize; - - if (attribute) { - update_attr(buf, src, attribute, vc); - src = buf; - } - - fb_pad_aligned_buffer(dst, pitch, src, idx, image.height); - dst += width; - } - } - info->fbops->fb_imageblit(info, &image); + + if (!mod) + bit_putcs_aligned(vc, info, s, attribute, cnt, pitch, + width, cellsize, &image, buf, dst); + else + bit_putcs_unaligned(vc, info, s, attribute, cnt, + pitch, width, cellsize, &image, + buf, dst); + image.dx += cnt * vc->vc_font.width; count -= cnt; + s += cnt; } /* buf is always NULL except when in monochrome mode, so in this case @@ -189,6 +228,7 @@ static void bit_putcs(struct vc_data *vc, struct fb_info *info, NULL pointers just fine */ if (unlikely(buf)) kfree(buf); + } static void bit_clear_margins(struct vc_data *vc, struct fb_info *info, diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c index 35c88bd7ba5..2e93224d2d5 100644 --- a/drivers/video/console/fbcon.c +++ b/drivers/video/console/fbcon.c @@ -214,7 +214,7 @@ static inline int fbcon_is_inactive(struct vc_data *vc, struct fb_info *info) static inline int get_color(struct vc_data *vc, struct fb_info *info, u16 c, int is_fg) { - int depth = fb_get_color_depth(&info->var); + int depth = fb_get_color_depth(&info->var, &info->fix); int color = 0; if (console_blanked) { @@ -230,9 +230,13 @@ static inline int get_color(struct vc_data *vc, struct fb_info *info, switch (depth) { case 1: { + int col = ~(0xfff << (max(info->var.green.length, + max(info->var.red.length, + info->var.blue.length)))) & 0xff; + /* 0 or 1 */ - int fg = (info->fix.visual != FB_VISUAL_MONO01) ? 1 : 0; - int bg = (info->fix.visual != FB_VISUAL_MONO01) ? 0 : 1; + int fg = (info->fix.visual != FB_VISUAL_MONO01) ? col : 0; + int bg = (info->fix.visual != FB_VISUAL_MONO01) ? 0 : col; if (console_blanked) fg = bg; @@ -243,9 +247,25 @@ static inline int get_color(struct vc_data *vc, struct fb_info *info, case 2: /* * Scale down 16-colors to 4 colors. Default 4-color palette - * is grayscale. + * is grayscale. However, simply dividing the values by 4 + * will not work, as colors 1, 2 and 3 will be scaled-down + * to zero rendering them invisible. So empirically convert + * colors to a sane 4-level grayscale. */ - color /= 4; + switch (color) { + case 0: + color = 0; /* black */ + break; + case 1 ... 6: + color = 2; /* white */ + break; + case 7 ... 8: + color = 1; /* gray */ + break; + default: + color = 3; /* intense white */ + break; + } break; case 3: /* @@ -311,6 +331,35 @@ static void cursor_timer_handler(unsigned long dev_addr) mod_timer(&ops->cursor_timer, jiffies + HZ/5); } +static void fbcon_add_cursor_timer(struct fb_info *info) +{ + struct fbcon_ops *ops = info->fbcon_par; + + if ((!info->queue.func || info->queue.func == fb_flashcursor) && + !(ops->flags & FBCON_FLAGS_CURSOR_TIMER)) { + if (!info->queue.func) + INIT_WORK(&info->queue, fb_flashcursor, info); + + init_timer(&ops->cursor_timer); + ops->cursor_timer.function = cursor_timer_handler; + ops->cursor_timer.expires = jiffies + HZ / 5; + ops->cursor_timer.data = (unsigned long ) info; + add_timer(&ops->cursor_timer); + ops->flags |= FBCON_FLAGS_CURSOR_TIMER; + } +} + +static void fbcon_del_cursor_timer(struct fb_info *info) +{ + struct fbcon_ops *ops = info->fbcon_par; + + if (info->queue.func == fb_flashcursor && + ops->flags & FBCON_FLAGS_CURSOR_TIMER) { + del_timer_sync(&ops->cursor_timer); + ops->flags &= ~FBCON_FLAGS_CURSOR_TIMER; + } +} + #ifndef MODULE static int __init fb_console_setup(char *this_opt) { @@ -426,7 +475,7 @@ static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info, * remove underline attribute from erase character * if black and white framebuffer. */ - if (fb_get_color_depth(&info->var) == 1) + if (fb_get_color_depth(&info->var, &info->fix) == 1) erase &= ~0x400; logo_height = fb_prepare_logo(info); logo_lines = (logo_height + vc->vc_font.height - 1) / @@ -563,9 +612,7 @@ static int con2fb_release_oldinfo(struct vc_data *vc, struct fb_info *oldinfo, } if (!err) { - if (oldinfo->queue.func == fb_flashcursor) - del_timer_sync(&ops->cursor_timer); - + fbcon_del_cursor_timer(oldinfo); kfree(ops->cursor_state.mask); kfree(ops->cursor_data); kfree(oldinfo->fbcon_par); @@ -576,22 +623,6 @@ static int con2fb_release_oldinfo(struct vc_data *vc, struct fb_info *oldinfo, return err; } -static void con2fb_init_newinfo(struct fb_info *info) -{ - if (!info->queue.func || info->queue.func == fb_flashcursor) { - struct fbcon_ops *ops = info->fbcon_par; - - if (!info->queue.func) - INIT_WORK(&info->queue, fb_flashcursor, info); - - init_timer(&ops->cursor_timer); - ops->cursor_timer.function = cursor_timer_handler; - ops->cursor_timer.expires = jiffies + HZ / 5; - ops->cursor_timer.data = (unsigned long ) info; - add_timer(&ops->cursor_timer); - } -} - static void con2fb_init_display(struct vc_data *vc, struct fb_info *info, int unit, int show_logo) { @@ -675,7 +706,7 @@ static int set_con2fb_map(int unit, int newidx, int user) logo_shown != FBCON_LOGO_DONTSHOW); if (!found) - con2fb_init_newinfo(info); + fbcon_add_cursor_timer(info); con2fb_map_boot[unit] = newidx; con2fb_init_display(vc, info, unit, show_logo); } @@ -878,18 +909,7 @@ static const char *fbcon_startup(void) } #endif /* CONFIG_MAC */ - /* Initialize the work queue. If the driver provides its - * own work queue this means it will use something besides - * default timer to flash the cursor. */ - if (!info->queue.func) { - INIT_WORK(&info->queue, fb_flashcursor, info); - - init_timer(&ops->cursor_timer); - ops->cursor_timer.function = cursor_timer_handler; - ops->cursor_timer.expires = jiffies + HZ / 5; - ops->cursor_timer.data = (unsigned long ) info; - add_timer(&ops->cursor_timer); - } + fbcon_add_cursor_timer(info); return display_desc; } @@ -930,7 +950,7 @@ static void fbcon_init(struct vc_data *vc, int init) } if (p->userfont) charcnt = FNTCHARCNT(p->fontdata); - vc->vc_can_do_color = (fb_get_color_depth(&info->var) != 1); + vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1); vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; if (charcnt == 256) { vc->vc_hi_font_mask = 0; @@ -1178,7 +1198,12 @@ static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var, if (p->userfont) charcnt = FNTCHARCNT(p->fontdata); - vc->vc_can_do_color = (fb_get_color_depth(var) != 1); + var->activate = FB_ACTIVATE_NOW; + info->var.activate = var->activate; + info->var.yoffset = info->var.xoffset = 0; + fb_set_var(info, var); + + vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1); vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; if (charcnt == 256) { vc->vc_hi_font_mask = 0; @@ -1898,7 +1923,7 @@ static int fbcon_resize(struct vc_data *vc, unsigned int width, static int fbcon_switch(struct vc_data *vc) { - struct fb_info *info; + struct fb_info *info, *old_info = NULL; struct display *p = &fb_display[vc->vc_num]; struct fb_var_screeninfo var; int i, prev_console; @@ -1931,7 +1956,8 @@ static int fbcon_switch(struct vc_data *vc) } prev_console = ((struct fbcon_ops *)info->fbcon_par)->currcon; - + if (prev_console != -1) + old_info = registered_fb[con2fb_map[prev_console]]; /* * FIXME: If we have multiple fbdev's loaded, we need to * update all info->currcon. Perhaps, we can place this @@ -1959,15 +1985,17 @@ static int fbcon_switch(struct vc_data *vc) info->var.yoffset = info->var.xoffset = p->yscroll = 0; fb_set_var(info, &var); - if (prev_console != -1 && - registered_fb[con2fb_map[prev_console]] != info && - info->fbops->fb_set_par) - info->fbops->fb_set_par(info); + if (old_info != NULL && old_info != info) { + if (info->fbops->fb_set_par) + info->fbops->fb_set_par(info); + fbcon_del_cursor_timer(old_info); + fbcon_add_cursor_timer(info); + } set_blitting_type(vc, info, p); ((struct fbcon_ops *)info->fbcon_par)->cursor_reset = 1; - vc->vc_can_do_color = (fb_get_color_depth(&info->var) != 1); + vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1); vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; updatescrollmode(p, info, vc); @@ -2048,11 +2076,16 @@ static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch) fbcon_generic_blank(vc, info, blank); } - if (!blank) - update_screen(vc); - } + if (!blank) + update_screen(vc); + } - return 0; + if (!blank) + fbcon_add_cursor_timer(info); + else + fbcon_del_cursor_timer(info); + + return 0; } static void fbcon_free_font(struct display *p) @@ -2332,7 +2365,7 @@ static int fbcon_set_palette(struct vc_data *vc, unsigned char *table) if (!CON_IS_VISIBLE(vc)) return 0; - depth = fb_get_color_depth(&info->var); + depth = fb_get_color_depth(&info->var, &info->fix); if (depth > 3) { for (i = j = 0; i < 16; i++) { k = table[i]; @@ -2593,6 +2626,51 @@ static void fbcon_modechanged(struct fb_info *info) } } +static void fbcon_set_all_vcs(struct fb_info *info) +{ + struct fbcon_ops *ops = info->fbcon_par; + struct vc_data *vc; + struct display *p; + int i, rows, cols; + + if (!ops || ops->currcon < 0) + return; + + for (i = 0; i < MAX_NR_CONSOLES; i++) { + vc = vc_cons[i].d; + if (!vc || vc->vc_mode != KD_TEXT || + registered_fb[con2fb_map[i]] != info) + continue; + + p = &fb_display[vc->vc_num]; + + info->var.xoffset = info->var.yoffset = p->yscroll = 0; + var_to_display(p, &info->var, info); + cols = info->var.xres / vc->vc_font.width; + rows = info->var.yres / vc->vc_font.height; + vc_resize(vc, cols, rows); + + if (CON_IS_VISIBLE(vc)) { + updatescrollmode(p, info, vc); + scrollback_max = 0; + scrollback_current = 0; + update_var(vc->vc_num, info); + fbcon_set_palette(vc, color_table); + update_screen(vc); + if (softback_buf) { + int l = fbcon_softback_size / vc->vc_size_row; + if (l > 5) + softback_end = softback_buf + l * vc->vc_size_row; + else { + /* Smaller scrollback makes no sense, and 0 + would screw the operation totally */ + softback_top = 0; + } + } + } + } +} + static int fbcon_mode_deleted(struct fb_info *info, struct fb_videomode *mode) { @@ -2708,6 +2786,9 @@ static int fbcon_event_notify(struct notifier_block *self, case FB_EVENT_MODE_CHANGE: fbcon_modechanged(info); break; + case FB_EVENT_MODE_CHANGE_ALL: + fbcon_set_all_vcs(info); + break; case FB_EVENT_MODE_DELETE: mode = event->data; ret = fbcon_mode_deleted(info, mode); diff --git a/drivers/video/console/fbcon.h b/drivers/video/console/fbcon.h index 5d377860bce..08befafe11d 100644 --- a/drivers/video/console/fbcon.h +++ b/drivers/video/console/fbcon.h @@ -18,7 +18,8 @@ #include <asm/io.h> -#define FBCON_FLAGS_INIT 1 +#define FBCON_FLAGS_INIT 1 +#define FBCON_FLAGS_CURSOR_TIMER 2 /* * This is the interface between the low-level console driver and the diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index d27fa91e588..0705cd74141 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -497,6 +497,57 @@ static void vgacon_cursor(struct vc_data *c, int mode) } } +static int vgacon_doresize(struct vc_data *c, + unsigned int width, unsigned int height) +{ + unsigned long flags; + unsigned int scanlines = height * c->vc_font.height; + u8 scanlines_lo, r7, vsync_end, mode; + + spin_lock_irqsave(&vga_lock, flags); + + outb_p(VGA_CRTC_MODE, vga_video_port_reg); + mode = inb_p(vga_video_port_val); + + if (mode & 0x04) + scanlines >>= 1; + + scanlines -= 1; + scanlines_lo = scanlines & 0xff; + + outb_p(VGA_CRTC_OVERFLOW, vga_video_port_reg); + r7 = inb_p(vga_video_port_val) & ~0x42; + + if (scanlines & 0x100) + r7 |= 0x02; + if (scanlines & 0x200) + r7 |= 0x40; + + /* deprotect registers */ + outb_p(VGA_CRTC_V_SYNC_END, vga_video_port_reg); + vsync_end = inb_p(vga_video_port_val); + outb_p(VGA_CRTC_V_SYNC_END, vga_video_port_reg); + outb_p(vsync_end & ~0x80, vga_video_port_val); + + outb_p(VGA_CRTC_H_DISP, vga_video_port_reg); + outb_p(width - 1, vga_video_port_val); + outb_p(VGA_CRTC_OFFSET, vga_video_port_reg); + outb_p(width >> 1, vga_video_port_val); + + outb_p(VGA_CRTC_V_DISP_END, vga_video_port_reg); + outb_p(scanlines_lo, vga_video_port_val); + outb_p(VGA_CRTC_OVERFLOW, vga_video_port_reg); + outb_p(r7,vga_video_port_val); + + /* reprotect registers */ + outb_p(VGA_CRTC_V_SYNC_END, vga_video_port_reg); + outb_p(vsync_end, vga_video_port_val); + + spin_unlock_irqrestore(&vga_lock, flags); + + return 0; +} + static int vgacon_switch(struct vc_data *c) { /* @@ -510,9 +561,13 @@ static int vgacon_switch(struct vc_data *c) /* We can only copy out the size of the video buffer here, * otherwise we get into VGA BIOS */ - if (!vga_is_gfx) + if (!vga_is_gfx) { scr_memcpyw((u16 *) c->vc_origin, (u16 *) c->vc_screenbuf, - c->vc_screenbuf_size > vga_vram_size ? vga_vram_size : c->vc_screenbuf_size); + c->vc_screenbuf_size > vga_vram_size ? + vga_vram_size : c->vc_screenbuf_size); + vgacon_doresize(c, c->vc_cols, c->vc_rows); + } + return 0; /* Redrawing not needed */ } @@ -962,6 +1017,17 @@ static int vgacon_font_get(struct vc_data *c, struct console_font *font) #endif +static int vgacon_resize(struct vc_data *c, unsigned int width, + unsigned int height) +{ + if (width % 2 || width > ORIG_VIDEO_COLS || height > ORIG_VIDEO_LINES) + return -EINVAL; + + if (CON_IS_VISIBLE(c) && !vga_is_gfx) /* who knows */ + vgacon_doresize(c, width, height); + return 0; +} + static int vgacon_scrolldelta(struct vc_data *c, int lines) { if (!lines) /* Turn scrollback off */ @@ -1103,6 +1169,7 @@ const struct consw vga_con = { .con_blank = vgacon_blank, .con_font_set = vgacon_font_set, .con_font_get = vgacon_font_get, + .con_resize = vgacon_resize, .con_set_palette = vgacon_set_palette, .con_scrolldelta = vgacon_scrolldelta, .con_set_origin = vgacon_set_origin, diff --git a/drivers/video/cyblafb.c b/drivers/video/cyblafb.c new file mode 100644 index 00000000000..ae2762cb560 --- /dev/null +++ b/drivers/video/cyblafb.c @@ -0,0 +1,1456 @@ +/* + * Frame buffer driver for Trident Cyberblade/i1 graphics core + * + * Copyright 2005 Knut Petersen <Knut_Petersen@t-online.de> + * + * CREDITS: + * tridentfb.c by Jani Monoses + * see files above for further credits + * + * TODO: + * + */ + +#define CYBLAFB_DEBUG 0 + +#include <linux/config.h> +#include <linux/module.h> +#include <linux/string.h> +#include <linux/fb.h> +#include <linux/init.h> +#include <linux/pci.h> +#include <asm/types.h> +#include <video/cyblafb.h> + +#define VERSION "0.54" + +struct cyblafb_par { + u32 pseudo_pal[16]; + struct fb_ops ops; +}; + +static struct fb_fix_screeninfo cyblafb_fix __devinitdata = { + .id = "CyBla", + .type = FB_TYPE_PACKED_PIXELS, + .ypanstep = 1, + .visual = FB_VISUAL_PSEUDOCOLOR, + .accel = FB_ACCEL_NONE, +}; + +static char *mode __devinitdata = NULL; +static int bpp __devinitdata = 8; +static int ref __devinitdata = 75; +static int fp __devinitdata; +static int crt __devinitdata; +static int memsize __devinitdata; +static int vesafb __devinitdata; + +static int nativex; +static int center; +static int stretch; +static int pciwb = 1; +static int pcirb = 1; +static int pciwr = 1; +static int pcirr = 1; +static int verbosity; +static int displaytype; + +static void __iomem * io_virt; // iospace virtual memory address + +module_param(mode,charp,0); +module_param(bpp,int,0); +module_param(ref,int,0); +module_param(fp,int,0); +module_param(crt,int,0); +module_param(nativex,int,0); +module_param(center,int,0); +module_param(stretch,int,0); +module_param(pciwb,int,0); +module_param(pcirb,int,0); +module_param(pciwr,int,0); +module_param(pcirr,int,0); +module_param(memsize,int,0); +module_param(verbosity,int,0); +module_param(vesafb,int,0); + +//========================================= +// +// Port access macros for memory mapped io +// +//========================================= + +#define out8(r,v) writeb(v,io_virt+r) +#define out32(r,v) writel(v,io_virt+r) +#define in8(r) readb(io_virt+r) +#define in32(r) readl(io_virt+r) + +//====================================== +// +// Hardware access inline functions +// +//====================================== + +static inline unsigned char read3X4(int reg) +{ + out8(0x3D4,reg); + return in8(0x3D5); +} + +static inline unsigned char read3C4(int reg) +{ + out8(0x3C4,reg); + return in8(0x3C5); +} + +static inline unsigned char read3CE(int reg) +{ + out8(0x3CE,reg); + return in8(0x3CF); +} + +static inline void write3X4(int reg,unsigned char val) +{ + out8(0x3D4,reg); + out8(0x3D5,val); +} + +static inline void write3C4(int reg,unsigned char val) +{ + out8(0x3C4,reg); + out8(0x3C5,val); +} + +static inline void write3CE(int reg,unsigned char val) +{ + out8(0x3CE,reg); + out8(0x3CF,val); +} + +static inline void write3C0(int reg,unsigned char val) +{ + in8(0x3DA); // read to reset index + out8(0x3C0,reg); + out8(0x3C0,val); +} + +//================================================= +// +// Enable memory mapped io and unprotect registers +// +//================================================= + +static inline void enable_mmio(void) +{ + int tmp; + + outb(0x0B,0x3C4); + inb(0x3C5); // Set NEW mode + outb(SR0E,0x3C4); // write enable a lot of extended ports + outb(0x80,0x3C5); + + outb(SR11,0x3C4); // write enable those extended ports that + outb(0x87,0x3C5); // are not affected by SR0E_New + + outb(CR1E,0x3d4); // clear write protect bit for port 0x3c2 + tmp=inb(0x3d5) & 0xBF; + outb(CR1E,0x3d4); + outb(tmp,0x3d5); + + outb(CR39,0x3D4); + outb(inb(0x3D5)|0x01,0x3D5); // Enable mmio, everything else untouched +} + +//================================================= +// +// Set pixel clock VCLK1 +// - multipliers set elswhere +// - freq in units of 0.01 MHz +// +//================================================= + +static void set_vclk(struct cyblafb_par *par, int freq) +{ + u32 m,n,k; + int f,fi,d,di; + u8 lo=0,hi=0; + + d = 2000; + k = freq >= 10000 ? 0 : freq >= 5000 ? 1 : freq >= 2500 ? 2 : 3; + for(m = 0;m<64;m++) + for(n = 0;n<250;n++) { // max 249 is a hardware limit for cybla/i1 ! + fi = (int)(((5864727*(n+8))/((m+2)*(1<<k)))>>12); + if ((di = abs(fi - freq)) < d) { + d = di; + f = fi; + lo = (u8) n; + hi = (u8) ((k<<6) | m); + } + } + write3C4(SR19,hi); + write3C4(SR18,lo); + if(verbosity > 1) + output("pixclock = %d.%02d MHz, k/m/n %x %x %x\n", + freq/100,freq%100,(hi&0xc0)>>6,hi&0x3f,lo); +} + +//================================================ +// +// Cyberblade specific Graphics Engine (GE) setup +// +//================================================ + +static void cyblafb_setup_GE(int pitch,int bpp) +{ + int base = (pitch>>3)<<20; + + switch (bpp) { + case 8: base |= (0<<29); break; + case 15: base |= (5<<29); break; + case 16: base |= (1<<29); break; + case 24: + case 32: base |= (2<<29); break; + } + + write3X4(CR36,0x90); // reset GE + write3X4(CR36,0x80); // enable GE + + out32(GE24,1<<7); // reset all GE pointers + out32(GE24,0); + + write3X4(CR2D,0x00); // GE Timinigs, no delays + + out32(GEB8,base); // Destination Stride / Buffer Base 0, p 133 + out32(GEBC,base); // Destination Stride / Buffer Base 1, p 133 + out32(GEC0,base); // Destination Stride / Buffer Base 2, p 133 + out32(GEC4,base); // Destination Stride / Buffer Base 3, p 133 + out32(GEC8,base); // Source Stride / Buffer Base 0, p 133 + out32(GECC,base); // Source Stride / Buffer Base 1, p 133 + out32(GED0,base); // Source Stride / Buffer Base 2, p 133 + out32(GED4,base); // Source Stride / Buffer Base 3, p 133 + out32(GE6C,0); // Pattern and Style, p 129, ok +} + +//===================================================================== +// +// Although this is a .fb_sync function that could be enabled in +// cyblafb_ops, we do not include it there. We sync immediately before +// new GE operations to improve performance. +// +//===================================================================== + +static int cyblafb_sync(struct fb_info *info) +{ + int status, i=100000; + while( ((status=in32(GE20)) & 0xFA800000) && i != 0) + i--; + + if (i == 0) { + // The timeout might be caused by disabled mmio. + // Cause: + // - bit CR39 & 1 == 0 upon return, X trident driver bug + // - kdm bug (KD_GRAPHICS not set on first switch) + // - kernel design flaw (it believes in the correctness + // of kdm/X + // So we make sure that mmio is enabled first ... + enable_mmio(); +// show_trace(NULL,&status); + i=1000000; + while( ((status=in32(GE20)) & 0xFA800000) && i != 0) + i--; + if (i == 0) { + output("GE Timeout, status: %x\n",status); + if(status & 0x80000000) + output("Bresenham Engine : Busy\n"); + if(status & 0x40000000) + output("Setup Engine : Busy\n"); + if(status & 0x20000000) + output("SP / DPE : Busy\n"); + if(status & 0x10000000) + output("Memory Interface : Busy\n"); + if(status & 0x08000000) + output("Com Lst Proc : Busy\n"); + if(status & 0x04000000) + output("Block Write : Busy\n"); + if(status & 0x02000000) + output("Command Buffer : Full\n"); + if(status & 0x01000000) + output("RESERVED : Busy\n"); + if(status & 0x00800000) + output("PCI Write Buffer : Busy\n"); + cyblafb_setup_GE(info->var.xres, + info->var.bits_per_pixel); + } + } + + return 0; +} + +//============================== +// +// Cyberblade specific fillrect +// +//============================== + +static void cyblafb_fillrect(struct fb_info * info, + const struct fb_fillrect *fr) +{ + int bpp = info->var.bits_per_pixel; + int col; + + switch (bpp) { + default: + case 8: col = fr->color; + col |= col <<8; + col |= col <<16; + break; + case 16: col = ((u32 *)(info->pseudo_palette))[fr->color]; + col |= col <<16; + break; + case 32: col = ((u32 *)(info->pseudo_palette))[fr->color]; + break; + } + + cyblafb_sync(info); + + out32(GE60,col); + out32(GE48,fr->rop ? 0x66:ROP_S); + out32(GE44,0x20000000|1<<19|1<<4|2<<2); + out32(GE08,point(fr->dx,fr->dy)); + out32(GE0C,point(fr->dx+fr->width-1,fr->dy+fr->height-1)); + +} + +//============================== +// +// Cyberblade specific copyarea +// +//============================== + +static void cyblafb_copyarea(struct fb_info *info, + const struct fb_copyarea *ca) +{ + __u32 s1,s2,d1,d2; + int direction; + + s1 = point(ca->sx,ca->sy); + s2 = point(ca->sx+ca->width-1,ca->sy+ca->height-1); + d1 = point(ca->dx,ca->dy); + d2 = point(ca->dx+ca->width-1,ca->dy+ca->height-1); + if ((ca->sy > ca->dy) || ((ca->sy == ca->dy) && (ca->sx > ca->dx))) + direction = 0; + else + direction = 2; + + cyblafb_sync(info); + + out32(GE44,0xa0000000|1<<19|1<<2|direction); + out32(GE00,direction?s2:s1); + out32(GE04,direction?s1:s2); + out32(GE08,direction?d2:d1); + out32(GE0C,direction?d1:d2); + +} + +//======================================================================= +// +// Cyberblade specific imageblit +// +// Accelerated for the most usual case, blitting 1-bit deep character +// character images. Everything else is passed to the generic imageblit. +// +//======================================================================= + +static void cyblafb_imageblit(struct fb_info *info, + const struct fb_image *image) +{ + + u32 fgcol, bgcol; + + int i; + int bpp = info->var.bits_per_pixel; + int index = 0; + int index_end=image->height * image->width / 8; + int width_dds=image->width / 32; + int width_dbs=image->width % 32; + + if (image->depth != 1 || bpp < 8 || bpp > 32 || bpp % 8 != 0 || + image->width % 8 != 0 || image->width == 0 || image->height == 0) { + cfb_imageblit(info,image); + return; + } + + if (info->fix.visual == FB_VISUAL_TRUECOLOR || + info->fix.visual == FB_VISUAL_DIRECTCOLOR) { + fgcol = ((u32*)(info->pseudo_palette))[image->fg_color]; + bgcol = ((u32*)(info->pseudo_palette))[image->bg_color]; + } else { + fgcol = image->fg_color; + bgcol = image->bg_color; + } + + switch (bpp) { + case 8: + fgcol |= fgcol <<8; fgcol |= fgcol <<16; + bgcol |= bgcol <<8; bgcol |= bgcol <<16; + break; + case 16: + fgcol |= fgcol <<16; + bgcol |= bgcol <<16; + break; + default: + break; + } + + cyblafb_sync(info); + + out32(GE60,fgcol); + out32(GE64,bgcol); + out32(GE44,0xa0000000 | 1<<20 | 1<<19); + out32(GE08,point(image->dx,image->dy)); + out32(GE0C,point(image->dx+image->width-1,image->dy+image->height-1)); + + while(index < index_end) { + for(i=0;i<width_dds;i++) { + out32(GE9C,*((u32*) ((u32)image->data + index))); + index+=4; + } + switch(width_dbs) { + case 0: break; + case 8: out32(GE9C,*((u8*)((u32)image->data+index))); + index+=1; + break; + case 16: out32(GE9C,*((u16*)((u32)image->data+index))); + index+=2; + break; + case 24: out32(GE9C,(u32)(*((u16*)((u32)image->data+index))) | + (u32)(*((u8*)((u32)image->data+index+2)))<<16); + index+=3; + break; + } + } +} + +//========================================================== +// +// Check if video mode is acceptable. We change var->??? if +// video mode is slightly off or return error otherwise. +// info->??? must not be changed! +// +//========================================================== + +static int cyblafb_check_var(struct fb_var_screeninfo *var, + struct fb_info *info) +{ + int bpp = var->bits_per_pixel; + int s,t,maxvyres; + + // + // we try to support 8, 16, 24 and 32 bpp modes, + // default to 8 + // + // there is a 24 bpp mode, but for now we change requests to 32 bpp + // (This is what tridentfb does ... will be changed in the future) + // + // + if ( bpp % 8 != 0 || bpp < 8 || bpp >32) + bpp = 8; + if (bpp == 24 ) + bpp = var->bits_per_pixel = 32; + + // + // interlaced modes are broken, fail if one is requested + // + if (var->vmode & FB_VMODE_INTERLACED) + return -EINVAL; + + // + // fail if requested resolution is higher than physical + // flatpanel resolution + // + if ((displaytype == DISPLAY_FP) && nativex && var->xres > nativex) + return -EINVAL; + + // + // xres != xres_virtual is broken, fail if such an + // unusual mode is requested + // + if (var->xres != var->xres_virtual) + return -EINVAL; + + // + // we do not allow vclk to exceed 230 MHz + // + if ((bpp==32 ? 200000000 : 100000000) / var->pixclock > 23000) + return -EINVAL; + + // + // calc max yres_virtual that would fit in memory + // and max yres_virtual that could be used for scrolling + // and use minimum of the results as maxvyres + // + // adjust vyres_virtual to maxvyres if necessary + // fail if requested yres is bigger than maxvyres + // + s = (0x1fffff / (var->xres * bpp/8)) + var->yres; + t = info->fix.smem_len / (var->xres * bpp/8); + maxvyres = t < s ? t : s; + if (maxvyres < var->yres_virtual) + var->yres_virtual=maxvyres; + if (maxvyres < var->yres) + return -EINVAL; + + switch (bpp) { + case 8: + var->red.offset = 0; + var->green.offset = 0; + var->blue.offset = 0; + var->red.length = 6; + var->green.length = 6; + var->blue.length = 6; + break; + case 16: + var->red.offset = 11; + var->green.offset = 5; + var->blue.offset = 0; + var->red.length = 5; + var->green.length = 6; + var->blue.length = 5; + break; + case 32: + var->red.offset = 16; + var->green.offset = 8; + var->blue.offset = 0; + var->red.length = 8; + var->green.length = 8; + var->blue.length = 8; + break; + default: + return -EINVAL; + } + + return 0; + +} + +//===================================================================== +// +// Pan the display +// +// The datasheets defines crt start address to be 20 bits wide and +// to be programmed to CR0C, CR0D, CR1E and CR27. Actually there is +// CR2B[5] as an undocumented extension bit. Epia BIOS 2.07 does use +// it, so it is also safe to be used here. BTW: datasheet CR0E on page +// 90 really is CR1E, the real CRE is documented on page 72. +// +//===================================================================== + +static int cyblafb_pan_display(struct fb_var_screeninfo *var, + struct fb_info *info) +{ + unsigned int offset; + + offset=(var->xoffset+(var->yoffset*var->xres))*var->bits_per_pixel/32; + info->var.xoffset = var->xoffset; + info->var.yoffset = var->yoffset; + + write3X4(CR0D,offset & 0xFF); + write3X4(CR0C,(offset & 0xFF00) >> 8); + write3X4(CR1E,(read3X4(CR1E) & 0xDF) | ((offset & 0x10000) >> 11)); + write3X4(CR27,(read3X4(CR27) & 0xF8) | ((offset & 0xE0000) >> 17)); + write3X4(CR2B,(read3X4(CR2B) & 0xDF) | ((offset & 0x100000) >> 15)); + + return 0; +} + +//============================================ +// +// This will really help in case of a bug ... +// dump most gaphics core registers. +// +//============================================ + +static void regdump(struct cyblafb_par *par) +{ + int i; + + if (verbosity < 2) + return; + + printk("\n"); + for(i=0; i<=0xff; i++) { + outb(i,0x3d4); + printk("CR%02x=%02x ",i,inb(0x3d5)); + if (i%16==15) + printk("\n"); + } + + outb(0x30,0x3ce); + outb(inb(0x3cf) | 0x40,0x3cf); + for(i=0; i<=0x1f; i++) { + if (i==0 || (i>2 && i<8) || i==0x10 || i==0x11 || i==0x16) { + outb(i,0x3d4); + printk("CR%02x=%02x ",i,inb(0x3d5)); + } else + printk("------- "); + if (i%16==15) + printk("\n"); + } + outb(0x30,0x3ce); + outb(inb(0x3cf) & 0xbf,0x3cf); + + printk("\n"); + for(i=0; i<=0x7f; i++) { + outb(i,0x3ce); + printk("GR%02x=%02x ",i,inb(0x3cf)); + if (i%16==15) + printk("\n"); + } + + printk("\n"); + for(i=0; i<=0xff; i++) { + outb(i,0x3c4); + printk("SR%02x=%02x ",i,inb(0x3c5)); + if (i%16==15) + printk("\n"); + } + + printk("\n"); + for(i=0; i <= 0x1F; i++) { + inb(0x3da); // next access is index! + outb(i,0x3c0); + printk("AR%02x=%02x ",i,inb(0x3c1)); + if (i%16==15) + printk("\n"); + } + printk("\n"); + + inb(0x3DA); // reset internal flag to 3c0 index + outb(0x20,0x3C0); // enable attr + + return; +} + +//====================================== +// +// Set hardware to requested video mode +// +//====================================== + +static int cyblafb_set_par(struct fb_info *info) +{ + struct cyblafb_par *par = info->par; + u32 + htotal,hdispend,hsyncstart,hsyncend,hblankstart,hblankend,preendfetch, + vtotal,vdispend,vsyncstart,vsyncend,vblankstart,vblankend; + struct fb_var_screeninfo *var = &info->var; + int bpp = var->bits_per_pixel; + int i; + + if (verbosity > 0) + output("Switching to new mode: " + "fbset -g %d %d %d %d %d -t %d %d %d %d %d %d %d\n", + var->xres,var->yres,var->xres_virtual, + var->yres_virtual,var->bits_per_pixel,var->pixclock, + var->left_margin,var->right_margin,var->upper_margin, + var->lower_margin,var->hsync_len,var->vsync_len); + + htotal = (var->xres + var->left_margin + var->right_margin + + var->hsync_len) / 8 - 5; + hdispend = var->xres/8 - 1; + hsyncstart = (var->xres + var->right_margin)/8; + hsyncend = var->hsync_len/8; + hblankstart = hdispend + 1; + hblankend = htotal + 3; // should be htotal + 5, bios does it this way + preendfetch = ((var->xres >> 3) + 1) * ((bpp+1) >> 3); + + vtotal = var->yres + var->upper_margin + var->lower_margin + + var->vsync_len - 2; + vdispend = var->yres - 1; + vsyncstart = var->yres + var->lower_margin; + vblankstart = var->yres; + vblankend = vtotal; // should be vtotal + 2, but bios does it this way + vsyncend = var->vsync_len; + + enable_mmio(); // necessary! ... check X ... + + write3X4(CR11,read3X4(CR11) & 0x7F); // unlock cr00 .. cr07 + + write3CE(GR30,8); + + if ((displaytype == DISPLAY_FP) && var->xres < nativex) { + + // stretch or center ? + + out8(0x3C2,0xEB); + + write3CE(GR30,read3CE(GR30) | 0x81); // shadow mode on + + if (center) { + write3CE(GR52,(read3CE(GR52) & 0x7C) | 0x80); + write3CE(GR53,(read3CE(GR53) & 0x7C) | 0x80); + } + else if (stretch) { + write3CE(GR5D,0); + write3CE(GR52,(read3CE(GR52) & 0x7C) | 1); + write3CE(GR53,(read3CE(GR53) & 0x7C) | 1); + } + + } else { + out8(0x3C2,0x2B); + write3CE(GR30,8); + } + + // + // Setup CRxx regs + // + + write3X4(CR00,htotal & 0xFF); + write3X4(CR01,hdispend & 0xFF); + write3X4(CR02,hblankstart & 0xFF); + write3X4(CR03,hblankend & 0x1F); + write3X4(CR04,hsyncstart & 0xFF); + write3X4(CR05,(hsyncend & 0x1F) | ((hblankend & 0x20)<<2)); + write3X4(CR06,vtotal & 0xFF); + write3X4(CR07,(vtotal & 0x100) >> 8 | + (vdispend & 0x100) >> 7 | + (vsyncstart & 0x100) >> 6 | + (vblankstart & 0x100) >> 5 | + 0x10 | + (vtotal & 0x200) >> 4 | + (vdispend & 0x200) >> 3 | + (vsyncstart & 0x200) >> 2); + write3X4(CR08,0); + write3X4(CR09,(vblankstart & 0x200) >> 4 | 0x40 | // FIX !!! + ((info->var.vmode & FB_VMODE_DOUBLE) ? 0x80 : 0)); + write3X4(CR0A,0); // Init to some reasonable default + write3X4(CR0B,0); // Init to some reasonable default + write3X4(CR0C,0); // Offset 0 + write3X4(CR0D,0); // Offset 0 + write3X4(CR0E,0); // Init to some reasonable default + write3X4(CR0F,0); // Init to some reasonable default + write3X4(CR10,vsyncstart & 0xFF); + write3X4(CR11,(vsyncend & 0x0F)); + write3X4(CR12,vdispend & 0xFF); + write3X4(CR13,((info->var.xres * bpp)/(4*16)) & 0xFF); + write3X4(CR14,0x40); // double word mode + write3X4(CR15,vblankstart & 0xFF); + write3X4(CR16,vblankend & 0xFF); + write3X4(CR17,0xC3); + write3X4(CR18,0xFF); + // CR19: needed for interlaced modes ... ignore it for now + write3X4(CR1A,0x07); // Arbitration Control Counter 1 + write3X4(CR1B,0x07); // Arbitration Control Counter 2 + write3X4(CR1C,0x07); // Arbitration Control Counter 3 + write3X4(CR1D,0x00); // Don't know, doesn't hurt ;-) + write3X4(CR1E,(info->var.vmode & FB_VMODE_INTERLACED) ? 0x84 : 0x80); + // CR1F: do not set, contains BIOS info about memsize + write3X4(CR20,0x20); // enabe wr buf, disable 16bit planar mode + write3X4(CR21,0x20); // enable linear memory access + // CR22: RO cpu latch readback + // CR23: ??? + // CR24: RO AR flag state + // CR25: RAMDAC rw timing, pclk buffer tristate control ???? + // CR26: ??? + write3X4(CR27,(vdispend & 0x400) >> 6 | + (vsyncstart & 0x400) >> 5 | + (vblankstart & 0x400) >> 4 | + (vtotal & 0x400) >> 3 | + 0x8); + // CR28: ??? + write3X4(CR29,(read3X4(CR29) & 0xCF) | + ((((info->var.xres * bpp) / (4*16)) & 0x300) >>4)); + write3X4(CR2A,read3X4(CR2A) | 0x40); + write3X4(CR2B,(htotal & 0x100) >> 8 | + (hdispend & 0x100) >> 7 | + // (0x00 & 0x100) >> 6 | hinterlace para bit 8 ??? + (hsyncstart & 0x100) >> 5 | + (hblankstart & 0x100) >> 4); + // CR2C: ??? + // CR2D: initialized in cyblafb_setup_GE() + write3X4(CR2F,0x92); // conservative, better signal quality + // CR30: reserved + // CR31: reserved + // CR32: reserved + // CR33: reserved + // CR34: disabled in CR36 + // CR35: disabled in CR36 + // CR36: initialized in cyblafb_setup_GE + // CR37: i2c, ignore for now + write3X4(CR38,(bpp == 8) ? 0x00 : // + (bpp == 16) ? 0x05 : // highcolor + (bpp == 24) ? 0x29 : // packed 24bit truecolor + (bpp == 32) ? 0x09 : 0); // truecolor, 16 bit pixelbus + write3X4(CR39,0x01 | // MMIO enable + (pcirb ? 0x02 : 0) | // pci read burst enable + (pciwb ? 0x04 : 0)); // pci write burst enable + write3X4(CR55,0x1F | // pci clocks * 2 for STOP# during 1st data phase + (pcirr ? 0x40 : 0) | // pci read retry enable + (pciwr ? 0x80 : 0)); // pci write retry enable + write3X4(CR56,preendfetch >> 8 < 2 ? (preendfetch >> 8 & 0x01)|2 : 0); + write3X4(CR57,preendfetch >> 8 < 2 ? preendfetch & 0xff : 0); + write3X4(CR58,0x82); // Bios does this .... don't know more + // + // Setup SRxx regs + // + write3C4(SR00,3); + write3C4(SR01,1); //set char clock 8 dots wide + write3C4(SR02,0x0F); //enable 4 maps needed in chain4 mode + write3C4(SR03,0); //no character map select + write3C4(SR04,0x0E); //memory mode: ext mem, even, chain4 + + out8(0x3C4,0x0b); + in8(0x3C5); // Set NEW mode + write3C4(SR0D,0x00); // test ... check + + set_vclk(par,(bpp==32 ? 200000000 : 100000000)/ + info->var.pixclock); //SR18,SR19 + + // + // Setup GRxx regs + // + write3CE(GR00,0x00); // test ... check + write3CE(GR01,0x00); // test ... check + write3CE(GR02,0x00); // test ... check + write3CE(GR03,0x00); // test ... check + write3CE(GR04,0x00); // test ... check + write3CE(GR05,0x40); // no CGA compat,allow 256 col + write3CE(GR06,0x05); // graphics mode + write3CE(GR07,0x0F); // planes? + write3CE(GR08,0xFF); // test ... check + write3CE(GR0F,(bpp==32)?0x1A:0x12); // div vclk by 2 if 32bpp, chain4 + write3CE(GR20,0xC0); // test ... check + write3CE(GR2F,0xA0); // PCLK = VCLK, no skew, + + // + // Setup ARxx regs + // + for(i = 0;i < 0x10;i++) // set AR00 .. AR0f + write3C0(i,i); + write3C0(AR10,0x41); // graphics mode and support 256 color modes + write3C0(AR12,0x0F); // planes + write3C0(AR13,0); // horizontal pel panning + in8(0x3DA); // reset internal flag to 3c0 index + out8(0x3C0,0x20); // enable attr + + // + // Setup hidden RAMDAC command register + // + in8(0x3C8); // these reads are + in8(0x3C6); // necessary to + in8(0x3C6); // unmask the RAMDAC + in8(0x3C6); // command reg, otherwise + in8(0x3C6); // we would write the pixelmask reg! + out8(0x3C6,(bpp == 8) ? 0x00 : // 256 colors + (bpp == 15) ? 0x10 : // + (bpp == 16) ? 0x30 : // hicolor + (bpp == 24) ? 0xD0 : // truecolor + (bpp == 32) ? 0xD0 : 0); // truecolor + in8(0x3C8); + + // + // GR31 is not mentioned in the datasheet + // + if (displaytype == DISPLAY_FP) + write3CE(GR31,(read3CE(GR31) & 0x8F) | + ((info->var.yres > 1024) ? 0x50 : + (info->var.yres > 768) ? 0x30 : + (info->var.yres > 600) ? 0x20 : + (info->var.yres > 480) ? 0x10 : 0)); + + info->fix.visual = (bpp == 8) ? FB_VISUAL_PSEUDOCOLOR + : FB_VISUAL_TRUECOLOR; + info->fix.line_length = info->var.xres * (bpp >> 3); + info->cmap.len = (bpp == 8) ? 256: 16; + + // + // init acceleration engine + // + cyblafb_setup_GE(info->var.xres,info->var.bits_per_pixel); + + regdump(par); + + return 0; +} + +//======================== +// +// Set one color register +// +//======================== + +static int cyblafb_setcolreg(unsigned regno, unsigned red, unsigned green, + unsigned blue, unsigned transp, + struct fb_info *info) +{ + int bpp = info->var.bits_per_pixel; + + if (regno >= info->cmap.len) + return 1; + + if (bpp == 8) { + out8(0x3C6,0xFF); + out8(0x3C8,regno); + out8(0x3C9,red>>10); + out8(0x3C9,green>>10); + out8(0x3C9,blue>>10); + + } else if (bpp == 16) // RGB 565 + ((u32*)info->pseudo_palette)[regno] = + (red & 0xF800) | + ((green & 0xFC00) >> 5) | + ((blue & 0xF800) >> 11); + else if (bpp == 32) // ARGB 8888 + ((u32*)info->pseudo_palette)[regno] = + ((transp & 0xFF00) <<16) | + ((red & 0xFF00) << 8) | + ((green & 0xFF00)) | + ((blue & 0xFF00)>>8); + + return 0; +} + +//========================================================== +// +// Try blanking the screen. For flat panels it does nothing +// +//========================================================== + +static int cyblafb_blank(int blank_mode, struct fb_info *info) +{ + unsigned char PMCont,DPMSCont; + + if (displaytype == DISPLAY_FP) + return 0; + + out8(0x83C8,0x04); // DPMS Control + PMCont = in8(0x83C6) & 0xFC; + + DPMSCont = read3CE(GR23) & 0xFC; + + switch (blank_mode) + { + case FB_BLANK_UNBLANK: // Screen: On, HSync: On, VSync: On + case FB_BLANK_NORMAL: // Screen: Off, HSync: On, VSync: On + PMCont |= 0x03; + DPMSCont |= 0x00; + break; + case FB_BLANK_HSYNC_SUSPEND: // Screen: Off, HSync: Off, VSync: On + PMCont |= 0x02; + DPMSCont |= 0x01; + break; + case FB_BLANK_VSYNC_SUSPEND: // Screen: Off, HSync: On, VSync: Off + PMCont |= 0x02; + DPMSCont |= 0x02; + break; + case FB_BLANK_POWERDOWN: // Screen: Off, HSync: Off, VSync: Off + PMCont |= 0x00; + DPMSCont |= 0x03; + break; + } + + write3CE(GR23,DPMSCont); + out8(0x83C8,4); + out8(0x83C6,PMCont); + // + // let fbcon do a softblank for us + // + return (blank_mode == FB_BLANK_NORMAL) ? 1 : 0; +} + +static struct fb_ops cyblafb_ops __devinitdata = { + .owner = THIS_MODULE, + .fb_setcolreg = cyblafb_setcolreg, + .fb_pan_display = cyblafb_pan_display, + .fb_blank = cyblafb_blank, + .fb_check_var = cyblafb_check_var, + .fb_set_par = cyblafb_set_par, + .fb_fillrect = cyblafb_fillrect, + .fb_copyarea= cyblafb_copyarea, + .fb_imageblit = cyblafb_imageblit, + .fb_cursor = soft_cursor, +}; + +//========================================================================== +// +// getstartupmode() decides about the inital video mode +// +// There is no reason to use modedb, a lot of video modes there would +// need altered timings to display correctly. So I decided that it is much +// better to provide a limited optimized set of modes plus the option of +// using the mode in effect at startup time (might be selected using the +// vga=??? paramter). After that the user might use fbset to select any +// mode he likes, check_var will not try to alter geometry parameters as +// it would be necessary otherwise. +// +//========================================================================== + +static int __devinit getstartupmode(struct fb_info *info) +{ + u32 htotal,hdispend,hsyncstart,hsyncend,hblankstart,hblankend, + vtotal,vdispend,vsyncstart,vsyncend,vblankstart,vblankend, + cr00,cr01,cr02,cr03,cr04,cr05,cr2b, + cr06,cr07,cr09,cr10,cr11,cr12,cr15,cr16,cr27, + cr38, + sr0d,sr18,sr19, + gr0f, + fi,pxclkdiv,vclkdiv,tmp,i; + + struct modus { + int xres; int yres; int vyres; int bpp; int pxclk; + int left_margin; int right_margin; int upper_margin; + int lower_margin; int hsync_len; int vsync_len; + } modedb[5] = { + { 0, 0, 8000, 0, 0, 0, 0, 0, 0, 0, 0}, + { 640, 480, 3756, 0, 0, -40, 24, 17, 0, 216, 3}, + { 800, 600, 3221, 0, 0, 96, 24, 14, 0, 136, 11}, + {1024, 768, 2815, 0, 0, 144, 24, 29, 0, 120, 3}, + {1280, 1024, 2662, 0, 0, 232, 16, 39, 0, 160, 3} + }; + + outb(0x00,0x3d4); cr00=inb(0x3d5); outb(0x01,0x3d4); cr01=inb(0x3d5); + outb(0x02,0x3d4); cr02=inb(0x3d5); outb(0x03,0x3d4); cr03=inb(0x3d5); + outb(0x04,0x3d4); cr04=inb(0x3d5); outb(0x05,0x3d4); cr05=inb(0x3d5); + outb(0x06,0x3d4); cr06=inb(0x3d5); outb(0x07,0x3d4); cr07=inb(0x3d5); + outb(0x09,0x3d4); cr09=inb(0x3d5); outb(0x10,0x3d4); cr10=inb(0x3d5); + outb(0x11,0x3d4); cr11=inb(0x3d5); outb(0x12,0x3d4); cr12=inb(0x3d5); + outb(0x15,0x3d4); cr15=inb(0x3d5); outb(0x16,0x3d4); cr16=inb(0x3d5); + outb(0x27,0x3d4); cr27=inb(0x3d5); outb(0x2b,0x3d4); cr2b=inb(0x3d5); + outb(0x38,0x3d4); cr38=inb(0x3d5); outb(0x0b,0x3c4); inb(0x3c5); + outb(0x0d,0x3c4); sr0d=inb(0x3c5); outb(0x18,0x3c4); sr18=inb(0x3c5); + outb(0x19,0x3c4); sr19=inb(0x3c5); outb(0x0f,0x3ce); gr0f=inb(0x3cf); + + htotal = cr00 | (cr2b & 0x01) << 8; + hdispend = cr01 | (cr2b & 0x02) << 7; + hblankstart = cr02 | (cr2b & 0x10) << 4; + hblankend = (cr03 & 0x1f) | (cr05 & 0x80) >> 2; + hsyncstart = cr04 | (cr2b & 0x08) << 5; + hsyncend = cr05 & 0x1f; + + modedb[0].xres = hblankstart * 8; + modedb[0].hsync_len = hsyncend * 8; + modedb[0].right_margin = hsyncstart * 8 - modedb[0].xres; + modedb[0].left_margin = (htotal + 5) * 8 - modedb[0].xres - + modedb[0].right_margin - modedb[0].hsync_len; + + vtotal = cr06 | (cr07 & 0x01) << 8 | (cr07 & 0x20) << 4 + | (cr27 & 0x80) << 3; + vdispend = cr12 | (cr07 & 0x02) << 7 | (cr07 & 0x40) << 3 + | (cr27 & 0x10) << 6; + vsyncstart = cr10 | (cr07 & 0x04) << 6 | (cr07 & 0x80) << 2 + | (cr27 & 0x20) << 5; + vsyncend = cr11 & 0x0f; + vblankstart = cr15 | (cr07 & 0x08) << 5 | (cr09 & 0x20) << 4 + | (cr27 & 0x40) << 4; + vblankend = cr16; + + modedb[0].yres = vdispend + 1; + modedb[0].vsync_len = vsyncend; + modedb[0].lower_margin = vsyncstart - modedb[0].yres; + modedb[0].upper_margin = vtotal - modedb[0].yres - + modedb[0].lower_margin - modedb[0].vsync_len + 2; + + tmp = cr38 & 0x3c; + modedb[0].bpp = tmp == 0 ? 8 : tmp == 4 ? 16 : tmp == 28 ? 24 : + tmp == 8 ? 32 : 8; + + fi = ((5864727*(sr18+8))/(((sr19&0x3f)+2)*(1<<((sr19&0xc0)>>6))))>>12; + pxclkdiv = ((gr0f & 0x08) >> 3 | (gr0f & 0x40) >> 5) + 1; + tmp = sr0d & 0x06; + vclkdiv = tmp == 0 ? 2 : tmp == 2 ? 4 : tmp == 4 ? 8 : 3; // * 2 ! + modedb[0].pxclk = ((100000000 * pxclkdiv * vclkdiv) >> 1) / fi; + + if (verbosity > 0) + output("detected startup mode: " + "fbset -g %d %d %d ??? %d -t %d %d %d %d %d %d %d\n", + modedb[0].xres,modedb[0].yres,modedb[0].xres, + modedb[0].bpp,modedb[0].pxclk,modedb[0].left_margin, + modedb[0].right_margin,modedb[0].upper_margin, + modedb[0].lower_margin,modedb[0].hsync_len, + modedb[0].vsync_len); + + // + // We use this goto target in case of a failed check_var. No, I really + // do not want to do it in another way! + // + + tryagain: + + i = (mode == NULL) ? 0 : + !strncmp(mode,"640x480",7) ? 1 : + !strncmp(mode,"800x600",7) ? 2 : + !strncmp(mode,"1024x768",8) ? 3 : + !strncmp(mode,"1280x1024",9) ? 4 : 0; + + ref = (ref < 50) ? 50 : (ref > 85) ? 85 : ref; + + if(i==0) { + info->var.pixclock = modedb[i].pxclk; + info->var.bits_per_pixel = modedb[i].bpp; + } else { + info->var.pixclock = (100000000 / + ((modedb[i].left_margin + modedb[i].xres + + modedb[i].right_margin + modedb[i].hsync_len + ) * ( + modedb[i].upper_margin + modedb[i].yres + + modedb[i].lower_margin + modedb[i].vsync_len + ) * + ref / 10000 + )); + info->var.bits_per_pixel = bpp; + } + + info->var.left_margin = modedb[i].left_margin; + info->var.right_margin = modedb[i].right_margin; + info->var.xres = modedb[i].xres; + info->var.xres_virtual = modedb[i].xres; + info->var.xoffset = 0; + info->var.hsync_len = modedb[i].hsync_len; + info->var.upper_margin = modedb[i].upper_margin; + info->var.yres = modedb[i].yres; + info->var.yres_virtual = modedb[i].vyres; + info->var.yoffset = 0; + info->var.lower_margin = modedb[i].lower_margin; + info->var.vsync_len = modedb[i].vsync_len; + info->var.sync = 0; + info->var.vmode = FB_VMODE_NONINTERLACED; + + if(cyblafb_check_var(&info->var,info)) { + // 640x480-8@75 should really never fail. One case would + // be fp == 1 and nativex < 640 ... give up then + if(i==1 && bpp == 8 && ref == 75){ + output("Can't find a valid mode :-(\n"); + return -EINVAL; + } + // Our detected mode is unlikely to fail. If it does, + // try 640x480-8@75 ... + if(i==0) { + mode="640x480"; + bpp=8; + ref=75; + output("Detected mode failed check_var! " + "Trying 640x480-8@75\n"); + goto tryagain; + } + // A specified video mode failed for some reason. + // Try the startup mode first + output("Specified mode '%s' failed check! " + "Falling back to startup mode.\n",mode); + mode=NULL; + goto tryagain; + } + + return 0; + +} + +//======================================================== +// +// Detect activated memory size. Undefined values require +// memsize parameter. +// +//======================================================== + +static unsigned int __devinit get_memsize(void) +{ + unsigned char tmp; + unsigned int k; + + if (memsize) + k = memsize * Kb; + else { + tmp = read3X4(CR1F) & 0x0F; + switch (tmp) { + case 0x03: k = 1 * Mb; break; + case 0x07: k = 2 * Mb; break; + case 0x0F: k = 4 * Mb; break; + case 0x04: k = 8 * Mb; break; + default: + k = 1 * Mb; + output("Unknown memory size code %x in CR1F." + " We default to 1 Mb for now, please" + " do provide a memsize parameter!\n", + tmp); + } + } + + if (verbosity > 0) + output("framebuffer size = %d Kb\n",k/Kb); + return k; +} + +//========================================================= +// +// Detect if a flat panel monitor connected to the special +// interface is active. Override is possible by fp and crt +// parameters. +// +//========================================================= + +static unsigned int __devinit get_displaytype(void) +{ + if (fp) + return DISPLAY_FP; + if (crt) + return DISPLAY_CRT; + return (read3CE(GR33) & 0x10)?DISPLAY_FP:DISPLAY_CRT; +} + +//===================================== +// +// Get native resolution of flat panel +// +//===================================== + +static int __devinit get_nativex(void) +{ + int x,y,tmp; + + if (nativex) + return nativex; + + tmp = (read3CE(GR52) >> 4) & 3; + + switch (tmp) { + case 0: x = 1280; y = 1024; break; + case 2: x = 1024; y = 768; break; + case 3: x = 800; y = 600; break; + case 4: x = 1400; y = 1050; break; + case 1: + default: x = 640; y = 480; break; + } + + if (verbosity > 0) + output("%dx%d flat panel found\n",x,y); + return x; +} + +static int __devinit cybla_pci_probe(struct pci_dev * dev, + const struct pci_device_id * id) +{ + struct fb_info *info; + struct cyblafb_par *par; + + info = framebuffer_alloc(sizeof(struct cyblafb_par),&dev->dev); + + if (!info) + goto errout_alloc; + + par = info->par; + par->ops = cyblafb_ops; + + info->fix = cyblafb_fix; + info->fbops = &par->ops; + info->fix = cyblafb_fix; + + if (pci_enable_device(dev)) { + output("could not enable device!\n"); + goto errout_enable; + } + + // might already be requested by vga console or vesafb, + // so we do care about success + request_region(0x3c0,32,"cyblafb"); + + // + // Graphics Engine Registers + // + request_region(GEBase,0x100,"cyblafb"); + + regdump(par); + + enable_mmio(); + + // setup MMIO region + info->fix.mmio_start = pci_resource_start(dev,1); + info->fix.mmio_len = 0x20000; + + if (!request_mem_region(info->fix.mmio_start, + info->fix.mmio_len,"cyblafb")) { + output("request_mem_region failed for mmio region!\n"); + goto errout_mmio_reqmem; + } + + io_virt = ioremap_nocache(info->fix.mmio_start, info->fix.mmio_len); + + if (!io_virt) { + output("ioremap failed for mmio region\n"); + goto errout_mmio_remap; + } + + // setup framebuffer memory ... might already be requested + // by vesafb. Not to fail in case of an unsuccessful request + // is useful for the development cycle + info->fix.smem_start = pci_resource_start(dev,0); + info->fix.smem_len = get_memsize(); + + if (!request_mem_region(info->fix.smem_start, + info->fix.smem_len,"cyblafb")) { + output("request_mem_region failed for smem region!\n"); + if (!vesafb) + goto errout_smem_req; + } + + info->screen_base = ioremap_nocache(info->fix.smem_start, + info->fix.smem_len); + + if (!info->screen_base) { + output("ioremap failed for smem region\n"); + goto errout_smem_remap; + } + + displaytype = get_displaytype(); + + if(displaytype == DISPLAY_FP) + nativex = get_nativex(); + + // + // FBINFO_HWACCEL_YWRAP .... does not work (could be made to work?) + // FBINFO_PARTIAL_PAN_OK .... is not ok + // FBINFO_READS_FAST .... is necessary for optimal scrolling + // + info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN + | FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT + | FBINFO_HWACCEL_IMAGEBLIT | FBINFO_READS_FAST; + + info->pseudo_palette = par->pseudo_pal; + + if(getstartupmode(info)) + goto errout_findmode; + + fb_alloc_cmap(&info->cmap,256,0); + + if (register_framebuffer(info)) { + output("Could not register CyBla framebuffer\n"); + goto errout_register; + } + + pci_set_drvdata(dev,info); + + // + // normal exit and error paths + // + + return 0; + + errout_register: + errout_findmode: + iounmap(info->screen_base); + errout_smem_remap: + release_mem_region(info->fix.smem_start, + info->fix.smem_len); + errout_smem_req: + iounmap(io_virt); + errout_mmio_remap: + release_mem_region(info->fix.mmio_start, + info->fix.mmio_len); + errout_mmio_reqmem: +// release_region(0x3c0,32); + errout_enable: + framebuffer_release(info); + errout_alloc: + output("CyblaFB version %s aborting init.\n",VERSION); + return -ENODEV; +} + +static void __devexit cybla_pci_remove(struct pci_dev *dev) +{ + struct fb_info *info = pci_get_drvdata(dev); + + unregister_framebuffer(info); + iounmap(io_virt); + iounmap(info->screen_base); + release_mem_region(info->fix.smem_start,info->fix.smem_len); + release_mem_region(info->fix.mmio_start,info->fix.mmio_len); + fb_dealloc_cmap(&info->cmap); + framebuffer_release(info); + output("CyblaFB version %s normal exit.\n",VERSION); +} + +// +// List of boards that we are trying to support +// +static struct pci_device_id cybla_devices[] = { + {PCI_VENDOR_ID_TRIDENT,CYBERBLADEi1,PCI_ANY_ID,PCI_ANY_ID,0,0,0}, + {0,} +}; + +MODULE_DEVICE_TABLE(pci,cybla_devices); + +static struct pci_driver cyblafb_pci_driver = { + .name = "cyblafb", + .id_table = cybla_devices, + .probe = cybla_pci_probe, + .remove = __devexit_p(cybla_pci_remove) +}; + +//============================================================= +// +// kernel command line example: +// +// video=cyblafb:1280x1024,bpp=16,ref=50 ... +// +// modprobe command line example: +// +// modprobe cyblafb mode=1280x1024 bpp=16 ref=50 ... +// +//============================================================= + +static int __devinit cyblafb_init(void) +{ +#ifndef MODULE + char *options = NULL; + char *opt; + + if (fb_get_options("cyblafb",&options)) + return -ENODEV; + + if (options && *options) + while((opt = strsep(&options,",")) != NULL ) { + if (!*opt) continue; + else if (!strncmp(opt,"bpp=",4)) + bpp = simple_strtoul(opt+4,NULL,0); + else if (!strncmp(opt,"ref=",4)) + ref = simple_strtoul(opt+4,NULL,0); + else if (!strncmp(opt,"fp",2)) + displaytype = DISPLAY_FP; + else if (!strncmp(opt,"crt",3)) + displaytype = DISPLAY_CRT; + else if (!strncmp(opt,"nativex=",8)) + nativex = simple_strtoul(opt+8,NULL,0); + else if (!strncmp(opt,"center",6)) + center = 1; + else if (!strncmp(opt,"stretch",7)) + stretch = 1; + else if (!strncmp(opt,"pciwb=",6)) + pciwb = simple_strtoul(opt+6,NULL,0); + else if (!strncmp(opt,"pcirb=",6)) + pcirb = simple_strtoul(opt+6,NULL,0); + else if (!strncmp(opt,"pciwr=",6)) + pciwr = simple_strtoul(opt+6,NULL,0); + else if (!strncmp(opt,"pcirr=",6)) + pcirr = simple_strtoul(opt+6,NULL,0); + else if (!strncmp(opt,"memsize=",8)) + memsize = simple_strtoul(opt+8,NULL,0); + else if (!strncmp(opt,"verbosity=",10)) + verbosity = simple_strtoul(opt+10,NULL,0); + else if (!strncmp(opt,"vesafb",6)) + vesafb = 1; + else + mode = opt; + } +#endif + output("CyblaFB version %s initializing\n",VERSION); + return pci_module_init(&cyblafb_pci_driver); +} + +static void __exit cyblafb_exit(void) +{ + pci_unregister_driver(&cyblafb_pci_driver); +} + +module_init(cyblafb_init); +module_exit(cyblafb_exit); + +MODULE_AUTHOR("Knut Petersen <knut_petersen@t-online.de>"); +MODULE_DESCRIPTION("Framebuffer driver for Cyberblade/i1 graphics core"); +MODULE_LICENSE("GPL"); diff --git a/drivers/video/fbcvt.c b/drivers/video/fbcvt.c new file mode 100644 index 00000000000..cfa61b512de --- /dev/null +++ b/drivers/video/fbcvt.c @@ -0,0 +1,380 @@ +/* + * linux/drivers/video/fbcvt.c - VESA(TM) Coordinated Video Timings + * + * Copyright (C) 2005 Antonino Daplas <adaplas@pol.net> + * + * Based from the VESA(TM) Coordinated Video Timing Generator by + * Graham Loveridge April 9, 2003 available at + * http://www.vesa.org/public/CVT/CVTd6r1.xls + * + * 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/fb.h> + +#define FB_CVT_CELLSIZE 8 +#define FB_CVT_GTF_C 40 +#define FB_CVT_GTF_J 20 +#define FB_CVT_GTF_K 128 +#define FB_CVT_GTF_M 600 +#define FB_CVT_MIN_VSYNC_BP 550 +#define FB_CVT_MIN_VPORCH 3 +#define FB_CVT_MIN_BPORCH 6 + +#define FB_CVT_RB_MIN_VBLANK 460 +#define FB_CVT_RB_HBLANK 160 +#define FB_CVT_RB_V_FPORCH 3 + +#define FB_CVT_FLAG_REDUCED_BLANK 1 +#define FB_CVT_FLAG_MARGINS 2 +#define FB_CVT_FLAG_INTERLACED 4 + +struct fb_cvt_data { + u32 xres; + u32 yres; + u32 refresh; + u32 f_refresh; + u32 pixclock; + u32 hperiod; + u32 hblank; + u32 hfreq; + u32 htotal; + u32 vtotal; + u32 vsync; + u32 hsync; + u32 h_front_porch; + u32 h_back_porch; + u32 v_front_porch; + u32 v_back_porch; + u32 h_margin; + u32 v_margin; + u32 interlace; + u32 aspect_ratio; + u32 active_pixels; + u32 flags; + u32 status; +}; + +static int fb_cvt_vbi_tab[] = { + 4, /* 4:3 */ + 5, /* 16:9 */ + 6, /* 16:10 */ + 7, /* 5:4 */ + 7, /* 15:9 */ + 8, /* reserved */ + 9, /* reserved */ + 10 /* custom */ +}; + +/* returns hperiod * 1000 */ +static u32 fb_cvt_hperiod(struct fb_cvt_data *cvt) +{ + u32 num = 1000000000/cvt->f_refresh; + u32 den; + + if (cvt->flags & FB_CVT_FLAG_REDUCED_BLANK) { + num -= FB_CVT_RB_MIN_VBLANK * 1000; + den = 2 * (cvt->yres/cvt->interlace + 2 * cvt->v_margin); + } else { + num -= FB_CVT_MIN_VSYNC_BP * 1000; + den = 2 * (cvt->yres/cvt->interlace + cvt->v_margin * 2 + + FB_CVT_MIN_VPORCH + cvt->interlace/2); + } + + return 2 * (num/den); +} + +/* returns ideal duty cycle * 1000 */ +static u32 fb_cvt_ideal_duty_cycle(struct fb_cvt_data *cvt) +{ + u32 c_prime = (FB_CVT_GTF_C - FB_CVT_GTF_J) * + (FB_CVT_GTF_K) + 256 * FB_CVT_GTF_J; + u32 m_prime = (FB_CVT_GTF_K * FB_CVT_GTF_M); + u32 h_period_est = cvt->hperiod; + + return (1000 * c_prime - ((m_prime * h_period_est)/1000))/256; +} + +static u32 fb_cvt_hblank(struct fb_cvt_data *cvt) +{ + u32 hblank = 0; + + if (cvt->flags & FB_CVT_FLAG_REDUCED_BLANK) + hblank = FB_CVT_RB_HBLANK; + else { + u32 ideal_duty_cycle = fb_cvt_ideal_duty_cycle(cvt); + u32 active_pixels = cvt->active_pixels; + + if (ideal_duty_cycle < 20000) + hblank = (active_pixels * 20000)/ + (100000 - 20000); + else { + hblank = (active_pixels * ideal_duty_cycle)/ + (100000 - ideal_duty_cycle); + } + } + + hblank &= ~((2 * FB_CVT_CELLSIZE) - 1); + + return hblank; +} + +static u32 fb_cvt_hsync(struct fb_cvt_data *cvt) +{ + u32 hsync; + + if (cvt->flags & FB_CVT_FLAG_REDUCED_BLANK) + hsync = 32; + else + hsync = (FB_CVT_CELLSIZE * cvt->htotal)/100; + + hsync &= ~(FB_CVT_CELLSIZE - 1); + return hsync; +} + +static u32 fb_cvt_vbi_lines(struct fb_cvt_data *cvt) +{ + u32 vbi_lines, min_vbi_lines, act_vbi_lines; + + if (cvt->flags & FB_CVT_FLAG_REDUCED_BLANK) { + vbi_lines = (1000 * FB_CVT_RB_MIN_VBLANK)/cvt->hperiod + 1; + min_vbi_lines = FB_CVT_RB_V_FPORCH + cvt->vsync + + FB_CVT_MIN_BPORCH; + + } else { + vbi_lines = (FB_CVT_MIN_VSYNC_BP * 1000)/cvt->hperiod + 1 + + FB_CVT_MIN_VPORCH; + min_vbi_lines = cvt->vsync + FB_CVT_MIN_BPORCH + + FB_CVT_MIN_VPORCH; + } + + if (vbi_lines < min_vbi_lines) + act_vbi_lines = min_vbi_lines; + else + act_vbi_lines = vbi_lines; + + return act_vbi_lines; +} + +static u32 fb_cvt_vtotal(struct fb_cvt_data *cvt) +{ + u32 vtotal = cvt->yres/cvt->interlace; + + vtotal += 2 * cvt->v_margin + cvt->interlace/2 + fb_cvt_vbi_lines(cvt); + vtotal |= cvt->interlace/2; + + return vtotal; +} + +static u32 fb_cvt_pixclock(struct fb_cvt_data *cvt) +{ + u32 pixclock; + + if (cvt->flags & FB_CVT_FLAG_REDUCED_BLANK) + pixclock = (cvt->f_refresh * cvt->vtotal * cvt->htotal)/1000; + else + pixclock = (cvt->htotal * 1000000)/cvt->hperiod; + + pixclock /= 250; + pixclock *= 250; + pixclock *= 1000; + + return pixclock; +} + +static u32 fb_cvt_aspect_ratio(struct fb_cvt_data *cvt) +{ + u32 xres = cvt->xres; + u32 yres = cvt->yres; + u32 aspect = -1; + + if (xres == (yres * 4)/3 && !((yres * 4) % 3)) + aspect = 0; + else if (xres == (yres * 16)/9 && !((yres * 16) % 9)) + aspect = 1; + else if (xres == (yres * 16)/10 && !((yres * 16) % 10)) + aspect = 2; + else if (xres == (yres * 5)/4 && !((yres * 5) % 4)) + aspect = 3; + else if (xres == (yres * 15)/9 && !((yres * 15) % 9)) + aspect = 4; + else { + printk(KERN_INFO "fbcvt: Aspect ratio not CVT " + "standard\n"); + aspect = 7; + cvt->status = 1; + } + + return aspect; +} + +static void fb_cvt_print_name(struct fb_cvt_data *cvt) +{ + u32 pixcount, pixcount_mod; + int cnt = 255, offset = 0, read = 0; + u8 *buf = kmalloc(256, GFP_KERNEL); + + if (!buf) + return; + + memset(buf, 0, 256); + pixcount = (cvt->xres * (cvt->yres/cvt->interlace))/1000000; + pixcount_mod = (cvt->xres * (cvt->yres/cvt->interlace)) % 1000000; + pixcount_mod /= 1000; + + read = snprintf(buf+offset, cnt, "fbcvt: %dx%d@%d: CVT Name - ", + cvt->xres, cvt->yres, cvt->refresh); + offset += read; + cnt -= read; + + if (cvt->status) + snprintf(buf+offset, cnt, "Not a CVT standard - %d.%03d Mega " + "Pixel Image\n", pixcount, pixcount_mod); + else { + if (pixcount) { + read = snprintf(buf+offset, cnt, "%d", pixcount); + cnt -= read; + offset += read; + } + + read = snprintf(buf+offset, cnt, ".%03dM", pixcount_mod); + cnt -= read; + offset += read; + + if (cvt->aspect_ratio == 0) + read = snprintf(buf+offset, cnt, "3"); + else if (cvt->aspect_ratio == 3) + read = snprintf(buf+offset, cnt, "4"); + else if (cvt->aspect_ratio == 1 || cvt->aspect_ratio == 4) + read = snprintf(buf+offset, cnt, "9"); + else if (cvt->aspect_ratio == 2) + read = snprintf(buf+offset, cnt, "A"); + else + read = 0; + cnt -= read; + offset += read; + + if (cvt->flags & FB_CVT_FLAG_REDUCED_BLANK) { + read = snprintf(buf+offset, cnt, "-R"); + cnt -= read; + offset += read; + } + } + + printk(KERN_INFO "%s\n", buf); + kfree(buf); +} + +static void fb_cvt_convert_to_mode(struct fb_cvt_data *cvt, + struct fb_videomode *mode) +{ + mode->refresh = cvt->f_refresh; + mode->pixclock = KHZ2PICOS(cvt->pixclock/1000); + mode->left_margin = cvt->h_front_porch; + mode->right_margin = cvt->h_back_porch; + mode->hsync_len = cvt->hsync; + mode->upper_margin = cvt->v_front_porch; + mode->lower_margin = cvt->v_back_porch; + mode->vsync_len = cvt->vsync; + + mode->sync &= ~(FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT); + + if (cvt->flags & FB_CVT_FLAG_REDUCED_BLANK) + mode->sync |= FB_SYNC_HOR_HIGH_ACT; + else + mode->sync |= FB_SYNC_VERT_HIGH_ACT; +} + +/* + * fb_find_mode_cvt - calculate mode using VESA(TM) CVT + * @mode: pointer to fb_videomode; xres, yres, refresh and vmode must be + * pre-filled with the desired values + * @margins: add margin to calculation (1.8% of xres and yres) + * @rb: compute with reduced blanking (for flatpanels) + * + * RETURNS: + * 0 for success + * @mode is filled with computed values. If interlaced, the refresh field + * will be filled with the field rate (2x the frame rate) + * + * DESCRIPTION: + * Computes video timings using VESA(TM) Coordinated Video Timings + */ +int fb_find_mode_cvt(struct fb_videomode *mode, int margins, int rb) +{ + struct fb_cvt_data cvt; + + memset(&cvt, 0, sizeof(cvt)); + + if (margins) + cvt.flags |= FB_CVT_FLAG_MARGINS; + + if (rb) + cvt.flags |= FB_CVT_FLAG_REDUCED_BLANK; + + if (mode->vmode & FB_VMODE_INTERLACED) + cvt.flags |= FB_CVT_FLAG_INTERLACED; + + cvt.xres = mode->xres; + cvt.yres = mode->yres; + cvt.refresh = mode->refresh; + cvt.f_refresh = cvt.refresh; + cvt.interlace = 1; + + if (!cvt.xres || !cvt.yres || !cvt.refresh) { + printk(KERN_INFO "fbcvt: Invalid input parameters\n"); + return 1; + } + + if (!(cvt.refresh == 50 || cvt.refresh == 60 || cvt.refresh == 70 || + cvt.refresh == 85)) { + printk(KERN_INFO "fbcvt: Refresh rate not CVT " + "standard\n"); + cvt.status = 1; + } + + cvt.xres &= ~(FB_CVT_CELLSIZE - 1); + + if (cvt.flags & FB_CVT_FLAG_INTERLACED) { + cvt.interlace = 2; + cvt.f_refresh *= 2; + } + + if (cvt.flags & FB_CVT_FLAG_REDUCED_BLANK) { + if (cvt.refresh != 60) { + printk(KERN_INFO "fbcvt: 60Hz refresh rate " + "advised for reduced blanking\n"); + cvt.status = 1; + } + } + + if (cvt.flags & FB_CVT_FLAG_MARGINS) { + cvt.h_margin = (cvt.xres * 18)/1000; + cvt.h_margin &= ~(FB_CVT_CELLSIZE - 1); + cvt.v_margin = ((cvt.yres/cvt.interlace)* 18)/1000; + } + + cvt.aspect_ratio = fb_cvt_aspect_ratio(&cvt); + cvt.active_pixels = cvt.xres + 2 * cvt.h_margin; + cvt.hperiod = fb_cvt_hperiod(&cvt); + cvt.vsync = fb_cvt_vbi_tab[cvt.aspect_ratio]; + cvt.vtotal = fb_cvt_vtotal(&cvt); + cvt.hblank = fb_cvt_hblank(&cvt); + cvt.htotal = cvt.active_pixels + cvt.hblank; + cvt.hsync = fb_cvt_hsync(&cvt); + cvt.pixclock = fb_cvt_pixclock(&cvt); + cvt.hfreq = cvt.pixclock/cvt.htotal; + cvt.h_back_porch = cvt.hblank/2 + cvt.h_margin; + cvt.h_front_porch = cvt.hblank - cvt.hsync - cvt.h_back_porch + + 2 * cvt.h_margin; + cvt.v_back_porch = 3 + cvt.v_margin; + cvt.v_front_porch = cvt.vtotal - cvt.yres/cvt.interlace - + cvt.v_back_porch - cvt.vsync; + fb_cvt_print_name(&cvt); + fb_cvt_convert_to_mode(&cvt, mode); + + return 0; +} +EXPORT_SYMBOL(fb_find_mode_cvt); diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c index 4ff853fbe0b..70be7009f8a 100644 --- a/drivers/video/fbmem.c +++ b/drivers/video/fbmem.c @@ -62,16 +62,26 @@ int num_registered_fb; * Helpers */ -int fb_get_color_depth(struct fb_var_screeninfo *var) +int fb_get_color_depth(struct fb_var_screeninfo *var, + struct fb_fix_screeninfo *fix) { - if (var->green.length == var->blue.length && - var->green.length == var->red.length && - !var->green.offset && !var->blue.offset && - !var->red.offset) - return var->green.length; - else - return (var->green.length + var->red.length + - var->blue.length); + int depth = 0; + + if (fix->visual == FB_VISUAL_MONO01 || + fix->visual == FB_VISUAL_MONO10) + depth = 1; + else { + if (var->green.length == var->blue.length && + var->green.length == var->red.length && + var->green.offset == var->blue.offset && + var->green.offset == var->red.offset) + depth = var->green.length; + else + depth = var->green.length + var->red.length + + var->blue.length; + } + + return depth; } EXPORT_SYMBOL(fb_get_color_depth); @@ -80,15 +90,7 @@ EXPORT_SYMBOL(fb_get_color_depth); */ void fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch, u32 height) { - int i, j; - - for (i = height; i--; ) { - /* s_pitch is a few bytes at the most, memcpy is suboptimal */ - for (j = 0; j < s_pitch; j++) - dst[j] = src[j]; - src += s_pitch; - dst += d_pitch; - } + __fb_pad_aligned_buffer(dst, d_pitch, src, s_pitch, height); } EXPORT_SYMBOL(fb_pad_aligned_buffer); @@ -249,13 +251,18 @@ static void fb_set_logo(struct fb_info *info, const struct linux_logo *logo, u8 *dst, int depth) { - int i, j, k, fg = 1; + int i, j, k; const u8 *src = logo->data; - u8 d, xor = (info->fix.visual == FB_VISUAL_MONO01) ? 0xff : 0; + u8 xor = (info->fix.visual == FB_VISUAL_MONO01) ? 0xff : 0; + u8 fg = 1, d; - if (fb_get_color_depth(&info->var) == 3) + if (fb_get_color_depth(&info->var, &info->fix) == 3) fg = 7; + if (info->fix.visual == FB_VISUAL_MONO01 || + info->fix.visual == FB_VISUAL_MONO10) + fg = ~((u8) (0xfff << info->var.green.length)); + switch (depth) { case 4: for (i = 0; i < logo->height; i++) @@ -318,7 +325,7 @@ static struct logo_data { int fb_prepare_logo(struct fb_info *info) { - int depth = fb_get_color_depth(&info->var); + int depth = fb_get_color_depth(&info->var, &info->fix); memset(&fb_logo, 0, sizeof(struct logo_data)); @@ -684,11 +691,13 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var) if (!err && (flags & FBINFO_MISC_USEREVENT)) { struct fb_event event; + int evnt = (var->activate & FB_ACTIVATE_ALL) ? + FB_EVENT_MODE_CHANGE_ALL : + FB_EVENT_MODE_CHANGE; info->flags &= ~FBINFO_MISC_USEREVENT; event.info = info; - notifier_call_chain(&fb_notifier_list, - FB_EVENT_MODE_CHANGE, + notifier_call_chain(&fb_notifier_list, evnt, &event); } } @@ -1012,6 +1021,7 @@ register_framebuffer(struct fb_info *fb_info) { int i; struct fb_event event; + struct fb_videomode mode; if (num_registered_fb == FB_MAX) return -ENXIO; @@ -1042,16 +1052,11 @@ register_framebuffer(struct fb_info *fb_info) } fb_info->pixmap.offset = 0; - if (!fb_info->modelist.prev || - !fb_info->modelist.next || - list_empty(&fb_info->modelist)) { - struct fb_videomode mode; - + if (!fb_info->modelist.prev || !fb_info->modelist.next) INIT_LIST_HEAD(&fb_info->modelist); - fb_var_to_videomode(&mode, &fb_info->var); - fb_add_videomode(&mode, &fb_info->modelist); - } + fb_var_to_videomode(&mode, &fb_info->var); + fb_add_videomode(&mode, &fb_info->modelist); registered_fb[i] = fb_info; devfs_mk_cdev(MKDEV(FB_MAJOR, i), diff --git a/drivers/video/fbmon.c b/drivers/video/fbmon.c index c2718bb9494..713226cdf3c 100644 --- a/drivers/video/fbmon.c +++ b/drivers/video/fbmon.c @@ -29,6 +29,7 @@ #include <linux/tty.h> #include <linux/fb.h> #include <linux/module.h> +#include <video/edid.h> #ifdef CONFIG_PPC_OF #include <linux/pci.h> #include <asm/prom.h> @@ -313,11 +314,13 @@ static int edid_is_monitor_block(unsigned char *block) return 0; } -static void calc_mode_timings(int xres, int yres, int refresh, struct fb_videomode *mode) +static void calc_mode_timings(int xres, int yres, int refresh, + struct fb_videomode *mode) { struct fb_var_screeninfo var; struct fb_info info; + memset(&var, 0, sizeof(struct fb_var_screeninfo)); var.xres = xres; var.yres = yres; fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON, @@ -1251,9 +1254,41 @@ int fb_validate_mode(const struct fb_var_screeninfo *var, struct fb_info *info) -EINVAL : 0; } +#if defined(__i386__) +#include <linux/pci.h> + +/* + * We need to ensure that the EDID block is only returned for + * the primary graphics adapter. + */ + +const unsigned char *fb_firmware_edid(struct device *device) +{ + struct pci_dev *dev = NULL; + struct resource *res = NULL; + unsigned char *edid = NULL; + + if (device) + dev = to_pci_dev(device); + + if (dev) + res = &dev->resource[PCI_ROM_RESOURCE]; + + if (res && res->flags & IORESOURCE_ROM_SHADOW) + edid = edid_info.dummy; + + return edid; +} +#else +const unsigned char *fb_firmware_edid(struct device *device) +{ + return NULL; +} +#endif /* _i386_ */ + EXPORT_SYMBOL(fb_parse_edid); EXPORT_SYMBOL(fb_edid_to_monspecs); - +EXPORT_SYMBOL(fb_firmware_edid); EXPORT_SYMBOL(fb_get_mode); EXPORT_SYMBOL(fb_validate_mode); EXPORT_SYMBOL(fb_destroy_modedb); diff --git a/drivers/video/geode/Kconfig b/drivers/video/geode/Kconfig index b075fd02de3..5a9b89c3831 100644 --- a/drivers/video/geode/Kconfig +++ b/drivers/video/geode/Kconfig @@ -3,15 +3,13 @@ # config FB_GEODE bool "AMD Geode family framebuffer support (EXPERIMENTAL)" - default n - depends on FB && EXPERIMENTAL && X86 + depends on FB && PCI && EXPERIMENTAL && X86 ---help--- Say 'Y' here to allow you to select framebuffer drivers for the AMD Geode family of processors. config FB_GEODE_GX1 tristate "AMD Geode GX1 framebuffer support (EXPERIMENTAL)" - default n depends on FB_GEODE && EXPERIMENTAL select FB_CFB_FILLRECT select FB_CFB_COPYAREA @@ -21,9 +19,7 @@ config FB_GEODE_GX1 Framebuffer driver for the display controller integrated into the AMD Geode GX1 processor. - This driver is also available as a module ( = code which can be - inserted and removed from the running kernel whenever you want). The - module will be called gx1fb. If you want to compile it as a module, - say M here and read <file:Documentation/modules.txt>. + To compile this driver as a module, choose M here: the module will be + called gx1fb. If unsure, say N. diff --git a/drivers/video/geode/display_gx1.c b/drivers/video/geode/display_gx1.c index f4983879fcc..926d53eeb54 100644 --- a/drivers/video/geode/display_gx1.c +++ b/drivers/video/geode/display_gx1.c @@ -22,7 +22,7 @@ #include "geodefb.h" #include "display_gx1.h" -static spinlock_t gx1_conf_reg_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(gx1_conf_reg_lock); static u8 gx1_read_conf_reg(u8 reg) { diff --git a/drivers/video/geode/geodefb.h b/drivers/video/geode/geodefb.h index b7bac0a526b..ae04820e0c5 100644 --- a/drivers/video/geode/geodefb.h +++ b/drivers/video/geode/geodefb.h @@ -29,7 +29,6 @@ struct geodefb_par { int enable_crt; int panel_x; /* dimensions of an attached flat panel, non-zero => enable panel */ int panel_y; - struct pci_dev *vid_dev; void __iomem *dc_regs; void __iomem *vid_regs; struct geode_dc_ops *dc_ops; diff --git a/drivers/video/geode/gx1fb_core.c b/drivers/video/geode/gx1fb_core.c index 83830d24bcd..74a5fca86b8 100644 --- a/drivers/video/geode/gx1fb_core.c +++ b/drivers/video/geode/gx1fb_core.c @@ -30,6 +30,62 @@ static char mode_option[32] = "640x480-16@60"; static int crt_option = 1; static char panel_option[32] = ""; +/* Modes relevant to the GX1 (taken from modedb.c) */ +static const struct fb_videomode __initdata gx1_modedb[] = { + /* 640x480-60 VESA */ + { NULL, 60, 640, 480, 39682, 48, 16, 33, 10, 96, 2, + 0, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA }, + /* 640x480-75 VESA */ + { NULL, 75, 640, 480, 31746, 120, 16, 16, 01, 64, 3, + 0, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA }, + /* 640x480-85 VESA */ + { NULL, 85, 640, 480, 27777, 80, 56, 25, 01, 56, 3, + 0, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA }, + /* 800x600-60 VESA */ + { NULL, 60, 800, 600, 25000, 88, 40, 23, 01, 128, 4, + FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, + FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA }, + /* 800x600-75 VESA */ + { NULL, 75, 800, 600, 20202, 160, 16, 21, 01, 80, 3, + FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, + FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA }, + /* 800x600-85 VESA */ + { NULL, 85, 800, 600, 17761, 152, 32, 27, 01, 64, 3, + FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, + FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA }, + /* 1024x768-60 VESA */ + { NULL, 60, 1024, 768, 15384, 160, 24, 29, 3, 136, 6, + 0, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA }, + /* 1024x768-75 VESA */ + { NULL, 75, 1024, 768, 12690, 176, 16, 28, 1, 96, 3, + FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, + FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA }, + /* 1024x768-85 VESA */ + { NULL, 85, 1024, 768, 10582, 208, 48, 36, 1, 96, 3, + FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, + FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA }, + /* 1280x960-60 VESA */ + { NULL, 60, 1280, 960, 9259, 312, 96, 36, 1, 112, 3, + FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, + FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA }, + /* 1280x960-85 VESA */ + { NULL, 85, 1280, 960, 6734, 224, 64, 47, 1, 160, 3, + FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, + FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA }, + /* 1280x1024-60 VESA */ + { NULL, 60, 1280, 1024, 9259, 248, 48, 38, 1, 112, 3, + FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, + FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA }, + /* 1280x1024-75 VESA */ + { NULL, 75, 1280, 1024, 7407, 248, 16, 38, 1, 144, 3, + FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, + FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA }, + /* 1280x1024-85 VESA */ + { NULL, 85, 1280, 1024, 6349, 224, 64, 44, 1, 160, 3, + FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, + FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA }, +}; + static int gx1_line_delta(int xres, int bpp) { int line_delta = xres * (bpp >> 3); @@ -47,8 +103,6 @@ static int gx1fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) { struct geodefb_par *par = info->par; - printk(KERN_DEBUG "%s()\n", __FUNCTION__); - /* Maximum resolution is 1280x1024. */ if (var->xres > 1280 || var->yres > 1024) return -EINVAL; @@ -146,40 +200,48 @@ static int gx1fb_blank(int blank_mode, struct fb_info *info) return par->vid_ops->blank_display(info, blank_mode); } -static int __init gx1fb_map_video_memory(struct fb_info *info) +static int __init gx1fb_map_video_memory(struct fb_info *info, struct pci_dev *dev) { struct geodefb_par *par = info->par; unsigned gx_base; int fb_len; + int ret; gx_base = gx1_gx_base(); if (!gx_base) return -ENODEV; - par->vid_dev = pci_get_device(PCI_VENDOR_ID_CYRIX, - PCI_DEVICE_ID_CYRIX_5530_VIDEO, NULL); - if (!par->vid_dev) - return -ENODEV; + ret = pci_enable_device(dev); + if (ret < 0) + return ret; - par->vid_regs = ioremap(pci_resource_start(par->vid_dev, 1), - pci_resource_len(par->vid_dev, 1)); + ret = pci_request_region(dev, 1, "gx1fb (video)"); + if (ret < 0) + return ret; + par->vid_regs = ioremap(pci_resource_start(dev, 1), + pci_resource_len(dev, 1)); if (!par->vid_regs) return -ENOMEM; + if (!request_mem_region(gx_base + 0x8300, 0x100, "gx1fb (display controller)")) + return -EBUSY; par->dc_regs = ioremap(gx_base + 0x8300, 0x100); if (!par->dc_regs) return -ENOMEM; - info->fix.smem_start = gx_base + 0x800000; + ret = pci_request_region(dev, 0, "gx1fb (frame buffer)"); + if (ret < 0 ) + return -EBUSY; if ((fb_len = gx1_frame_buffer_size()) < 0) return -ENOMEM; + info->fix.smem_start = pci_resource_start(dev, 0); info->fix.smem_len = fb_len; info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len); if (!info->screen_base) return -ENOMEM; - printk(KERN_INFO "%s: %d Kibyte of video memory at 0x%lx\n", - info->fix.id, info->fix.smem_len / 1024, info->fix.smem_start); + dev_info(&dev->dev, "%d Kibyte of video memory at 0x%lx\n", + info->fix.smem_len / 1024, info->fix.smem_start); return 0; } @@ -216,13 +278,13 @@ static struct fb_ops gx1fb_ops = { .fb_cursor = soft_cursor, }; -static struct fb_info * __init gx1fb_init_fbinfo(void) +static struct fb_info * __init gx1fb_init_fbinfo(struct device *dev) { - struct fb_info *info; struct geodefb_par *par; + struct fb_info *info; /* Alloc enough space for the pseudo palette. */ - info = framebuffer_alloc(sizeof(struct geodefb_par) + sizeof(u32) * 16, NULL); + info = framebuffer_alloc(sizeof(struct geodefb_par) + sizeof(u32) * 16, dev); if (!info) return NULL; @@ -255,47 +317,37 @@ static struct fb_info * __init gx1fb_init_fbinfo(void) /* CRT and panel options */ par->enable_crt = crt_option; if (parse_panel_option(info) < 0) - printk(KERN_WARNING "%s: invalid 'panel' option -- disabling flat panel\n", - info->fix.id); + printk(KERN_WARNING "gx1fb: invalid 'panel' option -- disabling flat panel\n"); if (!par->panel_x) par->enable_crt = 1; /* fall back to CRT if no panel is specified */ return info; } - -static struct fb_info *gx1fb_info; - -static int __init gx1fb_init(void) +static int __init gx1fb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { + struct geodefb_par *par; struct fb_info *info; - struct geodefb_par *par; int ret; -#ifndef MODULE - if (fb_get_options("gx1fb", NULL)) - return -ENODEV; -#endif - - info = gx1fb_init_fbinfo(); + info = gx1fb_init_fbinfo(&pdev->dev); if (!info) return -ENOMEM; - gx1fb_info = info; - par = info->par; /* GX1 display controller and CS5530 video device */ par->dc_ops = &gx1_dc_ops; par->vid_ops = &cs5530_vid_ops; - if ((ret = gx1fb_map_video_memory(info)) < 0) { - printk(KERN_ERR "%s: gx1fb_map_video_memory() failed\n", info->fix.id); + if ((ret = gx1fb_map_video_memory(info, pdev)) < 0) { + dev_err(&pdev->dev, "failed to map frame buffer or controller registers\n"); goto err; } - ret = fb_find_mode(&info->var, info, mode_option, NULL, 0, NULL, 16); + ret = fb_find_mode(&info->var, info, mode_option, + gx1_modedb, ARRAY_SIZE(gx1_modedb), NULL, 16); if (ret == 0 || ret == 4) { - printk(KERN_ERR "%s: could not find valid video mode\n", info->fix.id); + dev_err(&pdev->dev, "could not find valid video mode\n"); ret = -EINVAL; goto err; } @@ -310,39 +362,83 @@ static int __init gx1fb_init(void) ret = -EINVAL; goto err; } + pci_set_drvdata(pdev, info); printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node, info->fix.id); return 0; err: - if (info->screen_base) + if (info->screen_base) { iounmap(info->screen_base); - if (par->vid_regs) + pci_release_region(pdev, 0); + } + if (par->vid_regs) { iounmap(par->vid_regs); - if (par->dc_regs) + pci_release_region(pdev, 1); + } + if (par->dc_regs) { iounmap(par->dc_regs); - if (par->vid_dev) - pci_dev_put(par->vid_dev); + release_mem_region(gx1_gx_base() + 0x8300, 0x100); + } + + pci_disable_device(pdev); + if (info) framebuffer_release(info); return ret; } -static void __exit gx1fb_cleanup(void) +static void gx1fb_remove(struct pci_dev *pdev) { - struct fb_info *info = gx1fb_info; - struct geodefb_par *par = gx1fb_info->par; + struct fb_info *info = pci_get_drvdata(pdev); + struct geodefb_par *par = info->par; unregister_framebuffer(info); iounmap((void __iomem *)info->screen_base); + pci_release_region(pdev, 0); + iounmap(par->vid_regs); + pci_release_region(pdev, 1); + iounmap(par->dc_regs); + release_mem_region(gx1_gx_base() + 0x8300, 0x100); - pci_dev_put(par->vid_dev); + pci_disable_device(pdev); + pci_set_drvdata(pdev, NULL); framebuffer_release(info); } +static struct pci_device_id gx1fb_id_table[] = { + { PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5530_VIDEO, + PCI_ANY_ID, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY << 16, + 0xff0000, 0 }, + { 0, } +}; + +MODULE_DEVICE_TABLE(pci, gx1fb_id_table); + +static struct pci_driver gx1fb_driver = { + .name = "gx1fb", + .id_table = gx1fb_id_table, + .probe = gx1fb_probe, + .remove = gx1fb_remove, +}; + +static int __init gx1fb_init(void) +{ +#ifndef MODULE + if (fb_get_options("gx1fb", NULL)) + return -ENODEV; +#endif + return pci_register_driver(&gx1fb_driver); +} + +static void __exit gx1fb_cleanup(void) +{ + pci_unregister_driver(&gx1fb_driver); +} + module_init(gx1fb_init); module_exit(gx1fb_cleanup); diff --git a/drivers/video/geode/video_cs5530.c b/drivers/video/geode/video_cs5530.c index d3764acf844..649c3943d43 100644 --- a/drivers/video/geode/video_cs5530.c +++ b/drivers/video/geode/video_cs5530.c @@ -69,8 +69,6 @@ static const struct cs5530_pll_entry cs5530_pll_table[] = { { 4310, 0x2FB1B802, }, /* 232.0000 */ }; -#define NUM_CS5530_FREQUENCIES sizeof(cs5530_pll_table)/sizeof(struct cs5530_pll_entry) - static void cs5530_set_dclk_frequency(struct fb_info *info) { struct geodefb_par *par = info->par; @@ -82,7 +80,7 @@ static void cs5530_set_dclk_frequency(struct fb_info *info) value = cs5530_pll_table[0].pll_value; min = cs5530_pll_table[0].pixclock - info->var.pixclock; if (min < 0) min = -min; - for (i = 1; i < NUM_CS5530_FREQUENCIES; i++) { + for (i = 1; i < ARRAY_SIZE(cs5530_pll_table); i++) { diff = cs5530_pll_table[i].pixclock - info->var.pixclock; if (diff < 0L) diff = -diff; if (diff < min) { diff --git a/drivers/video/i810/Makefile b/drivers/video/i810/Makefile index 794ae76c7c4..96e08c8ded9 100644 --- a/drivers/video/i810/Makefile +++ b/drivers/video/i810/Makefile @@ -4,7 +4,6 @@ obj-$(CONFIG_FB_I810) += i810fb.o - i810fb-objs := i810_main.o i810_accel.o ifdef CONFIG_FB_I810_GTF @@ -12,3 +11,7 @@ i810fb-objs += i810_gtf.o else i810fb-objs += i810_dvt.o endif + +ifdef CONFIG_FB_I810_I2C +i810fb-objs += i810-i2c.o +endif diff --git a/drivers/video/i810/i810-i2c.c b/drivers/video/i810/i810-i2c.c new file mode 100644 index 00000000000..fda53aac1fc --- /dev/null +++ b/drivers/video/i810/i810-i2c.c @@ -0,0 +1,257 @@ + /*-*- linux-c -*- + * linux/drivers/video/i810-i2c.c -- Intel 810/815 I2C support + * + * Copyright (C) 2004 Antonino Daplas<adaplas@pol.net> + * All Rights Reserved + * + * 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/config.h> +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/sched.h> +#include <linux/delay.h> +#include <linux/pci.h> +#include <linux/fb.h> +#include "i810.h" +#include "i810_regs.h" +#include "../edid.h" + +#define I810_DDC 0x50 +/* bit locations in the registers */ +#define SCL_DIR_MASK 0x0001 +#define SCL_DIR 0x0002 +#define SCL_VAL_MASK 0x0004 +#define SCL_VAL_OUT 0x0008 +#define SCL_VAL_IN 0x0010 +#define SDA_DIR_MASK 0x0100 +#define SDA_DIR 0x0200 +#define SDA_VAL_MASK 0x0400 +#define SDA_VAL_OUT 0x0800 +#define SDA_VAL_IN 0x1000 + +#define DEBUG /* define this for verbose EDID parsing output */ + +#ifdef DEBUG +#define DPRINTK(fmt, args...) printk(fmt,## args) +#else +#define DPRINTK(fmt, args...) +#endif + +static void i810i2c_setscl(void *data, int state) +{ + struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; + struct i810fb_par *par = chan->par; + u8 *mmio = par->mmio_start_virtual; + + i810_writel(mmio, GPIOB, (state ? SCL_VAL_OUT : 0) | SCL_DIR | + SCL_DIR_MASK | SCL_VAL_MASK); + i810_readl(mmio, GPIOB); /* flush posted write */ +} + +static void i810i2c_setsda(void *data, int state) +{ + struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; + struct i810fb_par *par = chan->par; + u8 *mmio = par->mmio_start_virtual; + + i810_writel(mmio, GPIOB, (state ? SDA_VAL_OUT : 0) | SDA_DIR | + SDA_DIR_MASK | SDA_VAL_MASK); + i810_readl(mmio, GPIOB); /* flush posted write */ +} + +static int i810i2c_getscl(void *data) +{ + struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; + struct i810fb_par *par = chan->par; + u8 *mmio = par->mmio_start_virtual; + + i810_writel(mmio, GPIOB, SCL_DIR_MASK); + i810_writel(mmio, GPIOB, 0); + return (0 != (i810_readl(mmio, GPIOB) & SCL_VAL_IN)); +} + +static int i810i2c_getsda(void *data) +{ + struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; + struct i810fb_par *par = chan->par; + u8 *mmio = par->mmio_start_virtual; + + i810_writel(mmio, GPIOB, SDA_DIR_MASK); + i810_writel(mmio, GPIOB, 0); + return (0 != (i810_readl(mmio, GPIOB) & SDA_VAL_IN)); +} + +static void i810ddc_setscl(void *data, int state) +{ + struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; + struct i810fb_par *par = chan->par; + u8 *mmio = par->mmio_start_virtual; + + i810_writel(mmio, GPIOA, (state ? SCL_VAL_OUT : 0) | SCL_DIR | + SCL_DIR_MASK | SCL_VAL_MASK); + i810_readl(mmio, GPIOA); /* flush posted write */ +} + +static void i810ddc_setsda(void *data, int state) +{ + struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; + struct i810fb_par *par = chan->par; + u8 *mmio = par->mmio_start_virtual; + + i810_writel(mmio, GPIOA, (state ? SDA_VAL_OUT : 0) | SDA_DIR | + SDA_DIR_MASK | SDA_VAL_MASK); + i810_readl(mmio, GPIOA); /* flush posted write */ +} + +static int i810ddc_getscl(void *data) +{ + struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; + struct i810fb_par *par = chan->par; + u8 *mmio = par->mmio_start_virtual; + + i810_writel(mmio, GPIOA, SCL_DIR_MASK); + i810_writel(mmio, GPIOA, 0); + return (0 != (i810_readl(mmio, GPIOA) & SCL_VAL_IN)); +} + +static int i810ddc_getsda(void *data) +{ + struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; + struct i810fb_par *par = chan->par; + u8 *mmio = par->mmio_start_virtual; + + i810_writel(mmio, GPIOA, SDA_DIR_MASK); + i810_writel(mmio, GPIOA, 0); + return (0 != (i810_readl(mmio, GPIOA) & SDA_VAL_IN)); +} + +#define I2C_ALGO_DDC_I810 0x0e0000 +#define I2C_ALGO_I2C_I810 0x0f0000 +static int i810_setup_i2c_bus(struct i810fb_i2c_chan *chan, const char *name, + int conn) +{ + int rc; + + strcpy(chan->adapter.name, name); + chan->adapter.owner = THIS_MODULE; + chan->adapter.algo_data = &chan->algo; + chan->adapter.dev.parent = &chan->par->dev->dev; + switch (conn) { + case 1: + chan->adapter.id = I2C_ALGO_DDC_I810; + chan->algo.setsda = i810ddc_setsda; + chan->algo.setscl = i810ddc_setscl; + chan->algo.getsda = i810ddc_getsda; + chan->algo.getscl = i810ddc_getscl; + break; + case 2: + chan->adapter.id = I2C_ALGO_I2C_I810; + chan->algo.setsda = i810i2c_setsda; + chan->algo.setscl = i810i2c_setscl; + chan->algo.getsda = i810i2c_getsda; + chan->algo.getscl = i810i2c_getscl; + break; + } + chan->algo.udelay = 10; + chan->algo.mdelay = 10; + chan->algo.timeout = (HZ/2); + chan->algo.data = chan; + + i2c_set_adapdata(&chan->adapter, chan); + + /* Raise SCL and SDA */ + chan->algo.setsda(chan, 1); + chan->algo.setscl(chan, 1); + udelay(20); + + rc = i2c_bit_add_bus(&chan->adapter); + if (rc == 0) + dev_dbg(&chan->par->dev->dev, "I2C bus %s registered.\n",name); + else + dev_warn(&chan->par->dev->dev, "Failed to register I2C bus " + "%s.\n", name); + return rc; +} + +void i810_create_i2c_busses(struct i810fb_par *par) +{ + par->chan[0].par = par; + par->chan[1].par = par; + i810_setup_i2c_bus(&par->chan[0], "I810-DDC", 1); + i810_setup_i2c_bus(&par->chan[1], "I810-I2C", 2); +} + +void i810_delete_i2c_busses(struct i810fb_par *par) +{ + if (par->chan[0].par) + i2c_bit_del_bus(&par->chan[0].adapter); + par->chan[0].par = NULL; + if (par->chan[1].par) + i2c_bit_del_bus(&par->chan[1].adapter); + par->chan[1].par = NULL; +} + +static u8 *i810_do_probe_i2c_edid(struct i810fb_i2c_chan *chan) +{ + u8 start = 0x0; + struct i2c_msg msgs[] = { + { + .addr = I810_DDC, + .len = 1, + .buf = &start, + }, { + .addr = I810_DDC, + .flags = I2C_M_RD, + .len = EDID_LENGTH, + }, + }; + u8 *buf; + + buf = kmalloc(EDID_LENGTH, GFP_KERNEL); + if (!buf) { + DPRINTK("i810-i2c: Failed to allocate memory\n"); + return NULL; + } + msgs[1].buf = buf; + + if (i2c_transfer(&chan->adapter, msgs, 2) == 2) { + DPRINTK("i810-i2c: I2C Transfer successful\n"); + return buf; + } + DPRINTK("i810-i2c: Unable to read EDID block.\n"); + kfree(buf); + return NULL; +} + +int i810_probe_i2c_connector(struct fb_info *info, u8 **out_edid, int conn) +{ + struct i810fb_par *par = info->par; + u8 *edid = NULL; + int i; + + DPRINTK("i810-i2c: Probe DDC%i Bus\n", conn); + if (conn < 3) { + for (i = 0; i < 3; i++) { + /* Do the real work */ + edid = i810_do_probe_i2c_edid(&par->chan[conn-1]); + if (edid) + break; + } + } else { + DPRINTK("i810-i2c: Getting EDID from BIOS\n"); + edid = kmalloc(EDID_LENGTH, GFP_KERNEL); + if (edid) + memcpy(edid, fb_firmware_edid(info->device), + EDID_LENGTH); + } + + if (out_edid) + *out_edid = edid; + + return (edid) ? 0 : 1; +} + + diff --git a/drivers/video/i810/i810.h b/drivers/video/i810/i810.h index fe3b7579475..d48949ceaac 100644 --- a/drivers/video/i810/i810.h +++ b/drivers/video/i810/i810.h @@ -16,6 +16,9 @@ #include <linux/list.h> #include <linux/agp_backend.h> #include <linux/fb.h> +#include <linux/i2c.h> +#include <linux/i2c-id.h> +#include <linux/i2c-algo-bit.h> #include <video/vga.h> /* Fence */ @@ -201,7 +204,6 @@ #define HAS_ACCELERATION 2 #define ALWAYS_SYNC 4 #define LOCKUP 8 -#define USE_HWCUR 16 struct gtt_data { struct agp_memory *i810_fb_memory; @@ -241,6 +243,14 @@ struct state_registers { u8 cr39, cr41, cr70, sr01, msr; }; +struct i810fb_par; + +struct i810fb_i2c_chan { + struct i810fb_par *par; + struct i2c_adapter adapter; + struct i2c_algo_bit_data algo; +}; + struct i810fb_par { struct mode_registers regs; struct state_registers hw_state; @@ -252,10 +262,12 @@ struct i810fb_par { struct heap_data iring; struct heap_data cursor_heap; struct vgastate state; + struct i810fb_i2c_chan chan[2]; atomic_t use_count; u32 pseudo_palette[17]; unsigned long mmio_start_phys; u8 __iomem *mmio_start_virtual; + u8 *edid; u32 pitch; u32 pixconf; u32 watermark; diff --git a/drivers/video/i810/i810_main.c b/drivers/video/i810/i810_main.c index 6db183462b9..0dbc9ddb676 100644 --- a/drivers/video/i810/i810_main.c +++ b/drivers/video/i810/i810_main.c @@ -92,20 +92,21 @@ static struct pci_driver i810fb_driver = { .resume = i810fb_resume, }; -static int vram __initdata = 4; -static int bpp __initdata = 8; -static int mtrr __initdata = 0; -static int accel __initdata = 0; -static int hsync1 __initdata = 0; -static int hsync2 __initdata = 0; -static int vsync1 __initdata = 0; -static int vsync2 __initdata = 0; -static int xres __initdata = 640; -static int yres __initdata = 480; -static int vyres __initdata = 0; -static int sync __initdata = 0; -static int ext_vga __initdata = 0; -static int dcolor __initdata = 0; +static char *mode_option __devinitdata = NULL; +static int vram __devinitdata = 4; +static int bpp __devinitdata = 8; +static int mtrr __devinitdata; +static int accel __devinitdata; +static int hsync1 __devinitdata; +static int hsync2 __devinitdata; +static int vsync1 __devinitdata; +static int vsync2 __devinitdata; +static int xres __devinitdata; +static int yres __devinitdata; +static int vyres __devinitdata; +static int sync __devinitdata; +static int extvga __devinitdata; +static int dcolor __devinitdata; /*------------------------------------------------------------*/ @@ -310,6 +311,8 @@ static void i810_hires(u8 __iomem *mmio) val = i810_readb(CR_DATA_CGA, mmio); i810_writeb(CR_INDEX_CGA, mmio, CR80); i810_writeb(CR_DATA_CGA, mmio, val | 1); + /* Stop LCD displays from flickering */ + i810_writel(MEM_MODE, mmio, i810_readl(MEM_MODE, mmio) | 4); } /** @@ -947,31 +950,24 @@ static int i810_check_params(struct fb_var_screeninfo *var, struct fb_info *info) { struct i810fb_par *par = (struct i810fb_par *) info->par; - int line_length, vidmem; - u32 xres, yres, vxres, vyres; - - xres = var->xres; - yres = var->yres; - vxres = var->xres_virtual; - vyres = var->yres_virtual; - + int line_length, vidmem, mode_valid = 0, retval = 0; + u32 vyres = var->yres_virtual, vxres = var->xres_virtual; /* * Memory limit */ - line_length = get_line_length(par, vxres, - var->bits_per_pixel); - + line_length = get_line_length(par, vxres, var->bits_per_pixel); vidmem = line_length*vyres; + if (vidmem > par->fb.size) { vyres = par->fb.size/line_length; - if (vyres < yres) { + if (vyres < var->yres) { vyres = yres; vxres = par->fb.size/vyres; vxres /= var->bits_per_pixel >> 3; line_length = get_line_length(par, vxres, var->bits_per_pixel); vidmem = line_length * yres; - if (vxres < xres) { + if (vxres < var->xres) { printk("i810fb: required video memory, " "%d bytes, for %dx%d-%d (virtual) " "is out of range\n", @@ -981,6 +977,10 @@ static int i810_check_params(struct fb_var_screeninfo *var, } } } + + var->xres_virtual = vxres; + var->yres_virtual = vyres; + /* * Monitor limit */ @@ -996,26 +996,41 @@ static int i810_check_params(struct fb_var_screeninfo *var, info->monspecs.dclkmax = 204000000; break; } + info->monspecs.dclkmin = 15000000; - if (fb_validate_mode(var, info)) { + if (!fb_validate_mode(var, info)) + mode_valid = 1; + +#ifdef CONFIG_FB_I810_I2C + if (!mode_valid && info->monspecs.gtf && + !fb_get_mode(FB_MAXTIMINGS, 0, var, info)) + mode_valid = 1; + + if (!mode_valid && info->monspecs.modedb_len) { + struct fb_videomode *mode; + + mode = fb_find_best_mode(var, &info->modelist); + if (mode) { + fb_videomode_to_var(var, mode); + mode_valid = 1; + } + } +#endif + if (!mode_valid && info->monspecs.modedb_len == 0) { if (fb_get_mode(FB_MAXTIMINGS, 0, var, info)) { int default_sync = (info->monspecs.hfmin-HFMIN) - |(info->monspecs.hfmax-HFMAX) - |(info->monspecs.vfmin-VFMIN) - |(info->monspecs.vfmax-VFMAX); + |(info->monspecs.hfmax-HFMAX) + |(info->monspecs.vfmin-VFMIN) + |(info->monspecs.vfmax-VFMAX); printk("i810fb: invalid video mode%s\n", - default_sync ? "" : - ". Specifying vsyncN/hsyncN parameters may help"); - return -EINVAL; + default_sync ? "" : ". Specifying " + "vsyncN/hsyncN parameters may help"); + retval = -EINVAL; } } - - var->xres = xres; - var->yres = yres; - var->xres_virtual = vxres; - var->yres_virtual = vyres; - return 0; + + return retval; } /** @@ -1375,7 +1390,6 @@ static int i810fb_set_par(struct fb_info *info) decode_var(&info->var, par); i810_load_regs(par); i810_init_cursor(par); - encode_fix(&info->fix, info); if (info->var.accel_flags && !(par->dev_flags & LOCKUP)) { @@ -1418,9 +1432,8 @@ static int i810fb_cursor(struct fb_info *info, struct fb_cursor *cursor) struct i810fb_par *par = (struct i810fb_par *)info->par; u8 __iomem *mmio = par->mmio_start_virtual; - if (!(par->dev_flags & USE_HWCUR) || !info->var.accel_flags || - par->dev_flags & LOCKUP) - return soft_cursor(info, cursor); + if (!par->dev_flags & LOCKUP) + return -ENXIO; if (cursor->image.width > 64 || cursor->image.height > 64) return -ENXIO; @@ -1712,12 +1725,21 @@ static void __devinit i810_init_defaults(struct i810fb_par *par, if (bpp < 8) bpp = 8; + par->i810fb_ops = i810fb_ops; + + if (xres) + info->var.xres = xres; + else + info->var.xres = 640; + + if (yres) + info->var.yres = yres; + else + info->var.yres = 480; + if (!vyres) - vyres = (vram << 20)/(xres*bpp >> 3); + vyres = (vram << 20)/(info->var.xres*bpp >> 3); - par->i810fb_ops = i810fb_ops; - info->var.xres = xres; - info->var.yres = yres; info->var.yres_virtual = vyres; info->var.bits_per_pixel = bpp; @@ -1744,7 +1766,7 @@ static void __devinit i810_init_device(struct i810fb_par *par) i810_init_cursor(par); /* mvo: enable external vga-connector (for laptops) */ - if (ext_vga) { + if (extvga) { i810_writel(HVSYNC, mmio, 0); i810_writel(PWR_CLKC, mmio, 3); } @@ -1814,8 +1836,80 @@ i810_allocate_pci_resource(struct i810fb_par *par, return 0; } +static void __devinit i810fb_find_init_mode(struct fb_info *info) +{ + struct fb_videomode mode; + struct fb_var_screeninfo var; + struct fb_monspecs *specs = &info->monspecs; + int found = 0; +#ifdef CONFIG_FB_I810_I2C + int i; + int err; + struct i810fb_par *par = info->par; +#endif + + INIT_LIST_HEAD(&info->modelist); + memset(&mode, 0, sizeof(struct fb_videomode)); + var = info->var; +#ifdef CONFIG_FB_I810_I2C + i810_create_i2c_busses(par); + + for (i = 0; i < 3; i++) { + err = i810_probe_i2c_connector(info, &par->edid, i+1); + if (!err) + break; + } + + if (!err) + printk("i810fb_init_pci: DDC probe successful\n"); + + fb_edid_to_monspecs(par->edid, specs); + + if (specs->modedb == NULL) + printk("i810fb_init_pci: Unable to get Mode Database\n"); + + fb_videomode_to_modelist(specs->modedb, specs->modedb_len, + &info->modelist); + if (specs->modedb != NULL) { + if (xres && yres) { + struct fb_videomode *m; + + if ((m = fb_find_best_mode(&var, &info->modelist))) { + mode = *m; + found = 1; + } + } + + if (!found && specs->misc & FB_MISC_1ST_DETAIL) { + for (i = 0; i < specs->modedb_len; i++) { + if (specs->modedb[i].flag & FB_MODE_IS_FIRST) { + mode = specs->modedb[i]; + found = 1; + break; + } + } + } + + if (!found) { + mode = specs->modedb[0]; + found = 1; + } + + fb_videomode_to_var(&var, &mode); + } +#endif + if (mode_option) + fb_find_mode(&var, info, mode_option, specs->modedb, + specs->modedb_len, (found) ? &mode : NULL, + info->var.bits_per_pixel); + + info->var = var; + fb_destroy_modedb(specs->modedb); + specs->modedb = NULL; +} + #ifndef MODULE -static int __init i810fb_setup(char *options) +static int __devinit i810fb_setup(char *options) { char *this_opt, *suffix = NULL; @@ -1827,8 +1921,8 @@ static int __init i810fb_setup(char *options) mtrr = 1; else if (!strncmp(this_opt, "accel", 5)) accel = 1; - else if (!strncmp(this_opt, "ext_vga", 7)) - ext_vga = 1; + else if (!strncmp(this_opt, "extvga", 6)) + extvga = 1; else if (!strncmp(this_opt, "sync", 4)) sync = 1; else if (!strncmp(this_opt, "vram:", 5)) @@ -1857,6 +1951,8 @@ static int __init i810fb_setup(char *options) vsync2 = simple_strtoul(this_opt+7, NULL, 0); else if (!strncmp(this_opt, "dcolor", 6)) dcolor = 1; + else + mode_option = this_opt; } return 0; } @@ -1867,6 +1963,7 @@ static int __devinit i810fb_init_pci (struct pci_dev *dev, { struct fb_info *info; struct i810fb_par *par = NULL; + struct fb_videomode mode; int i, err = -1, vfreq, hfreq, pixclock; i = 0; @@ -1875,7 +1972,7 @@ static int __devinit i810fb_init_pci (struct pci_dev *dev, if (!info) return -ENOMEM; - par = (struct i810fb_par *) info->par; + par = info->par; par->dev = dev; if (!(info->pixmap.addr = kmalloc(8*1024, GFP_KERNEL))) { @@ -1906,15 +2003,20 @@ static int __devinit i810fb_init_pci (struct pci_dev *dev, info->fbops = &par->i810fb_ops; info->pseudo_palette = par->pseudo_palette; fb_alloc_cmap(&info->cmap, 256, 0); + i810fb_find_init_mode(info); if ((err = info->fbops->fb_check_var(&info->var, info))) { i810fb_release_resource(info, par); return err; } + + fb_var_to_videomode(&mode, &info->var); + fb_add_videomode(&mode, &info->modelist); encode_fix(&info->fix, info); i810fb_init_ringbuffer(info); err = register_framebuffer(info); + if (err < 0) { i810fb_release_resource(info, par); printk("i810fb_init: cannot register framebuffer device\n"); @@ -1953,6 +2055,8 @@ static void i810fb_release_resource(struct fb_info *info, struct gtt_data *gtt = &par->i810_gtt; unset_mtrr(par); + i810_delete_i2c_busses(par); + if (par->i810_gtt.i810_cursor_memory) agp_free_memory(gtt->i810_cursor_memory); if (par->i810_gtt.i810_fb_memory) @@ -1962,7 +2066,8 @@ static void i810fb_release_resource(struct fb_info *info, iounmap(par->mmio_start_virtual); if (par->aperture.virtual) iounmap(par->aperture.virtual); - + if (par->edid) + kfree(par->edid); if (par->res_flags & FRAMEBUFFER_REQ) release_mem_region(par->aperture.physical, par->aperture.size); @@ -1988,7 +2093,7 @@ static void __exit i810fb_remove_pci(struct pci_dev *dev) } #ifndef MODULE -static int __init i810fb_init(void) +static int __devinit i810fb_init(void) { char *option = NULL; @@ -2006,7 +2111,7 @@ static int __init i810fb_init(void) #ifdef MODULE -static int __init i810fb_init(void) +static int __devinit i810fb_init(void) { hsync1 *= 1000; hsync2 *= 1000; @@ -2046,14 +2151,16 @@ module_param(accel, bool, 0); MODULE_PARM_DESC(accel, "Use Acceleration (BLIT) engine (default = 0)"); module_param(mtrr, bool, 0); MODULE_PARM_DESC(mtrr, "Use MTRR (default = 0)"); -module_param(ext_vga, bool, 0); -MODULE_PARM_DESC(ext_vga, "Enable external VGA connector (default = 0)"); +module_param(extvga, bool, 0); +MODULE_PARM_DESC(extvga, "Enable external VGA connector (default = 0)"); module_param(sync, bool, 0); MODULE_PARM_DESC(sync, "wait for accel engine to finish drawing" " (default = 0)"); module_param(dcolor, bool, 0); MODULE_PARM_DESC(dcolor, "use DirectColor visuals" " (default = 0 = TrueColor)"); +module_param(mode_option, charp, 0); +MODULE_PARM_DESC(mode_option, "Specify initial video mode"); MODULE_AUTHOR("Tony A. Daplas"); MODULE_DESCRIPTION("Framebuffer device for the Intel 810/815 and" diff --git a/drivers/video/i810/i810_main.h b/drivers/video/i810/i810_main.h index 43b4297b4d4..06072a6466f 100644 --- a/drivers/video/i810/i810_main.h +++ b/drivers/video/i810/i810_main.h @@ -83,6 +83,22 @@ extern int i810fb_sync (struct fb_info *p); extern void i810fb_init_ringbuffer(struct fb_info *info); extern void i810fb_load_front (u32 offset, struct fb_info *info); +#ifdef CONFIG_FB_I810_I2C +/* I2C */ +extern int i810_probe_i2c_connector(struct fb_info *info, u8 **out_edid, + int conn); +extern void i810_create_i2c_busses(struct i810fb_par *par); +extern void i810_delete_i2c_busses(struct i810fb_par *par); +#else +static inline int i810_probe_i2c_connector(struct fb_info *info, u8 **out_edid, + int conn) +{ + return 1; +} +static inline void i810_create_i2c_busses(struct i810fb_par *par) { } +static inline void i810_delete_i2c_busses(struct i810fb_par *par) { } +#endif + /* Conditionals */ #ifdef CONFIG_X86 inline void flush_cache(void) diff --git a/drivers/video/intelfb/intelfb.h b/drivers/video/intelfb/intelfb.h index 6680ec9ba69..011e1162655 100644 --- a/drivers/video/intelfb/intelfb.h +++ b/drivers/video/intelfb/intelfb.h @@ -234,7 +234,6 @@ struct intelfb_info { /* palette */ u32 pseudo_palette[17]; - struct { u8 red, green, blue, pad; } palette[256]; /* chip info */ int pci_chipset; diff --git a/drivers/video/intelfb/intelfbdrv.c b/drivers/video/intelfb/intelfbdrv.c index a112a178685..bf62e6ed038 100644 --- a/drivers/video/intelfb/intelfbdrv.c +++ b/drivers/video/intelfb/intelfbdrv.c @@ -117,14 +117,10 @@ #include <linux/slab.h> #include <linux/delay.h> #include <linux/fb.h> -#include <linux/console.h> -#include <linux/selection.h> #include <linux/ioport.h> #include <linux/init.h> #include <linux/pci.h> #include <linux/vmalloc.h> -#include <linux/kd.h> -#include <linux/vt_kern.h> #include <linux/pagemap.h> #include <linux/version.h> @@ -242,7 +238,7 @@ static int voffset = 48; static char *mode = NULL; module_param(accel, bool, S_IRUGO); -MODULE_PARM_DESC(accel, "Enable console acceleration"); +MODULE_PARM_DESC(accel, "Enable hardware acceleration"); module_param(vram, int, S_IRUGO); MODULE_PARM_DESC(vram, "System RAM to allocate to framebuffer in MiB"); module_param(voffset, int, S_IRUGO); @@ -498,7 +494,7 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent) { struct fb_info *info; struct intelfb_info *dinfo; - int i, j, err, dvo; + int i, err, dvo; int aperture_size, stolen_size; struct agp_kern_info gtt_info; int agp_memtype; @@ -845,13 +841,6 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent) if (bailearly == 5) bailout(dinfo); - for (i = 0; i < 16; i++) { - j = color_table[i]; - dinfo->palette[i].red = default_red[j]; - dinfo->palette[i].green = default_grn[j]; - dinfo->palette[i].blue = default_blu[j]; - } - if (bailearly == 6) bailout(dinfo); @@ -1363,10 +1352,6 @@ intelfb_setcolreg(unsigned regno, unsigned red, unsigned green, green >>= 8; blue >>= 8; - dinfo->palette[regno].red = red; - dinfo->palette[regno].green = green; - dinfo->palette[regno].blue = blue; - intelfbhw_setcolreg(dinfo, regno, red, green, blue, transp); } @@ -1499,7 +1484,7 @@ intelfb_cursor(struct fb_info *info, struct fb_cursor *cursor) #endif if (!dinfo->hwcursor) - return soft_cursor(info, cursor); + return -ENXIO; intelfbhw_cursor_hide(dinfo); diff --git a/drivers/video/intelfb/intelfbhw.c b/drivers/video/intelfb/intelfbhw.c index f5bed581dc4..5bafc3c54db 100644 --- a/drivers/video/intelfb/intelfbhw.c +++ b/drivers/video/intelfb/intelfbhw.c @@ -29,14 +29,10 @@ #include <linux/slab.h> #include <linux/delay.h> #include <linux/fb.h> -#include <linux/console.h> -#include <linux/selection.h> #include <linux/ioport.h> #include <linux/init.h> #include <linux/pci.h> #include <linux/vmalloc.h> -#include <linux/kd.h> -#include <linux/vt_kern.h> #include <linux/pagemap.h> #include <linux/version.h> diff --git a/drivers/video/matrox/matroxfb_misc.c b/drivers/video/matrox/matroxfb_misc.c index a18dd024fc8..d9d3e9f6c08 100644 --- a/drivers/video/matrox/matroxfb_misc.c +++ b/drivers/video/matrox/matroxfb_misc.c @@ -68,6 +68,9 @@ * "David C. Hansen" <haveblue@us.ibm.com> * Fixes * + * "Ian Romanick" <idr@us.ibm.com> + * Find PInS data in BIOS on PowerPC systems. + * * (following author is not in any relation with this code, but his code * is included in this driver) * @@ -496,10 +499,35 @@ static void parse_bios(unsigned char __iomem* vbios, struct matrox_bios* bd) { get_bios_version(vbios, bd); get_bios_output(vbios, bd); get_bios_tvout(vbios, bd); +#if defined(__powerpc__) + /* On PowerPC cards, the PInS offset isn't stored at the end of the + * BIOS image. Instead, you must search the entire BIOS image for + * the magic PInS signature. + * + * This actually applies to all OpenFirmware base cards. Since these + * cards could be put in a MIPS or SPARC system, should the condition + * be something different? + */ + for ( pins_offset = 0 ; pins_offset <= 0xFF80 ; pins_offset++ ) { + unsigned char header[3]; + + header[0] = readb(vbios + pins_offset); + header[1] = readb(vbios + pins_offset + 1); + header[2] = readb(vbios + pins_offset + 2); + if ( (header[0] == 0x2E) && (header[1] == 0x41) + && ((header[2] == 0x40) || (header[2] == 0x80)) ) { + printk(KERN_INFO "PInS data found at offset %u\n", + pins_offset); + get_pins(vbios + pins_offset, bd); + break; + } + } +#else pins_offset = readb(vbios + 0x7FFC) | (readb(vbios + 0x7FFD) << 8); if (pins_offset <= 0xFF80) { get_pins(vbios + pins_offset, bd); } +#endif } #define get_u16(x) (le16_to_cpu(get_unaligned((__u16*)(x)))) @@ -755,6 +783,8 @@ void matroxfb_read_pins(WPMINFO2) { } #endif matroxfb_set_limits(PMINFO &ACCESS_FBINFO(bios)); + printk(KERN_INFO "PInS memtype = %u\n", + (ACCESS_FBINFO(values).reg.opt & 0x1C00) >> 10); } EXPORT_SYMBOL(matroxfb_DAC_in); diff --git a/drivers/video/modedb.c b/drivers/video/modedb.c index 3edc9f49344..47516c44a39 100644 --- a/drivers/video/modedb.c +++ b/drivers/video/modedb.c @@ -456,12 +456,22 @@ static int fb_try_mode(struct fb_var_screeninfo *var, struct fb_info *info, * * Valid mode specifiers for @mode_option: * - * <xres>x<yres>[-<bpp>][@<refresh>] or + * <xres>x<yres>[M][R][-<bpp>][@<refresh>][i][m] or * <name>[-<bpp>][@<refresh>] * * with <xres>, <yres>, <bpp> and <refresh> decimal numbers and * <name> a string. * + * If 'M' is present after yres (and before refresh/bpp if present), + * the function will compute the timings using VESA(tm) Coordinated + * Video Timings (CVT). If 'R' is present after 'M', will compute with + * reduced blanking (for flatpanels). If 'i' is present, compute + * interlaced mode. If 'm' is present, add margins equal to 1.8% + * of xres rounded down to 8 pixels, and 1.8% of yres. The char + * 'i' and 'm' must be after 'M' and 'R'. Example: + * + * 1024x768MR-8@60m - Reduced blank with margins at 60Hz. + * * NOTE: The passed struct @var is _not_ cleared! This allows you * to supply values for e.g. the grayscale and accel_flags fields. * @@ -495,7 +505,7 @@ int fb_find_mode(struct fb_var_screeninfo *var, unsigned int namelen = strlen(name); int res_specified = 0, bpp_specified = 0, refresh_specified = 0; unsigned int xres = 0, yres = 0, bpp = default_bpp, refresh = 0; - int yres_specified = 0; + int yres_specified = 0, cvt = 0, rb = 0, interlace = 0, margins = 0; u32 best, diff; for (i = namelen-1; i >= 0; i--) { @@ -506,6 +516,8 @@ int fb_find_mode(struct fb_var_screeninfo *var, !yres_specified) { refresh = my_atoi(&name[i+1]); refresh_specified = 1; + if (cvt || rb) + cvt = 0; } else goto done; break; @@ -514,6 +526,8 @@ int fb_find_mode(struct fb_var_screeninfo *var, if (!bpp_specified && !yres_specified) { bpp = my_atoi(&name[i+1]); bpp_specified = 1; + if (cvt || rb) + cvt = 0; } else goto done; break; @@ -526,6 +540,22 @@ int fb_find_mode(struct fb_var_screeninfo *var, break; case '0'...'9': break; + case 'M': + if (!yres_specified) + cvt = 1; + break; + case 'R': + if (!cvt) + rb = 1; + break; + case 'm': + if (!cvt) + margins = 1; + break; + case 'i': + if (!cvt) + interlace = 1; + break; default: goto done; } @@ -535,6 +565,34 @@ int fb_find_mode(struct fb_var_screeninfo *var, res_specified = 1; } done: + if (cvt) { + struct fb_videomode cvt_mode; + int ret; + + DPRINTK("CVT mode %dx%d@%dHz%s%s%s\n", xres, yres, + (refresh) ? refresh : 60, (rb) ? " reduced blanking" : + "", (margins) ? " with margins" : "", (interlace) ? + " interlaced" : ""); + + cvt_mode.xres = xres; + cvt_mode.yres = yres; + cvt_mode.refresh = (refresh) ? refresh : 60; + + if (interlace) + cvt_mode.vmode |= FB_VMODE_INTERLACED; + else + cvt_mode.vmode &= ~FB_VMODE_INTERLACED; + + ret = fb_find_mode_cvt(&cvt_mode, margins, rb); + + if (!ret && !fb_try_mode(var, info, &cvt_mode, bpp)) { + DPRINTK("modedb CVT: CVT mode ok\n"); + return 1; + } + + DPRINTK("CVT mode invalid, getting mode from database\n"); + } + DPRINTK("Trying specified video mode%s %ix%i\n", refresh_specified ? "" : " (ignoring refresh rate)", xres, yres); diff --git a/drivers/video/nvidia/nv_i2c.c b/drivers/video/nvidia/nv_i2c.c index 1a91bffdda2..ace484fa61c 100644 --- a/drivers/video/nvidia/nv_i2c.c +++ b/drivers/video/nvidia/nv_i2c.c @@ -194,8 +194,9 @@ static u8 *nvidia_do_probe_i2c_edid(struct nvidia_i2c_chan *chan) return NULL; } -int nvidia_probe_i2c_connector(struct nvidia_par *par, int conn, u8 **out_edid) +int nvidia_probe_i2c_connector(struct fb_info *info, int conn, u8 **out_edid) { + struct nvidia_par *par = info->par; u8 *edid = NULL; int i; @@ -205,10 +206,17 @@ int nvidia_probe_i2c_connector(struct nvidia_par *par, int conn, u8 **out_edid) if (edid) break; } + + if (!edid && conn == 1) { + /* try to get from firmware */ + edid = kmalloc(EDID_LENGTH, GFP_KERNEL); + if (edid) + memcpy(edid, fb_firmware_edid(info->device), + EDID_LENGTH); + } + if (out_edid) *out_edid = edid; - if (!edid) - return 1; - return 0; + return (edid) ? 0 : 1; } diff --git a/drivers/video/nvidia/nv_local.h b/drivers/video/nvidia/nv_local.h index 9da320986f4..afee284fc73 100644 --- a/drivers/video/nvidia/nv_local.h +++ b/drivers/video/nvidia/nv_local.h @@ -95,6 +95,7 @@ #define READ_GET(par) (NV_RD32(&(par)->FIFO[0x0011], 0) >> 2) +#ifdef __LITTLE_ENDIAN #define reverse_order(l) \ do { \ u8 *a = (u8 *)(l); \ @@ -103,5 +104,8 @@ do { \ *a = byte_rev[*a], a++; \ *a = byte_rev[*a]; \ } while(0) +#else +#define reverse_order(l) +#endif /* __LITTLE_ENDIAN */ #endif /* __NV_LOCAL_H__ */ diff --git a/drivers/video/nvidia/nv_of.c b/drivers/video/nvidia/nv_of.c index 7d12eb85310..4fa2cf9a8af 100644 --- a/drivers/video/nvidia/nv_of.c +++ b/drivers/video/nvidia/nv_of.c @@ -30,8 +30,9 @@ void nvidia_create_i2c_busses(struct nvidia_par *par) {} void nvidia_delete_i2c_busses(struct nvidia_par *par) {} -int nvidia_probe_i2c_connector(struct nvidia_par *par, int conn, u8 **out_edid) +int nvidia_probe_i2c_connector(struct fb_info *info, int conn, u8 **out_edid) { + struct nvidia_par *par = info->par; struct device_node *dp; unsigned char *pedid = NULL; unsigned char *disptype = NULL; diff --git a/drivers/video/nvidia/nv_proto.h b/drivers/video/nvidia/nv_proto.h index 42847ce1b8d..cac44fc7f58 100644 --- a/drivers/video/nvidia/nv_proto.h +++ b/drivers/video/nvidia/nv_proto.h @@ -34,7 +34,7 @@ void NVLockUnlock(struct nvidia_par *par, int); #if defined(CONFIG_FB_NVIDIA_I2C) || defined (CONFIG_PPC_OF) void nvidia_create_i2c_busses(struct nvidia_par *par); void nvidia_delete_i2c_busses(struct nvidia_par *par); -int nvidia_probe_i2c_connector(struct nvidia_par *par, int conn, +int nvidia_probe_i2c_connector(struct fb_info *info, int conn, u8 ** out_edid); #else #define nvidia_create_i2c_busses(...) diff --git a/drivers/video/nvidia/nv_setup.c b/drivers/video/nvidia/nv_setup.c index 0bbdca2e0f9..11c84178f42 100644 --- a/drivers/video/nvidia/nv_setup.c +++ b/drivers/video/nvidia/nv_setup.c @@ -401,7 +401,7 @@ void NVCommonSetup(struct fb_info *info) nvidia_create_i2c_busses(par); if (!par->twoHeads) { par->CRTCnumber = 0; - nvidia_probe_i2c_connector(par, 1, &edidA); + nvidia_probe_i2c_connector(info, 1, &edidA); if (edidA && !fb_parse_edid(edidA, &var)) { printk("nvidiafb: EDID found from BUS1\n"); monA = &monitorA; @@ -488,14 +488,14 @@ void NVCommonSetup(struct fb_info *info) oldhead = NV_RD32(par->PCRTC0, 0x00000860); NV_WR32(par->PCRTC0, 0x00000860, oldhead | 0x00000010); - nvidia_probe_i2c_connector(par, 1, &edidA); + nvidia_probe_i2c_connector(info, 1, &edidA); if (edidA && !fb_parse_edid(edidA, &var)) { printk("nvidiafb: EDID found from BUS1\n"); monA = &monitorA; fb_edid_to_monspecs(edidA, monA); } - nvidia_probe_i2c_connector(par, 2, &edidB); + nvidia_probe_i2c_connector(info, 2, &edidB); if (edidB && !fb_parse_edid(edidB, &var)) { printk("nvidiafb: EDID found from BUS2\n"); monB = &monitorB; diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c index 30f80c23f93..3620de0f252 100644 --- a/drivers/video/nvidia/nvidia.c +++ b/drivers/video/nvidia/nvidia.c @@ -658,7 +658,7 @@ static int nvidia_calc_regs(struct fb_info *info) { struct nvidia_par *par = info->par; struct _riva_hw_state *state = &par->ModeReg; - int i, depth = fb_get_color_depth(&info->var); + int i, depth = fb_get_color_depth(&info->var, &info->fix); int h_display = info->var.xres / 8 - 1; int h_start = (info->var.xres + info->var.right_margin) / 8 - 1; int h_end = (info->var.xres + info->var.right_margin + @@ -893,7 +893,7 @@ static int nvidiafb_cursor(struct fb_info *info, struct fb_cursor *cursor) int i, set = cursor->set; u16 fg, bg; - if (cursor->image.width > MAX_CURS || cursor->image.height > MAX_CURS) + if (!hwcur || cursor->image.width > MAX_CURS || cursor->image.height > MAX_CURS) return -ENXIO; NVShowHideCursor(par, 0); @@ -978,6 +978,9 @@ static int nvidiafb_set_par(struct fb_info *info) !par->twoHeads) par->FPDither = 0; + info->fix.visual = (info->var.bits_per_pixel == 8) ? + FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR; + nvidia_init_vga(info); nvidia_calc_regs(info); nvidia_write_regs(par); @@ -992,9 +995,6 @@ static int nvidiafb_set_par(struct fb_info *info) NVWriteCrtc(par, 0x11, 0x00); info->fix.line_length = (info->var.xres_virtual * info->var.bits_per_pixel) >> 3; - info->fix.visual = (info->var.bits_per_pixel == 8) ? - FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR; - if (info->var.accel_flags) { info->fbops->fb_imageblit = nvidiafb_imageblit; info->fbops->fb_fillrect = nvidiafb_fillrect; @@ -1328,7 +1328,7 @@ static int __devinit nvidia_set_fbinfo(struct fb_info *info) char buf[16]; memset(buf, 0, 16); - snprintf(buf, 15, "%dx%d", par->fpWidth, par->fpHeight); + snprintf(buf, 15, "%dx%dMR", par->fpWidth, par->fpHeight); fb_find_mode(&nvidiafb_default_var, info, buf, specs->modedb, specs->modedb_len, &modedb, 8); } @@ -1356,8 +1356,6 @@ static int __devinit nvidia_set_fbinfo(struct fb_info *info) info->pixmap.size = 8 * 1024; info->pixmap.flags = FB_PIXMAP_SYSTEM; - if (!hwcur) - info->fbops->fb_cursor = soft_cursor; info->var.accel_flags = (!noaccel); switch (par->Architecture) { diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c index 30112816420..34d4dcc0320 100644 --- a/drivers/video/pxafb.c +++ b/drivers/video/pxafb.c @@ -468,6 +468,36 @@ static inline unsigned int get_pcd(unsigned int pixclock) } /* + * Some touchscreens need hsync information from the video driver to + * function correctly. We export it here. + */ +static inline void set_hsync_time(struct pxafb_info *fbi, unsigned int pcd) +{ + unsigned long long htime; + + if ((pcd == 0) || (fbi->fb.var.hsync_len == 0)) { + fbi->hsync_time=0; + return; + } + + htime = (unsigned long long)get_lcdclk_frequency_10khz() * 10000; + do_div(htime, pcd * fbi->fb.var.hsync_len); + fbi->hsync_time = htime; +} + +unsigned long pxafb_get_hsync_time(struct device *dev) +{ + struct pxafb_info *fbi = dev_get_drvdata(dev); + + /* If display is blanked/suspended, hsync isn't active */ + if (!fbi || (fbi->state != C_ENABLE)) + return 0; + + return fbi->hsync_time; +} +EXPORT_SYMBOL(pxafb_get_hsync_time); + +/* * pxafb_activate_var(): * Configures LCD Controller based on entries in var parameter. Settings are * only written to the controller if changes were made. @@ -631,6 +661,7 @@ static int pxafb_activate_var(struct fb_var_screeninfo *var, struct pxafb_info * fbi->reg_lccr1 = new_regs.lccr1; fbi->reg_lccr2 = new_regs.lccr2; fbi->reg_lccr3 = new_regs.lccr3; + set_hsync_time(fbi, pcd); local_irq_restore(flags); /* @@ -907,6 +938,7 @@ pxafb_freq_transition(struct notifier_block *nb, unsigned long val, void *data) case CPUFREQ_POSTCHANGE: pcd = get_pcd(fbi->fb.var.pixclock); + set_hsync_time(fbi, pcd); fbi->reg_lccr3 = (fbi->reg_lccr3 & ~0xff) | LCCR3_PixClkDiv(pcd); set_ctrlr_state(fbi, C_ENABLE_CLKCHANGE); break; diff --git a/drivers/video/pxafb.h b/drivers/video/pxafb.h index de15fec5f82..22c00be786a 100644 --- a/drivers/video/pxafb.h +++ b/drivers/video/pxafb.h @@ -83,6 +83,8 @@ struct pxafb_info { u_int reg_lccr2; u_int reg_lccr3; + unsigned long hsync_time; + volatile u_char state; volatile u_char task_state; struct semaphore ctrlr_sem; diff --git a/drivers/video/s3c2410fb.c b/drivers/video/s3c2410fb.c new file mode 100644 index 00000000000..00c0223a352 --- /dev/null +++ b/drivers/video/s3c2410fb.c @@ -0,0 +1,915 @@ +/* + * linux/drivers/video/s3c2410fb.c + * Copyright (c) Arnaud Patard, Ben Dooks + * + * 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. + * + * S3C2410 LCD Controller Frame Buffer Driver + * based on skeletonfb.c, sa1100fb.c and others + * + * ChangeLog + * 2005-04-07: Arnaud Patard <arnaud.patard@rtp-net.org> + * - u32 state -> pm_message_t state + * - S3C2410_{VA,SZ}_LCD -> S3C24XX + * + * 2005-03-15: Arnaud Patard <arnaud.patard@rtp-net.org> + * - Removed the ioctl + * - use readl/writel instead of __raw_writel/__raw_readl + * + * 2004-12-04: Arnaud Patard <arnaud.patard@rtp-net.org> + * - Added the possibility to set on or off the + * debugging mesaages + * - Replaced 0 and 1 by on or off when reading the + * /sys files + * + * 2005-03-23: Ben Dooks <ben-linux@fluff.org> + * - added non 16bpp modes + * - updated platform information for range of x/y/bpp + * - add code to ensure palette is written correctly + * - add pixel clock divisor control + * + * 2004-11-11: Arnaud Patard <arnaud.patard@rtp-net.org> + * - Removed the use of currcon as it no more exist + * - Added LCD power sysfs interface + * + * 2004-11-03: Ben Dooks <ben-linux@fluff.org> + * - minor cleanups + * - add suspend/resume support + * - s3c2410fb_setcolreg() not valid in >8bpp modes + * - removed last CONFIG_FB_S3C2410_FIXED + * - ensure lcd controller stopped before cleanup + * - added sysfs interface for backlight power + * - added mask for gpio configuration + * - ensured IRQs disabled during GPIO configuration + * - disable TPAL before enabling video + * + * 2004-09-20: Arnaud Patard <arnaud.patard@rtp-net.org> + * - Suppress command line options + * + * 2004-09-15: Arnaud Patard <arnaud.patard@rtp-net.org> + * - code cleanup + * + * 2004-09-07: Arnaud Patard <arnaud.patard@rtp-net.org> + * - Renamed from h1940fb.c to s3c2410fb.c + * - Add support for different devices + * - Backlight support + * + * 2004-09-05: Herbert Pötzl <herbert@13thfloor.at> + * - added clock (de-)allocation code + * - added fixem fbmem option + * + * 2004-07-27: Arnaud Patard <arnaud.patard@rtp-net.org> + * - code cleanup + * - added a forgotten return in h1940fb_init + * + * 2004-07-19: Herbert Pötzl <herbert@13thfloor.at> + * - code cleanup and extended debugging + * + * 2004-07-15: Arnaud Patard <arnaud.patard@rtp-net.org> + * - First version + */ + +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/errno.h> +#include <linux/string.h> +#include <linux/mm.h> +#include <linux/tty.h> +#include <linux/slab.h> +#include <linux/delay.h> +#include <linux/fb.h> +#include <linux/init.h> +#include <linux/dma-mapping.h> +#include <linux/string.h> +#include <linux/interrupt.h> +#include <linux/workqueue.h> +#include <linux/wait.h> + +#include <asm/io.h> +#include <asm/uaccess.h> +#include <asm/div64.h> + +#include <asm/mach/map.h> +#include <asm/arch/regs-lcd.h> +#include <asm/arch/regs-gpio.h> +#include <asm/arch/fb.h> +#include <asm/hardware/clock.h> + +#ifdef CONFIG_PM +#include <linux/pm.h> +#endif + +#include "s3c2410fb.h" + + +static struct s3c2410fb_mach_info *mach_info; + +/* Debugging stuff */ +#ifdef CONFIG_FB_S3C2410_DEBUG +static int debug = 1; +#else +static int debug = 0; +#endif + +#define dprintk(msg...) if (debug) { printk(KERN_DEBUG "s3c2410fb: " msg); } + +/* useful functions */ + +/* s3c2410fb_set_lcdaddr + * + * initialise lcd controller address pointers +*/ + +static void s3c2410fb_set_lcdaddr(struct s3c2410fb_info *fbi) +{ + struct fb_var_screeninfo *var = &fbi->fb->var; + unsigned long saddr1, saddr2, saddr3; + + saddr1 = fbi->fb->fix.smem_start >> 1; + saddr2 = fbi->fb->fix.smem_start; + saddr2 += (var->xres * var->yres * var->bits_per_pixel)/8; + saddr2>>= 1; + + saddr3 = S3C2410_OFFSIZE(0) | S3C2410_PAGEWIDTH(var->xres); + + dprintk("LCDSADDR1 = 0x%08lx\n", saddr1); + dprintk("LCDSADDR2 = 0x%08lx\n", saddr2); + dprintk("LCDSADDR3 = 0x%08lx\n", saddr3); + + writel(saddr1, S3C2410_LCDSADDR1); + writel(saddr2, S3C2410_LCDSADDR2); + writel(saddr3, S3C2410_LCDSADDR3); +} + +/* s3c2410fb_calc_pixclk() + * + * calculate divisor for clk->pixclk +*/ + +static unsigned int s3c2410fb_calc_pixclk(struct s3c2410fb_info *fbi, + unsigned long pixclk) +{ + unsigned long clk = clk_get_rate(fbi->clk); + unsigned long long div; + + /* pixclk is in picoseoncds, our clock is in Hz + * + * Hz -> picoseconds is / 10^-12 + */ + + div = (unsigned long long)clk * pixclk; + do_div(div,1000000UL); + do_div(div,1000000UL); + + dprintk("pixclk %ld, divisor is %ld\n", pixclk, (long)div); + return div; +} + +/* + * s3c2410fb_check_var(): + * Get the video params out of 'var'. If a value doesn't fit, round it up, + * if it's too big, return -EINVAL. + * + */ +static int s3c2410fb_check_var(struct fb_var_screeninfo *var, + struct fb_info *info) +{ + struct s3c2410fb_info *fbi = info->par; + + dprintk("check_var(var=%p, info=%p)\n", var, info); + + /* validate x/y resolution */ + + if (var->yres > fbi->mach_info->yres.max) + var->yres = fbi->mach_info->yres.max; + else if (var->yres < fbi->mach_info->yres.min) + var->yres = fbi->mach_info->yres.min; + + if (var->xres > fbi->mach_info->xres.max) + var->yres = fbi->mach_info->xres.max; + else if (var->xres < fbi->mach_info->xres.min) + var->xres = fbi->mach_info->xres.min; + + /* validate bpp */ + + if (var->bits_per_pixel > fbi->mach_info->bpp.max) + var->bits_per_pixel = fbi->mach_info->bpp.max; + else if (var->bits_per_pixel < fbi->mach_info->bpp.min) + var->bits_per_pixel = fbi->mach_info->bpp.min; + + /* set r/g/b positions */ + + if (var->bits_per_pixel == 16) { + var->red.offset = 11; + var->green.offset = 5; + var->blue.offset = 0; + var->red.length = 5; + var->green.length = 6; + var->blue.length = 5; + var->transp.length = 0; + } else { + var->red.length = var->bits_per_pixel; + var->red.offset = 0; + var->green.length = var->bits_per_pixel; + var->green.offset = 0; + var->blue.length = var->bits_per_pixel; + var->blue.offset = 0; + var->transp.length = 0; + } + + return 0; +} + +/* s3c2410fb_activate_var + * + * activate (set) the controller from the given framebuffer + * information +*/ + +static int s3c2410fb_activate_var(struct s3c2410fb_info *fbi, + struct fb_var_screeninfo *var) +{ + fbi->regs.lcdcon1 &= ~S3C2410_LCDCON1_MODEMASK; + + dprintk("%s: var->xres = %d\n", __FUNCTION__, var->xres); + dprintk("%s: var->yres = %d\n", __FUNCTION__, var->yres); + dprintk("%s: var->bpp = %d\n", __FUNCTION__, var->bits_per_pixel); + + switch (var->bits_per_pixel) { + case 1: + fbi->regs.lcdcon1 |= S3C2410_LCDCON1_TFT1BPP; + break; + case 2: + fbi->regs.lcdcon1 |= S3C2410_LCDCON1_TFT2BPP; + break; + case 4: + fbi->regs.lcdcon1 |= S3C2410_LCDCON1_TFT4BPP; + break; + case 8: + fbi->regs.lcdcon1 |= S3C2410_LCDCON1_TFT8BPP; + break; + case 16: + fbi->regs.lcdcon1 |= S3C2410_LCDCON1_TFT16BPP; + break; + } + + /* check to see if we need to update sync/borders */ + + if (!fbi->mach_info->fixed_syncs) { + dprintk("setting vert: up=%d, low=%d, sync=%d\n", + var->upper_margin, var->lower_margin, + var->vsync_len); + + dprintk("setting horz: lft=%d, rt=%d, sync=%d\n", + var->left_margin, var->right_margin, + var->hsync_len); + + fbi->regs.lcdcon2 = + S3C2410_LCDCON2_VBPD(var->upper_margin - 1) | + S3C2410_LCDCON2_VFPD(var->lower_margin - 1) | + S3C2410_LCDCON2_VSPW(var->vsync_len - 1); + + fbi->regs.lcdcon3 = + S3C2410_LCDCON3_HBPD(var->right_margin - 1) | + S3C2410_LCDCON3_HFPD(var->left_margin - 1); + + fbi->regs.lcdcon4 &= ~S3C2410_LCDCON4_HSPW(0xff); + fbi->regs.lcdcon4 |= S3C2410_LCDCON4_HSPW(var->hsync_len - 1); + } + + /* update X/Y info */ + + fbi->regs.lcdcon2 &= ~S3C2410_LCDCON2_LINEVAL(0x3ff); + fbi->regs.lcdcon2 |= S3C2410_LCDCON2_LINEVAL(var->yres - 1); + + fbi->regs.lcdcon3 &= ~S3C2410_LCDCON3_HOZVAL(0x7ff); + fbi->regs.lcdcon3 |= S3C2410_LCDCON3_HOZVAL(var->xres - 1); + + if (var->pixclock > 0) { + int clkdiv = s3c2410fb_calc_pixclk(fbi, var->pixclock); + + clkdiv = (clkdiv / 2) -1; + if (clkdiv < 0) + clkdiv = 0; + + fbi->regs.lcdcon1 &= ~S3C2410_LCDCON1_CLKVAL(0x3ff); + fbi->regs.lcdcon1 |= S3C2410_LCDCON1_CLKVAL(clkdiv); + } + + /* write new registers */ + + dprintk("new register set:\n"); + dprintk("lcdcon[1] = 0x%08lx\n", fbi->regs.lcdcon1); + dprintk("lcdcon[2] = 0x%08lx\n", fbi->regs.lcdcon2); + dprintk("lcdcon[3] = 0x%08lx\n", fbi->regs.lcdcon3); + dprintk("lcdcon[4] = 0x%08lx\n", fbi->regs.lcdcon4); + dprintk("lcdcon[5] = 0x%08lx\n", fbi->regs.lcdcon5); + + writel(fbi->regs.lcdcon1 & ~S3C2410_LCDCON1_ENVID, S3C2410_LCDCON1); + writel(fbi->regs.lcdcon2, S3C2410_LCDCON2); + writel(fbi->regs.lcdcon3, S3C2410_LCDCON3); + writel(fbi->regs.lcdcon4, S3C2410_LCDCON4); + writel(fbi->regs.lcdcon5, S3C2410_LCDCON5); + + /* set lcd address pointers */ + s3c2410fb_set_lcdaddr(fbi); + + writel(fbi->regs.lcdcon1, S3C2410_LCDCON1); +} + + +/* + * s3c2410fb_set_par - Optional function. Alters the hardware state. + * @info: frame buffer structure that represents a single frame buffer + * + */ +static int s3c2410fb_set_par(struct fb_info *info) +{ + struct s3c2410fb_info *fbi = info->par; + struct fb_var_screeninfo *var = &info->var; + + if (var->bits_per_pixel == 16) + fbi->fb->fix.visual = FB_VISUAL_TRUECOLOR; + else + fbi->fb->fix.visual = FB_VISUAL_PSEUDOCOLOR; + + fbi->fb->fix.line_length = (var->width*var->bits_per_pixel)/8; + + /* activate this new configuration */ + + s3c2410fb_activate_var(fbi, var); + return 0; +} + +static void schedule_palette_update(struct s3c2410fb_info *fbi, + unsigned int regno, unsigned int val) +{ + unsigned long flags; + unsigned long irqen; + + local_irq_save(flags); + + fbi->palette_buffer[regno] = val; + + if (!fbi->palette_ready) { + fbi->palette_ready = 1; + + /* enable IRQ */ + irqen = readl(S3C2410_LCDINTMSK); + irqen &= ~S3C2410_LCDINT_FRSYNC; + writel(irqen, S3C2410_LCDINTMSK); + } + + local_irq_restore(flags); +} + +/* from pxafb.c */ +static inline unsigned int chan_to_field(unsigned int chan, struct fb_bitfield *bf) +{ + chan &= 0xffff; + chan >>= 16 - bf->length; + return chan << bf->offset; +} + +static int s3c2410fb_setcolreg(unsigned regno, + unsigned red, unsigned green, unsigned blue, + unsigned transp, struct fb_info *info) +{ + struct s3c2410fb_info *fbi = info->par; + unsigned int val; + + /* dprintk("setcol: regno=%d, rgb=%d,%d,%d\n", regno, red, green, blue); */ + + switch (fbi->fb->fix.visual) { + case FB_VISUAL_TRUECOLOR: + /* true-colour, use pseuo-palette */ + + if (regno < 16) { + u32 *pal = fbi->fb->pseudo_palette; + + val = chan_to_field(red, &fbi->fb->var.red); + val |= chan_to_field(green, &fbi->fb->var.green); + val |= chan_to_field(blue, &fbi->fb->var.blue); + + pal[regno] = val; + } + break; + + case FB_VISUAL_PSEUDOCOLOR: + if (regno < 256) { + /* currently assume RGB 5-6-5 mode */ + + val = ((red >> 0) & 0xf800); + val |= ((green >> 5) & 0x07e0); + val |= ((blue >> 11) & 0x001f); + + writel(val, S3C2410_TFTPAL(regno)); + schedule_palette_update(fbi, regno, val); + } + + break; + + default: + return 1; /* unknown type */ + } + + return 0; +} + + +/** + * s3c2410fb_blank + * @blank_mode: the blank mode we want. + * @info: frame buffer structure that represents a single frame buffer + * + * Blank the screen if blank_mode != 0, else unblank. Return 0 if + * blanking succeeded, != 0 if un-/blanking failed due to e.g. a + * video mode which doesn't support it. Implements VESA suspend + * and powerdown modes on hardware that supports disabling hsync/vsync: + * blank_mode == 2: suspend vsync + * blank_mode == 3: suspend hsync + * blank_mode == 4: powerdown + * + * Returns negative errno on error, or zero on success. + * + */ +static int s3c2410fb_blank(int blank_mode, struct fb_info *info) +{ + dprintk("blank(mode=%d, info=%p)\n", blank_mode, info); + + if (mach_info == NULL) + return -EINVAL; + + if (blank_mode == FB_BLANK_UNBLANK) + writel(0x0, S3C2410_TPAL); + else { + dprintk("setting TPAL to output 0x000000\n"); + writel(S3C2410_TPAL_EN, S3C2410_TPAL); + } + + return 0; +} + +static int s3c2410fb_debug_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%s\n", debug ? "on" : "off"); +} +static int s3c2410fb_debug_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t len) +{ + if (mach_info == NULL) + return -EINVAL; + + if (len < 1) + return -EINVAL; + + if (strnicmp(buf, "on", 2) == 0 || + strnicmp(buf, "1", 1) == 0) { + debug = 1; + printk(KERN_DEBUG "s3c2410fb: Debug On"); + } else if (strnicmp(buf, "off", 3) == 0 || + strnicmp(buf, "0", 1) == 0) { + debug = 0; + printk(KERN_DEBUG "s3c2410fb: Debug Off"); + } else { + return -EINVAL; + } + + return len; +} + + +static DEVICE_ATTR(debug, 0666, + s3c2410fb_debug_show, + s3c2410fb_debug_store); + +static struct fb_ops s3c2410fb_ops = { + .owner = THIS_MODULE, + .fb_check_var = s3c2410fb_check_var, + .fb_set_par = s3c2410fb_set_par, + .fb_blank = s3c2410fb_blank, + .fb_setcolreg = s3c2410fb_setcolreg, + .fb_fillrect = cfb_fillrect, + .fb_copyarea = cfb_copyarea, + .fb_imageblit = cfb_imageblit, + .fb_cursor = soft_cursor, +}; + + +/* + * s3c2410fb_map_video_memory(): + * Allocates the DRAM memory for the frame buffer. This buffer is + * remapped into a non-cached, non-buffered, memory region to + * allow palette and pixel writes to occur without flushing the + * cache. Once this area is remapped, all virtual memory + * access to the video memory should occur at the new region. + */ +static int __init s3c2410fb_map_video_memory(struct s3c2410fb_info *fbi) +{ + dprintk("map_video_memory(fbi=%p)\n", fbi); + + fbi->map_size = PAGE_ALIGN(fbi->fb->fix.smem_len + PAGE_SIZE); + fbi->map_cpu = dma_alloc_writecombine(fbi->dev, fbi->map_size, + &fbi->map_dma, GFP_KERNEL); + + fbi->map_size = fbi->fb->fix.smem_len; + + if (fbi->map_cpu) { + /* prevent initial garbage on screen */ + dprintk("map_video_memory: clear %p:%08x\n", + fbi->map_cpu, fbi->map_size); + memset(fbi->map_cpu, 0xf0, fbi->map_size); + + fbi->screen_dma = fbi->map_dma; + fbi->fb->screen_base = fbi->map_cpu; + fbi->fb->fix.smem_start = fbi->screen_dma; + + dprintk("map_video_memory: dma=%08x cpu=%p size=%08x\n", + fbi->map_dma, fbi->map_cpu, fbi->fb->fix.smem_len); + } + + return fbi->map_cpu ? 0 : -ENOMEM; +} + +static inline void s3c2410fb_unmap_video_memory(struct s3c2410fb_info *fbi) +{ + dma_free_writecombine(fbi->dev,fbi->map_size,fbi->map_cpu, fbi->map_dma); +} + +static inline void modify_gpio(void __iomem *reg, + unsigned long set, unsigned long mask) +{ + unsigned long tmp; + + tmp = readl(reg) & ~mask; + writel(tmp | set, reg); +} + + +/* + * s3c2410fb_init_registers - Initialise all LCD-related registers + */ + +int s3c2410fb_init_registers(struct s3c2410fb_info *fbi) +{ + unsigned long flags; + + /* Initialise LCD with values from haret */ + + local_irq_save(flags); + + /* modify the gpio(s) with interrupts set (bjd) */ + + modify_gpio(S3C2410_GPCUP, mach_info->gpcup, mach_info->gpcup_mask); + modify_gpio(S3C2410_GPCCON, mach_info->gpccon, mach_info->gpccon_mask); + modify_gpio(S3C2410_GPDUP, mach_info->gpdup, mach_info->gpdup_mask); + modify_gpio(S3C2410_GPDCON, mach_info->gpdcon, mach_info->gpdcon_mask); + + local_irq_restore(flags); + + writel(fbi->regs.lcdcon1, S3C2410_LCDCON1); + writel(fbi->regs.lcdcon2, S3C2410_LCDCON2); + writel(fbi->regs.lcdcon3, S3C2410_LCDCON3); + writel(fbi->regs.lcdcon4, S3C2410_LCDCON4); + writel(fbi->regs.lcdcon5, S3C2410_LCDCON5); + + s3c2410fb_set_lcdaddr(fbi); + + dprintk("LPCSEL = 0x%08lx\n", mach_info->lpcsel); + writel(mach_info->lpcsel, S3C2410_LPCSEL); + + dprintk("replacing TPAL %08x\n", readl(S3C2410_TPAL)); + + /* ensure temporary palette disabled */ + writel(0x00, S3C2410_TPAL); + + /* Enable video by setting the ENVID bit to 1 */ + fbi->regs.lcdcon1 |= S3C2410_LCDCON1_ENVID; + writel(fbi->regs.lcdcon1, S3C2410_LCDCON1); + return 0; +} + +static void s3c2410fb_write_palette(struct s3c2410fb_info *fbi) +{ + unsigned int i; + unsigned long ent; + + fbi->palette_ready = 0; + + for (i = 0; i < 256; i++) { + if ((ent = fbi->palette_buffer[i]) == PALETTE_BUFF_CLEAR) + continue; + + writel(ent, S3C2410_TFTPAL(i)); + + /* it seems the only way to know exactly + * if the palette wrote ok, is to check + * to see if the value verifies ok + */ + + if (readw(S3C2410_TFTPAL(i)) == ent) + fbi->palette_buffer[i] = PALETTE_BUFF_CLEAR; + else + fbi->palette_ready = 1; /* retry */ + } +} + +static irqreturn_t s3c2410fb_irq(int irq, void *dev_id, struct pt_regs *r) +{ + struct s3c2410fb_info *fbi = dev_id; + unsigned long lcdirq = readl(S3C2410_LCDINTPND); + + if (lcdirq & S3C2410_LCDINT_FRSYNC) { + if (fbi->palette_ready) + s3c2410fb_write_palette(fbi); + + writel(S3C2410_LCDINT_FRSYNC, S3C2410_LCDINTPND); + writel(S3C2410_LCDINT_FRSYNC, S3C2410_LCDSRCPND); + } + + return IRQ_HANDLED; +} + +static char driver_name[]="s3c2410fb"; + +int __init s3c2410fb_probe(struct device *dev) +{ + struct s3c2410fb_info *info; + struct fb_info *fbinfo; + struct platform_device *pdev = to_platform_device(dev); + struct s3c2410fb_hw *mregs; + int ret; + int irq; + int i; + + mach_info = dev->platform_data; + if (mach_info == NULL) { + dev_err(dev,"no platform data for lcd, cannot attach\n"); + return -EINVAL; + } + + mregs = &mach_info->regs; + + irq = platform_get_irq(pdev, 0); + if (irq < 0) { + dev_err(dev, "no irq for device\n"); + return -ENOENT; + } + + fbinfo = framebuffer_alloc(sizeof(struct s3c2410fb_info), dev); + if (!fbinfo) { + return -ENOMEM; + } + + + info = fbinfo->par; + info->fb = fbinfo; + dev_set_drvdata(dev, fbinfo); + + s3c2410fb_init_registers(info); + + dprintk("devinit\n"); + + strcpy(fbinfo->fix.id, driver_name); + + memcpy(&info->regs, &mach_info->regs, sizeof(info->regs)); + + info->mach_info = dev->platform_data; + + fbinfo->fix.type = FB_TYPE_PACKED_PIXELS; + fbinfo->fix.type_aux = 0; + fbinfo->fix.xpanstep = 0; + fbinfo->fix.ypanstep = 0; + fbinfo->fix.ywrapstep = 0; + fbinfo->fix.accel = FB_ACCEL_NONE; + + fbinfo->var.nonstd = 0; + fbinfo->var.activate = FB_ACTIVATE_NOW; + fbinfo->var.height = mach_info->height; + fbinfo->var.width = mach_info->width; + fbinfo->var.accel_flags = 0; + fbinfo->var.vmode = FB_VMODE_NONINTERLACED; + + fbinfo->fbops = &s3c2410fb_ops; + fbinfo->flags = FBINFO_FLAG_DEFAULT; + fbinfo->pseudo_palette = &info->pseudo_pal; + + fbinfo->var.xres = mach_info->xres.defval; + fbinfo->var.xres_virtual = mach_info->xres.defval; + fbinfo->var.yres = mach_info->yres.defval; + fbinfo->var.yres_virtual = mach_info->yres.defval; + fbinfo->var.bits_per_pixel = mach_info->bpp.defval; + + fbinfo->var.upper_margin = S3C2410_LCDCON2_GET_VBPD(mregs->lcdcon2) +1; + fbinfo->var.lower_margin = S3C2410_LCDCON2_GET_VFPD(mregs->lcdcon2) +1; + fbinfo->var.vsync_len = S3C2410_LCDCON2_GET_VSPW(mregs->lcdcon2) + 1; + + fbinfo->var.left_margin = S3C2410_LCDCON3_GET_HFPD(mregs->lcdcon3) + 1; + fbinfo->var.right_margin = S3C2410_LCDCON3_GET_HBPD(mregs->lcdcon3) + 1; + fbinfo->var.hsync_len = S3C2410_LCDCON4_GET_HSPW(mregs->lcdcon4) + 1; + + fbinfo->var.red.offset = 11; + fbinfo->var.green.offset = 5; + fbinfo->var.blue.offset = 0; + fbinfo->var.transp.offset = 0; + fbinfo->var.red.length = 5; + fbinfo->var.green.length = 6; + fbinfo->var.blue.length = 5; + fbinfo->var.transp.length = 0; + fbinfo->fix.smem_len = mach_info->xres.max * + mach_info->yres.max * + mach_info->bpp.max / 8; + + for (i = 0; i < 256; i++) + info->palette_buffer[i] = PALETTE_BUFF_CLEAR; + + if (!request_mem_region((unsigned long)S3C24XX_VA_LCD, SZ_1M, "s3c2410-lcd")) { + ret = -EBUSY; + goto dealloc_fb; + } + + + dprintk("got LCD region\n"); + + ret = request_irq(irq, s3c2410fb_irq, SA_INTERRUPT, pdev->name, info); + if (ret) { + dev_err(dev, "cannot get irq %d - err %d\n", irq, ret); + ret = -EBUSY; + goto release_mem; + } + + info->clk = clk_get(NULL, "lcd"); + if (!info->clk || IS_ERR(info->clk)) { + printk(KERN_ERR "failed to get lcd clock source\n"); + ret = -ENOENT; + goto release_irq; + } + + clk_use(info->clk); + clk_enable(info->clk); + dprintk("got and enabled clock\n"); + + msleep(1); + + /* Initialize video memory */ + ret = s3c2410fb_map_video_memory(info); + if (ret) { + printk( KERN_ERR "Failed to allocate video RAM: %d\n", ret); + ret = -ENOMEM; + goto release_clock; + } + dprintk("got video memory\n"); + + ret = s3c2410fb_init_registers(info); + + ret = s3c2410fb_check_var(&fbinfo->var, fbinfo); + + ret = register_framebuffer(fbinfo); + if (ret < 0) { + printk(KERN_ERR "Failed to register framebuffer device: %d\n", ret); + goto free_video_memory; + } + + /* create device files */ + device_create_file(dev, &dev_attr_debug); + + printk(KERN_INFO "fb%d: %s frame buffer device\n", + fbinfo->node, fbinfo->fix.id); + + return 0; + +free_video_memory: + s3c2410fb_unmap_video_memory(info); +release_clock: + clk_disable(info->clk); + clk_unuse(info->clk); + clk_put(info->clk); +release_irq: + free_irq(irq,info); +release_mem: + release_mem_region((unsigned long)S3C24XX_VA_LCD, S3C24XX_SZ_LCD); +dealloc_fb: + framebuffer_release(fbinfo); + return ret; +} + +/* s3c2410fb_stop_lcd + * + * shutdown the lcd controller +*/ + +static void s3c2410fb_stop_lcd(void) +{ + unsigned long flags; + unsigned long tmp; + + local_irq_save(flags); + + tmp = readl(S3C2410_LCDCON1); + writel(tmp & ~S3C2410_LCDCON1_ENVID, S3C2410_LCDCON1); + + local_irq_restore(flags); +} + +/* + * Cleanup + */ +static int s3c2410fb_remove(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct fb_info *fbinfo = dev_get_drvdata(dev); + struct s3c2410fb_info *info = fbinfo->par; + int irq; + + s3c2410fb_stop_lcd(); + msleep(1); + + s3c2410fb_unmap_video_memory(info); + + if (info->clk) { + clk_disable(info->clk); + clk_unuse(info->clk); + clk_put(info->clk); + info->clk = NULL; + } + + irq = platform_get_irq(pdev, 0); + free_irq(irq,info); + release_mem_region((unsigned long)S3C24XX_VA_LCD, S3C24XX_SZ_LCD); + unregister_framebuffer(fbinfo); + + return 0; +} + +#ifdef CONFIG_PM + +/* suspend and resume support for the lcd controller */ + +static int s3c2410fb_suspend(struct device *dev, pm_message_t state, u32 level) +{ + struct fb_info *fbinfo = dev_get_drvdata(dev); + struct s3c2410fb_info *info = fbinfo->par; + + if (level == SUSPEND_DISABLE || level == SUSPEND_POWER_DOWN) { + s3c2410fb_stop_lcd(); + + /* sleep before disabling the clock, we need to ensure + * the LCD DMA engine is not going to get back on the bus + * before the clock goes off again (bjd) */ + + msleep(1); + clk_disable(info->clk); + } + + return 0; +} + +static int s3c2410fb_resume(struct device *dev, u32 level) +{ + struct fb_info *fbinfo = dev_get_drvdata(dev); + struct s3c2410fb_info *info = fbinfo->par; + + if (level == RESUME_ENABLE) { + clk_enable(info->clk); + msleep(1); + + s3c2410fb_init_registers(info); + + } + + return 0; +} + +#else +#define s3c2410fb_suspend NULL +#define s3c2410fb_resume NULL +#endif + +static struct device_driver s3c2410fb_driver = { + .name = "s3c2410-lcd", + .bus = &platform_bus_type, + .probe = s3c2410fb_probe, + .suspend = s3c2410fb_suspend, + .resume = s3c2410fb_resume, + .remove = s3c2410fb_remove +}; + +int __devinit s3c2410fb_init(void) +{ + return driver_register(&s3c2410fb_driver); +} + +static void __exit s3c2410fb_cleanup(void) +{ + driver_unregister(&s3c2410fb_driver); +} + + +module_init(s3c2410fb_init); +module_exit(s3c2410fb_cleanup); + +MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>, Ben Dooks <ben-linux@fluff.org>"); +MODULE_DESCRIPTION("Framebuffer driver for the s3c2410"); +MODULE_LICENSE("GPL"); diff --git a/drivers/video/s3c2410fb.h b/drivers/video/s3c2410fb.h new file mode 100644 index 00000000000..be40968f899 --- /dev/null +++ b/drivers/video/s3c2410fb.h @@ -0,0 +1,56 @@ +/* + * linux/drivers/s3c2410fb.h + * Copyright (c) Arnaud Patard + * + * 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. + * + * S3C2410 LCD Controller Frame Buffer Driver + * based on skeletonfb.c, sa1100fb.h + * + * ChangeLog + * + * 2004-12-04: Arnaud Patard <arnaud.patard@rtp-net.org> + * - Moved dprintk to s3c2410fb.c + * + * 2004-09-07: Arnaud Patard <arnaud.patard@rtp-net.org> + * - Renamed from h1940fb.h to s3c2410fb.h + * - Chenged h1940 to s3c2410 + * + * 2004-07-15: Arnaud Patard <arnaud.patard@rtp-net.org> + * - First version + */ + +#ifndef __S3C2410FB_H +#define __S3C2410FB_H + +struct s3c2410fb_info { + struct fb_info *fb; + struct device *dev; + struct clk *clk; + + struct s3c2410fb_mach_info *mach_info; + + /* raw memory addresses */ + dma_addr_t map_dma; /* physical */ + u_char * map_cpu; /* virtual */ + u_int map_size; + + struct s3c2410fb_hw regs; + + /* addresses of pieces placed in raw buffer */ + u_char * screen_cpu; /* virtual address of buffer */ + dma_addr_t screen_dma; /* physical address of buffer */ + unsigned int palette_ready; + + /* keep these registers in case we need to re-write palette */ + u32 palette_buffer[256]; + u32 pseudo_pal[16]; +}; + +#define PALETTE_BUFF_CLEAR (0x80000000) /* entry is clear/invalid */ + +int s3c2410fb_init(void); + +#endif diff --git a/drivers/video/savage/savagefb-i2c.c b/drivers/video/savage/savagefb-i2c.c index 847698b5cfe..959404ad68f 100644 --- a/drivers/video/savage/savagefb-i2c.c +++ b/drivers/video/savage/savagefb-i2c.c @@ -259,8 +259,9 @@ static u8 *savage_do_probe_i2c_edid(struct savagefb_i2c_chan *chan) return buf; } -int savagefb_probe_i2c_connector(struct savagefb_par *par, u8 **out_edid) +int savagefb_probe_i2c_connector(struct fb_info *info, u8 **out_edid) { + struct savagefb_par *par = info->par; u8 *edid = NULL; int i; @@ -270,12 +271,19 @@ int savagefb_probe_i2c_connector(struct savagefb_par *par, u8 **out_edid) if (edid) break; } + + if (!edid) { + /* try to get from firmware */ + edid = kmalloc(EDID_LENGTH, GFP_KERNEL); + if (edid) + memcpy(edid, fb_firmware_edid(info->device), + EDID_LENGTH); + } + if (out_edid) *out_edid = edid; - if (!edid) - return 1; - return 0; + return (edid) ? 0 : 1; } MODULE_LICENSE("GPL"); diff --git a/drivers/video/savage/savagefb.h b/drivers/video/savage/savagefb.h index 8594b1e42d7..d6f94742c9f 100644 --- a/drivers/video/savage/savagefb.h +++ b/drivers/video/savage/savagefb.h @@ -60,6 +60,7 @@ #define S3_SAVAGE_SERIES(chip) ((chip>=S3_SAVAGE3D) && (chip<=S3_SAVAGE2000)) +#define S3_MOBILE_TWISTER_SERIES(chip) ((chip==S3_TWISTER) || (chip == S3_PROSAVAGEDDR)) /* Chip tags. These are used to group the adapters into * related families. @@ -73,6 +74,8 @@ typedef enum { S3_PROSAVAGE, S3_SUPERSAVAGE, S3_SAVAGE2000, + S3_PROSAVAGEDDR, + S3_TWISTER, S3_LAST } savage_chipset; @@ -128,6 +131,10 @@ typedef enum { #define BCI_CMD_SET_ROP(cmd, rop) ((cmd) |= ((rop & 0xFF) << 16)) #define BCI_CMD_SEND_COLOR 0x00008000 +#define DISP_CRT 1 +#define DISP_LCD 2 +#define DISP_DFP 3 + struct xtimings { unsigned int Clock; unsigned int HDisplay; @@ -166,6 +173,10 @@ struct savagefb_par { struct savagefb_i2c_chan chan; unsigned char *edid; u32 pseudo_palette[16]; + int pm_state; + int display_type; + int dvi; + int crtonly; int dacSpeedBpp; int maxClock; int minClock; @@ -338,7 +349,7 @@ do { \ } \ } -extern int savagefb_probe_i2c_connector(struct savagefb_par *par, +extern int savagefb_probe_i2c_connector(struct fb_info *info, u8 **out_edid); extern void savagefb_create_i2c_busses(struct fb_info *info); extern void savagefb_delete_i2c_busses(struct fb_info *info); diff --git a/drivers/video/savage/savagefb_driver.c b/drivers/video/savage/savagefb_driver.c index 117ad42f120..b5ca3ef8271 100644 --- a/drivers/video/savage/savagefb_driver.c +++ b/drivers/video/savage/savagefb_driver.c @@ -1400,6 +1400,58 @@ static int savagefb_pan_display (struct fb_var_screeninfo *var, return 0; } +static int savagefb_blank(int blank, struct fb_info *info) +{ + struct savagefb_par *par = info->par; + u8 sr8 = 0, srd = 0; + + if (par->display_type == DISP_CRT) { + vga_out8(0x3c4, 0x08); + sr8 = vga_in8(0x3c5); + sr8 |= 0x06; + vga_out8(0x3c5, sr8); + vga_out8(0x3c4, 0x0d); + srd = vga_in8(0x3c5); + srd &= 0x03; + + switch (blank) { + case FB_BLANK_UNBLANK: + case FB_BLANK_NORMAL: + break; + case FB_BLANK_VSYNC_SUSPEND: + srd |= 0x10; + break; + case FB_BLANK_HSYNC_SUSPEND: + srd |= 0x40; + break; + case FB_BLANK_POWERDOWN: + srd |= 0x50; + break; + } + + vga_out8(0x3c4, 0x0d); + vga_out8(0x3c5, srd); + } + + if (par->display_type == DISP_LCD || + par->display_type == DISP_DFP) { + switch(blank) { + case FB_BLANK_UNBLANK: + case FB_BLANK_NORMAL: + vga_out8(0x3c4, 0x31); /* SR31 bit 4 - FP enable */ + vga_out8(0x3c5, vga_in8(0x3c5) | 0x10); + break; + case FB_BLANK_VSYNC_SUSPEND: + case FB_BLANK_HSYNC_SUSPEND: + case FB_BLANK_POWERDOWN: + vga_out8(0x3c4, 0x31); /* SR31 bit 4 - FP enable */ + vga_out8(0x3c5, vga_in8(0x3c5) & ~0x10); + break; + } + } + + return (blank == FB_BLANK_NORMAL) ? 1 : 0; +} static struct fb_ops savagefb_ops = { .owner = THIS_MODULE, @@ -1407,6 +1459,7 @@ static struct fb_ops savagefb_ops = { .fb_set_par = savagefb_set_par, .fb_setcolreg = savagefb_setcolreg, .fb_pan_display = savagefb_pan_display, + .fb_blank = savagefb_blank, #if defined(CONFIG_FB_SAVAGE_ACCEL) .fb_fillrect = savagefb_fillrect, .fb_copyarea = savagefb_copyarea, @@ -1583,8 +1636,7 @@ static int __devinit savage_init_hw (struct savagefb_par *par) static unsigned char RamSavage4[] = { 2, 4, 8, 12, 16, 32, 64, 32 }; static unsigned char RamSavageMX[] = { 2, 8, 4, 16, 8, 16, 4, 16 }; static unsigned char RamSavageNB[] = { 0, 2, 4, 8, 16, 32, 2, 2 }; - - int videoRam, videoRambytes; + int videoRam, videoRambytes, dvi; DBG("savage_init_hw"); @@ -1705,6 +1757,30 @@ static int __devinit savage_init_hw (struct savagefb_par *par) printk (KERN_INFO "savagefb: Detected current MCLK value of %d kHz\n", par->MCLK); + /* check for DVI/flat panel */ + dvi = 0; + + if (par->chip == S3_SAVAGE4) { + unsigned char sr30 = 0x00; + + vga_out8(0x3c4, 0x30); + /* clear bit 1 */ + vga_out8(0x3c5, vga_in8(0x3c5) & ~0x02); + sr30 = vga_in8(0x3c5); + if (sr30 & 0x02 /*0x04 */) { + dvi = 1; + printk("savagefb: Digital Flat Panel Detected\n"); + } + } + + if (S3_SAVAGE_MOBILE_SERIES(par->chip) || + (S3_MOBILE_TWISTER_SERIES(par->chip) && !par->crtonly)) + par->display_type = DISP_LCD; + else if (dvi || (par->chip == S3_SAVAGE4 && par->dvi)) + par->display_type = DISP_DFP; + else + par->display_type = DISP_CRT; + /* Check LCD panel parrmation */ if (par->chip == S3_SAVAGE_MX) { @@ -1759,7 +1835,8 @@ static int __devinit savage_init_hw (struct savagefb_par *par) par->SavagePanelWidth = panelX; par->SavagePanelHeight = panelY; - } + } else + par->display_type = DISP_CRT; } savage_get_default_par (par); @@ -1845,15 +1922,15 @@ static int __devinit savage_init_fb_info (struct fb_info *info, snprintf (info->fix.id, 16, "ProSavageKM"); break; case FB_ACCEL_S3TWISTER_P: - par->chip = S3_PROSAVAGE; + par->chip = S3_TWISTER; snprintf (info->fix.id, 16, "TwisterP"); break; case FB_ACCEL_S3TWISTER_K: - par->chip = S3_PROSAVAGE; + par->chip = S3_TWISTER; snprintf (info->fix.id, 16, "TwisterK"); break; case FB_ACCEL_PROSAVAGE_DDR: - par->chip = S3_PROSAVAGE; + par->chip = S3_PROSAVAGEDDR; snprintf (info->fix.id, 16, "ProSavageDDR"); break; case FB_ACCEL_PROSAVAGE_DDRK: @@ -1899,12 +1976,11 @@ static int __devinit savage_init_fb_info (struct fb_info *info, info->pixmap.buf_align = 4; info->pixmap.access_align = 32; - fb_alloc_cmap (&info->cmap, NR_PALETTE, 0); + err = fb_alloc_cmap (&info->cmap, NR_PALETTE, 0); + if (!err) info->flags |= FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_IMAGEBLIT; - - err = 0; } #endif return err; @@ -1932,14 +2008,14 @@ static int __devinit savagefb_probe (struct pci_dev* dev, if (err) goto failed_enable; - if (pci_request_regions(dev, "savagefb")) { + if ((err = pci_request_regions(dev, "savagefb"))) { printk(KERN_ERR "cannot request PCI regions\n"); goto failed_enable; } err = -ENOMEM; - if (savage_init_fb_info(info, dev, id)) + if ((err = savage_init_fb_info(info, dev, id))) goto failed_init; err = savage_map_mmio(info); @@ -1947,6 +2023,7 @@ static int __devinit savagefb_probe (struct pci_dev* dev, goto failed_mmio; video_len = savage_init_hw(par); + /* FIXME: cant be negative */ if (video_len < 0) { err = video_len; goto failed_mmio; @@ -1959,7 +2036,8 @@ static int __devinit savagefb_probe (struct pci_dev* dev, INIT_LIST_HEAD(&info->modelist); #if defined(CONFIG_FB_SAVAGE_I2C) savagefb_create_i2c_busses(info); - savagefb_probe_i2c_connector(par, &par->edid); + savagefb_probe_i2c_connector(info, &par->edid); + kfree(par->edid); fb_edid_to_monspecs(par->edid, &info->monspecs); fb_videomode_to_modelist(info->monspecs.modedb, info->monspecs.modedb_len, @@ -2111,13 +2189,30 @@ static int savagefb_suspend (struct pci_dev* dev, pm_message_t state) DBG("savagefb_suspend"); + + par->pm_state = state.event; + + /* + * For PM_EVENT_FREEZE, do not power down so the console + * can remain active. + */ + if (state.event == PM_EVENT_FREEZE) { + dev->dev.power.power_state = state; + return 0; + } + acquire_console_sem(); - fb_set_suspend(info, pci_choose_state(dev, state)); - savage_disable_mmio(par); - release_console_sem(); + fb_set_suspend(info, 1); + if (info->fbops->fb_sync) + info->fbops->fb_sync(info); + + savagefb_blank(FB_BLANK_POWERDOWN, info); + savage_disable_mmio(par); + pci_save_state(dev); pci_disable_device(dev); pci_set_power_state(dev, pci_choose_state(dev, state)); + release_console_sem(); return 0; } @@ -2127,22 +2222,34 @@ static int savagefb_resume (struct pci_dev* dev) struct fb_info *info = (struct fb_info *)pci_get_drvdata(dev); struct savagefb_par *par = (struct savagefb_par *)info->par; + int cur_state = par->pm_state; DBG("savage_resume"); - pci_set_power_state(dev, 0); - pci_restore_state(dev); - if(pci_enable_device(dev)) - DBG("err"); + par->pm_state = PM_EVENT_ON; - SavagePrintRegs(); + /* + * The adapter was not powered down coming back from a + * PM_EVENT_FREEZE. + */ + if (cur_state == PM_EVENT_FREEZE) { + pci_set_power_state(dev, PCI_D0); + return 0; + } acquire_console_sem(); + pci_set_power_state(dev, PCI_D0); + pci_restore_state(dev); + + if(pci_enable_device(dev)) + DBG("err"); + + pci_set_master(dev); savage_enable_mmio(par); savage_init_hw(par); savagefb_set_par (info); - + savagefb_blank(FB_BLANK_UNBLANK, info); fb_set_suspend (info, 0); release_console_sem(); @@ -2276,3 +2383,6 @@ static int __init savagefb_init(void) module_init(savagefb_init); module_exit(savage_done); + +module_param(mode_option, charp, 0); +MODULE_PARM_DESC(mode_option, "Specify initial video mode"); diff --git a/drivers/video/sis/300vtbl.h b/drivers/video/sis/300vtbl.h index b6d5c71b256..e4b4a2626da 100644 --- a/drivers/video/sis/300vtbl.h +++ b/drivers/video/sis/300vtbl.h @@ -3,7 +3,7 @@ /* * Register settings for SiS 300 series * - * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2005 by Thomas Winischhofer, Vienna, Austria * * If distributed as part of the Linux kernel, the following license terms * apply: @@ -50,31 +50,7 @@ * */ -static const SiS_StStruct SiS300_SModeIDTable[] = -{ - {0x01,0x9208,0x01,0x00,0x00,0x00,0x00,0x00, 0}, - {0x01,0x1210,0x14,0x01,0x01,0x00,0x00,0x00, 0}, - {0x01,0x1010,0x17,0x02,0x02,0x00,0x00,0x00, 0}, - {0x03,0x8208,0x03,0x00,0x00,0x00,0x00,0x00, 0}, - {0x03,0x0210,0x16,0x01,0x01,0x00,0x00,0x00, 0}, - {0x03,0x0010,0x18,0x02,0x02,0x00,0x00,0x00, 0}, - {0x05,0x9209,0x05,0x00,0x00,0x00,0x00,0x00, 0}, - {0x06,0x8209,0x06,0x00,0x00,0x00,0x00,0x00, 0}, - {0x07,0x0000,0x07,0x03,0x03,0x00,0x00,0x00, 0}, - {0x07,0x0000,0x19,0x02,0x02,0x00,0x00,0x00, 0}, - {0x0d,0x920a,0x0d,0x00,0x00,0x00,0x00,0x00, 0}, - {0x0e,0x820a,0x0e,0x00,0x00,0x00,0x00,0x00, 0}, - {0x0f,0x0202,0x11,0x01,0x01,0x00,0x00,0x00, 0}, - {0x10,0x0212,0x12,0x01,0x01,0x00,0x00,0x00, 0}, - {0x11,0x0212,0x1a,0x04,0x04,0x00,0x00,0x00, 0}, - {0x12,0x0212,0x1b,0x04,0x04,0x00,0x00,0x00, 0}, - {0x13,0x021b,0x1c,0x00,0x00,0x00,0x00,0x00, 0}, - {0x12,0x0010,0x18,0x02,0x02,0x00,0x00,0x00, 0}, - {0x12,0x0210,0x18,0x01,0x01,0x00,0x00,0x00, 0}, - {0xff, 0, 0, 0, 0, 0, 0, 0, 0} -}; - -static const SiS_ExtStruct SiS300_EModeIDTable[] = +static const struct SiS_Ext SiS300_EModeIDTable[] = { {0x6a,0x2212,0x0102,SIS_RI_800x600, 0x00,0x00,0x00,0x00,0x00,-1}, /* 800x600x? */ {0x2e,0x0a1b,0x0101,SIS_RI_640x480, 0x00,0x00,0x00,0x00,0x08,-1}, @@ -110,7 +86,7 @@ static const SiS_ExtStruct SiS300_EModeIDTable[] = {0x59,0x921b,0x0138,SIS_RI_320x200, 0x00,0x00,0x00,0x00,0x23,-1}, /* 320x200x8 */ {0x5c,0x921f,0x0000,SIS_RI_512x384, 0x00,0x00,0x00,0x00,0x26,-1}, /* 512x384x32 */ {0x5d,0x021d,0x0139,SIS_RI_640x400, 0x00,0x00,0x00,0x00,0x10,-1}, /* 640x400x16 */ - {0x5e,0x021f,0x0000,SIS_RI_640x400, 0x00,0x00,0x00,0x00,0x10,-1}, /* 640x400x32 */ + {0x5e,0x021f,0x0000,SIS_RI_640x400, 0x00,0x00,0x00,0x00,0x10,-1}, /* 640x400x32 */ {0x62,0x0a3f,0x013a,SIS_RI_640x480, 0x00,0x00,0x00,0x00,0x08,-1}, {0x63,0x2a3f,0x013b,SIS_RI_800x600, 0x00,0x00,0x00,0x00,0x00,-1}, /* 800x600x32 */ {0x64,0x0a7f,0x013c,SIS_RI_1024x768, 0x00,0x00,0x00,0x00,0x13,-1}, @@ -119,8 +95,8 @@ static const SiS_ExtStruct SiS300_EModeIDTable[] = {0x68,0x067b,0x013f,SIS_RI_1920x1440,0x00,0x00,0x00,0x00,0x27,-1}, {0x69,0x06fd,0x0140,SIS_RI_1920x1440,0x00,0x00,0x00,0x00,0x27,-1}, {0x6b,0x07ff,0x0000,SIS_RI_1920x1440,0x00,0x00,0x00,0x00,0x27,-1}, - {0x6c,0x067b,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x00,0x28,-1}, /* 2048x1536x8 - not in BIOS! */ - {0x6d,0x06fd,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x00,0x28,-1}, /* 2048x1536x16 - not in BIOS! */ + {0x6c,0x067b,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x00,0x28,-1}, /* 2048x1536x8 */ + {0x6d,0x06fd,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x00,0x28,-1}, /* 2048x1536x16 */ {0x70,0x6a1b,0x0000,SIS_RI_800x480, 0x00,0x00,0x07,0x00,0x2d,-1}, /* 800x480x8 */ {0x71,0x4a1b,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x00,0x30,-1}, /* 1024x576x8 */ {0x74,0x4a1d,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x00,0x30,-1}, /* 1024x576x16 */ @@ -166,77 +142,77 @@ static const SiS_ExtStruct SiS300_EModeIDTable[] = {0xff,0x0000,0xffff,0, 0x00,0x00,0x00,0x00,0x00} }; -static const SiS_Ext2Struct SiS300_RefIndex[] = -{ - {0x085f,0x0d,0x03,0x05,0x05,0x6a, 800, 600, 0}, /* 00 */ - {0x0467,0x0e,0x44,0x05,0x05,0x6a, 800, 600, 0}, /* 01 */ - {0x0067,0x0f,0x07,0x48,0x05,0x6a, 800, 600, 0}, /* 02 - CRT1CRTC was 0x4f */ - {0x0067,0x10,0x06,0x8b,0x05,0x6a, 800, 600, 0}, /* 03 */ - {0x0147,0x11,0x08,0x00,0x05,0x6a, 800, 600, 0}, /* 04 */ - {0x0147,0x12,0x0c,0x00,0x05,0x6a, 800, 600, 0}, /* 05 */ - {0x0047,0x11,0x4e,0x00,0x05,0x6a, 800, 600, 0}, /* 06 - CRT1CRTC was 0x51 */ - {0x0047,0x11,0x13,0x00,0x05,0x6a, 800, 600, 0}, /* 07 */ - {0xc85f,0x05,0x00,0x04,0x04,0x2e, 640, 480, 0}, /* 08 */ - {0xc067,0x06,0x02,0x04,0x04,0x2e, 640, 480, 0}, /* 09 */ - {0xc067,0x07,0x02,0x47,0x04,0x2e, 640, 480, 0}, /* 0a */ - {0xc067,0x08,0x03,0x8a,0x04,0x2e, 640, 480, 0}, /* 0b */ - {0xc047,0x09,0x05,0x00,0x04,0x2e, 640, 480, 0}, /* 0c */ - {0xc047,0x0a,0x08,0x00,0x04,0x2e, 640, 480, 0}, /* 0d */ - {0xc047,0x0b,0x0a,0x00,0x04,0x2e, 640, 480, 0}, /* 0e */ - {0xc047,0x0c,0x10,0x00,0x04,0x2e, 640, 480, 0}, /* 0f */ - {0x487f,0x04,0x00,0x00,0x00,0x2f, 640, 400, 0}, /* 10 */ - {0xc06f,0x31,0x01,0x06,0x13,0x31, 720, 480, 0}, /* 11 */ - {0x006f,0x32,0x03,0x06,0x14,0x32, 720, 576, 0}, /* 12 */ - {0x0187,0x15,0x05,0x00,0x06,0x37,1024, 768, 0}, /* 13 */ - {0xc877,0x16,0x09,0x06,0x06,0x37,1024, 768, 0}, /* 14 */ - {0xc067,0x17,0x0b,0x49,0x06,0x37,1024, 768, 0}, /* 15 - CRT1CRTC was 0x97 */ - {0x0267,0x18,0x0d,0x00,0x06,0x37,1024, 768, 0}, /* 16 */ - {0x0047,0x19,0x11,0x8c,0x06,0x37,1024, 768, 0}, /* 17 - CRT1CRTC was 0x59 */ - {0x0047,0x1a,0x52,0x00,0x06,0x37,1024, 768, 0}, /* 18 */ - {0x0007,0x1b,0x16,0x00,0x06,0x37,1024, 768, 0}, /* 19 - CRT1CRTC was 0x5b */ - {0x0387,0x1c,0x4d,0x00,0x07,0x3a,1280,1024, 0}, /* 1a - CRT1CRTC was 0x5c */ - {0x0077,0x1d,0x14,0x07,0x07,0x3a,1280,1024, 0}, /* 1b */ - {0x0047,0x1e,0x17,0x00,0x07,0x3a,1280,1024, 0}, /* 1c */ - {0x0007,0x1f,0x98,0x00,0x07,0x3a,1280,1024, 0}, /* 1d */ - {0x0007,0x20,0x59,0x00,0x00,0x3c,1600,1200, 0}, /* 1e - CRT1CRTC was 0x60 */ - {0x0007,0x21,0x5a,0x00,0x00,0x3c,1600,1200, 0}, /* 1f */ - {0x0007,0x22,0x1b,0x00,0x00,0x3c,1600,1200, 0}, /* 20 */ - {0x0007,0x23,0x1d,0x00,0x00,0x3c,1600,1200, 0}, /* 21 - CRT1CRTC was 0x63 */ - {0x0007,0x24,0x1e,0x00,0x00,0x3c,1600,1200, 0}, /* 22 */ - {0x407f,0x00,0x00,0x00,0x00,0x40, 320, 200, 0}, /* 23 */ - {0xc07f,0x01,0x00,0x04,0x04,0x50, 320, 240, 0}, /* 24 */ - {0x0077,0x02,0x04,0x05,0x05,0x51, 400, 300, 0}, /* 25 */ - {0xc877,0x03,0x09,0x06,0x06,0x52, 512, 384, 0}, /* 26 */ /* was c077 */ - {0x8207,0x25,0x1f,0x00,0x00,0x68,1920,1440, 0}, /* 27 */ - {0x0007,0x26,0x20,0x00,0x00,0x6c,2048,1536, 0}, /* 28 */ - {0x0067,0x27,0x14,0x08,0x0a,0x6e,1280, 960, 0}, /* 29 - 1280x960-60 */ - {0x0027,0x45,0x3c,0x08,0x0a,0x6e,1280, 960, 0}, /* 2a - 1280x960-85 */ - {0xc077,0x33,0x09,0x06,0x00,0x20,1024, 600, 0}, /* 2b */ - {0xc077,0x34,0x0b,0x06,0x00,0x23,1152, 768, 0}, /* 2c */ /* VCLK 0x09 */ - {0x0077,0x35,0x27,0x08,0x18,0x70, 800, 480, 0}, /* 2d */ - {0x0047,0x36,0x37,0x08,0x18,0x70, 800, 480, 0}, /* 2e */ - {0x0047,0x37,0x08,0x08,0x18,0x70, 800, 480, 0}, /* 2f */ - {0x0077,0x38,0x09,0x09,0x19,0x71,1024, 576, 0}, /* 30 */ - {0x0047,0x39,0x38,0x09,0x19,0x71,1024, 576, 0}, /* 31 */ - {0x0047,0x3a,0x11,0x09,0x19,0x71,1024, 576, 0}, /* 32 */ - {0x0077,0x3b,0x39,0x0a,0x0c,0x75,1280, 720, 0}, /* 33 */ - {0x0047,0x3c,0x3a,0x0a,0x0c,0x75,1280, 720, 0}, /* 34 */ - {0x0007,0x3d,0x3b,0x0a,0x0c,0x75,1280, 720, 0}, /* 35 */ - {0x0067,0x49,0x35,0x06,0x1a,0x29,1152, 864, 0}, /* 36 1152x864-60Hz */ - {0x0067,0x3e,0x34,0x06,0x1a,0x29,1152, 864, 0}, /* 37 1152x864-75Hz */ - {0x0047,0x44,0x3a,0x06,0x1a,0x29,1152, 864, 0}, /* 38 1152x864-85Hz */ - {0x00c7,0x3f,0x28,0x00,0x16,0x39, 848, 480, 0}, /* 39 848x480-38Hzi */ - {0xc067,0x40,0x3d,0x0b,0x16,0x39, 848, 480, 0}, /* 3a 848x480-60Hz */ - {0x00c7,0x41,0x28,0x00,0x17,0x3f, 856, 480, 0}, /* 3b 856x480-38Hzi */ - {0xc047,0x42,0x28,0x00,0x17,0x3f, 856, 480, 0}, /* 3c 856x480-60Hz */ - {0x0067,0x43,0x3e,0x0c,0x1b,0x48,1360, 768, 0}, /* 3d 1360x768-60Hz */ - {0x0077,0x46,0x3f,0x08,0x08,0x55,1280, 768, 0}, /* 3e 1280x768-60Hz */ - {0x006f,0x47,0x03,0x06,0x15,0x5f, 768, 576, 0}, /* 3f 768x576 */ - {0x0027,0x48,0x13,0x08,0x00,0x67,1360,1024, 0}, /* 40 1360x1024-59Hz (BARCO1366 only) */ - {0xffff, 0, 0, 0, 0, 0, 0, 0, 0} -}; - -static const SiS_VBModeStruct SiS300_VBModeIDTable[] = +static const struct SiS_Ext2 SiS300_RefIndex[] = +{ + {0x085f,0x0d,0x03,0x05,0x05,0x6a, 800, 600, 0, 0x00, 0x00}, /* 00 */ + {0x0467,0x0e,0x04,0x05,0x05,0x6a, 800, 600, 0, 0x00, 0x00}, /* 01 */ + {0x0067,0x0f,0x07,0x48,0x05,0x6a, 800, 600, 0, 0x00, 0x00}, /* 02 - CRT1CRTC was 0x4f */ + {0x0067,0x10,0x06,0x8b,0x05,0x6a, 800, 600, 0, 0x00, 0x00}, /* 03 */ + {0x0147,0x11,0x08,0x00,0x05,0x6a, 800, 600, 0, 0x00, 0x00}, /* 04 */ + {0x0147,0x12,0x0c,0x00,0x05,0x6a, 800, 600, 0, 0x00, 0x00}, /* 05 */ + {0x0047,0x11,0x0e,0x00,0x05,0x6a, 800, 600, 0, 0x00, 0x00}, /* 06 - CRT1CRTC was 0x51 */ + {0x0047,0x11,0x13,0x00,0x05,0x6a, 800, 600, 0, 0x00, 0x00}, /* 07 */ + {0xc85f,0x05,0x00,0x04,0x04,0x2e, 640, 480, 0, 0x00, 0x00}, /* 08 */ + {0xc067,0x06,0x02,0x04,0x04,0x2e, 640, 480, 0, 0x00, 0x00}, /* 09 */ + {0xc067,0x07,0x02,0x47,0x04,0x2e, 640, 480, 0, 0x00, 0x00}, /* 0a */ + {0xc067,0x08,0x03,0x8a,0x04,0x2e, 640, 480, 0, 0x00, 0x00}, /* 0b */ + {0xc047,0x09,0x05,0x00,0x04,0x2e, 640, 480, 0, 0x00, 0x00}, /* 0c */ + {0xc047,0x0a,0x08,0x00,0x04,0x2e, 640, 480, 0, 0x00, 0x00}, /* 0d */ + {0xc047,0x0b,0x0a,0x00,0x04,0x2e, 640, 480, 0, 0x00, 0x00}, /* 0e */ + {0xc047,0x0c,0x10,0x00,0x04,0x2e, 640, 480, 0, 0x00, 0x00}, /* 0f */ + {0x487f,0x04,0x00,0x00,0x00,0x2f, 640, 400, 0, 0x4a, 0x49}, /* 10 */ + {0xc06f,0x31,0x01,0x06,0x13,0x31, 720, 480, 0, 0x00, 0x00}, /* 11 */ + {0x006f,0x32,0x4a,0x06,0x14,0x32, 720, 576, 0, 0x00, 0x00}, /* 12 */ /* 4a was 03 */ + {0x0187,0x15,0x05,0x00,0x06,0x37,1024, 768, 0, 0x00, 0x00}, /* 13 */ + {0xc877,0x16,0x09,0x06,0x06,0x37,1024, 768, 0, 0x00, 0x00}, /* 14 */ + {0xc067,0x17,0x0b,0x49,0x06,0x37,1024, 768, 0, 0x00, 0x00}, /* 15 - CRT1CRTC was 0x97 */ + {0x0267,0x18,0x0d,0x00,0x06,0x37,1024, 768, 0, 0x00, 0x00}, /* 16 */ + {0x0047,0x19,0x11,0x8c,0x06,0x37,1024, 768, 0, 0x00, 0x00}, /* 17 - CRT1CRTC was 0x59 */ + {0x0047,0x1a,0x12,0x00,0x06,0x37,1024, 768, 0, 0x00, 0x00}, /* 18 */ + {0x0007,0x1b,0x16,0x00,0x06,0x37,1024, 768, 0, 0x00, 0x00}, /* 19 - CRT1CRTC was 0x5b */ + {0x0387,0x1c,0x0d,0x00,0x07,0x3a,1280,1024, 0, 0x00, 0x00}, /* 1a - CRT1CRTC was 0x5c */ + {0x0077,0x1d,0x14,0x07,0x07,0x3a,1280,1024, 0, 0x00, 0x00}, /* 1b */ + {0x0047,0x1e,0x17,0x00,0x07,0x3a,1280,1024, 0, 0x00, 0x00}, /* 1c */ + {0x0007,0x1f,0x18,0x00,0x07,0x3a,1280,1024, 0, 0x00, 0x00}, /* 1d */ + {0x0007,0x20,0x19,0x00,0x00,0x3c,1600,1200, 0, 0x00, 0x00}, /* 1e - CRT1CRTC was 0x60 */ + {0x0007,0x21,0x1a,0x00,0x00,0x3c,1600,1200, 0, 0x00, 0x00}, /* 1f */ + {0x0007,0x22,0x1b,0x00,0x00,0x3c,1600,1200, 0, 0x00, 0x00}, /* 20 */ + {0x0007,0x23,0x1d,0x00,0x00,0x3c,1600,1200, 0, 0x00, 0x00}, /* 21 - CRT1CRTC was 0x63 */ + {0x0007,0x24,0x1e,0x00,0x00,0x3c,1600,1200, 0, 0x00, 0x00}, /* 22 */ + {0x407f,0x00,0x00,0x00,0x00,0x40, 320, 200, 0, 0x4b, 0x4b}, /* 23 */ + {0xc07f,0x01,0x00,0x04,0x04,0x50, 320, 240, 0, 0x00, 0x00}, /* 24 */ + {0x0077,0x02,0x04,0x05,0x05,0x51, 400, 300, 0, 0x00, 0x00}, /* 25 */ + {0xc877,0x03,0x09,0x06,0x06,0x52, 512, 384, 0, 0x00, 0x00}, /* 26 */ /* was c077 */ + {0x8207,0x25,0x1f,0x00,0x00,0x68,1920,1440, 0, 0x00, 0x00}, /* 27 */ + {0x0007,0x26,0x20,0x00,0x00,0x6c,2048,1536, 0, 0x00, 0x00}, /* 28 */ + {0x0067,0x27,0x14,0x08,0x0a,0x6e,1280, 960, 0, 0x00, 0x00}, /* 29 - 1280x960-60 */ + {0x0027,0x45,0x3c,0x08,0x0a,0x6e,1280, 960, 0, 0x00, 0x00}, /* 2a - 1280x960-85 */ + {0xc077,0x33,0x09,0x06,0x00,0x20,1024, 600, 0, 0x00, 0x00}, /* 2b */ + {0xc077,0x34,0x0b,0x06,0x00,0x23,1152, 768, 0, 0x00, 0x00}, /* 2c */ /* VCLK 0x09 */ + {0x0077,0x35,0x27,0x08,0x18,0x70, 800, 480, 0, 0x00, 0x00}, /* 2d */ + {0x0047,0x36,0x37,0x08,0x18,0x70, 800, 480, 0, 0x00, 0x00}, /* 2e */ + {0x0047,0x37,0x08,0x08,0x18,0x70, 800, 480, 0, 0x00, 0x00}, /* 2f */ + {0x0077,0x38,0x09,0x09,0x19,0x71,1024, 576, 0, 0x00, 0x00}, /* 30 */ + {0x0047,0x39,0x38,0x09,0x19,0x71,1024, 576, 0, 0x00, 0x00}, /* 31 */ + {0x0047,0x3a,0x11,0x09,0x19,0x71,1024, 576, 0, 0x00, 0x00}, /* 32 */ + {0x0077,0x3b,0x39,0x0a,0x0c,0x75,1280, 720, 0, 0x00, 0x00}, /* 33 */ + {0x0047,0x3c,0x3a,0x0a,0x0c,0x75,1280, 720, 0, 0x00, 0x00}, /* 34 */ + {0x0007,0x3d,0x3b,0x0a,0x0c,0x75,1280, 720, 0, 0x00, 0x00}, /* 35 */ + {0x0067,0x49,0x35,0x06,0x1a,0x29,1152, 864, 0, 0x00, 0x00}, /* 36 1152x864-60Hz */ + {0x0067,0x3e,0x34,0x06,0x1a,0x29,1152, 864, 0, 0x00, 0x00}, /* 37 1152x864-75Hz */ + {0x0047,0x44,0x3a,0x06,0x1a,0x29,1152, 864, 0, 0x00, 0x00}, /* 38 1152x864-85Hz */ + {0x00c7,0x3f,0x28,0x00,0x16,0x39, 848, 480, 0, 0x00, 0x00}, /* 39 848x480-38Hzi */ + {0xc067,0x40,0x3d,0x0b,0x16,0x39, 848, 480, 0, 0x00, 0x00}, /* 3a 848x480-60Hz */ + {0x00c7,0x41,0x28,0x00,0x17,0x3f, 856, 480, 0, 0x00, 0x00}, /* 3b 856x480-38Hzi */ + {0xc067,0x42,0x28,0x0c,0x17,0x3f, 856, 480, 0, 0x00, 0x00}, /* 3c 856x480-60Hz */ + {0x0067,0x43,0x3e,0x0d,0x1b,0x48,1360, 768, 0, 0x00, 0x00}, /* 3d 1360x768-60Hz */ + {0x0077,0x46,0x3f,0x08,0x08,0x55,1280, 768, 0, 0x00, 0x00}, /* 3e 1280x768-60Hz */ + {0x006f,0x47,0x4c,0x06,0x15,0x5f, 768, 576, 0, 0x00, 0x00}, /* 3f 768x576 */ + {0x0027,0x48,0x13,0x08,0x00,0x67,1360,1024, 0, 0x00, 0x00}, /* 40 1360x1024-59Hz (BARCO1366 only) */ + {0xffff, 0, 0, 0, 0, 0, 0, 0, 0, 0x00, 0x00} +}; + +static const struct SiS_VBMode SiS300_VBModeIDTable[] = { {0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01}, @@ -303,53 +279,26 @@ static const SiS_VBModeStruct SiS300_VBModeIDTable[] = {0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00} }; -static const SiS_CRT1TableStruct SiS300_CRT1Table[] = +static const struct SiS_CRT1Table SiS300_CRT1Table[] = { -#if 1 {{0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f, /* 0x00 - 320x200 */ 0x9c,0x8e,0x8f,0x96,0xb9,0x30,0x00,0x00, /* HRE [4],[15] is invalid - but correcting it does not work */ 0x00}}, -#endif -#if 0 - {{0x2d,0x27,0x27,0x91,0x2c,0x92,0xbf,0x1f, /* 0x00 - corrected 320x200-72 - does not work */ - 0x9c,0x8e,0x8f,0x96,0xb9,0x30,0x00,0x04, - 0x00}}, -#endif {{0x2d,0x27,0x28,0x90,0x2c,0x80,0x0b,0x3e, /* 0x01 */ 0xe9,0x8b,0xdf,0xe7,0x04,0x00,0x00,0x00, /* HRE [4],[15] is invalid - but correcting it does not work */ 0x00}}, -#if 0 - {{0x2d,0x27,0x27,0x91,0x2c,0x92,0x0b,0x3e, /* 0x01 - corrected 320x240-60 - does not work */ - 0xe9,0x8b,0xdf,0xe7,0x04,0x00,0x00,0x04, - 0x00}}, -#endif {{0x3d,0x31,0x31,0x81,0x37,0x1f,0x72,0xf0, /* 0x02 */ 0x58,0x8c,0x57,0x57,0x73,0x20,0x00,0x05, 0x01}}, -#if 0 - {{0x3d,0x31,0x31,0x81,0x37,0x1f,0x72,0xf0, /* 0x02 - corrected 400x300-60 */ - 0x58,0x8c,0x57,0x57,0x73,0x20,0x00,0x05, - 0x01}}, -#endif {{0x4f,0x3f,0x3f,0x93,0x45,0x0d,0x24,0xf5, 0x02,0x88,0xff,0xff,0x25,0x10,0x00,0x01, 0x01}}, {{0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, 0x9c,0x8e,0x8f,0x96,0xb9,0x30,0x00,0x05, 0x00}}, -#if 0 - {{0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e, /* 0x05 */ - 0xe9,0x8b,0xdf,0xe7,0x04,0x00,0x00,0x05, - 0x00}}, -#endif {{0x5f,0x4f,0x4f,0x83,0x55,0x81,0x0b,0x3e, /* 0x05 - corrected 640x480-60 */ 0xe9,0x8b,0xdf,0xe8,0x0c,0x00,0x00,0x05, 0x00}}, -#if 0 - {{0x63,0x4f,0x50,0x86,0x56,0x9b,0x06,0x3e, /* 0x06 */ - 0xe8,0x8b,0xdf,0xe7,0xff,0x10,0x00,0x01, - 0x00}}, -#endif {{0x63,0x4f,0x4f,0x87,0x56,0x9b,0x06,0x3e, /* 0x06 - corrected 640x480-72 */ 0xe8,0x8a,0xdf,0xe7,0x07,0x00,0x00,0x01, 0x00}}, @@ -359,19 +308,9 @@ static const SiS_CRT1TableStruct SiS300_CRT1Table[] = {{0x63,0x4f,0x4f,0x87,0x5a,0x81,0xfb,0x1f, 0xe0,0x83,0xdf,0xdf,0xfc,0x10,0x00,0x05, 0x00}}, -#if 0 - {{0x66,0x4f,0x4f,0x86,0x56,0x9e,0x03,0x3e, /* 0x09 */ - 0xe4,0x87,0xdf,0xdf,0x04,0x00,0x00,0x01, - 0x00}}, -#endif {{0x67,0x4f,0x4f,0x8b,0x57,0x83,0x10,0x3e, /* 0x09 - corrected 640x480-100 */ 0xe7,0x8d,0xdf,0xe6,0x11,0x00,0x00,0x05, 0x00}}, -#if 0 - {{0x6c,0x4f,0x4f,0x83,0x59,0x9e,0x00,0x3e, /* 0x0a */ - 0xe5,0x8d,0xdf,0xdf,0x01,0x00,0x00,0x01, - 0x00}}, -#endif {{0x67,0x4f,0x4f,0x8b,0x57,0x83,0x10,0x3e, /* 0x0a - corrected 640x480-120 */ 0xe7,0x8d,0xdf,0xe6,0x11,0x00,0x00,0x05, 0x00}}, @@ -459,11 +398,6 @@ static const SiS_CRT1TableStruct SiS300_CRT1Table[] = {{0x55,0xff,0xff,0x99,0x0d,0x0c,0x3e,0xba, 0x00,0x84,0xff,0xff,0x3f,0x0f,0x41,0x05, 0x00}}, -#if 0 - {{0xdc,0x9f,0x9f,0x00,0xab,0x19,0xe6,0xef, /* 0x27: 1280x960-70 - invalid! */ - 0xc0,0xc3,0xbf,0xbf,0xe7,0x10,0x00,0x07, - 0x01}}, -#endif {{0xdc,0x9f,0x9f,0x80,0xaf,0x9d,0xe6,0xff, /* 0x27: 1280x960-60 - correct */ 0xc0,0x83,0xbf,0xbf,0xe7,0x10,0x00,0x07, 0x01}}, @@ -497,9 +431,9 @@ static const SiS_CRT1TableStruct SiS300_CRT1Table[] = {{0x6b,0x59,0x59,0x8f,0x5e,0x8c,0x0b,0x3e, 0xe9,0x8b,0xdf,0xe7,0x04,0x00,0x00,0x05, 0x00}}, - {{0x7b,0x59,0x63,0x9f,0x6a,0x93,0x6f,0xf0, /* 0x32 */ - 0x58,0x8a,0x3f,0x57,0x70,0x20,0x00,0x05, - 0x01}}, + {{0x6d,0x59,0x59,0x91,0x60,0x89,0x53,0xf0, /* 0x32: 720x576, corrected to 60Hz */ + 0x41,0x84,0x3f,0x3f,0x54,0x00,0x00,0x05, + 0x41}}, {{0xa3,0x7f,0x7f,0x87,0x86,0x97,0x1e,0xf1, /* 0x33 - 1024x600 */ 0xae,0x85,0x57,0x57,0x1f,0x30,0x00,0x02, 0x01}}, @@ -560,18 +494,24 @@ static const SiS_CRT1TableStruct SiS300_CRT1Table[] = {{0xce,0x9f,0x9f,0x92,0xa9,0x17,0x20,0xf5, /* 1280x768-60 */ 0x03,0x88,0xff,0xff,0x21,0x10,0x00,0x07, 0x01}}, /* 0x46 */ - {{0x7b,0x5f,0x63,0x9f,0x6a,0x93,0x6f,0xf0, /* 768x576 */ - 0x58,0x8a,0x3f,0x57,0x70,0x20,0x00,0x05, - 0x01}}, /* 0x47 */ + {{0x75,0x5f,0x5f,0x99,0x66,0x90,0x53,0xf0, /* 768x576, corrected to 60Hz */ + 0x41,0x84,0x3f,0x3f,0x54,0x00,0x00,0x05, + 0x41}}, /* 0x47 */ {{0xce,0xa9,0xa9,0x92,0xb1,0x07,0x28,0x52, /* 1360x1024 (Barco iQ Pro R300) */ 0x02,0x8e,0xff,0x00,0x29,0x0d,0x00,0x03, 0x00}}, /* 0x48 */ {{0xcd,0x8f,0x8f,0x91,0x9b,0x1b,0x7a,0xff, /* 1152x864-60 */ 0x64,0x8c,0x5f,0x62,0x7b,0x10,0x00,0x07, - 0x41}} /* 0x49 */ + 0x41}}, /* 0x49 */ + {{0x5c,0x4f,0x4f,0x80,0x57,0x80,0xa3,0x1f, /* fake 640x400@60Hz (for LCD and TV, not actually used) */ + 0x98,0x8c,0x8f,0x96,0xa4,0x30,0x00,0x05, + 0x40}}, /* 0x4a */ + {{0x2c,0x27,0x27,0x90,0x2d,0x92,0xa4,0x1f, /* fake 320x200@60Hz (for LCD and TV, not actually used) */ + 0x98,0x8c,0x8f,0x96,0xa5,0x30,0x00,0x04, + 0x00}} /* 0x4b */ }; -static const SiS_MCLKDataStruct SiS300_MCLKData_630[] = +static const struct SiS_MCLKData SiS300_MCLKData_630[] = { { 0x5a,0x64,0x80, 66}, { 0xb3,0x45,0x80, 83}, @@ -583,7 +523,7 @@ static const SiS_MCLKDataStruct SiS300_MCLKData_630[] = { 0x37,0x61,0x80,100} }; -static const SiS_MCLKDataStruct SiS300_MCLKData_300[] = +static const struct SiS_MCLKData SiS300_MCLKData_300[] = { { 0x68,0x43,0x80,125}, { 0x68,0x43,0x80,125}, @@ -595,7 +535,7 @@ static const SiS_MCLKDataStruct SiS300_MCLKData_300[] = { 0x37,0x61,0x80,100} }; -static SiS_VCLKDataStruct SiS300_VCLKData[] = +static struct SiS_VCLKData SiS300_VCLKData[] = { { 0x1b,0xe1, 25}, /* 0x00 */ { 0x4e,0xe4, 28}, /* 0x01 */ @@ -669,53 +609,26 @@ static SiS_VCLKDataStruct SiS300_VCLKData[] = { 0xe2,0x46,135}, /* 0x45 */ /* 1280x1024-75, better clock for VGA2 */ { 0x70,0x29, 81}, /* 0x46 */ /* unused */ { 0, 0, 0}, /* 0x47 custom (will be filled out) */ - { 0xce,0x25,189} /* 0x48 */ /* Replacement for index 0x1b for 730 (and 540?) */ + { 0xce,0x25,189}, /* 0x48 */ /* Replacement for index 0x1b for 730 (and 540?) */ + { 0x15,0xe1, 20}, /* 0x49 */ /* 640x400@60 (fake, not actually used) */ + { 0x5f,0xc6, 33}, /* 0x4a */ /* 720x576@60 */ + { 0x37,0x5a, 10}, /* 0x4b */ /* 320x200@60 (fake, not actually used) */ + { 0x2b,0xc2, 35} /* 0x4c */ /* 768@576@60 */ }; -#ifdef LINUX_KERNEL -static UCHAR SiS300_SR07 = 0x10; -#endif - -static const DRAM4Type SiS300_SR15[8] = +static const unsigned char SiS300_SR15[4 * 8] = { - {0x01,0x09,0xa3,0x00}, - {0x43,0x43,0x43,0x00}, - {0x1e,0x1e,0x1e,0x00}, - {0x2a,0x2a,0x2a,0x00}, - {0x06,0x06,0x06,0x00}, - {0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00} + 0x01,0x09,0xa3,0x00, + 0x43,0x43,0x43,0x00, + 0x1e,0x1e,0x1e,0x00, + 0x2a,0x2a,0x2a,0x00, + 0x06,0x06,0x06,0x00, + 0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00 }; -#ifdef LINUX_KERNEL -static UCHAR SiS300_SR1F = 0x00; -static UCHAR SiS300_SR21 = 0x16; -static UCHAR SiS300_SR22 = 0xb2; -static UCHAR SiS300_SR23 = 0xf6; -static UCHAR SiS300_SR24 = 0x0d; -static UCHAR SiS300_SR25[] = {0x0,0x0}; -static UCHAR SiS300_SR31 = 0x00; -static UCHAR SiS300_SR32 = 0x11; -static UCHAR SiS300_SR33 = 0x00; -static UCHAR SiS300_CRT2Data_1_2 = 0x40; -static UCHAR SiS300_CRT2Data_4_D = 0x00; -static UCHAR SiS300_CRT2Data_4_E = 0x00; -static UCHAR SiS300_CRT2Data_4_10 = 0x80; - -static const USHORT SiS300_RGBSenseData = 0xd1; -static const USHORT SiS300_VideoSenseData = 0xb3; -static const USHORT SiS300_YCSenseData = 0xb9; -static const USHORT SiS300_RGBSenseData2 = 0x0190; -static const USHORT SiS300_VideoSenseData2 = 0x0174; -static const USHORT SiS300_YCSenseData2 = 0x016b; - -static const DRAM4Type SiS300_CR40[5]; - -static UCHAR SiS300_CR49[2]; -#endif - -static const SiS_PanelDelayTblStruct SiS300_PanelDelayTbl[] = +static const struct SiS_PanelDelayTbl SiS300_PanelDelayTbl[] = { {{0x05,0xaa}}, {{0x05,0x14}}, @@ -735,33 +648,11 @@ static const SiS_PanelDelayTblStruct SiS300_PanelDelayTbl[] = {{0x05,0x60}} }; -#if 0 -static const SiS_PanelDelayTblStruct SiS300_PanelDelayTblLVDS[] = -{ - {{0x05,0xaa}}, - {{0x05,0x14}}, - {{0x05,0x36}}, - {{0x05,0x14}}, - {{0x05,0x14}}, - {{0x05,0x14}}, - {{0x05,0x90}}, - {{0x05,0x90}}, - {{0x05,0x14}}, - {{0x05,0x14}}, - {{0x05,0x14}}, - {{0x05,0x14}}, /* 2.07a (JVC): 14,96 */ - {{0x05,0x28}}, /* 2.04.5c: 20, 80 - Clevo (2.04.2c): 05, 28 */ - {{0x05,0x14}}, - {{0x05,0x14}}, /* Some BIOSes: 05, 40 */ - {{0x05,0x60}} -}; -#endif - /**************************************************************/ /* SIS VIDEO BRIDGE ----------------------------------------- */ /**************************************************************/ -static const SiS_LCDDataStruct SiS300_St2LCD1024x768Data[] = +static const struct SiS_LCDData SiS300_St2LCD1024x768Data[] = { { 62, 25, 800, 546,1344, 806}, { 32, 15, 930, 546,1344, 806}, @@ -772,7 +663,7 @@ static const SiS_LCDDataStruct SiS300_St2LCD1024x768Data[] = { 1, 1,1344, 806,1344, 806} }; -static const SiS_LCDDataStruct SiS300_ExtLCD1024x768Data[] = +static const struct SiS_LCDData SiS300_ExtLCD1024x768Data[] = { { 12, 5, 896, 512,1344, 806}, { 12, 5, 896, 510,1344, 806}, @@ -789,7 +680,7 @@ static const SiS_LCDDataStruct SiS300_ExtLCD1024x768Data[] = { 1, 1,1344, 806,1344, 806} }; -static const SiS_LCDDataStruct SiS300_St2LCD1280x1024Data[] = +static const struct SiS_LCDData SiS300_St2LCD1280x1024Data[] = { { 22, 5, 800, 510,1650,1088}, { 22, 5, 800, 510,1650,1088}, @@ -801,7 +692,7 @@ static const SiS_LCDDataStruct SiS300_St2LCD1280x1024Data[] = { 1, 1,1688,1066,1688,1066} }; -static const SiS_LCDDataStruct SiS300_ExtLCD1280x1024Data[] = +static const struct SiS_LCDData SiS300_ExtLCD1280x1024Data[] = { { 211, 60,1024, 501,1688,1066}, { 211, 60,1024, 508,1688,1066}, @@ -813,53 +704,116 @@ static const SiS_LCDDataStruct SiS300_ExtLCD1280x1024Data[] = { 1, 1,1688,1066,1688,1066} }; -static const SiS_Part2PortTblStruct SiS300_CRT2Part2_1024x768_1[] = +static const struct SiS_Part2PortTbl SiS300_CRT2Part2_1024x768_1[] = { /* VESA Timing */ - {{0x21,0x12,0xbf,0xe4,0xc0,0x21,0x45,0x09,0x00,0xa9,0x09,0x04}}, - {{0x2c,0x12,0x9a,0xae,0x88,0x21,0x45,0x09,0x00,0xa9,0x09,0x04}}, - {{0x21,0x12,0xbf,0xe4,0xc0,0x21,0x45,0x09,0x00,0xa9,0x09,0x04}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x22,0x13,0xfe,0x25,0xff,0x21,0x45,0x0a,0x00,0xa9,0x0d,0x04}}, - {{0x22,0x13,0xfe,0x25,0xff,0x21,0x45,0x0a,0x00,0xa9,0x0d,0x04}}, - {{0x22,0x13,0xfe,0x25,0xff,0x21,0x45,0x0a,0x00,0xa9,0x0d,0x04}} + {{0x21,0x12,0xbf,0xe4,0xc0,0x21,0x45,0x09,0x00,0xa9,0x09,0x04}}, + {{0x2c,0x12,0x9a,0xae,0x88,0x21,0x45,0x09,0x00,0xa9,0x09,0x04}}, + {{0x21,0x12,0xbf,0xe4,0xc0,0x21,0x45,0x09,0x00,0xa9,0x09,0x04}}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, + {{0x22,0x13,0xfe,0x25,0xff,0x21,0x45,0x0a,0x00,0xa9,0x0d,0x04}}, + {{0x22,0x13,0xfe,0x25,0xff,0x21,0x45,0x0a,0x00,0xa9,0x0d,0x04}}, + {{0x22,0x13,0xfe,0x25,0xff,0x21,0x45,0x0a,0x00,0xa9,0x0d,0x04}} }; -static const SiS_Part2PortTblStruct SiS300_CRT2Part2_1024x768_2[] = +static const struct SiS_Part2PortTbl SiS300_CRT2Part2_1024x768_2[] = { /* Non-VESA */ - {{0x28,0x12,0xa3,0xd0,0xaa,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, - {{0x2c,0x12,0x9a,0xae,0x88,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, - {{0x28,0x12,0xa3,0xd0,0xaa,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, - {{0x2c,0x12,0x9a,0xae,0x88,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, - {{0x28,0x13,0xe7,0x0b,0xe8,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, - {{0x38,0x18,0x16,0x00,0x00,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, - {{0x36,0x13,0x13,0x25,0xff,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}} -}; - -static const SiS_Part2PortTblStruct SiS300_CRT2Part2_1024x768_3[] = -{ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} -}; - -static const SiS_Part2PortTblStruct SiS300_CRT2Part2_1280x1024_1[] = -{ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} -}; - -static const SiS_Part2PortTblStruct SiS300_CRT2Part2_1280x1024_2[] = -{ - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} + {{0x28,0x12,0xa3,0xd0,0xaa,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, + {{0x2c,0x12,0x9a,0xae,0x88,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, + {{0x28,0x12,0xa3,0xd0,0xaa,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, + {{0x2c,0x12,0x9a,0xae,0x88,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, + {{0x28,0x13,0xe7,0x0b,0xe8,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, + {{0x38,0x18,0x16,0x00,0x00,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, + {{0x36,0x13,0x13,0x25,0xff,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}} }; -static const SiS_Part2PortTblStruct SiS300_CRT2Part2_1280x1024_3[] = +static const struct SiS_Part2PortTbl SiS300_CRT2Part2_1024x768_3[] = { - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} }; /**************************************************************/ /* LVDS/Chrontel -------------------------------------------- */ /**************************************************************/ -static const SiS_LVDSDataStruct SiS300_CHTVUPALData[] = +/* Custom data for Barco iQ R series */ +static const struct SiS_LVDSData SiS300_LVDSBARCO1366Data_1[]= +{ + { 832, 438,1331, 806}, + { 832, 388,1331, 806}, + { 832, 438,1331, 806}, + { 832, 388,1331, 806}, + { 832, 518,1331, 806}, + {1050, 638,1344, 806}, + {1344, 806,1344, 806}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066} /* 1360x1024 */ +}; + +/* Custom data for Barco iQ R series */ +static const struct SiS_LVDSData SiS300_LVDSBARCO1366Data_2[]= +{ + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1344, 806,1344, 806}, + {1688,1066,1688,1066}, + {1688,1066,1688,1066} /* 1360x1024 */ +}; + +/* Custom data for Barco iQ G series */ +static const struct SiS_LVDSData SiS300_LVDSBARCO1024Data_1[]= +{ + { 832, 438,1331, 806}, + { 832, 409,1331, 806}, + { 832, 438,1331, 806}, + { 832, 409,1331, 806}, + { 832, 518,1331, 806}, /* 640x480 */ + {1050, 638,1344, 806}, /* 800x600 */ + {1344, 806,1344, 806}, /* 1024x768 */ +}; + +/* Custom data for 848x480 and 856x480 parallel LVDS panels */ +static const struct SiS_LVDSData SiS300_LVDS848x480Data_1[]= +{ + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + {1088, 525,1088, 525}, /* 640x480 TODO */ + {1088, 525,1088, 525}, /* 800x600 TODO */ + {1088, 525,1088, 525}, /* 1024x768 TODO */ + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + {1088, 525,1088, 525}, /* 848x480 */ + {1088, 525,1088, 525}, /* 856x480 */ + {1088, 525,1088, 525} /* 1360x768 TODO */ +}; + +/* Custom data for 848x480 parallel panel */ +static const struct SiS_LVDSData SiS300_LVDS848x480Data_2[]= +{ + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + {1088, 525,1088, 525}, /* 640x480 */ + {1088, 525,1088, 525}, /* 800x600 */ + {1088, 525,1088, 525}, /* 1024x768 */ + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, + {1088, 525,1088, 525}, /* 848x480 */ + {1088, 525,1088, 525}, /* 856x480 */ + {1088, 525,1088, 525} /* 1360x768 TODO */ +}; + +static const struct SiS_LVDSData SiS300_CHTVUPALData[] = { {1008, 625,1008, 625}, {1008, 625,1008, 625}, @@ -869,7 +823,7 @@ static const SiS_LVDSDataStruct SiS300_CHTVUPALData[] = { 936, 836, 936, 836} }; -static const SiS_LVDSDataStruct SiS300_CHTVOPALData[] = +static const struct SiS_LVDSData SiS300_CHTVOPALData[] = { {1008, 625,1008, 625}, {1008, 625,1008, 625}, @@ -879,7 +833,7 @@ static const SiS_LVDSDataStruct SiS300_CHTVOPALData[] = { 960, 750, 960, 750} }; -static const SiS_LVDSDataStruct SiS300_CHTVSOPALData[] = +static const struct SiS_LVDSData SiS300_CHTVSOPALData[] = { {1008, 625,1008, 625}, {1008, 625,1008, 625}, @@ -889,486 +843,8 @@ static const SiS_LVDSDataStruct SiS300_CHTVSOPALData[] = { 944, 625, 944, 625} }; - -static const SiS_LVDSDesStruct SiS300_PanelType00_1[] = -{ - { 1059, 626 }, /* 2.08 */ - { 1059, 624 }, - { 1059, 626 }, - { 1059, 624 }, - { 1059, 624 }, - { 0, 627 }, - { 0, 627 }, - { 0, 0 }, - { 0, 0 } -#if 0 - {0, 626}, - {0, 624}, - {0, 626}, - {0, 624}, - {0, 624}, - {0, 627}, - {0, 627}, - {0, 0}, - {0, 0} -#endif -}; - -static const SiS_LVDSDesStruct SiS300_PanelType01_1[] = -{ - { 0, 0 }, /* 2.08 */ - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 } -#if 0 - {1343, 798}, - {1343, 794}, - {1343, 798}, - {1343, 794}, - {1343, 0}, - {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} -#endif -}; - -static const SiS_LVDSDesStruct SiS300_PanelType02_1[] = -{ - { 1059, 626 }, /* 2.08 */ - { 1059, 624 }, - { 1059, 626 }, - { 1059, 624 }, - { 1059, 624 }, - { 0, 627 }, - { 0, 627 }, - { 0, 0 }, - { 0, 0 } -#if 0 - {0, 626}, - {0, 624}, - {0, 626}, - {0, 624}, - {0, 624}, - {0, 627}, - {0, 627}, - {0, 0}, - {0, 0} -#endif -}; - -static const SiS_LVDSDesStruct SiS300_PanelType03_1[] = -{ - { 8, 436}, - { 8, 440}, - { 8, 436}, - { 8, 440}, - { 8, 512}, - {1343, 798}, - {1343, 794}, - {1343, 798}, - {1343, 794} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType04_1[] = /* 1280x1024 */ -{ - {1343, 798}, - {1343, 794}, - {1343, 798}, - {1343, 794}, - {1343, 0}, - {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType05_1[] = -{ - {1343, 798}, - {1343, 794}, - {1343, 798}, - {1343, 794}, - {1343, 0}, - {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType06_1[] = /* Clevo Trumpion 1024x768 */ -{ - {1343, 798}, - {1343, 794}, - {1343, 798}, - {1343, 794}, - {1343, 0}, - {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType07_1[] = -{ - {1343, 798}, - {1343, 794}, - {1343, 798}, - {1343, 794}, - {1343, 0}, - {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType08_1[] = -{ - {1059, 626}, - {1059, 624}, - {1059, 626}, - {1059, 624}, - {1059, 624}, - { 0, 627}, - { 0, 627}, - { 0, 0}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType09_1[] = -{ - {1343, 798}, - {1343, 794}, - {1343, 798}, - {1343, 794}, - {1343, 0}, - {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType0a_1[] = -{ - {1059, 626}, - {1059, 624}, - {1059, 626}, - {1059, 624}, - {1059, 624}, - { 0, 627}, - { 0, 627}, - { 0, 0}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType0b_1[] = -{ - {1343, 0}, - {1343, 0}, - {1343, 0}, - {1343, 0}, - {1343, 0}, - {1343, 0}, - { 0, 799}, - { 0, 0}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType0c_1[] = -{ - {1343, 798}, - {1343, 794}, - {1343, 798}, - {1343, 794}, - {1343, 0}, - {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType0d_1[] = -{ - {1343, 798}, - {1343, 794}, - {1343, 798}, - {1343, 794}, - {1343, 0}, - {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType0e_1[] = -{ - {1343, 798}, - {1343, 794}, - {1343, 798}, - {1343, 794}, - {1343, 0}, /* 640x480 */ - {1343, 0}, /* 800x600 */ - { 0, 805}, /* 1024x768 */ - { 0, 794}, /* 1280x1024 */ - { 0, 0} /* 1280x960 - not applicable */ -}; - -static const SiS_LVDSDesStruct SiS300_PanelType0f_1[] = -{ - {1343, 798}, - {1343, 794}, - {1343, 798}, - {1343, 794}, - {1343, 0}, - {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType00_2[] = -{ - {976, 527}, - {976, 502}, - {976, 527}, - {976, 502}, - {976, 567}, - { 0, 627}, - { 0, 627}, - { 0, 0}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType01_2[] = -{ - {1152, 622}, - {1152, 597}, - {1152, 622}, - {1152, 597}, - {1152, 662}, - {1232, 722}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType02_2[] = -{ - {976, 527}, - {976, 502}, - {976, 527}, - {976, 502}, - {976, 567}, - { 0, 627}, - { 0, 627}, - { 0, 0}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType03_2[] = -{ - {1152, 622}, - {1152, 597}, - {1152, 622}, - {1152, 597}, - {1152, 662}, - {1232, 722}, - { 0, 805}, - {1152, 622}, - {1152, 597} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType04_2[] = -{ - {1152, 622}, - {1152, 597}, - {1152, 622}, - {1152, 597}, - {1152, 662}, - {1232, 722}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType05_2[] = -{ - {1152, 622}, - {1152, 597}, - {1152, 622}, - {1152, 597}, - {1152, 662}, - {1232, 722}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType06_2[] = -{ - {1152, 622}, - {1152, 597}, - {1152, 622}, - {1152, 597}, - {1152, 662}, - {1232, 722}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType07_2[] = -{ - {1152, 622}, - {1152, 597}, - {1152, 622}, - {1152, 597}, - {1152, 662}, - {1232, 722}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType08_2[] = -{ - {976, 527}, - {976, 502}, - {976, 527}, - {976, 502}, - {976, 567}, - { 0, 627}, - { 0, 627}, - { 0, 0}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType09_2[] = -{ - {1152, 622}, - {1152, 597}, - {1152, 622}, - {1152, 597}, - {1152, 662}, - {1232, 722}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType0a_2[] = -{ - {976, 527}, - {976, 502}, - {976, 527}, - {976, 502}, - {976, 567}, - { 0, 627}, - { 0, 627}, - { 0, 0}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType0b_2[] = -{ - { 1152, 700}, - { 1152, 675}, - { 1152, 700}, - { 1152, 675}, - { 1152, 740}, - { 1232, 799}, - { 0, 799}, - { 0, 0}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType0c_2[] = -{ - {1152, 622}, - {1152, 597}, - {1152, 622}, - {1152, 597}, - {1152, 662}, - {1232, 722}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType0d_2[] = -{ - {1152, 622}, - {1152, 597}, - {1152, 622}, - {1152, 597}, - {1152, 662}, - {1232, 722}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType0e_2[] = -{ - {1152, 622}, - {1152, 597}, - {1152, 622}, - {1152, 597}, - {1152, 662}, - {1232, 722}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelType0f_2[] = -{ - {1152, 622}, - {1152, 597}, - {1152, 622}, - {1152, 597}, - {1152, 662}, - {1232, 722}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelTypeNS_1[]= -{ - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 805}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS300_PanelTypeNS_2[] = -{ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - -/* Custom data for Barco iQ R200/300/400 (BIOS 2.00.07) */ -static const SiS_LVDSDesStruct SiS300_PanelType04_1a[] = /* 1280x1024 (1366x1024) */ +/* Custom des data for Barco iQ R200/300/400 (BIOS 2.00.07) */ +static const struct SiS_LVDSDes SiS300_PanelType04_1a[] = /* 1280x1024 (1366x1024) */ { {1330, 798}, /* 320x200 */ {1330, 794}, @@ -1381,7 +857,7 @@ static const SiS_LVDSDesStruct SiS300_PanelType04_1a[] = /* 1280x1024 (1366x102 { 0, 0} /* 1360x1024 */ }; -static const SiS_LVDSDesStruct SiS300_PanelType04_2a[] = +static const struct SiS_LVDSDes SiS300_PanelType04_2a[] = { {1152, 622}, {1152, 597}, @@ -1394,8 +870,8 @@ static const SiS_LVDSDesStruct SiS300_PanelType04_2a[] = { 0, 0} }; -/* Custom data for Barco iQ G200/300/400 (BIOS 2.00.07) */ -static const SiS_LVDSDesStruct SiS300_PanelType04_1b[] = /* 1024x768 */ +/* Custom des data for Barco iQ G200/300/400 (BIOS 2.00.07) */ +static const struct SiS_LVDSDes SiS300_PanelType04_1b[] = /* 1024x768 */ { {1330, 798}, /* 320x200 */ {1330, 794}, @@ -1406,7 +882,7 @@ static const SiS_LVDSDesStruct SiS300_PanelType04_1b[] = /* 1024x768 */ { 0, 805} /* 1024x768 / 512x384 */ }; -static const SiS_LVDSDesStruct SiS300_PanelType04_2b[] = +static const struct SiS_LVDSDes SiS300_PanelType04_2b[] = { {1152, 622}, {1152, 597}, @@ -1419,376 +895,7 @@ static const SiS_LVDSDesStruct SiS300_PanelType04_2b[] = /* CRT1 CRTC for slave modes */ -static const SiS_LVDSCRT1DataStruct SiS300_LVDSCRT1800x600_1[] = -{ - {{0x65,0x4f,0x89,0x56,0x83,0xaf,0x1f, - 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, - 0x00 }}, - {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f, - 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, - 0x00 }}, - {{0x65,0x4f,0x89,0x56,0x83,0xaf,0x1f, - 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, - 0x00 }}, - {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f, - 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, - 0x00 }}, - {{0x65,0x4f,0x89,0x56,0x83,0x04,0x3e, - 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05, - 0x00 }}, - {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0, - 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, - 0x01 }} -}; - -static const SiS_LVDSCRT1DataStruct SiS300_LVDSCRT1800x600_1_H[] = -{ - {{0x30,0x27,0x94,0x2c,0x92,0xaf,0x1f, - 0x90,0x85,0x8f,0xab,0x30,0x00,0x04, - 0x00 }}, - {{0x30,0x27,0x94,0x2c,0x92,0x83,0x1f, - 0x5e,0x83,0x5d,0x79,0x10,0x00,0x04, - 0x00 }}, - {{0x30,0x27,0x94,0x2c,0x92,0xaf,0x1f, - 0x90,0x85,0x8f,0xab,0x30,0x00,0x04, - 0x00 }}, - {{0x30,0x27,0x94,0x2c,0x92,0x83,0x1f, - 0x5e,0x83,0x5d,0x79,0x10,0x00,0x04, - 0x00 }}, - {{0x30,0x27,0x94,0x2c,0x92,0x04,0x3e, - 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x04, - 0x00 }}, - {{0x3d,0x31,0x81,0x37,0x1f,0x72,0xf0, - 0x58,0x8c,0x57,0x73,0x20,0x00,0x05, - 0x01 }} -}; - -static const SiS_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_1[] = -{ - {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x04,0x3e, - 0xe2,0x89,0xdf,0x05,0x00,0x00,0x01, - 0x00}}, - {{0x7e,0x63,0x82,0x68,0x15,0x7c,0xf0, - 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x26, - 0x01}}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, - 0x01}} -}; - -static const SiS_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_1_H[] = -{ - {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, - 0x00 }}, - {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, - 0x60,0x87,0x5D,0x83,0x10,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, - 0x60,0x87,0x5D,0x83,0x10,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e, - 0xE2,0x89,0xdf,0x05,0x00,0x00,0x44, - 0x00}}, - {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0, - 0x5A,0x8F,0x57,0x7D,0x20,0x00,0x55, - 0x01}}, - {{0x4f,0x3F,0x93,0x45,0x0D,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01 }} - -#if 0 - {{0x37,0x27,0x9B,0x2b,0x94,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, - 0x00 }}, - {{0x37,0x27,0x9B,0x2b,0x94,0x97,0x1f, - 0x60,0x87,0x5D,0x83,0x01,0x00,0x44, - 0x00}}, - {{0x37,0x27,0x9B,0x2b,0x94,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, - 0x00}}, - {{0x37,0x27,0x9B,0x2b,0x94,0x97,0x1f, - 0x60,0x87,0x5D,0x83,0x01,0x00,0x44, - 0x00}}, - {{0x37,0x27,0x9B,0x2b,0x94,0x04,0x3e, - 0xE2,0x89,0xDf,0x05,0x00,0x00,0x44, - 0x00}}, - {{0x41,0x31,0x85,0x35,0x1d,0x7c,0xf0, - 0x5A,0x8F,0x57,0x7D,0x20,0x00,0x55, - 0x01}}, - {{0x4f,0x3F,0x93,0x45,0x0D,0x24,0xf5, - 0x02,0x88,0xFf,0x25,0x10,0x00,0x01, - 0x01 }} -#endif -}; - -static const SiS_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_1[] = -{ - {{0x63,0x4f,0x87,0x54,0x9f,0xb4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, - 0x00 }}, - {{0x63,0x4f,0x87,0x54,0x9f,0x82,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, - 0x00 }}, - {{0x63,0x4f,0x87,0x54,0x9f,0xb4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, - 0x00 }}, - {{0x63,0x4f,0x87,0x54,0x9f,0x82,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, - 0x00 }}, - {{0x63,0x4f,0x87,0x54,0x9f,0x04,0x3e, - 0xe2,0x89,0xdf,0x05,0x00,0x00,0x01, - 0x00 }}, - {{0x7e,0x63,0x82,0x68,0x15,0x7c,0xf0, - 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x26, - 0x01 }}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, - 0x01 }} -}; - -static const SiS_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_1_H[] = -{ - {{0x2f,0x27,0x93,0x2b,0x90,0xb4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x04, - 0x00 }}, - {{0x2f,0x27,0x93,0x2b,0x90,0x82,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x04, - 0x00 }}, - {{0x2f,0x27,0x93,0x2b,0x90,0xb4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x04, - 0x00 }}, - {{0x2f,0x27,0x93,0x2b,0x90,0x82,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x04, - 0x00 }}, - {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e, - 0xe2,0x89,0xdf,0x05,0x00,0x00,0x04, - 0x00 }}, - {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0, - 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x55, - 0x01 }}, - {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01 }} -}; - -static const SiS_LVDSCRT1DataStruct SiS300_LVDSCRT1800x600_2[] = -{ - {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, - 0xf4,0x88,0x8f,0x73,0x20,0x00,0x06, - 0x00 }}, - {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, - 0xdb,0x8f,0x5d,0x73,0x20,0x00,0x06, - 0x00 }}, - {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, - 0xf4,0x88,0x8f,0x73,0x20,0x00,0x06, - 0x00 }}, - {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, - 0xdb,0x8f,0x5d,0x73,0x20,0x00,0x06, - 0x00 }}, - {{0x7f,0x4f,0x83,0x62,0x12,0x72,0xba, - 0x1c,0x80,0xdf,0x73,0x00,0x00,0x06, - 0x00 }}, - {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0, - 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, - 0x01 }} -}; - -static const SiS_LVDSCRT1DataStruct SiS300_LVDSCRT1800x600_2_H[] = -{ - {{0x3d,0x27,0x81,0x32,0x1a,0x72,0x3e, - 0xf4,0x88,0x8f,0x73,0x20,0x00,0x05, - 0x00 }}, - {{0x3d,0x27,0x81,0x32,0x1a,0x72,0x3e, - 0xdb,0x8f,0x5d,0x73,0x20,0x00,0x05, - 0x00 }}, - {{0x3d,0x27,0x81,0x32,0x1a,0x72,0x3e, - 0xf4,0x88,0x8f,0x73,0x20,0x00,0x05, - 0x00 }}, - {{0x3d,0x27,0x81,0x3a,0x1a,0x72,0x3e, - 0xdb,0x8f,0x5d,0x73,0x20,0x00,0x05, - 0x00 }}, - {{0x3d,0x27,0x81,0x32,0x1a,0x72,0xba, - 0x1c,0x80,0xdf,0x73,0x00,0x00,0x05, - 0x00 }}, - {{0x3d,0x31,0x81,0x37,0x1f,0x72,0xf0, - 0x58,0x8c,0x57,0x73,0x20,0x00,0x05, - 0x01 }} -}; - -static const SiS_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_2[] = -{ - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, - 0x00 }}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, - 0x00 }}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, - 0x00 }}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, - 0x00 }}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x72,0x88,0xdf,0x25,0x30,0x00,0x06, - 0x00 }}, - {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1, - 0xae,0x84,0x57,0x25,0x30,0x00,0x02, - 0x01 }}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, - 0x01 }} -}; - -static const SiS_LVDSCRT1DataStruct SiS300_LVDSCRT11024x768_2_H[] = -{ - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, - 0x00 }}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, - 0x00 }}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, - 0x00 }}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, - 0x00 }}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x72,0x88,0xdf,0x25,0x30,0x00,0x01, - 0x00 }}, - {{0x4f,0x31,0x93,0x3e,0x06,0x24,0xf1, - 0xae,0x84,0x57,0x25,0x30,0x00,0x01, - 0x01 }}, - {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01 }} -}; - -static const SiS_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_2[] = -{ - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, - 0x00 }}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, - 0x00 }}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, - 0x00 }}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, - 0x00 }}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x72,0x88,0xdf,0x25,0x30,0x00,0x06, - 0x00 }}, - {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1, - 0xae,0x84,0x57,0x25,0x30,0x00,0x02, - 0x01 }}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, - 0x01 }} -}; - -static const SiS_LVDSCRT1DataStruct SiS300_LVDSCRT11280x1024_2_H[] = -{ - {{0x4f,0x27,0x93,0x39,0x81,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, - 0x00 }}, - {{0x4f,0x27,0x93,0x39,0x81,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, - 0x00 }}, - {{0x4f,0x27,0x93,0x39,0x81,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, - 0x00 }}, - {{0x4f,0x27,0x93,0x39,0x81,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, - 0x00 }}, - {{0x4f,0x27,0x93,0x39,0x81,0x24,0xbb, - 0x72,0x88,0xdf,0x25,0x30,0x00,0x01, - 0x00 }}, - {{0x4f,0x31,0x93,0x3e,0x86,0x24,0xf1, - 0xae,0x84,0x57,0x25,0x30,0x00,0x01, - 0x01 }}, - {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01}} -}; - -static const SiS_LVDSCRT1DataStruct SiS300_LVDSCRT1XXXxXXX_1[] = -{ - {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05, - 0x00}}, - {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05, - 0x00}}, - {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05, - 0x00}}, - {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05, - 0x00}}, - {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, - 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x05, - 0x00}}, - {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0, - 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, - 0x01}}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, - 0x01}}, - {{0xce,0x9f,0x92,0xa8,0x14,0x28,0x5a, - 0x00,0x84,0xff,0x29,0x09,0x00,0x07, - 0x01}}, - {{0xce,0x9f,0x92,0xa9,0x17,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x07, - 0x01}} -}; - -static const SiS_LVDSCRT1DataStruct SiS300_LVDSCRT1XXXxXXX_1_H[] = -{ - {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00, - 0x00}}, - {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00, - 0x00}}, - {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00, - 0x00}}, - {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00, - 0x00}}, - {{0x38,0x27,0x9c,0x2c,0x80,0x0b,0x3e, - 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00, - 0x00}}, - {{0x4d,0x31,0x91,0x3b,0x03,0x72,0xf0, - 0x58,0x8c,0x57,0x73,0x20,0x00,0x01, - 0x01}}, - {{0x63,0x3f,0x87,0x4a,0x92,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01}} -}; - - -static const SiS_LVDSCRT1DataStruct SiS300_CHTVCRT1UNTSC[] = +static const struct SiS_LVDSCRT1Data SiS300_CHTVCRT1UNTSC[] = { {{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e, 0xe8,0x84,0x8f,0x57,0x20,0x00,0x01, @@ -1810,7 +917,7 @@ static const SiS_LVDSCRT1DataStruct SiS300_CHTVCRT1UNTSC[] = 0x01 }} }; -static const SiS_LVDSCRT1DataStruct SiS300_CHTVCRT1ONTSC[] = +static const struct SiS_LVDSCRT1Data SiS300_CHTVCRT1ONTSC[] = { {{0x64,0x4f,0x88,0x5a,0x9f,0x0b,0x3e, 0xc0,0x84,0x8f,0x0c,0x20,0x00,0x01, @@ -1832,7 +939,7 @@ static const SiS_LVDSCRT1DataStruct SiS300_CHTVCRT1ONTSC[] = 0x01 }} }; -static const SiS_LVDSCRT1DataStruct SiS300_CHTVCRT1UPAL[] = +static const struct SiS_LVDSCRT1Data SiS300_CHTVCRT1UPAL[] = { {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, 0xf8,0x83,0x8f,0x70,0x20,0x00,0x05, @@ -1854,7 +961,7 @@ static const SiS_LVDSCRT1DataStruct SiS300_CHTVCRT1UPAL[] = 0x01 }} }; -static const SiS_LVDSCRT1DataStruct SiS300_CHTVCRT1OPAL[] = +static const struct SiS_LVDSCRT1Data SiS300_CHTVCRT1OPAL[] = { {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, 0xf0,0x83,0x8f,0x70,0x20,0x00,0x05, @@ -1876,7 +983,7 @@ static const SiS_LVDSCRT1DataStruct SiS300_CHTVCRT1OPAL[] = 0x01 }} }; -static const SiS_LVDSCRT1DataStruct SiS300_CHTVCRT1SOPAL[] = +static const struct SiS_LVDSCRT1Data SiS300_CHTVCRT1SOPAL[] = { {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, 0xf0,0x83,0x8f,0x70,0x20,0x00,0x05, @@ -1898,7 +1005,7 @@ static const SiS_LVDSCRT1DataStruct SiS300_CHTVCRT1SOPAL[] = 0x01 }} }; -static const SiS_CHTVRegDataStruct SiS300_CHTVReg_UNTSC[] = +static const struct SiS_CHTVRegData SiS300_CHTVReg_UNTSC[] = { {{0x4a,0x94,0x00,0x48,0xfe,0,0,0,0,0,0,0,0,0,0,0}}, {{0x4a,0x94,0x00,0x48,0xfe,0,0,0,0,0,0,0,0,0,0,0}}, @@ -1908,7 +1015,7 @@ static const SiS_CHTVRegDataStruct SiS300_CHTVReg_UNTSC[] = {{0x8d,0xc4,0x00,0x3b,0xfb,0,0,0,0,0,0,0,0,0,0,0}} /* Mode 24: 800x600 NTSC 7/10 */ }; -static const SiS_CHTVRegDataStruct SiS300_CHTVReg_ONTSC[] = +static const struct SiS_CHTVRegData SiS300_CHTVReg_ONTSC[] = { {{0x49,0x94,0x00,0x34,0xfe,0,0,0,0,0,0,0,0,0,0,0}}, {{0x49,0x94,0x00,0x34,0xfe,0,0,0,0,0,0,0,0,0,0,0}}, @@ -1918,7 +1025,7 @@ static const SiS_CHTVRegDataStruct SiS300_CHTVReg_ONTSC[] = {{0x8c,0xb4,0x00,0x32,0xf9,0,0,0,0,0,0,0,0,0,0,0}} /* Mode 23: 800x600 NTSC 3/4 */ }; -static const SiS_CHTVRegDataStruct SiS300_CHTVReg_UPAL[] = +static const struct SiS_CHTVRegData SiS300_CHTVReg_UPAL[] = { {{0x41,0x12,0x01,0x50,0x34,0,0,0,0,0,0,0,0,0,0,0}}, {{0x41,0x12,0x00,0x50,0x00,0,0,0,0,0,0,0,0,0,0,0}}, @@ -1929,7 +1036,7 @@ static const SiS_CHTVRegDataStruct SiS300_CHTVReg_UPAL[] = }; -static const SiS_CHTVRegDataStruct SiS300_CHTVReg_OPAL[] = +static const struct SiS_CHTVRegData SiS300_CHTVReg_OPAL[] = { {{0x41,0x12,0x01,0x50,0x34,0,0,0,0,0,0,0,0,0,0,0}}, /* Mode 9: 640x400 PAL 1/1 */ {{0x41,0x12,0x00,0x50,0x00,0,0,0,0,0,0,0,0,0,0,0}}, @@ -1940,26 +1047,26 @@ static const SiS_CHTVRegDataStruct SiS300_CHTVReg_OPAL[] = }; -static const SiS_CHTVRegDataStruct SiS300_CHTVReg_SOPAL[] = +static const struct SiS_CHTVRegData SiS300_CHTVReg_SOPAL[] = { {{0x41,0x12,0x01,0x50,0x34,0,0,0,0,0,0,0,0,0,0,0}}, /* Mode 9: 640x400 PAL 1/1 */ {{0x41,0x12,0x00,0x50,0x00,0,0,0,0,0,0,0,0,0,0,0}}, {{0x41,0x12,0x01,0x50,0x34,0,0,0,0,0,0,0,0,0,0,0}}, {{0x41,0x12,0x00,0x50,0x00,0,0,0,0,0,0,0,0,0,0,0}}, - {{0x60,0x30,0x00,0x10,0x00,0,0,0,0,0,0,0,0,0,0,0}}, /* TW: Mode 13: 640x480 PAL 5/4 */ - {{0x81,0x50,0x00,0x1b,0x00,0,0,0,0,0,0,0,0,0,0,0}} /* TW: Mode 19: 800x600 PAL 1/1 */ + {{0x60,0x30,0x00,0x10,0x00,0,0,0,0,0,0,0,0,0,0,0}}, /* Mode 13: 640x480 PAL 5/4 */ + {{0x81,0x50,0x00,0x1b,0x00,0,0,0,0,0,0,0,0,0,0,0}} /* Mode 19: 800x600 PAL 1/1 */ }; -static const UCHAR SiS300_CHTVVCLKUNTSC[] = {0x29,0x29,0x29,0x29,0x2a,0x2e}; +static const unsigned char SiS300_CHTVVCLKUNTSC[] = { 0x29,0x29,0x29,0x29,0x2a,0x2e }; -static const UCHAR SiS300_CHTVVCLKONTSC[] = {0x2c,0x2c,0x2c,0x2c,0x2d,0x2b}; +static const unsigned char SiS300_CHTVVCLKONTSC[] = { 0x2c,0x2c,0x2c,0x2c,0x2d,0x2b }; -static const UCHAR SiS300_CHTVVCLKSONTSC[] = {0x2c,0x2c,0x2c,0x2c,0x2d,0x2b}; +static const unsigned char SiS300_CHTVVCLKSONTSC[] = { 0x2c,0x2c,0x2c,0x2c,0x2d,0x2b }; -static const UCHAR SiS300_CHTVVCLKUPAL[] = {0x2f,0x2f,0x2f,0x2f,0x2f,0x31}; +static const unsigned char SiS300_CHTVVCLKUPAL[] = { 0x2f,0x2f,0x2f,0x2f,0x2f,0x31 }; -static const UCHAR SiS300_CHTVVCLKOPAL[] = {0x2f,0x2f,0x2f,0x2f,0x30,0x32}; +static const unsigned char SiS300_CHTVVCLKOPAL[] = { 0x2f,0x2f,0x2f,0x2f,0x30,0x32 }; -static const UCHAR SiS300_CHTVVCLKSOPAL[] = {0x2f,0x2f,0x2f,0x2f,0x36,0x29}; +static const unsigned char SiS300_CHTVVCLKSOPAL[] = { 0x2f,0x2f,0x2f,0x2f,0x36,0x29 }; diff --git a/drivers/video/sis/310vtbl.h b/drivers/video/sis/310vtbl.h index 2c71d048f7c..54fcbbf4ef6 100644 --- a/drivers/video/sis/310vtbl.h +++ b/drivers/video/sis/310vtbl.h @@ -1,9 +1,9 @@ /* $XFree86$ */ /* $XdotOrg$ */ /* - * Register settings for SiS 315/330 series + * Register settings for SiS 315/330/340 series * - * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2005 by Thomas Winischhofer, Vienna, Austria * * If distributed as part of the Linux kernel, the following license terms * apply: @@ -50,37 +50,13 @@ * */ -static const SiS_StStruct SiS310_SModeIDTable[]= -{ - {0x01,0x9208,0x01,0x00,0x00,0x00,0x01,0x00, 0x40}, - {0x01,0x1210,0x14,0x01,0x01,0x00,0x01,0x00, 0x40}, - {0x01,0x1010,0x17,0x02,0x02,0x00,0x01,0x01, 0x40}, - {0x03,0x8208,0x03,0x00,0x00,0x00,0x01,0x02, 0x40}, - {0x03,0x0210,0x16,0x01,0x01,0x00,0x01,0x02, 0x40}, - {0x03,0x0010,0x18,0x02,0x02,0x00,0x01,0x03, 0x40}, - {0x05,0x9209,0x05,0x00,0x00,0x00,0x00,0x04, 0x40}, - {0x06,0x8209,0x06,0x00,0x00,0x00,0x00,0x05, 0x40}, - {0x07,0x0000,0x07,0x03,0x03,0x00,0x01,0x03, 0x40}, - {0x07,0x0000,0x19,0x02,0x02,0x00,0x01,0x03, 0x40}, - {0x0d,0x920a,0x0d,0x00,0x00,0x00,0x00,0x04, 0x40}, - {0x0e,0x820a,0x0e,0x00,0x00,0x00,0x00,0x05, 0x40}, - {0x0f,0x0202,0x11,0x01,0x01,0x00,0x00,0x05, 0x40}, - {0x10,0x0212,0x12,0x01,0x01,0x00,0x00,0x05, 0x40}, - {0x11,0x0212,0x1a,0x04,0x04,0x00,0x00,0x05, 0x40}, - {0x12,0x0212,0x1b,0x04,0x04,0x00,0x00,0x05, 0x40}, - {0x13,0x021b,0x1c,0x00,0x00,0x00,0x00,0x04, 0x40}, - {0x12,0x0010,0x18,0x02,0x02,0x00,0x00,0x05, 0x40}, - {0x12,0x0210,0x18,0x01,0x01,0x00,0x00,0x05, 0x40}, - {0xff,0x0000,0x00,0x00,0x00,0x00,0x00,0x00, 0x40} -}; - -static const SiS_ExtStruct SiS310_EModeIDTable[]= +static const struct SiS_Ext SiS310_EModeIDTable[] = { {0x6a,0x2212,0x0102,SIS_RI_800x600, 0x00,0x00,0x07,0x06,0x00, 3}, /* 800x600x? */ {0x2e,0x0a1b,0x0101,SIS_RI_640x480, 0x00,0x00,0x05,0x05,0x08, 2}, /* 640x480x8 */ - {0x2f,0x0a1b,0x0100,SIS_RI_640x400, 0x00,0x00,0x05,0x05,0x10, 0}, /* 640x400x8 */ + {0x2f,0x0a1b,0x0100,SIS_RI_640x400, 0x00,0x00,0x05,0x05,0x10, 0}, /* 640x400x8 */ {0x30,0x2a1b,0x0103,SIS_RI_800x600, 0x00,0x00,0x07,0x06,0x00, 3}, /* 800x600x8 */ - {0x31,0x4a1b,0x0000,SIS_RI_720x480, 0x00,0x00,0x06,0x06,0x11,-1}, /* 720x480x8 */ + {0x31,0x4a1b,0x0000,SIS_RI_720x480, 0x00,0x00,0x06,0x06,0x11,-1}, /* 720x480x8 */ {0x32,0x4a1b,0x0000,SIS_RI_720x576, 0x00,0x00,0x06,0x06,0x12,-1}, /* 720x576x8 */ {0x33,0x4a1d,0x0000,SIS_RI_720x480, 0x00,0x00,0x06,0x06,0x11,-1}, /* 720x480x16 */ {0x34,0x6a1d,0x0000,SIS_RI_720x576, 0x00,0x00,0x06,0x06,0x12,-1}, /* 720x576x16 */ @@ -103,10 +79,10 @@ static const SiS_ExtStruct SiS310_EModeIDTable[]= {0x4d,0x0e7d,0x011a,SIS_RI_1280x1024,0x00,0x00,0x00,0x00,0x1a, 8}, /* 1280x1024x16 */ {0x50,0x9a1b,0x0132,SIS_RI_320x240, 0x00,0x00,0x04,0x04,0x26, 2}, /* 320x240x8 */ {0x51,0xba1b,0x0133,SIS_RI_400x300, 0x00,0x00,0x07,0x07,0x27, 3}, /* 400x300x8 */ - {0x52,0xba1b,0x0134,SIS_RI_512x384, 0x00,0x00,0x00,0x00,0x28, 4}, /* 512x384x8 */ + {0x52,0xba1b,0x0134,SIS_RI_512x384, 0x00,0x00,0x00,0x00,0x28, 4}, /* 512x384x8 */ {0x56,0x9a1d,0x0135,SIS_RI_320x240, 0x00,0x00,0x04,0x04,0x26, 2}, /* 320x240x16 */ {0x57,0xba1d,0x0136,SIS_RI_400x300, 0x00,0x00,0x07,0x07,0x27, 3}, /* 400x300x16 */ - {0x58,0xba1d,0x0137,SIS_RI_512x384, 0x00,0x00,0x00,0x00,0x28, 4}, /* 512x384x16 */ + {0x58,0xba1d,0x0137,SIS_RI_512x384, 0x00,0x00,0x00,0x00,0x28, 4}, /* 512x384x16 */ {0x59,0x9a1b,0x0138,SIS_RI_320x200, 0x00,0x00,0x04,0x04,0x25, 0}, /* 320x200x8 */ {0x5a,0x021b,0x0138,SIS_RI_320x240, 0x00,0x00,0x00,0x00,0x3f, 2}, /* 320x240x8 fstn */ {0x5b,0x0a1d,0x0135,SIS_RI_320x240, 0x00,0x00,0x00,0x00,0x3f, 2}, /* 320x240x16 fstn */ @@ -139,406 +115,335 @@ static const SiS_ExtStruct SiS310_EModeIDTable[]= {0x23,0x0e3b,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x00,0x40, 6}, /* 1280x768x8 */ {0x24,0x0e7d,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x00,0x40, 6}, /* 1280x768x16 */ {0x25,0x0eff,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x00,0x40, 6}, /* 1280x768x32 */ - {0x26,0x0e3b,0x0000,SIS_RI_1400x1050,0x00,0x00,0x00,0x00,0x41, 9}, /* 1400x1050x8 */ - {0x27,0x0e7d,0x0000,SIS_RI_1400x1050,0x00,0x00,0x00,0x00,0x41, 9}, /* 1400x1050x16 */ - {0x28,0x0eff,0x0000,SIS_RI_1400x1050,0x00,0x00,0x00,0x00,0x41, 9}, /* 1400x1050x32*/ - {0x29,0x4e1b,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x00,0x43,-1}, /* 1152x864 */ - {0x2a,0x4e3d,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x00,0x43,-1}, - {0x2b,0x4e7f,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x00,0x43,-1}, - {0x39,0x6a1b,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x00,0x46,-1}, /* 848x480 */ - {0x3b,0x6a3d,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x00,0x46,-1}, - {0x3e,0x6a7f,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x00,0x46,-1}, - {0x3f,0x6a1b,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x00,0x48,-1}, /* 856x480 */ - {0x42,0x6a3d,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x00,0x48,-1}, - {0x45,0x6a7f,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x00,0x48,-1}, - {0x48,0x6a3b,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x00,0x4a,-1}, /* 1360x768 */ - {0x4b,0x6a7d,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x00,0x4a,-1}, - {0x4e,0x6aff,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x00,0x4a,-1}, + {0x26,0x0e3b,0x0000,SIS_RI_1400x1050,0x00,0x00,0x00,0x00,0x43, 9}, /* 1400x1050x8 */ + {0x27,0x0e7d,0x0000,SIS_RI_1400x1050,0x00,0x00,0x00,0x00,0x43, 9}, /* 1400x1050x16 */ + {0x28,0x0eff,0x0000,SIS_RI_1400x1050,0x00,0x00,0x00,0x00,0x43, 9}, /* 1400x1050x32*/ + {0x29,0x4e1b,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x00,0x45,-1}, /* 1152x864 */ + {0x2a,0x4e3d,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x00,0x45,-1}, + {0x2b,0x4e7f,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x00,0x45,-1}, + {0x39,0x6a1b,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x00,0x48,-1}, /* 848x480 */ + {0x3b,0x6a3d,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x00,0x48,-1}, + {0x3e,0x6a7f,0x0000,SIS_RI_848x480, 0x00,0x00,0x00,0x00,0x48,-1}, + {0x3f,0x6a1b,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x00,0x4a,-1}, /* 856x480 */ + {0x42,0x6a3d,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x00,0x4a,-1}, + {0x45,0x6a7f,0x0000,SIS_RI_856x480, 0x00,0x00,0x00,0x00,0x4a,-1}, + {0x48,0x6a3b,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x00,0x4c,-1}, /* 1360x768 */ + {0x4b,0x6a7d,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x00,0x4c,-1}, + {0x4e,0x6aff,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x00,0x4c,-1}, {0x4f,0x9a1f,0x0000,SIS_RI_320x200, 0x00,0x00,0x04,0x04,0x25, 0}, /* 320x200x32 */ {0x53,0x9a1f,0x0000,SIS_RI_320x240, 0x00,0x00,0x04,0x04,0x26, 2}, /* 320x240x32 */ {0x54,0xba1f,0x0000,SIS_RI_400x300, 0x00,0x00,0x07,0x07,0x27, 3}, /* 400x300x32 */ - {0x5f,0x6a1b,0x0000,SIS_RI_768x576, 0x00,0x00,0x06,0x06,0x4b,-1}, /* 768x576 */ - {0x60,0x6a1d,0x0000,SIS_RI_768x576, 0x00,0x00,0x06,0x06,0x4b,-1}, - {0x61,0x6a3f,0x0000,SIS_RI_768x576, 0x00,0x00,0x06,0x06,0x4b,-1}, - {0x14,0x0e3b,0x0000,SIS_RI_1280x800, 0x00,0x00,0x00,0x00,0x4c, 7}, /* 1280x800 */ - {0x15,0x0e7d,0x0000,SIS_RI_1280x800, 0x00,0x00,0x00,0x00,0x4c, 7}, - {0x16,0x0eff,0x0000,SIS_RI_1280x800, 0x00,0x00,0x00,0x00,0x4c, 7}, - {0x17,0x0e3b,0x0000,SIS_RI_1680x1050,0x00,0x00,0x00,0x00,0x4d, 9}, /* 1680x1050 */ - {0x18,0x0e7d,0x0000,SIS_RI_1680x1050,0x00,0x00,0x00,0x00,0x4d, 9}, - {0x19,0x0eff,0x0000,SIS_RI_1680x1050,0x00,0x00,0x00,0x00,0x4d, 9}, - {0x2c,0x267b,0x0000,SIS_RI_1920x1080,0x00,0x00,0x00,0x00,0x4e,-1}, /* 1920x1080(i) */ - {0x2d,0x26fd,0x0000,SIS_RI_1920x1080,0x00,0x00,0x00,0x00,0x4e,-1}, - {0x73,0x27ff,0x0000,SIS_RI_1920x1080,0x00,0x00,0x00,0x00,0x4e,-1}, - {0x1d,0x6a1b,0x0000,SIS_RI_960x540, 0x00,0x00,0x00,0x00,0x4f,-1}, /* 960x540 */ - {0x1e,0x6a3d,0x0000,SIS_RI_960x540, 0x00,0x00,0x00,0x00,0x4f,-1}, - {0x1f,0x6a7f,0x0000,SIS_RI_960x540, 0x00,0x00,0x00,0x00,0x4f,-1}, - {0x20,0x6a1b,0x0000,SIS_RI_960x600, 0x00,0x00,0x00,0x00,0x50,-1}, /* 960x600 */ - {0x21,0x6a3d,0x0000,SIS_RI_960x600, 0x00,0x00,0x00,0x00,0x50,-1}, - {0x22,0x6a7f,0x0000,SIS_RI_960x600, 0x00,0x00,0x00,0x00,0x50,-1}, + {0x5f,0x6a1b,0x0000,SIS_RI_768x576, 0x00,0x00,0x06,0x06,0x4d,-1}, /* 768x576 */ + {0x60,0x6a1d,0x0000,SIS_RI_768x576, 0x00,0x00,0x06,0x06,0x4d,-1}, + {0x61,0x6a3f,0x0000,SIS_RI_768x576, 0x00,0x00,0x06,0x06,0x4d,-1}, + {0x14,0x0e3b,0x0000,SIS_RI_1280x800, 0x00,0x00,0x00,0x00,0x4e, 7}, /* 1280x800 */ + {0x15,0x0e7d,0x0000,SIS_RI_1280x800, 0x00,0x00,0x00,0x00,0x4e, 7}, + {0x16,0x0eff,0x0000,SIS_RI_1280x800, 0x00,0x00,0x00,0x00,0x4e, 7}, + {0x17,0x0e3b,0x0000,SIS_RI_1680x1050,0x00,0x00,0x00,0x00,0x51, 9}, /* 1680x1050 */ + {0x18,0x0e7d,0x0000,SIS_RI_1680x1050,0x00,0x00,0x00,0x00,0x51, 9}, + {0x19,0x0eff,0x0000,SIS_RI_1680x1050,0x00,0x00,0x00,0x00,0x51, 9}, + {0x2c,0x267b,0x0000,SIS_RI_1920x1080,0x00,0x00,0x00,0x00,0x52,-1}, /* 1920x1080(i) */ + {0x2d,0x26fd,0x0000,SIS_RI_1920x1080,0x00,0x00,0x00,0x00,0x52,-1}, + {0x73,0x27ff,0x0000,SIS_RI_1920x1080,0x00,0x00,0x00,0x00,0x52,-1}, + {0x1d,0x6a1b,0x0000,SIS_RI_960x540, 0x00,0x00,0x00,0x00,0x53,-1}, /* 960x540 */ + {0x1e,0x6a3d,0x0000,SIS_RI_960x540, 0x00,0x00,0x00,0x00,0x53,-1}, + {0x1f,0x6a7f,0x0000,SIS_RI_960x540, 0x00,0x00,0x00,0x00,0x53,-1}, + {0x20,0x6a1b,0x0000,SIS_RI_960x600, 0x00,0x00,0x00,0x00,0x54,-1}, /* 960x600 */ + {0x21,0x6a3d,0x0000,SIS_RI_960x600, 0x00,0x00,0x00,0x00,0x54,-1}, + {0x22,0x6a7f,0x0000,SIS_RI_960x600, 0x00,0x00,0x00,0x00,0x54,-1}, + {0x1a,0x0e3b,0x0000,SIS_RI_1280x854, 0x00,0x00,0x00,0x00,0x55, 8}, /* 1280x854 */ + {0x1b,0x0e7d,0x0000,SIS_RI_1280x854, 0x00,0x00,0x00,0x00,0x55, 8}, + {0x1c,0x0eff,0x0000,SIS_RI_1280x854, 0x00,0x00,0x00,0x00,0x55, 8}, {0xff,0x0000,0x0000,0, 0x00,0x00,0x00,0x00,0x00,-1} }; -static const SiS_Ext2Struct SiS310_RefIndex[]= -{ - {0x085f,0x0d,0x03,0x05,0x05,0x6a, 800, 600, 0x40}, /* 0x0 */ - {0x0067,0x0e,0x04,0x05,0x05,0x6a, 800, 600, 0x40}, /* 0x1 */ - {0x0067,0x0f,0x08,0x48,0x05,0x6a, 800, 600, 0x40}, /* 0x2 */ - {0x0067,0x10,0x07,0x8b,0x05,0x6a, 800, 600, 0x40}, /* 0x3 */ - {0x0047,0x11,0x0a,0x00,0x05,0x6a, 800, 600, 0x40}, /* 0x4 */ - {0x0047,0x12,0x0d,0x00,0x05,0x6a, 800, 600, 0x40}, /* 0x5 */ - {0x0047,0x13,0x13,0x00,0x05,0x6a, 800, 600, 0x20}, /* 0x6 */ - {0x0107,0x14,0x1c,0x00,0x05,0x6a, 800, 600, 0x20}, /* 0x7 */ - {0xc85f,0x05,0x00,0x04,0x04,0x2e, 640, 480, 0x40}, /* 0x8 */ - {0xc067,0x06,0x02,0x04,0x04,0x2e, 640, 480, 0x40}, /* 0x9 */ - {0xc067,0x07,0x02,0x47,0x04,0x2e, 640, 480, 0x40}, /* 0xa */ - {0xc067,0x08,0x03,0x8a,0x04,0x2e, 640, 480, 0x40}, /* 0xb */ - {0xc047,0x09,0x05,0x00,0x04,0x2e, 640, 480, 0x40}, /* 0xc */ - {0xc047,0x0a,0x09,0x00,0x04,0x2e, 640, 480, 0x40}, /* 0xd */ - {0xc047,0x0b,0x0e,0x00,0x04,0x2e, 640, 480, 0x40}, /* 0xe */ - {0xc047,0x0c,0x15,0x00,0x04,0x2e, 640, 480, 0x40}, /* 0xf */ - {0x487f,0x04,0x00,0x00,0x00,0x2f, 640, 400, 0x30}, /* 0x10 */ - {0xc06f,0x3c,0x01,0x06,0x13,0x31, 720, 480, 0x30}, /* 0x11 */ - {0x006f,0x3d,0x03,0x06,0x14,0x32, 720, 576, 0x30}, /* 0x12 */ - {0x0087,0x15,0x06,0x00,0x06,0x37,1024, 768, 0x30}, /* 0x13 */ - {0xc877,0x16,0x0b,0x06,0x06,0x37,1024, 768, 0x20}, /* 0x14 */ - {0xc067,0x17,0x0f,0x49,0x06,0x37,1024, 768, 0x20}, /* 0x15 */ - {0x0067,0x18,0x11,0x00,0x06,0x37,1024, 768, 0x20}, /* 0x16 */ - {0x0047,0x19,0x16,0x8c,0x06,0x37,1024, 768, 0x20}, /* 0x17 */ - {0x0107,0x1a,0x1b,0x00,0x06,0x37,1024, 768, 0x10}, /* 0x18 */ - {0x0107,0x1b,0x1f,0x00,0x06,0x37,1024, 768, 0x10}, /* 0x19 */ - {0x0087,0x1c,0x11,0x00,0x07,0x3a,1280,1024, 0x30}, /* 0x1a */ - {0x0137,0x1d,0x19,0x07,0x07,0x3a,1280,1024, 0x00}, /* 0x1b */ - {0x0107,0x1e,0x1e,0x00,0x07,0x3a,1280,1024, 0x00}, /* 0x1c */ - {0x0207,0x1f,0x20,0x00,0x07,0x3a,1280,1024, 0x00}, /* 0x1d */ - {0x0227,0x20,0x21,0x09,0x09,0x3c,1600,1200, 0x00}, /* 0x1e */ - {0x0407,0x21,0x22,0x00,0x09,0x3c,1600,1200, 0x00}, /* 0x1f */ - {0x0407,0x22,0x23,0x00,0x09,0x3c,1600,1200, 0x00}, /* 0x20 */ - {0x0407,0x23,0x25,0x00,0x09,0x3c,1600,1200, 0x00}, /* 0x21 */ - {0x0007,0x24,0x26,0x00,0x09,0x3c,1600,1200, 0x00}, /* 0x22 */ - {0x0007,0x25,0x2c,0x00,0x09,0x3c,1600,1200, 0x00}, /* 0x23 */ - {0x0007,0x26,0x34,0x00,0x09,0x3c,1600,1200, 0x00}, /* 0x24 */ - {0x407f,0x00,0x00,0x00,0x00,0x40, 320, 200, 0x30}, /* 0x25 */ - {0xc07f,0x01,0x00,0x04,0x04,0x50, 320, 240, 0x30}, /* 0x26 */ - {0x007f,0x02,0x04,0x05,0x05,0x51, 400, 300, 0x30}, /* 0x27 */ - {0xc077,0x03,0x0b,0x06,0x06,0x52, 512, 384, 0x30}, /* 0x28 */ - {0x8007,0x27,0x27,0x00,0x00,0x68,1920,1440, 0x00}, /* 0x29 */ - {0x4007,0x28,0x29,0x00,0x00,0x68,1920,1440, 0x00}, /* 0x2a */ - {0x4007,0x29,0x2e,0x00,0x00,0x68,1920,1440, 0x00}, /* 0x2b */ - {0x4007,0x2a,0x30,0x00,0x00,0x68,1920,1440, 0x00}, /* 0x2c */ - {0x4007,0x2b,0x35,0x00,0x00,0x68,1920,1440, 0x00}, /* 0x2d */ - {0x4005,0x2c,0x39,0x00,0x00,0x68,1920,1440, 0x00}, /* 0x2e */ - {0x4007,0x2d,0x2b,0x00,0x00,0x6c,2048,1536, 0x00}, /* 0x2f */ - {0x4007,0x2e,0x31,0x00,0x00,0x6c,2048,1536, 0x00}, /* 0x30 */ - {0x4007,0x2f,0x33,0x00,0x00,0x6c,2048,1536, 0x00}, /* 0x31 */ - {0x4007,0x30,0x37,0x00,0x00,0x6c,2048,1536, 0x00}, /* 0x32 */ - {0x4005,0x31,0x38,0x00,0x00,0x6c,2048,1536, 0x00}, /* 0x33 */ - {0x0077,0x32,0x40,0x08,0x18,0x70, 800, 480, 0x30}, /* 0x34 */ - {0x0047,0x33,0x07,0x08,0x18,0x70, 800, 480, 0x30}, /* 0x35 */ - {0x0047,0x34,0x0a,0x08,0x18,0x70, 800, 480, 0x30}, /* 0x36 */ - {0x0077,0x35,0x0b,0x09,0x19,0x71,1024, 576, 0x30}, /* 0x37 */ - {0x0047,0x36,0x11,0x09,0x19,0x71,1024, 576, 0x30}, /* 0x38 */ - {0x0047,0x37,0x16,0x09,0x19,0x71,1024, 576, 0x30}, /* 0x39 */ - {0x1137,0x38,0x19,0x0a,0x0c,0x75,1280, 720, 0x30}, /* 0x3a */ - {0x1107,0x39,0x1e,0x0a,0x0c,0x75,1280, 720, 0x30}, /* 0x3b */ - {0x1307,0x3a,0x20,0x0a,0x0c,0x75,1280, 720, 0x30}, /* 0x3c */ - {0x0127,0x3b,0x19,0x08,0x0a,0x7c,1280, 960, 0x30}, /* 0x3d */ - {0x0227,0x4c,0x59,0x08,0x0a,0x7c,1280, 960, 0x20}, /* 0x3e */ - {0xc07f,0x4e,0x00,0x06,0x04,0x5a, 320, 240, 0x30}, /* 0x3f */ /* FSTN 320x240 */ - {0x0077,0x42,0x5b,0x08,0x11,0x23,1280, 768, 0x30}, /* 0x40 */ /* 0x5b was 0x12 */ - {0x0127,0x43,0x4d,0x08,0x0b,0x26,1400,1050, 0x30}, /* 0x41 */ - {0x0207,0x4b,0x5a,0x08,0x0b,0x26,1400,1050, 0x30}, /* 0x42 1400x1050-75Hz */ - {0x0127,0x54,0x6d,0x00,0x1a,0x29,1152, 864, 0x30}, /* 0x43 1152x864-60Hz */ - {0x0127,0x44,0x19,0x00,0x1a,0x29,1152, 864, 0x30}, /* 0x44 1152x864-75Hz */ - {0x0127,0x4a,0x1e,0x00,0x1a,0x29,1152, 864, 0x30}, /* 0x45 1152x864-85Hz */ - {0x0087,0x45,0x57,0x00,0x16,0x39, 848, 480, 0x30}, /* 0x46 848x480-38Hzi */ - {0xc067,0x46,0x55,0x0b,0x16,0x39, 848, 480, 0x30}, /* 0x47 848x480-60Hz */ - {0x0087,0x47,0x57,0x00,0x17,0x3f, 856, 480, 0x30}, /* 0x48 856x480-38Hzi */ - {0xc067,0x48,0x57,0x00,0x17,0x3f, 856, 480, 0x30}, /* 0x49 856x480-60Hz */ - {0x0067,0x49,0x58,0x0c,0x1b,0x48,1360, 768, 0x30}, /* 0x4a 1360x768-60Hz */ - {0x006f,0x4d,0x03,0x06,0x15,0x5f, 768, 576, 0x30}, /* 0x4b 768x576-56Hz */ - {0x0067,0x4f,0x5c,0x08,0x0d,0x14,1280, 800, 0x30}, /* 0x4c 1280x800-60Hz */ - {0x0067,0x50,0x5d,0x0c,0x0e,0x17,1680,1050, 0x30}, /* 0x4d 1680x1050-60Hz */ - {0x0087,0x51,0x69,0x00,0x00,0x2c,1920,1080, 0x30}, /* 0x4e 1920x1080 60Hzi */ - {0x0067,0x52,0x6a,0x00,0x1c,0x1d, 960, 540, 0x30}, /* 0x4f 960x540 60Hz */ - {0x0077,0x53,0x6b,0x0b,0x1d,0x20, 960, 600, 0x30}, /* 0x50 960x600 60Hz */ - {0xffff,0x00,0x00,0x00,0x00,0x00, 0, 0, 0} -}; - -#ifdef LINUX_XF86 -static const struct { - UCHAR Ext_ModeID; /* ModeID in new ROM */ - UCHAR Ext_MyModeID; /* corresponding ModeID in my tables (0 = identical) */ - USHORT Ext_VESAID; /* corresponding VESA ID in new ROM */ -} SiS_EModeIDTable661[] = { - { 0x6a, 0x00, 0x0102 }, - { 0x1d, 0x20, 0x0000 }, - { 0x1e, 0x21, 0x0000 }, - { 0x1f, 0x22, 0x0000 }, - { 0x20, 0x29, 0x0000 }, - { 0x21, 0x2a, 0x0000 }, - { 0x22, 0x2b, 0x0000 }, - { 0x23, 0x00, 0x011c }, - { 0x24, 0x00, 0x011d }, - { 0x25, 0x00, 0x011e }, - { 0x26, 0x00, 0x011f }, - { 0x27, 0x00, 0x0120 }, - { 0x28, 0x00, 0x0121 }, - { 0x2a, 0x14, 0x013d }, - { 0x2b, 0x15, 0x013e }, - { 0x2c, 0x16, 0x013f }, - { 0x2e, 0x00, 0x0101 }, - { 0x2f, 0x00, 0x0100 }, - { 0x30, 0x00, 0x0103 }, - { 0x37, 0x00, 0x0104 }, - { 0x38, 0x00, 0x0105 }, - { 0x3a, 0x00, 0x0107 }, - { 0x3c, 0x00, 0x0125 }, - { 0x3d, 0x00, 0x0126 }, - { 0x40, 0x00, 0x010d }, - { 0x41, 0x00, 0x010e }, - { 0x43, 0x00, 0x0110 }, - { 0x44, 0x00, 0x0111 }, - { 0x46, 0x00, 0x0113 }, - { 0x47, 0x00, 0x0114 }, - { 0x49, 0x00, 0x0116 }, - { 0x4a, 0x00, 0x0117 }, - { 0x4c, 0x00, 0x0119 }, - { 0x4d, 0x00, 0x011a }, - { 0x50, 0x00, 0x0127 }, - { 0x51, 0x00, 0x0128 }, - { 0x52, 0x00, 0x0129 }, - { 0x56, 0x00, 0x012a }, - { 0x57, 0x00, 0x012b }, - { 0x58, 0x00, 0x012c }, - { 0x59, 0x00, 0x012d }, - { 0x5a, 0x17, 0x012e }, - { 0x5b, 0x18, 0x012f }, - { 0x5c, 0x19, 0x0130 }, - { 0x5d, 0x00, 0x0131 }, - { 0x62, 0x00, 0x0112 }, - { 0x63, 0x00, 0x0115 }, - { 0x64, 0x00, 0x0118 }, - { 0x65, 0x00, 0x011b }, - { 0x66, 0x00, 0x0132 }, - { 0x75, 0x00, 0x013a }, - { 0x78, 0x00, 0x013b }, - { 0x79, 0x00, 0x013c }, - { 0x7b, 0x7c, 0x0136 }, - { 0x7c, 0x7d, 0x0137 }, - { 0x7d, 0x7e, 0x0138 }, - { 0xff, 0xff, 0xffff } -}; -#endif - -static const SiS_CRT1TableStruct SiS310_CRT1Table[]= +static const struct SiS_Ext2 SiS310_RefIndex[] = +{ + {0x085f,0x0d,0x03,0x05,0x05,0x6a, 800, 600, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x0 */ + {0x0067,0x0e,0x04,0x05,0x05,0x6a, 800, 600, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x1 */ + {0x0067,0x0f,0x08,0x48,0x05,0x6a, 800, 600, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x2 */ + {0x0067,0x10,0x07,0x8b,0x05,0x6a, 800, 600, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x3 */ + {0x0047,0x11,0x0a,0x00,0x05,0x6a, 800, 600, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x4 */ + {0x0047,0x12,0x0d,0x00,0x05,0x6a, 800, 600, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x5 */ + {0x0047,0x13,0x13,0x00,0x05,0x6a, 800, 600, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x6 */ + {0x0107,0x14,0x1c,0x00,0x05,0x6a, 800, 600, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x7 */ + {0xc85f,0x05,0x00,0x04,0x04,0x2e, 640, 480, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x8 */ + {0xc067,0x06,0x02,0x04,0x04,0x2e, 640, 480, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x9 */ + {0xc067,0x07,0x02,0x47,0x04,0x2e, 640, 480, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0xa */ + {0xc067,0x08,0x03,0x8a,0x04,0x2e, 640, 480, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0xb */ + {0xc047,0x09,0x05,0x00,0x04,0x2e, 640, 480, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0xc */ + {0xc047,0x0a,0x09,0x00,0x04,0x2e, 640, 480, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0xd */ + {0xc047,0x0b,0x0e,0x00,0x04,0x2e, 640, 480, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0xe */ + {0xc047,0x0c,0x15,0x00,0x04,0x2e, 640, 480, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0xf */ + {0x487f,0x04,0x00,0x00,0x00,0x2f, 640, 400, 0x30, 0x55, 0x6e, 0x00, 0x00, 0x00, 0x00}, /* 0x10 */ + {0xc06f,0x3c,0x01,0x06,0x13,0x31, 720, 480, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x11 */ + {0x006f,0x3d,0x6f,0x06,0x14,0x32, 720, 576, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x12 (6f was 03) */ + {0x0087,0x15,0x06,0x00,0x06,0x37,1024, 768, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x13 */ + {0xc877,0x16,0x0b,0x06,0x06,0x37,1024, 768, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x14 */ + {0xc067,0x17,0x0f,0x49,0x06,0x37,1024, 768, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x15 */ + {0x0067,0x18,0x11,0x00,0x06,0x37,1024, 768, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x16 */ + {0x0047,0x19,0x16,0x8c,0x06,0x37,1024, 768, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x17 */ + {0x0107,0x1a,0x1b,0x00,0x06,0x37,1024, 768, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x18 */ + {0x0107,0x1b,0x1f,0x00,0x06,0x37,1024, 768, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x19 */ + {0x0087,0x1c,0x11,0x00,0x07,0x3a,1280,1024, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x1a */ + {0x0137,0x1d,0x19,0x07,0x07,0x3a,1280,1024, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x1b */ + {0x0107,0x1e,0x1e,0x00,0x07,0x3a,1280,1024, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x1c */ + {0x0207,0x1f,0x20,0x00,0x07,0x3a,1280,1024, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x1d */ + {0x0227,0x20,0x21,0x09,0x09,0x3c,1600,1200, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x1e */ + {0x0407,0x21,0x22,0x00,0x09,0x3c,1600,1200, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x1f */ + {0x0407,0x22,0x23,0x00,0x09,0x3c,1600,1200, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x20 */ + {0x0407,0x23,0x25,0x00,0x09,0x3c,1600,1200, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x21 */ + {0x0007,0x24,0x26,0x00,0x09,0x3c,1600,1200, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x22 */ + {0x0007,0x25,0x2c,0x00,0x09,0x3c,1600,1200, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x23 */ + {0x0007,0x26,0x34,0x00,0x09,0x3c,1600,1200, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x24 */ + {0x407f,0x00,0x00,0x00,0x00,0x40, 320, 200, 0x30, 0x56, 0x4e, 0x00, 0x00, 0x00, 0x00}, /* 0x25 */ + {0xc07f,0x01,0x00,0x04,0x04,0x50, 320, 240, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x26 */ + {0x007f,0x02,0x04,0x05,0x05,0x51, 400, 300, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x27 */ + {0xc077,0x03,0x0b,0x06,0x06,0x52, 512, 384, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x28 */ + {0x8007,0x27,0x27,0x00,0x00,0x68,1920,1440, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x29 */ + {0x4007,0x28,0x29,0x00,0x00,0x68,1920,1440, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x2a */ + {0x4007,0x29,0x2e,0x00,0x00,0x68,1920,1440, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x2b */ + {0x4007,0x2a,0x30,0x00,0x00,0x68,1920,1440, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x2c */ + {0x4007,0x2b,0x35,0x00,0x00,0x68,1920,1440, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x2d */ + {0x4005,0x2c,0x39,0x00,0x00,0x68,1920,1440, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x2e */ + {0x4007,0x2d,0x2b,0x00,0x00,0x6c,2048,1536, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x2f */ + {0x4007,0x2e,0x31,0x00,0x00,0x6c,2048,1536, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x30 */ + {0x4007,0x2f,0x33,0x00,0x00,0x6c,2048,1536, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x31 */ + {0x4007,0x30,0x37,0x00,0x00,0x6c,2048,1536, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x32 */ + {0x4005,0x31,0x38,0x00,0x00,0x6c,2048,1536, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x33 */ + {0x2077,0x32,0x40,0x08,0x18,0x70, 800, 480, 0x30, 0x00, 0x00, 0x32, 0x40, 0x5e, 0x73}, /* 0x34 */ + {0x2047,0x33,0x07,0x08,0x18,0x70, 800, 480, 0x30, 0x00, 0x00, 0x33, 0x07, 0xff, 0xff}, /* 0x35 */ + {0x2047,0x34,0x0a,0x08,0x18,0x70, 800, 480, 0x30, 0x00, 0x00, 0x34, 0x0a, 0xff, 0xff}, /* 0x36 */ + {0x2077,0x35,0x0b,0x09,0x19,0x71,1024, 576, 0x30, 0x00, 0x00, 0x35, 0x0b, 0x5f, 0x74}, /* 0x37 */ + {0x2047,0x36,0x11,0x09,0x19,0x71,1024, 576, 0x30, 0x00, 0x00, 0x36, 0x11, 0xff, 0xff}, /* 0x38 */ + {0x2047,0x37,0x16,0x09,0x19,0x71,1024, 576, 0x30, 0x00, 0x00, 0x37, 0x16, 0xff, 0xff}, /* 0x39 */ + {0x3137,0x38,0x19,0x0a,0x0c,0x75,1280, 720, 0x30, 0x00, 0x00, 0x38, 0x19, 0x60, 0x75}, /* 0x3a */ + {0x3107,0x39,0x1e,0x0a,0x0c,0x75,1280, 720, 0x30, 0x00, 0x00, 0x39, 0x1e, 0xff, 0xff}, /* 0x3b */ + {0x3307,0x3a,0x20,0x0a,0x0c,0x75,1280, 720, 0x30, 0x00, 0x00, 0x3a, 0x20, 0xff, 0xff}, /* 0x3c */ + {0x0127,0x3b,0x19,0x08,0x0a,0x7c,1280, 960, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x3d */ + {0x0227,0x4c,0x59,0x08,0x0a,0x7c,1280, 960, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x3e */ + {0xc07f,0x4e,0x00,0x06,0x04,0x5a, 320, 240, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x3f */ /* FSTN 320x240 */ + {0x2077,0x42,0x5b,0x08,0x11,0x23,1280, 768, 0x30, 0x00, 0x00, 0x58, 0x19, 0x42, 0x5b}, /* 0x40 */ /* 0x5b was 0x12 */ + {0x2077,0x42,0x5b,0x08,0x11,0x23,1280, 768, 0x30, 0x00, 0x00, 0x59, 0x1e, 0xff, 0xff}, /* 0x41 */ + {0x2077,0x42,0x5b,0x08,0x11,0x23,1280, 768, 0x30, 0x00, 0x00, 0x5a, 0x20, 0xff, 0xff}, /* 0x42 */ + {0x0127,0x43,0x4d,0x08,0x0b,0x26,1400,1050, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x43 */ + {0x0207,0x4b,0x5a,0x08,0x0b,0x26,1400,1050, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x44 1400x1050-75Hz */ + {0x0127,0x54,0x6d,0x00,0x1a,0x29,1152, 864, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x45 1152x864-60Hz */ + {0x0127,0x44,0x19,0x00,0x1a,0x29,1152, 864, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x46 1152x864-75Hz */ + {0x0127,0x4a,0x1e,0x00,0x1a,0x29,1152, 864, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x47 1152x864-85Hz */ + {0x0087,0x45,0x57,0x00,0x16,0x39, 848, 480, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x48 848x480-38Hzi */ + {0xc067,0x46,0x55,0x0b,0x16,0x39, 848, 480, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x49 848x480-60Hz */ + {0x0087,0x47,0x57,0x00,0x17,0x3f, 856, 480, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x4a 856x480-38Hzi */ + {0xc067,0x48,0x57,0x00,0x17,0x3f, 856, 480, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x4b 856x480-60Hz */ + {0x0067,0x49,0x58,0x0c,0x1b,0x48,1360, 768, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x4c 1360x768-60Hz */ + {0x006f,0x4d,0x71,0x06,0x15,0x5f, 768, 576, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x4d 768x576-56Hz */ + {0x2067,0x4f,0x5c,0x08,0x0d,0x14,1280, 800, 0x30, 0x00, 0x00, 0x5b, 0x19, 0x4f, 0x5c}, /* 0x4e 1280x800-60Hz */ + {0x2067,0x4f,0x5c,0x08,0x0d,0x14,1280, 800, 0x30, 0x00, 0x00, 0x5c, 0x1e, 0xff, 0xff}, /* 0x4f 1280x800-75Hz */ + {0x2067,0x4f,0x5c,0x08,0x0d,0x14,1280, 800, 0x30, 0x00, 0x00, 0x5d, 0x20, 0xff, 0xff}, /* 0x50 1280x800-85Hz */ + {0x0067,0x50,0x5d,0x0c,0x0e,0x17,1680,1050, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x51 1680x1050-60Hz */ + {0x0087,0x51,0x69,0x00,0x00,0x2c,1920,1080, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x52 1920x1080 60Hzi */ + {0x0067,0x52,0x6a,0x00,0x1c,0x1d, 960, 540, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x53 960x540 60Hz */ + {0x0077,0x53,0x6b,0x0b,0x1d,0x20, 960, 600, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0x54 960x600 60Hz */ + {0x2067,0x61,0x76,0x0d,0x22,0x1a,1280, 854, 0x30, 0x00, 0x00, 0x62, 0x19, 0x61, 0x76}, /* 0x55 1280x854-60Hz */ + {0x2067,0x61,0x76,0x0d,0x22,0x1a,1280, 854, 0x30, 0x00, 0x00, 0x63, 0x1e, 0xff, 0xff}, /* 0x56 1280x854-75Hz */ + {0x2067,0x61,0x76,0x0d,0x22,0x1a,1280, 854, 0x30, 0x00, 0x00, 0x64, 0x20, 0xff, 0xff}, /* 0x57 1280x854-85Hz */ + {0xffff,0x00,0x00,0x00,0x00,0x00, 0, 0, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} +}; + +static const struct SiS_CRT1Table SiS310_CRT1Table[] = { {{0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f, 0x9c,0x8e,0x8f,0x96,0xb9,0x30,0x00,0x00, - 0x00}}, /* 0x0 */ + 0x00}}, /* 0x0 */ {{0x2d,0x27,0x28,0x90,0x2c,0x80,0x0b,0x3e, 0xe9,0x8b,0xdf,0xe7,0x04,0x00,0x00,0x00, - 0x00}}, /* 0x1 */ + 0x00}}, /* 0x1 */ {{0x3d,0x31,0x31,0x81,0x37,0x1f,0x72,0xf0, 0x58,0x8c,0x57,0x57,0x73,0x20,0x00,0x05, - 0x01}}, /* 0x2 */ + 0x01}}, /* 0x2 */ {{0x4f,0x3f,0x3f,0x93,0x45,0x0d,0x24,0xf5, 0x02,0x88,0xff,0xff,0x25,0x10,0x00,0x01, - 0x01}}, /* 0x3 */ + 0x01}}, /* 0x3 */ {{0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, 0x9c,0x8e,0x8f,0x96,0xb9,0x30,0x00,0x05, - 0x00}}, /* 0x4 */ -#if 0 - {{0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e, - 0xe9,0x8b,0xdf,0xe7,0x04,0x00,0x00,0x05, - 0x00}}, /* 0x5 */ -#endif - {{0x5f,0x4f,0x4f,0x83,0x55,0x81,0x0b,0x3e, /* 0x05 - corrected 640x480-60 */ + 0x00}}, /* 0x4 */ + {{0x5f,0x4f,0x4f,0x83,0x55,0x81,0x0b,0x3e, /* corrected 640x480-60 */ 0xe9,0x8b,0xdf,0xe8,0x0c,0x00,0x00,0x05, - 0x00}}, -#if 0 - {{0x63,0x4f,0x50,0x86,0x56,0x9b,0x06,0x3e, - 0xe8,0x8b,0xdf,0xe7,0xff,0x10,0x00,0x01, - 0x00}}, /* 0x6 */ -#endif - {{0x63,0x4f,0x4f,0x87,0x56,0x9b,0x06,0x3e, /* 0x06 - corrected 640x480-72 */ + 0x00}}, /* 0x5 */ + {{0x63,0x4f,0x4f,0x87,0x56,0x9b,0x06,0x3e, /* corrected 640x480-72 */ 0xe8,0x8a,0xdf,0xe7,0x07,0x00,0x00,0x01, - 0x00}}, + 0x00}}, /* 0x6 */ {{0x64,0x4f,0x4f,0x88,0x55,0x9d,0xf2,0x1f, 0xe0,0x83,0xdf,0xdf,0xf3,0x10,0x00,0x01, - 0x00}}, /* 0x7 */ + 0x00}}, /* 0x7 */ {{0x63,0x4f,0x4f,0x87,0x5a,0x81,0xfb,0x1f, 0xe0,0x83,0xdf,0xdf,0xfc,0x10,0x00,0x05, - 0x00}}, /* 0x8 */ + 0x00}}, /* 0x8 */ {{0x65,0x4f,0x4f,0x89,0x58,0x80,0xfb,0x1f, 0xe0,0x83,0xdf,0xdf,0xfc,0x10,0x00,0x05, /* Corrected VBE */ - 0x61}}, /* 0x9 */ + 0x61}}, /* 0x9 */ {{0x65,0x4f,0x4f,0x89,0x58,0x80,0x01,0x3e, 0xe0,0x83,0xdf,0xdf,0x02,0x00,0x00,0x05, - 0x61}}, /* 0xa */ + 0x61}}, /* 0xa */ {{0x67,0x4f,0x4f,0x8b,0x58,0x81,0x0d,0x3e, 0xe0,0x83,0xdf,0xdf,0x0e,0x00,0x00,0x05, /* Corrected VBE */ - 0x61}}, /* 0xb */ + 0x61}}, /* 0xb */ {{0x65,0x4f,0x4f,0x89,0x57,0x9f,0xfb,0x1f, 0xe6,0x8a,0xdf,0xdf,0xfc,0x10,0x00,0x01, /* Corrected VDE, VBE */ - 0x00}}, /* 0xc */ + 0x00}}, /* 0xc */ {{0x7b,0x63,0x63,0x9f,0x6a,0x93,0x6f,0xf0, 0x58,0x8a,0x57,0x57,0x70,0x20,0x00,0x05, - 0x01}}, /* 0xd */ + 0x01}}, /* 0xd */ {{0x7f,0x63,0x63,0x83,0x6c,0x1c,0x72,0xf0, 0x58,0x8c,0x57,0x57,0x73,0x20,0x00,0x06, - 0x01}}, /* 0xe */ + 0x01}}, /* 0xe */ {{0x7d,0x63,0x63,0x81,0x6e,0x1d,0x98,0xf0, 0x7c,0x82,0x57,0x57,0x99,0x00,0x00,0x06, - 0x01}}, /* 0xf */ + 0x01}}, /* 0xf */ {{0x7f,0x63,0x63,0x83,0x69,0x13,0x6f,0xf0, 0x58,0x8b,0x57,0x57,0x70,0x20,0x00,0x06, - 0x01}}, /* 0x10 */ + 0x01}}, /* 0x10 */ {{0x7e,0x63,0x63,0x82,0x6b,0x13,0x75,0xf0, 0x58,0x8b,0x57,0x57,0x76,0x20,0x00,0x06, - 0x01}}, /* 0x11 */ + 0x01}}, /* 0x11 */ {{0x81,0x63,0x63,0x85,0x6d,0x18,0x7a,0xf0, 0x58,0x8b,0x57,0x57,0x7b,0x20,0x00,0x06, - 0x61}}, /* 0x12 */ + 0x61}}, /* 0x12 */ {{0x83,0x63,0x63,0x87,0x6e,0x19,0x81,0xf0, 0x58,0x8b,0x57,0x57,0x82,0x20,0x00,0x06, - 0x61}}, /* 0x13 */ + 0x61}}, /* 0x13 */ {{0x85,0x63,0x63,0x89,0x6f,0x1a,0x91,0xf0, 0x58,0x8b,0x57,0x57,0x92,0x20,0x00,0x06, - 0x61}}, /* 0x14 */ + 0x61}}, /* 0x14 */ {{0x99,0x7f,0x7f,0x9d,0x84,0x1a,0x96,0x1f, 0x7f,0x83,0x7f,0x7f,0x97,0x10,0x00,0x02, - 0x00}}, /* 0x15 */ + 0x00}}, /* 0x15 */ {{0xa3,0x7f,0x7f,0x87,0x86,0x97,0x24,0xf5, 0x02,0x88,0xff,0xff,0x25,0x10,0x00,0x02, - 0x01}}, /* 0x16 */ + 0x01}}, /* 0x16 */ {{0xa1,0x7f,0x7f,0x85,0x86,0x97,0x24,0xf5, 0x02,0x88,0xff,0xff,0x25,0x10,0x00,0x02, - 0x01}}, /* 0x17 */ + 0x01}}, /* 0x17 */ {{0x9f,0x7f,0x7f,0x83,0x85,0x91,0x1e,0xf5, 0x00,0x83,0xff,0xff,0x1f,0x10,0x00,0x02, - 0x01}}, /* 0x18 */ + 0x01}}, /* 0x18 */ {{0xa7,0x7f,0x7f,0x8b,0x89,0x95,0x26,0xf5, 0x00,0x83,0xff,0xff,0x27,0x10,0x00,0x02, - 0x01}}, /* 0x19 */ + 0x01}}, /* 0x19 */ {{0xa9,0x7f,0x7f,0x8d,0x8c,0x9a,0x2c,0xf5, 0x00,0x83,0xff,0xff,0x2d,0x14,0x00,0x02, - 0x62}}, /* 0x1a */ + 0x62}}, /* 0x1a */ {{0xab,0x7f,0x7f,0x8f,0x8d,0x9b,0x35,0xf5, 0x00,0x83,0xff,0xff,0x36,0x14,0x00,0x02, - 0x62}}, /* 0x1b */ + 0x62}}, /* 0x1b */ {{0xcf,0x9f,0x9f,0x93,0xb2,0x01,0x14,0xba, 0x00,0x83,0xff,0xff,0x15,0x00,0x00,0x03, - 0x00}}, /* 0x1c */ + 0x00}}, /* 0x1c */ {{0xce,0x9f,0x9f,0x92,0xa9,0x17,0x28,0x5a, 0x00,0x83,0xff,0xff,0x29,0x09,0x00,0x07, - 0x01}}, /* 0x1d */ + 0x01}}, /* 0x1d */ {{0xce,0x9f,0x9f,0x92,0xa5,0x17,0x28,0x5a, 0x00,0x83,0xff,0xff,0x29,0x09,0x00,0x07, - 0x01}}, /* 0x1e */ + 0x01}}, /* 0x1e */ {{0xd3,0x9f,0x9f,0x97,0xab,0x1f,0x2e,0x5a, 0x00,0x83,0xff,0xff,0x2f,0x09,0x00,0x07, - 0x01}}, /* 0x1f */ + 0x01}}, /* 0x1f */ {{0x09,0xc7,0xc7,0x8d,0xd3,0x0b,0xe0,0x10, 0xb0,0x83,0xaf,0xaf,0xe1,0x2f,0x01,0x04, - 0x00}}, /* 0x20 */ + 0x00}}, /* 0x20 */ {{0x09,0xc7,0xc7,0x8d,0xd3,0x0b,0xe0,0x10, 0xb0,0x83,0xaf,0xaf,0xe1,0x2f,0x01,0x04, - 0x00}}, /* 0x21 @ 4084 */ + 0x00}}, /* 0x21 */ {{0x09,0xc7,0xc7,0x8d,0xd3,0x0b,0xe0,0x10, 0xb0,0x83,0xaf,0xaf,0xe1,0x2f,0x01,0x04, - 0x00}}, /* 0x22 */ + 0x00}}, /* 0x22 */ {{0x09,0xc7,0xc7,0x8d,0xd3,0x0b,0xe0,0x10, 0xb0,0x83,0xaf,0xaf,0xe1,0x2f,0x01,0x04, - 0x00}}, /* 0x23 */ + 0x00}}, /* 0x23 */ {{0x09,0xc7,0xc7,0x8d,0xd3,0x0b,0xe0,0x10, 0xb0,0x83,0xaf,0xaf,0xe1,0x2f,0x01,0x04, - 0x00}}, /* 0x24 */ + 0x00}}, /* 0x24 */ {{0x09,0xc7,0xc7,0x8d,0xd3,0x0b,0xe0,0x10, 0xb0,0x83,0xaf,0xaf,0xe1,0x2f,0x01,0x04, - 0x00}}, /* 0x25 */ + 0x00}}, /* 0x25 */ {{0x09,0xc7,0xc7,0x8d,0xd3,0x0b,0xe0,0x10, 0xb0,0x83,0xaf,0xaf,0xe1,0x2f,0x01,0x04, - 0x00}}, /* 0x26 */ + 0x00}}, /* 0x26 */ {{0x40,0xef,0xef,0x84,0x03,0x1d,0xda,0x1f, 0xa0,0x83,0x9f,0x9f,0xdb,0x1f,0x41,0x01, - 0x00}}, /* 0x27 */ + 0x00}}, /* 0x27 */ {{0x43,0xef,0xef,0x87,0x06,0x00,0xd4,0x1f, 0xa0,0x83,0x9f,0x9f,0xd5,0x1f,0x41,0x05, - 0x63}}, /* 0x28 */ + 0x63}}, /* 0x28 */ {{0x45,0xef,0xef,0x89,0x07,0x01,0xd9,0x1f, 0xa0,0x83,0x9f,0x9f,0xda,0x1f,0x41,0x05, - 0x63}}, /* 0x29 */ + 0x63}}, /* 0x29 */ {{0x40,0xef,0xef,0x84,0x03,0x1d,0xda,0x1f, 0xa0,0x83,0x9f,0x9f,0xdb,0x1f,0x41,0x01, - 0x00}}, /* 0x2a */ + 0x00}}, /* 0x2a */ {{0x40,0xef,0xef,0x84,0x03,0x1d,0xda,0x1f, 0xa0,0x83,0x9f,0x9f,0xdb,0x1f,0x41,0x01, - 0x00}}, /* 0x2b */ + 0x00}}, /* 0x2b */ {{0x40,0xef,0xef,0x84,0x03,0x1d,0xda,0x1f, 0xa0,0x83,0x9f,0x9f,0xdb,0x1f,0x41,0x01, - 0x00}}, /* 0x2c */ + 0x00}}, /* 0x2c */ {{0x59,0xff,0xff,0x9d,0x17,0x13,0x33,0xba, 0x00,0x83,0xff,0xff,0x34,0x0f,0x41,0x05, - 0x44}}, /* 0x2d */ + 0x44}}, /* 0x2d */ {{0x5b,0xff,0xff,0x9f,0x18,0x14,0x38,0xba, 0x00,0x83,0xff,0xff,0x39,0x0f,0x41,0x05, - 0x44}}, /* 0x2e */ + 0x44}}, /* 0x2e */ {{0x5b,0xff,0xff,0x9f,0x18,0x14,0x3d,0xba, 0x00,0x83,0xff,0xff,0x3e,0x0f,0x41,0x05, - 0x44}}, /* 0x2f */ + 0x44}}, /* 0x2f */ {{0x5d,0xff,0xff,0x81,0x19,0x95,0x41,0xba, 0x00,0x84,0xff,0xff,0x42,0x0f,0x41,0x05, - 0x44}}, /* 0x30 */ + 0x44}}, /* 0x30 */ {{0x55,0xff,0xff,0x99,0x0d,0x0c,0x3e,0xba, 0x00,0x84,0xff,0xff,0x3f,0x0f,0x41,0x05, - 0x00}}, /* 0x31 */ + 0x00}}, /* 0x31 */ {{0x7f,0x63,0x63,0x83,0x6c,0x1c,0x72,0xba, 0x27,0x8b,0xdf,0xdf,0x73,0x00,0x00,0x06, - 0x01}}, /* 0x32 */ + 0x01}}, /* 0x32 */ {{0x7f,0x63,0x63,0x83,0x69,0x13,0x6f,0xba, 0x26,0x89,0xdf,0xdf,0x6f,0x00,0x00,0x06, - 0x01}}, /* 0x33 */ + 0x01}}, /* 0x33 */ {{0x7f,0x63,0x63,0x82,0x6b,0x13,0x75,0xba, 0x29,0x8c,0xdf,0xdf,0x75,0x00,0x00,0x06, - 0x01}}, /* 0x34 */ + 0x01}}, /* 0x34 */ {{0xa3,0x7f,0x7f,0x87,0x86,0x97,0x24,0xf1, 0xaf,0x85,0x3f,0x3f,0x25,0x30,0x00,0x02, - 0x01}}, /* 0x35 */ + 0x01}}, /* 0x35 */ {{0x9f,0x7f,0x7f,0x83,0x85,0x91,0x1e,0xf1, 0xad,0x81,0x3f,0x3f,0x1f,0x30,0x00,0x02, - 0x01}}, /* 0x36 */ + 0x01}}, /* 0x36 */ {{0xa7,0x7f,0x7f,0x88,0x89,0x95,0x26,0xf1, /* 95 was 15 - illegal HBE! */ 0xb1,0x85,0x3f,0x3f,0x27,0x30,0x00,0x02, - 0x01}}, /* 0x37 */ + 0x01}}, /* 0x37 */ {{0xce,0x9f,0x9f,0x92,0xa9,0x17,0x28,0xc4, 0x7a,0x8e,0xcf,0xcf,0x29,0x21,0x00,0x07, - 0x01}}, /* 0x38 */ + 0x01}}, /* 0x38 */ {{0xce,0x9f,0x9f,0x92,0xa5,0x17,0x28,0xd4, 0x7a,0x8e,0xcf,0xcf,0x29,0x21,0x00,0x07, - 0x01}}, /* 0x39 */ + 0x01}}, /* 0x39 */ {{0xd3,0x9f,0x9f,0x97,0xab,0x1f,0x2e,0xd4, 0x7d,0x81,0xcf,0xcf,0x2f,0x21,0x00,0x07, - 0x01}}, /* 0x3a */ -#if 0 - {{0xdc,0x9f,0x9f,0x00,0xab,0x19,0xe6,0xef, /* 1280x960 - invalid */ - 0xc0,0xc3,0xbf,0xbf,0xe7,0x10,0x00,0x07, - 0x01}}, /* 0x3b */ -#endif + 0x01}}, /* 0x3a */ {{0xdc,0x9f,0x9f,0x80,0xaf,0x9d,0xe6,0xff, /* 1280x960-60 - corrected */ 0xc0,0x83,0xbf,0xbf,0xe7,0x10,0x00,0x07, - 0x01}}, /* 0x3b */ + 0x01}}, /* 0x3b */ {{0x6b,0x59,0x59,0x8f,0x5e,0x8c,0x0b,0x3e, 0xe9,0x8b,0xdf,0xe7,0x04,0x00,0x00,0x05, - 0x00}}, /* 0x3c */ - {{0x7b,0x59,0x63,0x9f,0x6a,0x93,0x6f,0xf0, - 0x58,0x8a,0x3f,0x57,0x70,0x20,0x00,0x05, - 0x01}}, /* 0x3d */ + 0x00}}, /* 0x3c */ + {{0x6d,0x59,0x59,0x91,0x60,0x89,0x53,0xf0, /* 720x576, corrected to 60Hz */ + 0x41,0x84,0x3f,0x3f,0x54,0x00,0x00,0x05, + 0x41}}, /* 0x3d */ {{0x86,0x6a,0x6a,0x8a,0x74,0x06,0x8c,0x15, 0x4f,0x83,0xef,0xef,0x8d,0x30,0x00,0x02, - 0x00}}, /* 0x3e */ + 0x00}}, /* 0x3e */ {{0x81,0x6a,0x6a,0x85,0x70,0x00,0x0f,0x3e, 0xeb,0x8e,0xdf,0xdf,0x10,0x00,0x00,0x02, - 0x00}}, /* 0x3f */ + 0x00}}, /* 0x3f */ {{0xa3,0x7f,0x7f,0x87,0x86,0x97,0x1e,0xf1, 0xae,0x85,0x57,0x57,0x1f,0x30,0x00,0x02, 0x01}}, /* 0x40 */ @@ -578,11 +483,11 @@ static const SiS_CRT1TableStruct SiS310_CRT1Table[]= {{0xd3,0x9f,0x9f,0x97,0xab,0x1f,0xf1,0xff, /* 1280x960-85 */ 0xc0,0x83,0xbf,0xbf,0xf2,0x10,0x00,0x07, 0x01}}, /* 0x4c */ - {{0x7b,0x5f,0x63,0x9f,0x6a,0x93,0x6f,0xf0, /* 768x576 */ - 0x58,0x8a,0x3f,0x57,0x70,0x20,0x00,0x05, - 0x01}}, /* 0x4d */ - {{0x2d,0x27,0x28,0x90,0x2c,0x80,0x0b,0x3e, /* FSTN 320x480, TEMP - possibly invalid */ - 0xe9,0x8b,0xdf,0xe7,0x04,0x00,0x00,0x00, + {{0x75,0x5f,0x5f,0x99,0x66,0x90,0x53,0xf0, /* 768x576, corrected to 60Hz */ + 0x41,0x84,0x3f,0x3f,0x54,0x00,0x00,0x05, + 0x41}}, /* 0x4d */ + {{0x5f,0x27,0x4f,0x83,0x55,0x81,0x0b,0x3e, /* FSTN 320x240 (working) */ + 0xe9,0x8b,0xdf,0xe8,0x0c,0x00,0x00,0x05, 0x00}}, /* 0x4e */ {{0xcd,0x9f,0x9f,0x91,0xab,0x1c,0x3a,0xff, /* 1280x800-60 */ 0x20,0x83,0x1f,0x1f,0x3b,0x10,0x00,0x07, @@ -601,10 +506,58 @@ static const SiS_CRT1TableStruct SiS310_CRT1Table[]= 0x01}}, /* 0x53 */ {{0xcd,0x8f,0x8f,0x91,0x9b,0x1b,0x7a,0xff, /* 1152x864-60 */ 0x64,0x8c,0x5f,0x62,0x7b,0x10,0x00,0x07, - 0x41}} /* 0x54 */ -}; - -static const SiS_MCLKDataStruct SiS310_MCLKData_0_315[] = + 0x41}}, /* 0x54 */ + {{0x5c,0x4f,0x4f,0x80,0x57,0x80,0xa3,0x1f, /* fake 640x400@60Hz (for LCD and TV, not actually used) */ + 0x98,0x8c,0x8f,0x96,0xa4,0x30,0x00,0x05, + 0x40}}, /* 0x55 */ + {{0x2c,0x27,0x27,0x90,0x2d,0x92,0xa4,0x1f, /* fake 320x200@60Hz (for LCD and TV, not actually used) */ + 0x98,0x8c,0x8f,0x96,0xa5,0x30,0x00,0x04, + 0x00}}, /* 0x56 */ + {{0xd7,0xc7,0xc7,0x9b,0xd1,0x15,0xd1,0x10, /* 1600x1200 for LCDA */ + 0xb2,0x86,0xaf,0xb0,0xd2,0x2f,0x00,0x03, + 0x00}}, /* 0x57 */ + {{0xce,0x9f,0x9f,0x92,0xa9,0x17,0x28,0xdc, /* 1280x768 (1280x1024) 60 Hz */ + 0x92,0x86,0xff,0x91,0x29,0x21,0x00,0x07, + 0x01}}, /* 0x58 */ + {{0xce,0x9f,0x9f,0x92,0xa5,0x17,0x28,0xdc, /* 1280x768 (1280x1024) 75 Hz */ + 0x92,0x86,0xff,0x91,0x29,0x21,0x00,0x07, + 0x01}}, /* 0x59 */ + {{0xd3,0x9f,0x9f,0x97,0xab,0x1f,0x2e,0xdc, /* 1280x768 (1280x1024) 85 Hz */ + 0x95,0x89,0xff,0x94,0x2f,0x21,0x00,0x07, + 0x01}}, /* 0x5a */ + {{0xce,0x9f,0x9f,0x92,0xa9,0x17,0x28,0xde, /* 1280x800 (1280x1024) 60 Hz */ + 0xa2,0x86,0x1f,0xa1,0x29,0x01,0x00,0x07, + 0x01}}, /* 0x5b */ + {{0xce,0x9f,0x9f,0x92,0xa5,0x17,0x28,0xde, /* 1280x800 (1280x1024) 75 Hz */ + 0xa2,0x86,0x1f,0xa1,0x29,0x01,0x00,0x07, + 0x01}}, /* 0x5c */ + {{0xd3,0x9f,0x9f,0x97,0xab,0x1f,0x2e,0xde, /* 1280x800 (1280x1024) 85 Hz */ + 0xa5,0x89,0x1f,0xa4,0x2f,0x01,0x00,0x07, + 0x01}}, /* 0x5d */ + {{0x7f,0x63,0x63,0x83,0x6d,0x1d,0x0b,0x3e, /* 800x480 (wide) 60 Hz */ + 0xe9,0x8b,0xdf,0xe8,0x0c,0x00,0x00,0x06, + 0x00}}, /* 0x5e */ + {{0xa0,0x7f,0x7f,0x84,0x85,0x97,0x52,0xf0, /* 1024x576 (wide) 60 Hz */ + 0x41,0x85,0x3f,0x40,0x53,0x00,0x00,0x02, + 0x01}}, /* 0x5f */ + {{0xc9,0x9f,0x9f,0x8d,0xb0,0x15,0xec,0xf0, /* 1280x720 (wide) 60 Hz */ + 0xd4,0x89,0xcf,0xd3,0xed,0x20,0x00,0x07, + 0x01}}, /* 0x60 */ + {{0xcb,0x9f,0x9f,0x8f,0xa5,0x13,0x5b,0xff, /* 1280x854-60 wide */ + 0x56,0x89,0x55,0x55,0x5c,0x30,0x00,0x07, + 0x01}}, /* 0x61 */ + {{0xce,0x9f,0x9f,0x92,0xa9,0x17,0x28,0xde, /* 1280x854 (1280x1024) 60 Hz */ + 0xbd,0x81,0x55,0xbc,0x29,0x01,0x00,0x07, + 0x41}}, /* 0x62 */ + {{0xce,0x9f,0x9f,0x92,0xa5,0x17,0x28,0xde, /* 1280x854 (1280x1024) 75 Hz */ + 0xbd,0x81,0x55,0xbc,0x29,0x01,0x00,0x07, + 0x41}}, /* 0x63 */ + {{0xd3,0x9f,0x9f,0x97,0xab,0x1f,0x2e,0xde, /* 1280x854 (1280x1024) 85 Hz */ + 0xc0,0x84,0x55,0xbf,0x2f,0x01,0x00,0x07, + 0x41}} /* 0x64 */ +}; + +static const struct SiS_MCLKData SiS310_MCLKData_0_315[] = { { 0x3b,0x22,0x01,143}, { 0x5c,0x23,0x01,166}, @@ -616,7 +569,7 @@ static const SiS_MCLKDataStruct SiS310_MCLKData_0_315[] = { 0x5c,0x23,0x01,166} }; -static const SiS_MCLKDataStruct SiS310_MCLKData_0_650[] = +static const struct SiS_MCLKData SiS310_MCLKData_0_650[] = { { 0x5a,0x64,0x82, 66}, { 0xb3,0x45,0x82, 83}, @@ -628,7 +581,7 @@ static const SiS_MCLKDataStruct SiS310_MCLKData_0_650[] = { 0x37,0x22,0x82,133} }; -static const SiS_MCLKDataStruct SiS310_MCLKData_0_330[] = +static const struct SiS_MCLKData SiS310_MCLKData_0_330[] = { { 0x5c,0x23,0x01,166}, { 0x5c,0x23,0x01,166}, @@ -640,7 +593,7 @@ static const SiS_MCLKDataStruct SiS310_MCLKData_0_330[] = { 0x79,0x06,0x01,250} }; -static const SiS_MCLKDataStruct SiS310_MCLKData_0_660[] = +static const struct SiS_MCLKData SiS310_MCLKData_0_660[] = { { 0x5c,0x23,0x82,166}, { 0x5c,0x23,0x82,166}, @@ -652,7 +605,7 @@ static const SiS_MCLKDataStruct SiS310_MCLKData_0_660[] = { 0x37,0x21,0x82,200} }; -static const SiS_MCLKDataStruct SiS310_MCLKData_0_760[] = +static const struct SiS_MCLKData SiS310_MCLKData_0_760[] = { { 0x37,0x22,0x82,133}, { 0x5c,0x23,0x82,166}, @@ -664,7 +617,7 @@ static const SiS_MCLKDataStruct SiS310_MCLKData_0_760[] = { 0x37,0x21,0x82,200} }; -static const SiS_MCLKDataStruct SiS310_MCLKData_0_761[] = +static const struct SiS_MCLKData SiS310_MCLKData_0_761[] = { { 0x37,0x22,0x82,133}, /* Preliminary */ { 0x5c,0x23,0x82,166}, @@ -676,7 +629,7 @@ static const SiS_MCLKDataStruct SiS310_MCLKData_0_761[] = { 0x37,0x21,0x82,200} }; -static const SiS_MCLKDataStruct SiS310_MCLKData_0_340[] = +static const struct SiS_MCLKData SiS310_MCLKData_0_340[] = { { 0x79,0x06,0x01,250}, { 0x7c,0x08,0x01,200}, @@ -688,9 +641,9 @@ static const SiS_MCLKDataStruct SiS310_MCLKData_0_340[] = { 0x29,0x01,0x81,300} }; -static const SiS_MCLKDataStruct SiS310_MCLKData_1[] = /* ECLK */ +static const struct SiS_MCLKData SiS310_MCLKData_1[] = /* ECLK */ { - { 0x29,0x21,0x82,150}, + { 0x29,0x21,0x82,150}, { 0x5c,0x23,0x82,166}, { 0x65,0x23,0x82,183}, { 0x37,0x21,0x82,200}, @@ -700,7 +653,7 @@ static const SiS_MCLKDataStruct SiS310_MCLKData_1[] = /* ECLK */ { 0x37,0x22,0x82,133} }; -static const SiS_MCLKDataStruct SiS310_MCLKData_1_340[] = +static const struct SiS_MCLKData SiS310_MCLKData_1_340[] = { { 0x7c,0x08,0x01,200}, { 0x7c,0x08,0x01,200}, @@ -712,7 +665,7 @@ static const SiS_MCLKDataStruct SiS310_MCLKData_1_340[] = { 0x29,0x01,0x81,300} }; -static SiS_VCLKDataStruct SiS310_VCLKData[]= +static struct SiS_VCLKData SiS310_VCLKData[] = { { 0x1b,0xe1, 25}, /* 0x00 */ { 0x4e,0xe4, 28}, /* 0x01 */ @@ -805,7 +758,7 @@ static SiS_VCLKDataStruct SiS310_VCLKData[]= { 0x30,0x23, 88}, /* 0x58 1360x768-62 (is 60Hz!) */ { 0x52,0x07,149}, /* 0x59 1280x960-85 */ { 0x56,0x07,156}, /* 0x5a 1400x1050-75 */ - { 0x70,0x29, 81}, /* 0x5b 1280x768 LCD */ + { 0x70,0x29, 81}, /* 0x5b 1280x768 LCD */ { 0x45,0x25, 83}, /* 0x5c 1280x800 */ { 0x70,0x0a,147}, /* 0x5d 1680x1050 */ { 0x70,0x24,162}, /* 0x5e 1600x1200 */ @@ -823,10 +776,19 @@ static SiS_VCLKDataStruct SiS310_VCLKData[]= { 0x7c,0x6b, 38}, /* 0x6a 960x540@60 */ { 0xe3,0x56, 41}, /* 0x6b 960x600@60 */ { 0x45,0x25, 83}, /* 0x6c 1280x800 */ - { 0x70,0x28, 90} /* 0x6d 1152x864@60 */ + { 0x70,0x28, 90}, /* 0x6d 1152x864@60 */ + { 0x15,0xe1, 20}, /* 0x6e 640x400@60 (fake, not actually used) */ + { 0x5f,0xc6, 33}, /* 0x6f 720x576@60 */ + { 0x37,0x5a, 10}, /* 0x70 320x200@60 (fake, not actually used) */ + { 0x2b,0xc2, 35}, /* 0x71 768x576@60 */ + { 0xa8,0x42,131}, /* 0x72 1600x1200@60 for LCDA */ + { 0x1b,0xc1, 34}, /* 0x73 800x480 60Hz (wide) */ + { 0x41,0x64, 48}, /* 0x74 1024x576 60Hz (wide) */ + { 0x52,0x27, 75}, /* 0x75 1280x720 60Hz (wide) */ + { 0x75,0x13, 84} /* 0x76 1280x854 60Hz (wide) */ }; -static SiS_VBVCLKDataStruct SiS310_VBVCLKData[]= +static struct SiS_VBVCLKData SiS310_VBVCLKData[] = { { 0x1b,0xe1, 25}, /* 0x00 */ { 0x4e,0xe4, 28}, /* 0x01 */ @@ -858,12 +820,6 @@ static SiS_VBVCLKDataStruct SiS310_VBVCLKData[]= { 0x5e,0x43,113}, /* 0x1b */ { 0xbc,0x44,116}, /* 0x1c */ { 0xe0,0x46,132}, /* 0x1d */ -#if 0 - { 0xd4,0x28,135}, /* 0x1e */ - { 0xea,0x2a,139}, /* 0x1f */ - { 0x41,0x22,157}, /* 0x20 */ - { 0x70,0x24,162}, /* 0x21 */ -#endif { 0xe2,0x46,135}, /* 0x1e */ /* 1280x1024-75, better clock for VGA2 */ { 0xe5,0x46,139}, /* 0x1f */ /* 1024x768-120, better clock for VGA2 */ { 0x15,0x01,157}, /* 0x20 */ /* 1280x1024-85, better clock for VGA2 */ @@ -912,7 +868,7 @@ static SiS_VBVCLKDataStruct SiS310_VBVCLKData[]= { 0x34,0x61, 95}, /* 0x4b UNUSED */ { 0x78,0x27,108}, /* 0x4c UNUSED */ { 0x66,0x43,123}, /* 0x4d 1400x1050-60 */ - { 0x41,0x4e, 21}, /* 0x4e UNUSED */ + { 0x41,0x4e, 21}, /* 0x4e */ { 0xa1,0x4a, 29}, /* 0x4f UNUSED */ { 0x19,0x42, 42}, /* 0x50 UNUSED */ { 0x54,0x46, 58}, /* 0x51 UNUSED */ @@ -925,7 +881,7 @@ static SiS_VBVCLKDataStruct SiS310_VBVCLKData[]= { 0x30,0x23, 88}, /* 0x58 1360x768-62 (is 60Hz!) TEMP, UNUSED */ { 0x52,0x07,149}, /* 0x59 1280x960-85 */ { 0x56,0x07,156}, /* 0x5a 1400x1050-75 */ - { 0x70,0x29, 81}, /* 0x5b 1280x768 LCD (TMDS) */ + { 0x70,0x29, 81}, /* 0x5b 1280x768 LCD (TMDS) */ { 0xce,0x1e, 73}, /* 0x5c 1280x800_2 LCD (SiS LVDS) - (CRT1: 45 25 83) */ { 0xbe,0x44,121}, /* 0x5d 1680x1050 LCD */ { 0x70,0x24,162}, /* 0x5e 1600x1200 LCD */ @@ -943,57 +899,33 @@ static SiS_VBVCLKDataStruct SiS310_VBVCLKData[]= { 0x7c,0x6b, 38}, /* 0x6a 960x540@60 */ { 0xe3,0x56, 41}, /* 0x6b 960x600@60 */ { 0x9c,0x62, 69}, /* 0x6c 1280x800 (SiS TMDS) (special) */ - { 0x70,0x28, 90} /* 0x6d 1152x864@60 */ + { 0x70,0x28, 90}, /* 0x6d 1152x864@60 */ + { 0x15,0xe1, 20}, /* 0x6e 640x400@60 (fake, not actually used) */ + { 0x5f,0xc6, 33}, /* 0x6f 720x576@60 */ + { 0x37,0x5a, 10}, /* 0x70 320x200@60 (fake, not actually used) */ + { 0x2b,0xc2, 35}, /* 0x71 768@576@60 */ + { 0xa8,0x42,131}, /* 0x72 1600x1200@60 for LCDA */ + { 0x1b,0xc1, 34}, /* 0x73 800x480 60Hz (wide) */ + { 0x41,0x64, 48}, /* 0x74 1024x576 60Hz (wide) */ + { 0x52,0x27, 75}, /* 0x75 1280x720 60Hz (wide) */ + { 0x75,0x13, 84} /* 0x76 1280x854 60Hz (SiS LVDS) LCD */ }; -static const DRAM4Type SiS310_SR15[8] = { - {0x00,0x04,0x60,0x60}, - {0x0f,0x0f,0x0f,0x0f}, - {0xba,0xba,0xba,0xba}, - {0xa9,0xa9,0xac,0xac}, - {0xa0,0xa0,0xa0,0xa8}, - {0x00,0x00,0x02,0x02}, - {0x30,0x30,0x40,0x40}, - {0x00,0xa5,0xfb,0xf6} -}; - -#ifdef LINUX_KERNEL - -static UCHAR SiS310_SR07 = 0x18; - -static const DRAM4Type SiS310_CR40[5] = { - {0x77,0x77,0x33,0x33}, - {0x77,0x77,0x33,0x33}, - {0x00,0x00,0x00,0x00}, - {0x5b,0x5b,0x03,0x03}, - {0x00,0x00,0xf0,0xf8} +static const unsigned char SiS310_SR15[4 * 8] = +{ + 0x00,0x04,0x60,0x60, + 0x0f,0x0f,0x0f,0x0f, + 0xba,0xba,0xba,0xba, + 0xa9,0xa9,0xac,0xac, + 0xa0,0xa0,0xa0,0xa8, + 0x00,0x00,0x02,0x02, + 0x30,0x30,0x40,0x40, + 0x00,0xa5,0xfb,0xf6 }; -static UCHAR SiS310_CR49[] = {0xaa,0x88}; -static UCHAR SiS310_SR1F = 0x00; -static UCHAR SiS310_SR21 = 0xa5; -static UCHAR SiS310_SR22 = 0xfb; -static UCHAR SiS310_SR23 = 0xf6; -static UCHAR SiS310_SR24 = 0x0d; -static UCHAR SiS310_SR25[] = {0x33,0x3}; -static UCHAR SiS310_SR31 = 0x00; -static UCHAR SiS310_SR32 = 0x11; -static UCHAR SiS310_SR33 = 0x00; -static UCHAR SiS310_CRT2Data_1_2 = 0x00; -static UCHAR SiS310_CRT2Data_4_D = 0x00; -static UCHAR SiS310_CRT2Data_4_E = 0x00; -static UCHAR SiS310_CRT2Data_4_10 = 0x80; -static const USHORT SiS310_RGBSenseData = 0xd1; -static const USHORT SiS310_VideoSenseData = 0xb9; -static const USHORT SiS310_YCSenseData = 0xb3; -static const USHORT SiS310_RGBSenseData2 = 0x0190; -static const USHORT SiS310_VideoSenseData2 = 0x0174; -static const USHORT SiS310_YCSenseData2 = 0x016b; -#endif - -static const SiS_PanelDelayTblStruct SiS310_PanelDelayTbl[]= +static const struct SiS_PanelDelayTbl SiS310_PanelDelayTbl[] = { - {{0x10,0x40}}, + {{0x10,0x40}}, {{0x10,0x40}}, {{0x10,0x40}}, {{0x10,0x40}}, @@ -1011,7 +943,7 @@ static const SiS_PanelDelayTblStruct SiS310_PanelDelayTbl[]= {{0x10,0x40}} }; -static const SiS_PanelDelayTblStruct SiS310_PanelDelayTblLVDS[]= +static const struct SiS_PanelDelayTbl SiS310_PanelDelayTblLVDS[] = { {{0x28,0xc8}}, {{0x28,0xc8}}, @@ -1035,18 +967,18 @@ static const SiS_PanelDelayTblStruct SiS310_PanelDelayTblLVDS[]= /* SIS VIDEO BRIDGE ----------------------------------------- */ /**************************************************************/ -static const SiS_LCDDataStruct SiS310_St2LCD1024x768Data[] = +static const struct SiS_LCDData SiS310_St2LCD1024x768Data[] = { { 62, 25, 800, 546,1344, 806}, { 32, 15, 930, 546,1344, 806}, - { 62, 25, 800, 546,1344, 806}, + { 62, 25, 800, 546,1344, 806}, { 104, 45, 945, 496,1344, 806}, { 62, 25, 800, 546,1344, 806}, { 31, 18,1008, 624,1344, 806}, { 1, 1,1344, 806,1344, 806} }; -static const SiS_LCDDataStruct SiS310_ExtLCD1024x768Data[] = +static const struct SiS_LCDData SiS310_ExtLCD1024x768Data[] = { { 42, 25,1536, 419,1344, 806}, { 48, 25,1536, 369,1344, 806}, @@ -1057,7 +989,7 @@ static const SiS_LCDDataStruct SiS310_ExtLCD1024x768Data[] = { 1, 1,1344, 806,1344, 806} }; -static const SiS_LCDDataStruct SiS310_St2LCD1280x1024Data[] = +static const struct SiS_LCDData SiS310_St2LCD1280x1024Data[] = { { 22, 5, 800, 510,1650,1088}, { 22, 5, 800, 510,1650,1088}, @@ -1069,7 +1001,7 @@ static const SiS_LCDDataStruct SiS310_St2LCD1280x1024Data[] = { 1, 1,1688,1066,1688,1066} }; -static const SiS_LCDDataStruct SiS310_ExtLCD1280x1024Data[] = +static const struct SiS_LCDData SiS310_ExtLCD1280x1024Data[] = { { 211, 60,1024, 501,1688,1066}, { 211, 60,1024, 508,1688,1066}, @@ -1081,45 +1013,22 @@ static const SiS_LCDDataStruct SiS310_ExtLCD1280x1024Data[] = { 1, 1,1688,1066,1688,1066} }; -static const SiS_Part2PortTblStruct SiS310_CRT2Part2_1024x768_1[] = +static const struct SiS_Part2PortTbl SiS310_CRT2Part2_1024x768_1[] = { - {{0x25,0x12,0xc9,0xdc,0xb6,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x2c,0x12,0x9a,0xae,0x88,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x25,0x12,0xc9,0xdc,0xb6,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x38,0x13,0x16,0x0c,0xe6,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x38,0x18,0x16,0x00,0x00,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x36,0x13,0x13,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}} + {{0x25,0x12,0xc9,0xdc,0xb6,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, + {{0x2c,0x12,0x9a,0xae,0x88,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, + {{0x25,0x12,0xc9,0xdc,0xb6,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, + {{0x38,0x13,0x16,0x0c,0xe6,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, + {{0x38,0x18,0x16,0x00,0x00,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, + {{0x36,0x13,0x13,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}} }; -/* *** LCDA *** */ - -#if 0 -static const SiS_LVDSDataStruct SiS_LCDA1600x1200Data_1[]= -{ /* Clevo, 651+301C */ - {1200, 450, 2048,1250}, - {1200, 400, 2048,1250}, - {1280, 450, 2048,1250}, - {1280, 400, 2048,1250}, - {1200, 530, 2048,1250}, - {1360, 650, 2048,1250}, - {1584, 818, 2048,1250}, - {1688,1066, 2048,1250}, - {1688,1066, 2048,1250}, -#if 0 - {2048,1250, 2048,1250} /* this should be correct */ -#endif -#if 1 - {2160,1250, 2048,1250} /* ? */ -#endif -}; -#endif - /**************************************************************/ /* LVDS, CHRONTEL ------------------------------------------- */ /**************************************************************/ -static const SiS_LVDSDataStruct SiS310_CHTVUPALData[]= +static const struct SiS_LVDSData SiS310_CHTVUPALData[] = { {1008, 625,1008, 625}, {1008, 625,1008, 625}, @@ -1130,7 +1039,7 @@ static const SiS_LVDSDataStruct SiS310_CHTVUPALData[]= {1400,1000,1400,1000} }; -static const SiS_LVDSDataStruct SiS310_CHTVOPALData[]= +static const struct SiS_LVDSData SiS310_CHTVOPALData[] = { {1008, 625,1008, 625}, {1008, 625,1008, 625}, @@ -1138,10 +1047,10 @@ static const SiS_LVDSDataStruct SiS310_CHTVOPALData[]= {1008, 625,1008, 625}, { 840, 625, 840, 625}, { 944, 625, 944, 625}, - {1400, 875,1400, 875} + {1400, 875,1400, 875} }; -static const SiS_LVDSDataStruct SiS310_CHTVUPALMData[]= +static const struct SiS_LVDSData SiS310_CHTVUPALMData[] = { { 840, 600, 840, 600}, { 840, 600, 840, 600}, @@ -1149,10 +1058,10 @@ static const SiS_LVDSDataStruct SiS310_CHTVUPALMData[]= { 840, 600, 840, 600}, { 784, 600, 784, 600}, {1064, 750,1064, 750}, - {1160, 945,1160, 945} + {1160, 945,1160, 945} }; -static const SiS_LVDSDataStruct SiS310_CHTVOPALMData[]= +static const struct SiS_LVDSData SiS310_CHTVOPALMData[] = { { 840, 525, 840, 525}, { 840, 525, 840, 525}, @@ -1160,10 +1069,10 @@ static const SiS_LVDSDataStruct SiS310_CHTVOPALMData[]= { 840, 525, 840, 525}, { 784, 525, 784, 525}, {1040, 700,1040, 700}, - {1160, 840,1160, 840} + {1160, 840,1160, 840} }; -static const SiS_LVDSDataStruct SiS310_CHTVUPALNData[]= +static const struct SiS_LVDSData SiS310_CHTVUPALNData[] = { {1008, 625,1008, 625}, {1008, 625,1008, 625}, @@ -1174,7 +1083,7 @@ static const SiS_LVDSDataStruct SiS310_CHTVUPALNData[]= {1400,1000,1400,1000} }; -static const SiS_LVDSDataStruct SiS310_CHTVOPALNData[]= +static const struct SiS_LVDSData SiS310_CHTVOPALNData[] = { {1008, 625,1008, 625}, {1008, 625,1008, 625}, @@ -1182,10 +1091,10 @@ static const SiS_LVDSDataStruct SiS310_CHTVOPALNData[]= {1008, 625,1008, 625}, { 840, 625, 840, 625}, { 944, 625, 944, 625}, - {1400, 875,1400, 875} + {1400, 875,1400, 875} }; -static const SiS_LVDSDataStruct SiS310_CHTVSOPALData[]= /* (super overscan - no effect on 7019) */ +static const struct SiS_LVDSData SiS310_CHTVSOPALData[] = /* (super overscan - no effect on 7019) */ { {1008, 625,1008, 625}, {1008, 625,1008, 625}, @@ -1196,1333 +1105,10 @@ static const SiS_LVDSDataStruct SiS310_CHTVSOPALData[]= /* (super overscan - {1400, 875,1400, 875} }; - -static const SiS_LVDSDesStruct SiS310_PanelType00_1[]= /* 800x600 */ -{ - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType01_1[]= /* 1024x768 */ -{ - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 805}, - { 0, 0}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType02_1[]= /* 1280x1024 */ -{ - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 1065}, - { 0, 0}, - { 0, 0} -}; - - -static const SiS_LVDSDesStruct SiS310_PanelType03_1[]= -{ - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType04_1[]= -{ - {1343, 798}, - {1343, 794}, - {1343, 798}, - {1343, 794}, - {1343, 0}, - {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType05_1[]= -{ - {1343, 798}, - {1343, 794}, - {1343, 798}, - {1343, 794}, - {1343, 0}, - {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType06_1[]= -{ - {1343, 798}, - {1343, 794}, - {1343, 798}, - {1343, 794}, - {1343, 0}, - {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType07_1[]= -{ - {1343, 798}, - {1343, 794}, - {1343, 798}, - {1343, 794}, - {1343, 0}, - {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType08_1[]= /* 1400x1050 */ -{ - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType09_1[]= /* 1280x768 */ -{ - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType0a_1[]= /* 1600x1200 */ -{ - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType0b_1[]= /* 640x480_2 */ -{ - { 0, 524}, - { 0, 524}, - { 0, 524}, - { 0, 524}, - { 0, 524}, - { 0, 524}, - { 8, 524}, - { 0, 524} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType0c_1[]= /* 640x480_3 */ -{ - { 0, 524}, - { 0, 524}, - { 0, 524}, - { 0, 524}, - { 0, 524}, - { 0, 524}, - { 8, 524}, - { 0, 524} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType0d_1[]= -{ - {1343, 798}, - {1343, 794}, - {1343, 798}, - {1343, 794}, - {1343, 0}, - {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType0e_1[]= -{ - {1343, 798}, - {1343, 794}, - {1343, 798}, - {1343, 794}, - {1343, 0}, - {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType0f_1[]= -{ - {1343, 798}, - {1343, 794}, - {1343, 798}, - {1343, 794}, - {1343, 0}, - {1343, 0}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType00_2[]= -{ - {980, 528}, - {980, 503}, - {980, 528}, - {980, 503}, - {980, 568}, - { 0, 628}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType01_2[]= -{ - {1152, 622}, - {1152, 597}, - {1152, 622}, - {1152, 597}, - {1152, 662}, - {1232, 722}, - { 0, 806}, - { 0, 0}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType02_2[]= -{ - {1368, 754}, - {1368, 729}, - {1368, 754}, - {1368, 729}, - {1368, 794}, - {1448, 854}, - {1560, 938}, - { 0,1066}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType03_2[]= -{ - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType04_2[]= -{ - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType05_2[]= -{ - {1152, 622}, - {1152, 597}, - {1152, 622}, - {1152, 597}, - {1152, 662}, - {1232, 722}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType06_2[]= -{ - {1152, 622}, - {1152, 597}, - {1152, 622}, - {1152, 597}, - {1152, 662}, - {1232, 722}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType07_2[]= -{ - {1152, 622}, - {1152, 597}, - {1152, 622}, - {1152, 597}, - {1152, 662}, - {1232, 722}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType08_2[]= /* 1400x1050 */ -{ - {1308, 741}, - {1308, 716}, - {1308, 741}, - {1308, 716}, - {1308, 781}, - {1388, 841}, - {1500, 925}, - {1628,1053}, - { 0,1065}, - { 0, 0}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType09_2[]= /* 1280x768 */ -{ - {1083, 622}, - {1083, 597}, - {1083, 622}, - {1083, 597}, - {1083, 662}, - {1163, 722}, - {1286, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType0a_2[]= /* 1600x1200 */ -{ - {1568, 920}, - {1568, 895}, - {1568, 920}, - {1568, 895}, - {1568, 960}, - {1648,1020}, - {1760,1104}, - {1888,1232}, - {1948,1245}, - { 0, 0} -#if 0 - {1568, 850}, - {1568, 825}, - {1568, 850}, - {1568, 825}, - {1568, 890}, - {1648, 950}, - {1760,1034}, - {1888,1162}, - {1948,1175}, - { 0, 0} -#endif -}; - -static const SiS_LVDSDesStruct SiS310_PanelType0b_2[]= /* 640x480_2 */ -{ - {1152, 622}, - {1152, 597}, - {1152, 622}, - {1152, 597}, - {1152, 662}, - {1232, 722}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType0c_2[]= /* 640x480_3 */ -{ - {1152, 622}, - {1152, 597}, - {1152, 622}, - {1152, 597}, - {1152, 662}, - {1232, 722}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType0d_2[]= -{ - {1152, 622}, - {1152, 597}, - {1152, 622}, - {1152, 597}, - {1152, 662}, - {1232, 722}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType0e_2[]= -{ - {1152, 622}, - {1152, 597}, - {1152, 622}, - {1152, 597}, - {1152, 662}, - {1232, 722}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelType0f_2[] = -{ - {1152, 622}, - {1152, 597}, - {1152, 622}, - {1152, 597}, - {1152, 662}, - {1232, 722}, - { 0, 805}, - { 0, 794}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelTypeNS_1[]= -{ - { 8, 0}, - { 8, 0}, - { 8, 0}, - { 8, 0}, - { 8, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 806}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS310_PanelTypeNS_2[] = -{ - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0}, - { 0 , 0} -}; - -/* CRT1 CRTC for SlaveModes and LCDA */ - -static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT1800x600_1[] = -{ - {{0x6b,0x4f,0x8f,0x55,0x85,0xaa,0x1f, - 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, - 0x00 }}, - {{0x6b,0x4f,0x8f,0x55,0x85,0x78,0x1f, - 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, - 0x00 }}, - {{0x6b,0x4f,0x8f,0x55,0x85,0xaa,0x1f, - 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, - 0x00 }}, - {{0x6b,0x4f,0x8f,0x55,0x85,0x78,0x1f, - 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, - 0x00 }}, - {{0x6b,0x4f,0x8f,0x55,0x85,0xfa,0x1f, - 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05, - 0x00 }}, - {{0x7f,0x63,0x83,0x69,0x19,0x72,0xf0, - 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, - 0x01 }} -}; - -static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT1800x600_1_H[] = -{ - {{0x43,0x27,0x87,0x2d,0x1d,0xaa,0x1f, - 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, - 0x00 }}, - {{0x43,0x27,0x87,0x2d,0x1d,0x78,0x1f, - 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, - 0x00 }}, - {{0x43,0x27,0x87,0x2d,0x1d,0xfa,0x1f, - 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05, - 0x00 }}, - {{0x43,0x27,0x87,0x2d,0x1d,0x78,0x1f, - 0x5e,0x83,0x5d,0x79,0x10,0x00,0x05, - 0x00 }}, - {{0x43,0x27,0x87,0x2d,0x1d,0xfa,0x1f, - 0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05, - 0x00 }}, - {{0x4d,0x31,0x91,0x37,0x07,0x72,0xf0, - 0x58,0x8d,0x57,0x73,0x20,0x00,0x01, - 0x01 }} -}; - -static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT1800x600_2[]= -{ - {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, - 0xff,0x84,0x8f,0x73,0x00,0x00,0x06, - 0x00 }}, - {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, - 0xe6,0x8b,0x5d,0x73,0x00,0x00,0x06, - 0x00 }}, - {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, - 0xff,0x84,0x8f,0x73,0x00,0x00,0x06, - 0x00 }}, - {{0x7f,0x4f,0x83,0x62,0x12,0x72,0x3e, - 0xe6,0x8b,0x5d,0x73,0x00,0x00,0x06, - 0x00 }}, - {{0x7f,0x4f,0x83,0x62,0x12,0x72,0xba, - 0x27,0x8c,0xdf,0x73,0x00,0x00,0x06, - 0x00 }}, - {{0x7f,0x63,0x83,0x69,0x19,0x72,0xf0, - 0x58,0x8d,0x57,0x73,0x20,0x00,0x06, - 0x01 }} -}; - -static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT1800x600_2_H[] = -{ - {{0x57,0x27,0x9b,0x3a,0x0a,0x72,0x3e, - 0xff,0x84,0x8f,0x73,0x00,0x00,0x01, - 0x00 }}, - {{0x57,0x27,0x9b,0x3a,0x0a,0x72,0x3e, - 0xd6,0x8b,0x5d,0x73,0x00,0x00,0x01, - 0x00 }}, - {{0x57,0x27,0x9b,0x3a,0x0a,0x72,0x3e, - 0xff,0x84,0x8f,0x73,0x00,0x00,0x01, - 0x00 }}, - {{0x57,0x27,0x9b,0x3a,0x0a,0x72,0x3e, - 0xd6,0x8b,0x5d,0x73,0x00,0x00,0x01, - 0x00 }}, - {{0x57,0x27,0x9b,0x3a,0x0a,0x72,0xba, - 0x27,0x8c,0xdf,0x73,0x00,0x00,0x01, - 0x00 }}, - {{0x4d,0x31,0x91,0x3a,0x0a,0x72,0xf0, - 0x63,0x88,0x57,0x73,0x00,0x00,0x01, - 0x01 }} -}; - -static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_1[] = -{ - {{0x73,0x4f,0x97,0x53,0x84,0xb4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x05, - 0x00}}, - {{0x73,0x4f,0x97,0x53,0x84,0x82,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x05, - 0x00}}, - {{0x73,0x4f,0x97,0x53,0x84,0xb4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x05, - 0x00}}, - {{0x73,0x4f,0x97,0x53,0x84,0x82,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x05, - 0x00}}, - {{0x73,0x4f,0x97,0x53,0x84,0x04,0x3e, - 0xE2,0x89,0xDf,0x05,0x00,0x00,0x05, - 0x00}}, - {{0x87,0x63,0x8B,0x67,0x18,0x7c,0xf0, - 0x5A,0x81,0x57,0x7D,0x00,0x00,0x06, - 0x01}}, - {{0xA3,0x7f,0x87,0x83,0x94,0x24,0xf5, - 0x02,0x89,0xFf,0x25,0x10,0x00,0x02, - 0x01}} -}; - -static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_1_H[] = -{ - {{0x4b,0x27,0x8f,0x2b,0x1c,0xb4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x05, - 0x00 }}, - {{0x4b,0x27,0x8f,0x2b,0x1c,0x82,0x1f, - 0x60,0x87,0x5D,0x83,0x01,0x00,0x05, - 0x00}}, - {{0x4b,0x27,0x8f,0x2b,0x1c,0xb4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x05, - 0x00}}, - {{0x4b,0x27,0x8f,0x2b,0x1c,0x82,0x1f, - 0x60,0x87,0x5D,0x83,0x01,0x00,0x05, - 0x00}}, - {{0x4b,0x27,0x8f,0x2b,0x1c,0x04,0x3e, - 0xE2,0x89,0xDf,0x05,0x00,0x00,0x05, - 0x00}}, - {{0x55,0x31,0x99,0x35,0x06,0x7c,0xf0, - 0x5A,0x81,0x57,0x7D,0x00,0x00,0x01, - 0x01}}, - {{0x63,0x3F,0x87,0x43,0x94,0x24,0xf5, - 0x02,0x89,0xFf,0x25,0x10,0x00,0x01, - 0x01 }} -}; - -static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_2[] = -{ - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x57,0x8e,0x8f,0x25,0x30,0x00,0x06, - 0x00 }}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x3e,0x85,0x5d,0x25,0x10,0x00,0x06, - 0x00 }}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x57,0x8e,0x8f,0x25,0x30,0x00,0x06, - 0x00 }}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x3e,0x85,0x5d,0x25,0x10,0x00,0x06, - 0x01 }}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x7f,0x86,0xdf,0x25,0x10,0x00,0x06, - 0x00 }}, - {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1, - 0xbb,0x82,0x57,0x25,0x10,0x00,0x02, - 0x01 }}, - {{0xa3,0x7f,0x87,0x83,0x94,0x24,0xf5, - 0x02,0x89,0xff,0x25,0x10,0x00,0x02, - 0x01 }} -}; - -static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11024x768_2_H[] = -{ - {{0x7b,0x27,0x9f,0x46,0x97,0x24,0xbb, - 0x57,0x8e,0x8f,0x25,0x30,0x00,0x01, - 0x00 }}, - {{0x7b,0x27,0x9f,0x46,0x97,0x24,0xbb, - 0x3e,0x85,0x5d,0x25,0x10,0x00,0x01, - 0x00 }}, - {{0x7b,0x27,0x9f,0x46,0x97,0x24,0xbb, - 0x57,0x8e,0x8f,0x25,0x30,0x00,0x01, - 0x00 }}, - {{0x7b,0x27,0x9f,0x46,0x97,0x24,0xbb, - 0x3e,0x85,0x5d,0x25,0x10,0x00,0x01, - 0x00 }}, - {{0x7b,0x27,0x9f,0x46,0x97,0x24,0xbb, - 0x7f,0x86,0xdf,0x25,0x10,0x00,0x01, - 0x00 }}, - {{0x71,0x31,0x95,0x46,0x97,0x24,0xf1, - 0xbb,0x82,0x57,0x25,0x10,0x00,0x01, - 0x01 }}, - {{0x63,0x3f,0x87,0x46,0x97,0x24,0xf5, - 0x0f,0x86,0xff,0x25,0x30,0x00,0x01, - 0x01 }} -}; - -static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_1[] = -{ - {{0x7e,0x4f,0x82,0x58,0x04,0xb8,0x1f, - 0x90,0x84,0x8f,0xb9,0x30,0x00,0x06, - 0x00}}, - {{0x7e,0x4f,0x82,0x58,0x04,0x86,0x1f, - 0x5e,0x82,0x5d,0x87,0x10,0x00,0x06, - 0x00}}, - {{0x7e,0x4f,0x82,0x58,0x04,0xb8,0x1f, - 0x90,0x84,0x8f,0xb9,0x30,0x00,0x06, - 0x00}}, - {{0x7e,0x4f,0x82,0x58,0x04,0x86,0x1f, - 0x5e,0x82,0x5d,0x87,0x10,0x00,0x06, - 0x00}}, - {{0x7e,0x4f,0x82,0x58,0x04,0x08,0x3e, - 0xe0,0x84,0xdf,0x09,0x00,0x00,0x06, - 0x00}}, - {{0x92,0x63,0x96,0x6c,0x18,0x80,0xf0, - 0x58,0x8c,0x57,0x81,0x20,0x00,0x06, - 0x01}}, - {{0xae,0x7f,0x92,0x88,0x94,0x28,0xf5, - 0x00,0x84,0xff,0x29,0x10,0x00,0x02, - 0x01}}, - {{0xce,0x9f,0x92,0xa8,0x14,0x28,0x5a, - 0x00,0x84,0xff,0x29,0x09,0x00,0x07, - 0x01}} -}; - -static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_1_H[] = -{ - {{0x56,0x27,0x9a,0x31,0x1c,0xb8,0x1f, - 0x90,0x84,0x8f,0xb9,0x30,0x00,0x05, - 0x00}}, - {{0x56,0x27,0x9a,0x31,0x1c,0x86,0x1f, - 0x5e,0x82,0x5d,0x87,0x10,0x00,0x05, - 0x00}}, - {{0x56,0x27,0x9a,0x31,0x1c,0xb8,0x1f, - 0x90,0x84,0x8f,0xb9,0x30,0x00,0x05, - 0x00}}, - {{0x56,0x27,0x9a,0x31,0x1c,0x86,0x1f, - 0x5e,0x82,0x5d,0x87,0x10,0x00,0x05, - 0x01}}, - {{0x56,0x27,0x9a,0x31,0x1c,0x08,0x3e, - 0xe0,0x84,0xdf,0x09,0x00,0x00,0x05, - 0x00}}, - {{0x60,0x31,0x84,0x3a,0x86,0x80,0xf0, - 0x58,0x8c,0x57,0x81,0x20,0x00,0x01, - 0x01}}, - {{0x6e,0x3f,0x92,0x48,0x94,0x28,0xf5, - 0x00,0x84,0xff,0x29,0x10,0x00,0x01, - 0x01}} -}; - -static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_2[] = -{ - {{0xce,0x72,0x91,0x81,0x8f,0x28,0x92, - 0xc8,0x8c,0x5d,0x5c,0x01,0x00,0x02, - 0x01}}, - {{0xce,0x72,0x91,0x81,0x8f,0x28,0x92, - 0xaf,0x83,0x44,0x43,0x21,0x00,0x02, - 0x01}}, - {{0xce,0x72,0x91,0x81,0x8f,0x28,0x92, - 0xc8,0x8c,0x5d,0x5c,0x01,0x00,0x02, - 0x01}}, - {{0xce,0x72,0x91,0x81,0x8f,0x28,0x92, - 0xaf,0x83,0x44,0x43,0x21,0x00,0x02, - 0x01}}, - {{0xce,0x72,0x91,0x81,0x8f,0x28,0x92, - 0xf0,0x84,0x85,0x84,0x11,0x00,0x02, - 0x01}}, - {{0xce,0x63,0x92,0x8b,0x19,0x28,0xd4, - 0x3f,0x83,0x57,0x29,0x01,0x00,0x03, - 0x01}}, - {{0xce,0x7f,0x92,0x99,0x07,0x28,0xd4, - 0x93,0x87,0xff,0x29,0x21,0x00,0x07, - 0x01}}, - {{0xce,0x9f,0x92,0xa8,0x14,0x28,0x5a, - 0x00,0x84,0xff,0x29,0x09,0x00,0x07, - 0x01}} -}; - -static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11280x1024_2_H[] = -{ - {{0xa6,0x4a,0x89,0x59,0x07,0x28,0x92, - 0xc8,0x8c,0x5d,0x5c,0x01,0x00,0x06, - 0x01}}, - {{0xa6,0x4a,0x89,0x59,0x07,0x28,0x92, - 0xaf,0x83,0x44,0x43,0x21,0x00,0x06, - 0x01}}, - {{0xa6,0x4a,0x89,0x59,0x07,0x28,0x92, - 0xc8,0x8c,0x5d,0x5c,0x01,0x00,0x06, - 0x01}}, - {{0xa6,0x4a,0x89,0x59,0x07,0x28,0x92, - 0xfa,0x83,0x44,0x43,0x31,0x00,0x06, - 0x01}}, - {{0xa6,0x4a,0x89,0x59,0x07,0x28,0x92, - 0xf0,0x84,0x85,0x84,0x11,0x00,0x06, - 0x01}}, - {{0x9c,0x31,0x80,0x59,0x87,0x28,0xd4, - 0x3f,0x83,0x57,0x29,0x01,0x00,0x06, - 0x01}}, - {{0x8e,0x3f,0x92,0x59,0x07,0x28,0xd4, - 0x93,0x87,0xff,0x29,0x21,0x00,0x06, - 0x01}} -}; - -static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_1[] = -{ - {{0x6f,0x4f,0x93,0x54,0x82,0x9e,0x1f, - 0x8f,0x81,0x8f,0x9f,0x30,0x00,0x05, - 0x00}}, - {{0x6f,0x4f,0x93,0x54,0x82,0x6c,0x1f, - 0x5e,0x81,0x5d,0x6d,0x10,0x00,0x05, - 0x00}}, - {{0x6f,0x4f,0x93,0x54,0x82,0x9e,0x1f, - 0x90,0x83,0x8f,0x9f,0x30,0x00,0x05, - 0x00}}, - {{0x6f,0x4f,0x93,0x54,0x82,0x6c,0x1f, - 0x60,0x84,0x5d,0x6d,0x10,0x00,0x05, - 0x00}}, - {{0x6f,0x4f,0x93,0x54,0x82,0xee,0x1f, - 0xdf,0x82,0xdf,0xef,0x10,0x00,0x05, - 0x00}}, - {{0x83,0x63,0x87,0x68,0x16,0x66,0xf0, - 0x57,0x8e,0x57,0x67,0x20,0x00,0x06, - 0x01}}, - {{0x9f,0x7f,0x83,0x84,0x92,0x0e,0xf1, - 0xff,0x86,0xff,0x0f,0x10,0x00,0x02, - 0x01,}}, - {{0xbf,0x9f,0x83,0xa4,0x12,0x0e,0xde, - 0xff,0x86,0xff,0x0f,0x01,0x00,0x07, - 0x01}}, - {{0xce,0xae,0x92,0xb3,0x01,0x28,0x10, - 0x19,0x80,0x19,0x29,0x0f,0x00,0x03, - 0x00}} -#if 0 - {{0x6f,0x4f,0x93,0x54,0x82,0x9e,0x1f, - 0x93,0x86,0x8f,0x9f,0x30,0x00,0x05, - 0x00}}, - {{0x6f,0x4f,0x93,0x54,0x82,0x6c,0x1f, - 0x60,0x84,0x5d,0x6d,0x10,0x00,0x05, - 0x00}}, - {{0x6f,0x4f,0x93,0x54,0x82,0x9e,0x1f, - 0x93,0x86,0x8f,0x9f,0x30,0x00,0x05, - 0x00}}, - {{0x6f,0x4f,0x93,0x54,0x82,0x6c,0x1f, - 0x60,0x84,0x5d,0x6d,0x10,0x00,0x05, - 0x00}}, - {{0x6f,0x4f,0x93,0x54,0x82,0xee,0x1f, - 0xe2,0x86,0xdf,0xef,0x10,0x00,0x05, - 0x00}}, - {{0x83,0x63,0x87,0x68,0x16,0x66,0xf0, - 0x5a,0x8e,0x57,0x67,0x20,0x00,0x06, - 0x01}}, - {{0x9f,0x7f,0x83,0x84,0x92,0x0e,0xf5, - 0x02,0x86,0xff,0x0f,0x10,0x00,0x02, - 0x01}}, - {{0xbf,0x9f,0x83,0xa4,0x12,0x0e,0x5a, - 0x02,0x86,0xff,0x0f,0x09,0x00,0x07, - 0x01}}, - {{0xce,0xae,0x92,0xb3,0x01,0x28,0x10, - 0x1a,0x80,0x19,0x29,0x0f,0x00,0x03, - 0x00}} -#endif -}; - -static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_1_H[] = -{ - {{0x47,0x27,0x8b,0x2c,0x1a,0x9e,0x1f, - 0x8f,0x81,0x8f,0x9f,0x30,0x00,0x05, - 0x00}}, - {{0x47,0x27,0x8b,0x2c,0x1a,0x6c,0x1f, - 0x60,0x84,0x5d,0x6d,0x10,0x00,0x05, - 0x00}}, - {{0x47,0x27,0x8b,0x30,0x1e,0x9e,0x1f, - 0x90,0x83,0x8f,0x9f,0x30,0x00,0x05, - 0x00}}, - {{0x47,0x27,0x8b,0x2c,0x1a,0x6c,0x1f, - 0x60,0x84,0x5d,0x6d,0x10,0x00,0x05, - 0x00}}, - {{0x47,0x27,0x8b,0x2c,0x1a,0xee,0x1f, - 0xdf,0x86,0xdf,0xef,0x10,0x00,0x05, - 0x00}}, - {{0x51,0x31,0x95,0x36,0x04,0x66,0xf0, - 0x57,0x8e,0x57,0x67,0x20,0x00,0x01, - 0x01}}, - {{0x5f,0x3f,0x83,0x44,0x92,0x0e,0xf1, - 0xff,0x86,0xff,0x0f,0x10,0x00,0x01, - 0x01}}, - {{0x6f,0x4f,0x93,0x54,0x82,0x0e,0x5a, - 0x02,0x86,0xff,0x0f,0x09,0x00,0x05, - 0x01}}, - {{0x76,0x56,0x9a,0x5b,0x89,0x28,0x10, - 0x1c,0x80,0x19,0x29,0x0b,0x00,0x05, - 0x00}} -#if 0 - {{0x47,0x27,0x8b,0x2c,0x1a,0x9e,0x1f, - 0x93,0x86,0x8f,0x9f,0x30,0x00,0x05, - 0x00}}, - {{0x47,0x27,0x8b,0x2c,0x1a,0x6c,0x1f, - 0x60,0x84,0x5d,0x6d,0x10,0x00,0x05, - 0x00}}, - {{0x47,0x27,0x8b,0x30,0x1e,0x9e,0x1f, - 0x92,0x86,0x8f,0x9f,0x30,0x00,0x05, - 0x00}}, - {{0x47,0x27,0x8b,0x2c,0x1a,0x6c,0x1f, - 0x60,0x84,0x5d,0x6d,0x10,0x00,0x05, - 0x00}}, - {{0x47,0x27,0x8b,0x2c,0x1a,0xee,0x1f, - 0xe2,0x86,0xdf,0xef,0x10,0x00,0x05, - 0x00}}, - {{0x51,0x31,0x95,0x36,0x04,0x66,0xf0, - 0x5a,0x8e,0x57,0x67,0x20,0x00,0x01, - 0x01}}, - {{0x5f,0x3f,0x83,0x44,0x92,0x0e,0xf5, - 0x02,0x86,0xff,0x0f,0x10,0x00,0x01, - 0x01}}, - {{0x6f,0x4f,0x93,0x54,0x82,0x0e,0x5a, - 0x02,0x86,0xff,0x0f,0x09,0x00,0x05, - 0x01}}, - {{0x76,0x56,0x9a,0x5b,0x89,0x28,0x10, - 0x1c,0x80,0x19,0x29,0x0b,0x00,0x05, - 0x00}} -#endif -}; - -static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_2[] = -{ - {{0xce,0x72,0x91,0x84,0x92,0x28,0x92, - 0xd7,0x8b,0x5d,0x5c,0x21,0x00,0x02, - 0x01}}, - {{0xce,0x72,0x91,0x84,0x92,0x28,0x92, - 0xbe,0x82,0x44,0x43,0x01,0x00,0x02, - 0x01}}, - {{0xce,0x72,0x91,0x84,0x92,0x28,0x92, - 0xd7,0x8b,0x5d,0x5c,0x21,0x00,0x02, - 0x01}}, - {{0xce,0x72,0x91,0x84,0x92,0x28,0x92, - 0xbe,0x82,0x44,0x43,0x01,0x00,0x02, - 0x01}}, - {{0xce,0x72,0x91,0x84,0x92,0x28,0x92, - 0xff,0x83,0x85,0x84,0x11,0x00,0x02, - 0x01}}, - {{0xce,0x63,0x92,0x8e,0x1c,0x28,0xd4, - 0x3f,0x83,0x57,0x29,0x01,0x00,0x03, - 0x01}}, - {{0xce,0x7f,0x92,0x9c,0x0a,0x28,0xd4, - 0x93,0x87,0xff,0x29,0x21,0x00,0x07, - 0x01}}, - {{0xce,0x9f,0x92,0xac,0x1a,0x28,0x5a, - 0x13,0x87,0xff,0x29,0x29,0x00,0x07, - 0x01}}, - {{0xce,0xae,0x92,0xbc,0x0a,0x28,0x10, - 0x20,0x84,0x19,0x29,0x0f,0x00,0x03, - 0x00}} -#if 0 - {{0xce,0x4f,0x92,0x8c,0x1a,0x28,0x9a, - 0xdb,0x8f,0x8f,0x29,0x21,0x00,0x03, - 0x00}}, - {{0xce,0x4f,0x92,0x8c,0x1a,0x28,0x9a, - 0xc2,0x86,0x5d,0x29,0x01,0x00,0x03, - 0x01}}, - {{0xce,0x4f,0x92,0x8c,0x1a,0x28,0x9a, - 0xdb,0x8f,0x8f,0x29,0x21,0x00,0x03, - 0x00}}, - {{0xce,0x4f,0x92,0x8c,0x1a,0x28,0x9a, - 0xc2,0x86,0x5d,0x29,0x01,0x00,0x03, - 0x00}}, - {{0xce,0x4f,0x92,0x8c,0x1a,0x28,0x9e, - 0x03,0x87,0xdf,0x29,0x01,0x00,0x03, - 0x00}}, - {{0xce,0x63,0x92,0x96,0x04,0x28,0xd4, - 0x3f,0x83,0x57,0x29,0x01,0x00,0x07, - 0x01}}, - {{0xce,0x7f,0x92,0xa4,0x12,0x28,0xd4, - 0x93,0x87,0xff,0x29,0x21,0x00,0x07, - 0x01}}, - {{0xce,0x9f,0x92,0xb4,0x02,0x28,0x5a, - 0x13,0x87,0xff,0x29,0x29,0x00,0x03, - 0x01}}, - {{0xce,0xae,0x92,0xbc,0x0a,0x28,0x10, - 0x20,0x84,0x19,0x29,0x0f,0x00,0x03, - 0x00}} -#endif -}; - -static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11400x1050_2_H[] = -{ - {{0xa6,0x4a,0x89,0x5c,0x0a,0x28,0x92, - 0xd7,0x8b,0x5d,0x5c,0x21,0x00,0x06, - 0x01}}, - {{0xa6,0x4a,0x89,0x5c,0x0a,0x28,0x92, - 0xbe,0x82,0x44,0x43,0x01,0x00,0x06, - 0x01}}, - {{0xa6,0x4a,0x89,0x5c,0x0a,0x28,0x92, - 0xd7,0x8b,0x5d,0x5c,0x21,0x00,0x06, - 0x01}}, - {{0xa6,0x4a,0x89,0x5c,0x0a,0x28,0x92, - 0xbe,0x82,0x44,0x43,0x01,0x00,0x06, - 0x01}}, - {{0xa6,0x4a,0x89,0x5c,0x0a,0x28,0x92, - 0xff,0x83,0x85,0x84,0x11,0x00,0x06, - 0x01}}, - {{0x9c,0x31,0x80,0x5c,0x8a,0x28,0xd4, - 0x3f,0x83,0x57,0x29,0x01,0x00,0x06, - 0x01}}, - {{0x8e,0x3f,0x92,0x5c,0x0a,0x28,0xd4, - 0x93,0x87,0xff,0x29,0x21,0x00,0x06, - 0x01}}, - {{0x7e,0x4f,0x82,0x5c,0x0a,0x28,0x5a, - 0x13,0x87,0xff,0x29,0x29,0x00,0x06, - 0x01}}, - {{0x76,0x56,0x9a,0x64,0x92,0x28,0x10, - 0x20,0x84,0x19,0x29,0x0f,0x00,0x05, - 0x00}} -#if 0 - {{0xa6,0x27,0x8a,0x64,0x92,0x28,0x9a, - 0xdb,0x8f,0x8f,0x29,0x21,0x00,0x06, - 0x00}}, - {{0xa6,0x27,0x8a,0x64,0x92,0x28,0x9a, - 0xc2,0x86,0x5d,0x29,0x01,0x00,0x06, - 0x00}}, - {{0xa6,0x27,0x8a,0x64,0x92,0x28,0x9a, - 0xdb,0x8f,0x8f,0x29,0x21,0x00,0x06, - 0x00}}, - {{0xa6,0x27,0x8a,0x64,0x92,0x28,0x9a, - 0xc2,0x86,0x5d,0x29,0x01,0x00,0x06, - 0x00}}, - {{0xa6,0x27,0x8a,0x64,0x92,0x28,0x9e, - 0x03,0x87,0xdf,0x29,0x01,0x00,0x06, - 0x00}}, - {{0x9c,0x31,0x80,0x64,0x92,0x28,0xd4, - 0x3f,0x83,0x57,0x29,0x01,0x00,0x06, - 0x01}}, - {{0x8e,0x3f,0x92,0x64,0x12,0x28,0xd4, - 0x93,0x87,0xff,0x29,0x21,0x00,0x06, - 0x01}}, - {{0x7e,0x4f,0x82,0x64,0x12,0x28,0x5a, - 0x13,0x87,0xff,0x29,0x29,0x00,0x06, - 0x01}}, - {{0x76,0x56,0x9a,0x64,0x92,0x28,0x10, - 0x20,0x84,0x19,0x29,0x0f,0x00,0x05, - 0x00}} -#endif -}; - -static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11600x1200_1[] = -{ - {{0x83,0x4F,0x87,0x5B,0x13,0x06,0x3E, - 0xB3,0x86,0x8F,0x07,0x20,0x00,0x06, - 0x00}}, - {{0x83,0x4F,0x87,0x5B,0x13,0xD4,0x1F, - 0x81,0x84,0x5D,0xD5,0x10,0x00,0x06, - 0x00}}, - {{0x83,0x4F,0x87,0x5B,0x13,0x06,0x3E, - 0xB3,0x86,0x8F,0x07,0x20,0x00,0x06, - 0x00}}, - {{0x83,0x4F,0x87,0x5B,0x13,0xD4,0x1F, - 0x81,0x84,0x5D,0xD5,0x10,0x00,0x06, - 0x00}}, - {{0x83,0x4F,0x87,0x5B,0x13,0x56,0xBA, - 0x03,0x86,0xDF,0x57,0x00,0x00,0x06, - 0x00}}, - {{0x97,0x63,0x9B,0x6F,0x07,0xCE,0xF0, - 0x7B,0x8E,0x57,0xCF,0x20,0x00,0x02, - 0x01}}, - {{0xB3,0x7F,0x97,0x8B,0x83,0x76,0xF5, - 0x23,0x86,0xFF,0x77,0x10,0x00,0x06, - 0x01}}, - {{0xD3,0x9F,0x97,0xAB,0x03,0x76,0x5A, - 0x23,0x86,0xFF,0x77,0x09,0x00,0x03, - 0x01}}, - {{0xE2,0xAE,0x86,0xBA,0x92,0x90,0x10, - 0x3D,0x80,0x19,0x91,0x0F,0x00,0x03, - 0x00}}, - {{0xFB,0xC7,0x9F,0xD3,0x8B,0x26,0x11, - 0xD3,0x86,0xAF,0x27,0x3F,0x00,0x07, - 0x00}} -#if 0 - {{0x83,0x4f,0x87,0x51,0x09,0xc0,0x1f, - 0x90,0x84,0x8f,0xc1,0x30,0x00,0x06, - 0x00}}, - {{0x83,0x4f,0x87,0x51,0x09,0x8e,0x1f, - 0x5e,0x82,0x5d,0x8f,0x10,0x00,0x06, - 0x00}}, - {{0x83,0x4f,0x87,0x51,0x09,0xc0,0x1f, - 0x90,0x84,0x8f,0xc1,0x30,0x00,0x06, - 0x00}}, - {{0x83,0x4f,0x87,0x51,0x09,0x8e,0x1f, - 0x5e,0x82,0x5d,0x8f,0x10,0x00,0x06, - 0x00}}, - {{0x83,0x4f,0x87,0x51,0x09,0x10,0x3e, - 0xe0,0x84,0xdf,0x11,0x00,0x00,0x06, - 0x00}}, - {{0x97,0x63,0x9b,0x65,0x1d,0x88,0xf0, - 0x58,0x8c,0x57,0x89,0x20,0x00,0x06, - 0x01}}, - {{0xb3,0x7f,0x97,0x81,0x99,0x30,0xf5, - 0x00,0x84,0xff,0x31,0x10,0x00,0x02, - 0x01}}, - {{0xd3,0x9f,0x97,0xa1,0x19,0x30,0x5a, - 0x00,0x84,0xff,0x31,0x09,0x00,0x07, - 0x01}}, - {{0xe2,0xae,0x86,0xb0,0x88,0x4a,0x10, - 0x1a,0x8e,0x19,0x4b,0x2f,0x00,0x03, - 0x00}}, - {{0xfb,0xc7,0x9f,0xc9,0x81,0xe0,0x10, - 0xb0,0x84,0xaf,0xe1,0x2f,0x00,0x07, - 0x00}} -#endif -}; - -static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11600x1200_1_H[] = -{ - {{0x5B,0x27,0x9F,0x33,0x0B,0x06,0x2E, - 0xB3,0x86,0x8F,0x07,0x20,0x00,0x01, - 0x00}}, - {{0x5B,0x27,0x9F,0x29,0x01,0x8E,0x1F, - 0x81,0x84,0x5D,0xD5,0x10,0x00,0x06, - 0x00}}, - {{0x5B,0x27,0x9F,0x33,0x0B,0x06,0x2E, - 0xB3,0x86,0x8F,0x07,0x20,0x00,0x01, - 0x00}}, - {{0x83,0x4F,0x87,0x5B,0x13,0xD4,0x1F, - 0x81,0x84,0x5D,0xD5,0x10,0x00,0x06, - 0x00}}, - {{0x5B,0x27,0x9F,0x33,0x0B,0x56,0xBA, - 0x03,0x86,0xDF,0x57,0x00,0x00,0x01, - 0x00}}, - {{0x65,0x31,0x89,0x3D,0x95,0xCE,0xF0, - 0x7B,0x8E,0x57,0xCF,0x20,0x00,0x01, - 0x01}}, - {{0x73,0x3F,0x97,0x4B,0x83,0x76,0xF5, - 0x23,0x86,0xFF,0x77,0x10,0x00,0x05, - 0x01}}, - {{0xD3,0x9F,0x97,0xAB,0x03,0x76,0x5A, - 0x23,0x86,0xFF,0x77,0x09,0x00,0x03, - 0x01}}, - {{0xE2,0xAE,0x86,0xBA,0x92,0x90,0x10, - 0x3D,0x80,0x19,0x91,0x0F,0x00,0x03, - 0x00}}, - {{0x97,0x63,0x9B,0x6F,0x07,0xE0,0x10, - 0xB0,0x84,0xAF,0xE1,0x2F,0x00,0x06, - 0x00}} -#if 0 - {{0x5b,0x27,0x9f,0x29,0x01,0xc0,0x1f, - 0x90,0x84,0x8f,0xc1,0x30,0x00,0x01, - 0x00}}, - {{0x5b,0x27,0x9f,0x29,0x01,0x8e,0x1f, - 0x5e,0x82,0x5d,0x8f,0x10,0x00,0x01, - 0x00}}, - {{0x5b,0x27,0x9f,0x29,0x01,0xc0,0x1f, - 0x90,0x84,0x8f,0xc1,0x30,0x00,0x01, - 0x00}}, - {{0x5b,0x27,0x9f,0x29,0x01,0x8e,0x1f, - 0x5e,0x82,0x5d,0x8f,0x10,0x00,0x01, - 0x00}}, - {{0x5b,0x27,0x9f,0x29,0x01,0x10,0x3e, - 0xe0,0x84,0xdf,0x11,0x00,0x00,0x01, - 0x00}}, - {{0x65,0x31,0x89,0x33,0x8b,0x88,0xf0, - 0x58,0x8c,0x57,0x89,0x20,0x00,0x01, - 0x01}}, - {{0x73,0x3f,0x97,0x41,0x99,0x30,0xf5, - 0x00,0x84,0xff,0x31,0x10,0x00,0x01, - 0x01}}, - {{0x83,0x4f,0x87,0x51,0x09,0x30,0x5a, - 0x00,0x84,0xff,0x31,0x09,0x00,0x06, - 0x01}}, - {{0x8a,0x56,0x8e,0x58,0x10,0x4a,0x10, - 0x1a,0x8e,0x19,0x4b,0x2f,0x00,0x06, - 0x00}}, - {{0x97,0x63,0x9b,0x65,0x1d,0xe0,0x10, - 0xb0,0x84,0xaf,0xe1,0x2f,0x00,0x06, - 0x00}} -#endif -}; - -static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11600x1200_2[] = -{ - {{0xFB,0x87,0x86,0x97,0x0F,0x26,0x97, - 0x43,0x86,0xDB,0xDA,0x11,0x00,0x07, - 0x01}}, - {{0xFB,0x87,0x86,0x97,0x0F,0x26,0x97, - 0x2A,0x8D,0xC2,0xC1,0x11,0x00,0x07, - 0x01}}, - {{0xFB,0x87,0x86,0x97,0x0F,0x26,0x97, - 0x43,0x86,0xDB,0xDA,0x11,0x00,0x07, - 0x01}}, - {{0xFB,0x87,0x86,0x97,0x0F,0x26,0x97, - 0x2A,0x8D,0xC2,0xC1,0x11,0x00,0x07, - 0x01}}, - {{0xFB,0x87,0x86,0x97,0x0F,0x26,0x9F, - 0x6B,0x8E,0x03,0x02,0x01,0x00,0x07, - 0x01}}, - {{0xFB,0x63,0x9F,0xA1,0x99,0x26,0xD5, - 0xA7,0x8A,0xBF,0xBE,0x01,0x00,0x07, - 0x01}}, - {{0xFB,0x7F,0x9F,0xAF,0x87,0x26,0xDD, - 0xFB,0x8E,0x13,0x12,0x31,0x00,0x03, - 0x01}}, - {{0xFB,0x9F,0x9F,0xBF,0x97,0x26,0x5B, - 0x7B,0x8E,0xFF,0x27,0x39,0x00,0x03, - 0x01}}, - {{0xFB,0xAE,0x9F,0xC6,0x9E,0x26,0x11, - 0x88,0x8B,0x19,0x27,0x1F,0x00,0x03, - 0x00}}, - {{0xFB,0xC7,0x9F,0xD3,0x8B,0x26,0x11, - 0xD3,0x86,0xAF,0x27,0x3F,0x00,0x07, - 0x00}} -#if 0 - {{0xfb,0x88,0x87,0x90,0x08,0xe0,0x96, - 0x20,0x84,0xb9,0xb8,0x01,0x00,0x07, - 0x01}}, - {{0xfb,0x88,0x87,0x90,0x08,0xe0,0x96, - 0x07,0x8b,0xa0,0x9f,0x01,0x00,0x07, - 0x01}}, - {{0xfb,0x88,0x87,0x90,0x08,0xe0,0x96, - 0x20,0x84,0xb9,0xb8,0x01,0x00,0x07, - 0x01}}, - {{0xfb,0x88,0x87,0x90,0x08,0xe0,0x96, - 0x07,0x8b,0xa0,0x9f,0x01,0x00,0x07, - 0x01}}, - {{0xfb,0x88,0x87,0x90,0x08,0xe0,0x96, - 0x48,0x8c,0xe1,0xe0,0x11,0x00,0x07, - 0x01}}, - {{0xfb,0x63,0x9f,0x9a,0x92,0xe0,0xd4, - 0x9b,0x8f,0x9d,0x9c,0x21,0x00,0x07, - 0x01}}, - {{0xfb,0x7f,0x9f,0xa8,0x80,0xe0,0xd4, - 0xef,0x83,0xff,0xe1,0x21,0x00,0x03, - 0x01}}, - {{0xfb,0x9f,0x9f,0xb8,0x90,0xe0,0x5a, - 0x6f,0x83,0xff,0xe1,0x29,0x00,0x03, - 0x01}}, - {{0xfb,0xae,0x9f,0xbf,0x97,0xe0,0x10, - 0x7c,0x80,0x19,0xe1,0x0f,0x00,0x03, - 0x00}}, - {{0xfb,0xc7,0x9f,0xc9,0x84,0xe0,0x10, - 0xc7,0x8b,0xaf,0xe1,0x0f,0x00,0x07, - 0x00}} -#endif -}; - -static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT11600x1200_2_H[] = -{ - {{0xD3,0x5F,0x9E,0x6F,0x07,0x26,0x97, - 0x43,0x86,0xDB,0xDA,0x11,0x00,0x02, - 0x01}}, - {{0xD3,0x27,0x97,0x6F,0x07,0x26,0x97, - 0x6B,0x8E,0x83,0x82,0x01,0x00,0x03, - 0x01}}, - {{0xD3,0x5F,0x9E,0x6F,0x07,0x26,0x97, - 0x43,0x86,0xDB,0xDA,0x11,0x00,0x02, - 0x01}}, - {{0xD3,0x27,0x97,0x6F,0x07,0x26,0x97, - 0x07,0x8B,0xA0,0x9F,0x01,0x00,0x02, - 0x01}}, - {{0xD3,0x27,0x97,0x6F,0x07,0x26,0x97, - 0x6B,0x8E,0x83,0x82,0x01,0x00,0x03, - 0x01}}, - {{0xC9,0x31,0x8D,0x6F,0x07,0x26,0xD5, - 0xA7,0x8A,0xBF,0xBE,0x01,0x00,0x03, - 0x01}}, - {{0xBB,0x3F,0x9F,0x6F,0x87,0x26,0xDD, - 0xFB,0x8E,0x13,0x12,0x31,0x00,0x02, - 0x01}}, - {{0xAB,0x4F,0x8F,0x68,0x80,0xE0,0x5A, - 0x6F,0x83,0xFF,0xE1,0x29,0x00,0x02, - 0x01}}, - {{0xA3,0x56,0x87,0x67,0x9F,0xE0,0x10, - 0x7C,0x80,0x19,0xE1,0x0F,0x00,0x06, - 0x00}}, - {{0x97,0x63,0x9B,0x68,0x00,0xE0,0x10, - 0xC7,0x8B,0xAF,0xE1,0x0F,0x00,0x02, - 0x00}} -#if 0 - {{0xd3,0x60,0x9f,0x68,0x00,0xe0,0x96, - 0x20,0x84,0xb9,0xb8,0x01,0x00,0x02, - 0x01}}, - {{0xd3,0x60,0x9f,0x68,0x00,0xe0,0x96, - 0x07,0x8b,0xa0,0x9f,0x01,0x00,0x02, - 0x01}}, - {{0xd3,0x60,0x9f,0x68,0x00,0xe0,0x96, - 0x20,0x84,0xb9,0xb8,0x01,0x00,0x02, - 0x01}}, - {{0xd3,0x60,0x9f,0x68,0x00,0xe0,0x96, - 0x07,0x8b,0xa0,0x9f,0x01,0x00,0x02, - 0x01}}, - {{0xd3,0x60,0x9f,0x68,0x00,0xe0,0x96, - 0x48,0x8c,0xe1,0xe0,0x11,0x00,0x02, - 0x01}}, - {{0xc9,0x31,0x8d,0x68,0x00,0xe0,0xd4, - 0x9b,0x8f,0x9d,0x9c,0x21,0x00,0x03, - 0x01}}, - {{0xbb,0x3f,0x9f,0x68,0x80,0xe0,0xd4, - 0xef,0x83,0xff,0xe1,0x21,0x00,0x02, - 0x01}}, - {{0xab,0x4f,0x8f,0x68,0x80,0xe0,0x5a, - 0x6f,0x83,0xff,0xe1,0x29,0x00,0x02, - 0x01}}, - {{0xa3,0x56,0x87,0x67,0x9f,0xe0,0x10, - 0x7c,0x80,0x19,0xe1,0x0f,0x00,0x06, - 0x00}}, - {{0x97,0x63,0x9b,0x68,0x00,0xe0,0x10, - 0xc7,0x8b,0xaf,0xe1,0x0f,0x00,0x02, - 0x00}} -#endif -}; - -static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT1XXXxXXX_1[] = -{ - {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05, - 0x00}}, - {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05, - 0x00}}, - {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05, - 0x00}}, - {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05, - 0x00}}, - {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, - 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x05, - 0x00}}, - {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0, - 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, - 0x01}}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, - 0x01}}, - {{0xce,0x9f,0x92,0xa8,0x14,0x28,0x5a, - 0x00,0x84,0xff,0x29,0x09,0x00,0x07, - 0x01}}, - {{0xce,0x9f,0x92,0xa9,0x17,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x07, - 0x01}} -}; - -static const SiS_LVDSCRT1DataStruct SiS310_LVDSCRT1XXXxXXX_1_H[] = -{ - {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00, - 0x00}}, - {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00, - 0x00}}, - {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00, - 0x00}}, - {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00, - 0x00}}, - {{0x38,0x27,0x9c,0x2c,0x80,0x0b,0x3e, - 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00, - 0x00}}, - {{0x4d,0x31,0x91,0x3b,0x03,0x72,0xf0, - 0x58,0x8c,0x57,0x73,0x20,0x00,0x01, - 0x01}}, - {{0x63,0x3f,0x87,0x4a,0x92,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01}} -}; - - /* CRT1 CRTC for Chrontel TV slave modes */ -static const SiS_LVDSCRT1DataStruct SiS310_CHTVCRT1UNTSC[] = -{ +static const struct SiS_LVDSCRT1Data SiS310_CHTVCRT1UNTSC[] = +{ {{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e, 0xe8,0x84,0x8f,0x57,0x20,0x00,0x01, 0x00 }}, @@ -2546,7 +1132,7 @@ static const SiS_LVDSCRT1DataStruct SiS310_CHTVCRT1UNTSC[] = 0x01}} }; -static const SiS_LVDSCRT1DataStruct SiS310_CHTVCRT1ONTSC[] = +static const struct SiS_LVDSCRT1Data SiS310_CHTVCRT1ONTSC[] = { {{0x63,0x4f,0x87,0x5a,0x9f,0x0b,0x3e, 0xc0,0x84,0x8f,0x0c,0x20,0x00,0x01, @@ -2571,8 +1157,8 @@ static const SiS_LVDSCRT1DataStruct SiS310_CHTVCRT1ONTSC[] = 0x01 }} }; -static const SiS_LVDSCRT1DataStruct SiS310_CHTVCRT1UPAL[] = -{ +static const struct SiS_LVDSCRT1Data SiS310_CHTVCRT1UPAL[] = +{ {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, 0xf8,0x83,0x8f,0x70,0x20,0x00,0x05, 0x00 }}, @@ -2596,7 +1182,7 @@ static const SiS_LVDSCRT1DataStruct SiS310_CHTVCRT1UPAL[] = 0x01}} }; -static const SiS_LVDSCRT1DataStruct SiS310_CHTVCRT1OPAL[] = +static const struct SiS_LVDSCRT1Data SiS310_CHTVCRT1OPAL[] = { {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e, 0xf0,0x83,0x8f,0x70,0x20,0x00,0x05, @@ -2621,8 +1207,7 @@ static const SiS_LVDSCRT1DataStruct SiS310_CHTVCRT1OPAL[] = 0x01 }} }; - -static const SiS_CHTVRegDataStruct SiS310_CHTVReg_UNTSC[] = +static const struct SiS_CHTVRegData SiS310_CHTVReg_UNTSC[] = { {{0x4a,0x77,0xbb,0x94,0x84,0x48,0xfe,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, {{0x4a,0x77,0xbb,0x94,0x84,0x48,0xfe,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, @@ -2642,7 +1227,7 @@ static const SiS_CHTVRegDataStruct SiS310_CHTVReg_UNTSC[] = for PAL-M and PAL-N all above is corrected. */ -static const SiS_CHTVRegDataStruct SiS310_CHTVReg_ONTSC[] = +static const struct SiS_CHTVRegData SiS310_CHTVReg_ONTSC[] = { {{0x49,0x77,0xbb,0x7b,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, {{0x49,0x77,0xbb,0x7b,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, @@ -2653,7 +1238,7 @@ static const SiS_CHTVRegDataStruct SiS310_CHTVReg_ONTSC[] = {{0xed,0x77,0xbb,0x66,0x8c,0x21,0x02,0x5a,0x04,0x00,0x80,0x1f,0x9f,0xc1,0x0c,0x00}} }; -static const SiS_CHTVRegDataStruct SiS310_CHTVReg_UPAL[] = +static const struct SiS_CHTVRegData SiS310_CHTVReg_UPAL[] = { {{0x41,0x7f,0xb7,0x34,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, {{0x41,0x7f,0xb7,0x80,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, @@ -2664,7 +1249,7 @@ static const SiS_CHTVRegDataStruct SiS310_CHTVReg_UPAL[] = {{0xe5,0x7f,0xb7,0x1d,0xa7,0x3e,0x04,0x5a,0x05,0x00,0x80,0x20,0x3e,0xe4,0x22,0x00}} }; -static const SiS_CHTVRegDataStruct SiS310_CHTVReg_OPAL[] = +static const struct SiS_CHTVRegData SiS310_CHTVReg_OPAL[] = { {{0x41,0x7f,0xb7,0x36,0xad,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, {{0x41,0x7f,0xb7,0x86,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, @@ -2675,7 +1260,7 @@ static const SiS_CHTVRegDataStruct SiS310_CHTVReg_OPAL[] = {{0xe4,0x7f,0xb7,0x1e,0xaf,0x29,0x37,0x5a,0x05,0x00,0x80,0x25,0x8c,0xb2,0x2a,0x00}} }; -static const SiS_CHTVRegDataStruct SiS310_CHTVReg_UPALM[] = +static const struct SiS_CHTVRegData SiS310_CHTVReg_UPALM[] = { {{0x52,0x77,0xbb,0x94,0x84,0x48,0xfe,0x83,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, {{0x52,0x77,0xbb,0x94,0x84,0x48,0xfe,0x83,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, @@ -2691,7 +1276,7 @@ static const SiS_CHTVRegDataStruct SiS310_CHTVReg_UPALM[] = #endif }; -static const SiS_CHTVRegDataStruct SiS310_CHTVReg_OPALM[] = +static const struct SiS_CHTVRegData SiS310_CHTVReg_OPALM[] = { {{0x51,0x77,0xbb,0x7b,0x84,0x34,0x00,0x83,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, {{0x51,0x77,0xbb,0x7b,0x84,0x34,0x00,0x83,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01}}, @@ -2707,7 +1292,7 @@ static const SiS_CHTVRegDataStruct SiS310_CHTVReg_OPALM[] = #endif }; -static const SiS_CHTVRegDataStruct SiS310_CHTVReg_UPALN[] = +static const struct SiS_CHTVRegData SiS310_CHTVReg_UPALN[] = { {{0x41,0x7f,0xb7,0x34,0xad,0x50,0x34,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, {{0x41,0x7f,0xb7,0x80,0x85,0x50,0x00,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, @@ -2723,7 +1308,7 @@ static const SiS_CHTVRegDataStruct SiS310_CHTVReg_UPALN[] = #endif }; -static const SiS_CHTVRegDataStruct SiS310_CHTVReg_OPALN[] = +static const struct SiS_CHTVRegData SiS310_CHTVReg_OPALN[] = { {{0x41,0x7f,0xb7,0x36,0xad,0x50,0x34,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, {{0x41,0x7f,0xb7,0x86,0x85,0x50,0x00,0x6e,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x03}}, @@ -2739,16 +1324,16 @@ static const SiS_CHTVRegDataStruct SiS310_CHTVReg_OPALN[] = #endif }; -static const UCHAR SiS310_CHTVVCLKUNTSC[] = {0x41,0x41,0x41,0x41,0x42,0x46,0x53}; -static const UCHAR SiS310_CHTVVCLKONTSC[] = {0x48,0x48,0x48,0x48,0x45,0x43,0x51}; +static const unsigned char SiS310_CHTVVCLKUNTSC[] = { 0x41,0x41,0x41,0x41,0x42,0x46,0x53 }; +static const unsigned char SiS310_CHTVVCLKONTSC[] = { 0x48,0x48,0x48,0x48,0x45,0x43,0x51 }; -static const UCHAR SiS310_CHTVVCLKUPAL[] = {0x47,0x47,0x47,0x47,0x48,0x4a,0x54}; -static const UCHAR SiS310_CHTVVCLKOPAL[] = {0x47,0x47,0x47,0x47,0x48,0x4f,0x52}; +static const unsigned char SiS310_CHTVVCLKUPAL[] = { 0x47,0x47,0x47,0x47,0x48,0x4a,0x54 }; +static const unsigned char SiS310_CHTVVCLKOPAL[] = { 0x47,0x47,0x47,0x47,0x48,0x4f,0x52 }; -static const UCHAR SiS310_CHTVVCLKUPALM[] = {0x41,0x41,0x41,0x41,0x42,0x46,0x53}; -static const UCHAR SiS310_CHTVVCLKOPALM[] = {0x48,0x48,0x48,0x48,0x45,0x43,0x51}; +static const unsigned char SiS310_CHTVVCLKUPALM[] = { 0x41,0x41,0x41,0x41,0x42,0x46,0x53 }; +static const unsigned char SiS310_CHTVVCLKOPALM[] = { 0x48,0x48,0x48,0x48,0x45,0x43,0x51 }; -static const UCHAR SiS310_CHTVVCLKUPALN[] = {0x47,0x47,0x47,0x47,0x48,0x4a,0x54}; -static const UCHAR SiS310_CHTVVCLKOPALN[] = {0x47,0x47,0x47,0x47,0x48,0x4f,0x52}; +static const unsigned char SiS310_CHTVVCLKUPALN[] = { 0x47,0x47,0x47,0x47,0x48,0x4a,0x54 }; +static const unsigned char SiS310_CHTVVCLKOPALN[] = { 0x47,0x47,0x47,0x47,0x48,0x4f,0x52 }; diff --git a/drivers/video/sis/Makefile b/drivers/video/sis/Makefile index aaed8c2b4a6..f7c0046e5b1 100644 --- a/drivers/video/sis/Makefile +++ b/drivers/video/sis/Makefile @@ -4,4 +4,4 @@ obj-$(CONFIG_FB_SIS) += sisfb.o -sisfb-objs := sis_main.o sis_accel.o init.o init301.o +sisfb-objs := sis_main.o sis_accel.o init.o init301.o initextlfb.o diff --git a/drivers/video/sis/init.c b/drivers/video/sis/init.c index ecfd72178db..2ab3868efde 100644 --- a/drivers/video/sis/init.c +++ b/drivers/video/sis/init.c @@ -2,11 +2,12 @@ /* $XdotOrg$ */ /* * Mode initializing code (CRT1 section) for - * for SiS 300/305/540/630/730 and - * SiS 315/550/650/M650/651/661FX/M661FX/740/741(GX)/M741/330/660/M660/760/M760 - * (Universal module for Linux kernel framebuffer and XFree86 4.x) + * for SiS 300/305/540/630/730, + * SiS 315/550/[M]650/651/[M]661[FGM]X/[M]74x[GX]/330/[M]76x[GX], + * XGI Volari V3XT/V5/V8, Z7 + * (Universal module for Linux kernel framebuffer and X.org/XFree86 4.x) * - * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2005 by Thomas Winischhofer, Vienna, Austria * * If distributed as part of the Linux kernel, the following license terms * apply: @@ -53,17 +54,12 @@ * * Formerly based on non-functional code-fragements for 300 series by SiS, Inc. * Used by permission. - * - * TW says: This code looks awful, I know. But please don't do anything about - * this otherwise debugging will be hell. - * The code is extremely fragile as regards the different chipsets, different - * video bridges and combinations thereof. If anything is changed, extreme - * care has to be taken that that change doesn't break it for other chipsets, - * bridges or combinations thereof. - * All comments in this file are by me, regardless if they are marked TW or not. - * */ - + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "init.h" #ifdef SIS300 @@ -84,24 +80,13 @@ #if defined(SIS300) || defined(SIS315H) static void -InitCommonPointer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +InitCommonPointer(struct SiS_Private *SiS_Pr) { + SiS_Pr->SiS_SModeIDTable = SiS_SModeIDTable; SiS_Pr->SiS_StResInfo = SiS_StResInfo; SiS_Pr->SiS_ModeResInfo = SiS_ModeResInfo; SiS_Pr->SiS_StandTable = SiS_StandTable; - SiS_Pr->SiS_NTSCPhase = SiS_NTSCPhase; - SiS_Pr->SiS_PALPhase = SiS_PALPhase; - SiS_Pr->SiS_NTSCPhase2 = SiS_NTSCPhase2; - SiS_Pr->SiS_PALPhase2 = SiS_PALPhase2; - SiS_Pr->SiS_PALMPhase = SiS_PALMPhase; - SiS_Pr->SiS_PALNPhase = SiS_PALNPhase; - SiS_Pr->SiS_PALMPhase2 = SiS_PALMPhase2; - SiS_Pr->SiS_PALNPhase2 = SiS_PALNPhase2; - SiS_Pr->SiS_SpecialPhase = SiS_SpecialPhase; - SiS_Pr->SiS_SpecialPhaseM = SiS_SpecialPhaseM; - SiS_Pr->SiS_SpecialPhaseJ = SiS_SpecialPhaseJ; - SiS_Pr->SiS_NTSCTiming = SiS_NTSCTiming; SiS_Pr->SiS_PALTiming = SiS_PALTiming; SiS_Pr->SiS_HiTVSt1Timing = SiS_HiTVSt1Timing; @@ -137,6 +122,7 @@ InitCommonPointer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) SiS_Pr->SiS_ExtLCD1280x768_2Data = SiS_ExtLCD1280x768_2Data; SiS_Pr->SiS_LCD1280x800Data = SiS_LCD1280x800Data; SiS_Pr->SiS_LCD1280x800_2Data = SiS_LCD1280x800_2Data; + SiS_Pr->SiS_LCD1280x854Data = SiS_LCD1280x854Data; SiS_Pr->SiS_LCD1280x960Data = SiS_LCD1280x960Data; SiS_Pr->SiS_StLCD1400x1050Data = SiS_StLCD1400x1050Data; SiS_Pr->SiS_ExtLCD1400x1050Data = SiS_ExtLCD1400x1050Data; @@ -145,67 +131,30 @@ InitCommonPointer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) SiS_Pr->SiS_ExtLCD1600x1200Data = SiS_ExtLCD1600x1200Data; SiS_Pr->SiS_NoScaleData = SiS_NoScaleData; - SiS_Pr->SiS_LVDS320x480Data_1 = SiS_LVDS320x480Data_1; + SiS_Pr->SiS_LVDS320x240Data_1 = SiS_LVDS320x240Data_1; + SiS_Pr->SiS_LVDS320x240Data_2 = SiS_LVDS320x240Data_2; + SiS_Pr->SiS_LVDS640x480Data_1 = SiS_LVDS640x480Data_1; SiS_Pr->SiS_LVDS800x600Data_1 = SiS_LVDS800x600Data_1; - SiS_Pr->SiS_LVDS800x600Data_2 = SiS_LVDS800x600Data_2; - SiS_Pr->SiS_LVDS1024x768Data_1 = SiS_LVDS1024x768Data_1; - SiS_Pr->SiS_LVDS1024x768Data_2 = SiS_LVDS1024x768Data_2; - SiS_Pr->SiS_LVDS1280x1024Data_1 = SiS_LVDS1280x1024Data_1; - SiS_Pr->SiS_LVDS1280x1024Data_2 = SiS_LVDS1280x1024Data_2; - SiS_Pr->SiS_LVDS1400x1050Data_1 = SiS_LVDS1400x1050Data_1; - SiS_Pr->SiS_LVDS1400x1050Data_2 = SiS_LVDS1400x1050Data_2; - SiS_Pr->SiS_LVDS1600x1200Data_1 = SiS_LVDS1600x1200Data_1; - SiS_Pr->SiS_LVDS1600x1200Data_2 = SiS_LVDS1600x1200Data_2; - SiS_Pr->SiS_LVDS1280x768Data_1 = SiS_LVDS1280x768Data_1; - SiS_Pr->SiS_LVDS1280x768Data_2 = SiS_LVDS1280x768Data_2; SiS_Pr->SiS_LVDS1024x600Data_1 = SiS_LVDS1024x600Data_1; - SiS_Pr->SiS_LVDS1024x600Data_2 = SiS_LVDS1024x600Data_2; - SiS_Pr->SiS_LVDS1152x768Data_1 = SiS_LVDS1152x768Data_1; - SiS_Pr->SiS_LVDS1152x768Data_2 = SiS_LVDS1152x768Data_2; - SiS_Pr->SiS_LVDSXXXxXXXData_1 = SiS_LVDSXXXxXXXData_1; - SiS_Pr->SiS_LVDS1280x960Data_1 = SiS_LVDS1280x960Data_1; - SiS_Pr->SiS_LVDS1280x960Data_2 = SiS_LVDS1280x960Data_2; - SiS_Pr->SiS_LVDS640x480Data_1 = SiS_LVDS640x480Data_1; - SiS_Pr->SiS_LVDS1280x960Data_1 = SiS_LVDS1280x1024Data_1; - SiS_Pr->SiS_LVDS1280x960Data_2 = SiS_LVDS1280x1024Data_2; - SiS_Pr->SiS_LVDS640x480Data_1 = SiS_LVDS640x480Data_1; - SiS_Pr->SiS_LVDS640x480Data_2 = SiS_LVDS640x480Data_2; - - SiS_Pr->SiS_LVDS848x480Data_1 = SiS_LVDS848x480Data_1; - SiS_Pr->SiS_LVDS848x480Data_2 = SiS_LVDS848x480Data_2; - SiS_Pr->SiS_LVDSBARCO1024Data_1 = SiS_LVDSBARCO1024Data_1; - SiS_Pr->SiS_LVDSBARCO1024Data_2 = SiS_LVDSBARCO1024Data_2; - SiS_Pr->SiS_LVDSBARCO1366Data_1 = SiS_LVDSBARCO1366Data_1; - SiS_Pr->SiS_LVDSBARCO1366Data_2 = SiS_LVDSBARCO1366Data_2; + SiS_Pr->SiS_LVDS1024x768Data_1 = SiS_LVDS1024x768Data_1; - SiS_Pr->SiS_LVDSCRT11280x768_1 = SiS_LVDSCRT11280x768_1; + SiS_Pr->SiS_LVDSCRT1320x240_1 = SiS_LVDSCRT1320x240_1; + SiS_Pr->SiS_LVDSCRT1320x240_2 = SiS_LVDSCRT1320x240_2; + SiS_Pr->SiS_LVDSCRT1320x240_2_H = SiS_LVDSCRT1320x240_2_H; + SiS_Pr->SiS_LVDSCRT1320x240_3 = SiS_LVDSCRT1320x240_3; + SiS_Pr->SiS_LVDSCRT1320x240_3_H = SiS_LVDSCRT1320x240_3_H; + SiS_Pr->SiS_LVDSCRT1640x480_1 = SiS_LVDSCRT1640x480_1; + SiS_Pr->SiS_LVDSCRT1640x480_1_H = SiS_LVDSCRT1640x480_1_H; +#if 0 SiS_Pr->SiS_LVDSCRT11024x600_1 = SiS_LVDSCRT11024x600_1; - SiS_Pr->SiS_LVDSCRT11152x768_1 = SiS_LVDSCRT11152x768_1; - SiS_Pr->SiS_LVDSCRT11280x768_1_H = SiS_LVDSCRT11280x768_1_H; SiS_Pr->SiS_LVDSCRT11024x600_1_H = SiS_LVDSCRT11024x600_1_H; - SiS_Pr->SiS_LVDSCRT11152x768_1_H = SiS_LVDSCRT11152x768_1_H; - SiS_Pr->SiS_LVDSCRT11280x768_2 = SiS_LVDSCRT11280x768_2; SiS_Pr->SiS_LVDSCRT11024x600_2 = SiS_LVDSCRT11024x600_2; - SiS_Pr->SiS_LVDSCRT11152x768_2 = SiS_LVDSCRT11152x768_2; - SiS_Pr->SiS_LVDSCRT11280x768_2_H = SiS_LVDSCRT11280x768_2_H; SiS_Pr->SiS_LVDSCRT11024x600_2_H = SiS_LVDSCRT11024x600_2_H; - SiS_Pr->SiS_LVDSCRT11152x768_2_H = SiS_LVDSCRT11152x768_2_H; - SiS_Pr->SiS_LVDSCRT1320x480_1 = SiS_LVDSCRT1320x480_1; - SiS_Pr->SiS_LVDSCRT1640x480_1 = SiS_LVDSCRT1640x480_1; - SiS_Pr->SiS_LVDSCRT1640x480_1_H = SiS_LVDSCRT1640x480_1_H; - SiS_Pr->SiS_LVDSCRT1640x480_2 = SiS_LVDSCRT1640x480_2; - SiS_Pr->SiS_LVDSCRT1640x480_2_H = SiS_LVDSCRT1640x480_2_H; - SiS_Pr->SiS_LVDSCRT1640x480_3 = SiS_LVDSCRT1640x480_3; - SiS_Pr->SiS_LVDSCRT1640x480_3_H = SiS_LVDSCRT1640x480_3_H; +#endif SiS_Pr->SiS_CHTVUNTSCData = SiS_CHTVUNTSCData; SiS_Pr->SiS_CHTVONTSCData = SiS_CHTVONTSCData; - SiS_Pr->SiS_CHTVUNTSCDesData = SiS_CHTVUNTSCDesData; - SiS_Pr->SiS_CHTVONTSCDesData = SiS_CHTVONTSCDesData; - SiS_Pr->SiS_CHTVUPALDesData = SiS_CHTVUPALDesData; - SiS_Pr->SiS_CHTVOPALDesData = SiS_CHTVOPALDesData; - SiS_Pr->SiS_PanelMinLVDS = Panel_800x600; /* lowest value LVDS/LCDA */ SiS_Pr->SiS_PanelMin301 = Panel_1024x768; /* lowest value 301 */ } @@ -213,50 +162,24 @@ InitCommonPointer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) #ifdef SIS300 static void -InitTo300Pointer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +InitTo300Pointer(struct SiS_Private *SiS_Pr) { - InitCommonPointer(SiS_Pr, HwInfo); + InitCommonPointer(SiS_Pr); - SiS_Pr->SiS_SModeIDTable = SiS300_SModeIDTable; SiS_Pr->SiS_VBModeIDTable = SiS300_VBModeIDTable; SiS_Pr->SiS_EModeIDTable = SiS300_EModeIDTable; SiS_Pr->SiS_RefIndex = SiS300_RefIndex; SiS_Pr->SiS_CRT1Table = SiS300_CRT1Table; - if(HwInfo->jChipType == SIS_300) { - SiS_Pr->SiS_MCLKData_0 = SiS300_MCLKData_300; /* 300 */ + if(SiS_Pr->ChipType == SIS_300) { + SiS_Pr->SiS_MCLKData_0 = SiS300_MCLKData_300; /* 300 */ } else { - SiS_Pr->SiS_MCLKData_0 = SiS300_MCLKData_630; /* 630, 730 */ + SiS_Pr->SiS_MCLKData_0 = SiS300_MCLKData_630; /* 630, 730 */ } SiS_Pr->SiS_VCLKData = SiS300_VCLKData; - SiS_Pr->SiS_VBVCLKData = (SiS_VBVCLKDataStruct *)SiS300_VCLKData; + SiS_Pr->SiS_VBVCLKData = (struct SiS_VBVCLKData *)SiS300_VCLKData; SiS_Pr->SiS_SR15 = SiS300_SR15; -#ifdef LINUX_KERNEL - SiS_Pr->pSiS_SR07 = &SiS300_SR07; - SiS_Pr->SiS_CR40 = SiS300_CR40; - SiS_Pr->SiS_CR49 = SiS300_CR49; - SiS_Pr->pSiS_SR1F = &SiS300_SR1F; - SiS_Pr->pSiS_SR21 = &SiS300_SR21; - SiS_Pr->pSiS_SR22 = &SiS300_SR22; - SiS_Pr->pSiS_SR23 = &SiS300_SR23; - SiS_Pr->pSiS_SR24 = &SiS300_SR24; - SiS_Pr->SiS_SR25 = SiS300_SR25; - SiS_Pr->pSiS_SR31 = &SiS300_SR31; - SiS_Pr->pSiS_SR32 = &SiS300_SR32; - SiS_Pr->pSiS_SR33 = &SiS300_SR33; - SiS_Pr->pSiS_CRT2Data_1_2 = &SiS300_CRT2Data_1_2; - SiS_Pr->pSiS_CRT2Data_4_D = &SiS300_CRT2Data_4_D; - SiS_Pr->pSiS_CRT2Data_4_E = &SiS300_CRT2Data_4_E; - SiS_Pr->pSiS_CRT2Data_4_10 = &SiS300_CRT2Data_4_10; - SiS_Pr->pSiS_RGBSenseData = &SiS300_RGBSenseData; - SiS_Pr->pSiS_VideoSenseData = &SiS300_VideoSenseData; - SiS_Pr->pSiS_YCSenseData = &SiS300_YCSenseData; - SiS_Pr->pSiS_RGBSenseData2 = &SiS300_RGBSenseData2; - SiS_Pr->pSiS_VideoSenseData2 = &SiS300_VideoSenseData2; - SiS_Pr->pSiS_YCSenseData2 = &SiS300_YCSenseData2; -#endif - SiS_Pr->SiS_PanelDelayTbl = SiS300_PanelDelayTbl; SiS_Pr->SiS_PanelDelayTblLVDS = SiS300_PanelDelayTbl; @@ -266,11 +189,8 @@ InitTo300Pointer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) SiS_Pr->SiS_St2LCD1280x1024Data = SiS300_St2LCD1280x1024Data; SiS_Pr->SiS_CRT2Part2_1024x768_1 = SiS300_CRT2Part2_1024x768_1; - SiS_Pr->SiS_CRT2Part2_1280x1024_1 = SiS300_CRT2Part2_1280x1024_1; SiS_Pr->SiS_CRT2Part2_1024x768_2 = SiS300_CRT2Part2_1024x768_2; - SiS_Pr->SiS_CRT2Part2_1280x1024_2 = SiS300_CRT2Part2_1280x1024_2; SiS_Pr->SiS_CRT2Part2_1024x768_3 = SiS300_CRT2Part2_1024x768_3; - SiS_Pr->SiS_CRT2Part2_1280x1024_3 = SiS300_CRT2Part2_1280x1024_3; SiS_Pr->SiS_CHTVUPALData = SiS300_CHTVUPALData; SiS_Pr->SiS_CHTVOPALData = SiS300_CHTVOPALData; @@ -280,64 +200,16 @@ InitTo300Pointer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) SiS_Pr->SiS_CHTVOPALNData = SiS300_CHTVOPALData; /* not supported on 300 series */ SiS_Pr->SiS_CHTVSOPALData = SiS300_CHTVSOPALData; - SiS_Pr->SiS_PanelType00_1 = SiS300_PanelType00_1; - SiS_Pr->SiS_PanelType01_1 = SiS300_PanelType01_1; - SiS_Pr->SiS_PanelType02_1 = SiS300_PanelType02_1; - SiS_Pr->SiS_PanelType03_1 = SiS300_PanelType03_1; - SiS_Pr->SiS_PanelType04_1 = SiS300_PanelType04_1; - SiS_Pr->SiS_PanelType05_1 = SiS300_PanelType05_1; - SiS_Pr->SiS_PanelType06_1 = SiS300_PanelType06_1; - SiS_Pr->SiS_PanelType07_1 = SiS300_PanelType07_1; - SiS_Pr->SiS_PanelType08_1 = SiS300_PanelType08_1; - SiS_Pr->SiS_PanelType09_1 = SiS300_PanelType09_1; - SiS_Pr->SiS_PanelType0a_1 = SiS300_PanelType0a_1; - SiS_Pr->SiS_PanelType0b_1 = SiS300_PanelType0b_1; - SiS_Pr->SiS_PanelType0c_1 = SiS300_PanelType0c_1; - SiS_Pr->SiS_PanelType0d_1 = SiS300_PanelType0d_1; - SiS_Pr->SiS_PanelType0e_1 = SiS300_PanelType0e_1; - SiS_Pr->SiS_PanelType0f_1 = SiS300_PanelType0f_1; - SiS_Pr->SiS_PanelType00_2 = SiS300_PanelType00_2; - SiS_Pr->SiS_PanelType01_2 = SiS300_PanelType01_2; - SiS_Pr->SiS_PanelType02_2 = SiS300_PanelType02_2; - SiS_Pr->SiS_PanelType03_2 = SiS300_PanelType03_2; - SiS_Pr->SiS_PanelType04_2 = SiS300_PanelType04_2; - SiS_Pr->SiS_PanelType05_2 = SiS300_PanelType05_2; - SiS_Pr->SiS_PanelType06_2 = SiS300_PanelType06_2; - SiS_Pr->SiS_PanelType07_2 = SiS300_PanelType07_2; - SiS_Pr->SiS_PanelType08_2 = SiS300_PanelType08_2; - SiS_Pr->SiS_PanelType09_2 = SiS300_PanelType09_2; - SiS_Pr->SiS_PanelType0a_2 = SiS300_PanelType0a_2; - SiS_Pr->SiS_PanelType0b_2 = SiS300_PanelType0b_2; - SiS_Pr->SiS_PanelType0c_2 = SiS300_PanelType0c_2; - SiS_Pr->SiS_PanelType0d_2 = SiS300_PanelType0d_2; - SiS_Pr->SiS_PanelType0e_2 = SiS300_PanelType0e_2; - SiS_Pr->SiS_PanelType0f_2 = SiS300_PanelType0f_2; - SiS_Pr->SiS_PanelTypeNS_1 = SiS300_PanelTypeNS_1; - SiS_Pr->SiS_PanelTypeNS_2 = SiS300_PanelTypeNS_2; - - if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { - SiS_Pr->SiS_PanelType04_1 = SiS300_PanelType04_1a; - SiS_Pr->SiS_PanelType04_2 = SiS300_PanelType04_2a; - } - if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) { - SiS_Pr->SiS_PanelType04_1 = SiS300_PanelType04_1b; - SiS_Pr->SiS_PanelType04_2 = SiS300_PanelType04_2b; - } - - SiS_Pr->SiS_LVDSCRT1800x600_1 = SiS300_LVDSCRT1800x600_1; - SiS_Pr->SiS_LVDSCRT1800x600_1_H = SiS300_LVDSCRT1800x600_1_H; - SiS_Pr->SiS_LVDSCRT1800x600_2 = SiS300_LVDSCRT1800x600_2; - SiS_Pr->SiS_LVDSCRT1800x600_2_H = SiS300_LVDSCRT1800x600_2_H; - SiS_Pr->SiS_LVDSCRT11024x768_1 = SiS300_LVDSCRT11024x768_1; - SiS_Pr->SiS_LVDSCRT11024x768_1_H = SiS300_LVDSCRT11024x768_1_H; - SiS_Pr->SiS_LVDSCRT11024x768_2 = SiS300_LVDSCRT11024x768_2; - SiS_Pr->SiS_LVDSCRT11024x768_2_H = SiS300_LVDSCRT11024x768_2_H; - SiS_Pr->SiS_LVDSCRT11280x1024_1 = SiS300_LVDSCRT11280x1024_1; - SiS_Pr->SiS_LVDSCRT11280x1024_1_H = SiS300_LVDSCRT11280x1024_1_H; - SiS_Pr->SiS_LVDSCRT11280x1024_2 = SiS300_LVDSCRT11280x1024_2; - SiS_Pr->SiS_LVDSCRT11280x1024_2_H = SiS300_LVDSCRT11280x1024_2_H; - SiS_Pr->SiS_LVDSCRT1XXXxXXX_1 = SiS300_LVDSCRT1XXXxXXX_1; - SiS_Pr->SiS_LVDSCRT1XXXxXXX_1_H = SiS300_LVDSCRT1XXXxXXX_1_H; + SiS_Pr->SiS_LVDS848x480Data_1 = SiS300_LVDS848x480Data_1; + SiS_Pr->SiS_LVDS848x480Data_2 = SiS300_LVDS848x480Data_2; + SiS_Pr->SiS_LVDSBARCO1024Data_1 = SiS300_LVDSBARCO1024Data_1; + SiS_Pr->SiS_LVDSBARCO1366Data_1 = SiS300_LVDSBARCO1366Data_1; + SiS_Pr->SiS_LVDSBARCO1366Data_2 = SiS300_LVDSBARCO1366Data_2; + + SiS_Pr->SiS_PanelType04_1a = SiS300_PanelType04_1a; + SiS_Pr->SiS_PanelType04_2a = SiS300_PanelType04_2a; + SiS_Pr->SiS_PanelType04_1b = SiS300_PanelType04_1b; + SiS_Pr->SiS_PanelType04_2b = SiS300_PanelType04_2b; SiS_Pr->SiS_CHTVCRT1UNTSC = SiS300_CHTVCRT1UNTSC; SiS_Pr->SiS_CHTVCRT1ONTSC = SiS300_CHTVCRT1ONTSC; @@ -367,64 +239,38 @@ InitTo300Pointer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) #ifdef SIS315H static void -InitTo310Pointer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +InitTo310Pointer(struct SiS_Private *SiS_Pr) { - InitCommonPointer(SiS_Pr, HwInfo); + InitCommonPointer(SiS_Pr); - SiS_Pr->SiS_SModeIDTable = SiS310_SModeIDTable; SiS_Pr->SiS_EModeIDTable = SiS310_EModeIDTable; - SiS_Pr->SiS_RefIndex = (SiS_Ext2Struct *)SiS310_RefIndex; + SiS_Pr->SiS_RefIndex = SiS310_RefIndex; SiS_Pr->SiS_CRT1Table = SiS310_CRT1Table; - if(HwInfo->jChipType >= SIS_340) { - SiS_Pr->SiS_MCLKData_0 = SiS310_MCLKData_0_340; /* 340 */ - } else if(HwInfo->jChipType >= SIS_761) { + if(SiS_Pr->ChipType >= SIS_340) { + SiS_Pr->SiS_MCLKData_0 = SiS310_MCLKData_0_340; /* 340 + XGI */ + } else if(SiS_Pr->ChipType >= SIS_761) { SiS_Pr->SiS_MCLKData_0 = SiS310_MCLKData_0_761; /* 761 - preliminary */ - } else if(HwInfo->jChipType >= SIS_760) { + } else if(SiS_Pr->ChipType >= SIS_760) { SiS_Pr->SiS_MCLKData_0 = SiS310_MCLKData_0_760; /* 760 */ - } else if(HwInfo->jChipType >= SIS_661) { + } else if(SiS_Pr->ChipType >= SIS_661) { SiS_Pr->SiS_MCLKData_0 = SiS310_MCLKData_0_660; /* 661/741 */ - } else if(HwInfo->jChipType == SIS_330) { + } else if(SiS_Pr->ChipType == SIS_330) { SiS_Pr->SiS_MCLKData_0 = SiS310_MCLKData_0_330; /* 330 */ - } else if(HwInfo->jChipType > SIS_315PRO) { + } else if(SiS_Pr->ChipType > SIS_315PRO) { SiS_Pr->SiS_MCLKData_0 = SiS310_MCLKData_0_650; /* 550, 650, 740 */ } else { SiS_Pr->SiS_MCLKData_0 = SiS310_MCLKData_0_315; /* 315 */ } - if(HwInfo->jChipType >= SIS_340) { - SiS_Pr->SiS_MCLKData_1 = SiS310_MCLKData_1_340; + if(SiS_Pr->ChipType >= SIS_340) { + SiS_Pr->SiS_MCLKData_1 = SiS310_MCLKData_1_340; } else { - SiS_Pr->SiS_MCLKData_1 = SiS310_MCLKData_1; + SiS_Pr->SiS_MCLKData_1 = SiS310_MCLKData_1; } SiS_Pr->SiS_VCLKData = SiS310_VCLKData; SiS_Pr->SiS_VBVCLKData = SiS310_VBVCLKData; SiS_Pr->SiS_SR15 = SiS310_SR15; -#ifdef LINUX_KERNEL - SiS_Pr->pSiS_SR07 = &SiS310_SR07; - SiS_Pr->SiS_CR40 = SiS310_CR40; - SiS_Pr->SiS_CR49 = SiS310_CR49; - SiS_Pr->pSiS_SR1F = &SiS310_SR1F; - SiS_Pr->pSiS_SR21 = &SiS310_SR21; - SiS_Pr->pSiS_SR22 = &SiS310_SR22; - SiS_Pr->pSiS_SR23 = &SiS310_SR23; - SiS_Pr->pSiS_SR24 = &SiS310_SR24; - SiS_Pr->SiS_SR25 = SiS310_SR25; - SiS_Pr->pSiS_SR31 = &SiS310_SR31; - SiS_Pr->pSiS_SR32 = &SiS310_SR32; - SiS_Pr->pSiS_SR33 = &SiS310_SR33; - SiS_Pr->pSiS_CRT2Data_1_2 = &SiS310_CRT2Data_1_2; - SiS_Pr->pSiS_CRT2Data_4_D = &SiS310_CRT2Data_4_D; - SiS_Pr->pSiS_CRT2Data_4_E = &SiS310_CRT2Data_4_E; - SiS_Pr->pSiS_CRT2Data_4_10 = &SiS310_CRT2Data_4_10; - SiS_Pr->pSiS_RGBSenseData = &SiS310_RGBSenseData; - SiS_Pr->pSiS_VideoSenseData = &SiS310_VideoSenseData; - SiS_Pr->pSiS_YCSenseData = &SiS310_YCSenseData; - SiS_Pr->pSiS_RGBSenseData2 = &SiS310_RGBSenseData2; - SiS_Pr->pSiS_VideoSenseData2 = &SiS310_VideoSenseData2; - SiS_Pr->pSiS_YCSenseData2 = &SiS310_YCSenseData2; -#endif - SiS_Pr->SiS_PanelDelayTbl = SiS310_PanelDelayTbl; SiS_Pr->SiS_PanelDelayTblLVDS = SiS310_PanelDelayTblLVDS; @@ -435,41 +281,6 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) SiS_Pr->SiS_CRT2Part2_1024x768_1 = SiS310_CRT2Part2_1024x768_1; - SiS_Pr->SiS_PanelType00_1 = SiS310_PanelType00_1; - SiS_Pr->SiS_PanelType01_1 = SiS310_PanelType01_1; - SiS_Pr->SiS_PanelType02_1 = SiS310_PanelType02_1; - SiS_Pr->SiS_PanelType03_1 = SiS310_PanelType03_1; - SiS_Pr->SiS_PanelType04_1 = SiS310_PanelType04_1; - SiS_Pr->SiS_PanelType05_1 = SiS310_PanelType05_1; - SiS_Pr->SiS_PanelType06_1 = SiS310_PanelType06_1; - SiS_Pr->SiS_PanelType07_1 = SiS310_PanelType07_1; - SiS_Pr->SiS_PanelType08_1 = SiS310_PanelType08_1; - SiS_Pr->SiS_PanelType09_1 = SiS310_PanelType09_1; - SiS_Pr->SiS_PanelType0a_1 = SiS310_PanelType0a_1; - SiS_Pr->SiS_PanelType0b_1 = SiS310_PanelType0b_1; - SiS_Pr->SiS_PanelType0c_1 = SiS310_PanelType0c_1; - SiS_Pr->SiS_PanelType0d_1 = SiS310_PanelType0d_1; - SiS_Pr->SiS_PanelType0e_1 = SiS310_PanelType0e_1; - SiS_Pr->SiS_PanelType0f_1 = SiS310_PanelType0f_1; - SiS_Pr->SiS_PanelType00_2 = SiS310_PanelType00_2; - SiS_Pr->SiS_PanelType01_2 = SiS310_PanelType01_2; - SiS_Pr->SiS_PanelType02_2 = SiS310_PanelType02_2; - SiS_Pr->SiS_PanelType03_2 = SiS310_PanelType03_2; - SiS_Pr->SiS_PanelType04_2 = SiS310_PanelType04_2; - SiS_Pr->SiS_PanelType05_2 = SiS310_PanelType05_2; - SiS_Pr->SiS_PanelType06_2 = SiS310_PanelType06_2; - SiS_Pr->SiS_PanelType07_2 = SiS310_PanelType07_2; - SiS_Pr->SiS_PanelType08_2 = SiS310_PanelType08_2; - SiS_Pr->SiS_PanelType09_2 = SiS310_PanelType09_2; - SiS_Pr->SiS_PanelType0a_2 = SiS310_PanelType0a_2; - SiS_Pr->SiS_PanelType0b_2 = SiS310_PanelType0b_2; - SiS_Pr->SiS_PanelType0c_2 = SiS310_PanelType0c_2; - SiS_Pr->SiS_PanelType0d_2 = SiS310_PanelType0d_2; - SiS_Pr->SiS_PanelType0e_2 = SiS310_PanelType0e_2; - SiS_Pr->SiS_PanelType0f_2 = SiS310_PanelType0f_2; - SiS_Pr->SiS_PanelTypeNS_1 = SiS310_PanelTypeNS_1; - SiS_Pr->SiS_PanelTypeNS_2 = SiS310_PanelTypeNS_2; - SiS_Pr->SiS_CHTVUPALData = SiS310_CHTVUPALData; SiS_Pr->SiS_CHTVOPALData = SiS310_CHTVOPALData; SiS_Pr->SiS_CHTVUPALMData = SiS310_CHTVUPALMData; @@ -478,33 +289,11 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) SiS_Pr->SiS_CHTVOPALNData = SiS310_CHTVOPALNData; SiS_Pr->SiS_CHTVSOPALData = SiS310_CHTVSOPALData; - SiS_Pr->SiS_LVDSCRT1800x600_1 = SiS310_LVDSCRT1800x600_1; - SiS_Pr->SiS_LVDSCRT11024x768_1 = SiS310_LVDSCRT11024x768_1; - SiS_Pr->SiS_LVDSCRT11280x1024_1 = SiS310_LVDSCRT11280x1024_1; - SiS_Pr->SiS_LVDSCRT11400x1050_1 = SiS310_LVDSCRT11400x1050_1; - SiS_Pr->SiS_LVDSCRT11600x1200_1 = SiS310_LVDSCRT11600x1200_1; - SiS_Pr->SiS_LVDSCRT1800x600_1_H = SiS310_LVDSCRT1800x600_1_H; - SiS_Pr->SiS_LVDSCRT11024x768_1_H = SiS310_LVDSCRT11024x768_1_H; - SiS_Pr->SiS_LVDSCRT11280x1024_1_H = SiS310_LVDSCRT11280x1024_1_H; - SiS_Pr->SiS_LVDSCRT11400x1050_1_H = SiS310_LVDSCRT11400x1050_1_H; - SiS_Pr->SiS_LVDSCRT11600x1200_1_H = SiS310_LVDSCRT11600x1200_1_H; - SiS_Pr->SiS_LVDSCRT1800x600_2 = SiS310_LVDSCRT1800x600_2; - SiS_Pr->SiS_LVDSCRT11024x768_2 = SiS310_LVDSCRT11024x768_2; - SiS_Pr->SiS_LVDSCRT11280x1024_2 = SiS310_LVDSCRT11280x1024_2; - SiS_Pr->SiS_LVDSCRT11400x1050_2 = SiS310_LVDSCRT11400x1050_2; - SiS_Pr->SiS_LVDSCRT11600x1200_2 = SiS310_LVDSCRT11600x1200_2; - SiS_Pr->SiS_LVDSCRT1800x600_2_H = SiS310_LVDSCRT1800x600_2_H; - SiS_Pr->SiS_LVDSCRT11024x768_2_H = SiS310_LVDSCRT11024x768_2_H; - SiS_Pr->SiS_LVDSCRT11280x1024_2_H = SiS310_LVDSCRT11280x1024_2_H; - SiS_Pr->SiS_LVDSCRT11400x1050_2_H = SiS310_LVDSCRT11400x1050_2_H; - SiS_Pr->SiS_LVDSCRT11600x1200_2_H = SiS310_LVDSCRT11600x1200_2_H; - SiS_Pr->SiS_LVDSCRT1XXXxXXX_1 = SiS310_LVDSCRT1XXXxXXX_1; - SiS_Pr->SiS_LVDSCRT1XXXxXXX_1_H = SiS310_LVDSCRT1XXXxXXX_1_H; - SiS_Pr->SiS_CHTVCRT1UNTSC = SiS310_CHTVCRT1UNTSC; - SiS_Pr->SiS_CHTVCRT1ONTSC = SiS310_CHTVCRT1ONTSC; - SiS_Pr->SiS_CHTVCRT1UPAL = SiS310_CHTVCRT1UPAL; - SiS_Pr->SiS_CHTVCRT1OPAL = SiS310_CHTVCRT1OPAL; - SiS_Pr->SiS_CHTVCRT1SOPAL = SiS310_CHTVCRT1OPAL; + SiS_Pr->SiS_CHTVCRT1UNTSC = SiS310_CHTVCRT1UNTSC; + SiS_Pr->SiS_CHTVCRT1ONTSC = SiS310_CHTVCRT1ONTSC; + SiS_Pr->SiS_CHTVCRT1UPAL = SiS310_CHTVCRT1UPAL; + SiS_Pr->SiS_CHTVCRT1OPAL = SiS310_CHTVCRT1OPAL; + SiS_Pr->SiS_CHTVCRT1SOPAL = SiS310_CHTVCRT1OPAL; SiS_Pr->SiS_CHTVReg_UNTSC = SiS310_CHTVReg_UNTSC; SiS_Pr->SiS_CHTVReg_ONTSC = SiS310_CHTVReg_ONTSC; @@ -528,208 +317,203 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) } #endif -static void -SiSInitPtr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +BOOLEAN +SiSInitPtr(struct SiS_Private *SiS_Pr) { - switch(HwInfo->jChipType) { -#ifdef SIS315H - case SIS_315H: - case SIS_315: - case SIS_315PRO: - case SIS_550: - case SIS_650: - case SIS_740: - case SIS_330: - case SIS_661: - case SIS_741: - case SIS_660: - case SIS_760: - case SIS_761: - case SIS_340: - InitTo310Pointer(SiS_Pr, HwInfo); - break; -#endif + if(SiS_Pr->ChipType < SIS_315H) { #ifdef SIS300 - case SIS_300: - case SIS_540: - case SIS_630: - case SIS_730: - InitTo300Pointer(SiS_Pr, HwInfo); - break; + InitTo300Pointer(SiS_Pr); +#else + return FALSE; +#endif + } else { +#ifdef SIS315H + InitTo310Pointer(SiS_Pr); +#else + return FALSE; #endif - default: - break; } + return TRUE; } /*********************************************/ /* HELPER: Get ModeID */ /*********************************************/ -#ifdef LINUX_XF86 -USHORT -SiS_GetModeID(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, - int Depth, BOOLEAN FSTN, int LCDwidth, int LCDheight) +#ifndef SIS_XORG_XF86 +static +#endif +unsigned short +SiS_GetModeID(int VGAEngine, unsigned int VBFlags, int HDisplay, int VDisplay, + int Depth, BOOLEAN FSTN, int LCDwidth, int LCDheight) { - USHORT ModeIndex = 0; + unsigned short ModeIndex = 0; switch(HDisplay) { - case 320: - if(VDisplay == 200) ModeIndex = ModeIndex_320x200[Depth]; - else if(VDisplay == 240) { - if(FSTN) ModeIndex = ModeIndex_320x240_FSTN[Depth]; - else ModeIndex = ModeIndex_320x240[Depth]; - } - break; - case 400: - if((!(VBFlags & CRT1_LCDA)) || ((LCDwidth >= 800) && (LCDwidth >= 600))) { - if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth]; - } - break; - case 512: - if((!(VBFlags & CRT1_LCDA)) || ((LCDwidth >= 1024) && (LCDwidth >= 768))) { - if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth]; - } - break; - case 640: - if(VDisplay == 480) ModeIndex = ModeIndex_640x480[Depth]; - else if(VDisplay == 400) ModeIndex = ModeIndex_640x400[Depth]; - break; - case 720: - if(VDisplay == 480) ModeIndex = ModeIndex_720x480[Depth]; - else if(VDisplay == 576) ModeIndex = ModeIndex_720x576[Depth]; - break; - case 768: - if(VDisplay == 576) ModeIndex = ModeIndex_768x576[Depth]; - break; - case 800: - if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth]; - else if(VDisplay == 480) ModeIndex = ModeIndex_800x480[Depth]; - break; - case 848: - if(VDisplay == 480) ModeIndex = ModeIndex_848x480[Depth]; - break; - case 856: - if(VDisplay == 480) ModeIndex = ModeIndex_856x480[Depth]; - break; - case 960: - if(VGAEngine == SIS_315_VGA) { - if(VDisplay == 540) ModeIndex = ModeIndex_960x540[Depth]; - else if(VDisplay == 600) ModeIndex = ModeIndex_960x600[Depth]; - } - break; - case 1024: - if(VDisplay == 576) ModeIndex = ModeIndex_1024x576[Depth]; - else if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth]; - else if(VGAEngine == SIS_300_VGA) { - if(VDisplay == 600) ModeIndex = ModeIndex_1024x600[Depth]; - } - break; - case 1152: - if(VDisplay == 864) ModeIndex = ModeIndex_1152x864[Depth]; - if(VGAEngine == SIS_300_VGA) { - if(VDisplay == 768) ModeIndex = ModeIndex_1152x768[Depth]; - } - break; - case 1280: - switch(VDisplay) { - case 720: - ModeIndex = ModeIndex_1280x720[Depth]; - break; - case 768: - if(VGAEngine == SIS_300_VGA) { - ModeIndex = ModeIndex_300_1280x768[Depth]; - } else { - ModeIndex = ModeIndex_310_1280x768[Depth]; - } - break; - case 800: - if(VGAEngine == SIS_315_VGA) { - ModeIndex = ModeIndex_1280x800[Depth]; - } - break; - case 960: - ModeIndex = ModeIndex_1280x960[Depth]; - break; - case 1024: - ModeIndex = ModeIndex_1280x1024[Depth]; - break; - } - break; - case 1360: - if(VDisplay == 768) ModeIndex = ModeIndex_1360x768[Depth]; - if(VGAEngine == SIS_300_VGA) { - if(VDisplay == 1024) ModeIndex = ModeIndex_300_1360x1024[Depth]; - } - break; - case 1400: - if(VGAEngine == SIS_315_VGA) { - if(VDisplay == 1050) { - ModeIndex = ModeIndex_1400x1050[Depth]; - } - } - break; - case 1600: - if(VDisplay == 1200) ModeIndex = ModeIndex_1600x1200[Depth]; - break; - case 1680: - if(VGAEngine == SIS_315_VGA) { - if(VDisplay == 1050) ModeIndex = ModeIndex_1680x1050[Depth]; - } - break; - case 1920: - if(VDisplay == 1440) ModeIndex = ModeIndex_1920x1440[Depth]; - else if(VGAEngine == SIS_315_VGA) { - if(VDisplay == 1080) ModeIndex = ModeIndex_1920x1080[Depth]; - } - break; - case 2048: - if(VDisplay == 1536) { - if(VGAEngine == SIS_300_VGA) { - ModeIndex = ModeIndex_300_2048x1536[Depth]; - } else { - ModeIndex = ModeIndex_310_2048x1536[Depth]; - } - } - break; + case 320: + if(VDisplay == 200) ModeIndex = ModeIndex_320x200[Depth]; + else if(VDisplay == 240) { + if((VBFlags & CRT2_LCD) && (FSTN)) + ModeIndex = ModeIndex_320x240_FSTN[Depth]; + else + ModeIndex = ModeIndex_320x240[Depth]; + } + break; + case 400: + if((!(VBFlags & CRT1_LCDA)) || ((LCDwidth >= 800) && (LCDwidth >= 600))) { + if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth]; + } + break; + case 512: + if((!(VBFlags & CRT1_LCDA)) || ((LCDwidth >= 1024) && (LCDwidth >= 768))) { + if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth]; + } + break; + case 640: + if(VDisplay == 480) ModeIndex = ModeIndex_640x480[Depth]; + else if(VDisplay == 400) ModeIndex = ModeIndex_640x400[Depth]; + break; + case 720: + if(VDisplay == 480) ModeIndex = ModeIndex_720x480[Depth]; + else if(VDisplay == 576) ModeIndex = ModeIndex_720x576[Depth]; + break; + case 768: + if(VDisplay == 576) ModeIndex = ModeIndex_768x576[Depth]; + break; + case 800: + if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth]; + else if(VDisplay == 480) ModeIndex = ModeIndex_800x480[Depth]; + break; + case 848: + if(VDisplay == 480) ModeIndex = ModeIndex_848x480[Depth]; + break; + case 856: + if(VDisplay == 480) ModeIndex = ModeIndex_856x480[Depth]; + break; + case 960: + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 540) ModeIndex = ModeIndex_960x540[Depth]; + else if(VDisplay == 600) ModeIndex = ModeIndex_960x600[Depth]; + } + break; + case 1024: + if(VDisplay == 576) ModeIndex = ModeIndex_1024x576[Depth]; + else if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth]; + else if(VGAEngine == SIS_300_VGA) { + if(VDisplay == 600) ModeIndex = ModeIndex_1024x600[Depth]; + } + break; + case 1152: + if(VDisplay == 864) ModeIndex = ModeIndex_1152x864[Depth]; + if(VGAEngine == SIS_300_VGA) { + if(VDisplay == 768) ModeIndex = ModeIndex_1152x768[Depth]; + } + break; + case 1280: + switch(VDisplay) { + case 720: + ModeIndex = ModeIndex_1280x720[Depth]; + break; + case 768: + if(VGAEngine == SIS_300_VGA) { + ModeIndex = ModeIndex_300_1280x768[Depth]; + } else { + ModeIndex = ModeIndex_310_1280x768[Depth]; + } + break; + case 800: + if(VGAEngine == SIS_315_VGA) { + ModeIndex = ModeIndex_1280x800[Depth]; + } + break; + case 854: + if(VGAEngine == SIS_315_VGA) { + ModeIndex = ModeIndex_1280x854[Depth]; + } + break; + case 960: + ModeIndex = ModeIndex_1280x960[Depth]; + break; + case 1024: + ModeIndex = ModeIndex_1280x1024[Depth]; + break; + } + break; + case 1360: + if(VDisplay == 768) ModeIndex = ModeIndex_1360x768[Depth]; + if(VGAEngine == SIS_300_VGA) { + if(VDisplay == 1024) ModeIndex = ModeIndex_300_1360x1024[Depth]; + } + break; + case 1400: + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 1050) { + ModeIndex = ModeIndex_1400x1050[Depth]; + } + } + break; + case 1600: + if(VDisplay == 1200) ModeIndex = ModeIndex_1600x1200[Depth]; + break; + case 1680: + if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 1050) ModeIndex = ModeIndex_1680x1050[Depth]; + } + break; + case 1920: + if(VDisplay == 1440) ModeIndex = ModeIndex_1920x1440[Depth]; + else if(VGAEngine == SIS_315_VGA) { + if(VDisplay == 1080) ModeIndex = ModeIndex_1920x1080[Depth]; + } + break; + case 2048: + if(VDisplay == 1536) { + if(VGAEngine == SIS_300_VGA) { + ModeIndex = ModeIndex_300_2048x1536[Depth]; + } else { + ModeIndex = ModeIndex_310_2048x1536[Depth]; + } + } + break; } - return(ModeIndex); + return ModeIndex; } -#endif -USHORT -SiS_GetModeID_LCD(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, - int Depth, BOOLEAN FSTN, USHORT CustomT, int LCDwidth, int LCDheight) +unsigned short +SiS_GetModeID_LCD(int VGAEngine, unsigned int VBFlags, int HDisplay, int VDisplay, + int Depth, BOOLEAN FSTN, unsigned short CustomT, int LCDwidth, int LCDheight, + unsigned int VBFlags2) { - USHORT ModeIndex = 0; + unsigned short ModeIndex = 0; - if(VBFlags & (VB_LVDS | VB_30xBDH)) { + if(VBFlags2 & (VB2_LVDS | VB2_30xBDH)) { switch(HDisplay) { case 320: - if(CustomT != CUT_PANEL848) { - if(VDisplay == 200) ModeIndex = ModeIndex_320x200[Depth]; - else if(VDisplay == 240) { + if((CustomT != CUT_PANEL848) && (CustomT != CUT_PANEL856)) { + if(VDisplay == 200) { + if(!FSTN) ModeIndex = ModeIndex_320x200[Depth]; + } else if(VDisplay == 240) { if(!FSTN) ModeIndex = ModeIndex_320x240[Depth]; - else if(VGAEngine == SIS_315_VGA) { - ModeIndex = ModeIndex_320x240_FSTN[Depth]; + else if(VGAEngine == SIS_315_VGA) { + ModeIndex = ModeIndex_320x240_FSTN[Depth]; } } } - break; - case 400: - if(CustomT != CUT_PANEL848) { - if(!((VGAEngine == SIS_300_VGA) && (VBFlags & VB_TRUMPION))) { - if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth]; + break; + case 400: + if((CustomT != CUT_PANEL848) && (CustomT != CUT_PANEL856)) { + if(!((VGAEngine == SIS_300_VGA) && (VBFlags2 & VB2_TRUMPION))) { + if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth]; } } - break; + break; case 512: - if(CustomT != CUT_PANEL848) { - if(!((VGAEngine == SIS_300_VGA) && (VBFlags & VB_TRUMPION))) { + if((CustomT != CUT_PANEL848) && (CustomT != CUT_PANEL856)) { + if(!((VGAEngine == SIS_300_VGA) && (VBFlags2 & VB2_TRUMPION))) { if(LCDwidth >= 1024 && LCDwidth != 1152 && LCDheight >= 768) { if(VDisplay == 384) { ModeIndex = ModeIndex_512x384[Depth]; @@ -739,9 +523,10 @@ SiS_GetModeID_LCD(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, } break; case 640: - if(VDisplay == 480) ModeIndex = ModeIndex_640x480[Depth]; + if(VDisplay == 480) ModeIndex = ModeIndex_640x480[Depth]; else if(VDisplay == 400) { - if(CustomT != CUT_PANEL848) ModeIndex = ModeIndex_640x400[Depth]; + if((CustomT != CUT_PANEL848) && (CustomT != CUT_PANEL856)) + ModeIndex = ModeIndex_640x400[Depth]; } break; case 800: @@ -752,6 +537,11 @@ SiS_GetModeID_LCD(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, if(VDisplay == 480) ModeIndex = ModeIndex_848x480[Depth]; } break; + case 856: + if(CustomT == CUT_PANEL856) { + if(VDisplay == 480) ModeIndex = ModeIndex_856x480[Depth]; + } + break; case 1024: if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth]; else if(VGAEngine == SIS_300_VGA) { @@ -762,7 +552,7 @@ SiS_GetModeID_LCD(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, break; case 1152: if(VGAEngine == SIS_300_VGA) { - if((VDisplay == 768) && (LCDheight == 768)) { + if((VDisplay == 768) && (LCDheight == 768)) { ModeIndex = ModeIndex_1152x768[Depth]; } } @@ -770,49 +560,49 @@ SiS_GetModeID_LCD(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, case 1280: if(VDisplay == 1024) ModeIndex = ModeIndex_1280x1024[Depth]; else if(VGAEngine == SIS_315_VGA) { - if((VDisplay == 768) && (LCDheight == 768)) { + if((VDisplay == 768) && (LCDheight == 768)) { ModeIndex = ModeIndex_310_1280x768[Depth]; } } break; case 1360: if(VGAEngine == SIS_300_VGA) { - if(CustomT == CUT_BARCO1366) { + if(CustomT == CUT_BARCO1366) { if(VDisplay == 1024) ModeIndex = ModeIndex_300_1360x1024[Depth]; } } if(CustomT == CUT_PANEL848) { - if(VDisplay == 768) ModeIndex = ModeIndex_1360x768[Depth]; + if(VDisplay == 768) ModeIndex = ModeIndex_1360x768[Depth]; } break; case 1400: if(VGAEngine == SIS_315_VGA) { - if(VDisplay == 1050) ModeIndex = ModeIndex_1400x1050[Depth]; + if(VDisplay == 1050) ModeIndex = ModeIndex_1400x1050[Depth]; } break; case 1600: if(VGAEngine == SIS_315_VGA) { - if(VDisplay == 1200) ModeIndex = ModeIndex_1600x1200[Depth]; + if(VDisplay == 1200) ModeIndex = ModeIndex_1600x1200[Depth]; } break; } - } else if(VBFlags & VB_SISBRIDGE) { + } else if(VBFlags2 & VB2_SISBRIDGE) { switch(HDisplay) { case 320: - if(VDisplay == 200) ModeIndex = ModeIndex_320x200[Depth]; + if(VDisplay == 200) ModeIndex = ModeIndex_320x200[Depth]; else if(VDisplay == 240) ModeIndex = ModeIndex_320x240[Depth]; - break; - case 400: + break; + case 400: if(LCDwidth >= 800 && LCDheight >= 600) { - if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth]; + if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth]; } - break; + break; case 512: if(LCDwidth >= 1024 && LCDheight >= 768 && LCDwidth != 1152) { - if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth]; + if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth]; } break; case 640: @@ -821,96 +611,115 @@ SiS_GetModeID_LCD(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, break; case 720: if(VGAEngine == SIS_315_VGA) { - if(VDisplay == 480) ModeIndex = ModeIndex_720x480[Depth]; + if(VDisplay == 480) ModeIndex = ModeIndex_720x480[Depth]; else if(VDisplay == 576) ModeIndex = ModeIndex_720x576[Depth]; } break; case 768: if(VGAEngine == SIS_315_VGA) { - if(VDisplay == 576) ModeIndex = ModeIndex_768x576[Depth]; + if(VDisplay == 576) ModeIndex = ModeIndex_768x576[Depth]; } break; case 800: if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth]; if(VGAEngine == SIS_315_VGA) { - if(VDisplay == 480) ModeIndex = ModeIndex_800x480[Depth]; + if(VDisplay == 480) ModeIndex = ModeIndex_800x480[Depth]; } break; case 848: if(VGAEngine == SIS_315_VGA) { - if(VDisplay == 480) ModeIndex = ModeIndex_848x480[Depth]; + if(VDisplay == 480) ModeIndex = ModeIndex_848x480[Depth]; } break; case 856: if(VGAEngine == SIS_315_VGA) { - if(VDisplay == 480) ModeIndex = ModeIndex_856x480[Depth]; + if(VDisplay == 480) ModeIndex = ModeIndex_856x480[Depth]; } break; case 960: if(VGAEngine == SIS_315_VGA) { - if(VDisplay == 540) ModeIndex = ModeIndex_960x540[Depth]; + if(VDisplay == 540) ModeIndex = ModeIndex_960x540[Depth]; else if(VDisplay == 600) ModeIndex = ModeIndex_960x600[Depth]; } break; case 1024: if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth]; if(VGAEngine == SIS_315_VGA) { - if(VDisplay == 576) ModeIndex = ModeIndex_1024x576[Depth]; + if(VDisplay == 576) ModeIndex = ModeIndex_1024x576[Depth]; } break; case 1152: if(VGAEngine == SIS_315_VGA) { - if(VDisplay == 864) ModeIndex = ModeIndex_1152x864[Depth]; + if(VDisplay == 864) ModeIndex = ModeIndex_1152x864[Depth]; } break; case 1280: switch(VDisplay) { case 720: - ModeIndex = ModeIndex_1280x720[Depth]; + ModeIndex = ModeIndex_1280x720[Depth]; case 768: - if(VGAEngine == SIS_300_VGA) { + if(VGAEngine == SIS_300_VGA) { ModeIndex = ModeIndex_300_1280x768[Depth]; } else { ModeIndex = ModeIndex_310_1280x768[Depth]; } break; case 800: - if(VGAEngine == SIS_315_VGA) { + if(VGAEngine == SIS_315_VGA) { ModeIndex = ModeIndex_1280x800[Depth]; } break; + case 854: + if(VGAEngine == SIS_315_VGA) { + ModeIndex = ModeIndex_1280x854[Depth]; + } + break; case 960: - ModeIndex = ModeIndex_1280x960[Depth]; + ModeIndex = ModeIndex_1280x960[Depth]; break; case 1024: - ModeIndex = ModeIndex_1280x1024[Depth]; + ModeIndex = ModeIndex_1280x1024[Depth]; break; } break; case 1360: - if(VGAEngine == SIS_315_VGA) { - if(VDisplay == 768) ModeIndex = ModeIndex_1360x768[Depth]; + if(VGAEngine == SIS_315_VGA) { /* OVER1280 only? */ + if(VDisplay == 768) ModeIndex = ModeIndex_1360x768[Depth]; } break; case 1400: if(VGAEngine == SIS_315_VGA) { - if(VBFlags & (VB_301C | VB_302LV | VB_302ELV)) { + if(VBFlags2 & VB2_LCDOVER1280BRIDGE) { if(VDisplay == 1050) ModeIndex = ModeIndex_1400x1050[Depth]; } } break; case 1600: if(VGAEngine == SIS_315_VGA) { - if(VBFlags & (VB_301C | VB_302LV | VB_302ELV)) { - if(VDisplay == 1200) ModeIndex = ModeIndex_1600x1200[Depth]; + if(VBFlags2 & VB2_LCDOVER1280BRIDGE) { + if(VDisplay == 1200) ModeIndex = ModeIndex_1600x1200[Depth]; } } break; #ifndef VB_FORBID_CRT2LCD_OVER_1600 case 1680: if(VGAEngine == SIS_315_VGA) { - if(VBFlags & (VB_301C | VB_302LV | VB_302ELV)) { - if(VDisplay == 1050) ModeIndex = ModeIndex_1680x1050[Depth]; + if(VBFlags2 & VB2_LCDOVER1280BRIDGE) { + if(VDisplay == 1050) ModeIndex = ModeIndex_1680x1050[Depth]; + } + } + break; + case 1920: + if(VGAEngine == SIS_315_VGA) { + if(VBFlags2 & VB2_LCDOVER1600BRIDGE) { + if(VDisplay == 1440) ModeIndex = ModeIndex_1920x1440[Depth]; + } + } + break; + case 2048: + if(VGAEngine == SIS_315_VGA) { + if(VBFlags2 & VB2_LCDOVER1600BRIDGE) { + if(VDisplay == 1536) ModeIndex = ModeIndex_310_2048x1536[Depth]; } } break; @@ -921,16 +730,17 @@ SiS_GetModeID_LCD(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, return ModeIndex; } -USHORT -SiS_GetModeID_TV(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth) +unsigned short +SiS_GetModeID_TV(int VGAEngine, unsigned int VBFlags, int HDisplay, int VDisplay, int Depth, + unsigned int VBFlags2) { - USHORT ModeIndex = 0; + unsigned short ModeIndex = 0; - if(VBFlags & VB_CHRONTEL) { + if(VBFlags2 & VB2_CHRONTEL) { switch(HDisplay) { - case 512: + case 512: if(VGAEngine == SIS_315_VGA) { if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth]; } @@ -944,27 +754,27 @@ SiS_GetModeID_TV(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int D break; case 1024: if(VGAEngine == SIS_315_VGA) { - if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth]; + if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth]; } break; } - } else if(VBFlags & VB_SISTVBRIDGE) { + } else if(VBFlags2 & VB2_SISTVBRIDGE) { switch(HDisplay) { case 320: - if(VDisplay == 200) ModeIndex = ModeIndex_320x200[Depth]; + if(VDisplay == 200) ModeIndex = ModeIndex_320x200[Depth]; else if(VDisplay == 240) ModeIndex = ModeIndex_320x240[Depth]; - break; - case 400: - if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth]; - break; - case 512: + break; + case 400: + if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth]; + break; + case 512: if( ((VBFlags & TV_YPBPR) && (VBFlags & (TV_YPBPR750P | TV_YPBPR1080I))) || - (VBFlags & TV_HIVISION) || - ((!(VBFlags & (TV_YPBPR | TV_PALM))) && (VBFlags & TV_PAL)) ) { - if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth]; + (VBFlags & TV_HIVISION) || + ((!(VBFlags & (TV_YPBPR | TV_PALM))) && (VBFlags & TV_PAL)) ) { + if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth]; } break; case 640: @@ -973,34 +783,34 @@ SiS_GetModeID_TV(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int D break; case 720: if((!(VBFlags & TV_HIVISION)) && (!((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I)))) { - if(VDisplay == 480) { - ModeIndex = ModeIndex_720x480[Depth]; - } else if(VDisplay == 576) { + if(VDisplay == 480) { + ModeIndex = ModeIndex_720x480[Depth]; + } else if(VDisplay == 576) { if( ((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR750P)) || ((!(VBFlags & (TV_YPBPR | TV_PALM))) && (VBFlags & TV_PAL)) ) - ModeIndex = ModeIndex_720x576[Depth]; - } + ModeIndex = ModeIndex_720x576[Depth]; + } } break; case 768: if((!(VBFlags & TV_HIVISION)) && (!((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I)))) { - if( ((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR750P)) || + if( ((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR750P)) || ((!(VBFlags & (TV_YPBPR | TV_PALM))) && (VBFlags & TV_PAL)) ) { - if(VDisplay == 576) ModeIndex = ModeIndex_768x576[Depth]; + if(VDisplay == 576) ModeIndex = ModeIndex_768x576[Depth]; } } break; case 800: if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth]; else if(VDisplay == 480) { - if((VBFlags & TV_HIVISION) || ((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I))) { + if(!((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR750P))) { ModeIndex = ModeIndex_800x480[Depth]; } } break; case 960: if(VGAEngine == SIS_315_VGA) { - if(VDisplay == 600) { + if(VDisplay == 600) { if((VBFlags & TV_HIVISION) || ((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I))) { ModeIndex = ModeIndex_960x600[Depth]; } @@ -1009,25 +819,28 @@ SiS_GetModeID_TV(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int D break; case 1024: if(VDisplay == 768) { - if(VBFlags & (VB_301B|VB_301C|VB_302B|VB_301LV|VB_302LV|VB_302ELV)) { + if(VBFlags2 & VB2_30xBLV) { ModeIndex = ModeIndex_1024x768[Depth]; } } else if(VDisplay == 576) { - if((VBFlags & TV_HIVISION) || ((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I))) { + if( (VBFlags & TV_HIVISION) || + ((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I)) || + ((VBFlags2 & VB2_30xBLV) && + ((!(VBFlags & (TV_YPBPR | TV_PALM))) && (VBFlags & TV_PAL))) ) { ModeIndex = ModeIndex_1024x576[Depth]; } } break; case 1280: if(VDisplay == 720) { - if((VBFlags & TV_HIVISION) || + if((VBFlags & TV_HIVISION) || ((VBFlags & TV_YPBPR) && (VBFlags & (TV_YPBPR1080I | TV_YPBPR750P)))) { - ModeIndex = ModeIndex_1280x720[Depth]; + ModeIndex = ModeIndex_1280x720[Depth]; } } else if(VDisplay == 1024) { - if((VBFlags & TV_HIVISION) || + if((VBFlags & TV_HIVISION) || ((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I))) { - ModeIndex = ModeIndex_1280x1024[Depth]; + ModeIndex = ModeIndex_1280x1024[Depth]; } } break; @@ -1036,99 +849,31 @@ SiS_GetModeID_TV(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int D return ModeIndex; } -USHORT -SiS_GetModeID_VGA2(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth) +unsigned short +SiS_GetModeID_VGA2(int VGAEngine, unsigned int VBFlags, int HDisplay, int VDisplay, int Depth, + unsigned int VBFlags2) { - USHORT ModeIndex = 0; + if(!(VBFlags2 & VB2_SISVGA2BRIDGE)) return 0; - if(!(VBFlags & (VB_301|VB_301B|VB_301C|VB_302B))) return 0; + if(HDisplay >= 1920) return 0; switch(HDisplay) { - case 320: - if(VDisplay == 200) ModeIndex = ModeIndex_320x200[Depth]; - else if(VDisplay == 240) ModeIndex = ModeIndex_320x240[Depth]; - break; - case 400: - if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth]; - break; - case 512: - if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth]; - break; - case 640: - if(VDisplay == 480) ModeIndex = ModeIndex_640x480[Depth]; - else if(VDisplay == 400) ModeIndex = ModeIndex_640x400[Depth]; - break; - case 720: - if(VDisplay == 480) ModeIndex = ModeIndex_720x480[Depth]; - else if(VDisplay == 576) ModeIndex = ModeIndex_720x576[Depth]; - break; - case 768: - if(VDisplay == 576) ModeIndex = ModeIndex_768x576[Depth]; - break; - case 800: - if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth]; - else if(VDisplay == 480) ModeIndex = ModeIndex_800x480[Depth]; - break; - case 848: - if(VDisplay == 480) ModeIndex = ModeIndex_848x480[Depth]; - break; - case 856: - if(VDisplay == 480) ModeIndex = ModeIndex_856x480[Depth]; - break; - case 960: - if(VGAEngine == SIS_315_VGA) { - if(VDisplay == 540) ModeIndex = ModeIndex_960x540[Depth]; - else if(VDisplay == 600) ModeIndex = ModeIndex_960x600[Depth]; - } - break; - case 1024: - if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth]; - else if(VDisplay == 576) ModeIndex = ModeIndex_1024x576[Depth]; - break; - case 1152: - if(VDisplay == 864) ModeIndex = ModeIndex_1152x864[Depth]; - else if(VGAEngine == SIS_300_VGA) { - if(VDisplay == 768) ModeIndex = ModeIndex_1152x768[Depth]; - } - break; - case 1280: - if(VDisplay == 768) { - if(VGAEngine == SIS_300_VGA) { - ModeIndex = ModeIndex_300_1280x768[Depth]; - } else { - ModeIndex = ModeIndex_310_1280x768[Depth]; - } - } else if(VDisplay == 1024) ModeIndex = ModeIndex_1280x1024[Depth]; - else if(VDisplay == 720) ModeIndex = ModeIndex_1280x720[Depth]; - else if(VDisplay == 800) ModeIndex = ModeIndex_1280x800[Depth]; - else if(VDisplay == 960) ModeIndex = ModeIndex_1280x960[Depth]; - break; - case 1360: - if(VDisplay == 768) ModeIndex = ModeIndex_1360x768[Depth]; - break; - case 1400: - if(VGAEngine == SIS_315_VGA) { - if(VDisplay == 1050) ModeIndex = ModeIndex_1400x1050[Depth]; - } - break; case 1600: - if(VGAEngine == SIS_315_VGA) { - if(VBFlags & (VB_301B|VB_301C|VB_302B)) { - if(VDisplay == 1200) ModeIndex = ModeIndex_1600x1200[Depth]; - } + if(VDisplay == 1200) { + if(VGAEngine != SIS_315_VGA) return 0; + if(!(VBFlags2 & VB2_30xB)) return 0; } break; case 1680: - if(VGAEngine == SIS_315_VGA) { - if(VBFlags & (VB_301B|VB_301C|VB_302B)) { - if(VDisplay == 1050) ModeIndex = ModeIndex_1680x1050[Depth]; - } + if(VDisplay == 1050) { + if(VGAEngine != SIS_315_VGA) return 0; + if(!(VBFlags2 & VB2_30xB)) return 0; } break; } - return ModeIndex; + return SiS_GetModeID(VGAEngine, 0, HDisplay, VDisplay, Depth, FALSE, 0, 0); } @@ -1137,83 +882,83 @@ SiS_GetModeID_VGA2(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int /*********************************************/ void -SiS_SetReg(SISIOADDRESS port, USHORT index, USHORT data) +SiS_SetReg(SISIOADDRESS port, unsigned short index, unsigned short data) { - OutPortByte(port,index); - OutPortByte(port + 1,data); + OutPortByte(port, index); + OutPortByte(port + 1, data); } void -SiS_SetRegByte(SISIOADDRESS port, USHORT data) +SiS_SetRegByte(SISIOADDRESS port, unsigned short data) { - OutPortByte(port,data); + OutPortByte(port, data); } void -SiS_SetRegShort(SISIOADDRESS port, USHORT data) +SiS_SetRegShort(SISIOADDRESS port, unsigned short data) { - OutPortWord(port,data); + OutPortWord(port, data); } void -SiS_SetRegLong(SISIOADDRESS port, ULONG data) +SiS_SetRegLong(SISIOADDRESS port, unsigned int data) { - OutPortLong(port,data); + OutPortLong(port, data); } -UCHAR -SiS_GetReg(SISIOADDRESS port, USHORT index) +unsigned char +SiS_GetReg(SISIOADDRESS port, unsigned short index) { - OutPortByte(port,index); + OutPortByte(port, index); return(InPortByte(port + 1)); } -UCHAR +unsigned char SiS_GetRegByte(SISIOADDRESS port) { return(InPortByte(port)); } -USHORT +unsigned short SiS_GetRegShort(SISIOADDRESS port) { return(InPortWord(port)); } -ULONG +unsigned int SiS_GetRegLong(SISIOADDRESS port) { return(InPortLong(port)); } void -SiS_SetRegANDOR(SISIOADDRESS Port,USHORT Index,USHORT DataAND,USHORT DataOR) +SiS_SetRegANDOR(SISIOADDRESS Port, unsigned short Index, unsigned short DataAND, unsigned short DataOR) { - USHORT temp; + unsigned short temp; - temp = SiS_GetReg(Port,Index); - temp = (temp & (DataAND)) | DataOR; - SiS_SetReg(Port,Index,temp); + temp = SiS_GetReg(Port, Index); + temp = (temp & (DataAND)) | DataOR; + SiS_SetReg(Port, Index, temp); } void -SiS_SetRegAND(SISIOADDRESS Port,USHORT Index,USHORT DataAND) +SiS_SetRegAND(SISIOADDRESS Port, unsigned short Index, unsigned short DataAND) { - USHORT temp; + unsigned short temp; - temp = SiS_GetReg(Port,Index); - temp &= DataAND; - SiS_SetReg(Port,Index,temp); + temp = SiS_GetReg(Port, Index); + temp &= DataAND; + SiS_SetReg(Port, Index, temp); } void -SiS_SetRegOR(SISIOADDRESS Port,USHORT Index,USHORT DataOR) +SiS_SetRegOR(SISIOADDRESS Port, unsigned short Index, unsigned short DataOR) { - USHORT temp; + unsigned short temp; - temp = SiS_GetReg(Port,Index); - temp |= DataOR; - SiS_SetReg(Port,Index,temp); + temp = SiS_GetReg(Port, Index); + temp |= DataOR; + SiS_SetReg(Port, Index, temp); } /*********************************************/ @@ -1221,13 +966,13 @@ SiS_SetRegOR(SISIOADDRESS Port,USHORT Index,USHORT DataOR) /*********************************************/ void -SiS_DisplayOn(SiS_Private *SiS_Pr) +SiS_DisplayOn(struct SiS_Private *SiS_Pr) { SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x01,0xDF); } void -SiS_DisplayOff(SiS_Private *SiS_Pr) +SiS_DisplayOff(struct SiS_Private *SiS_Pr) { SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x01,0x20); } @@ -1238,7 +983,7 @@ SiS_DisplayOff(SiS_Private *SiS_Pr) /*********************************************/ void -SiSRegInit(SiS_Private *SiS_Pr, SISIOADDRESS BaseAddr) +SiSRegInit(struct SiS_Private *SiS_Pr, SISIOADDRESS BaseAddr) { SiS_Pr->SiS_P3c4 = BaseAddr + 0x14; SiS_Pr->SiS_P3d4 = BaseAddr + 0x24; @@ -1251,16 +996,17 @@ SiSRegInit(SiS_Private *SiS_Pr, SISIOADDRESS BaseAddr) SiS_Pr->SiS_P3c8 = BaseAddr + 0x18; SiS_Pr->SiS_P3c9 = BaseAddr + 0x19; SiS_Pr->SiS_P3cb = BaseAddr + 0x1b; + SiS_Pr->SiS_P3cc = BaseAddr + 0x1c; SiS_Pr->SiS_P3cd = BaseAddr + 0x1d; SiS_Pr->SiS_P3da = BaseAddr + 0x2a; - SiS_Pr->SiS_Part1Port = BaseAddr + SIS_CRT2_PORT_04; /* Digital video interface registers (LCD) */ - SiS_Pr->SiS_Part2Port = BaseAddr + SIS_CRT2_PORT_10; /* 301 TV Encoder registers */ - SiS_Pr->SiS_Part3Port = BaseAddr + SIS_CRT2_PORT_12; /* 301 Macrovision registers */ - SiS_Pr->SiS_Part4Port = BaseAddr + SIS_CRT2_PORT_14; /* 301 VGA2 (and LCD) registers */ - SiS_Pr->SiS_Part5Port = BaseAddr + SIS_CRT2_PORT_14 + 2; /* 301 palette address port registers */ - SiS_Pr->SiS_DDC_Port = BaseAddr + 0x14; /* DDC Port ( = P3C4, SR11/0A) */ - SiS_Pr->SiS_VidCapt = BaseAddr + SIS_VIDEO_CAPTURE; - SiS_Pr->SiS_VidPlay = BaseAddr + SIS_VIDEO_PLAYBACK; + SiS_Pr->SiS_Part1Port = BaseAddr + SIS_CRT2_PORT_04; + SiS_Pr->SiS_Part2Port = BaseAddr + SIS_CRT2_PORT_10; + SiS_Pr->SiS_Part3Port = BaseAddr + SIS_CRT2_PORT_12; + SiS_Pr->SiS_Part4Port = BaseAddr + SIS_CRT2_PORT_14; + SiS_Pr->SiS_Part5Port = BaseAddr + SIS_CRT2_PORT_14 + 2; + SiS_Pr->SiS_DDC_Port = BaseAddr + 0x14; + SiS_Pr->SiS_VidCapt = BaseAddr + SIS_VIDEO_CAPTURE; + SiS_Pr->SiS_VidPlay = BaseAddr + SIS_VIDEO_PLAYBACK; } /*********************************************/ @@ -1268,7 +1014,7 @@ SiSRegInit(SiS_Private *SiS_Pr, SISIOADDRESS BaseAddr) /*********************************************/ static void -SiS_GetSysFlags(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_GetSysFlags(struct SiS_Private *SiS_Pr) { unsigned char cr5f, temp1, temp2; @@ -1276,9 +1022,9 @@ SiS_GetSysFlags(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) /* (SR11 is used for DDC and in enable/disablebridge) */ SiS_Pr->SiS_SensibleSR11 = FALSE; SiS_Pr->SiS_MyCR63 = 0x63; - if(HwInfo->jChipType >= SIS_330) { + if(SiS_Pr->ChipType >= SIS_330) { SiS_Pr->SiS_MyCR63 = 0x53; - if(HwInfo->jChipType >= SIS_661) { + if(SiS_Pr->ChipType >= SIS_661) { SiS_Pr->SiS_SensibleSR11 = TRUE; } } @@ -1286,43 +1032,52 @@ SiS_GetSysFlags(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) /* You should use the macros, not these flags directly */ SiS_Pr->SiS_SysFlags = 0; - if(HwInfo->jChipType == SIS_650) { + if(SiS_Pr->ChipType == SIS_650) { cr5f = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xf0; SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x5c,0x07); temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5c) & 0xf8; SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x5c,0xf8); temp2 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5c) & 0xf8; if((!temp1) || (temp2)) { - switch(cr5f) { + switch(cr5f) { case 0x80: case 0x90: case 0xc0: - SiS_Pr->SiS_SysFlags |= SF_IsM650; break; + SiS_Pr->SiS_SysFlags |= SF_IsM650; + break; case 0xa0: case 0xb0: case 0xe0: - SiS_Pr->SiS_SysFlags |= SF_Is651; break; + SiS_Pr->SiS_SysFlags |= SF_Is651; + break; } } else { - switch(cr5f) { + switch(cr5f) { case 0x90: temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5c) & 0xf8; switch(temp1) { - case 0x00: SiS_Pr->SiS_SysFlags |= SF_IsM652; break; + case 0x00: SiS_Pr->SiS_SysFlags |= SF_IsM652; break; case 0x40: SiS_Pr->SiS_SysFlags |= SF_IsM653; break; default: SiS_Pr->SiS_SysFlags |= SF_IsM650; break; } break; case 0xb0: - SiS_Pr->SiS_SysFlags |= SF_Is652; break; + SiS_Pr->SiS_SysFlags |= SF_Is652; + break; default: - SiS_Pr->SiS_SysFlags |= SF_IsM650; break; + SiS_Pr->SiS_SysFlags |= SF_IsM650; + break; } } } - if(HwInfo->jChipType == SIS_760) { - temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x78); - if(temp1 & 0x30) SiS_Pr->SiS_SysFlags |= SF_760LFB; + + if(SiS_Pr->ChipType >= SIS_760 && SiS_Pr->ChipType <= SIS_761) { + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x78) & 0x30) { + SiS_Pr->SiS_SysFlags |= SF_760LFB; + } + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x79) & 0xf0) { + SiS_Pr->SiS_SysFlags |= SF_760UMA; + } } } @@ -1331,18 +1086,20 @@ SiS_GetSysFlags(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) /*********************************************/ static void -SiSInitPCIetc(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiSInitPCIetc(struct SiS_Private *SiS_Pr) { - switch(HwInfo->jChipType) { + switch(SiS_Pr->ChipType) { +#ifdef SIS300 case SIS_300: case SIS_540: case SIS_630: case SIS_730: /* Set - PCI LINEAR ADDRESSING ENABLE (0x80) - * - RELOCATED VGA IO (0x20) - * - MMIO ENABLE (0x1) + * - RELOCATED VGA IO ENABLED (0x20) + * - MMIO ENABLED (0x01) + * Leave other bits untouched. */ - SiS_SetReg(SiS_Pr->SiS_P3c4,0x20,0xa1); + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x20,0xa1); /* - Enable 2D (0x40) * - Enable 3D (0x02) * - Enable 3D Vertex command fetch (0x10) ? @@ -1350,6 +1107,8 @@ SiSInitPCIetc(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) */ SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x5A); break; +#endif +#ifdef SIS315H case SIS_315H: case SIS_315: case SIS_315PRO: @@ -1362,21 +1121,30 @@ SiSInitPCIetc(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) case SIS_760: case SIS_761: case SIS_340: - SiS_SetReg(SiS_Pr->SiS_P3c4,0x20,0xa1); - /* - Enable 2D (0x40) - * - Enable 3D (0x02) + case XGI_40: + /* See above */ + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x20,0xa1); + /* - Enable 3D G/L transformation engine (0x80) + * - Enable 2D (0x40) * - Enable 3D vertex command fetch (0x10) * - Enable 3D command parser (0x08) - * - Enable 3D G/L transformation engine (0x80) + * - Enable 3D (0x02) */ SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0xDA); break; + case XGI_20: case SIS_550: - SiS_SetReg(SiS_Pr->SiS_P3c4,0x20,0xa1); + /* See above */ + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x20,0xa1); /* No 3D engine ! */ /* - Enable 2D (0x40) + * - disable 3D */ - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x40); + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x1E,0x60,0x40); + break; +#endif + default: + break; } } @@ -1384,38 +1152,40 @@ SiSInitPCIetc(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) /* HELPER: SetLVDSetc */ /*********************************************/ -static void -SiSSetLVDSetc(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +#ifdef SIS_LINUX_KERNEL +static +#endif +void +SiSSetLVDSetc(struct SiS_Private *SiS_Pr) { - USHORT temp; + unsigned short temp; SiS_Pr->SiS_IF_DEF_LVDS = 0; SiS_Pr->SiS_IF_DEF_TRUMPION = 0; SiS_Pr->SiS_IF_DEF_CH70xx = 0; - SiS_Pr->SiS_IF_DEF_DSTN = 0; - SiS_Pr->SiS_IF_DEF_FSTN = 0; SiS_Pr->SiS_IF_DEF_CONEX = 0; SiS_Pr->SiS_ChrontelInit = 0; + if(SiS_Pr->ChipType == XGI_20) return; + /* Check for SiS30x first */ temp = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x00); if((temp == 1) || (temp == 2)) return; - switch(HwInfo->jChipType) { + switch(SiS_Pr->ChipType) { #ifdef SIS300 case SIS_540: case SIS_630: case SIS_730: - temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37); - temp = (temp & 0x0E) >> 1; - if((temp >= 2) && (temp <= 5)) SiS_Pr->SiS_IF_DEF_LVDS = 1; - if(temp == 3) SiS_Pr->SiS_IF_DEF_TRUMPION = 1; - if((temp == 4) || (temp == 5)) { + temp = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x37) & 0x0e) >> 1; + if((temp >= 2) && (temp <= 5)) SiS_Pr->SiS_IF_DEF_LVDS = 1; + if(temp == 3) SiS_Pr->SiS_IF_DEF_TRUMPION = 1; + if((temp == 4) || (temp == 5)) { /* Save power status (and error check) - UNUSED */ SiS_Pr->SiS_Backup70xx = SiS_GetCH700x(SiS_Pr, 0x0e); SiS_Pr->SiS_IF_DEF_CH70xx = 1; - } + } break; #endif #ifdef SIS315H @@ -1423,26 +1193,26 @@ SiSSetLVDSetc(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) case SIS_650: case SIS_740: case SIS_330: - temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37); - temp = (temp & 0x0E) >> 1; - if((temp >= 2) && (temp <= 3)) SiS_Pr->SiS_IF_DEF_LVDS = 1; - if(temp == 3) SiS_Pr->SiS_IF_DEF_CH70xx = 2; - break; + temp = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x37) & 0x0e) >> 1; + if((temp >= 2) && (temp <= 3)) SiS_Pr->SiS_IF_DEF_LVDS = 1; + if(temp == 3) SiS_Pr->SiS_IF_DEF_CH70xx = 2; + break; case SIS_661: case SIS_741: case SIS_660: case SIS_760: case SIS_761: case SIS_340: - temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); - temp = (temp & 0xe0) >> 5; - if((temp >= 2) && (temp <= 3)) SiS_Pr->SiS_IF_DEF_LVDS = 1; - if(temp == 3) SiS_Pr->SiS_IF_DEF_CH70xx = 2; - if(temp == 4) SiS_Pr->SiS_IF_DEF_CONEX = 1; /* Not yet supported */ - break; + case XGI_20: + case XGI_40: + temp = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x38) & 0xe0) >> 5; + if((temp >= 2) && (temp <= 3)) SiS_Pr->SiS_IF_DEF_LVDS = 1; + if(temp == 3) SiS_Pr->SiS_IF_DEF_CH70xx = 2; + if(temp == 4) SiS_Pr->SiS_IF_DEF_CONEX = 1; /* Not yet supported */ + break; #endif default: - break; + break; } } @@ -1451,35 +1221,55 @@ SiSSetLVDSetc(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) /*********************************************/ void -SiS_SetEnableDstn(SiS_Private *SiS_Pr, int enable) +SiS_SetEnableDstn(struct SiS_Private *SiS_Pr, int enable) { SiS_Pr->SiS_IF_DEF_DSTN = enable ? 1 : 0; } void -SiS_SetEnableFstn(SiS_Private *SiS_Pr, int enable) +SiS_SetEnableFstn(struct SiS_Private *SiS_Pr, int enable) { SiS_Pr->SiS_IF_DEF_FSTN = enable ? 1 : 0; } /*********************************************/ +/* HELPER: Get modeflag */ +/*********************************************/ + +unsigned short +SiS_GetModeFlag(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex) +{ + if(SiS_Pr->UseCustomMode) { + return SiS_Pr->CModeFlag; + } else if(ModeNo <= 0x13) { + return SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + } else { + return SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + } +} + +/*********************************************/ /* HELPER: Determine ROM usage */ /*********************************************/ BOOLEAN -SiSDetermineROMLayout661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiSDetermineROMLayout661(struct SiS_Private *SiS_Pr) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT romversoffs, romvmaj = 1, romvmin = 0; - - if(HwInfo->jChipType >= SIS_761) { - /* I very much assume 761 and 340 will use new layout */ + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short romversoffs, romvmaj = 1, romvmin = 0; + + if(SiS_Pr->ChipType >= XGI_20) { + /* XGI ROMs don't qualify */ + return FALSE; + } else if(SiS_Pr->ChipType >= SIS_761) { + /* I very much assume 761, 340 and newer will use new layout */ return TRUE; - } else if(HwInfo->jChipType >= SIS_661) { + } else if(SiS_Pr->ChipType >= SIS_661) { if((ROMAddr[0x1a] == 'N') && - (ROMAddr[0x1b] == 'e') && - (ROMAddr[0x1c] == 'w') && - (ROMAddr[0x1d] == 'V')) { + (ROMAddr[0x1b] == 'e') && + (ROMAddr[0x1c] == 'w') && + (ROMAddr[0x1d] == 'V')) { return TRUE; } romversoffs = ROMAddr[0x16] | (ROMAddr[0x17] << 8); @@ -1494,9 +1284,9 @@ SiSDetermineROMLayout661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) } } else if(IS_SIS650740) { if((ROMAddr[0x1a] == 'N') && - (ROMAddr[0x1b] == 'e') && - (ROMAddr[0x1c] == 'w') && - (ROMAddr[0x1d] == 'V')) { + (ROMAddr[0x1b] == 'e') && + (ROMAddr[0x1c] == 'w') && + (ROMAddr[0x1d] == 'V')) { return TRUE; } } @@ -1504,45 +1294,50 @@ SiSDetermineROMLayout661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) } static void -SiSDetermineROMUsage(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiSDetermineROMUsage(struct SiS_Private *SiS_Pr) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT romptr = 0; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short romptr = 0; SiS_Pr->SiS_UseROM = FALSE; SiS_Pr->SiS_ROMNew = FALSE; + SiS_Pr->SiS_PWDOffset = 0; - if((ROMAddr) && (HwInfo->UseROM)) { - if(HwInfo->jChipType == SIS_300) { - /* 300: We check if the code starts below 0x220 by + if(SiS_Pr->ChipType >= XGI_20) return; + + if((ROMAddr) && (SiS_Pr->UseROM)) { + if(SiS_Pr->ChipType == SIS_300) { + /* 300: We check if the code starts below 0x220 by * checking the jmp instruction at the beginning * of the BIOS image. */ if((ROMAddr[3] == 0xe9) && ((ROMAddr[5] << 8) | ROMAddr[4]) > 0x21a) SiS_Pr->SiS_UseROM = TRUE; - } else if(HwInfo->jChipType < SIS_315H) { + } else if(SiS_Pr->ChipType < SIS_315H) { /* Sony's VAIO BIOS 1.09 follows the standard, so perhaps * the others do as well */ SiS_Pr->SiS_UseROM = TRUE; } else { - /* 315/330 series stick to the standard(s) */ + /* 315/330 series stick to the standard(s) */ SiS_Pr->SiS_UseROM = TRUE; - if((SiS_Pr->SiS_ROMNew = SiSDetermineROMLayout661(SiS_Pr, HwInfo))) { + if((SiS_Pr->SiS_ROMNew = SiSDetermineROMLayout661(SiS_Pr))) { SiS_Pr->SiS_EMIOffset = 14; + SiS_Pr->SiS_PWDOffset = 17; SiS_Pr->SiS661LCD2TableSize = 36; /* Find out about LCD data table entry size */ if((romptr = SISGETROMW(0x0102))) { if(ROMAddr[romptr + (32 * 16)] == 0xff) - SiS_Pr->SiS661LCD2TableSize = 32; + SiS_Pr->SiS661LCD2TableSize = 32; else if(ROMAddr[romptr + (34 * 16)] == 0xff) - SiS_Pr->SiS661LCD2TableSize = 34; - else if(ROMAddr[romptr + (36 * 16)] == 0xff) /* 0.94 */ - SiS_Pr->SiS661LCD2TableSize = 36; + SiS_Pr->SiS661LCD2TableSize = 34; + else if(ROMAddr[romptr + (36 * 16)] == 0xff) /* 0.94, 2.05.00+ */ + SiS_Pr->SiS661LCD2TableSize = 36; else if( (ROMAddr[romptr + (38 * 16)] == 0xff) || /* 2.00.00 - 2.02.00 */ - (ROMAddr[0x6F] & 0x01) ) { /* 2.03.00+ */ - SiS_Pr->SiS661LCD2TableSize = 38; + (ROMAddr[0x6F] & 0x01) ) { /* 2.03.00 - <2.05.00 */ + SiS_Pr->SiS661LCD2TableSize = 38; /* UMC data layout abandoned at 2.05.00 */ SiS_Pr->SiS_EMIOffset = 16; + SiS_Pr->SiS_PWDOffset = 19; } } } @@ -1555,9 +1350,9 @@ SiSDetermineROMUsage(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) /*********************************************/ static void -SiS_SetSegRegLower(SiS_Private *SiS_Pr, USHORT value) +SiS_SetSegRegLower(struct SiS_Private *SiS_Pr, unsigned short value) { - USHORT temp; + unsigned short temp; value &= 0x00ff; temp = SiS_GetRegByte(SiS_Pr->SiS_P3cb) & 0xf0; @@ -1569,9 +1364,9 @@ SiS_SetSegRegLower(SiS_Private *SiS_Pr, USHORT value) } static void -SiS_SetSegRegUpper(SiS_Private *SiS_Pr, USHORT value) +SiS_SetSegRegUpper(struct SiS_Private *SiS_Pr, unsigned short value) { - USHORT temp; + unsigned short temp; value &= 0x00ff; temp = SiS_GetRegByte(SiS_Pr->SiS_P3cb) & 0x0f; @@ -1583,22 +1378,22 @@ SiS_SetSegRegUpper(SiS_Private *SiS_Pr, USHORT value) } static void -SiS_SetSegmentReg(SiS_Private *SiS_Pr, USHORT value) +SiS_SetSegmentReg(struct SiS_Private *SiS_Pr, unsigned short value) { SiS_SetSegRegLower(SiS_Pr, value); SiS_SetSegRegUpper(SiS_Pr, value); } static void -SiS_ResetSegmentReg(SiS_Private *SiS_Pr) +SiS_ResetSegmentReg(struct SiS_Private *SiS_Pr) { SiS_SetSegmentReg(SiS_Pr, 0); } static void -SiS_SetSegmentRegOver(SiS_Private *SiS_Pr, USHORT value) +SiS_SetSegmentRegOver(struct SiS_Private *SiS_Pr, unsigned short value) { - USHORT temp = value >> 8; + unsigned short temp = value >> 8; temp &= 0x07; temp |= (temp << 4); @@ -1607,15 +1402,15 @@ SiS_SetSegmentRegOver(SiS_Private *SiS_Pr, USHORT value) } static void -SiS_ResetSegmentRegOver(SiS_Private *SiS_Pr) +SiS_ResetSegmentRegOver(struct SiS_Private *SiS_Pr) { SiS_SetSegmentRegOver(SiS_Pr, 0); } static void -SiS_ResetSegmentRegisters(SiS_Private *SiS_Pr,PSIS_HW_INFO HwInfo) +SiS_ResetSegmentRegisters(struct SiS_Private *SiS_Pr) { - if((IS_SIS65x) || (HwInfo->jChipType >= SIS_661)) { + if((IS_SIS65x) || (SiS_Pr->ChipType >= SIS_661)) { SiS_ResetSegmentReg(SiS_Pr); SiS_ResetSegmentRegOver(SiS_Pr); } @@ -1625,89 +1420,86 @@ SiS_ResetSegmentRegisters(SiS_Private *SiS_Pr,PSIS_HW_INFO HwInfo) /* HELPER: GetVBType */ /*********************************************/ -static void -SiS_GetVBType(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +#ifdef SIS_LINUX_KERNEL +static +#endif +void +SiS_GetVBType(struct SiS_Private *SiS_Pr) { - USHORT flag=0, rev=0, nolcd=0, p4_0f, p4_25, p4_27; - - SiS_Pr->SiS_VBType = 0; - - if((SiS_Pr->SiS_IF_DEF_LVDS) || (SiS_Pr->SiS_IF_DEF_CONEX)) - return; - - flag = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x00); - - if(flag > 3) return; - - rev = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01); - - if(flag >= 2) { - SiS_Pr->SiS_VBType = VB_SIS302B; - } else if(flag == 1) { - if(rev >= 0xC0) { - SiS_Pr->SiS_VBType = VB_SIS301C; - } else if(rev >= 0xB0) { - SiS_Pr->SiS_VBType = VB_SIS301B; - /* Check if 30xB DH version (no LCD support, use Panel Link instead) */ - nolcd = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x23); - if(!(nolcd & 0x02)) SiS_Pr->SiS_VBType |= VB_NoLCD; - } else { - SiS_Pr->SiS_VBType = VB_SIS301; - } - } - if(SiS_Pr->SiS_VBType & (VB_SIS301B | VB_SIS301C | VB_SIS302B)) { - if(rev >= 0xE0) { - flag = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x39); - if(flag == 0xff) SiS_Pr->SiS_VBType = VB_SIS302LV; - else SiS_Pr->SiS_VBType = VB_SIS301C; /* VB_SIS302ELV; */ - } else if(rev >= 0xD0) { - SiS_Pr->SiS_VBType = VB_SIS301LV; - } - } - if(SiS_Pr->SiS_VBType & (VB_301C | VB_301LV | VB_302LV | VB_302ELV)) { - p4_0f = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x0f); - p4_25 = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x25); - p4_27 = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x27); - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x0f,0x7f); - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x25,0x08); - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x27,0xfd); - if(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x08) { - SiS_Pr->SiS_VBType |= VB_UMC; - } - SiS_SetReg(SiS_Pr->SiS_Part4Port,0x27,p4_27); - SiS_SetReg(SiS_Pr->SiS_Part4Port,0x25,p4_25); - SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0f,p4_0f); - } + unsigned short flag = 0, rev = 0, nolcd = 0; + unsigned short p4_0f, p4_25, p4_27; + + SiS_Pr->SiS_VBType = 0; + + if((SiS_Pr->SiS_IF_DEF_LVDS) || (SiS_Pr->SiS_IF_DEF_CONEX)) + return; + + if(SiS_Pr->ChipType == XGI_20) + return; + + flag = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x00); + + if(flag > 3) + return; + + rev = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01); + + if(flag >= 2) { + SiS_Pr->SiS_VBType = VB_SIS302B; + } else if(flag == 1) { + if(rev >= 0xC0) { + SiS_Pr->SiS_VBType = VB_SIS301C; + } else if(rev >= 0xB0) { + SiS_Pr->SiS_VBType = VB_SIS301B; + /* Check if 30xB DH version (no LCD support, use Panel Link instead) */ + nolcd = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x23); + if(!(nolcd & 0x02)) SiS_Pr->SiS_VBType |= VB_NoLCD; + } else { + SiS_Pr->SiS_VBType = VB_SIS301; + } + } + if(SiS_Pr->SiS_VBType & (VB_SIS301B | VB_SIS301C | VB_SIS302B)) { + if(rev >= 0xE0) { + flag = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x39); + if(flag == 0xff) SiS_Pr->SiS_VBType = VB_SIS302LV; + else SiS_Pr->SiS_VBType = VB_SIS301C; /* VB_SIS302ELV; */ + } else if(rev >= 0xD0) { + SiS_Pr->SiS_VBType = VB_SIS301LV; + } + } + if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS301LV | VB_SIS302LV | VB_SIS302ELV)) { + p4_0f = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x0f); + p4_25 = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x25); + p4_27 = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x27); + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x0f,0x7f); + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x25,0x08); + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x27,0xfd); + if(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x08) { + SiS_Pr->SiS_VBType |= VB_UMC; + } + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x27,p4_27); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x25,p4_25); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0f,p4_0f); + } } /*********************************************/ /* HELPER: Check RAM size */ /*********************************************/ -#ifdef LINUX_KERNEL +#ifdef SIS_LINUX_KERNEL static BOOLEAN -SiS_CheckMemorySize(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo, USHORT ModeIdIndex) +SiS_CheckMemorySize(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex) { - USHORT AdapterMemSize = HwInfo->ulVideoMemorySize / (1024*1024); - USHORT memorysize,modeflag; - - if(SiS_Pr->UseCustomMode) { - modeflag = SiS_Pr->CModeFlag; - } else { - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - } - } - - memorysize = modeflag & MemoryInfoFlag; - memorysize >>= MemorySizeShift; /* Get required memory size */ - memorysize++; - - if(AdapterMemSize < memorysize) return FALSE; - return TRUE; + unsigned short AdapterMemSize = SiS_Pr->VideoMemorySize / (1024*1024); + unsigned short modeflag = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex); + unsigned short memorysize = ((modeflag & MemoryInfoFlag) >> MemorySizeShift) + 1; + + if(!AdapterMemSize) return TRUE; + + if(AdapterMemSize < memorysize) return FALSE; + return TRUE; } #endif @@ -1716,63 +1508,65 @@ SiS_CheckMemorySize(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, /*********************************************/ #ifdef SIS315H -static UCHAR -SiS_Get310DRAMType(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +static unsigned char +SiS_Get310DRAMType(struct SiS_Private *SiS_Pr) { - UCHAR data, temp; + unsigned char data; if((*SiS_Pr->pSiS_SoftSetting) & SoftDRAMType) { - data = (*SiS_Pr->pSiS_SoftSetting) & 0x03; + data = (*SiS_Pr->pSiS_SoftSetting) & 0x03; } else { - if(HwInfo->jChipType >= SIS_340) { - /* TODO */ - data = 0; - } if(HwInfo->jChipType >= SIS_661) { - data = SiS_GetReg(SiS_Pr->SiS_P3d4,0x78) & 0x07; - if(SiS_Pr->SiS_ROMNew) { - data = ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x78) & 0xc0) >> 6); - } - } else if(IS_SIS550650740) { - data = SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x07; - } else { /* 315, 330 */ - data = SiS_GetReg(SiS_Pr->SiS_P3c4,0x3a) & 0x03; - if(HwInfo->jChipType == SIS_330) { - if(data > 1) { - temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0x30; - switch(temp) { - case 0x00: data = 1; break; - case 0x10: data = 3; break; - case 0x20: data = 3; break; - case 0x30: data = 2; break; - } - } else { - data = 0; - } - } - } + if(SiS_Pr->ChipType >= XGI_20) { + /* Do I need this? SR17 seems to be zero anyway... */ + data = 0; + } else if(SiS_Pr->ChipType >= SIS_340) { + /* TODO */ + data = 0; + } if(SiS_Pr->ChipType >= SIS_661) { + if(SiS_Pr->SiS_ROMNew) { + data = ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x78) & 0xc0) >> 6); + } else { + data = SiS_GetReg(SiS_Pr->SiS_P3d4,0x78) & 0x07; + } + } else if(IS_SIS550650740) { + data = SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x07; + } else { /* 315, 330 */ + data = SiS_GetReg(SiS_Pr->SiS_P3c4,0x3a) & 0x03; + if(SiS_Pr->ChipType == SIS_330) { + if(data > 1) { + switch(SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0x30) { + case 0x00: data = 1; break; + case 0x10: data = 3; break; + case 0x20: data = 3; break; + case 0x30: data = 2; break; + } + } else { + data = 0; + } + } + } } return data; } -static USHORT -SiS_GetMCLK(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +static unsigned short +SiS_GetMCLK(struct SiS_Private *SiS_Pr) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT index; - - index = SiS_Get310DRAMType(SiS_Pr, HwInfo); - if(HwInfo->jChipType >= SIS_661) { - if(SiS_Pr->SiS_ROMNew) { - return((USHORT)(SISGETROMW((0x90 + (index * 5) + 3)))); - } - return(SiS_Pr->SiS_MCLKData_0[index].CLOCK); - } else if(index >= 4) { - index -= 4; - return(SiS_Pr->SiS_MCLKData_1[index].CLOCK); - } else { - return(SiS_Pr->SiS_MCLKData_0[index].CLOCK); - } + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short index; + + index = SiS_Get310DRAMType(SiS_Pr); + if(SiS_Pr->ChipType >= SIS_661) { + if(SiS_Pr->SiS_ROMNew) { + return((unsigned short)(SISGETROMW((0x90 + (index * 5) + 3)))); + } + return(SiS_Pr->SiS_MCLKData_0[index].CLOCK); + } else if(index >= 4) { + return(SiS_Pr->SiS_MCLKData_1[index - 4].CLOCK); + } else { + return(SiS_Pr->SiS_MCLKData_0[index].CLOCK); + } } #endif @@ -1780,30 +1574,30 @@ SiS_GetMCLK(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) /* HELPER: ClearBuffer */ /*********************************************/ -#ifdef LINUX_KERNEL +#ifdef SIS_LINUX_KERNEL static void -SiS_ClearBuffer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) +SiS_ClearBuffer(struct SiS_Private *SiS_Pr, unsigned short ModeNo) { - UCHAR SISIOMEMTYPE *VideoMemoryAddress = HwInfo->pjVideoMemoryAddress; - ULONG AdapterMemorySize = HwInfo->ulVideoMemorySize; - USHORT SISIOMEMTYPE *pBuffer; - int i; - - if(SiS_Pr->SiS_ModeType >= ModeEGA) { - if(ModeNo > 0x13) { - SiS_SetMemory(VideoMemoryAddress, AdapterMemorySize, 0); - } else { - pBuffer = (USHORT SISIOMEMTYPE *)VideoMemoryAddress; - for(i=0; i<0x4000; i++) writew(0x0000, &pBuffer[i]); - } - } else { - if(SiS_Pr->SiS_ModeType < ModeCGA) { - pBuffer = (USHORT SISIOMEMTYPE *)VideoMemoryAddress; - for(i=0; i<0x4000; i++) writew(0x0720, &pBuffer[i]); - } else { - SiS_SetMemory(VideoMemoryAddress, 0x8000, 0); - } - } + unsigned char SISIOMEMTYPE *memaddr = SiS_Pr->VideoMemoryAddress; + unsigned int memsize = SiS_Pr->VideoMemorySize; + unsigned short SISIOMEMTYPE *pBuffer; + int i; + + if(!memaddr || !memsize) return; + + if(SiS_Pr->SiS_ModeType >= ModeEGA) { + if(ModeNo > 0x13) { + SiS_SetMemory(memaddr, memsize, 0); + } else { + pBuffer = (unsigned short SISIOMEMTYPE *)memaddr; + for(i = 0; i < 0x4000; i++) writew(0x0000, &pBuffer[i]); + } + } else if(SiS_Pr->SiS_ModeType < ModeCGA) { + pBuffer = (unsigned short SISIOMEMTYPE *)memaddr; + for(i = 0; i < 0x4000; i++) writew(0x0720, &pBuffer[i]); + } else { + SiS_SetMemory(memaddr, 0x8000, 0); + } } #endif @@ -1812,35 +1606,36 @@ SiS_ClearBuffer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) /*********************************************/ BOOLEAN -SiS_SearchModeID(SiS_Private *SiS_Pr, USHORT *ModeNo, USHORT *ModeIdIndex) +SiS_SearchModeID(struct SiS_Private *SiS_Pr, unsigned short *ModeNo, + unsigned short *ModeIdIndex) { - UCHAR VGAINFO = SiS_Pr->SiS_VGAINFO; + unsigned char VGAINFO = SiS_Pr->SiS_VGAINFO; - if(*ModeNo <= 0x13) { + if((*ModeNo) <= 0x13) { if((*ModeNo) <= 0x05) (*ModeNo) |= 0x01; - for(*ModeIdIndex = 0; ;(*ModeIdIndex)++) { - if(SiS_Pr->SiS_SModeIDTable[*ModeIdIndex].St_ModeID == (*ModeNo)) break; - if(SiS_Pr->SiS_SModeIDTable[*ModeIdIndex].St_ModeID == 0xFF) return FALSE; + for((*ModeIdIndex) = 0; ;(*ModeIdIndex)++) { + if(SiS_Pr->SiS_SModeIDTable[(*ModeIdIndex)].St_ModeID == (*ModeNo)) break; + if(SiS_Pr->SiS_SModeIDTable[(*ModeIdIndex)].St_ModeID == 0xFF) return FALSE; } - if(*ModeNo == 0x07) { - if(VGAINFO & 0x10) (*ModeIdIndex)++; /* 400 lines */ - /* else 350 lines */ + if((*ModeNo) == 0x07) { + if(VGAINFO & 0x10) (*ModeIdIndex)++; /* 400 lines */ + /* else 350 lines */ } - if(*ModeNo <= 0x03) { - if(!(VGAINFO & 0x80)) (*ModeIdIndex)++; - if(VGAINFO & 0x10) (*ModeIdIndex)++; /* 400 lines */ - /* else 350 lines */ + if((*ModeNo) <= 0x03) { + if(!(VGAINFO & 0x80)) (*ModeIdIndex)++; + if(VGAINFO & 0x10) (*ModeIdIndex)++; /* 400 lines */ + /* else 350 lines */ } /* else 200 lines */ } else { - for(*ModeIdIndex = 0; ;(*ModeIdIndex)++) { - if(SiS_Pr->SiS_EModeIDTable[*ModeIdIndex].Ext_ModeID == (*ModeNo)) break; - if(SiS_Pr->SiS_EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF) return FALSE; + for((*ModeIdIndex) = 0; ;(*ModeIdIndex)++) { + if(SiS_Pr->SiS_EModeIDTable[(*ModeIdIndex)].Ext_ModeID == (*ModeNo)) break; + if(SiS_Pr->SiS_EModeIDTable[(*ModeIdIndex)].Ext_ModeID == 0xFF) return FALSE; } } @@ -1851,10 +1646,10 @@ SiS_SearchModeID(SiS_Private *SiS_Pr, USHORT *ModeNo, USHORT *ModeIdIndex) /* HELPER: GetModePtr */ /*********************************************/ -UCHAR -SiS_GetModePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex) +unsigned short +SiS_GetModePtr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - UCHAR index; + unsigned short index; if(ModeNo <= 0x13) { index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_StTableIndex; @@ -1866,79 +1661,125 @@ SiS_GetModePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex) } /*********************************************/ +/* HELPERS: Get some indices */ +/*********************************************/ + +unsigned short +SiS_GetRefCRTVCLK(struct SiS_Private *SiS_Pr, unsigned short Index, int UseWide) +{ + if(SiS_Pr->SiS_RefIndex[Index].Ext_InfoFlag & HaveWideTiming) { + if(UseWide == 1) { + return SiS_Pr->SiS_RefIndex[Index].Ext_CRTVCLK_WIDE; + } else { + return SiS_Pr->SiS_RefIndex[Index].Ext_CRTVCLK_NORM; + } + } else { + return SiS_Pr->SiS_RefIndex[Index].Ext_CRTVCLK; + } +} + +unsigned short +SiS_GetRefCRT1CRTC(struct SiS_Private *SiS_Pr, unsigned short Index, int UseWide) +{ + if(SiS_Pr->SiS_RefIndex[Index].Ext_InfoFlag & HaveWideTiming) { + if(UseWide == 1) { + return SiS_Pr->SiS_RefIndex[Index].Ext_CRT1CRTC_WIDE; + } else { + return SiS_Pr->SiS_RefIndex[Index].Ext_CRT1CRTC_NORM; + } + } else { + return SiS_Pr->SiS_RefIndex[Index].Ext_CRT1CRTC; + } +} + +/*********************************************/ /* HELPER: LowModeTests */ /*********************************************/ static BOOLEAN -SiS_DoLowModeTest(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_INFO HwInfo) +SiS_DoLowModeTest(struct SiS_Private *SiS_Pr, unsigned short ModeNo) { - USHORT temp,temp1,temp2; - - if((ModeNo != 0x03) && (ModeNo != 0x10) && (ModeNo != 0x12)) - return(TRUE); - temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x11); - SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x11,0x80); - temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x00); - SiS_SetReg(SiS_Pr->SiS_P3d4,0x00,0x55); - temp2 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x00); - SiS_SetReg(SiS_Pr->SiS_P3d4,0x00,temp1); - SiS_SetReg(SiS_Pr->SiS_P3d4,0x11,temp); - if((HwInfo->jChipType >= SIS_315H) || - (HwInfo->jChipType == SIS_300)) { - if(temp2 == 0x55) return(FALSE); - else return(TRUE); - } else { - if(temp2 != 0x55) return(TRUE); - else { - SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01); - return(FALSE); - } - } + unsigned short temp, temp1, temp2; + + if((ModeNo != 0x03) && (ModeNo != 0x10) && (ModeNo != 0x12)) + return TRUE; + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x11); + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x11,0x80); + temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x00); + SiS_SetReg(SiS_Pr->SiS_P3d4,0x00,0x55); + temp2 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x00); + SiS_SetReg(SiS_Pr->SiS_P3d4,0x00,temp1); + SiS_SetReg(SiS_Pr->SiS_P3d4,0x11,temp); + if((SiS_Pr->ChipType >= SIS_315H) || + (SiS_Pr->ChipType == SIS_300)) { + if(temp2 == 0x55) return FALSE; + else return TRUE; + } else { + if(temp2 != 0x55) return TRUE; + else { + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01); + return FALSE; + } + } } static void -SiS_SetLowModeTest(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_INFO HwInfo) +SiS_SetLowModeTest(struct SiS_Private *SiS_Pr, unsigned short ModeNo) { - if(SiS_DoLowModeTest(SiS_Pr, ModeNo, HwInfo)) { - SiS_Pr->SiS_SetFlag |= LowModeTests; - } + if(SiS_DoLowModeTest(SiS_Pr, ModeNo)) { + SiS_Pr->SiS_SetFlag |= LowModeTests; + } } /*********************************************/ -/* HELPER: ENABLE CRT1 */ +/* HELPER: OPEN/CLOSE CRT1 CRTC */ /*********************************************/ static void -SiS_SetupCR5x(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_OpenCRTC(struct SiS_Private *SiS_Pr) +{ + if(IS_SIS650) { + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f); + if(IS_SIS651) SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x51,0x20); + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7); + } else if(IS_SIS661741660760) { + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x61,0xf7); + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f); + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7); + if(!SiS_Pr->SiS_ROMNew) { + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x3a,0xef); + } + } +} + +static void +SiS_CloseCRTC(struct SiS_Private *SiS_Pr) { - if(IS_SIS650) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f); - if(IS_SIS651) SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x51,0x20); - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7); - } - } else if(IS_SIS661741660760) { - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x61,0xf7); - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f); - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7); - if(!SiS_Pr->SiS_ROMNew) { - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x3a,0xef); - } - } +#if 0 /* This locks some CRTC registers. We don't want that. */ + unsigned short temp1 = 0, temp2 = 0; + + if(IS_SIS661741660760) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + temp1 = 0xa0; temp2 = 0x08; + } + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x51,0x1f,temp1); + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x56,0xe7,temp2); + } +#endif } static void -SiS_HandleCRT1(SiS_Private *SiS_Pr) +SiS_HandleCRT1(struct SiS_Private *SiS_Pr) { - /* Enable CRT1 gating */ - SiS_SetRegAND(SiS_Pr->SiS_P3d4,SiS_Pr->SiS_MyCR63,0xbf); + /* Enable CRT1 gating */ + SiS_SetRegAND(SiS_Pr->SiS_P3d4,SiS_Pr->SiS_MyCR63,0xbf); #if 0 - if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x15) & 0x01)) { - if((SiS_GetReg(SiS_Pr->SiS_P3c4,0x15) & 0x0a) || - (SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x01)) { - SiS_SetRegOR(SiS_Pr->SiS_P3d4,SiS_Pr->SiS_MyCR63,0x40); - } - } + if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x15) & 0x01)) { + if((SiS_GetReg(SiS_Pr->SiS_P3c4,0x15) & 0x0a) || + (SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x01)) { + SiS_SetRegOR(SiS_Pr->SiS_P3d4,SiS_Pr->SiS_MyCR63,0x40); + } + } #endif } @@ -1946,57 +1787,54 @@ SiS_HandleCRT1(SiS_Private *SiS_Pr) /* HELPER: GetColorDepth */ /*********************************************/ -USHORT -SiS_GetColorDepth(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex) +unsigned short +SiS_GetColorDepth(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex) { - USHORT ColorDepth[6] = { 1, 2, 4, 4, 6, 8}; - SHORT index; - USHORT modeflag; - - /* Do NOT check UseCustomMode, will skrew up FIFO */ - if(ModeNo == 0xfe) { - modeflag = SiS_Pr->CModeFlag; - } else { - if(ModeNo <= 0x13) - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - else - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - } - - index = (modeflag & ModeTypeMask) - ModeEGA; - if(index < 0) index = 0; - return(ColorDepth[index]); + static const unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 }; + unsigned short modeflag; + short index; + + /* Do NOT check UseCustomMode, will skrew up FIFO */ + if(ModeNo == 0xfe) { + modeflag = SiS_Pr->CModeFlag; + } else if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + } + + index = (modeflag & ModeTypeMask) - ModeEGA; + if(index < 0) index = 0; + return ColorDepth[index]; } /*********************************************/ /* HELPER: GetOffset */ /*********************************************/ -USHORT -SiS_GetOffset(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_INFO HwInfo) +unsigned short +SiS_GetOffset(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex, unsigned short RRTI) { - USHORT xres, temp, colordepth, infoflag; - - if(SiS_Pr->UseCustomMode) { - infoflag = SiS_Pr->CInfoFlag; - xres = SiS_Pr->CHDisplay; - } else { - infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; - xres = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].XRes; - } - - colordepth = SiS_GetColorDepth(SiS_Pr,ModeNo,ModeIdIndex); - - temp = xres / 16; - if(infoflag & InterlaceMode) temp <<= 1; - temp *= colordepth; - if(xres % 16) { - colordepth >>= 1; - temp += colordepth; - } - - return(temp); + unsigned short xres, temp, colordepth, infoflag; + + if(SiS_Pr->UseCustomMode) { + infoflag = SiS_Pr->CInfoFlag; + xres = SiS_Pr->CHDisplay; + } else { + infoflag = SiS_Pr->SiS_RefIndex[RRTI].Ext_InfoFlag; + xres = SiS_Pr->SiS_RefIndex[RRTI].XRes; + } + + colordepth = SiS_GetColorDepth(SiS_Pr, ModeNo, ModeIdIndex); + + temp = xres / 16; + if(infoflag & InterlaceMode) temp <<= 1; + temp *= colordepth; + if(xres % 16) temp += (colordepth >> 1); + + return temp; } /*********************************************/ @@ -2004,55 +1842,29 @@ SiS_GetOffset(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, /*********************************************/ static void -SiS_SetSeqRegs(SiS_Private *SiS_Pr, USHORT StandTableIndex, PSIS_HW_INFO HwInfo) +SiS_SetSeqRegs(struct SiS_Private *SiS_Pr, unsigned short StandTableIndex) { - UCHAR SRdata; - USHORT i; + unsigned char SRdata; + int i; - SiS_SetReg(SiS_Pr->SiS_P3c4,0x00,0x03); /* Set SR0 */ + SiS_SetReg(SiS_Pr->SiS_P3c4,0x00,0x03); - SRdata = SiS_Pr->SiS_StandTable[StandTableIndex].SR[0]; + /* or "display off" */ + SRdata = SiS_Pr->SiS_StandTable[StandTableIndex].SR[0] | 0x20; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - SRdata |= 0x01; - } - if(HwInfo->jChipType >= SIS_661) { - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - SRdata |= 0x01; /* 8 dot clock */ - } - } - } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_Pr->SiS_VBType & VB_NoLCD) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - SRdata |= 0x01; /* 8 dot clock */ - } - } - } - } + /* determine whether to force x8 dotclock */ + if((SiS_Pr->SiS_VBType & VB_SISVB) || (SiS_Pr->SiS_IF_DEF_LVDS)) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - SRdata |= 0x01; /* 8 dot clock */ - } - } - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - SRdata |= 0x01; /* 8 dot clock */ - } - } - } + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) SRdata |= 0x01; + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) SRdata |= 0x01; - SRdata |= 0x20; /* screen off */ + } SiS_SetReg(SiS_Pr->SiS_P3c4,0x01,SRdata); for(i = 2; i <= 4; i++) { - SRdata = SiS_Pr->SiS_StandTable[StandTableIndex].SR[i-1]; + SRdata = SiS_Pr->SiS_StandTable[StandTableIndex].SR[i - 1]; SiS_SetReg(SiS_Pr->SiS_P3c4,i,SRdata); } } @@ -2062,17 +1874,17 @@ SiS_SetSeqRegs(SiS_Private *SiS_Pr, USHORT StandTableIndex, PSIS_HW_INFO HwInfo) /*********************************************/ static void -SiS_SetMiscRegs(SiS_Private *SiS_Pr, USHORT StandTableIndex, PSIS_HW_INFO HwInfo) +SiS_SetMiscRegs(struct SiS_Private *SiS_Pr, unsigned short StandTableIndex) { - UCHAR Miscdata; + unsigned char Miscdata; Miscdata = SiS_Pr->SiS_StandTable[StandTableIndex].MISC; - if(HwInfo->jChipType < SIS_661) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - Miscdata |= 0x0C; - } + if(SiS_Pr->ChipType < SIS_661) { + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + Miscdata |= 0x0C; + } } } @@ -2084,33 +1896,34 @@ SiS_SetMiscRegs(SiS_Private *SiS_Pr, USHORT StandTableIndex, PSIS_HW_INFO HwInfo /*********************************************/ static void -SiS_SetCRTCRegs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT StandTableIndex) +SiS_SetCRTCRegs(struct SiS_Private *SiS_Pr, unsigned short StandTableIndex) { - UCHAR CRTCdata; - USHORT i; - - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); /* Unlock CRTC */ - - for(i = 0; i <= 0x18; i++) { - CRTCdata = SiS_Pr->SiS_StandTable[StandTableIndex].CRTC[i]; - SiS_SetReg(SiS_Pr->SiS_P3d4,i,CRTCdata); /* Set CRTC(3d4) */ - } - if(HwInfo->jChipType >= SIS_661) { - SiS_SetupCR5x(SiS_Pr, HwInfo); - for(i = 0x13; i <= 0x14; i++) { - CRTCdata = SiS_Pr->SiS_StandTable[StandTableIndex].CRTC[i]; - SiS_SetReg(SiS_Pr->SiS_P3d4,i,CRTCdata); - } - } else if( ( (HwInfo->jChipType == SIS_630) || - (HwInfo->jChipType == SIS_730) ) && - (HwInfo->jChipRevision >= 0x30) ) { /* for 630S0 */ - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { - SiS_SetReg(SiS_Pr->SiS_P3d4,0x18,0xFE); - } - } - } + unsigned char CRTCdata; + unsigned short i; + + /* Unlock CRTC */ + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); + + for(i = 0; i <= 0x18; i++) { + CRTCdata = SiS_Pr->SiS_StandTable[StandTableIndex].CRTC[i]; + SiS_SetReg(SiS_Pr->SiS_P3d4,i,CRTCdata); + } + + if(SiS_Pr->ChipType >= SIS_661) { + SiS_OpenCRTC(SiS_Pr); + for(i = 0x13; i <= 0x14; i++) { + CRTCdata = SiS_Pr->SiS_StandTable[StandTableIndex].CRTC[i]; + SiS_SetReg(SiS_Pr->SiS_P3d4,i,CRTCdata); + } + } else if( ( (SiS_Pr->ChipType == SIS_630) || + (SiS_Pr->ChipType == SIS_730) ) && + (SiS_Pr->ChipRevision >= 0x30) ) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { + SiS_SetReg(SiS_Pr->SiS_P3d4,0x18,0xFE); + } + } + } } /*********************************************/ @@ -2118,64 +1931,58 @@ SiS_SetCRTCRegs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, /*********************************************/ static void -SiS_SetATTRegs(SiS_Private *SiS_Pr, USHORT StandTableIndex, - PSIS_HW_INFO HwInfo) +SiS_SetATTRegs(struct SiS_Private *SiS_Pr, unsigned short StandTableIndex) { - UCHAR ARdata; - USHORT i; + unsigned char ARdata; + unsigned short i; for(i = 0; i <= 0x13; i++) { ARdata = SiS_Pr->SiS_StandTable[StandTableIndex].ATTR[i]; -#if 0 - if((i <= 0x0f) || (i == 0x11)) { - if(ds:489 & 0x08) { - continue; - } - } -#endif + if(i == 0x13) { - /* Pixel shift. If screen on LCD or TV is shifted left or right, - * this might be the cause. - */ - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) ARdata=0; - } - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) ARdata=0; - } - } - } - if(HwInfo->jChipType >= SIS_661) { + /* Pixel shift. If screen on LCD or TV is shifted left or right, + * this might be the cause. + */ + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) ARdata = 0; + } + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) ARdata = 0; + } + } + } + if(SiS_Pr->ChipType >= SIS_661) { if(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV | SetCRT2ToLCD)) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) ARdata=0; + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) ARdata = 0; } } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->ChipType >= SIS_315H) { if(IS_SIS550650740660) { - /* 315, 330 don't do this */ - if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) ARdata=0; - } else { - ARdata = 0; - } + /* 315, 330 don't do this */ + if(SiS_Pr->SiS_VBType & VB_SIS30xB) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) ARdata = 0; + } else { + ARdata = 0; + } } } else { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) ARdata=0; + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) ARdata = 0; } - } + } } - SiS_GetRegByte(SiS_Pr->SiS_P3da); /* reset 3da */ - SiS_SetRegByte(SiS_Pr->SiS_P3c0,i); /* set index */ - SiS_SetRegByte(SiS_Pr->SiS_P3c0,ARdata); /* set data */ + SiS_GetRegByte(SiS_Pr->SiS_P3da); /* reset 3da */ + SiS_SetRegByte(SiS_Pr->SiS_P3c0,i); /* set index */ + SiS_SetRegByte(SiS_Pr->SiS_P3c0,ARdata); /* set data */ } - SiS_GetRegByte(SiS_Pr->SiS_P3da); /* reset 3da */ - SiS_SetRegByte(SiS_Pr->SiS_P3c0,0x14); /* set index */ - SiS_SetRegByte(SiS_Pr->SiS_P3c0,0x00); /* set data */ + + SiS_GetRegByte(SiS_Pr->SiS_P3da); /* reset 3da */ + SiS_SetRegByte(SiS_Pr->SiS_P3c0,0x14); /* set index */ + SiS_SetRegByte(SiS_Pr->SiS_P3c0,0x00); /* set data */ SiS_GetRegByte(SiS_Pr->SiS_P3da); - SiS_SetRegByte(SiS_Pr->SiS_P3c0,0x20); /* Enable Attribute */ + SiS_SetRegByte(SiS_Pr->SiS_P3c0,0x20); /* Enable Attribute */ SiS_GetRegByte(SiS_Pr->SiS_P3da); } @@ -2184,10 +1991,10 @@ SiS_SetATTRegs(SiS_Private *SiS_Pr, USHORT StandTableIndex, /*********************************************/ static void -SiS_SetGRCRegs(SiS_Private *SiS_Pr, USHORT StandTableIndex) +SiS_SetGRCRegs(struct SiS_Private *SiS_Pr, unsigned short StandTableIndex) { - UCHAR GRdata; - USHORT i; + unsigned char GRdata; + unsigned short i; for(i = 0; i <= 0x08; i++) { GRdata = SiS_Pr->SiS_StandTable[StandTableIndex].GRC[i]; @@ -2205,22 +2012,22 @@ SiS_SetGRCRegs(SiS_Private *SiS_Pr, USHORT StandTableIndex) /*********************************************/ static void -SiS_ClearExt1Regs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) +SiS_ClearExt1Regs(struct SiS_Private *SiS_Pr, unsigned short ModeNo) { - USHORT i; + unsigned short i; - for(i = 0x0A; i <= 0x0E; i++) { - SiS_SetReg(SiS_Pr->SiS_P3c4,i,0x00); - } + for(i = 0x0A; i <= 0x0E; i++) { + SiS_SetReg(SiS_Pr->SiS_P3c4,i,0x00); + } - if(HwInfo->jChipType >= SIS_315H) { - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x37,0xFE); - if(ModeNo <= 0x13) { - if(ModeNo == 0x06 || ModeNo >= 0x0e) { - SiS_SetReg(SiS_Pr->SiS_P3c4,0x0e,0x20); - } - } - } + if(SiS_Pr->ChipType >= SIS_315H) { + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x37,0xFE); + if(ModeNo <= 0x13) { + if(ModeNo == 0x06 || ModeNo >= 0x0e) { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x0e,0x20); + } + } + } } /*********************************************/ @@ -2228,32 +2035,24 @@ SiS_ClearExt1Regs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) /*********************************************/ static void -SiS_ResetCRT1VCLK(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_ResetCRT1VCLK(struct SiS_Private *SiS_Pr) { - if(HwInfo->jChipType >= SIS_315H) { - if(HwInfo->jChipType < SIS_661) { - if(SiS_Pr->SiS_IF_DEF_LVDS == 0) return; + if(SiS_Pr->ChipType >= SIS_315H) { + if(SiS_Pr->ChipType < SIS_661) { + if(SiS_Pr->SiS_IF_DEF_LVDS == 0) return; } } else { if((SiS_Pr->SiS_IF_DEF_LVDS == 0) && - (!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) ) { + (!(SiS_Pr->SiS_VBType & VB_SIS30xBLV)) ) { return; } } - if(HwInfo->jChipType >= SIS_315H) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x31,0xCF,0x20); - } else { - SiS_SetReg(SiS_Pr->SiS_P3c4,0x31,0x20); - } + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x31,0xcf,0x20); SiS_SetReg(SiS_Pr->SiS_P3c4,0x2B,SiS_Pr->SiS_VCLKData[1].SR2B); SiS_SetReg(SiS_Pr->SiS_P3c4,0x2C,SiS_Pr->SiS_VCLKData[1].SR2C); SiS_SetReg(SiS_Pr->SiS_P3c4,0x2D,0x80); - if(HwInfo->jChipType >= SIS_315H) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x31,0xcf,0x10); - } else { - SiS_SetReg(SiS_Pr->SiS_P3c4,0x31,0x10); - } + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x31,0xcf,0x10); SiS_SetReg(SiS_Pr->SiS_P3c4,0x2B,SiS_Pr->SiS_VCLKData[0].SR2B); SiS_SetReg(SiS_Pr->SiS_P3c4,0x2C,SiS_Pr->SiS_VCLKData[0].SR2C); SiS_SetReg(SiS_Pr->SiS_P3c4,0x2D,0x80); @@ -2264,19 +2063,19 @@ SiS_ResetCRT1VCLK(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) /*********************************************/ static void -SiS_SetCRT1Sync(SiS_Private *SiS_Pr, USHORT RefreshRateTableIndex) +SiS_SetCRT1Sync(struct SiS_Private *SiS_Pr, unsigned short RRTI) { - USHORT sync; + unsigned short sync; - if(SiS_Pr->UseCustomMode) { - sync = SiS_Pr->CInfoFlag >> 8; - } else { - sync = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8; - } + if(SiS_Pr->UseCustomMode) { + sync = SiS_Pr->CInfoFlag >> 8; + } else { + sync = SiS_Pr->SiS_RefIndex[RRTI].Ext_InfoFlag >> 8; + } - sync &= 0xC0; - sync |= 0x2f; - SiS_SetRegByte(SiS_Pr->SiS_P3c2,sync); + sync &= 0xC0; + sync |= 0x2f; + SiS_SetRegByte(SiS_Pr->SiS_P3c2,sync); } /*********************************************/ @@ -2284,72 +2083,67 @@ SiS_SetCRT1Sync(SiS_Private *SiS_Pr, USHORT RefreshRateTableIndex) /*********************************************/ static void -SiS_SetCRT1CRTC(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, - PSIS_HW_INFO HwInfo) +SiS_SetCRT1CRTC(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex, unsigned short RRTI) { - UCHAR index; - USHORT temp,i,j,modeflag; - - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); /* unlock cr0-7 */ - - if(SiS_Pr->UseCustomMode) { - - modeflag = SiS_Pr->CModeFlag; - - for(i=0,j=0;i<=7;i++,j++) { - SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->CCRT1CRTC[i]); - } - for(j=0x10;i<=10;i++,j++) { - SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->CCRT1CRTC[i]); - } - for(j=0x15;i<=12;i++,j++) { - SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->CCRT1CRTC[i]); - } - for(j=0x0A;i<=15;i++,j++) { - SiS_SetReg(SiS_Pr->SiS_P3c4,j,SiS_Pr->CCRT1CRTC[i]); - } - - temp = SiS_Pr->CCRT1CRTC[16] & 0xE0; - SiS_SetReg(SiS_Pr->SiS_P3c4,0x0E,temp); - - temp = (SiS_Pr->CCRT1CRTC[16] & 0x01) << 5; - if(modeflag & DoubleScanMode) temp |= 0x80; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0x5F,temp); - - } else { - - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - } - - index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; - - for(i=0,j=0;i<=7;i++,j++) { - SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->SiS_CRT1Table[index].CR[i]); - } - for(j=0x10;i<=10;i++,j++) { - SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->SiS_CRT1Table[index].CR[i]); - } - for(j=0x15;i<=12;i++,j++) { - SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->SiS_CRT1Table[index].CR[i]); - } - for(j=0x0A;i<=15;i++,j++) { - SiS_SetReg(SiS_Pr->SiS_P3c4,j,SiS_Pr->SiS_CRT1Table[index].CR[i]); - } - - temp = SiS_Pr->SiS_CRT1Table[index].CR[16] & 0xE0; - SiS_SetReg(SiS_Pr->SiS_P3c4,0x0E,temp); - - temp = ((SiS_Pr->SiS_CRT1Table[index].CR[16]) & 0x01) << 5; - if(modeflag & DoubleScanMode) temp |= 0x80; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0x5F,temp); - - } - - if(SiS_Pr->SiS_ModeType > ModeVGA) SiS_SetReg(SiS_Pr->SiS_P3d4,0x14,0x4F); + unsigned short temp, i, j, modeflag; + unsigned char *crt1data = NULL; + + modeflag = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex); + + if(SiS_Pr->UseCustomMode) { + + crt1data = &SiS_Pr->CCRT1CRTC[0]; + + } else { + + temp = SiS_GetRefCRT1CRTC(SiS_Pr, RRTI, SiS_Pr->SiS_UseWide); + + /* Alternate for 1600x1200 LCDA */ + if((temp == 0x20) && (SiS_Pr->Alternate1600x1200)) temp = 0x57; + + crt1data = (unsigned char *)&SiS_Pr->SiS_CRT1Table[temp].CR[0]; + + } + + /* unlock cr0-7 */ + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); + + for(i = 0, j = 0; i <= 7; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_P3d4,j,crt1data[i]); + } + for(j = 0x10; i <= 10; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_P3d4,j,crt1data[i]); + } + for(j = 0x15; i <= 12; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_P3d4,j,crt1data[i]); + } + for(j = 0x0A; i <= 15; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_P3c4,j,crt1data[i]); + } + + SiS_SetReg(SiS_Pr->SiS_P3c4,0x0E,crt1data[16] & 0xE0); + + temp = (crt1data[16] & 0x01) << 5; + if(modeflag & DoubleScanMode) temp |= 0x80; + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0x5F,temp); + + if(SiS_Pr->SiS_ModeType > ModeVGA) { + SiS_SetReg(SiS_Pr->SiS_P3d4,0x14,0x4F); + } + +#ifdef SIS315H + if(SiS_Pr->ChipType == XGI_20) { + SiS_SetReg(SiS_Pr->SiS_P3d4,0x04,crt1data[4] - 1); + if(!(temp = crt1data[5] & 0x1f)) { + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x0c,0xfb); + } + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x05,0xe0,((temp - 1) & 0x1f)); + temp = (crt1data[16] >> 5) + 3; + if(temp > 7) temp -= 7; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0e,0x1f,(temp << 5)); + } +#endif } /*********************************************/ @@ -2359,33 +2153,32 @@ SiS_SetCRT1CRTC(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /*********************************************/ static void -SiS_SetCRT1Offset(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, - PSIS_HW_INFO HwInfo) +SiS_SetCRT1Offset(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex, unsigned short RRTI) { - USHORT temp, DisplayUnit, infoflag; + unsigned short temp, DisplayUnit, infoflag; if(SiS_Pr->UseCustomMode) { infoflag = SiS_Pr->CInfoFlag; } else { - infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; + infoflag = SiS_Pr->SiS_RefIndex[RRTI].Ext_InfoFlag; } - DisplayUnit = SiS_GetOffset(SiS_Pr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwInfo); + DisplayUnit = SiS_GetOffset(SiS_Pr, ModeNo, ModeIdIndex, RRTI); temp = (DisplayUnit >> 8) & 0x0f; SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0xF0,temp); - temp = DisplayUnit & 0xFF; - SiS_SetReg(SiS_Pr->SiS_P3d4,0x13,temp); + SiS_SetReg(SiS_Pr->SiS_P3d4,0x13,DisplayUnit & 0xFF); if(infoflag & InterlaceMode) DisplayUnit >>= 1; DisplayUnit <<= 5; - temp = (DisplayUnit & 0xff00) >> 8; + temp = (DisplayUnit >> 8) + 1; if(DisplayUnit & 0xff) temp++; - temp++; + if(SiS_Pr->ChipType == XGI_20) { + if(ModeNo == 0x4a || ModeNo == 0x49) temp--; + } SiS_SetReg(SiS_Pr->SiS_P3c4,0x10,temp); } @@ -2394,39 +2187,49 @@ SiS_SetCRT1Offset(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /*********************************************/ static void -SiS_SetCRT1VCLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo, USHORT RefreshRateTableIndex) +SiS_SetCRT1VCLK(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex, unsigned short RRTI) { - USHORT index=0, clka, clkb; - - if(SiS_Pr->UseCustomMode) { - clka = SiS_Pr->CSR2B; - clkb = SiS_Pr->CSR2C; - } else { - index = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); - if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - clka = SiS_Pr->SiS_VBVCLKData[index].Part4_A; - clkb = SiS_Pr->SiS_VBVCLKData[index].Part4_B; - } else { - clka = SiS_Pr->SiS_VCLKData[index].SR2B; - clkb = SiS_Pr->SiS_VCLKData[index].SR2C; - } - } - - if(HwInfo->jChipType >= SIS_315H) { - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x31,0xCF); - } else { - SiS_SetReg(SiS_Pr->SiS_P3c4,0x31,0x00); - } - - SiS_SetReg(SiS_Pr->SiS_P3c4,0x2B,clka); - SiS_SetReg(SiS_Pr->SiS_P3c4,0x2C,clkb); - - if(HwInfo->jChipType >= SIS_315H) { - SiS_SetReg(SiS_Pr->SiS_P3c4,0x2D,0x01); - } else { - SiS_SetReg(SiS_Pr->SiS_P3c4,0x2D,0x80); - } + unsigned short index = 0, clka, clkb; + + if(SiS_Pr->UseCustomMode) { + clka = SiS_Pr->CSR2B; + clkb = SiS_Pr->CSR2C; + } else { + index = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RRTI); + if((SiS_Pr->SiS_VBType & VB_SIS30xBLV) && + (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + /* Alternate for 1600x1200 LCDA */ + if((index == 0x21) && (SiS_Pr->Alternate1600x1200)) index = 0x72; + clka = SiS_Pr->SiS_VBVCLKData[index].Part4_A; + clkb = SiS_Pr->SiS_VBVCLKData[index].Part4_B; + } else { + clka = SiS_Pr->SiS_VCLKData[index].SR2B; + clkb = SiS_Pr->SiS_VCLKData[index].SR2C; + } + } + + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x31,0xCF); + + SiS_SetReg(SiS_Pr->SiS_P3c4,0x2b,clka); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x2c,clkb); + + if(SiS_Pr->ChipType >= SIS_315H) { +#ifdef SIS315H + SiS_SetReg(SiS_Pr->SiS_P3c4,0x2D,0x01); + if(SiS_Pr->ChipType == XGI_20) { + unsigned short mf = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex); + if(mf & HalfDCLK) { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x2b,SiS_GetReg(SiS_Pr->SiS_P3c4,0x2b)); + clkb = SiS_GetReg(SiS_Pr->SiS_P3c4,0x2c); + clkb = (((clkb & 0x1f) << 1) + 1) | (clkb & 0xe0); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x2c,clkb); + } + } +#endif + } else { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x2D,0x80); + } } /*********************************************/ @@ -2434,415 +2237,358 @@ SiS_SetCRT1VCLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /*********************************************/ #ifdef SIS300 -static USHORT -SiS_DoCalcDelay(SiS_Private *SiS_Pr, USHORT MCLK, USHORT VCLK, USHORT colordepth, USHORT key) +void +SiS_GetFIFOThresholdIndex300(struct SiS_Private *SiS_Pr, unsigned short *idx1, + unsigned short *idx2) +{ + unsigned short temp1, temp2; + static const unsigned char ThTiming[8] = { + 1, 2, 2, 3, 0, 1, 1, 2 + }; + + temp1 = temp2 = (SiS_GetReg(SiS_Pr->SiS_P3c4,0x18) & 0x62) >> 1; + (*idx2) = (unsigned short)(ThTiming[((temp2 >> 3) | temp1) & 0x07]); + (*idx1) = (unsigned short)(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) >> 6) & 0x03; + (*idx1) |= (unsigned short)(((SiS_GetReg(SiS_Pr->SiS_P3c4,0x14) >> 4) & 0x0c)); + (*idx1) <<= 1; +} + +static unsigned short +SiS_GetFIFOThresholdA300(unsigned short idx1, unsigned short idx2) +{ + static const unsigned char ThLowA[8 * 3] = { + 61, 3,52, 5,68, 7,100,11, + 43, 3,42, 5,54, 7, 78,11, + 34, 3,37, 5,47, 7, 67,11 + }; + + return (unsigned short)((ThLowA[idx1 + 1] * idx2) + ThLowA[idx1]); +} + +unsigned short +SiS_GetFIFOThresholdB300(unsigned short idx1, unsigned short idx2) +{ + static const unsigned char ThLowB[8 * 3] = { + 81, 4,72, 6,88, 8,120,12, + 55, 4,54, 6,66, 8, 90,12, + 42, 4,45, 6,55, 8, 75,12 + }; + + return (unsigned short)((ThLowB[idx1 + 1] * idx2) + ThLowB[idx1]); +} + +static unsigned short +SiS_DoCalcDelay(struct SiS_Private *SiS_Pr, unsigned short MCLK, unsigned short VCLK, + unsigned short colordepth, unsigned short key) { - const UCHAR ThLowA[] = { 61, 3,52, 5,68, 7,100,11, - 43, 3,42, 5,54, 7, 78,11, - 34, 3,37, 5,47, 7, 67,11 }; - - const UCHAR ThLowB[] = { 81, 4,72, 6,88, 8,120,12, - 55, 4,54, 6,66, 8, 90,12, - 42, 4,45, 6,55, 8, 75,12 }; - - const UCHAR ThTiming[] = { 1, 2, 2, 3, 0, 1, 1, 2 }; - - USHORT tempah, tempal, tempcl, tempbx, temp; - ULONG longtemp; - - tempah = SiS_GetReg(SiS_Pr->SiS_P3c4,0x18); - tempah &= 0x62; - tempah >>= 1; - tempal = tempah; - tempah >>= 3; - tempal |= tempah; - tempal &= 0x07; - tempcl = ThTiming[tempal]; - tempbx = SiS_GetReg(SiS_Pr->SiS_P3c4,0x16); - tempbx >>= 6; - tempah = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); - tempah >>= 4; - tempah &= 0x0c; - tempbx |= tempah; - tempbx <<= 1; - if(key == 0) { - tempal = ThLowA[tempbx + 1]; - tempal *= tempcl; - tempal += ThLowA[tempbx]; - } else { - tempal = ThLowB[tempbx + 1]; - tempal *= tempcl; - tempal += ThLowB[tempbx]; - } - longtemp = tempal * VCLK * colordepth; - temp = longtemp % (MCLK * 16); - longtemp /= (MCLK * 16); - if(temp) longtemp++; - return((USHORT)longtemp); + unsigned short idx1, idx2; + unsigned int longtemp = VCLK * colordepth; + + SiS_GetFIFOThresholdIndex300(SiS_Pr, &idx1, &idx2); + + if(key == 0) { + longtemp *= SiS_GetFIFOThresholdA300(idx1, idx2); + } else { + longtemp *= SiS_GetFIFOThresholdB300(idx1, idx2); + } + idx1 = longtemp % (MCLK * 16); + longtemp /= (MCLK * 16); + if(idx1) longtemp++; + return (unsigned short)longtemp; } -static USHORT -SiS_CalcDelay(SiS_Private *SiS_Pr, USHORT VCLK, USHORT colordepth, USHORT MCLK) +static unsigned short +SiS_CalcDelay(struct SiS_Private *SiS_Pr, unsigned short VCLK, + unsigned short colordepth, unsigned short MCLK) { - USHORT tempax, tempbx; - - tempbx = SiS_DoCalcDelay(SiS_Pr, MCLK, VCLK, colordepth, 0); - tempax = SiS_DoCalcDelay(SiS_Pr, MCLK, VCLK, colordepth, 1); - if(tempax < 4) tempax = 4; - tempax -= 4; - if(tempbx < tempax) tempbx = tempax; - return(tempbx); + unsigned short temp1, temp2; + + temp2 = SiS_DoCalcDelay(SiS_Pr, MCLK, VCLK, colordepth, 0); + temp1 = SiS_DoCalcDelay(SiS_Pr, MCLK, VCLK, colordepth, 1); + if(temp1 < 4) temp1 = 4; + temp1 -= 4; + if(temp2 < temp1) temp2 = temp1; + return temp2; } static void -SiS_SetCRT1FIFO_300(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_INFO HwInfo, - USHORT RefreshRateTableIndex) +SiS_SetCRT1FIFO_300(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short RefreshRateTableIndex) +{ + unsigned short ThresholdLow = 0; + unsigned short temp, index, VCLK, MCLK, colorth; + static const unsigned short colortharray[6] = { 1, 1, 2, 2, 3, 4 }; + + if(ModeNo > 0x13) { + + /* Get VCLK */ + if(SiS_Pr->UseCustomMode) { + VCLK = SiS_Pr->CSRClock; + } else { + index = SiS_GetRefCRTVCLK(SiS_Pr, RefreshRateTableIndex, SiS_Pr->SiS_UseWide); + VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; + } + + /* Get half colordepth */ + colorth = colortharray[(SiS_Pr->SiS_ModeType - ModeEGA)]; + + /* Get MCLK */ + index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x3A) & 0x07; + MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; + + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35) & 0xc3; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x16,0x3c,temp); + + do { + ThresholdLow = SiS_CalcDelay(SiS_Pr, VCLK, colorth, MCLK) + 1; + if(ThresholdLow < 0x13) break; + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x16,0xfc); + ThresholdLow = 0x13; + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) >> 6; + if(!temp) break; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x16,0x3f,((temp - 1) << 6)); + } while(0); + + } else ThresholdLow = 2; + + /* Write CRT/CPU threshold low, CRT/Engine threshold high */ + temp = (ThresholdLow << 4) | 0x0f; + SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,temp); + + temp = (ThresholdLow & 0x10) << 1; + if(ModeNo > 0x13) temp |= 0x40; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0f,0x9f,temp); + + /* What is this? */ + SiS_SetReg(SiS_Pr->SiS_P3c4,0x3B,0x09); + + /* Write CRT/CPU threshold high */ + temp = ThresholdLow + 3; + if(temp > 0x0f) temp = 0x0f; + SiS_SetReg(SiS_Pr->SiS_P3c4,0x09,temp); +} + +unsigned short +SiS_GetLatencyFactor630(struct SiS_Private *SiS_Pr, unsigned short index) { - USHORT ThresholdLow = 0; - USHORT index, VCLK, MCLK, colorth=0; - USHORT tempah, temp; - - if(ModeNo > 0x13) { - - if(SiS_Pr->UseCustomMode) { - VCLK = SiS_Pr->CSRClock; - } else { - index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; - index &= 0x3F; - VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ - } - - switch (SiS_Pr->SiS_ModeType - ModeEGA) { /* Get half colordepth */ - case 0 : colorth = 1; break; - case 1 : colorth = 1; break; - case 2 : colorth = 2; break; - case 3 : colorth = 2; break; - case 4 : colorth = 3; break; - case 5 : colorth = 4; break; - } - - index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x3A); - index &= 0x07; - MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; /* Get MCLK */ - - tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); - tempah &= 0xc3; - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x16,0x3c,tempah); - - do { - ThresholdLow = SiS_CalcDelay(SiS_Pr, VCLK, colorth, MCLK); - ThresholdLow++; - if(ThresholdLow < 0x13) break; - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x16,0xfc); - ThresholdLow = 0x13; - tempah = SiS_GetReg(SiS_Pr->SiS_P3c4,0x16); - tempah >>= 6; - if(!(tempah)) break; - tempah--; - tempah <<= 6; - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x16,0x3f,tempah); - } while(0); - - } else ThresholdLow = 2; - - /* Write CRT/CPU threshold low, CRT/Engine threshold high */ - temp = (ThresholdLow << 4) | 0x0f; - SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,temp); - - temp = (ThresholdLow & 0x10) << 1; - if(ModeNo > 0x13) temp |= 0x40; - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0f,0x9f,temp); - - /* What is this? */ - SiS_SetReg(SiS_Pr->SiS_P3c4,0x3B,0x09); - - /* Write CRT/CPU threshold high */ - temp = ThresholdLow + 3; - if(temp > 0x0f) temp = 0x0f; - SiS_SetReg(SiS_Pr->SiS_P3c4,0x09,temp); + static const unsigned char LatencyFactor[] = { + 97, 88, 86, 79, 77, 0, /* 64 bit BQ=2 */ + 0, 87, 85, 78, 76, 54, /* 64 bit BQ=1 */ + 97, 88, 86, 79, 77, 0, /* 128 bit BQ=2 */ + 0, 79, 77, 70, 68, 48, /* 128 bit BQ=1 */ + 80, 72, 69, 63, 61, 0, /* 64 bit BQ=2 */ + 0, 70, 68, 61, 59, 37, /* 64 bit BQ=1 */ + 86, 77, 75, 68, 66, 0, /* 128 bit BQ=2 */ + 0, 68, 66, 59, 57, 37 /* 128 bit BQ=1 */ + }; + static const unsigned char LatencyFactor730[] = { + 69, 63, 61, + 86, 79, 77, + 103, 96, 94, + 120,113,111, + 137,130,128 + }; + + if(SiS_Pr->ChipType == SIS_730) { + return (unsigned short)LatencyFactor730[index]; + } else { + return (unsigned short)LatencyFactor[index]; + } } -static USHORT -SiS_CalcDelay2(SiS_Private *SiS_Pr, UCHAR key, PSIS_HW_INFO HwInfo) +static unsigned short +SiS_CalcDelay2(struct SiS_Private *SiS_Pr, unsigned char key) { - USHORT data,index; - const UCHAR LatencyFactor[] = { - 97, 88, 86, 79, 77, 00, /*; 64 bit BQ=2 */ - 00, 87, 85, 78, 76, 54, /*; 64 bit BQ=1 */ - 97, 88, 86, 79, 77, 00, /*; 128 bit BQ=2 */ - 00, 79, 77, 70, 68, 48, /*; 128 bit BQ=1 */ - 80, 72, 69, 63, 61, 00, /*; 64 bit BQ=2 */ - 00, 70, 68, 61, 59, 37, /*; 64 bit BQ=1 */ - 86, 77, 75, 68, 66, 00, /*; 128 bit BQ=2 */ - 00, 68, 66, 59, 57, 37 /*; 128 bit BQ=1 */ - }; - const UCHAR LatencyFactor730[] = { - 69, 63, 61, - 86, 79, 77, - 103, 96, 94, - 120,113,111, - 137,130,128, /* --- Table ends with this entry, data below */ - 137,130,128, /* to avoid using illegal values */ - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - }; - - if(HwInfo->jChipType == SIS_730) { - index = ((key & 0x0f) * 3) + ((key & 0xC0) >> 6); - data = LatencyFactor730[index]; - } else { - index = (key & 0xE0) >> 5; - if(key & 0x10) index +=6; - if(!(key & 0x01)) index += 24; - data = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); - if(data & 0x0080) index += 12; - data = LatencyFactor[index]; - } - return(data); + unsigned short index; + + if(SiS_Pr->ChipType == SIS_730) { + index = ((key & 0x0f) * 3) + ((key & 0xc0) >> 6); + } else { + index = (key & 0xe0) >> 5; + if(key & 0x10) index += 6; + if(!(key & 0x01)) index += 24; + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x14) & 0x80) index += 12; + } + return SiS_GetLatencyFactor630(SiS_Pr, index); } static void -SiS_SetCRT1FIFO_630(SiS_Private *SiS_Pr, USHORT ModeNo, - PSIS_HW_INFO HwInfo, - USHORT RefreshRateTableIndex) +SiS_SetCRT1FIFO_630(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short RefreshRateTableIndex) { - USHORT i,index,data,VCLK,MCLK,colorth=0; - ULONG B,eax,bl,data2; - USHORT ThresholdLow=0; - UCHAR FQBQData[]= { - 0x01,0x21,0x41,0x61,0x81, - 0x31,0x51,0x71,0x91,0xb1, - 0x00,0x20,0x40,0x60,0x80, - 0x30,0x50,0x70,0x90,0xb0, - 0xFF - }; - UCHAR FQBQData730[]= { - 0x34,0x74,0xb4, - 0x23,0x63,0xa3, - 0x12,0x52,0x92, - 0x01,0x41,0x81, - 0x00,0x40,0x80, - 0xff - }; - - i=0; - if(ModeNo > 0x13) { - if(SiS_Pr->UseCustomMode) { - VCLK = SiS_Pr->CSRClock; - } else { - index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; - index &= 0x3F; - VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ - } - - index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1A); - index &= 0x07; - MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; /* Get MCLK */ - - data2 = SiS_Pr->SiS_ModeType - ModeEGA; /* Get half colordepth */ - switch (data2) { - case 0 : colorth = 1; break; - case 1 : colorth = 1; break; - case 2 : colorth = 2; break; - case 3 : colorth = 2; break; - case 4 : colorth = 3; break; - case 5 : colorth = 4; break; - } - - if(HwInfo->jChipType == SIS_730) { - - do { - B = SiS_CalcDelay2(SiS_Pr, FQBQData730[i], HwInfo) * VCLK * colorth; - bl = B / (MCLK * 16); - - if(B == bl * 16 * MCLK) { - bl = bl + 1; - } else { - bl = bl + 2; - } - - if(bl > 0x13) { - if(FQBQData730[i+1] == 0xFF) { - ThresholdLow = 0x13; - break; - } - i++; - } else { - ThresholdLow = bl; - break; - } - } while(FQBQData730[i] != 0xFF); + unsigned short ThresholdLow = 0; + unsigned short i, data, VCLK, MCLK16, colorth = 0; + unsigned int templ, datal; + const unsigned char *queuedata = NULL; + static const unsigned char FQBQData[21] = { + 0x01,0x21,0x41,0x61,0x81, + 0x31,0x51,0x71,0x91,0xb1, + 0x00,0x20,0x40,0x60,0x80, + 0x30,0x50,0x70,0x90,0xb0, + 0xff + }; + static const unsigned char FQBQData730[16] = { + 0x34,0x74,0xb4, + 0x23,0x63,0xa3, + 0x12,0x52,0x92, + 0x01,0x41,0x81, + 0x00,0x40,0x80, + 0xff + }; + static const unsigned short colortharray[6] = { + 1, 1, 2, 2, 3, 4 + }; - } else { + i = 0; - do { - B = SiS_CalcDelay2(SiS_Pr, FQBQData[i], HwInfo) * VCLK * colorth; - bl = B / (MCLK * 16); + if(ModeNo > 0x13) { - if(B == bl * 16 * MCLK) { - bl = bl + 1; - } else { - bl = bl + 2; - } + /* Get VCLK */ + if(SiS_Pr->UseCustomMode) { + VCLK = SiS_Pr->CSRClock; + } else { + data = SiS_GetRefCRTVCLK(SiS_Pr, RefreshRateTableIndex, SiS_Pr->SiS_UseWide); + VCLK = SiS_Pr->SiS_VCLKData[data].CLOCK; + } - if(bl > 0x13) { - if(FQBQData[i+1] == 0xFF) { - ThresholdLow = 0x13; - break; - } - i++; - } else { - ThresholdLow = bl; - break; - } - } while(FQBQData[i] != 0xFF); - } - } - else { - if(HwInfo->jChipType == SIS_730) { - } else { - i = 9; - } - ThresholdLow = 0x02; - } + /* Get MCLK * 16 */ + data = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1A) & 0x07; + MCLK16 = SiS_Pr->SiS_MCLKData_0[data].CLOCK * 16; + + /* Get half colordepth */ + colorth = colortharray[(SiS_Pr->SiS_ModeType - ModeEGA)]; + + if(SiS_Pr->ChipType == SIS_730) { + queuedata = &FQBQData730[0]; + } else { + queuedata = &FQBQData[0]; + } + + do { + templ = SiS_CalcDelay2(SiS_Pr, queuedata[i]) * VCLK * colorth; + + datal = templ % MCLK16; + templ = (templ / MCLK16) + 1; + if(datal) templ++; + + if(templ > 0x13) { + if(queuedata[i + 1] == 0xFF) { + ThresholdLow = 0x13; + break; + } + i++; + } else { + ThresholdLow = templ; + break; + } + } while(queuedata[i] != 0xFF); + + } else { + + if(SiS_Pr->ChipType != SIS_730) i = 9; + ThresholdLow = 0x02; + + } + + /* Write CRT/CPU threshold low, CRT/Engine threshold high */ + data = ((ThresholdLow & 0x0f) << 4) | 0x0f; + SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,data); + + data = (ThresholdLow & 0x10) << 1; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xDF,data); + + /* What is this? */ + SiS_SetReg(SiS_Pr->SiS_P3c4,0x3B,0x09); + + /* Write CRT/CPU threshold high (gap = 3) */ + data = ThresholdLow + 3; + if(data > 0x0f) data = 0x0f; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x09,0x80,data); /* Write foreground and background queue */ - if(HwInfo->jChipType == SIS_730) { - - data2 = FQBQData730[i]; - data2 = (data2 & 0xC0) >> 5; - data2 <<= 8; - -#ifdef LINUX_KERNEL - SiS_SetRegLong(0xcf8,0x80000050); - eax = SiS_GetRegLong(0xcfc); - eax &= 0xfffff9ff; - eax |= data2; - SiS_SetRegLong(0xcfc,eax); +#ifdef SIS_LINUX_KERNEL + templ = sisfb_read_nbridge_pci_dword(SiS_Pr, 0x50); #else - /* We use pci functions X offers. We use pcitag 0, because - * we want to read/write to the host bridge (which is always - * 00:00.0 on 630, 730 and 540), not the VGA device. - */ - eax = pciReadLong(0x00000000, 0x50); - eax &= 0xfffff9ff; - eax |= data2; - pciWriteLong(0x00000000, 0x50, eax); + templ = pciReadLong(0x00000000, 0x50); #endif - /* Write GUI grant timer (PCI config 0xA3) */ - data2 = FQBQData730[i] << 8; - data2 = (data2 & 0x0f00) | ((data2 & 0x3000) >> 8); - data2 <<= 20; - -#ifdef LINUX_KERNEL - SiS_SetRegLong(0xcf8,0x800000A0); - eax = SiS_GetRegLong(0xcfc); - eax &= 0x00ffffff; - eax |= data2; - SiS_SetRegLong(0xcfc,eax); -#else - eax = pciReadLong(0x00000000, 0xA0); - eax &= 0x00ffffff; - eax |= data2; - pciWriteLong(0x00000000, 0xA0, eax); -#endif + if(SiS_Pr->ChipType == SIS_730) { - } else { + templ &= 0xfffff9ff; + templ |= ((queuedata[i] & 0xc0) << 3); - data2 = FQBQData[i]; - data2 = (data2 & 0xf0) >> 4; - data2 <<= 24; + } else { -#ifdef LINUX_KERNEL - SiS_SetRegLong(0xcf8,0x80000050); - eax = SiS_GetRegLong(0xcfc); - eax &= 0xf0ffffff; - eax |= data2; - SiS_SetRegLong(0xcfc,eax); -#else - eax = pciReadLong(0x00000000, 0x50); - eax &= 0xf0ffffff; - eax |= data2; - pciWriteLong(0x00000000, 0x50, eax); -#endif + templ &= 0xf0ffffff; + if( (ModeNo <= 0x13) && + (SiS_Pr->ChipType == SIS_630) && + (SiS_Pr->ChipRevision >= 0x30) ) { + templ |= 0x0b000000; + } else { + templ |= ((queuedata[i] & 0xf0) << 20); + } + + } - /* Write GUI grant timer (PCI config 0xA3) */ - data2 = FQBQData[i]; - data2 &= 0x0f; - data2 <<= 24; - -#ifdef LINUX_KERNEL - SiS_SetRegLong(0xcf8,0x800000A0); - eax = SiS_GetRegLong(0xcfc); - eax &= 0xf0ffffff; - eax |= data2; - SiS_SetRegLong(0xcfc,eax); +#ifdef SIS_LINUX_KERNEL + sisfb_write_nbridge_pci_dword(SiS_Pr, 0x50, templ); + templ = sisfb_read_nbridge_pci_dword(SiS_Pr, 0xA0); #else - eax = pciReadLong(0x00000000, 0xA0); - eax &= 0xf0ffffff; - eax |= data2; - pciWriteLong(0x00000000, 0xA0, eax); + pciWriteLong(0x00000000, 0x50, templ); + templ = pciReadLong(0x00000000, 0xA0); #endif - } + /* GUI grant timer (PCI config 0xA3) */ + if(SiS_Pr->ChipType == SIS_730) { + + templ &= 0x00ffffff; + datal = queuedata[i] << 8; + templ |= (((datal & 0x0f00) | ((datal & 0x3000) >> 8)) << 20); - /* Write CRT/CPU threshold low, CRT/Engine threshold high */ - data = ((ThresholdLow & 0x0f) << 4) | 0x0f; - SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,data); + } else { - data = (ThresholdLow & 0x10) << 1; - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xDF,data); + templ &= 0xf0ffffff; + templ |= ((queuedata[i] & 0x0f) << 24); - /* What is this? */ - SiS_SetReg(SiS_Pr->SiS_P3c4,0x3B,0x09); + } - /* Write CRT/CPU threshold high (gap = 3) */ - data = ThresholdLow + 3; - if(data > 0x0f) data = 0x0f; - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x09,0x80,data); -} +#ifdef SIS_LINUX_KERNEL + sisfb_write_nbridge_pci_dword(SiS_Pr, 0xA0, templ); +#else + pciWriteLong(0x00000000, 0xA0, templ); #endif +} +#endif /* SIS300 */ #ifdef SIS315H static void -SiS_SetCRT1FIFO_310(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo) +SiS_SetCRT1FIFO_310(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - USHORT modeflag; - - /* disable auto-threshold */ - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x3D,0xFE); - - if(SiS_Pr->UseCustomMode) { - modeflag = SiS_Pr->CModeFlag; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - } - - SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0xAE); - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x09,0xF0); - if(ModeNo > 0x13) { - if(HwInfo->jChipType >= SIS_661) { - if(!(modeflag & HalfDCLK)) { - SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0x34); - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x3D,0x01); - } - } else { - if((!(modeflag & DoubleScanMode)) || (!(modeflag & HalfDCLK))) { - SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0x34); - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x3D,0x01); - } - } - } + unsigned short modeflag; + + /* disable auto-threshold */ + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x3D,0xFE); + + modeflag = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex); + + SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0xAE); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x09,0xF0); + if(ModeNo > 0x13) { + if(SiS_Pr->ChipType >= XGI_20) { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0x34); + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x3D,0x01); + } else if(SiS_Pr->ChipType >= SIS_661) { + if(!(modeflag & HalfDCLK)) { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0x34); + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x3D,0x01); + } + } else { + if((!(modeflag & DoubleScanMode)) || (!(modeflag & HalfDCLK))) { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0x34); + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x3D,0x01); + } + } + } } #endif @@ -2851,385 +2597,370 @@ SiS_SetCRT1FIFO_310(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /*********************************************/ static void -SiS_SetVCLKState(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo, USHORT RefreshRateTableIndex, - USHORT ModeIdIndex) +SiS_SetVCLKState(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short RefreshRateTableIndex, unsigned short ModeIdIndex) { - USHORT data=0, VCLK=0, index=0; + unsigned short data = 0, VCLK = 0, index = 0; - if(ModeNo > 0x13) { - if(SiS_Pr->UseCustomMode) { - VCLK = SiS_Pr->CSRClock; - } else { - index = SiS_GetVCLK2Ptr(SiS_Pr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwInfo); - VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; - } - } - - if(HwInfo->jChipType < SIS_315H) { - - if(VCLK > 150) data |= 0x80; - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0x7B,data); - - data = 0x00; - if(VCLK >= 150) data |= 0x08; - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xF7,data); + if(ModeNo > 0x13) { + if(SiS_Pr->UseCustomMode) { + VCLK = SiS_Pr->CSRClock; + } else { + index = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); + VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; + } + } - } else { + if(SiS_Pr->ChipType < SIS_315H) { +#ifdef SIS300 + if(VCLK > 150) data |= 0x80; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0x7B,data); - if(VCLK >= 166) data |= 0x0c; - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xf3,data); + data = 0x00; + if(VCLK >= 150) data |= 0x08; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xF7,data); +#endif + } else if(SiS_Pr->ChipType < XGI_20) { +#ifdef SIS315H + if(VCLK >= 166) data |= 0x0c; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xf3,data); - if(VCLK >= 166) { - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1f,0xe7); - } - } + if(VCLK >= 166) { + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1f,0xe7); + } +#endif + } else { +#ifdef SIS315H + if(VCLK >= 200) data |= 0x0c; + if(SiS_Pr->ChipType == XGI_20) data &= ~0x04; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xf3,data); + if(SiS_Pr->ChipType != XGI_20) { + data = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1f) & 0xe7; + if(VCLK < 200) data |= 0x10; + SiS_SetReg(SiS_Pr->SiS_P3c4,0x1f,data); + } +#endif + } - /* DAC speed */ - if(HwInfo->jChipType >= SIS_661) { + /* DAC speed */ + if(SiS_Pr->ChipType >= SIS_661) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0xE8,0x10); + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0xE8,0x10); - } else { + } else { - data = 0x03; - if((VCLK >= 135) && (VCLK < 160)) data = 0x02; - else if((VCLK >= 160) && (VCLK < 260)) data = 0x01; - else if(VCLK >= 260) data = 0x00; + data = 0x03; + if(VCLK >= 260) data = 0x00; + else if(VCLK >= 160) data = 0x01; + else if(VCLK >= 135) data = 0x02; - if(HwInfo->jChipType == SIS_540) { - if((VCLK == 203) || (VCLK < 234)) data = 0x02; - } + if(SiS_Pr->ChipType == SIS_540) { + if((VCLK == 203) || (VCLK < 234)) data = 0x02; + } - if(HwInfo->jChipType < SIS_315H) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0xFC,data); - } else { - if(HwInfo->jChipType > SIS_315PRO) { - if(ModeNo > 0x13) data &= 0xfc; - } - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0xF8,data); - } + if(SiS_Pr->ChipType < SIS_315H) { + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0xFC,data); + } else { + if(SiS_Pr->ChipType > SIS_315PRO) { + if(ModeNo > 0x13) data &= 0xfc; + } + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0xF8,data); + } - } + } } static void -SiS_SetCRT1ModeRegs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex) +SiS_SetCRT1ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex, unsigned short RRTI) { - USHORT data,infoflag=0,modeflag; - USHORT resindex,xres; + unsigned short data, infoflag = 0, modeflag, resindex; #ifdef SIS315H - USHORT data2,data3; - ULONG longdata; - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short data2, data3; #endif - if(SiS_Pr->UseCustomMode) { - modeflag = SiS_Pr->CModeFlag; - infoflag = SiS_Pr->CInfoFlag; - xres = SiS_Pr->CHDisplay; - } else { - resindex = SiS_GetResInfo(SiS_Pr,ModeNo,ModeIdIndex); - if(ModeNo > 0x13) { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; - xres = SiS_Pr->SiS_ModeResInfo[resindex].HTotal; - } else { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - xres = SiS_Pr->SiS_StResInfo[resindex].HTotal; - } - } - - /* Disable DPMS */ - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1F,0x3F); - - data = 0; - if(ModeNo > 0x13) { - if(SiS_Pr->SiS_ModeType > ModeEGA) { - data |= 0x02; - data |= ((SiS_Pr->SiS_ModeType - ModeVGA) << 2); - } - if(infoflag & InterlaceMode) data |= 0x20; - } - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x06,0xC0,data); - - if(HwInfo->jChipType != SIS_300) { - data = 0; - if(infoflag & InterlaceMode) { - if(xres <= 800) data = 0x0020; - else if(xres <= 1024) data = 0x0035; - else data = 0x0048; - } - SiS_SetReg(SiS_Pr->SiS_P3d4,0x19,(data & 0xFF)); - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x1a,0xFC,(data >> 8)); - } - - if(modeflag & HalfDCLK) { - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x01,0x08); - } - - data = 0; - if(modeflag & LineCompareOff) data = 0x08; - if(HwInfo->jChipType == SIS_300) { - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xF7,data); - } else { - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xB7,data); - if(SiS_Pr->SiS_ModeType == ModeEGA) { - if(ModeNo > 0x13) { - SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x0F,0x40); - } - } - } - - if(HwInfo->jChipType >= SIS_661) { - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x31,0xfb); - } + modeflag = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex); + + if(SiS_Pr->UseCustomMode) { + infoflag = SiS_Pr->CInfoFlag; + } else { + resindex = SiS_GetResInfo(SiS_Pr, ModeNo, ModeIdIndex); + if(ModeNo > 0x13) { + infoflag = SiS_Pr->SiS_RefIndex[RRTI].Ext_InfoFlag; + } + } + + /* Disable DPMS */ + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1F,0x3F); + + data = 0; + if(ModeNo > 0x13) { + if(SiS_Pr->SiS_ModeType > ModeEGA) { + data |= 0x02; + data |= ((SiS_Pr->SiS_ModeType - ModeVGA) << 2); + } + if(infoflag & InterlaceMode) data |= 0x20; + } + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x06,0xC0,data); + + if(SiS_Pr->ChipType != SIS_300) { + data = 0; + if(infoflag & InterlaceMode) { + /* data = (Hsync / 8) - ((Htotal / 8) / 2) + 3 */ + int hrs = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x04) | + ((SiS_GetReg(SiS_Pr->SiS_P3c4,0x0b) & 0xc0) << 2)) - 3; + int hto = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x00) | + ((SiS_GetReg(SiS_Pr->SiS_P3c4,0x0b) & 0x03) << 8)) + 5; + data = hrs - (hto >> 1) + 3; + } + SiS_SetReg(SiS_Pr->SiS_P3d4,0x19,data); + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x1a,0xFC,((data >> 8) & 0x03)); + } + + if(modeflag & HalfDCLK) { + SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x01,0x08); + } + + data = 0; + if(modeflag & LineCompareOff) data = 0x08; + if(SiS_Pr->ChipType == SIS_300) { + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xF7,data); + } else { + if(SiS_Pr->ChipType >= XGI_20) data |= 0x20; + if(SiS_Pr->SiS_ModeType == ModeEGA) { + if(ModeNo > 0x13) { + data |= 0x40; + } + } + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xB7,data); + } #ifdef SIS315H - if(HwInfo->jChipType == SIS_315PRO) { - - data = SiS_Get310DRAMType(SiS_Pr, HwInfo); - data = SiS_Pr->SiS_SR15[2][data]; - if(SiS_Pr->SiS_ModeType == ModeText) { - data &= 0xc7; - } else { - data2 = SiS_GetOffset(SiS_Pr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwInfo); - data2 >>= 1; - if(infoflag & InterlaceMode) data2 >>= 1; - data3 = SiS_GetColorDepth(SiS_Pr,ModeNo,ModeIdIndex) >> 1; - if(!data3) data3++; - data2 /= data3; - if(data2 >= 0x50) { - data &= 0x0f; - data |= 0x50; - } - } - SiS_SetReg(SiS_Pr->SiS_P3c4,0x17,data); - - } else if( (HwInfo->jChipType == SIS_330) || - ((HwInfo->jChipType == SIS_760) && (SiS_Pr->SiS_SysFlags & SF_760LFB))) { - - data = SiS_Get310DRAMType(SiS_Pr, HwInfo); - if(HwInfo->jChipType == SIS_330) { - data = SiS_Pr->SiS_SR15[2][data]; - } else { - if(SiS_Pr->SiS_ROMNew) data = ROMAddr[0xf6]; - else if(SiS_Pr->SiS_UseROM) data = ROMAddr[0x100 + data]; - else data = 0xba; - } - if(SiS_Pr->SiS_ModeType <= ModeEGA) { - data &= 0xc7; - } else { - if(SiS_Pr->UseCustomMode) { - data2 = SiS_Pr->CSRClock; - } else { - data2 = SiS_GetVCLK2Ptr(SiS_Pr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwInfo); - data2 = SiS_Pr->SiS_VCLKData[data2].CLOCK; - } + if(SiS_Pr->ChipType >= SIS_315H) { + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x31,0xfb); + } - data3 = SiS_GetColorDepth(SiS_Pr,ModeNo,ModeIdIndex) >> 1; - if(data3) data2 *= data3; - - longdata = SiS_GetMCLK(SiS_Pr, HwInfo) * 1024; - - data2 = longdata / data2; - - if(HwInfo->jChipType == SIS_330) { - if(SiS_Pr->SiS_ModeType != Mode16Bpp) { - if (data2 >= 0x19c) data = 0xba; - else if(data2 >= 0x140) data = 0x7a; - else if(data2 >= 0x101) data = 0x3a; - else if(data2 >= 0xf5) data = 0x32; - else if(data2 >= 0xe2) data = 0x2a; - else if(data2 >= 0xc4) data = 0x22; - else if(data2 >= 0xac) data = 0x1a; - else if(data2 >= 0x9e) data = 0x12; - else if(data2 >= 0x8e) data = 0x0a; - else data = 0x02; - } else { - if(data2 >= 0x127) data = 0xba; - else data = 0x7a; - } - } else { /* 760+LFB */ - if (data2 >= 0x190) data = 0xba; - else if(data2 >= 0xff) data = 0x7a; - else if(data2 >= 0xd3) data = 0x3a; - else if(data2 >= 0xa9) data = 0x1a; - else if(data2 >= 0x93) data = 0x0a; - else data = 0x02; - } - } - SiS_SetReg(SiS_Pr->SiS_P3c4,0x17,data); - } else if(HwInfo->jChipType == SIS_340) { - /* TODO */ - } + if(SiS_Pr->ChipType == SIS_315PRO) { + + data = SiS_Pr->SiS_SR15[(2 * 4) + SiS_Get310DRAMType(SiS_Pr)]; + if(SiS_Pr->SiS_ModeType == ModeText) { + data &= 0xc7; + } else { + data2 = SiS_GetOffset(SiS_Pr, ModeNo, ModeIdIndex, RRTI) >> 1; + if(infoflag & InterlaceMode) data2 >>= 1; + data3 = SiS_GetColorDepth(SiS_Pr, ModeNo, ModeIdIndex) >> 1; + if(data3) data2 /= data3; + if(data2 >= 0x50) { + data &= 0x0f; + data |= 0x50; + } + } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x17,data); + + } else if((SiS_Pr->ChipType == SIS_330) || (SiS_Pr->SiS_SysFlags & SF_760LFB)) { + + data = SiS_Get310DRAMType(SiS_Pr); + if(SiS_Pr->ChipType == SIS_330) { + data = SiS_Pr->SiS_SR15[(2 * 4) + data]; + } else { + if(SiS_Pr->SiS_ROMNew) data = ROMAddr[0xf6]; + else if(SiS_Pr->SiS_UseROM) data = ROMAddr[0x100 + data]; + else data = 0xba; + } + if(SiS_Pr->SiS_ModeType <= ModeEGA) { + data &= 0xc7; + } else { + if(SiS_Pr->UseCustomMode) { + data2 = SiS_Pr->CSRClock; + } else { + data2 = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RRTI); + data2 = SiS_Pr->SiS_VCLKData[data2].CLOCK; + } + + data3 = SiS_GetColorDepth(SiS_Pr, ModeNo, ModeIdIndex) >> 1; + if(data3) data2 *= data3; + + data2 = ((unsigned int)(SiS_GetMCLK(SiS_Pr) * 1024)) / data2; + + if(SiS_Pr->ChipType == SIS_330) { + if(SiS_Pr->SiS_ModeType != Mode16Bpp) { + if (data2 >= 0x19c) data = 0xba; + else if(data2 >= 0x140) data = 0x7a; + else if(data2 >= 0x101) data = 0x3a; + else if(data2 >= 0xf5) data = 0x32; + else if(data2 >= 0xe2) data = 0x2a; + else if(data2 >= 0xc4) data = 0x22; + else if(data2 >= 0xac) data = 0x1a; + else if(data2 >= 0x9e) data = 0x12; + else if(data2 >= 0x8e) data = 0x0a; + else data = 0x02; + } else { + if(data2 >= 0x127) data = 0xba; + else data = 0x7a; + } + } else { /* 76x+LFB */ + if (data2 >= 0x190) data = 0xba; + else if(data2 >= 0xff) data = 0x7a; + else if(data2 >= 0xd3) data = 0x3a; + else if(data2 >= 0xa9) data = 0x1a; + else if(data2 >= 0x93) data = 0x0a; + else data = 0x02; + } + } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x17,data); + + } + /* XGI: Nothing. */ + /* TODO: Check SiS340 */ #endif - data = 0x60; - if(SiS_Pr->SiS_ModeType != ModeText) { - data ^= 0x60; - if(SiS_Pr->SiS_ModeType != ModeEGA) { - data ^= 0xA0; - } - } - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x21,0x1F,data); + data = 0x60; + if(SiS_Pr->SiS_ModeType != ModeText) { + data ^= 0x60; + if(SiS_Pr->SiS_ModeType != ModeEGA) { + data ^= 0xA0; + } + } + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x21,0x1F,data); - SiS_SetVCLKState(SiS_Pr, HwInfo, ModeNo, RefreshRateTableIndex, ModeIdIndex); + SiS_SetVCLKState(SiS_Pr, ModeNo, RRTI, ModeIdIndex); #ifdef SIS315H - if(HwInfo->jChipType >= SIS_315H) { - if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40) { - SiS_SetReg(SiS_Pr->SiS_P3d4,0x52,0x2c); - } else { - SiS_SetReg(SiS_Pr->SiS_P3d4,0x52,0x6c); - } - } + if(((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->ChipType < SIS_661)) || + (SiS_Pr->ChipType == XGI_40)) { + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40) { + SiS_SetReg(SiS_Pr->SiS_P3d4,0x52,0x2c); + } else { + SiS_SetReg(SiS_Pr->SiS_P3d4,0x52,0x6c); + } + } else if(SiS_Pr->ChipType == XGI_20) { + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40) { + SiS_SetReg(SiS_Pr->SiS_P3d4,0x52,0x33); + } else { + SiS_SetReg(SiS_Pr->SiS_P3d4,0x52,0x73); + } + SiS_SetReg(SiS_Pr->SiS_P3d4,0x51,0x02); + } #endif } -/*********************************************/ -/* LOAD DAC */ -/*********************************************/ - -#if 0 +#ifdef SIS315H static void -SiS_ClearDAC(SiS_Private *SiS_Pr, ULONG port) +SiS_SetupDualChip(struct SiS_Private *SiS_Pr) { +#if 0 + /* TODO: Find out about IOAddress2 */ + SISIOADDRESS P2_3c2 = SiS_Pr->IOAddress2 + 0x12; + SISIOADDRESS P2_3c4 = SiS_Pr->IOAddress2 + 0x14; + SISIOADDRESS P2_3ce = SiS_Pr->IOAddress2 + 0x1e; int i; - OutPortByte(port, 0); - port++; - for (i=0; i < (256 * 3); i++) { - OutPortByte(port, 0); + if((SiS_Pr->ChipRevision != 0) || + (!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x3a) & 0x04))) + return; + + for(i = 0; i <= 4; i++) { /* SR00 - SR04 */ + SiS_SetReg(P2_3c4,i,SiS_GetReg(SiS_Pr->SiS_P3c4,i)); } + for(i = 0; i <= 8; i++) { /* GR00 - GR08 */ + SiS_SetReg(P2_3ce,i,SiS_GetReg(SiS_Pr->SiS_P3ce,i)); + } + SiS_SetReg(P2_3c4,0x05,0x86); + SiS_SetReg(P2_3c4,0x06,SiS_GetReg(SiS_Pr->SiS_P3c4,0x06)); /* SR06 */ + SiS_SetReg(P2_3c4,0x21,SiS_GetReg(SiS_Pr->SiS_P3c4,0x21)); /* SR21 */ + SiS_SetRegByte(P2_3c2,SiS_GetRegByte(SiS_Pr->SiS_P3cc)); /* MISC */ + SiS_SetReg(P2_3c4,0x05,0x00); +#endif } #endif +/*********************************************/ +/* LOAD DAC */ +/*********************************************/ + static void -SiS_WriteDAC(SiS_Private *SiS_Pr, SISIOADDRESS DACData, USHORT shiftflag, - USHORT dl, USHORT ah, USHORT al, USHORT dh) +SiS_WriteDAC(struct SiS_Private *SiS_Pr, SISIOADDRESS DACData, unsigned short shiftflag, + unsigned short dl, unsigned short ah, unsigned short al, unsigned short dh) { - USHORT temp,bh,bl; - - bh = ah; - bl = al; - if(dl != 0) { - temp = bh; - bh = dh; - dh = temp; - if(dl == 1) { - temp = bl; - bl = dh; - dh = temp; - } else { - temp = bl; - bl = bh; - bh = temp; - } - } - if(shiftflag) { - dh <<= 2; - bh <<= 2; - bl <<= 2; - } - SiS_SetRegByte(DACData,(USHORT)dh); - SiS_SetRegByte(DACData,(USHORT)bh); - SiS_SetRegByte(DACData,(USHORT)bl); + unsigned short d1, d2, d3; + + switch(dl) { + case 0: d1 = dh; d2 = ah; d3 = al; break; + case 1: d1 = ah; d2 = al; d3 = dh; break; + default: d1 = al; d2 = dh; d3 = ah; + } + SiS_SetRegByte(DACData, (d1 << shiftflag)); + SiS_SetRegByte(DACData, (d2 << shiftflag)); + SiS_SetRegByte(DACData, (d3 << shiftflag)); } void -SiS_LoadDAC(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo, USHORT ModeIdIndex) +SiS_LoadDAC(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - USHORT data,data2; - USHORT time,i,j,k,m,n,o; - USHORT si,di,bx,dl,al,ah,dh; - USHORT shiftflag; + unsigned short data, data2, time, i, j, k, m, n, o; + unsigned short si, di, bx, sf; SISIOADDRESS DACAddr, DACData; - const USHORT *table = NULL; + const unsigned char *table = NULL; - if(ModeNo <= 0x13) { - data = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - } else { - if(SiS_Pr->UseCustomMode) { - data = SiS_Pr->CModeFlag; - } else { - data = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - } - } + data = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex) & DACInfoFlag; - data &= DACInfoFlag; - time = 64; - if(data == 0x00) table = SiS_MDA_DAC; - if(data == 0x08) table = SiS_CGA_DAC; - if(data == 0x10) table = SiS_EGA_DAC; - if(data == 0x18) { + j = time = 64; + if(data == 0x00) table = SiS_MDA_DAC; + else if(data == 0x08) table = SiS_CGA_DAC; + else if(data == 0x10) table = SiS_EGA_DAC; + else if(data == 0x18) { + j = 16; time = 256; table = SiS_VGA_DAC; } - if(time == 256) j = 16; - else j = time; if( ( (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && /* 301B-DH LCD */ (SiS_Pr->SiS_VBType & VB_NoLCD) ) || (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) || /* LCDA */ (!(SiS_Pr->SiS_SetFlag & ProgrammingCRT2)) ) { /* Programming CRT1 */ + SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF); DACAddr = SiS_Pr->SiS_P3c8; DACData = SiS_Pr->SiS_P3c9; - shiftflag = 0; - SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF); + sf = 0; } else { - shiftflag = 1; DACAddr = SiS_Pr->SiS_Part5Port; DACData = SiS_Pr->SiS_Part5Port + 1; + sf = 2; } SiS_SetRegByte(DACAddr,0x00); - for(i=0; i<j; i++) { + for(i = 0; i < j; i++) { data = table[i]; - for(k=0; k<3; k++) { + for(k = 0; k < 3; k++) { data2 = 0; - if(data & 0x01) data2 = 0x2A; + if(data & 0x01) data2 += 0x2A; if(data & 0x02) data2 += 0x15; - if(shiftflag) data2 <<= 2; - SiS_SetRegByte(DACData, data2); + SiS_SetRegByte(DACData, (data2 << sf)); data >>= 2; } } if(time == 256) { for(i = 16; i < 32; i++) { - data = table[i]; - if(shiftflag) data <<= 2; + data = table[i] << sf; for(k = 0; k < 3; k++) SiS_SetRegByte(DACData, data); } si = 32; for(m = 0; m < 9; m++) { - di = si; - bx = si + 4; - dl = 0; - for(n = 0; n < 3; n++) { - for(o = 0; o < 5; o++) { - dh = table[si]; - ah = table[di]; - al = table[bx]; + di = si; + bx = si + 4; + for(n = 0; n < 3; n++) { + for(o = 0; o < 5; o++) { + SiS_WriteDAC(SiS_Pr, DACData, sf, n, table[di], table[bx], table[si]); si++; - SiS_WriteDAC(SiS_Pr, DACData, shiftflag, dl, ah, al, dh); } si -= 2; for(o = 0; o < 3; o++) { - dh = table[bx]; - ah = table[di]; - al = table[si]; + SiS_WriteDAC(SiS_Pr, DACData, sf, n, table[di], table[si], table[bx]); si--; - SiS_WriteDAC(SiS_Pr, DACData, shiftflag, dl, ah, al, dh); } - dl++; } /* for n < 3 */ si += 5; } /* for m < 9 */ @@ -3241,89 +2972,114 @@ SiS_LoadDAC(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, /*********************************************/ static void -SiS_SetCRT1Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo, USHORT ModeIdIndex) +SiS_SetCRT1Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - USHORT StandTableIndex,RefreshRateTableIndex; - - SiS_Pr->SiS_CRT1Mode = ModeNo; - StandTableIndex = SiS_GetModePtr(SiS_Pr, ModeNo, ModeIdIndex); - if(SiS_Pr->SiS_SetFlag & LowModeTests) { - if(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchCRT2)) { - SiS_DisableBridge(SiS_Pr, HwInfo); - } - } - - SiS_ResetSegmentRegisters(SiS_Pr, HwInfo); - - SiS_SetSeqRegs(SiS_Pr, StandTableIndex, HwInfo); - SiS_SetMiscRegs(SiS_Pr, StandTableIndex, HwInfo); - SiS_SetCRTCRegs(SiS_Pr, HwInfo, StandTableIndex); - SiS_SetATTRegs(SiS_Pr, StandTableIndex, HwInfo); - SiS_SetGRCRegs(SiS_Pr, StandTableIndex); - SiS_ClearExt1Regs(SiS_Pr, HwInfo, ModeNo); - SiS_ResetCRT1VCLK(SiS_Pr, HwInfo); - - SiS_Pr->SiS_SelectCRT2Rate = 0; - SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); - -#ifdef LINUX_XF86 - xf86DrvMsgVerb(0, X_PROBED, 4, "(init: VBType=0x%04x, VBInfo=0x%04x)\n", + unsigned short StandTableIndex, RefreshRateTableIndex; + + SiS_Pr->SiS_CRT1Mode = ModeNo; + + StandTableIndex = SiS_GetModePtr(SiS_Pr, ModeNo, ModeIdIndex); + + if(SiS_Pr->SiS_SetFlag & LowModeTests) { + if(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchCRT2)) { + SiS_DisableBridge(SiS_Pr); + } + } + + SiS_ResetSegmentRegisters(SiS_Pr); + + SiS_SetSeqRegs(SiS_Pr, StandTableIndex); + SiS_SetMiscRegs(SiS_Pr, StandTableIndex); + SiS_SetCRTCRegs(SiS_Pr, StandTableIndex); + SiS_SetATTRegs(SiS_Pr, StandTableIndex); + SiS_SetGRCRegs(SiS_Pr, StandTableIndex); + SiS_ClearExt1Regs(SiS_Pr, ModeNo); + SiS_ResetCRT1VCLK(SiS_Pr); + + SiS_Pr->SiS_SelectCRT2Rate = 0; + SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); + +#ifdef SIS_XORG_XF86 + xf86DrvMsgVerb(0, X_PROBED, 4, "(init: VBType=0x%04x, VBInfo=0x%04x)\n", SiS_Pr->SiS_VBType, SiS_Pr->SiS_VBInfo); #endif - if(SiS_Pr->SiS_VBInfo & SetSimuScanMode) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; - } - } + if(SiS_Pr->SiS_VBInfo & SetSimuScanMode) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; + } + } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; + } - RefreshRateTableIndex = SiS_GetRatePtr(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + RefreshRateTableIndex = SiS_GetRatePtr(SiS_Pr, ModeNo, ModeIdIndex); - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - SiS_Pr->SiS_SetFlag &= ~ProgrammingCRT2; - } + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + SiS_Pr->SiS_SetFlag &= ~ProgrammingCRT2; + } - if(RefreshRateTableIndex != 0xFFFF) { - SiS_SetCRT1Sync(SiS_Pr, RefreshRateTableIndex); - SiS_SetCRT1CRTC(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); - SiS_SetCRT1Offset(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); - SiS_SetCRT1VCLK(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex); - } + if(RefreshRateTableIndex != 0xFFFF) { + SiS_SetCRT1Sync(SiS_Pr, RefreshRateTableIndex); + SiS_SetCRT1CRTC(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); + SiS_SetCRT1Offset(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); + SiS_SetCRT1VCLK(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); + } + switch(SiS_Pr->ChipType) { #ifdef SIS300 - if(HwInfo->jChipType == SIS_300) { - SiS_SetCRT1FIFO_300(SiS_Pr, ModeNo,HwInfo,RefreshRateTableIndex); - } else if((HwInfo->jChipType == SIS_630) || - (HwInfo->jChipType == SIS_730) || - (HwInfo->jChipType == SIS_540)) { - SiS_SetCRT1FIFO_630(SiS_Pr, ModeNo, HwInfo, RefreshRateTableIndex); - } + case SIS_300: + SiS_SetCRT1FIFO_300(SiS_Pr, ModeNo, RefreshRateTableIndex); + break; + case SIS_540: + case SIS_630: + case SIS_730: + SiS_SetCRT1FIFO_630(SiS_Pr, ModeNo, RefreshRateTableIndex); + break; #endif + default: #ifdef SIS315H - if(HwInfo->jChipType >= SIS_315H) { - SiS_SetCRT1FIFO_310(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); - } + if(SiS_Pr->ChipType == XGI_20) { + unsigned char sr2b = 0, sr2c = 0; + switch(ModeNo) { + case 0x00: + case 0x01: sr2b = 0x4e; sr2c = 0xe9; break; + case 0x04: + case 0x05: + case 0x0d: sr2b = 0x1b; sr2c = 0xe3; break; + } + if(sr2b) { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x2b,sr2b); + SiS_SetReg(SiS_Pr->SiS_P3c4,0x2c,sr2c); + SiS_SetRegByte(SiS_Pr->SiS_P3c2,(SiS_GetRegByte(SiS_Pr->SiS_P3cc) | 0x0c)); + } + } + SiS_SetCRT1FIFO_310(SiS_Pr, ModeNo, ModeIdIndex); #endif + break; + } + + SiS_SetCRT1ModeRegs(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); - SiS_SetCRT1ModeRegs(SiS_Pr, HwInfo, ModeNo, ModeIdIndex, RefreshRateTableIndex); +#ifdef SIS315H + if(SiS_Pr->ChipType == XGI_40) { + SiS_SetupDualChip(SiS_Pr); + } +#endif - SiS_LoadDAC(SiS_Pr, HwInfo, ModeNo, ModeIdIndex); + SiS_LoadDAC(SiS_Pr, ModeNo, ModeIdIndex); -#ifdef LINUX_KERNEL - if(SiS_Pr->SiS_flag_clearbuffer) { - SiS_ClearBuffer(SiS_Pr,HwInfo,ModeNo); - } +#ifdef SIS_LINUX_KERNEL + if(SiS_Pr->SiS_flag_clearbuffer) { + SiS_ClearBuffer(SiS_Pr, ModeNo); + } #endif - if(!(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchCRT2 | SetCRT2ToLCDA))) { - SiS_WaitRetrace1(SiS_Pr); - SiS_DisplayOn(SiS_Pr); - } + if(!(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchCRT2 | SetCRT2ToLCDA))) { + SiS_WaitRetrace1(SiS_Pr); + SiS_DisplayOn(SiS_Pr); + } } /*********************************************/ @@ -3331,33 +3087,62 @@ SiS_SetCRT1Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, /*********************************************/ static void -SiS_ResetVB(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_InitVB(struct SiS_Private *SiS_Pr) +{ + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + + SiS_Pr->Init_P4_0E = 0; + if(SiS_Pr->SiS_ROMNew) { + SiS_Pr->Init_P4_0E = ROMAddr[0x82]; + } else if(SiS_Pr->ChipType >= XGI_40) { + if(SiS_Pr->SiS_XGIROM) { + SiS_Pr->Init_P4_0E = ROMAddr[0x80]; + } + } +} + +static void +SiS_ResetVB(struct SiS_Private *SiS_Pr) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT temp; +#ifdef SIS315H + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short temp; /* VB programming clock */ if(SiS_Pr->SiS_UseROM) { - if(HwInfo->jChipType < SIS_330) { - temp = ROMAddr[VB310Data_1_2_Offset] | 0x40; + if(SiS_Pr->ChipType < SIS_330) { + temp = ROMAddr[VB310Data_1_2_Offset] | 0x40; if(SiS_Pr->SiS_ROMNew) temp = ROMAddr[0x80] | 0x40; SiS_SetReg(SiS_Pr->SiS_Part1Port,0x02,temp); - } else if(HwInfo->jChipType >= SIS_661) { - temp = ROMAddr[0x7e] | 0x40; - if(SiS_Pr->SiS_ROMNew) temp = ROMAddr[0x80] | 0x40; + } else if(SiS_Pr->ChipType >= SIS_661 && SiS_Pr->ChipType < XGI_20) { + temp = ROMAddr[0x7e] | 0x40; + if(SiS_Pr->SiS_ROMNew) temp = ROMAddr[0x80] | 0x40; SiS_SetReg(SiS_Pr->SiS_Part1Port,0x02,temp); } + } else if(SiS_Pr->ChipType >= XGI_40) { + temp = 0x40; + if(SiS_Pr->SiS_XGIROM) temp |= ROMAddr[0x7e]; + /* Can we do this on any chipset? */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x02,temp); } +#endif } /*********************************************/ -/* HELPER: SET VIDEO REGISTERS */ +/* HELPER: SET VIDEO/CAPTURE REGISTERS */ /*********************************************/ static void -SiS_StrangeStuff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_StrangeStuff(struct SiS_Private *SiS_Pr) { - if((IS_SIS651) || (IS_SISM650)) { + /* SiS65x and XGI set up some sort of "lock mode" for text + * which locks CRT2 in some way to CRT1 timing. Disable + * this here. + */ +#ifdef SIS315H + if((IS_SIS651) || (IS_SISM650) || + SiS_Pr->ChipType == SIS_340 || + SiS_Pr->ChipType == XGI_40) { SiS_SetReg(SiS_Pr->SiS_VidCapt, 0x3f, 0x00); /* Fiddle with capture regs */ SiS_SetReg(SiS_Pr->SiS_VidCapt, 0x00, 0x00); SiS_SetReg(SiS_Pr->SiS_VidPlay, 0x00, 0x86); /* (BIOS does NOT unlock) */ @@ -3365,49 +3150,99 @@ SiS_StrangeStuff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) SiS_SetRegAND(SiS_Pr->SiS_VidPlay, 0x3f, 0xef); } /* !!! This does not support modes < 0x13 !!! */ +#endif } /*********************************************/ -/* XFree86: SET SCREEN PITCH */ +/* HELPER: SET AGP TIMING FOR SiS760 */ /*********************************************/ -#ifdef LINUX_XF86 static void -SiS_SetPitchCRT1(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn) +SiS_Handle760(struct SiS_Private *SiS_Pr) +{ +#ifdef SIS315H + unsigned int somebase; + unsigned char temp1, temp2, temp3; + + if( (SiS_Pr->ChipType != SIS_760) || + ((SiS_GetReg(SiS_Pr->SiS_P3d4, 0x5c) & 0xf8) != 0x80) || + (!(SiS_Pr->SiS_SysFlags & SF_760LFB)) || + (!(SiS_Pr->SiS_SysFlags & SF_760UMA)) ) + return; + +#ifdef SIS_LINUX_KERNEL + somebase = sisfb_read_mio_pci_word(SiS_Pr, 0x74); +#else + somebase = pciReadWord(0x00001000, 0x74); +#endif + somebase &= 0xffff; + + if(somebase == 0) return; + + temp3 = SiS_GetRegByte((somebase + 0x85)) & 0xb7; + + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40) { + temp1 = 0x21; + temp2 = 0x03; + temp3 |= 0x08; + } else { + temp1 = 0x25; + temp2 = 0x0b; + } + +#ifdef SIS_LINUX_KERNEL + sisfb_write_nbridge_pci_byte(SiS_Pr, 0x7e, temp1); + sisfb_write_nbridge_pci_byte(SiS_Pr, 0x8d, temp2); +#else + pciWriteByte(0x00000000, 0x7e, temp1); + pciWriteByte(0x00000000, 0x8d, temp2); +#endif + + SiS_SetRegByte((somebase + 0x85), temp3); +#endif +} + +/*********************************************/ +/* X.org/XFree86: SET SCREEN PITCH */ +/*********************************************/ + +#ifdef SIS_XORG_XF86 +static void +SiS_SetPitchCRT1(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); - UShort HDisplay = pSiS->scrnPitch >> 3; + unsigned short HDisplay = pSiS->scrnPitch >> 3; SiS_SetReg(SiS_Pr->SiS_P3d4,0x13,(HDisplay & 0xFF)); - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0xF0,(HDisplay>>8)); + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0xF0,(HDisplay >> 8)); } static void -SiS_SetPitchCRT2(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn) +SiS_SetPitchCRT2(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); - UShort HDisplay = pSiS->scrnPitch2 >> 3; + unsigned short HDisplay = pSiS->scrnPitch2 >> 3; /* Unlock CRT2 */ if(pSiS->VGAEngine == SIS_315_VGA) - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2F, 0x01); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2F, 0x01); else - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x24, 0x01); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x24, 0x01); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x07,(HDisplay & 0xFF)); SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0xF0,(HDisplay >> 8)); } static void -SiS_SetPitch(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn) +SiS_SetPitch(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); BOOLEAN isslavemode = FALSE; - if( (pSiS->VBFlags & VB_VIDEOBRIDGE) && + if( (pSiS->VBFlags2 & VB2_VIDEOBRIDGE) && ( ((pSiS->VGAEngine == SIS_300_VGA) && - (SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0xa0) == 0x20) || - ((pSiS->VGAEngine == SIS_315_VGA) && + (SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0xa0) == 0x20) || + ((pSiS->VGAEngine == SIS_315_VGA) && (SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x50) == 0x10) ) ) { isslavemode = TRUE; } @@ -3427,59 +3262,59 @@ SiS_SetPitch(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn) /* SiSSetMode() */ /*********************************************/ -#ifdef LINUX_XF86 +#ifdef SIS_XORG_XF86 /* We need pScrn for setting the pitch correctly */ BOOLEAN -SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,ScrnInfoPtr pScrn,USHORT ModeNo, BOOLEAN dosetpitch) +SiSSetMode(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, unsigned short ModeNo, BOOLEAN dosetpitch) #else BOOLEAN -SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,USHORT ModeNo) +SiSSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo) #endif { - USHORT ModeIdIndex; - SISIOADDRESS BaseAddr = HwInfo->ulIOAddress; - unsigned char backupreg=0; -#ifdef LINUX_KERNEL - USHORT KeepLockReg; - ULONG temp; + SISIOADDRESS BaseAddr = SiS_Pr->IOAddress; + unsigned short RealModeNo, ModeIdIndex; + unsigned char backupreg = 0; +#ifdef SIS_LINUX_KERNEL + unsigned short KeepLockReg; SiS_Pr->UseCustomMode = FALSE; SiS_Pr->CRT1UsesCustomMode = FALSE; #endif + SiS_Pr->SiS_flag_clearbuffer = 0; + if(SiS_Pr->UseCustomMode) { ModeNo = 0xfe; + } else { +#ifdef SIS_LINUX_KERNEL + if(!(ModeNo & 0x80)) SiS_Pr->SiS_flag_clearbuffer = 1; +#endif + ModeNo &= 0x7f; } - SiSInitPtr(SiS_Pr, HwInfo); + /* Don't use FSTN mode for CRT1 */ + RealModeNo = ModeNo; + if(ModeNo == 0x5b) ModeNo = 0x56; + + SiSInitPtr(SiS_Pr); SiSRegInit(SiS_Pr, BaseAddr); - SiS_GetSysFlags(SiS_Pr, HwInfo); + SiS_GetSysFlags(SiS_Pr); -#if defined(LINUX_XF86) && (defined(i386) || defined(__i386) || defined(__i386__) || defined(__AMD64__)) + SiS_Pr->SiS_VGAINFO = 0x11; +#if defined(SIS_XORG_XF86) && (defined(i386) || defined(__i386) || defined(__i386__) || defined(__AMD64__) || defined(__amd64__) || defined(__x86_64__)) if(pScrn) SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff); - else -#endif - SiS_Pr->SiS_VGAINFO = 0x11; - - SiSInitPCIetc(SiS_Pr, HwInfo); - SiSSetLVDSetc(SiS_Pr, HwInfo); - SiSDetermineROMUsage(SiS_Pr, HwInfo); - - SiS_Pr->SiS_flag_clearbuffer = 0; - - if(!SiS_Pr->UseCustomMode) { -#ifdef LINUX_KERNEL - if(!(ModeNo & 0x80)) SiS_Pr->SiS_flag_clearbuffer = 1; #endif - ModeNo &= 0x7f; - } -#ifdef LINUX_KERNEL +#ifdef SIS_LINUX_KERNEL KeepLockReg = SiS_GetReg(SiS_Pr->SiS_P3c4,0x05); #endif SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86); - SiS_UnLockCRT2(SiS_Pr, HwInfo); + SiSInitPCIetc(SiS_Pr); + SiSSetLVDSetc(SiS_Pr); + SiSDetermineROMUsage(SiS_Pr); + + SiS_UnLockCRT2(SiS_Pr); if(!SiS_Pr->UseCustomMode) { if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return FALSE; @@ -3487,13 +3322,13 @@ SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,USHORT ModeNo) ModeIdIndex = 0; } - SiS_GetVBType(SiS_Pr, HwInfo); + SiS_GetVBType(SiS_Pr); /* Init/restore some VB registers */ - - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(HwInfo->jChipType >= SIS_315H) { - SiS_ResetVB(SiS_Pr, HwInfo); + SiS_InitVB(SiS_Pr); + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { + if(SiS_Pr->ChipType >= SIS_315H) { + SiS_ResetVB(SiS_Pr); SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x32,0x10); SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x00,0x0c); backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); @@ -3503,21 +3338,20 @@ SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,USHORT ModeNo) } /* Get VB information (connectors, connected devices) */ - SiS_GetVBInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, (SiS_Pr->UseCustomMode) ? 0 : 1); - SiS_SetYPbPr(SiS_Pr, HwInfo); - SiS_SetTVMode(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); - SiS_GetLCDResInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); - SiS_SetLowModeTest(SiS_Pr, ModeNo, HwInfo); - -#ifdef LINUX_KERNEL - /* 3. Check memory size (Kernel framebuffer driver only) */ - temp = SiS_CheckMemorySize(SiS_Pr, HwInfo, ModeNo, ModeIdIndex); - if(!temp) return(0); + SiS_GetVBInfo(SiS_Pr, ModeNo, ModeIdIndex, (SiS_Pr->UseCustomMode) ? 0 : 1); + SiS_SetYPbPr(SiS_Pr); + SiS_SetTVMode(SiS_Pr, ModeNo, ModeIdIndex); + SiS_GetLCDResInfo(SiS_Pr, ModeNo, ModeIdIndex); + SiS_SetLowModeTest(SiS_Pr, ModeNo); + +#ifdef SIS_LINUX_KERNEL + /* Check memory size (kernel framebuffer driver only) */ + if(!SiS_CheckMemorySize(SiS_Pr, ModeNo, ModeIdIndex)) { + return FALSE; + } #endif - if(HwInfo->jChipType >= SIS_315H) { - SiS_SetupCR5x(SiS_Pr, HwInfo); - } + SiS_OpenCRTC(SiS_Pr); if(SiS_Pr->UseCustomMode) { SiS_Pr->CRT1UsesCustomMode = TRUE; @@ -3530,38 +3364,41 @@ SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,USHORT ModeNo) /* Set mode on CRT1 */ if( (SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) || (!(SiS_Pr->SiS_VBInfo & SwitchCRT2)) ) { - SiS_SetCRT1Group(SiS_Pr, HwInfo, ModeNo, ModeIdIndex); + SiS_SetCRT1Group(SiS_Pr, ModeNo, ModeIdIndex); } /* Set mode on CRT2 */ if(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchCRT2 | SetCRT2ToLCDA)) { if( (SiS_Pr->SiS_VBType & VB_SISVB) || - (SiS_Pr->SiS_IF_DEF_LVDS == 1) || - (SiS_Pr->SiS_IF_DEF_CH70xx != 0) || - (SiS_Pr->SiS_IF_DEF_TRUMPION != 0) ) { - SiS_SetCRT2Group(SiS_Pr, HwInfo, ModeNo); + (SiS_Pr->SiS_IF_DEF_LVDS == 1) || + (SiS_Pr->SiS_IF_DEF_CH70xx != 0) || + (SiS_Pr->SiS_IF_DEF_TRUMPION != 0) ) { + SiS_SetCRT2Group(SiS_Pr, RealModeNo); } } SiS_HandleCRT1(SiS_Pr); - SiS_StrangeStuff(SiS_Pr, HwInfo); + SiS_StrangeStuff(SiS_Pr); SiS_DisplayOn(SiS_Pr); SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF); - if(HwInfo->jChipType >= SIS_315H) { +#ifdef SIS315H + if(SiS_Pr->ChipType >= SIS_315H) { if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(!(SiS_IsDualEdge(SiS_Pr, HwInfo))) { + if(!(SiS_IsDualEdge(SiS_Pr))) { SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); } } } +#endif - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(HwInfo->jChipType >= SIS_315H) { - if(!SiS_Pr->SiS_ROMNew) { - if(SiS_IsVAMode(SiS_Pr,HwInfo)) { + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { + if(SiS_Pr->ChipType >= SIS_315H) { +#ifdef SIS315H + if(!SiS_Pr->SiS_ROMNew) { + if(SiS_IsVAMode(SiS_Pr)) { SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01); } else { SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x35,0xFE); @@ -3574,23 +3411,24 @@ SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,USHORT ModeNo) if((ModeNo == 0x03) || (ModeNo == 0x10)) { SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x51,0x80); SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x56,0x08); - } + } } if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x30) & SetCRT2ToLCD) { SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0xfc); } - } else if((HwInfo->jChipType == SIS_630) || - (HwInfo->jChipType == SIS_730)) { - SiS_SetReg(SiS_Pr->SiS_P3d4,0x35,backupreg); +#endif + } else if((SiS_Pr->ChipType == SIS_630) || + (SiS_Pr->ChipType == SIS_730)) { + SiS_SetReg(SiS_Pr->SiS_P3d4,0x35,backupreg); } } -#ifdef LINUX_XF86 +#ifdef SIS_XORG_XF86 if(pScrn) { /* SetPitch: Adapt to virtual size & position */ if((ModeNo > 0x13) && (dosetpitch)) { - SiS_SetPitch(SiS_Pr, pScrn); + SiS_SetPitch(SiS_Pr, pScrn); } /* Backup/Set ModeNo in BIOS scratch area */ @@ -3598,33 +3436,37 @@ SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,USHORT ModeNo) } #endif -#ifdef LINUX_KERNEL /* We never lock registers in XF86 */ - if(KeepLockReg == 0xA1) SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86); - else SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x00); + SiS_CloseCRTC(SiS_Pr); + + SiS_Handle760(SiS_Pr); + +#ifdef SIS_LINUX_KERNEL + /* We never lock registers in XF86 */ + if(KeepLockReg != 0xA1) SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x00); #endif return TRUE; } /*********************************************/ -/* XFree86: SiSBIOSSetMode() */ +/* X.org/XFree86: SiSBIOSSetMode() */ /* for non-Dual-Head mode */ /*********************************************/ -#ifdef LINUX_XF86 +#ifdef SIS_XORG_XF86 BOOLEAN -SiSBIOSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, +SiSBIOSSetMode(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, DisplayModePtr mode, BOOLEAN IsCustom) { SISPtr pSiS = SISPTR(pScrn); - UShort ModeNo = 0; + unsigned short ModeNo = 0; SiS_Pr->UseCustomMode = FALSE; if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) { xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting custom mode %dx%d\n", - SiS_Pr->CHDisplay, + SiS_Pr->CHDisplay, (mode->Flags & V_INTERLACE ? SiS_Pr->CVDisplay * 2 : (mode->Flags & V_DBLSCAN ? SiS_Pr->CVDisplay / 2 : SiS_Pr->CVDisplay))); @@ -3632,32 +3474,33 @@ SiSBIOSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, } else { /* Don't need vbflags here; checks done earlier */ - ModeNo = SiS_GetModeNumber(pScrn, mode, 0); + ModeNo = SiS_GetModeNumber(pScrn, mode, pSiS->VBFlags); if(!ModeNo) return FALSE; xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting standard mode 0x%x\n", ModeNo); } - return(SiSSetMode(SiS_Pr, HwInfo, pScrn, ModeNo, TRUE)); + return(SiSSetMode(SiS_Pr, pScrn, ModeNo, TRUE)); } /*********************************************/ -/* XFree86: SiSBIOSSetModeCRT2() */ +/* X.org/XFree86: SiSBIOSSetModeCRT2() */ /* for Dual-Head modes */ /*********************************************/ + BOOLEAN -SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, +SiSBIOSSetModeCRT2(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, DisplayModePtr mode, BOOLEAN IsCustom) { - USHORT ModeIdIndex; - SISIOADDRESS BaseAddr = HwInfo->ulIOAddress; - UShort ModeNo = 0; - unsigned char backupreg=0; - SISPtr pSiS = SISPTR(pScrn); + SISIOADDRESS BaseAddr = SiS_Pr->IOAddress; + SISPtr pSiS = SISPTR(pScrn); #ifdef SISDUALHEAD SISEntPtr pSiSEnt = pSiS->entityPrivate; #endif + unsigned short ModeIdIndex; + unsigned short ModeNo = 0; + unsigned char backupreg = 0; SiS_Pr->UseCustomMode = FALSE; @@ -3672,22 +3515,25 @@ SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, } else { - ModeNo = SiS_GetModeNumber(pScrn, mode, 0); - if(!ModeNo) return FALSE; + ModeNo = SiS_GetModeNumber(pScrn, mode, pSiS->VBFlags); + if(!ModeNo) return FALSE; } SiSRegInit(SiS_Pr, BaseAddr); - SiSInitPtr(SiS_Pr, HwInfo); - SiS_GetSysFlags(SiS_Pr, HwInfo); -#if (defined(i386) || defined(__i386) || defined(__i386__) || defined(__AMD64__)) + SiSInitPtr(SiS_Pr); + SiS_GetSysFlags(SiS_Pr); +#if defined(i386) || defined(__i386) || defined(__i386__) || defined(__AMD64__) || defined(__amd64__) || defined(__x86_64__) SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff); #else SiS_Pr->SiS_VGAINFO = 0x11; #endif - SiSInitPCIetc(SiS_Pr, HwInfo); - SiSSetLVDSetc(SiS_Pr, HwInfo); - SiSDetermineROMUsage(SiS_Pr, HwInfo); + + SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86); + + SiSInitPCIetc(SiS_Pr); + SiSSetLVDSetc(SiS_Pr); + SiSDetermineROMUsage(SiS_Pr); /* Save mode info so we can set it from within SetMode for CRT1 */ #ifdef SISDUALHEAD @@ -3700,23 +3546,20 @@ SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, pSiSEnt->CRT2CR35 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); pSiSEnt->CRT2CR38 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); #if 0 - /* We can't set CRT2 mode before CRT1 mode is set */ + /* We can't set CRT2 mode before CRT1 mode is set - says who...? */ if(pSiSEnt->CRT1ModeNo == -1) { - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting CRT2 mode delayed until after setting CRT1 mode\n"); - return TRUE; + return TRUE; } #endif pSiSEnt->CRT2ModeSet = TRUE; } #endif - /* We don't clear the buffer in X */ - SiS_Pr->SiS_flag_clearbuffer=0; - if(SiS_Pr->UseCustomMode) { - USHORT temptemp = SiS_Pr->CVDisplay; + unsigned short temptemp = SiS_Pr->CVDisplay; if(SiS_Pr->CModeFlag & DoubleScanMode) temptemp >>= 1; else if(SiS_Pr->CInfoFlag & InterlaceMode) temptemp <<= 1; @@ -3728,13 +3571,11 @@ SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, } else { xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "Setting standard mode 0x%x on CRT2\n", ModeNo); + "Setting standard mode 0x%x on CRT2\n", ModeNo); } - SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86); - - SiS_UnLockCRT2(SiS_Pr, HwInfo); + SiS_UnLockCRT2(SiS_Pr); if(!SiS_Pr->UseCustomMode) { if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return FALSE; @@ -3742,56 +3583,59 @@ SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, ModeIdIndex = 0; } - SiS_GetVBType(SiS_Pr, HwInfo); + SiS_GetVBType(SiS_Pr); - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(HwInfo->jChipType >= SIS_315H) { - SiS_ResetVB(SiS_Pr, HwInfo); + SiS_InitVB(SiS_Pr); + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { + if(SiS_Pr->ChipType >= SIS_315H) { + SiS_ResetVB(SiS_Pr); SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x32,0x10); SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x00,0x0c); - backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); } else { - backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); + backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); } } /* Get VB information (connectors, connected devices) */ if(!SiS_Pr->UseCustomMode) { - SiS_GetVBInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, 1); + SiS_GetVBInfo(SiS_Pr, ModeNo, ModeIdIndex, 1); } else { /* If this is a custom mode, we don't check the modeflag for CRT2Mode */ - SiS_GetVBInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, 0); + SiS_GetVBInfo(SiS_Pr, ModeNo, ModeIdIndex, 0); } - SiS_SetYPbPr(SiS_Pr, HwInfo); - SiS_SetTVMode(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); - SiS_GetLCDResInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); - SiS_SetLowModeTest(SiS_Pr, ModeNo, HwInfo); + SiS_SetYPbPr(SiS_Pr); + SiS_SetTVMode(SiS_Pr, ModeNo, ModeIdIndex); + SiS_GetLCDResInfo(SiS_Pr, ModeNo, ModeIdIndex); + SiS_SetLowModeTest(SiS_Pr, ModeNo); + + SiS_ResetSegmentRegisters(SiS_Pr); /* Set mode on CRT2 */ if( (SiS_Pr->SiS_VBType & VB_SISVB) || (SiS_Pr->SiS_IF_DEF_LVDS == 1) || (SiS_Pr->SiS_IF_DEF_CH70xx != 0) || (SiS_Pr->SiS_IF_DEF_TRUMPION != 0) ) { - SiS_SetCRT2Group(SiS_Pr, HwInfo, ModeNo); + SiS_SetCRT2Group(SiS_Pr, ModeNo); } - SiS_StrangeStuff(SiS_Pr, HwInfo); + SiS_StrangeStuff(SiS_Pr); SiS_DisplayOn(SiS_Pr); SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF); - if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->ChipType >= SIS_315H) { if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(!(SiS_IsDualEdge(SiS_Pr, HwInfo))) { + if(!(SiS_IsDualEdge(SiS_Pr))) { SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); } } } - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(HwInfo->jChipType >= SIS_315H) { - if(!SiS_Pr->SiS_ROMNew) { - if(SiS_IsVAMode(SiS_Pr,HwInfo)) { + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { + if(SiS_Pr->ChipType >= SIS_315H) { + if(!SiS_Pr->SiS_ROMNew) { + if(SiS_IsVAMode(SiS_Pr)) { SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01); } else { SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x35,0xFE); @@ -3803,8 +3647,8 @@ SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x30) & SetCRT2ToLCD) { SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0xfc); } - } else if((HwInfo->jChipType == SIS_630) || - (HwInfo->jChipType == SIS_730)) { + } else if((SiS_Pr->ChipType == SIS_630) || + (SiS_Pr->ChipType == SIS_730)) { SiS_SetReg(SiS_Pr->SiS_P3d4,0x35,backupreg); } } @@ -3812,25 +3656,27 @@ SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, /* SetPitch: Adapt to virtual size & position */ SiS_SetPitchCRT2(SiS_Pr, pScrn); + SiS_Handle760(SiS_Pr); + return TRUE; } /*********************************************/ -/* XFree86: SiSBIOSSetModeCRT1() */ +/* X.org/XFree86: SiSBIOSSetModeCRT1() */ /* for Dual-Head modes */ /*********************************************/ BOOLEAN -SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, +SiSBIOSSetModeCRT1(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, DisplayModePtr mode, BOOLEAN IsCustom) { + SISIOADDRESS BaseAddr = SiS_Pr->IOAddress; SISPtr pSiS = SISPTR(pScrn); - SISIOADDRESS BaseAddr = HwInfo->ulIOAddress; - USHORT ModeIdIndex, ModeNo=0; - UCHAR backupreg=0; + unsigned short ModeIdIndex, ModeNo = 0; + unsigned char backupreg = 0; #ifdef SISDUALHEAD SISEntPtr pSiSEnt = pSiS->entityPrivate; - UCHAR backupcr30, backupcr31, backupcr38, backupcr35, backupp40d=0; + unsigned char backupcr30, backupcr31, backupcr38, backupcr35, backupp40d=0; BOOLEAN backupcustom; #endif @@ -3838,43 +3684,41 @@ SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) { - USHORT temptemp = SiS_Pr->CVDisplay; + unsigned short temptemp = SiS_Pr->CVDisplay; - if(SiS_Pr->CModeFlag & DoubleScanMode) temptemp >>= 1; - else if(SiS_Pr->CInfoFlag & InterlaceMode) temptemp <<= 1; + if(SiS_Pr->CModeFlag & DoubleScanMode) temptemp >>= 1; + else if(SiS_Pr->CInfoFlag & InterlaceMode) temptemp <<= 1; - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting custom mode %dx%d on CRT1\n", SiS_Pr->CHDisplay, temptemp); ModeNo = 0xfe; } else { - ModeNo = SiS_GetModeNumber(pScrn, mode, 0); - if(!ModeNo) return FALSE; + ModeNo = SiS_GetModeNumber(pScrn, mode, 0); /* don't give VBFlags */ + if(!ModeNo) return FALSE; - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting standard mode 0x%x on CRT1\n", ModeNo); } - SiSInitPtr(SiS_Pr, HwInfo); + SiSInitPtr(SiS_Pr); SiSRegInit(SiS_Pr, BaseAddr); - SiS_GetSysFlags(SiS_Pr, HwInfo); -#if (defined(i386) || defined(__i386) || defined(__i386__) || defined(__AMD64__)) + SiS_GetSysFlags(SiS_Pr); +#if defined(i386) || defined(__i386) || defined(__i386__) || defined(__AMD64__) || defined(__amd64__) || defined(__x86_64__) SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff); #else SiS_Pr->SiS_VGAINFO = 0x11; #endif - SiSInitPCIetc(SiS_Pr, HwInfo); - SiSSetLVDSetc(SiS_Pr, HwInfo); - SiSDetermineROMUsage(SiS_Pr, HwInfo); - - /* We don't clear the buffer in X */ - SiS_Pr->SiS_flag_clearbuffer = 0; SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86); - SiS_UnLockCRT2(SiS_Pr, HwInfo); + SiSInitPCIetc(SiS_Pr); + SiSSetLVDSetc(SiS_Pr); + SiSDetermineROMUsage(SiS_Pr); + + SiS_UnLockCRT2(SiS_Pr); if(!SiS_Pr->UseCustomMode) { if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return FALSE; @@ -3883,10 +3727,11 @@ SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, } /* Determine VBType */ - SiS_GetVBType(SiS_Pr, HwInfo); + SiS_GetVBType(SiS_Pr); - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(HwInfo->jChipType >= SIS_315H) { + SiS_InitVB(SiS_Pr); + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { + if(SiS_Pr->ChipType >= SIS_315H) { backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); } else { backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); @@ -3895,25 +3740,29 @@ SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, /* Get VB information (connectors, connected devices) */ /* (We don't care if the current mode is a CRT2 mode) */ - SiS_GetVBInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, 0); - SiS_SetYPbPr(SiS_Pr, HwInfo); - SiS_SetTVMode(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); - SiS_GetLCDResInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); - SiS_SetLowModeTest(SiS_Pr, ModeNo, HwInfo); + SiS_GetVBInfo(SiS_Pr, ModeNo, ModeIdIndex, 0); + SiS_SetYPbPr(SiS_Pr); + SiS_SetTVMode(SiS_Pr, ModeNo, ModeIdIndex); + SiS_GetLCDResInfo(SiS_Pr, ModeNo, ModeIdIndex); + SiS_SetLowModeTest(SiS_Pr, ModeNo); - if(HwInfo->jChipType >= SIS_315H) { - SiS_SetupCR5x(SiS_Pr, HwInfo); - } + SiS_OpenCRTC(SiS_Pr); /* Set mode on CRT1 */ - SiS_SetCRT1Group(SiS_Pr, HwInfo, ModeNo, ModeIdIndex); + SiS_SetCRT1Group(SiS_Pr, ModeNo, ModeIdIndex); if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - SiS_SetCRT2Group(SiS_Pr, HwInfo, ModeNo); + SiS_SetCRT2Group(SiS_Pr, ModeNo); } /* SetPitch: Adapt to virtual size & position */ SiS_SetPitchCRT1(SiS_Pr, pScrn); + SiS_HandleCRT1(SiS_Pr); + + SiS_StrangeStuff(SiS_Pr); + + SiS_CloseCRTC(SiS_Pr); + #ifdef SISDUALHEAD if(pSiS->DualHeadMode) { pSiSEnt->CRT1ModeNo = ModeNo; @@ -3933,7 +3782,7 @@ SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, #ifdef SISDUALHEAD if(pSiS->DualHeadMode) { if(pSiSEnt->CRT2ModeNo != -1) { - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "(Re-)Setting mode for CRT2\n"); backupcustom = SiS_Pr->UseCustomMode; backupcr30 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); @@ -3952,9 +3801,11 @@ SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, SiS_SetReg(SiS_Pr->SiS_P3d4,0x35,pSiSEnt->CRT2CR35); SiS_SetReg(SiS_Pr->SiS_P3d4,0x38,pSiSEnt->CRT2CR38); } - SiSBIOSSetModeCRT2(SiS_Pr, HwInfo, pSiSEnt->pScrn_1, + + SiSBIOSSetModeCRT2(SiS_Pr, pSiSEnt->pScrn_1, pSiSEnt->CRT2DMode, pSiSEnt->CRT2IsCustom); - SiS_SetReg(SiS_Pr->SiS_P3d4,0x30,backupcr30); + + SiS_SetReg(SiS_Pr->SiS_P3d4,0x30,backupcr30); SiS_SetReg(SiS_Pr->SiS_P3d4,0x31,backupcr31); SiS_SetReg(SiS_Pr->SiS_P3d4,0x35,backupcr35); SiS_SetReg(SiS_Pr->SiS_P3d4,0x38,backupcr38); @@ -3970,22 +3821,20 @@ SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, * possibly overwritten */ - SiS_HandleCRT1(SiS_Pr); - - SiS_StrangeStuff(SiS_Pr, HwInfo); - SiS_DisplayOn(SiS_Pr); SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF); - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { + if(SiS_Pr->ChipType >= SIS_315H) { SiS_SetReg(SiS_Pr->SiS_P3d4,0x38,backupreg); - } else if((HwInfo->jChipType == SIS_630) || - (HwInfo->jChipType == SIS_730)) { + } else if((SiS_Pr->ChipType == SIS_630) || + (SiS_Pr->ChipType == SIS_730)) { SiS_SetReg(SiS_Pr->SiS_P3d4,0x35,backupreg); } } + SiS_Handle760(SiS_Pr); + /* Backup/Set ModeNo in BIOS scratch area */ SiS_GetSetModeID(pScrn,ModeNo); @@ -3993,84 +3842,6 @@ SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, } #endif /* Linux_XF86 */ - -#ifdef LINUX_XF86 -BOOLEAN -SiS_GetPanelID(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) -{ - const USHORT PanelTypeTable300[16] = { - 0xc101, 0xc117, 0x0121, 0xc135, 0xc142, 0xc152, 0xc162, 0xc072, - 0xc181, 0xc192, 0xc1a1, 0xc1b6, 0xc1c2, 0xc0d2, 0xc1e2, 0xc1f2 - }; - const USHORT PanelTypeTable31030x[16] = { - 0xc102, 0xc112, 0x0122, 0xc132, 0xc142, 0xc152, 0xc169, 0xc179, - 0x0189, 0xc192, 0xc1a2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 - }; - const USHORT PanelTypeTable310LVDS[16] = { - 0xc111, 0xc122, 0xc133, 0xc144, 0xc155, 0xc166, 0xc177, 0xc188, - 0xc199, 0xc0aa, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 - }; - USHORT tempax,tempbx,temp; - - if(HwInfo->jChipType < SIS_315H) { - - tempax = SiS_GetReg(SiS_Pr->SiS_P3c4,0x18); - tempbx = tempax & 0x0F; - if(!(tempax & 0x10)){ - if(SiS_Pr->SiS_IF_DEF_LVDS == 1){ - tempbx = 0; - temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x38); - if(temp & 0x40) tempbx |= 0x08; - if(temp & 0x20) tempbx |= 0x02; - if(temp & 0x01) tempbx |= 0x01; - temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x39); - if(temp & 0x80) tempbx |= 0x04; - } else { - return 0; - } - } - tempbx = PanelTypeTable300[tempbx]; - tempbx |= LCDSync; - temp = tempbx & 0x00FF; - SiS_SetReg(SiS_Pr->SiS_P3d4,0x36,temp); - temp = (tempbx & 0xFF00) >> 8; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x37,~(LCDSyncBit|LCDRGB18Bit),temp); - - } else { - - if(HwInfo->jChipType >= SIS_661) return 0; - - tempax = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1a); - tempax &= 0x1e; - tempax >>= 1; - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(tempax == 0) { - /* TODO: Include HUGE detection routine - (Probably not worth bothering) - */ - return 0; - } - temp = tempax & 0xff; - tempax--; - tempbx = PanelTypeTable310LVDS[tempax]; - } else { - tempbx = PanelTypeTable31030x[tempax]; - temp = tempbx & 0xff; - } - SiS_SetReg(SiS_Pr->SiS_P3d4,0x36,temp); - tempbx = (tempbx & 0xff00) >> 8; - temp = tempbx & 0xc1; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x37,~(LCDSyncBit|LCDRGB18Bit),temp); - if(SiS_Pr->SiS_VBType & VB_SISVB) { - temp = tempbx & 0x04; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x39,0xfb,temp); - } - - } - return 1; -} -#endif - #ifndef GETBITSTR #define BITMASK(h,l) (((unsigned)(1U << ((h)-(l)+1))-1)<<(l)) #define GENMASK(mask) BITMASK(1?mask,0?mask) @@ -4078,26 +3849,28 @@ SiS_GetPanelID(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) #define GETBITSTR(val,from,to) ((GETBITS(val,from)) << (0?to)) #endif -static void -SiS_CalcCRRegisters(SiS_Private *SiS_Pr, int depth) +void +SiS_CalcCRRegisters(struct SiS_Private *SiS_Pr, int depth) { + int x = 1; /* Fix sync */ + SiS_Pr->CCRT1CRTC[0] = ((SiS_Pr->CHTotal >> 3) - 5) & 0xff; /* CR0 */ SiS_Pr->CCRT1CRTC[1] = (SiS_Pr->CHDisplay >> 3) - 1; /* CR1 */ SiS_Pr->CCRT1CRTC[2] = (SiS_Pr->CHBlankStart >> 3) - 1; /* CR2 */ SiS_Pr->CCRT1CRTC[3] = (((SiS_Pr->CHBlankEnd >> 3) - 1) & 0x1F) | 0x80; /* CR3 */ SiS_Pr->CCRT1CRTC[4] = (SiS_Pr->CHSyncStart >> 3) + 3; /* CR4 */ SiS_Pr->CCRT1CRTC[5] = ((((SiS_Pr->CHBlankEnd >> 3) - 1) & 0x20) << 2) | /* CR5 */ - (((SiS_Pr->CHSyncEnd >> 3) + 3) & 0x1F); + (((SiS_Pr->CHSyncEnd >> 3) + 3) & 0x1F); - SiS_Pr->CCRT1CRTC[6] = (SiS_Pr->CVTotal - 2) & 0xFF; /* CR6 */ - SiS_Pr->CCRT1CRTC[7] = (((SiS_Pr->CVTotal - 2) & 0x100) >> 8) /* CR7 */ - | (((SiS_Pr->CVDisplay - 1) & 0x100) >> 7) - | ((SiS_Pr->CVSyncStart & 0x100) >> 6) - | (((SiS_Pr->CVBlankStart - 1) & 0x100) >> 5) + SiS_Pr->CCRT1CRTC[6] = (SiS_Pr->CVTotal - 2) & 0xFF; /* CR6 */ + SiS_Pr->CCRT1CRTC[7] = (((SiS_Pr->CVTotal - 2) & 0x100) >> 8) /* CR7 */ + | (((SiS_Pr->CVDisplay - 1) & 0x100) >> 7) + | (((SiS_Pr->CVSyncStart - x) & 0x100) >> 6) + | (((SiS_Pr->CVBlankStart- 1) & 0x100) >> 5) | 0x10 - | (((SiS_Pr->CVTotal - 2) & 0x200) >> 4) - | (((SiS_Pr->CVDisplay - 1) & 0x200) >> 3) - | ((SiS_Pr->CVSyncStart & 0x200) >> 2); + | (((SiS_Pr->CVTotal - 2) & 0x200) >> 4) + | (((SiS_Pr->CVDisplay - 1) & 0x200) >> 3) + | (((SiS_Pr->CVSyncStart - x) & 0x200) >> 2); SiS_Pr->CCRT1CRTC[16] = ((((SiS_Pr->CVBlankStart - 1) & 0x200) >> 4) >> 5); /* CR9 */ @@ -4106,55 +3879,44 @@ SiS_CalcCRRegisters(SiS_Private *SiS_Pr, int depth) else if(SiS_Pr->CHDisplay >= 640) SiS_Pr->CCRT1CRTC[16] |= 0x40; } -#if 0 - if (mode->VScan >= 32) - regp->CRTC[9] |= 0x1F; - else if (mode->VScan > 1) - regp->CRTC[9] |= mode->VScan - 1; -#endif - - SiS_Pr->CCRT1CRTC[8] = (SiS_Pr->CVSyncStart ) & 0xFF; /* CR10 */ - SiS_Pr->CCRT1CRTC[9] = ((SiS_Pr->CVSyncEnd ) & 0x0F) | 0x80; /* CR11 */ + SiS_Pr->CCRT1CRTC[8] = (SiS_Pr->CVSyncStart - x) & 0xFF; /* CR10 */ + SiS_Pr->CCRT1CRTC[9] = ((SiS_Pr->CVSyncEnd - x) & 0x0F) | 0x80; /* CR11 */ SiS_Pr->CCRT1CRTC[10] = (SiS_Pr->CVDisplay - 1) & 0xFF; /* CR12 */ SiS_Pr->CCRT1CRTC[11] = (SiS_Pr->CVBlankStart - 1) & 0xFF; /* CR15 */ SiS_Pr->CCRT1CRTC[12] = (SiS_Pr->CVBlankEnd - 1) & 0xFF; /* CR16 */ SiS_Pr->CCRT1CRTC[13] = /* SRA */ - GETBITSTR((SiS_Pr->CVTotal -2), 10:10, 0:0) | - GETBITSTR((SiS_Pr->CVDisplay -1), 10:10, 1:1) | - GETBITSTR((SiS_Pr->CVBlankStart-1), 10:10, 2:2) | - GETBITSTR((SiS_Pr->CVSyncStart ), 10:10, 3:3) | - GETBITSTR((SiS_Pr->CVBlankEnd -1), 8:8, 4:4) | - GETBITSTR((SiS_Pr->CVSyncEnd ), 4:4, 5:5) ; + GETBITSTR((SiS_Pr->CVTotal -2), 10:10, 0:0) | + GETBITSTR((SiS_Pr->CVDisplay -1), 10:10, 1:1) | + GETBITSTR((SiS_Pr->CVBlankStart-1), 10:10, 2:2) | + GETBITSTR((SiS_Pr->CVSyncStart -x), 10:10, 3:3) | + GETBITSTR((SiS_Pr->CVBlankEnd -1), 8:8, 4:4) | + GETBITSTR((SiS_Pr->CVSyncEnd ), 4:4, 5:5) ; SiS_Pr->CCRT1CRTC[14] = /* SRB */ - GETBITSTR((SiS_Pr->CHTotal >> 3) - 5, 9:8, 1:0) | - GETBITSTR((SiS_Pr->CHDisplay >> 3) - 1, 9:8, 3:2) | - GETBITSTR((SiS_Pr->CHBlankStart >> 3) - 1, 9:8, 5:4) | - GETBITSTR((SiS_Pr->CHSyncStart >> 3) + 3, 9:8, 7:6) ; + GETBITSTR((SiS_Pr->CHTotal >> 3) - 5, 9:8, 1:0) | + GETBITSTR((SiS_Pr->CHDisplay >> 3) - 1, 9:8, 3:2) | + GETBITSTR((SiS_Pr->CHBlankStart >> 3) - 1, 9:8, 5:4) | + GETBITSTR((SiS_Pr->CHSyncStart >> 3) + 3, 9:8, 7:6) ; SiS_Pr->CCRT1CRTC[15] = /* SRC */ - GETBITSTR((SiS_Pr->CHBlankEnd >> 3) - 1, 7:6, 1:0) | - GETBITSTR((SiS_Pr->CHSyncEnd >> 3) + 3, 5:5, 2:2) ; + GETBITSTR((SiS_Pr->CHBlankEnd >> 3) - 1, 7:6, 1:0) | + GETBITSTR((SiS_Pr->CHSyncEnd >> 3) + 3, 5:5, 2:2) ; } void -SiS_CalcLCDACRT1Timing(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex) +SiS_CalcLCDACRT1Timing(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex) { - USHORT modeflag, tempax, tempbx, VGAHDE = SiS_Pr->SiS_VGAHDE; - int i,j; + unsigned short modeflag, tempax, tempbx = 0, remaining = 0; + unsigned short VGAHDE = SiS_Pr->SiS_VGAHDE; + int i, j; /* 1:1 data: use data set by setcrt1crtc() */ if(SiS_Pr->SiS_LCDInfo & LCDPass11) return; - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - } else if(SiS_Pr->UseCustomMode) { - modeflag = SiS_Pr->CModeFlag; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - } + modeflag = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex); if(modeflag & HalfDCLK) VGAHDE >>= 1; @@ -4164,32 +3926,91 @@ SiS_CalcLCDACRT1Timing(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex) SiS_Pr->CVDisplay = SiS_Pr->SiS_VGAVDE; SiS_Pr->CVBlankStart = SiS_Pr->SiS_VGAVDE; - tempbx = SiS_Pr->PanelHT - SiS_Pr->PanelXRes; - tempax = SiS_Pr->SiS_VGAHDE; /* not /2 ! */ - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { - tempax = SiS_Pr->PanelXRes; + if(SiS_Pr->ChipType < SIS_315H) { +#ifdef SIS300 + tempbx = SiS_Pr->SiS_VGAHT; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + tempbx = SiS_Pr->PanelHT; + } + if(modeflag & HalfDCLK) tempbx >>= 1; + remaining = tempbx % 8; +#endif + } else { +#ifdef SIS315H + /* OK for LCDA, LVDS */ + tempbx = SiS_Pr->PanelHT - SiS_Pr->PanelXRes; + tempax = SiS_Pr->SiS_VGAHDE; /* not /2 ! */ + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + tempax = SiS_Pr->PanelXRes; + } + tempbx += tempax; + if(modeflag & HalfDCLK) tempbx -= VGAHDE; +#endif } - tempbx += tempax; - if(modeflag & HalfDCLK) tempbx -= VGAHDE; SiS_Pr->CHTotal = SiS_Pr->CHBlankEnd = tempbx; - tempax = VGAHDE; - tempbx = SiS_Pr->CHTotal; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { - tempbx = SiS_Pr->PanelXRes; - if(modeflag & HalfDCLK) tempbx >>= 1; - tempax += ((tempbx - tempax) >> 1); + if(SiS_Pr->ChipType < SIS_315H) { +#ifdef SIS300 + if(SiS_Pr->SiS_VGAHDE == SiS_Pr->PanelXRes) { + SiS_Pr->CHSyncStart = SiS_Pr->SiS_VGAHDE + ((SiS_Pr->PanelHRS + 1) & ~1); + SiS_Pr->CHSyncEnd = SiS_Pr->CHSyncStart + SiS_Pr->PanelHRE; + if(modeflag & HalfDCLK) { + SiS_Pr->CHSyncStart >>= 1; + SiS_Pr->CHSyncEnd >>= 1; + } + } else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + tempax = (SiS_Pr->PanelXRes - SiS_Pr->SiS_VGAHDE) >> 1; + tempbx = (SiS_Pr->PanelHRS + 1) & ~1; + if(modeflag & HalfDCLK) { + tempax >>= 1; + tempbx >>= 1; + } + SiS_Pr->CHSyncStart = (VGAHDE + tempax + tempbx + 7) & ~7; + tempax = SiS_Pr->PanelHRE + 7; + if(modeflag & HalfDCLK) tempax >>= 1; + SiS_Pr->CHSyncEnd = (SiS_Pr->CHSyncStart + tempax) & ~7; + } else { + SiS_Pr->CHSyncStart = SiS_Pr->SiS_VGAHDE; + if(modeflag & HalfDCLK) { + SiS_Pr->CHSyncStart >>= 1; + tempax = ((SiS_Pr->CHTotal - SiS_Pr->CHSyncStart) / 3) << 1; + SiS_Pr->CHSyncEnd = SiS_Pr->CHSyncStart + tempax; + } else { + SiS_Pr->CHSyncEnd = (SiS_Pr->CHSyncStart + (SiS_Pr->CHTotal / 10) + 7) & ~7; + SiS_Pr->CHSyncStart += 8; + } + } +#endif + } else { +#ifdef SIS315H + tempax = VGAHDE; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + tempbx = SiS_Pr->PanelXRes; + if(modeflag & HalfDCLK) tempbx >>= 1; + tempax += ((tempbx - tempax) >> 1); + } + tempax += SiS_Pr->PanelHRS; + SiS_Pr->CHSyncStart = tempax; + tempax += SiS_Pr->PanelHRE; + SiS_Pr->CHSyncEnd = tempax; +#endif } - tempax += SiS_Pr->PanelHRS; - SiS_Pr->CHSyncStart = tempax; - tempax += SiS_Pr->PanelHRE; - SiS_Pr->CHSyncEnd = tempax; - tempbx = SiS_Pr->PanelVT - SiS_Pr->PanelYRes; tempax = SiS_Pr->SiS_VGAVDE; if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { tempax = SiS_Pr->PanelYRes; + } else if(SiS_Pr->ChipType < SIS_315H) { +#ifdef SIS300 + /* Stupid hack for 640x400/320x200 */ + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { + if((tempax + tempbx) == 438) tempbx += 16; + } else if((SiS_Pr->SiS_LCDResInfo == Panel_800x600) || + (SiS_Pr->SiS_LCDResInfo == Panel_1024x600)) { + tempax = 0; + tempbx = SiS_Pr->SiS_VGAVT; + } +#endif } SiS_Pr->CVTotal = SiS_Pr->CVBlankEnd = tempbx + tempax; @@ -4201,22 +4022,28 @@ SiS_CalcLCDACRT1Timing(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex) SiS_Pr->CVSyncStart = tempax; tempax += SiS_Pr->PanelVRE; SiS_Pr->CVSyncEnd = tempax; + if(SiS_Pr->ChipType < SIS_315H) { + SiS_Pr->CVSyncStart--; + SiS_Pr->CVSyncEnd--; + } SiS_CalcCRRegisters(SiS_Pr, 8); + SiS_Pr->CCRT1CRTC[15] &= ~0xF8; + SiS_Pr->CCRT1CRTC[15] |= (remaining << 4); SiS_Pr->CCRT1CRTC[16] &= ~0xE0; SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); - for(i=0,j=0;i<=7;i++,j++) { + for(i = 0, j = 0; i <= 7; i++, j++) { SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->CCRT1CRTC[i]); } - for(j=0x10;i<=10;i++,j++) { + for(j = 0x10; i <= 10; i++, j++) { SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->CCRT1CRTC[i]); } - for(j=0x15;i<=12;i++,j++) { + for(j = 0x15; i <= 12; i++, j++) { SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->CCRT1CRTC[i]); } - for(j=0x0A;i<=15;i++,j++) { + for(j = 0x0A; i <= 15; i++, j++) { SiS_SetReg(SiS_Pr->SiS_P3c4,j,SiS_Pr->CCRT1CRTC[i]); } @@ -4227,1092 +4054,192 @@ SiS_CalcLCDACRT1Timing(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex) if(modeflag & DoubleScanMode) tempax |= 0x80; SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0x5F,tempax); +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "%d %d %d %d %d %d %d %d (%d %d %d %d)\n", - SiS_Pr->CHDisplay, SiS_Pr->CHSyncStart, SiS_Pr->CHSyncEnd, SiS_Pr->CHTotal, + SiS_Pr->CHDisplay, SiS_Pr->CHSyncStart, SiS_Pr->CHSyncEnd, SiS_Pr->CHTotal, SiS_Pr->CVDisplay, SiS_Pr->CVSyncStart, SiS_Pr->CVSyncEnd, SiS_Pr->CVTotal, SiS_Pr->CHBlankStart, SiS_Pr->CHBlankEnd, SiS_Pr->CVBlankStart, SiS_Pr->CVBlankEnd); - xf86DrvMsg(0, X_INFO, " {{0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,\n", - SiS_Pr->CCRT1CRTC[0], SiS_Pr->CCRT1CRTC[1], + SiS_Pr->CCRT1CRTC[0], SiS_Pr->CCRT1CRTC[1], SiS_Pr->CCRT1CRTC[2], SiS_Pr->CCRT1CRTC[3], SiS_Pr->CCRT1CRTC[4], SiS_Pr->CCRT1CRTC[5], SiS_Pr->CCRT1CRTC[6], SiS_Pr->CCRT1CRTC[7]); xf86DrvMsg(0, X_INFO, " 0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,\n", - SiS_Pr->CCRT1CRTC[8], SiS_Pr->CCRT1CRTC[9], + SiS_Pr->CCRT1CRTC[8], SiS_Pr->CCRT1CRTC[9], SiS_Pr->CCRT1CRTC[10], SiS_Pr->CCRT1CRTC[11], SiS_Pr->CCRT1CRTC[12], SiS_Pr->CCRT1CRTC[13], SiS_Pr->CCRT1CRTC[14], SiS_Pr->CCRT1CRTC[15]); xf86DrvMsg(0, X_INFO, " 0x%02x}},\n", SiS_Pr->CCRT1CRTC[16]); #endif +#endif } -#ifdef LINUX_XF86 - void -SiS_MakeClockRegs(ScrnInfoPtr pScrn, int clock, UCHAR *p2b, UCHAR *p2c) -{ - int out_n, out_dn, out_div, out_sbit, out_scale; - unsigned int vclk[5]; - -#define Midx 0 -#define Nidx 1 -#define VLDidx 2 -#define Pidx 3 -#define PSNidx 4 - - if(SiS_compute_vclk(clock, &out_n, &out_dn, &out_div, &out_sbit, &out_scale)) { - (*p2b) = (out_div == 2) ? 0x80 : 0x00; - (*p2b) |= ((out_n - 1) & 0x7f); - (*p2c) = (out_dn - 1) & 0x1f; - (*p2c) |= (((out_scale - 1) & 3) << 5); - (*p2c) |= ((out_sbit & 0x01) << 7); -#ifdef TWDEBUG - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Clock %d: n %d dn %d div %d sb %d sc %d\n", - clock, out_n, out_dn, out_div, out_sbit, out_scale); +SiS_Generic_ConvertCRData(struct SiS_Private *SiS_Pr, unsigned char *crdata, + int xres, int yres, +#ifdef SIS_XORG_XF86 + DisplayModePtr current #endif - } else { - SiSCalcClock(pScrn, clock, 2, vclk); - (*p2b) = (vclk[VLDidx] == 2) ? 0x80 : 0x00; - (*p2b) |= (vclk[Midx] - 1) & 0x7f; - (*p2c) = (vclk[Nidx] - 1) & 0x1f; - if(vclk[Pidx] <= 4) { - /* postscale 1,2,3,4 */ - (*p2c) |= ((vclk[Pidx] - 1) & 3) << 5; - } else { - /* postscale 6,8 */ - (*p2c) |= (((vclk[Pidx] / 2) - 1) & 3) << 5; - (*p2c) |= 0x80; - } -#ifdef TWDEBUG - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Clock %d: n %d dn %d div %d sc %d\n", - clock, vclk[Midx], vclk[Nidx], vclk[VLDidx], vclk[Pidx]); +#ifdef SIS_LINUX_KERNEL + struct fb_var_screeninfo *var, BOOLEAN writeres #endif - } -} - -#endif - -/* ================ XFREE86/X.ORG ================= */ - -/* Helper functions */ - -#ifdef LINUX_XF86 - -USHORT -SiS_CheckBuildCustomMode(ScrnInfoPtr pScrn, DisplayModePtr mode, int VBFlags) +) { - SISPtr pSiS = SISPTR(pScrn); - int depth = pSiS->CurrentLayout.bitsPerPixel; - - pSiS->SiS_Pr->CModeFlag = 0; - - pSiS->SiS_Pr->CDClock = mode->Clock; - - pSiS->SiS_Pr->CHDisplay = mode->HDisplay; - pSiS->SiS_Pr->CHSyncStart = mode->HSyncStart; - pSiS->SiS_Pr->CHSyncEnd = mode->HSyncEnd; - pSiS->SiS_Pr->CHTotal = mode->HTotal; - - pSiS->SiS_Pr->CVDisplay = mode->VDisplay; - pSiS->SiS_Pr->CVSyncStart = mode->VSyncStart; - pSiS->SiS_Pr->CVSyncEnd = mode->VSyncEnd; - pSiS->SiS_Pr->CVTotal = mode->VTotal; - - pSiS->SiS_Pr->CFlags = mode->Flags; - - if(pSiS->SiS_Pr->CFlags & V_INTERLACE) { - pSiS->SiS_Pr->CVDisplay >>= 1; - pSiS->SiS_Pr->CVSyncStart >>= 1; - pSiS->SiS_Pr->CVSyncEnd >>= 1; - pSiS->SiS_Pr->CVTotal >>= 1; - } - if(pSiS->SiS_Pr->CFlags & V_DBLSCAN) { - /* pSiS->SiS_Pr->CDClock <<= 1; */ - pSiS->SiS_Pr->CVDisplay <<= 1; - pSiS->SiS_Pr->CVSyncStart <<= 1; - pSiS->SiS_Pr->CVSyncEnd <<= 1; - pSiS->SiS_Pr->CVTotal <<= 1; - } - - pSiS->SiS_Pr->CHBlankStart = pSiS->SiS_Pr->CHDisplay; - pSiS->SiS_Pr->CHBlankEnd = pSiS->SiS_Pr->CHTotal; - pSiS->SiS_Pr->CVBlankStart = pSiS->SiS_Pr->CVSyncStart - 1; - pSiS->SiS_Pr->CVBlankEnd = pSiS->SiS_Pr->CVTotal; + unsigned short HRE, HBE, HRS, HBS, HDE, HT; + unsigned short VRE, VBE, VRS, VBS, VDE, VT; + unsigned char sr_data, cr_data, cr_data2; + int A, B, C, D, E, F, temp; - SiS_MakeClockRegs(pScrn, pSiS->SiS_Pr->CDClock, &pSiS->SiS_Pr->CSR2B, &pSiS->SiS_Pr->CSR2C); + sr_data = crdata[14]; - pSiS->SiS_Pr->CSRClock = (pSiS->SiS_Pr->CDClock / 1000) + 1; + /* Horizontal total */ + HT = crdata[0] | ((unsigned short)(sr_data & 0x03) << 8); + A = HT + 5; - SiS_CalcCRRegisters(pSiS->SiS_Pr, depth); + /* Horizontal display enable end */ + HDE = crdata[1] | ((unsigned short)(sr_data & 0x0C) << 6); + E = HDE + 1; - switch(depth) { - case 8: pSiS->SiS_Pr->CModeFlag |= 0x223b; break; - case 16: pSiS->SiS_Pr->CModeFlag |= 0x227d; break; - case 32: pSiS->SiS_Pr->CModeFlag |= 0x22ff; break; - default: return 0; - } + /* Horizontal retrace (=sync) start */ + HRS = crdata[4] | ((unsigned short)(sr_data & 0xC0) << 2); + F = HRS - E - 3; - if(pSiS->SiS_Pr->CFlags & V_DBLSCAN) - pSiS->SiS_Pr->CModeFlag |= DoubleScanMode; + /* Horizontal blank start */ + HBS = crdata[2] | ((unsigned short)(sr_data & 0x30) << 4); - if((pSiS->SiS_Pr->CVDisplay >= 1024) || - (pSiS->SiS_Pr->CVTotal >= 1024) || - (pSiS->SiS_Pr->CHDisplay >= 1024)) - pSiS->SiS_Pr->CModeFlag |= LineCompareOff; + sr_data = crdata[15]; + cr_data = crdata[5]; - if(pSiS->SiS_Pr->CFlags & V_CLKDIV2) - pSiS->SiS_Pr->CModeFlag |= HalfDCLK; + /* Horizontal blank end */ + HBE = (crdata[3] & 0x1f) | + ((unsigned short)(cr_data & 0x80) >> 2) | + ((unsigned short)(sr_data & 0x03) << 6); - pSiS->SiS_Pr->CInfoFlag = 0x0007; + /* Horizontal retrace (=sync) end */ + HRE = (cr_data & 0x1f) | ((sr_data & 0x04) << 3); - if(pSiS->SiS_Pr->CFlags & V_NHSYNC) - pSiS->SiS_Pr->CInfoFlag |= 0x4000; + temp = HBE - ((E - 1) & 255); + B = (temp > 0) ? temp : (temp + 256); - if(pSiS->SiS_Pr->CFlags & V_NVSYNC) - pSiS->SiS_Pr->CInfoFlag |= 0x8000; + temp = HRE - ((E + F + 3) & 63); + C = (temp > 0) ? temp : (temp + 64); - if(pSiS->SiS_Pr->CFlags & V_INTERLACE) - pSiS->SiS_Pr->CInfoFlag |= InterlaceMode; + D = B - F - C; - pSiS->SiS_Pr->UseCustomMode = TRUE; +#ifdef SIS_XORG_XF86 + current->HDisplay = (E * 8); + current->HSyncStart = (E * 8) + (F * 8); + current->HSyncEnd = (E * 8) + (F * 8) + (C * 8); + current->HTotal = (E * 8) + (F * 8) + (C * 8) + (D * 8); #ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "Custom mode %dx%d:\n", - pSiS->SiS_Pr->CHDisplay,pSiS->SiS_Pr->CVDisplay); - xf86DrvMsg(0, X_INFO, "Modeflag %04x, Infoflag %04x\n", - pSiS->SiS_Pr->CModeFlag, pSiS->SiS_Pr->CInfoFlag); - xf86DrvMsg(0, X_INFO, " {{0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,\n", - pSiS->SiS_Pr->CCRT1CRTC[0], pSiS->SiS_Pr->CCRT1CRTC[1], - pSiS->SiS_Pr->CCRT1CRTC[2], pSiS->SiS_Pr->CCRT1CRTC[3], - pSiS->SiS_Pr->CCRT1CRTC[4], pSiS->SiS_Pr->CCRT1CRTC[5], - pSiS->SiS_Pr->CCRT1CRTC[6], pSiS->SiS_Pr->CCRT1CRTC[7]); - xf86DrvMsg(0, X_INFO, " 0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,\n", - pSiS->SiS_Pr->CCRT1CRTC[8], pSiS->SiS_Pr->CCRT1CRTC[9], - pSiS->SiS_Pr->CCRT1CRTC[10], pSiS->SiS_Pr->CCRT1CRTC[11], - pSiS->SiS_Pr->CCRT1CRTC[12], pSiS->SiS_Pr->CCRT1CRTC[13], - pSiS->SiS_Pr->CCRT1CRTC[14], pSiS->SiS_Pr->CCRT1CRTC[15]); - xf86DrvMsg(0, X_INFO, " 0x%02x}},\n", pSiS->SiS_Pr->CCRT1CRTC[16]); - xf86DrvMsg(0, X_INFO, "Clock: 0x%02x, 0x%02x, %d\n", - pSiS->SiS_Pr->CSR2B, pSiS->SiS_Pr->CSR2C, pSiS->SiS_Pr->CSRClock); -#endif - return 1; -} - -int -SiS_FindPanelFromDB(SISPtr pSiS, USHORT panelvendor, USHORT panelproduct, int *maxx, int *maxy, int *prefx, int *prefy) -{ - int i, j; - BOOLEAN done = FALSE; - - i = 0; - while((!done) && (SiS_PlasmaTable[i].vendor) && panelvendor) { - if(SiS_PlasmaTable[i].vendor == panelvendor) { - for(j=0; j<SiS_PlasmaTable[i].productnum; j++) { - if(SiS_PlasmaTable[i].product[j] == panelproduct) { - if(SiS_PlasmaTable[i].maxx && SiS_PlasmaTable[i].maxy) { - (*maxx) = (int)SiS_PlasmaTable[i].maxx; - (*maxy) = (int)SiS_PlasmaTable[i].maxy; - (*prefx) = (int)SiS_PlasmaTable[i].prefx; - (*prefy) = (int)SiS_PlasmaTable[i].prefy; - done = TRUE; - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "Identified %s, correcting max X res %d, max Y res %d\n", - SiS_PlasmaTable[i].plasmaname, - SiS_PlasmaTable[i].maxx, SiS_PlasmaTable[i].maxy); - break; - } - } - } - } - i++; - } - return (done) ? 1 : 0; -} - -/* Build a list of supported modes: - * Built-in modes for which we have all data are M_T_DEFAULT, - * modes derived from DDC or database data are M_T_BUILTIN - */ -DisplayModePtr -SiSBuildBuiltInModeList(ScrnInfoPtr pScrn, BOOLEAN includelcdmodes, BOOLEAN isfordvi) -{ - SISPtr pSiS = SISPTR(pScrn); - unsigned short VRE, VBE, VRS, VBS, VDE, VT; - unsigned short HRE, HBE, HRS, HBS, HDE, HT; - unsigned char sr_data, cr_data, cr_data2, cr_data3; - unsigned char sr2b, sr2c; - float num, denum, postscalar, divider; - int A, B, C, D, E, F, temp, i, j, k, l, index, vclkindex; - DisplayModePtr new = NULL, current = NULL, first = NULL; - BOOLEAN done = FALSE; -#if 0 - DisplayModePtr backup = NULL; -#endif - - pSiS->backupmodelist = NULL; - pSiS->AddedPlasmaModes = FALSE; - - /* Initialize our pointers */ - if(pSiS->VGAEngine == SIS_300_VGA) { -#ifdef SIS300 - InitTo300Pointer(pSiS->SiS_Pr, &pSiS->sishw_ext); + xf86DrvMsg(0, X_INFO, + "H: A %d B %d C %d D %d E %d F %d HT %d HDE %d HRS %d HBS %d HBE %d HRE %d\n", + A, B, C, D, E, F, HT, HDE, HRS, HBS, HBE, HRE); #else - return NULL; + (void)VBS; (void)HBS; (void)A; #endif - } else if(pSiS->VGAEngine == SIS_315_VGA) { -#ifdef SIS315H - InitTo310Pointer(pSiS->SiS_Pr, &pSiS->sishw_ext); -#else - return NULL; -#endif - } else return NULL; - - i = 0; - while(pSiS->SiS_Pr->SiS_RefIndex[i].Ext_InfoFlag != 0xFFFF) { - - index = pSiS->SiS_Pr->SiS_RefIndex[i].Ext_CRT1CRTC; - - /* 0x5a (320x240) is a pure FTSN mode, not DSTN! */ - if((!pSiS->FSTN) && - (pSiS->SiS_Pr->SiS_RefIndex[i].ModeID == 0x5a)) { - i++; - continue; - } - if((pSiS->FSTN) && - (pSiS->SiS_Pr->SiS_RefIndex[i].XRes == 320) && - (pSiS->SiS_Pr->SiS_RefIndex[i].YRes == 240) && - (pSiS->SiS_Pr->SiS_RefIndex[i].ModeID != 0x5a)) { - i++; - continue; - } - - if(!(new = xalloc(sizeof(DisplayModeRec)))) return first; - memset(new, 0, sizeof(DisplayModeRec)); - if(!(new->name = xalloc(10))) { - xfree(new); - return first; - } - if(!first) first = new; - if(current) { - current->next = new; - new->prev = current; - } - - current = new; - - sprintf(current->name, "%dx%d", pSiS->SiS_Pr->SiS_RefIndex[i].XRes, - pSiS->SiS_Pr->SiS_RefIndex[i].YRes); - - current->status = MODE_OK; - - current->type = M_T_DEFAULT; - - vclkindex = pSiS->SiS_Pr->SiS_RefIndex[i].Ext_CRTVCLK; - if(pSiS->VGAEngine == SIS_300_VGA) vclkindex &= 0x3F; - - sr2b = pSiS->SiS_Pr->SiS_VCLKData[vclkindex].SR2B; - sr2c = pSiS->SiS_Pr->SiS_VCLKData[vclkindex].SR2C; - - divider = (sr2b & 0x80) ? 2.0 : 1.0; - postscalar = (sr2c & 0x80) ? - ( (((sr2c >> 5) & 0x03) == 0x02) ? 6.0 : 8.0) : (((sr2c >> 5) & 0x03) + 1.0); - num = (sr2b & 0x7f) + 1.0; - denum = (sr2c & 0x1f) + 1.0; - -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "------------\n"); - xf86DrvMsg(0, X_INFO, "sr2b: %x sr2c %x div %f ps %f num %f denum %f\n", - sr2b, sr2c, divider, postscalar, num, denum); #endif - - current->Clock = (int)(14318 * (divider / postscalar) * (num / denum)); - - sr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[14]; - /* inSISIDXREG(SISSR, 0x0b, sr_data); */ - - cr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[0]; - /* inSISIDXREG(SISCR, 0x00, cr_data); */ - - /* Horizontal total */ - HT = (cr_data & 0xff) | - ((unsigned short) (sr_data & 0x03) << 8); - A = HT + 5; - - cr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[1]; - /* inSISIDXREG(SISCR, 0x01, cr_data); */ - - /* Horizontal display enable end */ - HDE = (cr_data & 0xff) | - ((unsigned short) (sr_data & 0x0C) << 6); - E = HDE + 1; /* 0x80 0x64 */ - - cr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[4]; - /* inSISIDXREG(SISCR, 0x04, cr_data); */ - - /* Horizontal retrace (=sync) start */ - HRS = (cr_data & 0xff) | - ((unsigned short) (sr_data & 0xC0) << 2); - F = HRS - E - 3; /* 0x06 0x06 */ - - cr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[2]; - /* inSISIDXREG(SISCR, 0x02, cr_data); */ - - /* Horizontal blank start */ - HBS = (cr_data & 0xff) | - ((unsigned short) (sr_data & 0x30) << 4); - - sr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[15]; - /* inSISIDXREG(SISSR, 0x0c, sr_data); */ - - cr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[3]; - /* inSISIDXREG(SISCR, 0x03, cr_data); */ - - cr_data2 = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[5]; - /* inSISIDXREG(SISCR, 0x05, cr_data2); */ - - /* Horizontal blank end */ - HBE = (cr_data & 0x1f) | - ((unsigned short) (cr_data2 & 0x80) >> 2) | - ((unsigned short) (sr_data & 0x03) << 6); - - /* Horizontal retrace (=sync) end */ - HRE = (cr_data2 & 0x1f) | ((sr_data & 0x04) << 3); - - temp = HBE - ((E - 1) & 255); - B = (temp > 0) ? temp : (temp + 256); - - temp = HRE - ((E + F + 3) & 63); - C = (temp > 0) ? temp : (temp + 64); /* 0x0b 0x0b */ - - D = B - F - C; - - if((pSiS->SiS_Pr->SiS_RefIndex[i].XRes == 320) && - ((pSiS->SiS_Pr->SiS_RefIndex[i].YRes == 200) || - (pSiS->SiS_Pr->SiS_RefIndex[i].YRes == 240))) { - - /* Terrible hack, but correct CRTC data for - * these modes only produces a black screen... - * (HRE is 0, leading into a too large C and - * a negative D. The CRT controller does not - * seem to like correcting HRE to 50 - */ - current->HDisplay = 320; - current->HSyncStart = 328; - current->HSyncEnd = 376; - current->HTotal = 400; - - } else { - - current->HDisplay = (E * 8); - current->HSyncStart = (E * 8) + (F * 8); - current->HSyncEnd = (E * 8) + (F * 8) + (C * 8); - current->HTotal = (E * 8) + (F * 8) + (C * 8) + (D * 8); - - } - -#ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, - "H: A %d B %d C %d D %d E %d F %d HT %d HDE %d HRS %d HBS %d HBE %d HRE %d\n", - A, B, C, D, E, F, HT, HDE, HRS, HBS, HBE, HRE); +#ifdef SIS_LINUX_KERNEL + if(writeres) var->xres = xres = E * 8; + var->left_margin = D * 8; + var->right_margin = F * 8; + var->hsync_len = C * 8; #endif - sr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[13]; - /* inSISIDXREG(SISSR, 0x0A, sr_data); */ - - cr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[6]; - /* inSISIDXREG(SISCR, 0x06, cr_data); */ - - cr_data2 = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[7]; - /* inSISIDXREG(SISCR, 0x07, cr_data2); */ - - /* Vertical total */ - VT = (cr_data & 0xFF) | - ((unsigned short) (cr_data2 & 0x01) << 8) | - ((unsigned short)(cr_data2 & 0x20) << 4) | - ((unsigned short) (sr_data & 0x01) << 10); - A = VT + 2; - - cr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[10]; - /* inSISIDXREG(SISCR, 0x12, cr_data); */ - - /* Vertical display enable end */ - VDE = (cr_data & 0xff) | - ((unsigned short) (cr_data2 & 0x02) << 7) | - ((unsigned short) (cr_data2 & 0x40) << 3) | - ((unsigned short) (sr_data & 0x02) << 9); - E = VDE + 1; - - cr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[8]; - /* inSISIDXREG(SISCR, 0x10, cr_data); */ - - /* Vertical retrace (=sync) start */ - VRS = (cr_data & 0xff) | - ((unsigned short) (cr_data2 & 0x04) << 6) | - ((unsigned short) (cr_data2 & 0x80) << 2) | - ((unsigned short) (sr_data & 0x08) << 7); - F = VRS + 1 - E; - - cr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[11]; - /* inSISIDXREG(SISCR, 0x15, cr_data); */ - - cr_data3 = (pSiS->SiS_Pr->SiS_CRT1Table[index].CR[16] & 0x01) << 5; - /* inSISIDXREG(SISCR, 0x09, cr_data3); */ - - /* Vertical blank start */ - VBS = (cr_data & 0xff) | - ((unsigned short) (cr_data2 & 0x08) << 5) | - ((unsigned short) (cr_data3 & 0x20) << 4) | - ((unsigned short) (sr_data & 0x04) << 8); - - cr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[12]; - /* inSISIDXREG(SISCR, 0x16, cr_data); */ - - /* Vertical blank end */ - VBE = (cr_data & 0xff) | - ((unsigned short) (sr_data & 0x10) << 4); - temp = VBE - ((E - 1) & 511); - B = (temp > 0) ? temp : (temp + 512); - - cr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[9]; - /* inSISIDXREG(SISCR, 0x11, cr_data); */ - - /* Vertical retrace (=sync) end */ - VRE = (cr_data & 0x0f) | ((sr_data & 0x20) >> 1); - temp = VRE - ((E + F - 1) & 31); - C = (temp > 0) ? temp : (temp + 32); - - D = B - F - C; - - current->VDisplay = VDE + 1; - current->VSyncStart = VRS + 1; - current->VSyncEnd = ((VRS & ~0x1f) | VRE) + 1; - if(VRE <= (VRS & 0x1f)) current->VSyncEnd += 32; - current->VTotal = E + D + C + F; - + /* Vertical */ + sr_data = crdata[13]; + cr_data = crdata[7]; + + /* Vertical total */ + VT = crdata[6] | + ((unsigned short)(cr_data & 0x01) << 8) | + ((unsigned short)(cr_data & 0x20) << 4) | + ((unsigned short)(sr_data & 0x01) << 10); + A = VT + 2; + + /* Vertical display enable end */ + VDE = crdata[10] | + ((unsigned short)(cr_data & 0x02) << 7) | + ((unsigned short)(cr_data & 0x40) << 3) | + ((unsigned short)(sr_data & 0x02) << 9); + E = VDE + 1; + + /* Vertical retrace (=sync) start */ + VRS = crdata[8] | + ((unsigned short)(cr_data & 0x04) << 6) | + ((unsigned short)(cr_data & 0x80) << 2) | + ((unsigned short)(sr_data & 0x08) << 7); + F = VRS + 1 - E; + + cr_data2 = (crdata[16] & 0x01) << 5; + + /* Vertical blank start */ + VBS = crdata[11] | + ((unsigned short)(cr_data & 0x08) << 5) | + ((unsigned short)(cr_data2 & 0x20) << 4) | + ((unsigned short)(sr_data & 0x04) << 8); + + /* Vertical blank end */ + VBE = crdata[12] | ((unsigned short)(sr_data & 0x10) << 4); + temp = VBE - ((E - 1) & 511); + B = (temp > 0) ? temp : (temp + 512); + + /* Vertical retrace (=sync) end */ + VRE = (crdata[9] & 0x0f) | ((sr_data & 0x20) >> 1); + temp = VRE - ((E + F - 1) & 31); + C = (temp > 0) ? temp : (temp + 32); + + D = B - F - C; + +#ifdef SIS_XORG_XF86 + current->VDisplay = VDE + 1; + current->VSyncStart = VRS + 1; + current->VSyncEnd = ((VRS & ~0x1f) | VRE) + 1; + if(VRE <= (VRS & 0x1f)) current->VSyncEnd += 32; + current->VTotal = E + D + C + F; #if 0 - current->VDisplay = E; - current->VSyncStart = E + D; - current->VSyncEnd = E + D + C; - current->VTotal = E + D + C + F; + current->VDisplay = E; + current->VSyncStart = E + D; + current->VSyncEnd = E + D + C; + current->VTotal = E + D + C + F; #endif - #ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, - "V: A %d B %d C %d D %d E %d F %d VT %d VDE %d VRS %d VBS %d VBE %d VRE %d\n", - A, B, C, D, E, F, VT, VDE, VRS, VBS, VBE, VRE); + xf86DrvMsg(0, X_INFO, + "V: A %d B %d C %d D %d E %d F %d VT %d VDE %d VRS %d VBS %d VBE %d VRE %d\n", + A, B, C, D, E, F, VT, VDE, VRS, VBS, VBE, VRE); #endif - - if(pSiS->SiS_Pr->SiS_RefIndex[i].Ext_InfoFlag & 0x4000) - current->Flags |= V_NHSYNC; - else - current->Flags |= V_PHSYNC; - - if(pSiS->SiS_Pr->SiS_RefIndex[i].Ext_InfoFlag & 0x8000) - current->Flags |= V_NVSYNC; - else - current->Flags |= V_PVSYNC; - - if(pSiS->SiS_Pr->SiS_RefIndex[i].Ext_InfoFlag & 0x0080) - current->Flags |= V_INTERLACE; - - j = 0; - while(pSiS->SiS_Pr->SiS_EModeIDTable[j].Ext_ModeID != 0xff) { - if(pSiS->SiS_Pr->SiS_EModeIDTable[j].Ext_ModeID == - pSiS->SiS_Pr->SiS_RefIndex[i].ModeID) { - if(pSiS->SiS_Pr->SiS_EModeIDTable[j].Ext_ModeFlag & DoubleScanMode) { - current->Flags |= V_DBLSCAN; - } - break; - } - j++; - } - - if(current->Flags & V_INTERLACE) { - current->VDisplay <<= 1; - current->VSyncStart <<= 1; - current->VSyncEnd <<= 1; - current->VTotal <<= 1; - current->VTotal |= 1; - } - if(current->Flags & V_DBLSCAN) { - current->Clock >>= 1; - current->VDisplay >>= 1; - current->VSyncStart >>= 1; - current->VSyncEnd >>= 1; - current->VTotal >>= 1; - } - -#ifdef TWDEBUG - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Built-in: %s %.2f %d %d %d %d %d %d %d %d\n", - current->name, (float)current->Clock / 1000, - current->HDisplay, current->HSyncStart, current->HSyncEnd, current->HTotal, - current->VDisplay, current->VSyncStart, current->VSyncEnd, current->VTotal); -#else - (void)VBS; (void)HBS; (void)A; #endif - - i++; - } - - /* Add non-standard LCD modes for panel's detailed timings */ - - if(!includelcdmodes) return first; - - if(pSiS->SiS_Pr->CP_Vendor) { - xf86DrvMsg(0, X_INFO, "Checking database for vendor %x, product %x\n", - pSiS->SiS_Pr->CP_Vendor, pSiS->SiS_Pr->CP_Product); - } - - i = 0; - while((!done) && (SiS_PlasmaTable[i].vendor) && (pSiS->SiS_Pr->CP_Vendor)) { - - if(SiS_PlasmaTable[i].vendor == pSiS->SiS_Pr->CP_Vendor) { - - for(j=0; j<SiS_PlasmaTable[i].productnum; j++) { - - if(SiS_PlasmaTable[i].product[j] == pSiS->SiS_Pr->CP_Product) { - - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Identified %s panel, adding specific modes\n", - SiS_PlasmaTable[i].plasmaname); - - for(k=0; k<SiS_PlasmaTable[i].modenum; k++) { - - if(isfordvi) { - if(!(SiS_PlasmaTable[i].plasmamodes[k] & 0x80)) continue; - } else { - if(!(SiS_PlasmaTable[i].plasmamodes[k] & 0x40)) continue; - } - - l = SiS_PlasmaTable[i].plasmamodes[k] & 0x3f; - - if(pSiS->VBFlags & (VB_301|VB_301B|VB_302B|VB_301LV)) { - if(isfordvi) { - if(SiS_PlasmaMode[l].VDisplay > 1024) continue; - } - } - - if(!(new = xalloc(sizeof(DisplayModeRec)))) return first; - - memset(new, 0, sizeof(DisplayModeRec)); - if(!(new->name = xalloc(12))) { - xfree(new); - return first; - } - if(!first) first = new; - if(current) { - current->next = new; - new->prev = current; - } - - current = new; - - pSiS->AddedPlasmaModes = TRUE; - - strcpy(current->name, SiS_PlasmaMode[l].name); - /* sprintf(current->name, "%dx%d", SiS_PlasmaMode[l].HDisplay, - SiS_PlasmaMode[l].VDisplay); */ - - current->status = MODE_OK; - - current->type = M_T_BUILTIN; - - current->Clock = SiS_PlasmaMode[l].clock; - current->SynthClock = current->Clock; - - current->HDisplay = SiS_PlasmaMode[l].HDisplay; - current->HSyncStart = current->HDisplay + SiS_PlasmaMode[l].HFrontPorch; - current->HSyncEnd = current->HSyncStart + SiS_PlasmaMode[l].HSyncWidth; - current->HTotal = SiS_PlasmaMode[l].HTotal; - - current->VDisplay = SiS_PlasmaMode[l].VDisplay; - current->VSyncStart = current->VDisplay + SiS_PlasmaMode[l].VFrontPorch; - current->VSyncEnd = current->VSyncStart + SiS_PlasmaMode[l].VSyncWidth; - current->VTotal = SiS_PlasmaMode[l].VTotal; - - current->CrtcHDisplay = current->HDisplay; - current->CrtcHBlankStart = current->HSyncStart; - current->CrtcHSyncStart = current->HSyncStart; - current->CrtcHSyncEnd = current->HSyncEnd; - current->CrtcHBlankEnd = current->HSyncEnd; - current->CrtcHTotal = current->HTotal; - - current->CrtcVDisplay = current->VDisplay; - current->CrtcVBlankStart = current->VSyncStart; - current->CrtcVSyncStart = current->VSyncStart; - current->CrtcVSyncEnd = current->VSyncEnd; - current->CrtcVBlankEnd = current->VSyncEnd; - current->CrtcVTotal = current->VTotal; - - if(SiS_PlasmaMode[l].SyncFlags & SIS_PL_HSYNCP) - current->Flags |= V_PHSYNC; - else - current->Flags |= V_NHSYNC; - - if(SiS_PlasmaMode[l].SyncFlags & SIS_PL_VSYNCP) - current->Flags |= V_PVSYNC; - else - current->Flags |= V_NVSYNC; - - if(current->HDisplay > pSiS->LCDwidth) - pSiS->LCDwidth = pSiS->SiS_Pr->CP_MaxX = current->HDisplay; - if(current->VDisplay > pSiS->LCDheight) - pSiS->LCDheight = pSiS->SiS_Pr->CP_MaxY = current->VDisplay; - - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "\tAdding \"%s\" to list of built-in modes\n", current->name); - - } - done = TRUE; - break; - } - } - } - - i++; - - } - - if(pSiS->SiS_Pr->CP_HaveCustomData) { - - for(i=0; i<7; i++) { - - if(pSiS->SiS_Pr->CP_DataValid[i]) { - - if(!(new = xalloc(sizeof(DisplayModeRec)))) return first; - - memset(new, 0, sizeof(DisplayModeRec)); - if(!(new->name = xalloc(10))) { - xfree(new); - return first; - } - if(!first) first = new; - if(current) { - current->next = new; - new->prev = current; - } - - current = new; - - sprintf(current->name, "%dx%d", pSiS->SiS_Pr->CP_HDisplay[i], - pSiS->SiS_Pr->CP_VDisplay[i]); - - current->status = MODE_OK; - - current->type = M_T_BUILTIN; - - current->Clock = pSiS->SiS_Pr->CP_Clock[i]; - current->SynthClock = current->Clock; - - current->HDisplay = pSiS->SiS_Pr->CP_HDisplay[i]; - current->HSyncStart = pSiS->SiS_Pr->CP_HSyncStart[i]; - current->HSyncEnd = pSiS->SiS_Pr->CP_HSyncEnd[i]; - current->HTotal = pSiS->SiS_Pr->CP_HTotal[i]; - - current->VDisplay = pSiS->SiS_Pr->CP_VDisplay[i]; - current->VSyncStart = pSiS->SiS_Pr->CP_VSyncStart[i]; - current->VSyncEnd = pSiS->SiS_Pr->CP_VSyncEnd[i]; - current->VTotal = pSiS->SiS_Pr->CP_VTotal[i]; - - current->CrtcHDisplay = current->HDisplay; - current->CrtcHBlankStart = pSiS->SiS_Pr->CP_HBlankStart[i]; - current->CrtcHSyncStart = current->HSyncStart; - current->CrtcHSyncEnd = current->HSyncEnd; - current->CrtcHBlankEnd = pSiS->SiS_Pr->CP_HBlankEnd[i]; - current->CrtcHTotal = current->HTotal; - - current->CrtcVDisplay = current->VDisplay; - current->CrtcVBlankStart = pSiS->SiS_Pr->CP_VBlankStart[i]; - current->CrtcVSyncStart = current->VSyncStart; - current->CrtcVSyncEnd = current->VSyncEnd; - current->CrtcVBlankEnd = pSiS->SiS_Pr->CP_VBlankEnd[i]; - current->CrtcVTotal = current->VTotal; - - if(pSiS->SiS_Pr->CP_SyncValid[i]) { - if(pSiS->SiS_Pr->CP_HSync_P[i]) - current->Flags |= V_PHSYNC; - else - current->Flags |= V_NHSYNC; - - if(pSiS->SiS_Pr->CP_VSync_P[i]) - current->Flags |= V_PVSYNC; - else - current->Flags |= V_NVSYNC; - } else { - /* No sync data? Use positive sync... */ - current->Flags |= V_PHSYNC; - current->Flags |= V_PVSYNC; - } - } - } - } - - return first; - -} - -/* Translate a mode number into the VESA pendant */ -int -SiSTranslateToVESA(ScrnInfoPtr pScrn, int modenumber) -{ - SISPtr pSiS = SISPTR(pScrn); - int i = 0; - - /* Initialize our pointers */ - if(pSiS->VGAEngine == SIS_300_VGA) { -#ifdef SIS300 - InitTo300Pointer(pSiS->SiS_Pr, &pSiS->sishw_ext); -#else - return -1; -#endif - } else if(pSiS->VGAEngine == SIS_315_VGA) { -#ifdef SIS315H - InitTo310Pointer(pSiS->SiS_Pr, &pSiS->sishw_ext); -#else - return -1; +#ifdef SIS_LINUX_KERNEL + if(writeres) var->yres = yres = E; + var->upper_margin = D; + var->lower_margin = F; + var->vsync_len = C; #endif - } else return -1; - - if(modenumber <= 0x13) return modenumber; -#ifdef SIS315H - if(pSiS->ROM661New) { - while(SiS_EModeIDTable661[i].Ext_ModeID != 0xff) { - if(SiS_EModeIDTable661[i].Ext_ModeID == modenumber) { - return (int)SiS_EModeIDTable661[i].Ext_VESAID; - } - i++; - } - } else { + if((xres == 320) && ((yres == 200) || (yres == 240))) { + /* Terrible hack, but correct CRTC data for + * these modes only produces a black screen... + * (HRE is 0, leading into a too large C and + * a negative D. The CRT controller does not + * seem to like correcting HRE to 50) + */ +#ifdef SIS_XORG_XF86 + current->HDisplay = 320; + current->HSyncStart = 328; + current->HSyncEnd = 376; + current->HTotal = 400; #endif - while(pSiS->SiS_Pr->SiS_EModeIDTable[i].Ext_ModeID != 0xff) { - if(pSiS->SiS_Pr->SiS_EModeIDTable[i].Ext_ModeID == modenumber) { - return (int)pSiS->SiS_Pr->SiS_EModeIDTable[i].Ext_VESAID; - } - i++; - } -#ifdef SIS315H - } +#ifdef SIS_LINUX_KERNEL + var->left_margin = (400 - 376); + var->right_margin = (328 - 320); + var->hsync_len = (376 - 328); #endif - return -1; -} -/* Translate a new BIOS mode number into the driver's pendant */ -int -SiSTranslateToOldMode(int modenumber) -{ -#ifdef SIS315H - int i = 0; - - while(SiS_EModeIDTable661[i].Ext_ModeID != 0xff) { - if(SiS_EModeIDTable661[i].Ext_ModeID == modenumber) { - if(SiS_EModeIDTable661[i].Ext_MyModeID) - return (int)SiS_EModeIDTable661[i].Ext_MyModeID; - else - return modenumber; - } - i++; } -#endif - return modenumber; -} - -#endif /* Xfree86 */ - -#ifdef LINUX_KERNEL -int -sisfb_mode_rate_to_dclock(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - unsigned char modeno, unsigned char rateindex) -{ - USHORT ModeNo = modeno; - USHORT ModeIdIndex = 0, ClockIndex = 0; - USHORT RefreshRateTableIndex = 0; - int Clock; - - if(HwInfo->jChipType < SIS_315H) { -#ifdef SIS300 - InitTo300Pointer(SiS_Pr, HwInfo); -#else - return 65 * 1000; -#endif - } else { -#ifdef SIS315H - InitTo310Pointer(SiS_Pr, HwInfo); -#else - return 65 * 1000; -#endif - } - - if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) {; - printk(KERN_ERR "Could not find mode %x\n", ModeNo); - return 65 * 1000; - } - - RefreshRateTableIndex = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex; - RefreshRateTableIndex += (rateindex - 1); - ClockIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; - if(HwInfo->jChipType < SIS_315H) { - ClockIndex &= 0x3F; - } - Clock = SiS_Pr->SiS_VCLKData[ClockIndex].CLOCK * 1000; - - return(Clock); -} - -BOOLEAN -sisfb_gettotalfrommode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - unsigned char modeno, int *htotal, int *vtotal, unsigned char rateindex) -{ - USHORT ModeNo = modeno; - USHORT ModeIdIndex = 0, CRT1Index = 0; - USHORT RefreshRateTableIndex = 0; - unsigned char sr_data, cr_data, cr_data2; - - if(HwInfo->jChipType < SIS_315H) { -#ifdef SIS300 - InitTo300Pointer(SiS_Pr, HwInfo); -#else - return FALSE; -#endif - } else { -#ifdef SIS315H - InitTo310Pointer(SiS_Pr, HwInfo); -#else - return FALSE; -#endif - } - - if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return FALSE; - - RefreshRateTableIndex = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex; - RefreshRateTableIndex += (rateindex - 1); - CRT1Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; - - sr_data = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[14]; - cr_data = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[0]; - *htotal = (((cr_data & 0xff) | ((unsigned short) (sr_data & 0x03) << 8)) + 5) * 8; - sr_data = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[13]; - cr_data = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[6]; - cr_data2 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[7]; - *vtotal = ((cr_data & 0xFF) | - ((unsigned short)(cr_data2 & 0x01) << 8) | - ((unsigned short)(cr_data2 & 0x20) << 4) | - ((unsigned short)(sr_data & 0x01) << 10)) + 2; - - if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag & InterlaceMode) - *vtotal *= 2; - - return TRUE; } -int -sisfb_mode_rate_to_ddata(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - unsigned char modeno, unsigned char rateindex, - struct fb_var_screeninfo *var) -{ - USHORT ModeNo = modeno; - USHORT ModeIdIndex = 0, index = 0; - USHORT RefreshRateTableIndex = 0; - unsigned short VRE, VBE, VRS, VBS, VDE, VT; - unsigned short HRE, HBE, HRS, HBS, HDE, HT; - unsigned char sr_data, cr_data, cr_data2, cr_data3; - int A, B, C, D, E, F, temp, j; - - if(HwInfo->jChipType < SIS_315H) { -#ifdef SIS300 - InitTo300Pointer(SiS_Pr, HwInfo); -#else - return 0; -#endif - } else { -#ifdef SIS315H - InitTo310Pointer(SiS_Pr, HwInfo); -#else - return 0; -#endif - } - - if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return 0; - - RefreshRateTableIndex = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex; - RefreshRateTableIndex += (rateindex - 1); - index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; - - sr_data = SiS_Pr->SiS_CRT1Table[index].CR[14]; - - cr_data = SiS_Pr->SiS_CRT1Table[index].CR[0]; - - /* Horizontal total */ - HT = (cr_data & 0xff) | - ((unsigned short) (sr_data & 0x03) << 8); - A = HT + 5; - - cr_data = SiS_Pr->SiS_CRT1Table[index].CR[1]; - - /* Horizontal display enable end */ - HDE = (cr_data & 0xff) | - ((unsigned short) (sr_data & 0x0C) << 6); - E = HDE + 1; - - cr_data = SiS_Pr->SiS_CRT1Table[index].CR[4]; - - /* Horizontal retrace (=sync) start */ - HRS = (cr_data & 0xff) | - ((unsigned short) (sr_data & 0xC0) << 2); - F = HRS - E - 3; - - cr_data = SiS_Pr->SiS_CRT1Table[index].CR[2]; - - /* Horizontal blank start */ - HBS = (cr_data & 0xff) | - ((unsigned short) (sr_data & 0x30) << 4); - - sr_data = SiS_Pr->SiS_CRT1Table[index].CR[15]; - - cr_data = SiS_Pr->SiS_CRT1Table[index].CR[3]; - - cr_data2 = SiS_Pr->SiS_CRT1Table[index].CR[5]; - - /* Horizontal blank end */ - HBE = (cr_data & 0x1f) | - ((unsigned short) (cr_data2 & 0x80) >> 2) | - ((unsigned short) (sr_data & 0x03) << 6); - - /* Horizontal retrace (=sync) end */ - HRE = (cr_data2 & 0x1f) | ((sr_data & 0x04) << 3); - temp = HBE - ((E - 1) & 255); - B = (temp > 0) ? temp : (temp + 256); - temp = HRE - ((E + F + 3) & 63); - C = (temp > 0) ? temp : (temp + 64); - - D = B - F - C; - - if((SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].XRes == 320) && - ((SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].YRes == 200) || - (SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].YRes == 240))) { - - /* Terrible hack, but the correct CRTC data for - * these modes only produces a black screen... - */ - var->left_margin = (400 - 376); - var->right_margin = (328 - 320); - var->hsync_len = (376 - 328); - - } else { - - var->left_margin = D * 8; - var->right_margin = F * 8; - var->hsync_len = C * 8; - - } - - sr_data = SiS_Pr->SiS_CRT1Table[index].CR[13]; - - cr_data = SiS_Pr->SiS_CRT1Table[index].CR[6]; - - cr_data2 = SiS_Pr->SiS_CRT1Table[index].CR[7]; - - /* Vertical total */ - VT = (cr_data & 0xFF) | - ((unsigned short) (cr_data2 & 0x01) << 8) | - ((unsigned short)(cr_data2 & 0x20) << 4) | - ((unsigned short) (sr_data & 0x01) << 10); - A = VT + 2; - - cr_data = SiS_Pr->SiS_CRT1Table[index].CR[10]; - - /* Vertical display enable end */ - VDE = (cr_data & 0xff) | - ((unsigned short) (cr_data2 & 0x02) << 7) | - ((unsigned short) (cr_data2 & 0x40) << 3) | - ((unsigned short) (sr_data & 0x02) << 9); - E = VDE + 1; - - cr_data = SiS_Pr->SiS_CRT1Table[index].CR[8]; - - /* Vertical retrace (=sync) start */ - VRS = (cr_data & 0xff) | - ((unsigned short) (cr_data2 & 0x04) << 6) | - ((unsigned short) (cr_data2 & 0x80) << 2) | - ((unsigned short) (sr_data & 0x08) << 7); - F = VRS + 1 - E; - - cr_data = SiS_Pr->SiS_CRT1Table[index].CR[11]; - - cr_data3 = (SiS_Pr->SiS_CRT1Table[index].CR[16] & 0x01) << 5; - - /* Vertical blank start */ - VBS = (cr_data & 0xff) | - ((unsigned short) (cr_data2 & 0x08) << 5) | - ((unsigned short) (cr_data3 & 0x20) << 4) | - ((unsigned short) (sr_data & 0x04) << 8); - - cr_data = SiS_Pr->SiS_CRT1Table[index].CR[12]; - - /* Vertical blank end */ - VBE = (cr_data & 0xff) | - ((unsigned short) (sr_data & 0x10) << 4); - temp = VBE - ((E - 1) & 511); - B = (temp > 0) ? temp : (temp + 512); - - cr_data = SiS_Pr->SiS_CRT1Table[index].CR[9]; - - /* Vertical retrace (=sync) end */ - VRE = (cr_data & 0x0f) | ((sr_data & 0x20) >> 1); - temp = VRE - ((E + F - 1) & 31); - C = (temp > 0) ? temp : (temp + 32); - - D = B - F - C; - - var->upper_margin = D; - var->lower_margin = F; - var->vsync_len = C; - - if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag & 0x8000) - var->sync &= ~FB_SYNC_VERT_HIGH_ACT; - else - var->sync |= FB_SYNC_VERT_HIGH_ACT; - - if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag & 0x4000) - var->sync &= ~FB_SYNC_HOR_HIGH_ACT; - else - var->sync |= FB_SYNC_HOR_HIGH_ACT; - - var->vmode = FB_VMODE_NONINTERLACED; - if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag & 0x0080) - var->vmode = FB_VMODE_INTERLACED; - else { - j = 0; - while(SiS_Pr->SiS_EModeIDTable[j].Ext_ModeID != 0xff) { - if(SiS_Pr->SiS_EModeIDTable[j].Ext_ModeID == - SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].ModeID) { - if(SiS_Pr->SiS_EModeIDTable[j].Ext_ModeFlag & DoubleScanMode) { - var->vmode = FB_VMODE_DOUBLE; - } - break; - } - j++; - } - } - - if((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { -#if 0 /* Do this? */ - var->upper_margin <<= 1; - var->lower_margin <<= 1; - var->vsync_len <<= 1; -#endif - } else if((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) { - var->upper_margin >>= 1; - var->lower_margin >>= 1; - var->vsync_len >>= 1; - } - - return 1; -} - -#endif diff --git a/drivers/video/sis/init.h b/drivers/video/sis/init.h index 7e36b7ac147..634c0a9d219 100644 --- a/drivers/video/sis/init.h +++ b/drivers/video/sis/init.h @@ -3,7 +3,7 @@ /* * Data and prototypes for init.c * - * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2005 by Thomas Winischhofer, Vienna, Austria * * If distributed as part of the Linux kernel, the following license terms * apply: @@ -50,18 +50,24 @@ * */ -#ifndef _INIT_ -#define _INIT_ +#ifndef _INIT_H_ +#define _INIT_H_ #include "osdef.h" #include "initdef.h" -#ifdef LINUX_XF86 +#ifdef SIS_XORG_XF86 #include "sis.h" +#define SIS_NEED_inSISREG +#define SIS_NEED_inSISREGW +#define SIS_NEED_inSISREGL +#define SIS_NEED_outSISREG +#define SIS_NEED_outSISREGW +#define SIS_NEED_outSISREGL #include "sis_regs.h" #endif -#ifdef LINUX_KERNEL +#ifdef SIS_LINUX_KERNEL #include "vgatypes.h" #include "vstruct.h" #ifdef SIS_CP @@ -73,6 +79,10 @@ #include <asm/io.h> #include <linux/fb.h> #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) +#include <video/fbcon.h> +#endif +#include "sis.h" +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) #include <linux/sisfb.h> #else #include <video/sisfb.h> @@ -80,44 +90,45 @@ #endif /* Mode numbers */ -static const USHORT ModeIndex_320x200[] = {0x59, 0x41, 0x00, 0x4f}; -static const USHORT ModeIndex_320x240[] = {0x50, 0x56, 0x00, 0x53}; -static const USHORT ModeIndex_320x240_FSTN[] = {0x5a, 0x5b, 0x00, 0x00}; /* FSTN */ -static const USHORT ModeIndex_400x300[] = {0x51, 0x57, 0x00, 0x54}; -static const USHORT ModeIndex_512x384[] = {0x52, 0x58, 0x00, 0x5c}; -static const USHORT ModeIndex_640x400[] = {0x2f, 0x5d, 0x00, 0x5e}; -static const USHORT ModeIndex_640x480[] = {0x2e, 0x44, 0x00, 0x62}; -static const USHORT ModeIndex_720x480[] = {0x31, 0x33, 0x00, 0x35}; -static const USHORT ModeIndex_720x576[] = {0x32, 0x34, 0x00, 0x36}; -static const USHORT ModeIndex_768x576[] = {0x5f, 0x60, 0x00, 0x61}; -static const USHORT ModeIndex_800x480[] = {0x70, 0x7a, 0x00, 0x76}; -static const USHORT ModeIndex_800x600[] = {0x30, 0x47, 0x00, 0x63}; -static const USHORT ModeIndex_848x480[] = {0x39, 0x3b, 0x00, 0x3e}; -static const USHORT ModeIndex_856x480[] = {0x3f, 0x42, 0x00, 0x45}; -static const USHORT ModeIndex_960x540[] = {0x1d, 0x1e, 0x00, 0x1f}; /* 315 series only */ -static const USHORT ModeIndex_960x600[] = {0x20, 0x21, 0x00, 0x22}; /* 315 series only */ -static const USHORT ModeIndex_1024x768[] = {0x38, 0x4a, 0x00, 0x64}; -static const USHORT ModeIndex_1024x576[] = {0x71, 0x74, 0x00, 0x77}; -static const USHORT ModeIndex_1024x600[] = {0x20, 0x21, 0x00, 0x22}; /* 300 series only */ -static const USHORT ModeIndex_1280x1024[] = {0x3a, 0x4d, 0x00, 0x65}; -static const USHORT ModeIndex_1280x960[] = {0x7c, 0x7d, 0x00, 0x7e}; -static const USHORT ModeIndex_1152x768[] = {0x23, 0x24, 0x00, 0x25}; /* 300 series only */ -static const USHORT ModeIndex_1152x864[] = {0x29, 0x2a, 0x00, 0x2b}; -static const USHORT ModeIndex_300_1280x768[] = {0x55, 0x5a, 0x00, 0x5b}; -static const USHORT ModeIndex_310_1280x768[] = {0x23, 0x24, 0x00, 0x25}; -static const USHORT ModeIndex_1280x720[] = {0x79, 0x75, 0x00, 0x78}; -static const USHORT ModeIndex_1280x800[] = {0x14, 0x15, 0x00, 0x16}; -static const USHORT ModeIndex_1360x768[] = {0x48, 0x4b, 0x00, 0x4e}; -static const USHORT ModeIndex_300_1360x1024[]= {0x67, 0x6f, 0x00, 0x72}; /* 300 series, BARCO only */ -static const USHORT ModeIndex_1400x1050[] = {0x26, 0x27, 0x00, 0x28}; /* 315 series only */ -static const USHORT ModeIndex_1680x1050[] = {0x17, 0x18, 0x00, 0x19}; /* 315 series only */ -static const USHORT ModeIndex_1600x1200[] = {0x3c, 0x3d, 0x00, 0x66}; -static const USHORT ModeIndex_1920x1080[] = {0x2c, 0x2d, 0x00, 0x73}; /* 315 series only */ -static const USHORT ModeIndex_1920x1440[] = {0x68, 0x69, 0x00, 0x6b}; -static const USHORT ModeIndex_300_2048x1536[]= {0x6c, 0x6d, 0x00, 0x00}; -static const USHORT ModeIndex_310_2048x1536[]= {0x6c, 0x6d, 0x00, 0x6e}; - -static const USHORT SiS_DRAMType[17][5]={ +static const unsigned short ModeIndex_320x200[] = {0x59, 0x41, 0x00, 0x4f}; +static const unsigned short ModeIndex_320x240[] = {0x50, 0x56, 0x00, 0x53}; +static const unsigned short ModeIndex_320x240_FSTN[] = {0x5a, 0x5b, 0x00, 0x00}; /* FSTN */ +static const unsigned short ModeIndex_400x300[] = {0x51, 0x57, 0x00, 0x54}; +static const unsigned short ModeIndex_512x384[] = {0x52, 0x58, 0x00, 0x5c}; +static const unsigned short ModeIndex_640x400[] = {0x2f, 0x5d, 0x00, 0x5e}; +static const unsigned short ModeIndex_640x480[] = {0x2e, 0x44, 0x00, 0x62}; +static const unsigned short ModeIndex_720x480[] = {0x31, 0x33, 0x00, 0x35}; +static const unsigned short ModeIndex_720x576[] = {0x32, 0x34, 0x00, 0x36}; +static const unsigned short ModeIndex_768x576[] = {0x5f, 0x60, 0x00, 0x61}; +static const unsigned short ModeIndex_800x480[] = {0x70, 0x7a, 0x00, 0x76}; +static const unsigned short ModeIndex_800x600[] = {0x30, 0x47, 0x00, 0x63}; +static const unsigned short ModeIndex_848x480[] = {0x39, 0x3b, 0x00, 0x3e}; +static const unsigned short ModeIndex_856x480[] = {0x3f, 0x42, 0x00, 0x45}; +static const unsigned short ModeIndex_960x540[] = {0x1d, 0x1e, 0x00, 0x1f}; /* 315 series only */ +static const unsigned short ModeIndex_960x600[] = {0x20, 0x21, 0x00, 0x22}; /* 315 series only */ +static const unsigned short ModeIndex_1024x768[] = {0x38, 0x4a, 0x00, 0x64}; +static const unsigned short ModeIndex_1024x576[] = {0x71, 0x74, 0x00, 0x77}; +static const unsigned short ModeIndex_1024x600[] = {0x20, 0x21, 0x00, 0x22}; /* 300 series only */ +static const unsigned short ModeIndex_1280x1024[] = {0x3a, 0x4d, 0x00, 0x65}; +static const unsigned short ModeIndex_1280x960[] = {0x7c, 0x7d, 0x00, 0x7e}; +static const unsigned short ModeIndex_1152x768[] = {0x23, 0x24, 0x00, 0x25}; /* 300 series only */ +static const unsigned short ModeIndex_1152x864[] = {0x29, 0x2a, 0x00, 0x2b}; +static const unsigned short ModeIndex_300_1280x768[] = {0x55, 0x5a, 0x00, 0x5b}; +static const unsigned short ModeIndex_310_1280x768[] = {0x23, 0x24, 0x00, 0x25}; +static const unsigned short ModeIndex_1280x720[] = {0x79, 0x75, 0x00, 0x78}; +static const unsigned short ModeIndex_1280x800[] = {0x14, 0x15, 0x00, 0x16}; +static const unsigned short ModeIndex_1280x854[] = {0x1a, 0x1b, 0x00, 0x1c}; +static const unsigned short ModeIndex_1360x768[] = {0x48, 0x4b, 0x00, 0x4e}; +static const unsigned short ModeIndex_300_1360x1024[]= {0x67, 0x6f, 0x00, 0x72}; /* 300 series, BARCO only */ +static const unsigned short ModeIndex_1400x1050[] = {0x26, 0x27, 0x00, 0x28}; /* 315 series only */ +static const unsigned short ModeIndex_1680x1050[] = {0x17, 0x18, 0x00, 0x19}; /* 315 series only */ +static const unsigned short ModeIndex_1600x1200[] = {0x3c, 0x3d, 0x00, 0x66}; +static const unsigned short ModeIndex_1920x1080[] = {0x2c, 0x2d, 0x00, 0x73}; /* 315 series only */ +static const unsigned short ModeIndex_1920x1440[] = {0x68, 0x69, 0x00, 0x6b}; +static const unsigned short ModeIndex_300_2048x1536[]= {0x6c, 0x6d, 0x00, 0x00}; +static const unsigned short ModeIndex_310_2048x1536[]= {0x6c, 0x6d, 0x00, 0x6e}; + +static const unsigned short SiS_DRAMType[17][5]={ {0x0C,0x0A,0x02,0x40,0x39}, {0x0D,0x0A,0x01,0x40,0x48}, {0x0C,0x09,0x02,0x20,0x35}, @@ -137,7 +148,7 @@ static const USHORT SiS_DRAMType[17][5]={ {0x09,0x08,0x01,0x01,0x00} }; -static const USHORT SiS_SDRDRAM_TYPE[13][5] = +static const unsigned short SiS_SDRDRAM_TYPE[13][5] = { { 2,12, 9,64,0x35}, { 1,13, 9,64,0x44}, @@ -154,7 +165,7 @@ static const USHORT SiS_SDRDRAM_TYPE[13][5] = { 1, 9, 8, 2,0x00} }; -static const USHORT SiS_DDRDRAM_TYPE[4][5] = +static const unsigned short SiS_DDRDRAM_TYPE[4][5] = { { 2,12, 9,64,0x35}, { 2,12, 8,32,0x31}, @@ -162,7 +173,7 @@ static const USHORT SiS_DDRDRAM_TYPE[4][5] = { 2, 9, 8, 4,0x01} }; -static const USHORT SiS_MDA_DAC[] = +static const unsigned char SiS_MDA_DAC[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15, @@ -174,7 +185,7 @@ static const USHORT SiS_MDA_DAC[] = 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F }; -static const USHORT SiS_CGA_DAC[] = +static const unsigned char SiS_CGA_DAC[] = { 0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15, 0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15, @@ -186,7 +197,7 @@ static const USHORT SiS_CGA_DAC[] = 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F }; -static const USHORT SiS_EGA_DAC[] = +static const unsigned char SiS_EGA_DAC[] = { 0x00,0x10,0x04,0x14,0x01,0x11,0x05,0x15, 0x20,0x30,0x24,0x34,0x21,0x31,0x25,0x35, @@ -198,7 +209,7 @@ static const USHORT SiS_EGA_DAC[] = 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F }; -static const USHORT SiS_VGA_DAC[] = +static const unsigned char SiS_VGA_DAC[] = { 0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15, 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F, @@ -212,7 +223,31 @@ static const USHORT SiS_VGA_DAC[] = 0x0B,0x0C,0x0D,0x0F,0x10 }; -static const SiS_StResInfoStruct SiS_StResInfo[]= +static const struct SiS_St SiS_SModeIDTable[] = +{ + {0x01,0x9208,0x01,0x00,0x00,0x00,0x01,0x00,0x40}, + {0x01,0x1210,0x14,0x01,0x01,0x00,0x01,0x00,0x40}, + {0x01,0x1010,0x17,0x02,0x02,0x00,0x01,0x01,0x40}, + {0x03,0x8208,0x03,0x00,0x00,0x00,0x01,0x02,0x40}, + {0x03,0x0210,0x16,0x01,0x01,0x00,0x01,0x02,0x40}, + {0x03,0x0010,0x18,0x02,0x02,0x00,0x01,0x03,0x40}, + {0x05,0x9209,0x05,0x00,0x00,0x00,0x00,0x04,0x40}, + {0x06,0x8209,0x06,0x00,0x00,0x00,0x00,0x05,0x40}, + {0x07,0x0000,0x07,0x03,0x03,0x00,0x01,0x03,0x40}, + {0x07,0x0000,0x19,0x02,0x02,0x00,0x01,0x03,0x40}, + {0x0d,0x920a,0x0d,0x00,0x00,0x00,0x00,0x04,0x40}, + {0x0e,0x820a,0x0e,0x00,0x00,0x00,0x00,0x05,0x40}, + {0x0f,0x0202,0x11,0x01,0x01,0x00,0x00,0x05,0x40}, + {0x10,0x0212,0x12,0x01,0x01,0x00,0x00,0x05,0x40}, + {0x11,0x0212,0x1a,0x04,0x04,0x00,0x00,0x05,0x40}, + {0x12,0x0212,0x1b,0x04,0x04,0x00,0x00,0x05,0x40}, + {0x13,0x021b,0x1c,0x00,0x00,0x00,0x00,0x04,0x40}, + {0x12,0x0010,0x18,0x02,0x02,0x00,0x00,0x05,0x40}, + {0x12,0x0210,0x18,0x01,0x01,0x00,0x00,0x05,0x40}, + {0xff,0x0000,0x00,0x00,0x00,0x00,0x00,0x00,0x00} +}; + +static const struct SiS_StResInfo_S SiS_StResInfo[]= { { 640,400}, { 640,350}, @@ -221,7 +256,7 @@ static const SiS_StResInfoStruct SiS_StResInfo[]= { 640,480} }; -static const SiS_ModeResInfoStruct SiS_ModeResInfo[] = +static const struct SiS_ModeResInfo_S SiS_ModeResInfo[] = { { 320, 200, 8, 8}, /* 0x00 */ { 320, 240, 8, 8}, /* 0x01 */ @@ -256,11 +291,12 @@ static const SiS_ModeResInfoStruct SiS_ModeResInfo[] = { 1280, 800, 8,16}, /* 0x1e */ { 1920,1080, 8,16}, /* 0x1f */ { 960, 540, 8,16}, /* 0x20 */ - { 960, 600, 8,16} /* 0x21 */ + { 960, 600, 8,16}, /* 0x21 */ + { 1280, 854, 8,16} /* 0x22 */ }; #if defined(SIS300) || defined(SIS315H) -static const SiS_StandTableStruct SiS_StandTable[]= +static const struct SiS_StandTable_S SiS_StandTable[]= { /* 0x00: MD_0_200 */ { @@ -704,11 +740,11 @@ static const SiS_StandTableStruct SiS_StandTable[]= /* SIS VIDEO BRIDGE ----------------------------------------- */ /**************************************************************/ -static const UCHAR SiS_SoftSetting = 0x30; /* RAM setting */ +static const unsigned char SiS_SoftSetting = 0x30; /* RAM setting */ -static const UCHAR SiS_OutputSelect = 0x40; +static const unsigned char SiS_OutputSelect = 0x40; -static const UCHAR SiS_NTSCTiming[] = { +static const unsigned char SiS_NTSCTiming[] = { 0x17,0x1d,0x03,0x09,0x05,0x06,0x0c,0x0c, 0x94,0x49,0x01,0x0a,0x06,0x0d,0x04,0x0a, 0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x1b, @@ -719,7 +755,7 @@ static const UCHAR SiS_NTSCTiming[] = { 0x00,0x40,0x44,0x00,0xdb,0x02,0x3b,0x00 }; -static const UCHAR SiS_PALTiming[] = { +static const unsigned char SiS_PALTiming[] = { 0x19,0x52,0x35,0x6e,0x04,0x38,0x3d,0x70, 0x94,0x49,0x01,0x12,0x06,0x3e,0x35,0x6d, 0x06,0x14,0x3e,0x35,0x6d,0x00,0x45,0x2b, @@ -730,8 +766,8 @@ static const UCHAR SiS_PALTiming[] = { 0x00,0x40,0x3e,0x00,0xe1,0x02,0x28,0x00 }; -static const UCHAR SiS_HiTVExtTiming[] = { - 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x64, +static const unsigned char SiS_HiTVExtTiming[] = { + 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x64, 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, 0x64,0x90,0x33,0x8c,0x18,0x36,0x3e,0x13, @@ -741,8 +777,8 @@ static const UCHAR SiS_HiTVExtTiming[] = { 0x63,0x4f,0x27,0x00,0xfc,0xff,0x6a,0x00 }; -static const UCHAR SiS_HiTVSt1Timing[] = { - 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65, +static const unsigned char SiS_HiTVSt1Timing[] = { + 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65, 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, 0x65,0x90,0x7b,0xa8,0x03,0xf0,0x87,0x03, @@ -752,8 +788,8 @@ static const UCHAR SiS_HiTVSt1Timing[] = { 0xaf,0x5d,0x0e,0x00,0xfc,0xff,0x2d,0x00 }; -static const UCHAR SiS_HiTVSt2Timing[] = { - 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x64, +static const unsigned char SiS_HiTVSt2Timing[] = { + 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x64, 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, 0x64,0x90,0x33,0x8c,0x18,0x36,0x3e,0x13, @@ -764,8 +800,8 @@ static const UCHAR SiS_HiTVSt2Timing[] = { }; #if 0 -static const UCHAR SiS_HiTVTextTiming[] = { - 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65, +static const unsigned char SiS_HiTVTextTiming[] = { + 0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65, 0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d, 0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f, 0x65,0x90,0xe7,0xbc,0x03,0x0c,0x97,0x03, @@ -776,8 +812,8 @@ static const UCHAR SiS_HiTVTextTiming[] = { }; #endif -static const UCHAR SiS_HiTVGroup3Data[] = { - 0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x5f, +static const unsigned char SiS_HiTVGroup3Data[] = { + 0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x5f, 0x05,0x21,0xb2,0xb2,0x55,0x77,0x2a,0xa6, 0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20, 0x8c,0x6e,0x60,0x2e,0x58,0x48,0x72,0x44, @@ -787,8 +823,8 @@ static const UCHAR SiS_HiTVGroup3Data[] = { 0x18,0x05,0x18,0x05,0x4c,0xa8,0x01 }; -static const UCHAR SiS_HiTVGroup3Simu[] = { - 0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x95, +static const unsigned char SiS_HiTVGroup3Simu[] = { + 0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x95, 0xdb,0x20,0xb8,0xb8,0x55,0x47,0x2a,0xa6, 0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20, 0x8c,0x6e,0x60,0x15,0x26,0xd3,0xe4,0x11, @@ -799,8 +835,8 @@ static const UCHAR SiS_HiTVGroup3Simu[] = { }; #if 0 -static const UCHAR SiS_HiTVGroup3Text[] = { - 0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0xa7, +static const unsigned char SiS_HiTVGroup3Text[] = { + 0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0xa7, 0xf5,0x20,0xce,0xce,0x55,0x47,0x2a,0xa6, 0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20, 0x8c,0x6e,0x60,0x18,0x2c,0x0c,0x20,0x22, @@ -811,136 +847,141 @@ static const UCHAR SiS_HiTVGroup3Text[] = { }; #endif -static const UCHAR SiS_NTSCPhase[] = {0x21,0xed,0xba,0x08}; -static const UCHAR SiS_PALPhase[] = {0x2a,0x05,0xe3,0x00}; -static const UCHAR SiS_PALMPhase[] = {0x21,0xE4,0x2E,0x9B}; -static const UCHAR SiS_PALNPhase[] = {0x21,0xF4,0x3E,0xBA}; -static const UCHAR SiS_NTSCPhase2[] = {0x21,0xF0,0x7B,0xD6}; -static const UCHAR SiS_PALPhase2[] = {0x2a,0x09,0x86,0xe9}; -static const UCHAR SiS_PALMPhase2[] = {0x21,0xE6,0xEF,0xA4}; -static const UCHAR SiS_PALNPhase2[] = {0x21,0xF6,0x94,0x46}; -static const UCHAR SiS_SpecialPhase[] = {0x1e,0x8c,0x5c,0x7a}; -static const UCHAR SiS_SpecialPhaseM[]= {0x1e,0x83,0x0a,0xe0}; -static const UCHAR SiS_SpecialPhaseJ[]= {0x25,0xd4,0xfd,0x5e}; - -static const SiS_TVDataStruct SiS_StPALData[] = +static const struct SiS_TVData SiS_StPALData[] = { - { 1, 1, 864, 525,1270, 400, 100, 0, 760,0xf4,0xff,0x1c,0x22}, - { 1, 1, 864, 525,1270, 350, 100, 0, 760,0xf4,0xff,0x1c,0x22}, - { 1, 1, 864, 525,1270, 400, 0, 0, 720,0xf1,0x04,0x1f,0x18}, - { 1, 1, 864, 525,1270, 350, 0, 0, 720,0xf4,0x0b,0x1c,0x0a}, - { 1, 1, 864, 525,1270, 480, 50, 0, 760,0xf4,0xff,0x1c,0x22}, - { 1, 1, 864, 525,1270, 600, 50, 0, 0,0xf4,0xff,0x1c,0x22} + { 1, 1, 864, 525,1270, 400, 100, 0, 760, 0,0xf4,0xff,0x1c,0x22}, + { 1, 1, 864, 525,1270, 350, 100, 0, 760, 0,0xf4,0xff,0x1c,0x22}, + { 1, 1, 864, 525,1270, 400, 0, 0, 720, 0,0xf1,0x04,0x1f,0x18}, + { 1, 1, 864, 525,1270, 350, 0, 0, 720, 0,0xf4,0x0b,0x1c,0x0a}, + { 1, 1, 864, 525,1270, 480, 50, 0, 760, 0,0xf4,0xff,0x1c,0x22}, + { 1, 1, 864, 525,1270, 600, 50, 0, 0,0x300,0xf4,0xff,0x1c,0x22} }; -static const SiS_TVDataStruct SiS_ExtPALData[] = +static const struct SiS_TVData SiS_ExtPALData[] = { - { 27, 10, 848, 448,1270, 530, 50, 0, 50,0xf4,0xff,0x1c,0x22}, /* 640x400, 320x200 */ - { 108, 35, 848, 398,1270, 530, 50, 0, 50,0xf4,0xff,0x1c,0x22}, - { 12, 5, 954, 448,1270, 530, 50, 0, 50,0xf1,0x04,0x1f,0x18}, - { 9, 4, 960, 463,1644, 438, 50, 0, 50,0xf4,0x0b,0x1c,0x0a}, - { 9, 4, 848, 528,1270, 530, 0, 0, 50,0xf5,0xfb,0x1b,0x2a}, /* 640x480, 320x240 */ -/*{ 36, 25,1060, 648,1316, 530, 438, 0, 438,0xeb,0x05,0x25,0x16},*//* 800x600, 400x300 */ - { 36, 25,1060, 648,1270, 530, 438, 0, 438,0xeb,0x05,0x25,0x16}, /* 800x600, 400x300 - better */ - { 3, 2,1080, 619,1270, 540, 438, 0, 438,0xf3,0x00,0x1d,0x20}, /* 720x576 */ - { 1, 1,1170, 821,1270, 520, 686, 0, 686,0xF3,0x00,0x1D,0x20}, /* 1024x768 */ - { 1, 1,1170, 821,1270, 520, 686, 0, 686,0xF3,0x00,0x1D,0x20}, /* 1024x768 (for NTSC equ) */ - { 9, 4, 848, 528,1270, 530, 0, 0, 50,0xf5,0xfb,0x1b,0x2a} /* 720x480 test */ + { 27, 10, 848, 448,1270, 530, 50, 0, 50, 0,0xf4,0xff,0x1c,0x22}, /* 640x400, 320x200 */ + { 108, 35, 848, 398,1270, 530, 50, 0, 50, 0,0xf4,0xff,0x1c,0x22}, + { 12, 5, 954, 448,1270, 530, 50, 0, 50, 0,0xf1,0x04,0x1f,0x18}, + { 9, 4, 960, 463,1644, 438, 50, 0, 50, 0,0xf4,0x0b,0x1c,0x0a}, + { 9, 4, 848, 528,1270, 530, 0, 0, 50, 0,0xf5,0xfb,0x1b,0x2a}, /* 640x480, 320x240 */ + { 36, 25,1060, 648,1270, 530, 438, 0, 438, 0,0xeb,0x05,0x25,0x16}, /* 800x600, 400x300 */ + { 3, 2,1080, 619,1270, 540, 438, 0, 438, 0,0xf3,0x00,0x1d,0x20}, /* 720x576 */ + { 1, 1,1170, 821,1270, 520, 686, 0, 686, 0,0xF3,0x00,0x1D,0x20}, /* 1024x768 */ + { 1, 1,1170, 821,1270, 520, 686, 0, 686, 0,0xF3,0x00,0x1D,0x20}, /* 1024x768 (for NTSC equ) */ + { 9, 4, 848, 528,1270, 530, 0, 0, 50, 0,0xf5,0xfb,0x1b,0x2a} /* 720x480 */ }; -static const SiS_TVDataStruct SiS_StNTSCData[] = +static const struct SiS_TVData SiS_StNTSCData[] = { - { 1, 1, 858, 525,1270, 400, 50, 0, 760,0xf1,0x04,0x1f,0x18}, - { 1, 1, 858, 525,1270, 350, 50, 0, 640,0xf1,0x04,0x1f,0x18}, - { 1, 1, 858, 525,1270, 400, 0, 0, 720,0xf1,0x04,0x1f,0x18}, - { 1, 1, 858, 525,1270, 350, 0, 0, 720,0xf4,0x0b,0x1c,0x0a}, - { 1, 1, 858, 525,1270, 480, 0, 0, 760,0xf1,0x04,0x1f,0x18} + { 1, 1, 858, 525,1270, 400, 50, 0, 760, 0,0xf1,0x04,0x1f,0x18}, + { 1, 1, 858, 525,1270, 350, 50, 0, 640, 0,0xf1,0x04,0x1f,0x18}, + { 1, 1, 858, 525,1270, 400, 0, 0, 720, 0,0xf1,0x04,0x1f,0x18}, + { 1, 1, 858, 525,1270, 350, 0, 0, 720, 0,0xf4,0x0b,0x1c,0x0a}, + { 1, 1, 858, 525,1270, 480, 0, 0, 760, 0,0xf1,0x04,0x1f,0x18} }; -static const SiS_TVDataStruct SiS_ExtNTSCData[] = +static const struct SiS_TVData SiS_ExtNTSCData[] = { - { 143, 65, 858, 443,1270, 440, 171, 0, 171,0xf1,0x04,0x1f,0x18}, /* 640x400, 320x200 */ - { 88, 35, 858, 393,1270, 440, 171, 0, 171,0xf1,0x04,0x1f,0x18}, - { 143, 70, 924, 443,1270, 440, 92, 0, 92,0xf1,0x04,0x1f,0x18}, - { 143, 70, 924, 393,1270, 440, 92, 0, 92,0xf4,0x0b,0x1c,0x0a}, - { 143, 76, 836, 523,1270, 440, 224, 0, 0,0xf1,0x05,0x1f,0x16}, /* 640x480, 320x240 */ - { 143, 120,1056, 643,1270, 440, 0, 128, 0,0xf4,0x10,0x1c,0x00}, /* 800x600, 400x300 */ -/*{ 2, 1, 858, 503,1270, 480, 0, 128, 0,0xee,0x0c,0x22,0x08},*/ /* 720x480 (old, from 650) */ - { 143, 76, 836, 523,1270, 440, 0, 128, 0,0xee,0x0c,0x22,0x08}, /* 720x480 - BETTER (from 300 series) */ -/*{ 65, 64,1056, 791,1270, 480, 638, 0, 0,0xEE,0x0C,0x22,0x08} */ /* 1024x768 (525i) */ - { 1, 1,1100, 811,1412, 440, 0, 128, 0,0xee,0x0c,0x22,0x08}, /* 1024x768 (525i) CORRECTED */ - { 65, 64,1056, 791,1270, 480, 455, 0, 0,0x00,0x00,0x00,0x00} /* 1024x768 (525p) */ + { 143, 65, 858, 443,1270, 440, 171, 0, 171, 0,0xf1,0x04,0x1f,0x18}, /* 640x400, 320x200 */ + { 88, 35, 858, 393,1270, 440, 171, 0, 171, 0,0xf1,0x04,0x1f,0x18}, + { 143, 70, 924, 443,1270, 440, 92, 0, 92, 0,0xf1,0x04,0x1f,0x18}, + { 143, 70, 924, 393,1270, 440, 92, 0, 92, 0,0xf4,0x0b,0x1c,0x0a}, + { 143, 76, 836, 523,1270, 440, 224, 0, 0, 0,0xf1,0x05,0x1f,0x16}, /* 640x480, 320x240 */ + { 143, 120,1056, 643,1270, 440, 0, 1, 0, 0,0xf4,0x10,0x1c,0x00}, /* 800x600, 400x300 */ + { 143, 76, 836, 523,1270, 440, 0, 1, 0, 0,0xee,0x0c,0x22,0x08}, /* 720x480 - BETTER (from 300 series) */ + { 1, 1,1100, 811,1412, 440, 0, 1, 0, 0,0xee,0x0c,0x22,0x08}, /* 1024x768 (525i) CORRECTED */ +#if 0 /* flimmert und ist unten abgeschnitten (NTSCHT, NTSC clock) */ + { 65, 64,1056, 791,1270, 480, 455, 0, 0, 0,0x00,0x00,0x00,0x00} /* 1024x768 (525p) */ +#endif +#if 0 + { 1, 1,1100, 811,1412, 440, 0, 1, 0, 0,0x00,0x00,0x00,0x00} /* 1024x768 (525p) */ +#endif +#if 0 + { 1, 1,1120, 821,1516, 420, 0, 1, 0, 0,0x00,0x00,0x00,0x00} /* 1024x768 (525p) */ +#endif +#if 0 + { 1, 1, 938, 821,1516, 420, 0, 1, 0, 0,0x00,0x00,0x00,0x00} /* 1024x768 (525p) */ +#endif +#if 0 /* zoom hin, unten abgeschnitten (NTSC2HT, NTSC1024 clock) */ + { 1, 1,1072, 791,1270, 480, 455, 0, 0, 0,0x00,0x00,0x00,0x00} /* 1024x768 (525p) */ +#endif +#if 1 /* zu weit links (squeezed) (NTSC2HT, NTSC1024 clock) */ + { 1, 1,1100, 846,1270, 440, 455, 0, 0, 0,0x00,0x00,0x00,0x00} /* 1024x768 (525p) */ +#endif +#if 0 /* zu weit links, rechts abgeschnitten (NTSC2HT, NTSC1024 clock) */ + { 1, 1,1100, 846,1412, 440, 455, 0, 0, 0,0x00,0x00,0x00,0x00} /* 1024x768 (525p) */ +#endif }; -static const SiS_TVDataStruct SiS_StHiTVData[] = /* Slave + TVSimu */ +static const struct SiS_TVData SiS_StHiTVData[] = /* Slave + TVSimu */ { - { 1, 1, 0x37c,0x233,0x2b2,0x320, 0, 0, 0, 0x00,0x00,0x00,0x00}, - { 1, 1, 0x37c,0x233,0x2b2,0x2bc, 0, 0, 0, 0x00,0x00,0x00,0x00}, - { 1, 1, 0x37c,0x233,0x2b2,0x320, 0, 0, 0, 0x00,0x00,0x00,0x00}, - { 1, 1, 0x37c,0x233,0x2b2,0x2bc, 0, 0, 0, 0x00,0x00,0x00,0x00}, - { 1, 1, 0x37c,0x233,0x2b2,0x3c0, 0, 0, 0, 0x00,0x00,0x00,0x00}, - { 8, 5, 0x41a,0x2ab,0x670,0x3c0,0x150,128, 0, 0x00,0x00,0x00,0x00} + { 1, 1, 0x37c,0x233,0x2b2,0x320, 0, 0, 0, 0, 0, 0, 0, 0}, + { 1, 1, 0x37c,0x233,0x2b2,0x2bc, 0, 0, 0, 0, 0, 0, 0, 0}, + { 1, 1, 0x37c,0x233,0x2b2,0x320, 0, 0, 0, 0, 0, 0, 0, 0}, + { 1, 1, 0x37c,0x233,0x2b2,0x2bc, 0, 0, 0, 0, 0, 0, 0, 0}, + { 1, 1, 0x37c,0x233,0x2b2,0x3c0, 0, 0, 0, 0, 0, 0, 0, 0}, + { 8, 5, 0x41a,0x2ab,0x670,0x3c0,0x150, 1, 0, 0, 0, 0, 0, 0} }; -static const SiS_TVDataStruct SiS_St2HiTVData[] = /* Slave */ +static const struct SiS_TVData SiS_St2HiTVData[] = /* Slave */ { - { 3, 1, 0x348,0x1e3,0x670,0x3c0,0x032, 0, 0, 0x00,0x00,0x00,0x00}, - { 1, 1, 0x37c,0x233,0x2b2,0x2bc, 0, 0, 0, 0x00,0x00,0x00,0x00}, - { 3, 1, 0x348,0x1e3,0x670,0x3c0,0x032, 0, 0, 0x00,0x00,0x00,0x00}, - { 1, 1, 0x37c,0x233,0x2b2,0x2bc, 0, 0, 0, 0x00,0x00,0x00,0x00}, - { 5, 2, 0x348,0x233,0x670,0x3c0,0x08d,128, 0, 0x00,0x00,0x00,0x00}, - { 8, 5, 0x41a,0x2ab,0x670,0x3c0,0x17c,128, 0, 0x00,0x00,0x00,0x00} + { 3, 1, 0x348,0x1e3,0x670,0x3c0,0x032, 0, 0, 0, 0, 0, 0, 0}, + { 1, 1, 0x37c,0x233,0x2b2,0x2bc, 0, 0, 0, 0, 0, 0, 0, 0}, + { 3, 1, 0x348,0x1e3,0x670,0x3c0,0x032, 0, 0, 0, 0, 0, 0, 0}, + { 1, 1, 0x37c,0x233,0x2b2,0x2bc, 0, 0, 0, 0, 0, 0, 0, 0}, + { 5, 2, 0x348,0x233,0x670,0x3c0,0x08d, 1, 0, 0, 0, 0, 0, 0}, + { 8, 5, 0x41a,0x2ab,0x670,0x3c0,0x17c, 1, 0, 0, 0, 0, 0, 0} }; -static const SiS_TVDataStruct SiS_ExtHiTVData[] = -{ - { 6, 1, 0x348,0x233,0x660,0x3c0, 0, 0, 0, 0x00,0x00,0x00,0x00}, - { 3, 1, 0x3c0,0x233,0x660,0x3c0, 0, 0, 0, 0x00,0x00,0x00,0x00}, - { 6, 1, 0x348,0x233,0x660,0x3c0, 0, 0, 0, 0x00,0x00,0x00,0x00}, - { 3, 1, 0x3c0,0x233,0x660,0x3c0, 0, 0, 0, 0x00,0x00,0x00,0x00}, - { 5, 1, 0x348,0x233,0x670,0x3c0,0x166,128, 0, 0x00,0x00,0x00,0x00}, /* 640x480 */ - { 16, 5, 0x41a,0x2ab,0x670,0x3c0,0x143,128, 0, 0x00,0x00,0x00,0x00}, /* 800x600 */ - { 25, 12, 0x4ec,0x353,0x670,0x3c0,0x032, 0, 0, 0x00,0x00,0x00,0x00}, /* 1024x768 */ - { 5, 4, 0x627,0x464,0x670,0x3c0,0x128, 0, 0, 0x00,0x00,0x00,0x00}, /* 1280x1024 */ - { 4, 1, 0x41a,0x233,0x60c,0x3c0,0x143,128, 0, 0x00,0x00,0x00,0x00}, /* 800x480 */ - { 5, 2, 0x578,0x293,0x670,0x3c0,0x032, 0, 0, 0x00,0x00,0x00,0x00}, /* 1024x576 */ - { 8, 5, 0x6d6,0x323,0x670,0x3c0,0x128, 0, 0, 0x00,0x00,0x00,0x00}, /* 1280x720 */ - { 137, 32, 0x3d4,0x233,0x663,0x3bf,0x143, 0, 0, 0x00,0x00,0x00,0x00} /* 960x600 */ +static const struct SiS_TVData SiS_ExtHiTVData[] = +{ /* all ok */ + { 6, 1, 0x348,0x233,0x660,0x3c0, 0, 0, 0, 0, 0, 0, 0, 0}, + { 3, 1, 0x3c0,0x233,0x660,0x3c0, 0, 0, 0, 0, 0, 0, 0, 0}, + { 6, 1, 0x348,0x233,0x660,0x3c0, 0, 0, 0, 0, 0, 0, 0, 0}, + { 3, 1, 0x3c0,0x233,0x660,0x3c0, 0, 0, 0, 0, 0, 0, 0, 0}, + { 5, 1, 0x348,0x233,0x670,0x3c0,0x166, 1, 0, 0, 0, 0, 0, 0}, /* 640x480 */ + { 16, 5, 0x41a,0x2ab,0x670,0x3c0,0x143, 1, 0, 0, 0, 0, 0, 0}, /* 800x600 */ + { 25, 12, 0x4ec,0x353,0x670,0x3c0,0x032, 0, 0, 0, 0, 0, 0, 0}, /* 1024x768 */ + { 5, 4, 0x627,0x464,0x670,0x3c0,0x128, 0, 0, 0, 0, 0, 0, 0}, /* 1280x1024 */ + { 4, 1, 0x41a,0x233,0x60c,0x3c0,0x143, 1, 0, 0, 0, 0, 0, 0}, /* 800x480 */ + { 5, 2, 0x578,0x293,0x670,0x3c0,0x032, 0, 0, 0, 0, 0, 0, 0}, /* 1024x576 */ + { 8, 5, 0x6d6,0x323,0x670,0x3c0,0x128, 0, 0, 0, 0, 0, 0, 0}, /* 1280x720 */ + { 8, 3, 0x4ec,0x353,0x670,0x3c0,0x032, 0, 0, 0, 0, 0, 0, 0}, /* 960x600 */ }; -static const SiS_TVDataStruct SiS_St525pData[] = +static const struct SiS_TVData SiS_St525pData[] = { - { 1, 1, 0x6b4,0x20d,0x4f6,0x190, 50, 0, 0x2f8, 0x00,0x00,0x00,0x00}, - { 1, 1, 0x6b4,0x20d,0x4f6,0x15e, 50, 0, 0x280, 0x00,0x00,0x00,0x00}, - { 1, 1, 0x6b4,0x20d,0x4f6,0x190, 50, 0, 0x2f8, 0x00,0x00,0x00,0x00}, - { 1, 1, 0x6b4,0x20d,0x4f6,0x15e, 50, 0, 0x280, 0x00,0x00,0x00,0x00}, - { 1, 1, 0x6b4,0x20d,0x4f6,0x1e0, 0, 0, 0x2f8, 0x00,0x00,0x00,0x00} + { 1, 1, 0x6b4,0x20d,0x4f6,0x190, 50, 0, 0x2f8, 0, 0, 0, 0, 0}, + { 1, 1, 0x6b4,0x20d,0x4f6,0x15e, 50, 0, 0x280, 0, 0, 0, 0, 0}, + { 1, 1, 0x6b4,0x20d,0x4f6,0x190, 50, 0, 0x2f8, 0, 0, 0, 0, 0}, + { 1, 1, 0x6b4,0x20d,0x4f6,0x15e, 50, 0, 0x280, 0, 0, 0, 0, 0}, + { 1, 1, 0x6b4,0x20d,0x4f6,0x1e0, 0, 0, 0x2f8, 0, 0, 0, 0, 0} }; -static const SiS_TVDataStruct SiS_St750pData[] = +static const struct SiS_TVData SiS_St750pData[] = { - { 1, 1, 0x672,0x2ee,0x500,0x190, 50, 0, 0x2f8, 0x00,0x00,0x00,0x00}, - { 1, 1, 0x672,0x2ee,0x500,0x15e, 50, 0, 0x280, 0x00,0x00,0x00,0x00}, - { 1, 1, 0x672,0x2ee,0x500,0x190, 0, 0, 0x2d0, 0x00,0x00,0x00,0x00}, - { 1, 1, 0x672,0x2ee,0x500,0x15e, 0, 0, 0x2d0, 0x00,0x00,0x00,0x00}, - { 1, 1, 0x672,0x2ee,0x500,0x1e0, 0, 0, 0x2f8, 0x00,0x00,0x00,0x00} + { 1, 1, 0x672,0x2ee,0x500,0x190, 50, 0, 0x2f8, 0, 0, 0, 0, 0}, + { 1, 1, 0x672,0x2ee,0x500,0x15e, 50, 0, 0x280, 0, 0, 0, 0, 0}, + { 1, 1, 0x672,0x2ee,0x500,0x190, 0, 0, 0x2d0, 0, 0, 0, 0, 0}, + { 1, 1, 0x672,0x2ee,0x500,0x15e, 0, 0, 0x2d0, 0, 0, 0, 0, 0}, + { 1, 1, 0x672,0x2ee,0x500,0x1e0, 0, 0, 0x2f8, 0, 0, 0, 0, 0} }; -static const SiS_TVDataStruct SiS_Ext750pData[] = -{ - { 143, 65, 0x35a,0x1bb,0x4f6,0x1b8,0x0ab, 0, 0x0ab, 0x00,0x00,0x00,0x00}, - { 88, 35, 0x35a,0x189,0x4f6,0x1b8,0x0ab, 0, 0x0ab, 0x00,0x00,0x00,0x00}, - { 18, 5, 0x339,0x1ae,0x500,0x2d0,0x05c, 0, 0x05c, 0x00,0x00,0x00,0x00}, - { 143, 70, 0x39c,0x189,0x4f6,0x1b8,0x05c, 0, 0x05c, 0x00,0x00,0x00,0x00}, - { 99, 32, 0x320,0x1fe,0x500,0x2d0, 50, 0, 0, 0x00,0x00,0x00,0x00}, /* 640x480 */ - { 5, 4, 0x5d8,0x29e,0x500,0x2a8, 50, 0, 0, 0x00,0x00,0x00,0x00}, /* 800x600 */ - { 99, 32, 0x320,0x1fe,0x500,0x2d0, 50, 0, 0, 0x00,0x00,0x00,0x00}, /* 720x480 test WORKS */ - { 68, 64, 0x55f,0x346,0x500,0x2a8,0x27e, 0, 0, 0x00,0x00,0x00,0x00}, /* 1024x768 */ - { 5, 2, 0x3a7,0x226,0x500,0x2a8, 0,128, 0, 0x00,0x00,0x00,0x00}, /* 720x576 */ - { 25, 24, 0x5d8,0x2f3,0x460,0x2a8, 50, 0, 0, 0x00,0x00,0x00,0x00} /* 1280x720 WORKS */ +static const struct SiS_TVData SiS_Ext750pData[] = +{ /* all ok */ + { 3, 1, 935, 470, 1130, 680, 50, 0, 0, 0, 0, 0, 0, 0}, /* 320x200/640x400 */ + { 24, 7, 935, 420, 1130, 680, 50, 0, 0, 0, 0, 0, 0, 0}, + { 3, 1, 935, 470, 1130, 680, 50, 0, 0, 0, 0, 0, 0, 0}, + { 24, 7, 935, 420, 1130, 680, 50, 0, 0, 0, 0, 0, 0, 0}, + { 2, 1, 1100, 590, 1130, 640, 50, 0, 0, 0, 0, 0, 0, 0}, /* 640x480 */ + { 3, 2, 1210, 690, 1130, 660, 50, 0, 0, 0, 0, 0, 0, 0}, /* 800x600 OK */ + { 2, 1, 1100, 562, 1130, 640, 0, 1, 0, 0, 0, 0, 0, 0}, /* 720x480 OK */ + { 1, 1, 1375, 878, 1130, 640, 638, 0, 0, 0, 0, 0, 0, 0}, /* 1024x768 OK */ + { 5, 3, 1100, 675, 1130, 640, 0, 1, 0, 0, 0, 0, 0, 0}, /* 720/768x576 OK */ + { 25, 24, 1496, 755, 1120, 680, 50, 0, 0, 0, 0, 0, 0, 0} /* 1280x720 OK */ }; -static const SiS_LCDDataStruct SiS_LCD1280x720Data[] = /* 2.03.00 */ +static const struct SiS_LCDData SiS_LCD1280x720Data[] = /* 2.03.00 */ { { 44, 15, 864, 430, 1408, 806 }, /* 640x400 */ { 128, 35, 792, 385, 1408, 806 }, @@ -962,7 +1003,7 @@ static const SiS_LCDDataStruct SiS_LCD1280x720Data[] = /* 2.03.00 */ * (Note: 1280x768_3 is now special for SiS301/NetVista */ -static const SiS_LCDDataStruct SiS_StLCD1280x768_2Data[] = /* 2.03.00 */ +static const struct SiS_LCDData SiS_StLCD1280x768_2Data[] = /* 2.03.00 */ { { 64, 21, 858, 434, 1408, 806 }, /* 640x400 */ { 32, 9, 858, 372, 1408, 806 }, @@ -977,7 +1018,7 @@ static const SiS_LCDDataStruct SiS_StLCD1280x768_2Data[] = /* 2.03.00 */ { 16, 15, 1600, 750, 1600, 806 } /* 1280x720 - from Ext */ }; -static const SiS_LCDDataStruct SiS_ExtLCD1280x768_2Data[] = /* 2.03.00 */ +static const struct SiS_LCDData SiS_ExtLCD1280x768_2Data[] = /* 2.03.00 */ { { 16, 5, 960, 410, 1600, 806 }, /* 640x400 */ { 64, 21, 1152, 364, 1600, 806 }, @@ -993,7 +1034,7 @@ static const SiS_LCDDataStruct SiS_ExtLCD1280x768_2Data[] = /* 2.03.00 */ }; #if 0 /* Not used; _3 now reserved for NetVista (SiS301) */ -static const SiS_LCDDataStruct SiS_LCD1280x768_3Data[] = +static const struct SiS_LCDData SiS_LCD1280x768_3Data[] = { { 64, 25, 1056, 422, 1664, 798 }, /* 640x400 */ { 128, 39, 884, 396, 1408, 806 }, /* ,640 */ @@ -1009,7 +1050,7 @@ static const SiS_LCDDataStruct SiS_LCD1280x768_3Data[] = }; #endif -static const SiS_LCDDataStruct SiS_LCD1280x800Data[] = /* 0.93.12a (TMDS) */ +static const struct SiS_LCDData SiS_LCD1280x800Data[] = /* 0.93.12a (TMDS) */ { { 128, 51, 1122, 412, 1408, 816 }, /* 640x400 */ { 128, 49, 1232, 361, 1408, 816 }, @@ -1024,7 +1065,7 @@ static const SiS_LCDDataStruct SiS_LCD1280x800Data[] = /* 0.93.12a (TMDS) */ { 0, 0, 0, 0, 0, 0 } /* 1280x720 */ }; -static const SiS_LCDDataStruct SiS_LCD1280x800_2Data[] = /* 2.03.00 (LVDS) */ +static const struct SiS_LCDData SiS_LCD1280x800_2Data[] = /* 2.03.00 (LVDS) */ { { 97, 42, 1344, 409, 1552, 812 }, /* 640x400 */ { 97, 35, 1280, 358, 1552, 812 }, @@ -1039,7 +1080,42 @@ static const SiS_LCDDataStruct SiS_LCD1280x800_2Data[] = /* 2.03.00 (LVDS) */ { 97, 90, 1600, 730, 1552, 812 } /* 1280x720 */ }; -static const SiS_LCDDataStruct SiS_LCD1280x960Data[] = +#if 0 +static const struct SiS_LCDData SiS_LCD1280x800_3Data[] = /* 2.02.05a (LVDS); m250 */ +{ + { 128, 51, 1122, 412, 1408, 816 }, /* 640x400 */ + { 128, 49, 1232, 361, 1408, 816 }, + { 128, 51, 1122, 412, 1408, 816 }, + { 128, 49, 1232, 361, 1408, 816 }, + { 8, 3, 880, 491, 1408, 816 }, /* 640x480 */ + { 11, 6, 1024, 612, 1408, 816 }, /* 800x600 */ + { 22, 21, 1400, 784, 1408, 816 }, /* 1024x768 */ + { 0, 0, 0, 0, 0, 0 }, /* 1280x1024 */ + { 1, 1, 1408, 816, 1408, 816 }, /* 1280x800 */ + { 0, 0, 0, 0, 0, 0 }, /* 1280x768 - patch index */ + { 0, 0, 0, 0, 0, 0 } /* 1280x720 */ +}; +#endif + +static const struct SiS_LCDData SiS_LCD1280x854Data[] = /* 2.21.00CS (LVDS) */ +{ + { 56, 15, 936, 410, 1664, 861 }, /* 640x400 */ + { 64, 25, 1586, 355, 1664, 861 }, + { 56, 15, 936, 410, 1664, 861 }, + { 64, 25, 1586, 355, 1664, 861 }, + { 91, 45, 1464, 485, 1664, 861 }, /* 640x480 */ + { 182, 75, 976, 605, 1664, 861 }, /* 800x600 */ + { 91, 66, 1342, 774, 1664, 861 }, /* 1024x768 */ + { 0, 0, 0, 0, 0, 0 }, /* 1280x1024 */ + { 26, 25, 1708, 807, 1664, 861 }, /* 1280x800 */ + { 13, 12, 1708, 774, 1664, 861 }, /* 1280x768 - patch index */ + { 52, 45, 1708, 725, 1664, 861 }, /* 1280x720 */ + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 }, + { 1, 1, 1664, 861, 1664, 861 } /* 1280x854 */ +}; + +static const struct SiS_LCDData SiS_LCD1280x960Data[] = { { 9, 2, 800, 500, 1800, 1000 }, { 9, 2, 800, 500, 1800, 1000 }, @@ -1049,10 +1125,15 @@ static const SiS_LCDDataStruct SiS_LCD1280x960Data[] = { 30, 11, 1056, 625, 1800, 1000 }, { 5, 3, 1350, 800, 1800, 1000 }, { 1, 1, 1576, 1050, 1576, 1050 }, - { 1, 1, 1800, 1000, 1800, 1000 } + { 1, 1, 1800, 1000, 1800, 1000 }, + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 } }; -static const SiS_LCDDataStruct SiS_StLCD1400x1050Data[] = +static const struct SiS_LCDData SiS_StLCD1400x1050Data[] = { { 211, 100, 2100, 408, 1688, 1066 }, { 211, 64, 1536, 358, 1688, 1066 }, @@ -1062,10 +1143,15 @@ static const SiS_LCDDataStruct SiS_StLCD1400x1050Data[] = { 211, 72, 1008, 609, 1688, 1066 }, { 211, 128, 1400, 776, 1688, 1066 }, { 211, 205, 1680, 1041, 1688, 1066 }, - { 1, 1, 1688, 1066, 1688, 1066 } + { 1, 1, 1688, 1066, 1688, 1066 }, + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 } }; -static const SiS_LCDDataStruct SiS_ExtLCD1400x1050Data[] = +static const struct SiS_LCDData SiS_ExtLCD1400x1050Data[] = { /* { 211, 60, 1260, 410, 1688, 1066 }, 640x400 (6330) */ { 211, 100, 2100, 408, 1688, 1066 }, /* 640x400 (6325) WORKS */ @@ -1080,10 +1166,13 @@ static const SiS_LCDDataStruct SiS_ExtLCD1400x1050Data[] = { 211, 205, 1680, 1041, 1688, 1066 }, /* 1280x1024 - not used (always unscaled) */ { 1, 1, 1688, 1066, 1688, 1066 }, /* 1400x1050 */ { 0, 0, 0, 0, 0, 0 }, /* kludge */ - { 211, 120, 1400, 730, 1688, 1066 } /* 1280x720 */ + { 211, 120, 1400, 730, 1688, 1066 }, /* 1280x720 */ + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 } }; -static const SiS_LCDDataStruct SiS_LCD1680x1050Data[] = +static const struct SiS_LCDData SiS_LCD1680x1050Data[] = { { 95, 24, 1260, 410, 1900, 1066 }, /* 0 640x400 */ { 10, 3, 1710, 362, 1900, 1066 }, @@ -1097,10 +1186,11 @@ static const SiS_LCDDataStruct SiS_LCD1680x1050Data[] = { 95, 69, 1800, 817, 1900, 1066 }, /* 9 1280x800 patch index */ { 13, 9, 1900, 739, 1900, 1066 }, /* 10 1280x720 */ { 95, 94, 1880, 1066, 1900, 1066 }, /* 11 1400x1050 patch index */ - { 1, 1, 1900, 1066, 1900, 1066 } /* 12 1680x1050 */ + { 1, 1, 1900, 1066, 1900, 1066 }, /* 12 1680x1050 */ + { 0, 0, 0, 0, 0, 0 } }; -static const SiS_LCDDataStruct SiS_StLCD1600x1200Data[] = +static const struct SiS_LCDData SiS_StLCD1600x1200Data[] = { {27, 4, 800, 500, 2160, 1250 }, {27, 4, 800, 500, 2160, 1250 }, @@ -1111,10 +1201,14 @@ static const SiS_LCDDataStruct SiS_StLCD1600x1200Data[] = { 5, 2,1350, 800, 2160, 1250 }, {135,88,1600,1100, 2160, 1250 }, {72, 49,1680,1092, 2160, 1250 }, - { 1, 1,2160,1250, 2160, 1250 } + { 1, 1,2160,1250, 2160, 1250 }, + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 } }; -static const SiS_LCDDataStruct SiS_ExtLCD1600x1200Data[] = +static const struct SiS_LCDData SiS_ExtLCD1600x1200Data[] = { {72,11, 990, 422, 2160, 1250 }, /* 640x400 (6330) WORKS */ /* {27, 4, 800, 500, 2160, 1250 }, 640x400 (6235) */ @@ -1127,10 +1221,14 @@ static const SiS_LCDDataStruct SiS_ExtLCD1600x1200Data[] = { 5, 2,1350, 800, 2160, 1250 }, {27,16,1500,1064, 2160, 1250 }, /* 1280x1024 */ {72,49,1680,1092, 2160, 1250 }, /* 1400x1050 (6330, was not supported on 6325) */ - { 1, 1,2160,1250, 2160, 1250 } + { 1, 1,2160,1250, 2160, 1250 }, + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 } }; -static const SiS_LCDDataStruct SiS_NoScaleData[] = +static const struct SiS_LCDData SiS_NoScaleData[] = { { 1, 1, 800, 449, 800, 449 }, /* 0x00: 320x200, 640x400 */ { 1, 1, 800, 449, 800, 449 }, @@ -1162,14 +1260,18 @@ static const SiS_LCDDataStruct SiS_NoScaleData[] = { 1, 1,1808, 808,1808, 808 }, /* 0x1b: 1360x768 */ { 1, 1,1104, 563,1104, 563 }, /* 0x1c: 960x540 */ { 1, 1,1120, 618,1120, 618 }, /* 0x1d: 960x600 */ - { 1, 1,1408, 816,1408, 816 } /* 0x1f: 1280x800 (TMDS special) */ + { 1, 1,1408, 816,1408, 816 }, /* 0x1f: 1280x800 (TMDS special) */ + { 1, 1,1760,1235,1760,1235 }, /* 0x20: 1600x1200 for LCDA */ + { 1, 1,2048,1320,2048,1320 }, /* 0x21: 1600x1200 for non-SiS LVDS */ + { 1, 1,1664, 861,1664, 861 } /* 0x22: 1280x854 */ }; /**************************************************************/ /* LVDS ----------------------------------------------------- */ /**************************************************************/ -static const SiS_LVDSDataStruct SiS_LVDS320x480Data_1[]= +/* FSTN/DSTN 320x240, 2 variants */ +static const struct SiS_LVDSData SiS_LVDS320x240Data_1[]= { { 848, 433, 400, 525}, { 848, 389, 400, 525}, @@ -1177,157 +1279,40 @@ static const SiS_LVDSDataStruct SiS_LVDS320x480Data_1[]= { 848, 389, 400, 525}, { 848, 518, 400, 525}, {1056, 628, 400, 525}, - { 400, 525, 400, 525}, - { 800, 449,1000, 644}, - { 800, 525,1000, 635} + { 400, 525, 400, 525} /* xSTN */ }; -static const SiS_LVDSDataStruct SiS_LVDS640x480Data_1[]= +static const struct SiS_LVDSData SiS_LVDS320x240Data_2[]= { - { 800, 445, 800, 525}, /* 800, 449, 800, 449 */ + { 800, 445, 800, 525}, { 800, 395, 800, 525}, { 800, 445, 800, 525}, { 800, 395, 800, 525}, { 800, 525, 800, 525}, - { 800, 525, 800, 525}, /* pseudo */ - { 800, 525, 800, 525} /* pseudo */ + {1056, 628,1056, 628}, + { 480, 525, 480, 525} /* xSTN */ }; -/* FSTN 320x240 */ -static const SiS_LVDSDataStruct SiS_LVDS640x480Data_2[]= +static const struct SiS_LVDSData SiS_LVDS640x480Data_1[]= { - { 800, 445, 800, 525}, + { 800, 445, 800, 525}, /* 800, 449, 800, 449 */ { 800, 395, 800, 525}, { 800, 445, 800, 525}, { 800, 395, 800, 525}, - { 800, 525, 800, 525}, - { 800, 525, 800, 525}, /* pseudo */ - { 800, 525, 800, 525} /* pseudo */ + { 800, 525, 800, 525} }; -static const SiS_LVDSDataStruct SiS_LVDS800x600Data_1[]= +static const struct SiS_LVDSData SiS_LVDS800x600Data_1[]= { { 848, 433,1060, 629}, { 848, 389,1060, 629}, { 848, 433,1060, 629}, { 848, 389,1060, 629}, { 848, 518,1060, 629}, - {1056, 628,1056, 628}, {1056, 628,1056, 628} }; -static const SiS_LVDSDataStruct SiS_LVDS800x600Data_2[]= -{ - {1056, 628,1056, 628} -}; - -static const SiS_LVDSDataStruct SiS_LVDS1024x768Data_1[]= -{ - { 840, 438,1344, 806}, - { 840, 409,1344, 806}, - { 840, 438,1344, 806}, - { 840, 409,1344, 806}, - { 840, 518,1344, 806}, /* 640x480 */ - {1050, 638,1344, 806}, /* 800x600 */ - {1344, 806,1344, 806}, /* 1024x768 */ -}; - -static const SiS_LVDSDataStruct SiS_LVDS1024x768Data_2[]= -{ - {1344, 806,1344, 806} -}; - -static const SiS_LVDSDataStruct SiS_LVDS1280x1024Data_1[]= -{ - {1048, 442,1688,1066}, - {1048, 392,1688,1066}, - {1048, 442,1688,1066}, - {1048, 392,1688,1066}, - {1048, 522,1688,1066}, - {1208, 642,1688,1066}, - {1432, 810,1688,1066}, - {1688,1066,1688,1066} -}; - -static const SiS_LVDSDataStruct SiS_LVDS1280x1024Data_2[]= -{ - {1688,1066,1688,1066} -}; - -static const SiS_LVDSDataStruct SiS_LVDS1400x1050Data_1[]= -{ - { 928, 416, 1688,1066}, - { 928, 366, 1688,1066}, - { 928, 416, 1688,1066}, - { 928, 366, 1688,1066}, - { 928, 496, 1688,1066}, - {1088, 616, 1688,1066}, - {1312, 784, 1688,1066}, - {1568,1040, 1688,1066}, - {1688,1066, 1688,1066} -}; - -static const SiS_LVDSDataStruct SiS_LVDS1400x1050Data_2[]= -{ - {1688,1066, 1688,1066} -}; - -static const SiS_LVDSDataStruct SiS_LVDS1600x1200Data_1[]= -{ - {1088, 520, 2048,1320}, - {1088, 470, 2048,1320}, - {1088, 520, 2048,1320}, - {1088, 470, 2048,1320}, - {1088, 600, 2048,1320}, - {1248, 720, 2048,1320}, - {1472, 888, 2048,1320}, - {1728,1144, 2048,1320}, - {1848,1170, 2048,1320}, - {2048,1320, 2048,1320} -}; - -static const SiS_LVDSDataStruct SiS_LVDS1600x1200Data_2[]= -{ - {2048,1320, 2048,1320} -}; - -static const SiS_LVDSDataStruct SiS_LVDS1280x960Data_1[]= -{ - { 840, 438,1344, 806}, - { 840, 409,1344, 806}, - { 840, 438,1344, 806}, - { 840, 409,1344, 806}, - { 840, 518,1344, 806}, - {1050, 638,1344, 806}, - {1344, 806,1344, 806}, - { 800, 449,1280, 801}, - { 800, 525,1280, 813} -}; - -static const SiS_LVDSDataStruct SiS_LVDS1280x960Data_2[]= -{ - {1344, 806,1344, 806} -}; - -static const SiS_LVDSDataStruct SiS_LVDS1280x768Data_1[]= -{ - { 768, 438, 1408, 806}, - { 768, 388, 1408, 806}, - { 768, 438, 1408, 806}, - { 768, 388, 1408, 806}, - { 768, 518, 1408, 806}, - { 928, 638, 1408, 806}, - {1152, 806, 1408, 806}, - {1408, 806, 1408, 806}, - {1408, 806, 1408, 806} -}; - -static const SiS_LVDSDataStruct SiS_LVDS1280x768Data_2[]= -{ - {1408, 806, 1408, 806} -}; - -static const SiS_LVDSDataStruct SiS_LVDS1024x600Data_1[] = +static const struct SiS_LVDSData SiS_LVDS1024x600Data_1[] = { { 840, 604,1344, 800}, { 840, 560,1344, 800}, @@ -1338,124 +1323,18 @@ static const SiS_LVDSDataStruct SiS_LVDS1024x600Data_1[] = {1344, 800,1344, 800} }; -static const SiS_LVDSDataStruct SiS_LVDS1024x600Data_2[] = -{ - {1344, 800,1344, 800} -}; - -static const SiS_LVDSDataStruct SiS_LVDS1152x768Data_1[] = +static const struct SiS_LVDSData SiS_LVDS1024x768Data_1[]= { { 840, 438,1344, 806}, { 840, 409,1344, 806}, { 840, 438,1344, 806}, { 840, 409,1344, 806}, - { 840, 518,1344, 806}, - {1050, 638,1344, 806}, - {1344, 806,1344, 806} -}; - -static const SiS_LVDSDataStruct SiS_LVDS1152x768Data_2[] = -{ - {1344, 806,1344, 806} -}; - -/* Pass 1:1 data */ -static const SiS_LVDSDataStruct SiS_LVDSXXXxXXXData_1[]= -{ - { 800, 449, 800, 449}, - { 800, 449, 800, 449}, - { 900, 449, 900, 449}, - { 900, 449, 900, 449}, - { 800, 525, 800, 525}, /* 640x480 */ - {1056, 628, 1056, 628}, /* 800x600 */ - {1344, 806, 1344, 806}, /* 1024x768 */ - {1688,1066, 1688,1066}, /* 1280x1024 */ /* INSERTED */ - {1688, 806, 1688, 806}, /* 1280x768 */ -}; - -/* Custom data for Barco iQ R series */ -static const SiS_LVDSDataStruct SiS_LVDSBARCO1366Data_1[]= -{ - { 832, 438,1331, 806}, - { 832, 388,1331, 806}, - { 832, 438,1331, 806}, - { 832, 388,1331, 806}, - { 832, 518,1331, 806}, - {1050, 638,1344, 806}, - {1344, 806,1344, 806}, - {1688,1066,1688,1066}, - {1688,1066,1688,1066} /* 1360x1024 */ -}; - -/* Custom data for Barco iQ R series */ -static const SiS_LVDSDataStruct SiS_LVDSBARCO1366Data_2[]= -{ - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1344, 806,1344, 806}, - {1688,1066,1688,1066}, - {1688,1066,1688,1066} /* 1360x1024 */ -}; - -/* Custom data for Barco iQ G series */ -static const SiS_LVDSDataStruct SiS_LVDSBARCO1024Data_1[]= -{ - { 832, 438,1331, 806}, - { 832, 409,1331, 806}, - { 832, 438,1331, 806}, - { 832, 409,1331, 806}, - { 832, 518,1331, 806}, /* 640x480 */ + { 840, 518,1344, 806}, /* 640x480 */ {1050, 638,1344, 806}, /* 800x600 */ {1344, 806,1344, 806}, /* 1024x768 */ }; -/* Custom data for Barco iQ G series */ -static const SiS_LVDSDataStruct SiS_LVDSBARCO1024Data_2[]= -{ - {1344, 806,1344, 806} -}; - -/* Custom data for 848x480 parallel panel */ -static const SiS_LVDSDataStruct SiS_LVDS848x480Data_1[]= -{ - { 0, 0, 0, 0}, - { 0, 0, 0, 0}, - { 0, 0, 0, 0}, - { 0, 0, 0, 0}, - {1088, 525,1088, 525}, /* 640x480 TODO */ - {1088, 525,1088, 525}, /* 800x600 TODO */ - {1088, 525,1088, 525}, /* 1024x768 TODO */ - { 0, 0, 0, 0}, - { 0, 0, 0, 0}, - { 0, 0, 0, 0}, - { 0, 0, 0, 0}, - {1088, 525,1088, 525}, /* 848x480 */ - {1088, 525,1088, 525} /* 1360x768 TODO */ -}; - -/* Custom data for 848x480 parallel panel */ -static const SiS_LVDSDataStruct SiS_LVDS848x480Data_2[]= -{ - { 0, 0, 0, 0}, - { 0, 0, 0, 0}, - { 0, 0, 0, 0}, - { 0, 0, 0, 0}, - {1088, 525,1088, 525}, /* 640x480 */ - {1088, 525,1088, 525}, /* 800x600 */ - {1088, 525,1088, 525}, /* 1024x768 */ - { 0, 0, 0, 0}, - { 0, 0, 0, 0}, - { 0, 0, 0, 0}, - { 0, 0, 0, 0}, - {1088, 525,1088, 525}, /* 848x480 */ - {1088, 525,1088, 525} /* 1360x768 TODO */ -}; - -static const SiS_LVDSDataStruct SiS_CHTVUNTSCData[]= +static const struct SiS_LVDSData SiS_CHTVUNTSCData[]= { { 840, 600, 840, 600}, { 840, 600, 840, 600}, @@ -1466,7 +1345,7 @@ static const SiS_LVDSDataStruct SiS_CHTVUNTSCData[]= {1160, 945,1160, 945} }; -static const SiS_LVDSDataStruct SiS_CHTVONTSCData[]= +static const struct SiS_LVDSData SiS_CHTVONTSCData[]= { { 840, 525, 840, 525}, { 840, 525, 840, 525}, @@ -1477,55 +1356,9 @@ static const SiS_LVDSDataStruct SiS_CHTVONTSCData[]= {1160, 840,1160, 840} }; -/* Chrontel TV Skew */ - -static const SiS_LVDSDesStruct SiS_CHTVUNTSCDesData[]= -{ - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS_CHTVONTSCDesData[]= -{ - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS_CHTVUPALDesData[]= -{ - {256, 0}, - {256, 0}, - {256, 0}, - {256, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - -static const SiS_LVDSDesStruct SiS_CHTVOPALDesData[]= -{ - {256, 0}, - {256, 0}, - {256, 0}, - {256, 0}, - { 0, 0}, - { 0, 0}, - { 0, 0} -}; - /* CRT1 CRTC data for slave modes */ -static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1320x480_1[] = +static const struct SiS_LVDSCRT1Data SiS_LVDSCRT1320x240_1[] = { {{0x65,0x4f,0x89,0x56,0x83,0xaa,0x1f, 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, @@ -1550,48 +1383,7 @@ static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1320x480_1[] = 0x00 }} }; -static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1640x480_1[] = -{ - {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, - 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, - 0x00}}, - {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, - 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, - 0x00}}, - {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, - 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, - 0x00}}, - {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, - 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, - 0x00}}, - {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, - 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, - 0x00}}, - {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0, - 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, - 0x01}} -}; - -static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1640x480_1_H[] = -{ - {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x00,0x00,0x00, - 0x00}}, - {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f, - 0x83,0x85,0x63,0xba,0x00,0x00,0x00, - 0x00}}, - {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f, - 0x9c,0x8e,0x96,0xb9,0x00,0x00,0x00, - 0x00}}, - {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f, - 0x83,0x85,0x63,0xba,0x00,0x00,0x00, - 0x00}}, - {{0x2d,0x28,0x90,0x2c,0x80,0x0b,0x3e, - 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00, - 0x00}} -}; - -static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1640x480_2[] = +static const struct SiS_LVDSCRT1Data SiS_LVDSCRT1320x240_2[] = { {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, @@ -1611,12 +1403,17 @@ static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1640x480_2[] = {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0, 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, 0x01}}, +#if 0 {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e, 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00, 0x00}} +#endif + {{0x5f,0x4f,0x83,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xe8,0x0c,0x00,0x00,0x05, + 0x00}}, }; -static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1640x480_2_H[] = +static const struct SiS_LVDSCRT1Data SiS_LVDSCRT1320x240_2_H[] = { {{0x65,0x4f,0x89,0x56,0x83,0xaa,0x1f, 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, @@ -1641,7 +1438,7 @@ static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1640x480_2_H[] = 0x00}} }; -static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1640x480_3[] = +static const struct SiS_LVDSCRT1Data SiS_LVDSCRT1320x240_3[] = { {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, 0xe9,0x8b,0xdf,0x04,0x00,0x00,0x05, @@ -1666,7 +1463,7 @@ static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1640x480_3[] = 0x00}} }; -static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1640x480_3_H[] = +static const struct SiS_LVDSCRT1Data SiS_LVDSCRT1320x240_3_H[] = { {{0x65,0x4f,0x89,0x56,0x83,0xaa,0x1f, 0x90,0x85,0x8f,0xab,0x30,0x00,0x05, @@ -1691,778 +1488,175 @@ static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT1640x480_3_H[] = 0x00}} }; -static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11024x600_1[] = -{ - {{0x64,0x4f,0x88,0x54,0x9f,0x5a,0x3e, - 0xe8,0x8f,0x8f,0x5b,0x00,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x2e,0x3e, - 0xb9,0x80,0x5d,0x2f,0x00,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x5a,0x3e, - 0xe8,0x8f,0x8f,0x5b,0x00,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x2e,0x3e, - 0xb9,0x80,0x5d,0x2f,0x00,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0xaf,0xba, - 0x3b,0x82,0xdf,0xb0,0x00,0x00,0x01, - 0x00}}, - {{0x7e,0x63,0x82,0x68,0x15,0x1e,0xf1, - 0xae,0x85,0x57,0x1f,0x30,0x00,0x26, - 0x01}}, - {{0xa3,0x7f,0x87,0x86,0x97,0x1e,0xf1, - 0xae,0x85,0x57,0x1f,0x30,0x00,0x02, - 0x01}} -}; - -static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11024x600_1_H[] = -{ - {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e, - 0xe2,0x89,0xdf,0x05,0x00,0x00,0x44, - 0x00}}, - {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0, - 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x55, - 0x01}}, - {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01}} -}; - -static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11024x600_2[] = -{ - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x72,0x88,0xdf,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1, - 0xae,0x84,0x57,0x25,0x30,0x00,0x02, - 0x01}}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, - 0x01}} -}; - -static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11024x600_2_H[] = -{ - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x72,0x88,0xdf,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x31,0x93,0x3e,0x06,0x24,0xf1, - 0xae,0x84,0x57,0x25,0x30,0x00,0x01, - 0x01}}, - {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01}} -}; - -static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11152x768_1[] = -{ - {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x01, - 0x00}}, - {{0x64,0x4f,0x88,0x54,0x9f,0x04,0x3e, - 0xe2,0x89,0xdf,0x05,0x00,0x00,0x01, - 0x00}}, - {{0x7e,0x63,0x82,0x68,0x15,0x7c,0xf0, - 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x26, - 0x01}}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, - 0x01}} -}; - -static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11152x768_1_H[] = -{ - {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f, - 0x92,0x89,0x8f,0xb5,0x30,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f, - 0x60,0x87,0x5d,0x83,0x10,0x00,0x44, - 0x00}}, - {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e, - 0xe2,0x89,0xdf,0x05,0x00,0x00,0x44, - 0x00}}, - {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0, - 0x5a,0x8f,0x57,0x7d,0x20,0x00,0x55, - 0x01}}, - {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01}} -}; - -static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11152x768_2[] = -{ - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb, - 0x72,0x88,0xdf,0x25,0x30,0x00,0x06, - 0x00}}, - {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1, - 0xae,0x84,0x57,0x25,0x30,0x00,0x02, - 0x01}}, - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x02, - 0x01}} -}; - -static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11152x768_2_H[] = -{ - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x4a,0x80,0x8f,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x31,0x87,0x5d,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb, - 0x72,0x88,0xdf,0x25,0x30,0x00,0x01, - 0x00}}, - {{0x4f,0x31,0x93,0x3e,0x06,0x24,0xf1, - 0xae,0x84,0x57,0x25,0x30,0x00,0x01, - 0x01}}, - {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5, - 0x02,0x88,0xff,0x25,0x10,0x00,0x01, - 0x01}} -}; - -static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11280x768_1[] = -{ - {{0x5b,0x4f,0x9f,0x55,0x19,0xb4,0x1f, - 0x9c,0x8e,0x8f,0xb5,0x10,0x00,0x01, - 0x00}}, - {{0x5b,0x4f,0x9f,0x55,0x19,0x82,0x1f, - 0x6a,0x8c,0x5d,0x83,0x30,0x00,0x01, - 0x00}}, - {{0x5b,0x4f,0x9f,0x55,0x19,0xb4,0x1f, - 0x9c,0x8e,0x8f,0xb5,0x10,0x00,0x01, - 0x00}}, - {{0x5b,0x4f,0x9f,0x55,0x19,0x82,0x1f, - 0x6a,0x8c,0x5d,0x83,0x30,0x00,0x01, - 0x00}}, - {{0x5b,0x4f,0x9f,0x55,0x19,0x04,0x3e, - 0xec,0x8e,0xdf,0x05,0x20,0x00,0x01, - 0x00}}, - {{0x6f,0x63,0x93,0x69,0x8d,0x7c,0xf0, - 0x64,0x86,0x57,0x7d,0x20,0x00,0x05, - 0x01}}, - {{0x8b,0x7f,0x8f,0x85,0x09,0x24,0xf5, - 0x0c,0x8e,0xff,0x25,0x30,0x00,0x02, - 0x01}}, - {{0xab,0x9f,0x8f,0xa5,0x89,0x24,0xf5, - 0x0c,0x8e,0xff,0x25,0x30,0x00,0x06, - 0x01}}, - {{0xab,0x9f,0x8f,0xa5,0x89,0x24,0xf5, - 0x0c,0x8e,0xff,0x25,0x30,0x00,0x06, - 0x01}} -}; - -static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11280x768_1_H[] = +static const struct SiS_LVDSCRT1Data SiS_LVDSCRT1640x480_1[] = { - {{0x47,0x27,0x8b,0x2c,0x1a,0x9e,0x1f, - 0x93,0x86,0x8f,0x9f,0x30,0x00,0x05, - 0x00}}, - {{0x47,0x27,0x8b,0x2c,0x1a,0x6c,0x1f, - 0x60,0x84,0x5d,0x6d,0x10,0x00,0x05, - 0x00}}, - {{0x47,0x27,0x8b,0x30,0x1e,0x9e,0x1f, - 0x92,0x86,0x8f,0x9f,0x30,0x00,0x05, - 0x00}}, - {{0x47,0x27,0x8b,0x2c,0x1a,0x6c,0x1f, - 0x60,0x84,0x5d,0x6d,0x10,0x00,0x05, - 0x00}}, - {{0x47,0x27,0x8b,0x2c,0x1a,0xee,0x1f, - 0xe2,0x86,0xdf,0xef,0x10,0x00,0x05, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, 0x00}}, - {{0x51,0x31,0x95,0x36,0x04,0x66,0xf0, - 0x5a,0x8e,0x57,0x67,0x20,0x00,0x01, - 0x01}}, - {{0x5f,0x3f,0x83,0x44,0x92,0x0e,0xf5, - 0x02,0x86,0xff,0x0f,0x10,0x00,0x01, - 0x01}}, - {{0x6f,0x4f,0x93,0x54,0x82,0x0e,0x5a, - 0x02,0x86,0xff,0x0f,0x09,0x00,0x05, - 0x01}}, - {{0x6f,0x4f,0x93,0x54,0x82,0x0e,0x5a, - 0x02,0x86,0xff,0x0f,0x09,0x00,0x05, - 0x01}} -}; - -static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11280x768_2[] = -{ - {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb, - 0x54,0x86,0xdb,0xda,0x00,0x00,0x02, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, 0x00}}, - {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb, - 0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x02, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, 0x00}}, - {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb, - 0x54,0x86,0xdb,0xda,0x00,0x00,0x02, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, 0x00}}, - {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb, - 0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x02, + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e, + 0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05, 0x00}}, - {{0xab,0x60,0x9f,0x80,0x04,0x24,0xb3, - 0x7c,0x8e,0x03,0x02,0x10,0x00,0x02, - 0x01}}, - {{0xab,0x63,0x8f,0x8a,0x8e,0x24,0xf1, - 0xb6,0x88,0x57,0x25,0x10,0x00,0x02, - 0x01}}, - {{0xab,0x7f,0x8f,0x98,0x9c,0x24,0xf5, - 0x0a,0x8c,0xff,0x25,0x30,0x00,0x02, - 0x01}}, - {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5, - 0x0a,0x8c,0xff,0x25,0x30,0x00,0x06, - 0x01}}, - {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5, - 0x0a,0x8c,0xff,0x25,0x30,0x00,0x06, + {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0, + 0x58,0x8c,0x57,0x73,0x20,0x00,0x06, 0x01}} }; -static const SiS_LVDSCRT1DataStruct SiS_LVDSCRT11280x768_2_H[] = +static const struct SiS_LVDSCRT1Data SiS_LVDSCRT1640x480_1_H[] = { - {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb, - 0x54,0x86,0xdb,0xda,0x00,0x00,0x01, + {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f, + 0x9c,0x8e,0x96,0xb9,0x00,0x00,0x00, 0x00}}, - {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb, - 0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x01, + {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f, + 0x83,0x85,0x63,0xba,0x00,0x00,0x00, 0x00}}, - {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb, - 0x54,0x86,0xdb,0xda,0x00,0x00,0x01, + {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f, + 0x9c,0x8e,0x96,0xb9,0x00,0x00,0x00, 0x00}}, - {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb, - 0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x01, + {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f, + 0x83,0x85,0x63,0xba,0x00,0x00,0x00, 0x00}}, - {{0x83,0x38,0x97,0x58,0x9c,0x24,0xb3, - 0x7c,0x8e,0x03,0x02,0x10,0x00,0x01, - 0x01}}, - {{0x79,0x31,0x9d,0x58,0x9c,0x24,0xf1, - 0xb6,0x88,0x57,0x25,0x10,0x00,0x01, - 0x01}}, - {{0x6b,0x3f,0x8f,0x58,0x9c,0x24,0xf5, - 0x0a,0x8c,0xff,0x25,0x30,0x00,0x01, - 0x01}}, - {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5, - 0x0a,0x8c,0xff,0x25,0x30,0x00,0x06, - 0x01}}, - {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5, - 0x0a,0x8c,0xff,0x25,0x30,0x00,0x06, - 0x01}} -}; - -/**************************************************************/ -/* COMMON --------------------------------------------------- */ -/**************************************************************/ - -#ifdef LINUX_XF86 - -#define SIS_PL_HSYNCP 0x01 -#define SIS_PL_HSYNCN 0x02 -#define SIS_PL_VSYNCP 0x04 -#define SIS_PL_VSYNCN 0x08 -#define SIS_PL_DVI 0x80 - -typedef struct _SiS_PlasmaModes -{ - const char *name; - ULONG clock; - USHORT HDisplay, HTotal, HFrontPorch, HSyncWidth; - USHORT VDisplay, VTotal, VFrontPorch, VSyncWidth; - UCHAR SyncFlags; -} SiS_PlasmaModes; - -typedef struct _SiS_PlasmaTables -{ - USHORT vendor; - UCHAR productnum; - USHORT product[5]; - const char *DDCnames[5]; - const char *plasmaname; - USHORT maxx,maxy; - USHORT prefx, prefy; - UCHAR modenum; - UCHAR plasmamodes[20]; /* | 0x80 = DVI-capable, | 0x40 = analog */ -} SiS_PlasmaTables; - -static const SiS_PlasmaModes SiS_PlasmaMode[] = { - { "640x400", /* 00: IBM 400@70 */ - 25175, - 640, 800, 17, 64, - 400, 449, 13, 2, - SIS_PL_HSYNCN | SIS_PL_VSYNCN }, - { "640x480", /* 01: VESA 480@72 */ - 31500, - 640, 832, 24, 40, - 480, 520, 9, 3, - SIS_PL_HSYNCN | SIS_PL_VSYNCN }, - { "800x600", /* 02: VESA 600@72 */ - 50000, - 800, 1040, 56, 120, - 600, 666, 37, 6, - SIS_PL_HSYNCP | SIS_PL_VSYNCP }, - { "864x480", /* 03: Cereb wide 1 */ - 42526, - 864, 1134, 22, 86, - 480, 500, 1, 3, - SIS_PL_HSYNCP | SIS_PL_VSYNCN }, - { "848x480", /* 04: VESA wide (NEC1) */ - 33750, - 848, 1088, 16, 112, - 480, 517, 6, 8, - SIS_PL_HSYNCP | SIS_PL_VSYNCP }, - { "1024x576", /* 05: VESA wide (NEC2) */ - 47250, - 1024, 1320, 16, 144, - 576, 596, 2, 4, - SIS_PL_HSYNCP | SIS_PL_VSYNCP }, - { "1280x720", /* 06: VESA wide (NEC3) */ - 76500, - 1280, 1696, 48, 176, - 720, 750, 4, 8, - SIS_PL_HSYNCP | SIS_PL_VSYNCP }, - { "1360x765", /* 07: VESA wide (NEC4) */ - 85500, - 1360, 1792, 64, 176, - 765, 795, 4, 8, - SIS_PL_HSYNCP | SIS_PL_VSYNCP }, - { "1024x600", /* 08: CEREB wide 2 */ - 51200, - 1024, 1352, 51, 164, - 600, 628, 1, 4, - SIS_PL_HSYNCN | SIS_PL_VSYNCP }, - { "1024x768", /* 09: VESA 768@75 */ - 78750, - 1024, 1312, 16, 96, - 768, 800, 1, 3, - SIS_PL_HSYNCP | SIS_PL_VSYNCP }, - { "1152x864", /* 10: VESA 1152x864@75 */ - 108000, - 1152, 1600, 64, 128, - 864, 900, 1, 3, - SIS_PL_HSYNCP | SIS_PL_VSYNCP }, - { "1280x1024", /* 11: VESA 1024@60 */ - 108000, - 1280, 1688, 48, 112, - 1024, 1066, 1, 3, - SIS_PL_HSYNCP | SIS_PL_VSYNCP }, - { "1280x768", /* 12: W_XGA */ - 81000, - 1280, 1688, 48, 112, - 768, 802, 3, 6, - SIS_PL_HSYNCP | SIS_PL_VSYNCN }, - { "1280x768", /* 13: I/O Data W_XGA@56Hz */ - 76064, - 1280, 1688, 48, 112, - 768, 802, 2, 3, - SIS_PL_HSYNCP | SIS_PL_VSYNCP }, - { "1376x768", /* 14: I/O Wide XGA */ - 87340, - 1376, 1808, 32, 128, - 768, 806, 3, 6, - SIS_PL_HSYNCN | SIS_PL_VSYNCP }, - { "1280x960", /* 15: VESA 960@60 */ - 108000, - 1280, 1800, 96, 112, - 960, 1000, 1, 3, - SIS_PL_HSYNCP | SIS_PL_VSYNCP }, - { "1400x1050", /* 16: VESA 1050@60Hz */ - 108000, - 1400, 1688, 48, 112, - 1050, 1066, 1, 3, - SIS_PL_HSYNCN | SIS_PL_VSYNCN }, - { "1360x768", /* 17: VESA wide (NEC4/2) */ - 85500, - 1360, 1792, 64, 112, - 765, 795, 3, 6, - SIS_PL_HSYNCP | SIS_PL_VSYNCP }, - { "800x600", /* 18: VESA 600@56 */ - 36000, - 800, 1024, 24, 2, - 600, 625, 1, 2, - SIS_PL_HSYNCP | SIS_PL_VSYNCP }, - { "1072x600", /* 19: Panasonic 1072x600 (sync?) */ - 54100, - 1072, 1424, 48, 176, - 600, 628, 16, 1, - SIS_PL_HSYNCP | SIS_PL_VSYNCP }, - { "848x480", /* 20: Panasonic 848x480 (sync?) */ - 33070, /* is 852x480, but we can't use 852 */ - 848, 1068, 20, 40, /* differs from DDC data, better centered */ - 480, 516, 3, 5, /* won't work assumingly, because data is % 8 */ - SIS_PL_HSYNCN | SIS_PL_VSYNCN }, - { "1280x720", /* 21: WIDE720(60) (aka "750p") (Panasonic) */ - 74300, - 1280, 1650,110, 40, - 720, 750, 5, 5, - SIS_PL_HSYNCP | SIS_PL_VSYNCP }, - { "1280x768", /* 22: 1280x768@56.5 (Panasonic) */ - 76200, /* (According to manual not supported for HDMI; but works) */ - 1280, 1680, 16, 24, - 768, 802, 2, 5, - SIS_PL_HSYNCP | SIS_PL_VSYNCP }, - { "1280x720@50", /* 23: WIDE720(50) (aka "750p") (Panasonic) */ - 74300, /* Panasonic states 45.0kHz. Not possible. This one works (with some overscan) */ - 1280, 1980,400, 80, - 720, 750, 1, 2, - SIS_PL_HSYNCP | SIS_PL_VSYNCP }, - { "720x480", /* 24: 720x480 (aka "525p" and "480p") (Panasonic) */ - 27000, - 720, 856, 40, 32, - 480, 525, 1, 3, - SIS_PL_HSYNCP | SIS_PL_VSYNCP }, - { "720x576", /* 25: 720x576 (aka "625p"and "576p") (Panasonic) */ - 27500, - 720, 864, 16, 64, - 576, 625, 5, 6, - SIS_PL_HSYNCP | SIS_PL_VSYNCP }, - { "1280x720@50", /* 26: WIDE720(50) (aka "750p") (Generic) */ - 74300, - 1280, 1980,400, 80, - 720, 750, 5, 5, - SIS_PL_HSYNCP | SIS_PL_VSYNCP }, + {{0x2d,0x28,0x90,0x2c,0x80,0x0b,0x3e, + 0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00, + 0x00}} }; -/* -27.00 720 755 791 858 480 480 484 525 -27.50 720 732 795 864 576 581 587 625 -*/ - -static const SiS_PlasmaTables SiS_PlasmaTable[] = { -#if 0 /* Product IDs missing */ - { 0x38a3, 4, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, - { "", "", "", "", "" }, - "NEC PlasmaSync 42VP4/42VP4D/42VP4G/42VP4DG", - 0, 0, - 0, 0, - 11, /* All DVI, except 0, 7, 13 */ - { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 7|0x40, 9|0xc0,10|0xc0,11|0xc0,13|0x40,14|0xc0, - 17|0xc0, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } - }, +BOOLEAN SiSInitPtr(struct SiS_Private *SiS_Pr); +#ifdef SIS_XORG_XF86 +unsigned short SiS_GetModeID(int VGAEngine, unsigned int VBFlags, int HDisplay, int VDisplay, + int Depth, BOOLEAN FSTN, int LCDwith, int LCDheight); #endif -#if 0 /* Product IDs missing */ - { 0x38a3, 3, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, - { "", "", "", "", "" }, - "NEC PlasmaSync 42PD1/50PD1/50PD2", - 0, 0, - 0, 0, - 5, /* DVI entirely unknown */ - { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 9|0xc0, 0 , 0 , 0 , 0 , 0 , - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } - }, - { 0x38a3, 1, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, - { "", "", "", "", "" }, - "NEC PlasmaSync 42PD3", - 0, 0, - 0, 0, - 10, /* DVI entirely unknown */ - { 0|0x40, 1|0xc0, 2|0xc0, 3|0xc0, 4|0xc0, 5|0xc0, 6|0xc0, 7|0x40, 8|0xc0, 9|0xc0, - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } - }, - { 0x38a3, 2, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, - { "", "", "", "", "" }, - "NEC PlasmaSync 42VM3/61XM1", - 0, 0, - 0, 0, - 11, /* DVI entirely unknown */ - { 0|0x40, 1|0xc0, 2|0xc0, 3|0xc0, 4|0xc0, 5|0xc0, 6|0xc0, 8|0xc0, 9|0xc0,11|0xc0, - 17|0xc0, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } - }, - { 0x38a3, 2, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, - { "", "", "", "", "" }, - "NEC PlasmaSync 42MP1/42MP2", - 0, 0, - 0, 0, - 6, /* DVI entirely unknown */ - { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 9|0xc0,11|0xc0, 0 , 0 , 0 , 0 , - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } - }, - { 0x38a3, 1, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, - { "", "", "", "", "" }, - "NEC PlasmaSync 50MP1", - 0, 0, - 0, 0, - 10, /* DVI entirely unknown */ - { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 7|0x40, 9|0xc0,10|0xc0,11|0xc0,13|0x40,14|0xc0, - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } - }, +unsigned short SiS_GetModeID_LCD(int VGAEngine, unsigned int VBFlags, int HDisplay, + int VDisplay, int Depth, BOOLEAN FSTN, + unsigned short CustomT, int LCDwith, int LCDheight, + unsigned int VBFlags2); +unsigned short SiS_GetModeID_TV(int VGAEngine, unsigned int VBFlags, int HDisplay, + int VDisplay, int Depth, unsigned int VBFlags2); +unsigned short SiS_GetModeID_VGA2(int VGAEngine, unsigned int VBFlags, int HDisplay, + int VDisplay, int Depth, unsigned int VBFlags2); + +void SiS_SetReg(SISIOADDRESS port, unsigned short index, unsigned short data); +void SiS_SetRegByte(SISIOADDRESS port, unsigned short data); +void SiS_SetRegShort(SISIOADDRESS port, unsigned short data); +void SiS_SetRegLong(SISIOADDRESS port, unsigned int data); +unsigned char SiS_GetReg(SISIOADDRESS port, unsigned short index); +unsigned char SiS_GetRegByte(SISIOADDRESS port); +unsigned short SiS_GetRegShort(SISIOADDRESS port); +unsigned int SiS_GetRegLong(SISIOADDRESS port); +void SiS_SetRegANDOR(SISIOADDRESS Port, unsigned short Index, unsigned short DataAND, + unsigned short DataOR); +void SiS_SetRegAND(SISIOADDRESS Port,unsigned short Index, unsigned short DataAND); +void SiS_SetRegOR(SISIOADDRESS Port,unsigned short Index, unsigned short DataOR); + +void SiS_DisplayOn(struct SiS_Private *SiS_Pr); +void SiS_DisplayOff(struct SiS_Private *SiS_Pr); +void SiSRegInit(struct SiS_Private *SiS_Pr, SISIOADDRESS BaseAddr); +#ifndef SIS_LINUX_KERNEL +void SiSSetLVDSetc(struct SiS_Private *SiS_Pr); #endif - { 0x38a3, 4, - { 0xa482, 0xa483, 0x0000, 0x0000, 0x0000 }, - { "PX-42VM", "", "", "", "" }, - "NEC PlasmaSync 42MP3/42MP4/50MP2/61MP1", - 0, 0, - 0, 0, - 11, /* All DVI except 0, 7, 13, 17 */ - { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 7|0x40, 9|0xc0,10|0xc0,11|0xc0,13|0x40,14|0xc0, - 17|0x40, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } - }, -#if 0 /* Product IDs missing */ - { 0x38a3, 1, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, - { "", "", "", "", "" }, - "NEC PlasmaSync 3300W", - 0, 0, - 0, 0, - 3, - { 0|0x40, 1|0xc0,18|0xc0, 0 , 0 , 0 , 0 , 0 , 0 , 0 , - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } - }, - { 0x38a3, 1, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, - { "", "", "", "", "" }, - "NEC PlasmaSync 4200W", - 4, /* DVI entirely unknown */ - { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 0 , 0 , 0 , 0 , 0 , 0 , - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } - }, - { 0x38a3, 1, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, - { "", "", "", "", "" }, - "NEC PlasmaSync 4210W", - 0, 0, - 0, 0, - 6, /* DVI entirely unknown */ - { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 9|0xc0,11|0xc0, 0 , 0 , 0 , 0 , - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } - }, - { 0x38a3, 1, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, - { "", "", "", "", "" }, - "NEC PlasmaSync 5000W", - 0, 0, - 0, 0, - 7, /* DVI entirely unknown */ - { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 7|0x40, 9|0xc0,11|0xc0, 0 , 0 , 0 , - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } - }, -#endif - { 0x412f, 2, - { 0x000c, 0x000b, 0x0000, 0x0000, 0x0000 }, - { "", "", "", "", "" }, - "Pioneer 503CMX/PDA-5002", - 0, 0, - 0, 0, - 6, /* DVI unknown */ - { 1|0xc0, 2|0xc0, 9|0xc0,11|0xc0,12|0xc0,15|0xc0, 0 , 0 , 0 , 0 , - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } - }, - { 0x34a9, 1, - { 0xa00e, 0x0000, 0x0000, 0x0000, 0x0000 }, - { "", "", "", "", "" }, - "Panasonic TH-42", - 0, 0, - 0, 0, - 5, /* No DVI output */ - { 1|0x40, 2|0x40, 4|0x40, 9|0x40,15|0x40, 0 , 0 , 0 , 0 , 0 , - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } - }, - { 0x34a9, 1, - { 0xa005, 0x0000, 0x0000, 0x0000, 0x0000 }, - { "TH-42PW*4", "", "", "", "" }, - "Panasonic TH-42PW5", - 0, 0, - 0, 0, - 1, /* No special modes otherwise; no DVI. */ - {20|0x40,19|0x40, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } - }, - { 0x4c2e, 1, - { 0x9b05, 0x0000, 0x0000, 0x0000, 0x0000 }, - { "PLV-Z2", "", "", "", "" }, - "Sanyo PLV-Z2 (non HDCP-mode)", /* HDCP mode would be id 9b06, but not needed */ - 1280, 768, /* as it then advertises correct size */ - 1280, 720, - 1, /* 1280x720, no special modes otherwise */ - {21|0xc0, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } - }, - { 0x34a9, 1, - { 0xd034, 0x0000, 0x0000, 0x0000, 0x0000 }, - { "AE500U (DVI-D)", "", "", "", "" }, - "Panasonic AE500U", - 1280, 768, - 1280, 720, - 1, /* 1280x720, no special modes otherwise */ - {21|0xc0, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } - }, - { 0x34a9, 1, - { 0xd043, 0x0000, 0x0000, 0x0000, 0x0000 }, - { "AE700U (HDMI)", "", "", "", "" }, - "Panasonic AE700U", - 1360, 768, - 1280, 720, - 6, /* 1280x720/60, 1280x720/50, 1280x768@56(digital/analog), 720x480, 720x576 */ - {21|0xc0,23|0xc0,22|0x80,13|0x40,24|0x80,25|0x80, 0 , 0 , 0 , 0 , - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } - }, - { 0x0000 } -}; +void SiS_SetEnableDstn(struct SiS_Private *SiS_Pr, int enable); +void SiS_SetEnableFstn(struct SiS_Private *SiS_Pr, int enable); +unsigned short SiS_GetModeFlag(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex); +BOOLEAN SiSDetermineROMLayout661(struct SiS_Private *SiS_Pr); +#ifndef SIS_LINUX_KERNEL +void SiS_GetVBType(struct SiS_Private *SiS_Pr); #endif -#ifdef LINUX_XF86 -USHORT SiS_GetModeID(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, - int Depth, BOOLEAN FSTN, int LCDwith, int LCDheight); +BOOLEAN SiS_SearchModeID(struct SiS_Private *SiS_Pr, unsigned short *ModeNo, + unsigned short *ModeIdIndex); +unsigned short SiS_GetModePtr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex); +unsigned short SiS_GetRefCRTVCLK(struct SiS_Private *SiS_Pr, unsigned short Index, int UseWide); +unsigned short SiS_GetRefCRT1CRTC(struct SiS_Private *SiS_Pr, unsigned short Index, int UseWide); +unsigned short SiS_GetColorDepth(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex); +unsigned short SiS_GetOffset(struct SiS_Private *SiS_Pr,unsigned short ModeNo, + unsigned short ModeIdIndex, unsigned short RRTI); +#ifdef SIS300 +void SiS_GetFIFOThresholdIndex300(struct SiS_Private *SiS_Pr, unsigned short *idx1, + unsigned short *idx2); +unsigned short SiS_GetFIFOThresholdB300(unsigned short idx1, unsigned short idx2); +unsigned short SiS_GetLatencyFactor630(struct SiS_Private *SiS_Pr, unsigned short index); #endif -USHORT SiS_GetModeID_LCD(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth, BOOLEAN FSTN, - USHORT CustomT, int LCDwith, int LCDheight); -USHORT SiS_GetModeID_TV(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth); -USHORT SiS_GetModeID_VGA2(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth); - -void SiS_SetReg(SISIOADDRESS port, USHORT index, USHORT data); -void SiS_SetRegByte(SISIOADDRESS port, USHORT data); -void SiS_SetRegShort(SISIOADDRESS port, USHORT data); -void SiS_SetRegLong(SISIOADDRESS port, ULONG data); -UCHAR SiS_GetReg(SISIOADDRESS port, USHORT index); -UCHAR SiS_GetRegByte(SISIOADDRESS port); -USHORT SiS_GetRegShort(SISIOADDRESS port); -ULONG SiS_GetRegLong(SISIOADDRESS port); -void SiS_SetRegANDOR(SISIOADDRESS Port, USHORT Index, USHORT DataAND, USHORT DataOR); -void SiS_SetRegAND(SISIOADDRESS Port,USHORT Index, USHORT DataAND); -void SiS_SetRegOR(SISIOADDRESS Port,USHORT Index, USHORT DataOR); -void SiS_DisplayOn(SiS_Private *SiS_Pr); -void SiS_DisplayOff(SiS_Private *SiS_Pr); -void SiSRegInit(SiS_Private *SiS_Pr, SISIOADDRESS BaseAddr); -BOOLEAN SiSDetermineROMLayout661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); -void SiS_SetEnableDstn(SiS_Private *SiS_Pr, int enable); -void SiS_SetEnableFstn(SiS_Private *SiS_Pr, int enable); -BOOLEAN SiS_SearchModeID(SiS_Private *SiS_Pr, USHORT *ModeNo, USHORT *ModeIdIndex); -UCHAR SiS_GetModePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex); -USHORT SiS_GetColorDepth(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex); -USHORT SiS_GetOffset(SiS_Private *SiS_Pr,USHORT ModeNo, USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo); -void SiS_LoadDAC(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, USHORT ModeIdIndex); -void SiS_CalcLCDACRT1Timing(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex); - -#ifdef LINUX_XF86 -BOOLEAN SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,ScrnInfoPtr pScrn,USHORT ModeNo, BOOLEAN dosetpitch); -BOOLEAN SiSBIOSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, - DisplayModePtr mode, BOOLEAN IsCustom); -BOOLEAN SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, - DisplayModePtr mode, BOOLEAN IsCustom); -BOOLEAN SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn, - DisplayModePtr mode, BOOLEAN IsCustom); -int SiSTranslateToVESA(ScrnInfoPtr pScrn, int modenumber); -int SiSTranslateToOldMode(int modenumber); -BOOLEAN SiS_GetPanelID(SiS_Private *SiS_Pr, PSIS_HW_INFO); -USHORT SiS_CheckBuildCustomMode(ScrnInfoPtr pScrn, DisplayModePtr mode, int VBFlags); -DisplayModePtr SiSBuildBuiltInModeList(ScrnInfoPtr pScrn, BOOLEAN includelcdmodes, BOOLEAN isfordvi); -int SiS_FindPanelFromDB(SISPtr pSiS, USHORT panelvendor, USHORT panelproduct, int *maxx, int *maxy, int *prefx, int *prefy); -void SiS_MakeClockRegs(ScrnInfoPtr pScrn, int clock, UCHAR *p2b, UCHAR *p2c); -#else -BOOLEAN SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,USHORT ModeNo); +void SiS_LoadDAC(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex); +#ifdef SIS_XORG_XF86 +BOOLEAN SiSSetMode(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, unsigned short ModeNo, + BOOLEAN dosetpitch); +BOOLEAN SiSBIOSSetMode(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, + DisplayModePtr mode, BOOLEAN IsCustom); +BOOLEAN SiSBIOSSetModeCRT2(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, + DisplayModePtr mode, BOOLEAN IsCustom); +BOOLEAN SiSBIOSSetModeCRT1(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, + DisplayModePtr mode, BOOLEAN IsCustom); +#endif +#ifdef SIS_LINUX_KERNEL +BOOLEAN SiSSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo); +#endif +void SiS_CalcCRRegisters(struct SiS_Private *SiS_Pr, int depth); +void SiS_CalcLCDACRT1Timing(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex); +#ifdef SIS_XORG_XF86 +void SiS_Generic_ConvertCRData(struct SiS_Private *SiS_Pr, unsigned char *crdata, int xres, + int yres, DisplayModePtr current); +#endif +#ifdef SIS_LINUX_KERNEL +void SiS_Generic_ConvertCRData(struct SiS_Private *SiS_Pr, unsigned char *crdata, int xres, + int yres, struct fb_var_screeninfo *var, BOOLEAN writeres); #endif -#ifdef LINUX_KERNEL -int sisfb_mode_rate_to_dclock(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - UCHAR modeno, UCHAR rateindex); -int sisfb_mode_rate_to_ddata(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - UCHAR modeno, UCHAR rateindex, - struct fb_var_screeninfo *var); -BOOLEAN sisfb_gettotalfrommode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - UCHAR modeno, int *htotal, int *vtotal, UCHAR rateindex); +/* From init301.c: */ +extern void SiS_GetVBInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex, int chkcrt2mode); +extern void SiS_GetLCDResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex); +extern void SiS_SetYPbPr(struct SiS_Private *SiS_Pr); +extern void SiS_SetTVMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex); +extern void SiS_UnLockCRT2(struct SiS_Private *SiS_Pr); +extern void SiS_DisableBridge(struct SiS_Private *); +extern BOOLEAN SiS_SetCRT2Group(struct SiS_Private *, unsigned short); +extern unsigned short SiS_GetRatePtr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex); +extern void SiS_WaitRetrace1(struct SiS_Private *SiS_Pr); +extern unsigned short SiS_GetResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex); +extern unsigned short SiS_GetCH700x(struct SiS_Private *SiS_Pr, unsigned short tempax); +extern unsigned short SiS_GetVCLK2Ptr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex, unsigned short RRTI); +extern BOOLEAN SiS_IsVAMode(struct SiS_Private *); +extern BOOLEAN SiS_IsDualEdge(struct SiS_Private *); + +#ifdef SIS_XORG_XF86 +/* From other modules: */ +extern unsigned short SiS_CheckBuildCustomMode(ScrnInfoPtr pScrn, DisplayModePtr mode, + unsigned int VBFlags); +extern unsigned char SiS_GetSetBIOSScratch(ScrnInfoPtr pScrn, unsigned short offset, + unsigned char value); +extern unsigned char SiS_GetSetModeID(ScrnInfoPtr pScrn, unsigned char id); +extern unsigned short SiS_GetModeNumber(ScrnInfoPtr pScrn, DisplayModePtr mode, + unsigned int VBFlags); #endif -/* init301.c: */ -extern void SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo, int chkcrt2mode); -extern void SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo); -extern void SiS_SetYPbPr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); -extern void SiS_SetTVMode(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_INFO HwInfo); -extern void SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); -extern void SiS_DisableBridge(SiS_Private *, PSIS_HW_INFO); -extern BOOLEAN SiS_SetCRT2Group(SiS_Private *, PSIS_HW_INFO, USHORT); -extern USHORT SiS_GetRatePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo); -extern void SiS_WaitRetrace1(SiS_Private *SiS_Pr); -extern USHORT SiS_GetResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex); -extern USHORT SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempax); -extern USHORT SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo); -extern BOOLEAN SiS_IsVAMode(SiS_Private *, PSIS_HW_INFO); -extern BOOLEAN SiS_IsDualEdge(SiS_Private *, PSIS_HW_INFO); - -#ifdef LINUX_XF86 -/* From other sis driver modules: */ -extern int SiS_compute_vclk(int Clock, int *out_n, int *out_dn, int *out_div, - int *out_sbit, int *out_scale); -extern void SiSCalcClock(ScrnInfoPtr pScrn, int clock, int max_VLD, unsigned int *vclk); - -extern UCHAR SiS_GetSetBIOSScratch(ScrnInfoPtr pScrn, USHORT offset, UCHAR value); -extern UCHAR SiS_GetSetModeID(ScrnInfoPtr pScrn, UCHAR id); -extern USHORT SiS_GetModeNumber(ScrnInfoPtr pScrn, DisplayModePtr mode, ULONG VBFlags); +#ifdef SIS_LINUX_KERNEL +#ifdef SIS300 +extern unsigned int sisfb_read_nbridge_pci_dword(struct SiS_Private *SiS_Pr, int reg); +extern void sisfb_write_nbridge_pci_dword(struct SiS_Private *SiS_Pr, int reg, + unsigned int val); +#endif +#ifdef SIS315H +extern void sisfb_write_nbridge_pci_byte(struct SiS_Private *SiS_Pr, int reg, + unsigned char val); +extern unsigned int sisfb_read_mio_pci_word(struct SiS_Private *SiS_Pr, int reg); +#endif #endif #endif diff --git a/drivers/video/sis/init301.c b/drivers/video/sis/init301.c index 274dacd54bb..2d88f908170 100644 --- a/drivers/video/sis/init301.c +++ b/drivers/video/sis/init301.c @@ -2,11 +2,12 @@ /* $XdotOrg$ */ /* * Mode initializing code (CRT2 section) - * for SiS 300/305/540/630/730 and - * SiS 315/550/650/M650/651/661FX/M661xX/740/741(GX)/M741/330/660/M660/760/M760 - * (Universal module for Linux kernel framebuffer and XFree86/X.org 4.x) + * for SiS 300/305/540/630/730, + * SiS 315/550/[M]650/651/[M]661[FGM]X/[M]74x[GX]/330/[M]76x[GX], + * XGI V3XT/V5/V8, Z7 + * (Universal module for Linux kernel framebuffer and X.org/XFree86 4.x) * - * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2005 by Thomas Winischhofer, Vienna, Austria * * If distributed as part of the Linux kernel, the following license terms * apply: @@ -38,7 +39,7 @@ * * 3) The name of the author may not be used to endorse or promote products * * derived from this software without specific prior written permission. * * - * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, @@ -54,20 +55,20 @@ * Formerly based on non-functional code-fragements for 300 series by SiS, Inc. * Used by permission. * - * TW says: This code looks awful, I know. But please don't do anything about - * this otherwise debugging will be hell. - * The code is extremely fragile as regards the different chipsets, different - * video bridges and combinations thereof. If anything is changed, extreme - * care has to be taken that that change doesn't break it for other chipsets, - * bridges or combinations thereof. - * All comments in this file are by me, regardless if marked TW or not. - * */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #if 1 #define SET_EMI /* 302LV/ELV: Set EMI values */ #endif +#if 1 +#define SET_PWD /* 301/302LV: Set PWD */ +#endif + #define COMPAL_HACK /* Needed for Compal 1400x1050 (EMI) */ #define COMPAQ_HACK /* Needed for Inventec/Compaq 1280x1024 (EMI) */ #define ASUS_HACK /* Needed for Asus A2H 1024x768 (EMI) */ @@ -85,26 +86,35 @@ #define SiS_I2CDELAY 1000 #define SiS_I2CDELAYSHORT 150 -static USHORT SiS_GetBIOSLCDResInfo(SiS_Private *SiS_Pr); -static void SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx); +static unsigned short SiS_GetBIOSLCDResInfo(struct SiS_Private *SiS_Pr); +#ifdef SIS_LINUX_KERNEL +static void SiS_SetCH70xx(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val); +#endif /*********************************************/ /* HELPER: Lock/Unlock CRT2 */ /*********************************************/ void -SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_UnLockCRT2(struct SiS_Private *SiS_Pr) { - if(HwInfo->jChipType >= SIS_315H) + if(SiS_Pr->ChipType == XGI_20) + return; + else if(SiS_Pr->ChipType >= SIS_315H) SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2f,0x01); else SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x24,0x01); } -static void -SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +#ifdef SIS_LINUX_KERNEL +static +#endif +void +SiS_LockCRT2(struct SiS_Private *SiS_Pr) { - if(HwInfo->jChipType >= SIS_315H) + if(SiS_Pr->ChipType == XGI_20) + return; + else if(SiS_Pr->ChipType >= SIS_315H) SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2F,0xFE); else SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x24,0xFE); @@ -115,9 +125,9 @@ SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) /*********************************************/ static void -SiS_SetRegSR11ANDOR(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT DataAND, USHORT DataOR) +SiS_SetRegSR11ANDOR(struct SiS_Private *SiS_Pr, unsigned short DataAND, unsigned short DataOR) { - if(HwInfo->jChipType >= SIS_661) { + if(SiS_Pr->ChipType >= SIS_661) { DataAND &= 0x0f; DataOR &= 0x0f; } @@ -129,12 +139,12 @@ SiS_SetRegSR11ANDOR(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT DataAND, US /*********************************************/ #ifdef SIS315H -static UCHAR * -GetLCDStructPtr661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +static unsigned char * +GetLCDStructPtr661(struct SiS_Private *SiS_Pr) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - UCHAR *myptr = NULL; - USHORT romindex = 0, reg = 0, idx = 0; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned char *myptr = NULL; + unsigned short romindex = 0, reg = 0, idx = 0; /* Use the BIOS tables only for LVDS panels; TMDS is unreliable * due to the variaty of panels the BIOS doesn't know about. @@ -144,15 +154,15 @@ GetLCDStructPtr661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) */ if((SiS_Pr->SiS_ROMNew) && - ((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) || (!SiS_Pr->PanelSelfDetected))) { + ((SiS_Pr->SiS_VBType & VB_SISLVDS) || (!SiS_Pr->PanelSelfDetected))) { - if(HwInfo->jChipType < SIS_661) reg = 0x3c; - else reg = 0x7d; + if(SiS_Pr->ChipType < SIS_661) reg = 0x3c; + else reg = 0x7d; idx = (SiS_GetReg(SiS_Pr->SiS_P3d4,reg) & 0x1f) * 26; if(idx < (8*26)) { - myptr = (UCHAR *)&SiS_LCDStruct661[idx]; + myptr = (unsigned char *)&SiS_LCDStruct661[idx]; } romindex = SISGETROMW(0x100); if(romindex) { @@ -163,11 +173,11 @@ GetLCDStructPtr661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) return myptr; } -static USHORT -GetLCDStructPtr661_2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +static unsigned short +GetLCDStructPtr661_2(struct SiS_Private *SiS_Pr) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT romptr = 0; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short romptr = 0; /* Use the BIOS tables only for LVDS panels; TMDS is unreliable * due to the variaty of panels the BIOS doesn't know about. @@ -177,12 +187,12 @@ GetLCDStructPtr661_2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) */ if((SiS_Pr->SiS_ROMNew) && - ((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) || (!SiS_Pr->PanelSelfDetected))) { + ((SiS_Pr->SiS_VBType & VB_SISLVDS) || (!SiS_Pr->PanelSelfDetected))) { romptr = SISGETROMW(0x102); romptr += ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4) * SiS_Pr->SiS661LCD2TableSize); } - return(romptr); + return romptr; } #endif @@ -191,186 +201,187 @@ GetLCDStructPtr661_2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) /*********************************************/ static BOOLEAN -SiS_AdjustCRT2Rate(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RRTI, USHORT *i, PSIS_HW_INFO HwInfo) +SiS_AdjustCRT2Rate(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RRTI, unsigned short *i) { - USHORT checkmask=0,modeid,infoflag; + unsigned short checkmask=0, modeid, infoflag; - modeid = SiS_Pr->SiS_RefIndex[RRTI + (*i)].ModeID; + modeid = SiS_Pr->SiS_RefIndex[RRTI + (*i)].ModeID; - if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { - checkmask |= SupportRAMDAC2; - if(HwInfo->jChipType >= SIS_315H) { - checkmask |= SupportRAMDAC2_135; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - checkmask |= SupportRAMDAC2_162; - if(SiS_Pr->SiS_VBType & VB_SIS301C) { - checkmask |= SupportRAMDAC2_202; - } - } - } + checkmask |= SupportRAMDAC2; + if(SiS_Pr->ChipType >= SIS_315H) { + checkmask |= SupportRAMDAC2_135; + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { + checkmask |= SupportRAMDAC2_162; + if(SiS_Pr->SiS_VBType & VB_SISRAMDAC202) { + checkmask |= SupportRAMDAC2_202; + } + } + } - } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - checkmask |= SupportLCD; - if(HwInfo->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_VBType & VB_SISVB) { - if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (SiS_Pr->SiS_LCDInfo & LCDPass11)) { - if(modeid == 0x2e) checkmask |= Support64048060Hz; - } - } - } + checkmask |= SupportLCD; + if(SiS_Pr->ChipType >= SIS_315H) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { + if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (SiS_Pr->SiS_LCDInfo & LCDPass11)) { + if(modeid == 0x2e) checkmask |= Support64048060Hz; + } + } + } - } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - checkmask |= SupportHiVision; + checkmask |= SupportHiVision; - } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToYPbPr525750|SetCRT2ToAVIDEO|SetCRT2ToSVIDEO|SetCRT2ToSCART)) { + } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToYPbPr525750|SetCRT2ToAVIDEO|SetCRT2ToSVIDEO|SetCRT2ToSCART)) { - checkmask |= SupportTV; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - checkmask |= SupportTV1024; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { - if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { - checkmask |= SupportYPbPr750p; - } - } - } + checkmask |= SupportTV; + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { + checkmask |= SupportTV1024; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { + if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { + checkmask |= SupportYPbPr750p; + } + } + } - } + } - } else { /* LVDS */ + } else { /* LVDS */ - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - checkmask |= SupportCHTV; - } - } + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + checkmask |= SupportCHTV; + } + } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - checkmask |= SupportLCD; - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + checkmask |= SupportLCD; + } - } + } - /* Look backwards in table for matching CRT2 mode */ - for(; SiS_Pr->SiS_RefIndex[RRTI + (*i)].ModeID == modeid; (*i)--) { - infoflag = SiS_Pr->SiS_RefIndex[RRTI + (*i)].Ext_InfoFlag; - if(infoflag & checkmask) return TRUE; - if((*i) == 0) break; - } + /* Look backwards in table for matching CRT2 mode */ + for(; SiS_Pr->SiS_RefIndex[RRTI + (*i)].ModeID == modeid; (*i)--) { + infoflag = SiS_Pr->SiS_RefIndex[RRTI + (*i)].Ext_InfoFlag; + if(infoflag & checkmask) return TRUE; + if((*i) == 0) break; + } - /* Look through the whole mode-section of the table from the beginning - * for a matching CRT2 mode if no mode was found yet. - */ - for((*i) = 0; ; (*i)++) { - if(SiS_Pr->SiS_RefIndex[RRTI + (*i)].ModeID != modeid) break; - infoflag = SiS_Pr->SiS_RefIndex[RRTI + (*i)].Ext_InfoFlag; - if(infoflag & checkmask) return TRUE; - } - return FALSE; + /* Look through the whole mode-section of the table from the beginning + * for a matching CRT2 mode if no mode was found yet. + */ + for((*i) = 0; ; (*i)++) { + if(SiS_Pr->SiS_RefIndex[RRTI + (*i)].ModeID != modeid) break; + infoflag = SiS_Pr->SiS_RefIndex[RRTI + (*i)].Ext_InfoFlag; + if(infoflag & checkmask) return TRUE; + } + return FALSE; } /*********************************************/ /* Get rate index */ /*********************************************/ -USHORT -SiS_GetRatePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo) -{ - SHORT LCDRefreshIndex[] = { 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00 }; - USHORT RRTI,i,backup_i; - USHORT modeflag,index,temp,backupindex; +unsigned short +SiS_GetRatePtr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) +{ + unsigned short RRTI,i,backup_i; + unsigned short modeflag,index,temp,backupindex; + static const unsigned short LCDRefreshIndex[] = { + 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00 + }; - /* Do NOT check for UseCustomMode here, will skrew up FIFO */ - if(ModeNo == 0xfe) return 0; + /* Do NOT check for UseCustomMode here, will skrew up FIFO */ + if(ModeNo == 0xfe) return 0; - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - } + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + } - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(modeflag & HalfDCLK) return 0; - } - } + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(modeflag & HalfDCLK) return 0; + } + } - if(ModeNo < 0x14) return 0xFFFF; + if(ModeNo < 0x14) return 0xFFFF; - index = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x33) >> SiS_Pr->SiS_SelectCRT2Rate) & 0x0F; - backupindex = index; + index = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x33) >> SiS_Pr->SiS_SelectCRT2Rate) & 0x0F; + backupindex = index; - if(index > 0) index--; + if(index > 0) index--; - if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { - if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_Pr->SiS_VBType & VB_NoLCD) index = 0; - else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index = backupindex = 0; - } - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - if(!(SiS_Pr->SiS_VBType & VB_NoLCD)) { - temp = LCDRefreshIndex[SiS_GetBIOSLCDResInfo(SiS_Pr)]; - if(index > temp) index = temp; - } - } - } else { - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) index = 0; - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) index = 0; - } - } - } + if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_VBType & VB_NoLCD) index = 0; + else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index = backupindex = 0; + } + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + if(!(SiS_Pr->SiS_VBType & VB_NoLCD)) { + temp = LCDRefreshIndex[SiS_GetBIOSLCDResInfo(SiS_Pr)]; + if(index > temp) index = temp; + } + } + } else { + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) index = 0; + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) index = 0; + } + } + } - RRTI = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex; - ModeNo = SiS_Pr->SiS_RefIndex[RRTI].ModeID; + RRTI = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex; + ModeNo = SiS_Pr->SiS_RefIndex[RRTI].ModeID; - if(HwInfo->jChipType >= SIS_315H) { - if(!(SiS_Pr->SiS_VBInfo & DriverMode)) { - if( (SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_VESAID == 0x105) || - (SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_VESAID == 0x107) ) { - if(backupindex <= 1) RRTI++; - } - } - } + if(SiS_Pr->ChipType >= SIS_315H) { + if(!(SiS_Pr->SiS_VBInfo & DriverMode)) { + if( (SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_VESAID == 0x105) || + (SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_VESAID == 0x107) ) { + if(backupindex <= 1) RRTI++; + } + } + } - i = 0; - do { - if(SiS_Pr->SiS_RefIndex[RRTI + i].ModeID != ModeNo) break; - temp = SiS_Pr->SiS_RefIndex[RRTI + i].Ext_InfoFlag; - temp &= ModeTypeMask; - if(temp < SiS_Pr->SiS_ModeType) break; - i++; - index--; - } while(index != 0xFFFF); - - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - temp = SiS_Pr->SiS_RefIndex[RRTI + i - 1].Ext_InfoFlag; - if(temp & InterlaceMode) i++; - } - } + i = 0; + do { + if(SiS_Pr->SiS_RefIndex[RRTI + i].ModeID != ModeNo) break; + temp = SiS_Pr->SiS_RefIndex[RRTI + i].Ext_InfoFlag; + temp &= ModeTypeMask; + if(temp < SiS_Pr->SiS_ModeType) break; + i++; + index--; + } while(index != 0xFFFF); + + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + temp = SiS_Pr->SiS_RefIndex[RRTI + i - 1].Ext_InfoFlag; + if(temp & InterlaceMode) i++; + } + } - i--; + i--; - if((SiS_Pr->SiS_SetFlag & ProgrammingCRT2) && (!(SiS_Pr->SiS_VBInfo & DisableCRT2Display))) { - backup_i = i; - if(!(SiS_AdjustCRT2Rate(SiS_Pr, ModeNo, ModeIdIndex, RRTI, &i, HwInfo))) { - i = backup_i; - } - } + if((SiS_Pr->SiS_SetFlag & ProgrammingCRT2) && (!(SiS_Pr->SiS_VBInfo & DisableCRT2Display))) { + backup_i = i; + if(!(SiS_AdjustCRT2Rate(SiS_Pr, ModeNo, ModeIdIndex, RRTI, &i))) { + i = backup_i; + } + } - return(RRTI + i); + return (RRTI + i); } /*********************************************/ @@ -378,15 +389,15 @@ SiS_GetRatePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /*********************************************/ static void -SiS_SaveCRT2Info(SiS_Private *SiS_Pr, USHORT ModeNo) +SiS_SaveCRT2Info(struct SiS_Private *SiS_Pr, unsigned short ModeNo) { - USHORT temp1,temp2; + unsigned short temp1, temp2; - /* Store CRT1 ModeNo in CR34 */ - SiS_SetReg(SiS_Pr->SiS_P3d4,0x34,ModeNo); - temp1 = (SiS_Pr->SiS_VBInfo & SetInSlaveMode) >> 8; - temp2 = ~(SetInSlaveMode >> 8); - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x31,temp2,temp1); + /* Store CRT1 ModeNo in CR34 */ + SiS_SetReg(SiS_Pr->SiS_P3d4,0x34,ModeNo); + temp1 = (SiS_Pr->SiS_VBInfo & SetInSlaveMode) >> 8; + temp2 = ~(SetInSlaveMode >> 8); + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x31,temp2,temp1); } /*********************************************/ @@ -395,35 +406,35 @@ SiS_SaveCRT2Info(SiS_Private *SiS_Pr, USHORT ModeNo) #ifdef SIS300 static BOOLEAN -SiS_CR36BIOSWord23b(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_CR36BIOSWord23b(struct SiS_Private *SiS_Pr) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT temp,temp1; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short temp,temp1; - if(SiS_Pr->SiS_UseROM) { - if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { - temp = 1 << ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4) & 0x0f); - temp1 = SISGETROMW(0x23b); - if(temp1 & temp) return TRUE; - } - } - return FALSE; + if(SiS_Pr->SiS_UseROM) { + if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { + temp = 1 << ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4) & 0x0f); + temp1 = SISGETROMW(0x23b); + if(temp1 & temp) return TRUE; + } + } + return FALSE; } static BOOLEAN -SiS_CR36BIOSWord23d(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_CR36BIOSWord23d(struct SiS_Private *SiS_Pr) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT temp,temp1; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short temp,temp1; - if(SiS_Pr->SiS_UseROM) { - if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { - temp = 1 << ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4) & 0x0f); - temp1 = SISGETROMW(0x23d); - if(temp1 & temp) return TRUE; - } - } - return FALSE; + if(SiS_Pr->SiS_UseROM) { + if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { + temp = 1 << ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4) & 0x0f); + temp1 = SISGETROMW(0x23d); + if(temp1 & temp) return TRUE; + } + } + return FALSE; } #endif @@ -432,85 +443,76 @@ SiS_CR36BIOSWord23d(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) /*********************************************/ void -SiS_DDC2Delay(SiS_Private *SiS_Pr, USHORT delaytime) +SiS_DDC2Delay(struct SiS_Private *SiS_Pr, unsigned int delaytime) { - USHORT i, j; + unsigned int i, j; - for(i=0; i<delaytime; i++) { - j += SiS_GetReg(SiS_Pr->SiS_P3c4,0x05); - } + for(i = 0; i < delaytime; i++) { + j += SiS_GetReg(SiS_Pr->SiS_P3c4,0x05); + } } #if defined(SIS300) || defined(SIS315H) static void -SiS_GenericDelay(SiS_Private *SiS_Pr, USHORT delay) +SiS_GenericDelay(struct SiS_Private *SiS_Pr, unsigned short delay) { - USHORT temp,flag; - - flag = SiS_GetRegByte(0x61) & 0x10; - - while(delay) { - temp = SiS_GetRegByte(0x61) & 0x10; - if(temp == flag) continue; - flag = temp; - delay--; - } + SiS_DDC2Delay(SiS_Pr, delay * 36); } #endif #ifdef SIS315H static void -SiS_LongDelay(SiS_Private *SiS_Pr, USHORT delay) +SiS_LongDelay(struct SiS_Private *SiS_Pr, unsigned short delay) { - while(delay--) { - SiS_GenericDelay(SiS_Pr,0x19df); - } + while(delay--) { + SiS_GenericDelay(SiS_Pr, 6623); + } } #endif #if defined(SIS300) || defined(SIS315H) static void -SiS_ShortDelay(SiS_Private *SiS_Pr, USHORT delay) +SiS_ShortDelay(struct SiS_Private *SiS_Pr, unsigned short delay) { - while(delay--) { - SiS_GenericDelay(SiS_Pr,0x42); - } + while(delay--) { + SiS_GenericDelay(SiS_Pr, 66); + } } #endif static void -SiS_PanelDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT DelayTime) +SiS_PanelDelay(struct SiS_Private *SiS_Pr, unsigned short DelayTime) { #if defined(SIS300) || defined(SIS315H) - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT PanelID, DelayIndex, Delay=0; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short PanelID, DelayIndex, Delay=0; #endif - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { #ifdef SIS300 PanelID = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36); if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(SiS_Pr->SiS_VBType & VB_SIS301) PanelID &= 0xf7; - if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x18) & 0x10)) PanelID = 0x12; + if(SiS_Pr->SiS_VBType & VB_SIS301) PanelID &= 0xf7; + if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x18) & 0x10)) PanelID = 0x12; } DelayIndex = PanelID >> 4; if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) { - Delay = 3; + Delay = 3; } else { - if(DelayTime >= 2) DelayTime -= 2; - if(!(DelayTime & 0x01)) { - Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[0]; - } else { - Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[1]; - } + if(DelayTime >= 2) DelayTime -= 2; + if(!(DelayTime & 0x01)) { + Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[0]; + } else { + Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[1]; + } if(SiS_Pr->SiS_UseROM) { - if(ROMAddr[0x220] & 0x40) { - if(!(DelayTime & 0x01)) Delay = (USHORT)ROMAddr[0x225]; - else Delay = (USHORT)ROMAddr[0x226]; - } - } + if(ROMAddr[0x220] & 0x40) { + if(!(DelayTime & 0x01)) Delay = (unsigned short)ROMAddr[0x225]; + else Delay = (unsigned short)ROMAddr[0x226]; + } + } } SiS_ShortDelay(SiS_Pr, Delay); @@ -520,23 +522,23 @@ SiS_PanelDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT DelayTime) #ifdef SIS315H - if((HwInfo->jChipType >= SIS_661) || - (HwInfo->jChipType <= SIS_315PRO) || - (HwInfo->jChipType == SIS_330) || + if((SiS_Pr->ChipType >= SIS_661) || + (SiS_Pr->ChipType <= SIS_315PRO) || + (SiS_Pr->ChipType == SIS_330) || (SiS_Pr->SiS_ROMNew)) { - if(!(DelayTime & 0x01)) { + if(!(DelayTime & 0x01)) { SiS_DDC2Delay(SiS_Pr, 0x1000); - } else { + } else { SiS_DDC2Delay(SiS_Pr, 0x4000); - } + } } else if((SiS_Pr->SiS_IF_DEF_LVDS == 1) /* || - (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || + (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || (SiS_Pr->SiS_CustomT == CUT_CLEVO1400) */ ) { /* 315 series, LVDS; Special */ - if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - PanelID = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36); + if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { + PanelID = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36); if(SiS_Pr->SiS_CustomT == CUT_CLEVO1400) { if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x1b) & 0x10)) PanelID = 0x12; } @@ -546,35 +548,35 @@ SiS_PanelDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT DelayTime) DelayIndex = PanelID >> 4; } if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) { - Delay = 3; - } else { - if(DelayTime >= 2) DelayTime -= 2; - if(!(DelayTime & 0x01)) { - Delay = SiS_Pr->SiS_PanelDelayTblLVDS[DelayIndex].timer[0]; - } else { - Delay = SiS_Pr->SiS_PanelDelayTblLVDS[DelayIndex].timer[1]; - } + Delay = 3; + } else { + if(DelayTime >= 2) DelayTime -= 2; + if(!(DelayTime & 0x01)) { + Delay = SiS_Pr->SiS_PanelDelayTblLVDS[DelayIndex].timer[0]; + } else { + Delay = SiS_Pr->SiS_PanelDelayTblLVDS[DelayIndex].timer[1]; + } if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { - if(ROMAddr[0x13c] & 0x40) { - if(!(DelayTime & 0x01)) { - Delay = (USHORT)ROMAddr[0x17e]; - } else { - Delay = (USHORT)ROMAddr[0x17f]; - } - } - } - } + if(ROMAddr[0x13c] & 0x40) { + if(!(DelayTime & 0x01)) { + Delay = (unsigned short)ROMAddr[0x17e]; + } else { + Delay = (unsigned short)ROMAddr[0x17f]; + } + } + } + } SiS_ShortDelay(SiS_Pr, Delay); } } else if(SiS_Pr->SiS_VBType & VB_SISVB) { /* 315 series, all bridges */ DelayIndex = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4; - if(!(DelayTime & 0x01)) { - Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[0]; - } else { - Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[1]; - } + if(!(DelayTime & 0x01)) { + Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[0]; + } else { + Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[1]; + } Delay <<= 8; SiS_DDC2Delay(SiS_Pr, Delay); @@ -587,12 +589,11 @@ SiS_PanelDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT DelayTime) #ifdef SIS315H static void -SiS_PanelDelayLoop(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT DelayTime, USHORT DelayLoop) +SiS_PanelDelayLoop(struct SiS_Private *SiS_Pr, unsigned short DelayTime, unsigned short DelayLoop) { int i; - for(i=0; i<DelayLoop; i++) { - SiS_PanelDelay(SiS_Pr, HwInfo, DelayTime); + for(i = 0; i < DelayLoop; i++) { + SiS_PanelDelay(SiS_Pr, DelayTime); } } #endif @@ -602,86 +603,86 @@ SiS_PanelDelayLoop(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, /*********************************************/ void -SiS_WaitRetrace1(SiS_Private *SiS_Pr) +SiS_WaitRetrace1(struct SiS_Private *SiS_Pr) { - USHORT watchdog; + unsigned short watchdog; - if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x1f) & 0xc0) return; - if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x17) & 0x80)) return; + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x1f) & 0xc0) return; + if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x17) & 0x80)) return; - watchdog = 65535; - while((SiS_GetRegByte(SiS_Pr->SiS_P3da) & 0x08) && --watchdog); - watchdog = 65535; - while((!(SiS_GetRegByte(SiS_Pr->SiS_P3da) & 0x08)) && --watchdog); + watchdog = 65535; + while((SiS_GetRegByte(SiS_Pr->SiS_P3da) & 0x08) && --watchdog); + watchdog = 65535; + while((!(SiS_GetRegByte(SiS_Pr->SiS_P3da) & 0x08)) && --watchdog); } #if defined(SIS300) || defined(SIS315H) static void -SiS_WaitRetrace2(SiS_Private *SiS_Pr, USHORT reg) +SiS_WaitRetrace2(struct SiS_Private *SiS_Pr, unsigned short reg) { - USHORT watchdog; + unsigned short watchdog; - watchdog = 65535; - while((SiS_GetReg(SiS_Pr->SiS_Part1Port,reg) & 0x02) && --watchdog); - watchdog = 65535; - while((!(SiS_GetReg(SiS_Pr->SiS_Part1Port,reg) & 0x02)) && --watchdog); + watchdog = 65535; + while((SiS_GetReg(SiS_Pr->SiS_Part1Port,reg) & 0x02) && --watchdog); + watchdog = 65535; + while((!(SiS_GetReg(SiS_Pr->SiS_Part1Port,reg) & 0x02)) && --watchdog); } #endif static void -SiS_WaitVBRetrace(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_WaitVBRetrace(struct SiS_Private *SiS_Pr) { - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { #ifdef SIS300 - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x20)) return; - } - if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x80)) { - SiS_WaitRetrace1(SiS_Pr); - } else { - SiS_WaitRetrace2(SiS_Pr, 0x25); - } + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { + if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x20)) return; + } + if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x80)) { + SiS_WaitRetrace1(SiS_Pr); + } else { + SiS_WaitRetrace2(SiS_Pr, 0x25); + } #endif - } else { + } else { #ifdef SIS315H - if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x40)) { - SiS_WaitRetrace1(SiS_Pr); - } else { - SiS_WaitRetrace2(SiS_Pr, 0x30); - } + if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x40)) { + SiS_WaitRetrace1(SiS_Pr); + } else { + SiS_WaitRetrace2(SiS_Pr, 0x30); + } #endif - } + } } static void -SiS_VBWait(SiS_Private *SiS_Pr) +SiS_VBWait(struct SiS_Private *SiS_Pr) { - USHORT tempal,temp,i,j; + unsigned short tempal,temp,i,j; - temp = 0; - for(i=0; i<3; i++) { - for(j=0; j<100; j++) { - tempal = SiS_GetRegByte(SiS_Pr->SiS_P3da); - if(temp & 0x01) { - if((tempal & 0x08)) continue; - else break; - } else { - if(!(tempal & 0x08)) continue; - else break; - } - } - temp ^= 0x01; - } + temp = 0; + for(i = 0; i < 3; i++) { + for(j = 0; j < 100; j++) { + tempal = SiS_GetRegByte(SiS_Pr->SiS_P3da); + if(temp & 0x01) { + if((tempal & 0x08)) continue; + else break; + } else { + if(!(tempal & 0x08)) continue; + else break; + } + } + temp ^= 0x01; + } } static void -SiS_VBLongWait(SiS_Private *SiS_Pr) +SiS_VBLongWait(struct SiS_Private *SiS_Pr) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - SiS_VBWait(SiS_Pr); - } else { - SiS_WaitRetrace1(SiS_Pr); - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + SiS_VBWait(SiS_Pr); + } else { + SiS_WaitRetrace1(SiS_Pr); + } } /*********************************************/ @@ -690,237 +691,225 @@ SiS_VBLongWait(SiS_Private *SiS_Pr) #ifdef SIS300 static BOOLEAN -SiS_Is301B(SiS_Private *SiS_Pr) +SiS_Is301B(struct SiS_Private *SiS_Pr) { - if(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01) >= 0xb0) return TRUE; - return FALSE; + if(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01) >= 0xb0) return TRUE; + return FALSE; } #endif static BOOLEAN -SiS_CRT2IsLCD(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_CRT2IsLCD(struct SiS_Private *SiS_Pr) { - USHORT flag; - - if(HwInfo->jChipType == SIS_730) { - flag = SiS_GetReg(SiS_Pr->SiS_P3c4,0x13); - if(flag & 0x20) return TRUE; - } - flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); - if(flag & 0x20) return TRUE; - return FALSE; + if(SiS_Pr->ChipType == SIS_730) { + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x20) return TRUE; + } + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x30) & 0x20) return TRUE; + return FALSE; } BOOLEAN -SiS_IsDualEdge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_IsDualEdge(struct SiS_Private *SiS_Pr) { #ifdef SIS315H - USHORT flag; - - if(HwInfo->jChipType >= SIS_315H) { - if((HwInfo->jChipType != SIS_650) || (SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xf0)) { - flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); - if(flag & EnableDualEdge) return TRUE; - } - } + if(SiS_Pr->ChipType >= SIS_315H) { + if((SiS_Pr->ChipType != SIS_650) || (SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xf0)) { + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x38) & EnableDualEdge) return TRUE; + } + } #endif - return FALSE; + return FALSE; } BOOLEAN -SiS_IsVAMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_IsVAMode(struct SiS_Private *SiS_Pr) { #ifdef SIS315H - USHORT flag; + unsigned short flag; - if(HwInfo->jChipType >= SIS_315H) { - flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); - if((flag & EnableDualEdge) && (flag & SetToLCDA)) return TRUE; - } + if(SiS_Pr->ChipType >= SIS_315H) { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if((flag & EnableDualEdge) && (flag & SetToLCDA)) return TRUE; + } #endif - return FALSE; + return FALSE; } #ifdef SIS315H static BOOLEAN -SiS_IsVAorLCD(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_IsVAorLCD(struct SiS_Private *SiS_Pr) { - if(SiS_IsVAMode(SiS_Pr,HwInfo)) return TRUE; - if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) return TRUE; - return FALSE; + if(SiS_IsVAMode(SiS_Pr)) return TRUE; + if(SiS_CRT2IsLCD(SiS_Pr)) return TRUE; + return FALSE; } #endif static BOOLEAN -SiS_IsDualLink(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_IsDualLink(struct SiS_Private *SiS_Pr) { #ifdef SIS315H - if(HwInfo->jChipType >= SIS_315H) { - if((SiS_CRT2IsLCD(SiS_Pr, HwInfo)) || - (SiS_IsVAMode(SiS_Pr, HwInfo))) { - if(SiS_Pr->SiS_LCDInfo & LCDDualLink) return TRUE; - } - } + if(SiS_Pr->ChipType >= SIS_315H) { + if((SiS_CRT2IsLCD(SiS_Pr)) || + (SiS_IsVAMode(SiS_Pr))) { + if(SiS_Pr->SiS_LCDInfo & LCDDualLink) return TRUE; + } + } #endif - return FALSE; + return FALSE; } #ifdef SIS315H static BOOLEAN -SiS_TVEnabled(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_TVEnabled(struct SiS_Private *SiS_Pr) { - if((SiS_GetReg(SiS_Pr->SiS_Part2Port,0x00) & 0x0f) != 0x0c) return TRUE; - if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS301LV302LV)) { - if(SiS_GetReg(SiS_Pr->SiS_Part2Port,0x4d) & 0x10) return TRUE; - } - return FALSE; + if((SiS_GetReg(SiS_Pr->SiS_Part2Port,0x00) & 0x0f) != 0x0c) return TRUE; + if(SiS_Pr->SiS_VBType & VB_SISYPBPR) { + if(SiS_GetReg(SiS_Pr->SiS_Part2Port,0x4d) & 0x10) return TRUE; + } + return FALSE; } #endif #ifdef SIS315H static BOOLEAN -SiS_LCDAEnabled(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_LCDAEnabled(struct SiS_Private *SiS_Pr) { - if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x13) & 0x04) return TRUE; - return FALSE; + if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x13) & 0x04) return TRUE; + return FALSE; } #endif #ifdef SIS315H static BOOLEAN -SiS_WeHaveBacklightCtrl(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_WeHaveBacklightCtrl(struct SiS_Private *SiS_Pr) { - if((HwInfo->jChipType >= SIS_315H) && (HwInfo->jChipType < SIS_661)) { - if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x79) & 0x10) return TRUE; - } - return FALSE; + if((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->ChipType < SIS_661)) { + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x79) & 0x10) return TRUE; + } + return FALSE; } #endif #ifdef SIS315H static BOOLEAN -SiS_IsNotM650orLater(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_IsNotM650orLater(struct SiS_Private *SiS_Pr) { - USHORT flag; + unsigned short flag; - if(HwInfo->jChipType == SIS_650) { - flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f); - flag &= 0xF0; - /* Check for revision != A0 only */ - if((flag == 0xe0) || (flag == 0xc0) || - (flag == 0xb0) || (flag == 0x90)) return FALSE; - } else if(HwInfo->jChipType >= SIS_661) return FALSE; - return TRUE; + if(SiS_Pr->ChipType == SIS_650) { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xf0; + /* Check for revision != A0 only */ + if((flag == 0xe0) || (flag == 0xc0) || + (flag == 0xb0) || (flag == 0x90)) return FALSE; + } else if(SiS_Pr->ChipType >= SIS_661) return FALSE; + return TRUE; } #endif #ifdef SIS315H static BOOLEAN -SiS_IsYPbPr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_IsYPbPr(struct SiS_Private *SiS_Pr) { - USHORT flag; - - if(HwInfo->jChipType >= SIS_315H) { - flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); - if(flag & EnableCHYPbPr) return TRUE; /* = YPrPb = 0x08 */ - } - return FALSE; + if(SiS_Pr->ChipType >= SIS_315H) { + /* YPrPb = 0x08 */ + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x38) & EnableCHYPbPr) return TRUE; + } + return FALSE; } #endif #ifdef SIS315H static BOOLEAN -SiS_IsChScart(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_IsChScart(struct SiS_Private *SiS_Pr) { - USHORT flag; - - if(HwInfo->jChipType >= SIS_315H) { - flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); - if(flag & EnableCHScart) return TRUE; /* = Scart = 0x04 */ - } - return FALSE; + if(SiS_Pr->ChipType >= SIS_315H) { + /* Scart = 0x04 */ + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x38) & EnableCHScart) return TRUE; + } + return FALSE; } #endif #ifdef SIS315H static BOOLEAN -SiS_IsTVOrYPbPrOrScart(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_IsTVOrYPbPrOrScart(struct SiS_Private *SiS_Pr) { - USHORT flag; + unsigned short flag; - if(HwInfo->jChipType >= SIS_315H) { - flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); - if(flag & SetCRT2ToTV) return TRUE; - flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); - if(flag & EnableCHYPbPr) return TRUE; /* = YPrPb = 0x08 */ - if(flag & EnableCHScart) return TRUE; /* = Scart = 0x04 - TW */ - } else { - flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); - if(flag & SetCRT2ToTV) return TRUE; - } - return FALSE; + if(SiS_Pr->ChipType >= SIS_315H) { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(flag & SetCRT2ToTV) return TRUE; + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if(flag & EnableCHYPbPr) return TRUE; /* = YPrPb = 0x08 */ + if(flag & EnableCHScart) return TRUE; /* = Scart = 0x04 - TW */ + } else { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(flag & SetCRT2ToTV) return TRUE; + } + return FALSE; } #endif #ifdef SIS315H static BOOLEAN -SiS_IsLCDOrLCDA(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_IsLCDOrLCDA(struct SiS_Private *SiS_Pr) { - USHORT flag; + unsigned short flag; - if(HwInfo->jChipType >= SIS_315H) { - flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); - if(flag & SetCRT2ToLCD) return TRUE; - flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); - if(flag & SetToLCDA) return TRUE; - } else { - flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); - if(flag & SetCRT2ToLCD) return TRUE; - } - return FALSE; + if(SiS_Pr->ChipType >= SIS_315H) { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(flag & SetCRT2ToLCD) return TRUE; + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if(flag & SetToLCDA) return TRUE; + } else { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(flag & SetCRT2ToLCD) return TRUE; + } + return FALSE; } #endif static BOOLEAN -SiS_BridgeIsOn(SiS_Private *SiS_Pr) +SiS_HaveBridge(struct SiS_Private *SiS_Pr) { - USHORT flag; + unsigned short flag; - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - return TRUE; - } else if(SiS_Pr->SiS_VBType & VB_SISVB) { - flag = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x00); - if((flag == 1) || (flag == 2)) return TRUE; - } - return FALSE; + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + return TRUE; + } else if(SiS_Pr->SiS_VBType & VB_SISVB) { + flag = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x00); + if((flag == 1) || (flag == 2)) return TRUE; + } + return FALSE; } static BOOLEAN -SiS_BridgeIsEnabled(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_BridgeIsEnabled(struct SiS_Private *SiS_Pr) { - USHORT flag; + unsigned short flag; - if(SiS_BridgeIsOn(SiS_Pr)) { - flag = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); - if(HwInfo->jChipType < SIS_315H) { - flag &= 0xa0; - if((flag == 0x80) || (flag == 0x20)) return TRUE; - } else { - flag &= 0x50; - if((flag == 0x40) || (flag == 0x10)) return TRUE; - } - } - return FALSE; + if(SiS_HaveBridge(SiS_Pr)) { + flag = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); + if(SiS_Pr->ChipType < SIS_315H) { + flag &= 0xa0; + if((flag == 0x80) || (flag == 0x20)) return TRUE; + } else { + flag &= 0x50; + if((flag == 0x40) || (flag == 0x10)) return TRUE; + } + } + return FALSE; } static BOOLEAN -SiS_BridgeInSlavemode(SiS_Private *SiS_Pr) +SiS_BridgeInSlavemode(struct SiS_Private *SiS_Pr) { - USHORT flag1; + unsigned short flag1; - flag1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31); - if(flag1 & (SetInSlaveMode >> 8)) return TRUE; - return FALSE; + flag1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31); + if(flag1 & (SetInSlaveMode >> 8)) return TRUE; + return FALSE; } /*********************************************/ @@ -928,119 +917,97 @@ SiS_BridgeInSlavemode(SiS_Private *SiS_Pr) /*********************************************/ /* Setup general purpose IO for Chrontel communication */ +#ifdef SIS300 void -SiS_SetChrontelGPIO(SiS_Private *SiS_Pr, USHORT myvbinfo) +SiS_SetChrontelGPIO(struct SiS_Private *SiS_Pr, unsigned short myvbinfo) { - unsigned long acpibase; + unsigned int acpibase; unsigned short temp; if(!(SiS_Pr->SiS_ChSW)) return; -#ifdef LINUX_KERNEL - SiS_SetRegLong(0xcf8,0x80000874); /* get ACPI base */ - acpibase = SiS_GetRegLong(0xcfc); +#ifdef SIS_LINUX_KERNEL + acpibase = sisfb_read_lpc_pci_dword(SiS_Pr, 0x74); #else acpibase = pciReadLong(0x00000800, 0x74); #endif acpibase &= 0xFFFF; - temp = SiS_GetRegShort((USHORT)(acpibase + 0x3c)); /* ACPI register 0x3c: GP Event 1 I/O mode select */ + if(!acpibase) return; + temp = SiS_GetRegShort((acpibase + 0x3c)); /* ACPI register 0x3c: GP Event 1 I/O mode select */ temp &= 0xFEFF; - SiS_SetRegShort((USHORT)(acpibase + 0x3c), temp); - temp = SiS_GetRegShort((USHORT)(acpibase + 0x3c)); - temp = SiS_GetRegShort((USHORT)(acpibase + 0x3a)); /* ACPI register 0x3a: GP Pin Level (low/high) */ + SiS_SetRegShort((acpibase + 0x3c), temp); + temp = SiS_GetRegShort((acpibase + 0x3c)); + temp = SiS_GetRegShort((acpibase + 0x3a)); /* ACPI register 0x3a: GP Pin Level (low/high) */ temp &= 0xFEFF; if(!(myvbinfo & SetCRT2ToTV)) temp |= 0x0100; - SiS_SetRegShort((USHORT)(acpibase + 0x3a), temp); - temp = SiS_GetRegShort((USHORT)(acpibase + 0x3a)); + SiS_SetRegShort((acpibase + 0x3a), temp); + temp = SiS_GetRegShort((acpibase + 0x3a)); } +#endif void -SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo, int checkcrt2mode) +SiS_GetVBInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex, int checkcrt2mode) { - USHORT tempax,tempbx,temp; - USHORT modeflag, resinfo=0; + unsigned short tempax, tempbx, temp; + unsigned short modeflag, resinfo = 0; - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - } else if(SiS_Pr->UseCustomMode) { - modeflag = SiS_Pr->CModeFlag; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; - } + SiS_Pr->SiS_SetFlag = 0; - SiS_Pr->SiS_SetFlag = 0; + modeflag = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex); - SiS_Pr->SiS_ModeType = modeflag & ModeTypeMask; + SiS_Pr->SiS_ModeType = modeflag & ModeTypeMask; - tempbx = 0; - if(SiS_BridgeIsOn(SiS_Pr)) { - temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); -#if 0 - if(HwInfo->jChipType < SIS_661) { - /* NO - YPbPr not set yet ! */ - if(SiS_Pr->SiS_YPbPr & <all ypbpr except 525i>) { - temp &= (SetCRT2ToHiVision | SwitchCRT2 | SetSimuScanMode); /* 0x83 */ - temp |= SetCRT2ToHiVision; /* 0x80 */ - } - if(SiS_Pr->SiS_YPbPr & <ypbpr525i>) { - temp &= (SetCRT2ToHiVision | SwitchCRT2 | SetSimuScanMode); /* 0x83 */ - temp |= SetCRT2ToSVIDEO; /* 0x08 */ - } - } -#endif - tempbx |= temp; - tempax = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) << 8; - tempax &= (DriverMode | LoadDACFlag | SetNotSimuMode | SetPALTV); - tempbx |= tempax; + if((ModeNo > 0x13) && (!SiS_Pr->UseCustomMode)) { + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + } + + tempbx = 0; + + if(SiS_HaveBridge(SiS_Pr)) { + + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + tempbx |= temp; + tempax = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) << 8; + tempax &= (DriverMode | LoadDACFlag | SetNotSimuMode | SetPALTV); + tempbx |= tempax; #ifdef SIS315H - if(HwInfo->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_VBType & VB_SISLCDA) { + if(SiS_Pr->ChipType >= SIS_315H) { + if(SiS_Pr->SiS_VBType & VB_SISLCDA) { if(ModeNo == 0x03) { - /* Mode 0x03 is never in driver mode */ + /* Mode 0x03 is never in driver mode */ SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x31,0xbf); } if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & (DriverMode >> 8))) { - /* Reset LCDA setting if not driver mode */ + /* Reset LCDA setting if not driver mode */ SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0xfc); } if(IS_SIS650) { - if(SiS_Pr->SiS_UseLCDA) { + if(SiS_Pr->SiS_UseLCDA) { if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xF0) { if((ModeNo <= 0x13) || (!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & (DriverMode >> 8)))) { - SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x38,(EnableDualEdge | SetToLCDA)); + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x38,(EnableDualEdge | SetToLCDA)); } } } } temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); - if((temp & (EnableDualEdge | SetToLCDA)) == (EnableDualEdge | SetToLCDA)) { - tempbx |= SetCRT2ToLCDA; + if((temp & (EnableDualEdge | SetToLCDA)) == (EnableDualEdge | SetToLCDA)) { + tempbx |= SetCRT2ToLCDA; } } - if(SiS_Pr->SiS_VBType & (VB_SIS301LV|VB_SIS302LV|VB_SIS302ELV)) { - tempbx &= ~(SetCRT2ToRAMDAC); - } - - if(HwInfo->jChipType >= SIS_661) { + if(SiS_Pr->ChipType >= SIS_661) { /* New CR layout */ tempbx &= ~(SetCRT2ToYPbPr525750 | SetCRT2ToHiVision); - temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); - if(SiS_Pr->SiS_VBType & VB_SISYPBPR) { - if(temp & 0x04) { - temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35) & 0xe0; - if(temp == 0x60) tempbx |= SetCRT2ToHiVision; - else tempbx |= SetCRT2ToYPbPr525750; - } - } else if(SiS_Pr->SiS_VBType & VB_SISHIVISION) { - if(temp & 0x04) { - temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35) & 0xe0; - if(temp == 0x60) tempbx |= SetCRT2ToHiVision; + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x38) & 0x04) { + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35) & 0xe0; + if(temp == 0x60) tempbx |= SetCRT2ToHiVision; + else if(SiS_Pr->SiS_VBType & VB_SISYPBPR) { + tempbx |= SetCRT2ToYPbPr525750; } } - } + } if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); @@ -1048,7 +1015,7 @@ SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, tempbx |= SetCRT2ToLCDA; } if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(temp & EnableCHYPbPr) { + if(temp & EnableCHYPbPr) { tempbx |= SetCRT2ToCHYPbPr; } } @@ -1057,44 +1024,49 @@ SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, #endif /* SIS315H */ - if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(!(SiS_Pr->SiS_VBType & VB_SISVGA2)) { + tempbx &= ~(SetCRT2ToRAMDAC); + } + + if(SiS_Pr->SiS_VBType & VB_SISVB) { temp = SetCRT2ToSVIDEO | - SetCRT2ToAVIDEO | - SetCRT2ToSCART | - SetCRT2ToLCDA | - SetCRT2ToLCD | - SetCRT2ToRAMDAC | - SetCRT2ToHiVision | + SetCRT2ToAVIDEO | + SetCRT2ToSCART | + SetCRT2ToLCDA | + SetCRT2ToLCD | + SetCRT2ToRAMDAC | + SetCRT2ToHiVision | SetCRT2ToYPbPr525750; - } else { - if(HwInfo->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - temp = SetCRT2ToAVIDEO | + } else { + if(SiS_Pr->ChipType >= SIS_315H) { + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + temp = SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToLCDA | SetCRT2ToLCD | SetCRT2ToCHYPbPr; - } else { - temp = SetCRT2ToLCDA | + } else { + temp = SetCRT2ToLCDA | SetCRT2ToLCD; } } else { - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - temp = SetCRT2ToTV | SetCRT2ToLCD; - } else { - temp = SetCRT2ToLCD; + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + temp = SetCRT2ToTV | SetCRT2ToLCD; + } else { + temp = SetCRT2ToLCD; } } - } + } + + if(!(tempbx & temp)) { + tempax = DisableCRT2Display; + tempbx = 0; + } - if(!(tempbx & temp)) { - tempax = DisableCRT2Display; - tempbx = 0; - } + if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(SiS_Pr->SiS_VBType & VB_SISVB) { - USHORT clearmask = ( DriverMode | + unsigned short clearmask = ( DriverMode | DisableCRT2Display | LoadDACFlag | SetNotSimuMode | @@ -1102,106 +1074,104 @@ SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SetPALTV | SwitchCRT2 | SetSimuScanMode ); - if(tempbx & SetCRT2ToLCDA) tempbx &= (clearmask | SetCRT2ToLCDA); + + if(tempbx & SetCRT2ToLCDA) tempbx &= (clearmask | SetCRT2ToLCDA); if(tempbx & SetCRT2ToRAMDAC) tempbx &= (clearmask | SetCRT2ToRAMDAC); if(tempbx & SetCRT2ToLCD) tempbx &= (clearmask | SetCRT2ToLCD); if(tempbx & SetCRT2ToSCART) tempbx &= (clearmask | SetCRT2ToSCART); if(tempbx & SetCRT2ToHiVision) tempbx &= (clearmask | SetCRT2ToHiVision); if(tempbx & SetCRT2ToYPbPr525750) tempbx &= (clearmask | SetCRT2ToYPbPr525750); - } else { - if(HwInfo->jChipType >= SIS_315H) { + + } else { + + if(SiS_Pr->ChipType >= SIS_315H) { if(tempbx & SetCRT2ToLCDA) { - tempbx &= (0xFF00|SwitchCRT2|SetSimuScanMode); + tempbx &= (0xFF00|SwitchCRT2|SetSimuScanMode); } } - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(tempbx & SetCRT2ToTV) { - tempbx &= (0xFF00|SetCRT2ToTV|SwitchCRT2|SetSimuScanMode); + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(tempbx & SetCRT2ToTV) { + tempbx &= (0xFF00|SetCRT2ToTV|SwitchCRT2|SetSimuScanMode); } - } - if(tempbx & SetCRT2ToLCD) { - tempbx &= (0xFF00|SetCRT2ToLCD|SwitchCRT2|SetSimuScanMode); } - if(HwInfo->jChipType >= SIS_315H) { + if(tempbx & SetCRT2ToLCD) { + tempbx &= (0xFF00|SetCRT2ToLCD|SwitchCRT2|SetSimuScanMode); + } + if(SiS_Pr->ChipType >= SIS_315H) { if(tempbx & SetCRT2ToLCDA) { tempbx |= SetCRT2ToLCD; } } + } - if(tempax & DisableCRT2Display) { - if(!(tempbx & (SwitchCRT2 | SetSimuScanMode))) { - tempbx = SetSimuScanMode | DisableCRT2Display; - } - } + if(tempax & DisableCRT2Display) { + if(!(tempbx & (SwitchCRT2 | SetSimuScanMode))) { + tempbx = SetSimuScanMode | DisableCRT2Display; + } + } - if(!(tempbx & DriverMode)) tempbx |= SetSimuScanMode; + if(!(tempbx & DriverMode)) tempbx |= SetSimuScanMode; /* LVDS/CHRONTEL (LCD/TV) and 301BDH (LCD) can only be slave in 8bpp modes */ if(SiS_Pr->SiS_ModeType <= ModeVGA) { if( (SiS_Pr->SiS_IF_DEF_LVDS == 1) || ((SiS_Pr->SiS_VBType & VB_NoLCD) && (tempbx & SetCRT2ToLCD)) ) { - modeflag &= (~CRT2Mode); + modeflag &= (~CRT2Mode); } } - if(!(tempbx & SetSimuScanMode)) { - if(tempbx & SwitchCRT2) { - if((!(modeflag & CRT2Mode)) && (checkcrt2mode)) { - if( (HwInfo->jChipType >= SIS_315H) && - (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) ) { - if(resinfo != SIS_RI_1600x1200) { - tempbx |= SetSimuScanMode; - } - } else { - tempbx |= SetSimuScanMode; - } + if(!(tempbx & SetSimuScanMode)) { + if(tempbx & SwitchCRT2) { + if((!(modeflag & CRT2Mode)) && (checkcrt2mode)) { + if(resinfo != SIS_RI_1600x1200) { + tempbx |= SetSimuScanMode; + } } - } else { - if(SiS_BridgeIsEnabled(SiS_Pr,HwInfo)) { - if(!(tempbx & DriverMode)) { - if(SiS_BridgeInSlavemode(SiS_Pr)) { + } else { + if(SiS_BridgeIsEnabled(SiS_Pr)) { + if(!(tempbx & DriverMode)) { + if(SiS_BridgeInSlavemode(SiS_Pr)) { tempbx |= SetSimuScanMode; - } - } - } - } - } - - if(!(tempbx & DisableCRT2Display)) { - if(tempbx & DriverMode) { - if(tempbx & SetSimuScanMode) { - if((!(modeflag & CRT2Mode)) && (checkcrt2mode)) { - if( (HwInfo->jChipType >= SIS_315H) && - (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) ) { - if(resinfo != SIS_RI_1600x1200) { - tempbx |= SetInSlaveMode; - } - } else { - tempbx |= SetInSlaveMode; - } - } - } - } else { - tempbx |= SetInSlaveMode; - } - } + } + } + } + } + } - } + if(!(tempbx & DisableCRT2Display)) { + if(tempbx & DriverMode) { + if(tempbx & SetSimuScanMode) { + if((!(modeflag & CRT2Mode)) && (checkcrt2mode)) { + if(resinfo != SIS_RI_1600x1200) { + tempbx |= SetInSlaveMode; + } + } + } + } else { + tempbx |= SetInSlaveMode; + } + } - SiS_Pr->SiS_VBInfo = tempbx; + } - if(HwInfo->jChipType == SIS_630) { - SiS_SetChrontelGPIO(SiS_Pr, SiS_Pr->SiS_VBInfo); - } + SiS_Pr->SiS_VBInfo = tempbx; -#ifdef TWDEBUG -#ifdef LINUX_KERNEL - printk(KERN_DEBUG "sisfb: (VBInfo= 0x%04x, SetFlag=0x%04x)\n", +#ifdef SIS300 + if(SiS_Pr->ChipType == SIS_630) { + SiS_SetChrontelGPIO(SiS_Pr, SiS_Pr->SiS_VBInfo); + } +#endif + +#ifdef SIS_LINUX_KERNEL +#if 0 + printk(KERN_DEBUG "sisfb: (init301: VBInfo= 0x%04x, SetFlag=0x%04x)\n", SiS_Pr->SiS_VBInfo, SiS_Pr->SiS_SetFlag); #endif -#ifdef LINUX_XF86 - xf86DrvMsgVerb(0, X_PROBED, 3, "(init301: VBInfo=0x%04x, SetFlag=0x%04x)\n", +#endif +#ifdef SIS_XORG_XF86 +#ifdef TWDEBUG + xf86DrvMsg(0, X_PROBED, "(init301: VBInfo=0x%04x, SetFlag=0x%04x)\n", SiS_Pr->SiS_VBInfo, SiS_Pr->SiS_SetFlag); #endif #endif @@ -1212,41 +1182,41 @@ SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /*********************************************/ void -SiS_SetYPbPr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_SetYPbPr(struct SiS_Private *SiS_Pr) { - UCHAR temp; + unsigned char temp; - /* Note: This variable is only used on 30xLV systems. - * CR38 has a different meaning on LVDS/CH7019 systems. - * On 661 and later, these bits moved to CR35. - * - * On 301, 301B, only HiVision 1080i is supported. - * On 30xLV, 301C, only YPbPr 1080i is supported. - */ + /* Note: This variable is only used on 30xLV systems. + * CR38 has a different meaning on LVDS/CH7019 systems. + * On 661 and later, these bits moved to CR35. + * + * On 301, 301B, only HiVision 1080i is supported. + * On 30xLV, 301C, only YPbPr 1080i is supported. + */ - SiS_Pr->SiS_YPbPr = 0; - if(HwInfo->jChipType >= SIS_661) return; + SiS_Pr->SiS_YPbPr = 0; + if(SiS_Pr->ChipType >= SIS_661) return; - if(SiS_Pr->SiS_VBType) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - SiS_Pr->SiS_YPbPr = YPbPrHiVision; - } - } + if(SiS_Pr->SiS_VBType) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + SiS_Pr->SiS_YPbPr = YPbPrHiVision; + } + } - if(HwInfo->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_VBType & (VB_SIS301LV302LV | VB_SIS301C)) { - temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); - if(temp & 0x08) { - switch((temp >> 4)) { - case 0x00: SiS_Pr->SiS_YPbPr = YPbPr525i; break; - case 0x01: SiS_Pr->SiS_YPbPr = YPbPr525p; break; - case 0x02: SiS_Pr->SiS_YPbPr = YPbPr750p; break; - case 0x03: SiS_Pr->SiS_YPbPr = YPbPrHiVision; break; - } - } - } - } + if(SiS_Pr->ChipType >= SIS_315H) { + if(SiS_Pr->SiS_VBType & VB_SISYPBPR) { + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if(temp & 0x08) { + switch((temp >> 4)) { + case 0x00: SiS_Pr->SiS_YPbPr = YPbPr525i; break; + case 0x01: SiS_Pr->SiS_YPbPr = YPbPr525p; break; + case 0x02: SiS_Pr->SiS_YPbPr = YPbPr750p; break; + case 0x03: SiS_Pr->SiS_YPbPr = YPbPrHiVision; break; + } + } + } + } } @@ -1255,199 +1225,204 @@ SiS_SetYPbPr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) /*********************************************/ void -SiS_SetTVMode(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_INFO HwInfo) +SiS_SetTVMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT temp, temp1, resinfo = 0, romindex = 0; - UCHAR OutputSelect = *SiS_Pr->pSiS_OutputSelect; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short temp, temp1, resinfo = 0, romindex = 0; + unsigned char OutputSelect = *SiS_Pr->pSiS_OutputSelect; - SiS_Pr->SiS_TVMode = 0; + SiS_Pr->SiS_TVMode = 0; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) return; - if(SiS_Pr->UseCustomMode) return; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) return; + if(SiS_Pr->UseCustomMode) return; - if(ModeNo > 0x13) { - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; - } + if(ModeNo > 0x13) { + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + } - if(HwInfo->jChipType < SIS_661) { + if(SiS_Pr->ChipType < SIS_661) { - if(SiS_Pr->SiS_VBInfo & SetPALTV) SiS_Pr->SiS_TVMode |= TVSetPAL; + if(SiS_Pr->SiS_VBInfo & SetPALTV) SiS_Pr->SiS_TVMode |= TVSetPAL; - if(SiS_Pr->SiS_VBType & VB_SISVB) { - temp = 0; - if((HwInfo->jChipType == SIS_630) || - (HwInfo->jChipType == SIS_730)) { - temp = 0x35; - romindex = 0xfe; - } else if(HwInfo->jChipType >= SIS_315H) { - temp = 0x38; - romindex = 0xf3; - if(HwInfo->jChipType >= SIS_330) romindex = 0x11b; - } - if(temp) { - if(romindex && SiS_Pr->SiS_UseROM && (!(SiS_Pr->SiS_ROMNew))) { - OutputSelect = ROMAddr[romindex]; - if(!(OutputSelect & EnablePALMN)) { - SiS_SetRegAND(SiS_Pr->SiS_P3d4,temp,0x3F); - } - } - temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,temp); - if(SiS_Pr->SiS_TVMode & TVSetPAL) { - if(temp1 & EnablePALM) { /* 0x40 */ - SiS_Pr->SiS_TVMode |= TVSetPALM; - SiS_Pr->SiS_TVMode &= ~TVSetPAL; - } else if(temp1 & EnablePALN) { /* 0x80 */ - SiS_Pr->SiS_TVMode |= TVSetPALN; - } - } else { - if(temp1 & EnableNTSCJ) { /* 0x40 */ - SiS_Pr->SiS_TVMode |= TVSetNTSCJ; - } - } - } - /* Translate HiVision/YPbPr to our new flags */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - if(SiS_Pr->SiS_YPbPr == YPbPr750p) SiS_Pr->SiS_TVMode |= TVSetYPbPr750p; - else if(SiS_Pr->SiS_YPbPr == YPbPr525p) SiS_Pr->SiS_TVMode |= TVSetYPbPr525p; - else if(SiS_Pr->SiS_YPbPr == YPbPrHiVision) SiS_Pr->SiS_TVMode |= TVSetHiVision; - else SiS_Pr->SiS_TVMode |= TVSetYPbPr525i; - if(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetYPbPr525p | TVSetYPbPr525i)) { - SiS_Pr->SiS_VBInfo &= ~SetCRT2ToHiVision; - SiS_Pr->SiS_VBInfo |= SetCRT2ToYPbPr525750; - } else if(SiS_Pr->SiS_TVMode & TVSetHiVision) { - SiS_Pr->SiS_TVMode |= TVSetPAL; - } - } - } else if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_Pr->SiS_CHOverScan) { - if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { - temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); - if((temp & TVOverScan) || (SiS_Pr->SiS_CHOverScan == 1)) { - SiS_Pr->SiS_TVMode |= TVSetCHOverScan; - } - } else if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x79); - if((temp & 0x80) || (SiS_Pr->SiS_CHOverScan == 1)) { - SiS_Pr->SiS_TVMode |= TVSetCHOverScan; - } - } - if(SiS_Pr->SiS_CHSOverScan) { - SiS_Pr->SiS_TVMode |= TVSetCHOverScan; - } - } - if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); - if(SiS_Pr->SiS_TVMode & TVSetPAL) { - if(temp & EnablePALM) SiS_Pr->SiS_TVMode |= TVSetPALM; - else if(temp & EnablePALN) SiS_Pr->SiS_TVMode |= TVSetPALN; - } else { - if(temp & EnableNTSCJ) { - SiS_Pr->SiS_TVMode |= TVSetNTSCJ; - } - } - } - } + if(SiS_Pr->SiS_VBType & VB_SISVB) { + temp = 0; + if((SiS_Pr->ChipType == SIS_630) || + (SiS_Pr->ChipType == SIS_730)) { + temp = 0x35; + romindex = 0xfe; + } else if(SiS_Pr->ChipType >= SIS_315H) { + temp = 0x38; + if(SiS_Pr->ChipType < XGI_20) { + romindex = 0xf3; + if(SiS_Pr->ChipType >= SIS_330) romindex = 0x11b; + } + } + if(temp) { + if(romindex && SiS_Pr->SiS_UseROM && (!(SiS_Pr->SiS_ROMNew))) { + OutputSelect = ROMAddr[romindex]; + if(!(OutputSelect & EnablePALMN)) { + SiS_SetRegAND(SiS_Pr->SiS_P3d4,temp,0x3F); + } + } + temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,temp); + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + if(temp1 & EnablePALM) { /* 0x40 */ + SiS_Pr->SiS_TVMode |= TVSetPALM; + SiS_Pr->SiS_TVMode &= ~TVSetPAL; + } else if(temp1 & EnablePALN) { /* 0x80 */ + SiS_Pr->SiS_TVMode |= TVSetPALN; + } + } else { + if(temp1 & EnableNTSCJ) { /* 0x40 */ + SiS_Pr->SiS_TVMode |= TVSetNTSCJ; + } + } + } + /* Translate HiVision/YPbPr to our new flags */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + if(SiS_Pr->SiS_YPbPr == YPbPr750p) SiS_Pr->SiS_TVMode |= TVSetYPbPr750p; + else if(SiS_Pr->SiS_YPbPr == YPbPr525p) SiS_Pr->SiS_TVMode |= TVSetYPbPr525p; + else if(SiS_Pr->SiS_YPbPr == YPbPrHiVision) SiS_Pr->SiS_TVMode |= TVSetHiVision; + else SiS_Pr->SiS_TVMode |= TVSetYPbPr525i; + if(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetYPbPr525p | TVSetYPbPr525i)) { + SiS_Pr->SiS_VBInfo &= ~SetCRT2ToHiVision; + SiS_Pr->SiS_VBInfo |= SetCRT2ToYPbPr525750; + } else if(SiS_Pr->SiS_TVMode & TVSetHiVision) { + SiS_Pr->SiS_TVMode |= TVSetPAL; + } + } + } else if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_CHOverScan) { + if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); + if((temp & TVOverScan) || (SiS_Pr->SiS_CHOverScan == 1)) { + SiS_Pr->SiS_TVMode |= TVSetCHOverScan; + } + } else if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x79); + if((temp & 0x80) || (SiS_Pr->SiS_CHOverScan == 1)) { + SiS_Pr->SiS_TVMode |= TVSetCHOverScan; + } + } + if(SiS_Pr->SiS_CHSOverScan) { + SiS_Pr->SiS_TVMode |= TVSetCHOverScan; + } + } + if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + if(temp & EnablePALM) SiS_Pr->SiS_TVMode |= TVSetPALM; + else if(temp & EnablePALN) SiS_Pr->SiS_TVMode |= TVSetPALN; + } else { + if(temp & EnableNTSCJ) { + SiS_Pr->SiS_TVMode |= TVSetNTSCJ; + } + } + } + } - } else { /* 661 and later */ + } else { /* 661 and later */ - temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); - if(temp1 & 0x01) { - SiS_Pr->SiS_TVMode |= TVSetPAL; - if(temp1 & 0x08) { - SiS_Pr->SiS_TVMode |= TVSetPALN; - } else if(temp1 & 0x04) { - if(SiS_Pr->SiS_VBType & VB_SISVB) { - SiS_Pr->SiS_TVMode &= ~TVSetPAL; - } - SiS_Pr->SiS_TVMode |= TVSetPALM; - } - } else { - if(temp1 & 0x02) { - SiS_Pr->SiS_TVMode |= TVSetNTSCJ; - } - } - if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - if(SiS_Pr->SiS_CHOverScan) { - if((temp1 & 0x10) || (SiS_Pr->SiS_CHOverScan == 1)) { - SiS_Pr->SiS_TVMode |= TVSetCHOverScan; - } - } - } - if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { - temp1 &= 0xe0; - if(temp1 == 0x00) SiS_Pr->SiS_TVMode |= TVSetYPbPr525i; - else if(temp1 == 0x20) SiS_Pr->SiS_TVMode |= TVSetYPbPr525p; - else if(temp1 == 0x40) SiS_Pr->SiS_TVMode |= TVSetYPbPr750p; - } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - SiS_Pr->SiS_TVMode |= (TVSetHiVision | TVSetPAL); - } - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToYPbPr525750 | SetCRT2ToHiVision)) { - if(resinfo == SIS_RI_800x480 || resinfo == SIS_RI_1024x576 || resinfo == SIS_RI_1280x720) { - SiS_Pr->SiS_TVMode |= TVAspect169; - } else { - temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x39); - if(temp1 & 0x02) { - if(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetHiVision)) { - SiS_Pr->SiS_TVMode |= TVAspect169; - } else { - SiS_Pr->SiS_TVMode |= TVAspect43LB; - } - } else { - SiS_Pr->SiS_TVMode |= TVAspect43; - } - } - } - } - } + temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); + if(temp1 & 0x01) { + SiS_Pr->SiS_TVMode |= TVSetPAL; + if(temp1 & 0x08) { + SiS_Pr->SiS_TVMode |= TVSetPALN; + } else if(temp1 & 0x04) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { + SiS_Pr->SiS_TVMode &= ~TVSetPAL; + } + SiS_Pr->SiS_TVMode |= TVSetPALM; + } + } else { + if(temp1 & 0x02) { + SiS_Pr->SiS_TVMode |= TVSetNTSCJ; + } + } + if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + if(SiS_Pr->SiS_CHOverScan) { + if((temp1 & 0x10) || (SiS_Pr->SiS_CHOverScan == 1)) { + SiS_Pr->SiS_TVMode |= TVSetCHOverScan; + } + } + } + if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { + temp1 &= 0xe0; + if(temp1 == 0x00) SiS_Pr->SiS_TVMode |= TVSetYPbPr525i; + else if(temp1 == 0x20) SiS_Pr->SiS_TVMode |= TVSetYPbPr525p; + else if(temp1 == 0x40) SiS_Pr->SiS_TVMode |= TVSetYPbPr750p; + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + SiS_Pr->SiS_TVMode |= (TVSetHiVision | TVSetPAL); + } + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToYPbPr525750 | SetCRT2ToHiVision)) { + if(resinfo == SIS_RI_800x480 || resinfo == SIS_RI_1024x576 || resinfo == SIS_RI_1280x720) { + SiS_Pr->SiS_TVMode |= TVAspect169; + } else { + temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x39); + if(temp1 & 0x02) { + if(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetHiVision)) { + SiS_Pr->SiS_TVMode |= TVAspect169; + } else { + SiS_Pr->SiS_TVMode |= TVAspect43LB; + } + } else { + SiS_Pr->SiS_TVMode |= TVAspect43; + } + } + } + } + } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToSCART) SiS_Pr->SiS_TVMode |= TVSetPAL; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToSCART) SiS_Pr->SiS_TVMode |= TVSetPAL; - if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - SiS_Pr->SiS_TVMode |= TVSetPAL; - SiS_Pr->SiS_TVMode &= ~(TVSetPALM | TVSetPALN | TVSetNTSCJ); - } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { - if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525i | TVSetYPbPr525p | TVSetYPbPr750p)) { - SiS_Pr->SiS_TVMode &= ~(TVSetPAL | TVSetNTSCJ | TVSetPALM | TVSetPALN); - } - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + SiS_Pr->SiS_TVMode |= TVSetPAL; + SiS_Pr->SiS_TVMode &= ~(TVSetPALM | TVSetPALN | TVSetNTSCJ); + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { + if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525i | TVSetYPbPr525p | TVSetYPbPr750p)) { + SiS_Pr->SiS_TVMode &= ~(TVSetPAL | TVSetNTSCJ | TVSetPALM | TVSetPALN); + } + } - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { - SiS_Pr->SiS_TVMode |= TVSetTVSimuMode; - } - } + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { + SiS_Pr->SiS_TVMode |= TVSetTVSimuMode; + } + } - if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { - /* BIOS sets TVNTSC1024 without checking 525p here. Wrong? */ - if(!(SiS_Pr->SiS_TVMode & (TVSetHiVision | TVSetYPbPr525p | TVSetYPbPr750p))) { - if(resinfo == SIS_RI_1024x768) { - SiS_Pr->SiS_TVMode |= TVSetNTSC1024; - } - } - } + if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { + if(resinfo == SIS_RI_1024x768) { + if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) { + SiS_Pr->SiS_TVMode |= TVSet525p1024; + } else if(!(SiS_Pr->SiS_TVMode & (TVSetHiVision | TVSetYPbPr750p))) { + SiS_Pr->SiS_TVMode |= TVSetNTSC1024; + } + } + } - SiS_Pr->SiS_TVMode |= TVRPLLDIV2XO; - if((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) && - (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO; - } else if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p)) { - SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO; - } else if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { - if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { - SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO; - } - } + SiS_Pr->SiS_TVMode |= TVRPLLDIV2XO; + if((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) && + (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO; + } else if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p)) { + SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO; + } else if(!(SiS_Pr->SiS_VBType & VB_SIS30xBLV)) { + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { + SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO; + } + } - } + } - SiS_Pr->SiS_VBInfo &= ~SetPALTV; + SiS_Pr->SiS_VBInfo &= ~SetPALTV; +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "(init301: TVMode %x, VBInfo %x)\n", SiS_Pr->SiS_TVMode, SiS_Pr->SiS_VBInfo); + xf86DrvMsg(0, X_INFO, "(init301: TVMode %x, VBInfo %x)\n", SiS_Pr->SiS_TVMode, SiS_Pr->SiS_VBInfo); +#endif #endif } @@ -1455,41 +1430,46 @@ SiS_SetTVMode(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_IN /* GET LCD INFO */ /*********************************************/ -static USHORT -SiS_GetBIOSLCDResInfo(SiS_Private *SiS_Pr) +static unsigned short +SiS_GetBIOSLCDResInfo(struct SiS_Private *SiS_Pr) { - USHORT temp = SiS_Pr->SiS_LCDResInfo; + unsigned short temp = SiS_Pr->SiS_LCDResInfo; /* Translate my LCDResInfo to BIOS value */ - if(temp == Panel_1280x768_2) temp = Panel_1280x768; - if(temp == Panel_1280x800_2) temp = Panel_1280x800; + switch(temp) { + case Panel_1280x768_2: temp = Panel_1280x768; break; + case Panel_1280x800_2: temp = Panel_1280x800; break; + case Panel_1280x854: temp = Panel661_1280x854; break; + } return temp; } static void -SiS_GetLCDInfoBIOS(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_GetLCDInfoBIOS(struct SiS_Private *SiS_Pr) { #ifdef SIS315H - UCHAR *ROMAddr; - USHORT temp; + unsigned char *ROMAddr; + unsigned short temp; +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "Paneldata driver: [%d %d] [H %d %d] [V %d %d] [C %d 0x%02x 0x%02x]\n", - SiS_Pr->PanelHT, SiS_Pr->PanelVT, + SiS_Pr->PanelHT, SiS_Pr->PanelVT, SiS_Pr->PanelHRS, SiS_Pr->PanelHRE, SiS_Pr->PanelVRS, SiS_Pr->PanelVRE, SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].CLOCK, SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_A, SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_B); #endif +#endif - if((ROMAddr = GetLCDStructPtr661(SiS_Pr, HwInfo))) { + if((ROMAddr = GetLCDStructPtr661(SiS_Pr))) { if((temp = SISGETROMW(6)) != SiS_Pr->PanelHT) { - SiS_Pr->SiS_NeedRomModeData = TRUE; + SiS_Pr->SiS_NeedRomModeData = TRUE; SiS_Pr->PanelHT = temp; } if((temp = SISGETROMW(8)) != SiS_Pr->PanelVT) { - SiS_Pr->SiS_NeedRomModeData = TRUE; - SiS_Pr->PanelVT = temp; + SiS_Pr->SiS_NeedRomModeData = TRUE; + SiS_Pr->PanelVT = temp; } SiS_Pr->PanelHRS = SISGETROMW(10); SiS_Pr->PanelHRE = SISGETROMW(12); @@ -1497,56 +1477,58 @@ SiS_GetLCDInfoBIOS(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) SiS_Pr->PanelVRE = SISGETROMW(16); SiS_Pr->PanelVCLKIdx315 = VCLK_CUSTOM_315; SiS_Pr->SiS_VCLKData[VCLK_CUSTOM_315].CLOCK = - SiS_Pr->SiS_VBVCLKData[VCLK_CUSTOM_315].CLOCK = (USHORT)((UCHAR)ROMAddr[18]); + SiS_Pr->SiS_VBVCLKData[VCLK_CUSTOM_315].CLOCK = (unsigned short)((unsigned char)ROMAddr[18]); SiS_Pr->SiS_VCLKData[VCLK_CUSTOM_315].SR2B = SiS_Pr->SiS_VBVCLKData[VCLK_CUSTOM_315].Part4_A = ROMAddr[19]; SiS_Pr->SiS_VCLKData[VCLK_CUSTOM_315].SR2C = SiS_Pr->SiS_VBVCLKData[VCLK_CUSTOM_315].Part4_B = ROMAddr[20]; +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "Paneldata BIOS: [%d %d] [H %d %d] [V %d %d] [C %d 0x%02x 0x%02x]\n", - SiS_Pr->PanelHT, SiS_Pr->PanelVT, + SiS_Pr->PanelHT, SiS_Pr->PanelVT, SiS_Pr->PanelHRS, SiS_Pr->PanelHRE, SiS_Pr->PanelVRS, SiS_Pr->PanelVRE, SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].CLOCK, SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_A, SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_B); #endif +#endif } #endif } static void -SiS_CheckScaling(SiS_Private *SiS_Pr, USHORT resinfo, const UCHAR *nonscalingmodes) -{ - int i = 0; - while(nonscalingmodes[i] != 0xff) { - if(nonscalingmodes[i++] == resinfo) { - if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) || - (SiS_Pr->UsePanelScaler == -1)) { - SiS_Pr->SiS_LCDInfo |= DontExpandLCD; - } - break; - } - } +SiS_CheckScaling(struct SiS_Private *SiS_Pr, unsigned short resinfo, + const unsigned char *nonscalingmodes) +{ + int i = 0; + while(nonscalingmodes[i] != 0xff) { + if(nonscalingmodes[i++] == resinfo) { + if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) || + (SiS_Pr->UsePanelScaler == -1)) { + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } + break; + } + } } void -SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo) +SiS_GetLCDResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { + unsigned short temp,modeflag,resinfo=0,modexres=0,modeyres=0; + BOOLEAN panelcanscale = FALSE; #ifdef SIS300 - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - const unsigned char SiS300SeriesLCDRes[] = + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + static const unsigned char SiS300SeriesLCDRes[] = { 0, 1, 2, 3, 7, 4, 5, 8, 0, 0, 10, 0, 0, 0, 0, 15 }; #endif #ifdef SIS315H - UCHAR *myptr = NULL; + unsigned char *myptr = NULL; #endif - USHORT temp,modeflag,resinfo=0,modexres=0,modeyres=0; - BOOLEAN panelcanscale = FALSE; SiS_Pr->SiS_LCDResInfo = 0; SiS_Pr->SiS_LCDTypeInfo = 0; @@ -1557,14 +1539,14 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_Pr->PanelVRE = 999; /* VSync end */ SiS_Pr->SiS_NeedRomModeData = FALSE; + /* Alternative 1600x1200@60 timing for 1600x1200 LCDA */ + SiS_Pr->Alternate1600x1200 = FALSE; + if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) return; - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - } else if(SiS_Pr->UseCustomMode) { - modeflag = SiS_Pr->CModeFlag; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + modeflag = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex); + + if((ModeNo > 0x13) && (!SiS_Pr->UseCustomMode)) { resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; modexres = SiS_Pr->SiS_ModeResInfo[resinfo].HTotal; modeyres = SiS_Pr->SiS_ModeResInfo[resinfo].VTotal; @@ -1575,16 +1557,16 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /* For broken BIOSes: Assume 1024x768 */ if(temp == 0) temp = 0x02; - if((HwInfo->jChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) { + if((SiS_Pr->ChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) { SiS_Pr->SiS_LCDTypeInfo = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x39) & 0x7c) >> 2; - } else if((HwInfo->jChipType < SIS_315H) || (HwInfo->jChipType >= SIS_661)) { + } else if((SiS_Pr->ChipType < SIS_315H) || (SiS_Pr->ChipType >= SIS_661)) { SiS_Pr->SiS_LCDTypeInfo = temp >> 4; } else { SiS_Pr->SiS_LCDTypeInfo = (temp & 0x0F) - 1; } temp &= 0x0f; #ifdef SIS300 - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { /* Very old BIOSes only know 7 sizes (NetVista 2179, 1.01g) */ if(SiS_Pr->SiS_VBType & VB_SIS301) { if(temp < 0x0f) temp &= 0x07; @@ -1595,17 +1577,22 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, #endif /* Translate to our internal types */ - if(HwInfo->jChipType == SIS_550) { - if(temp == Panel310_640x480_2) temp = Panel_640x480_2; - if(temp == Panel310_640x480_3) temp = Panel_640x480_3; +#ifdef SIS315H + if(SiS_Pr->ChipType == SIS_550) { + if (temp == Panel310_1152x768) temp = Panel_320x240_2; /* Verified working */ + else if(temp == Panel310_320x240_2) temp = Panel_320x240_2; + else if(temp == Panel310_320x240_3) temp = Panel_320x240_3; + } else if(SiS_Pr->ChipType >= SIS_661) { + if(temp == Panel661_1280x854) temp = Panel_1280x854; } +#endif - if(SiS_Pr->SiS_VBType & VB_SISLVDS) { /* SiS LVDS */ + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { /* SiS LVDS */ if(temp == Panel310_1280x768) { temp = Panel_1280x768_2; } if(SiS_Pr->SiS_ROMNew) { - if(temp == Panel661_1280x800) { + if(temp == Panel661_1280x800) { temp = Panel_1280x800_2; } } @@ -1613,13 +1600,17 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_Pr->SiS_LCDResInfo = temp; +#ifdef SIS300 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { - SiS_Pr->SiS_LCDResInfo = Panel_Barco1366; + SiS_Pr->SiS_LCDResInfo = Panel_Barco1366; } else if(SiS_Pr->SiS_CustomT == CUT_PANEL848) { - SiS_Pr->SiS_LCDResInfo = Panel_848x480; + SiS_Pr->SiS_LCDResInfo = Panel_848x480; + } else if(SiS_Pr->SiS_CustomT == CUT_PANEL856) { + SiS_Pr->SiS_LCDResInfo = Panel_856x480; } } +#endif if(SiS_Pr->SiS_VBType & VB_SISVB) { if(SiS_Pr->SiS_LCDResInfo < SiS_Pr->SiS_PanelMin301) @@ -1633,10 +1624,16 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_Pr->SiS_LCDInfo = temp & ~0x000e; /* Need temp below! */ - /* These can't scale no matter what */ + /* These must/can't scale no matter what */ switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_320x240_1: + case Panel_320x240_2: + case Panel_320x240_3: case Panel_1280x960: SiS_Pr->SiS_LCDInfo &= ~DontExpandLCD; + break; + case Panel_640x480: + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; } panelcanscale = (SiS_Pr->SiS_LCDInfo & DontExpandLCD) ? TRUE : FALSE; @@ -1646,41 +1643,41 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /* Dual link, Pass 1:1 BIOS default, etc. */ #ifdef SIS315H - if(HwInfo->jChipType >= SIS_661) { + if(SiS_Pr->ChipType >= SIS_661) { if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { - if(temp & 0x08) SiS_Pr->SiS_LCDInfo |= LCDPass11; + if(temp & 0x08) SiS_Pr->SiS_LCDInfo |= LCDPass11; } - if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { - if(SiS_Pr->SiS_ROMNew) { + if(SiS_Pr->SiS_VBType & VB_SISDUALLINK) { + if(SiS_Pr->SiS_ROMNew) { if(temp & 0x02) SiS_Pr->SiS_LCDInfo |= LCDDualLink; - } else if((myptr = GetLCDStructPtr661(SiS_Pr, HwInfo))) { - if(myptr[2] & 0x01) SiS_Pr->SiS_LCDInfo |= LCDDualLink; + } else if((myptr = GetLCDStructPtr661(SiS_Pr))) { + if(myptr[2] & 0x01) SiS_Pr->SiS_LCDInfo |= LCDDualLink; } } - } else if(HwInfo->jChipType >= SIS_315H) { + } else if(SiS_Pr->ChipType >= SIS_315H) { if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { - if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x39) & 0x01) SiS_Pr->SiS_LCDInfo |= LCDPass11; + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x39) & 0x01) SiS_Pr->SiS_LCDInfo |= LCDPass11; } if((SiS_Pr->SiS_ROMNew) && (!(SiS_Pr->PanelSelfDetected))) { - SiS_Pr->SiS_LCDInfo &= ~(LCDRGB18Bit); + SiS_Pr->SiS_LCDInfo &= ~(LCDRGB18Bit); temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); - if(temp & 0x01) SiS_Pr->SiS_LCDInfo |= LCDRGB18Bit; - if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + if(temp & 0x01) SiS_Pr->SiS_LCDInfo |= LCDRGB18Bit; + if(SiS_Pr->SiS_VBType & VB_SISDUALLINK) { if(temp & 0x02) SiS_Pr->SiS_LCDInfo |= LCDDualLink; } } else if(!(SiS_Pr->SiS_ROMNew)) { - if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { - if((SiS_Pr->SiS_CustomT == CUT_CLEVO1024) && + if(SiS_Pr->SiS_VBType & VB_SISDUALLINK) { + if((SiS_Pr->SiS_CustomT == CUT_CLEVO1024) && (SiS_Pr->SiS_LCDResInfo == Panel_1024x768)) { SiS_Pr->SiS_LCDInfo |= LCDDualLink; } - if((SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) || + if((SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) || (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) || - (SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) || + (SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) || (SiS_Pr->SiS_LCDResInfo == Panel_1680x1050)) { SiS_Pr->SiS_LCDInfo |= LCDDualLink; } - } + } } } #endif @@ -1691,12 +1688,12 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_Pr->SiS_LCDInfo &= ~LCDPass11; } else if(SiS_Pr->SiS_VBType & VB_SISVB) { if(SiS_Pr->SiS_VBType & VB_SISLVDS) { - /* Always center screen on SiS LVDS (if scaling is disabled) */ - SiS_Pr->SiS_LCDInfo &= ~LCDPass11; + /* Always center screen on SiS LVDS (if scaling is disabled) */ + SiS_Pr->SiS_LCDInfo &= ~LCDPass11; } else { - /* By default, pass 1:1 on SiS TMDS (if scaling is supported) */ - if(panelcanscale) SiS_Pr->SiS_LCDInfo |= LCDPass11; - if(SiS_Pr->CenterScreen == 1) SiS_Pr->SiS_LCDInfo &= ~LCDPass11; + /* By default, pass 1:1 on SiS TMDS (if scaling is supported) */ + if(panelcanscale) SiS_Pr->SiS_LCDInfo |= LCDPass11; + if(SiS_Pr->CenterScreen == 1) SiS_Pr->SiS_LCDInfo &= ~LCDPass11; } } @@ -1704,19 +1701,15 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_Pr->PanelVCLKIdx315 = VCLK108_2_315; switch(SiS_Pr->SiS_LCDResInfo) { - case Panel_320x480: SiS_Pr->PanelXRes = 320; SiS_Pr->PanelYRes = 480; - SiS_Pr->PanelHT = 400; SiS_Pr->PanelVT = 525; - SiS_Pr->PanelVCLKIdx300 = VCLK28; - SiS_Pr->PanelVCLKIdx315 = VCLK28; - break; - case Panel_640x480_2: - case Panel_640x480_3: SiS_Pr->PanelXRes = 640; SiS_Pr->PanelYRes = 480; - SiS_Pr->PanelVRS = 24; SiS_Pr->PanelVRE = 3; + case Panel_320x240_1: + case Panel_320x240_2: + case Panel_320x240_3: SiS_Pr->PanelXRes = 640; SiS_Pr->PanelYRes = 480; + SiS_Pr->PanelVRS = 24; SiS_Pr->PanelVRE = 3; SiS_Pr->PanelVCLKIdx300 = VCLK28; SiS_Pr->PanelVCLKIdx315 = VCLK28; break; case Panel_640x480: SiS_Pr->PanelXRes = 640; SiS_Pr->PanelYRes = 480; - SiS_Pr->PanelVRE = 3; + SiS_Pr->PanelVRE = 3; SiS_Pr->PanelVCLKIdx300 = VCLK28; SiS_Pr->PanelVCLKIdx315 = VCLK28; break; @@ -1728,52 +1721,52 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_Pr->PanelVCLKIdx315 = VCLK40; break; case Panel_1024x600: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 600; - SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 800; + SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 800; SiS_Pr->PanelHRS = 24; SiS_Pr->PanelHRE = 136; SiS_Pr->PanelVRS = 2 /* 88 */ ; SiS_Pr->PanelVRE = 6; - SiS_Pr->PanelVCLKIdx300 = VCLK65_300; + SiS_Pr->PanelVCLKIdx300 = VCLK65_300; SiS_Pr->PanelVCLKIdx315 = VCLK65_315; - break; + break; case Panel_1024x768: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 768; - SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806; + SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806; SiS_Pr->PanelHRS = 24; SiS_Pr->PanelHRE = 136; SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6; - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { SiS_Pr->PanelHRS = 23; - SiS_Pr->PanelVRE = 5; + SiS_Pr->PanelVRE = 5; } SiS_Pr->PanelVCLKIdx300 = VCLK65_300; SiS_Pr->PanelVCLKIdx315 = VCLK65_315; - SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + SiS_GetLCDInfoBIOS(SiS_Pr); break; case Panel_1152x768: SiS_Pr->PanelXRes = 1152; SiS_Pr->PanelYRes = 768; - SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806; - SiS_Pr->PanelHRS = 24; + SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806; + SiS_Pr->PanelHRS = 24; SiS_Pr->PanelHRE = 136; SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6; - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { SiS_Pr->PanelHRS = 23; - SiS_Pr->PanelVRE = 5; + SiS_Pr->PanelVRE = 5; } - SiS_Pr->PanelVCLKIdx300 = VCLK65_300; + SiS_Pr->PanelVCLKIdx300 = VCLK65_300; SiS_Pr->PanelVCLKIdx315 = VCLK65_315; - break; + break; case Panel_1152x864: SiS_Pr->PanelXRes = 1152; SiS_Pr->PanelYRes = 864; - break; + break; case Panel_1280x720: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 720; - SiS_Pr->PanelHT = 1650; SiS_Pr->PanelVT = 750; + SiS_Pr->PanelHT = 1650; SiS_Pr->PanelVT = 750; SiS_Pr->PanelHRS = 110; SiS_Pr->PanelHRE = 40; SiS_Pr->PanelVRS = 5; SiS_Pr->PanelVRE = 5; SiS_Pr->PanelVCLKIdx315 = VCLK_1280x720; /* Data above for TMDS (projector); get from BIOS for LVDS */ - SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + SiS_GetLCDInfoBIOS(SiS_Pr); break; case Panel_1280x768: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 768; - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { SiS_Pr->PanelHT = 1408; SiS_Pr->PanelVT = 806; SiS_Pr->PanelVCLKIdx300 = VCLK81_300; /* ? */ SiS_Pr->PanelVCLKIdx315 = VCLK81_315; /* ? */ } else { - SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 802; + SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 802; SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRS = 112; SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6; SiS_Pr->PanelVCLKIdx300 = VCLK81_300; @@ -1781,77 +1774,100 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } break; case Panel_1280x768_2: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 768; - SiS_Pr->PanelHT = 1660; SiS_Pr->PanelVT = 806; + SiS_Pr->PanelHT = 1660; SiS_Pr->PanelVT = 806; SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112; SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6; SiS_Pr->PanelVCLKIdx315 = VCLK_1280x768_2; - SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + SiS_GetLCDInfoBIOS(SiS_Pr); break; case Panel_1280x800: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 800; - SiS_Pr->PanelHT = 1408; SiS_Pr->PanelVT = 816; + SiS_Pr->PanelHT = 1408; SiS_Pr->PanelVT = 816; SiS_Pr->PanelHRS = 21; SiS_Pr->PanelHRE = 24; SiS_Pr->PanelVRS = 4; SiS_Pr->PanelVRE = 3; SiS_Pr->PanelVCLKIdx315 = VCLK_1280x800_315; - SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + SiS_GetLCDInfoBIOS(SiS_Pr); break; case Panel_1280x800_2: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 800; - SiS_Pr->PanelHT = 1552; SiS_Pr->PanelVT = 812; + SiS_Pr->PanelHT = 1552; SiS_Pr->PanelVT = 812; SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112; SiS_Pr->PanelVRS = 4; SiS_Pr->PanelVRE = 3; SiS_Pr->PanelVCLKIdx315 = VCLK_1280x800_315_2; - SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + SiS_GetLCDInfoBIOS(SiS_Pr); + break; + case Panel_1280x854: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 854; + SiS_Pr->PanelHT = 1664; SiS_Pr->PanelVT = 861; + SiS_Pr->PanelHRS = 16; SiS_Pr->PanelHRE = 112; + SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 3; + SiS_Pr->PanelVCLKIdx315 = VCLK_1280x854; + SiS_GetLCDInfoBIOS(SiS_Pr); break; case Panel_1280x960: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 960; - SiS_Pr->PanelHT = 1800; SiS_Pr->PanelVT = 1000; + SiS_Pr->PanelHT = 1800; SiS_Pr->PanelVT = 1000; SiS_Pr->PanelVCLKIdx300 = VCLK108_3_300; SiS_Pr->PanelVCLKIdx315 = VCLK108_3_315; - if(resinfo == SIS_RI_1280x1024) { + if(resinfo == SIS_RI_1280x1024) { SiS_Pr->PanelVCLKIdx300 = VCLK100_300; SiS_Pr->PanelVCLKIdx315 = VCLK100_315; } break; case Panel_1280x1024: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 1024; - SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066; + SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066; SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112; SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 3; SiS_Pr->PanelVCLKIdx300 = VCLK108_3_300; SiS_Pr->PanelVCLKIdx315 = VCLK108_2_315; - SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + SiS_GetLCDInfoBIOS(SiS_Pr); break; case Panel_1400x1050: SiS_Pr->PanelXRes = 1400; SiS_Pr->PanelYRes = 1050; - SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066; - SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112; /* HRE OK for LVDS, not for LCDA */ + SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066; + SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112; SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 3; SiS_Pr->PanelVCLKIdx315 = VCLK108_2_315; - SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + SiS_GetLCDInfoBIOS(SiS_Pr); break; case Panel_1600x1200: SiS_Pr->PanelXRes = 1600; SiS_Pr->PanelYRes = 1200; - SiS_Pr->PanelHT = 2160; SiS_Pr->PanelVT = 1250; + SiS_Pr->PanelHT = 2160; SiS_Pr->PanelVT = 1250; SiS_Pr->PanelHRS = 64; SiS_Pr->PanelHRE = 192; SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 3; SiS_Pr->PanelVCLKIdx315 = VCLK162_315; - SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + if(SiS_Pr->SiS_VBType & VB_SISTMDSLCDA) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + SiS_Pr->PanelHT = 1760; SiS_Pr->PanelVT = 1235; + SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 32; + SiS_Pr->PanelVRS = 2; SiS_Pr->PanelVRE = 4; + SiS_Pr->PanelVCLKIdx315 = VCLK130_315; + SiS_Pr->Alternate1600x1200 = TRUE; + } + } else if(SiS_Pr->SiS_IF_DEF_LVDS) { + SiS_Pr->PanelHT = 2048; SiS_Pr->PanelVT = 1320; + SiS_Pr->PanelHRS = SiS_Pr->PanelHRE = 999; + SiS_Pr->PanelVRS = SiS_Pr->PanelVRE = 999; + } + SiS_GetLCDInfoBIOS(SiS_Pr); break; case Panel_1680x1050: SiS_Pr->PanelXRes = 1680; SiS_Pr->PanelYRes = 1050; - SiS_Pr->PanelHT = 1900; SiS_Pr->PanelVT = 1066; + SiS_Pr->PanelHT = 1900; SiS_Pr->PanelVT = 1066; SiS_Pr->PanelHRS = 26; SiS_Pr->PanelHRE = 76; SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6; SiS_Pr->PanelVCLKIdx315 = VCLK121_315; - SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + SiS_GetLCDInfoBIOS(SiS_Pr); break; case Panel_Barco1366: SiS_Pr->PanelXRes = 1360; SiS_Pr->PanelYRes = 1024; - SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066; - break; + SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066; + break; case Panel_848x480: SiS_Pr->PanelXRes = 848; SiS_Pr->PanelYRes = 480; - SiS_Pr->PanelHT = 1088; SiS_Pr->PanelVT = 525; - break; + SiS_Pr->PanelHT = 1088; SiS_Pr->PanelVT = 525; + break; + case Panel_856x480: SiS_Pr->PanelXRes = 856; SiS_Pr->PanelYRes = 480; + SiS_Pr->PanelHT = 1088; SiS_Pr->PanelVT = 525; + break; case Panel_Custom: SiS_Pr->PanelXRes = SiS_Pr->CP_MaxX; - SiS_Pr->PanelYRes = SiS_Pr->CP_MaxY; + SiS_Pr->PanelYRes = SiS_Pr->CP_MaxY; SiS_Pr->PanelHT = SiS_Pr->CHTotal; SiS_Pr->PanelVT = SiS_Pr->CVTotal; if(SiS_Pr->CP_PreferredIndex != -1) { SiS_Pr->PanelXRes = SiS_Pr->CP_HDisplay[SiS_Pr->CP_PreferredIndex]; - SiS_Pr->PanelYRes = SiS_Pr->CP_VDisplay[SiS_Pr->CP_PreferredIndex]; + SiS_Pr->PanelYRes = SiS_Pr->CP_VDisplay[SiS_Pr->CP_PreferredIndex]; SiS_Pr->PanelHT = SiS_Pr->CP_HTotal[SiS_Pr->CP_PreferredIndex]; SiS_Pr->PanelVT = SiS_Pr->CP_VTotal[SiS_Pr->CP_PreferredIndex]; SiS_Pr->PanelHRS = SiS_Pr->CP_HSyncStart[SiS_Pr->CP_PreferredIndex]; @@ -1863,22 +1879,22 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_Pr->PanelVRS -= SiS_Pr->PanelYRes; SiS_Pr->PanelVRE -= SiS_Pr->PanelVRS; if(SiS_Pr->CP_PrefClock) { - int idx; - SiS_Pr->PanelVCLKIdx315 = VCLK_CUSTOM_315; + int idx; + SiS_Pr->PanelVCLKIdx315 = VCLK_CUSTOM_315; SiS_Pr->PanelVCLKIdx300 = VCLK_CUSTOM_300; - if(HwInfo->jChipType < SIS_315H) idx = VCLK_CUSTOM_300; + if(SiS_Pr->ChipType < SIS_315H) idx = VCLK_CUSTOM_300; else idx = VCLK_CUSTOM_315; - SiS_Pr->SiS_VCLKData[idx].CLOCK = - SiS_Pr->SiS_VBVCLKData[idx].CLOCK = SiS_Pr->CP_PrefClock; - SiS_Pr->SiS_VCLKData[idx].SR2B = - SiS_Pr->SiS_VBVCLKData[idx].Part4_A = SiS_Pr->CP_PrefSR2B; - SiS_Pr->SiS_VCLKData[idx].SR2C = - SiS_Pr->SiS_VBVCLKData[idx].Part4_B = SiS_Pr->CP_PrefSR2C; + SiS_Pr->SiS_VCLKData[idx].CLOCK = + SiS_Pr->SiS_VBVCLKData[idx].CLOCK = SiS_Pr->CP_PrefClock; + SiS_Pr->SiS_VCLKData[idx].SR2B = + SiS_Pr->SiS_VBVCLKData[idx].Part4_A = SiS_Pr->CP_PrefSR2B; + SiS_Pr->SiS_VCLKData[idx].SR2C = + SiS_Pr->SiS_VBVCLKData[idx].Part4_B = SiS_Pr->CP_PrefSR2C; } } break; default: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 768; - SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806; + SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806; break; } @@ -1887,14 +1903,16 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, (SiS_Pr->SiS_IF_DEF_DSTN) || (SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024) || - (SiS_Pr->SiS_CustomT == CUT_PANEL848) ) { + (SiS_Pr->SiS_CustomT == CUT_PANEL848) || + (SiS_Pr->SiS_CustomT == CUT_PANEL856) ) { SiS_Pr->PanelHRS = 999; SiS_Pr->PanelHRE = 999; } if( (SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024) || - (SiS_Pr->SiS_CustomT == CUT_PANEL848) ) { + (SiS_Pr->SiS_CustomT == CUT_PANEL848) || + (SiS_Pr->SiS_CustomT == CUT_PANEL856) ) { SiS_Pr->PanelVRS = 999; SiS_Pr->PanelVRE = 999; } @@ -1912,18 +1930,18 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, case Panel_Custom: case Panel_1152x864: case Panel_1280x768: /* TMDS only */ - SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; break; case Panel_800x600: { - static const UCHAR nonscalingmodes[] = { + static const unsigned char nonscalingmodes[] = { SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, 0xff }; SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); break; } case Panel_1024x768: { - static const UCHAR nonscalingmodes[] = { + static const unsigned char nonscalingmodes[] = { SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, 0xff @@ -1932,7 +1950,7 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, break; } case Panel_1280x720: { - static const UCHAR nonscalingmodes[] = { + static const unsigned char nonscalingmodes[] = { SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, 0xff @@ -1944,7 +1962,7 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, break; } case Panel_1280x768_2: { /* LVDS only */ - static const UCHAR nonscalingmodes[] = { + static const unsigned char nonscalingmodes[] = { SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, SIS_RI_1152x768,0xff @@ -1952,23 +1970,23 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); switch(resinfo) { case SIS_RI_1280x720: if(SiS_Pr->UsePanelScaler == -1) { - SiS_Pr->SiS_LCDInfo |= DontExpandLCD; - } - break; + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } + break; } - break; + break; } case Panel_1280x800: { /* SiS TMDS special (Averatec 6200 series) */ - static const UCHAR nonscalingmodes[] = { + static const unsigned char nonscalingmodes[] = { SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, SIS_RI_1152x768,SIS_RI_1280x720,SIS_RI_1280x768,0xff }; SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); - break; + break; } case Panel_1280x800_2: { /* SiS LVDS */ - static const UCHAR nonscalingmodes[] = { + static const unsigned char nonscalingmodes[] = { SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, SIS_RI_1152x768,0xff @@ -1977,66 +1995,83 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, switch(resinfo) { case SIS_RI_1280x720: case SIS_RI_1280x768: if(SiS_Pr->UsePanelScaler == -1) { - SiS_Pr->SiS_LCDInfo |= DontExpandLCD; - } - break; + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } + break; } - break; + break; + } + case Panel_1280x854: { /* SiS LVDS */ + static const unsigned char nonscalingmodes[] = { + SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, + SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, + SIS_RI_1152x768,0xff + }; + SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); + switch(resinfo) { + case SIS_RI_1280x720: + case SIS_RI_1280x768: + case SIS_RI_1280x800: if(SiS_Pr->UsePanelScaler == -1) { + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } + break; + } + break; } case Panel_1280x960: { - static const UCHAR nonscalingmodes[] = { + static const unsigned char nonscalingmodes[] = { SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x720,SIS_RI_1280x768,SIS_RI_1280x800, - 0xff + SIS_RI_1280x854,0xff }; SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); - break; + break; } case Panel_1280x1024: { - static const UCHAR nonscalingmodes[] = { + static const unsigned char nonscalingmodes[] = { SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x720,SIS_RI_1280x768,SIS_RI_1280x800, - SIS_RI_1280x960,0xff + SIS_RI_1280x854,SIS_RI_1280x960,0xff }; SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); break; } case Panel_1400x1050: { - static const UCHAR nonscalingmodes[] = { + static const unsigned char nonscalingmodes[] = { SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, - SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x768,SIS_RI_1280x800,SIS_RI_1280x960, - 0xff + SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x768,SIS_RI_1280x800,SIS_RI_1280x854, + SIS_RI_1280x960,0xff }; SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); - switch(resinfo) { + switch(resinfo) { case SIS_RI_1280x720: if(SiS_Pr->UsePanelScaler == -1) { - SiS_Pr->SiS_LCDInfo |= DontExpandLCD; - } - break; + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } + break; case SIS_RI_1280x1024: SiS_Pr->SiS_LCDInfo |= DontExpandLCD; - break; + break; } break; } case Panel_1600x1200: { - static const UCHAR nonscalingmodes[] = { + static const unsigned char nonscalingmodes[] = { SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x720,SIS_RI_1280x768,SIS_RI_1280x800, - SIS_RI_1280x960,SIS_RI_1360x768,SIS_RI_1360x1024,0xff + SIS_RI_1280x854,SIS_RI_1280x960,SIS_RI_1360x768,SIS_RI_1360x1024,0xff }; SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); - break; + break; } case Panel_1680x1050: { - static const UCHAR nonscalingmodes[] = { + static const unsigned char nonscalingmodes[] = { SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, - SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x960,SIS_RI_1360x768,SIS_RI_1360x1024, - 0xff + SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x854,SIS_RI_1280x960,SIS_RI_1360x768, + SIS_RI_1360x1024,0xff }; SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); break; @@ -2044,25 +2079,25 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } } +#ifdef SIS300 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(SiS_Pr->SiS_CustomT == CUT_PANEL848) { - SiS_Pr->SiS_LCDInfo = 0x80 | 0x40 | 0x20; /* neg h/v sync, RGB24(D0 = 0) */ + if(SiS_Pr->SiS_CustomT == CUT_PANEL848 || SiS_Pr->SiS_CustomT == CUT_PANEL856) { + SiS_Pr->SiS_LCDInfo = 0x80 | 0x40 | 0x20; /* neg h/v sync, RGB24(D0 = 0) */ } } -#ifdef SIS300 - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(SiS_Pr->SiS_UseROM) { + if(SiS_Pr->SiS_UseROM) { if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { - if(!(ROMAddr[0x235] & 0x02)) { - SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD); - } + if(!(ROMAddr[0x235] & 0x02)) { + SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD); + } } - } - } else if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + } + } else if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { if((SiS_Pr->SiS_SetFlag & SetDOSMode) && ((ModeNo == 0x03) || (ModeNo == 0x10))) { - SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD); + SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD); } } } @@ -2080,7 +2115,7 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, switch(SiS_Pr->SiS_LCDResInfo) { case Panel_640x480: - SiS_Pr->SiS_LCDInfo |= LCDPass11; + SiS_Pr->SiS_LCDInfo |= (DontExpandLCD | LCDPass11); break; case Panel_1280x800: /* Don't pass 1:1 by default (TMDS special) */ @@ -2097,7 +2132,7 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, break; } - if(SiS_Pr->UseCustomMode) { + if((SiS_Pr->UseCustomMode) || (SiS_Pr->SiS_CustomT == CUT_UNKNOWNLCD)) { SiS_Pr->SiS_LCDInfo |= (DontExpandLCD | LCDPass11); } @@ -2107,19 +2142,19 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } /* LVDS DDA */ - if(!((HwInfo->jChipType < SIS_315H) && (SiS_Pr->SiS_SetFlag & SetDOSMode))) { + if(!((SiS_Pr->ChipType < SIS_315H) && (SiS_Pr->SiS_SetFlag & SetDOSMode))) { if((SiS_Pr->SiS_IF_DEF_LVDS == 1) || (SiS_Pr->SiS_VBType & VB_NoLCD)) { if(SiS_Pr->SiS_IF_DEF_TRUMPION == 0) { if(ModeNo == 0x12) { if(SiS_Pr->SiS_LCDInfo & LCDPass11) { - SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; } } else if(ModeNo > 0x13) { if(SiS_Pr->SiS_LCDResInfo == Panel_1024x600) { - if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { - if((resinfo == SIS_RI_800x600) || (resinfo == SIS_RI_400x300)) { - SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { + if((resinfo == SIS_RI_800x600) || (resinfo == SIS_RI_400x300)) { + SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; } } } @@ -2128,18 +2163,18 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } if(modeflag & HalfDCLK) { - if(SiS_Pr->SiS_IF_DEF_TRUMPION == 1) { + if(SiS_Pr->SiS_IF_DEF_TRUMPION == 1) { SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; - } else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + } else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; } else if(SiS_Pr->SiS_LCDResInfo == Panel_640x480) { SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; } else if(ModeNo > 0x13) { - if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { - if(resinfo == SIS_RI_512x384) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; - } else if(SiS_Pr->SiS_LCDResInfo == Panel_800x600) { - if(resinfo == SIS_RI_400x300) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; - } + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { + if(resinfo == SIS_RI_512x384) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } else if(SiS_Pr->SiS_LCDResInfo == Panel_800x600) { + if(resinfo == SIS_RI_400x300) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } } } @@ -2148,21 +2183,21 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /* VESA timing */ if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { if(SiS_Pr->SiS_VBInfo & SetNotSimuMode) { - SiS_Pr->SiS_SetFlag |= LCDVESATiming; + SiS_Pr->SiS_SetFlag |= LCDVESATiming; } } else { SiS_Pr->SiS_SetFlag |= LCDVESATiming; } -#ifdef LINUX_KERNEL -#ifdef TWDEBUG +#ifdef SIS_LINUX_KERNEL +#if 0 printk(KERN_DEBUG "sisfb: (LCDInfo=0x%04x LCDResInfo=0x%02x LCDTypeInfo=0x%02x)\n", SiS_Pr->SiS_LCDInfo, SiS_Pr->SiS_LCDResInfo, SiS_Pr->SiS_LCDTypeInfo); #endif #endif -#ifdef LINUX_XF86 +#ifdef SIS_XORG_XF86 xf86DrvMsgVerb(0, X_PROBED, 4, - "(init301: LCDInfo=0x%04x LCDResInfo=0x%02x LCDTypeInfo=0x%02x SetFlag=0x%04x)\n", + "(init301: LCDInfo=0x%04x LCDResInfo=0x%02x LCDTypeInfo=0x%02x SetFlag=0x%04x)\n", SiS_Pr->SiS_LCDInfo, SiS_Pr->SiS_LCDResInfo, SiS_Pr->SiS_LCDTypeInfo, SiS_Pr->SiS_SetFlag); #endif } @@ -2171,45 +2206,46 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /* GET VCLK */ /*********************************************/ -USHORT -SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) +unsigned short +SiS_GetVCLK2Ptr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) { - USHORT CRT2Index,VCLKIndex=0,VCLKIndexGEN=0; - USHORT modeflag,resinfo,tempbx; - const UCHAR *CHTVVCLKPtr = NULL; + unsigned short CRT2Index, VCLKIndex = 0, VCLKIndexGEN = 0, VCLKIndexGENCRT = 0; + unsigned short modeflag, resinfo, tempbx; + const unsigned char *CHTVVCLKPtr = NULL; if(ModeNo <= 0x13) { modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; CRT2Index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; VCLKIndexGEN = (SiS_GetRegByte((SiS_Pr->SiS_P3ca+0x02)) >> 2) & 0x03; + VCLKIndexGENCRT = VCLKIndexGEN; } else { modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; CRT2Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; VCLKIndexGEN = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; - if(HwInfo->jChipType < SIS_315H) VCLKIndexGEN &= 0x3f; + VCLKIndexGENCRT = SiS_GetRefCRTVCLK(SiS_Pr, RefreshRateTableIndex, + (SiS_Pr->SiS_SetFlag & ProgrammingCRT2) ? SiS_Pr->SiS_UseWideCRT2 : SiS_Pr->SiS_UseWide); } if(SiS_Pr->SiS_VBType & VB_SISVB) { /* 30x/B/LV */ if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { - CRT2Index >>= 6; - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /* LCD */ + CRT2Index >>= 6; + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /* LCD */ - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { VCLKIndex = SiS_Pr->PanelVCLKIdx300; if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (SiS_Pr->SiS_LCDInfo & LCDPass11)) { - VCLKIndex = VCLKIndexGEN; + VCLKIndex = VCLKIndexGEN; } } else { VCLKIndex = SiS_Pr->PanelVCLKIdx315; if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (SiS_Pr->SiS_LCDInfo & LCDPass11)) { switch(resinfo) { - /* Only those whose IndexGEN doesn't match VBVCLK array */ - case SIS_RI_1280x720: VCLKIndex = VCLK_1280x720; break; + /* Correct those whose IndexGEN doesn't match VBVCLK array */ case SIS_RI_720x480: VCLKIndex = VCLK_720x480; break; case SIS_RI_720x576: VCLKIndex = VCLK_720x576; break; case SIS_RI_768x576: VCLKIndex = VCLK_768x576; break; @@ -2218,18 +2254,19 @@ SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, case SIS_RI_800x480: VCLKIndex = VCLK_800x480; break; case SIS_RI_1024x576: VCLKIndex = VCLK_1024x576; break; case SIS_RI_1152x864: VCLKIndex = VCLK_1152x864; break; + case SIS_RI_1280x720: VCLKIndex = VCLK_1280x720; break; case SIS_RI_1360x768: VCLKIndex = VCLK_1360x768; break; default: VCLKIndex = VCLKIndexGEN; } if(ModeNo <= 0x13) { - if(HwInfo->jChipType <= SIS_315PRO) { + if(SiS_Pr->ChipType <= SIS_315PRO) { if(SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC == 1) VCLKIndex = 0x42; - } else { + } else { if(SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC == 1) VCLKIndex = 0x00; } } - if(HwInfo->jChipType <= SIS_315PRO) { + if(SiS_Pr->ChipType <= SIS_315PRO) { if(VCLKIndex == 0) VCLKIndex = 0x41; if(VCLKIndex == 1) VCLKIndex = 0x43; if(VCLKIndex == 4) VCLKIndex = 0x44; @@ -2237,49 +2274,46 @@ SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } } - } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* TV */ + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* TV */ if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) VCLKIndex = HiTVVCLKDIV2; - else VCLKIndex = HiTVVCLK; - if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { - if(modeflag & Charx8Dot) VCLKIndex = HiTVSimuVCLK; - else VCLKIndex = HiTVTextVCLK; - } - } else if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) VCLKIndex = YPbPr750pVCLK; - else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) VCLKIndex = TVVCLKDIV2; - else if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) VCLKIndex = TVVCLKDIV2; - else VCLKIndex = TVVCLK; - - if(HwInfo->jChipType < SIS_315H) VCLKIndex += TVCLKBASE_300; - else VCLKIndex += TVCLKBASE_315; - - } else { /* VGA2 */ - - VCLKIndex = VCLKIndexGEN; - if(HwInfo->jChipType < SIS_315H) { - if(ModeNo > 0x13) { - if( (HwInfo->jChipType == SIS_630) && - (HwInfo->jChipRevision >= 0x30)) { + if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) VCLKIndex = HiTVVCLKDIV2; + else VCLKIndex = HiTVVCLK; + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) VCLKIndex = HiTVSimuVCLK; + } else if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) VCLKIndex = YPbPr750pVCLK; + else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) VCLKIndex = TVVCLKDIV2; + else if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) VCLKIndex = TVVCLKDIV2; + else VCLKIndex = TVVCLK; + + if(SiS_Pr->ChipType < SIS_315H) VCLKIndex += TVCLKBASE_300; + else VCLKIndex += TVCLKBASE_315; + + } else { /* VGA2 */ + + VCLKIndex = VCLKIndexGENCRT; + if(SiS_Pr->ChipType < SIS_315H) { + if(ModeNo > 0x13) { + if( (SiS_Pr->ChipType == SIS_630) && + (SiS_Pr->ChipRevision >= 0x30)) { if(VCLKIndex == 0x14) VCLKIndex = 0x34; } /* Better VGA2 clock for 1280x1024@75 */ if(VCLKIndex == 0x17) VCLKIndex = 0x45; } - } - } + } + } } else { /* If not programming CRT2 */ - VCLKIndex = VCLKIndexGEN; - if(HwInfo->jChipType < SIS_315H) { - if(ModeNo > 0x13) { - if( (HwInfo->jChipType != SIS_630) && - (HwInfo->jChipType != SIS_300) ) { + VCLKIndex = VCLKIndexGENCRT; + if(SiS_Pr->ChipType < SIS_315H) { + if(ModeNo > 0x13) { + if( (SiS_Pr->ChipType != SIS_630) && + (SiS_Pr->ChipType != SIS_300) ) { if(VCLKIndex == 0x1b) VCLKIndex = 0x48; } } - } + } } } else { /* LVDS */ @@ -2288,12 +2322,12 @@ SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { - if( (SiS_Pr->SiS_IF_DEF_CH70xx != 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) ) { + if( (SiS_Pr->SiS_IF_DEF_CH70xx != 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) ) { VCLKIndex &= 0x1f; - tempbx = 0; + tempbx = 0; if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; - if(SiS_Pr->SiS_TVMode & TVSetPAL) { + if(SiS_Pr->SiS_TVMode & TVSetPAL) { tempbx += 2; if(SiS_Pr->SiS_ModeType > ModeVGA) { if(SiS_Pr->SiS_CHSOverScan) tempbx = 8; @@ -2306,66 +2340,68 @@ SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; } } - switch(tempbx) { - case 0: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUNTSC; break; - case 1: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKONTSC; break; - case 2: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPAL; break; - case 3: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPAL; break; + switch(tempbx) { + case 0: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUNTSC; break; + case 1: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKONTSC; break; + case 2: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPAL; break; + case 3: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPAL; break; case 4: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPALM; break; - case 5: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPALM; break; - case 6: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPALN; break; - case 7: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPALN; break; + case 5: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPALM; break; + case 6: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPALN; break; + case 7: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPALN; break; case 8: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKSOPAL; break; default: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPAL; break; - } - VCLKIndex = CHTVVCLKPtr[VCLKIndex]; + } + VCLKIndex = CHTVVCLKPtr[VCLKIndex]; - } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { VCLKIndex = SiS_Pr->PanelVCLKIdx300; } else { VCLKIndex = SiS_Pr->PanelVCLKIdx315; } +#ifdef SIS300 /* Special Timing: Barco iQ Pro R series */ if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) VCLKIndex = 0x44; - /* Special Timing: 848x480 parallel lvds */ - if(SiS_Pr->SiS_CustomT == CUT_PANEL848) { - if(HwInfo->jChipType < SIS_315H) { + /* Special Timing: 848x480 and 856x480 parallel lvds panels */ + if(SiS_Pr->SiS_CustomT == CUT_PANEL848 || SiS_Pr->SiS_CustomT == CUT_PANEL856) { + if(SiS_Pr->ChipType < SIS_315H) { VCLKIndex = VCLK34_300; - /* if(resinfo == SIS_RI_1360x768) VCLKIndex = ?; */ + /* if(resinfo == SIS_RI_1360x768) VCLKIndex = ?; */ } else { VCLKIndex = VCLK34_315; /* if(resinfo == SIS_RI_1360x768) VCLKIndex = ?; */ } } +#endif - } else { + } else { - VCLKIndex = VCLKIndexGEN; - if(HwInfo->jChipType < SIS_315H) { - if(ModeNo > 0x13) { - if( (HwInfo->jChipType == SIS_630) && - (HwInfo->jChipRevision >= 0x30) ) { + VCLKIndex = VCLKIndexGENCRT; + if(SiS_Pr->ChipType < SIS_315H) { + if(ModeNo > 0x13) { + if( (SiS_Pr->ChipType == SIS_630) && + (SiS_Pr->ChipRevision >= 0x30) ) { if(VCLKIndex == 0x14) VCLKIndex = 0x2e; - } - } + } + } } - } + } } else { /* if not programming CRT2 */ - VCLKIndex = VCLKIndexGEN; - if(HwInfo->jChipType < SIS_315H) { - if(ModeNo > 0x13) { - if( (HwInfo->jChipType != SIS_630) && - (HwInfo->jChipType != SIS_300) ) { + VCLKIndex = VCLKIndexGENCRT; + if(SiS_Pr->ChipType < SIS_315H) { + if(ModeNo > 0x13) { + if( (SiS_Pr->ChipType != SIS_630) && + (SiS_Pr->ChipType != SIS_300) ) { if(VCLKIndex == 0x1b) VCLKIndex = 0x48; } #if 0 - if(HwInfo->jChipType == SIS_730) { + if(SiS_Pr->ChipType == SIS_730) { if(VCLKIndex == 0x0b) VCLKIndex = 0x40; /* 1024x768-70 */ if(VCLKIndex == 0x0d) VCLKIndex = 0x41; /* 1024x768-75 */ } @@ -2377,11 +2413,13 @@ SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "VCLKIndex %d (0x%x)\n", VCLKIndex, VCLKIndex); #endif +#endif - return(VCLKIndex); + return VCLKIndex; } /*********************************************/ @@ -2389,26 +2427,19 @@ SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /*********************************************/ static void -SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo) +SiS_SetCRT2ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - USHORT i,j,modeflag; - USHORT tempcl,tempah=0; + unsigned short i, j, modeflag, tempah=0; + short tempcl; #if defined(SIS300) || defined(SIS315H) - USHORT tempbl; + unsigned short tempbl; #endif #ifdef SIS315H - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT tempah2, tempbl2; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short tempah2, tempbl2; #endif - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - } else if(SiS_Pr->UseCustomMode) { - modeflag = SiS_Pr->CModeFlag; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - } + modeflag = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex); if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { @@ -2418,18 +2449,18 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } else { for(i=0,j=4; i<3; i++,j++) SiS_SetReg(SiS_Pr->SiS_Part1Port,j,0); - if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->ChipType >= SIS_315H) { SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0x7F); } tempcl = SiS_Pr->SiS_ModeType; - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { #ifdef SIS300 /* ---- 300 series ---- */ - /* For 301BDH: (with LCD via LVDS) */ - if(SiS_Pr->SiS_VBType & VB_NoLCD) { + /* For 301BDH: (with LCD via LVDS) */ + if(SiS_Pr->SiS_VBType & VB_NoLCD) { tempbl = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32); tempbl &= 0xef; tempbl |= 0x02; @@ -2438,16 +2469,16 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, tempbl &= 0xfd; } SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,tempbl); - } + } - if(ModeNo > 0x13) { - tempcl -= ModeVGA; - if((tempcl > 0) || (tempcl == 0)) { /* tempcl is USHORT -> always true! */ - tempah = ((0x10 >> tempcl) | 0x80); - } - } else tempah = 0x80; + if(ModeNo > 0x13) { + tempcl -= ModeVGA; + if(tempcl >= 0) { + tempah = ((0x10 >> tempcl) | 0x80); + } + } else tempah = 0x80; - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0xA0; + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0xA0; #endif /* SIS300 */ @@ -2455,22 +2486,16 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, #ifdef SIS315H /* ------- 315/330 series ------ */ - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x08); - } - } - - if(ModeNo > 0x13) { - tempcl -= ModeVGA; - if((tempcl > 0) || (tempcl == 0)) { /* tempcl is USHORT -> always true! */ - tempah = (0x08 >> tempcl); - if (tempah == 0) tempah = 1; - tempah |= 0x40; - } - } else tempah = 0x40; + if(ModeNo > 0x13) { + tempcl -= ModeVGA; + if(tempcl >= 0) { + tempah = (0x08 >> tempcl); + if (tempah == 0) tempah = 1; + tempah |= 0x40; + } + } else tempah = 0x40; - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0x50; + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0x50; #endif /* SIS315H */ @@ -2478,84 +2503,89 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0; - if(HwInfo->jChipType < SIS_315H) { - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,tempah); + if(SiS_Pr->ChipType < SIS_315H) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,tempah); } else { - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xa0,tempah); - } else if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(IS_SIS740) { +#ifdef SIS315H + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xa0,tempah); + } else if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(IS_SIS740) { SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,tempah); } else { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xa0,tempah); + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xa0,tempah); } - } + } +#endif } if(SiS_Pr->SiS_VBType & VB_SISVB) { - tempah = 0x01; - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - tempah |= 0x02; - } - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { - tempah ^= 0x05; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { - tempah ^= 0x01; - } - } + tempah = 0x01; + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + tempah |= 0x02; + } + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { + tempah ^= 0x05; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { + tempah ^= 0x01; + } + } - if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0; + if(SiS_Pr->ChipType < SIS_315H) { - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0; - tempah = (tempah << 5) & 0xFF; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,tempah); - tempah = (tempah >> 5) & 0xFF; + tempah = (tempah << 5) & 0xFF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,tempah); + tempah = (tempah >> 5) & 0xFF; - } else { + } else { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2E,0xF8,tempah); + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0x08; + else if(!(SiS_IsDualEdge(SiS_Pr))) tempah |= 0x08; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2E,0xF0,tempah); + tempah &= ~0x08; - } + } - if((SiS_Pr->SiS_ModeType == ModeVGA) && (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode))) { - tempah |= 0x10; - } + if((SiS_Pr->SiS_ModeType == ModeVGA) && (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode))) { + tempah |= 0x10; + } tempah |= 0x80; - if(SiS_Pr->SiS_VBType & VB_SIS301) { + if(SiS_Pr->SiS_VBType & VB_SIS301) { if(SiS_Pr->PanelXRes < 1280 && SiS_Pr->PanelYRes < 960) tempah &= ~0x80; - } + } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { if(!(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetYPbPr525p))) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - tempah |= 0x20; + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + tempah |= 0x20; } - } - } + } + } - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0D,0x40,tempah); + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0D,0x40,tempah); tempah = 0x80; if(SiS_Pr->SiS_VBType & VB_SIS301) { if(SiS_Pr->PanelXRes < 1280 && SiS_Pr->PanelYRes < 960) tempah = 0; } - if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempah |= 0x40; + if(SiS_IsDualLink(SiS_Pr)) tempah |= 0x40; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) { - tempah |= 0x40; - } - } + tempah |= 0x40; + } + } - SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0C,tempah); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0C,tempah); } else { /* LVDS */ - if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->ChipType >= SIS_315H) { #ifdef SIS315H /* LVDS can only be slave in 8bpp modes */ @@ -2566,36 +2596,30 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } } - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - tempah |= 0x02; - } + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) tempah |= 0x02; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - tempah ^= 0x01; - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) tempah ^= 0x01; - if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { - tempah = 1; - } + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 1; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2e,0xF0,tempah); + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2e,0xF0,tempah); #endif - } else { + } else { #ifdef SIS300 tempah = 0; if( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) && (SiS_Pr->SiS_ModeType > ModeVGA) ) { - tempah |= 0x02; - } + tempah |= 0x02; + } tempah <<= 5; - if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0; + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0; SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,tempah); #endif - } + } } @@ -2603,10 +2627,10 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->ChipType >= SIS_315H) { #ifdef SIS315H - unsigned char bridgerev = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01); + /* unsigned char bridgerev = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01); */ /* The following is nearly unpreditable and varies from machine * to machine. Especially the 301DH seems to be a real trouble @@ -2619,25 +2643,28 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /* 740 variants match for 30xB, 301B-DH, 30xLV */ - if(!(IS_SIS740)) { - tempah = 0x04; /* For all bridges */ - tempbl = 0xfb; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - tempah = 0x00; - if(SiS_IsDualEdge(SiS_Pr, HwInfo)) { + if(!(IS_SIS740)) { + tempah = 0x04; /* For all bridges */ + tempbl = 0xfb; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + tempah = 0x00; + if(SiS_IsDualEdge(SiS_Pr)) { tempbl = 0xff; } - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,tempbl,tempah); + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,tempbl,tempah); } /* The following two are responsible for eventually wrong colors * in TV output. The DH (VB_NoLCD) conditions are unknown; the * b0 was found in some 651 machine (Pim; P4_23=0xe5); the b1 version * in a 650 box (Jake). What is the criteria? + * Addendum: Another combination 651+301B-DH(b1) (Rapo) needs same + * treatment like the 651+301B-DH(b0) case. Seems more to be the + * chipset than the bridge revision. */ - if((IS_SIS740) || (HwInfo->jChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) { + if((IS_SIS740) || (SiS_Pr->ChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) { tempah = 0x30; tempbl = 0xc0; if((SiS_Pr->SiS_VBInfo & DisableCRT2Display) || @@ -2649,20 +2676,30 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0x3f,tempbl); } else if(SiS_Pr->SiS_VBType & VB_SIS301) { /* Fixes "TV-blue-bug" on 315+301 */ - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2c,0xcf); /* For 301 */ + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2c,0xcf); /* For 301 */ SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x21,0x3f); - } else if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); /* For 30xLV */ - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x21,0xc0); - } else if((SiS_Pr->SiS_VBType & VB_NoLCD) && (bridgerev == 0xb0)) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); /* For 30xB-DH rev b0 (or "DH on 651"?) */ + } else if(SiS_Pr->SiS_VBType & VB_SISLVDS) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); /* For 30xLV */ SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x21,0xc0); + } else if(SiS_Pr->SiS_VBType & VB_NoLCD) { /* For 301B-DH */ + tempah = 0x30; tempah2 = 0xc0; + tempbl = 0xcf; tempbl2 = 0x3f; + if(SiS_Pr->SiS_TVBlue == 0) { + tempah = tempah2 = 0x00; + } else if(SiS_Pr->SiS_TVBlue == -1) { + /* Set on 651/M650, clear on 315/650 */ + if(!(IS_SIS65x)) /* (bridgerev != 0xb0) */ { + tempah = tempah2 = 0x00; + } + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,tempbl,tempah); + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,tempbl2,tempah2); } else { - tempah = 0x30; tempah2 = 0xc0; /* For 30xB (and 301BDH rev b1) */ + tempah = 0x30; tempah2 = 0xc0; /* For 30xB, 301C */ tempbl = 0xcf; tempbl2 = 0x3f; if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { tempah = tempah2 = 0x00; - if(SiS_IsDualEdge(SiS_Pr, HwInfo)) { + if(SiS_IsDualEdge(SiS_Pr)) { tempbl = tempbl2 = 0xff; } } @@ -2676,23 +2713,23 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x23,0x7f,tempah); } else { tempah = 0x00; - tempbl = 0x7f; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - tempbl = 0xff; - if(!(SiS_IsDualEdge(SiS_Pr, HwInfo))) tempah = 0x80; - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x23,tempbl,tempah); + tempbl = 0x7f; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + tempbl = 0xff; + if(!(SiS_IsDualEdge(SiS_Pr))) tempah = 0x80; + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x23,tempbl,tempah); } #endif /* SIS315H */ - } else if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + } else if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { #ifdef SIS300 - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x21,0x3f); + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x21,0x3f); - if((SiS_Pr->SiS_VBInfo & DisableCRT2Display) || - ((SiS_Pr->SiS_VBType & VB_NoLCD) && + if((SiS_Pr->SiS_VBInfo & DisableCRT2Display) || + ((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD))) { SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x23,0x7F); } else { @@ -2702,9 +2739,9 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x0D,0x80); - if(SiS_Pr->SiS_VBType & VB_SIS301C) { + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x0D,0x80); + if(SiS_Pr->SiS_VBType & VB_SIS30xCLV) { SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x3A,0xC0); } } @@ -2712,16 +2749,16 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } else { /* LVDS */ #ifdef SIS315H - if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->ChipType >= SIS_315H) { - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - tempah = 0x04; + tempah = 0x04; tempbl = 0xfb; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - tempah = 0x00; - if(SiS_IsDualEdge(SiS_Pr, HwInfo)) tempbl = 0xff; - } + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + tempah = 0x00; + if(SiS_IsDualEdge(SiS_Pr)) tempbl = 0xff; + } SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,tempbl,tempah); if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { @@ -2730,7 +2767,7 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); - } else if(HwInfo->jChipType == SIS_550) { + } else if(SiS_Pr->ChipType == SIS_550) { SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); @@ -2748,212 +2785,120 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /* GET RESOLUTION DATA */ /*********************************************/ -USHORT -SiS_GetResInfo(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex) +unsigned short +SiS_GetResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - if(ModeNo <= 0x13) return((USHORT)SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo); - else return((USHORT)SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO); + if(ModeNo <= 0x13) + return ((unsigned short)SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo); + else + return ((unsigned short)SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO); } static void -SiS_GetCRT2ResInfo(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo) +SiS_GetCRT2ResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - USHORT xres,yres,modeflag=0,resindex; + unsigned short xres, yres, modeflag=0, resindex; - if(SiS_Pr->UseCustomMode) { - xres = SiS_Pr->CHDisplay; - if(SiS_Pr->CModeFlag & HalfDCLK) xres *= 2; - SiS_Pr->SiS_VGAHDE = SiS_Pr->SiS_HDE = xres; - yres = SiS_Pr->CVDisplay; - if(SiS_Pr->CModeFlag & DoubleScanMode) yres *= 2; - SiS_Pr->SiS_VGAVDE = SiS_Pr->SiS_VDE = yres; - return; - } - - resindex = SiS_GetResInfo(SiS_Pr,ModeNo,ModeIdIndex); + if(SiS_Pr->UseCustomMode) { + xres = SiS_Pr->CHDisplay; + if(SiS_Pr->CModeFlag & HalfDCLK) xres <<= 1; + SiS_Pr->SiS_VGAHDE = SiS_Pr->SiS_HDE = xres; + /* DoubleScanMode-check done in CheckCalcCustomMode()! */ + SiS_Pr->SiS_VGAVDE = SiS_Pr->SiS_VDE = SiS_Pr->CVDisplay; + return; + } - if(ModeNo <= 0x13) { - xres = SiS_Pr->SiS_StResInfo[resindex].HTotal; - yres = SiS_Pr->SiS_StResInfo[resindex].VTotal; - } else { - xres = SiS_Pr->SiS_ModeResInfo[resindex].HTotal; - yres = SiS_Pr->SiS_ModeResInfo[resindex].VTotal; - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - } + resindex = SiS_GetResInfo(SiS_Pr,ModeNo,ModeIdIndex); - if(!SiS_Pr->SiS_IF_DEF_DSTN && !SiS_Pr->SiS_IF_DEF_FSTN) { + if(ModeNo <= 0x13) { + xres = SiS_Pr->SiS_StResInfo[resindex].HTotal; + yres = SiS_Pr->SiS_StResInfo[resindex].VTotal; + } else { + xres = SiS_Pr->SiS_ModeResInfo[resindex].HTotal; + yres = SiS_Pr->SiS_ModeResInfo[resindex].VTotal; + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + } - if((HwInfo->jChipType >= SIS_315H) && (SiS_Pr->SiS_IF_DEF_LVDS == 1)) { - if((ModeNo != 0x03) && (SiS_Pr->SiS_SetFlag & SetDOSMode)) { - if(yres == 350) yres = 400; - } - if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x3a) & 0x01) { - if(ModeNo == 0x12) yres = 400; - } - } + if(!SiS_Pr->SiS_IF_DEF_DSTN && !SiS_Pr->SiS_IF_DEF_FSTN) { - if(modeflag & HalfDCLK) xres *= 2; - if(modeflag & DoubleScanMode) yres *= 2; + if((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->SiS_IF_DEF_LVDS == 1)) { + if((ModeNo != 0x03) && (SiS_Pr->SiS_SetFlag & SetDOSMode)) { + if(yres == 350) yres = 400; + } + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x3a) & 0x01) { + if(ModeNo == 0x12) yres = 400; + } + } - } + if(modeflag & HalfDCLK) xres <<= 1; + if(modeflag & DoubleScanMode) yres <<= 1; - if((SiS_Pr->SiS_VBType & VB_SISVB) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) { + } -#if 0 - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCDA | SetCRT2ToLCD | SetCRT2ToHiVision)) { - if(xres == 720) xres = 640; - } -#endif + if((SiS_Pr->SiS_VBType & VB_SISVB) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - switch(SiS_Pr->SiS_LCDResInfo) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + switch(SiS_Pr->SiS_LCDResInfo) { case Panel_1024x768: if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { - if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { - if(yres == 350) yres = 357; - if(yres == 400) yres = 420; - if(yres == 480) yres = 525; - } - } + if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { + if(yres == 350) yres = 357; + if(yres == 400) yres = 420; + if(yres == 480) yres = 525; + } + } break; case Panel_1280x1024: if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { /* BIOS bug - does this regardless of scaling */ - if(yres == 400) yres = 405; + if(yres == 400) yres = 405; + } + if(yres == 350) yres = 360; + if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { + if(yres == 360) yres = 375; } - if(yres == 350) yres = 360; - if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { - if(yres == 360) yres = 375; - } break; case Panel_1600x1200: if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { - if(yres == 1024) yres = 1056; - } + if(yres == 1024) yres = 1056; + } break; - } - } + } + } - } else { + } else { - if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToHiVision)) { - if(xres == 720) xres = 640; - } - } else if(xres == 720) xres = 640; + if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToHiVision)) { + if(xres == 720) xres = 640; + } + } else if(xres == 720) xres = 640; - if(SiS_Pr->SiS_SetFlag & SetDOSMode) { - yres = 400; - if(HwInfo->jChipType >= SIS_315H) { - if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x17) & 0x80) yres = 480; - } else { - if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x80) yres = 480; - } - if(SiS_Pr->SiS_IF_DEF_DSTN || SiS_Pr->SiS_IF_DEF_FSTN) yres = 480; - } + if(SiS_Pr->SiS_SetFlag & SetDOSMode) { + yres = 400; + if(SiS_Pr->ChipType >= SIS_315H) { + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x17) & 0x80) yres = 480; + } else { + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x80) yres = 480; + } + if(SiS_Pr->SiS_IF_DEF_DSTN || SiS_Pr->SiS_IF_DEF_FSTN) yres = 480; + } - } - SiS_Pr->SiS_VGAHDE = SiS_Pr->SiS_HDE = xres; - SiS_Pr->SiS_VGAVDE = SiS_Pr->SiS_VDE = yres; + } + SiS_Pr->SiS_VGAHDE = SiS_Pr->SiS_HDE = xres; + SiS_Pr->SiS_VGAVDE = SiS_Pr->SiS_VDE = yres; } /*********************************************/ /* GET CRT2 TIMING DATA */ /*********************************************/ -static BOOLEAN -SiS_GetLVDSCRT1Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, USHORT *ResIndex, - USHORT *DisplayType) - { - USHORT modeflag=0; - - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) return FALSE; - } - } else if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) return FALSE; - } else - return FALSE; - - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - (*ResIndex) = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - (*ResIndex) = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; - } - - (*ResIndex) &= 0x3F; - - if((SiS_Pr->SiS_IF_DEF_CH70xx) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { - (*DisplayType) = 18; - if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) (*DisplayType)++; - if(SiS_Pr->SiS_TVMode & TVSetPAL) { - (*DisplayType) += 2; - if(SiS_Pr->SiS_ModeType > ModeVGA) { - if(SiS_Pr->SiS_CHSOverScan) (*DisplayType) = 99; - } - if(SiS_Pr->SiS_TVMode & TVSetPALM) { - (*DisplayType) = 18; /* PALM uses NTSC data */ - if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) (*DisplayType)++; - } else if(SiS_Pr->SiS_TVMode & TVSetPALN) { - (*DisplayType) = 20; /* PALN uses PAL data */ - if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) (*DisplayType)++; - } - } - } else { - switch(SiS_Pr->SiS_LCDResInfo) { - case Panel_640x480: (*DisplayType) = 50; break; - case Panel_640x480_2: (*DisplayType) = 52; break; - case Panel_640x480_3: (*DisplayType) = 54; break; - case Panel_800x600: (*DisplayType) = 0; break; - case Panel_1024x600: (*DisplayType) = 23; break; - case Panel_1024x768: (*DisplayType) = 4; break; - case Panel_1152x768: (*DisplayType) = 27; break; - case Panel_1280x768: (*DisplayType) = 40; break; - case Panel_1280x1024: (*DisplayType) = 8; break; - case Panel_1400x1050: (*DisplayType) = 14; break; - case Panel_1600x1200: (*DisplayType) = 36; break; - default: return FALSE; - } - - if(modeflag & HalfDCLK) (*DisplayType)++; - - switch(SiS_Pr->SiS_LCDResInfo) { - case Panel_640x480: - case Panel_640x480_2: - case Panel_640x480_3: - break; - default: - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) (*DisplayType) += 2; - } - - if(SiS_Pr->SiS_LCDInfo & LCDPass11) { - (*DisplayType) = 12; - if(modeflag & HalfDCLK) (*DisplayType)++; - } - } - -#if 0 - if(SiS_Pr->SiS_IF_DEF_FSTN) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel320x480){ - (*DisplayType) = 22; - } - } -#endif - - return TRUE; -} - static void -SiS_GetCRT2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *CRT2Index,USHORT *ResIndex, - PSIS_HW_INFO HwInfo) +SiS_GetCRT2Ptr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex, unsigned short *CRT2Index, + unsigned short *ResIndex) { - USHORT tempbx=0,tempal=0,resinfo=0; + unsigned short tempbx=0, tempal=0, resinfo=0; if(ModeNo <= 0x13) { tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; @@ -2966,18 +2911,20 @@ SiS_GetCRT2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { /* LCD */ - tempbx = SiS_Pr->SiS_LCDResInfo; + tempbx = SiS_Pr->SiS_LCDResInfo; if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx += 32; + /* patch index */ if(SiS_Pr->SiS_LCDResInfo == Panel_1680x1050) { if (resinfo == SIS_RI_1280x800) tempal = 9; else if(resinfo == SIS_RI_1400x1050) tempal = 11; } else if((SiS_Pr->SiS_LCDResInfo == Panel_1280x800) || - (SiS_Pr->SiS_LCDResInfo == Panel_1280x800_2)) { + (SiS_Pr->SiS_LCDResInfo == Panel_1280x800_2) || + (SiS_Pr->SiS_LCDResInfo == Panel_1280x854)) { if (resinfo == SIS_RI_1280x768) tempal = 9; } - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { /* Pass 1:1 only (center-screen handled outside) */ /* This is never called for the panel's native resolution */ /* since Pass1:1 will not be set in this case */ @@ -2991,8 +2938,8 @@ SiS_GetCRT2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) { if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { - tempbx = 200; - if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx++; + tempbx = 200; + if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx++; } } } @@ -3000,23 +2947,23 @@ SiS_GetCRT2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, } else { /* TV */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - /* if(SiS_Pr->SiS_VGAVDE > 480) SiS_Pr->SiS_TVMode &= (~TVSetTVSimuMode); */ - tempbx = 2; - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + /* if(SiS_Pr->SiS_VGAVDE > 480) SiS_Pr->SiS_TVMode &= (~TVSetTVSimuMode); */ + tempbx = 2; + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { tempbx = 13; - if(!(SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) tempbx = 14; - } + if(!(SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) tempbx = 14; + } } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { - if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) tempbx = 7; - else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) tempbx = 6; - else tempbx = 5; - if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) tempbx += 5; - } else { - if(SiS_Pr->SiS_TVMode & TVSetPAL) tempbx = 3; - else tempbx = 4; - if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) tempbx += 5; - } + if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) tempbx = 7; + else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) tempbx = 6; + else tempbx = 5; + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) tempbx += 5; + } else { + if(SiS_Pr->SiS_TVMode & TVSetPAL) tempbx = 3; + else tempbx = 4; + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) tempbx += 5; + } } @@ -3024,26 +2971,34 @@ SiS_GetCRT2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, if(ModeNo > 0x13) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision) { - if(tempal == 6) tempal = 7; - if((resinfo == SIS_RI_720x480) || - (resinfo == SIS_RI_720x576) || - (resinfo == SIS_RI_768x576)) { + switch(resinfo) { + case SIS_RI_720x480: tempal = 6; - if(SiS_Pr->SiS_TVMode & (TVSetPAL | TVSetPALN)) { - if(resinfo == SIS_RI_720x480) tempal = 9; + if(SiS_Pr->SiS_TVMode & (TVSetPAL | TVSetPALN)) tempal = 9; + break; + case SIS_RI_720x576: + case SIS_RI_768x576: + case SIS_RI_1024x576: /* Not in NTSC or YPBPR mode (except 1080i)! */ + tempal = 6; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { + if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) tempal = 8; } - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { - if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) { - if(resinfo == SIS_RI_1024x768) tempal = 8; + break; + case SIS_RI_800x480: + tempal = 4; + break; + case SIS_RI_512x384: + case SIS_RI_1024x768: + tempal = 7; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { + if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) tempal = 8; } - if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { - if((resinfo == SIS_RI_720x576) || - (resinfo == SIS_RI_768x576)) { - tempal = 8; - } - if(resinfo == SIS_RI_1280x720) tempal = 9; + break; + case SIS_RI_1280x720: + if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { + if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) tempal = 9; } + break; } } } @@ -3056,65 +3011,60 @@ SiS_GetCRT2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, tempbx = 0; if((SiS_Pr->SiS_IF_DEF_CH70xx) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { - tempbx = 10; - if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; - if(SiS_Pr->SiS_TVMode & TVSetPAL) { - tempbx += 2; + tempbx = 90; + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + tempbx = 92; if(SiS_Pr->SiS_ModeType > ModeVGA) { if(SiS_Pr->SiS_CHSOverScan) tempbx = 99; } - if(SiS_Pr->SiS_TVMode & TVSetPALM) { - tempbx = 90; - if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; - } else if(SiS_Pr->SiS_TVMode & TVSetPALN) { - tempbx = 92; - if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; - } - } + if(SiS_Pr->SiS_TVMode & TVSetPALM) tempbx = 94; + else if(SiS_Pr->SiS_TVMode & TVSetPALN) tempbx = 96; + } + if(tempbx != 99) { + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx++; + } } else { - switch(SiS_Pr->SiS_LCDResInfo) { - case Panel_640x480: tempbx = 6; break; - case Panel_640x480_2: - case Panel_640x480_3: tempbx = 30; break; - case Panel_800x600: tempbx = 0; break; - case Panel_1024x600: tempbx = 15; break; - case Panel_1024x768: tempbx = 2; break; - case Panel_1152x768: tempbx = 17; break; - case Panel_1280x768: tempbx = 18; break; - case Panel_1280x1024: tempbx = 4; break; - case Panel_1400x1050: tempbx = 8; break; - case Panel_1600x1200: tempbx = 21; break; + switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_640x480: tempbx = 12; break; + case Panel_320x240_1: tempbx = 10; break; + case Panel_320x240_2: + case Panel_320x240_3: tempbx = 14; break; + case Panel_800x600: tempbx = 16; break; + case Panel_1024x600: tempbx = 18; break; + case Panel_1152x768: + case Panel_1024x768: tempbx = 20; break; + case Panel_1280x768: tempbx = 22; break; + case Panel_1280x1024: tempbx = 24; break; + case Panel_1400x1050: tempbx = 26; break; + case Panel_1600x1200: tempbx = 28; break; +#ifdef SIS300 case Panel_Barco1366: tempbx = 80; break; +#endif } switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_320x240_1: + case Panel_320x240_2: + case Panel_320x240_3: case Panel_640x480: - case Panel_640x480_2: - case Panel_640x480_3: break; default: if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; } - if(SiS_Pr->SiS_LCDInfo & LCDPass11) tempbx = 7; + if(SiS_Pr->SiS_LCDInfo & LCDPass11) tempbx = 30; +#ifdef SIS300 if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) { tempbx = 82; if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; - } else if(SiS_Pr->SiS_CustomT == CUT_PANEL848) { + } else if(SiS_Pr->SiS_CustomT == CUT_PANEL848 || SiS_Pr->SiS_CustomT == CUT_PANEL856) { tempbx = 84; if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; } - - if((SiS_Pr->SiS_CustomT != CUT_BARCO1366) && - (SiS_Pr->SiS_CustomT != CUT_PANEL848)) { - if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && - (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { - tempal = 0; - } - } +#endif } @@ -3124,12 +3074,11 @@ SiS_GetCRT2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, } static void -SiS_GetRAMDAC2DATA(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_INFO HwInfo) +SiS_GetRAMDAC2DATA(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) { - USHORT tempax=0,tempbx=0; - USHORT temp1=0,modeflag=0,tempcx=0; - USHORT index; + unsigned short tempax=0, tempbx=0, index, dotclock; + unsigned short temp1=0, modeflag=0, tempcx=0; SiS_Pr->SiS_RVBHCMAX = 1; SiS_Pr->SiS_RVBHCFACT = 1; @@ -3143,10 +3092,12 @@ SiS_GetRAMDAC2DATA(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, tempbx = SiS_Pr->SiS_StandTable[index].CRTC[6]; temp1 = SiS_Pr->SiS_StandTable[index].CRTC[7]; + dotclock = (modeflag & Charx8Dot) ? 8 : 9; + } else { modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; + index = SiS_GetRefCRT1CRTC(SiS_Pr, RefreshRateTableIndex, SiS_Pr->SiS_UseWideCRT2); tempax = SiS_Pr->SiS_CRT1Table[index].CR[0]; tempax |= (SiS_Pr->SiS_CRT1Table[index].CR[14] << 8); @@ -3158,22 +3109,16 @@ SiS_GetRAMDAC2DATA(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, tempbx |= tempcx; temp1 = SiS_Pr->SiS_CRT1Table[index].CR[7]; + dotclock = 8; + } if(temp1 & 0x01) tempbx |= 0x0100; if(temp1 & 0x20) tempbx |= 0x0200; tempax += 5; - - /* Charx8Dot is no more used (and assumed), so we set it */ - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - modeflag |= Charx8Dot; - } - - if(modeflag & Charx8Dot) tempax *= 8; - else tempax *= 9; - - if(modeflag & HalfDCLK) tempax <<= 1; + tempax *= dotclock; + if(modeflag & HalfDCLK) tempax <<= 1; tempbx++; @@ -3182,13 +3127,56 @@ SiS_GetRAMDAC2DATA(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, } static void -SiS_GetCRT2DataLVDS(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) +SiS_CalcPanelLinkTiming(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex) +{ + unsigned short ResIndex; + + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + if(SiS_Pr->UseCustomMode) { + ResIndex = SiS_Pr->CHTotal; + if(SiS_Pr->CModeFlag & HalfDCLK) ResIndex <<= 1; + SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = ResIndex; + SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = SiS_Pr->CVTotal; + } else { + if(ModeNo < 0x13) { + ResIndex = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + } else { + ResIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC_NS; + } + if(ResIndex == 0x09) { + if(SiS_Pr->Alternate1600x1200) ResIndex = 0x20; /* 1600x1200 LCDA */ + else if(SiS_Pr->SiS_IF_DEF_LVDS == 1) ResIndex = 0x21; /* 1600x1200 LVDS */ + } + SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_NoScaleData[ResIndex].VGAHT; + SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_NoScaleData[ResIndex].VGAVT; + SiS_Pr->SiS_HT = SiS_Pr->SiS_NoScaleData[ResIndex].LCDHT; + SiS_Pr->SiS_VT = SiS_Pr->SiS_NoScaleData[ResIndex].LCDVT; + } + } else { + SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = SiS_Pr->PanelHT; + SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = SiS_Pr->PanelVT; + } + } else { + /* This handles custom modes and custom panels */ + SiS_Pr->SiS_HDE = SiS_Pr->PanelXRes; + SiS_Pr->SiS_VDE = SiS_Pr->PanelYRes; + SiS_Pr->SiS_HT = SiS_Pr->PanelHT; + SiS_Pr->SiS_VT = SiS_Pr->PanelVT; + SiS_Pr->SiS_VGAHT = SiS_Pr->PanelHT - (SiS_Pr->PanelXRes - SiS_Pr->SiS_VGAHDE); + SiS_Pr->SiS_VGAVT = SiS_Pr->PanelVT - (SiS_Pr->PanelYRes - SiS_Pr->SiS_VGAVDE); + } +} + +static void +SiS_GetCRT2DataLVDS(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) { - USHORT CRT2Index, ResIndex; - const SiS_LVDSDataStruct *LVDSData = NULL; + unsigned short CRT2Index, ResIndex, backup; + const struct SiS_LVDSData *LVDSData = NULL; - SiS_GetCRT2ResInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + SiS_GetCRT2ResInfo(SiS_Pr, ModeNo, ModeIdIndex); if(SiS_Pr->SiS_VBType & VB_SISVB) { SiS_Pr->SiS_RVBHCMAX = 1; @@ -3199,133 +3187,94 @@ SiS_GetCRT2DataLVDS(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, SiS_Pr->SiS_RY2COE = 0; SiS_Pr->SiS_RY3COE = 0; SiS_Pr->SiS_RY4COE = 0; + SiS_Pr->SiS_RVBHRS2 = 0; } if((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { #ifdef SIS315H - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { - if(SiS_Pr->SiS_LCDInfo & LCDPass11) { - if(SiS_Pr->UseCustomMode) { - SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = SiS_Pr->CHTotal; - SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = SiS_Pr->CVTotal; - } else { - if(ModeNo < 0x13) { - ResIndex = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; - } else { - ResIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC_NS; - } - SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_NoScaleData[ResIndex].VGAHT; - SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_NoScaleData[ResIndex].VGAVT; - SiS_Pr->SiS_HT = SiS_Pr->SiS_NoScaleData[ResIndex].LCDHT; - SiS_Pr->SiS_VT = SiS_Pr->SiS_NoScaleData[ResIndex].LCDVT; - } - } else { - SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = SiS_Pr->PanelHT; - SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = SiS_Pr->PanelVT; - } - } else { - /* This handles custom modes and custom panels */ - SiS_Pr->SiS_HDE = SiS_Pr->PanelXRes; - SiS_Pr->SiS_VDE = SiS_Pr->PanelYRes; - SiS_Pr->SiS_HT = SiS_Pr->PanelHT; - SiS_Pr->SiS_VT = SiS_Pr->PanelVT; - SiS_Pr->SiS_VGAHT = SiS_Pr->PanelHT - (SiS_Pr->PanelXRes - SiS_Pr->SiS_VGAHDE); - SiS_Pr->SiS_VGAVT = SiS_Pr->PanelVT - (SiS_Pr->PanelYRes - SiS_Pr->SiS_VGAVDE); - } - - SiS_CalcLCDACRT1Timing(SiS_Pr,ModeNo,ModeIdIndex); - + SiS_CalcPanelLinkTiming(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); + SiS_CalcLCDACRT1Timing(SiS_Pr, ModeNo, ModeIdIndex); #endif } else { /* 301BDH needs LVDS Data */ + backup = SiS_Pr->SiS_IF_DEF_LVDS; if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { SiS_Pr->SiS_IF_DEF_LVDS = 1; } SiS_GetCRT2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, - &CRT2Index, &ResIndex, HwInfo); + &CRT2Index, &ResIndex); - /* 301BDH needs LVDS Data */ - if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { - SiS_Pr->SiS_IF_DEF_LVDS = 0; - } + SiS_Pr->SiS_IF_DEF_LVDS = backup; - switch (CRT2Index) { - case 0: LVDSData = SiS_Pr->SiS_LVDS800x600Data_1; break; - case 1: LVDSData = SiS_Pr->SiS_LVDS800x600Data_2; break; - case 2: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_1; break; - case 3: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_2; break; - case 4: LVDSData = SiS_Pr->SiS_LVDS1280x1024Data_1; break; - case 5: LVDSData = SiS_Pr->SiS_LVDS1280x1024Data_2; break; - case 6: LVDSData = SiS_Pr->SiS_LVDS640x480Data_1; break; - case 7: LVDSData = SiS_Pr->SiS_LVDSXXXxXXXData_1; break; - case 8: LVDSData = SiS_Pr->SiS_LVDS1400x1050Data_1; break; - case 9: LVDSData = SiS_Pr->SiS_LVDS1400x1050Data_2; break; - case 10: LVDSData = SiS_Pr->SiS_CHTVUNTSCData; break; - case 11: LVDSData = SiS_Pr->SiS_CHTVONTSCData; break; - case 12: LVDSData = SiS_Pr->SiS_CHTVUPALData; break; - case 13: LVDSData = SiS_Pr->SiS_CHTVOPALData; break; - case 14: LVDSData = SiS_Pr->SiS_LVDS320x480Data_1; break; - case 15: LVDSData = SiS_Pr->SiS_LVDS1024x600Data_1; break; - case 16: LVDSData = SiS_Pr->SiS_LVDS1024x600Data_2; break; - case 17: LVDSData = SiS_Pr->SiS_LVDS1152x768Data_1; break; - case 18: LVDSData = SiS_Pr->SiS_LVDS1152x768Data_2; break; - case 19: LVDSData = SiS_Pr->SiS_LVDS1280x768Data_1; break; - case 20: LVDSData = SiS_Pr->SiS_LVDS1280x768Data_2; break; - case 21: LVDSData = SiS_Pr->SiS_LVDS1600x1200Data_1; break; - case 22: LVDSData = SiS_Pr->SiS_LVDS1600x1200Data_2; break; - case 30: LVDSData = SiS_Pr->SiS_LVDS640x480Data_2; break; + switch(CRT2Index) { + case 10: LVDSData = SiS_Pr->SiS_LVDS320x240Data_1; break; + case 14: LVDSData = SiS_Pr->SiS_LVDS320x240Data_2; break; + case 12: LVDSData = SiS_Pr->SiS_LVDS640x480Data_1; break; + case 16: LVDSData = SiS_Pr->SiS_LVDS800x600Data_1; break; + case 18: LVDSData = SiS_Pr->SiS_LVDS1024x600Data_1; break; + case 20: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_1; break; +#ifdef SIS300 case 80: LVDSData = SiS_Pr->SiS_LVDSBARCO1366Data_1; break; case 81: LVDSData = SiS_Pr->SiS_LVDSBARCO1366Data_2; break; case 82: LVDSData = SiS_Pr->SiS_LVDSBARCO1024Data_1; break; - case 83: LVDSData = SiS_Pr->SiS_LVDSBARCO1024Data_2; break; case 84: LVDSData = SiS_Pr->SiS_LVDS848x480Data_1; break; case 85: LVDSData = SiS_Pr->SiS_LVDS848x480Data_2; break; - case 90: LVDSData = SiS_Pr->SiS_CHTVUPALMData; break; - case 91: LVDSData = SiS_Pr->SiS_CHTVOPALMData; break; - case 92: LVDSData = SiS_Pr->SiS_CHTVUPALNData; break; - case 93: LVDSData = SiS_Pr->SiS_CHTVOPALNData; break; - case 99: LVDSData = SiS_Pr->SiS_CHTVSOPALData; break; /* Super Overscan */ - default: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_1; break; +#endif + case 90: LVDSData = SiS_Pr->SiS_CHTVUNTSCData; break; + case 91: LVDSData = SiS_Pr->SiS_CHTVONTSCData; break; + case 92: LVDSData = SiS_Pr->SiS_CHTVUPALData; break; + case 93: LVDSData = SiS_Pr->SiS_CHTVOPALData; break; + case 94: LVDSData = SiS_Pr->SiS_CHTVUPALMData; break; + case 95: LVDSData = SiS_Pr->SiS_CHTVOPALMData; break; + case 96: LVDSData = SiS_Pr->SiS_CHTVUPALNData; break; + case 97: LVDSData = SiS_Pr->SiS_CHTVOPALNData; break; + case 99: LVDSData = SiS_Pr->SiS_CHTVSOPALData; break; } - SiS_Pr->SiS_VGAHT = (LVDSData+ResIndex)->VGAHT; - SiS_Pr->SiS_VGAVT = (LVDSData+ResIndex)->VGAVT; - SiS_Pr->SiS_HT = (LVDSData+ResIndex)->LCDHT; - SiS_Pr->SiS_VT = (LVDSData+ResIndex)->LCDVT; - - if(!(SiS_Pr->SiS_VBType & VB_SISVB)) { - if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { - if((!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) || (SiS_Pr->SiS_SetFlag & SetDOSMode)) { - SiS_Pr->SiS_HDE = SiS_Pr->PanelXRes; - SiS_Pr->SiS_VDE = SiS_Pr->PanelYRes; - if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { - if(ResIndex < 0x08) { - SiS_Pr->SiS_HDE = 1280; - SiS_Pr->SiS_VDE = 1024; - } - } - } + if(LVDSData) { + SiS_Pr->SiS_VGAHT = (LVDSData+ResIndex)->VGAHT; + SiS_Pr->SiS_VGAVT = (LVDSData+ResIndex)->VGAVT; + SiS_Pr->SiS_HT = (LVDSData+ResIndex)->LCDHT; + SiS_Pr->SiS_VT = (LVDSData+ResIndex)->LCDVT; + } else { + SiS_CalcPanelLinkTiming(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); + } + + if( (!(SiS_Pr->SiS_VBType & VB_SISVB)) && + (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && + (!(SiS_Pr->SiS_LCDInfo & LCDPass11)) ) { + if( (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) || + (SiS_Pr->SiS_SetFlag & SetDOSMode) ) { + SiS_Pr->SiS_HDE = SiS_Pr->PanelXRes; + SiS_Pr->SiS_VDE = SiS_Pr->PanelYRes; +#ifdef SIS300 + if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { + if(ResIndex < 0x08) { + SiS_Pr->SiS_HDE = 1280; + SiS_Pr->SiS_VDE = 1024; + } + } +#endif } } } } static void -SiS_GetCRT2Data301(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, - PSIS_HW_INFO HwInfo) -{ - UCHAR *ROMAddr = NULL; - USHORT tempax,tempbx,modeflag,romptr=0; - USHORT resinfo,CRT2Index,ResIndex; - const SiS_LCDDataStruct *LCDPtr = NULL; - const SiS_TVDataStruct *TVPtr = NULL; +SiS_GetCRT2Data301(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) +{ + unsigned char *ROMAddr = NULL; + unsigned short tempax, tempbx, modeflag, romptr=0; + unsigned short resinfo, CRT2Index, ResIndex; + const struct SiS_LCDData *LCDPtr = NULL; + const struct SiS_TVData *TVPtr = NULL; #ifdef SIS315H - SHORT resinfo661; + short resinfo661; #endif if(ModeNo <= 0x13) { @@ -3340,67 +3289,69 @@ SiS_GetCRT2Data301(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, #ifdef SIS315H resinfo661 = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].ROMMODEIDX661; if( (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && - (SiS_Pr->SiS_SetFlag & LCDVESATiming) && - (resinfo661 >= 0) && + (SiS_Pr->SiS_SetFlag & LCDVESATiming) && + (resinfo661 >= 0) && (SiS_Pr->SiS_NeedRomModeData) ) { - if((ROMAddr = GetLCDStructPtr661(SiS_Pr, HwInfo))) { + if((ROMAddr = GetLCDStructPtr661(SiS_Pr))) { if((romptr = (SISGETROMW(21)))) { - romptr += (resinfo661 * 10); - ROMAddr = HwInfo->pjVirtualRomBase; + romptr += (resinfo661 * 10); + ROMAddr = SiS_Pr->VirtualRomBase; } } } #endif } - + SiS_Pr->SiS_NewFlickerMode = 0; SiS_Pr->SiS_RVBHRS = 50; SiS_Pr->SiS_RY1COE = 0; SiS_Pr->SiS_RY2COE = 0; SiS_Pr->SiS_RY3COE = 0; SiS_Pr->SiS_RY4COE = 0; + SiS_Pr->SiS_RVBHRS2 = 0; - SiS_GetCRT2ResInfo(SiS_Pr,ModeNo,ModeIdIndex,HwInfo); + SiS_GetCRT2ResInfo(SiS_Pr,ModeNo,ModeIdIndex); - if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC){ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { if(SiS_Pr->UseCustomMode) { - SiS_Pr->SiS_RVBHCMAX = 1; - SiS_Pr->SiS_RVBHCFACT = 1; - SiS_Pr->SiS_VGAHT = SiS_Pr->CHTotal; - SiS_Pr->SiS_VGAVT = SiS_Pr->CVTotal; - SiS_Pr->SiS_HT = SiS_Pr->CHTotal; - SiS_Pr->SiS_VT = SiS_Pr->CVTotal; + SiS_Pr->SiS_RVBHCMAX = 1; + SiS_Pr->SiS_RVBHCFACT = 1; SiS_Pr->SiS_HDE = SiS_Pr->SiS_VGAHDE; - SiS_Pr->SiS_VDE = SiS_Pr->SiS_VGAVDE; + SiS_Pr->SiS_VDE = SiS_Pr->SiS_VGAVDE; + + tempax = SiS_Pr->CHTotal; + if(modeflag & HalfDCLK) tempax <<= 1; + SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = tempax; + SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = SiS_Pr->CVTotal; } else { - SiS_GetRAMDAC2DATA(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + SiS_GetRAMDAC2DATA(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); } } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { SiS_GetCRT2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &CRT2Index,&ResIndex,HwInfo); + &CRT2Index,&ResIndex); switch(CRT2Index) { - case 2: TVPtr = SiS_Pr->SiS_ExtHiTVData; break; - case 3: TVPtr = SiS_Pr->SiS_ExtPALData; break; - case 4: TVPtr = SiS_Pr->SiS_ExtNTSCData; break; - case 5: TVPtr = SiS_Pr->SiS_Ext525iData; break; - case 6: TVPtr = SiS_Pr->SiS_Ext525pData; break; - case 7: TVPtr = SiS_Pr->SiS_Ext750pData; break; - case 8: TVPtr = SiS_Pr->SiS_StPALData; break; - case 9: TVPtr = SiS_Pr->SiS_StNTSCData; break; - case 10: TVPtr = SiS_Pr->SiS_St525iData; break; - case 11: TVPtr = SiS_Pr->SiS_St525pData; break; - case 12: TVPtr = SiS_Pr->SiS_St750pData; break; - case 13: TVPtr = SiS_Pr->SiS_St1HiTVData; break; - case 14: TVPtr = SiS_Pr->SiS_St2HiTVData; break; - default: TVPtr = SiS_Pr->SiS_StPALData; break; + case 2: TVPtr = SiS_Pr->SiS_ExtHiTVData; break; + case 3: TVPtr = SiS_Pr->SiS_ExtPALData; break; + case 4: TVPtr = SiS_Pr->SiS_ExtNTSCData; break; + case 5: TVPtr = SiS_Pr->SiS_Ext525iData; break; + case 6: TVPtr = SiS_Pr->SiS_Ext525pData; break; + case 7: TVPtr = SiS_Pr->SiS_Ext750pData; break; + case 8: TVPtr = SiS_Pr->SiS_StPALData; break; + case 9: TVPtr = SiS_Pr->SiS_StNTSCData; break; + case 10: TVPtr = SiS_Pr->SiS_St525iData; break; + case 11: TVPtr = SiS_Pr->SiS_St525pData; break; + case 12: TVPtr = SiS_Pr->SiS_St750pData; break; + case 13: TVPtr = SiS_Pr->SiS_St1HiTVData; break; + case 14: TVPtr = SiS_Pr->SiS_St2HiTVData; break; + default: TVPtr = SiS_Pr->SiS_StPALData; break; } SiS_Pr->SiS_RVBHCMAX = (TVPtr+ResIndex)->RVBHCMAX; @@ -3409,73 +3360,77 @@ SiS_GetCRT2Data301(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, SiS_Pr->SiS_VGAVT = (TVPtr+ResIndex)->VGAVT; SiS_Pr->SiS_HDE = (TVPtr+ResIndex)->TVHDE; SiS_Pr->SiS_VDE = (TVPtr+ResIndex)->TVVDE; - SiS_Pr->SiS_RVBHRS = (TVPtr+ResIndex)->RVBHRS; - SiS_Pr->SiS_NewFlickerMode = (TVPtr+ResIndex)->FlickerMode; + SiS_Pr->SiS_RVBHRS2 = (TVPtr+ResIndex)->RVBHRS2 & 0x0fff; if(modeflag & HalfDCLK) { - SiS_Pr->SiS_RVBHRS = (TVPtr+ResIndex)->HALFRVBHRS; + SiS_Pr->SiS_RVBHRS = (TVPtr+ResIndex)->HALFRVBHRS; + if(SiS_Pr->SiS_RVBHRS2) { + SiS_Pr->SiS_RVBHRS2 = ((SiS_Pr->SiS_RVBHRS2 + 3) >> 1) - 3; + tempax = ((TVPtr+ResIndex)->RVBHRS2 >> 12) & 0x07; + if((TVPtr+ResIndex)->RVBHRS2 & 0x8000) SiS_Pr->SiS_RVBHRS2 -= tempax; + else SiS_Pr->SiS_RVBHRS2 += tempax; + } + } else { + SiS_Pr->SiS_RVBHRS = (TVPtr+ResIndex)->RVBHRS; } + SiS_Pr->SiS_NewFlickerMode = ((TVPtr+ResIndex)->FlickerMode) << 7; if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - if((resinfo == SIS_RI_1024x768) || - (resinfo == SIS_RI_1280x1024) || - (resinfo == SIS_RI_1280x720)) { + if((resinfo == SIS_RI_960x600) || + (resinfo == SIS_RI_1024x768) || + (resinfo == SIS_RI_1280x1024) || + (resinfo == SIS_RI_1280x720)) { SiS_Pr->SiS_NewFlickerMode = 0x40; } - if(SiS_Pr->SiS_VGAVDE == 350) SiS_Pr->SiS_TVMode |= TVSetTVSimuMode; + if(SiS_Pr->SiS_VGAVDE == 350) SiS_Pr->SiS_TVMode |= TVSetTVSimuMode; - SiS_Pr->SiS_HT = ExtHiTVHT; - SiS_Pr->SiS_VT = ExtHiTVVT; - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { - SiS_Pr->SiS_HT = StHiTVHT; - SiS_Pr->SiS_VT = StHiTVVT; -#if 0 - if(!(modeflag & Charx8Dot)) { - SiS_Pr->SiS_HT = StHiTextTVHT; - SiS_Pr->SiS_VT = StHiTextTVVT; - } -#endif - } - } + SiS_Pr->SiS_HT = ExtHiTVHT; + SiS_Pr->SiS_VT = ExtHiTVVT; + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { + SiS_Pr->SiS_HT = StHiTVHT; + SiS_Pr->SiS_VT = StHiTVVT; + } + } } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { - if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { - SiS_Pr->SiS_HT = 1650; - SiS_Pr->SiS_VT = 750; + if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { + SiS_Pr->SiS_HT = 1650; + SiS_Pr->SiS_VT = 750; } else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) { SiS_Pr->SiS_HT = NTSCHT; + if(SiS_Pr->SiS_TVMode & TVSet525p1024) SiS_Pr->SiS_HT = NTSC2HT; SiS_Pr->SiS_VT = NTSCVT; - } else { - SiS_Pr->SiS_HT = NTSCHT; + } else { + SiS_Pr->SiS_HT = NTSCHT; if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) SiS_Pr->SiS_HT = NTSC2HT; - SiS_Pr->SiS_VT = NTSCVT; - } + SiS_Pr->SiS_VT = NTSCVT; + } } else { - SiS_Pr->SiS_RY1COE = (TVPtr+ResIndex)->RY1COE; - SiS_Pr->SiS_RY2COE = (TVPtr+ResIndex)->RY2COE; - SiS_Pr->SiS_RY3COE = (TVPtr+ResIndex)->RY3COE; - SiS_Pr->SiS_RY4COE = (TVPtr+ResIndex)->RY4COE; + SiS_Pr->SiS_RY1COE = (TVPtr+ResIndex)->RY1COE; + SiS_Pr->SiS_RY2COE = (TVPtr+ResIndex)->RY2COE; + SiS_Pr->SiS_RY3COE = (TVPtr+ResIndex)->RY3COE; + SiS_Pr->SiS_RY4COE = (TVPtr+ResIndex)->RY4COE; - if(modeflag & HalfDCLK) { - SiS_Pr->SiS_RY1COE = 0x00; - SiS_Pr->SiS_RY2COE = 0xf4; - SiS_Pr->SiS_RY3COE = 0x10; - SiS_Pr->SiS_RY4COE = 0x38; - } + if(modeflag & HalfDCLK) { + SiS_Pr->SiS_RY1COE = 0x00; + SiS_Pr->SiS_RY2COE = 0xf4; + SiS_Pr->SiS_RY3COE = 0x10; + SiS_Pr->SiS_RY4COE = 0x38; + } - if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { - SiS_Pr->SiS_HT = NTSCHT; + if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { + SiS_Pr->SiS_HT = NTSCHT; if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) SiS_Pr->SiS_HT = NTSC2HT; - SiS_Pr->SiS_VT = NTSCVT; - } else { - SiS_Pr->SiS_HT = PALHT; - SiS_Pr->SiS_VT = PALVT; - } + SiS_Pr->SiS_VT = NTSCVT; + } else { + SiS_Pr->SiS_HT = PALHT; + SiS_Pr->SiS_VT = PALVT; + } } @@ -3486,42 +3441,53 @@ SiS_GetCRT2Data301(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, if(SiS_Pr->UseCustomMode) { - SiS_Pr->SiS_VGAHT = SiS_Pr->CHTotal; - SiS_Pr->SiS_VGAVT = SiS_Pr->CVTotal; - SiS_Pr->SiS_HT = SiS_Pr->CHTotal; - SiS_Pr->SiS_VT = SiS_Pr->CVTotal; SiS_Pr->SiS_HDE = SiS_Pr->SiS_VGAHDE; - SiS_Pr->SiS_VDE = SiS_Pr->SiS_VGAVDE; + SiS_Pr->SiS_VDE = SiS_Pr->SiS_VGAVDE; + + tempax = SiS_Pr->CHTotal; + if(modeflag & HalfDCLK) tempax <<= 1; + SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = tempax; + SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = SiS_Pr->CVTotal; } else { - BOOLEAN gotit = FALSE; + BOOLEAN gotit = FALSE; - if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { + if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { - SiS_Pr->SiS_VGAHT = SiS_Pr->PanelHT; - SiS_Pr->SiS_VGAVT = SiS_Pr->PanelVT; - SiS_Pr->SiS_HT = SiS_Pr->PanelHT; - SiS_Pr->SiS_VT = SiS_Pr->PanelVT; + SiS_Pr->SiS_VGAHT = SiS_Pr->PanelHT; + SiS_Pr->SiS_VGAVT = SiS_Pr->PanelVT; + SiS_Pr->SiS_HT = SiS_Pr->PanelHT; + SiS_Pr->SiS_VT = SiS_Pr->PanelVT; gotit = TRUE; } else if( (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) && (romptr) && (ROMAddr) ) { #ifdef SIS315H SiS_Pr->SiS_RVBHCMAX = ROMAddr[romptr]; - SiS_Pr->SiS_RVBHCFACT = ROMAddr[romptr+1]; - SiS_Pr->SiS_VGAHT = ROMAddr[romptr+2] | ((ROMAddr[romptr+3] & 0x0f) << 8); - SiS_Pr->SiS_VGAVT = ROMAddr[romptr+4] | ((ROMAddr[romptr+3] & 0xf0) << 4); - SiS_Pr->SiS_HT = ROMAddr[romptr+5] | ((ROMAddr[romptr+6] & 0x0f) << 8); - SiS_Pr->SiS_VT = ROMAddr[romptr+7] | ((ROMAddr[romptr+6] & 0xf0) << 4); + SiS_Pr->SiS_RVBHCFACT = ROMAddr[romptr+1]; + SiS_Pr->SiS_VGAHT = ROMAddr[romptr+2] | ((ROMAddr[romptr+3] & 0x0f) << 8); + SiS_Pr->SiS_VGAVT = (ROMAddr[romptr+4] << 4) | ((ROMAddr[romptr+3] & 0xf0) >> 4); + SiS_Pr->SiS_HT = ROMAddr[romptr+5] | ((ROMAddr[romptr+6] & 0x0f) << 8); + SiS_Pr->SiS_VT = (ROMAddr[romptr+7] << 4) | ((ROMAddr[romptr+6] & 0xf0) >> 4); + SiS_Pr->SiS_RVBHRS2 = ROMAddr[romptr+8] | ((ROMAddr[romptr+9] & 0x0f) << 8); + if((SiS_Pr->SiS_RVBHRS2) && (modeflag & HalfDCLK)) { + SiS_Pr->SiS_RVBHRS2 = ((SiS_Pr->SiS_RVBHRS2 + 3) >> 1) - 3; + tempax = (ROMAddr[romptr+9] >> 4) & 0x07; + if(ROMAddr[romptr+9] & 0x80) SiS_Pr->SiS_RVBHRS2 -= tempax; + else SiS_Pr->SiS_RVBHRS2 += tempax; + } if(SiS_Pr->SiS_VGAHT) gotit = TRUE; else { SiS_Pr->SiS_LCDInfo |= DontExpandLCD; SiS_Pr->SiS_LCDInfo &= ~LCDPass11; + SiS_Pr->SiS_RVBHCMAX = 1; + SiS_Pr->SiS_RVBHCFACT = 1; SiS_Pr->SiS_VGAHT = SiS_Pr->PanelHT; - SiS_Pr->SiS_VGAVT = SiS_Pr->PanelVT; - SiS_Pr->SiS_HT = SiS_Pr->PanelHT; - SiS_Pr->SiS_VT = SiS_Pr->PanelVT; + SiS_Pr->SiS_VGAVT = SiS_Pr->PanelVT; + SiS_Pr->SiS_HT = SiS_Pr->PanelHT; + SiS_Pr->SiS_VT = SiS_Pr->PanelVT; + SiS_Pr->SiS_RVBHRS2 = 0; gotit = TRUE; } #endif @@ -3530,28 +3496,30 @@ SiS_GetCRT2Data301(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, if(!gotit) { - SiS_GetCRT2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &CRT2Index,&ResIndex,HwInfo); + SiS_GetCRT2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex, + &CRT2Index,&ResIndex); - switch(CRT2Index) { + switch(CRT2Index) { case Panel_1024x768 : LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data; break; case Panel_1024x768 + 32: LCDPtr = SiS_Pr->SiS_St2LCD1024x768Data; break; case Panel_1280x720 : case Panel_1280x720 + 32: LCDPtr = SiS_Pr->SiS_LCD1280x720Data; break; case Panel_1280x768_2 : LCDPtr = SiS_Pr->SiS_ExtLCD1280x768_2Data; break; - case Panel_1280x768_2+ 32: LCDPtr = SiS_Pr->SiS_StLCD1280x768_2Data; break; + case Panel_1280x768_2+ 32: LCDPtr = SiS_Pr->SiS_StLCD1280x768_2Data; break; case Panel_1280x800 : case Panel_1280x800 + 32: LCDPtr = SiS_Pr->SiS_LCD1280x800Data; break; case Panel_1280x800_2 : case Panel_1280x800_2+ 32: LCDPtr = SiS_Pr->SiS_LCD1280x800_2Data; break; + case Panel_1280x854 : + case Panel_1280x854 + 32: LCDPtr = SiS_Pr->SiS_LCD1280x854Data; break; case Panel_1280x960 : case Panel_1280x960 + 32: LCDPtr = SiS_Pr->SiS_LCD1280x960Data; break; - case Panel_1280x1024 : LCDPtr = SiS_Pr->SiS_ExtLCD1280x1024Data; break; - case Panel_1280x1024 + 32: LCDPtr = SiS_Pr->SiS_St2LCD1280x1024Data; break; - case Panel_1400x1050 : LCDPtr = SiS_Pr->SiS_ExtLCD1400x1050Data; break; - case Panel_1400x1050 + 32: LCDPtr = SiS_Pr->SiS_StLCD1400x1050Data; break; - case Panel_1600x1200 : LCDPtr = SiS_Pr->SiS_ExtLCD1600x1200Data; break; - case Panel_1600x1200 + 32: LCDPtr = SiS_Pr->SiS_StLCD1600x1200Data; break; + case Panel_1280x1024 : LCDPtr = SiS_Pr->SiS_ExtLCD1280x1024Data; break; + case Panel_1280x1024 + 32: LCDPtr = SiS_Pr->SiS_St2LCD1280x1024Data; break; + case Panel_1400x1050 : LCDPtr = SiS_Pr->SiS_ExtLCD1400x1050Data; break; + case Panel_1400x1050 + 32: LCDPtr = SiS_Pr->SiS_StLCD1400x1050Data; break; + case Panel_1600x1200 : LCDPtr = SiS_Pr->SiS_ExtLCD1600x1200Data; break; + case Panel_1600x1200 + 32: LCDPtr = SiS_Pr->SiS_StLCD1600x1200Data; break; case Panel_1680x1050 : case Panel_1680x1050 + 32: LCDPtr = SiS_Pr->SiS_LCD1680x1050Data; break; case 100 : LCDPtr = SiS_Pr->SiS_NoScaleData; break; @@ -3559,271 +3527,340 @@ SiS_GetCRT2Data301(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, case 200 : LCDPtr = SiS310_ExtCompaq1280x1024Data; break; case 201 : LCDPtr = SiS_Pr->SiS_St2LCD1280x1024Data; break; #endif - default : LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data; break; - } + default : LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data; break; + } +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "GetCRT2Data: Index %d ResIndex %d\n", CRT2Index, ResIndex); + xf86DrvMsg(0, X_INFO, "GetCRT2Data: Index %d ResIndex %d\n", CRT2Index, ResIndex); +#endif #endif - SiS_Pr->SiS_RVBHCMAX = (LCDPtr+ResIndex)->RVBHCMAX; - SiS_Pr->SiS_RVBHCFACT = (LCDPtr+ResIndex)->RVBHCFACT; - SiS_Pr->SiS_VGAHT = (LCDPtr+ResIndex)->VGAHT; - SiS_Pr->SiS_VGAVT = (LCDPtr+ResIndex)->VGAVT; - SiS_Pr->SiS_HT = (LCDPtr+ResIndex)->LCDHT; - SiS_Pr->SiS_VT = (LCDPtr+ResIndex)->LCDVT; + SiS_Pr->SiS_RVBHCMAX = (LCDPtr+ResIndex)->RVBHCMAX; + SiS_Pr->SiS_RVBHCFACT = (LCDPtr+ResIndex)->RVBHCFACT; + SiS_Pr->SiS_VGAHT = (LCDPtr+ResIndex)->VGAHT; + SiS_Pr->SiS_VGAVT = (LCDPtr+ResIndex)->VGAVT; + SiS_Pr->SiS_HT = (LCDPtr+ResIndex)->LCDHT; + SiS_Pr->SiS_VT = (LCDPtr+ResIndex)->LCDVT; } tempax = SiS_Pr->PanelXRes; - tempbx = SiS_Pr->PanelYRes; + tempbx = SiS_Pr->PanelYRes; - if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { - if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { - if(HwInfo->jChipType < SIS_315H) { - if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 560; - else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640; - } - } else { - if (SiS_Pr->SiS_VGAVDE == 357) tempbx = 527; - else if(SiS_Pr->SiS_VGAVDE == 420) tempbx = 620; - else if(SiS_Pr->SiS_VGAVDE == 525) tempbx = 775; - else if(SiS_Pr->SiS_VGAVDE == 600) tempbx = 775; - else if(SiS_Pr->SiS_VGAVDE == 350) tempbx = 560; - else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640; - } - } else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x960) { - if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 700; - else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 800; - else if(SiS_Pr->SiS_VGAVDE == 1024) tempbx = 960; - } else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) { - if (SiS_Pr->SiS_VGAVDE == 360) tempbx = 768; - else if(SiS_Pr->SiS_VGAVDE == 375) tempbx = 800; - else if(SiS_Pr->SiS_VGAVDE == 405) tempbx = 864; - } else if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) { + switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_1024x768: + if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { + if(SiS_Pr->ChipType < SIS_315H) { + if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 560; + else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640; + } + } else { + if (SiS_Pr->SiS_VGAVDE == 357) tempbx = 527; + else if(SiS_Pr->SiS_VGAVDE == 420) tempbx = 620; + else if(SiS_Pr->SiS_VGAVDE == 525) tempbx = 775; + else if(SiS_Pr->SiS_VGAVDE == 600) tempbx = 775; + else if(SiS_Pr->SiS_VGAVDE == 350) tempbx = 560; + else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640; + } + break; + case Panel_1280x960: + if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 700; + else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 800; + else if(SiS_Pr->SiS_VGAVDE == 1024) tempbx = 960; + break; + case Panel_1280x1024: + if (SiS_Pr->SiS_VGAVDE == 360) tempbx = 768; + else if(SiS_Pr->SiS_VGAVDE == 375) tempbx = 800; + else if(SiS_Pr->SiS_VGAVDE == 405) tempbx = 864; + break; + case Panel_1600x1200: if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { - if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 875; - else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 1000; - } - } + if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 875; + else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 1000; + } + break; + } - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { - tempax = SiS_Pr->SiS_VGAHDE; - tempbx = SiS_Pr->SiS_VGAVDE; - } + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + tempax = SiS_Pr->SiS_VGAHDE; + tempbx = SiS_Pr->SiS_VGAVDE; + } - SiS_Pr->SiS_HDE = tempax; - SiS_Pr->SiS_VDE = tempbx; + SiS_Pr->SiS_HDE = tempax; + SiS_Pr->SiS_VDE = tempbx; } } } static void -SiS_GetCRT2Data(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) +SiS_GetCRT2Data(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) { - if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); - } else { - if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { - /* Need LVDS Data for LCD on 301B-DH */ - SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); - } else { - SiS_GetCRT2Data301(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); - } - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); + } else { + if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { + /* Need LVDS Data for LCD on 301B-DH */ + SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); + } else { + SiS_GetCRT2Data301(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); + } + } - } else { + } else { - SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); - } + } } /*********************************************/ /* GET LVDS DES (SKEW) DATA */ /*********************************************/ -static void -SiS_GetLVDSDesPtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, USHORT *PanelIndex, - USHORT *ResIndex, PSIS_HW_INFO HwInfo) +static const struct SiS_LVDSDes * +SiS_GetLVDSDesPtr(struct SiS_Private *SiS_Pr) { - USHORT modeflag; + const struct SiS_LVDSDes *PanelDesPtr = NULL; - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - (*ResIndex) = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - (*ResIndex) = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; - } +#ifdef SIS300 + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + + if(SiS_Pr->ChipType < SIS_315H) { + if(SiS_Pr->SiS_LCDTypeInfo == 4) { + if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { + PanelDesPtr = SiS_Pr->SiS_PanelType04_1a; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + PanelDesPtr = SiS_Pr->SiS_PanelType04_2a; + } + } else if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) { + PanelDesPtr = SiS_Pr->SiS_PanelType04_1b; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + PanelDesPtr = SiS_Pr->SiS_PanelType04_2b; + } + } + } + } + } +#endif + return PanelDesPtr; +} - (*ResIndex) &= 0x1F; - (*PanelIndex) = 0; +static void +SiS_GetLVDSDesData(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) +{ + unsigned short modeflag, ResIndex; + const struct SiS_LVDSDes *PanelDesPtr = NULL; - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - (*PanelIndex) = 50; - if((SiS_Pr->SiS_TVMode & TVSetPAL) && (!(SiS_Pr->SiS_TVMode & TVSetPALM))) (*PanelIndex) += 2; - if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) (*PanelIndex) += 1; - /* Nothing special needed for SOverscan */ - /* PALM uses NTSC data, PALN uses PAL data */ - } - } + SiS_Pr->SiS_LCDHDES = 0; + SiS_Pr->SiS_LCDVDES = 0; + /* Some special cases */ if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - *PanelIndex = SiS_Pr->SiS_LCDTypeInfo; - if(HwInfo->jChipType >= SIS_661) { - /* As long as we don's use the BIOS tables, we - * need to convert the TypeInfo as for 315 series - */ - (*PanelIndex) = SiS_Pr->SiS_LCDResInfo - 1; - } - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { - (*PanelIndex) += 16; - if(SiS_Pr->SiS_LCDInfo & LCDPass11) { - (*PanelIndex) = 32; - if(modeflag & HalfDCLK) (*PanelIndex)++; + + /* Trumpion */ + if(SiS_Pr->SiS_IF_DEF_TRUMPION) { + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { + if(SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) { + SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; + } } + return; } - } - if(SiS_Pr->SiS_SetFlag & SetDOSMode) { - if(SiS_Pr->SiS_LCDResInfo != Panel_640x480) { - (*ResIndex) = 7; - if(HwInfo->jChipType < SIS_315H) { - if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x80) (*ResIndex)++; - } + /* 640x480 on LVDS */ + if(SiS_Pr->ChipType < SIS_315H) { + if(SiS_Pr->SiS_LCDResInfo == Panel_640x480 && SiS_Pr->SiS_LCDTypeInfo == 3) { + SiS_Pr->SiS_LCDHDES = 8; + if (SiS_Pr->SiS_VGAVDE >= 480) SiS_Pr->SiS_LCDVDES = 512; + else if(SiS_Pr->SiS_VGAVDE >= 400) SiS_Pr->SiS_LCDVDES = 436; + else if(SiS_Pr->SiS_VGAVDE >= 350) SiS_Pr->SiS_LCDVDES = 440; + return; + } } - } -} - -static void -SiS_GetLVDSDesData(SiS_Private *SiS_Pr, USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) -{ - USHORT modeflag; - USHORT PanelIndex,ResIndex; - const SiS_LVDSDesStruct *PanelDesPtr = NULL; - SiS_Pr->SiS_LCDHDES = 0; - SiS_Pr->SiS_LCDVDES = 0; + } /* LCD */ if( (SiS_Pr->UseCustomMode) || (SiS_Pr->SiS_LCDResInfo == Panel_Custom) || (SiS_Pr->SiS_CustomT == CUT_PANEL848) || - ((SiS_Pr->SiS_VBType & VB_SISVB) && - (SiS_Pr->SiS_LCDInfo & DontExpandLCD) && - (SiS_Pr->SiS_LCDInfo & LCDPass11)) ) { + (SiS_Pr->SiS_CustomT == CUT_PANEL856) || + (SiS_Pr->SiS_LCDInfo & LCDPass11) ) { return; } - if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + if(ModeNo <= 0x13) ResIndex = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + else ResIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + + if((SiS_Pr->SiS_VBType & VB_SIS30xBLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { #ifdef SIS315H if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { - /* non-pass 1:1 only, see above */ - if(SiS_Pr->SiS_VGAHDE != SiS_Pr->PanelXRes) { - SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_HT - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_VGAHDE) / 2); + /* non-pass 1:1 only, see above */ + if(SiS_Pr->SiS_VGAHDE != SiS_Pr->PanelXRes) { + SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_HT - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_VGAHDE) / 2); } if(SiS_Pr->SiS_VGAVDE != SiS_Pr->PanelYRes) { SiS_Pr->SiS_LCDVDES = SiS_Pr->SiS_VT - ((SiS_Pr->PanelYRes - SiS_Pr->SiS_VGAVDE) / 2); } } if(SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) { - switch(SiS_Pr->SiS_CustomT) { - case CUT_UNIWILL1024: - case CUT_UNIWILL10242: - case CUT_CLEVO1400: + switch(SiS_Pr->SiS_CustomT) { + case CUT_UNIWILL1024: + case CUT_UNIWILL10242: + case CUT_CLEVO1400: if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; } break; } - if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) { + switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_1280x1024: if(SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) { SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; } + break; + case Panel_1280x800: /* Verified for Averatec 6240 */ + case Panel_1280x800_2: /* Verified for Asus A4L */ + case Panel_1280x854: /* Not verified yet FIXME */ + SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; + break; } } #endif } else { - SiS_GetLVDSDesPtr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, - &PanelIndex, &ResIndex, HwInfo); - - switch(PanelIndex) { - case 0: PanelDesPtr = SiS_Pr->SiS_PanelType00_1; break; /* --- */ - case 1: PanelDesPtr = SiS_Pr->SiS_PanelType01_1; break; - case 2: PanelDesPtr = SiS_Pr->SiS_PanelType02_1; break; - case 3: PanelDesPtr = SiS_Pr->SiS_PanelType03_1; break; - case 4: PanelDesPtr = SiS_Pr->SiS_PanelType04_1; break; - case 5: PanelDesPtr = SiS_Pr->SiS_PanelType05_1; break; - case 6: PanelDesPtr = SiS_Pr->SiS_PanelType06_1; break; - case 7: PanelDesPtr = SiS_Pr->SiS_PanelType07_1; break; - case 8: PanelDesPtr = SiS_Pr->SiS_PanelType08_1; break; - case 9: PanelDesPtr = SiS_Pr->SiS_PanelType09_1; break; - case 10: PanelDesPtr = SiS_Pr->SiS_PanelType0a_1; break; - case 11: PanelDesPtr = SiS_Pr->SiS_PanelType0b_1; break; - case 12: PanelDesPtr = SiS_Pr->SiS_PanelType0c_1; break; - case 13: PanelDesPtr = SiS_Pr->SiS_PanelType0d_1; break; - case 14: PanelDesPtr = SiS_Pr->SiS_PanelType0e_1; break; - case 15: PanelDesPtr = SiS_Pr->SiS_PanelType0f_1; break; - case 16: PanelDesPtr = SiS_Pr->SiS_PanelType00_2; break; /* --- */ - case 17: PanelDesPtr = SiS_Pr->SiS_PanelType01_2; break; - case 18: PanelDesPtr = SiS_Pr->SiS_PanelType02_2; break; - case 19: PanelDesPtr = SiS_Pr->SiS_PanelType03_2; break; - case 20: PanelDesPtr = SiS_Pr->SiS_PanelType04_2; break; - case 21: PanelDesPtr = SiS_Pr->SiS_PanelType05_2; break; - case 22: PanelDesPtr = SiS_Pr->SiS_PanelType06_2; break; - case 23: PanelDesPtr = SiS_Pr->SiS_PanelType07_2; break; - case 24: PanelDesPtr = SiS_Pr->SiS_PanelType08_2; break; - case 25: PanelDesPtr = SiS_Pr->SiS_PanelType09_2; break; - case 26: PanelDesPtr = SiS_Pr->SiS_PanelType0a_2; break; - case 27: PanelDesPtr = SiS_Pr->SiS_PanelType0b_2; break; - case 28: PanelDesPtr = SiS_Pr->SiS_PanelType0c_2; break; - case 29: PanelDesPtr = SiS_Pr->SiS_PanelType0d_2; break; - case 30: PanelDesPtr = SiS_Pr->SiS_PanelType0e_2; break; - case 31: PanelDesPtr = SiS_Pr->SiS_PanelType0f_2; break; - case 32: PanelDesPtr = SiS_Pr->SiS_PanelTypeNS_1; break; /* pass 1:1 */ - case 33: PanelDesPtr = SiS_Pr->SiS_PanelTypeNS_2; break; - case 50: PanelDesPtr = SiS_Pr->SiS_CHTVUNTSCDesData; break; /* TV */ - case 51: PanelDesPtr = SiS_Pr->SiS_CHTVONTSCDesData; break; - case 52: PanelDesPtr = SiS_Pr->SiS_CHTVUPALDesData; break; - case 53: PanelDesPtr = SiS_Pr->SiS_CHTVOPALDesData; break; - default: return; - } - - SiS_Pr->SiS_LCDHDES = (PanelDesPtr+ResIndex)->LCDHDES; - SiS_Pr->SiS_LCDVDES = (PanelDesPtr+ResIndex)->LCDVDES; + if((SiS_Pr->SiS_IF_DEF_CH70xx != 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { + + if((SiS_Pr->SiS_TVMode & TVSetPAL) && (!(SiS_Pr->SiS_TVMode & TVSetPALM))) { + if(ResIndex <= 3) SiS_Pr->SiS_LCDHDES = 256; + } + + } else if((PanelDesPtr = SiS_GetLVDSDesPtr(SiS_Pr))) { + + SiS_Pr->SiS_LCDHDES = (PanelDesPtr+ResIndex)->LCDHDES; + SiS_Pr->SiS_LCDVDES = (PanelDesPtr+ResIndex)->LCDVDES; + + } else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + + if(SiS_Pr->SiS_VGAHDE != SiS_Pr->PanelXRes) { + SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_HT - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_VGAHDE) / 2); + } + if(SiS_Pr->SiS_VGAVDE != SiS_Pr->PanelYRes) { + SiS_Pr->SiS_LCDVDES = SiS_Pr->SiS_VT - ((SiS_Pr->PanelYRes - SiS_Pr->SiS_VGAVDE) / 2); + } else { + if(SiS_Pr->ChipType < SIS_315H) { + SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; + } else { + switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_800x600: + case Panel_1024x768: + case Panel_1280x1024: + SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT; + break; + case Panel_1400x1050: + SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; + break; + } + } + } + + } else { + + if(SiS_Pr->ChipType < SIS_315H) { +#ifdef SIS300 + switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_800x600: + if(SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) { + SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; + } else { + SiS_Pr->SiS_LCDHDES = SiS_Pr->PanelHT + 3; + SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT; + if(SiS_Pr->SiS_VGAVDE == 400) SiS_Pr->SiS_LCDVDES -= 2; + else SiS_Pr->SiS_LCDVDES -= 4; + } + break; + case Panel_1024x768: + if(SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) { + SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; + } else { + SiS_Pr->SiS_LCDHDES = SiS_Pr->PanelHT - 1; + if(SiS_Pr->SiS_VGAVDE <= 400) SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 8; + if(SiS_Pr->SiS_VGAVDE <= 350) SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 12; + } + break; + case Panel_1024x600: + default: + if( (SiS_Pr->SiS_VGAHDE == SiS_Pr->PanelXRes) && + (SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) ) { + SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; + } else { + SiS_Pr->SiS_LCDHDES = SiS_Pr->PanelHT - 1; + } + break; + } + + switch(SiS_Pr->SiS_LCDTypeInfo) { + case 1: + SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_LCDVDES = 0; + break; + case 3: /* 640x480 only? */ + SiS_Pr->SiS_LCDHDES = 8; + if (SiS_Pr->SiS_VGAVDE >= 480) SiS_Pr->SiS_LCDVDES = 512; + else if(SiS_Pr->SiS_VGAVDE >= 400) SiS_Pr->SiS_LCDVDES = 436; + else if(SiS_Pr->SiS_VGAVDE >= 350) SiS_Pr->SiS_LCDVDES = 440; + break; + } +#endif + } else { +#ifdef SIS315H + switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_1024x768: + case Panel_1280x1024: + if(SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) { + SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; + } + break; + case Panel_320x240_1: + case Panel_320x240_2: + case Panel_320x240_3: + SiS_Pr->SiS_LCDVDES = 524; + break; + } +#endif + } + } if((ModeNo <= 0x13) && (SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + if((SiS_Pr->SiS_VBType & VB_SIS30xBLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { if(!(modeflag & HalfDCLK)) SiS_Pr->SiS_LCDHDES = 632; - } else if(!(SiS_Pr->SiS_SetFlag & SetDOSMode)) { - if(SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) { - if(SiS_Pr->SiS_LCDResInfo >= Panel_1024x768) { - if(HwInfo->jChipType < SIS_315H) { + } else if(!(SiS_Pr->SiS_SetFlag & SetDOSMode)) { + if(SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) { + if(SiS_Pr->SiS_LCDResInfo >= Panel_1024x768) { + if(SiS_Pr->ChipType < SIS_315H) { if(!(modeflag & HalfDCLK)) SiS_Pr->SiS_LCDHDES = 320; } else { - if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) SiS_Pr->SiS_LCDHDES = 480; - if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) SiS_Pr->SiS_LCDHDES = 804; +#ifdef SIS315H + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) SiS_Pr->SiS_LCDHDES = 480; + if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) SiS_Pr->SiS_LCDHDES = 804; if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) SiS_Pr->SiS_LCDHDES = 704; - if(!(modeflag & HalfDCLK)) { - SiS_Pr->SiS_LCDHDES = 320; - if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) SiS_Pr->SiS_LCDHDES = 632; + if(!(modeflag & HalfDCLK)) { + SiS_Pr->SiS_LCDHDES = 320; + if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) SiS_Pr->SiS_LCDHDES = 632; if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) SiS_Pr->SiS_LCDHDES = 542; - } - } - } - } - } + } +#endif + } + } + } + } } } } @@ -3832,54 +3869,90 @@ SiS_GetLVDSDesData(SiS_Private *SiS_Pr, USHORT ModeNo,USHORT ModeIdIndex, /* DISABLE VIDEO BRIDGE */ /*********************************************/ +#ifdef SIS315H +static int +SiS_HandlePWD(struct SiS_Private *SiS_Pr) +{ + int ret = 0; +#ifdef SET_PWD + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short romptr = GetLCDStructPtr661_2(SiS_Pr); + unsigned char drivermode = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40; + unsigned short temp; + + if( (SiS_Pr->SiS_VBType & VB_SISPWD) && + (romptr) && + (SiS_Pr->SiS_PWDOffset) ) { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2b,ROMAddr[romptr + SiS_Pr->SiS_PWDOffset + 0]); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2c,ROMAddr[romptr + SiS_Pr->SiS_PWDOffset + 1]); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2d,ROMAddr[romptr + SiS_Pr->SiS_PWDOffset + 2]); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2e,ROMAddr[romptr + SiS_Pr->SiS_PWDOffset + 3]); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2f,ROMAddr[romptr + SiS_Pr->SiS_PWDOffset + 4]); + temp = 0x00; + if((ROMAddr[romptr + 2] & (0x06 << 1)) && !drivermode) { + temp = 0x80; + ret = 1; + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x27,0x7f,temp); +#ifdef SIS_XORG_XF86 +#ifdef TWDEBUG + xf86DrvMsg(0, 0, "Setting PWD %x\n", temp); +#endif +#endif + } +#endif + return ret; +} +#endif + /* NEVER use any variables (VBInfo), this will be called * from outside the context of modeswitch! * MUST call getVBType before calling this */ void -SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_DisableBridge(struct SiS_Private *SiS_Pr) { #ifdef SIS315H - USHORT tempah,pushax=0,modenum; + unsigned short tempah, pushax=0, modenum; #endif - USHORT temp=0; + unsigned short temp=0; if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* ===== For 30xB/LV ===== */ + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { /* ===== For 30xB/C/LV ===== */ - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { #ifdef SIS300 /* 300 series */ - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE); + if(!(SiS_CR36BIOSWord23b(SiS_Pr))) { + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE); } else { - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08); + SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08); } - SiS_PanelDelay(SiS_Pr, HwInfo, 3); + SiS_PanelDelay(SiS_Pr, 3); } if(SiS_Is301B(SiS_Pr)) { SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,0x3f); SiS_ShortDelay(SiS_Pr,1); - } + } SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); SiS_DisplayOff(SiS_Pr); SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); - SiS_UnLockCRT2(SiS_Pr,HwInfo); - if(!(SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { + SiS_UnLockCRT2(SiS_Pr); + if(!(SiS_Pr->SiS_VBType & VB_SISLVDS)) { SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80); SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40); } - if( (!(SiS_CRT2IsLCD(SiS_Pr, HwInfo))) || - (!(SiS_CR36BIOSWord23d(SiS_Pr, HwInfo))) ) { - SiS_PanelDelay(SiS_Pr, HwInfo, 2); - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD); + if( (!(SiS_CRT2IsLCD(SiS_Pr))) || + (!(SiS_CR36BIOSWord23d(SiS_Pr))) ) { + SiS_PanelDelay(SiS_Pr, 2); + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD); } else { - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x04); + SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x04); } } @@ -3889,130 +3962,127 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) #ifdef SIS315H /* 315 series */ + int didpwd = 0; BOOLEAN custom1 = ((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) ? TRUE : FALSE; modenum = SiS_GetReg(SiS_Pr->SiS_P3d4,0x34) & 0x7f; - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { #ifdef SET_EMI - if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + if(SiS_Pr->SiS_VBType & VB_SISEMI) { if(SiS_Pr->SiS_CustomT != CUT_CLEVO1400) { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); } } #endif - if( (modenum <= 0x13) || - (SiS_IsVAMode(SiS_Pr,HwInfo)) || - (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) ) { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE); - if(custom1) SiS_PanelDelay(SiS_Pr, HwInfo, 3); + + didpwd = SiS_HandlePWD(SiS_Pr); + + if( (modenum <= 0x13) || + (SiS_IsVAMode(SiS_Pr)) || + (!(SiS_IsDualEdge(SiS_Pr))) ) { + if(!didpwd) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xfe); + if(custom1) SiS_PanelDelay(SiS_Pr, 3); + } else { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xfc); + } } if(!custom1) { SiS_DDC2Delay(SiS_Pr,0xff00); SiS_DDC2Delay(SiS_Pr,0xe000); - SiS_SetRegByte(SiS_Pr->SiS_P3c6,0x00); - pushax = SiS_GetReg(SiS_Pr->SiS_P3c4,0x06); + SiS_SetRegByte(SiS_Pr->SiS_P3c6,0x00); + pushax = SiS_GetReg(SiS_Pr->SiS_P3c4,0x06); if(IS_SIS740) { SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x06,0xE3); } - SiS_PanelDelay(SiS_Pr, HwInfo, 3); + SiS_PanelDelay(SiS_Pr, 3); } - } + } - if(!(SiS_IsNotM650orLater(SiS_Pr, HwInfo))) { - if(HwInfo->jChipType < SIS_340) { - tempah = 0xef; - if(SiS_IsVAMode(SiS_Pr,HwInfo)) tempah = 0xf7; - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,tempah); - } + if(!(SiS_IsNotM650orLater(SiS_Pr))) { + /* if(SiS_Pr->ChipType < SIS_340) {*/ + tempah = 0xef; + if(SiS_IsVAMode(SiS_Pr)) tempah = 0xf7; + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,tempah); + /*}*/ } - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,~0x10); } tempah = 0x3f; - if(SiS_IsDualEdge(SiS_Pr,HwInfo)) { + if(SiS_IsDualEdge(SiS_Pr)) { tempah = 0x7f; - if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) tempah = 0xbf; + if(!(SiS_IsVAMode(SiS_Pr))) tempah = 0xbf; } SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,tempah); - if((SiS_IsVAMode(SiS_Pr,HwInfo)) || - ((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && (modenum <= 0x13))) { + if((SiS_IsVAMode(SiS_Pr)) || + ((SiS_Pr->SiS_VBType & VB_SISLVDS) && (modenum <= 0x13))) { SiS_DisplayOff(SiS_Pr); - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - SiS_PanelDelay(SiS_Pr, HwInfo, 2); + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { + SiS_PanelDelay(SiS_Pr, 2); } SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1E,0xDF); } - if((!(SiS_IsVAMode(SiS_Pr,HwInfo))) || - ((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && (modenum <= 0x13))) { + if((!(SiS_IsVAMode(SiS_Pr))) || + ((SiS_Pr->SiS_VBType & VB_SISLVDS) && (modenum <= 0x13))) { - if(!(SiS_IsDualEdge(SiS_Pr,HwInfo))) { + if(!(SiS_IsDualEdge(SiS_Pr))) { SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xdf); SiS_DisplayOff(SiS_Pr); } SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - SiS_PanelDelay(SiS_Pr, HwInfo, 2); + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { + SiS_PanelDelay(SiS_Pr, 2); } SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10); SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,temp); } - if(SiS_IsNotM650orLater(SiS_Pr,HwInfo)) { + if(SiS_IsNotM650orLater(SiS_Pr)) { SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); } - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - - if(!custom1) { - - if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) { - if(!(SiS_CRT2IsLCD(SiS_Pr,HwInfo))) { - if(!(SiS_IsDualEdge(SiS_Pr,HwInfo))) { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD); - } - } - } + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { - SiS_SetReg(SiS_Pr->SiS_P3c4,0x06,pushax); + if( (!(SiS_IsVAMode(SiS_Pr))) && + (!(SiS_CRT2IsLCD(SiS_Pr))) && + (!(SiS_IsDualEdge(SiS_Pr))) ) { - if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { - if(SiS_IsVAorLCD(SiS_Pr, HwInfo)) { - SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 20); - } - } - - } else { + if(custom1) SiS_PanelDelay(SiS_Pr, 2); + if(!didpwd) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD); + } + if(custom1) SiS_PanelDelay(SiS_Pr, 4); + } - if((SiS_IsVAMode(SiS_Pr,HwInfo)) || - (!(SiS_IsDualEdge(SiS_Pr,HwInfo)))) { - if((!(SiS_WeHaveBacklightCtrl(SiS_Pr, HwInfo))) || - (!(SiS_CRT2IsLCD(SiS_Pr, HwInfo)))) { - SiS_PanelDelay(SiS_Pr, HwInfo, 2); - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD); - SiS_PanelDelay(SiS_Pr, HwInfo, 4); + if(!custom1) { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x06,pushax); + if(SiS_Pr->SiS_VBType & VB_SISEMI) { + if(SiS_IsVAorLCD(SiS_Pr)) { + SiS_PanelDelayLoop(SiS_Pr, 3, 20); } } - } - } + + } #endif /* SIS315H */ @@ -4020,36 +4090,36 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) } else { /* ============ For 301 ================ */ - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { #ifdef SIS300 - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08); - SiS_PanelDelay(SiS_Pr, HwInfo, 3); + if(!(SiS_CR36BIOSWord23b(SiS_Pr))) { + SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08); + SiS_PanelDelay(SiS_Pr, 3); } #endif } - SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); /* disable VB */ - SiS_DisplayOff(SiS_Pr); + SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); /* disable VB */ + SiS_DisplayOff(SiS_Pr); - if(HwInfo->jChipType >= SIS_315H) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); + if(SiS_Pr->ChipType >= SIS_315H) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); } - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); /* disable lock mode */ + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); /* disable lock mode */ - if(HwInfo->jChipType >= SIS_315H) { - temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10); + if(SiS_Pr->ChipType >= SIS_315H) { + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10); SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,temp); } else { #ifdef SIS300 - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); /* disable CRT2 */ - if( (!(SiS_CRT2IsLCD(SiS_Pr, HwInfo))) || - (!(SiS_CR36BIOSWord23d(SiS_Pr,HwInfo))) ) { - SiS_PanelDelay(SiS_Pr, HwInfo, 2); - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x04); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); /* disable CRT2 */ + if( (!(SiS_CRT2IsLCD(SiS_Pr))) || + (!(SiS_CR36BIOSWord23d(SiS_Pr))) ) { + SiS_PanelDelay(SiS_Pr, 2); + SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x04); } #endif } @@ -4058,34 +4128,34 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) } else { /* ============ For LVDS =============*/ - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { #ifdef SIS300 /* 300 series */ if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { - SiS_SetCH700x(SiS_Pr,0x090E); + SiS_SetCH700x(SiS_Pr,0x0E,0x09); } - if(HwInfo->jChipType == SIS_730) { + if(SiS_Pr->ChipType == SIS_730) { if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x11) & 0x08)) { - SiS_WaitVBRetrace(SiS_Pr,HwInfo); + SiS_WaitVBRetrace(SiS_Pr); } - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08); - SiS_PanelDelay(SiS_Pr, HwInfo, 3); + if(!(SiS_CR36BIOSWord23b(SiS_Pr))) { + SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08); + SiS_PanelDelay(SiS_Pr, 3); } } else { if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x11) & 0x08)) { if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x40)) { - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { - SiS_WaitVBRetrace(SiS_Pr,HwInfo); + if(!(SiS_CR36BIOSWord23b(SiS_Pr))) { + SiS_WaitVBRetrace(SiS_Pr); if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x06) & 0x1c)) { SiS_DisplayOff(SiS_Pr); - } - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08); - SiS_PanelDelay(SiS_Pr, HwInfo, 3); - } - } + } + SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08); + SiS_PanelDelay(SiS_Pr, 3); + } + } } } @@ -4094,14 +4164,14 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); - SiS_UnLockCRT2(SiS_Pr,HwInfo); + SiS_UnLockCRT2(SiS_Pr); SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80); SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40); - if( (!(SiS_CRT2IsLCD(SiS_Pr, HwInfo))) || - (!(SiS_CR36BIOSWord23d(SiS_Pr,HwInfo))) ) { - SiS_PanelDelay(SiS_Pr, HwInfo, 2); - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x04); + if( (!(SiS_CRT2IsLCD(SiS_Pr))) || + (!(SiS_CR36BIOSWord23d(SiS_Pr))) ) { + SiS_PanelDelay(SiS_Pr, 2); + SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x04); } #endif /* SIS300 */ @@ -4110,113 +4180,113 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) #ifdef SIS315H /* 315 series */ - if(!(SiS_IsNotM650orLater(SiS_Pr,HwInfo))) { - if(HwInfo->jChipType < SIS_340) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,~0x18); - } - } + if(!(SiS_IsNotM650orLater(SiS_Pr))) { + /*if(SiS_Pr->ChipType < SIS_340) { */ /* XGI needs this */ + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,~0x18); + /* } */ + } if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->ChipType == SIS_740) { temp = SiS_GetCH701x(SiS_Pr,0x61); if(temp < 1) { - SiS_SetCH701x(SiS_Pr,0xac76); - SiS_SetCH701x(SiS_Pr,0x0066); + SiS_SetCH701x(SiS_Pr,0x76,0xac); + SiS_SetCH701x(SiS_Pr,0x66,0x00); } - if( (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || - (SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwInfo)) ) { - SiS_SetCH701x(SiS_Pr,0x3e49); + if( (!(SiS_IsDualEdge(SiS_Pr))) || + (SiS_IsTVOrYPbPrOrScart(SiS_Pr)) ) { + SiS_SetCH701x(SiS_Pr,0x49,0x3e); } } - if( (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || - (SiS_IsVAMode(SiS_Pr,HwInfo)) ) { + if( (!(SiS_IsDualEdge(SiS_Pr))) || + (SiS_IsVAMode(SiS_Pr)) ) { SiS_Chrontel701xBLOff(SiS_Pr); - SiS_Chrontel701xOff(SiS_Pr,HwInfo); + SiS_Chrontel701xOff(SiS_Pr); } - if(HwInfo->jChipType != SIS_740) { - if( (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || - (SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwInfo)) ) { - SiS_SetCH701x(SiS_Pr,0x0149); - } + if(SiS_Pr->ChipType != SIS_740) { + if( (!(SiS_IsDualEdge(SiS_Pr))) || + (SiS_IsTVOrYPbPrOrScart(SiS_Pr)) ) { + SiS_SetCH701x(SiS_Pr,0x49,0x01); + } } } if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08); - SiS_PanelDelay(SiS_Pr, HwInfo, 3); + SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08); + SiS_PanelDelay(SiS_Pr, 3); } if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) || - (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || - (!(SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwInfo))) ) { + (!(SiS_IsDualEdge(SiS_Pr))) || + (!(SiS_IsTVOrYPbPrOrScart(SiS_Pr))) ) { SiS_DisplayOff(SiS_Pr); } if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) || - (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || - (!(SiS_IsVAMode(SiS_Pr,HwInfo))) ) { + (!(SiS_IsDualEdge(SiS_Pr))) || + (!(SiS_IsVAMode(SiS_Pr))) ) { SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); } - if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->ChipType == SIS_740) { SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); } SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) || - (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || - (!(SiS_IsVAMode(SiS_Pr,HwInfo))) ) { + (!(SiS_IsDualEdge(SiS_Pr))) || + (!(SiS_IsVAMode(SiS_Pr))) ) { SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); } if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { + if(SiS_CRT2IsLCD(SiS_Pr)) { SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); - if(HwInfo->jChipType == SIS_550) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xbf); - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xef); + if(SiS_Pr->ChipType == SIS_550) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xbf); + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xef); } } } else { - if(HwInfo->jChipType == SIS_740) { - if(SiS_IsLCDOrLCDA(SiS_Pr,HwInfo)) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); + if(SiS_Pr->ChipType == SIS_740) { + if(SiS_IsLCDOrLCDA(SiS_Pr)) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); } - } else if(SiS_IsVAMode(SiS_Pr,HwInfo)) { + } else if(SiS_IsVAMode(SiS_Pr)) { SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); } } if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_IsDualEdge(SiS_Pr,HwInfo)) { + if(SiS_IsDualEdge(SiS_Pr)) { /* SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xff); */ } else { SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); } } - SiS_UnLockCRT2(SiS_Pr,HwInfo); + SiS_UnLockCRT2(SiS_Pr); - if(HwInfo->jChipType == SIS_550) { + if(SiS_Pr->ChipType == SIS_550) { SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80); /* DirectDVD PAL?*/ SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40); /* VB clock / 4 ? */ } else if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) || - (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || - (!(SiS_IsVAMode(SiS_Pr,HwInfo))) ) { + (!(SiS_IsDualEdge(SiS_Pr))) || + (!(SiS_IsVAMode(SiS_Pr))) ) { SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7); } if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { - SiS_PanelDelay(SiS_Pr, HwInfo, 2); - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x04); + if(SiS_CRT2IsLCD(SiS_Pr)) { + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) { + SiS_PanelDelay(SiS_Pr, 2); + SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x04); } } } @@ -4237,78 +4307,81 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) * from outside the context of a mode switch! * MUST call getVBType before calling this */ -static void -SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +#ifdef SIS_LINUX_KERNEL +static +#endif +void +SiS_EnableBridge(struct SiS_Private *SiS_Pr) { - USHORT temp=0,tempah; + unsigned short temp=0, tempah; #ifdef SIS315H - USHORT temp1,pushax=0; + unsigned short temp1, pushax=0; BOOLEAN delaylong = FALSE; #endif if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* ====== For 301B et al ====== */ + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { /* ====== For 301B et al ====== */ - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { #ifdef SIS300 /* 300 series */ - if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(SiS_CRT2IsLCD(SiS_Pr)) { + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); } else if(SiS_Pr->SiS_VBType & VB_NoLCD) { - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x00); + SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x00); } - if(SiS_Pr->SiS_VBType & (VB_SIS301LV302LV | VB_NoLCD)) { - if(!(SiS_CR36BIOSWord23d(SiS_Pr, HwInfo))) { - SiS_PanelDelay(SiS_Pr, HwInfo, 0); + if(SiS_Pr->SiS_VBType & (VB_SISLVDS | VB_NoLCD)) { + if(!(SiS_CR36BIOSWord23d(SiS_Pr))) { + SiS_PanelDelay(SiS_Pr, 0); } } } if((SiS_Pr->SiS_VBType & VB_NoLCD) && - (SiS_CRT2IsLCD(SiS_Pr, HwInfo))) { + (SiS_CRT2IsLCD(SiS_Pr))) { SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* Enable CRT2 */ - SiS_DisplayOn(SiS_Pr); - SiS_UnLockCRT2(SiS_Pr,HwInfo); + SiS_DisplayOn(SiS_Pr); + SiS_UnLockCRT2(SiS_Pr); SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xBF); if(SiS_BridgeInSlavemode(SiS_Pr)) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F); - } else { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40); - } + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F); + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40); + } if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x40)) { if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x10)) { - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { - SiS_PanelDelay(SiS_Pr, HwInfo, 1); - } - SiS_WaitVBRetrace(SiS_Pr,HwInfo); - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x00); - } + if(!(SiS_CR36BIOSWord23b(SiS_Pr))) { + SiS_PanelDelay(SiS_Pr, 1); + } + SiS_WaitVBRetrace(SiS_Pr); + SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x00); + } } } else { temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; /* lock mode */ - if(SiS_BridgeInSlavemode(SiS_Pr)) { - tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); - if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; - } - SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); + if(SiS_BridgeInSlavemode(SiS_Pr)) { + tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; + } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1F,0x20); /* enable VB processor */ SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,0xC0); SiS_DisplayOn(SiS_Pr); - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { - if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x10)) { - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { - SiS_PanelDelay(SiS_Pr, HwInfo, 1); - } + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { + if(SiS_CRT2IsLCD(SiS_Pr)) { + if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x10)) { + if(!(SiS_CR36BIOSWord23b(SiS_Pr))) { + SiS_PanelDelay(SiS_Pr, 1); + } SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01); - } + } } } @@ -4322,31 +4395,32 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) #ifdef SIS315H /* 315 series */ #ifdef SET_EMI - UCHAR r30=0, r31=0, r32=0, r33=0, cr36=0; - /* USHORT emidelay=0; */ + unsigned char r30=0, r31=0, r32=0, r33=0, cr36=0; + int didpwd = 0; + /* unsigned short emidelay=0; */ #endif - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,0xef); #ifdef SET_EMI - if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + if(SiS_Pr->SiS_VBType & VB_SISEMI) { SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); } #endif } - if(!(SiS_IsNotM650orLater(SiS_Pr, HwInfo))) { - if(HwInfo->jChipType < SIS_340) { + if(!(SiS_IsNotM650orLater(SiS_Pr))) { + /*if(SiS_Pr->ChipType < SIS_340) { */ tempah = 0x10; - if(SiS_LCDAEnabled(SiS_Pr, HwInfo)) { - if(SiS_TVEnabled(SiS_Pr, HwInfo)) tempah = 0x18; - else tempah = 0x08; + if(SiS_LCDAEnabled(SiS_Pr)) { + if(SiS_TVEnabled(SiS_Pr)) tempah = 0x18; + else tempah = 0x08; } SiS_SetReg(SiS_Pr->SiS_Part1Port,0x4c,tempah); - } + /*}*/ } - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { SiS_SetRegByte(SiS_Pr->SiS_P3c6,0x00); SiS_DisplayOff(SiS_Pr); @@ -4355,42 +4429,51 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x06,0xE3); } - if(SiS_IsVAorLCD(SiS_Pr, HwInfo)) { - if(!(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) { - SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 2); - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); - SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 2); - if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { - SiS_GenericDelay(SiS_Pr, 0x4500); + didpwd = SiS_HandlePWD(SiS_Pr); + + if(SiS_IsVAorLCD(SiS_Pr)) { + if(!didpwd) { + if(!(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) { + SiS_PanelDelayLoop(SiS_Pr, 3, 2); + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); + SiS_PanelDelayLoop(SiS_Pr, 3, 2); + if(SiS_Pr->SiS_VBType & VB_SISEMI) { + SiS_GenericDelay(SiS_Pr, 17664); + } + } + } else { + SiS_PanelDelayLoop(SiS_Pr, 3, 2); + if(SiS_Pr->SiS_VBType & VB_SISEMI) { + SiS_GenericDelay(SiS_Pr, 17664); } } } if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40)) { - SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 10); + SiS_PanelDelayLoop(SiS_Pr, 3, 10); delaylong = TRUE; } } - if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) { + if(!(SiS_IsVAMode(SiS_Pr))) { - temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; if(SiS_BridgeInSlavemode(SiS_Pr)) { - tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); - if(!(tempah & SetCRT2ToRAMDAC)) { - if(!(SiS_LCDAEnabled(SiS_Pr, HwInfo))) temp |= 0x20; + tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(!(tempah & SetCRT2ToRAMDAC)) { + if(!(SiS_LCDAEnabled(SiS_Pr))) temp |= 0x20; } - } - SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); + } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */ SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80); - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - SiS_PanelDelay(SiS_Pr, HwInfo, 2); + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { + SiS_PanelDelay(SiS_Pr, 2); } } else { @@ -4402,38 +4485,48 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1f,0x20); SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80); + if(SiS_Pr->SiS_VBType & VB_SISPOWER) { + if( (SiS_LCDAEnabled(SiS_Pr)) || + (SiS_CRT2IsLCD(SiS_Pr)) ) { + /* Enable "LVDS PLL power on" (even on 301C) */ + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x2a,0x7f); + /* Enable "LVDS Driver Power on" (even on 301C) */ + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x7f); + } + } + tempah = 0xc0; - if(SiS_IsDualEdge(SiS_Pr, HwInfo)) { + if(SiS_IsDualEdge(SiS_Pr)) { tempah = 0x80; - if(!(SiS_IsVAMode(SiS_Pr, HwInfo))) tempah = 0x40; + if(!(SiS_IsVAMode(SiS_Pr))) tempah = 0x40; } - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,tempah); + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,tempah); - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { - SiS_PanelDelay(SiS_Pr, HwInfo, 2); + SiS_PanelDelay(SiS_Pr, 2); SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1f,0x10); SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80); if(SiS_Pr->SiS_CustomT != CUT_CLEVO1400) { #ifdef SET_EMI - if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); - SiS_GenericDelay(SiS_Pr, 0x500); + if(SiS_Pr->SiS_VBType & VB_SISEMI) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); + SiS_GenericDelay(SiS_Pr, 2048); } #endif SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x0c); - if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + if(SiS_Pr->SiS_VBType & VB_SISEMI) { #ifdef SET_EMI cr36 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36); if(SiS_Pr->SiS_ROMNew) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT romptr = GetLCDStructPtr661_2(SiS_Pr, HwInfo); + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short romptr = GetLCDStructPtr661_2(SiS_Pr); if(romptr) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x20); /* Reset */ + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x20); /* Reset */ SiS_Pr->EMI_30 = 0; SiS_Pr->EMI_31 = ROMAddr[romptr + SiS_Pr->SiS_EMIOffset + 0]; SiS_Pr->EMI_32 = ROMAddr[romptr + SiS_Pr->SiS_EMIOffset + 1]; @@ -4511,21 +4604,21 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) if(!SiS_Pr->OverruleEMI) { #ifdef COMPAL_HACK if(SiS_Pr->SiS_CustomT == CUT_COMPAL1400_2) { - if((cr36 & 0x0f) == 0x09) { + if((cr36 & 0x0f) == 0x09) { r30 = 0x60; r31 = 0x05; r32 = 0x60; r33 = 0x00; } } #endif #ifdef COMPAQ_HACK if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { - if((cr36 & 0x0f) == 0x03) { + if((cr36 & 0x0f) == 0x03) { r30 = 0x20; r31 = 0x12; r32 = 0xd0; r33 = 0x6b; } } #endif #ifdef ASUS_HACK if(SiS_Pr->SiS_CustomT == CUT_ASUSA2H_2) { - if((cr36 & 0x0f) == 0x02) { + if((cr36 & 0x0f) == 0x02) { /* r30 = 0x60; r31 = 0x05; r32 = 0x60; r33 = 0x33; */ /* rev 2 */ /* r30 = 0x20; r31 = 0x05; r32 = 0x60; r33 = 0x33; */ /* rev 3 */ /* r30 = 0x60; r31 = 0x0d; r32 = 0x70; r33 = 0x40; */ /* rev 4 */ @@ -4533,11 +4626,11 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) } } #endif - } + } if(!(SiS_Pr->OverruleEMI && (!r30) && (!r31) && (!r32) && (!r33))) { SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x20); /* Reset */ - SiS_GenericDelay(SiS_Pr, 0x500); + SiS_GenericDelay(SiS_Pr, 2048); } SiS_SetReg(SiS_Pr->SiS_Part4Port,0x31,r31); SiS_SetReg(SiS_Pr->SiS_Part4Port,0x32,r32); @@ -4547,36 +4640,44 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); #ifdef SET_EMI - if( (SiS_LCDAEnabled(SiS_Pr, HwInfo)) || - (SiS_CRT2IsLCD(SiS_Pr, HwInfo)) ) { - if(r30 & 0x40) { - SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 5); + if( (SiS_LCDAEnabled(SiS_Pr)) || + (SiS_CRT2IsLCD(SiS_Pr)) ) { + if(r30 & 0x40) { + /*SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x2a,0x80);*/ + SiS_PanelDelayLoop(SiS_Pr, 3, 5); if(delaylong) { - SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 5); + SiS_PanelDelayLoop(SiS_Pr, 3, 5); delaylong = FALSE; } - SiS_WaitVBRetrace(SiS_Pr,HwInfo); + SiS_WaitVBRetrace(SiS_Pr); + SiS_WaitVBRetrace(SiS_Pr); if(SiS_Pr->SiS_CustomT == CUT_ASUSA2H_2) { - SiS_GenericDelay(SiS_Pr, 0x500); + SiS_GenericDelay(SiS_Pr, 1280); } - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x40); /* Enable */ - } + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x40); /* Enable */ + /*SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x2a,0x7f);*/ + } } #endif } } - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { - if(SiS_IsVAorLCD(SiS_Pr, HwInfo)) { - SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 10); + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) { + if(SiS_IsVAorLCD(SiS_Pr)) { + SiS_PanelDelayLoop(SiS_Pr, 3, 10); if(delaylong) { - SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 10); + SiS_PanelDelayLoop(SiS_Pr, 3, 10); } - SiS_WaitVBRetrace(SiS_Pr,HwInfo); - if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { - SiS_GenericDelay(SiS_Pr, 0x500); + SiS_WaitVBRetrace(SiS_Pr); + if(SiS_Pr->SiS_VBType & VB_SISEMI) { + SiS_GenericDelay(SiS_Pr, 2048); + SiS_WaitVBRetrace(SiS_Pr); + } + if(!didpwd) { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01); + } else { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x03); } - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01); } } @@ -4586,7 +4687,7 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) } - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) { SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); } @@ -4596,26 +4697,26 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) } else { /* ============ For 301 ================ */ - if(HwInfo->jChipType < SIS_315H) { - if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x00); - SiS_PanelDelay(SiS_Pr, HwInfo, 0); + if(SiS_Pr->ChipType < SIS_315H) { + if(SiS_CRT2IsLCD(SiS_Pr)) { + SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x00); + SiS_PanelDelay(SiS_Pr, 0); } } temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; /* lock mode */ if(SiS_BridgeInSlavemode(SiS_Pr)) { - tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); - if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; + tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; } SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */ - if(HwInfo->jChipType >= SIS_315H) { - temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2E); - if(!(temp & 0x80)) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); /* BVBDOENABLE=1 */ + if(SiS_Pr->ChipType >= SIS_315H) { + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2E); + if(!(temp & 0x80)) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); /* BVBDOENABLE=1 */ } } @@ -4623,15 +4724,15 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) SiS_VBLongWait(SiS_Pr); SiS_DisplayOn(SiS_Pr); - if(HwInfo->jChipType >= SIS_315H) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); + if(SiS_Pr->ChipType >= SIS_315H) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); } SiS_VBLongWait(SiS_Pr); - if(HwInfo->jChipType < SIS_315H) { - if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { - SiS_PanelDelay(SiS_Pr, HwInfo, 1); - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x00); + if(SiS_Pr->ChipType < SIS_315H) { + if(SiS_CRT2IsLCD(SiS_Pr)) { + SiS_PanelDelay(SiS_Pr, 1); + SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x00); } } @@ -4639,49 +4740,49 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) } else { /* =================== For LVDS ================== */ - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { #ifdef SIS300 /* 300 series */ - if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { - if(HwInfo->jChipType == SIS_730) { - SiS_PanelDelay(SiS_Pr, HwInfo, 1); - SiS_PanelDelay(SiS_Pr, HwInfo, 1); - SiS_PanelDelay(SiS_Pr, HwInfo, 1); + if(SiS_CRT2IsLCD(SiS_Pr)) { + if(SiS_Pr->ChipType == SIS_730) { + SiS_PanelDelay(SiS_Pr, 1); + SiS_PanelDelay(SiS_Pr, 1); + SiS_PanelDelay(SiS_Pr, 1); } - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x00); - if(!(SiS_CR36BIOSWord23d(SiS_Pr,HwInfo))) { - SiS_PanelDelay(SiS_Pr, HwInfo, 0); + SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x00); + if(!(SiS_CR36BIOSWord23d(SiS_Pr))) { + SiS_PanelDelay(SiS_Pr, 0); } } SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); SiS_DisplayOn(SiS_Pr); - SiS_UnLockCRT2(SiS_Pr,HwInfo); + SiS_UnLockCRT2(SiS_Pr); SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xBF); if(SiS_BridgeInSlavemode(SiS_Pr)) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F); + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F); } else { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40); + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40); } if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { - if(!(SiS_CRT2IsLCD(SiS_Pr, HwInfo))) { - SiS_WaitVBRetrace(SiS_Pr, HwInfo); - SiS_SetCH700x(SiS_Pr,0x0B0E); - } + if(!(SiS_CRT2IsLCD(SiS_Pr))) { + SiS_WaitVBRetrace(SiS_Pr); + SiS_SetCH700x(SiS_Pr,0x0E,0x0B); + } } - if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { - if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x40)) { - if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x10)) { - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { - SiS_PanelDelay(SiS_Pr, HwInfo, 1); - SiS_PanelDelay(SiS_Pr, HwInfo, 1); - } - SiS_WaitVBRetrace(SiS_Pr, HwInfo); - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x00); - } + if(SiS_CRT2IsLCD(SiS_Pr)) { + if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x40)) { + if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x10)) { + if(!(SiS_CR36BIOSWord23b(SiS_Pr))) { + SiS_PanelDelay(SiS_Pr, 1); + SiS_PanelDelay(SiS_Pr, 1); + } + SiS_WaitVBRetrace(SiS_Pr); + SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x00); + } } } @@ -4691,94 +4792,94 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) #ifdef SIS315H /* 315 series */ - if(!(SiS_IsNotM650orLater(SiS_Pr,HwInfo))) { - if(HwInfo->jChipType < SIS_340) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x4c,0x18); - } + if(!(SiS_IsNotM650orLater(SiS_Pr))) { + /*if(SiS_Pr->ChipType < SIS_340) {*/ /* XGI needs this */ + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x4c,0x18); + /*}*/ } if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x00); - SiS_PanelDelay(SiS_Pr, HwInfo, 0); - } + if(SiS_CRT2IsLCD(SiS_Pr)) { + SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x00); + SiS_PanelDelay(SiS_Pr, 0); + } } SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); - SiS_UnLockCRT2(SiS_Pr,HwInfo); + SiS_UnLockCRT2(SiS_Pr); SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7); if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - temp = SiS_GetCH701x(SiS_Pr,0x66); + temp = SiS_GetCH701x(SiS_Pr,0x66); temp &= 0x20; SiS_Chrontel701xBLOff(SiS_Pr); } - if(HwInfo->jChipType != SIS_550) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); + if(SiS_Pr->ChipType != SIS_550) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); } - if(HwInfo->jChipType == SIS_740) { - if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - if(SiS_IsLCDOrLCDA(SiS_Pr, HwInfo)) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); + if(SiS_Pr->ChipType == SIS_740) { + if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + if(SiS_IsLCDOrLCDA(SiS_Pr)) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); } } } temp1 = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2E); if(!(temp1 & 0x80)) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); } if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - if(temp) { - SiS_Chrontel701xBLOn(SiS_Pr, HwInfo); + if(temp) { + SiS_Chrontel701xBLOn(SiS_Pr); } } if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { + if(SiS_CRT2IsLCD(SiS_Pr)) { SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); - if(HwInfo->jChipType == SIS_550) { + if(SiS_Pr->ChipType == SIS_550) { SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x40); SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x10); } } - } else if(SiS_IsVAMode(SiS_Pr,HwInfo)) { - if(HwInfo->jChipType != SIS_740) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); + } else if(SiS_IsVAMode(SiS_Pr)) { + if(SiS_Pr->ChipType != SIS_740) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); } } - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); } if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - if(SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwInfo)) { - SiS_Chrontel701xOn(SiS_Pr,HwInfo); - } - if( (SiS_IsVAMode(SiS_Pr,HwInfo)) || - (SiS_IsLCDOrLCDA(SiS_Pr,HwInfo)) ) { - SiS_ChrontelDoSomething1(SiS_Pr,HwInfo); - } + if(SiS_IsTVOrYPbPrOrScart(SiS_Pr)) { + SiS_Chrontel701xOn(SiS_Pr); + } + if( (SiS_IsVAMode(SiS_Pr)) || + (SiS_IsLCDOrLCDA(SiS_Pr)) ) { + SiS_ChrontelDoSomething1(SiS_Pr); + } } if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { - if( (SiS_IsVAMode(SiS_Pr,HwInfo)) || - (SiS_IsLCDOrLCDA(SiS_Pr,HwInfo)) ) { - SiS_Chrontel701xBLOn(SiS_Pr, HwInfo); - SiS_ChrontelInitTVVSync(SiS_Pr,HwInfo); - } - } + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) { + if( (SiS_IsVAMode(SiS_Pr)) || + (SiS_IsLCDOrLCDA(SiS_Pr)) ) { + SiS_Chrontel701xBLOn(SiS_Pr); + SiS_ChrontelInitTVVSync(SiS_Pr); + } + } } else if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { - if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { - SiS_PanelDelay(SiS_Pr, HwInfo, 1); - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x00); + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) { + if(SiS_CRT2IsLCD(SiS_Pr)) { + SiS_PanelDelay(SiS_Pr, 1); + SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x00); } } } @@ -4797,243 +4898,204 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) /* Set CRT2 OFFSET / PITCH */ static void -SiS_SetCRT2Offset(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RRTI, PSIS_HW_INFO HwInfo) +SiS_SetCRT2Offset(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RRTI) { - USHORT offset; - UCHAR temp; + unsigned short offset; + unsigned char temp; - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) return; + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) return; - offset = SiS_GetOffset(SiS_Pr,ModeNo,ModeIdIndex,RRTI,HwInfo); + offset = SiS_GetOffset(SiS_Pr,ModeNo,ModeIdIndex,RRTI); - if((SiS_Pr->SiS_LCDResInfo == Panel_640x480_2) || - (SiS_Pr->SiS_LCDResInfo == Panel_640x480_3)) { - offset >>= 1; - } + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x07,(offset & 0xFF)); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x09,(offset >> 8)); - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x07,(offset & 0xFF)); - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x09,(offset >> 8)); - temp = (UCHAR)(((offset >> 3) & 0xFF) + 1); - if(offset % 8) temp++; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x03,temp); + temp = (unsigned char)(((offset >> 3) & 0xFF) + 1); + if(offset & 0x07) temp++; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x03,temp); } /* Set CRT2 sync and PanelLink mode */ static void -SiS_SetCRT2Sync(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT RefreshRateTableIndex, - PSIS_HW_INFO HwInfo) +SiS_SetCRT2Sync(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short RefreshRateTableIndex) { - USHORT tempah=0,tempbl,infoflag; + unsigned short tempah=0, tempbl, infoflag; - tempbl = 0xC0; + tempbl = 0xC0; - if(SiS_Pr->UseCustomMode) { - infoflag = SiS_Pr->CInfoFlag; - } else { - infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; - } + if(SiS_Pr->UseCustomMode) { + infoflag = SiS_Pr->CInfoFlag; + } else { + infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; + } - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* LVDS */ + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* LVDS */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - tempah = 0; - } else if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (SiS_Pr->SiS_LCDInfo & LCDSync)) { - tempah = SiS_Pr->SiS_LCDInfo; - } else tempah = infoflag >> 8; - tempah &= 0xC0; - tempah |= 0x20; - if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || - (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { - tempah |= 0xf0; - } - if( (SiS_Pr->SiS_IF_DEF_FSTN) || - (SiS_Pr->SiS_IF_DEF_DSTN) || - (SiS_Pr->SiS_IF_DEF_TRUMPION) || - (SiS_Pr->SiS_CustomT == CUT_PANEL848) ) { - tempah |= 0x30; - } - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(HwInfo->jChipType >= SIS_315H) { - tempah >>= 3; - tempah &= 0x18; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xE7,tempah); - /* Don't care about 12/18/24 bit mode - TV is via VGA, not PL */ - } else { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,0xe0); - } - } else { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + tempah = 0; + } else if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (SiS_Pr->SiS_LCDInfo & LCDSync)) { + tempah = SiS_Pr->SiS_LCDInfo; + } else tempah = infoflag >> 8; + tempah &= 0xC0; + tempah |= 0x20; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || + (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { + tempah |= 0xf0; + } + if( (SiS_Pr->SiS_IF_DEF_FSTN) || + (SiS_Pr->SiS_IF_DEF_DSTN) || + (SiS_Pr->SiS_IF_DEF_TRUMPION) || + (SiS_Pr->SiS_CustomT == CUT_PANEL848) || + (SiS_Pr->SiS_CustomT == CUT_PANEL856) ) { + tempah |= 0x30; + } + if( (SiS_Pr->SiS_IF_DEF_FSTN) || + (SiS_Pr->SiS_IF_DEF_DSTN) ) { + tempah &= ~0xc0; + } + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(SiS_Pr->ChipType >= SIS_315H) { + tempah >>= 3; + tempah &= 0x18; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xE7,tempah); + /* Don't care about 12/18/24 bit mode - TV is via VGA, not PL */ + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,0xe0); + } + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + } - } else if(SiS_Pr->SiS_VBType & VB_SISVB) { + } else if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { #ifdef SIS300 /* ---- 300 series --- */ - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* 630 - 301B(-DH) */ + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { /* 630 - 301B(-DH) */ - tempah = infoflag >> 8; - tempbl = 0; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_Pr->SiS_LCDInfo & LCDSync) { - tempah = SiS_Pr->SiS_LCDInfo; - tempbl = (tempah >> 6) & 0x03; - } - } - tempah &= 0xC0; - tempah |= 0x20; - if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; - tempah |= 0xc0; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); - if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl); - } + tempah = infoflag >> 8; + tempbl = 0; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_LCDInfo & LCDSync) { + tempah = SiS_Pr->SiS_LCDInfo; + tempbl = (tempah >> 6) & 0x03; + } + } + tempah &= 0xC0; + tempah |= 0x20; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; + tempah |= 0xc0; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl); + } - } else { /* 630 - 301 */ + } else { /* 630 - 301 */ - tempah = infoflag >> 8; - tempah &= 0xC0; - tempah |= 0x20; - if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + tempah = ((infoflag >> 8) & 0xc0) | 0x20; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); - } + } #endif /* SIS300 */ - } else { + } else { #ifdef SIS315H /* ------- 315 series ------ */ - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { /* 315 - LVDS */ + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { /* 315 - LVDS */ - tempbl = 0; - if((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) && - (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)) { - tempah = infoflag >> 8; - if(SiS_Pr->SiS_LCDInfo & LCDSync) { - tempbl = ((SiS_Pr->SiS_LCDInfo & 0xc0) >> 6); - } - } else if((SiS_Pr->SiS_CustomT == CUT_CLEVO1400) && - (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050)) { - tempah = infoflag >> 8; - tempbl = 0x03; - } else { - tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37); - tempbl = (tempah >> 6) & 0x03; - tempbl |= 0x08; - if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempbl |= 0x04; - } - tempah &= 0xC0; - tempah |= 0x20; - if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) tempah |= 0xc0; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl); - } - } + tempbl = 0; + if((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) && + (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)) { + tempah = infoflag >> 8; + if(SiS_Pr->SiS_LCDInfo & LCDSync) { + tempbl = ((SiS_Pr->SiS_LCDInfo & 0xc0) >> 6); + } + } else if((SiS_Pr->SiS_CustomT == CUT_CLEVO1400) && + (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050)) { + tempah = infoflag >> 8; + tempbl = 0x03; + } else { + tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37); + tempbl = (tempah >> 6) & 0x03; + tempbl |= 0x08; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempbl |= 0x04; + } + tempah &= 0xC0; + tempah |= 0x20; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) tempah |= 0xc0; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl); + } + } - } else { /* 315 - TMDS */ + } else { /* 315 - TMDS */ - tempah = tempbl = infoflag >> 8; - if(!SiS_Pr->UseCustomMode) { - tempbl = 0; - if((SiS_Pr->SiS_VBType & VB_SIS301C) && (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { - if(ModeNo <= 0x13) { - tempah = SiS_GetRegByte((SiS_Pr->SiS_P3ca+0x02)); - } - } - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { - if(SiS_Pr->SiS_LCDInfo & LCDSync) { - tempah = SiS_Pr->SiS_LCDInfo; + tempah = tempbl = infoflag >> 8; + if(!SiS_Pr->UseCustomMode) { + tempbl = 0; + if((SiS_Pr->SiS_VBType & VB_SIS30xC) && (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { + if(ModeNo <= 0x13) { + tempah = SiS_GetRegByte((SiS_Pr->SiS_P3ca+0x02)); + } + } + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { + if(SiS_Pr->SiS_LCDInfo & LCDSync) { + tempah = SiS_Pr->SiS_LCDInfo; tempbl = (tempah >> 6) & 0x03; } - } - } - } - tempah &= 0xC0; - tempah |= 0x20; - if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; - if(SiS_Pr->SiS_VBType & VB_NoLCD) { - /* Imitate BIOS bug */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) tempah |= 0xc0; - } - if((SiS_Pr->SiS_VBType & VB_SIS301C) && (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { - tempah >>= 3; - tempah &= 0x18; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xe7,tempah); - } else { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl); - } - } - } + } + } + } + tempah &= 0xC0; + tempah |= 0x20; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; + if(SiS_Pr->SiS_VBType & VB_NoLCD) { + /* Imitate BIOS bug */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) tempah |= 0xc0; + } + if((SiS_Pr->SiS_VBType & VB_SIS30xC) && (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { + tempah >>= 3; + tempah &= 0x18; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xe7,tempah); + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl); + } + } + } - } + } #endif /* SIS315H */ } } } -/* Set CRT2 FIFO on 300/630/730 */ +/* Set CRT2 FIFO on 300/540/630/730 */ #ifdef SIS300 static void -SiS_SetCRT2FIFO_300(SiS_Private *SiS_Pr,USHORT ModeNo, - PSIS_HW_INFO HwInfo) -{ - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT temp,index; - USHORT modeidindex,refreshratetableindex; - USHORT VCLK=0,MCLK,colorth=0,data2=0; - USHORT tempal, tempah, tempbx, tempcl, tempax; - USHORT CRT1ModeNo,CRT2ModeNo; - USHORT SelectRate_backup; - ULONG data,eax; - const UCHAR LatencyFactor[] = { - 97, 88, 86, 79, 77, 00, /*; 64 bit BQ=2 */ - 00, 87, 85, 78, 76, 54, /*; 64 bit BQ=1 */ - 97, 88, 86, 79, 77, 00, /*; 128 bit BQ=2 */ - 00, 79, 77, 70, 68, 48, /*; 128 bit BQ=1 */ - 80, 72, 69, 63, 61, 00, /*; 64 bit BQ=2 */ - 00, 70, 68, 61, 59, 37, /*; 64 bit BQ=1 */ - 86, 77, 75, 68, 66, 00, /*; 128 bit BQ=2 */ - 00, 68, 66, 59, 57, 37 /*; 128 bit BQ=1 */ - }; - const UCHAR LatencyFactor730[] = { - 69, 63, 61, - 86, 79, 77, - 103, 96, 94, - 120,113,111, - 137,130,128, /* <-- last entry, data below */ - 137,130,128, /* to avoid using illegal values */ - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - }; - const UCHAR ThLowB[] = { - 81, 4, 72, 6, 88, 8,120,12, - 55, 4, 54, 6, 66, 8, 90,12, - 42, 4, 45, 6, 55, 8, 75,12 - }; - const UCHAR ThTiming[] = { - 1, 2, 2, 3, 0, 1, 1, 2 +SiS_SetCRT2FIFO_300(struct SiS_Private *SiS_Pr,unsigned short ModeNo) +{ + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short temp, index, modeidindex, refreshratetableindex; + unsigned short VCLK = 0, MCLK, colorth = 0, data2 = 0; + unsigned short tempbx, tempcl, CRT1ModeNo, CRT2ModeNo, SelectRate_backup; + unsigned int data, pci50, pciA0; + static const unsigned char colortharray[] = { + 1, 1, 2, 2, 3, 4 }; SelectRate_backup = SiS_Pr->SiS_SelectCRT2Rate; @@ -5044,232 +5106,159 @@ SiS_SetCRT2FIFO_300(SiS_Private *SiS_Pr,USHORT ModeNo, SiS_SearchModeID(SiS_Pr, &CRT1ModeNo, &modeidindex); SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); SiS_Pr->SiS_SelectCRT2Rate = 0; - refreshratetableindex = SiS_GetRatePtr(SiS_Pr, CRT1ModeNo, modeidindex, HwInfo); + refreshratetableindex = SiS_GetRatePtr(SiS_Pr, CRT1ModeNo, modeidindex); if(CRT1ModeNo >= 0x13) { - index = SiS_Pr->SiS_RefIndex[refreshratetableindex].Ext_CRTVCLK; - index &= 0x3F; - VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ + /* Get VCLK */ + index = SiS_GetRefCRTVCLK(SiS_Pr, refreshratetableindex, SiS_Pr->SiS_UseWide); + VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; - colorth = SiS_GetColorDepth(SiS_Pr,CRT1ModeNo,modeidindex); /* Get colordepth */ - colorth >>= 1; - if(!colorth) colorth++; + /* Get colordepth */ + colorth = SiS_GetColorDepth(SiS_Pr,CRT1ModeNo,modeidindex) >> 1; + if(!colorth) colorth++; } } else { CRT1ModeNo = 0xfe; - VCLK = SiS_Pr->CSRClock_CRT1; /* Get VCLK */ - data2 = (SiS_Pr->CModeFlag_CRT1 & ModeTypeMask) - 2; - switch(data2) { /* Get color depth */ - case 0 : colorth = 1; break; - case 1 : colorth = 1; break; - case 2 : colorth = 2; break; - case 3 : colorth = 2; break; - case 4 : colorth = 3; break; - case 5 : colorth = 4; break; - default: colorth = 2; - } + + /* Get VCLK */ + VCLK = SiS_Pr->CSRClock_CRT1; + + /* Get color depth */ + colorth = colortharray[((SiS_Pr->CModeFlag_CRT1 & ModeTypeMask) - 2)]; } if(CRT1ModeNo >= 0x13) { - if(HwInfo->jChipType == SIS_300) { - index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x3A); - } else { - index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1A); - } - index &= 0x07; - MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; /* Get MCLK */ + /* Get MCLK */ + if(SiS_Pr->ChipType == SIS_300) { + index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x3A); + } else { + index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1A); + } + index &= 0x07; + MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; - data2 = (colorth * VCLK) / MCLK; + temp = ((SiS_GetReg(SiS_Pr->SiS_P3c4,0x14) >> 6) & 0x03) << 1; + if(!temp) temp++; + temp <<= 2; - temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); - temp = ((temp & 0x00FF) >> 6) << 1; - if(temp == 0) temp = 1; - temp <<= 2; - temp &= 0xff; + data2 = temp - ((colorth * VCLK) / MCLK); - data2 = temp - data2; + temp = (28 * 16) % data2; + data2 = (28 * 16) / data2; + if(temp) data2++; - if((28 * 16) % data2) { - data2 = (28 * 16) / data2; - data2++; - } else { - data2 = (28 * 16) / data2; - } + if(SiS_Pr->ChipType == SIS_300) { - if(HwInfo->jChipType == SIS_300) { - - tempah = SiS_GetReg(SiS_Pr->SiS_P3c4,0x18); - tempah &= 0x62; - tempah >>= 1; - tempal = tempah; - tempah >>= 3; - tempal |= tempah; - tempal &= 0x07; - tempcl = ThTiming[tempal]; - tempbx = SiS_GetReg(SiS_Pr->SiS_P3c4,0x16); - tempbx >>= 6; - tempah = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); - tempah >>= 4; - tempah &= 0x0c; - tempbx |= tempah; - tempbx <<= 1; - tempal = ThLowB[tempbx + 1]; - tempal *= tempcl; - tempal += ThLowB[tempbx]; - data = tempal; - - } else if(HwInfo->jChipType == SIS_730) { - -#ifdef LINUX_KERNEL - SiS_SetRegLong(0xcf8,0x80000050); - eax = SiS_GetRegLong(0xcfc); + SiS_GetFIFOThresholdIndex300(SiS_Pr, &tempbx, &tempcl); + data = SiS_GetFIFOThresholdB300(tempbx, tempcl); + + } else { + +#ifdef SIS_LINUX_KERNEL + pci50 = sisfb_read_nbridge_pci_dword(SiS_Pr, 0x50); + pciA0 = sisfb_read_nbridge_pci_dword(SiS_Pr, 0xa0); #else - eax = pciReadLong(0x00000000, 0x50); + pci50 = pciReadLong(0x00000000, 0x50); + pciA0 = pciReadLong(0x00000000, 0xA0); #endif - tempal = (USHORT)(eax >> 8); - tempal &= 0x06; - tempal <<= 5; -#ifdef LINUX_KERNEL - SiS_SetRegLong(0xcf8,0x800000A0); - eax = SiS_GetRegLong(0xcfc); -#else - eax = pciReadLong(0x00000000, 0xA0); -#endif - temp = (USHORT)(eax >> 28); - temp &= 0x0F; - tempal |= temp; - - tempbx = tempal; /* BIOS BUG (2.04.5d, 2.04.6a use ah here, which is unset!) */ - tempbx = 0; /* -- do it like the BIOS anyway... */ - tempax = tempbx; - tempbx &= 0xc0; - tempbx >>= 6; - tempax &= 0x0f; - tempax *= 3; - tempbx += tempax; - - data = LatencyFactor730[tempbx]; - data += 15; - temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); - if(!(temp & 0x80)) data += 5; + if(SiS_Pr->ChipType == SIS_730) { - } else { + index = (unsigned short)(((pciA0 >> 28) & 0x0f) * 3); + index += (unsigned short)(((pci50 >> 9)) & 0x03); - index = 0; - temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); - if(temp & 0x0080) index += 12; + /* BIOS BUG (2.04.5d, 2.04.6a use ah here, which is unset!) */ + index = 0; /* -- do it like the BIOS anyway... */ -#ifdef LINUX_KERNEL - SiS_SetRegLong(0xcf8,0x800000A0); - eax = SiS_GetRegLong(0xcfc); -#else - /* We use pci functions X offers. We use tag 0, because - * we want to read/write to the host bridge (which is always - * 00:00.0 on 630, 730 and 540), not the VGA device. - */ - eax = pciReadLong(0x00000000, 0xA0); -#endif - temp = (USHORT)(eax >> 24); - if(!(temp&0x01)) index += 24; - -#ifdef LINUX_KERNEL - SiS_SetRegLong(0xcf8,0x80000050); - eax = SiS_GetRegLong(0xcfc); -#else - eax = pciReadLong(0x00000000, 0x50); -#endif - temp=(USHORT)(eax >> 24); - if(temp & 0x01) index += 6; + } else { - temp = (temp & 0x0F) >> 1; - index += temp; + pci50 >>= 24; + pciA0 >>= 24; - data = LatencyFactor[index]; - data += 15; - temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); - if(!(temp & 0x80)) data += 5; - } + index = (pci50 >> 1) & 0x07; - data += data2; /* CRT1 Request Period */ + if(pci50 & 0x01) index += 6; + if(!(pciA0 & 0x01)) index += 24; - SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; - SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup; + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x14) & 0x80) index += 12; - if(!SiS_Pr->UseCustomMode) { + } - CRT2ModeNo = ModeNo; - SiS_SearchModeID(SiS_Pr, &CRT2ModeNo, &modeidindex); + data = SiS_GetLatencyFactor630(SiS_Pr, index) + 15; + if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x14) & 0x80)) data += 5; - refreshratetableindex = SiS_GetRatePtr(SiS_Pr, CRT2ModeNo, modeidindex, HwInfo); + } - index = SiS_GetVCLK2Ptr(SiS_Pr,CRT2ModeNo,modeidindex, - refreshratetableindex,HwInfo); - VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ + data += data2; /* CRT1 Request Period */ - if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { - if(SiS_Pr->SiS_UseROM) { - if(ROMAddr[0x220] & 0x01) { - VCLK = ROMAddr[0x229] | (ROMAddr[0x22a] << 8); - } - } - } + SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; + SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup; - } else { + if(!SiS_Pr->UseCustomMode) { - CRT2ModeNo = 0xfe; - VCLK = SiS_Pr->CSRClock; /* Get VCLK */ + CRT2ModeNo = ModeNo; + SiS_SearchModeID(SiS_Pr, &CRT2ModeNo, &modeidindex); - } + refreshratetableindex = SiS_GetRatePtr(SiS_Pr, CRT2ModeNo, modeidindex); - colorth = SiS_GetColorDepth(SiS_Pr,CRT2ModeNo,modeidindex); /* Get colordepth */ - colorth >>= 1; - if(!colorth) colorth++; + /* Get VCLK */ + index = SiS_GetVCLK2Ptr(SiS_Pr, CRT2ModeNo, modeidindex, refreshratetableindex); + VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; - data = data * VCLK * colorth; - if(data % (MCLK << 4)) { - data = data / (MCLK << 4); - data++; - } else { - data = data / (MCLK << 4); - } + if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { + if(SiS_Pr->SiS_UseROM) { + if(ROMAddr[0x220] & 0x01) { + VCLK = ROMAddr[0x229] | (ROMAddr[0x22a] << 8); + } + } + } - if(data <= 6) data = 6; - if(data > 0x14) data = 0x14; + } else { - temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x01); - if(HwInfo->jChipType == SIS_300) { - if(data <= 0x0f) temp = (temp & (~0x1F)) | 0x13; - else temp = (temp & (~0x1F)) | 0x16; - if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) { - temp = (temp & (~0x1F)) | 0x13; - } - } else { - if( ( (HwInfo->jChipType == SIS_630) || - (HwInfo->jChipType == SIS_730) ) && - (HwInfo->jChipRevision >= 0x30) ) /* 630s or 730(s?) */ - { - temp = (temp & (~0x1F)) | 0x1b; - } else { - temp = (temp & (~0x1F)) | 0x16; - } - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0xe0,temp); + /* Get VCLK */ + CRT2ModeNo = 0xfe; + VCLK = SiS_Pr->CSRClock; - if( (HwInfo->jChipType == SIS_630) && - (HwInfo->jChipRevision >= 0x30) ) /* 630s, NOT 730 */ - { - if(data > 0x13) data = 0x13; - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x02,0xe0,data); + } + + /* Get colordepth */ + colorth = SiS_GetColorDepth(SiS_Pr,CRT2ModeNo,modeidindex) >> 1; + if(!colorth) colorth++; + + data = data * VCLK * colorth; + temp = data % (MCLK << 4); + data = data / (MCLK << 4); + if(temp) data++; + + if(data < 6) data = 6; + else if(data > 0x14) data = 0x14; + + if(SiS_Pr->ChipType == SIS_300) { + temp = 0x16; + if((data <= 0x0f) || (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)) + temp = 0x13; + } else { + temp = 0x16; + if(( (SiS_Pr->ChipType == SIS_630) || + (SiS_Pr->ChipType == SIS_730) ) && + (SiS_Pr->ChipRevision >= 0x30)) + temp = 0x1b; + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0xe0,temp); + + if((SiS_Pr->ChipType == SIS_630) && + (SiS_Pr->ChipRevision >= 0x30)) { + if(data > 0x13) data = 0x13; + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x02,0xe0,data); } else { /* If mode <= 0x13, we just restore everything */ - SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; - SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup; + SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; + SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup; } } @@ -5278,10 +5267,10 @@ SiS_SetCRT2FIFO_300(SiS_Private *SiS_Pr,USHORT ModeNo, /* Set CRT2 FIFO on 315/330 series */ #ifdef SIS315H static void -SiS_SetCRT2FIFO_310(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_SetCRT2FIFO_310(struct SiS_Private *SiS_Pr) { SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,0x3B); - if( (HwInfo->jChipType == SIS_760) && + if( (SiS_Pr->ChipType == SIS_760) && (SiS_Pr->SiS_SysFlags & SF_760LFB) && (SiS_Pr->SiS_ModeType == Mode32Bpp) && (SiS_Pr->SiS_VGAHDE >= 1280) && @@ -5299,337 +5288,162 @@ SiS_SetCRT2FIFO_310(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) } #endif -static USHORT -SiS_GetVGAHT2(SiS_Private *SiS_Pr) +static unsigned short +SiS_GetVGAHT2(struct SiS_Private *SiS_Pr) { - ULONG tempax,tempbx; + unsigned int tempax,tempbx; tempbx = (SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE) * SiS_Pr->SiS_RVBHCMAX; tempax = (SiS_Pr->SiS_VT - SiS_Pr->SiS_VDE) * SiS_Pr->SiS_RVBHCFACT; tempax = (tempax * SiS_Pr->SiS_HT) / tempbx; - return((USHORT)tempax); + return (unsigned short)tempax; } /* Set Part 1 / SiS bridge slave mode */ static void -SiS_SetGroup1_301(SiS_Private *SiS_Pr, USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo,USHORT RefreshRateTableIndex) -{ - USHORT push1,push2; - USHORT tempax,tempbx,tempcx,temp; - USHORT resinfo,modeflag,xres=0; - unsigned char p1_7, p1_8; +SiS_SetGroup1_301(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) +{ + unsigned short temp, modeflag, i, j, xres=0, VGAVDE; + static const unsigned short CRTranslation[] = { + /* CR0 CR1 CR2 CR3 CR4 CR5 CR6 CR7 */ + 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, + /* CR8 CR9 SR0A SR0B SR0C SR0D SR0E CR0F */ + 0x00, 0x0b, 0x17, 0x18, 0x19, 0x00, 0x1a, 0x00, + /* CR10 CR11 CR12 CR13 CR14 CR15 CR16 CR17 */ + 0x0c, 0x0d, 0x0e, 0x00, 0x0f, 0x10, 0x11, 0x00 + }; if(ModeNo <= 0x13) { modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; } else if(SiS_Pr->UseCustomMode) { modeflag = SiS_Pr->CModeFlag; - resinfo = 0; xres = SiS_Pr->CHDisplay; } else { modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; xres = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].XRes; } /* The following is only done if bridge is in slave mode: */ - if((HwInfo->jChipType >= SIS_661) && (ModeNo > 0x13)) { - if(xres >= 1600) { + if(SiS_Pr->ChipType >= SIS_315H) { + if(xres >= 1600) { /* BIOS: == 1600 */ SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x31,0x04); } } - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x03,0xff); /* set MAX HT */ - - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) modeflag |= Charx8Dot; + SiS_Pr->CHTotal = 8224; /* Max HT, 0x2020, results in 0x3ff in registers */ - if(modeflag & Charx8Dot) tempcx = 0x08; - else tempcx = 0x09; - - tempax = SiS_Pr->SiS_VGAHDE; /* 0x04 Horizontal Display End */ - if(modeflag & HalfDCLK) tempax >>= 1; - tempax = ((tempax / tempcx) - 1) & 0xff; - tempbx = tempax; - - temp = tempax; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x04,temp); + SiS_Pr->CHDisplay = SiS_Pr->SiS_VGAHDE; + if(modeflag & HalfDCLK) SiS_Pr->CHDisplay >>= 1; + SiS_Pr->CHBlankStart = SiS_Pr->CHDisplay; if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { - temp += 2; - } - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - if(resinfo == SIS_RI_800x600) temp -= 2; - } - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x05,temp); /* 0x05 Horizontal Display Start */ - - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x06,0x03); /* 0x06 Horizontal Blank end */ - - tempax = 0xFFFF; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempax = SiS_GetVGAHT2(SiS_Pr); - if(tempax >= SiS_Pr->SiS_VGAHT) tempax = SiS_Pr->SiS_VGAHT; - if(modeflag & HalfDCLK) tempax >>= 1; - tempax = (tempax / tempcx) - 5; - tempcx = tempax; - - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - temp = tempcx - 1; - if(!(modeflag & HalfDCLK)) { - temp -= 6; - if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { - temp -= 2; - if(ModeNo > 0x13) temp -= 10; - } - } - } else { - tempcx = (tempcx + tempbx) >> 1; - temp = (tempcx & 0x00FF) + 2; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - temp--; - if(!(modeflag & HalfDCLK)) { - if((modeflag & Charx8Dot)) { - temp += 4; - if(SiS_Pr->SiS_VGAHDE >= 800) temp -= 6; - if(HwInfo->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_VGAHDE == 800) temp += 2; - } - } - } - } else { - if(!(modeflag & HalfDCLK)) { - temp -= 4; - if((SiS_Pr->SiS_LCDResInfo != Panel_1280x960) && - (SiS_Pr->SiS_LCDResInfo != Panel_1600x1200)) { - if(SiS_Pr->SiS_VGAHDE >= 800) { - temp -= 7; - if(HwInfo->jChipType < SIS_315H) { - if(SiS_Pr->SiS_ModeType == ModeEGA) { - if(SiS_Pr->SiS_VGAVDE == 1024) { - temp += 15; - if(SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) - temp += 7; - } - } - } - if(SiS_Pr->SiS_LCDResInfo != Panel_1400x1050) { - if(SiS_Pr->SiS_VGAHDE >= 1280) { - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) temp += 28; - } - } - } - } - } - } + SiS_Pr->CHBlankStart += 16; } - p1_7 = temp; - p1_8 = 0x00; - - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { - if(ModeNo <= 0x01) { - p1_7 = 0x2a; - if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) p1_8 = 0x61; - else p1_8 = 0x41; - } else if(SiS_Pr->SiS_ModeType == ModeText) { - if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) p1_7 = 0x54; - else p1_7 = 0x55; - p1_8 = 0x00; - } else if(ModeNo <= 0x13) { - if(modeflag & HalfDCLK) { - if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { - p1_7 = 0x30; - p1_8 = 0x03; - } else { - p1_7 = 0x2f; - p1_8 = 0x02; - } - } else { - p1_7 = 0x5b; - p1_8 = 0x03; - } - } else if( ((HwInfo->jChipType >= SIS_315H) && - ((ModeNo == 0x50) || (ModeNo == 0x56) || (ModeNo == 0x53))) || - ((HwInfo->jChipType < SIS_315H) && - (resinfo == SIS_RI_320x200 || resinfo == SIS_RI_320x240)) ) { - if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { - p1_7 = 0x30, - p1_8 = 0x03; - } else { - p1_7 = 0x2f; - p1_8 = 0x03; - } - } - } + SiS_Pr->CHBlankEnd = 32; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(xres == 1600) SiS_Pr->CHBlankEnd += 80; } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { - if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p|TVSetYPbPr750p)) { - p1_7 = 0x63; - if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) p1_7 = 0x55; - } - if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { - if(!(modeflag & HalfDCLK)) { - p1_7 = 0xb2; - if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { - p1_7 = 0xab; - } - } - } else { - if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) { - if(modeflag & HalfDCLK) p1_7 = 0x30; - } - } + temp = SiS_Pr->SiS_VGAHT - 96; + if(!(modeflag & HalfDCLK)) temp -= 32; + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x04); + temp |= ((SiS_GetReg(SiS_Pr->SiS_P3c4,0x0b) & 0xc0) << 2); + temp -= 3; + temp <<= 3; + } else { + if(SiS_Pr->SiS_RVBHRS2) temp = SiS_Pr->SiS_RVBHRS2; } + SiS_Pr->CHSyncStart = temp; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x07,p1_7); /* 0x07 Horizontal Retrace Start */ - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x08,p1_8); /* 0x08 Horizontal Retrace End */ + SiS_Pr->CHSyncEnd = 0xffe8; /* results in 0x2000 in registers */ - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x03); /* 0x18 SR08 (FIFO Threshold?) */ + SiS_Pr->CVTotal = 2049; /* Max VT, 0x0801, results in 0x7ff in registers */ - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x19,0xF0); + VGAVDE = SiS_Pr->SiS_VGAVDE; + if (VGAVDE == 357) VGAVDE = 350; + else if(VGAVDE == 360) VGAVDE = 350; + else if(VGAVDE == 375) VGAVDE = 350; + else if(VGAVDE == 405) VGAVDE = 400; + else if(VGAVDE == 420) VGAVDE = 400; + else if(VGAVDE == 525) VGAVDE = 480; + else if(VGAVDE == 1056) VGAVDE = 1024; + SiS_Pr->CVDisplay = VGAVDE; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x09,0xFF); /* 0x09 Set Max VT */ + SiS_Pr->CVBlankStart = SiS_Pr->CVDisplay; - tempcx = 0x121; - tempbx = SiS_Pr->SiS_VGAVDE; /* 0x0E Vertical Display End */ - if (tempbx == 357) tempbx = 350; - else if(tempbx == 360) tempbx = 350; - else if(tempbx == 375) tempbx = 350; - else if(tempbx == 405) tempbx = 400; - else if(tempbx == 420) tempbx = 400; - else if(tempbx == 525) tempbx = 480; - push2 = tempbx; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { - if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { - if (tempbx == 350) tempbx += 5; - else if(tempbx == 480) tempbx += 5; - } - } - } - tempbx -= 2; - temp = tempbx & 0x00FF; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x10,temp); /* 0x10 vertical Blank Start */ - - tempbx = push2; - tempbx--; - temp = tempbx & 0x00FF; -#if 0 - /* Missing code from 630/301B 2.04.5a and 650/302LV 1.10.6s (calles int 2f) */ - if(xxx()) { - if(temp == 0xdf) temp = 0xda; - } -#endif - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0E,temp); - - temp = 0; - if(modeflag & DoubleScanMode) temp |= 0x80; - if(HwInfo->jChipType >= SIS_661) { - if(tempbx & 0x0200) temp |= 0x20; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x0B,0x5F,temp); - if(tempbx & 0x0100) tempcx |= 0x000a; - if(tempbx & 0x0400) tempcx |= 0x1200; - } else { - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0B,temp); - if(tempbx & 0x0100) tempcx |= 0x0002; - if(tempbx & 0x0400) tempcx |= 0x0600; - } + SiS_Pr->CVBlankEnd = 1; + if(ModeNo == 0x3c) SiS_Pr->CVBlankEnd = 226; - if(tempbx & 0x0200) tempcx |= 0x0040; + temp = (SiS_Pr->SiS_VGAVT - VGAVDE) >> 1; + SiS_Pr->CVSyncStart = VGAVDE + temp; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x11,0x00); /* 0x11 Vertical Blank End */ + temp >>= 3; + SiS_Pr->CVSyncEnd = SiS_Pr->CVSyncStart + temp; - tempax = (SiS_Pr->SiS_VGAVT - tempbx) >> 2; + SiS_CalcCRRegisters(SiS_Pr, 0); + SiS_Pr->CCRT1CRTC[16] &= ~0xE0; - if((ModeNo > 0x13) || (HwInfo->jChipType < SIS_315H)) { - if(resinfo != SIS_RI_1280x1024) { - tempbx += (tempax << 1); - } - } else if(HwInfo->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_LCDResInfo != Panel_1400x1050) { - tempbx += (tempax << 1); - } + for(i = 0; i <= 7; i++) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,CRTranslation[i],SiS_Pr->CCRT1CRTC[i]); } - - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - tempbx -= 10; - } else { - if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { - if(SiS_Pr->SiS_TVMode & TVSetPAL) { - tempbx += 40; - if(HwInfo->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_VGAHDE == 800) tempbx += 10; - } - } - } - } - tempax >>= 2; - tempax++; - tempax += tempbx; - push1 = tempax; - if(SiS_Pr->SiS_TVMode & TVSetPAL) { - if(tempbx <= 513) { - if(tempax >= 513) tempbx = 513; - } + for(i = 0x10, j = 8; i <= 0x12; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,CRTranslation[i],SiS_Pr->CCRT1CRTC[j]); } - temp = tempbx & 0x00FF; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0C,temp); /* 0x0C Vertical Retrace Start */ - - tempbx--; - temp = tempbx & 0x00FF; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x10,temp); - - if(tempbx & 0x0100) tempcx |= 0x0008; - - if(tempbx & 0x0200) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x0B,0x20); + for(i = 0x15, j = 11; i <= 0x16; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,CRTranslation[i],SiS_Pr->CCRT1CRTC[j]); } - tempbx++; - - if(tempbx & 0x0100) tempcx |= 0x0004; - if(tempbx & 0x0200) tempcx |= 0x0080; - if(tempbx & 0x0400) { - if(HwInfo->jChipType >= SIS_661) tempcx |= 0x0800; - else if(SiS_Pr->SiS_VBType & VB_SIS301) tempcx |= 0x0800; - else tempcx |= 0x0C00; + for(i = 0x0a, j = 13; i <= 0x0c; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,CRTranslation[i],SiS_Pr->CCRT1CRTC[j]); } - tempbx = push1; - temp = tempbx & 0x000F; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0D,temp); /* 0x0D vertical Retrace End */ - - if(tempbx & 0x0010) tempcx |= 0x2000; - - temp = tempcx & 0x00FF; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0A,temp); /* 0x0A CR07 */ - - temp = (tempcx & 0xFF00) >> 8; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x17,temp); /* 0x17 SR0A */ + temp = SiS_Pr->CCRT1CRTC[16] & 0xE0; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,CRTranslation[0x0E],0x1F,temp); - tempax = modeflag; - temp = (tempax & 0xFF00) >> 8; - temp = (temp >> 1) & 0x09; - if(!(SiS_Pr->SiS_VBType & VB_SIS301)) temp |= 0x01; /* Always 8 dotclock */ - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x16,temp); /* 0x16 SR01 */ + temp = (SiS_Pr->CCRT1CRTC[16] & 0x01) << 5; + if(modeflag & DoubleScanMode) temp |= 0x80; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,CRTranslation[0x09],0x5F,temp); - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0F,0x00); /* 0x0F CR14 */ + temp = 0; + temp |= (SiS_GetReg(SiS_Pr->SiS_P3c4,0x01) & 0x01); + if(modeflag & HalfDCLK) temp |= 0x08; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x16,temp); /* SR01: HalfDCLK[3], 8/9 div dotclock[0] */ - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x12,0x00); /* 0x12 CR17 */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0F,0x00); /* CR14: (text mode: underline location) */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x12,0x00); /* CR17: n/a */ - temp = 0x00; + temp = 0; if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { - if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x01) { - temp = 0x80; - } + temp = (SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x01) << 7; } - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1A,temp); /* 0x1A SR0E */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1A,temp); /* SR0E, dither[7] */ temp = SiS_GetRegByte((SiS_Pr->SiS_P3ca+0x02)); - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,temp); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,temp); /* ? */ + +#ifdef SIS_XORG_XF86 +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "%d %d %d %d %d %d %d %d (%d %d %d %d)\n", + SiS_Pr->CHDisplay, SiS_Pr->CHSyncStart, SiS_Pr->CHSyncEnd, SiS_Pr->CHTotal, + SiS_Pr->CVDisplay, SiS_Pr->CVSyncStart, SiS_Pr->CVSyncEnd, SiS_Pr->CVTotal, + SiS_Pr->CHBlankStart, SiS_Pr->CHBlankEnd, SiS_Pr->CVBlankStart, SiS_Pr->CVBlankEnd); + + xf86DrvMsg(0, X_INFO, " {{0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,\n", + SiS_Pr->CCRT1CRTC[0], SiS_Pr->CCRT1CRTC[1], + SiS_Pr->CCRT1CRTC[2], SiS_Pr->CCRT1CRTC[3], + SiS_Pr->CCRT1CRTC[4], SiS_Pr->CCRT1CRTC[5], + SiS_Pr->CCRT1CRTC[6], SiS_Pr->CCRT1CRTC[7]); + xf86DrvMsg(0, X_INFO, " 0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,\n", + SiS_Pr->CCRT1CRTC[8], SiS_Pr->CCRT1CRTC[9], + SiS_Pr->CCRT1CRTC[10], SiS_Pr->CCRT1CRTC[11], + SiS_Pr->CCRT1CRTC[12], SiS_Pr->CCRT1CRTC[13], + SiS_Pr->CCRT1CRTC[14], SiS_Pr->CCRT1CRTC[15]); + xf86DrvMsg(0, X_INFO, " 0x%02x}},\n", SiS_Pr->CCRT1CRTC[16]); +#endif +#endif } /* Setup panel link @@ -5637,18 +5451,18 @@ SiS_SetGroup1_301(SiS_Private *SiS_Pr, USHORT ModeNo,USHORT ModeIdIndex, * 300/LVDS+TV, 300/301B-DH, 315/LVDS+TV, 315/LCDA */ static void -SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo, USHORT RefreshRateTableIndex) +SiS_SetGroup1_LVDS(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) { - USHORT modeflag,resinfo; - USHORT push2,tempax,tempbx,tempcx,temp; - ULONG tempeax=0,tempebx,tempecx,tempvcfact=0; + unsigned short modeflag, resinfo = 0; + unsigned short push2, tempax, tempbx, tempcx, temp; + unsigned int tempeax = 0, tempebx, tempecx, tempvcfact = 0; BOOLEAN islvds = FALSE, issis = FALSE, chkdclkfirst = FALSE; #ifdef SIS300 - USHORT crt2crtc; + unsigned short crt2crtc = 0; #endif #ifdef SIS315H - USHORT pushcx; + unsigned short pushcx; #endif if(ModeNo <= 0x13) { @@ -5659,15 +5473,11 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, #endif } else if(SiS_Pr->UseCustomMode) { modeflag = SiS_Pr->CModeFlag; - resinfo = 0; -#ifdef SIS300 - crt2crtc = 0; -#endif } else { modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; #ifdef SIS300 - crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + crt2crtc = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; #endif } @@ -5681,14 +5491,14 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, issis = TRUE; } - if((HwInfo->jChipType >= SIS_315H) && (islvds) && (!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA))) { + if((SiS_Pr->ChipType >= SIS_315H) && (islvds) && (!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA))) { if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) { chkdclkfirst = TRUE; } } #ifdef SIS315H - if((HwInfo->jChipType >= SIS_315H) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + if((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { if(IS_SIS330) { SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x10); } else if(IS_SIS740) { @@ -5704,7 +5514,7 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x00); } else if(SiS_Pr->SiS_VBType & VB_SISVB) { SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2D,0x0f); - if(SiS_Pr->SiS_VBType & VB_SIS301C) { + if(SiS_Pr->SiS_VBType & VB_SIS30xC) { if((SiS_Pr->SiS_LCDResInfo == Panel_1024x768) || (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)) { SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x20); @@ -5720,10 +5530,10 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, tempax = SiS_Pr->SiS_LCDHDES; if(islvds) { if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) { - if((SiS_Pr->SiS_LCDResInfo == Panel_640x480) && - (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode))) { - tempax -= 8; + if(!SiS_Pr->SiS_IF_DEF_FSTN && !SiS_Pr->SiS_IF_DEF_DSTN) { + if((SiS_Pr->SiS_LCDResInfo == Panel_640x480) && + (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode))) { + tempax -= 8; } } } @@ -5736,13 +5546,14 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, tempbx = SiS_Pr->SiS_HDE; if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - if((SiS_Pr->SiS_LCDResInfo == Panel_640x480_2) || - (SiS_Pr->SiS_LCDResInfo == Panel_640x480_3)) { - tempbx >>= 1; - } if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { tempbx = SiS_Pr->PanelXRes; } + if((SiS_Pr->SiS_LCDResInfo == Panel_320x240_1) || + (SiS_Pr->SiS_LCDResInfo == Panel_320x240_2) || + (SiS_Pr->SiS_LCDResInfo == Panel_320x240_3)) { + tempbx >>= 1; + } } tempax += tempbx; @@ -5767,25 +5578,25 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, temp = (tempcx >> 3) & 0x00FF; if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { if(SiS_Pr->SiS_IF_DEF_TRUMPION) { - if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { - switch(ModeNo) { - case 0x04: - case 0x05: - case 0x0d: temp = 0x56; break; - case 0x10: temp = 0x60; break; - case 0x13: temp = 0x5f; break; - case 0x40: - case 0x41: - case 0x4f: - case 0x43: - case 0x44: - case 0x62: - case 0x56: - case 0x53: - case 0x5d: - case 0x5e: temp = 0x54; break; - } - } + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { + switch(ModeNo) { + case 0x04: + case 0x05: + case 0x0d: temp = 0x56; break; + case 0x10: temp = 0x60; break; + case 0x13: temp = 0x5f; break; + case 0x40: + case 0x41: + case 0x4f: + case 0x43: + case 0x44: + case 0x62: + case 0x56: + case 0x53: + case 0x5d: + case 0x5e: temp = 0x54; break; + } + } } } SiS_SetReg(SiS_Pr->SiS_Part1Port,0x14,temp); /* BPLHRS */ @@ -5793,12 +5604,12 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { temp += 2; if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { - temp += 8; - if(SiS_Pr->PanelHRE != 999) { - temp = tempcx + SiS_Pr->PanelHRE; + temp += 8; + if(SiS_Pr->PanelHRE != 999) { + temp = tempcx + SiS_Pr->PanelHRE; if(temp >= SiS_Pr->SiS_HT) temp -= SiS_Pr->SiS_HT; temp >>= 3; - } + } } } else { temp += 10; @@ -5806,9 +5617,6 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, temp &= 0x1F; temp |= ((tempcx & 0x07) << 5); -#if 0 - if(SiS_Pr->SiS_IF_DEF_FSTN) temp = 0x20; /* WRONG? BIOS loads cl, not ah */ -#endif SiS_SetReg(SiS_Pr->SiS_Part1Port,0x15,temp); /* BPLHRE */ /* Vertical */ @@ -5826,9 +5634,9 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, push2 = tempbx; tempcx = SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE; - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { + if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { tempcx = SiS_Pr->SiS_VGAVT - SiS_Pr->PanelYRes; } } @@ -5844,19 +5652,19 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if(issis) tempbx++; } else { tempbx += tempcx; - if(HwInfo->jChipType < SIS_315H) tempbx++; + if(SiS_Pr->ChipType < SIS_315H) tempbx++; else if(issis) tempbx++; } - if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT; /* BPLVRS */ + if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT; temp = tempbx & 0x00FF; if(SiS_Pr->SiS_IF_DEF_TRUMPION) { if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { - if(ModeNo == 0x10) temp = 0xa9; + if(ModeNo == 0x10) temp = 0xa9; } } - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,temp); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,temp); /* BPLVRS */ tempcx >>= 3; tempcx++; @@ -5879,13 +5687,13 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } else if(SiS_Pr->SiS_VGAVDE != SiS_Pr->SiS_VDE) temp |= 0x40; if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) temp |= 0x40; tempbx = 0x87; - if((HwInfo->jChipType >= SIS_315H) || - (HwInfo->jChipRevision >= 0x30)) { + if((SiS_Pr->ChipType >= SIS_315H) || + (SiS_Pr->ChipRevision >= 0x30)) { tempbx = 0x07; if((SiS_Pr->SiS_IF_DEF_CH70xx == 1) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x03) temp |= 0x80; } - /* Chrontel 701x operates in 24bit mode (8-8-8, 2x12bit mutliplexed) via VGA2 */ + /* Chrontel 701x operates in 24bit mode (8-8-8, 2x12bit multiplexed) via VGA2 */ if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x06) & 0x10) temp |= 0x80; @@ -5896,59 +5704,58 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1A,tempbx,temp); - tempbx = push2; /* BPLVDEE */ + tempbx = push2; /* BPLVDEE */ - tempcx = SiS_Pr->SiS_LCDVDES; /* BPLVDES */ + tempcx = SiS_Pr->SiS_LCDVDES; /* BPLVDES */ if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { switch(SiS_Pr->SiS_LCDResInfo) { case Panel_640x480: - tempbx = SiS_Pr->SiS_VGAVDE - 1; - tempcx = SiS_Pr->SiS_VGAVDE; + tempbx = SiS_Pr->SiS_VGAVDE - 1; + tempcx = SiS_Pr->SiS_VGAVDE; break; case Panel_800x600: - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if(resinfo == SIS_RI_800x600) tempcx++; - } + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + if(resinfo == SIS_RI_800x600) tempcx++; + } break; case Panel_1024x600: - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if(resinfo == SIS_RI_1024x600) tempcx++; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + if(resinfo == SIS_RI_1024x600) tempcx++; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { if(resinfo == SIS_RI_800x600) tempcx++; } - } + } break; case Panel_1024x768: - if(HwInfo->jChipType < SIS_315H) { - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if(resinfo == SIS_RI_1024x768) tempcx++; + if(SiS_Pr->ChipType < SIS_315H) { + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + if(resinfo == SIS_RI_1024x768) tempcx++; } - } + } break; } } temp = ((tempbx >> 8) & 0x07) << 3; - temp = temp | ((tempcx >> 8) & 0x07); + temp |= ((tempcx >> 8) & 0x07); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1D,temp); - /* if(SiS_Pr->SiS_IF_DEF_FSTN) tempbx++; */ SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1C,tempbx); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1B,tempcx); /* Vertical scaling */ - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { #ifdef SIS300 /* 300 series */ tempeax = SiS_Pr->SiS_VGAVDE << 6; - temp = (tempeax % (ULONG)SiS_Pr->SiS_VDE); - tempeax = tempeax / (ULONG)SiS_Pr->SiS_VDE; + temp = (tempeax % (unsigned int)SiS_Pr->SiS_VDE); + tempeax = tempeax / (unsigned int)SiS_Pr->SiS_VDE; if(temp) tempeax++; if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) tempeax = 0x3F; - temp = (USHORT)(tempeax & 0x00FF); + temp = (unsigned short)(tempeax & 0x00FF); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1E,temp); /* BPLVCFACT */ tempvcfact = temp; #endif /* SIS300 */ @@ -5963,20 +5770,20 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if(temp) tempeax++; tempvcfact = tempeax; - temp = (USHORT)(tempeax & 0x00FF); + temp = (unsigned short)(tempeax & 0x00FF); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x37,temp); - temp = (USHORT)((tempeax & 0x00FF00) >> 8); + temp = (unsigned short)((tempeax & 0x00FF00) >> 8); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x36,temp); - temp = (USHORT)((tempeax & 0x00030000) >> 16); + temp = (unsigned short)((tempeax & 0x00030000) >> 16); if(SiS_Pr->SiS_VDE == SiS_Pr->SiS_VGAVDE) temp |= 0x04; SiS_SetReg(SiS_Pr->SiS_Part1Port,0x35,temp); - if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302ELV)) { - temp = (USHORT)(tempeax & 0x00FF); + if(SiS_Pr->SiS_VBType & VB_SISPART4SCALER) { + temp = (unsigned short)(tempeax & 0x00FF); SiS_SetReg(SiS_Pr->SiS_Part4Port,0x3c,temp); - temp = (USHORT)((tempeax & 0x00FF00) >> 8); + temp = (unsigned short)((tempeax & 0x00FF00) >> 8); SiS_SetReg(SiS_Pr->SiS_Part4Port,0x3b,temp); - temp = (USHORT)(((tempeax & 0x00030000) >> 16) << 6); + temp = (unsigned short)(((tempeax & 0x00030000) >> 16) << 6); SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x3a,0x3f,temp); temp = 0; if(SiS_Pr->SiS_VDE != SiS_Pr->SiS_VGAVDE) temp |= 0x08; @@ -5997,29 +5804,29 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, tempecx = 0xFFFF; } else { tempecx = tempebx / SiS_Pr->SiS_HDE; - if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->ChipType >= SIS_315H) { if(tempebx % SiS_Pr->SiS_HDE) tempecx++; } } - if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->ChipType >= SIS_315H) { tempeax = (tempebx / tempecx) - 1; } else { tempeax = ((SiS_Pr->SiS_VGAHT << 16) / tempecx) - 1; } tempecx = (tempecx << 16) | (tempeax & 0xFFFF); - temp = (USHORT)(tempecx & 0x00FF); + temp = (unsigned short)(tempecx & 0x00FF); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1F,temp); - if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->ChipType >= SIS_315H) { tempeax = (SiS_Pr->SiS_VGAVDE << 18) / tempvcfact; - tempbx = (USHORT)(tempeax & 0xFFFF); + tempbx = (unsigned short)(tempeax & 0xFFFF); } else { tempeax = SiS_Pr->SiS_VGAVDE << 6; tempbx = tempvcfact & 0x3f; if(tempbx == 0) tempbx = 64; tempeax /= tempbx; - tempbx = (USHORT)(tempeax & 0xFFFF); + tempbx = (unsigned short)(tempeax & 0xFFFF); } if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) tempbx--; if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) { @@ -6032,24 +5839,24 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_SetReg(SiS_Pr->SiS_Part1Port,0x20,temp); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x21,tempbx); - tempecx >>= 16; /* BPLHCFACT */ + tempecx >>= 16; /* BPLHCFACT */ if(!chkdclkfirst) { if(modeflag & HalfDCLK) tempecx >>= 1; } - temp = (USHORT)((tempecx & 0xFF00) >> 8); + temp = (unsigned short)((tempecx & 0xFF00) >> 8); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x22,temp); - temp = (USHORT)(tempecx & 0x00FF); + temp = (unsigned short)(tempecx & 0x00FF); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x23,temp); #ifdef SIS315H - if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->ChipType >= SIS_315H) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - if((islvds) || (SiS_Pr->SiS_VBInfo & VB_SIS301LV302LV)) { + if((islvds) || (SiS_Pr->SiS_VBInfo & VB_SISLVDS)) { SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1e,0x20); } } else { if(islvds) { - if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->ChipType == SIS_740) { SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x03); } else { SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1e,0x23); @@ -6061,17 +5868,26 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, #ifdef SIS300 if(SiS_Pr->SiS_IF_DEF_TRUMPION) { - int i; - UCHAR TrumpMode13[4] = { 0x01, 0x10, 0x2c, 0x00 }; - UCHAR TrumpMode10_1[4] = { 0x01, 0x10, 0x27, 0x00 }; - UCHAR TrumpMode10_2[4] = { 0x01, 0x16, 0x10, 0x00 }; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned char *trumpdata; + int i, j = crt2crtc; + unsigned char TrumpMode13[4] = { 0x01, 0x10, 0x2c, 0x00 }; + unsigned char TrumpMode10_1[4] = { 0x01, 0x10, 0x27, 0x00 }; + unsigned char TrumpMode10_2[4] = { 0x01, 0x16, 0x10, 0x00 }; + + if(SiS_Pr->SiS_UseROM) { + trumpdata = &ROMAddr[0x8001 + (j * 80)]; + } else { + if(SiS_Pr->SiS_LCDTypeInfo == 0x0e) j += 7; + trumpdata = &SiS300_TrumpionData[j][0]; + } SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xbf); for(i=0; i<5; i++) { - SiS_SetTrumpionBlock(SiS_Pr, &SiS300_TrumpionData[crt2crtc][0]); + SiS_SetTrumpionBlock(SiS_Pr, trumpdata); } if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { - if(ModeNo == 0x13) { + if(ModeNo == 0x13) { for(i=0; i<4; i++) { SiS_SetTrumpionBlock(SiS_Pr, &TrumpMode13[0]); } @@ -6095,67 +5911,66 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_SetReg(SiS_Pr->SiS_Part1Port,0x29,0x5A); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2A,0x4B); SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x44,~0x07,0x03); - tempax = SiS_Pr->SiS_HDE; /* Blps = lcdhdee(lcdhdes+HDE) + 64 */ - if(SiS_Pr->SiS_LCDResInfo == Panel_640x480_2 || - SiS_Pr->SiS_LCDResInfo == Panel_640x480_3) tempax >>= 1; + tempax = SiS_Pr->SiS_HDE; /* Blps = lcdhdee(lcdhdes+HDE) + 64 */ + if(SiS_Pr->SiS_LCDResInfo == Panel_320x240_1 || + SiS_Pr->SiS_LCDResInfo == Panel_320x240_2 || + SiS_Pr->SiS_LCDResInfo == Panel_320x240_3) tempax >>= 1; tempax += 64; - temp = tempax & 0x00FF; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x38,temp); - temp = ((tempax & 0xFF00) >> 8) << 3; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x38,tempax & 0xff); + temp = (tempax >> 8) << 3; SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x35,~0x078,temp); - tempax += 32; /* Blpe=lBlps+32 */ - temp = tempax & 0x00FF; - if(SiS_Pr->SiS_IF_DEF_FSTN) temp = 0; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x39,temp); - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3A,0x00); /* Bflml=0 */ - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x007,0x00); + tempax += 32; /* Blpe = lBlps+32 */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x39,tempax & 0xff); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3A,0x00); /* Bflml = 0 */ + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x3C,~0x007); tempax = SiS_Pr->SiS_VDE; - if(SiS_Pr->SiS_LCDResInfo == Panel_640x480_2 || - SiS_Pr->SiS_LCDResInfo == Panel_640x480_3) tempax >>= 1; + if(SiS_Pr->SiS_LCDResInfo == Panel_320x240_1 || + SiS_Pr->SiS_LCDResInfo == Panel_320x240_2 || + SiS_Pr->SiS_LCDResInfo == Panel_320x240_3) tempax >>= 1; tempax >>= 1; - temp = tempax & 0x00FF; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3B,temp); - temp = ((tempax & 0xFF00) >> 8) << 3; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3B,tempax & 0xff); + temp = (tempax >> 8) << 3; SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x038,temp); tempeax = SiS_Pr->SiS_HDE; - if(SiS_Pr->SiS_LCDResInfo == Panel_640x480_2 || - SiS_Pr->SiS_LCDResInfo == Panel_640x480_3) tempeax >>= 1; - tempeax <<= 2; /* BDxFIFOSTOP = (HDE*4)/128 */ - tempebx = 128; - temp = (USHORT)(tempeax % tempebx); - tempeax = tempeax / tempebx; + if(SiS_Pr->SiS_LCDResInfo == Panel_320x240_1 || + SiS_Pr->SiS_LCDResInfo == Panel_320x240_2 || + SiS_Pr->SiS_LCDResInfo == Panel_320x240_3) tempeax >>= 1; + tempeax <<= 2; /* BDxFIFOSTOP = (HDE*4)/128 */ + temp = tempeax & 0x7f; + tempeax >>= 7; if(temp) tempeax++; - temp = (USHORT)(tempeax & 0x003F); - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x45,~0x0FF,temp); - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3F,0x00); /* BDxWadrst0 */ + temp = tempeax & 0x3f; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x45,temp); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3F,0x00); /* BDxWadrst0 */ SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3E,0x00); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3D,0x10); - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x040,0x00); + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x3C,~0x040); tempax = SiS_Pr->SiS_HDE; - if(SiS_Pr->SiS_LCDResInfo == Panel_640x480_2 || - SiS_Pr->SiS_LCDResInfo == Panel_640x480_3) tempax >>= 1; - tempax >>= 4; /* BDxWadroff = HDE*4/8/8 */ + if(SiS_Pr->SiS_LCDResInfo == Panel_320x240_1 || + SiS_Pr->SiS_LCDResInfo == Panel_320x240_2 || + SiS_Pr->SiS_LCDResInfo == Panel_320x240_3) tempax >>= 1; + tempax >>= 4; /* BDxWadroff = HDE*4/8/8 */ pushcx = tempax; temp = tempax & 0x00FF; SiS_SetReg(SiS_Pr->SiS_Part1Port,0x43,temp); temp = ((tempax & 0xFF00) >> 8) << 3; SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x44,~0x0F8,temp); - tempax = SiS_Pr->SiS_VDE; /* BDxWadrst1 = BDxWadrst0 + BDxWadroff * VDE */ - if(SiS_Pr->SiS_LCDResInfo == Panel_640x480_2 || - SiS_Pr->SiS_LCDResInfo == Panel_640x480_3) tempax >>= 1; - tempeax = (tempax * pushcx); - tempebx = 0x00100000 + tempeax; - temp = (USHORT)tempebx & 0x000000FF; + tempax = SiS_Pr->SiS_VDE; /* BDxWadrst1 = BDxWadrst0 + BDxWadroff * VDE */ + if(SiS_Pr->SiS_LCDResInfo == Panel_320x240_1 || + SiS_Pr->SiS_LCDResInfo == Panel_320x240_2 || + SiS_Pr->SiS_LCDResInfo == Panel_320x240_3) tempax >>= 1; + tempeax = tempax * pushcx; + temp = tempeax & 0xFF; SiS_SetReg(SiS_Pr->SiS_Part1Port,0x42,temp); - temp = (USHORT)((tempebx & 0x0000FF00) >> 8); + temp = (tempeax & 0xFF00) >> 8; SiS_SetReg(SiS_Pr->SiS_Part1Port,0x41,temp); - temp = (USHORT)((tempebx & 0x00FF0000) >> 16); + temp = ((tempeax & 0xFF0000) >> 16) | 0x10; SiS_SetReg(SiS_Pr->SiS_Part1Port,0x40,temp); - temp = (USHORT)(((tempebx & 0x01000000) >> 24) << 7); + temp = ((tempeax & 0x01000000) >> 24) << 7; SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x080,temp); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2F,0x03); @@ -6192,20 +6007,20 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /* Set Part 1 */ static void -SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo, USHORT RefreshRateTableIndex) +SiS_SetGroup1(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) { #if defined(SIS300) || defined(SIS315H) - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; #endif - USHORT temp=0, tempax=0, tempbx=0, tempcx=0, bridgeadd=0; - USHORT pushbx=0, CRT1Index=0, modeflag, resinfo=0; + unsigned short temp=0, tempax=0, tempbx=0, tempcx=0, bridgeadd=0; + unsigned short pushbx=0, CRT1Index=0, modeflag, resinfo=0; #ifdef SIS315H - USHORT tempbl=0; + unsigned short tempbl=0; #endif if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex); + SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); return; } @@ -6214,47 +6029,47 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } else if(SiS_Pr->UseCustomMode) { modeflag = SiS_Pr->CModeFlag; } else { - CRT1Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; + CRT1Index = SiS_GetRefCRT1CRTC(SiS_Pr, RefreshRateTableIndex, SiS_Pr->SiS_UseWideCRT2); resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; } - SiS_SetCRT2Offset(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + SiS_SetCRT2Offset(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); - if( ! ((HwInfo->jChipType >= SIS_315H) && + if( ! ((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->SiS_IF_DEF_LVDS == 1) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ) { - if(HwInfo->jChipType < SIS_315H ) { + if(SiS_Pr->ChipType < SIS_315H ) { #ifdef SIS300 - SiS_SetCRT2FIFO_300(SiS_Pr, ModeNo, HwInfo); + SiS_SetCRT2FIFO_300(SiS_Pr, ModeNo); #endif } else { #ifdef SIS315H - SiS_SetCRT2FIFO_310(SiS_Pr, HwInfo); + SiS_SetCRT2FIFO_310(SiS_Pr); #endif } /* 1. Horizontal setup */ - if(HwInfo->jChipType < SIS_315H ) { + if(SiS_Pr->ChipType < SIS_315H ) { #ifdef SIS300 /* ------------- 300 series --------------*/ - temp = (SiS_Pr->SiS_VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */ - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x08,temp); /* CRT2 Horizontal Total */ + temp = (SiS_Pr->SiS_VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x08,temp); /* CRT2 Horizontal Total */ - temp = (((SiS_Pr->SiS_VGAHT - 1) & 0xFF00) >> 8) << 4; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0f,temp); /* CRT2 Horizontal Total Overflow [7:4] */ + temp = (((SiS_Pr->SiS_VGAHT - 1) & 0xFF00) >> 8) << 4; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0f,temp); /* CRT2 Horizontal Total Overflow [7:4] */ - temp = (SiS_Pr->SiS_VGAHDE + 12) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */ - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0A,temp); /* CRT2 Horizontal Display Enable End */ + temp = (SiS_Pr->SiS_VGAHDE + 12) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0A,temp); /* CRT2 Horizontal Display Enable End */ pushbx = SiS_Pr->SiS_VGAHDE + 12; /* bx BTVGA2HRS 0x0B,0x0C */ - tempcx = (SiS_Pr->SiS_VGAHT - SiS_Pr->SiS_VGAHDE) >> 2; - tempbx = pushbx + tempcx; - tempcx <<= 1; - tempcx += tempbx; + tempcx = (SiS_Pr->SiS_VGAHT - SiS_Pr->SiS_VGAHDE) >> 2; + tempbx = pushbx + tempcx; + tempcx <<= 1; + tempcx += tempbx; bridgeadd = 12; @@ -6301,7 +6116,7 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, bridgeadd = 16; if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(HwInfo->jChipType >= SIS_661) { + if(SiS_Pr->ChipType >= SIS_661) { if((SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) || (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)) { if(resinfo == SIS_RI_1280x1024) { @@ -6319,7 +6134,7 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(SiS_Pr->UseCustomMode) { + if(SiS_Pr->UseCustomMode) { tempbx = SiS_Pr->CHSyncStart + bridgeadd; tempcx = SiS_Pr->CHSyncEnd + bridgeadd; tempax = SiS_Pr->SiS_VGAHT; @@ -6341,22 +6156,22 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, cr5 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[5]; cr15 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[15]; } - tempbx = ((cr4 | ((cr14 & 0xC0) << 2)) - 3) << 3; /* (VGAHRS-3)*8 */ - tempcx = (((cr5 & 0x1f) | ((cr15 & 0x04) << (5-2))) - 3) << 3; /* (VGAHRE-3)*8 */ + tempbx = ((cr4 | ((cr14 & 0xC0) << 2)) - 3) << 3; /* (VGAHRS-3)*8 */ + tempcx = (((cr5 & 0x1f) | ((cr15 & 0x04) << (5-2))) - 3) << 3; /* (VGAHRE-3)*8 */ tempcx &= 0x00FF; tempcx |= (tempbx & 0xFF00); - tempbx += bridgeadd; - tempcx += bridgeadd; + tempbx += bridgeadd; + tempcx += bridgeadd; tempax = SiS_Pr->SiS_VGAHT; if(modeflag & HalfDCLK) tempax >>= 1; tempax--; if(tempcx > tempax) tempcx = tempax; - } + } - if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) { - tempbx = 1040; - tempcx = 1044; /* HWCursor bug! */ - } + if(SiS_Pr->SiS_TVMode & (TVSetNTSC1024 | TVSet525p1024)) { + tempbx = 1040; + tempcx = 1044; /* HWCursor bug! */ + } } @@ -6372,18 +6187,18 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, tempcx = SiS_Pr->SiS_VGAVT - 1; temp = tempcx & 0x00FF; - if(HwInfo->jChipType < SIS_661) { + if(SiS_Pr->ChipType < SIS_661) { if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSVIDEO | SetCRT2ToAVIDEO)) { temp--; } - } + } } else { - temp--; - } - } else if(HwInfo->jChipType >= SIS_315H) { + temp--; + } + } else if(SiS_Pr->ChipType >= SIS_315H) { temp--; } } @@ -6395,9 +6210,9 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, temp = ((tempbx >> 5) & 0x38) | ((tempcx >> 8) & 0x07); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x12,temp); /* Overflow */ - if((HwInfo->jChipType >= SIS_315H) && (HwInfo->jChipType < SIS_661)) { - tempbx++; - tempax = tempbx; + if((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->ChipType < SIS_661)) { + tempbx++; + tempax = tempbx; tempcx++; tempcx -= tempax; tempcx >>= 2; @@ -6407,8 +6222,8 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, tempcx += tempbx; tempcx++; } else { - tempbx = (SiS_Pr->SiS_VGAVT + SiS_Pr->SiS_VGAVDE) >> 1; /* BTVGA2VRS 0x10,0x11 */ - tempcx = ((SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE) >> 4) + tempbx + 1; /* BTVGA2VRE 0x11 */ + tempbx = (SiS_Pr->SiS_VGAVT + SiS_Pr->SiS_VGAVDE) >> 1; /* BTVGA2VRS 0x10,0x11 */ + tempcx = ((SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE) >> 4) + tempbx + 1; /* BTVGA2VRE 0x11 */ } if(SiS_Pr->SiS_VBType & VB_SISVB) { @@ -6416,7 +6231,7 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, tempbx = SiS_Pr->CVSyncStart; tempcx = SiS_Pr->CVSyncEnd; } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { unsigned char cr8, cr7, cr13; if(SiS_Pr->UseCustomMode) { cr8 = SiS_Pr->CCRT1CRTC[8]; @@ -6429,11 +6244,11 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, cr13 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[13]; tempcx = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[9]; } - tempbx = cr8; - if(cr7 & 0x04) tempbx |= 0x0100; - if(cr7 & 0x80) tempbx |= 0x0200; - if(cr13 & 0x08) tempbx |= 0x0400; - } + tempbx = cr8; + if(cr7 & 0x04) tempbx |= 0x0100; + if(cr7 & 0x80) tempbx |= 0x0200; + if(cr13 & 0x08) tempbx |= 0x0400; + } } SiS_SetReg(SiS_Pr->SiS_Part1Port,0x10,tempbx); /* CRT2 Vertical Retrace Start */ @@ -6442,13 +6257,13 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /* 3. Panel delay compensation */ - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { #ifdef SIS300 /* ---------- 300 series -------------- */ if(SiS_Pr->SiS_VBType & VB_SISVB) { temp = 0x20; - if(HwInfo->jChipType == SIS_300) { + if(SiS_Pr->ChipType == SIS_300) { temp = 0x10; if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) temp = 0x2c; if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) temp = 0x20; @@ -6460,24 +6275,23 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if(SiS_Pr->SiS_LCDResInfo == Panel_Custom) temp = 0x2c; if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) temp = 0x08; if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) temp = 0x2c; - else temp = 0x20; - } + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) temp = 0x2c; + else temp = 0x20; + } if(SiS_Pr->SiS_UseROM) { if(ROMAddr[0x220] & 0x80) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoYPbPrHiVision) - temp = ROMAddr[0x221]; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoYPbPrHiVision) + temp = ROMAddr[0x221]; else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) temp = ROMAddr[0x222]; else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) temp = ROMAddr[0x223]; else temp = ROMAddr[0x224]; - temp &= 0x3c; } } if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_Pr->PDC != -1) temp = SiS_Pr->PDC & 0x3c; + if(SiS_Pr->PDC != -1) temp = SiS_Pr->PDC; } } else { @@ -6487,15 +6301,17 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } if(SiS_Pr->SiS_UseROM) { if(ROMAddr[0x220] & 0x80) { - temp = ROMAddr[0x220] & 0x3c; + temp = ROMAddr[0x220]; } } if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_Pr->PDC != -1) temp = SiS_Pr->PDC & 0x3c; + if(SiS_Pr->PDC != -1) temp = SiS_Pr->PDC; } - } + } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x3C,temp); /* Panel Link Delay Compensation; (Software Command Reset; Power Saving) */ + temp &= 0x3c; + + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x3C,temp); /* Panel Link Delay Compensation; (Software Command Reset; Power Saving) */ #endif /* SIS300 */ @@ -6503,16 +6319,16 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, #ifdef SIS315H /* --------------- 315/330 series ---------------*/ - if(HwInfo->jChipType < SIS_661) { + if(SiS_Pr->ChipType < SIS_661) { if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(HwInfo->jChipType == SIS_740) temp = 0x03; - else temp = 0x00; + if(SiS_Pr->ChipType == SIS_740) temp = 0x03; + else temp = 0x00; if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) temp = 0x0a; tempbl = 0xF0; - if(HwInfo->jChipType == SIS_650) { + if(SiS_Pr->ChipType == SIS_650) { if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempbl = 0x0F; } @@ -6531,10 +6347,10 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } /* < 661 */ - tempax = 0; - if(modeflag & DoubleScanMode) tempax |= 0x80; - if(modeflag & HalfDCLK) tempax |= 0x40; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2C,0x3f,tempax); + tempax = 0; + if(modeflag & DoubleScanMode) tempax |= 0x80; + if(modeflag & HalfDCLK) tempax |= 0x40; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2C,0x3f,tempax); #endif /* SIS315H */ @@ -6544,21 +6360,21 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if(SiS_Pr->SiS_VBType & VB_SISVB) { if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { - /* For 301BDH with LCD, we set up the Panel Link */ - SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex); + /* For 301BDH with LCD, we set up the Panel Link */ + SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); } else if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - SiS_SetGroup1_301(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex); + SiS_SetGroup1_301(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); } } else { - if(HwInfo->jChipType < SIS_315H) { - SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex); + if(SiS_Pr->ChipType < SIS_315H) { + SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); } else { if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if((!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) || (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - SiS_SetGroup1_LVDS(SiS_Pr, ModeNo,ModeIdIndex, HwInfo,RefreshRateTableIndex); - } + if((!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) || (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + SiS_SetGroup1_LVDS(SiS_Pr, ModeNo,ModeIdIndex,RefreshRateTableIndex); + } } else { - SiS_SetGroup1_LVDS(SiS_Pr, ModeNo,ModeIdIndex, HwInfo,RefreshRateTableIndex); + SiS_SetGroup1_LVDS(SiS_Pr, ModeNo,ModeIdIndex,RefreshRateTableIndex); } } } @@ -6569,11 +6385,11 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /*********************************************/ #ifdef SIS315H -static UCHAR * -SiS_GetGroup2CLVXPtr(SiS_Private *SiS_Pr, int tabletype, PSIS_HW_INFO HwInfo) +static unsigned char * +SiS_GetGroup2CLVXPtr(struct SiS_Private *SiS_Pr, int tabletype) { - const UCHAR *tableptr = NULL; - USHORT a, b, p = 0; + const unsigned char *tableptr = NULL; + unsigned short a, b, p = 0; a = SiS_Pr->SiS_VGAHDE; b = SiS_Pr->SiS_HDE; @@ -6606,25 +6422,25 @@ SiS_GetGroup2CLVXPtr(SiS_Private *SiS_Pr, int tabletype, PSIS_HW_INFO HwInfo) if((tableptr[p] | tableptr[p+1] << 8) == 0xffff) p -= 0x42; } p += 2; - return((UCHAR *)&tableptr[p]); + return ((unsigned char *)&tableptr[p]); } static void -SiS_SetGroup2_C_ELV(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) +SiS_SetGroup2_C_ELV(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) { - UCHAR *tableptr; + unsigned char *tableptr; + unsigned char temp; int i, j; - UCHAR temp; - if(!(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302ELV))) return; + if(!(SiS_Pr->SiS_VBType & VB_SISTAP4SCALER)) return; - tableptr = SiS_GetGroup2CLVXPtr(SiS_Pr, 0, HwInfo); + tableptr = SiS_GetGroup2CLVXPtr(SiS_Pr, 0); for(i = 0x80, j = 0; i <= 0xbf; i++, j++) { SiS_SetReg(SiS_Pr->SiS_Part2Port, i, tableptr[j]); } if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - tableptr = SiS_GetGroup2CLVXPtr(SiS_Pr, 1, HwInfo); + tableptr = SiS_GetGroup2CLVXPtr(SiS_Pr, 1); for(i = 0xc0, j = 0; i <= 0xff; i++, j++) { SiS_SetReg(SiS_Pr->SiS_Part2Port, i, tableptr[j]); } @@ -6635,12 +6451,12 @@ SiS_SetGroup2_C_ELV(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } static BOOLEAN -SiS_GetCRT2Part2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *CRT2Index, - USHORT *ResIndex,PSIS_HW_INFO HwInfo) +SiS_GetCRT2Part2Ptr(struct SiS_Private *SiS_Pr,unsigned short ModeNo,unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex,unsigned short *CRT2Index, + unsigned short *ResIndex) { - if(HwInfo->jChipType < SIS_315H) return FALSE; + if(SiS_Pr->ChipType < SIS_315H) return FALSE; if(ModeNo <= 0x13) (*ResIndex) = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; @@ -6661,82 +6477,79 @@ SiS_GetCRT2Part2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, if(SiS_Pr->SiS_SetFlag & LCDVESATiming) (*CRT2Index) = 206; } } - return(((*CRT2Index) != 0)); + return (((*CRT2Index) != 0)); } #endif #ifdef SIS300 static void -SiS_Group2LCDSpecial(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, USHORT crt2crtc) +SiS_Group2LCDSpecial(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short crt2crtc) { - USHORT tempcx; - const UCHAR atable[] = { + unsigned short tempcx; + static const unsigned char atable[] = { 0xc3,0x9e,0xc3,0x9e,0x02,0x02,0x02, 0xab,0x87,0xab,0x9e,0xe7,0x02,0x02 }; if(!SiS_Pr->UseCustomMode) { - if( ( ( (HwInfo->jChipType == SIS_630) || - (HwInfo->jChipType == SIS_730) ) && - (HwInfo->jChipRevision > 2) ) && - (SiS_Pr->SiS_LCDResInfo == Panel_1024x768) && - (!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) && - (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) ) { - if(ModeNo == 0x13) { - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,0xB9); - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,0xCC); - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xA6); - } else { - if((crt2crtc & 0x3F) == 4) { - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x2B); - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x13); - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,0xE5); - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,0x08); - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xE2); - } - } + if( ( ( (SiS_Pr->ChipType == SIS_630) || + (SiS_Pr->ChipType == SIS_730) ) && + (SiS_Pr->ChipRevision > 2) ) && + (SiS_Pr->SiS_LCDResInfo == Panel_1024x768) && + (!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) && + (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) ) { + if(ModeNo == 0x13) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,0xB9); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,0xCC); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xA6); + } else if((crt2crtc & 0x3F) == 4) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x2B); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x13); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,0xE5); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,0x08); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xE2); + } } - if(HwInfo->jChipType < SIS_315H) { - if(SiS_Pr->SiS_LCDTypeInfo == 0x0c) { - crt2crtc &= 0x1f; - tempcx = 0; - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - tempcx += 7; - } - } - tempcx += crt2crtc; - if(crt2crtc >= 4) { - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xff); - } + if(SiS_Pr->ChipType < SIS_315H) { + if(SiS_Pr->SiS_LCDTypeInfo == 0x0c) { + crt2crtc &= 0x1f; + tempcx = 0; + if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + tempcx += 7; + } + } + tempcx += crt2crtc; + if(crt2crtc >= 4) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xff); + } - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(crt2crtc == 4) { - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x28); - } - } - } - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x18); - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,atable[tempcx]); - } + if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(crt2crtc == 4) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x28); + } + } + } + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x18); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,atable[tempcx]); + } } } } /* For ECS A907. Highly preliminary. */ static void -SiS_Set300Part2Regs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeIdIndex, USHORT RefreshRateTableIndex, - USHORT ModeNo) +SiS_Set300Part2Regs(struct SiS_Private *SiS_Pr, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, + unsigned short ModeNo) { - USHORT crt2crtc, resindex; - int i,j; - const SiS_Part2PortTblStruct *CRT2Part2Ptr = NULL; + const struct SiS_Part2PortTbl *CRT2Part2Ptr = NULL; + unsigned short crt2crtc, resindex; + int i, j; - if(HwInfo->jChipType != SIS_300) return; - if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) return; + if(SiS_Pr->ChipType != SIS_300) return; + if(!(SiS_Pr->SiS_VBType & VB_SIS30xBLV)) return; if(SiS_Pr->UseCustomMode) return; if(ModeNo <= 0x13) { @@ -6758,13 +6571,13 @@ SiS_Set300Part2Regs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x01,0x80,(CRT2Part2Ptr+resindex)->CR[0]); SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x02,0x80,(CRT2Part2Ptr+resindex)->CR[1]); for(i = 2, j = 0x04; j <= 0x06; i++, j++ ) { - SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); + SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); } for(j = 0x1c; j <= 0x1d; i++, j++ ) { - SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); + SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); } for(j = 0x1f; j <= 0x21; i++, j++ ) { - SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); + SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); } SiS_SetReg(SiS_Pr->SiS_Part2Port,0x23,(CRT2Part2Ptr+resindex)->CR[10]); SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0x0f,(CRT2Part2Ptr+resindex)->CR[11]); @@ -6772,15 +6585,15 @@ SiS_Set300Part2Regs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, #endif static void -SiS_SetTVSpecial(SiS_Private *SiS_Pr, USHORT ModeNo) +SiS_SetTVSpecial(struct SiS_Private *SiS_Pr, unsigned short ModeNo) { - if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) return; + if(!(SiS_Pr->SiS_VBType & VB_SIS30xBLV)) return; if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision)) return; if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p)) return; if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) { - const UCHAR specialtv[] = { + const unsigned char specialtv[] = { 0xa7,0x07,0xf2,0x6e,0x17,0x8b,0x73,0x53, 0x13,0x40,0x34,0xf4,0x63,0xbb,0xcc,0x7a, 0x58,0xe4,0x73,0xda,0x13 @@ -6813,16 +6626,16 @@ SiS_SetTVSpecial(SiS_Private *SiS_Pr, USHORT ModeNo) } static void -SiS_SetGroup2_Tail(SiS_Private *SiS_Pr, USHORT ModeNo) +SiS_SetGroup2_Tail(struct SiS_Private *SiS_Pr, unsigned short ModeNo) { - USHORT temp; + unsigned short temp; if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { if(SiS_Pr->SiS_VGAVDE == 525) { temp = 0xc3; if(SiS_Pr->SiS_ModeType <= ModeVGA) { temp++; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) temp += 2; + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) temp += 2; } SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2f,temp); SiS_SetReg(SiS_Pr->SiS_Part2Port,0x30,0xb3); @@ -6830,7 +6643,7 @@ SiS_SetGroup2_Tail(SiS_Private *SiS_Pr, USHORT ModeNo) temp = 0x4d; if(SiS_Pr->SiS_ModeType <= ModeVGA) { temp++; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) temp++; + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) temp++; } SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2f,temp); } @@ -6838,7 +6651,7 @@ SiS_SetGroup2_Tail(SiS_Private *SiS_Pr, USHORT ModeNo) if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) { - if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { + if(SiS_Pr->SiS_VBType & VB_SIS30xB) { SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x1a,0x03); /* Not always for LV, see SetGrp2 */ } @@ -6872,17 +6685,17 @@ SiS_SetGroup2_Tail(SiS_Private *SiS_Pr, USHORT ModeNo) } static void -SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT RefreshRateTableIndex, - PSIS_HW_INFO HwInfo) -{ - USHORT i, j, tempax, tempbx, tempcx, tempch, tempcl, temp; - USHORT push2, modeflag, crt2crtc, bridgeoffset; - ULONG longtemp; - const UCHAR *PhasePoint; - const UCHAR *TimingPoint; +SiS_SetGroup2(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) +{ + unsigned short i, j, tempax, tempbx, tempcx, tempch, tempcl, temp; + unsigned short push2, modeflag, crt2crtc, bridgeoffset; + unsigned int longtemp, PhaseIndex; + BOOLEAN newtvphase; + const unsigned char *TimingPoint; #ifdef SIS315H - USHORT resindex, CRT2Index; - const SiS_Part2PortTblStruct *CRT2Part2Ptr = NULL; + unsigned short resindex, CRT2Index; + const struct SiS_Part2PortTbl *CRT2Part2Ptr = NULL; if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return; #endif @@ -6908,9 +6721,16 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr SiS_SetReg(SiS_Pr->SiS_Part2Port,0x00,temp); - PhasePoint = SiS_Pr->SiS_PALPhase; + PhaseIndex = 0x01; /* SiS_PALPhase */ TimingPoint = SiS_Pr->SiS_PALTiming; + newtvphase = FALSE; + if( (SiS_Pr->SiS_VBType & VB_SIS30xBLV) && + ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || + (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) { + newtvphase = TRUE; + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { TimingPoint = SiS_Pr->SiS_HiTVExtTiming; @@ -6918,82 +6738,54 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr TimingPoint = SiS_Pr->SiS_HiTVSt2Timing; if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { TimingPoint = SiS_Pr->SiS_HiTVSt1Timing; -#if 0 - if(!(modeflag & Charx8Dot)) TimingPoint = SiS_Pr->SiS_HiTVTextTiming; -#endif } } } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { - if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) TimingPoint = &SiS_YPbPrTable[2][0]; - else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) TimingPoint = &SiS_YPbPrTable[1][0]; - else TimingPoint = &SiS_YPbPrTable[0][0]; + i = 0; + if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) i = 2; + else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) i = 1; + + TimingPoint = &SiS_YPbPrTable[i][0]; - PhasePoint = SiS_Pr->SiS_NTSCPhase; + PhaseIndex = 0x00; /* SiS_NTSCPhase */ } else if(SiS_Pr->SiS_TVMode & TVSetPAL) { - if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && - ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || - (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) { - PhasePoint = SiS_Pr->SiS_PALPhase2; - } + if(newtvphase) PhaseIndex = 0x09; /* SiS_PALPhase2 */ } else { TimingPoint = SiS_Pr->SiS_NTSCTiming; - PhasePoint = SiS_Pr->SiS_NTSCPhase; - if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) { - PhasePoint = SiS_Pr->SiS_PALPhase; - } - - if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && - ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || - (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) { - PhasePoint = SiS_Pr->SiS_NTSCPhase2; - if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) { - PhasePoint = SiS_Pr->SiS_PALPhase2; - } - } - - } + PhaseIndex = (SiS_Pr->SiS_TVMode & TVSetNTSCJ) ? 0x01 : 0x00; /* SiS_PALPhase : SiS_NTSCPhase */ + if(newtvphase) PhaseIndex += 8; /* SiS_PALPhase2 : SiS_NTSCPhase2 */ - if(SiS_Pr->SiS_TVMode & TVSetPALM) { - PhasePoint = SiS_Pr->SiS_PALMPhase; - if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && - ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || - (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) { - PhasePoint = SiS_Pr->SiS_PALMPhase2; - } } - if(SiS_Pr->SiS_TVMode & TVSetPALN) { - PhasePoint = SiS_Pr->SiS_PALNPhase; - if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && - ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || - (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) { - PhasePoint = SiS_Pr->SiS_PALNPhase2; - } + if(SiS_Pr->SiS_TVMode & (TVSetPALM | TVSetPALN)) { + PhaseIndex = (SiS_Pr->SiS_TVMode & TVSetPALM) ? 0x02 : 0x03; /* SiS_PALMPhase : SiS_PALNPhase */ + if(newtvphase) PhaseIndex += 8; /* SiS_PALMPhase2 : SiS_PALNPhase2 */ } if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) { - PhasePoint = SiS_Pr->SiS_SpecialPhase; if(SiS_Pr->SiS_TVMode & TVSetPALM) { - PhasePoint = SiS_Pr->SiS_SpecialPhaseM; + PhaseIndex = 0x05; /* SiS_SpecialPhaseM */ } else if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) { - PhasePoint = SiS_Pr->SiS_SpecialPhaseJ; + PhaseIndex = 0x11; /* SiS_SpecialPhaseJ */ + } else { + PhaseIndex = 0x10; /* SiS_SpecialPhase */ } } - for(i=0x31, j=0; i<=0x34; i++, j++) { - SiS_SetReg(SiS_Pr->SiS_Part2Port,i,PhasePoint[j]); + for(i = 0x31, j = 0; i <= 0x34; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS_TVPhase[(PhaseIndex * 4) + j]); } - for(i=0x01, j=0; i<=0x2D; i++, j++) { + for(i = 0x01, j = 0; i <= 0x2D; i++, j++) { SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]); } - for(i=0x39; i<=0x45; i++, j++) { + for(i = 0x39; i <= 0x45; i++, j++) { SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]); } @@ -7010,28 +6802,32 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr SiS_SetReg(SiS_Pr->SiS_Part2Port,0x37,SiS_Pr->SiS_RY3COE); SiS_SetReg(SiS_Pr->SiS_Part2Port,0x38,SiS_Pr->SiS_RY4COE); - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) tempax = 950; - else if(SiS_Pr->SiS_TVMode & TVSetPAL) tempax = 520; - else tempax = 440; /* NTSC, YPbPr 525, 750 */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) tempax = 950; + else if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) tempax = 680; + else if(SiS_Pr->SiS_TVMode & TVSetPAL) tempax = 520; + else tempax = 440; /* NTSC, YPbPr 525 */ - if( ( (!(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision)) && (SiS_Pr->SiS_VDE <= tempax) ) || + if( ((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) && (SiS_Pr->SiS_VDE <= tempax)) || ( (SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision) && ((SiS_Pr->SiS_VGAHDE == 1024) || (SiS_Pr->SiS_VDE <= tempax)) ) ) { tempax -= SiS_Pr->SiS_VDE; - tempax >>= 2; + tempax >>= 1; + if(!(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p))) { + tempax >>= 1; + } tempax &= 0x00ff; - temp = tempax + (USHORT)TimingPoint[0]; + temp = tempax + (unsigned short)TimingPoint[0]; SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,temp); - temp = tempax + (USHORT)TimingPoint[1]; + temp = tempax + (unsigned short)TimingPoint[1]; SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,temp); if((SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoYPbPrHiVision) && (SiS_Pr->SiS_VGAHDE >= 1024)) { if(SiS_Pr->SiS_TVMode & TVSetPAL) { - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x1b); /* 19 */ - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x54); /* 52 */ + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x1b); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x54); } else { SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x17); SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x1d); @@ -7041,14 +6837,14 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr } tempcx = SiS_Pr->SiS_HT; - if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempcx >>= 1; + if(SiS_IsDualLink(SiS_Pr)) tempcx >>= 1; tempcx--; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) tempcx--; + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) tempcx--; SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1B,tempcx); SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1D,0xF0,((tempcx >> 8) & 0x0f)); tempcx = SiS_Pr->SiS_HT >> 1; - if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempcx >>= 1; + if(SiS_IsDualLink(SiS_Pr)) tempcx >>= 1; tempcx += 7; if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) tempcx -= 4; SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x22,0x0F,((tempcx << 4) & 0xf0)); @@ -7075,7 +6871,7 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2A,0x0F,((tempcx << 4) & 0xf0)); tempcx = SiS_Pr->SiS_HT >> 1; - if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempcx >>= 1; + if(SiS_IsDualLink(SiS_Pr)) tempcx >>= 1; j += 2; tempcx -= (TimingPoint[j] | ((TimingPoint[j+1]) << 8)); SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2D,0x0F,((tempcx << 4) & 0xf0)); @@ -7094,7 +6890,7 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr } else if( (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (!(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p|TVSetYPbPr750p))) ) { tempbx >>= 1; - if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->ChipType >= SIS_315H) { if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { if((ModeNo <= 0x13) && (crt2crtc == 1)) tempbx++; } else if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { @@ -7123,23 +6919,11 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr } SiS_SetReg(SiS_Pr->SiS_Part2Port,0x30,temp); - if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302LV | VB_SIS302ELV)) { + if(SiS_Pr->SiS_VBType & VB_SISPART4OVERFLOW) { SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x10,0xdf,((tempbx & 0x0400) >> 5)); } -#if 0 - /* TEST qqqq */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { - for(i=0x01, j=0; i<=0x2D; i++, j++) { - SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]); - } - for(i=0x39; i<=0x45; i++, j++) { - SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]); - } - } -#endif - - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { tempbx = SiS_Pr->SiS_VDE; if( (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (!(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p))) ) { @@ -7150,7 +6934,7 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr SiS_SetReg(SiS_Pr->SiS_Part2Port,0x46,temp); SiS_SetReg(SiS_Pr->SiS_Part2Port,0x47,tempbx); - if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302LV | VB_SIS302ELV)) { + if(SiS_Pr->SiS_VBType & VB_SISPART4OVERFLOW) { SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x10,0xbf,((tempbx & 0x0400) >> 4)); } } @@ -7165,14 +6949,17 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr tempch = tempcl = 0x01; if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(SiS_Pr->SiS_VGAHDE >= 1024) { - if((!(modeflag & HalfDCLK)) || (HwInfo->jChipType < SIS_315H)) { - tempch = 0x19; + if(SiS_Pr->SiS_VGAHDE >= 960) { + if((!(modeflag & HalfDCLK)) || (SiS_Pr->ChipType < SIS_315H)) { tempcl = 0x20; - if(SiS_Pr->SiS_VGAHDE >= 1280) { - tempch = 0x14; + if(SiS_Pr->SiS_VGAHDE >= 1280) { + tempch = 20; tempbx &= ~0x20; - } + } else if(SiS_Pr->SiS_VGAHDE >= 1024) { + tempch = 25; + } else { + tempch = 25; /* OK */ + } } } } @@ -7180,7 +6967,7 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr if(!(tempbx & 0x20)) { if(modeflag & HalfDCLK) tempcl <<= 1; longtemp = ((SiS_Pr->SiS_VGAHDE * tempch) / tempcl) << 13; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) longtemp <<= 3; + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) longtemp <<= 3; tempax = longtemp / SiS_Pr->SiS_HDE; if(longtemp % SiS_Pr->SiS_HDE) tempax++; tempbx |= ((tempax >> 8) & 0x1F); @@ -7190,7 +6977,7 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr SiS_SetReg(SiS_Pr->SiS_Part2Port,0x44,tempax); SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x45,0xC0,tempbx); - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { tempcx &= 0x07; if(tempbx & 0x20) tempcx = 0; @@ -7219,7 +7006,7 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr SiS_SetTVSpecial(SiS_Pr, ModeNo); - if(SiS_Pr->SiS_VBType & VB_SIS301C) { + if(SiS_Pr->SiS_VBType & VB_SIS30xCLV) { temp = 0; if(SiS_Pr->SiS_TVMode & TVSetPALM) temp = 8; SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x4e,0xf7,temp); @@ -7246,7 +7033,7 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr /* From here: Part2 LCD setup */ tempbx = SiS_Pr->SiS_HDE; - if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1; + if(SiS_IsDualLink(SiS_Pr)) tempbx >>= 1; tempbx--; /* RHACTE = HDE - 1 */ SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2C,tempbx); SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2B,0x0F,((tempbx >> 4) & 0xf0)); @@ -7256,10 +7043,8 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr if(SiS_Pr->SiS_ModeType == ModeEGA) { if(SiS_Pr->SiS_VGAHDE >= 1024) { temp = 0x02; - if(HwInfo->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { - temp = 0x01; - } + if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { + temp = 0x01; } } } @@ -7289,11 +7074,11 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr #ifdef SIS315H if(SiS_GetCRT2Part2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, - &CRT2Index, &resindex, HwInfo)) { + &CRT2Index, &resindex)) { switch(CRT2Index) { + case 206: CRT2Part2Ptr = SiS310_CRT2Part2_Asus1024x768_3; break; + default: case 200: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1; break; - case 206: CRT2Part2Ptr = SiS310_CRT2Part2_Asus1024x768_3; break; - default: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_3; break; } SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x01,0x80,(CRT2Part2Ptr+resindex)->CR[0]); @@ -7312,7 +7097,6 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr SiS_SetGroup2_Tail(SiS_Pr, ModeNo); - } else { #endif @@ -7349,9 +7133,11 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr /* Non-expanding: lcdvdes = tempcx = VT-1; lcdvdee = tempbx = VDE-1 */ +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "lcdvdes 0x%x lcdvdee 0x%x\n", tempcx, tempbx); #endif +#endif SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,tempcx); /* lcdvdes */ SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,tempbx); /* lcdvdee */ @@ -7401,9 +7187,11 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr tempbx = SiS_Pr->CVSyncStart; } +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "lcdvrs 0x%x\n", tempbx); #endif +#endif SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,tempbx); /* lcdvrs */ @@ -7416,26 +7204,30 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr temp |= (SiS_Pr->CVSyncEnd & 0x0f); } +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "lcdvre[3:0] 0x%x\n", (temp & 0x0f)); #endif +#endif SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,temp); #ifdef SIS300 - SiS_Group2LCDSpecial(SiS_Pr, HwInfo, ModeNo, crt2crtc); + SiS_Group2LCDSpecial(SiS_Pr, ModeNo, crt2crtc); #endif bridgeoffset = 7; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) bridgeoffset += 2; - if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302ELV)) bridgeoffset++; - if(SiS_IsDualLink(SiS_Pr, HwInfo)) bridgeoffset++; + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) bridgeoffset += 2; + if(SiS_Pr->SiS_VBType & VB_SIS30xCLV) bridgeoffset += 2; /* OK for Averatec 1280x800 (301C) */ + if(SiS_IsDualLink(SiS_Pr)) bridgeoffset++; + else if(SiS_Pr->SiS_VBType & VB_SIS302LV) bridgeoffset++; /* OK for Asus A4L 1280x800 */ + /* Higher bridgeoffset shifts to the LEFT */ temp = 0; if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { if(SiS_Pr->PanelXRes != SiS_Pr->SiS_HDE) { - temp = SiS_Pr->SiS_HT - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_HDE) / 2); - if(SiS_IsDualLink(SiS_Pr, HwInfo)) temp >>= 1; + temp = SiS_Pr->SiS_HT - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_HDE) / 2); + if(SiS_IsDualLink(SiS_Pr)) temp >>= 1; } } temp += bridgeoffset; @@ -7450,15 +7242,17 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr tempbx = SiS_Pr->PanelXRes - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_HDE) / 2); } } - if(SiS_IsDualLink(SiS_Pr, HwInfo)) { + if(SiS_IsDualLink(SiS_Pr)) { tempcx >>= 1; tempbx >>= 1; tempax >>= 1; } +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "lcdhdee 0x%x\n", tempbx); #endif +#endif tempbx += bridgeoffset; @@ -7480,13 +7274,16 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr if(SiS_Pr->UseCustomMode) { tempbx = SiS_Pr->CHSyncStart; - if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1; + if(modeflag & HalfDCLK) tempbx <<= 1; + if(SiS_IsDualLink(SiS_Pr)) tempbx >>= 1; tempbx += bridgeoffset; } +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "lcdhrs 0x%x\n", tempbx); #endif +#endif SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1C,tempbx); /* lcdhrs */ SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1D,0x0F,((tempbx >> 4) & 0xf0)); @@ -7501,20 +7298,23 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr if(SiS_Pr->UseCustomMode) { tempbx = SiS_Pr->CHSyncEnd; - if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1; + if(modeflag & HalfDCLK) tempbx <<= 1; + if(SiS_IsDualLink(SiS_Pr)) tempbx >>= 1; tempbx += bridgeoffset; } +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "lcdhre 0x%x\n", tempbx); #endif +#endif SiS_SetReg(SiS_Pr->SiS_Part2Port,0x21,tempbx); /* lcdhre */ SiS_SetGroup2_Tail(SiS_Pr, ModeNo); #ifdef SIS300 - SiS_Set300Part2Regs(SiS_Pr, HwInfo, ModeIdIndex, RefreshRateTableIndex, ModeNo); + SiS_Set300Part2Regs(SiS_Pr, ModeIdIndex, RefreshRateTableIndex, ModeNo); #endif #ifdef SIS315H } /* CRT2-LCD from table */ @@ -7526,11 +7326,10 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr /*********************************************/ static void -SiS_SetGroup3(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo) +SiS_SetGroup3(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - USHORT i; - const UCHAR *tempdi; + unsigned short i; + const unsigned char *tempdi; if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return; @@ -7570,7 +7369,7 @@ SiS_SetGroup3(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, for(i=0; i<=0x3E; i++) { SiS_SetReg(SiS_Pr->SiS_Part3Port,i,tempdi[i]); } - if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302ELV)) { + if(SiS_Pr->SiS_VBType & VB_SIS30xCLV) { if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) { SiS_SetReg(SiS_Pr->SiS_Part3Port,0x28,0x3f); } @@ -7587,35 +7386,43 @@ SiS_SetGroup3(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /*********************************************/ #ifdef SIS315H +#if 0 static void -SiS_ShiftXPos(SiS_Private *SiS_Pr, int shift) +SiS_ShiftXPos(struct SiS_Private *SiS_Pr, int shift) { - USHORT temp, temp1, temp2; + unsigned short temp, temp1, temp2; temp1 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x1f); temp2 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x20); - temp = (USHORT)((int)((temp1 | ((temp2 & 0xf0) << 4))) + shift); + temp = (unsigned short)((int)((temp1 | ((temp2 & 0xf0) << 4))) + shift); SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1f,temp); SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x20,0x0f,((temp >> 4) & 0xf0)); temp = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x2b) & 0x0f; - temp = (USHORT)((int)(temp) + shift); + temp = (unsigned short)((int)(temp) + shift); SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2b,0xf0,(temp & 0x0f)); temp1 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x43); temp2 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x42); - temp = (USHORT)((int)((temp1 | ((temp2 & 0xf0) << 4))) + shift); + temp = (unsigned short)((int)((temp1 | ((temp2 & 0xf0) << 4))) + shift); SiS_SetReg(SiS_Pr->SiS_Part2Port,0x43,temp); SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x42,0x0f,((temp >> 4) & 0xf0)); } +#endif static void -SiS_SetGroup4_C_ELV(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo, USHORT ModeIdIndex) +SiS_SetGroup4_C_ELV(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - USHORT temp, temp1, resinfo = 0; + unsigned short temp, temp1, resinfo = 0; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; - if(!(SiS_Pr->SiS_VBType & VB_SIS301C)) return; + if(!(SiS_Pr->SiS_VBType & VB_SIS30xCLV)) return; if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToHiVision | SetCRT2ToYPbPr525750))) return; + if(SiS_Pr->ChipType >= XGI_20) return; + + if((SiS_Pr->ChipType >= SIS_661) && (SiS_Pr->SiS_ROMNew)) { + if(!(ROMAddr[0x61] & 0x04)) return; + } + if(ModeNo > 0x13) { resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; } @@ -7625,7 +7432,7 @@ SiS_SetGroup4_C_ELV(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, if(!(temp & 0x01)) { SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x3a,0xdf); SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x25,0xfc); - if((HwInfo->jChipType < SIS_661) && (!(SiS_Pr->SiS_ROMNew))) { + if((SiS_Pr->ChipType < SIS_661) && (!(SiS_Pr->SiS_ROMNew))) { SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x25,0xf8); } SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x0f,0xfb); @@ -7633,24 +7440,29 @@ SiS_SetGroup4_C_ELV(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) temp = 0x0002; else if(SiS_Pr->SiS_TVMode & TVSetHiVision) temp = 0x0400; else temp = 0x0402; - if((HwInfo->jChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) { + if((SiS_Pr->ChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) { temp1 = 0; if(SiS_Pr->SiS_TVMode & TVAspect43) temp1 = 4; SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0f,0xfb,temp1); if(SiS_Pr->SiS_TVMode & TVAspect43LB) temp |= 0x01; SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0x7c,(temp & 0xff)); + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x3a,0xfb,(temp >> 8)); + if(ModeNo > 0x13) { + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x39,0xfd); + } } else { temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x3b) & 0x03; if(temp1 == 0x01) temp |= 0x01; if(temp1 == 0x03) temp |= 0x04; /* ? why not 0x10? */ SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xf8,(temp & 0xff)); - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x3a,0xfb,(temp >> 8)); - if(ModeNo > 0x13) { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x3b,0xfd); + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x3a,0xfb,(temp >> 8)); + if(ModeNo > 0x13) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x3b,0xfd); + } } - if(HwInfo->jChipType >= SIS_661) { /* ? */ +#if 0 + if(SiS_Pr->ChipType >= SIS_661) { /* ? */ if(SiS_Pr->SiS_TVMode & TVAspect43) { if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { if(resinfo == SIS_RI_1024x768) { @@ -7663,29 +7475,30 @@ SiS_SetGroup4_C_ELV(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } } } +#endif + } + } #endif static void -SiS_SetCRT2VCLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) +SiS_SetCRT2VCLK(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) { - USHORT vclkindex; - USHORT temp, reg1, reg2; + unsigned short vclkindex, temp, reg1, reg2; if(SiS_Pr->UseCustomMode) { reg1 = SiS_Pr->CSR2B; reg2 = SiS_Pr->CSR2C; } else { - vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, - HwInfo); + vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); reg1 = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_A; reg2 = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_B; } - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) { + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { + if(SiS_Pr->SiS_TVMode & (TVSetNTSC1024 | TVSet525p1024)) { SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0a,0x57); SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0b,0x46); SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1f,0xf6); @@ -7705,11 +7518,35 @@ SiS_SetCRT2VCLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } static void -SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) +SiS_SetDualLinkEtc(struct SiS_Private *SiS_Pr) +{ + if(SiS_Pr->ChipType >= SIS_315H) { + if(SiS_Pr->SiS_VBType & VB_SISDUALLINK) { + if((SiS_CRT2IsLCD(SiS_Pr)) || + (SiS_IsVAMode(SiS_Pr))) { + if(SiS_Pr->SiS_LCDInfo & LCDDualLink) { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c); + } else { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x27,~0x20); + } + } + } + } + if(SiS_Pr->SiS_VBType & VB_SISEMI) { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00); +#ifdef SET_EMI + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); +#endif + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); + } +} + +static void +SiS_SetGroup4(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) { - USHORT tempax,tempcx,tempbx,modeflag,temp,resinfo; - ULONG tempebx,tempeax,templong; + unsigned short tempax, tempcx, tempbx, modeflag, temp, resinfo; + unsigned int tempebx, tempeax, templong; if(ModeNo <= 0x13) { modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; @@ -7722,38 +7559,24 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; } - if(HwInfo->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - SiS_SetReg(SiS_Pr->SiS_Part4Port,0x24,0x0e); - } + if(SiS_Pr->ChipType >= SIS_315H) { + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x24,0x0e); + } } } - if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302LV)) { + if(SiS_Pr->SiS_VBType & (VB_SIS30xCLV | VB_SIS302LV)) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x10,0x9f); + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x10,0x9f); } } - if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->ChipType >= SIS_315H) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - if(SiS_IsDualLink(SiS_Pr, HwInfo)) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c); - } else { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x27,~0x20); - } - - if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { - SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00); -#ifdef SET_EMI - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); -#endif - SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); - } - } - return; + SiS_SetDualLinkEtc(SiS_Pr); + return; } } @@ -7777,16 +7600,16 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_SetReg(SiS_Pr->SiS_Part4Port,0x15,temp); tempbx = SiS_Pr->SiS_VGAHDE; - if(modeflag & HalfDCLK) tempbx >>= 1; - if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1; + if(modeflag & HalfDCLK) tempbx >>= 1; + if(SiS_IsDualLink(SiS_Pr)) tempbx >>= 1; if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { temp = 0; if(tempbx > 800) temp = 0x60; } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { temp = 0; - if(tempbx == 1024) temp = 0xA0; - else if(tempbx > 1024) temp = 0xC0; + if(tempbx > 1024) temp = 0xC0; + else if(tempbx >= 960) temp = 0xA0; } else if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p)) { temp = 0; if(tempbx >= 1280) temp = 0x40; @@ -7796,8 +7619,13 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if(tempbx >= 1024) temp = 0xA0; } + temp |= SiS_Pr->Init_P4_0E; + if(SiS_Pr->SiS_VBType & VB_SIS301) { - if(SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) temp |= 0x0A; + if(SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) { + temp &= 0xf0; + temp |= 0x0A; + } } SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0E,0x10,temp); @@ -7824,15 +7652,15 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, tempeax /= tempebx; if(templong) tempeax++; - temp = (USHORT)(tempeax & 0x000000FF); + temp = (unsigned short)(tempeax & 0x000000FF); SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1B,temp); - temp = (USHORT)((tempeax & 0x0000FF00) >> 8); + temp = (unsigned short)((tempeax & 0x0000FF00) >> 8); SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1A,temp); - temp = (USHORT)((tempeax >> 12) & 0x70); /* sic! */ + temp = (unsigned short)((tempeax >> 12) & 0x70); /* sic! */ temp |= (tempcx & 0x4F); SiS_SetReg(SiS_Pr->SiS_Part4Port,0x19,temp); - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1C,0x28); @@ -7840,23 +7668,26 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, tempbx = 0; if(SiS_Pr->SiS_TVMode & (TVSetHiVision | TVSetYPbPr750p)) tempbx = 0x08; tempax = SiS_Pr->SiS_VGAHDE; - if(modeflag & HalfDCLK) tempax >>= 1; - if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempax >>= 1; + if(modeflag & HalfDCLK) tempax >>= 1; + if(SiS_IsDualLink(SiS_Pr)) tempax >>= 1; if(tempax > 800) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { tempax -= 800; - } else { /* 651+301C: Only if TVNoHiviNoYPbPr */ + } else { tempbx = 0x08; - if(tempax == 1024) tempax *= 25; - else tempax *= 20; + if(tempax == 960) tempax *= 25; /* Correct */ + else if(tempax == 1024) tempax *= 25; + else tempax *= 20; temp = tempax % 32; tempax /= 32; if(temp) tempax++; tempax++; - if((SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoYPbPrHiVision) || - (SiS_Pr->SiS_TVMode & TVSetYPbPr525i)) { - if(resinfo == SIS_RI_1024x768) { - /* Otherwise white line at right edge */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(resinfo == SIS_RI_1024x768 || + resinfo == SIS_RI_1024x576 || + resinfo == SIS_RI_1280x1024 || + resinfo == SIS_RI_1280x720) { + /* Otherwise white line or garbage at right edge */ tempax = (tempax & 0xff00) | 0x20; } } @@ -7868,7 +7699,7 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1E,temp); temp = 0x0036; tempbx = 0xD0; - if((HwInfo->jChipType >= SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { + if((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->SiS_VBType & VB_SISLVDS)) { temp = 0x0026; tempbx = 0xC0; /* See En/DisableBridge() */ } if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { @@ -7884,36 +7715,24 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x1F,tempbx,temp); tempbx = SiS_Pr->SiS_HT >> 1; - if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1; + if(SiS_IsDualLink(SiS_Pr)) tempbx >>= 1; tempbx -= 2; SiS_SetReg(SiS_Pr->SiS_Part4Port,0x22,tempbx); temp = (tempbx >> 5) & 0x38; SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0xC0,temp); - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { SiS_SetReg(SiS_Pr->SiS_Part4Port,0x24,0x0e); /* LCD-too-dark-error-source, see FinalizeLCD() */ } - if(HwInfo->jChipType >= SIS_315H) { - if(SiS_IsDualLink(SiS_Pr, HwInfo)) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c); - } else { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x27,~0x20); - } - } - if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { - SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00); -#ifdef SET_EMI - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); -#endif - SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); - } } + SiS_SetDualLinkEtc(SiS_Pr); + } /* 301B */ - SiS_SetCRT2VCLK(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + SiS_SetCRT2VCLK(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); } /*********************************************/ @@ -7921,8 +7740,7 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /*********************************************/ static void -SiS_SetGroup5(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo) +SiS_SetGroup5(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return; @@ -7930,7 +7748,7 @@ SiS_SetGroup5(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if(SiS_Pr->SiS_ModeType == ModeVGA) { if(!(SiS_Pr->SiS_VBInfo & (SetInSlaveMode | LoadDACFlag))) { SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); - SiS_LoadDAC(SiS_Pr, HwInfo, ModeNo, ModeIdIndex); + SiS_LoadDAC(SiS_Pr, ModeNo, ModeIdIndex); } } } @@ -7939,116 +7757,156 @@ SiS_SetGroup5(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /* MODIFY CRT1 GROUP FOR SLAVE MODE */ /*********************************************/ -static void -SiS_ModCRT1CRTC(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) -{ - USHORT tempah,i,modeflag,j; - USHORT ResIndex,DisplayType; - const SiS_LVDSCRT1DataStruct *LVDSCRT1Ptr=NULL; +static BOOLEAN +SiS_GetLVDSCRT1Ptr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex, unsigned short *ResIndex, + unsigned short *DisplayType) + { + unsigned short modeflag = 0; + BOOLEAN checkhd = TRUE; - if(ModeNo <= 0x13) modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - else modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + /* Pass 1:1 not supported here */ + + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + (*ResIndex) = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + (*ResIndex) = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + } + + (*ResIndex) &= 0x3F; + + if((SiS_Pr->SiS_IF_DEF_CH70xx) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { + + (*DisplayType) = 80; + if((SiS_Pr->SiS_TVMode & TVSetPAL) && (!(SiS_Pr->SiS_TVMode & TVSetPALM))) { + (*DisplayType) = 82; + if(SiS_Pr->SiS_ModeType > ModeVGA) { + if(SiS_Pr->SiS_CHSOverScan) (*DisplayType) = 84; + } + } + if((*DisplayType) != 84) { + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) (*DisplayType)++; + } + + } else { + + (*DisplayType = 0); + switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_320x240_1: (*DisplayType) = 50; + checkhd = FALSE; + break; + case Panel_320x240_2: (*DisplayType) = 14; + break; + case Panel_320x240_3: (*DisplayType) = 18; + break; + case Panel_640x480: (*DisplayType) = 10; + break; + case Panel_1024x600: (*DisplayType) = 26; + break; + default: return TRUE; + } + + if(checkhd) { + if(modeflag & HalfDCLK) (*DisplayType)++; + } + + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x600) { + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) (*DisplayType) += 2; + } + + } + + return TRUE; +} + +static void +SiS_ModCRT1CRTC(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) +{ + unsigned short tempah, i, modeflag, j, ResIndex, DisplayType; + const struct SiS_LVDSCRT1Data *LVDSCRT1Ptr=NULL; + static const unsigned short CRIdx[] = { + 0x00, 0x02, 0x03, 0x04, 0x05, 0x06, + 0x07, 0x10, 0x11, 0x15, 0x16 + }; if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024) || - (SiS_Pr->SiS_CustomT == CUT_PANEL848)) + (SiS_Pr->SiS_CustomT == CUT_PANEL848) || + (SiS_Pr->SiS_CustomT == CUT_PANEL856) ) return; + if(SiS_Pr->SiS_IF_DEF_LVDS) { + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) return; + } + } else if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) return; + } else return; + + if(SiS_Pr->SiS_LCDInfo & LCDPass11) return; + + if(SiS_Pr->ChipType < SIS_315H) { + if(SiS_Pr->SiS_SetFlag & SetDOSMode) return; + } + if(!(SiS_GetLVDSCRT1Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, &ResIndex, &DisplayType))) { return; } - if(HwInfo->jChipType < SIS_315H) { - if(SiS_Pr->SiS_SetFlag & SetDOSMode) return; + switch(DisplayType) { + case 50: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x240_1; break; /* xSTN */ + case 14: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x240_2; break; /* xSTN */ + case 15: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x240_2_H; break; /* xSTN */ + case 18: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x240_3; break; /* xSTN */ + case 19: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x240_3_H; break; /* xSTN */ + case 10: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_1; break; + case 11: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_1_H; break; +#if 0 /* Works better with calculated numbers */ + case 26: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_1; break; + case 27: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_1_H; break; + case 28: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_2; break; + case 29: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_2_H; break; +#endif + case 80: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1UNTSC; break; + case 81: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1ONTSC; break; + case 82: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1UPAL; break; + case 83: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1OPAL; break; + case 84: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1SOPAL; break; } - switch(DisplayType) { - case 0 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_1; break; - case 1 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_1_H; break; - case 2 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_2; break; - case 3 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_2_H; break; - case 4 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1; break; - case 5 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1_H; break; - case 6 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_2; break; - case 7 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_2_H; break; - case 8 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_1; break; - case 9 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_1_H; break; - case 10: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_2; break; - case 11: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_2_H; break; - case 12: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1XXXxXXX_1; break; - case 13: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1XXXxXXX_1_H; break; - case 14: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_1; break; - case 15: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_1_H; break; - case 16: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_2; break; - case 17: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_2_H; break; - case 18: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1UNTSC; break; - case 19: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1ONTSC; break; - case 20: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1UPAL; break; - case 21: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1OPAL; break; - case 22: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x480_1; break; /* FSTN */ - case 23: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_1; break; - case 24: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_1_H; break; - case 25: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_2; break; - case 26: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_2_H; break; - case 27: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_1; break; - case 28: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_1_H; break; - case 29: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_2; break; - case 30: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_2_H; break; - case 36: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_1; break; - case 37: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_1_H; break; - case 38: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_2; break; - case 39: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_2_H; break; - case 40: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x768_1; break; - case 41: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x768_1_H; break; - case 42: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x768_2; break; - case 43: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x768_2_H; break; - case 50: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_1; break; - case 51: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_1_H; break; - case 52: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_2; break; - case 53: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_2_H; break; - case 54: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_3; break; - case 55: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_3_H; break; - case 99: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1SOPAL; break; - default: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1; break; - } - - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); - - tempah = (LVDSCRT1Ptr + ResIndex)->CR[0]; - SiS_SetReg(SiS_Pr->SiS_P3d4,0x00,tempah); - - for(i=0x02,j=1;i<=0x05;i++,j++){ - tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; - SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah); - } - for(i=0x06,j=5;i<=0x07;i++,j++){ - tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; - SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah); - } - for(i=0x10,j=7;i<=0x11;i++,j++){ - tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; - SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah); - } - for(i=0x15,j=9;i<=0x16;i++,j++){ - tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; - SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah); - } - for(i=0x0A,j=11;i<=0x0C;i++,j++){ - tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; - SiS_SetReg(SiS_Pr->SiS_P3c4,i,tempah); - } - - tempah = (LVDSCRT1Ptr + ResIndex)->CR[14]; - tempah &= 0xE0; - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0x1f,tempah); - - tempah = (LVDSCRT1Ptr + ResIndex)->CR[14]; - tempah &= 0x01; - tempah <<= 5; - if(modeflag & DoubleScanMode) tempah |= 0x080; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,~0x020,tempah); + if(LVDSCRT1Ptr) { + + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); + + for(i = 0; i <= 10; i++) { + tempah = (LVDSCRT1Ptr + ResIndex)->CR[i]; + SiS_SetReg(SiS_Pr->SiS_P3d4,CRIdx[i],tempah); + } + + for(i = 0x0A, j = 11; i <= 0x0C; i++, j++) { + tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; + SiS_SetReg(SiS_Pr->SiS_P3c4,i,tempah); + } + + tempah = (LVDSCRT1Ptr + ResIndex)->CR[14] & 0xE0; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0x1f,tempah); + + if(ModeNo <= 0x13) modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + else modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + + tempah = ((LVDSCRT1Ptr + ResIndex)->CR[14] & 0x01) << 5; + if(modeflag & DoubleScanMode) tempah |= 0x80; + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,~0x020,tempah); + + } else { + + SiS_CalcLCDACRT1Timing(SiS_Pr, ModeNo, ModeIdIndex); + + } } /*********************************************/ @@ -8056,24 +7914,24 @@ SiS_ModCRT1CRTC(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /*********************************************/ static void -SiS_SetCRT2ECLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) +SiS_SetCRT2ECLK(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT clkbase, vclkindex=0; - UCHAR sr2b, sr2c; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short clkbase, vclkindex = 0; + unsigned char sr2b, sr2c; - if((SiS_Pr->SiS_LCDResInfo == Panel_640x480) || (SiS_Pr->SiS_LCDInfo & LCDPass11)) { - SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); - if((SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK & 0x3f) == 2) { - RefreshRateTableIndex--; - } - vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, - RefreshRateTableIndex, HwInfo); - SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); + if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK == 2) { + RefreshRateTableIndex--; + } + vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, + RefreshRateTableIndex); + SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; } else { - vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, - RefreshRateTableIndex, HwInfo); + vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, + RefreshRateTableIndex); } sr2b = SiS_Pr->SiS_VCLKData[vclkindex].SR2B; @@ -8082,7 +7940,7 @@ SiS_SetCRT2ECLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { if(SiS_Pr->SiS_UseROM) { if(ROMAddr[0x220] & 0x01) { - sr2b = ROMAddr[0x227]; + sr2b = ROMAddr[0x227]; sr2c = ROMAddr[0x228]; } } @@ -8091,7 +7949,7 @@ SiS_SetCRT2ECLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, clkbase = 0x02B; if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - clkbase += 3; + clkbase += 3; } } @@ -8111,368 +7969,331 @@ SiS_SetCRT2ECLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /*********************************************/ static void -SiS_SetCHTVReg(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RefreshRateTableIndex) +SiS_SetCHTVReg(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) { -#if defined(SIS300) || defined(SIS315H) - USHORT temp, tempbx; -#endif - USHORT tempcl; - USHORT TVType, resindex; - const SiS_CHTVRegDataStruct *CHTVRegData = NULL; + unsigned short TVType, resindex; + const struct SiS_CHTVRegData *CHTVRegData = NULL; - if(ModeNo <= 0x13) - tempcl = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; - else - tempcl = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + if(ModeNo <= 0x13) + resindex = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + else + resindex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; - TVType = 0; - if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1; - if(SiS_Pr->SiS_TVMode & TVSetPAL) { - TVType += 2; - if(SiS_Pr->SiS_ModeType > ModeVGA) { - if(SiS_Pr->SiS_CHSOverScan) TVType = 8; - } - if(SiS_Pr->SiS_TVMode & TVSetPALM) { - TVType = 4; - if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1; - } else if(SiS_Pr->SiS_TVMode & TVSetPALN) { - TVType = 6; - if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1; - } - } - switch(TVType) { - case 0: CHTVRegData = SiS_Pr->SiS_CHTVReg_UNTSC; break; - case 1: CHTVRegData = SiS_Pr->SiS_CHTVReg_ONTSC; break; - case 2: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPAL; break; - case 3: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPAL; break; - case 4: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPALM; break; - case 5: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPALM; break; - case 6: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPALN; break; - case 7: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPALN; break; - case 8: CHTVRegData = SiS_Pr->SiS_CHTVReg_SOPAL; break; - default: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPAL; break; - } - resindex = tempcl & 0x3F; + resindex &= 0x3F; + + TVType = 0; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1; + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + TVType += 2; + if(SiS_Pr->SiS_ModeType > ModeVGA) { + if(SiS_Pr->SiS_CHSOverScan) TVType = 8; + } + if(SiS_Pr->SiS_TVMode & TVSetPALM) { + TVType = 4; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1; + } else if(SiS_Pr->SiS_TVMode & TVSetPALN) { + TVType = 6; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1; + } + } + + switch(TVType) { + case 0: CHTVRegData = SiS_Pr->SiS_CHTVReg_UNTSC; break; + case 1: CHTVRegData = SiS_Pr->SiS_CHTVReg_ONTSC; break; + case 2: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPAL; break; + case 3: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPAL; break; + case 4: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPALM; break; + case 5: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPALM; break; + case 6: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPALN; break; + case 7: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPALN; break; + case 8: CHTVRegData = SiS_Pr->SiS_CHTVReg_SOPAL; break; + default: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPAL; break; + } - if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { + + if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { #ifdef SIS300 - /* Chrontel 7005 - I assume that it does not come with a 315 series chip */ + /* Chrontel 7005 - I assume that it does not come with a 315 series chip */ - /* We don't support modes >800x600 */ - if (resindex > 5) return; + /* We don't support modes >800x600 */ + if (resindex > 5) return; - if(SiS_Pr->SiS_TVMode & TVSetPAL) { - SiS_SetCH700x(SiS_Pr,0x4304); /* 0x40=76uA (PAL); 0x03=15bit non-multi RGB*/ - SiS_SetCH700x(SiS_Pr,0x6909); /* Black level for PAL (105)*/ - } else { - SiS_SetCH700x(SiS_Pr,0x0304); /* upper nibble=71uA (NTSC), 0x03=15bit non-multi RGB*/ - SiS_SetCH700x(SiS_Pr,0x7109); /* Black level for NTSC (113)*/ - } - - temp = CHTVRegData[resindex].Reg[0]; - tempbx=((temp&0x00FF)<<8)|0x00; /* Mode register */ - SiS_SetCH700x(SiS_Pr,tempbx); - temp = CHTVRegData[resindex].Reg[1]; - tempbx=((temp&0x00FF)<<8)|0x07; /* Start active video register */ - SiS_SetCH700x(SiS_Pr,tempbx); - temp = CHTVRegData[resindex].Reg[2]; - tempbx=((temp&0x00FF)<<8)|0x08; /* Position overflow register */ - SiS_SetCH700x(SiS_Pr,tempbx); - temp = CHTVRegData[resindex].Reg[3]; - tempbx=((temp&0x00FF)<<8)|0x0A; /* Horiz Position register */ - SiS_SetCH700x(SiS_Pr,tempbx); - temp = CHTVRegData[resindex].Reg[4]; - tempbx=((temp&0x00FF)<<8)|0x0B; /* Vertical Position register */ - SiS_SetCH700x(SiS_Pr,tempbx); - - /* Set minimum flicker filter for Luma channel (SR1-0=00), + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + SiS_SetCH700x(SiS_Pr,0x04,0x43); /* 0x40=76uA (PAL); 0x03=15bit non-multi RGB*/ + SiS_SetCH700x(SiS_Pr,0x09,0x69); /* Black level for PAL (105)*/ + } else { + SiS_SetCH700x(SiS_Pr,0x04,0x03); /* upper nibble=71uA (NTSC), 0x03=15bit non-multi RGB*/ + SiS_SetCH700x(SiS_Pr,0x09,0x71); /* Black level for NTSC (113)*/ + } + + SiS_SetCH700x(SiS_Pr,0x00,CHTVRegData[resindex].Reg[0]); /* Mode register */ + SiS_SetCH700x(SiS_Pr,0x07,CHTVRegData[resindex].Reg[1]); /* Start active video register */ + SiS_SetCH700x(SiS_Pr,0x08,CHTVRegData[resindex].Reg[2]); /* Position overflow register */ + SiS_SetCH700x(SiS_Pr,0x0a,CHTVRegData[resindex].Reg[3]); /* Horiz Position register */ + SiS_SetCH700x(SiS_Pr,0x0b,CHTVRegData[resindex].Reg[4]); /* Vertical Position register */ + + /* Set minimum flicker filter for Luma channel (SR1-0=00), minimum text enhancement (S3-2=10), maximum flicker filter for Chroma channel (S5-4=10) =00101000=0x28 (When reading, S1-0->S3-2, and S3-2->S1-0!) - */ - SiS_SetCH700x(SiS_Pr,0x2801); + */ + SiS_SetCH700x(SiS_Pr,0x01,0x28); - /* Set video bandwidth + /* Set video bandwidth High bandwith Luma composite video filter(S0=1) low bandwith Luma S-video filter (S2-1=00) disable peak filter in S-video channel (S3=0) high bandwidth Chroma Filter (S5-4=11) =00110001=0x31 - */ - SiS_SetCH700x(SiS_Pr,0xb103); /* old: 3103 */ + */ + SiS_SetCH700x(SiS_Pr,0x03,0xb1); /* old: 3103 */ - /* Register 0x3D does not exist in non-macrovision register map + /* Register 0x3D does not exist in non-macrovision register map (Maybe this is a macrovision register?) - */ + */ #ifndef SIS_CP - SiS_SetCH70xx(SiS_Pr,0x003D); + SiS_SetCH70xx(SiS_Pr,0x3d,0x00); #endif - /* Register 0x10 only contains 1 writable bit (S0) for sensing, - all other bits a read-only. Macrovision? - */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0010,0x1F); + /* Register 0x10 only contains 1 writable bit (S0) for sensing, + all other bits a read-only. Macrovision? + */ + SiS_SetCH70xxANDOR(SiS_Pr,0x10,0x00,0x1F); - /* Register 0x11 only contains 3 writable bits (S0-S2) for - contrast enhancement (set to 010 -> gain 1 Yout = 17/16*(Yin-30) ) - */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0211,0xF8); + /* Register 0x11 only contains 3 writable bits (S0-S2) for + contrast enhancement (set to 010 -> gain 1 Yout = 17/16*(Yin-30) ) + */ + SiS_SetCH70xxANDOR(SiS_Pr,0x11,0x02,0xF8); - /* Clear DSEN - */ - SiS_SetCH70xxANDOR(SiS_Pr,0x001C,0xEF); - - if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { /* ---- NTSC ---- */ - if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) { - if(resindex == 0x04) { /* 640x480 overscan: Mode 16 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); /* ACIV on, no need to set FSCI */ - } else if(resindex == 0x05) { /* 800x600 overscan: Mode 23 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0118,0xF0); /* 0x18-0x1f: FSCI 469,762,048 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0C19,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x001A,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x001B,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x001C,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x001D,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x001E,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x001F,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x0120,0xEF); /* Loop filter on for mode 23 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0021,0xFE); /* ACIV off, need to set FSCI */ - } - } else { - if(resindex == 0x04) { /* ----- 640x480 underscan; Mode 17 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); - } else if(resindex == 0x05) { /* ----- 800x600 underscan: Mode 24 */ + /* Clear DSEN + */ + SiS_SetCH70xxANDOR(SiS_Pr,0x1c,0x00,0xEF); + + if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { /* ---- NTSC ---- */ + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) { + if(resindex == 0x04) { /* 640x480 overscan: Mode 16 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x20,0x00,0xEF); /* loop filter off */ + SiS_SetCH70xxANDOR(SiS_Pr,0x21,0x01,0xFE); /* ACIV on, no need to set FSCI */ + } else if(resindex == 0x05) { /* 800x600 overscan: Mode 23 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x18,0x01,0xF0); /* 0x18-0x1f: FSCI 469,762,048 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x19,0x0C,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x1a,0x00,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x1b,0x00,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x1c,0x00,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x1d,0x00,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x1e,0x00,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x1f,0x00,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x20,0x01,0xEF); /* Loop filter on for mode 23 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x21,0x00,0xFE); /* ACIV off, need to set FSCI */ + } + } else { + if(resindex == 0x04) { /* ----- 640x480 underscan; Mode 17 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x20,0x00,0xEF); /* loop filter off */ + SiS_SetCH70xxANDOR(SiS_Pr,0x21,0x01,0xFE); + } else if(resindex == 0x05) { /* ----- 800x600 underscan: Mode 24 */ #if 0 - SiS_SetCH70xxANDOR(SiS_Pr,0x0118,0xF0); /* (FSCI was 0x1f1c71c7 - this is for mode 22) */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0919,0xF0); /* FSCI for mode 24 is 428,554,851 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x081A,0xF0); /* 198b3a63 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0b1B,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x041C,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x011D,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x061E,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x051F,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off for mode 24 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0021,0xFE); /* ACIV off, need to set FSCI */ -#endif /* All alternatives wrong (datasheet wrong?), don't use FSCI */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); + SiS_SetCH70xxANDOR(SiS_Pr,0x18,0x01,0xF0); /* (FSCI was 0x1f1c71c7 - this is for mode 22) */ + SiS_SetCH70xxANDOR(SiS_Pr,0x19,0x09,0xF0); /* FSCI for mode 24 is 428,554,851 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x1a,0x08,0xF0); /* 198b3a63 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x1b,0x0b,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x1c,0x04,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x1d,0x01,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x1e,0x06,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x1f,0x05,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x20,0x00,0xEF); /* loop filter off for mode 24 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x21,0x00,0xFE); * ACIV off, need to set FSCI */ +#endif /* All alternatives wrong (datasheet wrong?), don't use FSCI */ + SiS_SetCH70xxANDOR(SiS_Pr,0x20,0x00,0xEF); /* loop filter off */ + SiS_SetCH70xxANDOR(SiS_Pr,0x21,0x01,0xFE); + } } - } - } else { /* ---- PAL ---- */ - /* We don't play around with FSCI in PAL mode */ + } else { /* ---- PAL ---- */ + /* We don't play around with FSCI in PAL mode */ if(resindex == 0x04) { - SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); /* ACIV on */ + SiS_SetCH70xxANDOR(SiS_Pr,0x20,0x00,0xEF); /* loop filter off */ + SiS_SetCH70xxANDOR(SiS_Pr,0x21,0x01,0xFE); /* ACIV on */ } else { - SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); /* ACIV on */ + SiS_SetCH70xxANDOR(SiS_Pr,0x20,0x00,0xEF); /* loop filter off */ + SiS_SetCH70xxANDOR(SiS_Pr,0x21,0x01,0xFE); /* ACIV on */ } - } - + } + #endif /* 300 */ - } else { + } else { - /* Chrontel 7019 - assumed that it does not come with a 300 series chip */ + /* Chrontel 7019 - assumed that it does not come with a 300 series chip */ #ifdef SIS315H - /* We don't support modes >1024x768 */ - if (resindex > 6) return; - - temp = CHTVRegData[resindex].Reg[0]; - if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) { - temp |= 0x10; - } - tempbx=((temp & 0x00FF) << 8) | 0x00; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[1]; - tempbx=((temp & 0x00FF) << 8) | 0x01; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[2]; - tempbx=((temp & 0x00FF) << 8) | 0x02; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[3]; - tempbx=((temp & 0x00FF) << 8) | 0x04; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[4]; - tempbx=((temp & 0x00FF) << 8) | 0x03; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[5]; - tempbx=((temp & 0x00FF) << 8) | 0x05; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[6]; - tempbx=((temp & 0x00FF) << 8) | 0x06; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[7]; - if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) { - temp = 0x66; - } - tempbx=((temp & 0x00FF) << 8) | 0x07; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[8]; - tempbx=((temp & 0x00FF) << 8) | 0x08; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[9]; - tempbx=((temp & 0x00FF) << 8) | 0x15; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[10]; - tempbx=((temp & 0x00FF) << 8) | 0x1f; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[11]; - tempbx=((temp & 0x00FF) << 8) | 0x0c; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[12]; - tempbx=((temp & 0x00FF) << 8) | 0x0d; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[13]; - tempbx=((temp & 0x00FF) << 8) | 0x0e; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[14]; - tempbx=((temp & 0x00FF) << 8) | 0x0f; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[15]; - tempbx=((temp & 0x00FF) << 8) | 0x10; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = SiS_GetCH701x(SiS_Pr,0x21) & ~0x02; - /* D1 should be set for PAL, PAL-N and NTSC-J, - but I won't do that for PAL unless somebody - tells me to do so. Since the BIOS uses - non-default CIV values and blacklevels, - this might be compensated anyway. - */ - if(SiS_Pr->SiS_TVMode & (TVSetPALN | TVSetNTSCJ)) temp |= 0x02; - SiS_SetCH701x(SiS_Pr,((temp << 8) | 0x21)); + unsigned short temp; + + /* We don't support modes >1024x768 */ + if (resindex > 6) return; + + temp = CHTVRegData[resindex].Reg[0]; + if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) temp |= 0x10; + SiS_SetCH701x(SiS_Pr,0x00,temp); + + SiS_SetCH701x(SiS_Pr,0x01,CHTVRegData[resindex].Reg[1]); + SiS_SetCH701x(SiS_Pr,0x02,CHTVRegData[resindex].Reg[2]); + SiS_SetCH701x(SiS_Pr,0x04,CHTVRegData[resindex].Reg[3]); + SiS_SetCH701x(SiS_Pr,0x03,CHTVRegData[resindex].Reg[4]); + SiS_SetCH701x(SiS_Pr,0x05,CHTVRegData[resindex].Reg[5]); + SiS_SetCH701x(SiS_Pr,0x06,CHTVRegData[resindex].Reg[6]); + + temp = CHTVRegData[resindex].Reg[7]; + if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) temp = 0x66; + SiS_SetCH701x(SiS_Pr,0x07,temp); + + SiS_SetCH701x(SiS_Pr,0x08,CHTVRegData[resindex].Reg[8]); + SiS_SetCH701x(SiS_Pr,0x15,CHTVRegData[resindex].Reg[9]); + SiS_SetCH701x(SiS_Pr,0x1f,CHTVRegData[resindex].Reg[10]); + SiS_SetCH701x(SiS_Pr,0x0c,CHTVRegData[resindex].Reg[11]); + SiS_SetCH701x(SiS_Pr,0x0d,CHTVRegData[resindex].Reg[12]); + SiS_SetCH701x(SiS_Pr,0x0e,CHTVRegData[resindex].Reg[13]); + SiS_SetCH701x(SiS_Pr,0x0f,CHTVRegData[resindex].Reg[14]); + SiS_SetCH701x(SiS_Pr,0x10,CHTVRegData[resindex].Reg[15]); + + temp = SiS_GetCH701x(SiS_Pr,0x21) & ~0x02; + /* D1 should be set for PAL, PAL-N and NTSC-J, + but I won't do that for PAL unless somebody + tells me to do so. Since the BIOS uses + non-default CIV values and blacklevels, + this might be compensated anyway. + */ + if(SiS_Pr->SiS_TVMode & (TVSetPALN | TVSetNTSCJ)) temp |= 0x02; + SiS_SetCH701x(SiS_Pr,0x21,temp); #endif /* 315 */ - } + } #ifdef SIS_CP - SIS_CP_INIT301_CP3 + SIS_CP_INIT301_CP3 #endif } +#ifdef SIS315H /* ----------- 315 series only ---------- */ + void -SiS_Chrontel701xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_Chrontel701xBLOn(struct SiS_Private *SiS_Pr) { - USHORT temp; + unsigned short temp; - /* Enable Chrontel 7019 LCD panel backlight */ - if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - if(HwInfo->jChipType == SIS_740) { - SiS_SetCH701x(SiS_Pr,0x6566); - } else { - temp = SiS_GetCH701x(SiS_Pr,0x66); - temp |= 0x20; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66); - } - } + /* Enable Chrontel 7019 LCD panel backlight */ + if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + if(SiS_Pr->ChipType == SIS_740) { + SiS_SetCH701x(SiS_Pr,0x66,0x65); + } else { + temp = SiS_GetCH701x(SiS_Pr,0x66); + temp |= 0x20; + SiS_SetCH701x(SiS_Pr,0x66,temp); + } + } } void -SiS_Chrontel701xBLOff(SiS_Private *SiS_Pr) +SiS_Chrontel701xBLOff(struct SiS_Private *SiS_Pr) { - USHORT temp; + unsigned short temp; - /* Disable Chrontel 7019 LCD panel backlight */ - if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - temp = SiS_GetCH701x(SiS_Pr,0x66); - temp &= 0xDF; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66); - } + /* Disable Chrontel 7019 LCD panel backlight */ + if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + temp = SiS_GetCH701x(SiS_Pr,0x66); + temp &= 0xDF; + SiS_SetCH701x(SiS_Pr,0x66,temp); + } } -#ifdef SIS315H /* ----------- 315 series only ---------- */ - static void -SiS_ChrontelPowerSequencing(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) -{ - UCHAR regtable[] = { 0x67, 0x68, 0x69, 0x6a, 0x6b }; - UCHAR table1024_740[] = { 0x01, 0x02, 0x01, 0x01, 0x01 }; - UCHAR table1400_740[] = { 0x01, 0x6e, 0x01, 0x01, 0x01 }; - UCHAR asus1024_740[] = { 0x19, 0x6e, 0x01, 0x19, 0x09 }; - UCHAR asus1400_740[] = { 0x19, 0x6e, 0x01, 0x19, 0x09 }; - UCHAR table1024_650[] = { 0x01, 0x02, 0x01, 0x01, 0x02 }; - UCHAR table1400_650[] = { 0x01, 0x02, 0x01, 0x01, 0x02 }; - UCHAR *tableptr = NULL; +SiS_ChrontelPowerSequencing(struct SiS_Private *SiS_Pr) +{ + static const unsigned char regtable[] = { 0x67, 0x68, 0x69, 0x6a, 0x6b }; + static const unsigned char table1024_740[] = { 0x01, 0x02, 0x01, 0x01, 0x01 }; + static const unsigned char table1400_740[] = { 0x01, 0x6e, 0x01, 0x01, 0x01 }; + static const unsigned char asus1024_740[] = { 0x19, 0x6e, 0x01, 0x19, 0x09 }; + static const unsigned char asus1400_740[] = { 0x19, 0x6e, 0x01, 0x19, 0x09 }; + static const unsigned char table1024_650[] = { 0x01, 0x02, 0x01, 0x01, 0x02 }; + static const unsigned char table1400_650[] = { 0x01, 0x02, 0x01, 0x01, 0x02 }; + const unsigned char *tableptr = NULL; int i; /* Set up Power up/down timing */ - if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->ChipType == SIS_740) { if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { - if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) tableptr = asus1024_740; - else tableptr = table1024_740; + if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) tableptr = asus1024_740; + else tableptr = table1024_740; } else if((SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) || - (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) || + (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) || (SiS_Pr->SiS_LCDResInfo == Panel_1600x1200)) { if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) tableptr = asus1400_740; else tableptr = table1400_740; } else return; } else { if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { - tableptr = table1024_650; + tableptr = table1024_650; } else if((SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) || - (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) || + (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) || (SiS_Pr->SiS_LCDResInfo == Panel_1600x1200)) { - tableptr = table1400_650; + tableptr = table1400_650; } else return; } for(i=0; i<5; i++) { - SiS_SetCH701x(SiS_Pr,(tableptr[i] << 8) | regtable[i]); + SiS_SetCH701x(SiS_Pr, regtable[i], tableptr[i]); } } static void -SiS_SetCH701xForLCD(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) -{ - UCHAR regtable[] = { 0x1c, 0x5f, 0x64, 0x6f, 0x70, 0x71, - 0x72, 0x73, 0x74, 0x76, 0x78, 0x7d, 0x66 }; - UCHAR table1024_740[] = { 0x60, 0x02, 0x00, 0x07, 0x40, 0xed, - 0xa3, 0xc8, 0xc7, 0xac, 0xe0, 0x02, 0x44 }; - UCHAR table1280_740[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3, - 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02, 0x44 }; - UCHAR table1400_740[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3, - 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02, 0x44 }; - UCHAR table1600_740[] = { 0x60, 0x04, 0x11, 0x00, 0x40, 0xe3, - 0xad, 0xde, 0xf6, 0xac, 0x60, 0x1a, 0x44 }; - UCHAR table1024_650[] = { 0x60, 0x02, 0x00, 0x07, 0x40, 0xed, - 0xa3, 0xc8, 0xc7, 0xac, 0x60, 0x02 }; - UCHAR table1280_650[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3, - 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02 }; - UCHAR table1400_650[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xef, - 0xad, 0xdb, 0xf6, 0xac, 0x60, 0x02 }; - UCHAR table1600_650[] = { 0x60, 0x04, 0x11, 0x00, 0x40, 0xe3, - 0xad, 0xde, 0xf6, 0xac, 0x60, 0x1a }; - UCHAR *tableptr = NULL; - USHORT tempbh; +SiS_SetCH701xForLCD(struct SiS_Private *SiS_Pr) +{ + const unsigned char *tableptr = NULL; + unsigned short tempbh; int i; + static const unsigned char regtable[] = { + 0x1c, 0x5f, 0x64, 0x6f, 0x70, 0x71, + 0x72, 0x73, 0x74, 0x76, 0x78, 0x7d, 0x66 + }; + static const unsigned char table1024_740[] = { + 0x60, 0x02, 0x00, 0x07, 0x40, 0xed, + 0xa3, 0xc8, 0xc7, 0xac, 0xe0, 0x02, 0x44 + }; + static const unsigned char table1280_740[] = { + 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3, + 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02, 0x44 + }; + static const unsigned char table1400_740[] = { + 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3, + 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02, 0x44 + }; + static const unsigned char table1600_740[] = { + 0x60, 0x04, 0x11, 0x00, 0x40, 0xe3, + 0xad, 0xde, 0xf6, 0xac, 0x60, 0x1a, 0x44 + }; + static const unsigned char table1024_650[] = { + 0x60, 0x02, 0x00, 0x07, 0x40, 0xed, + 0xa3, 0xc8, 0xc7, 0xac, 0x60, 0x02 + }; + static const unsigned char table1280_650[] = { + 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3, + 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02 + }; + static const unsigned char table1400_650[] = { + 0x60, 0x03, 0x11, 0x00, 0x40, 0xef, + 0xad, 0xdb, 0xf6, 0xac, 0x60, 0x02 + }; + static const unsigned char table1600_650[] = { + 0x60, 0x04, 0x11, 0x00, 0x40, 0xe3, + 0xad, 0xde, 0xf6, 0xac, 0x60, 0x1a + }; - if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->ChipType == SIS_740) { if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) tableptr = table1024_740; else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) tableptr = table1280_740; else if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) tableptr = table1400_740; @@ -8499,138 +8320,139 @@ SiS_SetCH701xForLCD(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) } } - if(HwInfo->jChipType == SIS_740) tempbh = 0x0d; - else tempbh = 0x0c; + if(SiS_Pr->ChipType == SIS_740) tempbh = 0x0d; + else tempbh = 0x0c; for(i = 0; i < tempbh; i++) { - SiS_SetCH701x(SiS_Pr,(tableptr[i] << 8) | regtable[i]); + SiS_SetCH701x(SiS_Pr, regtable[i], tableptr[i]); } - SiS_ChrontelPowerSequencing(SiS_Pr,HwInfo); + SiS_ChrontelPowerSequencing(SiS_Pr); tempbh = SiS_GetCH701x(SiS_Pr,0x1e); tempbh |= 0xc0; - SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x1e); + SiS_SetCH701x(SiS_Pr,0x1e,tempbh); - if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->ChipType == SIS_740) { tempbh = SiS_GetCH701x(SiS_Pr,0x1c); tempbh &= 0xfb; - SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x1c); + SiS_SetCH701x(SiS_Pr,0x1c,tempbh); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2d,0x03); tempbh = SiS_GetCH701x(SiS_Pr,0x64); tempbh |= 0x40; - SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x64); + SiS_SetCH701x(SiS_Pr,0x64,tempbh); tempbh = SiS_GetCH701x(SiS_Pr,0x03); tempbh &= 0x3f; - SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x03); + SiS_SetCH701x(SiS_Pr,0x03,tempbh); } } static void -SiS_ChrontelResetVSync(SiS_Private *SiS_Pr) +SiS_ChrontelResetVSync(struct SiS_Private *SiS_Pr) { unsigned char temp, temp1; temp1 = SiS_GetCH701x(SiS_Pr,0x49); - SiS_SetCH701x(SiS_Pr,0x3e49); + SiS_SetCH701x(SiS_Pr,0x49,0x3e); temp = SiS_GetCH701x(SiS_Pr,0x47); temp &= 0x7f; /* Use external VSYNC */ - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); - SiS_LongDelay(SiS_Pr,3); + SiS_SetCH701x(SiS_Pr,0x47,temp); + SiS_LongDelay(SiS_Pr, 3); temp = SiS_GetCH701x(SiS_Pr,0x47); temp |= 0x80; /* Use internal VSYNC */ - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); - SiS_SetCH701x(SiS_Pr,(temp1 << 8) | 0x49); + SiS_SetCH701x(SiS_Pr,0x47,temp); + SiS_SetCH701x(SiS_Pr,0x49,temp1); } static void -SiS_Chrontel701xOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_Chrontel701xOn(struct SiS_Private *SiS_Pr) { - USHORT temp; + unsigned short temp; if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->ChipType == SIS_740) { temp = SiS_GetCH701x(SiS_Pr,0x1c); temp |= 0x04; /* Invert XCLK phase */ - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x1c); + SiS_SetCH701x(SiS_Pr,0x1c,temp); } - if(SiS_IsYPbPr(SiS_Pr, HwInfo)) { + if(SiS_IsYPbPr(SiS_Pr)) { temp = SiS_GetCH701x(SiS_Pr,0x01); temp &= 0x3f; temp |= 0x80; /* Enable YPrPb (HDTV) */ - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x01); + SiS_SetCH701x(SiS_Pr,0x01,temp); } - if(SiS_IsChScart(SiS_Pr, HwInfo)) { + if(SiS_IsChScart(SiS_Pr)) { temp = SiS_GetCH701x(SiS_Pr,0x01); temp &= 0x3f; temp |= 0xc0; /* Enable SCART + CVBS */ - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x01); + SiS_SetCH701x(SiS_Pr,0x01,temp); } - if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->ChipType == SIS_740) { SiS_ChrontelResetVSync(SiS_Pr); - SiS_SetCH701x(SiS_Pr,0x2049); /* Enable TV path */ + SiS_SetCH701x(SiS_Pr,0x49,0x20); /* Enable TV path */ } else { - SiS_SetCH701x(SiS_Pr,0x2049); /* Enable TV path */ + SiS_SetCH701x(SiS_Pr,0x49,0x20); /* Enable TV path */ temp = SiS_GetCH701x(SiS_Pr,0x49); - if(SiS_IsYPbPr(SiS_Pr,HwInfo)) { + if(SiS_IsYPbPr(SiS_Pr)) { temp = SiS_GetCH701x(SiS_Pr,0x73); temp |= 0x60; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x73); + SiS_SetCH701x(SiS_Pr,0x73,temp); } temp = SiS_GetCH701x(SiS_Pr,0x47); temp &= 0x7f; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); - SiS_LongDelay(SiS_Pr,2); + SiS_SetCH701x(SiS_Pr,0x47,temp); + SiS_LongDelay(SiS_Pr, 2); temp = SiS_GetCH701x(SiS_Pr,0x47); temp |= 0x80; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); + SiS_SetCH701x(SiS_Pr,0x47,temp); } } } static void -SiS_Chrontel701xOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_Chrontel701xOff(struct SiS_Private *SiS_Pr) { - USHORT temp; + unsigned short temp; /* Complete power down of LVDS */ if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - if(HwInfo->jChipType == SIS_740) { - SiS_LongDelay(SiS_Pr,1); - SiS_GenericDelay(SiS_Pr,0x16ff); - SiS_SetCH701x(SiS_Pr,0xac76); - SiS_SetCH701x(SiS_Pr,0x0066); + if(SiS_Pr->ChipType == SIS_740) { + SiS_LongDelay(SiS_Pr, 1); + SiS_GenericDelay(SiS_Pr, 5887); + SiS_SetCH701x(SiS_Pr,0x76,0xac); + SiS_SetCH701x(SiS_Pr,0x66,0x00); } else { - SiS_LongDelay(SiS_Pr,2); + SiS_LongDelay(SiS_Pr, 2); temp = SiS_GetCH701x(SiS_Pr,0x76); temp &= 0xfc; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76); - SiS_SetCH701x(SiS_Pr,0x0066); + SiS_SetCH701x(SiS_Pr,0x76,temp); + SiS_SetCH701x(SiS_Pr,0x66,0x00); } } } static void -SiS_ChrontelResetDB(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_ChrontelResetDB(struct SiS_Private *SiS_Pr) { - USHORT temp; + unsigned short temp; - if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->ChipType == SIS_740) { temp = SiS_GetCH701x(SiS_Pr,0x4a); /* Version ID */ temp &= 0x01; if(!temp) { - if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo)) { + if(SiS_WeHaveBacklightCtrl(SiS_Pr)) { temp = SiS_GetCH701x(SiS_Pr,0x49); - SiS_SetCH701x(SiS_Pr,0x3e49); + SiS_SetCH701x(SiS_Pr,0x49,0x3e); } + /* Reset Chrontel 7019 datapath */ - SiS_SetCH701x(SiS_Pr,0x1048); - SiS_LongDelay(SiS_Pr,1); - SiS_SetCH701x(SiS_Pr,0x1848); + SiS_SetCH701x(SiS_Pr,0x48,0x10); + SiS_LongDelay(SiS_Pr, 1); + SiS_SetCH701x(SiS_Pr,0x48,0x18); - if(SiS_WeHaveBacklightCtrl(SiS_Pr, HwInfo)) { + if(SiS_WeHaveBacklightCtrl(SiS_Pr)) { SiS_ChrontelResetVSync(SiS_Pr); - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x49); + SiS_SetCH701x(SiS_Pr,0x49,temp); } } else { @@ -8638,72 +8460,72 @@ SiS_ChrontelResetDB(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) /* Clear/set/clear GPIO */ temp = SiS_GetCH701x(SiS_Pr,0x5c); temp &= 0xef; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c); + SiS_SetCH701x(SiS_Pr,0x5c,temp); temp = SiS_GetCH701x(SiS_Pr,0x5c); temp |= 0x10; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c); + SiS_SetCH701x(SiS_Pr,0x5c,temp); temp = SiS_GetCH701x(SiS_Pr,0x5c); temp &= 0xef; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c); + SiS_SetCH701x(SiS_Pr,0x5c,temp); temp = SiS_GetCH701x(SiS_Pr,0x61); if(!temp) { - SiS_SetCH701xForLCD(SiS_Pr, HwInfo); + SiS_SetCH701xForLCD(SiS_Pr); } } } else { /* 650 */ /* Reset Chrontel 7019 datapath */ - SiS_SetCH701x(SiS_Pr,0x1048); - SiS_LongDelay(SiS_Pr,1); - SiS_SetCH701x(SiS_Pr,0x1848); + SiS_SetCH701x(SiS_Pr,0x48,0x10); + SiS_LongDelay(SiS_Pr, 1); + SiS_SetCH701x(SiS_Pr,0x48,0x18); } } static void -SiS_ChrontelInitTVVSync(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_ChrontelInitTVVSync(struct SiS_Private *SiS_Pr) { - USHORT temp; + unsigned short temp; - if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->ChipType == SIS_740) { - if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo)) { + if(SiS_WeHaveBacklightCtrl(SiS_Pr)) { SiS_ChrontelResetVSync(SiS_Pr); } } else { - SiS_SetCH701x(SiS_Pr,0xaf76); /* Power up LVDS block */ + SiS_SetCH701x(SiS_Pr,0x76,0xaf); /* Power up LVDS block */ temp = SiS_GetCH701x(SiS_Pr,0x49); temp &= 1; if(temp != 1) { /* TV block powered? (0 = yes, 1 = no) */ temp = SiS_GetCH701x(SiS_Pr,0x47); temp &= 0x70; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); /* enable VSYNC */ - SiS_LongDelay(SiS_Pr,3); + SiS_SetCH701x(SiS_Pr,0x47,temp); /* enable VSYNC */ + SiS_LongDelay(SiS_Pr, 3); temp = SiS_GetCH701x(SiS_Pr,0x47); temp |= 0x80; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); /* disable VSYNC */ + SiS_SetCH701x(SiS_Pr,0x47,temp); /* disable VSYNC */ } } } static void -SiS_ChrontelDoSomething3(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_INFO HwInfo) +SiS_ChrontelDoSomething3(struct SiS_Private *SiS_Pr, unsigned short ModeNo) { - USHORT temp,temp1; + unsigned short temp,temp1; - if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->ChipType == SIS_740) { temp = SiS_GetCH701x(SiS_Pr,0x61); if(temp < 1) { temp++; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x61); + SiS_SetCH701x(SiS_Pr,0x61,temp); } - SiS_SetCH701x(SiS_Pr,0x4566); /* Panel power on */ - SiS_SetCH701x(SiS_Pr,0xaf76); /* All power on */ - SiS_LongDelay(SiS_Pr,1); - SiS_GenericDelay(SiS_Pr,0x16ff); + SiS_SetCH701x(SiS_Pr,0x66,0x45); /* Panel power on */ + SiS_SetCH701x(SiS_Pr,0x76,0xaf); /* All power on */ + SiS_LongDelay(SiS_Pr, 1); + SiS_GenericDelay(SiS_Pr, 5887); } else { /* 650 */ @@ -8711,38 +8533,38 @@ SiS_ChrontelDoSomething3(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_INFO HwInfo temp = SiS_GetCH701x(SiS_Pr,0x61); if(temp < 2) { temp++; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x61); + SiS_SetCH701x(SiS_Pr,0x61,temp); temp1 = 1; } - SiS_SetCH701x(SiS_Pr,0xac76); + SiS_SetCH701x(SiS_Pr,0x76,0xac); temp = SiS_GetCH701x(SiS_Pr,0x66); temp |= 0x5f; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66); + SiS_SetCH701x(SiS_Pr,0x66,temp); if(ModeNo > 0x13) { - if(SiS_WeHaveBacklightCtrl(SiS_Pr, HwInfo)) { - SiS_GenericDelay(SiS_Pr,0x3ff); + if(SiS_WeHaveBacklightCtrl(SiS_Pr)) { + SiS_GenericDelay(SiS_Pr, 1023); } else { - SiS_GenericDelay(SiS_Pr,0x2ff); + SiS_GenericDelay(SiS_Pr, 767); } } else { if(!temp1) - SiS_GenericDelay(SiS_Pr,0x2ff); + SiS_GenericDelay(SiS_Pr, 767); } temp = SiS_GetCH701x(SiS_Pr,0x76); temp |= 0x03; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76); + SiS_SetCH701x(SiS_Pr,0x76,temp); temp = SiS_GetCH701x(SiS_Pr,0x66); temp &= 0x7f; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66); - SiS_LongDelay(SiS_Pr,1); + SiS_SetCH701x(SiS_Pr,0x66,temp); + SiS_LongDelay(SiS_Pr, 1); } } static void -SiS_ChrontelDoSomething2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_ChrontelDoSomething2(struct SiS_Private *SiS_Pr) { - USHORT temp,tempcl,tempch; + unsigned short temp,tempcl,tempch; SiS_LongDelay(SiS_Pr, 1); tempcl = 3; @@ -8753,87 +8575,87 @@ SiS_ChrontelDoSomething2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) temp &= 0x04; /* PLL stable? -> bail out */ if(temp == 0x04) break; - if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->ChipType == SIS_740) { /* Power down LVDS output, PLL normal operation */ - SiS_SetCH701x(SiS_Pr,0xac76); + SiS_SetCH701x(SiS_Pr,0x76,0xac); } - SiS_SetCH701xForLCD(SiS_Pr,HwInfo); + SiS_SetCH701xForLCD(SiS_Pr); if(tempcl == 0) { if(tempch == 3) break; - SiS_ChrontelResetDB(SiS_Pr,HwInfo); + SiS_ChrontelResetDB(SiS_Pr); tempcl = 3; tempch++; } tempcl--; temp = SiS_GetCH701x(SiS_Pr,0x76); temp &= 0xfb; /* Reset PLL */ - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76); - SiS_LongDelay(SiS_Pr,2); + SiS_SetCH701x(SiS_Pr,0x76,temp); + SiS_LongDelay(SiS_Pr, 2); temp = SiS_GetCH701x(SiS_Pr,0x76); temp |= 0x04; /* PLL normal operation */ - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76); - if(HwInfo->jChipType == SIS_740) { - SiS_SetCH701x(SiS_Pr,0xe078); /* PLL loop filter */ + SiS_SetCH701x(SiS_Pr,0x76,temp); + if(SiS_Pr->ChipType == SIS_740) { + SiS_SetCH701x(SiS_Pr,0x78,0xe0); /* PLL loop filter */ } else { - SiS_SetCH701x(SiS_Pr,0x6078); + SiS_SetCH701x(SiS_Pr,0x78,0x60); } - SiS_LongDelay(SiS_Pr,2); + SiS_LongDelay(SiS_Pr, 2); } while(0); - SiS_SetCH701x(SiS_Pr,0x0077); /* MV? */ + SiS_SetCH701x(SiS_Pr,0x77,0x00); /* MV? */ } static void -SiS_ChrontelDoSomething1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_ChrontelDoSomething1(struct SiS_Private *SiS_Pr) { - USHORT temp; + unsigned short temp; temp = SiS_GetCH701x(SiS_Pr,0x03); temp |= 0x80; /* Set datapath 1 to TV */ temp &= 0xbf; /* Set datapath 2 to LVDS */ - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x03); + SiS_SetCH701x(SiS_Pr,0x03,temp); - if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->ChipType == SIS_740) { temp = SiS_GetCH701x(SiS_Pr,0x1c); temp &= 0xfb; /* Normal XCLK phase */ - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x1c); + SiS_SetCH701x(SiS_Pr,0x1c,temp); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2d,0x03); temp = SiS_GetCH701x(SiS_Pr,0x64); temp |= 0x40; /* ? Bit not defined */ - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x64); + SiS_SetCH701x(SiS_Pr,0x64,temp); temp = SiS_GetCH701x(SiS_Pr,0x03); temp &= 0x3f; /* D1 input to both LVDS and TV */ - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x03); + SiS_SetCH701x(SiS_Pr,0x03,temp); if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) { - SiS_SetCH701x(SiS_Pr,0x4063); /* LVDS off */ + SiS_SetCH701x(SiS_Pr,0x63,0x40); /* LVDS off */ SiS_LongDelay(SiS_Pr, 1); - SiS_SetCH701x(SiS_Pr,0x0063); /* LVDS on */ - SiS_ChrontelResetDB(SiS_Pr, HwInfo); - SiS_ChrontelDoSomething2(SiS_Pr, HwInfo); - SiS_ChrontelDoSomething3(SiS_Pr, 0, HwInfo); + SiS_SetCH701x(SiS_Pr,0x63,0x00); /* LVDS on */ + SiS_ChrontelResetDB(SiS_Pr); + SiS_ChrontelDoSomething2(SiS_Pr); + SiS_ChrontelDoSomething3(SiS_Pr, 0); } else { temp = SiS_GetCH701x(SiS_Pr,0x66); if(temp != 0x45) { - SiS_ChrontelResetDB(SiS_Pr, HwInfo); - SiS_ChrontelDoSomething2(SiS_Pr, HwInfo); - SiS_ChrontelDoSomething3(SiS_Pr, 0, HwInfo); + SiS_ChrontelResetDB(SiS_Pr); + SiS_ChrontelDoSomething2(SiS_Pr); + SiS_ChrontelDoSomething3(SiS_Pr, 0); } } } else { /* 650 */ - SiS_ChrontelResetDB(SiS_Pr,HwInfo); - SiS_ChrontelDoSomething2(SiS_Pr,HwInfo); + SiS_ChrontelResetDB(SiS_Pr); + SiS_ChrontelDoSomething2(SiS_Pr); temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x34); - SiS_ChrontelDoSomething3(SiS_Pr,temp,HwInfo); - SiS_SetCH701x(SiS_Pr,0xaf76); /* All power on, LVDS normal operation */ + SiS_ChrontelDoSomething3(SiS_Pr,temp); + SiS_SetCH701x(SiS_Pr,0x76,0xaf); /* All power on, LVDS normal operation */ } @@ -8845,15 +8667,12 @@ SiS_ChrontelDoSomething1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) /*********************************************/ BOOLEAN -SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) +SiS_SetCRT2Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo) { #ifdef SIS300 - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; -#endif - USHORT ModeIdIndex, RefreshRateTableIndex; -#if 0 - USHORT temp; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; #endif + unsigned short ModeIdIndex, RefreshRateTableIndex; SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; @@ -8866,37 +8685,37 @@ SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) /* Used for shifting CR33 */ SiS_Pr->SiS_SelectCRT2Rate = 4; - SiS_UnLockCRT2(SiS_Pr, HwInfo); + SiS_UnLockCRT2(SiS_Pr); - RefreshRateTableIndex = SiS_GetRatePtr(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + RefreshRateTableIndex = SiS_GetRatePtr(SiS_Pr, ModeNo, ModeIdIndex); SiS_SaveCRT2Info(SiS_Pr,ModeNo); if(SiS_Pr->SiS_SetFlag & LowModeTests) { - SiS_DisableBridge(SiS_Pr,HwInfo); - if((SiS_Pr->SiS_IF_DEF_LVDS == 1) && (HwInfo->jChipType == SIS_730)) { + SiS_DisableBridge(SiS_Pr); + if((SiS_Pr->SiS_IF_DEF_LVDS == 1) && (SiS_Pr->ChipType == SIS_730)) { SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,0x80); } - SiS_SetCRT2ModeRegs(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + SiS_SetCRT2ModeRegs(SiS_Pr, ModeNo, ModeIdIndex); } if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { - SiS_LockCRT2(SiS_Pr, HwInfo); + SiS_LockCRT2(SiS_Pr); SiS_DisplayOn(SiS_Pr); return TRUE; } - SiS_GetCRT2Data(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + SiS_GetCRT2Data(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); /* Set up Panel Link for LVDS and LCDA */ SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_LCDVDES = 0; if( (SiS_Pr->SiS_IF_DEF_LVDS == 1) || ((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) || - ((HwInfo->jChipType >= SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) ) { - SiS_GetLVDSDesData(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + ((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS30xBLV)) ) { + SiS_GetLVDSDesData(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); } -#ifdef LINUX_XF86 +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "(init301: LCDHDES 0x%03x LCDVDES 0x%03x)\n", SiS_Pr->SiS_LCDHDES, SiS_Pr->SiS_LCDVDES); xf86DrvMsg(0, X_INFO, "(init301: HDE 0x%03x VDE 0x%03x)\n", SiS_Pr->SiS_HDE, SiS_Pr->SiS_VDE); @@ -8907,86 +8726,79 @@ SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) #endif if(SiS_Pr->SiS_SetFlag & LowModeTests) { - SiS_SetGroup1(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex); + SiS_SetGroup1(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); } if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(SiS_Pr->SiS_SetFlag & LowModeTests) { + if(SiS_Pr->SiS_SetFlag & LowModeTests) { - SiS_SetGroup2(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + SiS_SetGroup2(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); #ifdef SIS315H - SiS_SetGroup2_C_ELV(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + SiS_SetGroup2_C_ELV(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); #endif - SiS_SetGroup3(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); - SiS_SetGroup4(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + SiS_SetGroup3(SiS_Pr, ModeNo, ModeIdIndex); + SiS_SetGroup4(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); #ifdef SIS315H - SiS_SetGroup4_C_ELV(SiS_Pr, HwInfo, ModeNo, ModeIdIndex); + SiS_SetGroup4_C_ELV(SiS_Pr, ModeNo, ModeIdIndex); #endif - SiS_SetGroup5(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + SiS_SetGroup5(SiS_Pr, ModeNo, ModeIdIndex); - SiS_SetCRT2Sync(SiS_Pr, ModeNo, RefreshRateTableIndex, HwInfo); + SiS_SetCRT2Sync(SiS_Pr, ModeNo, RefreshRateTableIndex); - /* For 301BDH (Panel link initialization): */ - if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { - if(SiS_Pr->SiS_LCDResInfo != Panel_640x480) { - if(!((SiS_Pr->SiS_SetFlag & SetDOSMode) && ((ModeNo == 0x03) || (ModeNo == 0x10)))) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - SiS_ModCRT1CRTC(SiS_Pr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwInfo); - } - } - } - SiS_SetCRT2ECLK(SiS_Pr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwInfo); - } - } + /* For 301BDH (Panel link initialization): */ + if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { + + if(!((SiS_Pr->SiS_SetFlag & SetDOSMode) && ((ModeNo == 0x03) || (ModeNo == 0x10)))) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + SiS_ModCRT1CRTC(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); + } + } + SiS_SetCRT2ECLK(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); + } + } } else { - SiS_SetCRT2Sync(SiS_Pr, ModeNo, RefreshRateTableIndex, HwInfo); + SiS_SetCRT2Sync(SiS_Pr, ModeNo, RefreshRateTableIndex); - if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { - SiS_ModCRT1CRTC(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex,HwInfo); - } + SiS_ModCRT1CRTC(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex); - SiS_SetCRT2ECLK(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex,HwInfo); + SiS_SetCRT2ECLK(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex); - if(SiS_Pr->SiS_SetFlag & LowModeTests) { - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + if(SiS_Pr->SiS_SetFlag & LowModeTests) { + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { #ifdef SIS315H - SiS_SetCH701xForLCD(SiS_Pr,HwInfo); + SiS_SetCH701xForLCD(SiS_Pr); #endif - } - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - SiS_SetCHTVReg(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex); - } - } - } + } + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + SiS_SetCHTVReg(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex); + } + } + } } #ifdef SIS300 - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { if(SiS_Pr->SiS_SetFlag & LowModeTests) { if(SiS_Pr->SiS_UseOEM) { if((SiS_Pr->SiS_UseROM) && (SiS_Pr->SiS_UseOEM == -1)) { if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { - SiS_OEM300Setting(SiS_Pr,HwInfo,ModeNo,ModeIdIndex, - RefreshRateTableIndex); + SiS_OEM300Setting(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); } } else { - SiS_OEM300Setting(SiS_Pr,HwInfo,ModeNo,ModeIdIndex, - RefreshRateTableIndex); + SiS_OEM300Setting(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); } } if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || + if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { - SetOEMLCDData2(SiS_Pr, HwInfo, ModeNo, ModeIdIndex,RefreshRateTableIndex); + SetOEMLCDData2(SiS_Pr, ModeNo, ModeIdIndex,RefreshRateTableIndex); } SiS_DisplayOn(SiS_Pr); } @@ -8995,21 +8807,21 @@ SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) #endif #ifdef SIS315H - if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->ChipType >= SIS_315H) { if(SiS_Pr->SiS_SetFlag & LowModeTests) { - if(HwInfo->jChipType < SIS_661) { - SiS_FinalizeLCD(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); - SiS_OEM310Setting(SiS_Pr, HwInfo, ModeNo, ModeIdIndex, RefreshRateTableIndex); + if(SiS_Pr->ChipType < SIS_661) { + SiS_FinalizeLCD(SiS_Pr, ModeNo, ModeIdIndex); + SiS_OEM310Setting(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); } else { - SiS_OEM661Setting(SiS_Pr, HwInfo, ModeNo, ModeIdIndex, RefreshRateTableIndex); + SiS_OEM661Setting(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); } - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x40); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x40); } } #endif if(SiS_Pr->SiS_SetFlag & LowModeTests) { - SiS_EnableBridge(SiS_Pr, HwInfo); + SiS_EnableBridge(SiS_Pr); } SiS_DisplayOn(SiS_Pr); @@ -9017,15 +8829,15 @@ SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* Disable LCD panel when using TV */ - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFF,0x0C); + SiS_SetRegSR11ANDOR(SiS_Pr,0xFF,0x0C); } else { /* Disable TV when using LCD */ - SiS_SetCH70xxANDOR(SiS_Pr,0x010E,0xF8); + SiS_SetCH70xxANDOR(SiS_Pr,0x0e,0x01,0xf8); } } if(SiS_Pr->SiS_SetFlag & LowModeTests) { - SiS_LockCRT2(SiS_Pr,HwInfo); + SiS_LockCRT2(SiS_Pr); } return TRUE; @@ -9037,13 +8849,13 @@ SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) /*********************************************/ void -SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_SiS30xBLOn(struct SiS_Private *SiS_Pr) { /* Switch on LCD backlight on SiS30xLV */ SiS_DDC2Delay(SiS_Pr,0xff00); if(!(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) { SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); - SiS_WaitVBRetrace(SiS_Pr,HwInfo); + SiS_WaitVBRetrace(SiS_Pr); } if(!(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x01)) { SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01); @@ -9051,12 +8863,11 @@ SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) } void -SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_SiS30xBLOff(struct SiS_Private *SiS_Pr) { /* Switch off LCD backlight on SiS30xLV */ SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE); - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD); - SiS_DDC2Delay(SiS_Pr,0xe000); + SiS_DDC2Delay(SiS_Pr,0xff00); } /*********************************************/ @@ -9064,7 +8875,7 @@ SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) /*********************************************/ static void -SiS_SetupDDCN(SiS_Private *SiS_Pr) +SiS_SetupDDCN(struct SiS_Private *SiS_Pr) { SiS_Pr->SiS_DDC_NData = ~SiS_Pr->SiS_DDC_Data; SiS_Pr->SiS_DDC_NClk = ~SiS_Pr->SiS_DDC_Clk; @@ -9075,12 +8886,12 @@ SiS_SetupDDCN(SiS_Private *SiS_Pr) } #ifdef SIS300 -static UCHAR * -SiS_SetTrumpBlockLoop(SiS_Private *SiS_Pr, UCHAR *dataptr) +static unsigned char * +SiS_SetTrumpBlockLoop(struct SiS_Private *SiS_Pr, unsigned char *dataptr) { int i, j, num; - USHORT tempah,temp; - UCHAR *mydataptr; + unsigned short tempah,temp; + unsigned char *mydataptr; for(i=0; i<20; i++) { /* Do 20 attempts to write */ mydataptr = dataptr; @@ -9088,7 +8899,7 @@ SiS_SetTrumpBlockLoop(SiS_Private *SiS_Pr, UCHAR *dataptr) if(!num) return mydataptr; if(i) { SiS_SetStop(SiS_Pr); - SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT*2); + SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT * 2); } if(SiS_SetStart(SiS_Pr)) continue; /* Set start condition */ tempah = SiS_Pr->SiS_DDC_DeviceAddr; @@ -9110,12 +8921,12 @@ SiS_SetTrumpBlockLoop(SiS_Private *SiS_Pr, UCHAR *dataptr) } static BOOLEAN -SiS_SetTrumpionBlock(SiS_Private *SiS_Pr, UCHAR *dataptr) +SiS_SetTrumpionBlock(struct SiS_Private *SiS_Pr, unsigned char *dataptr) { SiS_Pr->SiS_DDC_DeviceAddr = 0xF0; /* DAB (Device Address Byte) */ SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ - SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ - SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ + SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ + SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ SiS_SetupDDCN(SiS_Pr); SiS_SetSwitchDDC2(SiS_Pr); @@ -9124,9 +8935,11 @@ SiS_SetTrumpionBlock(SiS_Private *SiS_Pr, UCHAR *dataptr) dataptr = SiS_SetTrumpBlockLoop(SiS_Pr, dataptr); if(!dataptr) return FALSE; } +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "Trumpion block success\n"); #endif +#endif return TRUE; } #endif @@ -9139,155 +8952,121 @@ SiS_SetTrumpionBlock(SiS_Private *SiS_Pr, UCHAR *dataptr) */ static BOOLEAN -SiS_SetChReg(SiS_Private *SiS_Pr, USHORT tempbx, USHORT myor) +SiS_SetChReg(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val, unsigned short myor) { - USHORT tempah,temp,i; + unsigned short temp, i; for(i=0; i<20; i++) { /* Do 20 attempts to write */ if(i) { - SiS_SetStop(SiS_Pr); - SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT); - } - if(SiS_SetStart(SiS_Pr)) continue; /* Set start condition */ - tempah = SiS_Pr->SiS_DDC_DeviceAddr; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* Write DAB (S0=0=write) */ - if(temp) continue; /* (ERROR: no ack) */ - tempah = tempbx & 0x00FF; /* Write RAB */ - tempah |= myor; /* (700x: set bit 7, see datasheet) */ - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); - if(temp) continue; /* (ERROR: no ack) */ - tempah = (tempbx & 0xFF00) >> 8; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* Write data */ - if(temp) continue; /* (ERROR: no ack) */ - if(SiS_SetStop(SiS_Pr)) continue; /* Set stop condition */ + SiS_SetStop(SiS_Pr); + SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT * 4); + } + if(SiS_SetStart(SiS_Pr)) continue; /* Set start condition */ + temp = SiS_WriteDDC2Data(SiS_Pr, SiS_Pr->SiS_DDC_DeviceAddr); /* Write DAB (S0=0=write) */ + if(temp) continue; /* (ERROR: no ack) */ + temp = SiS_WriteDDC2Data(SiS_Pr, (reg | myor)); /* Write RAB (700x: set bit 7, see datasheet) */ + if(temp) continue; /* (ERROR: no ack) */ + temp = SiS_WriteDDC2Data(SiS_Pr, val); /* Write data */ + if(temp) continue; /* (ERROR: no ack) */ + if(SiS_SetStop(SiS_Pr)) continue; /* Set stop condition */ SiS_Pr->SiS_ChrontelInit = 1; return TRUE; } return FALSE; } -#if 0 -#ifdef SIS300 -/* Write Trumpion register */ -static void -SiS_SetTrumpReg(SiS_Private *SiS_Pr, USHORT tempbx) -{ - SiS_Pr->SiS_DDC_DeviceAddr = 0xF0; /* DAB (Device Address Byte) */ - SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ - SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ - SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ - SiS_SetupDDCN(SiS_Pr); - SiS_SetChReg(SiS_Pr, tempbx, 0); -} -#endif -#endif - /* Write to Chrontel 700x */ -/* Parameter is [Data (S15-S8) | Register no (S7-S0)] */ void -SiS_SetCH700x(SiS_Private *SiS_Pr, USHORT tempbx) +SiS_SetCH700x(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val) { SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB (Device Address Byte) */ + SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT); + if(!(SiS_Pr->SiS_ChrontelInit)) { SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ - SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ - SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ + SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ + SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ SiS_SetupDDCN(SiS_Pr); } - if( (!(SiS_SetChReg(SiS_Pr, tempbx, 0x80))) && + if( (!(SiS_SetChReg(SiS_Pr, reg, val, 0x80))) && (!(SiS_Pr->SiS_ChrontelInit)) ) { - SiS_Pr->SiS_DDC_Index = 0x0a; /* Bit 7 = SC; Bit 6 = SD */ - SiS_Pr->SiS_DDC_Data = 0x80; /* Bitmask in IndexReg for Data */ - SiS_Pr->SiS_DDC_Clk = 0x40; /* Bitmask in IndexReg for Clk */ + SiS_Pr->SiS_DDC_Index = 0x0a; + SiS_Pr->SiS_DDC_Data = 0x80; + SiS_Pr->SiS_DDC_Clk = 0x40; SiS_SetupDDCN(SiS_Pr); - SiS_SetChReg(SiS_Pr, tempbx, 0x80); + SiS_SetChReg(SiS_Pr, reg, val, 0x80); } } /* Write to Chrontel 701x */ /* Parameter is [Data (S15-S8) | Register no (S7-S0)] */ void -SiS_SetCH701x(SiS_Private *SiS_Pr, USHORT tempbx) +SiS_SetCH701x(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val) { SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ - SiS_Pr->SiS_DDC_Data = 0x08; /* Bitmask in IndexReg for Data */ - SiS_Pr->SiS_DDC_Clk = 0x04; /* Bitmask in IndexReg for Clk */ + SiS_Pr->SiS_DDC_Data = 0x08; /* Bitmask in IndexReg for Data */ + SiS_Pr->SiS_DDC_Clk = 0x04; /* Bitmask in IndexReg for Clk */ SiS_SetupDDCN(SiS_Pr); - SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB (Device Address Byte) */ - SiS_SetChReg(SiS_Pr, tempbx, 0); + SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB (Device Address Byte) */ + SiS_SetChReg(SiS_Pr, reg, val, 0); } -static void -SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx) +#ifdef SIS_LINUX_KERNEL +static +#endif +void +SiS_SetCH70xx(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val) { if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) - SiS_SetCH700x(SiS_Pr,tempbx); + SiS_SetCH700x(SiS_Pr, reg, val); else - SiS_SetCH701x(SiS_Pr,tempbx); + SiS_SetCH701x(SiS_Pr, reg, val); } -static USHORT -SiS_GetChReg(SiS_Private *SiS_Pr, USHORT myor) +static unsigned short +SiS_GetChReg(struct SiS_Private *SiS_Pr, unsigned short myor) { - USHORT tempah,temp,i; + unsigned short tempah, temp, i; for(i=0; i<20; i++) { /* Do 20 attempts to read */ if(i) { - SiS_SetStop(SiS_Pr); - SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT); - } - if(SiS_SetStart(SiS_Pr)) continue; /* Set start condition */ - tempah = SiS_Pr->SiS_DDC_DeviceAddr; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* Write DAB (S0=0=write) */ - if(temp) continue; /* (ERROR: no ack) */ - tempah = SiS_Pr->SiS_DDC_ReadAddr | myor; /* Write RAB (700x: | 0x80) */ - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); - if(temp) continue; /* (ERROR: no ack) */ - if (SiS_SetStart(SiS_Pr)) continue; /* Re-start */ - tempah = SiS_Pr->SiS_DDC_DeviceAddr | 0x01;/* DAB | 0x01 = Read */ - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* DAB (S0=1=read) */ - if(temp) continue; /* (ERROR: no ack) */ - tempah = SiS_ReadDDC2Data(SiS_Pr,tempah); /* Read byte */ - if(SiS_SetStop(SiS_Pr)) continue; /* Stop condition */ + SiS_SetStop(SiS_Pr); + SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT * 4); + } + if(SiS_SetStart(SiS_Pr)) continue; /* Set start condition */ + temp = SiS_WriteDDC2Data(SiS_Pr,SiS_Pr->SiS_DDC_DeviceAddr); /* Write DAB (S0=0=write) */ + if(temp) continue; /* (ERROR: no ack) */ + temp = SiS_WriteDDC2Data(SiS_Pr,SiS_Pr->SiS_DDC_ReadAddr | myor); /* Write RAB (700x: | 0x80) */ + if(temp) continue; /* (ERROR: no ack) */ + if (SiS_SetStart(SiS_Pr)) continue; /* Re-start */ + temp = SiS_WriteDDC2Data(SiS_Pr,SiS_Pr->SiS_DDC_DeviceAddr | 0x01);/* DAB (S0=1=read) */ + if(temp) continue; /* (ERROR: no ack) */ + tempah = SiS_ReadDDC2Data(SiS_Pr); /* Read byte */ + if(SiS_SetStop(SiS_Pr)) continue; /* Stop condition */ SiS_Pr->SiS_ChrontelInit = 1; - return(tempah); + return tempah; } return 0xFFFF; } -#if 0 -#ifdef SIS300 -/* Read from Trumpion */ -static USHORT -SiS_GetTrumpReg(SiS_Private *SiS_Pr, USHORT tempbx) -{ - SiS_Pr->SiS_DDC_DeviceAddr = 0xF0; /* DAB */ - SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ - SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ - SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ - SiS_SetupDDCN(SiS_Pr); - SiS_Pr->SiS_DDC_ReadAddr = tempbx; - return(SiS_GetChReg(SiS_Pr,0)); -} -#endif -#endif - /* Read from Chrontel 700x */ /* Parameter is [Register no (S7-S0)] */ -USHORT -SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempbx) +unsigned short +SiS_GetCH700x(struct SiS_Private *SiS_Pr, unsigned short tempbx) { - USHORT result; + unsigned short result; SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB */ + SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT); + if(!(SiS_Pr->SiS_ChrontelInit)) { SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ - SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ - SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ + SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ + SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ SiS_SetupDDCN(SiS_Pr); } @@ -9303,52 +9082,69 @@ SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempbx) result = SiS_GetChReg(SiS_Pr,0x80); } - return(result); + return result; } /* Read from Chrontel 701x */ /* Parameter is [Register no (S7-S0)] */ -USHORT -SiS_GetCH701x(SiS_Private *SiS_Pr, USHORT tempbx) +unsigned short +SiS_GetCH701x(struct SiS_Private *SiS_Pr, unsigned short tempbx) { SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ - SiS_Pr->SiS_DDC_Data = 0x08; /* Bitmask in IndexReg for Data */ - SiS_Pr->SiS_DDC_Clk = 0x04; /* Bitmask in IndexReg for Clk */ + SiS_Pr->SiS_DDC_Data = 0x08; /* Bitmask in IndexReg for Data */ + SiS_Pr->SiS_DDC_Clk = 0x04; /* Bitmask in IndexReg for Clk */ SiS_SetupDDCN(SiS_Pr); SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB */ SiS_Pr->SiS_DDC_ReadAddr = tempbx; - return(SiS_GetChReg(SiS_Pr,0)); + return SiS_GetChReg(SiS_Pr,0); } /* Read from Chrontel 70xx */ /* Parameter is [Register no (S7-S0)] */ -static USHORT -SiS_GetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx) +#ifdef SIS_LINUX_KERNEL +static +#endif +unsigned short +SiS_GetCH70xx(struct SiS_Private *SiS_Pr, unsigned short tempbx) { if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) - return(SiS_GetCH700x(SiS_Pr, tempbx)); + return SiS_GetCH700x(SiS_Pr, tempbx); else - return(SiS_GetCH701x(SiS_Pr, tempbx)); + return SiS_GetCH701x(SiS_Pr, tempbx); +} + +void +SiS_SetCH70xxANDOR(struct SiS_Private *SiS_Pr, unsigned short reg, + unsigned char myor, unsigned short myand) +{ + unsigned short tempbl; + + tempbl = (SiS_GetCH70xx(SiS_Pr, (reg & 0xFF)) & myand) | myor; + SiS_SetCH70xx(SiS_Pr, reg, tempbl); } /* Our own DDC functions */ -static USHORT -SiS_InitDDCRegs(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, - USHORT adaptnum, USHORT DDCdatatype, BOOLEAN checkcr32) +#ifndef SIS_XORG_XF86 +static +#endif +unsigned short +SiS_InitDDCRegs(struct SiS_Private *SiS_Pr, unsigned int VBFlags, int VGAEngine, + unsigned short adaptnum, unsigned short DDCdatatype, BOOLEAN checkcr32, + unsigned int VBFlags2) { unsigned char ddcdtype[] = { 0xa0, 0xa0, 0xa0, 0xa2, 0xa6 }; unsigned char flag, cr32; - USHORT temp = 0, myadaptnum = adaptnum; + unsigned short temp = 0, myadaptnum = adaptnum; if(adaptnum != 0) { - if(!(VBFlags & (VB_301|VB_301B|VB_301C|VB_302B))) return 0xFFFF; - if((VBFlags & VB_30xBDH) && (adaptnum == 1)) return 0xFFFF; - } - + if(!(VBFlags2 & VB2_SISTMDSBRIDGE)) return 0xFFFF; + if((VBFlags2 & VB2_30xBDH) && (adaptnum == 1)) return 0xFFFF; + } + /* adapternum for SiS bridges: 0 = CRT1, 1 = LCD, 2 = VGA2 */ - + SiS_Pr->SiS_ChrontelInit = 0; /* force re-detection! */ SiS_Pr->SiS_DDC_SecAddr = 0; @@ -9360,7 +9156,7 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, cr32 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x32); #if 0 - if(VBFlags & VB_SISBRIDGE) { + if(VBFlags2 & VB2_SISBRIDGE) { if(myadaptnum == 0) { if(!(cr32 & 0x20)) { myadaptnum = 2; @@ -9376,20 +9172,20 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, #endif if(VGAEngine == SIS_300_VGA) { /* 300 series */ - + if(myadaptnum != 0) { flag = 0; - if(VBFlags & VB_SISBRIDGE) { + if(VBFlags2 & VB2_SISBRIDGE) { SiS_Pr->SiS_DDC_Port = SiS_Pr->SiS_Part4Port; SiS_Pr->SiS_DDC_Index = 0x0f; } } - if(!(VBFlags & VB_301)) { + if(!(VBFlags2 & VB2_301)) { if((cr32 & 0x80) && (checkcr32)) { if(myadaptnum >= 1) { if(!(cr32 & 0x08)) { - myadaptnum = 1; + myadaptnum = 1; if(!(cr32 & 0x10)) return 0xFFFF; } } @@ -9401,17 +9197,17 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, } else { /* 315/330 series */ - /* here we simplify: 0 = CRT1, 1 = CRT2 (VGA, LCD) */ + /* here we simplify: 0 = CRT1, 1 = CRT2 (VGA, LCD) */ - if(VBFlags & VB_SISBRIDGE) { + if(VBFlags2 & VB2_SISBRIDGE) { if(myadaptnum == 2) { myadaptnum = 1; - } + } } if(myadaptnum == 1) { - flag = 0; - if(VBFlags & VB_SISBRIDGE) { + flag = 0; + if(VBFlags2 & VB2_SISBRIDGE) { SiS_Pr->SiS_DDC_Port = SiS_Pr->SiS_Part4Port; SiS_Pr->SiS_DDC_Index = 0x0f; } @@ -9429,93 +9225,96 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, temp = myadaptnum; if(myadaptnum == 1) { temp = 0; - if(VBFlags & VB_LVDS) flag = 0xff; + if(VBFlags2 & VB2_LVDS) flag = 0xff; } if(flag) temp = 0; } - + SiS_Pr->SiS_DDC_Data = 0x02 << temp; SiS_Pr->SiS_DDC_Clk = 0x01 << temp; SiS_SetupDDCN(SiS_Pr); +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "DDC Port %x Index %x Shift %d\n", SiS_Pr->SiS_DDC_Port, SiS_Pr->SiS_DDC_Index, temp); #endif - +#endif return 0; } -static USHORT -SiS_WriteDABDDC(SiS_Private *SiS_Pr) +static unsigned short +SiS_WriteDABDDC(struct SiS_Private *SiS_Pr) { if(SiS_SetStart(SiS_Pr)) return 0xFFFF; if(SiS_WriteDDC2Data(SiS_Pr, SiS_Pr->SiS_DDC_DeviceAddr)) { - return 0xFFFF; + return 0xFFFF; } if(SiS_WriteDDC2Data(SiS_Pr, SiS_Pr->SiS_DDC_SecAddr)) { - return 0xFFFF; + return 0xFFFF; } - return(0); + return 0; } -static USHORT -SiS_PrepareReadDDC(SiS_Private *SiS_Pr) +static unsigned short +SiS_PrepareReadDDC(struct SiS_Private *SiS_Pr) { if(SiS_SetStart(SiS_Pr)) return 0xFFFF; if(SiS_WriteDDC2Data(SiS_Pr, (SiS_Pr->SiS_DDC_DeviceAddr | 0x01))) { - return 0xFFFF; + return 0xFFFF; } - return(0); + return 0; } -static USHORT -SiS_PrepareDDC(SiS_Private *SiS_Pr) +static unsigned short +SiS_PrepareDDC(struct SiS_Private *SiS_Pr) { if(SiS_WriteDABDDC(SiS_Pr)) SiS_WriteDABDDC(SiS_Pr); - if(SiS_PrepareReadDDC(SiS_Pr)) return(SiS_PrepareReadDDC(SiS_Pr)); - return(0); + if(SiS_PrepareReadDDC(SiS_Pr)) return (SiS_PrepareReadDDC(SiS_Pr)); + return 0; } static void -SiS_SendACK(SiS_Private *SiS_Pr, USHORT yesno) +SiS_SendACK(struct SiS_Private *SiS_Pr, unsigned short yesno) { SiS_SetSCLKLow(SiS_Pr); if(yesno) { SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, - SiS_Pr->SiS_DDC_Index, - SiS_Pr->SiS_DDC_NData, + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, SiS_Pr->SiS_DDC_Data); } else { SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, - SiS_Pr->SiS_DDC_Index, - SiS_Pr->SiS_DDC_NData, + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, 0); } SiS_SetSCLKHigh(SiS_Pr); } -static USHORT -SiS_DoProbeDDC(SiS_Private *SiS_Pr) +static unsigned short +SiS_DoProbeDDC(struct SiS_Private *SiS_Pr) { unsigned char mask, value; - USHORT temp, ret=0; + unsigned short temp, ret=0; BOOLEAN failed = FALSE; SiS_SetSwitchDDC2(SiS_Pr); if(SiS_PrepareDDC(SiS_Pr)) { SiS_SetStop(SiS_Pr); +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "Probe: Prepare failed\n"); #endif - return(0xFFFF); +#endif + return 0xFFFF; } mask = 0xf0; value = 0x20; if(SiS_Pr->SiS_DDC_DeviceAddr == 0xa0) { - temp = (unsigned char)SiS_ReadDDC2Data(SiS_Pr, 0); + temp = (unsigned char)SiS_ReadDDC2Data(SiS_Pr); SiS_SendACK(SiS_Pr, 0); if(temp == 0) { mask = 0xff; @@ -9523,34 +9322,41 @@ SiS_DoProbeDDC(SiS_Private *SiS_Pr) } else { failed = TRUE; ret = 0xFFFF; +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "Probe: Read 1 failed\n"); #endif +#endif } } if(failed == FALSE) { - temp = (unsigned char)SiS_ReadDDC2Data(SiS_Pr, 0); + temp = (unsigned char)SiS_ReadDDC2Data(SiS_Pr); SiS_SendACK(SiS_Pr, 1); temp &= mask; if(temp == value) ret = 0; else { ret = 0xFFFF; +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "Probe: Read 2 failed\n"); #endif +#endif if(SiS_Pr->SiS_DDC_DeviceAddr == 0xa0) { if(temp == 0x30) ret = 0; } } } SiS_SetStop(SiS_Pr); - return(ret); + return ret; } -static USHORT -SiS_ProbeDDC(SiS_Private *SiS_Pr) +#ifndef SIS_XORG_XF86 +static +#endif +unsigned short +SiS_ProbeDDC(struct SiS_Private *SiS_Pr) { - USHORT flag; + unsigned short flag; flag = 0x180; SiS_Pr->SiS_DDC_DeviceAddr = 0xa0; @@ -9560,16 +9366,19 @@ SiS_ProbeDDC(SiS_Private *SiS_Pr) SiS_Pr->SiS_DDC_DeviceAddr = 0xa6; if(!(SiS_DoProbeDDC(SiS_Pr))) flag |= 0x10; if(!(flag & 0x1a)) flag = 0; - return(flag); + return flag; } -static USHORT -SiS_ReadDDC(SiS_Private *SiS_Pr, USHORT DDCdatatype, unsigned char *buffer) +#ifndef SIS_XORG_XF86 +static +#endif +unsigned short +SiS_ReadDDC(struct SiS_Private *SiS_Pr, unsigned short DDCdatatype, unsigned char *buffer) { - USHORT flag, length, i; + unsigned short flag, length, i; unsigned char chksum,gotcha; - if(DDCdatatype > 4) return 0xFFFF; + if(DDCdatatype > 4) return 0xFFFF; flag = 0; SiS_SetSwitchDDC2(SiS_Pr); @@ -9579,21 +9388,21 @@ SiS_ReadDDC(SiS_Private *SiS_Pr, USHORT DDCdatatype, unsigned char *buffer) chksum = 0; gotcha = 0; for(i=0; i<length; i++) { - buffer[i] = (unsigned char)SiS_ReadDDC2Data(SiS_Pr, 0); + buffer[i] = (unsigned char)SiS_ReadDDC2Data(SiS_Pr); chksum += buffer[i]; gotcha |= buffer[i]; SiS_SendACK(SiS_Pr, 0); } - buffer[i] = (unsigned char)SiS_ReadDDC2Data(SiS_Pr, 0); + buffer[i] = (unsigned char)SiS_ReadDDC2Data(SiS_Pr); chksum += buffer[i]; SiS_SendACK(SiS_Pr, 1); - if(gotcha) flag = (USHORT)chksum; + if(gotcha) flag = (unsigned short)chksum; else flag = 0xFFFF; } else { flag = 0xFFFF; } SiS_SetStop(SiS_Pr); - return(flag); + return flag; } /* Our private DDC functions @@ -9617,17 +9426,25 @@ SiS_ReadDDC(SiS_Private *SiS_Pr, USHORT DDCdatatype, unsigned char *buffer) if DDCdatatype = 0: Returns supported DDC modes */ -USHORT -SiS_HandleDDC(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, - USHORT adaptnum, USHORT DDCdatatype, unsigned char *buffer) +unsigned short +SiS_HandleDDC(struct SiS_Private *SiS_Pr, unsigned int VBFlags, int VGAEngine, + unsigned short adaptnum, unsigned short DDCdatatype, unsigned char *buffer, + unsigned int VBFlags2) { - unsigned char sr1f,cr17=1; - USHORT result; + unsigned char sr1f, cr17=1; + unsigned short result; - if(adaptnum > 2) return 0xFFFF; - if(DDCdatatype > 4) return 0xFFFF; - if((!(VBFlags & VB_VIDEOBRIDGE)) && (adaptnum > 0)) return 0xFFFF; - if(SiS_InitDDCRegs(SiS_Pr, VBFlags, VGAEngine, adaptnum, DDCdatatype, FALSE) == 0xFFFF) return 0xFFFF; + if(adaptnum > 2) + return 0xFFFF; + + if(DDCdatatype > 4) + return 0xFFFF; + + if((!(VBFlags2 & VB2_VIDEOBRIDGE)) && (adaptnum > 0)) + return 0xFFFF; + + if(SiS_InitDDCRegs(SiS_Pr, VBFlags, VGAEngine, adaptnum, DDCdatatype, FALSE, VBFlags2) == 0xFFFF) + return 0xFFFF; sr1f = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1f); SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x1f,0x3f,0x04); @@ -9656,10 +9473,12 @@ SiS_HandleDDC(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, (buffer[4] == 0xff) && (buffer[5] == 0xff) && (buffer[6] == 0xff) && (buffer[7] == 0x00) && (buffer[0x12] == 1)) { - if(adaptnum == 1) { - if(!(buffer[0x14] & 0x80)) result = 0xFFFE; - } else { - if(buffer[0x14] & 0x80) result = 0xFFFE; + if(!SiS_Pr->DDCPortMixup) { + if(adaptnum == 1) { + if(!(buffer[0x14] & 0x80)) result = 0xFFFE; + } else { + if(buffer[0x14] & 0x80) result = 0xFFFE; + } } } } @@ -9671,832 +9490,10 @@ SiS_HandleDDC(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, return result; } -#ifdef LINUX_XF86 - -static BOOLEAN -checkedid1(unsigned char *buffer) -{ - /* Check header */ - if((buffer[0] != 0x00) || - (buffer[1] != 0xff) || - (buffer[2] != 0xff) || - (buffer[3] != 0xff) || - (buffer[4] != 0xff) || - (buffer[5] != 0xff) || - (buffer[6] != 0xff) || - (buffer[7] != 0x00)) - return FALSE; - - /* Check EDID version and revision */ - if((buffer[0x12] != 1) || (buffer[0x13] > 4)) return FALSE; - - /* Check week of manufacture for sanity */ - if(buffer[0x10] > 53) return FALSE; - - /* Check year of manufacture for sanity */ - if(buffer[0x11] > 40) return FALSE; - - return TRUE; -} - -static BOOLEAN -checkedid2(unsigned char *buffer) -{ - USHORT year = buffer[6] | (buffer[7] << 8); - - /* Check EDID version */ - if((buffer[0] & 0xf0) != 0x20) return FALSE; - - /* Check week of manufacture for sanity */ - if(buffer[5] > 53) return FALSE; - - /* Check year of manufacture for sanity */ - if((year != 0) && ((year < 1990) || (year > 2030))) return FALSE; - - return TRUE; -} - -/* Sense the LCD parameters (CR36, CR37) via DDC */ -/* SiS30x(B) only */ -USHORT -SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS) -{ - USHORT DDCdatatype, paneltype, flag, xres=0, yres=0; - USHORT index, myindex, lumsize, numcodes, panelvendor, panelproduct; - int maxx=0, maxy=0, prefx=0, prefy=0; - unsigned char cr37=0, seekcode; - BOOLEAN checkexpand = FALSE; - BOOLEAN havesync = FALSE; - BOOLEAN indb = FALSE; - int retry, i; - unsigned char buffer[256]; - - for(i=0; i<7; i++) SiS_Pr->CP_DataValid[i] = FALSE; - SiS_Pr->CP_HaveCustomData = FALSE; - SiS_Pr->CP_MaxX = SiS_Pr->CP_MaxY = SiS_Pr->CP_MaxClock = 0; - SiS_Pr->CP_PreferredX = SiS_Pr->CP_PreferredY = 0; - SiS_Pr->CP_PreferredIndex = -1; - SiS_Pr->CP_PrefClock = 0; - SiS_Pr->PanelSelfDetected = FALSE; - - if(!(pSiS->VBFlags & (VB_301|VB_301B|VB_301C|VB_302B))) return 0; - if(pSiS->VBFlags & VB_30xBDH) return 0; - - if(SiS_InitDDCRegs(SiS_Pr, pSiS->VBFlags, pSiS->VGAEngine, 1, 0, FALSE) == 0xFFFF) return 0; - - SiS_Pr->SiS_DDC_SecAddr = 0x00; - - /* Probe supported DA's */ - flag = SiS_ProbeDDC(SiS_Pr); -#ifdef TWDEBUG - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO, - "CRT2 DDC capabilities 0x%x\n", flag); -#endif - if(flag & 0x10) { - SiS_Pr->SiS_DDC_DeviceAddr = 0xa6; /* EDID V2 (FP) */ - DDCdatatype = 4; - } else if(flag & 0x08) { - SiS_Pr->SiS_DDC_DeviceAddr = 0xa2; /* EDID V2 (P&D-D Monitor) */ - DDCdatatype = 3; - } else if(flag & 0x02) { - SiS_Pr->SiS_DDC_DeviceAddr = 0xa0; /* EDID V1 */ - DDCdatatype = 1; - } else return 0; /* no DDC support (or no device attached) */ - - /* Read the entire EDID */ - retry = 2; - do { - if(SiS_ReadDDC(SiS_Pr, DDCdatatype, buffer)) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "CRT2: DDC read failed (attempt %d), %s\n", - (3-retry), (retry == 1) ? "giving up" : "retrying"); - retry--; - if(retry == 0) return 0xFFFF; - } else break; - } while(1); - -#ifdef TWDEBUG - for(i=0; i<256; i+=16) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", - buffer[i], buffer[i+1], buffer[i+2], buffer[i+3], - buffer[i+4], buffer[i+5], buffer[i+6], buffer[i+7], - buffer[i+8], buffer[i+9], buffer[i+10], buffer[i+11], - buffer[i+12], buffer[i+13], buffer[i+14], buffer[i+15]); - } -#endif - - /* Analyze EDID and retrieve LCD panel information */ - paneltype = 0; - switch(DDCdatatype) { - case 1: /* Analyze EDID V1 */ - /* Catch a few clear cases: */ - if(!(checkedid1(buffer))) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "LCD sense: EDID corrupt\n"); - return 0; - } - - if(!(buffer[0x14] & 0x80)) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "LCD sense: Attached display expects analog input (0x%02x)\n", - buffer[0x14]); - return 0; - } - - if((buffer[0x18] & 0x18) != 0x08) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "LCD sense: Warning: Attached display is not of RGB but of %s type (0x%02x)\n", - ((buffer[0x18] & 0x18) == 0x00) ? "monochrome/greyscale" : - ( ((buffer[0x18] & 0x18) == 0x10) ? "non-RGB multicolor" : - "undefined"), - buffer[0x18]); - } - - /* Now analyze the first Detailed Timing Block and see - * if the preferred timing mode is stored there. If so, - * check if this is a standard panel for which we already - * know the timing. - */ - - paneltype = Panel_Custom; - checkexpand = FALSE; - - panelvendor = buffer[9] | (buffer[8] << 8); - panelproduct = buffer[10] | (buffer[11] << 8); - - /* Overrule bogus preferred modes from database */ - if((indb = SiS_FindPanelFromDB(pSiS, panelvendor, panelproduct, &maxx, &maxy, &prefx, &prefy))) { - if(prefx) SiS_Pr->CP_PreferredX = xres = prefx; - if(prefy) SiS_Pr->CP_PreferredY = yres = prefy; - } - - if(buffer[0x18] & 0x02) { - - USHORT pclk = (buffer[0x36] | (buffer[0x37] << 8)); - USHORT phb = (buffer[0x39] | ((buffer[0x3a] & 0x0f) << 8)); - USHORT pvb = (buffer[0x3c] | ((buffer[0x3d] & 0x0f) << 8)); - - if(!xres) SiS_Pr->CP_PreferredX = xres = buffer[0x38] | ((buffer[0x3a] & 0xf0) << 4); - if(!yres) SiS_Pr->CP_PreferredY = yres = buffer[0x3b] | ((buffer[0x3d] & 0xf0) << 4); - - switch(xres) { -#if 0 /* Treat as custom */ - case 800: - if(yres == 600) { - paneltype = Panel_800x600; - checkexpand = TRUE; - } - break; -#endif - case 1024: - if(yres == 768) { - paneltype = Panel_1024x768; - checkexpand = TRUE; - } - break; - case 1280: - if(yres == 1024) { - paneltype = Panel_1280x1024; - checkexpand = TRUE; - } else if(yres == 960) { - if(pSiS->VGAEngine == SIS_300_VGA) { - paneltype = Panel300_1280x960; - } else { - paneltype = Panel310_1280x960; - } - } else if(yres == 768) { - if( (pclk == 8100) && - (phb == (1688 - 1280)) && - (pvb == (802 - 768)) ) { - paneltype = Panel_1280x768; - checkexpand = FALSE; - cr37 |= 0x10; - } - } else if(yres == 800) { - if( (pclk == 6900) && - (phb == (1408 - 1280)) && - (pvb == (816 - 800)) ) { - paneltype = Panel_1280x800; - } - } - break; - case 1400: - if(pSiS->VGAEngine == SIS_315_VGA) { - if(yres == 1050) { - paneltype = Panel310_1400x1050; - checkexpand = TRUE; - } - } - break; - case 1600: - if(pSiS->VGAEngine == SIS_315_VGA) { - if(pSiS->VBFlags & VB_301C) { - if(yres == 1200) { - paneltype = Panel310_1600x1200; - checkexpand = TRUE; - } - } - } - break; - } - - /* Save sync: This is used if "Pass 1:1" is off; in this case - * we always use the panel's native mode = this "preferred mode" - * we just have been analysing. Hence, we also need its sync. - */ - if((buffer[0x47] & 0x18) == 0x18) { - cr37 |= ((((buffer[0x47] & 0x06) ^ 0x06) << 5) | 0x20); - havesync = TRUE; - } else { - /* What now? There is no digital separate output timing... */ - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING, - "LCD sense: Unable to retrieve Sync polarity information\n"); - cr37 |= 0xc0; /* Default */ - } - - } - - /* Check against our database; eg. Sanyo Z2 projector reports - * 1024x768 as preferred mode, although it supports 1280x720 - * natively in non-HDCP mode. Treat such wrongly reporting - * panels as custom and fixup actual maximum resolutions. - */ - if(paneltype != Panel_Custom) { - if(indb) { - paneltype = Panel_Custom; - SiS_Pr->CP_MaxX = maxx; - SiS_Pr->CP_MaxY = maxy; - /* Leave preferred unchanged (MUST contain a valid mode!) */ - } - } - - /* If we still don't know what panel this is, we take it - * as a custom panel and derive the timing data from the - * detailed timing blocks - */ - if(paneltype == Panel_Custom) { - - int i, temp, base = 0x36; - unsigned long estpack; - const unsigned short estx[] = { - 720, 720, 640, 640, 640, 640, 800, 800, - 800, 800, 832,1024,1024,1024,1024,1280, - 1152 - }; - const unsigned short esty[] = { - 400, 400, 480, 480, 480, 480, 600, 600, - 600, 600, 624, 768, 768, 768, 768,1024, - 870 - }; - const int estclk[] = { - 0, 0, 25100, 0, 31500, 31500, 36100, 40000, - 50100, 49500, 0, 0, 65100, 75200, 78700,135200, - 0 - }; - - paneltype = 0; - SiS_Pr->CP_Supports64048075 = TRUE; - - /* Find the maximum resolution */ - - /* 1. From Established timings */ - estpack = (buffer[0x23] << 9) | (buffer[0x24] << 1) | ((buffer[0x25] >> 7) & 0x01); - for(i=16; i>=0; i--) { - if(estpack & (1 << i)) { - if(estx[16 - i] > SiS_Pr->CP_MaxX) SiS_Pr->CP_MaxX = estx[16 - i]; - if(esty[16 - i] > SiS_Pr->CP_MaxY) SiS_Pr->CP_MaxY = esty[16 - i]; - if(estclk[16 - i] > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = estclk[16 - i]; - } - } - - /* By default we drive the LCD at 75Hz in 640x480 mode; if - * the panel does not provide this mode, use 60hz - */ - if(!(buffer[0x23] & 0x04)) SiS_Pr->CP_Supports64048075 = FALSE; - - /* 2. From Standard Timings */ - for(i=0x26; i < 0x36; i+=2) { - if((buffer[i] != 0x01) && (buffer[i+1] != 0x01)) { - temp = (buffer[i] + 31) * 8; - if(temp > SiS_Pr->CP_MaxX) SiS_Pr->CP_MaxX = temp; - switch((buffer[i+1] & 0xc0) >> 6) { - case 0x03: temp = temp * 9 / 16; break; - case 0x02: temp = temp * 4 / 5; break; - case 0x01: temp = temp * 3 / 4; break; - } - if(temp > SiS_Pr->CP_MaxY) SiS_Pr->CP_MaxY = temp; - } - } - - /* Now extract the Detailed Timings and convert them into modes */ - - for(i = 0; i < 4; i++, base += 18) { - - /* Is this a detailed timing block or a monitor descriptor? */ - if(buffer[base] || buffer[base+1] || buffer[base+2]) { - - xres = buffer[base+2] | ((buffer[base+4] & 0xf0) << 4); - yres = buffer[base+5] | ((buffer[base+7] & 0xf0) << 4); - - SiS_Pr->CP_HDisplay[i] = xres; - SiS_Pr->CP_HSyncStart[i] = xres + (buffer[base+8] | ((buffer[base+11] & 0xc0) << 2)); - SiS_Pr->CP_HSyncEnd[i] = SiS_Pr->CP_HSyncStart[i] + (buffer[base+9] | ((buffer[base+11] & 0x30) << 4)); - SiS_Pr->CP_HTotal[i] = xres + (buffer[base+3] | ((buffer[base+4] & 0x0f) << 8)); - SiS_Pr->CP_HBlankStart[i] = xres + 1; - SiS_Pr->CP_HBlankEnd[i] = SiS_Pr->CP_HTotal[i]; - - SiS_Pr->CP_VDisplay[i] = yres; - SiS_Pr->CP_VSyncStart[i] = yres + (((buffer[base+10] & 0xf0) >> 4) | ((buffer[base+11] & 0x0c) << 2)); - SiS_Pr->CP_VSyncEnd[i] = SiS_Pr->CP_VSyncStart[i] + ((buffer[base+10] & 0x0f) | ((buffer[base+11] & 0x03) << 4)); - SiS_Pr->CP_VTotal[i] = yres + (buffer[base+6] | ((buffer[base+7] & 0x0f) << 8)); - SiS_Pr->CP_VBlankStart[i] = yres + 1; - SiS_Pr->CP_VBlankEnd[i] = SiS_Pr->CP_VTotal[i]; - - SiS_Pr->CP_Clock[i] = (buffer[base] | (buffer[base+1] << 8)) * 10; - - SiS_Pr->CP_DataValid[i] = TRUE; - - /* Sort out invalid timings, interlace and too high clocks */ - if((SiS_Pr->CP_HDisplay[i] & 7) || - (SiS_Pr->CP_HDisplay[i] > SiS_Pr->CP_HSyncStart[i]) || - (SiS_Pr->CP_HDisplay[i] >= SiS_Pr->CP_HSyncEnd[i]) || - (SiS_Pr->CP_HDisplay[i] >= SiS_Pr->CP_HTotal[i]) || - (SiS_Pr->CP_HSyncStart[i] >= SiS_Pr->CP_HSyncEnd[i]) || - (SiS_Pr->CP_HSyncStart[i] > SiS_Pr->CP_HTotal[i]) || - (SiS_Pr->CP_HSyncEnd[i] > SiS_Pr->CP_HTotal[i]) || - (SiS_Pr->CP_VDisplay[i] > SiS_Pr->CP_VSyncStart[i]) || - (SiS_Pr->CP_VDisplay[i] >= SiS_Pr->CP_VSyncEnd[i]) || - (SiS_Pr->CP_VDisplay[i] >= SiS_Pr->CP_VTotal[i]) || - (SiS_Pr->CP_VSyncStart[i] > SiS_Pr->CP_VSyncEnd[i]) || - (SiS_Pr->CP_VSyncStart[i] > SiS_Pr->CP_VTotal[i]) || - (SiS_Pr->CP_VSyncEnd[i] > SiS_Pr->CP_VTotal[i]) || - (((pSiS->VBFlags & VB_301C) && (SiS_Pr->CP_Clock[i] > 162500)) || - ((!(pSiS->VBFlags & VB_301C)) && - ((SiS_Pr->CP_Clock[i] > 108200) || (SiS_Pr->CP_VDisplay[i] > 1024) || - (SiS_Pr->CP_HDisplay[i] > 1600)))) || - (buffer[base+17] & 0x80)) { - - SiS_Pr->CP_DataValid[i] = FALSE; - - } else { - - SiS_Pr->CP_HaveCustomData = TRUE; - - if(xres > SiS_Pr->CP_MaxX) SiS_Pr->CP_MaxX = xres; - if(yres > SiS_Pr->CP_MaxY) SiS_Pr->CP_MaxY = yres; - if(SiS_Pr->CP_Clock[i] > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = SiS_Pr->CP_Clock[i]; - - if((SiS_Pr->CP_PreferredX == xres) && (SiS_Pr->CP_PreferredY == yres)) { - SiS_Pr->CP_PreferredIndex = i; - SiS_MakeClockRegs(pSiS->pScrn, SiS_Pr->CP_Clock[i], &SiS_Pr->CP_PrefSR2B, &SiS_Pr->CP_PrefSR2C); - SiS_Pr->CP_PrefClock = (SiS_Pr->CP_Clock[i] / 1000) + 1; - } - - /* Extract the sync polarisation information. This only works - * if the Flags indicate a digital separate output. - */ - if((buffer[base+17] & 0x18) == 0x18) { - SiS_Pr->CP_HSync_P[i] = (buffer[base+17] & 0x02) ? TRUE : FALSE; - SiS_Pr->CP_VSync_P[i] = (buffer[base+17] & 0x04) ? TRUE : FALSE; - SiS_Pr->CP_SyncValid[i] = TRUE; - if((i == SiS_Pr->CP_PreferredIndex) && (!havesync)) { - cr37 |= ((((buffer[base+17] & 0x06) ^ 0x06) << 5) | 0x20); - havesync = TRUE; - } - } else { - SiS_Pr->CP_SyncValid[i] = FALSE; - } - - } - - } else if((!buffer[base]) && (!buffer[base+1]) && (!buffer[base+2]) && (!buffer[base+4])) { - - /* Maximum pixclock from Monitor Range Limits */ - if((buffer[base+3] == 0xfd) && (buffer[base+9] != 0xff)) { - int maxclk = buffer[base+9] * 10; - /* More than 170 is not supported anyway */ - if(maxclk <= 170) SiS_Pr->CP_MaxClock = maxclk * 1000; - } - - } - - } - - if(SiS_Pr->CP_MaxX && SiS_Pr->CP_MaxY) { - paneltype = Panel_Custom; - checkexpand = FALSE; - cr37 |= 0x10; - SiS_Pr->CP_Vendor = panelvendor; - SiS_Pr->CP_Product = panelproduct; - } - - } - - if(paneltype && checkexpand) { - /* If any of the Established low-res modes is supported, the - * panel can scale automatically. For 800x600 panels, we only - * check the even lower ones. - */ - if(paneltype == Panel_800x600) { - if(buffer[0x23] & 0xfc) cr37 |= 0x10; - } else { - if(buffer[0x23]) cr37 |= 0x10; - } - } - - break; - - case 3: /* Analyze EDID V2 */ - case 4: - index = 0; - - if(!(checkedid2(buffer))) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "LCD sense: EDID corrupt\n"); - return 0; - } - - if((buffer[0x41] & 0x0f) == 0x03) { - index = 0x42 + 3; - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "LCD sense: Display supports TMDS input on primary interface\n"); - } else if((buffer[0x41] & 0xf0) == 0x30) { - index = 0x46 + 3; - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "LCD sense: Display supports TMDS input on secondary interface\n"); - } else { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "LCD sense: Display does not support TMDS video interface (0x%02x)\n", - buffer[0x41]); - return 0; - } - - SiS_Pr->CP_Vendor = panelvendor = buffer[2] | (buffer[1] << 8); - SiS_Pr->CP_Product = panelproduct = buffer[3] | (buffer[4] << 8); - - paneltype = Panel_Custom; - SiS_Pr->CP_MaxX = SiS_Pr->CP_PreferredX = xres = buffer[0x76] | (buffer[0x77] << 8); - SiS_Pr->CP_MaxY = SiS_Pr->CP_PreferredY = yres = buffer[0x78] | (buffer[0x79] << 8); - - switch(xres) { -#if 0 - case 800: - if(yres == 600) { - paneltype = Panel_800x600; - checkexpand = TRUE; - } - break; -#endif - case 1024: - if(yres == 768) { - paneltype = Panel_1024x768; - checkexpand = TRUE; - } - break; - case 1280: - if(yres == 960) { - if(pSiS->VGAEngine == SIS_315_VGA) { - paneltype = Panel310_1280x960; - } else { - paneltype = Panel300_1280x960; - } - } else if(yres == 1024) { - paneltype = Panel_1280x1024; - checkexpand = TRUE; - } - /* 1280x768 treated as custom here */ - break; - case 1400: - if(pSiS->VGAEngine == SIS_315_VGA) { - if(yres == 1050) { - paneltype = Panel310_1400x1050; - checkexpand = TRUE; - } - } - break; - case 1600: - if(pSiS->VGAEngine == SIS_315_VGA) { - if(pSiS->VBFlags & VB_301C) { - if(yres == 1200) { - paneltype = Panel310_1600x1200; - checkexpand = TRUE; - } - } - } - break; - } - - /* Determine if RGB18 or RGB24 */ - if(index) { - if((buffer[index] == 0x20) || (buffer[index] == 0x34)) { - cr37 |= 0x01; - } - } - - if(checkexpand) { - /* TODO - for now, we let the panel scale */ - cr37 |= 0x10; - } - - /* Now seek 4-Byte Timing codes and extract sync pol info */ - index = 0x80; - if(buffer[0x7e] & 0x20) { /* skip Luminance Table (if provided) */ - lumsize = buffer[0x80] & 0x1f; - if(buffer[0x80] & 0x80) lumsize *= 3; - lumsize++; /* luminance header byte */ - index += lumsize; - } -#if 0 /* "pixel rate" = pixel clock? */ - if(buffer[0x7e] & 0x1c) { - for(i=0; i<((buffer[0x7e] & 0x1c) >> 2); i++) { - if(buffer[index + (i*8) + 6] && (buffer[index + (i*8) + 7] & 0x0f)) { - int clk = (buffer[index + (i*8) + 6] | ((buffer[index + (i*8) + 7] & 0x0f) << 4)) * 1000; - if(clk > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = clk; - } - } - } -#endif - index += (((buffer[0x7e] & 0x1c) >> 2) * 8); /* skip Frequency Ranges */ - if(buffer[0x7e] & 0x03) { - for(i=0; i<(buffer[0x7e] & 0x03); i++) { - if((buffer[index + (i*27) + 9]) || (buffer[index + (i*27) + 10])) { - int clk = ((buffer[index + (i*27) + 9]) | ((buffer[index + (i*27) + 9]) << 8)) * 10; - if(clk > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = clk; - } - } - } - index += ((buffer[0x7e] & 0x03) * 27); /* skip Detailed Range Limits */ - numcodes = (buffer[0x7f] & 0xf8) >> 3; - if(numcodes) { - myindex = index; - seekcode = (xres - 256) / 16; - for(i=0; i<numcodes; i++) { - if(buffer[myindex] == seekcode) break; - myindex += 4; - } - if(buffer[myindex] == seekcode) { - cr37 |= ((((buffer[myindex + 1] & 0x0c) ^ 0x0c) << 4) | 0x20); - havesync = TRUE; - } else { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING, - "LCD sense: Unable to retrieve Sync polarity information\n"); - } - } else { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING, - "LCD sense: Unable to retrieve Sync polarity information\n"); - } - - /* Check against our database; Eg. Sanyo projector reports - * 1024x768 in non-HDPC mode, although it supports 1280x720. - * Treat such wrongly reporting panels as custom. - */ - if(paneltype != Panel_Custom) { - int maxx, maxy, prefx, prefy; - if((SiS_FindPanelFromDB(pSiS, panelvendor, panelproduct, &maxx, &maxy, &prefx, &prefy))) { - paneltype = Panel_Custom; - SiS_Pr->CP_MaxX = maxx; - SiS_Pr->CP_MaxY = maxy; - cr37 |= 0x10; - /* Leave preferred unchanged (MUST be a valid mode!) */ - } - } - - /* Now seek the detailed timing descriptions for custom panels */ - if(paneltype == Panel_Custom) { - - SiS_Pr->CP_Supports64048075 = TRUE; - - index += (numcodes * 4); - numcodes = buffer[0x7f] & 0x07; - for(i=0; i<numcodes; i++, index += 18) { - xres = buffer[index+2] | ((buffer[index+4] & 0xf0) << 4); - yres = buffer[index+5] | ((buffer[index+7] & 0xf0) << 4); - - SiS_Pr->CP_HDisplay[i] = xres; - SiS_Pr->CP_HSyncStart[i] = xres + (buffer[index+8] | ((buffer[index+11] & 0xc0) << 2)); - SiS_Pr->CP_HSyncEnd[i] = SiS_Pr->CP_HSyncStart[i] + (buffer[index+9] | ((buffer[index+11] & 0x30) << 4)); - SiS_Pr->CP_HTotal[i] = xres + (buffer[index+3] | ((buffer[index+4] & 0x0f) << 8)); - SiS_Pr->CP_HBlankStart[i] = xres + 1; - SiS_Pr->CP_HBlankEnd[i] = SiS_Pr->CP_HTotal[i]; - - SiS_Pr->CP_VDisplay[i] = yres; - SiS_Pr->CP_VSyncStart[i] = yres + (((buffer[index+10] & 0xf0) >> 4) | ((buffer[index+11] & 0x0c) << 2)); - SiS_Pr->CP_VSyncEnd[i] = SiS_Pr->CP_VSyncStart[i] + ((buffer[index+10] & 0x0f) | ((buffer[index+11] & 0x03) << 4)); - SiS_Pr->CP_VTotal[i] = yres + (buffer[index+6] | ((buffer[index+7] & 0x0f) << 8)); - SiS_Pr->CP_VBlankStart[i] = yres + 1; - SiS_Pr->CP_VBlankEnd[i] = SiS_Pr->CP_VTotal[i]; - - SiS_Pr->CP_Clock[i] = (buffer[index] | (buffer[index+1] << 8)) * 10; - - SiS_Pr->CP_DataValid[i] = TRUE; - - if((SiS_Pr->CP_HDisplay[i] & 7) || - (SiS_Pr->CP_HDisplay[i] > SiS_Pr->CP_HSyncStart[i]) || - (SiS_Pr->CP_HDisplay[i] >= SiS_Pr->CP_HSyncEnd[i]) || - (SiS_Pr->CP_HDisplay[i] >= SiS_Pr->CP_HTotal[i]) || - (SiS_Pr->CP_HSyncStart[i] >= SiS_Pr->CP_HSyncEnd[i]) || - (SiS_Pr->CP_HSyncStart[i] > SiS_Pr->CP_HTotal[i]) || - (SiS_Pr->CP_HSyncEnd[i] > SiS_Pr->CP_HTotal[i]) || - (SiS_Pr->CP_VDisplay[i] > SiS_Pr->CP_VSyncStart[i]) || - (SiS_Pr->CP_VDisplay[i] >= SiS_Pr->CP_VSyncEnd[i]) || - (SiS_Pr->CP_VDisplay[i] >= SiS_Pr->CP_VTotal[i]) || - (SiS_Pr->CP_VSyncStart[i] > SiS_Pr->CP_VSyncEnd[i]) || - (SiS_Pr->CP_VSyncStart[i] > SiS_Pr->CP_VTotal[i]) || - (SiS_Pr->CP_VSyncEnd[i] > SiS_Pr->CP_VTotal[i]) || - (((pSiS->VBFlags & VB_301C) && (SiS_Pr->CP_Clock[i] > 162500)) || - ((!(pSiS->VBFlags & VB_301C)) && - ((SiS_Pr->CP_Clock[i] > 108200) || (SiS_Pr->CP_VDisplay[i] > 1024)))) || - (buffer[index + 17] & 0x80)) { - - SiS_Pr->CP_DataValid[i] = FALSE; - - } else { - - SiS_Pr->CP_HaveCustomData = TRUE; - - if(SiS_Pr->CP_Clock[i] > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = SiS_Pr->CP_Clock[i]; - - if((SiS_Pr->CP_PreferredX == xres) && (SiS_Pr->CP_PreferredY == yres)) { - SiS_Pr->CP_PreferredIndex = i; - SiS_MakeClockRegs(pSiS->pScrn, SiS_Pr->CP_Clock[i], &SiS_Pr->CP_PrefSR2B, &SiS_Pr->CP_PrefSR2C); - SiS_Pr->CP_PrefClock = (SiS_Pr->CP_Clock[i] / 1000) + 1; - if(!havesync) { - cr37 |= ((((buffer[index + 17] & 0x06) ^ 0x06) << 5) | 0x20); - havesync = TRUE; - } - } - - SiS_Pr->CP_HSync_P[i] = (buffer[index + 17] & 0x02) ? TRUE : FALSE; - SiS_Pr->CP_VSync_P[i] = (buffer[index + 17] & 0x04) ? TRUE : FALSE; - SiS_Pr->CP_SyncValid[i] = TRUE; - - } - } - - cr37 |= 0x10; - - } - - break; - - } - - /* 1280x960 panels are always RGB24, unable to scale and use - * high active sync polarity - */ - if(pSiS->VGAEngine == SIS_315_VGA) { - if(paneltype == Panel310_1280x960) cr37 &= 0x0e; - } else { - if(paneltype == Panel300_1280x960) cr37 &= 0x0e; - } - - for(i = 0; i < 7; i++) { - if(SiS_Pr->CP_DataValid[i]) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "Non-standard LCD/DVI-D timing data no. %d:\n", i); - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - " HDisplay %d HSync %d HSyncEnd %d HTotal %d\n", - SiS_Pr->CP_HDisplay[i], SiS_Pr->CP_HSyncStart[i], - SiS_Pr->CP_HSyncEnd[i], SiS_Pr->CP_HTotal[i]); - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - " VDisplay %d VSync %d VSyncEnd %d VTotal %d\n", - SiS_Pr->CP_VDisplay[i], SiS_Pr->CP_VSyncStart[i], - SiS_Pr->CP_VSyncEnd[i], SiS_Pr->CP_VTotal[i]); - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - " Pixel clock: %3.3fMhz\n", (float)SiS_Pr->CP_Clock[i] / 1000); - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO, - " To use this, add \"%dx%d\" to the list of Modes in the Screen section\n", - SiS_Pr->CP_HDisplay[i], - SiS_Pr->CP_VDisplay[i]); - } - } - - if(paneltype) { - if(!SiS_Pr->CP_PreferredX) SiS_Pr->CP_PreferredX = SiS_Pr->CP_MaxX; - if(!SiS_Pr->CP_PreferredY) SiS_Pr->CP_PreferredY = SiS_Pr->CP_MaxY; - SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x32,0x08); - SiS_SetReg(SiS_Pr->SiS_P3d4,0x36,paneltype); - cr37 &= 0xf1; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x37,0x0c,cr37); - SiS_Pr->PanelSelfDetected = TRUE; -#ifdef TWDEBUG - xf86DrvMsgVerb(pSiS->pScrn->scrnIndex, X_PROBED, 3, - "LCD sense: [DDC LCD results: 0x%02x, 0x%02x]\n", paneltype, cr37); -#endif - } else { - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x32,~0x08); - SiS_SetReg(SiS_Pr->SiS_P3d4,0x36,0x00); - } - return 0; -} - -USHORT -SiS_SenseVGA2DDC(SiS_Private *SiS_Pr, SISPtr pSiS) -{ - USHORT DDCdatatype,flag; - BOOLEAN foundcrt = FALSE; - int retry; - unsigned char buffer[256]; - - if(!(pSiS->VBFlags & (VB_301|VB_301B|VB_301C|VB_302B))) return 0; - - if(SiS_InitDDCRegs(SiS_Pr, pSiS->VBFlags, pSiS->VGAEngine, 2, 0, FALSE) == 0xFFFF) return 0; - - SiS_Pr->SiS_DDC_SecAddr = 0x00; - - /* Probe supported DA's */ - flag = SiS_ProbeDDC(SiS_Pr); - if(flag & 0x10) { - SiS_Pr->SiS_DDC_DeviceAddr = 0xa6; /* EDID V2 (FP) */ - DDCdatatype = 4; - } else if(flag & 0x08) { - SiS_Pr->SiS_DDC_DeviceAddr = 0xa2; /* EDID V2 (P&D-D Monitor) */ - DDCdatatype = 3; - } else if(flag & 0x02) { - SiS_Pr->SiS_DDC_DeviceAddr = 0xa0; /* EDID V1 */ - DDCdatatype = 1; - } else { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "VGA2 sense: Do DDC answer\n"); - return 0; /* no DDC support (or no device attached) */ - } - - /* Read the entire EDID */ - retry = 2; - do { - if(SiS_ReadDDC(SiS_Pr, DDCdatatype, buffer)) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "VGA2 sense: DDC read failed (attempt %d), %s\n", - (3-retry), (retry == 1) ? "giving up" : "retrying"); - retry--; - if(retry == 0) return 0xFFFF; - } else break; - } while(1); - - /* Analyze EDID. We don't have many chances to - * distinguish a flat panel from a CRT... - */ - switch(DDCdatatype) { - case 1: - if(!(checkedid1(buffer))) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_ERROR, - "VGA2 sense: EDID corrupt\n"); - return 0; - } - if(buffer[0x14] & 0x80) { /* Display uses digital input */ - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_ERROR, - "VGA2 sense: Attached display expects digital input\n"); - return 0; - } - SiS_Pr->CP_Vendor = buffer[9] | (buffer[8] << 8); - SiS_Pr->CP_Product = buffer[10] | (buffer[11] << 8); - foundcrt = TRUE; - break; - case 3: - case 4: - if(!(checkedid2(buffer))) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_ERROR, - "VGA2 sense: EDID corrupt\n"); - return 0; - } - if( ((buffer[0x41] & 0x0f) != 0x01) && /* Display does not support analog input */ - ((buffer[0x41] & 0x0f) != 0x02) && - ((buffer[0x41] & 0xf0) != 0x10) && - ((buffer[0x41] & 0xf0) != 0x20) ) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_ERROR, - "VGA2 sense: Attached display does not support analog input (0x%02x)\n", - buffer[0x41]); - return 0; - } - SiS_Pr->CP_Vendor = buffer[2] | (buffer[1] << 8); - SiS_Pr->CP_Product = buffer[3] | (buffer[4] << 8); - foundcrt = TRUE; - break; - } - - if(foundcrt) { - SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x32,0x10); - } - return(0); -} - -#endif - -void -SiS_SetCH70xxANDOR(SiS_Private *SiS_Pr, USHORT tempax,USHORT tempbh) -{ - USHORT tempbl; - - tempbl = SiS_GetCH70xx(SiS_Pr,(tempax & 0x00FF)); - tempbl = (((tempbl & tempbh) << 8) | tempax); - SiS_SetCH70xx(SiS_Pr,tempbl); -} - /* Generic I2C functions for Chrontel & DDC --------- */ static void -SiS_SetSwitchDDC2(SiS_Private *SiS_Pr) +SiS_SetSwitchDDC2(struct SiS_Private *SiS_Pr) { SiS_SetSCLKHigh(SiS_Pr); SiS_WaitRetrace1(SiS_Pr); @@ -10505,125 +9502,127 @@ SiS_SetSwitchDDC2(SiS_Private *SiS_Pr) SiS_WaitRetrace1(SiS_Pr); } -USHORT -SiS_ReadDDC1Bit(SiS_Private *SiS_Pr) +unsigned short +SiS_ReadDDC1Bit(struct SiS_Private *SiS_Pr) { SiS_WaitRetrace1(SiS_Pr); - return((SiS_GetReg(SiS_Pr->SiS_P3c4,0x11) & 0x02) >> 1); + return ((SiS_GetReg(SiS_Pr->SiS_P3c4,0x11) & 0x02) >> 1); } /* Set I2C start condition */ /* This is done by a SD high-to-low transition while SC is high */ -static USHORT -SiS_SetStart(SiS_Private *SiS_Pr) +static unsigned short +SiS_SetStart(struct SiS_Private *SiS_Pr) { - if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF; /* (SC->low) */ + if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF; /* (SC->low) */ SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, - SiS_Pr->SiS_DDC_Index, - SiS_Pr->SiS_DDC_NData, - SiS_Pr->SiS_DDC_Data); /* SD->high */ - if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* SC->high */ + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, + SiS_Pr->SiS_DDC_Data); /* SD->high */ + if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* SC->high */ SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, - SiS_Pr->SiS_DDC_Index, - SiS_Pr->SiS_DDC_NData, - 0x00); /* SD->low = start condition */ - if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* (SC->low) */ + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, + 0x00); /* SD->low = start condition */ + if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* (SC->low) */ return 0; } /* Set I2C stop condition */ /* This is done by a SD low-to-high transition while SC is high */ -static USHORT -SiS_SetStop(SiS_Private *SiS_Pr) +static unsigned short +SiS_SetStop(struct SiS_Private *SiS_Pr) { - if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF; /* (SC->low) */ + if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF; /* (SC->low) */ SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, - SiS_Pr->SiS_DDC_Index, - SiS_Pr->SiS_DDC_NData, - 0x00); /* SD->low */ - if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* SC->high */ + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, + 0x00); /* SD->low */ + if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* SC->high */ SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, - SiS_Pr->SiS_DDC_Index, - SiS_Pr->SiS_DDC_NData, - SiS_Pr->SiS_DDC_Data); /* SD->high = stop condition */ - if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* (SC->high) */ + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, + SiS_Pr->SiS_DDC_Data); /* SD->high = stop condition */ + if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* (SC->high) */ return 0; } /* Write 8 bits of data */ -static USHORT -SiS_WriteDDC2Data(SiS_Private *SiS_Pr, USHORT tempax) +static unsigned short +SiS_WriteDDC2Data(struct SiS_Private *SiS_Pr, unsigned short tempax) { - USHORT i,flag,temp; + unsigned short i,flag,temp; flag = 0x80; - for(i=0; i<8; i++) { - SiS_SetSCLKLow(SiS_Pr); /* SC->low */ + for(i = 0; i < 8; i++) { + SiS_SetSCLKLow(SiS_Pr); /* SC->low */ if(tempax & flag) { SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, - SiS_Pr->SiS_DDC_Index, - SiS_Pr->SiS_DDC_NData, - SiS_Pr->SiS_DDC_Data); /* Write bit (1) to SD */ + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, + SiS_Pr->SiS_DDC_Data); /* Write bit (1) to SD */ } else { SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, - SiS_Pr->SiS_DDC_Index, - SiS_Pr->SiS_DDC_NData, - 0x00); /* Write bit (0) to SD */ + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, + 0x00); /* Write bit (0) to SD */ } - SiS_SetSCLKHigh(SiS_Pr); /* SC->high */ + SiS_SetSCLKHigh(SiS_Pr); /* SC->high */ flag >>= 1; } - temp = SiS_CheckACK(SiS_Pr); /* Check acknowledge */ - return(temp); + temp = SiS_CheckACK(SiS_Pr); /* Check acknowledge */ + return temp; } -static USHORT -SiS_ReadDDC2Data(SiS_Private *SiS_Pr, USHORT tempax) +static unsigned short +SiS_ReadDDC2Data(struct SiS_Private *SiS_Pr) { - USHORT i,temp,getdata; + unsigned short i, temp, getdata; - getdata=0; - for(i=0; i<8; i++) { + getdata = 0; + for(i = 0; i < 8; i++) { getdata <<= 1; SiS_SetSCLKLow(SiS_Pr); SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, - SiS_Pr->SiS_DDC_Index, - SiS_Pr->SiS_DDC_NData, + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, SiS_Pr->SiS_DDC_Data); SiS_SetSCLKHigh(SiS_Pr); temp = SiS_GetReg(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index); if(temp & SiS_Pr->SiS_DDC_Data) getdata |= 0x01; } - return(getdata); + return getdata; } -static USHORT -SiS_SetSCLKLow(SiS_Private *SiS_Pr) +static unsigned short +SiS_SetSCLKLow(struct SiS_Private *SiS_Pr) { SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, - SiS_Pr->SiS_DDC_Index, - SiS_Pr->SiS_DDC_NClk, - 0x00); /* SetSCLKLow() */ + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NClk, + 0x00); /* SetSCLKLow() */ SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT); return 0; } -static USHORT -SiS_SetSCLKHigh(SiS_Private *SiS_Pr) +static unsigned short +SiS_SetSCLKHigh(struct SiS_Private *SiS_Pr) { - USHORT temp, watchdog=1000; + unsigned short temp, watchdog=1000; SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, - SiS_Pr->SiS_DDC_Index, - SiS_Pr->SiS_DDC_NClk, + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NClk, SiS_Pr->SiS_DDC_Clk); /* SetSCLKHigh() */ do { temp = SiS_GetReg(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index); } while((!(temp & SiS_Pr->SiS_DDC_Clk)) && --watchdog); if (!watchdog) { +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "SetClkHigh failed\n"); #endif +#endif return 0xFFFF; } SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT); @@ -10632,21 +9631,21 @@ SiS_SetSCLKHigh(SiS_Private *SiS_Pr) /* Check I2C acknowledge */ /* Returns 0 if ack ok, non-0 if ack not ok */ -static USHORT -SiS_CheckACK(SiS_Private *SiS_Pr) +static unsigned short +SiS_CheckACK(struct SiS_Private *SiS_Pr) { - USHORT tempah; + unsigned short tempah; SiS_SetSCLKLow(SiS_Pr); /* (SC->low) */ SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, - SiS_Pr->SiS_DDC_Index, - SiS_Pr->SiS_DDC_NData, - SiS_Pr->SiS_DDC_Data); /* (SD->high) */ + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, + SiS_Pr->SiS_DDC_Data); /* (SD->high) */ SiS_SetSCLKHigh(SiS_Pr); /* SC->high = clock impulse for ack */ tempah = SiS_GetReg(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index); /* Read SD */ SiS_SetSCLKLow(SiS_Pr); /* SC->low = end of clock impulse */ - if(tempah & SiS_Pr->SiS_DDC_Data) return(1); /* Ack OK if bit = 0 */ - else return(0); + if(tempah & SiS_Pr->SiS_DDC_Data) return 1; /* Ack OK if bit = 0 */ + return 0; } /* End of I2C functions ----------------------- */ @@ -10656,67 +9655,67 @@ SiS_CheckACK(SiS_Private *SiS_Pr) #ifdef SIS315H -static USHORT -GetRAMDACromptr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +static unsigned short +GetRAMDACromptr(struct SiS_Private *SiS_Pr) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT romptr; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short romptr; - if(HwInfo->jChipType < SIS_330) { + if(SiS_Pr->ChipType < SIS_330) { romptr = SISGETROMW(0x128); - if(SiS_Pr->SiS_VBType & VB_SIS301B302B) + if(SiS_Pr->SiS_VBType & VB_SIS30xB) romptr = SISGETROMW(0x12a); } else { romptr = SISGETROMW(0x1a8); - if(SiS_Pr->SiS_VBType & VB_SIS301B302B) + if(SiS_Pr->SiS_VBType & VB_SIS30xB) romptr = SISGETROMW(0x1aa); } - return(romptr); + return romptr; } -static USHORT -GetLCDromptr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +static unsigned short +GetLCDromptr(struct SiS_Private *SiS_Pr) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT romptr; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short romptr; - if(HwInfo->jChipType < SIS_330) { + if(SiS_Pr->ChipType < SIS_330) { romptr = SISGETROMW(0x120); - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) romptr = SISGETROMW(0x122); } else { romptr = SISGETROMW(0x1a0); - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) romptr = SISGETROMW(0x1a2); } - return(romptr); + return romptr; } -static USHORT -GetTVromptr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +static unsigned short +GetTVromptr(struct SiS_Private *SiS_Pr) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT romptr; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short romptr; - if(HwInfo->jChipType < SIS_330) { + if(SiS_Pr->ChipType < SIS_330) { romptr = SISGETROMW(0x114); - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) romptr = SISGETROMW(0x11a); } else { romptr = SISGETROMW(0x194); - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) romptr = SISGETROMW(0x19a); } - return(romptr); + return romptr; } -static USHORT -GetLCDPtrIndexBIOS(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +static unsigned short +GetLCDPtrIndexBIOS(struct SiS_Private *SiS_Pr) { - USHORT index; + unsigned short index; - if((IS_SIS650) && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { - if(!(SiS_IsNotM650orLater(SiS_Pr, HwInfo))) { + if((IS_SIS650) && (SiS_Pr->SiS_VBType & VB_SISLVDS)) { + if(!(SiS_IsNotM650orLater(SiS_Pr))) { if((index = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0xf0)) { index >>= 4; index *= 3; @@ -10729,7 +9728,12 @@ GetLCDPtrIndexBIOS(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) index = SiS_GetBIOSLCDResInfo(SiS_Pr) & 0x0F; if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) index -= 5; - else if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) index -= 6; + if(SiS_Pr->SiS_VBType & VB_SIS301C) { /* 1.15.20 and later (not VB specific) */ + if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) index -= 5; + if(SiS_Pr->SiS_LCDResInfo == Panel_1280x768) index -= 5; + } else { + if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) index -= 6; + } index--; index *= 3; if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index += 2; @@ -10737,10 +9741,10 @@ GetLCDPtrIndexBIOS(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) return index; } -static USHORT -GetLCDPtrIndex(SiS_Private *SiS_Pr) +static unsigned short +GetLCDPtrIndex(struct SiS_Private *SiS_Pr) { - USHORT index; + unsigned short index; index = ((SiS_GetBIOSLCDResInfo(SiS_Pr) & 0x0F) - 1) * 3; if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index += 2; @@ -10748,10 +9752,10 @@ GetLCDPtrIndex(SiS_Private *SiS_Pr) return index; } -static USHORT -GetTVPtrIndex(SiS_Private *SiS_Pr) +static unsigned short +GetTVPtrIndex(struct SiS_Private *SiS_Pr) { - USHORT index; + unsigned short index; index = 0; if(SiS_Pr->SiS_TVMode & TVSetPAL) index = 1; @@ -10769,10 +9773,10 @@ GetTVPtrIndex(SiS_Private *SiS_Pr) return index; } -static ULONG -GetOEMTVPtr661_2_GEN(SiS_Private *SiS_Pr, int addme) +static unsigned int +GetOEMTVPtr661_2_GEN(struct SiS_Private *SiS_Pr, int addme) { - USHORT index = 0, temp = 0; + unsigned short index = 0, temp = 0; if(SiS_Pr->SiS_TVMode & TVSetPAL) index = 1; if(SiS_Pr->SiS_TVMode & TVSetPALM) index = 2; @@ -10784,7 +9788,7 @@ GetOEMTVPtr661_2_GEN(SiS_Private *SiS_Pr, int addme) if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) index = 7; } - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { if((!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || (SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) { index += addme; @@ -10792,25 +9796,25 @@ GetOEMTVPtr661_2_GEN(SiS_Private *SiS_Pr, int addme) } temp += 0x0100; } - return(ULONG)(index | (temp << 16)); + return (unsigned int)(index | (temp << 16)); } -static ULONG -GetOEMTVPtr661_2_OLD(SiS_Private *SiS_Pr) +static unsigned int +GetOEMTVPtr661_2_OLD(struct SiS_Private *SiS_Pr) { - return(GetOEMTVPtr661_2_GEN(SiS_Pr, 8)); + return (GetOEMTVPtr661_2_GEN(SiS_Pr, 8)); } #if 0 -static ULONG -GetOEMTVPtr661_2_NEW(SiS_Private *SiS_Pr) +static unsigned int +GetOEMTVPtr661_2_NEW(struct SiS_Private *SiS_Pr) { - return(GetOEMTVPtr661_2_GEN(SiS_Pr, 6)); + return (GetOEMTVPtr661_2_GEN(SiS_Pr, 6)); } #endif static int -GetOEMTVPtr661(SiS_Private *SiS_Pr) +GetOEMTVPtr661(struct SiS_Private *SiS_Pr) { int index = 0; @@ -10833,10 +9837,10 @@ GetOEMTVPtr661(SiS_Private *SiS_Pr) } static void -SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) +SetDelayComp(struct SiS_Private *SiS_Pr, unsigned short ModeNo) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT delay=0,index,myindex,temp,romptr=0; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short delay=0,index,myindex,temp,romptr=0; BOOLEAN dochiptest = TRUE; if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { @@ -10848,19 +9852,19 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) /* Find delay (from ROM, internal tables, PCI subsystem) */ if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { /* ------------ VGA */ - + if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { - romptr = GetRAMDACromptr(SiS_Pr, HwInfo); + romptr = GetRAMDACromptr(SiS_Pr); } if(romptr) delay = ROMAddr[romptr]; else { delay = 0x04; - if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { + if(SiS_Pr->SiS_VBType & VB_SIS30xB) { if(IS_SIS650) { delay = 0x0a; } else if(IS_SIS740) { delay = 0x00; - } else if(HwInfo->jChipType < SIS_330) { + } else if(SiS_Pr->ChipType < SIS_330) { delay = 0x0c; } else { delay = 0x0c; @@ -10901,8 +9905,12 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0x0f,delay); } else { delay = 0x0c; - if(SiS_Pr->SiS_VBType & VB_SIS301C) delay = 0x03; - else if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(SiS_Pr->SiS_VBType & VB_SIS301C) { + delay = 0x03; + if((SiS_Pr->PanelXRes > 1280) && (SiS_Pr->PanelYRes > 1024)) { + delay = 0x00; + } + } else if(SiS_Pr->SiS_VBType & VB_SISLVDS) { if(IS_SIS740) delay = 0x01; else delay = 0x03; } @@ -10947,12 +9955,12 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) if(!gotitfrompci) { - index = GetLCDPtrIndexBIOS(SiS_Pr, HwInfo); + index = GetLCDPtrIndexBIOS(SiS_Pr); myindex = GetLCDPtrIndex(SiS_Pr); - if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { + if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SISLVDS)) { - if(SiS_IsNotM650orLater(SiS_Pr, HwInfo)) { + if(SiS_IsNotM650orLater(SiS_Pr)) { if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { /* Always use the second pointer on 650; some BIOSes */ @@ -10978,11 +9986,12 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) (!(SiS_Pr->SiS_ROMNew)) && (SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) && (SiS_Pr->SiS_LCDResInfo != Panel_1280x768) && - (SiS_Pr->SiS_LCDResInfo != Panel_1280x960)) { + (SiS_Pr->SiS_LCDResInfo != Panel_1280x960) && + (SiS_Pr->SiS_LCDResInfo != Panel_1600x1200) && + ((romptr = GetLCDromptr(SiS_Pr)))) { /* Data for 1280x1024 wrong in 301B BIOS */ - romptr = GetLCDromptr(SiS_Pr, HwInfo); - if(!romptr) return; + /* Data for 1600x1200 wrong in 301C BIOS */ delay = ROMAddr[(romptr + index)]; } else if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { @@ -10993,14 +10002,15 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) } else { delay = SiS310_LCDDelayCompensation_301[myindex]; - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { if(IS_SIS740) delay = 0x01; - else if(HwInfo->jChipType <= SIS_315PRO) delay = SiS310_LCDDelayCompensation_3xx301LV[myindex]; + else if(SiS_Pr->ChipType <= SIS_315PRO) delay = SiS310_LCDDelayCompensation_3xx301LV[myindex]; else delay = SiS310_LCDDelayCompensation_650301LV[myindex]; } else if(SiS_Pr->SiS_VBType & VB_SIS301C) { if(IS_SIS740) delay = 0x01; /* ? */ else delay = 0x03; - } else if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { + if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) delay = 0x00; /* experience */ + } else if(SiS_Pr->SiS_VBType & VB_SIS30xB) { if(IS_SIS740) delay = 0x01; else delay = SiS310_LCDDelayCompensation_3xx301B[myindex]; } @@ -11013,14 +10023,14 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0x0F,((delay << 4) & 0xf0)); dochiptest = FALSE; } - + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* ------------ TV */ index = GetTVPtrIndex(SiS_Pr); - - if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { - if(SiS_IsNotM650orLater(SiS_Pr,HwInfo)) { + if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SISLVDS)) { + + if(SiS_IsNotM650orLater(SiS_Pr)) { if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { /* Always use the second pointer on 650; some BIOSes */ @@ -11062,7 +10072,7 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) } else if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { - romptr = GetTVromptr(SiS_Pr, HwInfo); + romptr = GetTVromptr(SiS_Pr); if(!romptr) return; delay = ROMAddr[romptr + index]; @@ -11073,7 +10083,7 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) } else { delay = SiS310_TVDelayCompensation_301[index]; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { if(IS_SIS740) { delay = SiS310_TVDelayCompensation_740301B[index]; /* LV: use 301 data? BIOS bug? */ @@ -11085,18 +10095,18 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) } - if(SiS_LCDAEnabled(SiS_Pr, HwInfo)) { + if(SiS_LCDAEnabled(SiS_Pr)) { delay &= 0x0f; dochiptest = FALSE; } - + } else return; /* Write delay */ if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && dochiptest) { + if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SISLVDS) && dochiptest) { temp = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0xf0) >> 4; if(temp == 8) { /* 1400x1050 BIOS (COMPAL) */ @@ -11134,11 +10144,10 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) } static void -SetAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex) +SetAntiFlicker(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT index,temp,temp1,romptr=0; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short index,temp,temp1,romptr=0; if(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p|TVSetYPbPr525p)) return; @@ -11152,14 +10161,14 @@ SetAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, temp1 = temp; if(SiS_Pr->SiS_UseROM && (!(SiS_Pr->SiS_ROMNew))) { - if(HwInfo->jChipType >= SIS_661) { + if(SiS_Pr->ChipType >= SIS_661) { temp1 = GetOEMTVPtr661(SiS_Pr); temp1 >>= 1; romptr = SISGETROMW(0x260); - if(HwInfo->jChipType >= SIS_760) { + if(SiS_Pr->ChipType >= SIS_760) { romptr = SISGETROMW(0x360); } - } else if(HwInfo->jChipType >= SIS_330) { + } else if(SiS_Pr->ChipType >= SIS_330) { romptr = SISGETROMW(0x192); } else { romptr = SISGETROMW(0x112); @@ -11178,11 +10187,10 @@ SetAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } static void -SetEdgeEnhance(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex) +SetEdgeEnhance(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned short ModeIdIndex) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT index,temp,temp1,romptr=0; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short index,temp,temp1,romptr=0; temp = temp1 = GetTVPtrIndex(SiS_Pr) >> 1; /* 0: NTSC/YPbPr, 1: PAL, 2: HiTV */ @@ -11192,14 +10200,14 @@ SetEdgeEnhance(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, index = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex; if(SiS_Pr->SiS_UseROM && (!(SiS_Pr->SiS_ROMNew))) { - if(HwInfo->jChipType >= SIS_661) { + if(SiS_Pr->ChipType >= SIS_661) { romptr = SISGETROMW(0x26c); - if(HwInfo->jChipType >= SIS_760) { + if(SiS_Pr->ChipType >= SIS_760) { romptr = SISGETROMW(0x36c); } temp1 = GetOEMTVPtr661(SiS_Pr); temp1 >>= 1; - } else if(HwInfo->jChipType >= SIS_330) { + } else if(SiS_Pr->ChipType >= SIS_330) { romptr = SISGETROMW(0x1a4); } else { romptr = SISGETROMW(0x124); @@ -11217,10 +10225,9 @@ SetEdgeEnhance(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } static void -SetYFilter(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex) +SetYFilter(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned short ModeIdIndex) { - USHORT index, temp, i, j; + unsigned short index, temp, i, j; if(ModeNo <= 0x13) { index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].VB_StTVYFilterIndex; @@ -11235,7 +10242,7 @@ SetYFilter(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, else if(SiS_Pr->SiS_TVMode & TVSetPALN) temp = 4; /* PAL-N */ if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) temp = 1; /* HiVision uses PAL */ - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { for(i=0x35, j=0; i<=0x38; i++, j++) { SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVYFilter2[temp][index][j]); } @@ -11250,23 +10257,22 @@ SetYFilter(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } static void -SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex) +SetPhaseIncr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT index,temp,i,j,resinfo,romptr=0; - ULONG lindex; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short index,temp,i,j,resinfo,romptr=0; + unsigned int lindex; if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) return; /* NTSC-J data not in BIOS, and already set in SetGroup2 */ if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) return; - if((HwInfo->jChipType >= SIS_661) || SiS_Pr->SiS_ROMNew) { + if((SiS_Pr->ChipType >= SIS_661) || SiS_Pr->SiS_ROMNew) { lindex = GetOEMTVPtr661_2_OLD(SiS_Pr) & 0xffff; lindex <<= 2; for(j=0, i=0x31; i<=0x34; i++, j++) { - SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS661_TVPhase[lindex + j]); + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS_TVPhase[lindex + j]); } return; } @@ -11286,17 +10292,17 @@ SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, */ if(SiS_Pr->SiS_UseROM) { romptr = SISGETROMW(0x116); - if(HwInfo->jChipType >= SIS_330) { + if(SiS_Pr->ChipType >= SIS_330) { romptr = SISGETROMW(0x196); } - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { romptr = SISGETROMW(0x11c); - if(HwInfo->jChipType >= SIS_330) { + if(SiS_Pr->ChipType >= SIS_330) { romptr = SISGETROMW(0x19c); } if((SiS_Pr->SiS_VBInfo & SetInSlaveMode) && (!(SiS_Pr->SiS_TVMode & TVSetTVSimuMode))) { romptr = SISGETROMW(0x116); - if(HwInfo->jChipType >= SIS_330) { + if(SiS_Pr->ChipType >= SIS_330) { romptr = SISGETROMW(0x196); } } @@ -11311,7 +10317,7 @@ SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, index = temp % 2; temp >>= 1; /* 0:NTSC, 1:PAL, 2:HiTV */ for(j=0, i=0x31; i<=0x34; i++, j++) { - if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) + if(!(SiS_Pr->SiS_VBType & VB_SIS30xBLV)) SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVPhaseIncr1[temp][index][j]); else if((!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || (SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVPhaseIncr2[temp][index][j]); @@ -11320,7 +10326,7 @@ SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } } - if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (!(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision))) { + if((SiS_Pr->SiS_VBType & VB_SIS30xBLV) && (!(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision))) { if((!(SiS_Pr->SiS_TVMode & (TVSetPAL | TVSetYPbPr525p | TVSetYPbPr750p))) && (ModeNo > 0x13)) { if((resinfo == SIS_RI_640x480) || (resinfo == SIS_RI_800x600)) { @@ -11339,11 +10345,11 @@ SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } static void -SetDelayComp661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, - USHORT ModeIdIndex, USHORT RTI) +SetDelayComp661(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex, unsigned short RTI) { - USHORT delay = 0, romptr = 0, index, lcdpdcindex; - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + unsigned short delay = 0, romptr = 0, index, lcdpdcindex; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToRAMDAC))) return; @@ -11359,7 +10365,7 @@ SetDelayComp661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, if(SiS_Pr->UseCustomMode) { index = SiS_Pr->CSRClock; } else if(ModeNo > 0x13) { - index = SiS_GetVCLK2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RTI,HwInfo); + index = SiS_GetVCLK2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RTI); index = SiS_Pr->SiS_VCLKData[index].CLOCK; } if(index < 25) index = 25; @@ -11387,7 +10393,36 @@ SetDelayComp661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, else delay = (SiS_Pr->SiS_RefIndex[RTI].Ext_PDC >> 4); delay |= (delay << 8); - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(SiS_Pr->ChipType >= XGI_20) { + + delay = 0x0606; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + + delay = 0x0404; + if(SiS_Pr->SiS_XGIROM) { + index = GetTVPtrIndex(SiS_Pr); + if((romptr = SISGETROMW(0x35e))) { + delay = (ROMAddr[romptr + index] & 0x0f) << 1; + delay |= (delay << 8); + } + } + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + if(SiS_Pr->ChipType == XGI_40 && SiS_Pr->ChipRevision == 0x02) { + delay -= 0x0404; + } + } + } + + } else if(SiS_Pr->ChipType >= SIS_340) { + + delay = 0x0606; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + delay = 0x0404; + } + /* TODO (eventually) */ + + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* 3. TV */ @@ -11406,7 +10441,7 @@ SetDelayComp661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, /* 4. LCD, LCDA (for new ROM only LV and non-Pass 1:1) */ if( (SiS_Pr->SiS_LCDResInfo != Panel_Custom) && - ((romptr = GetLCDStructPtr661_2(SiS_Pr, HwInfo))) ) { + ((romptr = GetLCDStructPtr661_2(SiS_Pr))) ) { lcdpdcindex = (SiS_Pr->SiS_VBType & VB_UMC) ? 14 : 12; @@ -11426,6 +10461,7 @@ SetDelayComp661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, case Panel_1280x768_2:delay = 0x0004; break; case Panel_1280x800: case Panel_1280x800_2:delay = 0x0004; break; /* Verified for 1280x800 */ + case Panel_1280x854: delay = 0x0004; break; /* FIXME */ case Panel_1280x1024: delay = 0x1e04; break; case Panel_1400x1050: delay = 0x0004; break; case Panel_1600x1200: delay = 0x0400; break; @@ -11469,10 +10505,10 @@ SetDelayComp661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, } static void -SetCRT2SyncDither661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, USHORT RTI) +SetCRT2SyncDither661(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short RTI) { - USHORT infoflag; - UCHAR temp; + unsigned short infoflag; + unsigned char temp; if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { @@ -11513,12 +10549,16 @@ SetCRT2SyncDither661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, US } static void -SetPanelParms661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SetPanelParms661(struct SiS_Private *SiS_Pr) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT romptr, temp1, temp2; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short romptr, temp1, temp2; + + if(SiS_Pr->SiS_VBType & (VB_SISLVDS | VB_SIS30xC)) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x24,0x0f); + } - if(SiS_Pr->SiS_VBType & (VB_SIS301LV | VB_SIS302LV | VB_SIS302ELV)) { + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { if(SiS_Pr->LVDSHL != -1) { SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,SiS_Pr->LVDSHL); } @@ -11526,8 +10566,8 @@ SetPanelParms661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) if(SiS_Pr->SiS_ROMNew) { - if((romptr = GetLCDStructPtr661_2(SiS_Pr, HwInfo))) { - if(SiS_Pr->SiS_VBType & (VB_SIS301LV | VB_SIS302LV | VB_SIS302ELV)) { + if((romptr = GetLCDStructPtr661_2(SiS_Pr))) { + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { temp1 = (ROMAddr[romptr] & 0x03) | 0x0c; temp2 = 0xfc; if(SiS_Pr->LVDSHL != -1) { @@ -11546,48 +10586,47 @@ SetPanelParms661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) } static void -SiS_OEM310Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex,USHORT RRTI) +SiS_OEM310Setting(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RRTI) { if((SiS_Pr->SiS_ROMNew) && (SiS_Pr->SiS_VBType & VB_SISLVDS)) { - SetDelayComp661(SiS_Pr,HwInfo,ModeNo,ModeIdIndex,RRTI); + SetDelayComp661(SiS_Pr, ModeNo, ModeIdIndex, RRTI); if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - SetCRT2SyncDither661(SiS_Pr,HwInfo,ModeNo,RRTI); - SetPanelParms661(SiS_Pr,HwInfo); + SetCRT2SyncDither661(SiS_Pr, ModeNo, RRTI); + SetPanelParms661(SiS_Pr); } } else { - SetDelayComp(SiS_Pr,HwInfo,ModeNo); + SetDelayComp(SiS_Pr,ModeNo); } if((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { - SetAntiFlicker(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); - SetPhaseIncr(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); - SetYFilter(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); + SetAntiFlicker(SiS_Pr,ModeNo,ModeIdIndex); + SetPhaseIncr(SiS_Pr,ModeNo,ModeIdIndex); + SetYFilter(SiS_Pr,ModeNo,ModeIdIndex); if(SiS_Pr->SiS_VBType & VB_SIS301) { - SetEdgeEnhance(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); + SetEdgeEnhance(SiS_Pr,ModeNo,ModeIdIndex); } } } static void -SiS_OEM661Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex, USHORT RRTI) +SiS_OEM661Setting(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex, unsigned short RRTI) { if(SiS_Pr->SiS_VBType & VB_SISVB) { - SetDelayComp661(SiS_Pr,HwInfo,ModeNo,ModeIdIndex,RRTI); + SetDelayComp661(SiS_Pr, ModeNo, ModeIdIndex, RRTI); if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - SetCRT2SyncDither661(SiS_Pr,HwInfo,ModeNo,RRTI); - SetPanelParms661(SiS_Pr,HwInfo); + SetCRT2SyncDither661(SiS_Pr, ModeNo, RRTI); + SetPanelParms661(SiS_Pr); } if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - SetPhaseIncr(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); - SetYFilter(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); - SetAntiFlicker(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); + SetPhaseIncr(SiS_Pr, ModeNo, ModeIdIndex); + SetYFilter(SiS_Pr, ModeNo, ModeIdIndex); + SetAntiFlicker(SiS_Pr, ModeNo, ModeIdIndex); if(SiS_Pr->SiS_VBType & VB_SIS301) { - SetEdgeEnhance(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); + SetEdgeEnhance(SiS_Pr, ModeNo, ModeIdIndex); } } } @@ -11601,13 +10640,12 @@ SiS_OEM661Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, * pray that we have a backup... */ static void -SiS_FinalizeLCD(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo) +SiS_FinalizeLCD(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - USHORT tempcl,tempch,tempbl,tempbh,tempbx,tempax,temp; - USHORT resinfo,modeflag; + unsigned short tempcl,tempch,tempbl,tempbh,tempbx,tempax,temp; + unsigned short resinfo,modeflag; - if(!(SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) return; + if(!(SiS_Pr->SiS_VBType & VB_SISLVDS)) return; if(SiS_Pr->SiS_ROMNew) return; if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { @@ -11678,7 +10716,7 @@ SiS_FinalizeLCD(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { - if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + if(SiS_Pr->SiS_VBType & VB_SISEMI) { SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00); #ifdef SET_EMI SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); @@ -11806,11 +10844,11 @@ SiS_FinalizeLCD(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, #ifdef SIS300 static void -SetOEMLCDData2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex, USHORT RefTabIndex) +SetOEMLCDData2(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned short ModeIdIndex, + unsigned short RefTabIndex) { - USHORT crt2crtc=0, modeflag, myindex=0; - UCHAR temp; + unsigned short crt2crtc=0, modeflag, myindex=0; + unsigned char temp; int i; if(ModeNo <= 0x13) { @@ -11849,21 +10887,21 @@ SetOEMLCDData2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } } -static USHORT -GetOEMLCDPtr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, int Flag) +static unsigned short +GetOEMLCDPtr(struct SiS_Private *SiS_Pr, int Flag) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT tempbx=0,romptr=0; - UCHAR customtable300[] = { - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short tempbx=0,romptr=0; + static const unsigned char customtable300[] = { + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }; - UCHAR customtable630[] = { - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + static const unsigned char customtable630[] = { + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }; - if(HwInfo->jChipType == SIS_300) { + if(SiS_Pr->ChipType == SIS_300) { tempbx = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0x0f; if(SiS_Pr->SiS_VBType & VB_SIS301) tempbx &= 0x07; @@ -11912,11 +10950,10 @@ GetOEMLCDPtr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, int Flag) } static void -SetOEMLCDDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex) +SetOEMLCDDelay(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned short ModeIdIndex) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT index,temp,romptr=0; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short index,temp,romptr=0; if(SiS_Pr->SiS_LCDResInfo == Panel_Custom) return; @@ -11927,22 +10964,22 @@ SetOEMLCDDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } /* The Panel Compensation Delay should be set according to tables - * here. Unfortunately, various BIOS versions don't case about + * here. Unfortunately, various BIOS versions don't care about * a uniform way using eg. ROM byte 0x220, but use different * hard coded delays (0x04, 0x20, 0x18) in SetGroup1(). - * Thus we don't set this if the user select a custom pdc or if + * Thus we don't set this if the user selected a custom pdc or if * we otherwise detected a valid pdc. */ if(SiS_Pr->PDC != -1) return; - temp = GetOEMLCDPtr(SiS_Pr,HwInfo, 0); + temp = GetOEMLCDPtr(SiS_Pr, 0); if(SiS_Pr->UseCustomMode) index = 0; else index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_LCDDelayIndex; - if(HwInfo->jChipType != SIS_300) { + if(SiS_Pr->ChipType != SIS_300) { if(romptr) { romptr += (temp * 2); romptr = SISGETROMW(romptr); @@ -11986,12 +11023,11 @@ SetOEMLCDDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } static void -SetOEMLCDData(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex) +SetOEMLCDData(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { #if 0 /* Unfinished; Data table missing */ - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT index,temp; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short index,temp; if((SiS_Pr->SiS_UseROM) { if(!(ROMAddr[0x237] & 0x01)) return; @@ -11999,8 +11035,8 @@ SetOEMLCDData(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, /* No rom pointer in BIOS header! */ } - temp = GetOEMLCDPtr(SiS_Pr,HwInfo, 1); - if(temp = 0xFFFF) return; + temp = GetOEMLCDPtr(SiS_Pr, 1); + if(temp == 0xFFFF) return; index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex]._VB_LCDHIndex; for(i=0x14, j=0; i<=0x17; i++, j++) { @@ -12018,10 +11054,10 @@ SetOEMLCDData(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, #endif } -static USHORT -GetOEMTVPtr(SiS_Private *SiS_Pr) +static unsigned short +GetOEMTVPtr(struct SiS_Private *SiS_Pr) { - USHORT index; + unsigned short index; index = 0; if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) index += 4; @@ -12037,11 +11073,10 @@ GetOEMTVPtr(SiS_Private *SiS_Pr) } static void -SetOEMTVDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex) +SetOEMTVDelay(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT index,temp,romptr=0; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short index,temp,romptr=0; if(SiS_Pr->SiS_UseROM) { if(!(ROMAddr[0x238] & 0x01)) return; @@ -12070,11 +11105,10 @@ SetOEMTVDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } static void -SetOEMAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo, USHORT ModeIdIndex) +SetOEMAntiFlicker(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT index,temp,romptr=0; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short index,temp,romptr=0; if(SiS_Pr->SiS_UseROM) { if(!(ROMAddr[0x238] & 0x01)) return; @@ -12099,11 +11133,10 @@ SetOEMAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } static void -SetOEMPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex) +SetOEMPhaseIncr(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned short ModeIdIndex) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT index,i,j,temp,romptr=0; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short index,i,j,temp,romptr=0; if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) return; @@ -12119,7 +11152,7 @@ SetOEMPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_TVPhaseIndex; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { for(i=0x31, j=0; i<=0x34; i++, j++) { SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Phase2[temp][index][j]); } @@ -12140,11 +11173,10 @@ SetOEMPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } static void -SetOEMYFilter(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex) +SetOEMYFilter(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT index,temp,i,j,romptr=0; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short index,temp,i,j,romptr=0; if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSCART | SetCRT2ToHiVision | SetCRT2ToYPbPr525750)) return; @@ -12162,7 +11194,7 @@ SetOEMYFilter(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_TVYFilterIndex; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { for(i=0x35, j=0; i<=0x38; i++, j++) { SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Filter2[temp][index][j]); } @@ -12185,11 +11217,11 @@ SetOEMYFilter(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } } -static USHORT -SiS_SearchVBModeID(SiS_Private *SiS_Pr, USHORT *ModeNo) +static unsigned short +SiS_SearchVBModeID(struct SiS_Private *SiS_Pr, unsigned short *ModeNo) { - USHORT ModeIdIndex; - UCHAR VGAINFO = SiS_Pr->SiS_VGAINFO; + unsigned short ModeIdIndex; + unsigned char VGAINFO = SiS_Pr->SiS_VGAINFO; if(*ModeNo <= 5) *ModeNo |= 1; @@ -12210,10 +11242,10 @@ SiS_SearchVBModeID(SiS_Private *SiS_Pr, USHORT *ModeNo) } static void -SiS_OEM300Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo, USHORT ModeIdIndex, USHORT RefTableIndex) +SiS_OEM300Setting(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefTableIndex) { - USHORT OEMModeIdIndex=0; + unsigned short OEMModeIdIndex = 0; if(!SiS_Pr->UseCustomMode) { OEMModeIdIndex = SiS_SearchVBModeID(SiS_Pr,&ModeNo); @@ -12221,18 +11253,18 @@ SiS_OEM300Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - SetOEMLCDDelay(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex); + SetOEMLCDDelay(SiS_Pr, ModeNo, OEMModeIdIndex); if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - SetOEMLCDData(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex); + SetOEMLCDData(SiS_Pr, ModeNo, OEMModeIdIndex); } } if(SiS_Pr->UseCustomMode) return; if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - SetOEMTVDelay(SiS_Pr, HwInfo, ModeNo,OEMModeIdIndex); + SetOEMTVDelay(SiS_Pr, ModeNo,OEMModeIdIndex); if(SiS_Pr->SiS_VBType & VB_SISVB) { - SetOEMAntiFlicker(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex); - SetOEMPhaseIncr(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex); - SetOEMYFilter(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex); + SetOEMAntiFlicker(SiS_Pr, ModeNo, OEMModeIdIndex); + SetOEMPhaseIncr(SiS_Pr, ModeNo, OEMModeIdIndex); + SetOEMYFilter(SiS_Pr, ModeNo, OEMModeIdIndex); } } } diff --git a/drivers/video/sis/init301.h b/drivers/video/sis/init301.h index f84eb54164a..f475b21a85c 100644 --- a/drivers/video/sis/init301.h +++ b/drivers/video/sis/init301.h @@ -3,7 +3,7 @@ /* * Data and prototypes for init301.c * - * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2005 by Thomas Winischhofer, Vienna, Austria * * If distributed as part of the Linux kernel, the following license terms * apply: @@ -50,18 +50,18 @@ * */ -#ifndef _INIT301_ -#define _INIT301_ +#ifndef _INIT301_H_ +#define _INIT301_H_ #include "osdef.h" #include "initdef.h" -#ifdef LINUX_XF86 +#ifdef SIS_XORG_XF86 #include "sis.h" #include "sis_regs.h" #endif -#ifdef LINUX_KERNEL +#ifdef SIS_LINUX_KERNEL #include "vgatypes.h" #include "vstruct.h" #ifdef SIS_CP @@ -69,8 +69,13 @@ #endif #include <linux/config.h> #include <linux/version.h> -#include <asm/io.h> #include <linux/types.h> +#include <asm/io.h> +#include <linux/fb.h> +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) +#include <video/fbcon.h> +#endif +#include "sis.h" #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) #include <linux/sisfb.h> #else @@ -78,7 +83,7 @@ #endif #endif -static const UCHAR SiS_YPbPrTable[3][64] = { +static const unsigned char SiS_YPbPrTable[3][64] = { { 0x17,0x1d,0x03,0x09,0x05,0x06,0x0c,0x0c, 0x94,0x49,0x01,0x0a,0x06,0x0d,0x04,0x0a, @@ -90,17 +95,17 @@ static const UCHAR SiS_YPbPrTable[3][64] = { 0x00,0x40,0x44,0x00,0xdb,0x02,0x3b,0x00 }, { - 0x1d,0x11,0x06,0x09,0x0b,0x0c,0x0c,0x0c, + 0x33,0x06,0x06,0x09,0x0b,0x0c,0x0c,0x0c, 0x98,0x0a,0x01,0x0d,0x06,0x0d,0x04,0x0a, 0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x3f, - 0x0c,0x50,0xb2,0x9f,0x16,0x59,0x4c /*0x4f*/,0x13, + 0x0c,0x50,0xb2,0x9f,0x16,0x59,0x4f,0x13, 0xad,0x11,0xad,0x1d,0x40,0x8a,0x3d,0xb8, - 0x51,0x5e,0x60,0x57 /*0x49*/,0x7b /*0x7d*/,0x92,0x0f,0x40, - 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x4b, + 0x51,0x5e,0x60,0x49,0x7d,0x92,0x0f,0x40, + 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x4e, 0x43,0x41,0x11,0x00,0xfc,0xff,0x32,0x00 }, { -#if 1 +#if 0 /* OK, but sticks to left edge */ 0x13,0x1d,0xe8,0x09,0x09,0xed,0x0c,0x0c, 0x98,0x0a,0x01,0x0c,0x06,0x0d,0x04,0x0a, 0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x3f, @@ -110,20 +115,42 @@ static const UCHAR SiS_YPbPrTable[3][64] = { 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x27, 0x00,0x40,0x11,0x00,0xfc,0xff,0x32,0x00 #endif -#if 0 - 0x2a,0x14,0xe8,0x09,0x09,0xed,0x0c,0x0c, /* TEST (0.93) - BAD */ +#if 1 /* Perfect */ + 0x23,0x2d,0xe8,0x09,0x09,0xed,0x0c,0x0c, 0x98,0x0a,0x01,0x0c,0x06,0x0d,0x04,0x0a, 0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x3f, - 0xed,0x50,0x70,0x9e,0x16,0x57,0x6c,0x13, - 0x27,0x0b,0x27,0xfb,0x30,0x27,0x15,0xb0, - 0x3b,0xdb,0x61,0x24,0x78,0x92,0x0f,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0x14,0x6f, - 0x00,0x52,0xbb,0x00,0xd5,0xf7,0xa2,0x00 + 0xed,0x50,0x70,0x9f,0x16,0x59,0x60,0x13, + 0x27,0x0b,0x27,0xfc,0x30,0x27,0x1c,0xb0, + 0x4b,0x4b,0x6f,0x2f,0x63,0x92,0x0f,0x40, + 0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x73, + 0x00,0x40,0x11,0x00,0xfc,0xff,0x32,0x00 #endif } }; -static const UCHAR SiS_HiTVGroup3_1[] = { +static const unsigned char SiS_TVPhase[] = +{ + 0x21,0xED,0xBA,0x08, /* 0x00 SiS_NTSCPhase */ + 0x2A,0x05,0xE3,0x00, /* 0x01 SiS_PALPhase */ + 0x21,0xE4,0x2E,0x9B, /* 0x02 SiS_PALMPhase */ + 0x21,0xF4,0x3E,0xBA, /* 0x03 SiS_PALNPhase */ + 0x1E,0x8B,0xA2,0xA7, + 0x1E,0x83,0x0A,0xE0, /* 0x05 SiS_SpecialPhaseM */ + 0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + 0x21,0xF0,0x7B,0xD6, /* 0x08 SiS_NTSCPhase2 */ + 0x2A,0x09,0x86,0xE9, /* 0x09 SiS_PALPhase2 */ + 0x21,0xE6,0xEF,0xA4, /* 0x0a SiS_PALMPhase2 */ + 0x21,0xF6,0x94,0x46, /* 0x0b SiS_PALNPhase2 */ + 0x1E,0x8B,0xA2,0xA7, + 0x1E,0x83,0x0A,0xE0, /* 0x0d SiS_SpecialPhaseM */ + 0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + 0x1e,0x8c,0x5c,0x7a, /* 0x10 SiS_SpecialPhase */ + 0x25,0xd4,0xfd,0x5e /* 0x11 SiS_SpecialPhaseJ */ +}; + +static const unsigned char SiS_HiTVGroup3_1[] = { 0x00, 0x14, 0x15, 0x25, 0x55, 0x15, 0x0b, 0x13, 0xb1, 0x41, 0x62, 0x62, 0xff, 0xf4, 0x45, 0xa6, 0x25, 0x2f, 0x67, 0xf6, 0xbf, 0xff, 0x8e, 0x20, @@ -134,7 +161,7 @@ static const UCHAR SiS_HiTVGroup3_1[] = { 0x1a, 0x1f, 0x25, 0x2a, 0x4c, 0xaa, 0x01 }; -static const UCHAR SiS_HiTVGroup3_2[] = { +static const unsigned char SiS_HiTVGroup3_2[] = { 0x00, 0x14, 0x15, 0x25, 0x55, 0x15, 0x0b, 0x7a, 0x54, 0x41, 0xe7, 0xe7, 0xff, 0xf4, 0x45, 0xa6, 0x25, 0x2f, 0x67, 0xf6, 0xbf, 0xff, 0x8e, 0x20, @@ -147,7 +174,7 @@ static const UCHAR SiS_HiTVGroup3_2[] = { /* 301C / 302ELV extended Part2 TV registers (4 tap scaler) */ -static const UCHAR SiS_Part2CLVX_1[] = { +static const unsigned char SiS_Part2CLVX_1[] = { 0x00,0x00, 0x00,0x20,0x00,0x00,0x7F,0x20,0x02,0x7F,0x7D,0x20,0x04,0x7F,0x7D,0x1F,0x06,0x7E, 0x7C,0x1D,0x09,0x7E,0x7C,0x1B,0x0B,0x7E,0x7C,0x19,0x0E,0x7D,0x7C,0x17,0x11,0x7C, @@ -155,7 +182,7 @@ static const UCHAR SiS_Part2CLVX_1[] = { 0x7E,0x09,0x1D,0x7C,0x7F,0x06,0x1F,0x7C,0x7F,0x04,0x20,0x7D,0x00,0x02,0x20,0x7E }; -static const UCHAR SiS_Part2CLVX_2[] = { +static const unsigned char SiS_Part2CLVX_2[] = { 0x00,0x00, 0x00,0x20,0x00,0x00,0x7F,0x20,0x02,0x7F,0x7D,0x20,0x04,0x7F,0x7D,0x1F,0x06,0x7E, 0x7C,0x1D,0x09,0x7E,0x7C,0x1B,0x0B,0x7E,0x7C,0x19,0x0E,0x7D,0x7C,0x17,0x11,0x7C, @@ -163,7 +190,7 @@ static const UCHAR SiS_Part2CLVX_2[] = { 0x7E,0x09,0x1D,0x7C,0x7F,0x06,0x1F,0x7C,0x7F,0x04,0x20,0x7D,0x00,0x02,0x20,0x7E }; -static const UCHAR SiS_Part2CLVX_3[] = { /* NTSC, 525i, 525p */ +static const unsigned char SiS_Part2CLVX_3[] = { /* NTSC, 525i, 525p */ 0xE0,0x01, 0x04,0x1A,0x04,0x7E,0x03,0x1A,0x06,0x7D,0x01,0x1A,0x08,0x7D,0x00,0x19,0x0A,0x7D, 0x7F,0x19,0x0C,0x7C,0x7E,0x18,0x0E,0x7C,0x7E,0x17,0x10,0x7B,0x7D,0x15,0x12,0x7C, @@ -182,7 +209,7 @@ static const UCHAR SiS_Part2CLVX_3[] = { /* NTSC, 525i, 525p */ 0xFF,0xFF }; -static const UCHAR SiS_Part2CLVX_4[] = { /* PAL */ +static const unsigned char SiS_Part2CLVX_4[] = { /* PAL */ 0x58,0x02, 0x05,0x19,0x05,0x7D,0x03,0x19,0x06,0x7E,0x02,0x19,0x08,0x7D,0x01,0x18,0x0A,0x7D, 0x00,0x18,0x0C,0x7C,0x7F,0x17,0x0E,0x7C,0x7E,0x16,0x0F,0x7D,0x7E,0x14,0x11,0x7D, @@ -201,7 +228,7 @@ static const UCHAR SiS_Part2CLVX_4[] = { /* PAL */ 0xFF,0xFF }; -static const UCHAR SiS_Part2CLVX_5[] = { /* 750p */ +static const unsigned char SiS_Part2CLVX_5[] = { /* 750p */ 0x00,0x03, 0x05,0x19,0x05,0x7D,0x03,0x19,0x06,0x7E,0x02,0x19,0x08,0x7D,0x01,0x18,0x0A,0x7D, 0x00,0x18,0x0C,0x7C,0x7F,0x17,0x0E,0x7C,0x7E,0x16,0x0F,0x7D,0x7E,0x14,0x11,0x7D, @@ -210,7 +237,7 @@ static const UCHAR SiS_Part2CLVX_5[] = { /* 750p */ 0xFF,0xFF }; -static const UCHAR SiS_Part2CLVX_6[] = { /* 1080i */ +static const unsigned char SiS_Part2CLVX_6[] = { /* 1080i */ 0x00,0x04, 0x04,0x1A,0x04,0x7E,0x02,0x1B,0x05,0x7E,0x01,0x1A,0x07,0x7E,0x00,0x1A,0x09,0x7D, 0x7F,0x19,0x0B,0x7D,0x7E,0x18,0x0D,0x7D,0x7D,0x17,0x10,0x7C,0x7D,0x15,0x12,0x7C, @@ -221,7 +248,7 @@ static const UCHAR SiS_Part2CLVX_6[] = { /* 1080i */ #ifdef SIS315H /* 661 et al LCD data structure (2.03.00) */ -static const UCHAR SiS_LCDStruct661[] = { +static const unsigned char SiS_LCDStruct661[] = { /* 1024x768 */ /* type|CR37| HDE | VDE | HT | VT | hss | hse */ 0x02,0xC0,0x00,0x04,0x00,0x03,0x40,0x05,0x26,0x03,0x10,0x00,0x88, @@ -249,11 +276,20 @@ static const UCHAR SiS_LCDStruct661[] = { /* 1680x1050 */ 0x0D,0xE0,0x90,0x06,0x1A,0x04,0x6C,0x07,0x2A,0x04,0x1A,0x00,0x4C, 0x00,0x03,0x00,0x06,0x00,0x79,0xBE,0x44,0x00,0x00,0x00,0x00,0x06, + /* 1280x800_3 */ + 0x0C,0xE0,0x00,0x05,0x20,0x03,0xAA,0x05,0x2E,0x03,0x30,0x00,0x50, + 0x00,0x04,0x00,0x03,0x00,0x47,0xA9,0x10,0x00,0x00,0x00,0x00,0x07, + /* 800x600 */ + 0x01,0xC0,0x20,0x03,0x58,0x02,0x20,0x04,0x74,0x02,0x2A,0x00,0x80, + 0x00,0x06,0x00,0x04,0x00,0x28,0x63,0x4B,0x00,0x00,0x00,0x00,0x00, + /* 1280x854 */ + 0x08,0xE0,0x00,0x05,0x56,0x03,0x80,0x06,0x5d,0x03,0x10,0x00,0x70, + 0x00,0x01,0x00,0x03,0x00,0x54,0x75,0x13,0x00,0x00,0x00,0x00,0x08 }; #endif #ifdef SIS300 -static UCHAR SiS300_TrumpionData[7][80] = { +static unsigned char SiS300_TrumpionData[14][80] = { { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0x7F,0x00,0x80,0x02, 0x20,0x03,0x0B,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x10,0x00,0x00,0x04,0x23, 0x00,0x00,0x03,0x28,0x03,0x10,0x05,0x08,0x40,0x10,0x00,0x10,0x04,0x23,0x00,0x23, @@ -288,119 +324,182 @@ static UCHAR SiS300_TrumpionData[7][80] = { 0x40,0x05,0x13,0x00,0x00,0x03,0x26,0x03,0x88,0x0C,0x30,0x90,0x00,0x00,0x04,0x23, 0x00,0x01,0x03,0x24,0x03,0x28,0x06,0x08,0x40,0x90,0x00,0x90,0x04,0x23,0x00,0x23, 0x03,0x11,0x60,0x40,0x05,0xFF,0x0F,0xF4,0x18,0x01,0x00,0x08,0x01,0x00,0x08,0x01, - 0x00,0x08,0x01,0x01,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x5B,0x01,0xBE,0x01,0x00 } + 0x00,0x08,0x01,0x01,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x5B,0x01,0xBE,0x01,0x00 }, + /* variant 2 */ + { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0x7F,0x00,0x80,0x02, + 0x20,0x03,0x15,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x18,0x00,0x00,0x04,0x23, + 0x00,0x01,0x03,0x44,0x03,0x28,0x06,0x08,0x40,0x18,0x00,0x18,0x04,0x23,0x00,0x23, + 0x03,0x11,0x60,0xA6,0x01,0xFF,0x03,0xFF,0x19,0x01,0x00,0x05,0x13,0x04,0x04,0x05, + 0x04,0x0C,0x13,0x0A,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x55,0x01,0xBE,0x01,0x00 }, + { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0x7F,0x00,0x80,0x02, + 0x20,0x03,0x15,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x18,0x00,0x00,0x04,0x23, + 0x00,0x01,0x03,0x44,0x03,0x28,0x06,0x08,0x40,0x18,0x00,0x18,0x04,0x23,0x00,0x23, + 0x03,0x11,0x60,0xA6,0x01,0xFF,0x03,0xFF,0x19,0x01,0x00,0x05,0x13,0x04,0x04,0x05, + 0x04,0x0C,0x13,0x0A,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x55,0x01,0xBE,0x01,0x00 }, + { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0x8A,0x00,0xD8,0x02, + 0x84,0x03,0x16,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x1C,0x00,0x20,0x04,0x23, + 0x00,0x01,0x03,0x53,0x03,0x28,0x06,0x08,0x40,0x1C,0x00,0x16,0x04,0x23,0x00,0x23, + 0x03,0x11,0x60,0xDA,0x01,0xFF,0x0F,0xF4,0x18,0x07,0x05,0x05,0x13,0x04,0x04,0x05, + 0x01,0x0B,0x13,0x0A,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x55,0x01,0xBE,0x01,0x00 }, + { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0x72,0x00,0xD8,0x02, + 0x84,0x03,0x16,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x1C,0x00,0x20,0x04,0x23, + 0x00,0x01,0x03,0x53,0x03,0x28,0x06,0x08,0x40,0x1C,0x00,0x16,0x04,0x23,0x00,0x23, + 0x03,0x11,0x60,0xDA,0x01,0xFF,0x0F,0xF4,0x18,0x07,0x05,0x05,0x13,0x04,0x04,0x05, + 0x01,0x0B,0x13,0x0A,0x02,0xB0,0x00,0x00,0x02,0xBA,0xF0,0x55,0x01,0xBE,0x01,0x00 }, + { 0x02,0x0A,0x02,0x00,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0x7F,0x00,0x80,0x02, + 0x20,0x03,0x16,0x00,0xE0,0x01,0x0D,0x02,0x60,0x0C,0x30,0x98,0x00,0x00,0x04,0x23, + 0x00,0x01,0x03,0x45,0x03,0x48,0x06,0x08,0x40,0x98,0x00,0x98,0x04,0x23,0x00,0x23, + 0x03,0x11,0x60,0xF4,0x01,0xFF,0x0F,0xF4,0x18,0x01,0x00,0x05,0x01,0x00,0x05,0x05, + 0x04,0x0C,0x08,0x05,0x02,0xB0,0x00,0x00,0x02,0xBA,0xEA,0x58,0x01,0xBE,0x01,0x00 }, + { 0x02,0x0A,0x02,0x01,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0xBF,0x00,0x20,0x03, + 0x20,0x04,0x0D,0x00,0x58,0x02,0x71,0x02,0x80,0x0C,0x30,0x9A,0x00,0xFA,0x03,0x1D, + 0x00,0x01,0x03,0x22,0x03,0x28,0x06,0x08,0x40,0x98,0x00,0x98,0x04,0x1D,0x00,0x1D, + 0x03,0x11,0x60,0x39,0x03,0x40,0x05,0xF4,0x18,0x07,0x02,0x06,0x04,0x01,0x06,0x0B, + 0x02,0x0A,0x20,0x19,0x02,0xB0,0x00,0x00,0x02,0xBA,0xEA,0x58,0x01,0xBE,0x01,0x00 }, + { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x11,0x00,0x0D,0x10,0xEF,0x00,0x00,0x04, + 0x40,0x05,0x13,0x00,0x00,0x03,0x26,0x03,0x88,0x0C,0x30,0x90,0x00,0x00,0x04,0x23, + 0x00,0x01,0x03,0x24,0x03,0x28,0x06,0x08,0x40,0x90,0x00,0x90,0x04,0x23,0x00,0x23, + 0x03,0x11,0x60,0x40,0x05,0xFF,0x0F,0xF4,0x18,0x01,0x00,0x08,0x01,0x00,0x08,0x01, + 0x00,0x08,0x01,0x01,0x02,0xB0,0x00,0x00,0x02,0xBA,0xEA,0x58,0x01,0xBE,0x01,0x00 } }; #endif -void SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); -void SiS_EnableCRT2(SiS_Private *SiS_Pr); -USHORT SiS_GetRatePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_INFO HwInfo); -void SiS_WaitRetrace1(SiS_Private *SiS_Pr); -BOOLEAN SiS_IsDualEdge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); -BOOLEAN SiS_IsVAMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); -void SiS_SetChrontelGPIO(SiS_Private *SiS_Pr, USHORT myvbinfo); -void SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT ModeNo, - USHORT ModeIdIndex, PSIS_HW_INFO HwInfo, - int checkcrt2mode); -void SiS_SetYPbPr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); -void SiS_SetTVMode(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_INFO HwInfo); -void SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_INFO HwInfo); -USHORT SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo); -USHORT SiS_GetResInfo(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex); -void SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); -BOOLEAN SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo); -void SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); -void SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); +void SiS_UnLockCRT2(struct SiS_Private *SiS_Pr); +#ifndef SIS_LINUX_KERNEL +void SiS_LockCRT2(struct SiS_Private *SiS_Pr); +#endif +void SiS_EnableCRT2(struct SiS_Private *SiS_Pr); +unsigned short SiS_GetRatePtr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex); +void SiS_WaitRetrace1(struct SiS_Private *SiS_Pr); +BOOLEAN SiS_IsDualEdge(struct SiS_Private *SiS_Pr); +BOOLEAN SiS_IsVAMode(struct SiS_Private *SiS_Pr); +void SiS_GetVBInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex, int checkcrt2mode); +void SiS_SetYPbPr(struct SiS_Private *SiS_Pr); +void SiS_SetTVMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex); +void SiS_GetLCDResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex); +unsigned short SiS_GetVCLK2Ptr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex); +unsigned short SiS_GetResInfo(struct SiS_Private *SiS_Pr,unsigned short ModeNo,unsigned short ModeIdIndex); +void SiS_DisableBridge(struct SiS_Private *SiS_Pr); +#ifndef SIS_LINUX_KERNEL +void SiS_EnableBridge(struct SiS_Private *SiS_Pr); +#endif +BOOLEAN SiS_SetCRT2Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo); +void SiS_SiS30xBLOn(struct SiS_Private *SiS_Pr); +void SiS_SiS30xBLOff(struct SiS_Private *SiS_Pr); -void SiS_SetCH700x(SiS_Private *SiS_Pr, USHORT tempax); -USHORT SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempax); -void SiS_SetCH701x(SiS_Private *SiS_Pr, USHORT tempax); -USHORT SiS_GetCH701x(SiS_Private *SiS_Pr, USHORT tempax); -void SiS_SetCH70xxANDOR(SiS_Private *SiS_Pr, USHORT tempax,USHORT tempbh); +void SiS_SetCH700x(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val); +unsigned short SiS_GetCH700x(struct SiS_Private *SiS_Pr, unsigned short tempax); +void SiS_SetCH701x(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val); +unsigned short SiS_GetCH701x(struct SiS_Private *SiS_Pr, unsigned short tempax); +#ifndef SIS_LINUX_KERNEL +void SiS_SetCH70xx(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val); +unsigned short SiS_GetCH70xx(struct SiS_Private *SiS_Pr, unsigned short tempax); +#endif +void SiS_SetCH70xxANDOR(struct SiS_Private *SiS_Pr, unsigned short reg, + unsigned char orval,unsigned short andval); #ifdef SIS315H -static void SiS_Chrontel701xOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); -static void SiS_Chrontel701xOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); -static void SiS_ChrontelInitTVVSync(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); -static void SiS_ChrontelDoSomething1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); -void SiS_Chrontel701xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); -void SiS_Chrontel701xBLOff(SiS_Private *SiS_Pr); +static void SiS_Chrontel701xOn(struct SiS_Private *SiS_Pr); +static void SiS_Chrontel701xOff(struct SiS_Private *SiS_Pr); +static void SiS_ChrontelInitTVVSync(struct SiS_Private *SiS_Pr); +static void SiS_ChrontelDoSomething1(struct SiS_Private *SiS_Pr); +void SiS_Chrontel701xBLOn(struct SiS_Private *SiS_Pr); +void SiS_Chrontel701xBLOff(struct SiS_Private *SiS_Pr); #endif /* 315 */ #ifdef SIS300 -#if 0 -static void SiS_SetTrumpReg(SiS_Private *SiS_Pr, USHORT tempbx); -static USHORT SiS_GetTrumpReg(SiS_Private *SiS_Pr, USHORT tempbx); -#endif -static BOOLEAN SiS_SetTrumpionBlock(SiS_Private *SiS_Pr, UCHAR *dataptr); +static BOOLEAN SiS_SetTrumpionBlock(struct SiS_Private *SiS_Pr, unsigned char *dataptr); +void SiS_SetChrontelGPIO(struct SiS_Private *SiS_Pr, unsigned short myvbinfo); #endif -void SiS_DDC2Delay(SiS_Private *SiS_Pr, USHORT delaytime); -USHORT SiS_ReadDDC1Bit(SiS_Private *SiS_Pr); -USHORT SiS_HandleDDC(SiS_Private *SiS_Pr, ULONG VBFlags, int VGAEngine, - USHORT adaptnum, USHORT DDCdatatype, UCHAR *buffer); -#ifdef LINUX_XF86 -USHORT SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS); -USHORT SiS_SenseVGA2DDC(SiS_Private *SiS_Pr, SISPtr pSiS); -#endif +void SiS_DDC2Delay(struct SiS_Private *SiS_Pr, unsigned int delaytime); +unsigned short SiS_ReadDDC1Bit(struct SiS_Private *SiS_Pr); +unsigned short SiS_HandleDDC(struct SiS_Private *SiS_Pr, unsigned int VBFlags, int VGAEngine, + unsigned short adaptnum, unsigned short DDCdatatype, + unsigned char *buffer, unsigned int VBFlags2); -static void SiS_SetSwitchDDC2(SiS_Private *SiS_Pr); -static USHORT SiS_SetStart(SiS_Private *SiS_Pr); -static USHORT SiS_SetStop(SiS_Private *SiS_Pr); -static USHORT SiS_SetSCLKLow(SiS_Private *SiS_Pr); -static USHORT SiS_SetSCLKHigh(SiS_Private *SiS_Pr); -static USHORT SiS_ReadDDC2Data(SiS_Private *SiS_Pr, USHORT tempax); -static USHORT SiS_WriteDDC2Data(SiS_Private *SiS_Pr, USHORT tempax); -static USHORT SiS_CheckACK(SiS_Private *SiS_Pr); -static USHORT SiS_InitDDCRegs(SiS_Private *SiS_Pr, ULONG VBFlags, int VGAEngine, - USHORT adaptnum, USHORT DDCdatatype, BOOLEAN checkcr32); -static USHORT SiS_WriteDABDDC(SiS_Private *SiS_Pr); -static USHORT SiS_PrepareReadDDC(SiS_Private *SiS_Pr); -static USHORT SiS_PrepareDDC(SiS_Private *SiS_Pr); -static void SiS_SendACK(SiS_Private *SiS_Pr, USHORT yesno); -static USHORT SiS_DoProbeDDC(SiS_Private *SiS_Pr); -static USHORT SiS_ProbeDDC(SiS_Private *SiS_Pr); -static USHORT SiS_ReadDDC(SiS_Private *SiS_Pr, USHORT DDCdatatype, UCHAR *buffer); +#ifdef SIS_XORG_XF86 +unsigned short SiS_InitDDCRegs(struct SiS_Private *SiS_Pr, unsigned int VBFlags, + int VGAEngine, unsigned short adaptnum, unsigned short DDCdatatype, + BOOLEAN checkcr32, unsigned int VBFlags2); +unsigned short SiS_ProbeDDC(struct SiS_Private *SiS_Pr); +unsigned short SiS_ReadDDC(struct SiS_Private *SiS_Pr, unsigned short DDCdatatype, + unsigned char *buffer); +#else +static unsigned short SiS_InitDDCRegs(struct SiS_Private *SiS_Pr, unsigned int VBFlags, + int VGAEngine, unsigned short adaptnum, unsigned short DDCdatatype, + BOOLEAN checkcr32, unsigned int VBFlags2); +static unsigned short SiS_ProbeDDC(struct SiS_Private *SiS_Pr); +static unsigned short SiS_ReadDDC(struct SiS_Private *SiS_Pr, unsigned short DDCdatatype, + unsigned char *buffer); +#endif +static void SiS_SetSwitchDDC2(struct SiS_Private *SiS_Pr); +static unsigned short SiS_SetStart(struct SiS_Private *SiS_Pr); +static unsigned short SiS_SetStop(struct SiS_Private *SiS_Pr); +static unsigned short SiS_SetSCLKLow(struct SiS_Private *SiS_Pr); +static unsigned short SiS_SetSCLKHigh(struct SiS_Private *SiS_Pr); +static unsigned short SiS_ReadDDC2Data(struct SiS_Private *SiS_Pr); +static unsigned short SiS_WriteDDC2Data(struct SiS_Private *SiS_Pr, unsigned short tempax); +static unsigned short SiS_CheckACK(struct SiS_Private *SiS_Pr); +static unsigned short SiS_WriteDABDDC(struct SiS_Private *SiS_Pr); +static unsigned short SiS_PrepareReadDDC(struct SiS_Private *SiS_Pr); +static unsigned short SiS_PrepareDDC(struct SiS_Private *SiS_Pr); +static void SiS_SendACK(struct SiS_Private *SiS_Pr, unsigned short yesno); +static unsigned short SiS_DoProbeDDC(struct SiS_Private *SiS_Pr); +#ifdef SIS300 +static void SiS_OEM300Setting(struct SiS_Private *SiS_Pr, + unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefTabindex); +static void SetOEMLCDData2(struct SiS_Private *SiS_Pr, + unsigned short ModeNo, unsigned short ModeIdIndex,unsigned short RefTableIndex); +#endif #ifdef SIS315H -static void SiS_OEM310Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex, USHORT RRTI); -static void SiS_OEM661Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex, USHORT RRTI); -static void SiS_FinalizeLCD(SiS_Private *, USHORT, USHORT, PSIS_HW_INFO); +static void SiS_OEM310Setting(struct SiS_Private *SiS_Pr, + unsigned short ModeNo,unsigned short ModeIdIndex, unsigned short RRTI); +static void SiS_OEM661Setting(struct SiS_Private *SiS_Pr, + unsigned short ModeNo,unsigned short ModeIdIndex, unsigned short RRTI); +static void SiS_FinalizeLCD(struct SiS_Private *, unsigned short, unsigned short); #endif + +extern void SiS_SetReg(SISIOADDRESS, unsigned short, unsigned short); +extern void SiS_SetRegByte(SISIOADDRESS, unsigned short); +extern void SiS_SetRegShort(SISIOADDRESS, unsigned short); +extern void SiS_SetRegLong(SISIOADDRESS, unsigned int); +extern unsigned char SiS_GetReg(SISIOADDRESS, unsigned short); +extern unsigned char SiS_GetRegByte(SISIOADDRESS); +extern unsigned short SiS_GetRegShort(SISIOADDRESS); +extern unsigned int SiS_GetRegLong(SISIOADDRESS); +extern void SiS_SetRegANDOR(SISIOADDRESS, unsigned short, unsigned short, unsigned short); +extern void SiS_SetRegOR(SISIOADDRESS, unsigned short, unsigned short); +extern void SiS_SetRegAND(SISIOADDRESS, unsigned short, unsigned short); +extern void SiS_DisplayOff(struct SiS_Private *SiS_Pr); +extern void SiS_DisplayOn(struct SiS_Private *SiS_Pr); +extern BOOLEAN SiS_SearchModeID(struct SiS_Private *, unsigned short *, unsigned short *); +extern unsigned short SiS_GetModeFlag(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex); +extern unsigned short SiS_GetModePtr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex); +extern unsigned short SiS_GetColorDepth(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex); +extern unsigned short SiS_GetOffset(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex); +extern void SiS_LoadDAC(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex); +extern void SiS_CalcLCDACRT1Timing(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex); +extern void SiS_CalcCRRegisters(struct SiS_Private *SiS_Pr, int depth); +extern unsigned short SiS_GetRefCRTVCLK(struct SiS_Private *SiS_Pr, unsigned short Index, int UseWide); +extern unsigned short SiS_GetRefCRT1CRTC(struct SiS_Private *SiS_Pr, unsigned short Index, int UseWide); #ifdef SIS300 -static void SiS_OEM300Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo, USHORT ModeIdIndex, USHORT RefTabindex); -static void SetOEMLCDData2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo, USHORT ModeIdIndex,USHORT RefTableIndex); +extern void SiS_GetFIFOThresholdIndex300(struct SiS_Private *SiS_Pr, unsigned short *tempbx, + unsigned short *tempcl); +extern unsigned short SiS_GetFIFOThresholdB300(unsigned short tempbx, unsigned short tempcl); +extern unsigned short SiS_GetLatencyFactor630(struct SiS_Private *SiS_Pr, unsigned short index); +#ifdef SIS_LINUX_KERNEL +extern unsigned int sisfb_read_nbridge_pci_dword(struct SiS_Private *SiS_Pr, int reg); +extern unsigned int sisfb_read_lpc_pci_dword(struct SiS_Private *SiS_Pr, int reg); #endif - -extern void SiS_SetReg(SISIOADDRESS, USHORT, USHORT); -extern void SiS_SetRegByte(SISIOADDRESS, USHORT); -extern void SiS_SetRegShort(SISIOADDRESS, USHORT); -extern void SiS_SetRegLong(SISIOADDRESS, ULONG); -extern UCHAR SiS_GetReg(SISIOADDRESS, USHORT); -extern UCHAR SiS_GetRegByte(SISIOADDRESS); -extern USHORT SiS_GetRegShort(SISIOADDRESS); -extern ULONG SiS_GetRegLong(SISIOADDRESS); -extern void SiS_SetRegANDOR(SISIOADDRESS, USHORT, USHORT, USHORT); -extern void SiS_SetRegOR(SISIOADDRESS, USHORT, USHORT); -extern void SiS_SetRegAND(SISIOADDRESS, USHORT, USHORT); -extern void SiS_DisplayOff(SiS_Private *SiS_Pr); -extern void SiS_DisplayOn(SiS_Private *SiS_Pr); -extern BOOLEAN SiS_SearchModeID(SiS_Private *, USHORT *, USHORT *); -extern UCHAR SiS_GetModePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex); -extern USHORT SiS_GetColorDepth(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex); -extern USHORT SiS_GetOffset(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo); -extern void SiS_LoadDAC(SiS_Private *SiS_Pr, PSIS_HW_INFO, USHORT ModeNo, - USHORT ModeIdIndex); -extern void SiS_CalcLCDACRT1Timing(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex); -#ifdef LINUX_XF86 -extern void SiS_MakeClockRegs(ScrnInfoPtr pScrn, int clock, UCHAR *p2b, UCHAR *p2c); -extern int SiS_FindPanelFromDB(SISPtr pSiS, USHORT panelvendor, USHORT panelproduct, - int *maxx, int *maxy, int *prefx, int *prefy); #endif #endif diff --git a/drivers/video/sis/initdef.h b/drivers/video/sis/initdef.h index 55a82d6dc4c..264b55a5947 100644 --- a/drivers/video/sis/initdef.h +++ b/drivers/video/sis/initdef.h @@ -3,7 +3,7 @@ /* * Global definitions for init.c and init301.c * - * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2005 by Thomas Winischhofer, Vienna, Austria * * If distributed as part of the Linux kernel, the following license terms * apply: @@ -53,19 +53,20 @@ #ifndef _INITDEF_ #define _INITDEF_ -#define IS_SIS330 (HwInfo->jChipType == SIS_330) -#define IS_SIS550 (HwInfo->jChipType == SIS_550) -#define IS_SIS650 (HwInfo->jChipType == SIS_650) /* All versions, incl 651, M65x */ -#define IS_SIS740 (HwInfo->jChipType == SIS_740) +#define IS_SIS330 (SiS_Pr->ChipType == SIS_330) +#define IS_SIS550 (SiS_Pr->ChipType == SIS_550) +#define IS_SIS650 (SiS_Pr->ChipType == SIS_650) /* All versions, incl 651, M65x */ +#define IS_SIS740 (SiS_Pr->ChipType == SIS_740) #define IS_SIS651 (SiS_Pr->SiS_SysFlags & (SF_Is651 | SF_Is652)) #define IS_SISM650 (SiS_Pr->SiS_SysFlags & (SF_IsM650 | SF_IsM652 | SF_IsM653)) #define IS_SIS65x (IS_SIS651 || IS_SISM650) /* Only special versions of 65x */ -#define IS_SIS661 (HwInfo->jChipType == SIS_661) -#define IS_SIS741 (HwInfo->jChipType == SIS_741) -#define IS_SIS660 (HwInfo->jChipType == SIS_660) -#define IS_SIS760 (HwInfo->jChipType == SIS_760) -#define IS_SIS661741660760 (IS_SIS661 || IS_SIS741 || IS_SIS660 || IS_SIS760) -#define IS_SIS650740 ((HwInfo->jChipType >= SIS_650) && (HwInfo->jChipType < SIS_330)) +#define IS_SIS661 (SiS_Pr->ChipType == SIS_661) +#define IS_SIS741 (SiS_Pr->ChipType == SIS_741) +#define IS_SIS660 (SiS_Pr->ChipType == SIS_660) +#define IS_SIS760 (SiS_Pr->ChipType == SIS_760) +#define IS_SIS761 (SiS_Pr->ChipType == SIS_761) +#define IS_SIS661741660760 (IS_SIS661 || IS_SIS741 || IS_SIS660 || IS_SIS760 || IS_SIS761) +#define IS_SIS650740 ((SiS_Pr->ChipType >= SIS_650) && (SiS_Pr->ChipType < SIS_330)) #define IS_SIS550650740 (IS_SIS550 || IS_SIS650740) #define IS_SIS650740660 (IS_SIS650 || IS_SIS740 || IS_SIS661741660760) #define IS_SIS550650740660 (IS_SIS550 || IS_SIS650740660) @@ -73,24 +74,37 @@ #define SISGETROMW(x) (ROMAddr[(x)] | (ROMAddr[(x)+1] << 8)) /* SiS_VBType */ -#define VB_SIS301 0x0001 -#define VB_SIS301B 0x0002 -#define VB_SIS302B 0x0004 -#define VB_SIS301LV 0x0008 -#define VB_SIS302LV 0x0010 +#define VB_SIS301 0x0001 +#define VB_SIS301B 0x0002 +#define VB_SIS302B 0x0004 +#define VB_SIS301LV 0x0008 +#define VB_SIS302LV 0x0010 #define VB_SIS302ELV 0x0020 -#define VB_SIS301C 0x0040 +#define VB_SIS301C 0x0040 +#define VB_SIS307T 0x0080 +#define VB_SIS307LV 0x0100 #define VB_UMC 0x4000 #define VB_NoLCD 0x8000 -#define VB_SIS301BLV302BLV (VB_SIS301B|VB_SIS301C|VB_SIS302B|VB_SIS301LV|VB_SIS302LV|VB_SIS302ELV) -#define VB_SIS301B302B (VB_SIS301B|VB_SIS301C|VB_SIS302B) -#define VB_SIS301LV302LV (VB_SIS301LV|VB_SIS302LV|VB_SIS302ELV) -#define VB_SISVB (VB_SIS301 | VB_SIS301BLV302BLV) -#define VB_SISTMDS (VB_SIS301 | VB_SIS301B302B) -#define VB_SISLVDS VB_SIS301LV302LV -#define VB_SISLCDA (VB_SIS302B|VB_SIS301C|VB_SIS301LV|VB_SIS302LV|VB_SIS302ELV) -#define VB_SISYPBPR (VB_SIS301C|VB_SIS301LV|VB_SIS302LV|VB_SIS302ELV) -#define VB_SISHIVISION (VB_SIS301|VB_SIS301B|VB_SIS302B) +#define VB_SIS30xB (VB_SIS301B | VB_SIS301C | VB_SIS302B | VB_SIS307T) +#define VB_SIS30xC (VB_SIS301C | VB_SIS307T) +#define VB_SISTMDS (VB_SIS301 | VB_SIS301B | VB_SIS301C | VB_SIS302B | VB_SIS307T) +#define VB_SISLVDS (VB_SIS301LV | VB_SIS302LV | VB_SIS302ELV | VB_SIS307LV) +#define VB_SIS30xBLV (VB_SIS30xB | VB_SISLVDS) +#define VB_SIS30xCLV (VB_SIS30xC | VB_SIS302ELV | VB_SIS307LV) +#define VB_SISVB (VB_SIS301 | VB_SIS30xBLV) +#define VB_SISLCDA (VB_SIS302B | VB_SIS301C | VB_SIS307T | VB_SISLVDS) +#define VB_SISTMDSLCDA (VB_SIS301C | VB_SIS307T) +#define VB_SISPART4SCALER (VB_SIS301C | VB_SIS307T | VB_SIS302ELV | VB_SIS307LV) +#define VB_SISHIVISION (VB_SIS301 | VB_SIS301B | VB_SIS302B) +#define VB_SISYPBPR (VB_SIS301C | VB_SIS307T | VB_SIS301LV | VB_SIS302LV | VB_SIS302ELV | VB_SIS307LV) +#define VB_SISTAP4SCALER (VB_SIS301C | VB_SIS307T | VB_SIS302ELV | VB_SIS307LV) +#define VB_SISPART4OVERFLOW (VB_SIS301C | VB_SIS307T | VB_SIS302LV | VB_SIS302ELV | VB_SIS307LV) +#define VB_SISPWD (VB_SIS301C | VB_SIS307T | VB_SISLVDS) +#define VB_SISEMI (VB_SIS302LV | VB_SIS302ELV | VB_SIS307LV) +#define VB_SISPOWER (VB_SIS301C | VB_SIS307T | VB_SIS302LV | VB_SIS302ELV | VB_SIS307LV) +#define VB_SISDUALLINK (VB_SIS302LV | VB_SIS302ELV | VB_SIS307T | VB_SIS307LV) +#define VB_SISVGA2 VB_SISTMDS +#define VB_SISRAMDAC202 (VB_SIS301C | VB_SIS307T) /* VBInfo */ #define SetSimuScanMode 0x0001 /* CR 30 */ @@ -160,6 +174,7 @@ #define SupportRAMDAC2_202 0x0400 /* C (<= 202Mhz) */ #define InterlaceMode 0x0080 #define SyncPP 0x0000 +#define HaveWideTiming 0x2000 /* Have specific wide- and non-wide timing */ #define SyncPN 0x4000 #define SyncNP 0x8000 #define SyncNN 0xc000 @@ -188,6 +203,7 @@ #define TVSetTVSimuMode 0x0200 /* new 0x200, prev. 0x800 */ #define TVRPLLDIV2XO 0x0400 /* prev 0x1000 */ #define TVSetNTSC1024 0x0800 /* new 0x100, prev. 0x2000 */ +#define TVSet525p1024 0x1000 /* TW */ #define TVAspect43 0x2000 #define TVAspect169 0x4000 #define TVAspect43LB 0x8000 @@ -208,7 +224,8 @@ #define SF_IsM661 0x0020 #define SF_IsM741 0x0040 #define SF_IsM760 0x0080 -#define SF_760LFB 0x8000 /* 760: We have LFB */ +#define SF_760UMA 0x4000 /* 76x: We have UMA */ +#define SF_760LFB 0x8000 /* 76x: We have LFB */ /* CR32 (Newer 630, and 315 series) @@ -228,25 +245,19 @@ #define TVOverScanShift 4 /* CR35 (661 series only) - [0] 1 = PAL, 0 = NTSC [1] 1 = NTSC-J (if D0 = 0) [2] 1 = PALM (if D0 = 1) [3] 1 = PALN (if D0 = 1) [4] 1 = Overscan (Chrontel only) [7:5] (only if D2 in CR38 is set) - 000 525i - 001 525p + 000 525i + 001 525p 010 750p 011 1080i (or HiVision on 301, 301B) - - These bits are being translated to TVMode flag. - */ -/* - CR37 - +/* CR37 [0] Set 24/18 bit (0/1) RGB to LVDS/TMDS transmitter (set by BIOS) [3:1] External chip 300 series: @@ -260,7 +271,7 @@ 010 LVDS 011 LVDS + Chrontel 7019 660 series [2:1] only: - reserved (now in CR38) + reserved (chip type now in CR38) All other combinations reserved [3] 661 only: Pass 1:1 data [4] LVDS: 0: Panel Link expands / 1: Panel Link does not expand @@ -320,6 +331,7 @@ #define Enable302LV_DualLink 0x04 /* 302LV only; enable dual link */ /* CR39 (661 and later) + D[7] LVDS (SiS or third party) D[1:0] YPbPr Aspect Ratio 00 4:3 letterbox 01 4:3 @@ -341,7 +353,7 @@ 0101 Set Contrast event 0110 Set Mute event 0111 Set Volume Up/Down event - [4] Enable Backlight Control by BIOS/driver + [4] Enable Backlight Control by BIOS/driver (set by driver; set means that the BIOS should not touch the backlight registers because eg. the driver already switched off the backlight) @@ -350,6 +362,26 @@ [7] TV UnderScan/OverScan (set by BIOS) */ +/* CR7C - 661 and later + [7] DualEdge enabled (or: to be enabled) + [6] CRT2 = TV/LCD/VGA enabled (or: to be enabled) + [5] Init done (set at end of SiS_Init) + {4] LVDS LCD capabilities + [3] LVDS LCD capabilities + [2] LVDS LCD capabilities (PWD) + [1] LVDS LCD capabilities (PWD) + [0] LVDS=1, TMDS=0 (SiS or third party) +*/ + +/* CR7E - 661 and later + VBType: + [7] LVDS (third party) + [3] 301C + [2] 302LV + [1] 301LV + [0] 301B +*/ + /* LCDResInfo */ #define Panel300_800x600 0x01 /* CR36 */ #define Panel300_1024x768 0x02 @@ -359,7 +391,6 @@ #define Panel300_1024x600 0x06 #define Panel300_1152x768 0x07 #define Panel300_1280x768 0x0a -#define Panel300_320x480 0x0e /* fstn - This is fake, can be any */ #define Panel300_Custom 0x0f #define Panel300_Barco1366 0x10 @@ -374,9 +405,9 @@ #define Panel310_1400x1050 0x09 #define Panel310_1280x768 0x0a #define Panel310_1600x1200 0x0b -#define Panel310_640x480_2 0x0c -#define Panel310_640x480_3 0x0d -#define Panel310_320x480 0x0e /* fstn - TW: This is fake, can be any */ +#define Panel310_320x240_2 0x0c /* xSTN */ +#define Panel310_320x240_3 0x0d /* xSTN */ +#define Panel310_320x240_1 0x0e /* xSTN - This is fake, can be any */ #define Panel310_Custom 0x0f #define Panel661_800x600 0x01 @@ -386,7 +417,7 @@ #define Panel661_1024x600 0x05 #define Panel661_1152x864 0x06 #define Panel661_1280x960 0x07 -#define Panel661_1152x768 0x08 +#define Panel661_1280x854 0x08 #define Panel661_1400x1050 0x09 #define Panel661_1280x768 0x0a #define Panel661_1600x1200 0x0b @@ -410,14 +441,16 @@ #define Panel_1680x1050 0x0d /* 661etc */ #define Panel_1280x720 0x0e /* 661etc */ #define Panel_Custom 0x0f /* MUST BE 0x0f (for DVI DDC detection) */ -#define Panel_320x480 0x10 /* SiS 550 fstn - TW: This is fake, can be any */ +#define Panel_320x240_1 0x10 /* SiS 550 xSTN */ #define Panel_Barco1366 0x11 #define Panel_848x480 0x12 -#define Panel_640x480_2 0x13 /* SiS 550 */ -#define Panel_640x480_3 0x14 /* SiS 550 */ +#define Panel_320x240_2 0x13 /* SiS 550 xSTN */ +#define Panel_320x240_3 0x14 /* SiS 550 xSTN */ #define Panel_1280x768_2 0x15 /* 30xLV */ #define Panel_1280x768_3 0x16 /* (unused) */ #define Panel_1280x800_2 0x17 /* 30xLV */ +#define Panel_856x480 0x18 +#define Panel_1280x854 0x19 /* 661etc */ /* Index in ModeResInfo table */ #define SIS_RI_320x200 0 @@ -454,6 +487,7 @@ #define SIS_RI_1920x1080 31 #define SIS_RI_960x540 32 #define SIS_RI_960x600 33 +#define SIS_RI_1280x854 34 /* CR5F */ #define IsM650 0x80 @@ -482,16 +516,18 @@ #define VCLK100_300 0x43 /* Index in VCLKData table (300) */ #define VCLK34_300 0x3d /* Index in VCLKData table (300) */ #define VCLK_CUSTOM_300 0x47 -#define VCLK65_315 0x0b /* Index in (VB)VCLKData table (315) */ -#define VCLK108_2_315 0x19 /* Index in (VB)VCLKData table (315) */ -#define VCLK81_315 0x5b /* Index in (VB)VCLKData table (315) */ -#define VCLK162_315 0x5e /* Index in (VB)VCLKData table (315) */ -#define VCLK108_3_315 0x45 /* Index in VBVCLKData table (315) */ -#define VCLK100_315 0x46 /* Index in VBVCLKData table (315) */ + +#define VCLK65_315 0x0b /* Indices in (VB)VCLKData table (315) */ +#define VCLK108_2_315 0x19 +#define VCLK81_315 0x5b +#define VCLK162_315 0x5e +#define VCLK108_3_315 0x45 +#define VCLK100_315 0x46 #define VCLK34_315 0x55 #define VCLK68_315 0x0d -#define VCLK_1280x800_315_2 0x5c /* Index in VBVCLKData table (315) */ -#define VCLK121_315 0x5d /* Index in VBVCLKData table (315) */ +#define VCLK_1280x800_315_2 0x5c +#define VCLK121_315 0x5d +#define VCLK130_315 0x72 #define VCLK_1280x720 0x5f #define VCLK_1280x768_2 0x60 #define VCLK_1280x768_3 0x61 /* (unused?) */ @@ -507,6 +543,7 @@ #define VCLK_1152x864 0x64 #define VCLK_1360x768 0x58 #define VCLK_1280x800_315 0x6c +#define VCLK_1280x854 0x76 #define TVCLKBASE_300 0x21 /* Indices on TV clocks in VCLKData table (300) */ #define TVCLKBASE_315 0x3a /* Indices on TV clocks in (VB)VCLKData table (315) */ diff --git a/drivers/video/sis/initextlfb.c b/drivers/video/sis/initextlfb.c new file mode 100644 index 00000000000..cc856d90903 --- /dev/null +++ b/drivers/video/sis/initextlfb.c @@ -0,0 +1,238 @@ +/* + * SiS 300/540/630[S]/730[S] + * SiS 315[E|PRO]/550/[M]65x/[M]66x[F|M|G]X/[M]74x[GX]/330/[M]76x[GX] + * XGI V3XT/V5/V8, Z7 + * frame buffer driver for Linux kernels >= 2.4.14 and >=2.6.3 + * + * Linux kernel specific extensions to init.c/init301.c + * + * Copyright (C) 2001-2005 Thomas Winischhofer, Vienna, Austria. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the named License, + * or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + * + * Author: Thomas Winischhofer <thomas@winischhofer.net> + */ + +#include "osdef.h" +#include "initdef.h" +#include "vgatypes.h" +#include "vstruct.h" + +#include <linux/config.h> +#include <linux/version.h> +#include <linux/types.h> +#include <linux/fb.h> + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) +int sisfb_mode_rate_to_dclock(struct SiS_Private *SiS_Pr, + unsigned char modeno, unsigned char rateindex); +int sisfb_mode_rate_to_ddata(struct SiS_Private *SiS_Pr, unsigned char modeno, + unsigned char rateindex, struct fb_var_screeninfo *var); +#endif +BOOLEAN sisfb_gettotalfrommode(struct SiS_Private *SiS_Pr, unsigned char modeno, + int *htotal, int *vtotal, unsigned char rateindex); + +extern BOOLEAN SiSInitPtr(struct SiS_Private *SiS_Pr); +extern BOOLEAN SiS_SearchModeID(struct SiS_Private *SiS_Pr, unsigned short *ModeNo, + unsigned short *ModeIdIndex); +extern void SiS_Generic_ConvertCRData(struct SiS_Private *SiS_Pr, unsigned char *crdata, + int xres, int yres, struct fb_var_screeninfo *var, BOOLEAN writeres); + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) +int +sisfb_mode_rate_to_dclock(struct SiS_Private *SiS_Pr, unsigned char modeno, + unsigned char rateindex) +{ + unsigned short ModeNo = modeno; + unsigned short ModeIdIndex = 0, ClockIndex = 0; + unsigned short RRTI = 0; + int Clock; + + if(!SiSInitPtr(SiS_Pr)) return 65000; + + if(rateindex > 0) rateindex--; + +#ifdef SIS315H + switch(ModeNo) { + case 0x5a: ModeNo = 0x50; break; + case 0x5b: ModeNo = 0x56; + } +#endif + + if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) {; + printk(KERN_ERR "Could not find mode %x\n", ModeNo); + return 65000; + } + + RRTI = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex; + + if(SiS_Pr->SiS_RefIndex[RRTI].Ext_InfoFlag & HaveWideTiming) { + if(SiS_Pr->SiS_UseWide == 1) { + /* Wide screen: Ignore rateindex */ + ClockIndex = SiS_Pr->SiS_RefIndex[RRTI].Ext_CRTVCLK_WIDE; + } else { + RRTI += rateindex; + ClockIndex = SiS_Pr->SiS_RefIndex[RRTI].Ext_CRTVCLK_NORM; + } + } else { + RRTI += rateindex; + ClockIndex = SiS_Pr->SiS_RefIndex[RRTI].Ext_CRTVCLK; + } + + Clock = SiS_Pr->SiS_VCLKData[ClockIndex].CLOCK * 1000; + + return Clock; +} + +int +sisfb_mode_rate_to_ddata(struct SiS_Private *SiS_Pr, unsigned char modeno, + unsigned char rateindex, struct fb_var_screeninfo *var) +{ + unsigned short ModeNo = modeno; + unsigned short ModeIdIndex = 0, index = 0, RRTI = 0; + int j; + + if(!SiSInitPtr(SiS_Pr)) return 0; + + if(rateindex > 0) rateindex--; + +#ifdef SIS315H + switch(ModeNo) { + case 0x5a: ModeNo = 0x50; break; + case 0x5b: ModeNo = 0x56; + } +#endif + + if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return 0; + + RRTI = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex; + if(SiS_Pr->SiS_RefIndex[RRTI].Ext_InfoFlag & HaveWideTiming) { + if(SiS_Pr->SiS_UseWide == 1) { + /* Wide screen: Ignore rateindex */ + index = SiS_Pr->SiS_RefIndex[RRTI].Ext_CRT1CRTC_WIDE; + } else { + RRTI += rateindex; + index = SiS_Pr->SiS_RefIndex[RRTI].Ext_CRT1CRTC_NORM; + } + } else { + RRTI += rateindex; + index = SiS_Pr->SiS_RefIndex[RRTI].Ext_CRT1CRTC; + } + + SiS_Generic_ConvertCRData(SiS_Pr, + (unsigned char *)&SiS_Pr->SiS_CRT1Table[index].CR[0], + SiS_Pr->SiS_RefIndex[RRTI].XRes, + SiS_Pr->SiS_RefIndex[RRTI].YRes, + var, FALSE); + + if(SiS_Pr->SiS_RefIndex[RRTI].Ext_InfoFlag & 0x8000) + var->sync &= ~FB_SYNC_VERT_HIGH_ACT; + else + var->sync |= FB_SYNC_VERT_HIGH_ACT; + + if(SiS_Pr->SiS_RefIndex[RRTI].Ext_InfoFlag & 0x4000) + var->sync &= ~FB_SYNC_HOR_HIGH_ACT; + else + var->sync |= FB_SYNC_HOR_HIGH_ACT; + + var->vmode = FB_VMODE_NONINTERLACED; + if(SiS_Pr->SiS_RefIndex[RRTI].Ext_InfoFlag & 0x0080) + var->vmode = FB_VMODE_INTERLACED; + else { + j = 0; + while(SiS_Pr->SiS_EModeIDTable[j].Ext_ModeID != 0xff) { + if(SiS_Pr->SiS_EModeIDTable[j].Ext_ModeID == + SiS_Pr->SiS_RefIndex[RRTI].ModeID) { + if(SiS_Pr->SiS_EModeIDTable[j].Ext_ModeFlag & DoubleScanMode) { + var->vmode = FB_VMODE_DOUBLE; + } + break; + } + j++; + } + } + + if((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { +#if 0 /* Do this? */ + var->upper_margin <<= 1; + var->lower_margin <<= 1; + var->vsync_len <<= 1; +#endif + } else if((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) { + var->upper_margin >>= 1; + var->lower_margin >>= 1; + var->vsync_len >>= 1; + } + + return 1; +} +#endif /* Linux >= 2.5 */ + +BOOLEAN +sisfb_gettotalfrommode(struct SiS_Private *SiS_Pr, unsigned char modeno, int *htotal, + int *vtotal, unsigned char rateindex) +{ + unsigned short ModeNo = modeno; + unsigned short ModeIdIndex = 0, CRT1Index = 0; + unsigned short RRTI = 0; + unsigned char sr_data, cr_data, cr_data2; + + if(!SiSInitPtr(SiS_Pr)) return FALSE; + + if(rateindex > 0) rateindex--; + +#ifdef SIS315H + switch(ModeNo) { + case 0x5a: ModeNo = 0x50; break; + case 0x5b: ModeNo = 0x56; + } +#endif + + if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return FALSE; + + RRTI = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex; + if(SiS_Pr->SiS_RefIndex[RRTI].Ext_InfoFlag & HaveWideTiming) { + if(SiS_Pr->SiS_UseWide == 1) { + /* Wide screen: Ignore rateindex */ + CRT1Index = SiS_Pr->SiS_RefIndex[RRTI].Ext_CRT1CRTC_WIDE; + } else { + RRTI += rateindex; + CRT1Index = SiS_Pr->SiS_RefIndex[RRTI].Ext_CRT1CRTC_NORM; + } + } else { + RRTI += rateindex; + CRT1Index = SiS_Pr->SiS_RefIndex[RRTI].Ext_CRT1CRTC; + } + + sr_data = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[14]; + cr_data = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[0]; + *htotal = (((cr_data & 0xff) | ((unsigned short) (sr_data & 0x03) << 8)) + 5) * 8; + + sr_data = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[13]; + cr_data = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[6]; + cr_data2 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[7]; + *vtotal = ((cr_data & 0xFF) | + ((unsigned short)(cr_data2 & 0x01) << 8) | + ((unsigned short)(cr_data2 & 0x20) << 4) | + ((unsigned short)(sr_data & 0x01) << 10)) + 2; + + if(SiS_Pr->SiS_RefIndex[RRTI].Ext_InfoFlag & InterlaceMode) + *vtotal *= 2; + + return TRUE; +} + + + diff --git a/drivers/video/sis/oem300.h b/drivers/video/sis/oem300.h index b1358b750f5..b73f2684014 100644 --- a/drivers/video/sis/oem300.h +++ b/drivers/video/sis/oem300.h @@ -3,7 +3,7 @@ /* * OEM Data for 300 series * - * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2005 by Thomas Winischhofer, Vienna, Austria * * If distributed as part of the Linux kernel, the following license terms * apply: @@ -50,7 +50,7 @@ * */ -static const UCHAR SiS300_OEMTVDelay301[8][4] = +static const unsigned char SiS300_OEMTVDelay301[8][4] = { {0x08,0x08,0x08,0x08}, {0x08,0x08,0x08,0x08}, @@ -62,7 +62,7 @@ static const UCHAR SiS300_OEMTVDelay301[8][4] = {0x20,0x20,0x20,0x20} }; -static const UCHAR SiS300_OEMTVDelayLVDS[8][4] = +static const unsigned char SiS300_OEMTVDelayLVDS[8][4] = { {0x20,0x20,0x20,0x20}, {0x20,0x20,0x20,0x20}, @@ -74,7 +74,7 @@ static const UCHAR SiS300_OEMTVDelayLVDS[8][4] = {0x20,0x20,0x20,0x20} }; -static const UCHAR SiS300_OEMTVFlicker[8][4] = +static const unsigned char SiS300_OEMTVFlicker[8][4] = { {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, @@ -86,25 +86,7 @@ static const UCHAR SiS300_OEMTVFlicker[8][4] = {0x00,0x00,0x00,0x00} }; -#if 0 /* TW: Not used */ -static const UCHAR SiS300_OEMLCDDelay1[12][4]={ - {0x2c,0x2c,0x2c,0x2c}, - {0x20,0x20,0x20,0x20}, - {0x20,0x20,0x20,0x20}, - {0x2c,0x2c,0x2c,0x2c}, - {0x2c,0x2c,0x2c,0x2c}, - {0x20,0x20,0x20,0x20}, - {0x20,0x20,0x20,0x20}, - {0x24,0x24,0x24,0x24}, - {0x24,0x24,0x24,0x24}, - {0x20,0x20,0x20,0x20}, - {0x20,0x20,0x20,0x20}, - {0x24,0x24,0x24,0x24} -}; -#endif - -/* From 630/301B BIOS */ -static const UCHAR SiS300_OEMLCDDelay2[64][4] = /* for 301/301b/302b/301LV/302LV */ +static const unsigned char SiS300_OEMLCDDelay2[64][4] = /* for 301/301b/302b/301LV/302LV */ { {0x20,0x20,0x20,0x20}, {0x20,0x20,0x20,0x20}, @@ -172,8 +154,7 @@ static const UCHAR SiS300_OEMLCDDelay2[64][4] = /* for 301/301b/302b/301LV/302 {0x20,0x20,0x20,0x20} }; -/* From 300/301LV BIOS */ -static const UCHAR SiS300_OEMLCDDelay4[12][4] = +static const unsigned char SiS300_OEMLCDDelay4[12][4] = { {0x2c,0x2c,0x2c,0x2c}, {0x20,0x20,0x20,0x20}, @@ -189,8 +170,7 @@ static const UCHAR SiS300_OEMLCDDelay4[12][4] = {0x24,0x24,0x24,0x24} }; -/* From 300/301LV BIOS */ -static const UCHAR SiS300_OEMLCDDelay5[32][4] = +static const unsigned char SiS300_OEMLCDDelay5[32][4] = { {0x20,0x20,0x20,0x20}, {0x20,0x20,0x20,0x20}, @@ -226,8 +206,8 @@ static const UCHAR SiS300_OEMLCDDelay5[32][4] = {0x20,0x20,0x20,0x20}, }; -/* Added for LVDS */ -static const UCHAR SiS300_OEMLCDDelay3[64][4] = { /* For LVDS */ +static const unsigned char SiS300_OEMLCDDelay3[64][4] = /* For LVDS */ +{ {0x20,0x20,0x20,0x20}, {0x20,0x20,0x20,0x20}, {0x20,0x20,0x20,0x20}, @@ -294,7 +274,7 @@ static const UCHAR SiS300_OEMLCDDelay3[64][4] = { /* For LVDS */ {0x20,0x20,0x20,0x20} }; -static const UCHAR SiS300_Phase1[8][5][4] = +static const unsigned char SiS300_Phase1[8][5][4] = { { {0x21,0xed,0x00,0x08}, @@ -354,11 +334,10 @@ static const UCHAR SiS300_Phase1[8][5][4] = } }; - -static const UCHAR SiS300_Phase2[8][5][4] = +static const unsigned char SiS300_Phase2[8][5][4] = { { - {0x21,0xed,0x00,0x08}, + {0x21,0xed,0x00,0x08}, {0x21,0xed,0x8a,0x08}, {0x21,0xed,0x8a,0x08}, {0x21,0xed,0x8a,0x08}, @@ -372,42 +351,42 @@ static const UCHAR SiS300_Phase2[8][5][4] = {0x2a,0x05,0xd3,0x00} }, { - {0x2a,0x05,0xd3,0x00}, + {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00} }, { - {0x2a,0x05,0xd3,0x00}, + {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00} }, { - {0x21,0xed,0x00,0x08}, + {0x21,0xed,0x00,0x08}, {0x21,0xed,0x8a,0x08}, {0x21,0xed,0x8a,0x08}, {0x21,0xed,0x8a,0x08}, {0x21,0xed,0x8a,0x08} }, { - {0x2a,0x05,0xd3,0x00}, + {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00} }, { - {0x2a,0x05,0xd3,0x00}, + {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00} }, { - {0x2a,0x05,0xd3,0x00}, + {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00}, @@ -415,7 +394,7 @@ static const UCHAR SiS300_Phase2[8][5][4] = } }; -static const UCHAR SiS300_Filter1[10][16][4] = +static const unsigned char SiS300_Filter1[10][16][4] = { { {0x00,0xf4,0x10,0x38}, @@ -599,7 +578,7 @@ static const UCHAR SiS300_Filter1[10][16][4] = }, }; -static const UCHAR SiS300_Filter2[10][9][7] = +static const unsigned char SiS300_Filter2[10][9][7] = { { {0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46}, @@ -714,142 +693,144 @@ static const UCHAR SiS300_Filter2[10][9][7] = }; /* Custom data for Barco iQ Pro R300 */ -static const UCHAR barco_p1[2][9][7][3] = { - { - { { 0x16, 0xcf, 0x00 }, - { 0x18, 0x00, 0x00 }, - { 0x1a, 0xe7, 0x00 }, - { 0x1b, 0x26, 0x00 }, - { 0x1c, 0xff, 0x00 }, - { 0x1d, 0x1c, 0x00 }, - { 0x1e, 0x19, 0x00 } - }, - { - { 0x16, 0xcf, 0x00 }, - { 0x18, 0x00, 0x00 }, - { 0x1a, 0xe7, 0x00 }, - { 0x1b, 0x1e, 0x00 }, - { 0x1c, 0xff, 0x00 }, - { 0x1d, 0x1c, 0x00 }, - { 0x1e, 0x16, 0x00 } - }, - { - { 0x16, 0xcf, 0x00 }, - { 0x1a, 0xe7, 0x00 }, - { 0x1b, 0x26, 0x00 }, - { 0x1c, 0xff, 0x00 }, - { 0x1d, 0x1c, 0x00 }, - { 0x1e, 0x19, 0x00 }, - { 0, 0, 0 } - }, - { - { 0, 0, 0 } - }, - { - { 0x16, 0xcf, 0x00 }, - { 0x1a, 0xe7, 0x00 }, - { 0x1b, 0x26, 0x00 }, - { 0x1c, 0xff, 0x00 }, - { 0x1d, 0x1c, 0x00 }, - { 0x1e, 0x1e, 0x00 }, - { 0, 0, 0 } - }, - { - { 0x16, 0xd1, 0x00 }, - { 0x18, 0x00, 0x00 }, - { 0x1a, 0xe7, 0x00 }, - { 0x1b, 0x11, 0x00 }, - { 0x1c, 0xff, 0x00 }, - { 0x1d, 0x1c, 0x00 }, - { 0x1e, 0x26, 0x00 } - }, - { - { 0x16, 0xd1, 0x00 }, - { 0x1a, 0xe7, 0x00 }, - { 0x1b, 0x26, 0x00 }, - { 0x1c, 0xff, 0x00 }, - { 0x1d, 0x1c, 0x00 }, - { 0x1e, 0x30, 0x00 }, - { 0, 0, 0 } - }, - { - { 0x16, 0x00, 0x00 }, - { 0x17, 0xa0, 0x00 }, - { 0x1a, 0xa0, 0x00 }, - { 0x1b, 0x2a, 0x00 }, - { 0x1c, 0xff, 0x00 }, - { 0x1d, 0x1c, 0x00 }, - { 0, 0, 0 } - }, - { - { 0x16, 0x00, 0x00 }, - { 0x17, 0xaa, 0x00 }, - { 0x1a, 0xa0, 0x00 }, - { 0x1b, 0x2a, 0x00 }, - { 0x1c, 0xff, 0x00 }, - { 0x1d, 0x1c, 0x00 }, - { 0, 0, 0 } - } - }, - { - { - { 0x16, 0xcf, 0x00 }, - { 0x18, 0x00, 0x00 }, - { 0x1a, 0xe7, 0x00 }, - { 0x1b, 0x26, 0x00 }, - { 0x1c, 0xff, 0x00 }, - { 0x1d, 0x1c, 0x00 }, - { 0x1e, 0x19, 0x00 } - }, - { - { 0, 0, 0 } - }, - { - { 0x16, 0xcf, 0x00 }, - { 0x18, 0x00, 0x00 }, - { 0x1a, 0xe7, 0x00 }, - { 0x1b, 0x26, 0x00 }, - { 0x1c, 0xff, 0x00 }, - { 0x1d, 0x1c, 0x00 }, - { 0x1e, 0x19, 0x00 }, - }, - { - { 0, 0, 0 } - }, - { - { 0x16, 0xcf, 0x00 }, - { 0x18, 0x00, 0x00 }, - { 0x1a, 0xe7, 0x00 }, - { 0x1b, 0x26, 0x00 }, - { 0x1c, 0xff, 0x00 }, - { 0x1d, 0x1c, 0x00 }, - { 0x1e, 0x1e, 0x00 } - }, - { - { 0x16, 0xd1, 0x00 }, - { 0x18, 0x00, 0x00 }, - { 0x1a, 0xe6, 0x00 }, - { 0x1b, 0x11, 0x00 }, - { 0x1c, 0xff, 0x00 }, - { 0x1d, 0x1c, 0x00 }, - { 0x1e, 0x26, 0x00 } - }, - { - { 0x18, 0x00, 0x00 }, - { 0x1a, 0xe0, 0x00 }, - { 0x1b, 0x26, 0x00 }, - { 0x1c, 0xff, 0x00 }, - { 0x1d, 0x1c, 0x00 }, - { 0x1e, 0x30, 0x00 }, - { 0, 0, 0 } - }, - { - { 0, 0, 0 } - }, - { - { 0, 0, 0 } - } - } +static const unsigned char barco_p1[2][9][7][3] = +{ + { + { + { 0x16, 0xcf, 0x00 }, + { 0x18, 0x00, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x26, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x19, 0x00 } + }, + { + { 0x16, 0xcf, 0x00 }, + { 0x18, 0x00, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x1e, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x16, 0x00 } + }, + { + { 0x16, 0xcf, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x26, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x19, 0x00 }, + { 0, 0, 0 } + }, + { + { 0, 0, 0 } + }, + { + { 0x16, 0xcf, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x26, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x1e, 0x00 }, + { 0, 0, 0 } + }, + { + { 0x16, 0xd1, 0x00 }, + { 0x18, 0x00, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x11, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x26, 0x00 } + }, + { + { 0x16, 0xd1, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x26, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x30, 0x00 }, + { 0, 0, 0 } + }, + { + { 0x16, 0x00, 0x00 }, + { 0x17, 0xa0, 0x00 }, + { 0x1a, 0xa0, 0x00 }, + { 0x1b, 0x2a, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0, 0, 0 } + }, + { + { 0x16, 0x00, 0x00 }, + { 0x17, 0xaa, 0x00 }, + { 0x1a, 0xa0, 0x00 }, + { 0x1b, 0x2a, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0, 0, 0 } + } + }, + { + { + { 0x16, 0xcf, 0x00 }, + { 0x18, 0x00, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x26, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x19, 0x00 } + }, + { + { 0, 0, 0 } + }, + { + { 0x16, 0xcf, 0x00 }, + { 0x18, 0x00, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x26, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x19, 0x00 }, + }, + { + { 0, 0, 0 } + }, + { + { 0x16, 0xcf, 0x00 }, + { 0x18, 0x00, 0x00 }, + { 0x1a, 0xe7, 0x00 }, + { 0x1b, 0x26, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x1e, 0x00 } + }, + { + { 0x16, 0xd1, 0x00 }, + { 0x18, 0x00, 0x00 }, + { 0x1a, 0xe6, 0x00 }, + { 0x1b, 0x11, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x26, 0x00 } + }, + { + { 0x18, 0x00, 0x00 }, + { 0x1a, 0xe0, 0x00 }, + { 0x1b, 0x26, 0x00 }, + { 0x1c, 0xff, 0x00 }, + { 0x1d, 0x1c, 0x00 }, + { 0x1e, 0x30, 0x00 }, + { 0, 0, 0 } + }, + { + { 0, 0, 0 } + }, + { + { 0, 0, 0 } + } + } }; diff --git a/drivers/video/sis/oem310.h b/drivers/video/sis/oem310.h index 2b7db916b7e..8fce56e4482 100644 --- a/drivers/video/sis/oem310.h +++ b/drivers/video/sis/oem310.h @@ -1,9 +1,9 @@ /* $XFree86$ */ /* $XdotOrg$ */ /* - * OEM Data for 315/330 series + * OEM Data for 315/330/340 series * - * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2005 by Thomas Winischhofer, Vienna, Austria * * If distributed as part of the Linux kernel, the following license terms * apply: @@ -50,206 +50,206 @@ * */ -static const UCHAR SiS310_LCDDelayCompensation_301[] = /* 301 */ +static const unsigned char SiS310_LCDDelayCompensation_301[] = /* 301 */ { - 0x00,0x00,0x00, /* 800x600 */ - 0x0b,0x0b,0x0b, /* 1024x768 */ - 0x08,0x08,0x08, /* 1280x1024 */ - 0x00,0x00,0x00, /* 640x480 (unknown) */ - 0x00,0x00,0x00, /* 1024x600 (unknown) */ - 0x00,0x00,0x00, /* 1152x864 (unknown) */ - 0x08,0x08,0x08, /* 1280x960 (guessed) */ - 0x00,0x00,0x00, /* 1152x768 (unknown) */ - 0x08,0x08,0x08, /* 1400x1050 */ - 0x08,0x08,0x08, /* 1280x768 (guessed) */ - 0x00,0x00,0x00, /* 1600x1200 */ - 0x00,0x00,0x00, /* 320x480 (unknown) */ - 0x00,0x00,0x00, - 0x00,0x00,0x00, - 0x00,0x00,0x00 + 0x00,0x00,0x00, /* 800x600 */ + 0x0b,0x0b,0x0b, /* 1024x768 */ + 0x08,0x08,0x08, /* 1280x1024 */ + 0x00,0x00,0x00, /* 640x480 (unknown) */ + 0x00,0x00,0x00, /* 1024x600 (unknown) */ + 0x00,0x00,0x00, /* 1152x864 (unknown) */ + 0x08,0x08,0x08, /* 1280x960 (guessed) */ + 0x00,0x00,0x00, /* 1152x768 (unknown) */ + 0x08,0x08,0x08, /* 1400x1050 */ + 0x08,0x08,0x08, /* 1280x768 (guessed) */ + 0x00,0x00,0x00, /* 1600x1200 */ + 0x00,0x00,0x00, /* 320x480 (unknown) */ + 0x00,0x00,0x00, + 0x00,0x00,0x00, + 0x00,0x00,0x00 }; /* This is contained in 650+301B BIOSes, but it is wrong - so we don't use it */ -static const UCHAR SiS310_LCDDelayCompensation_650301LV[] = /* 650 + 30xLV */ +static const unsigned char SiS310_LCDDelayCompensation_650301LV[] = /* 650 + 30xLV */ { - 0x01,0x01,0x01, /* 800x600 */ - 0x01,0x01,0x01, /* 1024x768 */ - 0x01,0x01,0x01, /* 1280x1024 */ - 0x01,0x01,0x01, /* 640x480 (unknown) */ - 0x01,0x01,0x01, /* 1024x600 (unknown) */ - 0x01,0x01,0x01, /* 1152x864 (unknown) */ - 0x01,0x01,0x01, /* 1280x960 (guessed) */ - 0x01,0x01,0x01, /* 1152x768 (unknown) */ - 0x01,0x01,0x01, /* 1400x1050 */ - 0x01,0x01,0x01, /* 1280x768 (guessed) */ - 0x01,0x01,0x01, /* 1600x1200 */ - 0x02,0x02,0x02, - 0x02,0x02,0x02, - 0x02,0x02,0x02, - 0x02,0x02,0x02 + 0x01,0x01,0x01, /* 800x600 */ + 0x01,0x01,0x01, /* 1024x768 */ + 0x01,0x01,0x01, /* 1280x1024 */ + 0x01,0x01,0x01, /* 640x480 (unknown) */ + 0x01,0x01,0x01, /* 1024x600 (unknown) */ + 0x01,0x01,0x01, /* 1152x864 (unknown) */ + 0x01,0x01,0x01, /* 1280x960 (guessed) */ + 0x01,0x01,0x01, /* 1152x768 (unknown) */ + 0x01,0x01,0x01, /* 1400x1050 */ + 0x01,0x01,0x01, /* 1280x768 (guessed) */ + 0x01,0x01,0x01, /* 1600x1200 */ + 0x02,0x02,0x02, + 0x02,0x02,0x02, + 0x02,0x02,0x02, + 0x02,0x02,0x02 }; -static const UCHAR SiS310_LCDDelayCompensation_651301LV[] = /* M650/651 301LV */ +static const unsigned char SiS310_LCDDelayCompensation_651301LV[] = /* M650/651 301LV */ { - 0x33,0x33,0x33, /* 800x600 (guessed) - new: PanelType, not PanelRes ! */ - 0x33,0x33,0x33, /* 1024x768 */ - 0x33,0x33,0x33, /* 1280x1024 */ - 0x33,0x33,0x33, /* 640x480 (unknown) */ - 0x33,0x33,0x33, /* 1024x600 (unknown) */ - 0x33,0x33,0x33, /* 1152x864 (unknown) */ - 0x33,0x33,0x33, /* 1280x960 (guessed) */ - 0x33,0x33,0x33, /* 1152x768 (unknown) */ - 0x33,0x33,0x33, /* 1400x1050 */ - 0x33,0x33,0x33, /* 1280x768 (guessed) */ - 0x33,0x33,0x33, /* 1600x1200 */ - 0x33,0x33,0x33, - 0x33,0x33,0x33, - 0x33,0x33,0x33, - 0x33,0x33,0x33 + 0x33,0x33,0x33, /* 800x600 (guessed) - new: PanelType, not PanelRes ! */ + 0x33,0x33,0x33, /* 1024x768 */ + 0x33,0x33,0x33, /* 1280x1024 */ + 0x33,0x33,0x33, /* 640x480 (unknown) */ + 0x33,0x33,0x33, /* 1024x600 (unknown) */ + 0x33,0x33,0x33, /* 1152x864 (unknown) */ + 0x33,0x33,0x33, /* 1280x960 (guessed) */ + 0x33,0x33,0x33, /* 1152x768 (unknown) */ + 0x33,0x33,0x33, /* 1400x1050 */ + 0x33,0x33,0x33, /* 1280x768 (guessed) */ + 0x33,0x33,0x33, /* 1600x1200 */ + 0x33,0x33,0x33, + 0x33,0x33,0x33, + 0x33,0x33,0x33, + 0x33,0x33,0x33 }; -static const UCHAR SiS310_LCDDelayCompensation_651302LV[] = /* M650/651 302LV */ +static const unsigned char SiS310_LCDDelayCompensation_651302LV[] = /* M650/651 302LV */ { - 0x33,0x33,0x33, /* 800x600 (guessed) */ - 0x33,0x33,0x33, /* 1024x768 */ - 0x33,0x33,0x33, /* 1280x1024 */ - 0x33,0x33,0x33, /* 640x480 (unknown) */ - 0x33,0x33,0x33, /* 1024x600 (unknown) */ - 0x33,0x33,0x33, /* 1152x864 (unknown) */ - 0x33,0x33,0x33, /* 1280x960 (guessed) */ - 0x33,0x33,0x33, /* 1152x768 (unknown) */ - 0x33,0x33,0x33, /* 1400x1050 */ - 0x33,0x33,0x33, /* 1280x768 (guessed) */ - 0x33,0x33,0x33, /* 1600x1200 */ - 0x33,0x33,0x33, - 0x33,0x33,0x33, - 0x33,0x33,0x33, - 0x33,0x33,0x33 + 0x33,0x33,0x33, /* 800x600 (guessed) */ + 0x33,0x33,0x33, /* 1024x768 */ + 0x33,0x33,0x33, /* 1280x1024 */ + 0x33,0x33,0x33, /* 640x480 (unknown) */ + 0x33,0x33,0x33, /* 1024x600 (unknown) */ + 0x33,0x33,0x33, /* 1152x864 (unknown) */ + 0x33,0x33,0x33, /* 1280x960 (guessed) */ + 0x33,0x33,0x33, /* 1152x768 (unknown) */ + 0x33,0x33,0x33, /* 1400x1050 */ + 0x33,0x33,0x33, /* 1280x768 (guessed) */ + 0x33,0x33,0x33, /* 1600x1200 */ + 0x33,0x33,0x33, + 0x33,0x33,0x33, + 0x33,0x33,0x33, + 0x33,0x33,0x33 }; -static const UCHAR SiS310_LCDDelayCompensation_3xx301B[] = /* 30xB */ +static const unsigned char SiS310_LCDDelayCompensation_3xx301B[] = /* 30xB */ { - 0x01,0x01,0x01, /* 800x600 */ - 0x0C,0x0C,0x0C, /* 1024x768 */ - 0x0C,0x0C,0x0C, /* 1280x1024 */ - 0x08,0x08,0x08, /* 640x480 */ - 0x0C,0x0C,0x0C, /* 1024x600 (guessed) */ - 0x0C,0x0C,0x0C, /* 1152x864 (guessed) */ - 0x0C,0x0C,0x0C, /* 1280x960 (guessed) */ - 0x0C,0x0C,0x0C, /* 1152x768 (guessed) */ - 0x0C,0x0C,0x0C, /* 1400x1050 (guessed) */ - 0x0C,0x0C,0x0C, /* 1280x768 (guessed) */ - 0x0C,0x0C,0x0C, /* 1600x1200 (guessed) */ - 0x02,0x02,0x02, - 0x02,0x02,0x02, - 0x02,0x02,0x02, - 0x02,0x02,0x02 + 0x01,0x01,0x01, /* 800x600 */ + 0x0C,0x0C,0x0C, /* 1024x768 */ + 0x0C,0x0C,0x0C, /* 1280x1024 */ + 0x08,0x08,0x08, /* 640x480 */ + 0x0C,0x0C,0x0C, /* 1024x600 (guessed) */ + 0x0C,0x0C,0x0C, /* 1152x864 (guessed) */ + 0x0C,0x0C,0x0C, /* 1280x960 (guessed) */ + 0x0C,0x0C,0x0C, /* 1152x768 (guessed) */ + 0x0C,0x0C,0x0C, /* 1400x1050 (guessed) */ + 0x0C,0x0C,0x0C, /* 1280x768 (guessed) */ + 0x0C,0x0C,0x0C, /* 1600x1200 (guessed) */ + 0x02,0x02,0x02, + 0x02,0x02,0x02, + 0x02,0x02,0x02, + 0x02,0x02,0x02 }; -static const UCHAR SiS310_LCDDelayCompensation_3xx301LV[] = /* 315+30xLV */ +static const unsigned char SiS310_LCDDelayCompensation_3xx301LV[] = /* 315+30xLV */ { - 0x01,0x01,0x01, /* 800x600 */ - 0x04,0x04,0x04, /* 1024x768 (A531/BIOS 1.14.05f: 4 - works with 6 */ - 0x0C,0x0C,0x0C, /* 1280x1024 */ - 0x08,0x08,0x08, /* 640x480 */ - 0x0C,0x0C,0x0C, /* 1024x600 (guessed) */ - 0x0C,0x0C,0x0C, /* 1152x864 (guessed) */ - 0x0C,0x0C,0x0C, /* 1280x960 (guessed) */ - 0x0C,0x0C,0x0C, /* 1152x768 (guessed) */ - 0x0C,0x0C,0x0C, /* 1400x1050 (guessed) */ - 0x0C,0x0C,0x0C, /* 1280x768 (guessed) */ - 0x0C,0x0C,0x0C, /* 1600x1200 (guessed) */ - 0x02,0x02,0x02, - 0x02,0x02,0x02, - 0x02,0x02,0x02, - 0x02,0x02,0x02 + 0x01,0x01,0x01, /* 800x600 */ + 0x04,0x04,0x04, /* 1024x768 (A531/BIOS 1.14.05f: 4 - works with 6 */ + 0x0C,0x0C,0x0C, /* 1280x1024 */ + 0x08,0x08,0x08, /* 640x480 */ + 0x0C,0x0C,0x0C, /* 1024x600 (guessed) */ + 0x0C,0x0C,0x0C, /* 1152x864 (guessed) */ + 0x0C,0x0C,0x0C, /* 1280x960 (guessed) */ + 0x0C,0x0C,0x0C, /* 1152x768 (guessed) */ + 0x0C,0x0C,0x0C, /* 1400x1050 (guessed) */ + 0x0C,0x0C,0x0C, /* 1280x768 (guessed) */ + 0x0C,0x0C,0x0C, /* 1600x1200 (guessed) */ + 0x02,0x02,0x02, + 0x02,0x02,0x02, + 0x02,0x02,0x02, + 0x02,0x02,0x02 }; -static const UCHAR SiS310_TVDelayCompensation_301[] = /* 301 */ +static const unsigned char SiS310_TVDelayCompensation_301[] = /* 301 */ { - 0x02,0x02, /* NTSC Enhanced, Standard */ - 0x02,0x02, /* PAL */ - 0x08,0x0b /* HiVision */ + 0x02,0x02, /* NTSC Enhanced, Standard */ + 0x02,0x02, /* PAL */ + 0x08,0x0b /* HiVision */ }; -static const UCHAR SiS310_TVDelayCompensation_301B[] = /* 30xB, 30xLV */ +static const unsigned char SiS310_TVDelayCompensation_301B[] = /* 30xB, 30xLV */ { - 0x03,0x03, - 0x03,0x03, - 0x03,0x03 + 0x03,0x03, + 0x03,0x03, + 0x03,0x03 }; -static const UCHAR SiS310_TVDelayCompensation_740301B[] = /* 740 + 30xB (30xLV?) */ +static const unsigned char SiS310_TVDelayCompensation_740301B[] = /* 740 + 30xB (30xLV?) */ { - 0x05,0x05, - 0x05,0x05, - 0x05,0x05 + 0x05,0x05, + 0x05,0x05, + 0x05,0x05 }; -static const UCHAR SiS310_TVDelayCompensation_651301LV[] = /* M650, 651, 301LV */ +static const unsigned char SiS310_TVDelayCompensation_651301LV[] = /* M650, 651, 301LV */ { - 0x33,0x33, - 0x33,0x33, - 0x33,0x33 + 0x33,0x33, + 0x33,0x33, + 0x33,0x33 }; -static const UCHAR SiS310_TVDelayCompensation_651302LV[] = /* M650, 651, 302LV */ +static const unsigned char SiS310_TVDelayCompensation_651302LV[] = /* M650, 651, 302LV */ { - 0x33,0x33, - 0x33,0x33, - 0x33,0x33 + 0x33,0x33, + 0x33,0x33, + 0x33,0x33 }; -static const UCHAR SiS_TVDelay661_301[] = /* 661, 301 */ +static const unsigned char SiS_TVDelay661_301[] = /* 661, 301 */ { - 0x44,0x44, - 0x44,0x44, - 0x00,0x00, - 0x44,0x44, - 0x44,0x44, - 0x44,0x44 + 0x44,0x44, + 0x44,0x44, + 0x00,0x00, + 0x44,0x44, + 0x44,0x44, + 0x44,0x44 }; -static const UCHAR SiS_TVDelay661_301B[] = /* 661, 301B et al */ +static const unsigned char SiS_TVDelay661_301B[] = /* 661, 301B et al */ { - 0x44,0x44, - 0x44,0x44, - 0x00,0x00, - 0x44,0x44, - 0x44,0x44, - 0x44,0x44 + 0x44,0x44, + 0x44,0x44, + 0x00,0x00, + 0x44,0x44, + 0x44,0x44, + 0x44,0x44 }; -static const UCHAR SiS310_TVDelayCompensation_LVDS[] = /* LVDS */ +static const unsigned char SiS310_TVDelayCompensation_LVDS[] = /* LVDS */ { - 0x0a,0x0a, - 0x0a,0x0a, - 0x0a,0x0a + 0x0a,0x0a, + 0x0a,0x0a, + 0x0a,0x0a }; -static const UCHAR SiS310_TVAntiFlick1[6][2] = +static const unsigned char SiS310_TVAntiFlick1[6][2] = { - {0x4,0x0}, - {0x4,0x8}, - {0x0,0x0}, - {0x0,0x0}, - {0x0,0x0}, - {0x0,0x0} + {0x4,0x0}, + {0x4,0x8}, + {0x0,0x0}, + {0x0,0x0}, + {0x0,0x0}, + {0x0,0x0} }; -static const UCHAR SiS310_TVEdge1[6][2] = +static const unsigned char SiS310_TVEdge1[6][2] = { - {0x0,0x4}, - {0x0,0x4}, - {0x0,0x0}, - {0x0,0x0}, - {0x0,0x0}, - {0x0,0x0} + {0x0,0x4}, + {0x0,0x4}, + {0x0,0x0}, + {0x0,0x0}, + {0x0,0x0}, + {0x0,0x0} }; -static const UCHAR SiS310_TVYFilter1[5][8][4] = +static const unsigned char SiS310_TVYFilter1[5][8][4] = { - { + { {0x00,0xf4,0x10,0x38}, /* NTSC */ {0x00,0xf4,0x10,0x38}, {0xeb,0x04,0x25,0x18}, @@ -258,8 +258,8 @@ static const UCHAR SiS310_TVYFilter1[5][8][4] = {0xeb,0x04,0x25,0x18}, {0xee,0x0c,0x22,0x08}, {0xeb,0x15,0x25,0xf6} - }, - { + }, + { {0x00,0xf4,0x10,0x38}, /* PAL */ {0x00,0xf4,0x10,0x38}, {0xf1,0xf7,0x1f,0x32}, @@ -268,8 +268,8 @@ static const UCHAR SiS310_TVYFilter1[5][8][4] = {0xf1,0xf7,0x1f,0x32}, {0xf3,0x00,0x1d,0x20}, {0xfc,0xfb,0x14,0x2a} - }, - { + }, + { {0x00,0x00,0x00,0x00}, /* HiVision */ {0x00,0xf4,0x10,0x38}, {0x00,0xf4,0x10,0x38}, @@ -278,9 +278,9 @@ static const UCHAR SiS310_TVYFilter1[5][8][4] = {0x00,0xf4,0x10,0x38}, {0xeb,0x04,0x25,0x18}, {0xee,0x0c,0x22,0x08} - }, - { - {0x00,0xf4,0x10,0x38}, /* PAL-M */ + }, + { + {0x00,0xf4,0x10,0x38}, /* PAL-M */ {0x00,0xf4,0x10,0x38}, {0xeb,0x04,0x10,0x18}, {0xf7,0x06,0x19,0x14}, @@ -288,9 +288,9 @@ static const UCHAR SiS310_TVYFilter1[5][8][4] = {0xeb,0x04,0x25,0x18}, {0xeb,0x04,0x25,0x18}, {0xeb,0x15,0x25,0xf6} - }, - { - {0x00,0xf4,0x10,0x38}, /* PAL-N */ + }, + { + {0x00,0xf4,0x10,0x38}, /* PAL-N */ {0x00,0xf4,0x10,0x38}, {0xeb,0x04,0x10,0x18}, {0xf7,0x06,0x19,0x14}, @@ -298,12 +298,12 @@ static const UCHAR SiS310_TVYFilter1[5][8][4] = {0xeb,0x04,0x25,0x18}, {0xeb,0x04,0x25,0x18}, {0xeb,0x15,0x25,0xf6} - } + } }; -static const UCHAR SiS310_TVYFilter2[5][9][7] = +static const unsigned char SiS310_TVYFilter2[5][9][7] = { - { + { {0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46}, /* NTSC */ {0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C}, {0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46}, @@ -313,8 +313,8 @@ static const UCHAR SiS310_TVYFilter2[5][9][7] = {0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C}, {0x01,0x01,0xFC,0xF8,0x08,0x26,0x38}, {0xFF,0xFF,0xFC,0x00,0x0F,0x22,0x28} - }, - { + }, + { {0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46}, /* PAL */ {0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C}, {0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46}, @@ -324,8 +324,8 @@ static const UCHAR SiS310_TVYFilter2[5][9][7] = {0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C}, {0x01,0x01,0xFC,0xF8,0x08,0x26,0x38}, {0xFF,0xFF,0xFC,0x00,0x0F,0x22,0x28} - }, - { + }, + { {0x00,0x00,0x00,0xF4,0xFF,0x1C,0x22}, /* HiVision */ {0x00,0x00,0x00,0xF4,0xFF,0x1C,0x22}, {0x00,0x00,0x00,0xF4,0xFF,0x1C,0x22}, @@ -335,9 +335,9 @@ static const UCHAR SiS310_TVYFilter2[5][9][7] = {0x00,0x00,0x00,0xF4,0xFF,0x1C,0x22}, {0x00,0x00,0x00,0xF4,0xFF,0x1C,0x22}, {0x00,0x00,0x00,0xF4,0xFF,0x1C,0x22} - }, - { - {0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46}, /* PAL-M */ + }, + { + {0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46}, /* PAL-M */ {0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C}, {0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46}, {0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C}, @@ -346,9 +346,9 @@ static const UCHAR SiS310_TVYFilter2[5][9][7] = {0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C}, {0x01,0x01,0xFC,0xF8,0x08,0x26,0x38}, {0xFF,0xFF,0xFC,0x00,0x0F,0x22,0x28} - }, - { - {0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46}, /* PAL-N */ + }, + { + {0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46}, /* PAL-N */ {0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C}, {0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46}, {0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C}, @@ -357,58 +357,39 @@ static const UCHAR SiS310_TVYFilter2[5][9][7] = {0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C}, {0x01,0x01,0xFC,0xF8,0x08,0x26,0x38}, {0xFF,0xFF,0xFC,0x00,0x0F,0x22,0x28} - } + } }; -static const UCHAR SiS310_TVPhaseIncr1[3][2][4] = +static const unsigned char SiS310_TVPhaseIncr1[3][2][4] = { - { + { {0x21,0xed,0xba,0x08}, {0x21,0xed,0xba,0x08} - }, - { + }, + { {0x2a,0x05,0xe3,0x00}, {0x2a,0x05,0xe3,0x00} - }, - { + }, + { {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00} - } + } }; -static const UCHAR SiS310_TVPhaseIncr2[3][2][4] = +static const unsigned char SiS310_TVPhaseIncr2[3][2][4] = { - { + { {0x21,0xf0,0x7b,0xd6}, {0x21,0xf0,0x7b,0xd6} - }, - { + }, + { {0x2a,0x0a,0x41,0xe9}, {0x2a,0x0a,0x41,0xe9} - }, - { + }, + { {0x2a,0x05,0xd3,0x00}, {0x2a,0x05,0xd3,0x00} - } -}; - -static const UCHAR SiS661_TVPhase[] = { - 0x21,0xED,0xBA,0x08, - 0x2A,0x05,0xE3,0x00, - 0x21,0xE4,0x2E,0x9B, - 0x21,0xF4,0x3E,0xBA, - 0x1E,0x8B,0xA2,0xA7, - 0x1E,0x83,0x0A,0xE0, - 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, - 0x21,0xF0,0x7B,0xD6, - 0x2A,0x09,0x86,0xE9, - 0x21,0xE6,0xEF,0xA4, - 0x21,0xF6,0x94,0x46, - 0x1E,0x8B,0xA2,0xA7, - 0x1E,0x83,0x0A,0xE0, - 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00 + } }; /**************************************************************/ @@ -417,7 +398,7 @@ static const UCHAR SiS661_TVPhase[] = { /* Inventec / Compaq Presario 3045US, 3017 */ -static const SiS_LCDDataStruct SiS310_ExtCompaq1280x1024Data[] = +static const struct SiS_LCDData SiS310_ExtCompaq1280x1024Data[] = { { 211, 60,1024, 501,1688,1066}, { 211, 60,1024, 508,1688,1066}, @@ -431,17 +412,17 @@ static const SiS_LCDDataStruct SiS310_ExtCompaq1280x1024Data[] = /* Asus A2xxxH _2 */ -static const SiS_Part2PortTblStruct SiS310_CRT2Part2_Asus1024x768_3[] = +static const struct SiS_Part2PortTbl SiS310_CRT2Part2_Asus1024x768_3[] = { - {{0x25,0x13,0xc9,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x2c,0x13,0x9a,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x25,0x13,0xc9,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x38,0x13,0x13,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, - {{0x38,0x13,0x16,0x25,0xff,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, - {{0x36,0x13,0x13,0x25,0xff,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, - {{0x25,0x13,0xc9,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}} + {{0x25,0x13,0xc9,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, + {{0x2c,0x13,0x9a,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, + {{0x25,0x13,0xc9,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, + {{0x38,0x13,0x13,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}}, + {{0x38,0x13,0x16,0x25,0xff,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, + {{0x36,0x13,0x13,0x25,0xff,0x5a,0x45,0x0a,0x07,0xfa,0x0a,0x24}}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}, + {{0x25,0x13,0xc9,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}} }; diff --git a/drivers/video/sis/osdef.h b/drivers/video/sis/osdef.h index 15939b05771..841ca3190cd 100644 --- a/drivers/video/sis/osdef.h +++ b/drivers/video/sis/osdef.h @@ -3,7 +3,7 @@ /* * OS depending defines * - * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2005 by Thomas Winischhofer, Vienna, Austria * * If distributed as part of the Linux kernel, the following license terms * apply: @@ -55,8 +55,11 @@ #define _SIS_OSDEF_H_ /* The choices are: */ -#define LINUX_KERNEL /* Linux kernel framebuffer */ -/* #define LINUX_XF86 */ /* XFree86/X.org */ +#define SIS_LINUX_KERNEL /* Linux kernel framebuffer */ +#undef SIS_XORG_XF86 /* XFree86/X.org */ + +#undef SIS_LINUX_KERNEL_24 +#undef SIS_LINUX_KERNEL_26 #ifdef OutPortByte #undef OutPortByte @@ -86,8 +89,9 @@ /* LINUX KERNEL */ /**********************************************************************/ -#ifdef LINUX_KERNEL +#ifdef SIS_LINUX_KERNEL #include <linux/config.h> +#include <linux/version.h> #ifdef CONFIG_FB_SIS_300 #define SIS300 @@ -97,6 +101,12 @@ #define SIS315H #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) +#define SIS_LINUX_KERNEL_26 +#else +#define SIS_LINUX_KERNEL_24 +#endif + #if !defined(SIS300) && !defined(SIS315H) #warning Neither CONFIG_FB_SIS_300 nor CONFIG_FB_SIS_315 is set #warning sisfb will not work! @@ -109,13 +119,15 @@ #define InPortWord(p) inw((SISIOADDRESS)(p)) #define InPortLong(p) inl((SISIOADDRESS)(p)) #define SiS_SetMemory(MemoryAddress,MemorySize,value) memset_io(MemoryAddress, value, MemorySize) -#endif + +#endif /* LINUX_KERNEL */ /**********************************************************************/ /* XFree86/X.org */ /**********************************************************************/ -#ifdef LINUX_XF86 +#ifdef SIS_XORG_XF86 + #define SIS300 #define SIS315H @@ -126,6 +138,7 @@ #define InPortWord(p) inSISREGW((IOADDRESS)(p)) #define InPortLong(p) inSISREGL((IOADDRESS)(p)) #define SiS_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize) -#endif + +#endif /* XF86 */ #endif /* _OSDEF_H_ */ diff --git a/drivers/video/sis/sis.h b/drivers/video/sis/sis.h index d0103c162e4..0b6e625d733 100644 --- a/drivers/video/sis/sis.h +++ b/drivers/video/sis/sis.h @@ -1,8 +1,10 @@ /* - * SiS 300/630/730/540/315/550/[M]650/651/[M]661[FM]X/740/[M]741[GX]/330/[M]760[GX] + * SiS 300/540/630[S]/730[S], + * SiS 315[E|PRO]/550/[M]65x/[M]661[F|M]X/740/[M]741[GX]/330/[M]76x[GX], + * XGI V3XT/V5/V8, Z7 * frame buffer driver for Linux kernels >=2.4.14 and >=2.6.3 * - * Copyright (C) 2001-2004 Thomas Winischhofer, Vienna, Austria. + * Copyright (C) 2001-2005 Thomas Winischhofer, Vienna, Austria. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,8 +21,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA */ -#ifndef _SIS_H -#define _SIS_H +#ifndef _SIS_H_ +#define _SIS_H_ #include <linux/config.h> #include <linux/version.h> @@ -35,26 +37,37 @@ #include "vgatypes.h" #include "vstruct.h" -#define VER_MAJOR 1 -#define VER_MINOR 7 -#define VER_LEVEL 17 - -#undef SIS_CONFIG_COMPAT +#define VER_MAJOR 1 +#define VER_MINOR 8 +#define VER_LEVEL 9 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) #include <linux/spinlock.h> +#define SIS_PCI_GET_CLASS(a, b) pci_get_class(a, b) +#define SIS_PCI_GET_DEVICE(a,b,c) pci_get_device(a,b,c) +#define SIS_PCI_GET_SLOT(a,b) pci_get_slot(a,b) +#define SIS_PCI_PUT_DEVICE(a) pci_dev_put(a) #ifdef CONFIG_COMPAT +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,10) #include <linux/ioctl32.h> -#define SIS_CONFIG_COMPAT -#endif -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,19) -#ifdef __x86_64__ -/* Shouldn't we check for CONFIG_IA32_EMULATION here? */ +#define SIS_OLD_CONFIG_COMPAT +#else +#include <linux/smp_lock.h> +#define SIS_NEW_CONFIG_COMPAT +#endif +#endif /* CONFIG_COMPAT */ +#else /* 2.4 */ +#define SIS_PCI_GET_CLASS(a, b) pci_find_class(a, b) +#define SIS_PCI_GET_DEVICE(a,b,c) pci_find_device(a,b,c) +#define SIS_PCI_GET_SLOT(a,b) pci_find_slot(a,b) +#define SIS_PCI_PUT_DEVICE(a) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,19) +#ifdef __x86_64__ /* Shouldn't we check for CONFIG_IA32_EMULATION here? */ #include <asm/ioctl32.h> -#define SIS_CONFIG_COMPAT +#define SIS_OLD_CONFIG_COMPAT #endif #endif - +#endif /* 2.4 */ #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,8) #define SIS_IOTYPE1 void __iomem #define SIS_IOTYPE2 __iomem @@ -79,228 +92,312 @@ /* To be included in pci_ids.h */ #ifndef PCI_DEVICE_ID_SI_650_VGA -#define PCI_DEVICE_ID_SI_650_VGA 0x6325 +#define PCI_DEVICE_ID_SI_650_VGA 0x6325 #endif #ifndef PCI_DEVICE_ID_SI_650 -#define PCI_DEVICE_ID_SI_650 0x0650 +#define PCI_DEVICE_ID_SI_650 0x0650 #endif #ifndef PCI_DEVICE_ID_SI_651 -#define PCI_DEVICE_ID_SI_651 0x0651 +#define PCI_DEVICE_ID_SI_651 0x0651 #endif #ifndef PCI_DEVICE_ID_SI_740 -#define PCI_DEVICE_ID_SI_740 0x0740 +#define PCI_DEVICE_ID_SI_740 0x0740 #endif #ifndef PCI_DEVICE_ID_SI_330 -#define PCI_DEVICE_ID_SI_330 0x0330 +#define PCI_DEVICE_ID_SI_330 0x0330 #endif #ifndef PCI_DEVICE_ID_SI_660_VGA -#define PCI_DEVICE_ID_SI_660_VGA 0x6330 +#define PCI_DEVICE_ID_SI_660_VGA 0x6330 #endif #ifndef PCI_DEVICE_ID_SI_661 -#define PCI_DEVICE_ID_SI_661 0x0661 +#define PCI_DEVICE_ID_SI_661 0x0661 #endif #ifndef PCI_DEVICE_ID_SI_741 -#define PCI_DEVICE_ID_SI_741 0x0741 +#define PCI_DEVICE_ID_SI_741 0x0741 #endif #ifndef PCI_DEVICE_ID_SI_660 -#define PCI_DEVICE_ID_SI_660 0x0660 +#define PCI_DEVICE_ID_SI_660 0x0660 #endif #ifndef PCI_DEVICE_ID_SI_760 -#define PCI_DEVICE_ID_SI_760 0x0760 +#define PCI_DEVICE_ID_SI_760 0x0760 +#endif +#ifndef PCI_DEVICE_ID_SI_761 +#define PCI_DEVICE_ID_SI_761 0x0761 +#endif + +#ifndef PCI_VENDOR_ID_XGI +#define PCI_VENDOR_ID_XGI 0x18ca +#endif + +#ifndef PCI_DEVICE_ID_XGI_20 +#define PCI_DEVICE_ID_XGI_20 0x0020 +#endif + +#ifndef PCI_DEVICE_ID_XGI_40 +#define PCI_DEVICE_ID_XGI_40 0x0040 #endif /* To be included in fb.h */ #ifndef FB_ACCEL_SIS_GLAMOUR_2 -#define FB_ACCEL_SIS_GLAMOUR_2 40 /* SiS 315, 65x, 740, 661, 741 */ +#define FB_ACCEL_SIS_GLAMOUR_2 40 /* SiS 315, 65x, 740, 661, 741 */ #endif #ifndef FB_ACCEL_SIS_XABRE -#define FB_ACCEL_SIS_XABRE 41 /* SiS 330 ("Xabre"), 760 */ +#define FB_ACCEL_SIS_XABRE 41 /* SiS 330 ("Xabre"), 76x */ +#endif +#ifndef FB_ACCEL_XGI_VOLARI_V +#define FB_ACCEL_XGI_VOLARI_V 47 /* XGI Volari Vx (V3XT, V5, V8) */ +#endif +#ifndef FB_ACCEL_XGI_VOLARI_Z +#define FB_ACCEL_XGI_VOLARI_Z 48 /* XGI Volari Z7 */ #endif - -#define MAX_ROM_SCAN 0x10000 /* ivideo->caps */ -#define HW_CURSOR_CAP 0x80 -#define TURBO_QUEUE_CAP 0x40 -#define AGP_CMD_QUEUE_CAP 0x20 -#define VM_CMD_QUEUE_CAP 0x10 -#define MMIO_CMD_QUEUE_CAP 0x08 +#define HW_CURSOR_CAP 0x80 +#define TURBO_QUEUE_CAP 0x40 +#define AGP_CMD_QUEUE_CAP 0x20 +#define VM_CMD_QUEUE_CAP 0x10 +#define MMIO_CMD_QUEUE_CAP 0x08 /* For 300 series */ -#define TURBO_QUEUE_AREA_SIZE 0x80000 /* 512K */ -#define HW_CURSOR_AREA_SIZE_300 0x1000 /* 4K */ +#define TURBO_QUEUE_AREA_SIZE (512 * 1024) /* 512K */ +#define HW_CURSOR_AREA_SIZE_300 4096 /* 4K */ /* For 315/Xabre series */ -#define COMMAND_QUEUE_AREA_SIZE 0x80000 /* 512K */ -#define COMMAND_QUEUE_THRESHOLD 0x1F -#define HW_CURSOR_AREA_SIZE_315 0x4000 /* 16K */ - -#define SIS_OH_ALLOC_SIZE 4000 -#define SENTINEL 0x7fffffff - -#define SEQ_ADR 0x14 -#define SEQ_DATA 0x15 -#define DAC_ADR 0x18 -#define DAC_DATA 0x19 -#define CRTC_ADR 0x24 -#define CRTC_DATA 0x25 -#define DAC2_ADR (0x16-0x30) -#define DAC2_DATA (0x17-0x30) -#define VB_PART1_ADR (0x04-0x30) -#define VB_PART1_DATA (0x05-0x30) -#define VB_PART2_ADR (0x10-0x30) -#define VB_PART2_DATA (0x11-0x30) -#define VB_PART3_ADR (0x12-0x30) -#define VB_PART3_DATA (0x13-0x30) -#define VB_PART4_ADR (0x14-0x30) -#define VB_PART4_DATA (0x15-0x30) - -#define SISSR ivideo->SiS_Pr.SiS_P3c4 -#define SISCR ivideo->SiS_Pr.SiS_P3d4 -#define SISDACA ivideo->SiS_Pr.SiS_P3c8 -#define SISDACD ivideo->SiS_Pr.SiS_P3c9 -#define SISPART1 ivideo->SiS_Pr.SiS_Part1Port -#define SISPART2 ivideo->SiS_Pr.SiS_Part2Port -#define SISPART3 ivideo->SiS_Pr.SiS_Part3Port -#define SISPART4 ivideo->SiS_Pr.SiS_Part4Port -#define SISPART5 ivideo->SiS_Pr.SiS_Part5Port -#define SISDAC2A SISPART5 -#define SISDAC2D (SISPART5 + 1) -#define SISMISCR (ivideo->SiS_Pr.RelIO + 0x1c) -#define SISMISCW ivideo->SiS_Pr.SiS_P3c2 -#define SISINPSTAT (ivideo->SiS_Pr.RelIO + 0x2a) -#define SISPEL ivideo->SiS_Pr.SiS_P3c6 - -#define IND_SIS_PASSWORD 0x05 /* SRs */ -#define IND_SIS_COLOR_MODE 0x06 -#define IND_SIS_RAMDAC_CONTROL 0x07 -#define IND_SIS_DRAM_SIZE 0x14 -#define IND_SIS_MODULE_ENABLE 0x1E -#define IND_SIS_PCI_ADDRESS_SET 0x20 -#define IND_SIS_TURBOQUEUE_ADR 0x26 -#define IND_SIS_TURBOQUEUE_SET 0x27 -#define IND_SIS_POWER_ON_TRAP 0x38 -#define IND_SIS_POWER_ON_TRAP2 0x39 -#define IND_SIS_CMDQUEUE_SET 0x26 -#define IND_SIS_CMDQUEUE_THRESHOLD 0x27 - -#define IND_SIS_AGP_IO_PAD 0x48 - -#define SIS_CRT2_WENABLE_300 0x24 /* Part1 */ -#define SIS_CRT2_WENABLE_315 0x2F - -#define SIS_PASSWORD 0x86 /* SR05 */ - -#define SIS_INTERLACED_MODE 0x20 /* SR06 */ -#define SIS_8BPP_COLOR_MODE 0x0 -#define SIS_15BPP_COLOR_MODE 0x1 -#define SIS_16BPP_COLOR_MODE 0x2 -#define SIS_32BPP_COLOR_MODE 0x4 - -#define SIS_ENABLE_2D 0x40 /* SR1E */ - -#define SIS_MEM_MAP_IO_ENABLE 0x01 /* SR20 */ -#define SIS_PCI_ADDR_ENABLE 0x80 - -#define SIS_AGP_CMDQUEUE_ENABLE 0x80 /* 315/330 series SR26 */ -#define SIS_VRAM_CMDQUEUE_ENABLE 0x40 -#define SIS_MMIO_CMD_ENABLE 0x20 -#define SIS_CMD_QUEUE_SIZE_512k 0x00 -#define SIS_CMD_QUEUE_SIZE_1M 0x04 -#define SIS_CMD_QUEUE_SIZE_2M 0x08 -#define SIS_CMD_QUEUE_SIZE_4M 0x0C -#define SIS_CMD_QUEUE_RESET 0x01 -#define SIS_CMD_AUTO_CORR 0x02 - -#define SIS_SIMULTANEOUS_VIEW_ENABLE 0x01 /* CR30 */ -#define SIS_MODE_SELECT_CRT2 0x02 -#define SIS_VB_OUTPUT_COMPOSITE 0x04 -#define SIS_VB_OUTPUT_SVIDEO 0x08 -#define SIS_VB_OUTPUT_SCART 0x10 -#define SIS_VB_OUTPUT_LCD 0x20 -#define SIS_VB_OUTPUT_CRT2 0x40 -#define SIS_VB_OUTPUT_HIVISION 0x80 - -#define SIS_VB_OUTPUT_DISABLE 0x20 /* CR31 */ -#define SIS_DRIVER_MODE 0x40 - -#define SIS_VB_COMPOSITE 0x01 /* CR32 */ -#define SIS_VB_SVIDEO 0x02 -#define SIS_VB_SCART 0x04 -#define SIS_VB_LCD 0x08 -#define SIS_VB_CRT2 0x10 -#define SIS_CRT1 0x20 -#define SIS_VB_HIVISION 0x40 -#define SIS_VB_YPBPR 0x80 -#define SIS_VB_TV (SIS_VB_COMPOSITE | SIS_VB_SVIDEO | \ - SIS_VB_SCART | SIS_VB_HIVISION | SIS_VB_YPBPR) - -#define SIS_EXTERNAL_CHIP_MASK 0x0E /* CR37 (< SiS 660) */ -#define SIS_EXTERNAL_CHIP_SIS301 0x01 /* in CR37 << 1 ! */ -#define SIS_EXTERNAL_CHIP_LVDS 0x02 -#define SIS_EXTERNAL_CHIP_TRUMPION 0x03 -#define SIS_EXTERNAL_CHIP_LVDS_CHRONTEL 0x04 -#define SIS_EXTERNAL_CHIP_CHRONTEL 0x05 -#define SIS310_EXTERNAL_CHIP_LVDS 0x02 -#define SIS310_EXTERNAL_CHIP_LVDS_CHRONTEL 0x03 - -#define SIS_AGP_2X 0x20 /* CR48 */ - -#define HW_DEVICE_EXTENSION SIS_HW_INFO -#define PHW_DEVICE_EXTENSION PSIS_HW_INFO +#define COMMAND_QUEUE_AREA_SIZE (512 * 1024) /* 512K */ +#define COMMAND_QUEUE_AREA_SIZE_Z7 (128 * 1024) /* 128k for XGI Z7 */ +#define HW_CURSOR_AREA_SIZE_315 16384 /* 16K */ +#define COMMAND_QUEUE_THRESHOLD 0x1F + +#define SIS_OH_ALLOC_SIZE 4000 +#define SENTINEL 0x7fffffff + +#define SEQ_ADR 0x14 +#define SEQ_DATA 0x15 +#define DAC_ADR 0x18 +#define DAC_DATA 0x19 +#define CRTC_ADR 0x24 +#define CRTC_DATA 0x25 +#define DAC2_ADR (0x16-0x30) +#define DAC2_DATA (0x17-0x30) +#define VB_PART1_ADR (0x04-0x30) +#define VB_PART1_DATA (0x05-0x30) +#define VB_PART2_ADR (0x10-0x30) +#define VB_PART2_DATA (0x11-0x30) +#define VB_PART3_ADR (0x12-0x30) +#define VB_PART3_DATA (0x13-0x30) +#define VB_PART4_ADR (0x14-0x30) +#define VB_PART4_DATA (0x15-0x30) + +#define SISSR ivideo->SiS_Pr.SiS_P3c4 +#define SISCR ivideo->SiS_Pr.SiS_P3d4 +#define SISDACA ivideo->SiS_Pr.SiS_P3c8 +#define SISDACD ivideo->SiS_Pr.SiS_P3c9 +#define SISPART1 ivideo->SiS_Pr.SiS_Part1Port +#define SISPART2 ivideo->SiS_Pr.SiS_Part2Port +#define SISPART3 ivideo->SiS_Pr.SiS_Part3Port +#define SISPART4 ivideo->SiS_Pr.SiS_Part4Port +#define SISPART5 ivideo->SiS_Pr.SiS_Part5Port +#define SISDAC2A SISPART5 +#define SISDAC2D (SISPART5 + 1) +#define SISMISCR (ivideo->SiS_Pr.RelIO + 0x1c) +#define SISMISCW ivideo->SiS_Pr.SiS_P3c2 +#define SISINPSTAT (ivideo->SiS_Pr.RelIO + 0x2a) +#define SISPEL ivideo->SiS_Pr.SiS_P3c6 +#define SISVGAENABLE (ivideo->SiS_Pr.RelIO + 0x13) +#define SISVID (ivideo->SiS_Pr.RelIO + 0x02 - 0x30) +#define SISCAP (ivideo->SiS_Pr.RelIO + 0x00 - 0x30) + +#define IND_SIS_PASSWORD 0x05 /* SRs */ +#define IND_SIS_COLOR_MODE 0x06 +#define IND_SIS_RAMDAC_CONTROL 0x07 +#define IND_SIS_DRAM_SIZE 0x14 +#define IND_SIS_MODULE_ENABLE 0x1E +#define IND_SIS_PCI_ADDRESS_SET 0x20 +#define IND_SIS_TURBOQUEUE_ADR 0x26 +#define IND_SIS_TURBOQUEUE_SET 0x27 +#define IND_SIS_POWER_ON_TRAP 0x38 +#define IND_SIS_POWER_ON_TRAP2 0x39 +#define IND_SIS_CMDQUEUE_SET 0x26 +#define IND_SIS_CMDQUEUE_THRESHOLD 0x27 + +#define IND_SIS_AGP_IO_PAD 0x48 + +#define SIS_CRT2_WENABLE_300 0x24 /* Part1 */ +#define SIS_CRT2_WENABLE_315 0x2F + +#define SIS_PASSWORD 0x86 /* SR05 */ + +#define SIS_INTERLACED_MODE 0x20 /* SR06 */ +#define SIS_8BPP_COLOR_MODE 0x0 +#define SIS_15BPP_COLOR_MODE 0x1 +#define SIS_16BPP_COLOR_MODE 0x2 +#define SIS_32BPP_COLOR_MODE 0x4 + +#define SIS_ENABLE_2D 0x40 /* SR1E */ + +#define SIS_MEM_MAP_IO_ENABLE 0x01 /* SR20 */ +#define SIS_PCI_ADDR_ENABLE 0x80 + +#define SIS_AGP_CMDQUEUE_ENABLE 0x80 /* 315/330/340 series SR26 */ +#define SIS_VRAM_CMDQUEUE_ENABLE 0x40 +#define SIS_MMIO_CMD_ENABLE 0x20 +#define SIS_CMD_QUEUE_SIZE_512k 0x00 +#define SIS_CMD_QUEUE_SIZE_1M 0x04 +#define SIS_CMD_QUEUE_SIZE_2M 0x08 +#define SIS_CMD_QUEUE_SIZE_4M 0x0C +#define SIS_CMD_QUEUE_RESET 0x01 +#define SIS_CMD_AUTO_CORR 0x02 + +#define SIS_CMD_QUEUE_SIZE_Z7_64k 0x00 /* XGI Z7 */ +#define SIS_CMD_QUEUE_SIZE_Z7_128k 0x04 + +#define SIS_SIMULTANEOUS_VIEW_ENABLE 0x01 /* CR30 */ +#define SIS_MODE_SELECT_CRT2 0x02 +#define SIS_VB_OUTPUT_COMPOSITE 0x04 +#define SIS_VB_OUTPUT_SVIDEO 0x08 +#define SIS_VB_OUTPUT_SCART 0x10 +#define SIS_VB_OUTPUT_LCD 0x20 +#define SIS_VB_OUTPUT_CRT2 0x40 +#define SIS_VB_OUTPUT_HIVISION 0x80 + +#define SIS_VB_OUTPUT_DISABLE 0x20 /* CR31 */ +#define SIS_DRIVER_MODE 0x40 + +#define SIS_VB_COMPOSITE 0x01 /* CR32 */ +#define SIS_VB_SVIDEO 0x02 +#define SIS_VB_SCART 0x04 +#define SIS_VB_LCD 0x08 +#define SIS_VB_CRT2 0x10 +#define SIS_CRT1 0x20 +#define SIS_VB_HIVISION 0x40 +#define SIS_VB_YPBPR 0x80 +#define SIS_VB_TV (SIS_VB_COMPOSITE | SIS_VB_SVIDEO | \ + SIS_VB_SCART | SIS_VB_HIVISION | SIS_VB_YPBPR) + +#define SIS_EXTERNAL_CHIP_MASK 0x0E /* CR37 (< SiS 660) */ +#define SIS_EXTERNAL_CHIP_SIS301 0x01 /* in CR37 << 1 ! */ +#define SIS_EXTERNAL_CHIP_LVDS 0x02 +#define SIS_EXTERNAL_CHIP_TRUMPION 0x03 +#define SIS_EXTERNAL_CHIP_LVDS_CHRONTEL 0x04 +#define SIS_EXTERNAL_CHIP_CHRONTEL 0x05 +#define SIS310_EXTERNAL_CHIP_LVDS 0x02 +#define SIS310_EXTERNAL_CHIP_LVDS_CHRONTEL 0x03 + +#define SIS_AGP_2X 0x20 /* CR48 */ + +/* vbflags, private entries (others in sisfb.h) */ +#define VB_CONEXANT 0x00000800 /* 661 series only */ +#define VB_TRUMPION VB_CONEXANT /* 300 series only */ +#define VB_302ELV 0x00004000 +#define VB_301 0x00100000 /* Video bridge type */ +#define VB_301B 0x00200000 +#define VB_302B 0x00400000 +#define VB_30xBDH 0x00800000 /* 30xB DH version (w/o LCD support) */ +#define VB_LVDS 0x01000000 +#define VB_CHRONTEL 0x02000000 +#define VB_301LV 0x04000000 +#define VB_302LV 0x08000000 +#define VB_301C 0x10000000 + +#define VB_SISBRIDGE (VB_301|VB_301B|VB_301C|VB_302B|VB_301LV|VB_302LV|VB_302ELV) +#define VB_VIDEOBRIDGE (VB_SISBRIDGE | VB_LVDS | VB_CHRONTEL | VB_CONEXANT) + +/* vbflags2 (static stuff only!) */ +#define VB2_SISUMC 0x00000001 +#define VB2_301 0x00000002 /* Video bridge type */ +#define VB2_301B 0x00000004 +#define VB2_301C 0x00000008 +#define VB2_307T 0x00000010 +#define VB2_302B 0x00000800 +#define VB2_301LV 0x00001000 +#define VB2_302LV 0x00002000 +#define VB2_302ELV 0x00004000 +#define VB2_307LV 0x00008000 +#define VB2_30xBDH 0x08000000 /* 30xB DH version (w/o LCD support) */ +#define VB2_CONEXANT 0x10000000 +#define VB2_TRUMPION 0x20000000 +#define VB2_LVDS 0x40000000 +#define VB2_CHRONTEL 0x80000000 + +#define VB2_SISLVDSBRIDGE (VB2_301LV | VB2_302LV | VB2_302ELV | VB2_307LV) +#define VB2_SISTMDSBRIDGE (VB2_301 | VB2_301B | VB2_301C | VB2_302B | VB2_307T) +#define VB2_SISBRIDGE (VB2_SISLVDSBRIDGE | VB2_SISTMDSBRIDGE) + +#define VB2_SISTMDSLCDABRIDGE (VB2_301C | VB2_307T) +#define VB2_SISLCDABRIDGE (VB2_SISTMDSLCDABRIDGE | VB2_301LV | VB2_302LV | VB2_302ELV | VB2_307LV) + +#define VB2_SISHIVISIONBRIDGE (VB2_301 | VB2_301B | VB2_302B) +#define VB2_SISYPBPRBRIDGE (VB2_301C | VB2_307T | VB2_SISLVDSBRIDGE) +#define VB2_SISYPBPRARBRIDGE (VB2_301C | VB2_307T | VB2_307LV) +#define VB2_SISTAP4SCALER (VB2_301C | VB2_307T | VB2_302ELV | VB2_307LV) +#define VB2_SISTVBRIDGE (VB2_SISHIVISIONBRIDGE | VB2_SISYPBPRBRIDGE) + +#define VB2_SISVGA2BRIDGE (VB2_301 | VB2_301B | VB2_301C | VB2_302B | VB2_307T) + +#define VB2_VIDEOBRIDGE (VB2_SISBRIDGE | VB2_LVDS | VB2_CHRONTEL | VB2_CONEXANT) + +#define VB2_30xB (VB2_301B | VB2_301C | VB2_302B | VB2_307T) +#define VB2_30xBLV (VB2_30xB | VB2_SISLVDSBRIDGE) +#define VB2_30xC (VB2_301C | VB2_307T) +#define VB2_30xCLV (VB2_301C | VB2_307T | VB2_302ELV| VB2_307LV) +#define VB2_SISEMIBRIDGE (VB2_302LV | VB2_302ELV | VB2_307LV) +#define VB2_LCD162MHZBRIDGE (VB2_301C | VB2_307T) +#define VB2_LCDOVER1280BRIDGE (VB2_301C | VB2_307T | VB2_302LV | VB2_302ELV | VB2_307LV) +#define VB2_LCDOVER1600BRIDGE (VB2_307T | VB2_307LV) +#define VB2_RAMDAC202MHZBRIDGE (VB2_301C | VB2_307T) /* I/O port access macros */ -#define inSISREG(base) inb(base) +#define inSISREG(base) inb(base) -#define outSISREG(base,val) outb(val,base) +#define outSISREG(base,val) outb(val,base) #define orSISREG(base,val) \ - do { \ - u8 __Temp = inSISREG(base); \ - outSISREG(base, __Temp | (val)); \ - } while (0) + do { \ + u8 __Temp = inSISREG(base); \ + outSISREG(base, __Temp | (val));\ + } while (0) #define andSISREG(base,val) \ - do { \ - u8 __Temp = inSISREG(base); \ - outSISREG(base, __Temp & (val)); \ - } while (0) - -#define inSISIDXREG(base,idx,var) \ - do { \ - outSISREG(base, idx); \ - var = inSISREG((base)+1); \ - } while (0) - -#define outSISIDXREG(base,idx,val) \ - do { \ - outSISREG(base, idx); \ - outSISREG((base)+1, val); \ - } while (0) - -#define orSISIDXREG(base,idx,val) \ - do { \ - u8 __Temp; \ - outSISREG(base, idx); \ - __Temp = inSISREG((base)+1) | (val); \ - outSISREG((base)+1, __Temp); \ - } while (0) - -#define andSISIDXREG(base,idx,and) \ - do { \ - u8 __Temp; \ - outSISREG(base, idx); \ - __Temp = inSISREG((base)+1) & (and); \ - outSISREG((base)+1, __Temp); \ - } while (0) - -#define setSISIDXREG(base,idx,and,or) \ - do { \ - u8 __Temp; \ - outSISREG(base, idx); \ - __Temp = (inSISREG((base)+1) & (and)) | (or); \ - outSISREG((base)+1, __Temp); \ - } while (0) + do { \ + u8 __Temp = inSISREG(base); \ + outSISREG(base, __Temp & (val));\ + } while (0) + +#define inSISIDXREG(base,idx,var) \ + do { \ + outSISREG(base, idx); \ + var = inSISREG((base)+1); \ + } while (0) + +#define outSISIDXREG(base,idx,val) \ + do { \ + outSISREG(base, idx); \ + outSISREG((base)+1, val); \ + } while (0) + +#define orSISIDXREG(base,idx,val) \ + do { \ + u8 __Temp; \ + outSISREG(base, idx); \ + __Temp = inSISREG((base)+1) | (val); \ + outSISREG((base)+1, __Temp); \ + } while (0) + +#define andSISIDXREG(base,idx,and) \ + do { \ + u8 __Temp; \ + outSISREG(base, idx); \ + __Temp = inSISREG((base)+1) & (and); \ + outSISREG((base)+1, __Temp); \ + } while (0) + +#define setSISIDXREG(base,idx,and,or) \ + do { \ + u8 __Temp; \ + outSISREG(base, idx); \ + __Temp = (inSISREG((base)+1) & (and)) | (or); \ + outSISREG((base)+1, __Temp); \ + } while (0) /* MMIO access macros */ #define MMIO_IN8(base, offset) readb((base+offset)) @@ -322,19 +419,19 @@ #define MMIO_QUEUE_READPORT Q_READ_PTR #ifndef FB_BLANK_UNBLANK -#define FB_BLANK_UNBLANK 0 +#define FB_BLANK_UNBLANK 0 #endif #ifndef FB_BLANK_NORMAL -#define FB_BLANK_NORMAL 1 +#define FB_BLANK_NORMAL 1 #endif #ifndef FB_BLANK_VSYNC_SUSPEND -#define FB_BLANK_VSYNC_SUSPEND 2 +#define FB_BLANK_VSYNC_SUSPEND 2 #endif #ifndef FB_BLANK_HSYNC_SUSPEND -#define FB_BLANK_HSYNC_SUSPEND 3 +#define FB_BLANK_HSYNC_SUSPEND 3 #endif #ifndef FB_BLANK_POWERDOWN -#define FB_BLANK_POWERDOWN 4 +#define FB_BLANK_POWERDOWN 4 #endif enum _SIS_LCD_TYPE { @@ -347,18 +444,19 @@ enum _SIS_LCD_TYPE { LCD_1600x1200, LCD_1920x1440, LCD_2048x1536, - LCD_320x480, /* FSTN */ + LCD_320x240, /* FSTN */ LCD_1400x1050, LCD_1152x864, LCD_1152x768, LCD_1280x768, LCD_1024x600, - LCD_640x480_2, /* DSTN */ - LCD_640x480_3, /* DSTN */ + LCD_320x240_2, /* DSTN */ + LCD_320x240_3, /* DSTN */ LCD_848x480, LCD_1280x800, LCD_1680x1050, LCD_1280x720, + LCD_1280x854, LCD_CUSTOM, LCD_UNKNOWN }; @@ -368,31 +466,50 @@ enum _SIS_CMDTYPE { AGP_CMD_QUEUE, VM_CMD_QUEUE, }; -typedef unsigned int SIS_CMDTYPE; + +struct SIS_OH { + struct SIS_OH *poh_next; + struct SIS_OH *poh_prev; + u32 offset; + u32 size; +}; + +struct SIS_OHALLOC { + struct SIS_OHALLOC *poha_next; + struct SIS_OH aoh[1]; +}; + +struct SIS_HEAP { + struct SIS_OH oh_free; + struct SIS_OH oh_used; + struct SIS_OH *poh_freelist; + struct SIS_OHALLOC *poha_chain; + u32 max_freesize; + struct sis_video_info *vinfo; +}; /* Our "par" */ struct sis_video_info { int cardnumber; struct fb_info *memyselfandi; - SIS_HW_INFO sishw_ext; - SiS_Private SiS_Pr; + struct SiS_Private SiS_Pr; - sisfb_info sisfbinfo; /* For ioctl SISFB_GET_INFO */ + struct sisfb_info sisfbinfo; /* For ioctl SISFB_GET_INFO */ struct fb_var_screeninfo default_var; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) struct fb_fix_screeninfo sisfb_fix; - u32 pseudo_palette[17]; + u32 pseudo_palette[17]; #endif #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - struct display sis_disp; + struct display sis_disp; struct display_switch sisfb_sw; struct { u16 red, green, blue, pad; - } sis_palette[256]; + } sis_palette[256]; union { #ifdef FBCON_HAS_CFB16 u16 cfb16[16]; @@ -400,10 +517,10 @@ struct sis_video_info { #ifdef FBCON_HAS_CFB32 u32 cfb32[16]; #endif - } sis_fbcon_cmap; + } sis_fbcon_cmap; #endif - struct sisfb_monitor { + struct sisfb_monitor { u16 hmin; u16 hmax; u16 vmin; @@ -411,163 +528,166 @@ struct sis_video_info { u32 dclockmax; u8 feature; BOOLEAN datavalid; - } sisfb_thismonitor; + } sisfb_thismonitor; - int chip_id; + unsigned short chip_id; /* PCI ID of chip */ + unsigned short chip_vendor; /* PCI ID of vendor */ char myid[40]; struct pci_dev *nbridge; + struct pci_dev *lpcdev; int mni; /* Mode number index */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - int currcon; + int currcon; #endif unsigned long video_size; - unsigned long video_base; + unsigned long video_base; unsigned long mmio_size; - unsigned long mmio_base; - unsigned long vga_base; + unsigned long mmio_base; + unsigned long vga_base; + + unsigned long video_offset; - SIS_IOTYPE1 *video_vbase; - SIS_IOTYPE1 *mmio_vbase; + unsigned long UMAsize, LFBsize; - unsigned char *bios_abase; + SIS_IOTYPE1 *video_vbase; + SIS_IOTYPE1 *mmio_vbase; - int mtrr; + unsigned char *bios_abase; + + int mtrr; u32 sisfb_mem; - u32 sisfb_parm_mem; - int sisfb_accel; - int sisfb_ypan; - int sisfb_max; - int sisfb_userom; - int sisfb_useoem; + u32 sisfb_parm_mem; + int sisfb_accel; + int sisfb_ypan; + int sisfb_max; + int sisfb_userom; + int sisfb_useoem; int sisfb_mode_idx; int sisfb_parm_rate; int sisfb_crt1off; int sisfb_forcecrt1; int sisfb_crt2type; int sisfb_crt2flags; - int sisfb_dstn; - int sisfb_fstn; + int sisfb_dstn; + int sisfb_fstn; int sisfb_tvplug; int sisfb_tvstd; - int sisfb_filter; int sisfb_nocrt2rate; #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) int sisfb_inverse; #endif - u32 heapstart; /* offset */ - SIS_IOTYPE1 *sisfb_heap_start; /* address */ - SIS_IOTYPE1 *sisfb_heap_end; /* address */ - u32 sisfb_heap_size; + u32 heapstart; /* offset */ + SIS_IOTYPE1 *sisfb_heap_start; /* address */ + SIS_IOTYPE1 *sisfb_heap_end; /* address */ + u32 sisfb_heap_size; int havenoheap; -#if 0 - SIS_HEAP sisfb_heap; -#endif + struct SIS_HEAP sisfb_heap; /* This card's vram heap */ - int video_bpp; - int video_cmap_len; - int video_width; - int video_height; - unsigned int refresh_rate; + int video_bpp; + int video_cmap_len; + int video_width; + int video_height; + unsigned int refresh_rate; - unsigned int chip; - u8 revision_id; + unsigned int chip; + u8 revision_id; + int sisvga_enabled; /* PCI device was enabled */ - int video_linelength; /* real pitch */ + int video_linelength; /* real pitch */ int scrnpitchCRT1; /* pitch regarding interlace */ - u16 DstColor; /* For 2d acceleration */ - u32 SiS310_AccelDepth; - u32 CommandReg; - int cmdqueuelength; + u16 DstColor; /* For 2d acceleration */ + u32 SiS310_AccelDepth; + u32 CommandReg; + int cmdqueuelength; /* Current (for accel) */ + u32 cmdQueueSize; /* Total size in KB */ - spinlock_t lockaccel; /* Do not use outside of kernel! */ + spinlock_t lockaccel; /* Do not use outside of kernel! */ - unsigned int pcibus; - unsigned int pcislot; - unsigned int pcifunc; + unsigned int pcibus; + unsigned int pcislot; + unsigned int pcifunc; - int accel; + int accel; + int engineok; - u16 subsysvendor; - u16 subsysdevice; + u16 subsysvendor; + u16 subsysdevice; - u32 vbflags; /* Replacing deprecated stuff from above */ - u32 currentvbflags; + u32 vbflags; /* Replacing deprecated stuff from above */ + u32 currentvbflags; + u32 vbflags2; int lcdxres, lcdyres; int lcddefmodeidx, tvdefmodeidx, defmodeidx; - u32 CRT2LCDType; /* defined in "SIS_LCD_TYPE" */ - - int current_bpp; - int current_width; - int current_height; - int current_htotal; - int current_vtotal; + u32 CRT2LCDType; /* defined in "SIS_LCD_TYPE" */ + u32 curFSTN, curDSTN; + + int current_bpp; + int current_width; + int current_height; + int current_htotal; + int current_vtotal; int current_linelength; - __u32 current_pixclock; - int current_refresh_rate; + __u32 current_pixclock; + int current_refresh_rate; + + unsigned int current_base; - u8 mode_no; - u8 rate_idx; - int modechanged; - unsigned char modeprechange; + u8 mode_no; + u8 rate_idx; + int modechanged; + unsigned char modeprechange; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) - u8 sisfb_lastrates[128]; + u8 sisfb_lastrates[128]; #endif - int newrom; - int registered; + int newrom; + int haveXGIROM; + int registered; int warncount; +#ifdef SIS_OLD_CONFIG_COMPAT + int ioctl32registered; +#endif - int sisvga_engine; - int hwcursor_size; - int CRT2_write_enable; - u8 caps; + int sisvga_engine; + int hwcursor_size; + int CRT2_write_enable; + u8 caps; - u8 detectedpdc; - u8 detectedpdca; - u8 detectedlcda; + u8 detectedpdc; + u8 detectedpdca; + u8 detectedlcda; - SIS_IOTYPE1 *hwcursor_vbase; + SIS_IOTYPE1 *hwcursor_vbase; - int chronteltype; - int tvxpos, tvypos; - u8 p2_1f,p2_20,p2_2b,p2_42,p2_43,p2_01,p2_02; + int chronteltype; + int tvxpos, tvypos; + u8 p2_1f,p2_20,p2_2b,p2_42,p2_43,p2_01,p2_02; int tvx, tvy; - u8 sisfblocked; + u8 sisfblocked; + + struct sisfb_info sisfb_infoblock; + + struct sisfb_cmd sisfb_command; + + u32 sisfb_id; + + u8 sisfb_can_post; + u8 sisfb_card_posted; + u8 sisfb_was_boot_device; struct sis_video_info *next; }; -typedef struct _SIS_OH { - struct _SIS_OH *poh_next; - struct _SIS_OH *poh_prev; - u32 offset; - u32 size; -} SIS_OH; - -typedef struct _SIS_OHALLOC { - struct _SIS_OHALLOC *poha_next; - SIS_OH aoh[1]; -} SIS_OHALLOC; - -typedef struct _SIS_HEAP { - SIS_OH oh_free; - SIS_OH oh_used; - SIS_OH *poh_freelist; - SIS_OHALLOC *poha_chain; - u32 max_freesize; - struct sis_video_info *vinfo; -} SIS_HEAP; - #endif diff --git a/drivers/video/sis/sis_accel.c b/drivers/video/sis/sis_accel.c index 30e90a553e8..bab933e6c6a 100644 --- a/drivers/video/sis/sis_accel.c +++ b/drivers/video/sis/sis_accel.c @@ -1,6 +1,8 @@ /* - * SiS 300/630/730/540/315/550/65x/74x/330/760 frame buffer driver - * for Linux kernels 2.4.x and 2.6.x + * SiS 300/540/630[S]/730[S], + * SiS 315[E|PRO]/550/[M]650/651/[M]661[F|M]X/740/[M]741[GX]/330/[M]760[GX], + * XGI V3XT/V5/V8, Z7 + * frame buffer driver for Linux kernels >= 2.4.14 and >=2.6.3 * * 2D acceleration part * @@ -19,7 +21,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA * * Based on the XFree86/X.org driver which is - * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2005 by Thomas Winischhofer, Vienna, Austria * * Author: Thomas Winischhofer <thomas@winischhofer.net> * (see http://www.winischhofer.net/ @@ -30,13 +32,11 @@ #include <linux/version.h> #include <linux/module.h> #include <linux/kernel.h> -#include <linux/errno.h> #include <linux/fb.h> +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) #include <linux/console.h> -#include <linux/selection.h> +#endif #include <linux/ioport.h> -#include <linux/capability.h> -#include <linux/fs.h> #include <linux/types.h> #include <asm/io.h> @@ -188,7 +188,7 @@ SiS300SubsequentSolidFillRect(struct sis_video_info *ivideo, int x, int y, int w } #endif -/* 315/330 series ------------------------------------------------- */ +/* 315/330/340 series ---------------------------------------------- */ #ifdef CONFIG_FB_SIS_315 static void @@ -202,7 +202,7 @@ SiS310SetupForScreenToScreenCopy(struct sis_video_info *ivideo, int rop, int tra { SiS310SetupDSTColorDepth(ivideo->DstColor); SiS310SetupSRCPitch(ivideo->video_linelength) - SiS310SetupDSTRect(ivideo->video_linelength, 0xffff) + SiS310SetupDSTRect(ivideo->video_linelength, 0x0fff) if(trans_color != -1) { SiS310SetupROP(0x0A) SiS310SetupSRCTrans(trans_color) @@ -213,7 +213,7 @@ SiS310SetupForScreenToScreenCopy(struct sis_video_info *ivideo, int rop, int tra /* SiSSetupCMDFlag(BITBLT | SRCVIDEO) */ } SiS310SetupCMDFlag(ivideo->SiS310_AccelDepth) - /* The 315 series is smart enough to know the direction */ + /* The chip is smart enough to know the direction */ } static void @@ -223,35 +223,38 @@ SiS310SubsequentScreenToScreenCopy(struct sis_video_info *ivideo, int src_x, int u32 srcbase = 0, dstbase = 0; int mymin = min(src_y, dst_y); int mymax = max(src_y, dst_y); - + /* Although the chip knows the direction to use - * if the source and destination areas overlap, + * if the source and destination areas overlap, * that logic fails if we fiddle with the bitmap * addresses. Therefore, we check if the source - * and destination blitting areas overlap and - * adapt the bitmap addresses synchronously + * and destination blitting areas overlap and + * adapt the bitmap addresses synchronously * if the coordinates exceed the valid range. - * The the areas do not overlap, we do our + * The the areas do not overlap, we do our * normal check. */ - if((mymax - mymin) < height) { - if((src_y >= 2048) || (dst_y >= 2048)) { - srcbase = ivideo->video_linelength * mymin; - dstbase = ivideo->video_linelength * mymin; - src_y -= mymin; - dst_y -= mymin; - } + if((mymax - mymin) < height) { + if((src_y >= 2048) || (dst_y >= 2048)) { + srcbase = ivideo->video_linelength * mymin; + dstbase = ivideo->video_linelength * mymin; + src_y -= mymin; + dst_y -= mymin; + } } else { - if(src_y >= 2048) { - srcbase = ivideo->video_linelength * src_y; - src_y = 0; - } - if(dst_y >= 2048) { - dstbase = ivideo->video_linelength * dst_y; - dst_y = 0; - } + if(src_y >= 2048) { + srcbase = ivideo->video_linelength * src_y; + src_y = 0; + } + if(dst_y >= 2048) { + dstbase = ivideo->video_linelength * dst_y; + dst_y = 0; + } } + srcbase += ivideo->video_offset; + dstbase += ivideo->video_offset; + SiS310SetupSRCBase(srcbase); SiS310SetupDSTBase(dstbase); SiS310SetupRect(width, height) @@ -264,7 +267,7 @@ static void SiS310SetupForSolidFill(struct sis_video_info *ivideo, u32 color, int rop) { SiS310SetupPATFG(color) - SiS310SetupDSTRect(ivideo->video_linelength, 0xffff) + SiS310SetupDSTRect(ivideo->video_linelength, 0x0fff) SiS310SetupDSTColorDepth(ivideo->DstColor); SiS310SetupROP(sisPatALUConv[rop]) SiS310SetupCMDFlag(PATFG | ivideo->SiS310_AccelDepth) @@ -279,6 +282,7 @@ SiS310SubsequentSolidFillRect(struct sis_video_info *ivideo, int x, int y, int w dstbase = ivideo->video_linelength * y; y = 0; } + dstbase += ivideo->video_offset; SiS310SetupDSTBase(dstbase) SiS310SetupDSTXY(x,y) SiS310SetupRect(w,h) @@ -294,384 +298,153 @@ SiS310SubsequentSolidFillRect(struct sis_video_info *ivideo, int x, int y, int w int sisfb_initaccel(struct sis_video_info *ivideo) { #ifdef SISFB_USE_SPINLOCKS - spin_lock_init(&ivideo->lockaccel); + spin_lock_init(&ivideo->lockaccel); #endif - return(0); + return 0; } void sisfb_syncaccel(struct sis_video_info *ivideo) { - if(ivideo->sisvga_engine == SIS_300_VGA) { + if(ivideo->sisvga_engine == SIS_300_VGA) { #ifdef CONFIG_FB_SIS_300 - SiS300Sync(ivideo); + SiS300Sync(ivideo); #endif - } else { + } else { #ifdef CONFIG_FB_SIS_315 - SiS310Sync(ivideo); + SiS310Sync(ivideo); #endif - } + } } #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) /* --------------- 2.5 --------------- */ int fbcon_sis_sync(struct fb_info *info) { - struct sis_video_info *ivideo = (struct sis_video_info *)info->par; - CRITFLAGS + struct sis_video_info *ivideo = (struct sis_video_info *)info->par; + CRITFLAGS - if(!ivideo->accel) - return 0; + if((!ivideo->accel) || (!ivideo->engineok)) + return 0; - if(ivideo->sisvga_engine == SIS_300_VGA) { -#ifdef CONFIG_FB_SIS_300 - SiS300Sync(ivideo); -#endif - } else { -#ifdef CONFIG_FB_SIS_315 - SiS310Sync(ivideo); -#endif - } - CRITEND - return 0; + CRITBEGIN + sisfb_syncaccel(ivideo); + CRITEND + + return 0; } void fbcon_sis_fillrect(struct fb_info *info, const struct fb_fillrect *rect) { - struct sis_video_info *ivideo = (struct sis_video_info *)info->par; - u32 col = 0; - u32 vxres = info->var.xres_virtual; - u32 vyres = info->var.yres_virtual; - int width, height; - CRITFLAGS - - if(info->state != FBINFO_STATE_RUNNING) { - return; - } - - if(!ivideo->accel) { - cfb_fillrect(info, rect); - return; - } - - if(!rect->width || !rect->height || rect->dx >= vxres || rect->dy >= vyres) { - return; - } - - /* Clipping */ - width = ((rect->dx + rect->width) > vxres) ? (vxres - rect->dx) : rect->width; - height = ((rect->dy + rect->height) > vyres) ? (vyres - rect->dy) : rect->height; - - switch(info->var.bits_per_pixel) { + struct sis_video_info *ivideo = (struct sis_video_info *)info->par; + u32 col = 0; + u32 vxres = info->var.xres_virtual; + u32 vyres = info->var.yres_virtual; + int width, height; + CRITFLAGS + + if(info->state != FBINFO_STATE_RUNNING) + return; + + if((!ivideo->accel) || (!ivideo->engineok)) { + cfb_fillrect(info, rect); + return; + } + + if(!rect->width || !rect->height || rect->dx >= vxres || rect->dy >= vyres) + return; + + /* Clipping */ + width = ((rect->dx + rect->width) > vxres) ? (vxres - rect->dx) : rect->width; + height = ((rect->dy + rect->height) > vyres) ? (vyres - rect->dy) : rect->height; + + switch(info->var.bits_per_pixel) { case 8: col = rect->color; break; case 16: case 32: col = ((u32 *)(info->pseudo_palette))[rect->color]; break; - } + } - if(ivideo->sisvga_engine == SIS_300_VGA) { + if(ivideo->sisvga_engine == SIS_300_VGA) { #ifdef CONFIG_FB_SIS_300 - CRITBEGIN - SiS300SetupForSolidFill(ivideo, col, myrops[rect->rop]); - SiS300SubsequentSolidFillRect(ivideo, rect->dx, rect->dy, width, height); - CRITEND - SiS300Sync(ivideo); + CRITBEGIN + SiS300SetupForSolidFill(ivideo, col, myrops[rect->rop]); + SiS300SubsequentSolidFillRect(ivideo, rect->dx, rect->dy, width, height); + CRITEND #endif - } else { + } else { #ifdef CONFIG_FB_SIS_315 - CRITBEGIN - SiS310SetupForSolidFill(ivideo, col, myrops[rect->rop]); - SiS310SubsequentSolidFillRect(ivideo, rect->dx, rect->dy, width, height); - CRITEND - SiS310Sync(ivideo); + CRITBEGIN + SiS310SetupForSolidFill(ivideo, col, myrops[rect->rop]); + SiS310SubsequentSolidFillRect(ivideo, rect->dx, rect->dy, width, height); + CRITEND #endif - } + } + sisfb_syncaccel(ivideo); } void fbcon_sis_copyarea(struct fb_info *info, const struct fb_copyarea *area) { - struct sis_video_info *ivideo = (struct sis_video_info *)info->par; - u32 vxres = info->var.xres_virtual; - u32 vyres = info->var.yres_virtual; - int width = area->width; - int height = area->height; - CRITFLAGS - - if(info->state != FBINFO_STATE_RUNNING) { - return; - } - - if(!ivideo->accel) { - cfb_copyarea(info, area); - return; - } - - if(!width || !height || - area->sx >= vxres || area->sy >= vyres || - area->dx >= vxres || area->dy >= vyres) { - return; - } - - /* Clipping */ - if((area->sx + width) > vxres) width = vxres - area->sx; - if((area->dx + width) > vxres) width = vxres - area->dx; - if((area->sy + height) > vyres) height = vyres - area->sy; - if((area->dy + height) > vyres) height = vyres - area->dy; - - if(ivideo->sisvga_engine == SIS_300_VGA) { -#ifdef CONFIG_FB_SIS_300 - int xdir, ydir; - - if(area->sx < area->dx) xdir = 0; - else xdir = 1; - if(area->sy < area->dy) ydir = 0; - else ydir = 1; - - CRITBEGIN - SiS300SetupForScreenToScreenCopy(ivideo, xdir, ydir, 3, -1); - SiS300SubsequentScreenToScreenCopy(ivideo, area->sx, area->sy, area->dx, area->dy, - width, height); - CRITEND - SiS300Sync(ivideo); -#endif - } else { -#ifdef CONFIG_FB_SIS_315 - CRITBEGIN - SiS310SetupForScreenToScreenCopy(ivideo, 3, -1); - SiS310SubsequentScreenToScreenCopy(ivideo, area->sx, area->sy, area->dx, area->dy, - width, height); - CRITEND - SiS310Sync(ivideo); -#endif - } -} - -#endif - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) /* -------------- 2.4 --------------- */ - -void fbcon_sis_bmove(struct display *p, int srcy, int srcx, - int dsty, int dstx, int height, int width) -{ - struct sis_video_info *ivideo = (struct sis_video_info *)p->fb_info->par; - + struct sis_video_info *ivideo = (struct sis_video_info *)info->par; + u32 vxres = info->var.xres_virtual; + u32 vyres = info->var.yres_virtual; + int width = area->width; + int height = area->height; CRITFLAGS - if(!ivideo->accel) { - switch(ivideo->video_bpp) { - case 8: -#ifdef FBCON_HAS_CFB8 - fbcon_cfb8_bmove(p, srcy, srcx, dsty, dstx, height, width); -#endif - break; - case 16: -#ifdef FBCON_HAS_CFB16 - fbcon_cfb16_bmove(p, srcy, srcx, dsty, dstx, height, width); -#endif - break; - case 32: -#ifdef FBCON_HAS_CFB32 - fbcon_cfb32_bmove(p, srcy, srcx, dsty, dstx, height, width); -#endif - break; - } - return; - } - - srcx *= fontwidth(p); - srcy *= fontheight(p); - dstx *= fontwidth(p); - dsty *= fontheight(p); - width *= fontwidth(p); - height *= fontheight(p); + if(info->state != FBINFO_STATE_RUNNING) + return; - if(ivideo->sisvga_engine == SIS_300_VGA) { -#ifdef CONFIG_FB_SIS_300 - int xdir, ydir; - - if(srcx < dstx) xdir = 0; - else xdir = 1; - if(srcy < dsty) ydir = 0; - else ydir = 1; - - CRITBEGIN - SiS300SetupForScreenToScreenCopy(ivideo, xdir, ydir, 3, -1); - SiS300SubsequentScreenToScreenCopy(ivideo, srcx, srcy, dstx, dsty, width, height); - CRITEND - SiS300Sync(ivideo); -#endif - } else { -#ifdef CONFIG_FB_SIS_315 - CRITBEGIN - SiS310SetupForScreenToScreenCopy(ivideo, 3, -1); - SiS310SubsequentScreenToScreenCopy(ivideo, srcx, srcy, dstx, dsty, width, height); - CRITEND - SiS310Sync(ivideo); -#endif + if((!ivideo->accel) || (!ivideo->engineok)) { + cfb_copyarea(info, area); + return; } -} -static void fbcon_sis_clear(struct vc_data *conp, struct display *p, - int srcy, int srcx, int height, int width, int color) -{ - struct sis_video_info *ivideo = (struct sis_video_info *)p->fb_info->par; - CRITFLAGS + if(!width || !height || + area->sx >= vxres || area->sy >= vyres || + area->dx >= vxres || area->dy >= vyres) + return; - srcx *= fontwidth(p); - srcy *= fontheight(p); - width *= fontwidth(p); - height *= fontheight(p); + /* Clipping */ + if((area->sx + width) > vxres) width = vxres - area->sx; + if((area->dx + width) > vxres) width = vxres - area->dx; + if((area->sy + height) > vyres) height = vyres - area->sy; + if((area->dy + height) > vyres) height = vyres - area->dy; if(ivideo->sisvga_engine == SIS_300_VGA) { #ifdef CONFIG_FB_SIS_300 - CRITBEGIN - SiS300SetupForSolidFill(ivideo, color, 3); - SiS300SubsequentSolidFillRect(ivideo, srcx, srcy, width, height); - CRITEND - SiS300Sync(ivideo); + int xdir, ydir; + + if(area->sx < area->dx) xdir = 0; + else xdir = 1; + if(area->sy < area->dy) ydir = 0; + else ydir = 1; + + CRITBEGIN + SiS300SetupForScreenToScreenCopy(ivideo, xdir, ydir, 3, -1); + SiS300SubsequentScreenToScreenCopy(ivideo, area->sx, area->sy, + area->dx, area->dy, width, height); + CRITEND #endif } else { #ifdef CONFIG_FB_SIS_315 - CRITBEGIN - SiS310SetupForSolidFill(ivideo, color, 3); - SiS310SubsequentSolidFillRect(ivideo, srcx, srcy, width, height); - CRITEND - SiS310Sync(ivideo); -#endif - } -} - -void fbcon_sis_clear8(struct vc_data *conp, struct display *p, - int srcy, int srcx, int height, int width) -{ - struct sis_video_info *ivideo = (struct sis_video_info *)p->fb_info->par; - u32 bgx; - - if(!ivideo->accel) { -#ifdef FBCON_HAS_CFB8 - fbcon_cfb8_clear(conp, p, srcy, srcx, height, width); + CRITBEGIN + SiS310SetupForScreenToScreenCopy(ivideo, 3, -1); + SiS310SubsequentScreenToScreenCopy(ivideo, area->sx, area->sy, + area->dx, area->dy, width, height); + CRITEND #endif - return; } - bgx = attr_bgcol_ec(p, conp); - fbcon_sis_clear(conp, p, srcy, srcx, height, width, bgx); + sisfb_syncaccel(ivideo); } -void fbcon_sis_clear16(struct vc_data *conp, struct display *p, - int srcy, int srcx, int height, int width) -{ - struct sis_video_info *ivideo = (struct sis_video_info *)p->fb_info->par; - u32 bgx; - - if(!ivideo->accel) { -#ifdef FBCON_HAS_CFB16 - fbcon_cfb16_clear(conp, p, srcy, srcx, height, width); #endif - return; - } - - bgx = ((u_int16_t*)p->dispsw_data)[attr_bgcol_ec(p, conp)]; - fbcon_sis_clear(conp, p, srcy, srcx, height, width, bgx); -} -void fbcon_sis_clear32(struct vc_data *conp, struct display *p, - int srcy, int srcx, int height, int width) -{ - struct sis_video_info *ivideo = (struct sis_video_info *)p->fb_info->par; - u32 bgx; - - if(!ivideo->accel) { -#ifdef FBCON_HAS_CFB32 - fbcon_cfb32_clear(conp, p, srcy, srcx, height, width); -#endif - return; - } - - bgx = ((u_int32_t*)p->dispsw_data)[attr_bgcol_ec(p, conp)]; - fbcon_sis_clear(conp, p, srcy, srcx, height, width, bgx); -} - -void fbcon_sis_revc(struct display *p, int srcx, int srcy) -{ - struct sis_video_info *ivideo = (struct sis_video_info *)p->fb_info->par; - CRITFLAGS - - if(!ivideo->accel) { - switch(ivideo->video_bpp) { - case 16: -#ifdef FBCON_HAS_CFB16 - fbcon_cfb16_revc(p, srcx, srcy); -#endif - break; - case 32: -#ifdef FBCON_HAS_CFB32 - fbcon_cfb32_revc(p, srcx, srcy); -#endif - break; - } - return; - } - - srcx *= fontwidth(p); - srcy *= fontheight(p); - - if(ivideo->sisvga_engine == SIS_300_VGA) { -#ifdef CONFIG_FB_SIS_300 - CRITBEGIN - SiS300SetupForSolidFill(ivideo, 0, 0x0a); - SiS300SubsequentSolidFillRect(ivideo, srcx, srcy, fontwidth(p), fontheight(p)); - CRITEND - SiS300Sync(ivideo); -#endif - } else { -#ifdef CONFIG_FB_SIS_315 - CRITBEGIN - SiS310SetupForSolidFill(ivideo, 0, 0x0a); - SiS310SubsequentSolidFillRect(ivideo, srcx, srcy, fontwidth(p), fontheight(p)); - CRITEND - SiS310Sync(ivideo); -#endif - } -} +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) /* -------------- 2.4 --------------- */ -#ifdef FBCON_HAS_CFB8 -struct display_switch fbcon_sis8 = { - .setup = fbcon_cfb8_setup, - .bmove = fbcon_sis_bmove, - .clear = fbcon_sis_clear8, - .putc = fbcon_cfb8_putc, - .putcs = fbcon_cfb8_putcs, - .revc = fbcon_cfb8_revc, - .clear_margins = fbcon_cfb8_clear_margins, - .fontwidthmask = FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16) -}; -#endif -#ifdef FBCON_HAS_CFB16 -struct display_switch fbcon_sis16 = { - .setup = fbcon_cfb16_setup, - .bmove = fbcon_sis_bmove, - .clear = fbcon_sis_clear16, - .putc = fbcon_cfb16_putc, - .putcs = fbcon_cfb16_putcs, - .revc = fbcon_sis_revc, - .clear_margins = fbcon_cfb16_clear_margins, - .fontwidthmask = FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16) -}; -#endif -#ifdef FBCON_HAS_CFB32 -struct display_switch fbcon_sis32 = { - .setup = fbcon_cfb32_setup, - .bmove = fbcon_sis_bmove, - .clear = fbcon_sis_clear32, - .putc = fbcon_cfb32_putc, - .putcs = fbcon_cfb32_putcs, - .revc = fbcon_sis_revc, - .clear_margins = fbcon_cfb32_clear_margins, - .fontwidthmask = FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16) -}; -#endif +#include "sisfb_accel_2_4.h" #endif /* KERNEL VERSION */ diff --git a/drivers/video/sis/sis_accel.h b/drivers/video/sis/sis_accel.h index bb28f331d60..046e2c4a8e0 100644 --- a/drivers/video/sis/sis_accel.h +++ b/drivers/video/sis/sis_accel.h @@ -1,6 +1,8 @@ /* - * SiS 300/630/730/540/315/550/650/740 frame buffer driver - * for Linux kernels 2.4.x and 2.5.x + * SiS 300/540/630[S]/730[S], + * SiS 315[E|PRO]/550/[M]650/651/[M]661[F|M]X/740/[M]741[GX]/330/[M]760[GX], + * XGI V3XT/V5/V8, Z7 + * frame buffer driver for Linux kernels >= 2.4.14 and >=2.6.3 * * 2D acceleration part * @@ -283,6 +285,8 @@ { \ while( (MMIO_IN16(ivideo->mmio_vbase, Q_STATUS+2) & 0x8000) != 0x8000){}; \ while( (MMIO_IN16(ivideo->mmio_vbase, Q_STATUS+2) & 0x8000) != 0x8000){}; \ + while( (MMIO_IN16(ivideo->mmio_vbase, Q_STATUS+2) & 0x8000) != 0x8000){}; \ + while( (MMIO_IN16(ivideo->mmio_vbase, Q_STATUS+2) & 0x8000) != 0x8000){}; \ CmdQueLen = 0; \ } @@ -402,6 +406,7 @@ void fbcon_sis_clear32(struct vc_data *conp, struct display *p, int srcy, int srcx, int height, int width); #endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,34) +int fbcon_sis_sync(struct fb_info *info); void fbcon_sis_fillrect(struct fb_info *info, const struct fb_fillrect *rect); void fbcon_sis_copyarea(struct fb_info *info, const struct fb_copyarea *area); #endif diff --git a/drivers/video/sis/sis_main.c b/drivers/video/sis/sis_main.c index 69826603681..42c54b69726 100644 --- a/drivers/video/sis/sis_main.c +++ b/drivers/video/sis/sis_main.c @@ -1,9 +1,10 @@ /* - * SiS 300/305/540/630(S)/730(S) - * SiS 315(H/PRO)/55x/(M)65x/(M)661(F/M)X/740/741(GX)/330/(M)760 + * SiS 300/540/630[S]/730[S], + * SiS 315[E|PRO]/550/[M]65x/[M]66x[F|M|G]X/[M]74x[GX]/330/[M]76x[GX], + * XGI V3XT/V5/V8, Z7 * frame buffer driver for Linux kernels >= 2.4.14 and >=2.6.3 * - * Copyright (C) 2001-2004 Thomas Winischhofer, Vienna, Austria. + * Copyright (C) 2001-2005 Thomas Winischhofer, Vienna, Austria. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,11 +20,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA * - * Author: Thomas Winischhofer <thomas@winischhofer.net> + * Author: Thomas Winischhofer <thomas@winischhofer.net> * * Author of (practically wiped) code base: * SiS (www.sis.com) - * Copyright (C) 1999 Silicon Integrated Systems, Inc. + * Copyright (C) 1999 Silicon Integrated Systems, Inc. * * See http://www.winischhofer.net/ for more information and updates * @@ -46,16 +47,15 @@ #include <linux/mm.h> #include <linux/tty.h> #include <linux/slab.h> -#include <linux/delay.h> #include <linux/fb.h> -#include <linux/console.h> #include <linux/selection.h> -#include <linux/smp_lock.h> #include <linux/ioport.h> #include <linux/init.h> #include <linux/pci.h> #include <linux/vmalloc.h> +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) #include <linux/vt_kern.h> +#endif #include <linux/capability.h> #include <linux/fs.h> #include <linux/types.h> @@ -94,71 +94,75 @@ extern struct display_switch fbcon_sis32; #endif #endif +static void sisfb_handle_command(struct sis_video_info *ivideo, + struct sisfb_cmd *sisfb_command); + /* ------------------ Internal helper routines ----------------- */ static void __init sisfb_setdefaultparms(void) { - sisfb_off = 0; - sisfb_parm_mem = 0; - sisfb_accel = -1; - sisfb_ypan = -1; - sisfb_max = -1; - sisfb_userom = -1; - sisfb_useoem = -1; + sisfb_off = 0; + sisfb_parm_mem = 0; + sisfb_accel = -1; + sisfb_ypan = -1; + sisfb_max = -1; + sisfb_userom = -1; + sisfb_useoem = -1; #ifdef MODULE /* Module: "None" for 2.4, default mode for 2.5+ */ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) - sisfb_mode_idx = -1; + sisfb_mode_idx = -1; #else - sisfb_mode_idx = MODE_INDEX_NONE; + sisfb_mode_idx = MODE_INDEX_NONE; #endif #else /* Static: Default mode */ - sisfb_mode_idx = -1; -#endif - sisfb_parm_rate = -1; - sisfb_crt1off = 0; - sisfb_forcecrt1 = -1; - sisfb_crt2type = -1; - sisfb_crt2flags = 0; - sisfb_pdc = 0xff; - sisfb_pdca = 0xff; - sisfb_scalelcd = -1; + sisfb_mode_idx = -1; +#endif + sisfb_parm_rate = -1; + sisfb_crt1off = 0; + sisfb_forcecrt1 = -1; + sisfb_crt2type = -1; + sisfb_crt2flags = 0; + sisfb_pdc = 0xff; + sisfb_pdca = 0xff; + sisfb_scalelcd = -1; sisfb_specialtiming = CUT_NONE; - sisfb_lvdshl = -1; - sisfb_dstn = 0; - sisfb_fstn = 0; - sisfb_tvplug = -1; - sisfb_tvstd = -1; - sisfb_tvxposoffset = 0; - sisfb_tvyposoffset = 0; - sisfb_filter = -1; - sisfb_nocrt2rate = 0; + sisfb_lvdshl = -1; + sisfb_dstn = 0; + sisfb_fstn = 0; + sisfb_tvplug = -1; + sisfb_tvstd = -1; + sisfb_tvxposoffset = 0; + sisfb_tvyposoffset = 0; + sisfb_nocrt2rate = 0; #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - sisfb_inverse = 0; - sisfb_fontname[0] = 0; + sisfb_inverse = 0; + sisfb_fontname[0] = 0; #endif #if !defined(__i386__) && !defined(__x86_64__) - sisfb_resetcard = 0; - sisfb_videoram = 0; + sisfb_resetcard = 0; + sisfb_videoram = 0; #endif } +/* ------------- Parameter parsing -------------- */ + static void __devinit sisfb_search_vesamode(unsigned int vesamode, BOOLEAN quiet) { int i = 0, j = 0; - /* BEWARE: We don't know the hardware specs yet and there is no ivideo */ + /* We don't know the hardware specs yet and there is no ivideo */ if(vesamode == 0) { #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) sisfb_mode_idx = MODE_INDEX_NONE; #else - if(!quiet) { - printk(KERN_ERR "sisfb: Invalid mode. Using default.\n"); - } + if(!quiet) + printk(KERN_ERR "sisfb: Invalid mode. Using default.\n"); + sisfb_mode_idx = DEFAULT_MODE; #endif return; @@ -169,95 +173,102 @@ sisfb_search_vesamode(unsigned int vesamode, BOOLEAN quiet) while(sisbios_mode[i++].mode_no[0] != 0) { if( (sisbios_mode[i-1].vesa_mode_no_1 == vesamode) || (sisbios_mode[i-1].vesa_mode_no_2 == vesamode) ) { - if(sisfb_fstn) { - if(sisbios_mode[i-1].mode_no[1] == 0x50 || - sisbios_mode[i-1].mode_no[1] == 0x56 || - sisbios_mode[i-1].mode_no[1] == 0x53) continue; - } else { - if(sisbios_mode[i-1].mode_no[1] == 0x5a || - sisbios_mode[i-1].mode_no[1] == 0x5b) continue; - } - sisfb_mode_idx = i - 1; - j = 1; - break; + if(sisfb_fstn) { + if(sisbios_mode[i-1].mode_no[1] == 0x50 || + sisbios_mode[i-1].mode_no[1] == 0x56 || + sisbios_mode[i-1].mode_no[1] == 0x53) + continue; + } else { + if(sisbios_mode[i-1].mode_no[1] == 0x5a || + sisbios_mode[i-1].mode_no[1] == 0x5b) + continue; + } + sisfb_mode_idx = i - 1; + j = 1; + break; } } - if((!j) && !quiet) printk(KERN_ERR "sisfb: Invalid VESA mode 0x%x'\n", vesamode); + if((!j) && !quiet) + printk(KERN_ERR "sisfb: Invalid VESA mode 0x%x'\n", vesamode); } -static void +static void __devinit sisfb_search_mode(char *name, BOOLEAN quiet) { - int i = 0; unsigned int j = 0, xres = 0, yres = 0, depth = 0, rate = 0; + int i = 0; char strbuf[16], strbuf1[20]; char *nameptr = name; - /* BEWARE: We don't know the hardware specs yet and there is no ivideo */ + /* We don't know the hardware specs yet and there is no ivideo */ if(name == NULL) { - if(!quiet) { - printk(KERN_ERR "sisfb: Internal error, using default mode.\n"); - } - sisfb_mode_idx = DEFAULT_MODE; - return; + if(!quiet) + printk(KERN_ERR "sisfb: Internal error, using default mode.\n"); + + sisfb_mode_idx = DEFAULT_MODE; + return; } #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) - if(!strnicmp(name, sisbios_mode[MODE_INDEX_NONE].name, strlen(name))) { - if(!quiet) { - printk(KERN_ERR "sisfb: Mode 'none' not supported anymore. Using default.\n"); - } - sisfb_mode_idx = DEFAULT_MODE; - return; + if(!strnicmp(name, sisbios_mode[MODE_INDEX_NONE].name, strlen(name))) { + if(!quiet) + printk(KERN_ERR "sisfb: Mode 'none' not supported anymore. Using default.\n"); + + sisfb_mode_idx = DEFAULT_MODE; + return; } #endif if(strlen(name) <= 19) { - strcpy(strbuf1, name); - for(i=0; i<strlen(strbuf1); i++) { - if(strbuf1[i] < '0' || strbuf1[i] > '9') strbuf1[i] = ' '; - } + strcpy(strbuf1, name); + for(i = 0; i < strlen(strbuf1); i++) { + if(strbuf1[i] < '0' || strbuf1[i] > '9') strbuf1[i] = ' '; + } - /* This does some fuzzy mode naming detection */ - if(sscanf(strbuf1, "%u %u %u %u", &xres, &yres, &depth, &rate) == 4) { - if((rate <= 32) || (depth > 32)) { - j = rate; rate = depth; depth = j; - } - sprintf(strbuf, "%ux%ux%u", xres, yres, depth); - nameptr = strbuf; - sisfb_parm_rate = rate; - } else if(sscanf(strbuf1, "%u %u %u", &xres, &yres, &depth) == 3) { - sprintf(strbuf, "%ux%ux%u", xres, yres, depth); - nameptr = strbuf; - } else { - xres = 0; - if((sscanf(strbuf1, "%u %u", &xres, &yres) == 2) && (xres != 0)) { - sprintf(strbuf, "%ux%ux8", xres, yres); - nameptr = strbuf; - } else { - sisfb_search_vesamode(simple_strtoul(name, NULL, 0), quiet); - return; - } - } + /* This does some fuzzy mode naming detection */ + if(sscanf(strbuf1, "%u %u %u %u", &xres, &yres, &depth, &rate) == 4) { + if((rate <= 32) || (depth > 32)) { + j = rate; rate = depth; depth = j; + } + sprintf(strbuf, "%ux%ux%u", xres, yres, depth); + nameptr = strbuf; + sisfb_parm_rate = rate; + } else if(sscanf(strbuf1, "%u %u %u", &xres, &yres, &depth) == 3) { + sprintf(strbuf, "%ux%ux%u", xres, yres, depth); + nameptr = strbuf; + } else { + xres = 0; + if((sscanf(strbuf1, "%u %u", &xres, &yres) == 2) && (xres != 0)) { + sprintf(strbuf, "%ux%ux8", xres, yres); + nameptr = strbuf; + } else { + sisfb_search_vesamode(simple_strtoul(name, NULL, 0), quiet); + return; + } + } } i = 0; j = 0; while(sisbios_mode[i].mode_no[0] != 0) { if(!strnicmp(nameptr, sisbios_mode[i++].name, strlen(nameptr))) { - if(sisfb_fstn) { - if(sisbios_mode[i-1].mode_no[1] == 0x50 || - sisbios_mode[i-1].mode_no[1] == 0x56 || - sisbios_mode[i-1].mode_no[1] == 0x53) continue; - } else { - if(sisbios_mode[i-1].mode_no[1] == 0x5a || - sisbios_mode[i-1].mode_no[1] == 0x5b) continue; - } - sisfb_mode_idx = i - 1; - j = 1; - break; - } - } - if((!j) && !quiet) printk(KERN_ERR "sisfb: Invalid mode '%s'\n", nameptr); + if(sisfb_fstn) { + if(sisbios_mode[i-1].mode_no[1] == 0x50 || + sisbios_mode[i-1].mode_no[1] == 0x56 || + sisbios_mode[i-1].mode_no[1] == 0x53) + continue; + } else { + if(sisbios_mode[i-1].mode_no[1] == 0x5a || + sisbios_mode[i-1].mode_no[1] == 0x5b) + continue; + } + sisfb_mode_idx = i - 1; + j = 1; + break; + } + } + + if((!j) && !quiet) + printk(KERN_ERR "sisfb: Invalid mode '%s'\n", nameptr); } #ifndef MODULE @@ -265,7 +276,7 @@ static void __devinit sisfb_get_vga_mode_from_kernel(void) { #if (defined(__i386__) || defined(__x86_64__)) && defined(CONFIG_VIDEO_SELECT) - char mymode[32]; + char mymode[32]; int mydepth = screen_info.lfb_depth; if(screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB) return; @@ -274,15 +285,17 @@ sisfb_get_vga_mode_from_kernel(void) (screen_info.lfb_height >= 200) && (screen_info.lfb_height <= 1536) && (mydepth >= 8) && (mydepth <= 32) ) { - if(mydepth == 24) mydepth = 32; + if(mydepth == 24) mydepth = 32; - sprintf(mymode, "%ux%ux%u", screen_info.lfb_width, - screen_info.lfb_height, + sprintf(mymode, "%ux%ux%u", screen_info.lfb_width, + screen_info.lfb_height, mydepth); - printk(KERN_DEBUG "sisfb: Using vga mode %s pre-set by kernel as default\n", mymode); + printk(KERN_DEBUG + "sisfb: Using vga mode %s pre-set by kernel as default\n", + mymode); - sisfb_search_mode(mymode, TRUE); + sisfb_search_mode(mymode, TRUE); } #endif return; @@ -294,26 +307,25 @@ sisfb_search_crt2type(const char *name) { int i = 0; - /* BEWARE: We don't know the hardware specs yet and there is no ivideo */ + /* We don't know the hardware specs yet and there is no ivideo */ if(name == NULL) return; while(sis_crt2type[i].type_no != -1) { - if(!strnicmp(name, sis_crt2type[i].name, strlen(sis_crt2type[i].name))) { - sisfb_crt2type = sis_crt2type[i].type_no; - sisfb_tvplug = sis_crt2type[i].tvplug_no; - sisfb_crt2flags = sis_crt2type[i].flags; - break; - } - i++; + if(!strnicmp(name, sis_crt2type[i].name, strlen(sis_crt2type[i].name))) { + sisfb_crt2type = sis_crt2type[i].type_no; + sisfb_tvplug = sis_crt2type[i].tvplug_no; + sisfb_crt2flags = sis_crt2type[i].flags; + break; + } + i++; } sisfb_dstn = (sisfb_crt2flags & FL_550_DSTN) ? 1 : 0; sisfb_fstn = (sisfb_crt2flags & FL_550_FSTN) ? 1 : 0; - if(sisfb_crt2type < 0) { + if(sisfb_crt2type < 0) printk(KERN_ERR "sisfb: Invalid CRT2 type: %s\n", name); - } } static void __init @@ -321,16 +333,17 @@ sisfb_search_tvstd(const char *name) { int i = 0; - /* BEWARE: We don't know the hardware specs yet and there is no ivideo */ + /* We don't know the hardware specs yet and there is no ivideo */ - if(name == NULL) return; + if(name == NULL) + return; while(sis_tvtype[i].type_no != -1) { - if(!strnicmp(name, sis_tvtype[i].name, strlen(sis_tvtype[i].name))) { - sisfb_tvstd = sis_tvtype[i].type_no; - break; - } - i++; + if(!strnicmp(name, sis_tvtype[i].name, strlen(sis_tvtype[i].name))) { + sisfb_tvstd = sis_tvtype[i].type_no; + break; + } + i++; } } @@ -340,38 +353,101 @@ sisfb_search_specialtiming(const char *name) int i = 0; BOOLEAN found = FALSE; - /* BEWARE: We don't know the hardware specs yet and there is no ivideo */ + /* We don't know the hardware specs yet and there is no ivideo */ - if(name == NULL) return; + if(name == NULL) + return; if(!strnicmp(name, "none", 4)) { - sisfb_specialtiming = CUT_FORCENONE; + sisfb_specialtiming = CUT_FORCENONE; printk(KERN_DEBUG "sisfb: Special timing disabled\n"); } else { - while(mycustomttable[i].chipID != 0) { - if(!strnicmp(name,mycustomttable[i].optionName, strlen(mycustomttable[i].optionName))) { - sisfb_specialtiming = mycustomttable[i].SpecialID; - found = TRUE; - printk(KERN_INFO "sisfb: Special timing for %s %s forced (\"%s\")\n", - mycustomttable[i].vendorName, mycustomttable[i].cardName, - mycustomttable[i].optionName); - break; - } - i++; - } - if(!found) { - printk(KERN_WARNING "sisfb: Invalid SpecialTiming parameter, valid are:"); - printk(KERN_WARNING "\t\"none\" (to disable special timings)\n"); - i = 0; - while(mycustomttable[i].chipID != 0) { - printk(KERN_WARNING "\t\"%s\" (for %s %s)\n", - mycustomttable[i].optionName, - mycustomttable[i].vendorName, - mycustomttable[i].cardName); - i++; - } - } - } + while(mycustomttable[i].chipID != 0) { + if(!strnicmp(name,mycustomttable[i].optionName, + strlen(mycustomttable[i].optionName))) { + sisfb_specialtiming = mycustomttable[i].SpecialID; + found = TRUE; + printk(KERN_INFO "sisfb: Special timing for %s %s forced (\"%s\")\n", + mycustomttable[i].vendorName, + mycustomttable[i].cardName, + mycustomttable[i].optionName); + break; + } + i++; + } + if(!found) { + printk(KERN_WARNING "sisfb: Invalid SpecialTiming parameter, valid are:"); + printk(KERN_WARNING "\t\"none\" (to disable special timings)\n"); + i = 0; + while(mycustomttable[i].chipID != 0) { + printk(KERN_WARNING "\t\"%s\" (for %s %s)\n", + mycustomttable[i].optionName, + mycustomttable[i].vendorName, + mycustomttable[i].cardName); + i++; + } + } + } +} + +/* ----------- Various detection routines ----------- */ + +static void __devinit +sisfb_detect_custom_timing(struct sis_video_info *ivideo) +{ + unsigned char *biosver = NULL; + unsigned char *biosdate = NULL; + BOOLEAN footprint; + u32 chksum = 0; + int i, j; + + if(ivideo->SiS_Pr.UseROM) { + biosver = ivideo->SiS_Pr.VirtualRomBase + 0x06; + biosdate = ivideo->SiS_Pr.VirtualRomBase + 0x2c; + for(i = 0; i < 32768; i++) + chksum += ivideo->SiS_Pr.VirtualRomBase[i]; + } + + i = 0; + do { + if( (mycustomttable[i].chipID == ivideo->chip) && + ((!strlen(mycustomttable[i].biosversion)) || + (ivideo->SiS_Pr.UseROM && + (!strncmp(mycustomttable[i].biosversion, biosver, + strlen(mycustomttable[i].biosversion))))) && + ((!strlen(mycustomttable[i].biosdate)) || + (ivideo->SiS_Pr.UseROM && + (!strncmp(mycustomttable[i].biosdate, biosdate, + strlen(mycustomttable[i].biosdate))))) && + ((!mycustomttable[i].bioschksum) || + (ivideo->SiS_Pr.UseROM && + (mycustomttable[i].bioschksum == chksum))) && + (mycustomttable[i].pcisubsysvendor == ivideo->subsysvendor) && + (mycustomttable[i].pcisubsyscard == ivideo->subsysdevice) ) { + footprint = TRUE; + for(j = 0; j < 5; j++) { + if(mycustomttable[i].biosFootprintAddr[j]) { + if(ivideo->SiS_Pr.UseROM) { + if(ivideo->SiS_Pr.VirtualRomBase[mycustomttable[i].biosFootprintAddr[j]] != + mycustomttable[i].biosFootprintData[j]) { + footprint = FALSE; + } + } else + footprint = FALSE; + } + } + if(footprint) { + ivideo->SiS_Pr.SiS_CustomT = mycustomttable[i].SpecialID; + printk(KERN_DEBUG "sisfb: Identified [%s %s], special timing applies\n", + mycustomttable[i].vendorName, + mycustomttable[i].cardName); + printk(KERN_DEBUG "sisfb: [specialtiming parameter name: %s]\n", + mycustomttable[i].optionName); + break; + } + } + i++; + } while(mycustomttable[i].chipID); } static BOOLEAN __devinit @@ -384,22 +460,23 @@ sisfb_interpret_edid(struct sisfb_monitor *monitor, u8 *buffer) buffer[2] != 0xff || buffer[3] != 0xff || buffer[4] != 0xff || buffer[5] != 0xff || buffer[6] != 0xff || buffer[7] != 0x00) { - printk(KERN_DEBUG "sisfb: Bad EDID header\n"); - return FALSE; + printk(KERN_DEBUG "sisfb: Bad EDID header\n"); + return FALSE; } if(buffer[0x12] != 0x01) { - printk(KERN_INFO "sisfb: EDID version %d not supported\n", - buffer[0x12]); - return FALSE; + printk(KERN_INFO "sisfb: EDID version %d not supported\n", + buffer[0x12]); + return FALSE; } monitor->feature = buffer[0x18]; if(!buffer[0x14] & 0x80) { - if(!(buffer[0x14] & 0x08)) { - printk(KERN_INFO "sisfb: WARNING: Monitor does not support separate syncs\n"); - } + if(!(buffer[0x14] & 0x08)) { + printk(KERN_INFO + "sisfb: WARNING: Monitor does not support separate syncs\n"); + } } if(buffer[0x13] >= 0x01) { @@ -409,7 +486,7 @@ sisfb_interpret_edid(struct sisfb_monitor *monitor, u8 *buffer) j = 0x36; for(i=0; i<4; i++) { if(buffer[j] == 0x00 && buffer[j + 1] == 0x00 && - buffer[j + 2] == 0x00 && buffer[j + 3] == 0xfd && + buffer[j + 2] == 0x00 && buffer[j + 3] == 0xfd && buffer[j + 4] == 0x00) { monitor->hmin = buffer[j + 7]; monitor->hmax = buffer[j + 8]; @@ -435,7 +512,7 @@ sisfb_interpret_edid(struct sisfb_monitor *monitor, u8 *buffer) emodes = buffer[0x23] | (buffer[0x24] << 8) | (buffer[0x25] << 16); for(i = 0; i < 13; i++) { if(emodes & sisfb_ddcsmodes[i].mask) { - if(monitor->hmin > sisfb_ddcsmodes[i].h) monitor->hmin = sisfb_ddcsmodes[i].h; + if(monitor->hmin > sisfb_ddcsmodes[i].h) monitor->hmin = sisfb_ddcsmodes[i].h; if(monitor->hmax < sisfb_ddcsmodes[i].h) monitor->hmax = sisfb_ddcsmodes[i].h + 1; if(monitor->vmin > sisfb_ddcsmodes[i].v) monitor->vmin = sisfb_ddcsmodes[i].v; if(monitor->vmax < sisfb_ddcsmodes[i].v) monitor->vmax = sisfb_ddcsmodes[i].v; @@ -446,80 +523,81 @@ sisfb_interpret_edid(struct sisfb_monitor *monitor, u8 *buffer) for(i = 0; i < 8; i++) { xres = (buffer[index] + 31) * 8; switch(buffer[index + 1] & 0xc0) { - case 0xc0: yres = (xres * 9) / 16; break; - case 0x80: yres = (xres * 4) / 5; break; - case 0x40: yres = (xres * 3) / 4; break; - default: yres = xres; break; + case 0xc0: yres = (xres * 9) / 16; break; + case 0x80: yres = (xres * 4) / 5; break; + case 0x40: yres = (xres * 3) / 4; break; + default: yres = xres; break; } refresh = (buffer[index + 1] & 0x3f) + 60; if((xres >= 640) && (yres >= 480)) { - for(j = 0; j < 8; j++) { - if((xres == sisfb_ddcfmodes[j].x) && - (yres == sisfb_ddcfmodes[j].y) && + for(j = 0; j < 8; j++) { + if((xres == sisfb_ddcfmodes[j].x) && + (yres == sisfb_ddcfmodes[j].y) && (refresh == sisfb_ddcfmodes[j].v)) { if(monitor->hmin > sisfb_ddcfmodes[j].h) monitor->hmin = sisfb_ddcfmodes[j].h; if(monitor->hmax < sisfb_ddcfmodes[j].h) monitor->hmax = sisfb_ddcfmodes[j].h + 1; if(monitor->vmin > sisfb_ddcsmodes[j].v) monitor->vmin = sisfb_ddcsmodes[j].v; if(monitor->vmax < sisfb_ddcsmodes[j].v) monitor->vmax = sisfb_ddcsmodes[j].v; - if(monitor->dclockmax < sisfb_ddcsmodes[j].d) monitor->dclockmax = sisfb_ddcsmodes[i].d; - } - } + if(monitor->dclockmax < sisfb_ddcsmodes[j].d) monitor->dclockmax = sisfb_ddcsmodes[j].d; + } + } } index += 2; - } + } if((monitor->hmin <= monitor->hmax) && (monitor->vmin <= monitor->vmax)) { monitor->datavalid = TRUE; } } - return(monitor->datavalid); + return monitor->datavalid; } static void __devinit sisfb_handle_ddc(struct sis_video_info *ivideo, struct sisfb_monitor *monitor, int crtno) { - USHORT temp, i, realcrtno = crtno; - u8 buffer[256]; + unsigned short temp, i, realcrtno = crtno; + unsigned char buffer[256]; monitor->datavalid = FALSE; if(crtno) { - if(ivideo->vbflags & CRT2_LCD) realcrtno = 1; - else if(ivideo->vbflags & CRT2_VGA) realcrtno = 2; - else return; - } + if(ivideo->vbflags & CRT2_LCD) realcrtno = 1; + else if(ivideo->vbflags & CRT2_VGA) realcrtno = 2; + else return; + } - if((ivideo->sisfb_crt1off) && (!crtno)) return; + if((ivideo->sisfb_crt1off) && (!crtno)) + return; - temp = SiS_HandleDDC(&ivideo->SiS_Pr, ivideo->vbflags, ivideo->sisvga_engine, - realcrtno, 0, &buffer[0]); - if((!temp) || (temp == 0xffff)) { - printk(KERN_INFO "sisfb: CRT%d DDC probing failed\n", crtno + 1); + temp = SiS_HandleDDC(&ivideo->SiS_Pr, ivideo->vbflags, ivideo->sisvga_engine, + realcrtno, 0, &buffer[0], ivideo->vbflags2); + if((!temp) || (temp == 0xffff)) { + printk(KERN_INFO "sisfb: CRT%d DDC probing failed\n", crtno + 1); return; - } else { - printk(KERN_INFO "sisfb: CRT%d DDC supported\n", crtno + 1); - printk(KERN_INFO "sisfb: CRT%d DDC level: %s%s%s%s\n", - crtno + 1, - (temp & 0x1a) ? "" : "[none of the supported]", - (temp & 0x02) ? "2 " : "", - (temp & 0x08) ? "D&P" : "", - (temp & 0x10) ? "FPDI-2" : ""); - if(temp & 0x02) { + } else { + printk(KERN_INFO "sisfb: CRT%d DDC supported\n", crtno + 1); + printk(KERN_INFO "sisfb: CRT%d DDC level: %s%s%s%s\n", + crtno + 1, + (temp & 0x1a) ? "" : "[none of the supported]", + (temp & 0x02) ? "2 " : "", + (temp & 0x08) ? "D&P" : "", + (temp & 0x10) ? "FPDI-2" : ""); + if(temp & 0x02) { i = 3; /* Number of retrys */ do { - temp = SiS_HandleDDC(&ivideo->SiS_Pr, ivideo->vbflags, ivideo->sisvga_engine, - realcrtno, 1, &buffer[0]); + temp = SiS_HandleDDC(&ivideo->SiS_Pr, ivideo->vbflags, ivideo->sisvga_engine, + realcrtno, 1, &buffer[0], ivideo->vbflags2); } while((temp) && i--); - if(!temp) { - if(sisfb_interpret_edid(monitor, &buffer[0])) { + if(!temp) { + if(sisfb_interpret_edid(monitor, &buffer[0])) { printk(KERN_INFO "sisfb: Monitor range H %d-%dKHz, V %d-%dHz, Max. dotclock %dMHz\n", - monitor->hmin, monitor->hmax, monitor->vmin, monitor->vmax, + monitor->hmin, monitor->hmax, monitor->vmin, monitor->vmax, monitor->dclockmax / 1000); } else { - printk(KERN_INFO "sisfb: CRT%d DDC EDID corrupt\n", crtno + 1); - } + printk(KERN_INFO "sisfb: CRT%d DDC EDID corrupt\n", crtno + 1); + } } else { - printk(KERN_INFO "sisfb: CRT%d DDC reading failed\n", crtno + 1); + printk(KERN_INFO "sisfb: CRT%d DDC reading failed\n", crtno + 1); } } else { printk(KERN_INFO "sisfb: VESA D&P and FPDI-2 not supported yet\n"); @@ -527,6 +605,8 @@ sisfb_handle_ddc(struct sis_video_info *ivideo, struct sisfb_monitor *monitor, i } } +/* -------------- Mode validation --------------- */ + static BOOLEAN sisfb_verify_rate(struct sis_video_info *ivideo, struct sisfb_monitor *monitor, int mode_idx, int rate_idx, int rate) @@ -534,42 +614,49 @@ sisfb_verify_rate(struct sis_video_info *ivideo, struct sisfb_monitor *monitor, int htotal, vtotal; unsigned int dclock, hsync; - if(!monitor->datavalid) return TRUE; + if(!monitor->datavalid) + return TRUE; - if(mode_idx < 0) return FALSE; + if(mode_idx < 0) + return FALSE; /* Skip for 320x200, 320x240, 640x400 */ - switch(sisbios_mode[mode_idx].mode_no[ivideo->mni]) { - case 0x59: - case 0x41: - case 0x4f: - case 0x50: - case 0x56: - case 0x53: - case 0x2f: - case 0x5d: - case 0x5e: - return TRUE; + switch(sisbios_mode[mode_idx].mode_no[ivideo->mni]) { + case 0x59: + case 0x41: + case 0x4f: + case 0x50: + case 0x56: + case 0x53: + case 0x2f: + case 0x5d: + case 0x5e: + return TRUE; #ifdef CONFIG_FB_SIS_315 case 0x5a: case 0x5b: if(ivideo->sisvga_engine == SIS_315_VGA) return TRUE; #endif - } + } - if(rate < (monitor->vmin - 1)) return FALSE; - if(rate > (monitor->vmax + 1)) return FALSE; + if(rate < (monitor->vmin - 1)) + return FALSE; + if(rate > (monitor->vmax + 1)) + return FALSE; - if(sisfb_gettotalfrommode(&ivideo->SiS_Pr, &ivideo->sishw_ext, + if(sisfb_gettotalfrommode(&ivideo->SiS_Pr, sisbios_mode[mode_idx].mode_no[ivideo->mni], - &htotal, &vtotal, rate_idx)) { + &htotal, &vtotal, rate_idx)) { dclock = (htotal * vtotal * rate) / 1000; - if(dclock > (monitor->dclockmax + 1000)) return FALSE; + if(dclock > (monitor->dclockmax + 1000)) + return FALSE; hsync = dclock / htotal; - if(hsync < (monitor->hmin - 1)) return FALSE; - if(hsync > (monitor->hmax + 1)) return FALSE; + if(hsync < (monitor->hmin - 1)) + return FALSE; + if(hsync > (monitor->hmax + 1)) + return FALSE; } else { - return FALSE; + return FALSE; } return TRUE; } @@ -577,82 +664,79 @@ sisfb_verify_rate(struct sis_video_info *ivideo, struct sisfb_monitor *monitor, static int sisfb_validate_mode(struct sis_video_info *ivideo, int myindex, u32 vbflags) { - u16 xres=0, yres, myres; + u16 xres=0, yres, myres; #ifdef CONFIG_FB_SIS_300 - if(ivideo->sisvga_engine == SIS_300_VGA) { - if(!(sisbios_mode[myindex].chipset & MD_SIS300)) return(-1); - } + if(ivideo->sisvga_engine == SIS_300_VGA) { + if(!(sisbios_mode[myindex].chipset & MD_SIS300)) + return -1 ; + } #endif #ifdef CONFIG_FB_SIS_315 - if(ivideo->sisvga_engine == SIS_315_VGA) { - if(!(sisbios_mode[myindex].chipset & MD_SIS315)) return(-1); - } + if(ivideo->sisvga_engine == SIS_315_VGA) { + if(!(sisbios_mode[myindex].chipset & MD_SIS315)) + return -1; + } #endif - myres = sisbios_mode[myindex].yres; - - switch(vbflags & VB_DISPTYPE_DISP2) { + myres = sisbios_mode[myindex].yres; - case CRT2_LCD: + switch(vbflags & VB_DISPTYPE_DISP2) { - xres = ivideo->lcdxres; yres = ivideo->lcdyres; + case CRT2_LCD: + xres = ivideo->lcdxres; yres = ivideo->lcdyres; - if(ivideo->SiS_Pr.SiS_CustomT != CUT_PANEL848) { - if(sisbios_mode[myindex].xres > xres) return(-1); - if(myres > yres) return(-1); - } + if((ivideo->SiS_Pr.SiS_CustomT != CUT_PANEL848) && + (ivideo->SiS_Pr.SiS_CustomT != CUT_PANEL856)) { + if(sisbios_mode[myindex].xres > xres) + return -1; + if(myres > yres) + return -1; + } - if(vbflags & (VB_LVDS | VB_30xBDH)) { - if(sisbios_mode[myindex].xres == 320) { - if((myres == 240) || (myres == 480)) { - if(!ivideo->sisfb_fstn) { - if(sisbios_mode[myindex].mode_no[1] == 0x5a || - sisbios_mode[myindex].mode_no[1] == 0x5b) - return(-1); - } else { - if(sisbios_mode[myindex].mode_no[1] == 0x50 || - sisbios_mode[myindex].mode_no[1] == 0x56 || - sisbios_mode[myindex].mode_no[1] == 0x53) - return(-1); - } - } - } - } + if(ivideo->sisfb_fstn) { + if(sisbios_mode[myindex].xres == 320) { + if(myres == 240) { + switch(sisbios_mode[myindex].mode_no[1]) { + case 0x50: myindex = MODE_FSTN_8; break; + case 0x56: myindex = MODE_FSTN_16; break; + case 0x53: return -1; + } + } + } + } - if(SiS_GetModeID_LCD(ivideo->sisvga_engine, vbflags, sisbios_mode[myindex].xres, - sisbios_mode[myindex].yres, 0, ivideo->sisfb_fstn, - ivideo->SiS_Pr.SiS_CustomT, xres, yres) < 0x14) { - return(-1); - } - break; + if(SiS_GetModeID_LCD(ivideo->sisvga_engine, vbflags, sisbios_mode[myindex].xres, + sisbios_mode[myindex].yres, 0, ivideo->sisfb_fstn, + ivideo->SiS_Pr.SiS_CustomT, xres, yres, ivideo->vbflags2) < 0x14) { + return -1; + } + break; - case CRT2_TV: - if(SiS_GetModeID_TV(ivideo->sisvga_engine, vbflags, sisbios_mode[myindex].xres, - sisbios_mode[myindex].yres, 0) < 0x14) { - return(-1); - } - break; + case CRT2_TV: + if(SiS_GetModeID_TV(ivideo->sisvga_engine, vbflags, sisbios_mode[myindex].xres, + sisbios_mode[myindex].yres, 0, ivideo->vbflags2) < 0x14) { + return -1; + } + break; - case CRT2_VGA: - if(SiS_GetModeID_VGA2(ivideo->sisvga_engine, vbflags, sisbios_mode[myindex].xres, - sisbios_mode[myindex].yres, 0) < 0x14) { - return(-1); + case CRT2_VGA: + if(SiS_GetModeID_VGA2(ivideo->sisvga_engine, vbflags, sisbios_mode[myindex].xres, + sisbios_mode[myindex].yres, 0, ivideo->vbflags2) < 0x14) { + return -1; + } + break; } - break; - } - return(myindex); + return myindex; } static u8 sisfb_search_refresh_rate(struct sis_video_info *ivideo, unsigned int rate, int mode_idx) { - u16 xres, yres; int i = 0; - - xres = sisbios_mode[mode_idx].xres; - yres = sisbios_mode[mode_idx].yres; + u16 xres = sisbios_mode[mode_idx].xres; + u16 yres = sisbios_mode[mode_idx].yres; ivideo->rate_idx = 0; while((sisfb_vrate[i].idx != 0) && (sisfb_vrate[i].xres <= xres)) { @@ -672,14 +756,14 @@ sisfb_search_refresh_rate(struct sis_video_info *ivideo, unsigned int rate, int rate, sisfb_vrate[i-1].refresh); ivideo->rate_idx = sisfb_vrate[i-1].idx; ivideo->refresh_rate = sisfb_vrate[i-1].refresh; - } + } break; } else if((rate - sisfb_vrate[i].refresh) <= 2) { DPRINTK("sisfb: Adjusting rate from %d down to %d\n", rate, sisfb_vrate[i].refresh); - ivideo->rate_idx = sisfb_vrate[i].idx; - break; - } + ivideo->rate_idx = sisfb_vrate[i].idx; + break; + } } i++; } @@ -695,252 +779,321 @@ sisfb_search_refresh_rate(struct sis_video_info *ivideo, unsigned int rate, int static BOOLEAN sisfb_bridgeisslave(struct sis_video_info *ivideo) { - unsigned char P1_00; + unsigned char P1_00; - if(!(ivideo->vbflags & VB_VIDEOBRIDGE)) return FALSE; + if(!(ivideo->vbflags2 & VB2_VIDEOBRIDGE)) + return FALSE; - inSISIDXREG(SISPART1,0x00,P1_00); - if( ((ivideo->sisvga_engine == SIS_300_VGA) && (P1_00 & 0xa0) == 0x20) || - ((ivideo->sisvga_engine == SIS_315_VGA) && (P1_00 & 0x50) == 0x10) ) { - return TRUE; - } else { - return FALSE; - } + inSISIDXREG(SISPART1,0x00,P1_00); + if( ((ivideo->sisvga_engine == SIS_300_VGA) && (P1_00 & 0xa0) == 0x20) || + ((ivideo->sisvga_engine == SIS_315_VGA) && (P1_00 & 0x50) == 0x10) ) { + return TRUE; + } else { + return FALSE; + } } static BOOLEAN sisfballowretracecrt1(struct sis_video_info *ivideo) { - u8 temp; + u8 temp; - inSISIDXREG(SISCR,0x17,temp); - if(!(temp & 0x80)) return FALSE; + inSISIDXREG(SISCR,0x17,temp); + if(!(temp & 0x80)) + return FALSE; - inSISIDXREG(SISSR,0x1f,temp); - if(temp & 0xc0) return FALSE; + inSISIDXREG(SISSR,0x1f,temp); + if(temp & 0xc0) + return FALSE; - return TRUE; + return TRUE; } static BOOLEAN sisfbcheckvretracecrt1(struct sis_video_info *ivideo) { - if(!sisfballowretracecrt1(ivideo)) return FALSE; + if(!sisfballowretracecrt1(ivideo)) + return FALSE; - if(inSISREG(SISINPSTAT) & 0x08) return TRUE; - else return FALSE; + if(inSISREG(SISINPSTAT) & 0x08) + return TRUE; + else + return FALSE; } static void sisfbwaitretracecrt1(struct sis_video_info *ivideo) { - int watchdog; + int watchdog; - if(!sisfballowretracecrt1(ivideo)) return; + if(!sisfballowretracecrt1(ivideo)) + return; - watchdog = 65536; - while((!(inSISREG(SISINPSTAT) & 0x08)) && --watchdog); - watchdog = 65536; - while((inSISREG(SISINPSTAT) & 0x08) && --watchdog); + watchdog = 65536; + while((!(inSISREG(SISINPSTAT) & 0x08)) && --watchdog); + watchdog = 65536; + while((inSISREG(SISINPSTAT) & 0x08) && --watchdog); } static BOOLEAN sisfbcheckvretracecrt2(struct sis_video_info *ivideo) { - unsigned char temp, reg; + unsigned char temp, reg; - switch(ivideo->sisvga_engine) { - case SIS_300_VGA: reg = 0x25; break; - case SIS_315_VGA: reg = 0x30; break; - default: return FALSE; - } + switch(ivideo->sisvga_engine) { + case SIS_300_VGA: reg = 0x25; break; + case SIS_315_VGA: reg = 0x30; break; + default: return FALSE; + } - inSISIDXREG(SISPART1, reg, temp); - if(temp & 0x02) return TRUE; - else return FALSE; + inSISIDXREG(SISPART1, reg, temp); + if(temp & 0x02) + return TRUE; + else + return FALSE; } static BOOLEAN sisfb_CheckVBRetrace(struct sis_video_info *ivideo) { - if(ivideo->currentvbflags & VB_DISPTYPE_DISP2) { - if(sisfb_bridgeisslave(ivideo)) { - return(sisfbcheckvretracecrt1(ivideo)); - } else { - return(sisfbcheckvretracecrt2(ivideo)); - } - } - return(sisfbcheckvretracecrt1(ivideo)); + if(ivideo->currentvbflags & VB_DISPTYPE_DISP2) { + if(!sisfb_bridgeisslave(ivideo)) { + return sisfbcheckvretracecrt2(ivideo); + } + } + return sisfbcheckvretracecrt1(ivideo); } static u32 sisfb_setupvbblankflags(struct sis_video_info *ivideo, u32 *vcount, u32 *hcount) { - u8 idx, reg1, reg2, reg3, reg4; - u32 ret = 0; - - (*vcount) = (*hcount) = 0; - - if((ivideo->currentvbflags & VB_DISPTYPE_DISP2) && (!(sisfb_bridgeisslave(ivideo)))) { - ret |= (FB_VBLANK_HAVE_VSYNC | - FB_VBLANK_HAVE_HBLANK | - FB_VBLANK_HAVE_VBLANK | - FB_VBLANK_HAVE_VCOUNT | - FB_VBLANK_HAVE_HCOUNT); - switch(ivideo->sisvga_engine) { - case SIS_300_VGA: idx = 0x25; break; - default: - case SIS_315_VGA: idx = 0x30; break; - } - inSISIDXREG(SISPART1,(idx+0),reg1); /* 30 */ - inSISIDXREG(SISPART1,(idx+1),reg2); /* 31 */ - inSISIDXREG(SISPART1,(idx+2),reg3); /* 32 */ - inSISIDXREG(SISPART1,(idx+3),reg4); /* 33 */ - if(reg1 & 0x01) ret |= FB_VBLANK_VBLANKING; - if(reg1 & 0x02) ret |= FB_VBLANK_VSYNCING; - if(reg4 & 0x80) ret |= FB_VBLANK_HBLANKING; - (*vcount) = reg3 | ((reg4 & 0x70) << 4); - (*hcount) = reg2 | ((reg4 & 0x0f) << 8); - } else if(sisfballowretracecrt1(ivideo)) { - ret |= (FB_VBLANK_HAVE_VSYNC | - FB_VBLANK_HAVE_VBLANK | - FB_VBLANK_HAVE_VCOUNT | - FB_VBLANK_HAVE_HCOUNT); - reg1 = inSISREG(SISINPSTAT); - if(reg1 & 0x08) ret |= FB_VBLANK_VSYNCING; - if(reg1 & 0x01) ret |= FB_VBLANK_VBLANKING; - inSISIDXREG(SISCR,0x20,reg1); - inSISIDXREG(SISCR,0x1b,reg1); - inSISIDXREG(SISCR,0x1c,reg2); - inSISIDXREG(SISCR,0x1d,reg3); - (*vcount) = reg2 | ((reg3 & 0x07) << 8); - (*hcount) = (reg1 | ((reg3 & 0x10) << 4)) << 3; - } - return ret; + u8 idx, reg1, reg2, reg3, reg4; + u32 ret = 0; + + (*vcount) = (*hcount) = 0; + + if((ivideo->currentvbflags & VB_DISPTYPE_DISP2) && (!(sisfb_bridgeisslave(ivideo)))) { + + ret |= (FB_VBLANK_HAVE_VSYNC | + FB_VBLANK_HAVE_HBLANK | + FB_VBLANK_HAVE_VBLANK | + FB_VBLANK_HAVE_VCOUNT | + FB_VBLANK_HAVE_HCOUNT); + switch(ivideo->sisvga_engine) { + case SIS_300_VGA: idx = 0x25; break; + default: + case SIS_315_VGA: idx = 0x30; break; + } + inSISIDXREG(SISPART1,(idx+0),reg1); /* 30 */ + inSISIDXREG(SISPART1,(idx+1),reg2); /* 31 */ + inSISIDXREG(SISPART1,(idx+2),reg3); /* 32 */ + inSISIDXREG(SISPART1,(idx+3),reg4); /* 33 */ + if(reg1 & 0x01) ret |= FB_VBLANK_VBLANKING; + if(reg1 & 0x02) ret |= FB_VBLANK_VSYNCING; + if(reg4 & 0x80) ret |= FB_VBLANK_HBLANKING; + (*vcount) = reg3 | ((reg4 & 0x70) << 4); + (*hcount) = reg2 | ((reg4 & 0x0f) << 8); + + } else if(sisfballowretracecrt1(ivideo)) { + + ret |= (FB_VBLANK_HAVE_VSYNC | + FB_VBLANK_HAVE_VBLANK | + FB_VBLANK_HAVE_VCOUNT | + FB_VBLANK_HAVE_HCOUNT); + reg1 = inSISREG(SISINPSTAT); + if(reg1 & 0x08) ret |= FB_VBLANK_VSYNCING; + if(reg1 & 0x01) ret |= FB_VBLANK_VBLANKING; + inSISIDXREG(SISCR,0x20,reg1); + inSISIDXREG(SISCR,0x1b,reg1); + inSISIDXREG(SISCR,0x1c,reg2); + inSISIDXREG(SISCR,0x1d,reg3); + (*vcount) = reg2 | ((reg3 & 0x07) << 8); + (*hcount) = (reg1 | ((reg3 & 0x10) << 4)) << 3; + } + + return ret; } static int sisfb_myblank(struct sis_video_info *ivideo, int blank) { - u8 sr01, sr11, sr1f, cr63=0, p2_0, p1_13; - BOOLEAN backlight = TRUE; - - switch(blank) { - case FB_BLANK_UNBLANK: /* on */ - sr01 = 0x00; - sr11 = 0x00; - sr1f = 0x00; - cr63 = 0x00; - p2_0 = 0x20; - p1_13 = 0x00; - backlight = TRUE; - break; - case FB_BLANK_NORMAL: /* blank */ - sr01 = 0x20; - sr11 = 0x00; - sr1f = 0x00; - cr63 = 0x00; - p2_0 = 0x20; - p1_13 = 0x00; - backlight = TRUE; - break; - case FB_BLANK_VSYNC_SUSPEND: /* no vsync */ - sr01 = 0x20; - sr11 = 0x08; - sr1f = 0x80; - cr63 = 0x40; - p2_0 = 0x40; - p1_13 = 0x80; - backlight = FALSE; - break; - case FB_BLANK_HSYNC_SUSPEND: /* no hsync */ - sr01 = 0x20; - sr11 = 0x08; - sr1f = 0x40; - cr63 = 0x40; - p2_0 = 0x80; - p1_13 = 0x40; - backlight = FALSE; - break; - case FB_BLANK_POWERDOWN: /* off */ - sr01 = 0x20; - sr11 = 0x08; - sr1f = 0xc0; - cr63 = 0x40; - p2_0 = 0xc0; - p1_13 = 0xc0; - backlight = FALSE; - break; - default: - return 1; - } - - if(ivideo->currentvbflags & VB_DISPTYPE_CRT1) { - - if( (!ivideo->sisfb_thismonitor.datavalid) || - ((ivideo->sisfb_thismonitor.datavalid) && - (ivideo->sisfb_thismonitor.feature & 0xe0))) { - - if(ivideo->sisvga_engine == SIS_315_VGA) { - setSISIDXREG(SISCR, ivideo->SiS_Pr.SiS_MyCR63, 0xbf, cr63); - } - - if(!(sisfb_bridgeisslave(ivideo))) { - setSISIDXREG(SISSR, 0x01, ~0x20, sr01); - setSISIDXREG(SISSR, 0x1f, 0x3f, sr1f); - } - } - - } - - if(ivideo->currentvbflags & CRT2_LCD) { - - if(ivideo->vbflags & (VB_301LV|VB_302LV|VB_302ELV)) { - if(backlight) { - SiS_SiS30xBLOn(&ivideo->SiS_Pr, &ivideo->sishw_ext); - } else { - SiS_SiS30xBLOff(&ivideo->SiS_Pr, &ivideo->sishw_ext); - } - } else if(ivideo->sisvga_engine == SIS_315_VGA) { - if(ivideo->vbflags & VB_CHRONTEL) { - if(backlight) { - SiS_Chrontel701xBLOn(&ivideo->SiS_Pr,&ivideo->sishw_ext); - } else { - SiS_Chrontel701xBLOff(&ivideo->SiS_Pr); - } - } - } - - if(((ivideo->sisvga_engine == SIS_300_VGA) && - (ivideo->vbflags & (VB_301|VB_30xBDH|VB_LVDS))) || - ((ivideo->sisvga_engine == SIS_315_VGA) && - ((ivideo->vbflags & (VB_LVDS | VB_CHRONTEL)) == VB_LVDS))) { - setSISIDXREG(SISSR, 0x11, ~0x0c, sr11); - } - - if(ivideo->sisvga_engine == SIS_300_VGA) { - if((ivideo->vbflags & (VB_301B|VB_301C|VB_302B)) && - (!(ivideo->vbflags & VB_30xBDH))) { - setSISIDXREG(SISPART1, 0x13, 0x3f, p1_13); - } - } else if(ivideo->sisvga_engine == SIS_315_VGA) { - if((ivideo->vbflags & (VB_301B|VB_301C|VB_302B)) && - (!(ivideo->vbflags & VB_30xBDH))) { - setSISIDXREG(SISPART2, 0x00, 0x1f, p2_0); - } - } - - } else if(ivideo->currentvbflags & CRT2_VGA) { - - if(ivideo->vbflags & (VB_301B|VB_301C|VB_302B)) { - setSISIDXREG(SISPART2, 0x00, 0x1f, p2_0); - } - - } - - return(0); + u8 sr01, sr11, sr1f, cr63=0, p2_0, p1_13; + BOOLEAN backlight = TRUE; + + switch(blank) { + case FB_BLANK_UNBLANK: /* on */ + sr01 = 0x00; + sr11 = 0x00; + sr1f = 0x00; + cr63 = 0x00; + p2_0 = 0x20; + p1_13 = 0x00; + backlight = TRUE; + break; + case FB_BLANK_NORMAL: /* blank */ + sr01 = 0x20; + sr11 = 0x00; + sr1f = 0x00; + cr63 = 0x00; + p2_0 = 0x20; + p1_13 = 0x00; + backlight = TRUE; + break; + case FB_BLANK_VSYNC_SUSPEND: /* no vsync */ + sr01 = 0x20; + sr11 = 0x08; + sr1f = 0x80; + cr63 = 0x40; + p2_0 = 0x40; + p1_13 = 0x80; + backlight = FALSE; + break; + case FB_BLANK_HSYNC_SUSPEND: /* no hsync */ + sr01 = 0x20; + sr11 = 0x08; + sr1f = 0x40; + cr63 = 0x40; + p2_0 = 0x80; + p1_13 = 0x40; + backlight = FALSE; + break; + case FB_BLANK_POWERDOWN: /* off */ + sr01 = 0x20; + sr11 = 0x08; + sr1f = 0xc0; + cr63 = 0x40; + p2_0 = 0xc0; + p1_13 = 0xc0; + backlight = FALSE; + break; + default: + return 1; + } + + if(ivideo->currentvbflags & VB_DISPTYPE_CRT1) { + + if( (!ivideo->sisfb_thismonitor.datavalid) || + ((ivideo->sisfb_thismonitor.datavalid) && + (ivideo->sisfb_thismonitor.feature & 0xe0))) { + + if(ivideo->sisvga_engine == SIS_315_VGA) { + setSISIDXREG(SISCR, ivideo->SiS_Pr.SiS_MyCR63, 0xbf, cr63); + } + + if(!(sisfb_bridgeisslave(ivideo))) { + setSISIDXREG(SISSR, 0x01, ~0x20, sr01); + setSISIDXREG(SISSR, 0x1f, 0x3f, sr1f); + } + } + + } + + if(ivideo->currentvbflags & CRT2_LCD) { + + if(ivideo->vbflags2 & VB2_SISLVDSBRIDGE) { + if(backlight) { + SiS_SiS30xBLOn(&ivideo->SiS_Pr); + } else { + SiS_SiS30xBLOff(&ivideo->SiS_Pr); + } + } else if(ivideo->sisvga_engine == SIS_315_VGA) { +#ifdef CONFIG_FB_SIS_315 + if(ivideo->vbflags2 & VB2_CHRONTEL) { + if(backlight) { + SiS_Chrontel701xBLOn(&ivideo->SiS_Pr); + } else { + SiS_Chrontel701xBLOff(&ivideo->SiS_Pr); + } + } +#endif + } + + if(((ivideo->sisvga_engine == SIS_300_VGA) && + (ivideo->vbflags2 & (VB2_301|VB2_30xBDH|VB2_LVDS))) || + ((ivideo->sisvga_engine == SIS_315_VGA) && + ((ivideo->vbflags2 & (VB2_LVDS | VB2_CHRONTEL)) == VB2_LVDS))) { + setSISIDXREG(SISSR, 0x11, ~0x0c, sr11); + } + + if(ivideo->sisvga_engine == SIS_300_VGA) { + if((ivideo->vbflags2 & VB2_30xB) && + (!(ivideo->vbflags2 & VB2_30xBDH))) { + setSISIDXREG(SISPART1, 0x13, 0x3f, p1_13); + } + } else if(ivideo->sisvga_engine == SIS_315_VGA) { + if((ivideo->vbflags2 & VB2_30xB) && + (!(ivideo->vbflags2 & VB2_30xBDH))) { + setSISIDXREG(SISPART2, 0x00, 0x1f, p2_0); + } + } + + } else if(ivideo->currentvbflags & CRT2_VGA) { + + if(ivideo->vbflags2 & VB2_30xB) { + setSISIDXREG(SISPART2, 0x00, 0x1f, p2_0); + } + + } + + return 0; +} + +/* ------------- Callbacks from init.c/init301.c -------------- */ + +#ifdef CONFIG_FB_SIS_300 +unsigned int +sisfb_read_nbridge_pci_dword(struct SiS_Private *SiS_Pr, int reg) +{ + struct sis_video_info *ivideo = (struct sis_video_info *)SiS_Pr->ivideo; + u32 val = 0; + + pci_read_config_dword(ivideo->nbridge, reg, &val); + return (unsigned int)val; +} + +void +sisfb_write_nbridge_pci_dword(struct SiS_Private *SiS_Pr, int reg, unsigned int val) +{ + struct sis_video_info *ivideo = (struct sis_video_info *)SiS_Pr->ivideo; + + pci_write_config_dword(ivideo->nbridge, reg, (u32)val); } +unsigned int +sisfb_read_lpc_pci_dword(struct SiS_Private *SiS_Pr, int reg) +{ + struct sis_video_info *ivideo = (struct sis_video_info *)SiS_Pr->ivideo; + u32 val = 0; + + if(!ivideo->lpcdev) return 0; + + pci_read_config_dword(ivideo->lpcdev, reg, &val); + return (unsigned int)val; +} +#endif + +#ifdef CONFIG_FB_SIS_315 +void +sisfb_write_nbridge_pci_byte(struct SiS_Private *SiS_Pr, int reg, unsigned char val) +{ + struct sis_video_info *ivideo = (struct sis_video_info *)SiS_Pr->ivideo; + + pci_write_config_byte(ivideo->nbridge, reg, (u8)val); +} + +unsigned int +sisfb_read_mio_pci_word(struct SiS_Private *SiS_Pr, int reg) +{ + struct sis_video_info *ivideo = (struct sis_video_info *)SiS_Pr->ivideo; + u16 val = 0; + + if(!ivideo->lpcdev) return 0; + + pci_read_config_word(ivideo->lpcdev, reg, &val); + return (unsigned int)val; +} +#endif + /* ----------- FBDev related routines for all series ----------- */ static int @@ -952,7 +1105,7 @@ sisfb_get_cmap_len(const struct fb_var_screeninfo *var) static void sisfb_set_vparms(struct sis_video_info *ivideo) { - switch(ivideo->video_bpp) { + switch(ivideo->video_bpp) { case 8: ivideo->DstColor = 0x0000; ivideo->SiS310_AccelDepth = 0x00000000; @@ -972,14 +1125,13 @@ sisfb_set_vparms(struct sis_video_info *ivideo) ivideo->video_cmap_len = 16; printk(KERN_ERR "sisfb: Unsupported depth %d", ivideo->video_bpp); ivideo->accel = 0; - break; - } + } } static int sisfb_calc_maxyres(struct sis_video_info *ivideo, struct fb_var_screeninfo *var) { - int maxyres = ivideo->heapstart / (var->xres_virtual * (var->bits_per_pixel >> 3)); + int maxyres = ivideo->sisfb_mem / (var->xres_virtual * (var->bits_per_pixel >> 3)); if(maxyres > 32767) maxyres = 32767; @@ -996,30 +1148,29 @@ sisfb_calc_pitch(struct sis_video_info *ivideo, struct fb_var_screeninfo *var) ivideo->scrnpitchCRT1 <<= 1; } } - } static void sisfb_set_pitch(struct sis_video_info *ivideo) { - BOOLEAN isslavemode = FALSE; + BOOLEAN isslavemode = FALSE; unsigned short HDisplay1 = ivideo->scrnpitchCRT1 >> 3; unsigned short HDisplay2 = ivideo->video_linelength >> 3; - if(sisfb_bridgeisslave(ivideo)) isslavemode = TRUE; + if(sisfb_bridgeisslave(ivideo)) isslavemode = TRUE; - /* We need to set pitch for CRT1 if bridge is in slave mode, too */ - if((ivideo->currentvbflags & VB_DISPTYPE_DISP1) || (isslavemode)) { - outSISIDXREG(SISCR,0x13,(HDisplay1 & 0xFF)); - setSISIDXREG(SISSR,0x0E,0xF0,(HDisplay1 >> 8)); + /* We need to set pitch for CRT1 if bridge is in slave mode, too */ + if((ivideo->currentvbflags & VB_DISPTYPE_DISP1) || (isslavemode)) { + outSISIDXREG(SISCR,0x13,(HDisplay1 & 0xFF)); + setSISIDXREG(SISSR,0x0E,0xF0,(HDisplay1 >> 8)); } - /* We must not set the pitch for CRT2 if bridge is in slave mode */ - if((ivideo->currentvbflags & VB_DISPTYPE_DISP2) && (!isslavemode)) { + /* We must not set the pitch for CRT2 if bridge is in slave mode */ + if((ivideo->currentvbflags & VB_DISPTYPE_DISP2) && (!isslavemode)) { orSISIDXREG(SISPART1,ivideo->CRT2_write_enable,0x01); - outSISIDXREG(SISPART1,0x07,(HDisplay2 & 0xFF)); - setSISIDXREG(SISPART1,0x09,0xF0,(HDisplay2 >> 8)); - } + outSISIDXREG(SISPART1,0x07,(HDisplay2 & 0xFF)); + setSISIDXREG(SISPART1,0x09,0xF0,(HDisplay2 >> 8)); + } } static void @@ -1056,12 +1207,41 @@ sisfb_bpp_to_var(struct sis_video_info *ivideo, struct fb_var_screeninfo *var) } static int +sisfb_set_mode(struct sis_video_info *ivideo, int clrscrn) +{ + unsigned short modeno = ivideo->mode_no; + + /* >=2.6.12's fbcon clears the screen anyway */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12) + if(!clrscrn) modeno |= 0x80; +#else + modeno |= 0x80; +#endif + + outSISIDXREG(SISSR, IND_SIS_PASSWORD, SIS_PASSWORD); + + sisfb_pre_setmode(ivideo); + + if(SiSSetMode(&ivideo->SiS_Pr, modeno) == 0) { + printk(KERN_ERR "sisfb: Setting mode[0x%x] failed\n", ivideo->mode_no); + return -EINVAL; + } + + outSISIDXREG(SISSR, IND_SIS_PASSWORD, SIS_PASSWORD); + + sisfb_post_setmode(ivideo); + + return 0; +} + + +static int sisfb_do_set_var(struct fb_var_screeninfo *var, int isactive, struct fb_info *info) { struct sis_video_info *ivideo = (struct sis_video_info *)info->par; unsigned int htotal = 0, vtotal = 0; unsigned int drate = 0, hrate = 0; - int found_mode = 0; + int found_mode = 0, ret; int old_mode; u32 pixclock; @@ -1088,11 +1268,11 @@ sisfb_do_set_var(struct fb_var_screeninfo *var, int isactive, struct fb_info *in } if(pixclock && htotal && vtotal) { - drate = 1000000000 / pixclock; - hrate = (drate * 1000) / htotal; - ivideo->refresh_rate = (unsigned int) (hrate * 2 / vtotal); + drate = 1000000000 / pixclock; + hrate = (drate * 1000) / htotal; + ivideo->refresh_rate = (unsigned int) (hrate * 2 / vtotal); } else { - ivideo->refresh_rate = 60; + ivideo->refresh_rate = 60; } old_mode = ivideo->sisfb_mode_idx; @@ -1113,6 +1293,7 @@ sisfb_do_set_var(struct fb_var_screeninfo *var, int isactive, struct fb_info *in if(found_mode) { ivideo->sisfb_mode_idx = sisfb_validate_mode(ivideo, ivideo->sisfb_mode_idx, ivideo->currentvbflags); + ivideo->mode_no = sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni]; } else { ivideo->sisfb_mode_idx = -1; } @@ -1131,10 +1312,10 @@ sisfb_do_set_var(struct fb_var_screeninfo *var, int isactive, struct fb_info *in #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) if(ivideo->sisfb_thismonitor.datavalid) { - if(!sisfb_verify_rate(ivideo, &ivideo->sisfb_thismonitor, ivideo->sisfb_mode_idx, + if(!sisfb_verify_rate(ivideo, &ivideo->sisfb_thismonitor, ivideo->sisfb_mode_idx, ivideo->rate_idx, ivideo->refresh_rate)) { - printk(KERN_INFO "sisfb: WARNING: Refresh rate exceeds monitor specs!\n"); - } + printk(KERN_INFO "sisfb: WARNING: Refresh rate exceeds monitor specs!\n"); + } } #endif @@ -1143,24 +1324,9 @@ sisfb_do_set_var(struct fb_var_screeninfo *var, int isactive, struct fb_info *in #else if(isactive) { #endif - sisfb_pre_setmode(ivideo); - - if(SiSSetMode(&ivideo->SiS_Pr, &ivideo->sishw_ext, ivideo->mode_no) == 0) { - printk(KERN_ERR "sisfb: Setting mode[0x%x] failed\n", ivideo->mode_no); - return -EINVAL; - } - - outSISIDXREG(SISSR, IND_SIS_PASSWORD, SIS_PASSWORD); - - sisfb_post_setmode(ivideo); - - ivideo->video_bpp = sisbios_mode[ivideo->sisfb_mode_idx].bpp; - ivideo->video_width = sisbios_mode[ivideo->sisfb_mode_idx].xres; - ivideo->video_height = sisbios_mode[ivideo->sisfb_mode_idx].yres; - - sisfb_calc_pitch(ivideo, var); - sisfb_set_pitch(ivideo); - + /* If acceleration to be used? Need to know + * before pre/post_set_mode() + */ ivideo->accel = 0; #if defined(FBINFO_HWACCEL_DISABLED) && defined(FBINFO_HWACCEL_XPAN) #ifdef STUPID_ACCELF_TEXT_SHIT @@ -1175,6 +1341,17 @@ sisfb_do_set_var(struct fb_var_screeninfo *var, int isactive, struct fb_info *in if(var->accel_flags & FB_ACCELF_TEXT) ivideo->accel = -1; #endif + if((ret = sisfb_set_mode(ivideo, 1))) { + return ret; + } + + ivideo->video_bpp = sisbios_mode[ivideo->sisfb_mode_idx].bpp; + ivideo->video_width = sisbios_mode[ivideo->sisfb_mode_idx].xres; + ivideo->video_height = sisbios_mode[ivideo->sisfb_mode_idx].yres; + + sisfb_calc_pitch(ivideo, var); + sisfb_set_pitch(ivideo); + sisfb_set_vparms(ivideo); ivideo->current_width = ivideo->video_width; @@ -1186,572 +1363,79 @@ sisfb_do_set_var(struct fb_var_screeninfo *var, int isactive, struct fb_info *in ivideo->current_pixclock = var->pixclock; ivideo->current_refresh_rate = ivideo->refresh_rate; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) - ivideo->sisfb_lastrates[ivideo->mode_no] = ivideo->refresh_rate; + ivideo->sisfb_lastrates[ivideo->mode_no] = ivideo->refresh_rate; #endif } return 0; } -static int -sisfb_pan_var(struct sis_video_info *ivideo, struct fb_var_screeninfo *var) +static void +sisfb_set_base_CRT1(struct sis_video_info *ivideo, unsigned int base) { - unsigned int base; - - if(var->xoffset > (var->xres_virtual - var->xres)) { - return -EINVAL; - } - if(var->yoffset > (var->yres_virtual - var->yres)) { - return -EINVAL; - } - - base = (var->yoffset * var->xres_virtual) + var->xoffset; - - /* calculate base bpp dep. */ - switch(var->bits_per_pixel) { - case 32: - break; - case 16: - base >>= 1; - break; - case 8: - default: - base >>= 2; - break; - } - outSISIDXREG(SISSR, IND_SIS_PASSWORD, SIS_PASSWORD); - outSISIDXREG(SISCR, 0x0D, base & 0xFF); + outSISIDXREG(SISCR, 0x0D, base & 0xFF); outSISIDXREG(SISCR, 0x0C, (base >> 8) & 0xFF); outSISIDXREG(SISSR, 0x0D, (base >> 16) & 0xFF); if(ivideo->sisvga_engine == SIS_315_VGA) { setSISIDXREG(SISSR, 0x37, 0xFE, (base >> 24) & 0x01); } - if(ivideo->currentvbflags & VB_DISPTYPE_DISP2) { - orSISIDXREG(SISPART1, ivideo->CRT2_write_enable, 0x01); - outSISIDXREG(SISPART1, 0x06, (base & 0xFF)); - outSISIDXREG(SISPART1, 0x05, ((base >> 8) & 0xFF)); - outSISIDXREG(SISPART1, 0x04, ((base >> 16) & 0xFF)); - if(ivideo->sisvga_engine == SIS_315_VGA) { - setSISIDXREG(SISPART1, 0x02, 0x7F, ((base >> 24) & 0x01) << 7); - } - } - return 0; } -/* ------------ FBDev related routines for 2.4 series ----------- */ - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - static void -sisfb_crtc_to_var(struct sis_video_info *ivideo, struct fb_var_screeninfo *var) -{ - u16 VRE, VBE, VRS, VBS, VDE, VT; - u16 HRE, HBE, HRS, HBS, HDE, HT; - u8 sr_data, cr_data, cr_data2, cr_data3, mr_data; - int A, B, C, D, E, F, temp; - unsigned int hrate, drate, maxyres; - - inSISIDXREG(SISSR, IND_SIS_COLOR_MODE, sr_data); - - if(sr_data & SIS_INTERLACED_MODE) - var->vmode = FB_VMODE_INTERLACED; - else - var->vmode = FB_VMODE_NONINTERLACED; - - switch((sr_data & 0x1C) >> 2) { - case SIS_8BPP_COLOR_MODE: - var->bits_per_pixel = 8; - break; - case SIS_16BPP_COLOR_MODE: - var->bits_per_pixel = 16; - break; - case SIS_32BPP_COLOR_MODE: - var->bits_per_pixel = 32; - break; - } - - sisfb_bpp_to_var(ivideo, var); - - inSISIDXREG(SISSR, 0x0A, sr_data); - inSISIDXREG(SISCR, 0x06, cr_data); - inSISIDXREG(SISCR, 0x07, cr_data2); - - VT = (cr_data & 0xFF) | - ((u16) (cr_data2 & 0x01) << 8) | - ((u16) (cr_data2 & 0x20) << 4) | - ((u16) (sr_data & 0x01) << 10); - A = VT + 2; - - inSISIDXREG(SISCR, 0x12, cr_data); - - VDE = (cr_data & 0xff) | - ((u16) (cr_data2 & 0x02) << 7) | - ((u16) (cr_data2 & 0x40) << 3) | - ((u16) (sr_data & 0x02) << 9); - E = VDE + 1; - - inSISIDXREG(SISCR, 0x10, cr_data); - - VRS = (cr_data & 0xff) | - ((u16) (cr_data2 & 0x04) << 6) | - ((u16) (cr_data2 & 0x80) << 2) | - ((u16) (sr_data & 0x08) << 7); - F = VRS + 1 - E; - - inSISIDXREG(SISCR, 0x15, cr_data); - inSISIDXREG(SISCR, 0x09, cr_data3); - - if(cr_data3 & 0x80) var->vmode = FB_VMODE_DOUBLE; - - VBS = (cr_data & 0xff) | - ((u16) (cr_data2 & 0x08) << 5) | - ((u16) (cr_data3 & 0x20) << 4) | - ((u16) (sr_data & 0x04) << 8); - - inSISIDXREG(SISCR, 0x16, cr_data); - - VBE = (cr_data & 0xff) | ((u16) (sr_data & 0x10) << 4); - temp = VBE - ((E - 1) & 511); - B = (temp > 0) ? temp : (temp + 512); - - inSISIDXREG(SISCR, 0x11, cr_data); - - VRE = (cr_data & 0x0f) | ((sr_data & 0x20) >> 1); - temp = VRE - ((E + F - 1) & 31); - C = (temp > 0) ? temp : (temp + 32); - - D = B - F - C; - - var->yres = E; - var->upper_margin = D; - var->lower_margin = F; - var->vsync_len = C; - - if((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { - var->yres <<= 1; - var->upper_margin <<= 1; - var->lower_margin <<= 1; - var->vsync_len <<= 1; - } else if((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) { - var->yres >>= 1; - var->upper_margin >>= 1; - var->lower_margin >>= 1; - var->vsync_len >>= 1; - } - - inSISIDXREG(SISSR, 0x0b, sr_data); - inSISIDXREG(SISCR, 0x00, cr_data); - - HT = (cr_data & 0xff) | ((u16) (sr_data & 0x03) << 8); - A = HT + 5; - - inSISIDXREG(SISCR, 0x01, cr_data); - - HDE = (cr_data & 0xff) | ((u16) (sr_data & 0x0C) << 6); - E = HDE + 1; - - inSISIDXREG(SISCR, 0x04, cr_data); - - HRS = (cr_data & 0xff) | ((u16) (sr_data & 0xC0) << 2); - F = HRS - E - 3; - - inSISIDXREG(SISCR, 0x02, cr_data); - - HBS = (cr_data & 0xff) | ((u16) (sr_data & 0x30) << 4); - - inSISIDXREG(SISSR, 0x0c, sr_data); - inSISIDXREG(SISCR, 0x03, cr_data); - inSISIDXREG(SISCR, 0x05, cr_data2); - - HBE = (cr_data & 0x1f) | - ((u16) (cr_data2 & 0x80) >> 2) | - ((u16) (sr_data & 0x03) << 6); - HRE = (cr_data2 & 0x1f) | ((sr_data & 0x04) << 3); - - temp = HBE - ((E - 1) & 255); - B = (temp > 0) ? temp : (temp + 256); - - temp = HRE - ((E + F + 3) & 63); - C = (temp > 0) ? temp : (temp + 64); - - D = B - F - C; - - var->xres = E * 8; - if(var->xres_virtual < var->xres) { - var->xres_virtual = var->xres; - } - - if((var->xres == 320) && - (var->yres == 200 || var->yres == 240)) { - /* Terrible hack, but the correct CRTC data for - * these modes only produces a black screen... - */ - var->left_margin = (400 - 376); - var->right_margin = (328 - 320); - var->hsync_len = (376 - 328); - } else { - var->left_margin = D * 8; - var->right_margin = F * 8; - var->hsync_len = C * 8; - } - var->activate = FB_ACTIVATE_NOW; - - var->sync = 0; - - mr_data = inSISREG(SISMISCR); - if(mr_data & 0x80) - var->sync &= ~FB_SYNC_VERT_HIGH_ACT; - else - var->sync |= FB_SYNC_VERT_HIGH_ACT; - - if(mr_data & 0x40) - var->sync &= ~FB_SYNC_HOR_HIGH_ACT; - else - var->sync |= FB_SYNC_HOR_HIGH_ACT; - - VT += 2; - VT <<= 1; - HT = (HT + 5) * 8; - - if((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { - VT <<= 1; - } - hrate = ivideo->refresh_rate * VT / 2; - drate = (hrate * HT) / 1000; - var->pixclock = (u32) (1000000000 / drate); - - if(ivideo->sisfb_ypan) { - maxyres = sisfb_calc_maxyres(ivideo, var); - if(ivideo->sisfb_max) { - var->yres_virtual = maxyres; - } else { - if(var->yres_virtual > maxyres) { - var->yres_virtual = maxyres; - } - } - if(var->yres_virtual <= var->yres) { - var->yres_virtual = var->yres; - } - } else { - var->yres_virtual = var->yres; - } - -} - -static int -sis_getcolreg(unsigned regno, unsigned *red, unsigned *green, unsigned *blue, - unsigned *transp, struct fb_info *info) +sisfb_set_base_CRT2(struct sis_video_info *ivideo, unsigned int base) { - struct sis_video_info *ivideo = (struct sis_video_info *)info->par; - - if(regno >= ivideo->video_cmap_len) return 1; - - *red = ivideo->sis_palette[regno].red; - *green = ivideo->sis_palette[regno].green; - *blue = ivideo->sis_palette[regno].blue; - *transp = 0; - - return 0; -} - -static int -sisfb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue, - unsigned transp, struct fb_info *info) -{ - struct sis_video_info *ivideo = (struct sis_video_info *)info->par; - - if(regno >= ivideo->video_cmap_len) return 1; - - ivideo->sis_palette[regno].red = red; - ivideo->sis_palette[regno].green = green; - ivideo->sis_palette[regno].blue = blue; - - switch(ivideo->video_bpp) { -#ifdef FBCON_HAS_CFB8 - case 8: - outSISREG(SISDACA, regno); - outSISREG(SISDACD, (red >> 10)); - outSISREG(SISDACD, (green >> 10)); - outSISREG(SISDACD, (blue >> 10)); - if(ivideo->currentvbflags & VB_DISPTYPE_DISP2) { - outSISREG(SISDAC2A, regno); - outSISREG(SISDAC2D, (red >> 8)); - outSISREG(SISDAC2D, (green >> 8)); - outSISREG(SISDAC2D, (blue >> 8)); + if(ivideo->currentvbflags & VB_DISPTYPE_DISP2) { + orSISIDXREG(SISPART1, ivideo->CRT2_write_enable, 0x01); + outSISIDXREG(SISPART1, 0x06, (base & 0xFF)); + outSISIDXREG(SISPART1, 0x05, ((base >> 8) & 0xFF)); + outSISIDXREG(SISPART1, 0x04, ((base >> 16) & 0xFF)); + if(ivideo->sisvga_engine == SIS_315_VGA) { + setSISIDXREG(SISPART1, 0x02, 0x7F, ((base >> 24) & 0x01) << 7); } - break; -#endif -#ifdef FBCON_HAS_CFB16 - case 16: - ivideo->sis_fbcon_cmap.cfb16[regno] = - ((red & 0xf800)) | ((green & 0xfc00) >> 5) | ((blue & 0xf800) >> 11); - break; -#endif -#ifdef FBCON_HAS_CFB32 - case 32: - red >>= 8; - green >>= 8; - blue >>= 8; - ivideo->sis_fbcon_cmap.cfb32[regno] = (red << 16) | (green << 8) | (blue); - break; -#endif - } - - return 0; -} - -static void -sisfb_set_disp(int con, struct fb_var_screeninfo *var, struct fb_info *info) -{ - struct sis_video_info *ivideo = (struct sis_video_info *)info->par; - struct display *display; - struct display_switch *sw; - struct fb_fix_screeninfo fix; - long flags; - - display = (con >= 0) ? &fb_display[con] : &ivideo->sis_disp; - - sisfb_get_fix(&fix, con, info); - - display->var = *var; - display->screen_base = (char *)ivideo->video_vbase; - display->visual = fix.visual; - display->type = fix.type; - display->type_aux = fix.type_aux; - display->ypanstep = fix.ypanstep; - display->ywrapstep = fix.ywrapstep; - display->line_length = fix.line_length; - display->can_soft_blank = 1; - display->inverse = ivideo->sisfb_inverse; - display->next_line = fix.line_length; - - save_flags(flags); - - switch(ivideo->video_bpp) { -#ifdef FBCON_HAS_CFB8 - case 8: sw = ivideo->accel ? &fbcon_sis8 : &fbcon_cfb8; - break; -#endif -#ifdef FBCON_HAS_CFB16 - case 16:sw = ivideo->accel ? &fbcon_sis16 : &fbcon_cfb16; - display->dispsw_data = &ivideo->sis_fbcon_cmap.cfb16; - break; -#endif -#ifdef FBCON_HAS_CFB32 - case 32:sw = ivideo->accel ? &fbcon_sis32 : &fbcon_cfb32; - display->dispsw_data = &ivideo->sis_fbcon_cmap.cfb32; - break; -#endif - default:sw = &fbcon_dummy; - break; - } - memcpy(&ivideo->sisfb_sw, sw, sizeof(*sw)); - display->dispsw = &ivideo->sisfb_sw; - - restore_flags(flags); - - if(ivideo->sisfb_ypan) { - /* display->scrollmode = 0; */ - } else { - display->scrollmode = SCROLL_YREDRAW; - ivideo->sisfb_sw.bmove = fbcon_redraw_bmove; - } -} - -static void -sisfb_do_install_cmap(int con, struct fb_info *info) -{ - struct sis_video_info *ivideo = (struct sis_video_info *)info->par; - - if(con != ivideo->currcon) return; - - if(fb_display[con].cmap.len) { - fb_set_cmap(&fb_display[con].cmap, 1, sisfb_setcolreg, info); - } else { - int size = sisfb_get_cmap_len(&fb_display[con].var); - fb_set_cmap(fb_default_cmap(size), 1, sisfb_setcolreg, info); } } static int -sisfb_get_var(struct fb_var_screeninfo *var, int con, struct fb_info *info) -{ - struct sis_video_info *ivideo = (struct sis_video_info *)info->par; - - if(con == -1) { - memcpy(var, &ivideo->default_var, sizeof(struct fb_var_screeninfo)); - } else { - *var = fb_display[con].var; - } - - if(ivideo->sisfb_fstn) { - if(var->xres == 320 && var->yres == 480) var->yres = 240; - } - - return 0; -} - -static int -sisfb_set_var(struct fb_var_screeninfo *var, int con, struct fb_info *info) +sisfb_pan_var(struct sis_video_info *ivideo, struct fb_var_screeninfo *var) { - struct sis_video_info *ivideo = (struct sis_video_info *)info->par; - int err; - - fb_display[con].var.activate = FB_ACTIVATE_NOW; - - if(sisfb_do_set_var(var, con == ivideo->currcon, info)) { - sisfb_crtc_to_var(ivideo, var); + if(var->xoffset > (var->xres_virtual - var->xres)) { return -EINVAL; } - - sisfb_crtc_to_var(ivideo, var); - - sisfb_set_disp(con, var, info); - - if(info->changevar) { - (*info->changevar)(con); - } - - if((err = fb_alloc_cmap(&fb_display[con].cmap, 0, 0))) { - return err; - } - - sisfb_do_install_cmap(con, info); - -#if 0 /* Why was this called here? */ - unsigned int cols, rows; - cols = sisbios_mode[ivideo->sisfb_mode_idx].cols; - rows = sisbios_mode[ivideo->sisfb_mode_idx].rows; - vc_resize_con(rows, cols, fb_display[con].conp->vc_num); -#endif - return 0; -} - -static int -sisfb_get_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info) -{ - struct sis_video_info *ivideo = (struct sis_video_info *)info->par; - struct display *display; - - display = (con >= 0) ? &fb_display[con] : &ivideo->sis_disp; - - if(con == ivideo->currcon) { - - return fb_get_cmap(cmap, kspc, sis_getcolreg, info); - - } else if(display->cmap.len) { - - fb_copy_cmap(&display->cmap, cmap, kspc ? 0 : 2); - - } else { - - int size = sisfb_get_cmap_len(&display->var); - fb_copy_cmap(fb_default_cmap(size), cmap, kspc ? 0 : 2); - + if(var->yoffset > (var->yres_virtual - var->yres)) { + return -EINVAL; } - return 0; -} + ivideo->current_base = (var->yoffset * var->xres_virtual) + var->xoffset; -static int -sisfb_set_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info) -{ - struct sis_video_info *ivideo = (struct sis_video_info *)info->par; - struct display *display; - int err, size; - - display = (con >= 0) ? &fb_display[con] : &ivideo->sis_disp; - - size = sisfb_get_cmap_len(&display->var); - if(display->cmap.len != size) { - err = fb_alloc_cmap(&display->cmap, size, 0); - if(err) return err; - } - - if(con == ivideo->currcon) { - return fb_set_cmap(cmap, kspc, sisfb_setcolreg, info); - } else { - fb_copy_cmap(cmap, &display->cmap, kspc ? 0 : 1); - } - - return 0; -} - -static int -sisfb_pan_display(struct fb_var_screeninfo *var, int con, struct fb_info* info) -{ - struct sis_video_info *ivideo = (struct sis_video_info *)info->par; - int err; - - if(var->vmode & FB_VMODE_YWRAP) return -EINVAL; - - if((var->xoffset+fb_display[con].var.xres > fb_display[con].var.xres_virtual) || - (var->yoffset+fb_display[con].var.yres > fb_display[con].var.yres_virtual)) { - return -EINVAL; + /* calculate base bpp dep. */ + switch(var->bits_per_pixel) { + case 32: + break; + case 16: + ivideo->current_base >>= 1; + break; + case 8: + default: + ivideo->current_base >>= 2; + break; } - if(con == ivideo->currcon) { - if((err = sisfb_pan_var(ivideo, var)) < 0) return err; - } + ivideo->current_base += (ivideo->video_offset >> 2); - fb_display[con].var.xoffset = var->xoffset; - fb_display[con].var.yoffset = var->yoffset; + sisfb_set_base_CRT1(ivideo, ivideo->current_base); + sisfb_set_base_CRT2(ivideo, ivideo->current_base); return 0; } -static int -sisfb_update_var(int con, struct fb_info *info) -{ - struct sis_video_info *ivideo = (struct sis_video_info *)info->par; - - return(sisfb_pan_var(ivideo, &fb_display[con].var)); -} - -static int -sisfb_switch(int con, struct fb_info *info) -{ - struct sis_video_info *ivideo = (struct sis_video_info *)info->par; - int cols, rows; - - if(fb_display[ivideo->currcon].cmap.len) { - fb_get_cmap(&fb_display[ivideo->currcon].cmap, 1, sis_getcolreg, info); - } - - fb_display[con].var.activate = FB_ACTIVATE_NOW; - - if(!memcmp(&fb_display[con].var, &fb_display[ivideo->currcon].var, - sizeof(struct fb_var_screeninfo))) { - ivideo->currcon = con; - return 1; - } - - ivideo->currcon = con; - - sisfb_do_set_var(&fb_display[con].var, 1, info); - - sisfb_set_disp(con, &fb_display[con].var, info); - - sisfb_do_install_cmap(con, info); - - cols = sisbios_mode[ivideo->sisfb_mode_idx].cols; - rows = sisbios_mode[ivideo->sisfb_mode_idx].rows; - vc_resize_con(rows, cols, fb_display[con].conp->vc_num); - - sisfb_update_var(con, info); +/* ------------ FBDev related routines for 2.4 series ----------- */ - return 1; -} +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -static void -sisfb_blank(int blank, struct fb_info *info) -{ - struct sis_video_info *ivideo = (struct sis_video_info *)info->par; +#include "sisfb_fbdev_2_4.h" - sisfb_myblank(ivideo, blank); -} #endif /* ------------ FBDev related routines for 2.6 series ----------- */ @@ -1761,13 +1445,13 @@ sisfb_blank(int blank, struct fb_info *info) static int sisfb_open(struct fb_info *info, int user) { - return 0; + return 0; } static int sisfb_release(struct fb_info *info, int user) { - return 0; + return 0; } static int @@ -1776,16 +1460,17 @@ sisfb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue, { struct sis_video_info *ivideo = (struct sis_video_info *)info->par; - if(regno >= sisfb_get_cmap_len(&info->var)) return 1; + if(regno >= sisfb_get_cmap_len(&info->var)) + return 1; switch(info->var.bits_per_pixel) { case 8: - outSISREG(SISDACA, regno); + outSISREG(SISDACA, regno); outSISREG(SISDACD, (red >> 10)); outSISREG(SISDACD, (green >> 10)); outSISREG(SISDACD, (blue >> 10)); if(ivideo->currentvbflags & VB_DISPTYPE_DISP2) { - outSISREG(SISDAC2A, regno); + outSISREG(SISDAC2A, regno); outSISREG(SISDAC2D, (red >> 8)); outSISREG(SISDAC2D, (green >> 8)); outSISREG(SISDAC2D, (blue >> 8)); @@ -1793,7 +1478,9 @@ sisfb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue, break; case 16: ((u32 *)(info->pseudo_palette))[regno] = - ((red & 0xf800)) | ((green & 0xfc00) >> 5) | ((blue & 0xf800) >> 11); + (red & 0xf800) | + ((green & 0xfc00) >> 5) | + ((blue & 0xf800) >> 11); break; case 32: red >>= 8; @@ -1811,13 +1498,13 @@ sisfb_set_par(struct fb_info *info) { int err; - if((err = sisfb_do_set_var(&info->var, 1, info))) { + if((err = sisfb_do_set_var(&info->var, 1, info))) return err; - } + #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) sisfb_get_fix(&info->fix, info->currcon, info); #else - sisfb_get_fix(&info->fix, -1, info); + sisfb_get_fix(&info->fix, -1, info); #endif return 0; } @@ -1829,7 +1516,7 @@ sisfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) unsigned int htotal = 0, vtotal = 0, myrateindex = 0; unsigned int drate = 0, hrate = 0, maxyres; int found_mode = 0; - int refresh_rate, search_idx; + int refresh_rate, search_idx, tidx; BOOLEAN recalc_clock = FALSE; u32 pixclock; @@ -1848,7 +1535,8 @@ sisfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) } else if((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { vtotal += var->yres; vtotal <<= 1; - } else vtotal += var->yres; + } else + vtotal += var->yres; if(!(htotal) || !(vtotal)) { SISFAIL("sisfb: no valid timing data"); @@ -1860,60 +1548,68 @@ sisfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) if( (sisbios_mode[search_idx].xres == var->xres) && (sisbios_mode[search_idx].yres == var->yres) && (sisbios_mode[search_idx].bpp == var->bits_per_pixel)) { - if(sisfb_validate_mode(ivideo, search_idx, ivideo->currentvbflags) > 0) { - found_mode = 1; - break; + if((tidx = sisfb_validate_mode(ivideo, search_idx, + ivideo->currentvbflags)) > 0) { + found_mode = 1; + search_idx = tidx; + break; } } search_idx++; } if(!found_mode) { - search_idx = 0; + search_idx = 0; while(sisbios_mode[search_idx].mode_no[0] != 0) { if( (var->xres <= sisbios_mode[search_idx].xres) && (var->yres <= sisbios_mode[search_idx].yres) && (var->bits_per_pixel == sisbios_mode[search_idx].bpp) ) { - if(sisfb_validate_mode(ivideo,search_idx, ivideo->currentvbflags) > 0) { - found_mode = 1; - break; - } + if((tidx = sisfb_validate_mode(ivideo,search_idx, + ivideo->currentvbflags)) > 0) { + found_mode = 1; + search_idx = tidx; + break; + } } search_idx++; - } + } if(found_mode) { - printk(KERN_DEBUG "sisfb: Adapted from %dx%dx%d to %dx%dx%d\n", - var->xres, var->yres, var->bits_per_pixel, + printk(KERN_DEBUG + "sisfb: Adapted from %dx%dx%d to %dx%dx%d\n", + var->xres, var->yres, var->bits_per_pixel, sisbios_mode[search_idx].xres, sisbios_mode[search_idx].yres, var->bits_per_pixel); var->xres = sisbios_mode[search_idx].xres; - var->yres = sisbios_mode[search_idx].yres; - - + var->yres = sisbios_mode[search_idx].yres; } else { - printk(KERN_ERR "sisfb: Failed to find supported mode near %dx%dx%d\n", + printk(KERN_ERR + "sisfb: Failed to find supported mode near %dx%dx%d\n", var->xres, var->yres, var->bits_per_pixel); - return -EINVAL; + return -EINVAL; } } - if( ((ivideo->vbflags & VB_LVDS) || /* Slave modes on LVDS and 301B-DH */ - ((ivideo->vbflags & VB_30xBDH) && (ivideo->currentvbflags & CRT2_LCD))) && + if( ((ivideo->vbflags2 & VB2_LVDS) || + ((ivideo->vbflags2 & VB2_30xBDH) && (ivideo->currentvbflags & CRT2_LCD))) && (var->bits_per_pixel == 8) ) { - refresh_rate = 60; + /* Slave modes on LVDS and 301B-DH */ + refresh_rate = 60; recalc_clock = TRUE; - } else if( (ivideo->current_htotal == htotal) && /* x=x & y=y & c=c -> assume depth change */ - (ivideo->current_vtotal == vtotal) && - (ivideo->current_pixclock == pixclock) ) { + } else if( (ivideo->current_htotal == htotal) && + (ivideo->current_vtotal == vtotal) && + (ivideo->current_pixclock == pixclock) ) { + /* x=x & y=y & c=c -> assume depth change */ drate = 1000000000 / pixclock; - hrate = (drate * 1000) / htotal; - refresh_rate = (unsigned int) (hrate * 2 / vtotal); - } else if( ( (ivideo->current_htotal != htotal) || /* x!=x | y!=y & c=c -> invalid pixclock */ - (ivideo->current_vtotal != vtotal) ) && - (ivideo->current_pixclock == var->pixclock) ) { + hrate = (drate * 1000) / htotal; + refresh_rate = (unsigned int) (hrate * 2 / vtotal); + } else if( ( (ivideo->current_htotal != htotal) || + (ivideo->current_vtotal != vtotal) ) && + (ivideo->current_pixclock == var->pixclock) ) { + /* x!=x | y!=y & c=c -> invalid pixclock */ if(ivideo->sisfb_lastrates[sisbios_mode[search_idx].mode_no[ivideo->mni]]) { - refresh_rate = ivideo->sisfb_lastrates[sisbios_mode[search_idx].mode_no[ivideo->mni]]; + refresh_rate = + ivideo->sisfb_lastrates[sisbios_mode[search_idx].mode_no[ivideo->mni]]; } else if(ivideo->sisfb_parm_rate != -1) { /* Sic, sisfb_parm_rate - want to know originally desired rate here */ refresh_rate = ivideo->sisfb_parm_rate; @@ -1923,8 +1619,8 @@ sisfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) recalc_clock = TRUE; } else if((pixclock) && (htotal) && (vtotal)) { drate = 1000000000 / pixclock; - hrate = (drate * 1000) / htotal; - refresh_rate = (unsigned int) (hrate * 2 / vtotal); + hrate = (drate * 1000) / htotal; + refresh_rate = (unsigned int) (hrate * 2 / vtotal); } else if(ivideo->current_refresh_rate) { refresh_rate = ivideo->current_refresh_rate; recalc_clock = TRUE; @@ -1937,72 +1633,72 @@ sisfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) /* Eventually recalculate timing and clock */ if(recalc_clock) { - if(!myrateindex) myrateindex = sisbios_mode[search_idx].rate_idx; - var->pixclock = (u32) (1000000000 / sisfb_mode_rate_to_dclock(&ivideo->SiS_Pr, - &ivideo->sishw_ext, + if(!myrateindex) myrateindex = sisbios_mode[search_idx].rate_idx; + var->pixclock = (u32) (1000000000 / sisfb_mode_rate_to_dclock(&ivideo->SiS_Pr, sisbios_mode[search_idx].mode_no[ivideo->mni], myrateindex)); - sisfb_mode_rate_to_ddata(&ivideo->SiS_Pr, &ivideo->sishw_ext, - sisbios_mode[search_idx].mode_no[ivideo->mni], myrateindex, var); - if((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) { - var->pixclock <<= 1; - } + sisfb_mode_rate_to_ddata(&ivideo->SiS_Pr, + sisbios_mode[search_idx].mode_no[ivideo->mni], + myrateindex, var); + if((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) { + var->pixclock <<= 1; + } } if(ivideo->sisfb_thismonitor.datavalid) { - if(!sisfb_verify_rate(ivideo, &ivideo->sisfb_thismonitor, search_idx, - myrateindex, refresh_rate)) { - printk(KERN_INFO "sisfb: WARNING: Refresh rate exceeds monitor specs!\n"); - } + if(!sisfb_verify_rate(ivideo, &ivideo->sisfb_thismonitor, search_idx, + myrateindex, refresh_rate)) { + printk(KERN_INFO + "sisfb: WARNING: Refresh rate exceeds monitor specs!\n"); + } } /* Adapt RGB settings */ sisfb_bpp_to_var(ivideo, var); - + /* Sanity check for offsets */ if(var->xoffset < 0) var->xoffset = 0; if(var->yoffset < 0) var->yoffset = 0; - if(var->xres > var->xres_virtual) { - var->xres_virtual = var->xres; - } + if(var->xres > var->xres_virtual) + var->xres_virtual = var->xres; if(ivideo->sisfb_ypan) { - maxyres = sisfb_calc_maxyres(ivideo, var); - if(ivideo->sisfb_max) { - var->yres_virtual = maxyres; - } else { - if(var->yres_virtual > maxyres) { - var->yres_virtual = maxyres; - } - } - if(var->yres_virtual <= var->yres) { - var->yres_virtual = var->yres; - } + maxyres = sisfb_calc_maxyres(ivideo, var); + if(ivideo->sisfb_max) { + var->yres_virtual = maxyres; + } else { + if(var->yres_virtual > maxyres) { + var->yres_virtual = maxyres; + } + } + if(var->yres_virtual <= var->yres) { + var->yres_virtual = var->yres; + } } else { - if(var->yres != var->yres_virtual) { - var->yres_virtual = var->yres; - } - var->xoffset = 0; - var->yoffset = 0; + if(var->yres != var->yres_virtual) { + var->yres_virtual = var->yres; + } + var->xoffset = 0; + var->yoffset = 0; } - + /* Truncate offsets to maximum if too high */ if(var->xoffset > var->xres_virtual - var->xres) { - var->xoffset = var->xres_virtual - var->xres - 1; + var->xoffset = var->xres_virtual - var->xres - 1; } if(var->yoffset > var->yres_virtual - var->yres) { - var->yoffset = var->yres_virtual - var->yres - 1; + var->yoffset = var->yres_virtual - var->yres - 1; } - + /* Set everything else to 0 */ - var->red.msb_right = - var->green.msb_right = - var->blue.msb_right = - var->transp.offset = - var->transp.length = - var->transp.msb_right = 0; + var->red.msb_right = + var->green.msb_right = + var->blue.msb_right = + var->transp.offset = + var->transp.length = + var->transp.msb_right = 0; return 0; } @@ -2013,21 +1709,21 @@ sisfb_pan_display(struct fb_var_screeninfo *var, struct fb_info* info) struct sis_video_info *ivideo = (struct sis_video_info *)info->par; int err; - if(var->xoffset > (var->xres_virtual - var->xres)) { + if(var->xoffset > (var->xres_virtual - var->xres)) return -EINVAL; - } - if(var->yoffset > (var->yres_virtual - var->yres)) { + + if(var->yoffset > (var->yres_virtual - var->yres)) return -EINVAL; - } - if(var->vmode & FB_VMODE_YWRAP) return -EINVAL; + if(var->vmode & FB_VMODE_YWRAP) + return -EINVAL; if(var->xoffset + info->var.xres > info->var.xres_virtual || - var->yoffset + info->var.yres > info->var.yres_virtual) { + var->yoffset + info->var.yres > info->var.yres_virtual) return -EINVAL; - } - if((err = sisfb_pan_var(ivideo, var)) < 0) return err; + if((err = sisfb_pan_var(ivideo, var)) < 0) + return err; info->var.xoffset = var->xoffset; info->var.yoffset = var->yoffset; @@ -2040,7 +1736,7 @@ sisfb_blank(int blank, struct fb_info *info) { struct sis_video_info *ivideo = (struct sis_video_info *)info->par; - return(sisfb_myblank(ivideo, blank)); + return sisfb_myblank(ivideo, blank); } #endif @@ -2056,153 +1752,184 @@ sisfb_ioctl(struct inode *inode, struct file *file, struct fb_info *info) { struct sis_video_info *ivideo = (struct sis_video_info *)info->par; - struct sis_memreq sismemreq; - struct fb_vblank sisvbblank; - sisfb_info x; + struct sis_memreq sismemreq; + struct fb_vblank sisvbblank; u32 gpu32 = 0; #ifndef __user #define __user #endif u32 __user *argp = (u32 __user *)arg; - switch (cmd) { + switch(cmd) { case FBIO_ALLOC: - if(!capable(CAP_SYS_RAWIO)) { + if(!capable(CAP_SYS_RAWIO)) return -EPERM; - } - if(copy_from_user(&sismemreq, (void __user *)arg, sizeof(sismemreq))) { - return -EFAULT; - } + + if(copy_from_user(&sismemreq, (void __user *)arg, sizeof(sismemreq))) + return -EFAULT; + sis_malloc(&sismemreq); + if(copy_to_user((void __user *)arg, &sismemreq, sizeof(sismemreq))) { sis_free((u32)sismemreq.offset); - return -EFAULT; + return -EFAULT; } break; case FBIO_FREE: - if(!capable(CAP_SYS_RAWIO)) { + if(!capable(CAP_SYS_RAWIO)) return -EPERM; - } - if(get_user(gpu32, argp)) { + + if(get_user(gpu32, argp)) return -EFAULT; - } + sis_free(gpu32); break; case FBIOGET_VBLANK: sisvbblank.count = 0; sisvbblank.flags = sisfb_setupvbblankflags(ivideo, &sisvbblank.vcount, &sisvbblank.hcount); - if(copy_to_user((void __user *)arg, &sisvbblank, sizeof(sisvbblank))) { + + if(copy_to_user((void __user *)arg, &sisvbblank, sizeof(sisvbblank))) return -EFAULT; - } + break; case SISFB_GET_INFO_SIZE: - return put_user(sizeof(sisfb_info), argp); + return put_user(sizeof(struct sisfb_info), argp); case SISFB_GET_INFO_OLD: - if(ivideo->warncount++ < 50) { - printk(KERN_INFO "sisfb: Deprecated ioctl call received - update your application!\n"); - } + if(ivideo->warncount++ < 10) + printk(KERN_INFO + "sisfb: Deprecated ioctl call received - update your application!\n"); case SISFB_GET_INFO: /* For communication with X driver */ - x.sisfb_id = SISFB_ID; - x.sisfb_version = VER_MAJOR; - x.sisfb_revision = VER_MINOR; - x.sisfb_patchlevel = VER_LEVEL; - x.chip_id = ivideo->chip_id; - x.memory = ivideo->video_size / 1024; - x.heapstart = ivideo->heapstart / 1024; + ivideo->sisfb_infoblock.sisfb_id = SISFB_ID; + ivideo->sisfb_infoblock.sisfb_version = VER_MAJOR; + ivideo->sisfb_infoblock.sisfb_revision = VER_MINOR; + ivideo->sisfb_infoblock.sisfb_patchlevel = VER_LEVEL; + ivideo->sisfb_infoblock.chip_id = ivideo->chip_id; + ivideo->sisfb_infoblock.sisfb_pci_vendor = ivideo->chip_vendor; + ivideo->sisfb_infoblock.memory = ivideo->video_size / 1024; + ivideo->sisfb_infoblock.heapstart = ivideo->heapstart / 1024; if(ivideo->modechanged) { - x.fbvidmode = ivideo->mode_no; + ivideo->sisfb_infoblock.fbvidmode = ivideo->mode_no; } else { - x.fbvidmode = ivideo->modeprechange; - } - x.sisfb_caps = ivideo->caps; - x.sisfb_tqlen = 512; /* yet fixed */ - x.sisfb_pcibus = ivideo->pcibus; - x.sisfb_pcislot = ivideo->pcislot; - x.sisfb_pcifunc = ivideo->pcifunc; - x.sisfb_lcdpdc = ivideo->detectedpdc; - x.sisfb_lcdpdca = ivideo->detectedpdca; - x.sisfb_lcda = ivideo->detectedlcda; - x.sisfb_vbflags = ivideo->vbflags; - x.sisfb_currentvbflags = ivideo->currentvbflags; - x.sisfb_scalelcd = ivideo->SiS_Pr.UsePanelScaler; - x.sisfb_specialtiming = ivideo->SiS_Pr.SiS_CustomT; - x.sisfb_haveemi = ivideo->SiS_Pr.HaveEMI ? 1 : 0; - x.sisfb_haveemilcd = ivideo->SiS_Pr.HaveEMILCD ? 1 : 0; - x.sisfb_emi30 = ivideo->SiS_Pr.EMI_30; - x.sisfb_emi31 = ivideo->SiS_Pr.EMI_31; - x.sisfb_emi32 = ivideo->SiS_Pr.EMI_32; - x.sisfb_emi33 = ivideo->SiS_Pr.EMI_33; - x.sisfb_tvxpos = (u16)(ivideo->tvxpos + 32); - x.sisfb_tvypos = (u16)(ivideo->tvypos + 32); - - if(copy_to_user((void __user *)arg, &x, sizeof(x))) { - return -EFAULT; + ivideo->sisfb_infoblock.fbvidmode = ivideo->modeprechange; } + ivideo->sisfb_infoblock.sisfb_caps = ivideo->caps; + ivideo->sisfb_infoblock.sisfb_tqlen = ivideo->cmdQueueSize / 1024; + ivideo->sisfb_infoblock.sisfb_pcibus = ivideo->pcibus; + ivideo->sisfb_infoblock.sisfb_pcislot = ivideo->pcislot; + ivideo->sisfb_infoblock.sisfb_pcifunc = ivideo->pcifunc; + ivideo->sisfb_infoblock.sisfb_lcdpdc = ivideo->detectedpdc; + ivideo->sisfb_infoblock.sisfb_lcdpdca = ivideo->detectedpdca; + ivideo->sisfb_infoblock.sisfb_lcda = ivideo->detectedlcda; + ivideo->sisfb_infoblock.sisfb_vbflags = ivideo->vbflags; + ivideo->sisfb_infoblock.sisfb_currentvbflags = ivideo->currentvbflags; + ivideo->sisfb_infoblock.sisfb_scalelcd = ivideo->SiS_Pr.UsePanelScaler; + ivideo->sisfb_infoblock.sisfb_specialtiming = ivideo->SiS_Pr.SiS_CustomT; + ivideo->sisfb_infoblock.sisfb_haveemi = ivideo->SiS_Pr.HaveEMI ? 1 : 0; + ivideo->sisfb_infoblock.sisfb_haveemilcd = ivideo->SiS_Pr.HaveEMILCD ? 1 : 0; + ivideo->sisfb_infoblock.sisfb_emi30 = ivideo->SiS_Pr.EMI_30; + ivideo->sisfb_infoblock.sisfb_emi31 = ivideo->SiS_Pr.EMI_31; + ivideo->sisfb_infoblock.sisfb_emi32 = ivideo->SiS_Pr.EMI_32; + ivideo->sisfb_infoblock.sisfb_emi33 = ivideo->SiS_Pr.EMI_33; + ivideo->sisfb_infoblock.sisfb_tvxpos = (u16)(ivideo->tvxpos + 32); + ivideo->sisfb_infoblock.sisfb_tvypos = (u16)(ivideo->tvypos + 32); + ivideo->sisfb_infoblock.sisfb_heapsize = ivideo->sisfb_heap_size / 1024; + ivideo->sisfb_infoblock.sisfb_videooffset = ivideo->video_offset; + ivideo->sisfb_infoblock.sisfb_curfstn = ivideo->curFSTN; + ivideo->sisfb_infoblock.sisfb_curdstn = ivideo->curDSTN; + ivideo->sisfb_infoblock.sisfb_vbflags2 = ivideo->vbflags2; + ivideo->sisfb_infoblock.sisfb_can_post = ivideo->sisfb_can_post ? 1 : 0; + ivideo->sisfb_infoblock.sisfb_card_posted = ivideo->sisfb_card_posted ? 1 : 0; + ivideo->sisfb_infoblock.sisfb_was_boot_device = ivideo->sisfb_was_boot_device ? 1 : 0; + + if(copy_to_user((void __user *)arg, &ivideo->sisfb_infoblock, + sizeof(ivideo->sisfb_infoblock))) + return -EFAULT; + break; case SISFB_GET_VBRSTATUS_OLD: - if(ivideo->warncount++ < 50) { - printk(KERN_INFO "sisfb: Deprecated ioctl call received - update your application!\n"); - } + if(ivideo->warncount++ < 10) + printk(KERN_INFO + "sisfb: Deprecated ioctl call received - update your application!\n"); case SISFB_GET_VBRSTATUS: - if(sisfb_CheckVBRetrace(ivideo)) { + if(sisfb_CheckVBRetrace(ivideo)) return put_user((u32)1, argp); - } else { + else return put_user((u32)0, argp); - } case SISFB_GET_AUTOMAXIMIZE_OLD: - if(ivideo->warncount++ < 50) { - printk(KERN_INFO "sisfb: Deprecated ioctl call received - update your application!\n"); - } + if(ivideo->warncount++ < 10) + printk(KERN_INFO + "sisfb: Deprecated ioctl call received - update your application!\n"); case SISFB_GET_AUTOMAXIMIZE: - if(ivideo->sisfb_max) return put_user((u32)1, argp); - else return put_user((u32)0, argp); + if(ivideo->sisfb_max) + return put_user((u32)1, argp); + else + return put_user((u32)0, argp); case SISFB_SET_AUTOMAXIMIZE_OLD: - if(ivideo->warncount++ < 50) { - printk(KERN_INFO "sisfb: Deprecated ioctl call received - update your application!\n"); - } + if(ivideo->warncount++ < 10) + printk(KERN_INFO + "sisfb: Deprecated ioctl call received - update your application!\n"); case SISFB_SET_AUTOMAXIMIZE: - if(copy_from_user(&gpu32, argp, sizeof(gpu32))) { + if(get_user(gpu32, argp)) return -EFAULT; - } + ivideo->sisfb_max = (gpu32) ? 1 : 0; break; case SISFB_SET_TVPOSOFFSET: - if(copy_from_user(&gpu32, argp, sizeof(gpu32))) { + if(get_user(gpu32, argp)) return -EFAULT; - } + sisfb_set_TVxposoffset(ivideo, ((int)(gpu32 >> 16)) - 32); sisfb_set_TVyposoffset(ivideo, ((int)(gpu32 & 0xffff)) - 32); break; case SISFB_GET_TVPOSOFFSET: - return put_user((u32)(((ivideo->tvxpos+32)<<16)|((ivideo->tvypos+32)&0xffff)), - argp); + return put_user((u32)(((ivideo->tvxpos+32)<<16)|((ivideo->tvypos+32)&0xffff)), + argp); + + case SISFB_COMMAND: + if(copy_from_user(&ivideo->sisfb_command, (void __user *)arg, + sizeof(struct sisfb_cmd))) + return -EFAULT; + + sisfb_handle_command(ivideo, &ivideo->sisfb_command); + + if(copy_to_user((void __user *)arg, &ivideo->sisfb_command, + sizeof(struct sisfb_cmd))) + return -EFAULT; + + break; case SISFB_SET_LOCK: - if(copy_from_user(&gpu32, argp, sizeof(gpu32))) { + if(get_user(gpu32, argp)) return -EFAULT; - } + ivideo->sisfblocked = (gpu32) ? 1 : 0; break; default: +#ifdef SIS_NEW_CONFIG_COMPAT return -ENOIOCTLCMD; +#else + return -EINVAL; +#endif } return 0; } -#ifdef CONFIG_COMPAT -static long sisfb_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg, struct fb_info *info) +#ifdef SIS_NEW_CONFIG_COMPAT +static long +sisfb_compat_ioctl(struct file *f, unsigned int cmd, unsigned long arg, struct fb_info *info) { int ret; + lock_kernel(); ret = sisfb_ioctl(NULL, f, cmd, arg, info); unlock_kernel(); @@ -2219,7 +1946,7 @@ sisfb_get_fix(struct fb_fix_screeninfo *fix, int con, struct fb_info *info) strcpy(fix->id, ivideo->myid); - fix->smem_start = ivideo->video_base; + fix->smem_start = ivideo->video_base + ivideo->video_offset; fix->smem_len = ivideo->sisfb_mem; fix->type = FB_TYPE_PACKED_PIXELS; fix->type_aux = 0; @@ -2231,11 +1958,17 @@ sisfb_get_fix(struct fb_fix_screeninfo *fix, int con, struct fb_info *info) fix->mmio_start = ivideo->mmio_base; fix->mmio_len = ivideo->mmio_size; if(ivideo->sisvga_engine == SIS_300_VGA) { - fix->accel = FB_ACCEL_SIS_GLAMOUR; - } else if((ivideo->chip == SIS_330) || (ivideo->chip == SIS_760)) { - fix->accel = FB_ACCEL_SIS_XABRE; + fix->accel = FB_ACCEL_SIS_GLAMOUR; + } else if((ivideo->chip == SIS_330) || + (ivideo->chip == SIS_760) || + (ivideo->chip == SIS_761)) { + fix->accel = FB_ACCEL_SIS_XABRE; + } else if(ivideo->chip == XGI_20) { + fix->accel = FB_ACCEL_XGI_VOLARI_Z; + } else if(ivideo->chip >= XGI_40) { + fix->accel = FB_ACCEL_XGI_VOLARI_V; } else { - fix->accel = FB_ACCEL_SIS_GLAMOUR_2; + fix->accel = FB_ACCEL_SIS_GLAMOUR_2; } return 0; @@ -2251,40 +1984,41 @@ static struct fb_ops sisfb_ops = { .fb_set_var = sisfb_set_var, .fb_get_cmap = sisfb_get_cmap, .fb_set_cmap = sisfb_set_cmap, - .fb_pan_display = sisfb_pan_display, + .fb_pan_display = sisfb_pan_display, .fb_ioctl = sisfb_ioctl }; #endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) static struct fb_ops sisfb_ops = { - .owner = THIS_MODULE, - .fb_open = sisfb_open, - .fb_release = sisfb_release, - .fb_check_var = sisfb_check_var, - .fb_set_par = sisfb_set_par, - .fb_setcolreg = sisfb_setcolreg, - .fb_pan_display = sisfb_pan_display, - .fb_blank = sisfb_blank, - .fb_fillrect = fbcon_sis_fillrect, - .fb_copyarea = fbcon_sis_copyarea, - .fb_imageblit = cfb_imageblit, - .fb_cursor = soft_cursor, - .fb_sync = fbcon_sis_sync, - .fb_ioctl = sisfb_ioctl, -#ifdef CONFIG_COMPAT - .fb_compat_ioctl = sisfb_compat_ioctl, + .owner = THIS_MODULE, + .fb_open = sisfb_open, + .fb_release = sisfb_release, + .fb_check_var = sisfb_check_var, + .fb_set_par = sisfb_set_par, + .fb_setcolreg = sisfb_setcolreg, + .fb_pan_display = sisfb_pan_display, + .fb_blank = sisfb_blank, + .fb_fillrect = fbcon_sis_fillrect, + .fb_copyarea = fbcon_sis_copyarea, + .fb_imageblit = cfb_imageblit, + .fb_cursor = soft_cursor, + .fb_sync = fbcon_sis_sync, +#ifdef SIS_NEW_CONFIG_COMPAT + .fb_compat_ioctl= sisfb_compat_ioctl, #endif + .fb_ioctl = sisfb_ioctl }; #endif /* ---------------- Chip generation dependent routines ---------------- */ -static struct pci_dev * sisfb_get_northbridge(int basechipid) +static struct pci_dev * __devinit +sisfb_get_northbridge(int basechipid) { struct pci_dev *pdev = NULL; int nbridgenum, nbridgeidx, i; - const unsigned short nbridgeids[] = { + static const unsigned short nbridgeids[] = { PCI_DEVICE_ID_SI_540, /* for SiS 540 VGA */ PCI_DEVICE_ID_SI_630, /* for SiS 630/730 VGA */ PCI_DEVICE_ID_SI_730, @@ -2292,13 +2026,14 @@ static struct pci_dev * sisfb_get_northbridge(int basechipid) PCI_DEVICE_ID_SI_650, /* for SiS 650/651/740 VGA */ PCI_DEVICE_ID_SI_651, PCI_DEVICE_ID_SI_740, - PCI_DEVICE_ID_SI_661, /* for SiS 661/741/660/760 VGA */ + PCI_DEVICE_ID_SI_661, /* for SiS 661/741/660/760/761 VGA */ PCI_DEVICE_ID_SI_741, PCI_DEVICE_ID_SI_660, - PCI_DEVICE_ID_SI_760 + PCI_DEVICE_ID_SI_760, + PCI_DEVICE_ID_SI_761 }; - switch(basechipid) { + switch(basechipid) { #ifdef CONFIG_FB_SIS_300 case SIS_540: nbridgeidx = 0; nbridgenum = 1; break; case SIS_630: nbridgeidx = 1; nbridgenum = 2; break; @@ -2306,35 +2041,40 @@ static struct pci_dev * sisfb_get_northbridge(int basechipid) #ifdef CONFIG_FB_SIS_315 case SIS_550: nbridgeidx = 3; nbridgenum = 1; break; case SIS_650: nbridgeidx = 4; nbridgenum = 3; break; - case SIS_660: nbridgeidx = 7; nbridgenum = 4; break; + case SIS_660: nbridgeidx = 7; nbridgenum = 5; break; #endif default: return NULL; } for(i = 0; i < nbridgenum; i++) { - if((pdev = pci_find_device(PCI_VENDOR_ID_SI, nbridgeids[nbridgeidx+i], NULL))) break; + if((pdev = SIS_PCI_GET_DEVICE(PCI_VENDOR_ID_SI, + nbridgeids[nbridgeidx+i], NULL))) + break; } return pdev; } -static int __devinit sisfb_get_dram_size(struct sis_video_info *ivideo) +static int __devinit +sisfb_get_dram_size(struct sis_video_info *ivideo) { #if defined(CONFIG_FB_SIS_300) || defined(CONFIG_FB_SIS_315) u8 reg; #endif ivideo->video_size = 0; + ivideo->UMAsize = ivideo->LFBsize = 0; switch(ivideo->chip) { #ifdef CONFIG_FB_SIS_300 case SIS_300: - inSISIDXREG(SISSR, 0x14, reg); + inSISIDXREG(SISSR, 0x14, reg); ivideo->video_size = ((reg & 0x3F) + 1) << 20; break; case SIS_540: case SIS_630: case SIS_730: - if(!ivideo->nbridge) return -1; - pci_read_config_byte(ivideo->nbridge, 0x63, ®); + if(!ivideo->nbridge) + return -1; + pci_read_config_byte(ivideo->nbridge, 0x63, ®); ivideo->video_size = 1 << (((reg & 0x70) >> 4) + 21); break; #endif @@ -2342,45 +2082,68 @@ static int __devinit sisfb_get_dram_size(struct sis_video_info *ivideo) case SIS_315H: case SIS_315PRO: case SIS_315: - inSISIDXREG(SISSR, 0x14, reg); + inSISIDXREG(SISSR, 0x14, reg); ivideo->video_size = (1 << ((reg & 0xf0) >> 4)) << 20; switch((reg >> 2) & 0x03) { case 0x01: case 0x03: - ivideo->video_size <<= 1; - break; + ivideo->video_size <<= 1; + break; case 0x02: - ivideo->video_size += (ivideo->video_size/2); + ivideo->video_size += (ivideo->video_size/2); } - break; + break; case SIS_330: - inSISIDXREG(SISSR, 0x14, reg); + inSISIDXREG(SISSR, 0x14, reg); ivideo->video_size = (1 << ((reg & 0xf0) >> 4)) << 20; if(reg & 0x0c) ivideo->video_size <<= 1; - break; + break; case SIS_550: case SIS_650: case SIS_740: - inSISIDXREG(SISSR, 0x14, reg); + inSISIDXREG(SISSR, 0x14, reg); ivideo->video_size = (((reg & 0x3f) + 1) << 2) << 20; break; case SIS_661: case SIS_741: - inSISIDXREG(SISCR, 0x79, reg); + inSISIDXREG(SISCR, 0x79, reg); ivideo->video_size = (1 << ((reg & 0xf0) >> 4)) << 20; - break; + break; case SIS_660: case SIS_760: + case SIS_761: inSISIDXREG(SISCR, 0x79, reg); reg = (reg & 0xf0) >> 4; - if(reg) ivideo->video_size = (1 << reg) << 20; + if(reg) { + ivideo->video_size = (1 << reg) << 20; + ivideo->UMAsize = ivideo->video_size; + } inSISIDXREG(SISCR, 0x78, reg); reg &= 0x30; if(reg) { - if(reg == 0x10) ivideo->video_size += (32 << 20); - else ivideo->video_size += (64 << 20); + if(reg == 0x10) { + ivideo->LFBsize = (32 << 20); + } else { + ivideo->LFBsize = (64 << 20); + } + ivideo->video_size += ivideo->LFBsize; } - break; + break; + case SIS_340: + case XGI_20: + case XGI_40: + inSISIDXREG(SISSR, 0x14, reg); + ivideo->video_size = (1 << ((reg & 0xf0) >> 4)) << 20; + if(ivideo->chip != XGI_20) { + reg = (reg & 0x0c) >> 2; + if(ivideo->revision_id == 2) { + if(reg & 0x01) reg = 0x02; + else reg = 0x00; + } + if(reg == 0x02) ivideo->video_size <<= 1; + else if(reg == 0x03) ivideo->video_size <<= 2; + } + break; #endif default: return -1; @@ -2390,17 +2153,24 @@ static int __devinit sisfb_get_dram_size(struct sis_video_info *ivideo) /* -------------- video bridge device detection --------------- */ -static void __devinit sisfb_detect_VB_connect(struct sis_video_info *ivideo) +static void __devinit +sisfb_detect_VB_connect(struct sis_video_info *ivideo) { u8 cr32, temp; + /* No CRT2 on XGI Z7 */ + if(ivideo->chip == XGI_20) { + ivideo->sisfb_crt1off = 0; + return; + } + #ifdef CONFIG_FB_SIS_300 if(ivideo->sisvga_engine == SIS_300_VGA) { inSISIDXREG(SISSR, 0x17, temp); if((temp & 0x0F) && (ivideo->chip != SIS_300)) { /* PAL/NTSC is stored on SR16 on such machines */ if(!(ivideo->vbflags & (TV_PAL | TV_NTSC | TV_PALM | TV_PALN))) { - inSISIDXREG(SISSR, 0x16, temp); + inSISIDXREG(SISSR, 0x16, temp); if(temp & 0x20) ivideo->vbflags |= TV_PAL; else @@ -2435,28 +2205,29 @@ static void __devinit sisfb_detect_VB_connect(struct sis_video_info *ivideo) if(ivideo->sisfb_tvplug != -1) { if( (ivideo->sisvga_engine != SIS_315_VGA) || - (!(ivideo->vbflags & (VB_301C|VB_301LV|VB_302LV))) ) { + (!(ivideo->vbflags2 & VB2_SISYPBPRBRIDGE)) ) { if(ivideo->sisfb_tvplug & TV_YPBPR) { - ivideo->sisfb_tvplug = -1; + ivideo->sisfb_tvplug = -1; printk(KERN_ERR "sisfb: YPbPr not supported\n"); } } } if(ivideo->sisfb_tvplug != -1) { if( (ivideo->sisvga_engine != SIS_315_VGA) || - (!(ivideo->vbflags & (VB_301|VB_301B|VB_302B))) ) { + (!(ivideo->vbflags2 & VB2_SISHIVISIONBRIDGE)) ) { if(ivideo->sisfb_tvplug & TV_HIVISION) { - ivideo->sisfb_tvplug = -1; + ivideo->sisfb_tvplug = -1; printk(KERN_ERR "sisfb: HiVision not supported\n"); } } } if(ivideo->sisfb_tvstd != -1) { - if( (!(ivideo->vbflags & VB_SISBRIDGE)) && - (!((ivideo->sisvga_engine == SIS_315_VGA) && (ivideo->vbflags & VB_CHRONTEL))) ) { + if( (!(ivideo->vbflags2 & VB2_SISBRIDGE)) && + (!((ivideo->sisvga_engine == SIS_315_VGA) && + (ivideo->vbflags2 & VB2_CHRONTEL))) ) { if(ivideo->sisfb_tvstd & (TV_PALN | TV_PALN | TV_NTSCJ)) { - ivideo->sisfb_tvstd = -1; - printk(KERN_ERR "sisfb: PALM/PALN/NTSCJ not supported\n"); + ivideo->sisfb_tvstd = -1; + printk(KERN_ERR "sisfb: PALM/PALN/NTSCJ not supported\n"); } } } @@ -2468,7 +2239,7 @@ static void __devinit sisfb_detect_VB_connect(struct sis_video_info *ivideo) if(cr32 & SIS_VB_YPBPR) ivideo->vbflags |= (TV_YPBPR|TV_YPBPR525I); /* default: 480i */ else if(cr32 & SIS_VB_HIVISION) ivideo->vbflags |= TV_HIVISION; else if(cr32 & SIS_VB_SCART) ivideo->vbflags |= TV_SCART; - else { + else { if(cr32 & SIS_VB_SVIDEO) ivideo->vbflags |= TV_SVIDEO; if(cr32 & SIS_VB_COMPOSITE) ivideo->vbflags |= TV_AVIDEO; } @@ -2485,165 +2256,44 @@ static void __devinit sisfb_detect_VB_connect(struct sis_video_info *ivideo) } if(!(ivideo->vbflags & (TV_PAL | TV_NTSC | TV_PALM | TV_PALN | TV_NTSCJ))) { if(ivideo->sisvga_engine == SIS_300_VGA) { - inSISIDXREG(SISSR, 0x38, temp); + inSISIDXREG(SISSR, 0x38, temp); if(temp & 0x01) ivideo->vbflags |= TV_PAL; else ivideo->vbflags |= TV_NTSC; } else if((ivideo->chip <= SIS_315PRO) || (ivideo->chip >= SIS_330)) { - inSISIDXREG(SISSR, 0x38, temp); + inSISIDXREG(SISSR, 0x38, temp); if(temp & 0x01) ivideo->vbflags |= TV_PAL; else ivideo->vbflags |= TV_NTSC; - } else { - inSISIDXREG(SISCR, 0x79, temp); + } else { + inSISIDXREG(SISCR, 0x79, temp); if(temp & 0x20) ivideo->vbflags |= TV_PAL; else ivideo->vbflags |= TV_NTSC; - } + } } } /* Copy forceCRT1 option to CRT1off if option is given */ - if(ivideo->sisfb_forcecrt1 != -1) { - ivideo->sisfb_crt1off = (ivideo->sisfb_forcecrt1) ? 0 : 1; - } -} - -static void __devinit sisfb_get_VB_type(struct sis_video_info *ivideo) -{ - char stdstr[] = "sisfb: Detected"; - char bridgestr[] = "video bridge"; - u8 vb_chipid; - u8 reg; - - inSISIDXREG(SISPART4, 0x00, vb_chipid); - switch(vb_chipid) { - case 0x01: - inSISIDXREG(SISPART4, 0x01, reg); - if(reg < 0xb0) { - ivideo->vbflags |= VB_301; - printk(KERN_INFO "%s SiS301 %s\n", stdstr, bridgestr); - } else if(reg < 0xc0) { - ivideo->vbflags |= VB_301B; - inSISIDXREG(SISPART4,0x23,reg); - if(!(reg & 0x02)) { - ivideo->vbflags |= VB_30xBDH; - printk(KERN_INFO "%s SiS301B-DH %s\n", stdstr, bridgestr); - } else { - printk(KERN_INFO "%s SiS301B %s\n", stdstr, bridgestr); - } - } else if(reg < 0xd0) { - ivideo->vbflags |= VB_301C; - printk(KERN_INFO "%s SiS301C %s\n", stdstr, bridgestr); - } else if(reg < 0xe0) { - ivideo->vbflags |= VB_301LV; - printk(KERN_INFO "%s SiS301LV %s\n", stdstr, bridgestr); - } else if(reg <= 0xe1) { - inSISIDXREG(SISPART4,0x39,reg); - if(reg == 0xff) { - ivideo->vbflags |= VB_302LV; - printk(KERN_INFO "%s SiS302LV %s\n", stdstr, bridgestr); - } else { - ivideo->vbflags |= VB_301C; - printk(KERN_INFO "%s SiS301C(P4) %s\n", stdstr, bridgestr); -#if 0 - ivideo->vbflags |= VB_302ELV; - printk(KERN_INFO "%s SiS302ELV %s\n", stdstr, bridgestr); -#endif - } - } - break; - case 0x02: - ivideo->vbflags |= VB_302B; - printk(KERN_INFO "%s SiS302B %s\n", stdstr, bridgestr); - break; - } - - if((!(ivideo->vbflags & VB_VIDEOBRIDGE)) && (ivideo->chip != SIS_300)) { - inSISIDXREG(SISCR, 0x37, reg); - reg &= SIS_EXTERNAL_CHIP_MASK; - reg >>= 1; - if(ivideo->sisvga_engine == SIS_300_VGA) { -#ifdef CONFIG_FB_SIS_300 - switch(reg) { - case SIS_EXTERNAL_CHIP_LVDS: - ivideo->vbflags |= VB_LVDS; - break; - case SIS_EXTERNAL_CHIP_TRUMPION: - ivideo->vbflags |= VB_TRUMPION; - break; - case SIS_EXTERNAL_CHIP_CHRONTEL: - ivideo->vbflags |= VB_CHRONTEL; - break; - case SIS_EXTERNAL_CHIP_LVDS_CHRONTEL: - ivideo->vbflags |= (VB_LVDS | VB_CHRONTEL); - break; - } - if(ivideo->vbflags & VB_CHRONTEL) ivideo->chronteltype = 1; -#endif - } else if(ivideo->chip < SIS_661) { -#ifdef CONFIG_FB_SIS_315 - switch (reg) { - case SIS310_EXTERNAL_CHIP_LVDS: - ivideo->vbflags |= VB_LVDS; - break; - case SIS310_EXTERNAL_CHIP_LVDS_CHRONTEL: - ivideo->vbflags |= (VB_LVDS | VB_CHRONTEL); - break; - } - if(ivideo->vbflags & VB_CHRONTEL) ivideo->chronteltype = 2; -#endif - } else if(ivideo->chip >= SIS_661) { -#ifdef CONFIG_FB_SIS_315 - inSISIDXREG(SISCR, 0x38, reg); - reg >>= 5; - switch(reg) { - case 0x02: - ivideo->vbflags |= VB_LVDS; - break; - case 0x03: - ivideo->vbflags |= (VB_LVDS | VB_CHRONTEL); - break; - case 0x04: - ivideo->vbflags |= (VB_LVDS | VB_CONEXANT); - break; - } - if(ivideo->vbflags & VB_CHRONTEL) ivideo->chronteltype = 2; -#endif - } - if(ivideo->vbflags & VB_LVDS) { - printk(KERN_INFO "%s LVDS transmitter\n", stdstr); - } - if(ivideo->vbflags & VB_TRUMPION) { - printk(KERN_INFO "%s Trumpion Zurac LCD scaler\n", stdstr); - } - if(ivideo->vbflags & VB_CHRONTEL) { - printk(KERN_INFO "%s Chrontel TV encoder\n", stdstr); - } - if(ivideo->vbflags & VB_CONEXANT) { - printk(KERN_INFO "%s Conexant external device\n", stdstr); - } - } - - if(ivideo->vbflags & VB_SISBRIDGE) { - SiS_Sense30x(ivideo); - } else if(ivideo->vbflags & VB_CHRONTEL) { - SiS_SenseCh(ivideo); + if(ivideo->sisfb_forcecrt1 != -1) { + ivideo->sisfb_crt1off = (ivideo->sisfb_forcecrt1) ? 0 : 1; } } /* ------------------ Sensing routines ------------------ */ -static BOOLEAN __devinit sisfb_test_DDC1(struct sis_video_info *ivideo) +static BOOLEAN __devinit +sisfb_test_DDC1(struct sis_video_info *ivideo) { unsigned short old; int count = 48; old = SiS_ReadDDC1Bit(&ivideo->SiS_Pr); do { - if(old != SiS_ReadDDC1Bit(&ivideo->SiS_Pr)) break; + if(old != SiS_ReadDDC1Bit(&ivideo->SiS_Pr)) break; } while(count--); return (count == -1) ? FALSE : TRUE; } -static void __devinit sisfb_sense_crt1(struct sis_video_info *ivideo) +static void __devinit +sisfb_sense_crt1(struct sis_video_info *ivideo) { BOOLEAN mustwait = FALSE; u8 sr1F, cr17; @@ -2699,7 +2349,8 @@ static void __devinit sisfb_sense_crt1(struct sis_video_info *ivideo) if(temp == 0xffff) { i = 3; do { - temp = SiS_HandleDDC(&ivideo->SiS_Pr, ivideo->vbflags, ivideo->sisvga_engine, 0, 0, NULL); + temp = SiS_HandleDDC(&ivideo->SiS_Pr, ivideo->vbflags, + ivideo->sisvga_engine, 0, 0, NULL, ivideo->vbflags2); } while(((temp == 0) || (temp == 0xffff)) && i--); if((temp == 0) || (temp == 0xffff)) { @@ -2723,7 +2374,96 @@ static void __devinit sisfb_sense_crt1(struct sis_video_info *ivideo) } /* Determine and detect attached devices on SiS30x */ -static int __devinit SISDoSense(struct sis_video_info *ivideo, u16 type, u16 test) +static void __devinit +SiS_SenseLCD(struct sis_video_info *ivideo) +{ + unsigned char buffer[256]; + unsigned short temp, realcrtno, i; + u8 reg, cr37 = 0, paneltype = 0; + u16 xres, yres; + + ivideo->SiS_Pr.PanelSelfDetected = FALSE; + + /* LCD detection only for TMDS bridges */ + if(!(ivideo->vbflags2 & VB2_SISTMDSBRIDGE)) + return; + if(ivideo->vbflags2 & VB2_30xBDH) + return; + + /* If LCD already set up by BIOS, skip it */ + inSISIDXREG(SISCR, 0x32, reg); + if(reg & 0x08) + return; + + realcrtno = 1; + if(ivideo->SiS_Pr.DDCPortMixup) + realcrtno = 0; + + /* Check DDC capabilities */ + temp = SiS_HandleDDC(&ivideo->SiS_Pr, ivideo->vbflags, ivideo->sisvga_engine, + realcrtno, 0, &buffer[0], ivideo->vbflags2); + + if((!temp) || (temp == 0xffff) || (!(temp & 0x02))) + return; + + /* Read DDC data */ + i = 3; /* Number of retrys */ + do { + temp = SiS_HandleDDC(&ivideo->SiS_Pr, ivideo->vbflags, + ivideo->sisvga_engine, realcrtno, 1, + &buffer[0], ivideo->vbflags2); + } while((temp) && i--); + + if(temp) + return; + + /* No digital device */ + if(!(buffer[0x14] & 0x80)) + return; + + /* First detailed timing preferred timing? */ + if(!(buffer[0x18] & 0x02)) + return; + + xres = buffer[0x38] | ((buffer[0x3a] & 0xf0) << 4); + yres = buffer[0x3b] | ((buffer[0x3d] & 0xf0) << 4); + + switch(xres) { + case 1024: + if(yres == 768) + paneltype = 0x02; + break; + case 1280: + if(yres == 1024) + paneltype = 0x03; + break; + case 1600: + if((yres == 1200) && (ivideo->vbflags2 & VB2_30xC)) + paneltype = 0x0b; + break; + } + + if(!paneltype) + return; + + if(buffer[0x23]) + cr37 |= 0x10; + + if((buffer[0x47] & 0x18) == 0x18) + cr37 |= ((((buffer[0x47] & 0x06) ^ 0x06) << 5) | 0x20); + else + cr37 |= 0xc0; + + outSISIDXREG(SISCR, 0x36, paneltype); + cr37 &= 0xf1; + setSISIDXREG(SISCR, 0x37, 0x0c, cr37); + orSISIDXREG(SISCR, 0x32, 0x08); + + ivideo->SiS_Pr.PanelSelfDetected = TRUE; +} + +static int __devinit +SISDoSense(struct sis_video_info *ivideo, u16 type, u16 test) { int temp, mytest, result, i, j; @@ -2749,10 +2489,11 @@ static int __devinit SISDoSense(struct sis_video_info *ivideo, u16 type, u16 tes } if((result == 0) || (result >= 2)) break; } - return(result); + return result; } -static void __devinit SiS_Sense30x(struct sis_video_info *ivideo) +static void __devinit +SiS_Sense30x(struct sis_video_info *ivideo) { u8 backupP4_0d,backupP2_00,backupP2_4d,backupSR_1e,biosflag=0; u16 svhs=0, svhs_c=0; @@ -2762,36 +2503,51 @@ static void __devinit SiS_Sense30x(struct sis_video_info *ivideo) char stdstr[] = "sisfb: Detected"; char tvstr[] = "TV connected to"; - if(ivideo->vbflags & VB_301) { + if(ivideo->vbflags2 & VB2_301) { svhs = 0x00b9; cvbs = 0x00b3; vga2 = 0x00d1; inSISIDXREG(SISPART4,0x01,myflag); if(myflag & 0x04) { svhs = 0x00dd; cvbs = 0x00ee; vga2 = 0x00fd; } - } else if(ivideo->vbflags & (VB_301B | VB_302B)) { + } else if(ivideo->vbflags2 & (VB2_301B | VB2_302B)) { svhs = 0x016b; cvbs = 0x0174; vga2 = 0x0190; - } else if(ivideo->vbflags & (VB_301LV | VB_302LV)) { + } else if(ivideo->vbflags2 & (VB2_301LV | VB2_302LV)) { svhs = 0x0200; cvbs = 0x0100; - } else if(ivideo->vbflags & (VB_301C | VB_302ELV)) { + } else if(ivideo->vbflags2 & (VB2_301C | VB2_302ELV | VB2_307T | VB2_307LV)) { svhs = 0x016b; cvbs = 0x0110; vga2 = 0x0190; - } else return; + } else + return; vga2_c = 0x0e08; svhs_c = 0x0404; cvbs_c = 0x0804; - if(ivideo->vbflags & (VB_301LV|VB_302LV|VB_302ELV)) { + if(ivideo->vbflags & (VB2_301LV|VB2_302LV|VB2_302ELV|VB2_307LV)) { svhs_c = 0x0408; cvbs_c = 0x0808; } + biosflag = 2; + if(ivideo->haveXGIROM) { + biosflag = ivideo->bios_abase[0x58] & 0x03; + } else if(ivideo->newrom) { + if(ivideo->bios_abase[0x5d] & 0x04) biosflag |= 0x01; + } else if(ivideo->sisvga_engine == SIS_300_VGA) { + if(ivideo->bios_abase) { + biosflag = ivideo->bios_abase[0xfe] & 0x03; + } + } if(ivideo->chip == SIS_300) { inSISIDXREG(SISSR,0x3b,myflag); if(!(myflag & 0x01)) vga2 = vga2_c = 0; } + if(!(ivideo->vbflags2 & VB2_SISVGA2BRIDGE)) { + vga2 = vga2_c = 0; + } + inSISIDXREG(SISSR,0x1e,backupSR_1e); orSISIDXREG(SISSR,0x1e,0x20); inSISIDXREG(SISPART4,0x0d,backupP4_0d); - if(ivideo->vbflags & VB_301C) { + if(ivideo->vbflags2 & VB2_30xC) { setSISIDXREG(SISPART4,0x0d,~0x07,0x01); } else { orSISIDXREG(SISPART4,0x0d,0x04); @@ -2802,11 +2558,11 @@ static void __devinit SiS_Sense30x(struct sis_video_info *ivideo) outSISIDXREG(SISPART2,0x00,((backupP2_00 | 0x1c) & 0xfc)); inSISIDXREG(SISPART2,0x4d,backupP2_4d); - if(ivideo->vbflags & (VB_301C|VB_301LV|VB_302LV|VB_302ELV)) { + if(ivideo->vbflags2 & VB2_SISYPBPRBRIDGE) { outSISIDXREG(SISPART2,0x4d,(backupP2_4d & ~0x10)); } - if(!(ivideo->vbflags & VB_301C)) { + if(!(ivideo->vbflags2 & VB2_30xCLV)) { SISDoSense(ivideo, 0, 0); } @@ -2826,12 +2582,11 @@ static void __devinit SiS_Sense30x(struct sis_video_info *ivideo) andSISIDXREG(SISCR, 0x32, 0x3f); - if(ivideo->vbflags & VB_301C) { + if(ivideo->vbflags2 & VB2_30xCLV) { orSISIDXREG(SISPART4,0x0d,0x04); } - if((ivideo->sisvga_engine == SIS_315_VGA) && - (ivideo->vbflags & (VB_301C|VB_301LV|VB_302LV|VB_302ELV))) { + if((ivideo->sisvga_engine == SIS_315_VGA) && (ivideo->vbflags2 & VB2_SISYPBPRBRIDGE)) { outSISIDXREG(SISPART2,0x4d,(backupP2_4d | 0x10)); SiS_DDC2Delay(&ivideo->SiS_Pr, 0x2000); if((result = SISDoSense(ivideo, svhs, 0x0604))) { @@ -2864,7 +2619,7 @@ static void __devinit SiS_Sense30x(struct sis_video_info *ivideo) outSISIDXREG(SISPART4,0x0d,backupP4_0d); outSISIDXREG(SISSR,0x1e,backupSR_1e); - if(ivideo->vbflags & VB_301C) { + if(ivideo->vbflags2 & VB2_30xCLV) { inSISIDXREG(SISPART2,0x00,biosflag); if(biosflag & 0x20) { for(myflag = 2; myflag > 0; myflag--) { @@ -2878,7 +2633,8 @@ static void __devinit SiS_Sense30x(struct sis_video_info *ivideo) } /* Determine and detect attached TV's on Chrontel */ -static void __devinit SiS_SenseCh(struct sis_video_info *ivideo) +static void __devinit +SiS_SenseCh(struct sis_video_info *ivideo) { #if defined(CONFIG_FB_SIS_300) || defined(CONFIG_FB_SIS_315) u8 temp1, temp2; @@ -2899,7 +2655,7 @@ static void __devinit SiS_SenseCh(struct sis_video_info *ivideo) /* See Chrontel TB31 for explanation */ temp2 = SiS_GetCH700x(&ivideo->SiS_Pr, 0x0e); if(((temp2 & 0x07) == 0x01) || (temp2 & 0x04)) { - SiS_SetCH700x(&ivideo->SiS_Pr, 0x0b0e); + SiS_SetCH700x(&ivideo->SiS_Pr, 0x0e, 0x0b); SiS_DDC2Delay(&ivideo->SiS_Pr, 300); } temp2 = SiS_GetCH700x(&ivideo->SiS_Pr, 0x25); @@ -2909,15 +2665,15 @@ static void __devinit SiS_SenseCh(struct sis_video_info *ivideo) /* Read power status */ temp1 = SiS_GetCH700x(&ivideo->SiS_Pr, 0x0e); if((temp1 & 0x03) != 0x03) { - /* Power all outputs */ - SiS_SetCH700x(&ivideo->SiS_Pr, 0x0B0E); + /* Power all outputs */ + SiS_SetCH700x(&ivideo->SiS_Pr, 0x0e,0x0b); SiS_DDC2Delay(&ivideo->SiS_Pr, 300); } /* Sense connected TV devices */ for(i = 0; i < 3; i++) { - SiS_SetCH700x(&ivideo->SiS_Pr, 0x0110); + SiS_SetCH700x(&ivideo->SiS_Pr, 0x10, 0x01); SiS_DDC2Delay(&ivideo->SiS_Pr, 0x96); - SiS_SetCH700x(&ivideo->SiS_Pr, 0x0010); + SiS_SetCH700x(&ivideo->SiS_Pr, 0x10, 0x00); SiS_DDC2Delay(&ivideo->SiS_Pr, 0x96); temp1 = SiS_GetCH700x(&ivideo->SiS_Pr, 0x10); if(!(temp1 & 0x08)) test[i] = 0x02; @@ -2930,7 +2686,7 @@ static void __devinit SiS_SenseCh(struct sis_video_info *ivideo) else if(test[0] == test[2]) temp1 = test[0]; else if(test[1] == test[2]) temp1 = test[1]; else { - printk(KERN_INFO + printk(KERN_INFO "sisfb: TV detection unreliable - test results varied\n"); temp1 = test[2]; } @@ -2945,11 +2701,11 @@ static void __devinit SiS_SenseCh(struct sis_video_info *ivideo) orSISIDXREG(SISCR, 0x32, 0x01); andSISIDXREG(SISCR, 0x32, ~0x06); } else { - SiS_SetCH70xxANDOR(&ivideo->SiS_Pr, 0x010E,0xF8); + SiS_SetCH70xxANDOR(&ivideo->SiS_Pr, 0x0e, 0x01, 0xF8); andSISIDXREG(SISCR, 0x32, ~0x07); } } else if(temp1 == 0) { - SiS_SetCH70xxANDOR(&ivideo->SiS_Pr, 0x010E,0xF8); + SiS_SetCH70xxANDOR(&ivideo->SiS_Pr, 0x0e, 0x01, 0xF8); andSISIDXREG(SISCR, 0x32, ~0x07); } /* Set general purpose IO for Chrontel communication */ @@ -2960,19 +2716,19 @@ static void __devinit SiS_SenseCh(struct sis_video_info *ivideo) #ifdef CONFIG_FB_SIS_315 ivideo->SiS_Pr.SiS_IF_DEF_CH70xx = 2; /* Chrontel 7019 */ - temp1 = SiS_GetCH701x(&ivideo->SiS_Pr, 0x49); - SiS_SetCH701x(&ivideo->SiS_Pr, 0x2049); + temp1 = SiS_GetCH701x(&ivideo->SiS_Pr, 0x49); + SiS_SetCH701x(&ivideo->SiS_Pr, 0x49, 0x20); SiS_DDC2Delay(&ivideo->SiS_Pr, 0x96); temp2 = SiS_GetCH701x(&ivideo->SiS_Pr, 0x20); temp2 |= 0x01; - SiS_SetCH701x(&ivideo->SiS_Pr, (temp2 << 8) | 0x20); + SiS_SetCH701x(&ivideo->SiS_Pr, 0x20, temp2); SiS_DDC2Delay(&ivideo->SiS_Pr, 0x96); temp2 ^= 0x01; - SiS_SetCH701x(&ivideo->SiS_Pr, (temp2 << 8) | 0x20); + SiS_SetCH701x(&ivideo->SiS_Pr, 0x20, temp2); SiS_DDC2Delay(&ivideo->SiS_Pr, 0x96); temp2 = SiS_GetCH701x(&ivideo->SiS_Pr, 0x20); - SiS_SetCH701x(&ivideo->SiS_Pr, (temp1 << 8) | 0x49); - temp1 = 0; + SiS_SetCH701x(&ivideo->SiS_Pr, 0x49, temp1); + temp1 = 0; if(temp2 & 0x02) temp1 |= 0x01; if(temp2 & 0x10) temp1 |= 0x01; if(temp2 & 0x04) temp1 |= 0x02; @@ -2983,18 +2739,18 @@ static void __devinit SiS_SenseCh(struct sis_video_info *ivideo) ivideo->vbflags |= TV_AVIDEO; orSISIDXREG(SISCR, 0x32, 0x01); andSISIDXREG(SISCR, 0x32, ~0x06); - break; + break; case 0x02: printk(KERN_INFO "%s SVIDEO output\n", stdstr); ivideo->vbflags |= TV_SVIDEO; orSISIDXREG(SISCR, 0x32, 0x02); andSISIDXREG(SISCR, 0x32, ~0x05); - break; + break; case 0x04: printk(KERN_INFO "%s SCART output\n", stdstr); orSISIDXREG(SISCR, 0x32, 0x04); andSISIDXREG(SISCR, 0x32, ~0x03); - break; + break; default: andSISIDXREG(SISCR, 0x32, ~0x07); } @@ -3002,165 +2758,589 @@ static void __devinit SiS_SenseCh(struct sis_video_info *ivideo) } } -/* ------------------------ Heap routines -------------------------- */ - -static u32 __devinit -sisfb_getheapstart(struct sis_video_info *ivideo) +static void __devinit +sisfb_get_VB_type(struct sis_video_info *ivideo) { - u32 ret = ivideo->sisfb_parm_mem * 1024; - u32 max = ivideo->video_size - ivideo->hwcursor_size; - u32 def; + char stdstr[] = "sisfb: Detected"; + char bridgestr[] = "video bridge"; + u8 vb_chipid; + u8 reg; - /* Calculate heap start = end of memory for console - * - * CCCCCCCCDDDDDDDDDDDDDDDDDDDDDDDDDDDDHHHHQQQQQQQQQQ - * C = console, D = heap, H = HWCursor, Q = cmd-queue - * - * Basically given by "mem" parameter - * - * maximum = videosize - cmd_queue - hwcursor - * (results in a heap of size 0) - * default = SiS 300: depends on videosize - * SiS 315/330: 32k below max - */ + /* No CRT2 on XGI Z7 */ + if(ivideo->chip == XGI_20) + return; - if(ivideo->sisvga_engine == SIS_300_VGA) { - max -= TURBO_QUEUE_AREA_SIZE; - if(ivideo->video_size > 0x1000000) { - def = 0xc00000; - } else if(ivideo->video_size > 0x800000) { - def = 0x800000; - } else { - def = 0x400000; - } - } else { - max -= COMMAND_QUEUE_AREA_SIZE; - def = max - 0x8000; + inSISIDXREG(SISPART4, 0x00, vb_chipid); + switch(vb_chipid) { + case 0x01: + inSISIDXREG(SISPART4, 0x01, reg); + if(reg < 0xb0) { + ivideo->vbflags |= VB_301; /* Deprecated */ + ivideo->vbflags2 |= VB2_301; + printk(KERN_INFO "%s SiS301 %s\n", stdstr, bridgestr); + } else if(reg < 0xc0) { + ivideo->vbflags |= VB_301B; /* Deprecated */ + ivideo->vbflags2 |= VB2_301B; + inSISIDXREG(SISPART4,0x23,reg); + if(!(reg & 0x02)) { + ivideo->vbflags |= VB_30xBDH; /* Deprecated */ + ivideo->vbflags2 |= VB2_30xBDH; + printk(KERN_INFO "%s SiS301B-DH %s\n", stdstr, bridgestr); + } else { + printk(KERN_INFO "%s SiS301B %s\n", stdstr, bridgestr); + } + } else if(reg < 0xd0) { + ivideo->vbflags |= VB_301C; /* Deprecated */ + ivideo->vbflags2 |= VB2_301C; + printk(KERN_INFO "%s SiS301C %s\n", stdstr, bridgestr); + } else if(reg < 0xe0) { + ivideo->vbflags |= VB_301LV; /* Deprecated */ + ivideo->vbflags2 |= VB2_301LV; + printk(KERN_INFO "%s SiS301LV %s\n", stdstr, bridgestr); + } else if(reg <= 0xe1) { + inSISIDXREG(SISPART4,0x39,reg); + if(reg == 0xff) { + ivideo->vbflags |= VB_302LV; /* Deprecated */ + ivideo->vbflags2 |= VB2_302LV; + printk(KERN_INFO "%s SiS302LV %s\n", stdstr, bridgestr); + } else { + ivideo->vbflags |= VB_301C; /* Deprecated */ + ivideo->vbflags2 |= VB2_301C; + printk(KERN_INFO "%s SiS301C(P4) %s\n", stdstr, bridgestr); +#if 0 + ivideo->vbflags |= VB_302ELV; /* Deprecated */ + ivideo->vbflags2 |= VB2_302ELV; + printk(KERN_INFO "%s SiS302ELV %s\n", stdstr, bridgestr); +#endif + } + } + break; + case 0x02: + ivideo->vbflags |= VB_302B; /* Deprecated */ + ivideo->vbflags2 |= VB2_302B; + printk(KERN_INFO "%s SiS302B %s\n", stdstr, bridgestr); + break; } - if((!ret) || (ret > max) || (ivideo->cardnumber != 0)) { - ret = def; - } + if((!(ivideo->vbflags2 & VB2_VIDEOBRIDGE)) && (ivideo->chip != SIS_300)) { + inSISIDXREG(SISCR, 0x37, reg); + reg &= SIS_EXTERNAL_CHIP_MASK; + reg >>= 1; + if(ivideo->sisvga_engine == SIS_300_VGA) { +#ifdef CONFIG_FB_SIS_300 + switch(reg) { + case SIS_EXTERNAL_CHIP_LVDS: + ivideo->vbflags |= VB_LVDS; /* Deprecated */ + ivideo->vbflags2 |= VB2_LVDS; + break; + case SIS_EXTERNAL_CHIP_TRUMPION: + ivideo->vbflags |= (VB_LVDS | VB_TRUMPION); /* Deprecated */ + ivideo->vbflags2 |= (VB2_LVDS | VB2_TRUMPION); + break; + case SIS_EXTERNAL_CHIP_CHRONTEL: + ivideo->vbflags |= VB_CHRONTEL; /* Deprecated */ + ivideo->vbflags2 |= VB2_CHRONTEL; + break; + case SIS_EXTERNAL_CHIP_LVDS_CHRONTEL: + ivideo->vbflags |= (VB_LVDS | VB_CHRONTEL); /* Deprecated */ + ivideo->vbflags2 |= (VB2_LVDS | VB2_CHRONTEL); + break; + } + if(ivideo->vbflags2 & VB2_CHRONTEL) ivideo->chronteltype = 1; +#endif + } else if(ivideo->chip < SIS_661) { +#ifdef CONFIG_FB_SIS_315 + switch (reg) { + case SIS310_EXTERNAL_CHIP_LVDS: + ivideo->vbflags |= VB_LVDS; /* Deprecated */ + ivideo->vbflags2 |= VB2_LVDS; + break; + case SIS310_EXTERNAL_CHIP_LVDS_CHRONTEL: + ivideo->vbflags |= (VB_LVDS | VB_CHRONTEL); /* Deprecated */ + ivideo->vbflags2 |= (VB2_LVDS | VB2_CHRONTEL); + break; + } + if(ivideo->vbflags2 & VB2_CHRONTEL) ivideo->chronteltype = 2; +#endif + } else if(ivideo->chip >= SIS_661) { +#ifdef CONFIG_FB_SIS_315 + inSISIDXREG(SISCR, 0x38, reg); + reg >>= 5; + switch(reg) { + case 0x02: + ivideo->vbflags |= VB_LVDS; /* Deprecated */ + ivideo->vbflags2 |= VB2_LVDS; + break; + case 0x03: + ivideo->vbflags |= (VB_LVDS | VB_CHRONTEL); /* Deprecated */ + ivideo->vbflags2 |= (VB2_LVDS | VB2_CHRONTEL); + break; + case 0x04: + ivideo->vbflags |= (VB_LVDS | VB_CONEXANT); /* Deprecated */ + ivideo->vbflags2 |= (VB2_LVDS | VB2_CONEXANT); + break; + } + if(ivideo->vbflags2 & VB2_CHRONTEL) ivideo->chronteltype = 2; +#endif + } + if(ivideo->vbflags2 & VB2_LVDS) { + printk(KERN_INFO "%s LVDS transmitter\n", stdstr); + } + if((ivideo->sisvga_engine == SIS_300_VGA) && (ivideo->vbflags2 & VB2_TRUMPION)) { + printk(KERN_INFO "%s Trumpion Zurac LCD scaler\n", stdstr); + } + if(ivideo->vbflags2 & VB2_CHRONTEL) { + printk(KERN_INFO "%s Chrontel TV encoder\n", stdstr); + } + if((ivideo->chip >= SIS_661) && (ivideo->vbflags2 & VB2_CONEXANT)) { + printk(KERN_INFO "%s Conexant external device\n", stdstr); + } + } - return ret; + if(ivideo->vbflags2 & VB2_SISBRIDGE) { + SiS_SenseLCD(ivideo); + SiS_Sense30x(ivideo); + } else if(ivideo->vbflags2 & VB2_CHRONTEL) { + SiS_SenseCh(ivideo); + } } -static int __devinit -sisfb_heap_init(struct sis_video_info *ivideo) +/* ---------- Engine initialization routines ------------ */ + +static void +sisfb_engine_init(struct sis_video_info *ivideo) { - SIS_OH *poh; - ivideo->heapstart = ivideo->sisfb_mem = sisfb_getheapstart(ivideo); + /* Initialize command queue (we use MMIO only) */ - ivideo->sisfb_heap_start = ivideo->video_vbase + ivideo->heapstart; - ivideo->sisfb_heap_end = ivideo->video_vbase + ivideo->video_size; + /* BEFORE THIS IS CALLED, THE ENGINES *MUST* BE SYNC'ED */ - /* Initialize command queue (We use MMIO only) */ + ivideo->caps &= ~(TURBO_QUEUE_CAP | + MMIO_CMD_QUEUE_CAP | + VM_CMD_QUEUE_CAP | + AGP_CMD_QUEUE_CAP); + +#ifdef CONFIG_FB_SIS_300 + if(ivideo->sisvga_engine == SIS_300_VGA) { + u32 tqueue_pos; + u8 tq_state; + + tqueue_pos = (ivideo->video_size - ivideo->cmdQueueSize) / (64 * 1024); + + inSISIDXREG(SISSR, IND_SIS_TURBOQUEUE_SET, tq_state); + tq_state |= 0xf0; + tq_state &= 0xfc; + tq_state |= (u8)(tqueue_pos >> 8); + outSISIDXREG(SISSR, IND_SIS_TURBOQUEUE_SET, tq_state); + + outSISIDXREG(SISSR, IND_SIS_TURBOQUEUE_ADR, (u8)(tqueue_pos & 0xff)); + + ivideo->caps |= TURBO_QUEUE_CAP; + } +#endif #ifdef CONFIG_FB_SIS_315 - if(ivideo->sisvga_engine == SIS_315_VGA) { - u32 tempq = 0; - u8 temp = 0; + if(ivideo->sisvga_engine == SIS_315_VGA) { + u32 tempq = 0, templ; + u8 temp; + + if(ivideo->chip == XGI_20) { + switch(ivideo->cmdQueueSize) { + case (64 * 1024): + temp = SIS_CMD_QUEUE_SIZE_Z7_64k; + break; + case (128 * 1024): + default: + temp = SIS_CMD_QUEUE_SIZE_Z7_128k; + } + } else { + switch(ivideo->cmdQueueSize) { + case (4 * 1024 * 1024): + temp = SIS_CMD_QUEUE_SIZE_4M; + break; + case (2 * 1024 * 1024): + temp = SIS_CMD_QUEUE_SIZE_2M; + break; + case (1 * 1024 * 1024): + temp = SIS_CMD_QUEUE_SIZE_1M; + break; + default: + case (512 * 1024): + temp = SIS_CMD_QUEUE_SIZE_512k; + } + } + + outSISIDXREG(SISSR, IND_SIS_CMDQUEUE_THRESHOLD, COMMAND_QUEUE_THRESHOLD); + outSISIDXREG(SISSR, IND_SIS_CMDQUEUE_SET, SIS_CMD_QUEUE_RESET); + + if((ivideo->chip >= XGI_40) && ivideo->modechanged) { + /* Must disable dual pipe on XGI_40. Can't do + * this in MMIO mode, because it requires + * setting/clearing a bit in the MMIO fire trigger + * register. + */ + if(!((templ = MMIO_IN32(ivideo->mmio_vbase, 0x8240)) & (1 << 10))) { + + MMIO_OUT32(ivideo->mmio_vbase, Q_WRITE_PTR, 0); + + outSISIDXREG(SISSR, IND_SIS_CMDQUEUE_SET, (temp | SIS_VRAM_CMDQUEUE_ENABLE)); + + tempq = MMIO_IN32(ivideo->mmio_vbase, Q_READ_PTR); + MMIO_OUT32(ivideo->mmio_vbase, Q_WRITE_PTR, tempq); + + tempq = (u32)(ivideo->video_size - ivideo->cmdQueueSize); + MMIO_OUT32(ivideo->mmio_vbase, Q_BASE_ADDR, tempq); + + writel(0x16800000 + 0x8240, ivideo->video_vbase + tempq); + writel(templ | (1 << 10), ivideo->video_vbase + tempq + 4); + writel(0x168F0000, ivideo->video_vbase + tempq + 8); + writel(0x168F0000, ivideo->video_vbase + tempq + 12); + + MMIO_OUT32(ivideo->mmio_vbase, Q_WRITE_PTR, (tempq + 16)); + + sisfb_syncaccel(ivideo); + + outSISIDXREG(SISSR, IND_SIS_CMDQUEUE_SET, SIS_CMD_QUEUE_RESET); + + } + } + + tempq = MMIO_IN32(ivideo->mmio_vbase, MMIO_QUEUE_READPORT); + MMIO_OUT32(ivideo->mmio_vbase, MMIO_QUEUE_WRITEPORT, tempq); + + temp |= (SIS_MMIO_CMD_ENABLE | SIS_CMD_AUTO_CORR); + outSISIDXREG(SISSR, IND_SIS_CMDQUEUE_SET, temp); + + tempq = (u32)(ivideo->video_size - ivideo->cmdQueueSize); + MMIO_OUT32(ivideo->mmio_vbase, MMIO_QUEUE_PHYBASE, tempq); - ivideo->sisfb_heap_end -= COMMAND_QUEUE_AREA_SIZE; + ivideo->caps |= MMIO_CMD_QUEUE_CAP; + } +#endif - outSISIDXREG(SISSR, IND_SIS_CMDQUEUE_THRESHOLD, COMMAND_QUEUE_THRESHOLD); - outSISIDXREG(SISSR, IND_SIS_CMDQUEUE_SET, SIS_CMD_QUEUE_RESET); + ivideo->engineok = 1; +} - tempq = MMIO_IN32(ivideo->mmio_vbase, MMIO_QUEUE_READPORT); - MMIO_OUT32(ivideo->mmio_vbase, MMIO_QUEUE_WRITEPORT, tempq); +static void __devinit +sisfb_detect_lcd_type(struct sis_video_info *ivideo) +{ + u8 reg; + int i; - temp = SIS_CMD_QUEUE_SIZE_512k; - temp |= (SIS_MMIO_CMD_ENABLE | SIS_CMD_AUTO_CORR); - outSISIDXREG(SISSR, IND_SIS_CMDQUEUE_SET, temp); + inSISIDXREG(SISCR, 0x36, reg); + reg &= 0x0f; + if(ivideo->sisvga_engine == SIS_300_VGA) { + ivideo->CRT2LCDType = sis300paneltype[reg]; + } else if(ivideo->chip >= SIS_661) { + ivideo->CRT2LCDType = sis661paneltype[reg]; + } else { + ivideo->CRT2LCDType = sis310paneltype[reg]; + if((ivideo->chip == SIS_550) && (sisfb_fstn)) { + if((ivideo->CRT2LCDType != LCD_320x240_2) && + (ivideo->CRT2LCDType != LCD_320x240_3)) { + ivideo->CRT2LCDType = LCD_320x240; + } + } + } - tempq = (u32)(ivideo->video_size - COMMAND_QUEUE_AREA_SIZE); - MMIO_OUT32(ivideo->mmio_vbase, MMIO_QUEUE_PHYBASE, tempq); + if(ivideo->CRT2LCDType == LCD_UNKNOWN) { + /* For broken BIOSes: Assume 1024x768, RGB18 */ + ivideo->CRT2LCDType = LCD_1024x768; + setSISIDXREG(SISCR,0x36,0xf0,0x02); + setSISIDXREG(SISCR,0x37,0xee,0x01); + printk(KERN_DEBUG "sisfb: Invalid panel ID (%02x), assuming 1024x768, RGB18\n", reg); + } - ivideo->caps |= MMIO_CMD_QUEUE_CAP; - } + for(i = 0; i < SIS_LCD_NUMBER; i++) { + if(ivideo->CRT2LCDType == sis_lcd_data[i].lcdtype) { + ivideo->lcdxres = sis_lcd_data[i].xres; + ivideo->lcdyres = sis_lcd_data[i].yres; + ivideo->lcddefmodeidx = sis_lcd_data[i].default_mode_idx; + break; + } + } + +#ifdef CONFIG_FB_SIS_300 + if(ivideo->SiS_Pr.SiS_CustomT == CUT_BARCO1366) { + ivideo->lcdxres = 1360; ivideo->lcdyres = 1024; + ivideo->lcddefmodeidx = DEFAULT_MODE_1360; + } else if(ivideo->SiS_Pr.SiS_CustomT == CUT_PANEL848) { + ivideo->lcdxres = 848; ivideo->lcdyres = 480; + ivideo->lcddefmodeidx = DEFAULT_MODE_848; + } else if(ivideo->SiS_Pr.SiS_CustomT == CUT_PANEL856) { + ivideo->lcdxres = 856; ivideo->lcdyres = 480; + ivideo->lcddefmodeidx = DEFAULT_MODE_856; + } #endif + printk(KERN_DEBUG "sisfb: Detected %dx%d flat panel\n", + ivideo->lcdxres, ivideo->lcdyres); +} + +static void __devinit +sisfb_save_pdc_emi(struct sis_video_info *ivideo) +{ #ifdef CONFIG_FB_SIS_300 - if(ivideo->sisvga_engine == SIS_300_VGA) { - unsigned long tqueue_pos; - u8 tq_state; + /* Save the current PanelDelayCompensation if the LCD is currently used */ + if(ivideo->sisvga_engine == SIS_300_VGA) { + if(ivideo->vbflags2 & (VB2_LVDS | VB2_30xBDH)) { + int tmp; + inSISIDXREG(SISCR,0x30,tmp); + if(tmp & 0x20) { + /* Currently on LCD? If yes, read current pdc */ + inSISIDXREG(SISPART1,0x13,ivideo->detectedpdc); + ivideo->detectedpdc &= 0x3c; + if(ivideo->SiS_Pr.PDC == -1) { + /* Let option override detection */ + ivideo->SiS_Pr.PDC = ivideo->detectedpdc; + } + printk(KERN_INFO "sisfb: Detected LCD PDC 0x%02x\n", + ivideo->detectedpdc); + } + if((ivideo->SiS_Pr.PDC != -1) && + (ivideo->SiS_Pr.PDC != ivideo->detectedpdc)) { + printk(KERN_INFO "sisfb: Using LCD PDC 0x%02x\n", + ivideo->SiS_Pr.PDC); + } + } + } +#endif - ivideo->sisfb_heap_end -= TURBO_QUEUE_AREA_SIZE; +#ifdef CONFIG_FB_SIS_315 + if(ivideo->sisvga_engine == SIS_315_VGA) { - tqueue_pos = (ivideo->video_size - TURBO_QUEUE_AREA_SIZE) / (64 * 1024); + /* Try to find about LCDA */ + if(ivideo->vbflags2 & VB2_SISLCDABRIDGE) { + int tmp; + inSISIDXREG(SISPART1,0x13,tmp); + if(tmp & 0x04) { + ivideo->SiS_Pr.SiS_UseLCDA = TRUE; + ivideo->detectedlcda = 0x03; + } + } - inSISIDXREG(SISSR, IND_SIS_TURBOQUEUE_SET, tq_state); - tq_state |= 0xf0; - tq_state &= 0xfc; - tq_state |= (u8)(tqueue_pos >> 8); - outSISIDXREG(SISSR, IND_SIS_TURBOQUEUE_SET, tq_state); + /* Save PDC */ + if(ivideo->vbflags2 & VB2_SISLVDSBRIDGE) { + int tmp; + inSISIDXREG(SISCR,0x30,tmp); + if((tmp & 0x20) || (ivideo->detectedlcda != 0xff)) { + /* Currently on LCD? If yes, read current pdc */ + u8 pdc; + inSISIDXREG(SISPART1,0x2D,pdc); + ivideo->detectedpdc = (pdc & 0x0f) << 1; + ivideo->detectedpdca = (pdc & 0xf0) >> 3; + inSISIDXREG(SISPART1,0x35,pdc); + ivideo->detectedpdc |= ((pdc >> 7) & 0x01); + inSISIDXREG(SISPART1,0x20,pdc); + ivideo->detectedpdca |= ((pdc >> 6) & 0x01); + if(ivideo->newrom) { + /* New ROM invalidates other PDC resp. */ + if(ivideo->detectedlcda != 0xff) { + ivideo->detectedpdc = 0xff; + } else { + ivideo->detectedpdca = 0xff; + } + } + if(ivideo->SiS_Pr.PDC == -1) { + if(ivideo->detectedpdc != 0xff) { + ivideo->SiS_Pr.PDC = ivideo->detectedpdc; + } + } + if(ivideo->SiS_Pr.PDCA == -1) { + if(ivideo->detectedpdca != 0xff) { + ivideo->SiS_Pr.PDCA = ivideo->detectedpdca; + } + } + if(ivideo->detectedpdc != 0xff) { + printk(KERN_INFO + "sisfb: Detected LCD PDC 0x%02x (for LCD=CRT2)\n", + ivideo->detectedpdc); + } + if(ivideo->detectedpdca != 0xff) { + printk(KERN_INFO + "sisfb: Detected LCD PDC1 0x%02x (for LCD=CRT1)\n", + ivideo->detectedpdca); + } + } - outSISIDXREG(SISSR, IND_SIS_TURBOQUEUE_ADR, (u8)(tqueue_pos & 0xff)); + /* Save EMI */ + if(ivideo->vbflags2 & VB2_SISEMIBRIDGE) { + inSISIDXREG(SISPART4,0x30,ivideo->SiS_Pr.EMI_30); + inSISIDXREG(SISPART4,0x31,ivideo->SiS_Pr.EMI_31); + inSISIDXREG(SISPART4,0x32,ivideo->SiS_Pr.EMI_32); + inSISIDXREG(SISPART4,0x33,ivideo->SiS_Pr.EMI_33); + ivideo->SiS_Pr.HaveEMI = TRUE; + if((tmp & 0x20) || (ivideo->detectedlcda != 0xff)) { + ivideo->SiS_Pr.HaveEMILCD = TRUE; + } + } + } - ivideo->caps |= TURBO_QUEUE_CAP; - } + /* Let user override detected PDCs (all bridges) */ + if(ivideo->vbflags2 & VB2_30xBLV) { + if((ivideo->SiS_Pr.PDC != -1) && + (ivideo->SiS_Pr.PDC != ivideo->detectedpdc)) { + printk(KERN_INFO "sisfb: Using LCD PDC 0x%02x (for LCD=CRT2)\n", + ivideo->SiS_Pr.PDC); + } + if((ivideo->SiS_Pr.PDCA != -1) && + (ivideo->SiS_Pr.PDCA != ivideo->detectedpdca)) { + printk(KERN_INFO "sisfb: Using LCD PDC1 0x%02x (for LCD=CRT1)\n", + ivideo->SiS_Pr.PDCA); + } + } + + } #endif +} - /* Reserve memory for the HWCursor */ - ivideo->sisfb_heap_end -= ivideo->hwcursor_size; - ivideo->hwcursor_vbase = ivideo->sisfb_heap_end; - ivideo->caps |= HW_CURSOR_CAP; +/* -------------------- Memory manager routines ---------------------- */ - ivideo->sisfb_heap_size = ivideo->sisfb_heap_end - ivideo->sisfb_heap_start; +static u32 __devinit +sisfb_getheapstart(struct sis_video_info *ivideo) +{ + u32 ret = ivideo->sisfb_parm_mem * 1024; + u32 maxoffs = ivideo->video_size - ivideo->hwcursor_size - ivideo->cmdQueueSize; + u32 def; - if(ivideo->cardnumber == 0) { + /* Calculate heap start = end of memory for console + * + * CCCCCCCCDDDDDDDDDDDDDDDDDDDDDDDDDDDDHHHHQQQQQQQQQQ + * C = console, D = heap, H = HWCursor, Q = cmd-queue + * + * On 76x in UMA+LFB mode, the layout is as follows: + * DDDDDDDDDDDCCCCCCCCCCCCCCCCCCCCCCCCHHHHQQQQQQQQQQQ + * where the heap is the entire UMA area, eventually + * into the LFB area if the given mem parameter is + * higher than the size of the UMA memory. + * + * Basically given by "mem" parameter + * + * maximum = videosize - cmd_queue - hwcursor + * (results in a heap of size 0) + * default = SiS 300: depends on videosize + * SiS 315/330/340/XGI: 32k below max + */ - printk(KERN_INFO "sisfb: Memory heap starting at %dK, size %dK\n", - (int)(ivideo->heapstart / 1024), (int)(ivideo->sisfb_heap_size / 1024)); + if(ivideo->sisvga_engine == SIS_300_VGA) { + if(ivideo->video_size > 0x1000000) { + def = 0xc00000; + } else if(ivideo->video_size > 0x800000) { + def = 0x800000; + } else { + def = 0x400000; + } + } else if(ivideo->UMAsize && ivideo->LFBsize) { + ret = def = 0; + } else { + def = maxoffs - 0x8000; + } - sisfb_heap.vinfo = ivideo; + /* Use default for secondary card for now (FIXME) */ + if((!ret) || (ret > maxoffs) || (ivideo->cardnumber != 0)) + ret = def; - sisfb_heap.poha_chain = NULL; - sisfb_heap.poh_freelist = NULL; + return ret; +} - poh = sisfb_poh_new_node(); - if(poh == NULL) return 1; +static u32 __devinit +sisfb_getheapsize(struct sis_video_info *ivideo) +{ + u32 max = ivideo->video_size - ivideo->hwcursor_size - ivideo->cmdQueueSize; + u32 ret = 0; + + if(ivideo->UMAsize && ivideo->LFBsize) { + if( (!ivideo->sisfb_parm_mem) || + ((ivideo->sisfb_parm_mem * 1024) > max) || + ((max - (ivideo->sisfb_parm_mem * 1024)) < ivideo->UMAsize) ) { + ret = ivideo->UMAsize; + max -= ivideo->UMAsize; + } else { + ret = max - (ivideo->sisfb_parm_mem * 1024); + max = ivideo->sisfb_parm_mem * 1024; + } + ivideo->video_offset = ret; + ivideo->sisfb_mem = max; + } else { + ret = max - ivideo->heapstart; + ivideo->sisfb_mem = ivideo->heapstart; + } - poh->poh_next = &sisfb_heap.oh_free; - poh->poh_prev = &sisfb_heap.oh_free; - poh->size = ivideo->sisfb_heap_size; - poh->offset = ivideo->heapstart; + return ret; +} - sisfb_heap.oh_free.poh_next = poh; - sisfb_heap.oh_free.poh_prev = poh; - sisfb_heap.oh_free.size = 0; - sisfb_heap.max_freesize = poh->size; +static int __devinit +sisfb_heap_init(struct sis_video_info *ivideo) +{ + struct SIS_OH *poh; - sisfb_heap.oh_used.poh_next = &sisfb_heap.oh_used; - sisfb_heap.oh_used.poh_prev = &sisfb_heap.oh_used; - sisfb_heap.oh_used.size = SENTINEL; + ivideo->video_offset = 0; + if(ivideo->sisfb_parm_mem) { + if( (ivideo->sisfb_parm_mem < (2 * 1024 * 1024)) || + (ivideo->sisfb_parm_mem > ivideo->video_size) ) { + ivideo->sisfb_parm_mem = 0; + } + } - } else { + ivideo->heapstart = sisfb_getheapstart(ivideo); + ivideo->sisfb_heap_size = sisfb_getheapsize(ivideo); - printk(KERN_INFO "Skipped heap initialization for secondary cards\n"); + ivideo->sisfb_heap_start = ivideo->video_vbase + ivideo->heapstart; + ivideo->sisfb_heap_end = ivideo->sisfb_heap_start + ivideo->sisfb_heap_size; - } + printk(KERN_INFO "sisfb: Memory heap starting at %dK, size %dK\n", + (int)(ivideo->heapstart / 1024), (int)(ivideo->sisfb_heap_size / 1024)); - return 0; + ivideo->sisfb_heap.vinfo = ivideo; + + ivideo->sisfb_heap.poha_chain = NULL; + ivideo->sisfb_heap.poh_freelist = NULL; + + poh = sisfb_poh_new_node(&ivideo->sisfb_heap); + if(poh == NULL) + return 1; + + poh->poh_next = &ivideo->sisfb_heap.oh_free; + poh->poh_prev = &ivideo->sisfb_heap.oh_free; + poh->size = ivideo->sisfb_heap_size; + poh->offset = ivideo->heapstart; + + ivideo->sisfb_heap.oh_free.poh_next = poh; + ivideo->sisfb_heap.oh_free.poh_prev = poh; + ivideo->sisfb_heap.oh_free.size = 0; + ivideo->sisfb_heap.max_freesize = poh->size; + + ivideo->sisfb_heap.oh_used.poh_next = &ivideo->sisfb_heap.oh_used; + ivideo->sisfb_heap.oh_used.poh_prev = &ivideo->sisfb_heap.oh_used; + ivideo->sisfb_heap.oh_used.size = SENTINEL; + + if(ivideo->cardnumber == 0) { + /* For the first card, make this heap the "global" one + * for old DRM (which could handle only one card) + */ + sisfb_heap = &ivideo->sisfb_heap; + } + + return 0; } -static SIS_OH * -sisfb_poh_new_node(void) +static struct SIS_OH * +sisfb_poh_new_node(struct SIS_HEAP *memheap) { - int i; - unsigned long cOhs; - SIS_OHALLOC *poha; - SIS_OH *poh; + struct SIS_OHALLOC *poha; + struct SIS_OH *poh; + unsigned long cOhs; + int i; - if(sisfb_heap.poh_freelist == NULL) { + if(memheap->poh_freelist == NULL) { poha = kmalloc(SIS_OH_ALLOC_SIZE, GFP_KERNEL); - if(!poha) return NULL; + if(!poha) + return NULL; - poha->poha_next = sisfb_heap.poha_chain; - sisfb_heap.poha_chain = poha; + poha->poha_next = memheap->poha_chain; + memheap->poha_chain = poha; - cOhs = (SIS_OH_ALLOC_SIZE - sizeof(SIS_OHALLOC)) / sizeof(SIS_OH) + 1; + cOhs = (SIS_OH_ALLOC_SIZE - sizeof(struct SIS_OHALLOC)) / sizeof(struct SIS_OH) + 1; poh = &poha->aoh[0]; for(i = cOhs - 1; i != 0; i--) { @@ -3169,32 +3349,32 @@ sisfb_poh_new_node(void) } poh->poh_next = NULL; - sisfb_heap.poh_freelist = &poha->aoh[0]; + memheap->poh_freelist = &poha->aoh[0]; } - poh = sisfb_heap.poh_freelist; - sisfb_heap.poh_freelist = poh->poh_next; + poh = memheap->poh_freelist; + memheap->poh_freelist = poh->poh_next; - return (poh); + return poh; } -static SIS_OH * -sisfb_poh_allocate(u32 size) +static struct SIS_OH * +sisfb_poh_allocate(struct SIS_HEAP *memheap, u32 size) { - SIS_OH *pohThis; - SIS_OH *pohRoot; - int bAllocated = 0; + struct SIS_OH *pohThis; + struct SIS_OH *pohRoot; + int bAllocated = 0; - if(size > sisfb_heap.max_freesize) { + if(size > memheap->max_freesize) { DPRINTK("sisfb: Can't allocate %dk video memory\n", (unsigned int) size / 1024); - return (NULL); + return NULL; } - pohThis = sisfb_heap.oh_free.poh_next; + pohThis = memheap->oh_free.poh_next; - while(pohThis != &sisfb_heap.oh_free) { - if (size <= pohThis->size) { + while(pohThis != &memheap->oh_free) { + if(size <= pohThis->size) { bAllocated = 1; break; } @@ -3204,18 +3384,16 @@ sisfb_poh_allocate(u32 size) if(!bAllocated) { DPRINTK("sisfb: Can't allocate %dk video memory\n", (unsigned int) size / 1024); - return (NULL); + return NULL; } if(size == pohThis->size) { pohRoot = pohThis; sisfb_delete_node(pohThis); } else { - pohRoot = sisfb_poh_new_node(); - - if(pohRoot == NULL) { - return (NULL); - } + pohRoot = sisfb_poh_new_node(memheap); + if(pohRoot == NULL) + return NULL; pohRoot->offset = pohThis->offset; pohRoot->size = size; @@ -3224,33 +3402,25 @@ sisfb_poh_allocate(u32 size) pohThis->size -= size; } - sisfb_heap.max_freesize -= size; + memheap->max_freesize -= size; - pohThis = &sisfb_heap.oh_used; + pohThis = &memheap->oh_used; sisfb_insert_node(pohThis, pohRoot); - return (pohRoot); + return pohRoot; } static void -sisfb_delete_node(SIS_OH *poh) +sisfb_delete_node(struct SIS_OH *poh) { - SIS_OH *poh_prev; - SIS_OH *poh_next; - - poh_prev = poh->poh_prev; - poh_next = poh->poh_next; - - poh_prev->poh_next = poh_next; - poh_next->poh_prev = poh_prev; + poh->poh_prev->poh_next = poh->poh_next; + poh->poh_next->poh_prev = poh->poh_prev; } static void -sisfb_insert_node(SIS_OH *pohList, SIS_OH *poh) +sisfb_insert_node(struct SIS_OH *pohList, struct SIS_OH *poh) { - SIS_OH *pohTemp; - - pohTemp = pohList->poh_next; + struct SIS_OH *pohTemp = pohList->poh_next; pohList->poh_next = poh; pohTemp->poh_prev = poh; @@ -3259,20 +3429,20 @@ sisfb_insert_node(SIS_OH *pohList, SIS_OH *poh) poh->poh_next = pohTemp; } -static SIS_OH * -sisfb_poh_free(u32 base) +static struct SIS_OH * +sisfb_poh_free(struct SIS_HEAP *memheap, u32 base) { - SIS_OH *pohThis; - SIS_OH *poh_freed; - SIS_OH *poh_prev; - SIS_OH *poh_next; - u32 ulUpper; - u32 ulLower; - int foundNode = 0; + struct SIS_OH *pohThis; + struct SIS_OH *poh_freed; + struct SIS_OH *poh_prev; + struct SIS_OH *poh_next; + u32 ulUpper; + u32 ulLower; + int foundNode = 0; - poh_freed = sisfb_heap.oh_used.poh_next; + poh_freed = memheap->oh_used.poh_next; - while(poh_freed != &sisfb_heap.oh_used) { + while(poh_freed != &memheap->oh_used) { if(poh_freed->offset == base) { foundNode = 1; break; @@ -3281,17 +3451,18 @@ sisfb_poh_free(u32 base) poh_freed = poh_freed->poh_next; } - if(!foundNode) return(NULL); + if(!foundNode) + return NULL; - sisfb_heap.max_freesize += poh_freed->size; + memheap->max_freesize += poh_freed->size; poh_prev = poh_next = NULL; ulUpper = poh_freed->offset + poh_freed->size; ulLower = poh_freed->offset; - pohThis = sisfb_heap.oh_free.poh_next; + pohThis = memheap->oh_free.poh_next; - while(pohThis != &sisfb_heap.oh_free) { + while(pohThis != &memheap->oh_free) { if(pohThis->offset == ulUpper) { poh_next = pohThis; } else if((pohThis->offset + pohThis->size) == ulLower) { @@ -3305,70 +3476,88 @@ sisfb_poh_free(u32 base) if(poh_prev && poh_next) { poh_prev->size += (poh_freed->size + poh_next->size); sisfb_delete_node(poh_next); - sisfb_free_node(poh_freed); - sisfb_free_node(poh_next); - return(poh_prev); + sisfb_free_node(memheap, poh_freed); + sisfb_free_node(memheap, poh_next); + return poh_prev; } if(poh_prev) { poh_prev->size += poh_freed->size; - sisfb_free_node(poh_freed); - return(poh_prev); + sisfb_free_node(memheap, poh_freed); + return poh_prev; } if(poh_next) { poh_next->size += poh_freed->size; poh_next->offset = poh_freed->offset; - sisfb_free_node(poh_freed); - return(poh_next); + sisfb_free_node(memheap, poh_freed); + return poh_next; } - sisfb_insert_node(&sisfb_heap.oh_free, poh_freed); + sisfb_insert_node(&memheap->oh_free, poh_freed); - return(poh_freed); + return poh_freed; } static void -sisfb_free_node(SIS_OH *poh) +sisfb_free_node(struct SIS_HEAP *memheap, struct SIS_OH *poh) { - if(poh == NULL) return; + if(poh == NULL) + return; - poh->poh_next = sisfb_heap.poh_freelist; - sisfb_heap.poh_freelist = poh; + poh->poh_next = memheap->poh_freelist; + memheap->poh_freelist = poh; } -void -sis_malloc(struct sis_memreq *req) +static void +sis_int_malloc(struct sis_video_info *ivideo, struct sis_memreq *req) { - struct sis_video_info *ivideo = sisfb_heap.vinfo; - SIS_OH *poh = NULL; + struct SIS_OH *poh = NULL; - if((ivideo) && (!ivideo->havenoheap)) { - poh = sisfb_poh_allocate((u32)req->size); - } + if((ivideo) && (ivideo->sisfb_id == SISFB_ID) && (!ivideo->havenoheap)) + poh = sisfb_poh_allocate(&ivideo->sisfb_heap, (u32)req->size); if(poh == NULL) { - req->offset = req->size = 0; - DPRINTK("sisfb: Video RAM allocation failed\n"); + req->offset = req->size = 0; + DPRINTK("sisfb: Video RAM allocation failed\n"); } else { - req->offset = poh->offset; - req->size = poh->size; - DPRINTK("sisfb: Video RAM allocation succeeded: 0x%lx\n", - (poh->offset + ivideo->video_vbase)); + req->offset = poh->offset; + req->size = poh->size; + DPRINTK("sisfb: Video RAM allocation succeeded: 0x%lx\n", + (poh->offset + ivideo->video_vbase)); } } -/* sis_free: u32 because "base" is offset inside video ram, can never be >4GB */ +void +sis_malloc(struct sis_memreq *req) +{ + struct sis_video_info *ivideo = sisfb_heap->vinfo; + + if(&ivideo->sisfb_heap == sisfb_heap) + sis_int_malloc(ivideo, req); + else + req->offset = req->size = 0; +} void -sis_free(u32 base) +sis_malloc_new(struct pci_dev *pdev, struct sis_memreq *req) { - struct sis_video_info *ivideo = sisfb_heap.vinfo; - SIS_OH *poh; + struct sis_video_info *ivideo = pci_get_drvdata(pdev); + + sis_int_malloc(ivideo, req); +} + +/* sis_free: u32 because "base" is offset inside video ram, can never be >4GB */ - if((!ivideo) || (ivideo->havenoheap)) return; +static void +sis_int_free(struct sis_video_info *ivideo, u32 base) +{ + struct SIS_OH *poh; - poh = sisfb_poh_free((u32)base); + if((!ivideo) || (ivideo->sisfb_id != SISFB_ID) || (ivideo->havenoheap)) + return; + + poh = sisfb_poh_free(&ivideo->sisfb_heap, base); if(poh == NULL) { DPRINTK("sisfb: sisfb_poh_free() failed at base 0x%x\n", @@ -3376,9 +3565,63 @@ sis_free(u32 base) } } +void +sis_free(u32 base) +{ + struct sis_video_info *ivideo = sisfb_heap->vinfo; + + sis_int_free(ivideo, base); +} + +void +sis_free_new(struct pci_dev *pdev, u32 base) +{ + struct sis_video_info *ivideo = pci_get_drvdata(pdev); + + sis_int_free(ivideo, base); +} + /* --------------------- SetMode routines ------------------------- */ static void +sisfb_check_engine_and_sync(struct sis_video_info *ivideo) +{ + u8 cr30, cr31; + + /* Check if MMIO and engines are enabled, + * and sync in case they are. Can't use + * ivideo->accel here, as this might have + * been changed before this is called. + */ + inSISIDXREG(SISSR, IND_SIS_PCI_ADDRESS_SET, cr30); + inSISIDXREG(SISSR, IND_SIS_MODULE_ENABLE, cr31); + /* MMIO and 2D/3D engine enabled? */ + if((cr30 & SIS_MEM_MAP_IO_ENABLE) && (cr31 & 0x42)) { +#ifdef CONFIG_FB_SIS_300 + if(ivideo->sisvga_engine == SIS_300_VGA) { + /* Don't care about TurboQueue. It's + * enough to know that the engines + * are enabled + */ + sisfb_syncaccel(ivideo); + } +#endif +#ifdef CONFIG_FB_SIS_315 + if(ivideo->sisvga_engine == SIS_315_VGA) { + /* Check that any queue mode is + * enabled, and that the queue + * is not in the state of "reset" + */ + inSISIDXREG(SISSR, 0x26, cr30); + if((cr30 & 0xe0) && (!(cr30 & 0x01))) { + sisfb_syncaccel(ivideo); + } + } +#endif + } +} + +static void sisfb_pre_setmode(struct sis_video_info *ivideo) { u8 cr30 = 0, cr31 = 0, cr33 = 0, cr35 = 0, cr38 = 0; @@ -3386,6 +3629,8 @@ sisfb_pre_setmode(struct sis_video_info *ivideo) ivideo->currentvbflags &= (VB_VIDEOBRIDGE | VB_DISPTYPE_DISP2); + outSISIDXREG(SISSR, 0x05, 0x86); + inSISIDXREG(SISCR, 0x31, cr31); cr31 &= ~0x60; cr31 |= 0x04; @@ -3413,41 +3658,43 @@ sisfb_pre_setmode(struct sis_video_info *ivideo) SiS_SetEnableDstn(&ivideo->SiS_Pr, FALSE); SiS_SetEnableFstn(&ivideo->SiS_Pr, FALSE); + ivideo->curFSTN = ivideo->curDSTN = 0; switch(ivideo->currentvbflags & VB_DISPTYPE_DISP2) { case CRT2_TV: cr38 &= ~0xc0; /* Clear PAL-M / PAL-N bits */ - if((ivideo->vbflags & TV_YPBPR) && (ivideo->vbflags & (VB_301C|VB_301LV|VB_302LV))) { + if((ivideo->vbflags & TV_YPBPR) && (ivideo->vbflags2 & VB2_SISYPBPRBRIDGE)) { #ifdef CONFIG_FB_SIS_315 - if(ivideo->chip >= SIS_661) { - cr38 |= 0x04; - if(ivideo->vbflags & TV_YPBPR525P) cr35 |= 0x20; + if(ivideo->chip >= SIS_661) { + cr38 |= 0x04; + if(ivideo->vbflags & TV_YPBPR525P) cr35 |= 0x20; else if(ivideo->vbflags & TV_YPBPR750P) cr35 |= 0x40; else if(ivideo->vbflags & TV_YPBPR1080I) cr35 |= 0x60; cr30 |= SIS_SIMULTANEOUS_VIEW_ENABLE; cr35 &= ~0x01; ivideo->currentvbflags |= (TV_YPBPR | (ivideo->vbflags & TV_YPBPRALL)); - } else if(ivideo->sisvga_engine == SIS_315_VGA) { - cr30 |= (0x80 | SIS_SIMULTANEOUS_VIEW_ENABLE); + } else if(ivideo->sisvga_engine == SIS_315_VGA) { + cr30 |= (0x80 | SIS_SIMULTANEOUS_VIEW_ENABLE); cr38 |= 0x08; - if(ivideo->vbflags & TV_YPBPR525P) cr38 |= 0x10; + if(ivideo->vbflags & TV_YPBPR525P) cr38 |= 0x10; else if(ivideo->vbflags & TV_YPBPR750P) cr38 |= 0x20; else if(ivideo->vbflags & TV_YPBPR1080I) cr38 |= 0x30; cr31 &= ~0x01; ivideo->currentvbflags |= (TV_YPBPR | (ivideo->vbflags & TV_YPBPRALL)); - } -#endif - } else if((ivideo->vbflags & TV_HIVISION) && (ivideo->vbflags & (VB_301|VB_301B|VB_302B))) { - if(ivideo->chip >= SIS_661) { - cr38 |= 0x04; - cr35 |= 0x60; - } else { - cr30 |= 0x80; - } + } +#endif + } else if((ivideo->vbflags & TV_HIVISION) && + (ivideo->vbflags2 & VB2_SISHIVISIONBRIDGE)) { + if(ivideo->chip >= SIS_661) { + cr38 |= 0x04; + cr35 |= 0x60; + } else { + cr30 |= 0x80; + } cr30 |= SIS_SIMULTANEOUS_VIEW_ENABLE; - cr31 |= 0x01; - cr35 |= 0x01; + cr31 |= 0x01; + cr35 |= 0x01; ivideo->currentvbflags |= TV_HIVISION; } else if(ivideo->vbflags & TV_SCART) { cr30 = (SIS_VB_OUTPUT_SCART | SIS_SIMULTANEOUS_VIEW_ENABLE); @@ -3466,8 +3713,8 @@ sisfb_pre_setmode(struct sis_video_info *ivideo) } cr31 |= SIS_DRIVER_MODE; - if(ivideo->vbflags & (TV_AVIDEO|TV_SVIDEO)) { - if(ivideo->vbflags & TV_PAL) { + if(ivideo->vbflags & (TV_AVIDEO | TV_SVIDEO)) { + if(ivideo->vbflags & TV_PAL) { cr31 |= 0x01; cr35 |= 0x01; ivideo->currentvbflags |= TV_PAL; if(ivideo->vbflags & TV_PALM) { @@ -3476,14 +3723,14 @@ sisfb_pre_setmode(struct sis_video_info *ivideo) } else if(ivideo->vbflags & TV_PALN) { cr38 |= 0x80; cr35 |= 0x08; ivideo->currentvbflags |= TV_PALN; - } - } else { + } + } else { cr31 &= ~0x01; cr35 &= ~0x01; ivideo->currentvbflags |= TV_NTSC; if(ivideo->vbflags & TV_NTSCJ) { cr38 |= 0x40; cr35 |= 0x02; ivideo->currentvbflags |= TV_NTSCJ; - } + } } } break; @@ -3493,6 +3740,8 @@ sisfb_pre_setmode(struct sis_video_info *ivideo) cr31 |= SIS_DRIVER_MODE; SiS_SetEnableDstn(&ivideo->SiS_Pr, ivideo->sisfb_dstn); SiS_SetEnableFstn(&ivideo->SiS_Pr, ivideo->sisfb_fstn); + ivideo->curFSTN = ivideo->sisfb_fstn; + ivideo->curDSTN = ivideo->sisfb_dstn; break; case CRT2_VGA: @@ -3525,9 +3774,9 @@ sisfb_pre_setmode(struct sis_video_info *ivideo) } outSISIDXREG(SISCR, 0x31, cr31); - if(ivideo->accel) sisfb_syncaccel(ivideo); - ivideo->SiS_Pr.SiS_UseOEM = ivideo->sisfb_useoem; + + sisfb_check_engine_and_sync(ivideo); } /* Fix SR11 for 661 and later */ @@ -3535,125 +3784,129 @@ sisfb_pre_setmode(struct sis_video_info *ivideo) static void sisfb_fixup_SR11(struct sis_video_info *ivideo) { - u8 tmpreg; - - if(ivideo->chip >= SIS_661) { - inSISIDXREG(SISSR,0x11,tmpreg); - if(tmpreg & 0x20) { - inSISIDXREG(SISSR,0x3e,tmpreg); - tmpreg = (tmpreg + 1) & 0xff; - outSISIDXREG(SISSR,0x3e,tmpreg); - inSISIDXREG(SISSR,0x11,tmpreg); - } - if(tmpreg & 0xf0) { - andSISIDXREG(SISSR,0x11,0x0f); - } - } + u8 tmpreg; + + if(ivideo->chip >= SIS_661) { + inSISIDXREG(SISSR,0x11,tmpreg); + if(tmpreg & 0x20) { + inSISIDXREG(SISSR,0x3e,tmpreg); + tmpreg = (tmpreg + 1) & 0xff; + outSISIDXREG(SISSR,0x3e,tmpreg); + inSISIDXREG(SISSR,0x11,tmpreg); + } + if(tmpreg & 0xf0) { + andSISIDXREG(SISSR,0x11,0x0f); + } + } } #endif -static void sisfb_set_TVxposoffset(struct sis_video_info *ivideo, int val) +static void +sisfb_set_TVxposoffset(struct sis_video_info *ivideo, int val) { - if(val > 32) val = 32; - if(val < -32) val = -32; - ivideo->tvxpos = val; + if(val > 32) val = 32; + if(val < -32) val = -32; + ivideo->tvxpos = val; - if(ivideo->sisfblocked) return; - if(!ivideo->modechanged) return; + if(ivideo->sisfblocked) return; + if(!ivideo->modechanged) return; - if(ivideo->currentvbflags & CRT2_TV) { + if(ivideo->currentvbflags & CRT2_TV) { - if(ivideo->vbflags & VB_CHRONTEL) { + if(ivideo->vbflags2 & VB2_CHRONTEL) { - int x = ivideo->tvx; + int x = ivideo->tvx; - switch(ivideo->chronteltype) { - case 1: - x += val; - if(x < 0) x = 0; - outSISIDXREG(SISSR,0x05,0x86); - SiS_SetCH700x(&ivideo->SiS_Pr, (((x & 0xff) << 8) | 0x0a)); - SiS_SetCH70xxANDOR(&ivideo->SiS_Pr, (((x & 0x0100) << 1) | 0x08),0xFD); - break; - case 2: - /* Not supported by hardware */ - break; - } - - } else if(ivideo->vbflags & VB_SISBRIDGE) { - - u8 p2_1f,p2_20,p2_2b,p2_42,p2_43; - unsigned short temp; - - p2_1f = ivideo->p2_1f; - p2_20 = ivideo->p2_20; - p2_2b = ivideo->p2_2b; - p2_42 = ivideo->p2_42; - p2_43 = ivideo->p2_43; - - temp = p2_1f | ((p2_20 & 0xf0) << 4); - temp += (val * 2); - p2_1f = temp & 0xff; - p2_20 = (temp & 0xf00) >> 4; - p2_2b = ((p2_2b & 0x0f) + (val * 2)) & 0x0f; - temp = p2_43 | ((p2_42 & 0xf0) << 4); - temp += (val * 2); - p2_43 = temp & 0xff; - p2_42 = (temp & 0xf00) >> 4; - outSISIDXREG(SISPART2,0x1f,p2_1f); - setSISIDXREG(SISPART2,0x20,0x0F,p2_20); - setSISIDXREG(SISPART2,0x2b,0xF0,p2_2b); - setSISIDXREG(SISPART2,0x42,0x0F,p2_42); - outSISIDXREG(SISPART2,0x43,p2_43); - } - } + switch(ivideo->chronteltype) { + case 1: + x += val; + if(x < 0) x = 0; + outSISIDXREG(SISSR,0x05,0x86); + SiS_SetCH700x(&ivideo->SiS_Pr, 0x0a, (x & 0xff)); + SiS_SetCH70xxANDOR(&ivideo->SiS_Pr, 0x08, ((x & 0x0100) >> 7), 0xFD); + break; + case 2: + /* Not supported by hardware */ + break; + } + + } else if(ivideo->vbflags2 & VB2_SISBRIDGE) { + + u8 p2_1f,p2_20,p2_2b,p2_42,p2_43; + unsigned short temp; + + p2_1f = ivideo->p2_1f; + p2_20 = ivideo->p2_20; + p2_2b = ivideo->p2_2b; + p2_42 = ivideo->p2_42; + p2_43 = ivideo->p2_43; + + temp = p2_1f | ((p2_20 & 0xf0) << 4); + temp += (val * 2); + p2_1f = temp & 0xff; + p2_20 = (temp & 0xf00) >> 4; + p2_2b = ((p2_2b & 0x0f) + (val * 2)) & 0x0f; + temp = p2_43 | ((p2_42 & 0xf0) << 4); + temp += (val * 2); + p2_43 = temp & 0xff; + p2_42 = (temp & 0xf00) >> 4; + outSISIDXREG(SISPART2,0x1f,p2_1f); + setSISIDXREG(SISPART2,0x20,0x0F,p2_20); + setSISIDXREG(SISPART2,0x2b,0xF0,p2_2b); + setSISIDXREG(SISPART2,0x42,0x0F,p2_42); + outSISIDXREG(SISPART2,0x43,p2_43); + } + } } -static void sisfb_set_TVyposoffset(struct sis_video_info *ivideo, int val) +static void +sisfb_set_TVyposoffset(struct sis_video_info *ivideo, int val) { - if(val > 32) val = 32; - if(val < -32) val = -32; - ivideo->tvypos = val; - - if(ivideo->sisfblocked) return; - if(!ivideo->modechanged) return; - - if(ivideo->currentvbflags & CRT2_TV) { - - if(ivideo->vbflags & VB_CHRONTEL) { - - int y = ivideo->tvy; - - switch(ivideo->chronteltype) { - case 1: - y -= val; - if(y < 0) y = 0; - outSISIDXREG(SISSR,0x05,0x86); - SiS_SetCH700x(&ivideo->SiS_Pr, (((y & 0xff) << 8) | 0x0b)); - SiS_SetCH70xxANDOR(&ivideo->SiS_Pr, ((y & 0x0100) | 0x08),0xFE); - break; - case 2: - /* Not supported by hardware */ - break; - } - - } else if(ivideo->vbflags & VB_SISBRIDGE) { - - char p2_01, p2_02; - val /= 2; - p2_01 = ivideo->p2_01; - p2_02 = ivideo->p2_02; - - p2_01 += val; - p2_02 += val; - while((p2_01 <= 0) || (p2_02 <= 0)) { - p2_01 += 2; - p2_02 += 2; - } - outSISIDXREG(SISPART2,0x01,p2_01); - outSISIDXREG(SISPART2,0x02,p2_02); - } - } + if(val > 32) val = 32; + if(val < -32) val = -32; + ivideo->tvypos = val; + + if(ivideo->sisfblocked) return; + if(!ivideo->modechanged) return; + + if(ivideo->currentvbflags & CRT2_TV) { + + if(ivideo->vbflags2 & VB2_CHRONTEL) { + + int y = ivideo->tvy; + + switch(ivideo->chronteltype) { + case 1: + y -= val; + if(y < 0) y = 0; + outSISIDXREG(SISSR,0x05,0x86); + SiS_SetCH700x(&ivideo->SiS_Pr, 0x0b, (y & 0xff)); + SiS_SetCH70xxANDOR(&ivideo->SiS_Pr, 0x08, ((y & 0x0100) >> 8), 0xFE); + break; + case 2: + /* Not supported by hardware */ + break; + } + + } else if(ivideo->vbflags2 & VB2_SISBRIDGE) { + + char p2_01, p2_02; + val /= 2; + p2_01 = ivideo->p2_01; + p2_02 = ivideo->p2_02; + + p2_01 += val; + p2_02 += val; + if(!(ivideo->currentvbflags & (TV_HIVISION | TV_YPBPR))) { + while((p2_01 <= 0) || (p2_02 <= 0)) { + p2_01 += 2; + p2_02 += 2; + } + } + outSISIDXREG(SISPART2,0x01,p2_01); + outSISIDXREG(SISPART2,0x02,p2_02); + } + } } static void @@ -3668,207 +3921,172 @@ sisfb_post_setmode(struct sis_video_info *ivideo) u8 reg1; #endif - outSISIDXREG(SISSR,0x05,0x86); + outSISIDXREG(SISSR, 0x05, 0x86); #ifdef CONFIG_FB_SIS_315 sisfb_fixup_SR11(ivideo); #endif /* Now we actually HAVE changed the display mode */ - ivideo->modechanged = 1; + ivideo->modechanged = 1; /* We can't switch off CRT1 if bridge is in slave mode */ - if(ivideo->vbflags & VB_VIDEOBRIDGE) { + if(ivideo->vbflags2 & VB2_VIDEOBRIDGE) { if(sisfb_bridgeisslave(ivideo)) doit = FALSE; - } else ivideo->sisfb_crt1off = 0; + } else + ivideo->sisfb_crt1off = 0; #ifdef CONFIG_FB_SIS_300 if(ivideo->sisvga_engine == SIS_300_VGA) { - if((ivideo->sisfb_crt1off) && (doit)) { - crt1isoff = TRUE; - reg = 0x00; - } else { - crt1isoff = FALSE; - reg = 0x80; - } - setSISIDXREG(SISCR, 0x17, 0x7f, reg); + if((ivideo->sisfb_crt1off) && (doit)) { + crt1isoff = TRUE; + reg = 0x00; + } else { + crt1isoff = FALSE; + reg = 0x80; + } + setSISIDXREG(SISCR, 0x17, 0x7f, reg); } #endif #ifdef CONFIG_FB_SIS_315 if(ivideo->sisvga_engine == SIS_315_VGA) { - if((ivideo->sisfb_crt1off) && (doit)) { - crt1isoff = TRUE; - reg = 0x40; - reg1 = 0xc0; - } else { - crt1isoff = FALSE; - reg = 0x00; - reg1 = 0x00; - - } - setSISIDXREG(SISCR, ivideo->SiS_Pr.SiS_MyCR63, ~0x40, reg); - setSISIDXREG(SISSR, 0x1f, ~0xc0, reg1); + if((ivideo->sisfb_crt1off) && (doit)) { + crt1isoff = TRUE; + reg = 0x40; + reg1 = 0xc0; + } else { + crt1isoff = FALSE; + reg = 0x00; + reg1 = 0x00; + } + setSISIDXREG(SISCR, ivideo->SiS_Pr.SiS_MyCR63, ~0x40, reg); + setSISIDXREG(SISSR, 0x1f, ~0xc0, reg1); } #endif if(crt1isoff) { - ivideo->currentvbflags &= ~VB_DISPTYPE_CRT1; - ivideo->currentvbflags |= VB_SINGLE_MODE; + ivideo->currentvbflags &= ~VB_DISPTYPE_CRT1; + ivideo->currentvbflags |= VB_SINGLE_MODE; } else { - ivideo->currentvbflags |= VB_DISPTYPE_CRT1; - if(ivideo->currentvbflags & VB_DISPTYPE_CRT2) { - ivideo->currentvbflags |= VB_MIRROR_MODE; - } else { - ivideo->currentvbflags |= VB_SINGLE_MODE; - } + ivideo->currentvbflags |= VB_DISPTYPE_CRT1; + if(ivideo->currentvbflags & VB_DISPTYPE_CRT2) { + ivideo->currentvbflags |= VB_MIRROR_MODE; + } else { + ivideo->currentvbflags |= VB_SINGLE_MODE; + } } - andSISIDXREG(SISSR, IND_SIS_RAMDAC_CONTROL, ~0x04); + andSISIDXREG(SISSR, IND_SIS_RAMDAC_CONTROL, ~0x04); if(ivideo->currentvbflags & CRT2_TV) { - if(ivideo->vbflags & VB_SISBRIDGE) { - inSISIDXREG(SISPART2,0x1f,ivideo->p2_1f); - inSISIDXREG(SISPART2,0x20,ivideo->p2_20); - inSISIDXREG(SISPART2,0x2b,ivideo->p2_2b); - inSISIDXREG(SISPART2,0x42,ivideo->p2_42); - inSISIDXREG(SISPART2,0x43,ivideo->p2_43); - inSISIDXREG(SISPART2,0x01,ivideo->p2_01); - inSISIDXREG(SISPART2,0x02,ivideo->p2_02); - } else if(ivideo->vbflags & VB_CHRONTEL) { - if(ivideo->chronteltype == 1) { - ivideo->tvx = SiS_GetCH700x(&ivideo->SiS_Pr, 0x0a); - ivideo->tvx |= (((SiS_GetCH700x(&ivideo->SiS_Pr, 0x08) & 0x02) >> 1) << 8); - ivideo->tvy = SiS_GetCH700x(&ivideo->SiS_Pr, 0x0b); - ivideo->tvy |= ((SiS_GetCH700x(&ivideo->SiS_Pr, 0x08) & 0x01) << 8); - } - } + if(ivideo->vbflags2 & VB2_SISBRIDGE) { + inSISIDXREG(SISPART2,0x1f,ivideo->p2_1f); + inSISIDXREG(SISPART2,0x20,ivideo->p2_20); + inSISIDXREG(SISPART2,0x2b,ivideo->p2_2b); + inSISIDXREG(SISPART2,0x42,ivideo->p2_42); + inSISIDXREG(SISPART2,0x43,ivideo->p2_43); + inSISIDXREG(SISPART2,0x01,ivideo->p2_01); + inSISIDXREG(SISPART2,0x02,ivideo->p2_02); + } else if(ivideo->vbflags2 & VB2_CHRONTEL) { + if(ivideo->chronteltype == 1) { + ivideo->tvx = SiS_GetCH700x(&ivideo->SiS_Pr, 0x0a); + ivideo->tvx |= (((SiS_GetCH700x(&ivideo->SiS_Pr, 0x08) & 0x02) >> 1) << 8); + ivideo->tvy = SiS_GetCH700x(&ivideo->SiS_Pr, 0x0b); + ivideo->tvy |= ((SiS_GetCH700x(&ivideo->SiS_Pr, 0x08) & 0x01) << 8); + } + } } if(ivideo->tvxpos) { - sisfb_set_TVxposoffset(ivideo, ivideo->tvxpos); + sisfb_set_TVxposoffset(ivideo, ivideo->tvxpos); } if(ivideo->tvypos) { - sisfb_set_TVyposoffset(ivideo, ivideo->tvypos); + sisfb_set_TVyposoffset(ivideo, ivideo->tvypos); } - if((ivideo->currentvbflags & CRT2_TV) && (ivideo->vbflags & VB_301)) { /* Set filter for SiS301 */ + /* Eventually sync engines */ + sisfb_check_engine_and_sync(ivideo); - unsigned char filter_tb = 0; + /* (Re-)Initialize chip engines */ + if(ivideo->accel) { + sisfb_engine_init(ivideo); + } else { + ivideo->engineok = 0; + } +} - switch (ivideo->video_width) { - case 320: - filter_tb = (ivideo->vbflags & TV_NTSC) ? 4 : 12; - break; - case 640: - filter_tb = (ivideo->vbflags & TV_NTSC) ? 5 : 13; - break; - case 720: - filter_tb = (ivideo->vbflags & TV_NTSC) ? 6 : 14; - break; - case 400: - case 800: - filter_tb = (ivideo->vbflags & TV_NTSC) ? 7 : 15; - break; - default: - ivideo->sisfb_filter = -1; - break; - } +static int +sisfb_reset_mode(struct sis_video_info *ivideo) +{ + if(sisfb_set_mode(ivideo, 0)) + return 1; - orSISIDXREG(SISPART1, ivideo->CRT2_write_enable, 0x01); + sisfb_set_pitch(ivideo); + sisfb_set_base_CRT1(ivideo, ivideo->current_base); + sisfb_set_base_CRT2(ivideo, ivideo->current_base); - if(ivideo->vbflags & TV_NTSC) { - - andSISIDXREG(SISPART2, 0x3a, 0x1f); - - if (ivideo->vbflags & TV_SVIDEO) { - - andSISIDXREG(SISPART2, 0x30, 0xdf); - - } else if (ivideo->vbflags & TV_AVIDEO) { - - orSISIDXREG(SISPART2, 0x30, 0x20); - - switch (ivideo->video_width) { - case 640: - outSISIDXREG(SISPART2, 0x35, 0xEB); - outSISIDXREG(SISPART2, 0x36, 0x04); - outSISIDXREG(SISPART2, 0x37, 0x25); - outSISIDXREG(SISPART2, 0x38, 0x18); - break; - case 720: - outSISIDXREG(SISPART2, 0x35, 0xEE); - outSISIDXREG(SISPART2, 0x36, 0x0C); - outSISIDXREG(SISPART2, 0x37, 0x22); - outSISIDXREG(SISPART2, 0x38, 0x08); - break; - case 400: - case 800: - outSISIDXREG(SISPART2, 0x35, 0xEB); - outSISIDXREG(SISPART2, 0x36, 0x15); - outSISIDXREG(SISPART2, 0x37, 0x25); - outSISIDXREG(SISPART2, 0x38, 0xF6); - break; - } - } + return 0; +} + +static void +sisfb_handle_command(struct sis_video_info *ivideo, struct sisfb_cmd *sisfb_command) +{ + int mycrt1off; - } else if(ivideo->vbflags & TV_PAL) { - - andSISIDXREG(SISPART2, 0x3A, 0x1F); - - if (ivideo->vbflags & TV_SVIDEO) { - - andSISIDXREG(SISPART2, 0x30, 0xDF); - - } else if (ivideo->vbflags & TV_AVIDEO) { - - orSISIDXREG(SISPART2, 0x30, 0x20); - - switch (ivideo->video_width) { - case 640: - outSISIDXREG(SISPART2, 0x35, 0xF1); - outSISIDXREG(SISPART2, 0x36, 0xF7); - outSISIDXREG(SISPART2, 0x37, 0x1F); - outSISIDXREG(SISPART2, 0x38, 0x32); - break; - case 720: - outSISIDXREG(SISPART2, 0x35, 0xF3); - outSISIDXREG(SISPART2, 0x36, 0x00); - outSISIDXREG(SISPART2, 0x37, 0x1D); - outSISIDXREG(SISPART2, 0x38, 0x20); - break; - case 400: - case 800: - outSISIDXREG(SISPART2, 0x35, 0xFC); - outSISIDXREG(SISPART2, 0x36, 0xFB); - outSISIDXREG(SISPART2, 0x37, 0x14); - outSISIDXREG(SISPART2, 0x38, 0x2A); - break; + switch(sisfb_command->sisfb_cmd) { + case SISFB_CMD_GETVBFLAGS: + if(!ivideo->modechanged) { + sisfb_command->sisfb_result[0] = SISFB_CMD_ERR_EARLY; + } else { + sisfb_command->sisfb_result[0] = SISFB_CMD_ERR_OK; + sisfb_command->sisfb_result[1] = ivideo->currentvbflags; + sisfb_command->sisfb_result[2] = ivideo->vbflags2; + } + break; + case SISFB_CMD_SWITCHCRT1: + /* arg[0]: 0 = off, 1 = on, 99 = query */ + if(!ivideo->modechanged) { + sisfb_command->sisfb_result[0] = SISFB_CMD_ERR_EARLY; + } else if(sisfb_command->sisfb_arg[0] == 99) { + /* Query */ + sisfb_command->sisfb_result[1] = ivideo->sisfb_crt1off ? 0 : 1; + sisfb_command->sisfb_result[0] = SISFB_CMD_ERR_OK; + } else if(ivideo->sisfblocked) { + sisfb_command->sisfb_result[0] = SISFB_CMD_ERR_LOCKED; + } else if((!(ivideo->currentvbflags & CRT2_ENABLE)) && + (sisfb_command->sisfb_arg[0] == 0)) { + sisfb_command->sisfb_result[0] = SISFB_CMD_ERR_NOCRT2; + } else { + sisfb_command->sisfb_result[0] = SISFB_CMD_ERR_OK; + mycrt1off = sisfb_command->sisfb_arg[0] ? 0 : 1; + if( ((ivideo->currentvbflags & VB_DISPTYPE_CRT1) && mycrt1off) || + ((!(ivideo->currentvbflags & VB_DISPTYPE_CRT1)) && !mycrt1off) ) { + ivideo->sisfb_crt1off = mycrt1off; + if(sisfb_reset_mode(ivideo)) { + sisfb_command->sisfb_result[0] = SISFB_CMD_ERR_OTHER; } } + sisfb_command->sisfb_result[1] = ivideo->sisfb_crt1off ? 0 : 1; } - - if((ivideo->sisfb_filter >= 0) && (ivideo->sisfb_filter <= 7)) { - outSISIDXREG(SISPART2,0x35,(sis_TV_filter[filter_tb].filter[ivideo->sisfb_filter][0])); - outSISIDXREG(SISPART2,0x36,(sis_TV_filter[filter_tb].filter[ivideo->sisfb_filter][1])); - outSISIDXREG(SISPART2,0x37,(sis_TV_filter[filter_tb].filter[ivideo->sisfb_filter][2])); - outSISIDXREG(SISPART2,0x38,(sis_TV_filter[filter_tb].filter[ivideo->sisfb_filter][3])); - } - + break; + /* more to come */ + default: + sisfb_command->sisfb_result[0] = SISFB_CMD_ERR_UNKNOWN; + printk(KERN_ERR "sisfb: Unknown command 0x%x\n", + sisfb_command->sisfb_cmd); } } #ifndef MODULE -SISINITSTATIC int __init sisfb_setup(char *options) +SISINITSTATIC int __init +sisfb_setup(char *options) { char *this_opt; - - sisfb_setdefaultparms(); - printk(KERN_DEBUG "sisfb: Options %s\n", options); + sisfb_setdefaultparms(); - if(!options || !(*options)) { + if(!options || !(*options)) return 0; - } while((this_opt = strsep(&options, ",")) != NULL) { @@ -3880,9 +4098,9 @@ SISINITSTATIC int __init sisfb_setup(char *options) /* Need to check crt2 type first for fstn/dstn */ sisfb_search_crt2type(this_opt + 14); } else if(!strnicmp(this_opt, "tvmode:",7)) { - sisfb_search_tvstd(this_opt + 7); - } else if(!strnicmp(this_opt, "tvstandard:",11)) { sisfb_search_tvstd(this_opt + 7); + } else if(!strnicmp(this_opt, "tvstandard:",11)) { + sisfb_search_tvstd(this_opt + 11); } else if(!strnicmp(this_opt, "mode:", 5)) { sisfb_search_mode(this_opt + 5, FALSE); } else if(!strnicmp(this_opt, "vesa:", 5)) { @@ -3892,74 +4110,72 @@ SISINITSTATIC int __init sisfb_setup(char *options) sisfb_inverse = 1; /* fb_invert_cmaps(); */ } else if(!strnicmp(this_opt, "font:", 5)) { - if(strlen(this_opt + 5) < 40) { + if(strlen(this_opt + 5) < 40) { strncpy(sisfb_fontname, this_opt + 5, sizeof(sisfb_fontname) - 1); sisfb_fontname[sizeof(sisfb_fontname) - 1] = '\0'; } #endif } else if(!strnicmp(this_opt, "rate:", 5)) { sisfb_parm_rate = simple_strtoul(this_opt + 5, NULL, 0); - } else if(!strnicmp(this_opt, "filter:", 7)) { - sisfb_filter = (int)simple_strtoul(this_opt + 7, NULL, 0); } else if(!strnicmp(this_opt, "forcecrt1:", 10)) { sisfb_forcecrt1 = (int)simple_strtoul(this_opt + 10, NULL, 0); - } else if(!strnicmp(this_opt, "mem:",4)) { - sisfb_parm_mem = simple_strtoul(this_opt + 4, NULL, 0); + } else if(!strnicmp(this_opt, "mem:",4)) { + sisfb_parm_mem = simple_strtoul(this_opt + 4, NULL, 0); } else if(!strnicmp(this_opt, "pdc:", 4)) { - sisfb_pdc = simple_strtoul(this_opt + 4, NULL, 0); + sisfb_pdc = simple_strtoul(this_opt + 4, NULL, 0); } else if(!strnicmp(this_opt, "pdc1:", 5)) { - sisfb_pdca = simple_strtoul(this_opt + 5, NULL, 0); + sisfb_pdca = simple_strtoul(this_opt + 5, NULL, 0); } else if(!strnicmp(this_opt, "noaccel", 7)) { sisfb_accel = 0; } else if(!strnicmp(this_opt, "accel", 5)) { sisfb_accel = -1; } else if(!strnicmp(this_opt, "noypan", 6)) { - sisfb_ypan = 0; + sisfb_ypan = 0; } else if(!strnicmp(this_opt, "ypan", 4)) { - sisfb_ypan = -1; + sisfb_ypan = -1; } else if(!strnicmp(this_opt, "nomax", 5)) { - sisfb_max = 0; + sisfb_max = 0; } else if(!strnicmp(this_opt, "max", 3)) { - sisfb_max = -1; + sisfb_max = -1; } else if(!strnicmp(this_opt, "userom:", 7)) { sisfb_userom = (int)simple_strtoul(this_opt + 7, NULL, 0); } else if(!strnicmp(this_opt, "useoem:", 7)) { sisfb_useoem = (int)simple_strtoul(this_opt + 7, NULL, 0); } else if(!strnicmp(this_opt, "nocrt2rate", 10)) { sisfb_nocrt2rate = 1; - } else if(!strnicmp(this_opt, "scalelcd:", 9)) { - unsigned long temp = 2; - temp = simple_strtoul(this_opt + 9, NULL, 0); - if((temp == 0) || (temp == 1)) { + } else if(!strnicmp(this_opt, "scalelcd:", 9)) { + unsigned long temp = 2; + temp = simple_strtoul(this_opt + 9, NULL, 0); + if((temp == 0) || (temp == 1)) { sisfb_scalelcd = temp ^ 1; - } + } } else if(!strnicmp(this_opt, "tvxposoffset:", 13)) { - int temp = 0; - temp = (int)simple_strtol(this_opt + 13, NULL, 0); - if((temp >= -32) && (temp <= 32)) { + int temp = 0; + temp = (int)simple_strtol(this_opt + 13, NULL, 0); + if((temp >= -32) && (temp <= 32)) { sisfb_tvxposoffset = temp; - } + } } else if(!strnicmp(this_opt, "tvyposoffset:", 13)) { - int temp = 0; - temp = (int)simple_strtol(this_opt + 13, NULL, 0); - if((temp >= -32) && (temp <= 32)) { + int temp = 0; + temp = (int)simple_strtol(this_opt + 13, NULL, 0); + if((temp >= -32) && (temp <= 32)) { sisfb_tvyposoffset = temp; - } + } } else if(!strnicmp(this_opt, "specialtiming:", 14)) { sisfb_search_specialtiming(this_opt + 14); } else if(!strnicmp(this_opt, "lvdshl:", 7)) { - int temp = 4; - temp = simple_strtoul(this_opt + 7, NULL, 0); - if((temp >= 0) && (temp <= 3)) { + int temp = 4; + temp = simple_strtoul(this_opt + 7, NULL, 0); + if((temp >= 0) && (temp <= 3)) { sisfb_lvdshl = temp; - } + } } else if(this_opt[0] >= '0' && this_opt[0] <= '9') { sisfb_search_mode(this_opt, TRUE); #if !defined(__i386__) && !defined(__x86_64__) - } else if(!strnicmp(this_opt, "resetcard", 9)) { - sisfb_resetcard = 1; + } else if(!strnicmp(this_opt, "resetcard", 9)) { + sisfb_resetcard = 1; } else if(!strnicmp(this_opt, "videoram:", 9)) { - sisfb_videoram = simple_strtoul(this_opt + 9, NULL, 0); + sisfb_videoram = simple_strtoul(this_opt + 9, NULL, 0); #endif } else { printk(KERN_INFO "sisfb: Invalid option %s\n", this_opt); @@ -3967,63 +4183,99 @@ SISINITSTATIC int __init sisfb_setup(char *options) } - - return 0; } #endif -static UCHAR * __devinit sis_find_rom(struct pci_dev *pdev) +static int __devinit +sisfb_check_rom(SIS_IOTYPE1 *rom_base, struct sis_video_info *ivideo) +{ + SIS_IOTYPE1 *rom; + int romptr; + + if((readb(rom_base) != 0x55) || (readb(rom_base + 1) != 0xaa)) + return 0; + + romptr = (readb(rom_base + 0x18) | (readb(rom_base + 0x19) << 8)); + if(romptr > (0x10000 - 8)) + return 0; + + rom = rom_base + romptr; + + if((readb(rom) != 'P') || (readb(rom + 1) != 'C') || + (readb(rom + 2) != 'I') || (readb(rom + 3) != 'R')) + return 0; + + if((readb(rom + 4) | (readb(rom + 5) << 8)) != ivideo->chip_vendor) + return 0; + + if((readb(rom + 6) | (readb(rom + 7) << 8)) != ivideo->chip_id) + return 0; + + return 1; +} + +static unsigned char * __devinit +sisfb_find_rom(struct pci_dev *pdev) { struct sis_video_info *ivideo = pci_get_drvdata(pdev); - USHORT pciid; - int romptr; - UCHAR *myrombase; - u32 temp; - SIS_IOTYPE1 *rom_base, *rom; + SIS_IOTYPE1 *rom_base; + unsigned char *myrombase = NULL; + u32 temp; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11) + size_t romsize; + + /* First, try the official pci ROM functions (except + * on integrated chipsets which have no ROM). + */ - if(!(myrombase = vmalloc(65536))) return NULL; + if(!ivideo->nbridge) { -#if defined(__i386__) || defined(__x86_64__) + if((rom_base = pci_map_rom(pdev, &romsize))) { - for(temp = 0x000c0000; temp < 0x000f0000; temp += 0x00001000) { + if(sisfb_check_rom(rom_base, ivideo)) { - rom_base = ioremap(temp, 0x10000); - if(!rom_base) continue; + if((myrombase = vmalloc(65536))) { - if((readb(rom_base) != 0x55) || (readb(rom_base + 1) != 0xaa)) { - iounmap(rom_base); - continue; - } + /* Work around bug in pci/rom.c: Folks forgot to check + * whether the size retrieved from the BIOS image eventually + * is larger than the mapped size + */ + if(pci_resource_len(pdev, PCI_ROM_RESOURCE) < romsize) + romsize = pci_resource_len(pdev, PCI_ROM_RESOURCE); - romptr = (unsigned short)(readb(rom_base + 0x18) | (readb(rom_base + 0x19) << 8)); - if(romptr > (0x10000 - 8)) { - iounmap(rom_base); - continue; - } + memcpy_fromio(myrombase, rom_base, + (romsize > 65536) ? 65536 : romsize); + } + } + pci_unmap_rom(pdev, rom_base); + } + } - rom = rom_base + romptr; + if(myrombase) return myrombase; +#endif - if((readb(rom) != 'P') || (readb(rom + 1) != 'C') || - (readb(rom + 2) != 'I') || (readb(rom + 3) != 'R')) { - iounmap(rom_base); - continue; - } + /* Otherwise do it the conventional way. */ - pciid = readb(rom + 4) | (readb(rom + 5) << 8); - if(pciid != 0x1039) { - iounmap(rom_base); - continue; - } +#if defined(__i386__) || defined(__x86_64__) - pciid = readb(rom + 6) | (readb(rom + 7) << 8); - if(pciid == ivideo->chip_id) { - memcpy_fromio(myrombase, rom_base, 65536); - iounmap(rom_base); - return myrombase; - } + for(temp = 0x000c0000; temp < 0x000f0000; temp += 0x00001000) { + + rom_base = ioremap(temp, 65536); + if(!rom_base) + continue; + + if(!sisfb_check_rom(rom_base, ivideo)) { + iounmap(rom_base); + continue; + } + + if((myrombase = vmalloc(65536))) + memcpy_fromio(myrombase, rom_base, 65536); + + iounmap(rom_base); + break; - iounmap(rom_base); } #else @@ -4034,752 +4286,1603 @@ static UCHAR * __devinit sis_find_rom(struct pci_dev *pdev) rom_base = ioremap(ivideo->video_base, 65536); if(rom_base) { - if((readb(rom_base) == 0x55) && (readb(rom_base + 1) == 0xaa)) { - romptr = (u16)(readb(rom_base + 0x18) | (readb(rom_base + 0x19) << 8)); - if(romptr <= (0x10000 - 8)) { - rom = rom_base + romptr; - if((readb(rom) == 'P') && (readb(rom + 1) == 'C') && - (readb(rom + 2) == 'I') && (readb(rom + 3) == 'R')) { - pciid = readb(rom + 4) | (readb(rom + 5) << 8); - if(pciid == 0x1039) { - pciid = readb(rom + 6) | (readb(rom + 7) << 8); - if(pciid == ivideo->chip_id) { - memcpy_fromio(myrombase, rom_base, 65536); - iounmap(rom_base); - pci_write_config_dword(pdev, PCI_ROM_ADDRESS, temp); - return myrombase; - } - } - } - } - } - iounmap(rom_base); + if(sisfb_check_rom(rom_base, ivideo)) { + if((myrombase = vmalloc(65536))) + memcpy_fromio(myrombase, rom_base, 65536); + } + iounmap(rom_base); } - pci_write_config_dword(pdev, PCI_ROM_ADDRESS, temp); + + pci_write_config_dword(pdev, PCI_ROM_ADDRESS, temp); #endif - vfree(myrombase); - return NULL; + return myrombase; +} + +static void __devinit +sisfb_post_map_vram(struct sis_video_info *ivideo, unsigned int *mapsize, + unsigned int min) +{ + ivideo->video_vbase = ioremap(ivideo->video_base, (*mapsize)); + + if(!ivideo->video_vbase) { + printk(KERN_ERR + "sisfb: Unable to map maximum video RAM for size detection\n"); + (*mapsize) >>= 1; + while((!(ivideo->video_vbase = ioremap(ivideo->video_base, (*mapsize))))) { + (*mapsize) >>= 1; + if((*mapsize) < (min << 20)) + break; + } + if(ivideo->video_vbase) { + printk(KERN_ERR + "sisfb: Video RAM size detection limited to %dMB\n", + (int)((*mapsize) >> 20)); + } + } } #ifdef CONFIG_FB_SIS_300 static int __devinit -sisfb_chkbuswidth300(struct pci_dev *pdev, SIS_IOTYPE1 *FBAddress) +sisfb_post_300_buswidth(struct sis_video_info *ivideo) { - struct sis_video_info *ivideo = pci_get_drvdata(pdev); + SIS_IOTYPE1 *FBAddress = ivideo->video_vbase; + unsigned short temp; + unsigned char reg; int i, j; - USHORT temp; - UCHAR reg; - - andSISIDXREG(SISSR,0x15,0xFB); - orSISIDXREG(SISSR,0x15,0x04); - outSISIDXREG(SISSR,0x13,0x00); - outSISIDXREG(SISSR,0x14,0xBF); - - for(i=0; i<2; i++) { - temp = 0x1234; - for(j=0; j<4; j++) { - writew(temp, FBAddress); - if(readw(FBAddress) == temp) break; - orSISIDXREG(SISSR,0x3c,0x01); - inSISIDXREG(SISSR,0x05,reg); - inSISIDXREG(SISSR,0x05,reg); - andSISIDXREG(SISSR,0x3c,0xfe); - inSISIDXREG(SISSR,0x05,reg); - inSISIDXREG(SISSR,0x05,reg); - temp++; - } + + andSISIDXREG(SISSR, 0x15, 0xFB); + orSISIDXREG(SISSR, 0x15, 0x04); + outSISIDXREG(SISSR, 0x13, 0x00); + outSISIDXREG(SISSR, 0x14, 0xBF); + + for(i = 0; i < 2; i++) { + temp = 0x1234; + for(j = 0; j < 4; j++) { + writew(temp, FBAddress); + if(readw(FBAddress) == temp) + break; + orSISIDXREG(SISSR, 0x3c, 0x01); + inSISIDXREG(SISSR, 0x05, reg); + inSISIDXREG(SISSR, 0x05, reg); + andSISIDXREG(SISSR, 0x3c, 0xfe); + inSISIDXREG(SISSR, 0x05, reg); + inSISIDXREG(SISSR, 0x05, reg); + temp++; + } } writel(0x01234567L, FBAddress); - writel(0x456789ABL, (FBAddress+4)); - writel(0x89ABCDEFL, (FBAddress+8)); - writel(0xCDEF0123L, (FBAddress+12)); - inSISIDXREG(SISSR,0x3b,reg); + writel(0x456789ABL, (FBAddress + 4)); + writel(0x89ABCDEFL, (FBAddress + 8)); + writel(0xCDEF0123L, (FBAddress + 12)); + + inSISIDXREG(SISSR, 0x3b, reg); if(reg & 0x01) { - if(readl((FBAddress+12)) == 0xCDEF0123L) return(4); /* Channel A 128bit */ + if(readl((FBAddress + 12)) == 0xCDEF0123L) + return 4; /* Channel A 128bit */ } - if(readl((FBAddress+4)) == 0x456789ABL) return(2); /* Channel B 64bit */ - return(1); /* 32bit */ + + if(readl((FBAddress + 4)) == 0x456789ABL) + return 2; /* Channel B 64bit */ + + return 1; /* 32bit */ +} + +static int __devinit +sisfb_post_300_rwtest(struct sis_video_info *ivideo, int iteration, int buswidth, + int PseudoRankCapacity, int PseudoAdrPinCount, + unsigned int mapsize) +{ + SIS_IOTYPE1 *FBAddr = ivideo->video_vbase; + unsigned short sr14; + unsigned int k, RankCapacity, PageCapacity, BankNumHigh, BankNumMid; + unsigned int PhysicalAdrOtherPage, PhysicalAdrHigh, PhysicalAdrHalfPage; + static const unsigned short SiS_DRAMType[17][5] = { + {0x0C,0x0A,0x02,0x40,0x39}, + {0x0D,0x0A,0x01,0x40,0x48}, + {0x0C,0x09,0x02,0x20,0x35}, + {0x0D,0x09,0x01,0x20,0x44}, + {0x0C,0x08,0x02,0x10,0x31}, + {0x0D,0x08,0x01,0x10,0x40}, + {0x0C,0x0A,0x01,0x20,0x34}, + {0x0C,0x09,0x01,0x08,0x32}, + {0x0B,0x08,0x02,0x08,0x21}, + {0x0C,0x08,0x01,0x08,0x30}, + {0x0A,0x08,0x02,0x04,0x11}, + {0x0B,0x0A,0x01,0x10,0x28}, + {0x09,0x08,0x02,0x02,0x01}, + {0x0B,0x09,0x01,0x08,0x24}, + {0x0B,0x08,0x01,0x04,0x20}, + {0x0A,0x08,0x01,0x02,0x10}, + {0x09,0x08,0x01,0x01,0x00} + }; + + for(k = 0; k <= 16; k++) { + + RankCapacity = buswidth * SiS_DRAMType[k][3]; + + if(RankCapacity != PseudoRankCapacity) + continue; + + if((SiS_DRAMType[k][2] + SiS_DRAMType[k][0]) > PseudoAdrPinCount) + continue; + + BankNumHigh = RankCapacity * 16 * iteration - 1; + if(iteration == 3) { /* Rank No */ + BankNumMid = RankCapacity * 16 - 1; + } else { + BankNumMid = RankCapacity * 16 * iteration / 2 - 1; + } + + PageCapacity = (1 << SiS_DRAMType[k][1]) * buswidth * 4; + PhysicalAdrHigh = BankNumHigh; + PhysicalAdrHalfPage = (PageCapacity / 2 + PhysicalAdrHigh) % PageCapacity; + PhysicalAdrOtherPage = PageCapacity * SiS_DRAMType[k][2] + PhysicalAdrHigh; + + andSISIDXREG(SISSR, 0x15, 0xFB); /* Test */ + orSISIDXREG(SISSR, 0x15, 0x04); /* Test */ + sr14 = (SiS_DRAMType[k][3] * buswidth) - 1; + if(buswidth == 4) sr14 |= 0x80; + else if(buswidth == 2) sr14 |= 0x40; + outSISIDXREG(SISSR, 0x13, SiS_DRAMType[k][4]); + outSISIDXREG(SISSR, 0x14, sr14); + + BankNumHigh <<= 16; + BankNumMid <<= 16; + + if((BankNumHigh + PhysicalAdrHigh >= mapsize) || + (BankNumMid + PhysicalAdrHigh >= mapsize) || + (BankNumHigh + PhysicalAdrHalfPage >= mapsize) || + (BankNumHigh + PhysicalAdrOtherPage >= mapsize)) + continue; + + /* Write data */ + writew(((unsigned short)PhysicalAdrHigh), + (FBAddr + BankNumHigh + PhysicalAdrHigh)); + writew(((unsigned short)BankNumMid), + (FBAddr + BankNumMid + PhysicalAdrHigh)); + writew(((unsigned short)PhysicalAdrHalfPage), + (FBAddr + BankNumHigh + PhysicalAdrHalfPage)); + writew(((unsigned short)PhysicalAdrOtherPage), + (FBAddr + BankNumHigh + PhysicalAdrOtherPage)); + + /* Read data */ + if(readw(FBAddr + BankNumHigh + PhysicalAdrHigh) == PhysicalAdrHigh) + return 1; + } + + return 0; } static void __devinit -sisfb_setramsize300(struct pci_dev *pdev) +sisfb_post_300_ramsize(struct pci_dev *pdev, unsigned int mapsize) { - struct sis_video_info *ivideo = pci_get_drvdata(pdev); - SIS_IOTYPE1 *FBAddr = ivideo->video_vbase; - SIS_IOTYPE1 *Addr; - USHORT sr13, sr14=0, buswidth, Done, data, TotalCapacity, PhysicalAdrOtherPage=0; - int PseudoRankCapacity, PseudoTotalCapacity, PseudoAdrPinCount; - int RankCapacity, AdrPinCount, BankNumHigh, BankNumMid, MB2Bank; - int PageCapacity, PhysicalAdrHigh, PhysicalAdrHalfPage, i, j, k; - const USHORT SiS_DRAMType[17][5] = { - {0x0C,0x0A,0x02,0x40,0x39}, - {0x0D,0x0A,0x01,0x40,0x48}, - {0x0C,0x09,0x02,0x20,0x35}, - {0x0D,0x09,0x01,0x20,0x44}, - {0x0C,0x08,0x02,0x10,0x31}, - {0x0D,0x08,0x01,0x10,0x40}, - {0x0C,0x0A,0x01,0x20,0x34}, - {0x0C,0x09,0x01,0x08,0x32}, - {0x0B,0x08,0x02,0x08,0x21}, - {0x0C,0x08,0x01,0x08,0x30}, - {0x0A,0x08,0x02,0x04,0x11}, - {0x0B,0x0A,0x01,0x10,0x28}, - {0x09,0x08,0x02,0x02,0x01}, - {0x0B,0x09,0x01,0x08,0x24}, - {0x0B,0x08,0x01,0x04,0x20}, - {0x0A,0x08,0x01,0x02,0x10}, - {0x09,0x08,0x01,0x01,0x00} - }; - - buswidth = sisfb_chkbuswidth300(pdev, FBAddr); - - MB2Bank = 16; - Done = 0; - for(i = 6; i >= 0; i--) { - if(Done) break; - PseudoRankCapacity = 1 << i; - for(j = 4; j >= 1; j--) { - if(Done) break; - PseudoTotalCapacity = PseudoRankCapacity * j; - PseudoAdrPinCount = 15 - j; - if(PseudoTotalCapacity <= 64) { - for(k = 0; k <= 16; k++) { - if(Done) break; - RankCapacity = buswidth * SiS_DRAMType[k][3]; - AdrPinCount = SiS_DRAMType[k][2] + SiS_DRAMType[k][0]; - if(RankCapacity == PseudoRankCapacity) - if(AdrPinCount <= PseudoAdrPinCount) { - if(j == 3) { /* Rank No */ - BankNumHigh = RankCapacity * MB2Bank * 3 - 1; - BankNumMid = RankCapacity * MB2Bank * 1 - 1; - } else { - BankNumHigh = RankCapacity * MB2Bank * j - 1; - BankNumMid = RankCapacity * MB2Bank * j / 2 - 1; - } - PageCapacity = (1 << SiS_DRAMType[k][1]) * buswidth * 4; - PhysicalAdrHigh = BankNumHigh; - PhysicalAdrHalfPage = (PageCapacity / 2 + PhysicalAdrHigh) % PageCapacity; - PhysicalAdrOtherPage = PageCapacity * SiS_DRAMType[k][2] + PhysicalAdrHigh; - /* Write data */ - andSISIDXREG(SISSR,0x15,0xFB); /* Test */ - orSISIDXREG(SISSR,0x15,0x04); /* Test */ - TotalCapacity = SiS_DRAMType[k][3] * buswidth; - sr13 = SiS_DRAMType[k][4]; - if(buswidth == 4) sr14 = (TotalCapacity - 1) | 0x80; - if(buswidth == 2) sr14 = (TotalCapacity - 1) | 0x40; - if(buswidth == 1) sr14 = (TotalCapacity - 1) | 0x00; - outSISIDXREG(SISSR,0x13,sr13); - outSISIDXREG(SISSR,0x14,sr14); - Addr = FBAddr + BankNumHigh * 64 * 1024 + PhysicalAdrHigh; - /* *((USHORT *)(Addr)) = (USHORT)PhysicalAdrHigh; */ - writew(((USHORT)PhysicalAdrHigh), Addr); - Addr = FBAddr + BankNumMid * 64 * 1024 + PhysicalAdrHigh; - /* *((USHORT *)(Addr)) = (USHORT)BankNumMid; */ - writew(((USHORT)BankNumMid), Addr); - Addr = FBAddr + BankNumHigh * 64 * 1024 + PhysicalAdrHalfPage; - /* *((USHORT *)(Addr)) = (USHORT)PhysicalAdrHalfPage; */ - writew(((USHORT)PhysicalAdrHalfPage), Addr); - Addr = FBAddr + BankNumHigh * 64 * 1024 + PhysicalAdrOtherPage; - /* *((USHORT *)(Addr)) = PhysicalAdrOtherPage; */ - writew(((USHORT)PhysicalAdrOtherPage), Addr); - /* Read data */ - Addr = FBAddr + BankNumHigh * 64 * 1024 + PhysicalAdrHigh; - data = readw(Addr); /* *((USHORT *)(Addr)); */ - if(data == PhysicalAdrHigh) Done = 1; - } /* if */ - } /* for k */ - } /* if */ - } /* for j */ - } /* for i */ + struct sis_video_info *ivideo = pci_get_drvdata(pdev); + int i, j, buswidth; + int PseudoRankCapacity, PseudoAdrPinCount; + + buswidth = sisfb_post_300_buswidth(ivideo); + + for(i = 6; i >= 0; i--) { + PseudoRankCapacity = 1 << i; + for(j = 4; j >= 1; j--) { + PseudoAdrPinCount = 15 - j; + if((PseudoRankCapacity * j) <= 64) { + if(sisfb_post_300_rwtest(ivideo, + j, + buswidth, + PseudoRankCapacity, + PseudoAdrPinCount, + mapsize)) + return; + } + } + } } -static void __devinit sisfb_post_sis300(struct pci_dev *pdev) +static void __devinit +sisfb_post_sis300(struct pci_dev *pdev) { struct sis_video_info *ivideo = pci_get_drvdata(pdev); + unsigned char *bios = ivideo->SiS_Pr.VirtualRomBase; u8 reg, v1, v2, v3, v4, v5, v6, v7, v8; u16 index, rindex, memtype = 0; + unsigned int mapsize; - outSISIDXREG(SISSR,0x05,0x86); + if(!ivideo->SiS_Pr.UseROM) + bios = NULL; - if(ivideo->sishw_ext.UseROM) { - if(ivideo->sishw_ext.pjVirtualRomBase[0x52] & 0x80) { - memtype = ivideo->sishw_ext.pjVirtualRomBase[0x52]; - } else { - inSISIDXREG(SISSR,0x3a,memtype); - } - memtype &= 0x07; + outSISIDXREG(SISSR, 0x05, 0x86); + + if(bios) { + if(bios[0x52] & 0x80) { + memtype = bios[0x52]; + } else { + inSISIDXREG(SISSR, 0x3a, memtype); + } + memtype &= 0x07; } + v3 = 0x80; v6 = 0x80; if(ivideo->revision_id <= 0x13) { - v1 = 0x44; v2 = 0x42; v3 = 0x80; - v4 = 0x44; v5 = 0x42; v6 = 0x80; + v1 = 0x44; v2 = 0x42; + v4 = 0x44; v5 = 0x42; } else { - v1 = 0x68; v2 = 0x43; v3 = 0x80; /* Assume 125Mhz MCLK */ - v4 = 0x68; v5 = 0x43; v6 = 0x80; /* Assume 125Mhz ECLK */ - if(ivideo->sishw_ext.UseROM) { - index = memtype * 5; - rindex = index + 0x54; - v1 = ivideo->sishw_ext.pjVirtualRomBase[rindex++]; - v2 = ivideo->sishw_ext.pjVirtualRomBase[rindex++]; - v3 = ivideo->sishw_ext.pjVirtualRomBase[rindex++]; - rindex = index + 0x7c; - v4 = ivideo->sishw_ext.pjVirtualRomBase[rindex++]; - v5 = ivideo->sishw_ext.pjVirtualRomBase[rindex++]; - v6 = ivideo->sishw_ext.pjVirtualRomBase[rindex++]; - } + v1 = 0x68; v2 = 0x43; /* Assume 125Mhz MCLK */ + v4 = 0x68; v5 = 0x43; /* Assume 125Mhz ECLK */ + if(bios) { + index = memtype * 5; + rindex = index + 0x54; + v1 = bios[rindex++]; + v2 = bios[rindex++]; + v3 = bios[rindex++]; + rindex = index + 0x7c; + v4 = bios[rindex++]; + v5 = bios[rindex++]; + v6 = bios[rindex++]; + } } - outSISIDXREG(SISSR,0x28,v1); - outSISIDXREG(SISSR,0x29,v2); - outSISIDXREG(SISSR,0x2a,v3); - outSISIDXREG(SISSR,0x2e,v4); - outSISIDXREG(SISSR,0x2f,v5); - outSISIDXREG(SISSR,0x30,v6); + outSISIDXREG(SISSR, 0x28, v1); + outSISIDXREG(SISSR, 0x29, v2); + outSISIDXREG(SISSR, 0x2a, v3); + outSISIDXREG(SISSR, 0x2e, v4); + outSISIDXREG(SISSR, 0x2f, v5); + outSISIDXREG(SISSR, 0x30, v6); + v1 = 0x10; - if(ivideo->sishw_ext.UseROM) v1 = ivideo->sishw_ext.pjVirtualRomBase[0xa4]; - outSISIDXREG(SISSR,0x07,v1); /* DAC speed */ - outSISIDXREG(SISSR,0x11,0x0f); /* DDC, power save */ + if(bios) + v1 = bios[0xa4]; + outSISIDXREG(SISSR, 0x07, v1); /* DAC speed */ + + outSISIDXREG(SISSR, 0x11, 0x0f); /* DDC, power save */ + v1 = 0x01; v2 = 0x43; v3 = 0x1e; v4 = 0x2a; v5 = 0x06; v6 = 0x00; v7 = 0x00; v8 = 0x00; - if(ivideo->sishw_ext.UseROM) { - memtype += 0xa5; - v1 = ivideo->sishw_ext.pjVirtualRomBase[memtype]; - v2 = ivideo->sishw_ext.pjVirtualRomBase[memtype + 8]; - v3 = ivideo->sishw_ext.pjVirtualRomBase[memtype + 16]; - v4 = ivideo->sishw_ext.pjVirtualRomBase[memtype + 24]; - v5 = ivideo->sishw_ext.pjVirtualRomBase[memtype + 32]; - v6 = ivideo->sishw_ext.pjVirtualRomBase[memtype + 40]; - v7 = ivideo->sishw_ext.pjVirtualRomBase[memtype + 48]; - v8 = ivideo->sishw_ext.pjVirtualRomBase[memtype + 56]; - } - if(ivideo->revision_id >= 0x80) v3 &= 0xfd; - outSISIDXREG(SISSR,0x15,v1); /* Ram type (assuming 0, BIOS 0xa5 step 8) */ - outSISIDXREG(SISSR,0x16,v2); - outSISIDXREG(SISSR,0x17,v3); - outSISIDXREG(SISSR,0x18,v4); - outSISIDXREG(SISSR,0x19,v5); - outSISIDXREG(SISSR,0x1a,v6); - outSISIDXREG(SISSR,0x1b,v7); - outSISIDXREG(SISSR,0x1c,v8); /* ---- */ - andSISIDXREG(SISSR,0x15,0xfb); - orSISIDXREG(SISSR,0x15,0x04); - if(ivideo->sishw_ext.UseROM) { - if(ivideo->sishw_ext.pjVirtualRomBase[0x53] & 0x02) { - orSISIDXREG(SISSR,0x19,0x20); - } + if(bios) { + memtype += 0xa5; + v1 = bios[memtype]; + v2 = bios[memtype + 8]; + v3 = bios[memtype + 16]; + v4 = bios[memtype + 24]; + v5 = bios[memtype + 32]; + v6 = bios[memtype + 40]; + v7 = bios[memtype + 48]; + v8 = bios[memtype + 56]; + } + if(ivideo->revision_id >= 0x80) + v3 &= 0xfd; + outSISIDXREG(SISSR, 0x15, v1); /* Ram type (assuming 0, BIOS 0xa5 step 8) */ + outSISIDXREG(SISSR, 0x16, v2); + outSISIDXREG(SISSR, 0x17, v3); + outSISIDXREG(SISSR, 0x18, v4); + outSISIDXREG(SISSR, 0x19, v5); + outSISIDXREG(SISSR, 0x1a, v6); + outSISIDXREG(SISSR, 0x1b, v7); + outSISIDXREG(SISSR, 0x1c, v8); /* ---- */ + andSISIDXREG(SISSR, 0x15 ,0xfb); + orSISIDXREG(SISSR, 0x15, 0x04); + if(bios) { + if(bios[0x53] & 0x02) { + orSISIDXREG(SISSR, 0x19, 0x20); + } } v1 = 0x04; /* DAC pedestal (BIOS 0xe5) */ - if(ivideo->revision_id >= 0x80) v1 |= 0x01; - outSISIDXREG(SISSR,0x1f,v1); - outSISIDXREG(SISSR,0x20,0xa0); /* linear & relocated io */ + if(ivideo->revision_id >= 0x80) + v1 |= 0x01; + outSISIDXREG(SISSR, 0x1f, v1); + outSISIDXREG(SISSR, 0x20, 0xa4); /* linear & relocated io & disable a0000 */ v1 = 0xf6; v2 = 0x0d; v3 = 0x00; - if(ivideo->sishw_ext.UseROM) { - v1 = ivideo->sishw_ext.pjVirtualRomBase[0xe8]; - v2 = ivideo->sishw_ext.pjVirtualRomBase[0xe9]; - v3 = ivideo->sishw_ext.pjVirtualRomBase[0xea]; - } - outSISIDXREG(SISSR,0x23,v1); - outSISIDXREG(SISSR,0x24,v2); - outSISIDXREG(SISSR,0x25,v3); - outSISIDXREG(SISSR,0x21,0x84); - outSISIDXREG(SISSR,0x22,0x00); - outSISIDXREG(SISCR,0x37,0x00); - orSISIDXREG(SISPART1,0x24,0x01); /* unlock crt2 */ - outSISIDXREG(SISPART1,0x00,0x00); + if(bios) { + v1 = bios[0xe8]; + v2 = bios[0xe9]; + v3 = bios[0xea]; + } + outSISIDXREG(SISSR, 0x23, v1); + outSISIDXREG(SISSR, 0x24, v2); + outSISIDXREG(SISSR, 0x25, v3); + outSISIDXREG(SISSR, 0x21, 0x84); + outSISIDXREG(SISSR, 0x22, 0x00); + outSISIDXREG(SISCR, 0x37, 0x00); + orSISIDXREG(SISPART1, 0x24, 0x01); /* unlock crt2 */ + outSISIDXREG(SISPART1, 0x00, 0x00); v1 = 0x40; v2 = 0x11; - if(ivideo->sishw_ext.UseROM) { - v1 = ivideo->sishw_ext.pjVirtualRomBase[0xec]; - v2 = ivideo->sishw_ext.pjVirtualRomBase[0xeb]; + if(bios) { + v1 = bios[0xec]; + v2 = bios[0xeb]; } - outSISIDXREG(SISPART1,0x02,v1); - if(ivideo->revision_id >= 0x80) v2 &= ~0x01; - inSISIDXREG(SISPART4,0x00,reg); + outSISIDXREG(SISPART1, 0x02, v1); + + if(ivideo->revision_id >= 0x80) + v2 &= ~0x01; + + inSISIDXREG(SISPART4, 0x00, reg); if((reg == 1) || (reg == 2)) { - outSISIDXREG(SISCR,0x37,0x02); - outSISIDXREG(SISPART2,0x00,0x1c); - v4 = 0x00; v5 = 0x00; v6 = 0x10; - if(ivideo->sishw_ext.UseROM) { - v4 = ivideo->sishw_ext.pjVirtualRomBase[0xf5]; - v5 = ivideo->sishw_ext.pjVirtualRomBase[0xf6]; - v6 = ivideo->sishw_ext.pjVirtualRomBase[0xf7]; - } - outSISIDXREG(SISPART4,0x0d,v4); - outSISIDXREG(SISPART4,0x0e,v5); - outSISIDXREG(SISPART4,0x10,v6); - outSISIDXREG(SISPART4,0x0f,0x3f); - inSISIDXREG(SISPART4,0x01,reg); - if(reg >= 0xb0) { - inSISIDXREG(SISPART4,0x23,reg); - reg &= 0x20; - reg <<= 1; - outSISIDXREG(SISPART4,0x23,reg); - } + outSISIDXREG(SISCR, 0x37, 0x02); + outSISIDXREG(SISPART2, 0x00, 0x1c); + v4 = 0x00; v5 = 0x00; v6 = 0x10; + if(ivideo->SiS_Pr.UseROM) { + v4 = bios[0xf5]; + v5 = bios[0xf6]; + v6 = bios[0xf7]; + } + outSISIDXREG(SISPART4, 0x0d, v4); + outSISIDXREG(SISPART4, 0x0e, v5); + outSISIDXREG(SISPART4, 0x10, v6); + outSISIDXREG(SISPART4, 0x0f, 0x3f); + inSISIDXREG(SISPART4, 0x01, reg); + if(reg >= 0xb0) { + inSISIDXREG(SISPART4, 0x23, reg); + reg &= 0x20; + reg <<= 1; + outSISIDXREG(SISPART4, 0x23, reg); + } } else { - v2 &= ~0x10; + v2 &= ~0x10; } - outSISIDXREG(SISSR,0x32,v2); - andSISIDXREG(SISPART1,0x24,0xfe); /* Lock CRT2 */ - inSISIDXREG(SISSR,0x16,reg); + outSISIDXREG(SISSR, 0x32, v2); + + andSISIDXREG(SISPART1, 0x24, 0xfe); /* Lock CRT2 */ + + inSISIDXREG(SISSR, 0x16, reg); reg &= 0xc3; - outSISIDXREG(SISCR,0x35,reg); - outSISIDXREG(SISCR,0x83,0x00); + outSISIDXREG(SISCR, 0x35, reg); + outSISIDXREG(SISCR, 0x83, 0x00); #if !defined(__i386__) && !defined(__x86_64__) if(sisfb_videoram) { - outSISIDXREG(SISSR,0x13,0x28); /* ? */ - reg = ((sisfb_videoram >> 10) - 1) | 0x40; - outSISIDXREG(SISSR,0x14,reg); + outSISIDXREG(SISSR, 0x13, 0x28); /* ? */ + reg = ((sisfb_videoram >> 10) - 1) | 0x40; + outSISIDXREG(SISSR, 0x14, reg); } else { #endif - /* Need to map max FB size for finding out about RAM size */ - ivideo->video_vbase = ioremap(ivideo->video_base, 0x4000000); - if(ivideo->video_vbase) { - sisfb_setramsize300(pdev); - iounmap(ivideo->video_vbase); - } else { - printk(KERN_DEBUG "sisfb: Failed to map memory for size detection, assuming 8MB\n"); - outSISIDXREG(SISSR,0x13,0x28); /* ? */ - outSISIDXREG(SISSR,0x14,0x47); /* 8MB, 64bit default */ - } + /* Need to map max FB size for finding out about RAM size */ + mapsize = 64 << 20; + sisfb_post_map_vram(ivideo, &mapsize, 4); + + if(ivideo->video_vbase) { + sisfb_post_300_ramsize(pdev, mapsize); + iounmap(ivideo->video_vbase); + } else { + printk(KERN_DEBUG + "sisfb: Failed to map memory for size detection, assuming 8MB\n"); + outSISIDXREG(SISSR, 0x13, 0x28); /* ? */ + outSISIDXREG(SISSR, 0x14, 0x47); /* 8MB, 64bit default */ + } #if !defined(__i386__) && !defined(__x86_64__) } #endif - if(ivideo->sishw_ext.UseROM) { - v1 = ivideo->sishw_ext.pjVirtualRomBase[0xe6]; - v2 = ivideo->sishw_ext.pjVirtualRomBase[0xe7]; + if(bios) { + v1 = bios[0xe6]; + v2 = bios[0xe7]; } else { - inSISIDXREG(SISSR,0x3a,reg); - if((reg & 0x30) == 0x30) { - v1 = 0x04; /* PCI */ - v2 = 0x92; - } else { - v1 = 0x14; /* AGP */ - v2 = 0xb2; - } + inSISIDXREG(SISSR, 0x3a, reg); + if((reg & 0x30) == 0x30) { + v1 = 0x04; /* PCI */ + v2 = 0x92; + } else { + v1 = 0x14; /* AGP */ + v2 = 0xb2; + } } - outSISIDXREG(SISSR,0x21,v1); - outSISIDXREG(SISSR,0x22,v2); + outSISIDXREG(SISSR, 0x21, v1); + outSISIDXREG(SISSR, 0x22, v2); + + /* Sense CRT1 */ + sisfb_sense_crt1(ivideo); + + /* Set default mode, don't clear screen */ + ivideo->SiS_Pr.SiS_UseOEM = FALSE; + SiS_SetEnableDstn(&ivideo->SiS_Pr, FALSE); + SiS_SetEnableFstn(&ivideo->SiS_Pr, FALSE); + ivideo->curFSTN = ivideo->curDSTN = 0; + ivideo->SiS_Pr.VideoMemorySize = 8 << 20; + SiSSetMode(&ivideo->SiS_Pr, 0x2e | 0x80); + + outSISIDXREG(SISSR, 0x05, 0x86); + + /* Display off */ + orSISIDXREG(SISSR, 0x01, 0x20); + + /* Save mode number in CR34 */ + outSISIDXREG(SISCR, 0x34, 0x2e); + + /* Let everyone know what the current mode is */ + ivideo->modeprechange = 0x2e; } #endif #ifdef CONFIG_FB_SIS_315 -static void __devinit sisfb_post_sis315330(struct pci_dev *pdev) +#if 0 +static void __devinit +sisfb_post_sis315330(struct pci_dev *pdev) { -#ifdef YET_TO_BE_DONE - struct sis_video_info *ivideo = pci_get_drvdata(pdev); - u8 reg, v1, v2, v3, v4, v5, v6, v7, v8; - u16 index, rindex, memtype = 0; - u32 reg1_32, reg2_32, reg3_32; + /* TODO */ +} +#endif + +static void __devinit +sisfb_post_xgi_delay(struct sis_video_info *ivideo, int delay) +{ + unsigned int i; + u8 reg; + + for(i = 0; i <= (delay * 10 * 36); i++) { + inSISIDXREG(SISSR, 0x05, reg); + reg++; + } +} + +static int __devinit +sisfb_find_host_bridge(struct sis_video_info *ivideo, struct pci_dev *mypdev, + unsigned short pcivendor) +{ + struct pci_dev *pdev = NULL; + unsigned short temp; + int ret = 0; + + while((pdev = SIS_PCI_GET_CLASS(PCI_CLASS_BRIDGE_HOST, pdev))) { + temp = pdev->vendor; + SIS_PCI_PUT_DEVICE(pdev); + if(temp == pcivendor) { + ret = 1; + break; + } + } + + return ret; +} + +static int __devinit +sisfb_post_xgi_rwtest(struct sis_video_info *ivideo, int starta, + unsigned int enda, unsigned int mapsize) +{ + unsigned int pos; int i; - /* Unlock */ - /* outSISIDXREG(0x3c4,0x05,0x86); */ - outSISIDXREG(SISSR,0x05,0x86); + writel(0, ivideo->video_vbase); - /* Enable relocated i/o ports */ - /* setSISIDXREG(0x3c4,0x20,~0x10,0x20); */ - setSISIDXREG(SISSR,0x20,~0x10,0x20); + for(i = starta; i <= enda; i++) { + pos = 1 << i; + if(pos < mapsize) + writel(pos, ivideo->video_vbase + pos); + } + + sisfb_post_xgi_delay(ivideo, 150); + + if(readl(ivideo->video_vbase) != 0) + return 0; - /* Clear regs */ + for(i = starta; i <= enda; i++) { + pos = 1 << i; + if(pos < mapsize) { + if(readl(ivideo->video_vbase + pos) != pos) + return 0; + } else + return 0; + } + + return 1; +} + +static void __devinit +sisfb_post_xgi_ramsize(struct sis_video_info *ivideo) +{ + unsigned int buswidth, ranksize, channelab, mapsize; + int i, j, k, l; + u8 reg, sr14; + static const u8 dramsr13[12 * 5] = { + 0x02, 0x0e, 0x0b, 0x80, 0x5d, + 0x02, 0x0e, 0x0a, 0x40, 0x59, + 0x02, 0x0d, 0x0b, 0x40, 0x4d, + 0x02, 0x0e, 0x09, 0x20, 0x55, + 0x02, 0x0d, 0x0a, 0x20, 0x49, + 0x02, 0x0c, 0x0b, 0x20, 0x3d, + 0x02, 0x0e, 0x08, 0x10, 0x51, + 0x02, 0x0d, 0x09, 0x10, 0x45, + 0x02, 0x0c, 0x0a, 0x10, 0x39, + 0x02, 0x0d, 0x08, 0x08, 0x41, + 0x02, 0x0c, 0x09, 0x08, 0x35, + 0x02, 0x0c, 0x08, 0x04, 0x31 + }; + static const u8 dramsr13_4[4 * 5] = { + 0x02, 0x0d, 0x09, 0x40, 0x45, + 0x02, 0x0c, 0x09, 0x20, 0x35, + 0x02, 0x0c, 0x08, 0x10, 0x31, + 0x02, 0x0b, 0x08, 0x08, 0x21 + }; + + /* Enable linear mode, disable 0xa0000 address decoding */ + /* We disable a0000 address decoding, because + * - if running on x86, if the card is disabled, it means + * that another card is in the system. We don't want + * to interphere with that primary card's textmode. + * - if running on non-x86, there usually is no VGA window + * at a0000. + */ + orSISIDXREG(SISSR, 0x20, (0x80 | 0x04)); + + /* Need to map max FB size for finding out about RAM size */ + mapsize = 256 << 20; + sisfb_post_map_vram(ivideo, &mapsize, 32); + + if(!ivideo->video_vbase) { + printk(KERN_ERR "sisfb: Unable to detect RAM size. Setting default.\n"); + outSISIDXREG(SISSR, 0x13, 0x35); + outSISIDXREG(SISSR, 0x14, 0x41); + /* TODO */ + return; + } + + /* Non-interleaving */ + outSISIDXREG(SISSR, 0x15, 0x00); + /* No tiling */ + outSISIDXREG(SISSR, 0x1c, 0x00); + + if(ivideo->chip == XGI_20) { + + channelab = 1; + inSISIDXREG(SISCR, 0x97, reg); + if(!(reg & 0x01)) { /* Single 32/16 */ + buswidth = 32; + outSISIDXREG(SISSR, 0x13, 0xb1); + outSISIDXREG(SISSR, 0x14, 0x52); + sisfb_post_xgi_delay(ivideo, 1); + sr14 = 0x02; + if(sisfb_post_xgi_rwtest(ivideo, 23, 24, mapsize)) + goto bail_out; + + outSISIDXREG(SISSR, 0x13, 0x31); + outSISIDXREG(SISSR, 0x14, 0x42); + sisfb_post_xgi_delay(ivideo, 1); + if(sisfb_post_xgi_rwtest(ivideo, 23, 23, mapsize)) + goto bail_out; + + buswidth = 16; + outSISIDXREG(SISSR, 0x13, 0xb1); + outSISIDXREG(SISSR, 0x14, 0x41); + sisfb_post_xgi_delay(ivideo, 1); + sr14 = 0x01; + if(sisfb_post_xgi_rwtest(ivideo, 22, 23, mapsize)) + goto bail_out; + else + outSISIDXREG(SISSR, 0x13, 0x31); + } else { /* Dual 16/8 */ + buswidth = 16; + outSISIDXREG(SISSR, 0x13, 0xb1); + outSISIDXREG(SISSR, 0x14, 0x41); + sisfb_post_xgi_delay(ivideo, 1); + sr14 = 0x01; + if(sisfb_post_xgi_rwtest(ivideo, 22, 23, mapsize)) + goto bail_out; + + outSISIDXREG(SISSR, 0x13, 0x31); + outSISIDXREG(SISSR, 0x14, 0x31); + sisfb_post_xgi_delay(ivideo, 1); + if(sisfb_post_xgi_rwtest(ivideo, 22, 22, mapsize)) + goto bail_out; + + buswidth = 8; + outSISIDXREG(SISSR, 0x13, 0xb1); + outSISIDXREG(SISSR, 0x14, 0x30); + sisfb_post_xgi_delay(ivideo, 1); + sr14 = 0x00; + if(sisfb_post_xgi_rwtest(ivideo, 21, 22, mapsize)) + goto bail_out; + else + outSISIDXREG(SISSR, 0x13, 0x31); + } + + } else { /* XGI_40 */ + + inSISIDXREG(SISCR, 0x97, reg); + if(!(reg & 0x10)) { + inSISIDXREG(SISSR, 0x39, reg); + reg >>= 1; + } + + if(reg & 0x01) { /* DDRII */ + buswidth = 32; + if(ivideo->revision_id == 2) { + channelab = 2; + outSISIDXREG(SISSR, 0x13, 0xa1); + outSISIDXREG(SISSR, 0x14, 0x44); + sr14 = 0x04; + sisfb_post_xgi_delay(ivideo, 1); + if(sisfb_post_xgi_rwtest(ivideo, 23, 24, mapsize)) + goto bail_out; + + outSISIDXREG(SISSR, 0x13, 0x21); + outSISIDXREG(SISSR, 0x14, 0x34); + if(sisfb_post_xgi_rwtest(ivideo, 22, 23, mapsize)) + goto bail_out; + + channelab = 1; + outSISIDXREG(SISSR, 0x13, 0xa1); + outSISIDXREG(SISSR, 0x14, 0x40); + sr14 = 0x00; + if(sisfb_post_xgi_rwtest(ivideo, 22, 23, mapsize)) + goto bail_out; + + outSISIDXREG(SISSR, 0x13, 0x21); + outSISIDXREG(SISSR, 0x14, 0x30); + } else { + channelab = 3; + outSISIDXREG(SISSR, 0x13, 0xa1); + outSISIDXREG(SISSR, 0x14, 0x4c); + sr14 = 0x0c; + sisfb_post_xgi_delay(ivideo, 1); + if(sisfb_post_xgi_rwtest(ivideo, 23, 25, mapsize)) + goto bail_out; + + channelab = 2; + outSISIDXREG(SISSR, 0x14, 0x48); + sisfb_post_xgi_delay(ivideo, 1); + sr14 = 0x08; + if(sisfb_post_xgi_rwtest(ivideo, 23, 24, mapsize)) + goto bail_out; + + outSISIDXREG(SISSR, 0x13, 0x21); + outSISIDXREG(SISSR, 0x14, 0x3c); + sr14 = 0x0c; + + if(sisfb_post_xgi_rwtest(ivideo, 23, 24, mapsize)) { + channelab = 3; + } else { + channelab = 2; + outSISIDXREG(SISSR, 0x14, 0x38); + sr14 = 0x08; + } + } + sisfb_post_xgi_delay(ivideo, 1); + + } else { /* DDR */ + + buswidth = 64; + if(ivideo->revision_id == 2) { + channelab = 1; + outSISIDXREG(SISSR, 0x13, 0xa1); + outSISIDXREG(SISSR, 0x14, 0x52); + sisfb_post_xgi_delay(ivideo, 1); + sr14 = 0x02; + if(sisfb_post_xgi_rwtest(ivideo, 23, 24, mapsize)) + goto bail_out; + + outSISIDXREG(SISSR, 0x13, 0x21); + outSISIDXREG(SISSR, 0x14, 0x42); + } else { + channelab = 2; + outSISIDXREG(SISSR, 0x13, 0xa1); + outSISIDXREG(SISSR, 0x14, 0x5a); + sisfb_post_xgi_delay(ivideo, 1); + sr14 = 0x0a; + if(sisfb_post_xgi_rwtest(ivideo, 24, 25, mapsize)) + goto bail_out; + + outSISIDXREG(SISSR, 0x13, 0x21); + outSISIDXREG(SISSR, 0x14, 0x4a); + } + sisfb_post_xgi_delay(ivideo, 1); + + } + } + +bail_out: + setSISIDXREG(SISSR, 0x14, 0xf0, sr14); + sisfb_post_xgi_delay(ivideo, 1); + + j = (ivideo->chip == XGI_20) ? 5 : 9; + k = (ivideo->chip == XGI_20) ? 12 : 4; + + for(i = 0; i < k; i++) { + + reg = (ivideo->chip == XGI_20) ? + dramsr13[(i * 5) + 4] : dramsr13_4[(i * 5) + 4]; + setSISIDXREG(SISSR, 0x13, 0x80, reg); + sisfb_post_xgi_delay(ivideo, 50); + + ranksize = (ivideo->chip == XGI_20) ? + dramsr13[(i * 5) + 3] : dramsr13_4[(i * 5) + 3]; + + inSISIDXREG(SISSR, 0x13, reg); + if(reg & 0x80) ranksize <<= 1; + + if(ivideo->chip == XGI_20) { + if(buswidth == 16) ranksize <<= 1; + else if(buswidth == 32) ranksize <<= 2; + } else { + if(buswidth == 64) ranksize <<= 1; + } + + reg = 0; + l = channelab; + if(l == 3) l = 4; + if((ranksize * l) <= 256) { + while((ranksize >>= 1)) reg += 0x10; + } + + if(!reg) continue; + + setSISIDXREG(SISSR, 0x14, 0x0f, (reg & 0xf0)); + sisfb_post_xgi_delay(ivideo, 1); + + if(sisfb_post_xgi_rwtest(ivideo, j, ((reg >> 4) + channelab - 2 + 20), mapsize)) + break; + } + + iounmap(ivideo->video_vbase); +} + +static void __devinit +sisfb_post_xgi_setclocks(struct sis_video_info *ivideo, u8 regb) +{ + u8 v1, v2, v3; + int index; + static const u8 cs90[8 * 3] = { + 0x16, 0x01, 0x01, + 0x3e, 0x03, 0x01, + 0x7c, 0x08, 0x01, + 0x79, 0x06, 0x01, + 0x29, 0x01, 0x81, + 0x5c, 0x23, 0x01, + 0x5c, 0x23, 0x01, + 0x5c, 0x23, 0x01 + }; + static const u8 csb8[8 * 3] = { + 0x5c, 0x23, 0x01, + 0x29, 0x01, 0x01, + 0x7c, 0x08, 0x01, + 0x79, 0x06, 0x01, + 0x29, 0x01, 0x81, + 0x5c, 0x23, 0x01, + 0x5c, 0x23, 0x01, + 0x5c, 0x23, 0x01 + }; + + regb = 0; /* ! */ + + index = regb * 3; + v1 = cs90[index]; v2 = cs90[index + 1]; v3 = cs90[index + 2]; + if(ivideo->haveXGIROM) { + v1 = ivideo->bios_abase[0x90 + index]; + v2 = ivideo->bios_abase[0x90 + index + 1]; + v3 = ivideo->bios_abase[0x90 + index + 2]; + } + outSISIDXREG(SISSR, 0x28, v1); + outSISIDXREG(SISSR, 0x29, v2); + outSISIDXREG(SISSR, 0x2a, v3); + sisfb_post_xgi_delay(ivideo, 0x43); + sisfb_post_xgi_delay(ivideo, 0x43); + sisfb_post_xgi_delay(ivideo, 0x43); + index = regb * 3; + v1 = csb8[index]; v2 = csb8[index + 1]; v3 = csb8[index + 2]; + if(ivideo->haveXGIROM) { + v1 = ivideo->bios_abase[0xb8 + index]; + v2 = ivideo->bios_abase[0xb8 + index + 1]; + v3 = ivideo->bios_abase[0xb8 + index + 2]; + } + outSISIDXREG(SISSR, 0x2e, v1); + outSISIDXREG(SISSR, 0x2f, v2); + outSISIDXREG(SISSR, 0x30, v3); + sisfb_post_xgi_delay(ivideo, 0x43); + sisfb_post_xgi_delay(ivideo, 0x43); + sisfb_post_xgi_delay(ivideo, 0x43); +} + +static int __devinit +sisfb_post_xgi(struct pci_dev *pdev) +{ + struct sis_video_info *ivideo = pci_get_drvdata(pdev); + unsigned char *bios = ivideo->bios_abase; + struct pci_dev *mypdev = NULL; + const u8 *ptr, *ptr2; + u8 v1, v2, v3, v4, v5, reg, ramtype; + u32 rega, regb, regd; + int i, j, k, index; + static const u8 cs78[3] = { 0xf6, 0x0d, 0x00 }; + static const u8 cs76[2] = { 0xa3, 0xfb }; + static const u8 cs7b[3] = { 0xc0, 0x11, 0x00 }; + static const u8 cs158[8] = { + 0x88, 0xaa, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + static const u8 cs160[8] = { + 0x44, 0x77, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + static const u8 cs168[8] = { + 0x48, 0x78, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + static const u8 cs128[3 * 8] = { + 0x90, 0x28, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x77, 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x77, 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + static const u8 cs148[2 * 8] = { + 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + static const u8 cs31a[8 * 4] = { + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + static const u8 cs33a[8 * 4] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + static const u8 cs45a[8 * 2] = { + 0x00, 0x00, 0xa0, 0x00, 0xa0, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + static const u8 cs170[7 * 8] = { + 0x54, 0x32, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x54, 0x43, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0a, 0x05, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x44, 0x34, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x10, 0x0a, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x11, 0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x05, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + static const u8 cs1a8[3 * 8] = { + 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + static const u8 cs100[2 * 8] = { + 0xc4, 0x04, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xc4, 0x04, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + + /* VGA enable */ + reg = inSISREG(SISVGAENABLE) | 0x01; + outSISREG(SISVGAENABLE, reg); + + /* Misc */ + reg = inSISREG(SISMISCR) | 0x01; + outSISREG(SISMISCW, reg); + + /* Unlock SR */ + outSISIDXREG(SISSR, 0x05, 0x86); + inSISIDXREG(SISSR, 0x05, reg); + if(reg != 0xa1) + return 0; + + /* Clear some regs */ for(i = 0; i < 0x22; i++) { - outSISIDXREG(SISSR,(0x06 + i),0x00); + if(0x06 + i == 0x20) continue; + outSISIDXREG(SISSR, 0x06 + i, 0x00); } - v1 = 0x0d; - if( is 330) v1 = 0x0b; - for(i = 0; i < v1; i++) { - outSISIDXREG(SISSR,(0x31 + i),0x00); + for(i = 0; i < 0x0b; i++) { + outSISIDXREG(SISSR, 0x31 + i, 0x00); } for(i = 0; i < 0x10; i++) { - outSISIDXREG(SISCR,(0x30 + i),0x00); - } - - /* Reset clocks */ - reg = inSISREG(SISMISCR); - outSISIDXREG(SISSR,0x28,0x81); - outSISIDXREG(SISSR,0x2A,0x00); - outSISIDXREG(SISSR,0x29,0xE1); - outSISREG(SISMISCW,(reg | 0x0c)); - outSISIDXREG(SISSR,0x2B,0x81); - outSISIDXREG(SISSR,0x2D,0x00); - outSISIDXREG(SISSR,0x2C,0xE1); - outSISIDXREG(SISSR,0x2E,0x81); - outSISIDXREG(SISSR,0x30,0x00); - outSISIDXREG(SISSR,0x2F,0xE1); - SiS_DDC2Delay(....); - outSISREG(SISMISCW,reg); - - /* Get memory type */ - if(ivideo->sishw_ext.UseROM) { - if(ivideo->sishw_ext.pjVirtualRomBase[0x52] & 0x80)) { - memtype = ivideo->sishw_ext.pjVirtualRomBase[0x52]; - } else { - inSISIDXREG(SISSR,0x3a,memtype); - } - memtype &= 0x03; - if( is 330 ) { - if(memtype <= 1) memtype = 0; - else { - inSISIDXREG(SISCR,0x5F,reg); - reg &= 0x30; - switch(reg) { - case 0x00: memtype = 1; break; - case 0x10: memtype = 3; break; - case 0x20: memtype = 3; break; - default: memtype = 2; - } - } - } + outSISIDXREG(SISCR, 0x30 + i, 0x00); } - /* Set clocks */ - v1 = 0x3b; v2 = 0x22; v3 = 0x01; /* Assume 143Mhz MCLK */ - v4 = 0x5c; v5 = 0x23; v6 = 0x01; /* Assume 166Mhz ECLK */ - if(ivideo->sishw_ext.UseROM) { - index = memtype * 5; - rindex = index + 0x54; - v1 = ivideo->sishw_ext.pjVirtualRomBase[rindex++]; - v2 = ivideo->sishw_ext.pjVirtualRomBase[rindex++]; - v3 = ivideo->sishw_ext.pjVirtualRomBase[rindex++]; - rindex = index + 0x68; - v4 = ivideo->sishw_ext.pjVirtualRomBase[rindex++]; - v5 = ivideo->sishw_ext.pjVirtualRomBase[rindex++]; - v6 = ivideo->sishw_ext.pjVirtualRomBase[rindex++]; - } - outSISIDXREG(SISSR,0x28,v1); - outSISIDXREG(SISSR,0x29,v2); - outSISIDXREG(SISSR,0x2a,v3); - if( is 330 ) { - inSISIDXREG(SISSR,0x3a,reg); - reg &= 0x03; - if(reg >= 2) { - ... - } + ptr = cs78; + if(ivideo->haveXGIROM) { + ptr = (const u8 *)&bios[0x78]; + } + for(i = 0; i < 3; i++) { + outSISIDXREG(SISSR, 0x23 + i, ptr[i]); + } + + ptr = cs76; + if(ivideo->haveXGIROM) { + ptr = (const u8 *)&bios[0x76]; + } + for(i = 0; i < 2; i++) { + outSISIDXREG(SISSR, 0x21 + i, ptr[i]); + } + + v1 = 0x18; v2 = 0x00; + if(ivideo->haveXGIROM) { + v1 = bios[0x74]; + v2 = bios[0x75]; + } + outSISIDXREG(SISSR, 0x07, v1); + outSISIDXREG(SISSR, 0x11, 0x0f); + outSISIDXREG(SISSR, 0x1f, v2); + /* PCI linear mode, RelIO enabled, A0000 decoding disabled */ + outSISIDXREG(SISSR, 0x20, 0x80 | 0x20 | 0x04); + outSISIDXREG(SISSR, 0x27, 0x74); + + ptr = cs7b; + if(ivideo->haveXGIROM) { + ptr = (const u8 *)&bios[0x7b]; + } + for(i = 0; i < 3; i++) { + outSISIDXREG(SISSR, 0x31 + i, ptr[i]); } - outSISIDXREG(SISSR,0x2e,v4); - outSISIDXREG(SISSR,0x2f,v5); - outSISIDXREG(SISSR,0x30,v6); - - /* End of comp with 330 */ - - v1 = 0x18; - if(ivideo->sishw_ext.UseROM) v1 = ivideo->sishw_ext.pjVirtualRomBase[0x7c]; - outSISIDXREG(SISSR,0x07,v1); - outSISIDXREG(SISSR,0x11,0x0f); - - v1 = 0x00; v2 = 0x0f; v3 = 0xba; v4 = 0xa9; - v5 = 0xa0; v6 = 0x00; v7 = 0x30; - if(ivideo->sishw_ext.UseROM) { - index = memtype + 0x7d; - v1 = ivideo->sishw_ext.pjVirtualRomBase[index]; - v2 = ivideo->sishw_ext.pjVirtualRomBase[index + 4]; - v3 = ivideo->sishw_ext.pjVirtualRomBase[index + 8]; - v4 = ivideo->sishw_ext.pjVirtualRomBase[index + 12]; - v5 = ivideo->sishw_ext.pjVirtualRomBase[index + 16]; - v6 = ivideo->sishw_ext.pjVirtualRomBase[index + 20]; - v7 = ivideo->sishw_ext.pjVirtualRomBase[index + 24]; - } - outSISIDXREG(SISSR,0x15,v1); /* Ram type (assuming 0, BIOS 0x7d step 4) */ - outSISIDXREG(SISSR,0x16,v2); - outSISIDXREG(SISSR,0x17,v3); - outSISIDXREG(SISSR,0x18,v4); - outSISIDXREG(SISSR,0x19,v5); - outSISIDXREG(SISSR,0x1a,v6); - outSISIDXREG(SISSR,0x1b,v7); - outSISIDXREG(SISSR,0x1c,v8); /* ---- */ - - v1 = 0x77; v2 = 0x77; v3 = 0x00; v4 = 0x5b; v5 = 0x00; - if(ivideo->sishw_ext.UseROM) { - index = memtype + 0xa2; - v1 = ivideo->sishw_ext.pjVirtualRomBase[index]; - v2 = ivideo->sishw_ext.pjVirtualRomBase[index + 4]; - v3 = ivideo->sishw_ext.pjVirtualRomBase[index + 8]; - v4 = ivideo->sishw_ext.pjVirtualRomBase[index + 12]; - v5 = ivideo->sishw_ext.pjVirtualRomBase[index + 16]; - } - outSISIDXREG(SISCR,0x40,v1); - outSISIDXREG(SISCR,0x41,v2); - outSISIDXREG(SISCR,0x42,v3); - outSISIDXREG(SISCR,0x43,v4); - outSISIDXREG(SISCR,0x44,v5); - - if( is 330 ) { - - v1 = 0x; - if(ivideo->sishw_ext.UseROM) { - v1 = ivideo->sishw_ext.pjVirtualRomBase[0xBA]; - } - outSISIDXREG(SISCR,0x59,v1); - - v1 = 0x; v2 = 0x; v3 = 0x; v4 = 0x; - v5 = 0x; v6 = 0x; v7 = 0x; v8 = 0x; - if(ivideo->sishw_ext.UseROM) { - index = memtype + 0xbe; - v1 = ivideo->sishw_ext.pjVirtualRomBase[index]; - v2 = ivideo->sishw_ext.pjVirtualRomBase[index + 4]; - v3 = ivideo->sishw_ext.pjVirtualRomBase[index + 8]; - v4 = ivideo->sishw_ext.pjVirtualRomBase[index + 12]; - v5 = ivideo->sishw_ext.pjVirtualRomBase[index + 16]; - v6 = ivideo->sishw_ext.pjVirtualRomBase[index + 20]; - v7 = ivideo->sishw_ext.pjVirtualRomBase[index + 24]; - v8 = ivideo->sishw_ext.pjVirtualRomBase[index + 28]; - } - outSISIDXREG(SISCR,0x68,v1); - outSISIDXREG(SISCR,0x69,v2); - outSISIDXREG(SISCR,0x6a,v3); - outSISIDXREG(SISCR,0x6b,v4); - outSISIDXREG(SISCR,0x6c,v5); - outSISIDXREG(SISCR,0x6d,v6); - outSISIDXREG(SISCR,0x6e,v7); - outSISIDXREG(SISCR,0x6f,v8); - - v1 = 0x20; - inSISIDXREG(SISSR,0x3b,reg); - - if(!(reg & 0x04)) { - inSISIDXREG(SISCR,0x5F,reg); - reg &= 0x30; - if(reg) v1 = 0x23; - } - outSISIDXREG(SISCR,0x48,v1); - outSISIDXREG(SISCR,0x4c,0x20); - - xx= xxx(); - if(xx >= 1) { - v1 = 0x; - if(ivideo->sishw_ext.UseROM) { - v1 = ivideo->sishw_ext.pjVirtualRomBase[0xBA]; - } - outSISIDXREG(SISCR,0x59,v1); - } + if(ivideo->chip == XGI_40) { + if(ivideo->revision_id == 2) { + setSISIDXREG(SISSR, 0x3b, 0x3f, 0xc0); + } + outSISIDXREG(SISCR, 0x7d, 0xfe); + outSISIDXREG(SISCR, 0x7e, 0x0f); + } + if(ivideo->revision_id == 0) { /* 40 *and* 20? */ + andSISIDXREG(SISCR, 0x58, 0xd7); + inSISIDXREG(SISCR, 0xcb, reg); + if(reg & 0x20) { + setSISIDXREG(SISCR, 0x58, 0xd7, (reg & 0x10) ? 0x08 : 0x20); /* =0x28 Z7 ? */ + } + } + reg = (ivideo->chip == XGI_40) ? 0x20 : 0x00; + setSISIDXREG(SISCR, 0x38, 0x1f, reg); + if(ivideo->chip == XGI_20) { + outSISIDXREG(SISSR, 0x36, 0x70); } else { + outSISIDXREG(SISVID, 0x00, 0x86); + outSISIDXREG(SISVID, 0x32, 0x00); + outSISIDXREG(SISVID, 0x30, 0x00); + outSISIDXREG(SISVID, 0x32, 0x01); + outSISIDXREG(SISVID, 0x30, 0x00); + andSISIDXREG(SISVID, 0x2f, 0xdf); + andSISIDXREG(SISCAP, 0x00, 0x3f); + + outSISIDXREG(SISPART1, 0x2f, 0x01); + outSISIDXREG(SISPART1, 0x00, 0x00); + outSISIDXREG(SISPART1, 0x02, bios[0x7e]); + outSISIDXREG(SISPART1, 0x2e, 0x08); + andSISIDXREG(SISPART1, 0x35, 0x7f); + andSISIDXREG(SISPART1, 0x50, 0xfe); + + inSISIDXREG(SISPART4, 0x00, reg); + if(reg == 1 || reg == 2) { + outSISIDXREG(SISPART2, 0x00, 0x1c); + outSISIDXREG(SISPART4, 0x0d, bios[0x7f]); + outSISIDXREG(SISPART4, 0x0e, bios[0x80]); + outSISIDXREG(SISPART4, 0x10, bios[0x81]); + andSISIDXREG(SISPART4, 0x0f, 0x3f); + + inSISIDXREG(SISPART4, 0x01, reg); + if((reg & 0xf0) >= 0xb0) { + inSISIDXREG(SISPART4, 0x23, reg); + if(reg & 0x20) reg |= 0x40; + outSISIDXREG(SISPART4, 0x23, reg); + reg = (reg & 0x20) ? 0x02 : 0x00; + setSISIDXREG(SISPART1, 0x1e, 0xfd, reg); + } + } - outSISIDXREG(SISCR,0x48,0x23); + v1 = bios[0x77]; + + inSISIDXREG(SISSR, 0x3b, reg); + if(reg & 0x02) { + inSISIDXREG(SISSR, 0x3a, reg); + v2 = (reg & 0x30) >> 3; + if(!(v2 & 0x04)) v2 ^= 0x02; + inSISIDXREG(SISSR, 0x39, reg); + if(reg & 0x80) v2 |= 0x80; + v2 |= 0x01; + + if((mypdev = SIS_PCI_GET_DEVICE(PCI_VENDOR_ID_SI, 0x0730, NULL))) { + SIS_PCI_PUT_DEVICE(mypdev); + if(((v2 & 0x06) == 2) || ((v2 & 0x06) == 4)) + v2 &= 0xf9; + v2 |= 0x08; + v1 &= 0xfe; + } else { + mypdev = SIS_PCI_GET_DEVICE(PCI_VENDOR_ID_SI, 0x0735, NULL); + if(!mypdev) + mypdev = SIS_PCI_GET_DEVICE(PCI_VENDOR_ID_SI, 0x0645, NULL); + if(!mypdev) + mypdev = SIS_PCI_GET_DEVICE(PCI_VENDOR_ID_SI, 0x0650, NULL); + if(mypdev) { + pci_read_config_dword(mypdev, 0x94, ®d); + regd &= 0xfffffeff; + pci_write_config_dword(mypdev, 0x94, regd); + v1 &= 0xfe; + SIS_PCI_PUT_DEVICE(mypdev); + } else if(sisfb_find_host_bridge(ivideo, pdev, PCI_VENDOR_ID_SI)) { + v1 &= 0xfe; + } else if(sisfb_find_host_bridge(ivideo, pdev, 0x1106) || + sisfb_find_host_bridge(ivideo, pdev, 0x1022) || + sisfb_find_host_bridge(ivideo, pdev, 0x700e) || + sisfb_find_host_bridge(ivideo, pdev, 0x10de)) { + if((v2 & 0x06) == 4) + v2 ^= 0x06; + v2 |= 0x08; + } + } + setSISIDXREG(SISCR, 0x5f, 0xf0, v2); + } + outSISIDXREG(SISSR, 0x22, v1); + + if(ivideo->revision_id == 2) { + inSISIDXREG(SISSR, 0x3b, v1); + inSISIDXREG(SISSR, 0x3a, v2); + regd = bios[0x90 + 3] | (bios[0x90 + 4] << 8); + if( (!(v1 & 0x02)) && (v2 & 0x30) && (regd < 0xcf) ) + setSISIDXREG(SISCR, 0x5f, 0xf1, 0x01); + + if((mypdev = SIS_PCI_GET_DEVICE(0x10de, 0x01e0, NULL))) { + /* TODO: set CR5f &0xf1 | 0x01 for version 6570 + * of nforce 2 ROM + */ + if(0) + setSISIDXREG(SISCR, 0x5f, 0xf1, 0x01); + SIS_PCI_PUT_DEVICE(mypdev); + } + } - andSISIDXREG(SISSR,0x16,0x0f); - if(memtype <= 1) { - orSISIDXREG(SISSR,0x16,0x80); - } else { - v1 = 0x0f; - if(ivideo->sishw_ext.UseROM) { - v1 = ivideo->sishw_ext.pjVirtualRomBase[0x81 + memtype]; - } - if(!(v1 & 0x10)) v2 = 0xc0; - else v2 = 0xd0; - orSISIDXREG(SISSR,0x16,v2); - andSISIDXREG(SISSR,0x16,0x0f); - if(!(v1 & 0x10)) v2 = 0x80; - else v2 = 0xA0; - orSISIDXREG(SISSR,0x16,v2); - } - - if(memtype >= 2) { - const u8 sr3cseq1[] = { 0xc0,0xe0,0xf0,0xe0,0xf0,0xa0,0xb0,0xa0,0xb0,0x90,0xd0 }; - const u8 sr3cseq2[] = { 0xc0,0xa0,0xb0,0xa0,0xb0,0xe0,0xf0,0xa0,0xb0,0x90,0xd0 }; - for(i = 0; i < 11; i++) { - outSISIDXREG(SISSR,0x3c,sr3cseq1[i]); - } - outSISIDXREG(SISSR,0x3d,0x00); - outSISIDXREG(SISSR,0x3d,0x04); - SiS_DDC2Delay(0x200); - v1 = inSISIDXREG(SISCR,0xEC); - v2 = inSISIDXREG(SISCR,0xED); - reg1_32 = (v2 << 8) | v1; - outSISIDXREG(SISSR,0x3D,0x00); - for(i = 0; i < 11; i++) { - outSISIDXREG(SISSR,0x3c,sr3cseq2[i]); - } - outSISIDXREG(SISSR,0x3d,0x00); - outSISIDXREG(SISSR,0x3d,0x04); - SiS_DDC2Delay(0x200); - v1 = inSISIDXREG(SISCR,0xEC); - v2 = inSISIDXREG(SISCR,0xED); - reg2_32 = (v2 << 8) | v1; - outSISIDXREG(SISSR,0x3D,0x00); - reg3_32 = reg2_32 << 1; - reg2_32 >>= 1; - reg3_32 += reg2_32; - v1 = 0x40; - if(reg3_32 > reg1_32) v1 = 0x10; - outSISIDXREG(SISCR,0x59,v1); - } + v1 = 0x30; + inSISIDXREG(SISSR, 0x3b, reg); + inSISIDXREG(SISCR, 0x5f, v2); + if((!(reg & 0x02)) && (v2 & 0x0e)) + v1 |= 0x08; + outSISIDXREG(SISSR, 0x27, v1); + + if(bios[0x64] & 0x01) { + setSISIDXREG(SISCR, 0x5f, 0xf0, bios[0x64]); + } + v1 = bios[0x4f7]; + pci_read_config_dword(pdev, 0x50, ®d); + regd = (regd >> 20) & 0x0f; + if(regd == 1) { + v1 &= 0xfc; + orSISIDXREG(SISCR, 0x5f, 0x08); + } + outSISIDXREG(SISCR, 0x48, v1); + + setSISIDXREG(SISCR, 0x47, 0x04, bios[0x4f6] & 0xfb); + setSISIDXREG(SISCR, 0x49, 0xf0, bios[0x4f8] & 0x0f); + setSISIDXREG(SISCR, 0x4a, 0x60, bios[0x4f9] & 0x9f); + setSISIDXREG(SISCR, 0x4b, 0x08, bios[0x4fa] & 0xf7); + setSISIDXREG(SISCR, 0x4c, 0x80, bios[0x4fb] & 0x7f); + outSISIDXREG(SISCR, 0x70, bios[0x4fc]); + setSISIDXREG(SISCR, 0x71, 0xf0, bios[0x4fd] & 0x0f); + outSISIDXREG(SISCR, 0x74, 0xd0); + setSISIDXREG(SISCR, 0x74, 0xcf, bios[0x4fe] & 0x30); + setSISIDXREG(SISCR, 0x75, 0xe0, bios[0x4ff] & 0x1f); + setSISIDXREG(SISCR, 0x76, 0xe0, bios[0x500] & 0x1f); + v1 = bios[0x501]; + if((mypdev = SIS_PCI_GET_DEVICE(0x8086, 0x2530, NULL))) { + v1 = 0xf0; + SIS_PCI_PUT_DEVICE(mypdev); + } + outSISIDXREG(SISCR, 0x77, v1); } - v1 = 0x00; - if(ivideo->sishw_ext.UseROM) { - v1 = ivideo->sishw_ext.pjVirtualRomBase[0x99]; + /* RAM type */ + + regb = 0; /* ! */ + + v1 = 0xff; + if(ivideo->haveXGIROM) { + v1 = bios[0x140 + regb]; } - outSISIDXREG(SISSR,0x1f,v1); + outSISIDXREG(SISCR, 0x6d, v1); - outSISIDXREG(SISSR,0x20,0x20); + ptr = cs128; + if(ivideo->haveXGIROM) { + ptr = (const u8 *)&bios[0x128]; + } + for(i = 0, j = 0; i < 3; i++, j += 8) { + outSISIDXREG(SISCR, 0x68 + i, ptr[j + regb]); + } - v1 = 0xf6; v2 = 0x0d; v3 = 0x33; - if(ivideo->sishw_ext.UseROM) { - v1 = ivideo->sishw_ext.pjVirtualRomBase[0x9c]; - v2 = ivideo->sishw_ext.pjVirtualRomBase[0x9d]; - v3 = ivideo->sishw_ext.pjVirtualRomBase[0x9e]; + ptr = cs31a; + ptr2 = cs33a; + if(ivideo->haveXGIROM) { + index = (ivideo->chip == XGI_20) ? 0x31a : 0x3a6; + ptr = (const u8 *)&bios[index]; + ptr2 = (const u8 *)&bios[index + 0x20]; + } + for(i = 0; i < 2; i++) { + if(i == 0) { + regd = le32_to_cpu(((u32 *)ptr)[regb]); + rega = 0x6b; + } else { + regd = le32_to_cpu(((u32 *)ptr2)[regb]); + rega = 0x6e; + } + reg = 0x00; + for(j = 0; j < 16; j++) { + reg &= 0xf3; + if(regd & 0x01) reg |= 0x04; + if(regd & 0x02) reg |= 0x08; + regd >>= 2; + outSISIDXREG(SISCR, rega, reg); + inSISIDXREG(SISCR, rega, reg); + inSISIDXREG(SISCR, rega, reg); + reg += 0x10; + } } - outSISIDXREG(SISSR,0x23,v1); - outSISIDXREG(SISSR,0x24,v2); - outSISIDXREG(SISSR,0x25,v3); - outSISIDXREG(SISSR,0x21,0x84); - outSISIDXREG(SISSR,0x22,0x00); - outSISIDXREG(SISSR,0x27,0x1f); + andSISIDXREG(SISCR, 0x6e, 0xfc); - v1 = 0x00; v2 = 0x00; - if(ivideo->sishw_ext.UseROM) { - v1 = ivideo->sishw_ext.pjVirtualRomBase[0x9F]; - v2 = ivideo->sishw_ext.pjVirtualRomBase[0xA1]; - } - outSISIDXREG(SISSR,0x31,v1); - outSISIDXREG(SISSR,0x33,v2); - - v1 = 0x11; - if(ivideo->sishw_ext.UseROM) { - v1 = ivideo->sishw_ext.pjVirtualRomBase[0xA0]; - } - v2 = inSISIDXREG(SISPART4,0x00); - if((v2 != 1) && (v2 != 2)) v1 &= 0xef; - outSISIDXREG(SISSR,0x32,v1); - - /* AGP */ - pci_read_config_long(pdev, 0x50, ®1_32); - reg1_32 >>= 20; - reg1_32 &= 0x0f; - if(reg1_32 == 1) { - v1 = 0xAA; v2 = 0x33; - if(ivideo->sishw_ext.UseROM) { - v1 = ivideo->sishw_ext.pjVirtualRomBase[0xF7]; - v2 = ivideo->sishw_ext.pjVirtualRomBase[0x9E]; - } - } else { - v1 = 0x88; v2 = 0x03; - if(ivideo->sishw_ext.UseROM) { - v1 = ivideo->sishw_ext.pjVirtualRomBase[0xF8]; - v2 = ivideo->sishw_ext.pjVirtualRomBase[0xF6]; - } + ptr = NULL; + if(ivideo->haveXGIROM) { + index = (ivideo->chip == XGI_20) ? 0x35a : 0x3e6; + ptr = (const u8 *)&bios[index]; + } + for(i = 0; i < 4; i++) { + setSISIDXREG(SISCR, 0x6e, 0xfc, i); + reg = 0x00; + for(j = 0; j < 2; j++) { + regd = 0; + if(ptr) { + regd = le32_to_cpu(((u32 *)ptr)[regb * 8]); + ptr += 4; + } + /* reg = 0x00; */ + for(k = 0; k < 16; k++) { + reg &= 0xfc; + if(regd & 0x01) reg |= 0x01; + if(regd & 0x02) reg |= 0x02; + regd >>= 2; + outSISIDXREG(SISCR, 0x6f, reg); + inSISIDXREG(SISCR, 0x6f, reg); + inSISIDXREG(SISCR, 0x6f, reg); + reg += 0x08; + } + } } - outSISIDXREG(SISCR,0x49,v1); - outSISIDXREG(SISSR,0x25,v2); - v1 = inSISIDXREG(SISPART4,0x00); - if((v1 == 1) || (v1 == 2)) { - orSISIDXREG(SISPART1,0x2F,0x01); /* Unlock CRT2 */ - outSISIDXREG(SISPART1,0x00,0x00); - v1 = 0x00; - if(ivideo->sishw_ext.UseROM) { - v1 = ivideo->sishw_ext.pjVirtualRomBase[0xb6]; - } - outSISIDXREG(SISPART1,0x02,v1); - outSISIDXREG(SISPART1,0x2E,0x08); - outSISIDXREG(SISPART2,0x00,0x1c); - v1 = 0x40; v2 = 0x00; v3 = 0x80; - if(ivideo->sishw_ext.UseROM) { - v1 = ivideo->sishw_ext.pjVirtualRomBase[0xb7]; - v2 = ivideo->sishw_ext.pjVirtualRomBase[0xb8]; - v3 = ivideo->sishw_ext.pjVirtualRomBase[0xbb]; - } - outSISIDXREG(SISPART4,0x0d,v1); - outSISIDXREG(SISPART4,0x0e,v2); - outSISIDXREG(SISPART4,0x10,v3); - outSISIDXREG(SISPART4,0x0F,0x3F); - - inSISIDXREG(SISPART4,0x01,reg); - if(reg >= 0xb0) { - inSISIDXREG(SISPART4,0x23,reg); - reg &= 0x20; - reg <<= 1; - outSISIDXREG(SISPART4,0x23,reg); - } + ptr = cs148; + if(ivideo->haveXGIROM) { + ptr = (const u8 *)&bios[0x148]; + } + for(i = 0, j = 0; i < 2; i++, j += 8) { + outSISIDXREG(SISCR, 0x80 + i, ptr[j + regb]); } - outSISIDXREG(SISCR,0x37,0x02); /* Why? */ - - outSISIDXREG(SISCR,0x83,0x00); - outSISIDXREG(SISCR,0x90,0x00); - andSISIDXREG(SISSR,0x5B,0xDF); - outSISIDXREG(SISVID,0x00,0x86); - outSISIDXREG(SISVID,0x32,0x00); - outSISIDXREG(SISVID,0x30,0x00); - outSISIDXREG(SISVID,0x32,0x01); - outSISIDXREG(SISVID,0x30,0x00); - orSISIDXREG(SISCR,0x63,0x80); - /* End of Init1 */ - - /* Set Mode 0x2e */ - - /* Ramsize */ - orSISIDXREG(SISSR,0x16,0x0f); - orSISIDXREG(SISSR,0x18,0xA9); - orSISIDXREG(SISSR,0x19,0xA0); - orSISIDXREG(SISSR,0x1B,0x30); - andSISIDXREG(SISSR,0x17,0xF8); - orSISIDXREG(SISSR,0x19,0x03); - andSIDIDXREG(SISSR,0x13,0x00); - /* Need to map max FB size for finding out about RAM size */ - ivideo->video_vbase = ioremap(ivideo->video_base, 0x4000000); - if(ivideo->video_vbase) { - /* Find out about bus width */ - if(memtype <= 1) { - outSISIDXREG(SISSR,0x14,0x02); - andSISIDXREG(SISSR,0x16,0x0F); - orSISIDXREG(SISSR,0x16,0x80); + andSISIDXREG(SISCR, 0x89, 0x8f); - ... + ptr = cs45a; + if(ivideo->haveXGIROM) { + index = (ivideo->chip == XGI_20) ? 0x45a : 0x4e6; + ptr = (const u8 *)&bios[index]; + } + regd = le16_to_cpu(((const u16 *)ptr)[regb]); + reg = 0x80; + for(i = 0; i < 5; i++) { + reg &= 0xfc; + if(regd & 0x01) reg |= 0x01; + if(regd & 0x02) reg |= 0x02; + regd >>= 2; + outSISIDXREG(SISCR, 0x89, reg); + inSISIDXREG(SISCR, 0x89, reg); + inSISIDXREG(SISCR, 0x89, reg); + reg += 0x10; + } - } else { + v1 = 0xb5; v2 = 0x20; v3 = 0xf0; v4 = 0x13; + if(ivideo->haveXGIROM) { + v1 = bios[0x118 + regb]; + v2 = bios[0xf8 + regb]; + v3 = bios[0x120 + regb]; + v4 = bios[0x1ca]; + } + outSISIDXREG(SISCR, 0x45, v1 & 0x0f); + outSISIDXREG(SISCR, 0x99, (v1 >> 4) & 0x07); + orSISIDXREG(SISCR, 0x40, v1 & 0x80); + outSISIDXREG(SISCR, 0x41, v2); - ... + ptr = cs170; + if(ivideo->haveXGIROM) { + ptr = (const u8 *)&bios[0x170]; + } + for(i = 0, j = 0; i < 7; i++, j += 8) { + outSISIDXREG(SISCR, 0x90 + i, ptr[j + regb]); + } - } + outSISIDXREG(SISCR, 0x59, v3); - /* Find out about size */ + ptr = cs1a8; + if(ivideo->haveXGIROM) { + ptr = (const u8 *)&bios[0x1a8]; + } + for(i = 0, j = 0; i < 3; i++, j += 8) { + outSISIDXREG(SISCR, 0xc3 + i, ptr[j + regb]); + } + ptr = cs100; + if(ivideo->haveXGIROM) { + ptr = (const u8 *)&bios[0x100]; + } + for(i = 0, j = 0; i < 2; i++, j += 8) { + outSISIDXREG(SISCR, 0x8a + i, ptr[j + regb]); + } - iounmap(ivideo->video_vbase); - } else { - printk(KERN_DEBUG "sisfb: Failed to map memory for size detection, assuming 8MB\n"); - outSISIDXREG(SISSR,0x14,0x??); /* 8MB, 64bit default */ + outSISIDXREG(SISCR, 0xcf, v4); + + outSISIDXREG(SISCR, 0x83, 0x09); + outSISIDXREG(SISCR, 0x87, 0x00); + + if(ivideo->chip == XGI_40) { + if( (ivideo->revision_id == 1) || + (ivideo->revision_id == 2) ) { + outSISIDXREG(SISCR, 0x8c, 0x87); + } + } + + outSISIDXREG(SISSR, 0x17, 0x00); + outSISIDXREG(SISSR, 0x1a, 0x87); + + if(ivideo->chip == XGI_20) { + outSISIDXREG(SISSR, 0x15, 0x00); + outSISIDXREG(SISSR, 0x1c, 0x00); + } + + ramtype = 0x00; v1 = 0x10; + if(ivideo->haveXGIROM) { + ramtype = bios[0x62]; + v1 = bios[0x1d2]; + } + if(!(ramtype & 0x80)) { + if(ivideo->chip == XGI_20) { + outSISIDXREG(SISCR, 0x97, v1); + inSISIDXREG(SISCR, 0x97, reg); + if(reg & 0x10) { + ramtype = (reg & 0x01) << 1; + } + } else { + inSISIDXREG(SISSR, 0x39, reg); + ramtype = reg & 0x02; + if(!(ramtype)) { + inSISIDXREG(SISSR, 0x3a, reg); + ramtype = (reg >> 1) & 0x01; + } + } + } + ramtype &= 0x07; + + regb = 0; /* ! */ + + switch(ramtype) { + case 0: + sisfb_post_xgi_setclocks(ivideo, regb); + if((ivideo->chip == XGI_20) || + (ivideo->revision_id == 1) || + (ivideo->revision_id == 2)) { + v1 = cs158[regb]; v2 = cs160[regb]; v3 = cs168[regb]; + if(ivideo->haveXGIROM) { + v1 = bios[regb + 0x158]; + v2 = bios[regb + 0x160]; + v3 = bios[regb + 0x168]; + } + outSISIDXREG(SISCR, 0x82, v1); + outSISIDXREG(SISCR, 0x85, v2); + outSISIDXREG(SISCR, 0x86, v3); + } else { + outSISIDXREG(SISCR, 0x82, 0x88); + outSISIDXREG(SISCR, 0x86, 0x00); + inSISIDXREG(SISCR, 0x86, reg); + outSISIDXREG(SISCR, 0x86, 0x88); + inSISIDXREG(SISCR, 0x86, reg); + outSISIDXREG(SISCR, 0x86, bios[regb + 0x168]); + outSISIDXREG(SISCR, 0x82, 0x77); + outSISIDXREG(SISCR, 0x85, 0x00); + inSISIDXREG(SISCR, 0x85, reg); + outSISIDXREG(SISCR, 0x85, 0x88); + inSISIDXREG(SISCR, 0x85, reg); + outSISIDXREG(SISCR, 0x85, bios[regb + 0x160]); + outSISIDXREG(SISCR, 0x82, bios[regb + 0x158]); + } + if(ivideo->chip == XGI_40) { + outSISIDXREG(SISCR, 0x97, 0x00); + } + outSISIDXREG(SISCR, 0x98, 0x01); + outSISIDXREG(SISCR, 0x9a, 0x02); + + outSISIDXREG(SISSR, 0x18, 0x01); + if((ivideo->chip == XGI_20) || + (ivideo->revision_id == 2)) { + outSISIDXREG(SISSR, 0x19, 0x40); + } else { + outSISIDXREG(SISSR, 0x19, 0x20); + } + outSISIDXREG(SISSR, 0x16, 0x00); + outSISIDXREG(SISSR, 0x16, 0x80); + if((ivideo->chip == XGI_20) || (bios[0x1cb] != 0x0c)) { + sisfb_post_xgi_delay(ivideo, 0x43); + sisfb_post_xgi_delay(ivideo, 0x43); + sisfb_post_xgi_delay(ivideo, 0x43); + outSISIDXREG(SISSR, 0x18, 0x00); + if((ivideo->chip == XGI_20) || + (ivideo->revision_id == 2)) { + outSISIDXREG(SISSR, 0x19, 0x40); + } else { + outSISIDXREG(SISSR, 0x19, 0x20); + } + } else if((ivideo->chip == XGI_40) && (bios[0x1cb] == 0x0c)) { + /* outSISIDXREG(SISSR, 0x16, 0x0c); */ /* ? */ + } + outSISIDXREG(SISSR, 0x16, 0x00); + outSISIDXREG(SISSR, 0x16, 0x80); + sisfb_post_xgi_delay(ivideo, 4); + v1 = 0x31; v2 = 0x03; v3 = 0x83; v4 = 0x03; v5 = 0x83; + if(ivideo->haveXGIROM) { + v1 = bios[0xf0]; + index = (ivideo->chip == XGI_20) ? 0x4b2 : 0x53e; + v2 = bios[index]; + v3 = bios[index + 1]; + v4 = bios[index + 2]; + v5 = bios[index + 3]; + } + outSISIDXREG(SISSR, 0x18, v1); + outSISIDXREG(SISSR, 0x19, ((ivideo->chip == XGI_20) ? 0x02 : 0x01)); + outSISIDXREG(SISSR, 0x16, v2); + outSISIDXREG(SISSR, 0x16, v3); + sisfb_post_xgi_delay(ivideo, 0x43); + outSISIDXREG(SISSR, 0x1b, 0x03); + sisfb_post_xgi_delay(ivideo, 0x22); + outSISIDXREG(SISSR, 0x18, v1); + outSISIDXREG(SISSR, 0x19, 0x00); + outSISIDXREG(SISSR, 0x16, v4); + outSISIDXREG(SISSR, 0x16, v5); + outSISIDXREG(SISSR, 0x1b, 0x00); + break; + case 1: + outSISIDXREG(SISCR, 0x82, 0x77); + outSISIDXREG(SISCR, 0x86, 0x00); + inSISIDXREG(SISCR, 0x86, reg); + outSISIDXREG(SISCR, 0x86, 0x88); + inSISIDXREG(SISCR, 0x86, reg); + v1 = cs168[regb]; v2 = cs160[regb]; v3 = cs158[regb]; + if(ivideo->haveXGIROM) { + v1 = bios[regb + 0x168]; + v2 = bios[regb + 0x160]; + v3 = bios[regb + 0x158]; + } + outSISIDXREG(SISCR, 0x86, v1); + outSISIDXREG(SISCR, 0x82, 0x77); + outSISIDXREG(SISCR, 0x85, 0x00); + inSISIDXREG(SISCR, 0x85, reg); + outSISIDXREG(SISCR, 0x85, 0x88); + inSISIDXREG(SISCR, 0x85, reg); + outSISIDXREG(SISCR, 0x85, v2); + outSISIDXREG(SISCR, 0x82, v3); + outSISIDXREG(SISCR, 0x98, 0x01); + outSISIDXREG(SISCR, 0x9a, 0x02); + + outSISIDXREG(SISSR, 0x28, 0x64); + outSISIDXREG(SISSR, 0x29, 0x63); + sisfb_post_xgi_delay(ivideo, 15); + outSISIDXREG(SISSR, 0x18, 0x00); + outSISIDXREG(SISSR, 0x19, 0x20); + outSISIDXREG(SISSR, 0x16, 0x00); + outSISIDXREG(SISSR, 0x16, 0x80); + outSISIDXREG(SISSR, 0x18, 0xc5); + outSISIDXREG(SISSR, 0x19, 0x23); + outSISIDXREG(SISSR, 0x16, 0x00); + outSISIDXREG(SISSR, 0x16, 0x80); + sisfb_post_xgi_delay(ivideo, 1); + outSISIDXREG(SISCR, 0x97,0x11); + sisfb_post_xgi_setclocks(ivideo, regb); + sisfb_post_xgi_delay(ivideo, 0x46); + outSISIDXREG(SISSR, 0x18, 0xc5); + outSISIDXREG(SISSR, 0x19, 0x23); + outSISIDXREG(SISSR, 0x16, 0x00); + outSISIDXREG(SISSR, 0x16, 0x80); + sisfb_post_xgi_delay(ivideo, 1); + outSISIDXREG(SISSR, 0x1b, 0x04); + sisfb_post_xgi_delay(ivideo, 1); + outSISIDXREG(SISSR, 0x1b, 0x00); + sisfb_post_xgi_delay(ivideo, 1); + v1 = 0x31; + if(ivideo->haveXGIROM) { + v1 = bios[0xf0]; + } + outSISIDXREG(SISSR, 0x18, v1); + outSISIDXREG(SISSR, 0x19, 0x06); + outSISIDXREG(SISSR, 0x16, 0x04); + outSISIDXREG(SISSR, 0x16, 0x84); + sisfb_post_xgi_delay(ivideo, 1); + break; + default: + sisfb_post_xgi_setclocks(ivideo, regb); + if((ivideo->chip == XGI_40) && + ((ivideo->revision_id == 1) || + (ivideo->revision_id == 2))) { + outSISIDXREG(SISCR, 0x82, bios[regb + 0x158]); + outSISIDXREG(SISCR, 0x85, bios[regb + 0x160]); + outSISIDXREG(SISCR, 0x86, bios[regb + 0x168]); + } else { + outSISIDXREG(SISCR, 0x82, 0x88); + outSISIDXREG(SISCR, 0x86, 0x00); + inSISIDXREG(SISCR, 0x86, reg); + outSISIDXREG(SISCR, 0x86, 0x88); + outSISIDXREG(SISCR, 0x82, 0x77); + outSISIDXREG(SISCR, 0x85, 0x00); + inSISIDXREG(SISCR, 0x85, reg); + outSISIDXREG(SISCR, 0x85, 0x88); + inSISIDXREG(SISCR, 0x85, reg); + v1 = cs160[regb]; v2 = cs158[regb]; + if(ivideo->haveXGIROM) { + v1 = bios[regb + 0x160]; + v2 = bios[regb + 0x158]; + } + outSISIDXREG(SISCR, 0x85, v1); + outSISIDXREG(SISCR, 0x82, v2); + } + if(ivideo->chip == XGI_40) { + outSISIDXREG(SISCR, 0x97, 0x11); + } + if((ivideo->chip == XGI_40) && (ivideo->revision_id == 2)) { + outSISIDXREG(SISCR, 0x98, 0x01); + } else { + outSISIDXREG(SISCR, 0x98, 0x03); + } + outSISIDXREG(SISCR, 0x9a, 0x02); + + if(ivideo->chip == XGI_40) { + outSISIDXREG(SISSR, 0x18, 0x01); + } else { + outSISIDXREG(SISSR, 0x18, 0x00); + } + outSISIDXREG(SISSR, 0x19, 0x40); + outSISIDXREG(SISSR, 0x16, 0x00); + outSISIDXREG(SISSR, 0x16, 0x80); + if((ivideo->chip == XGI_40) && (bios[0x1cb] != 0x0c)) { + sisfb_post_xgi_delay(ivideo, 0x43); + sisfb_post_xgi_delay(ivideo, 0x43); + sisfb_post_xgi_delay(ivideo, 0x43); + outSISIDXREG(SISSR, 0x18, 0x00); + outSISIDXREG(SISSR, 0x19, 0x40); + outSISIDXREG(SISSR, 0x16, 0x00); + outSISIDXREG(SISSR, 0x16, 0x80); + } + sisfb_post_xgi_delay(ivideo, 4); + v1 = 0x31; + if(ivideo->haveXGIROM) { + v1 = bios[0xf0]; + } + outSISIDXREG(SISSR, 0x18, v1); + outSISIDXREG(SISSR, 0x19, 0x01); + if(ivideo->chip == XGI_40) { + outSISIDXREG(SISSR, 0x16, bios[0x53e]); + outSISIDXREG(SISSR, 0x16, bios[0x53f]); + } else { + outSISIDXREG(SISSR, 0x16, 0x05); + outSISIDXREG(SISSR, 0x16, 0x85); + } + sisfb_post_xgi_delay(ivideo, 0x43); + if(ivideo->chip == XGI_40) { + outSISIDXREG(SISSR, 0x1b, 0x01); + } else { + outSISIDXREG(SISSR, 0x1b, 0x03); + } + sisfb_post_xgi_delay(ivideo, 0x22); + outSISIDXREG(SISSR, 0x18, v1); + outSISIDXREG(SISSR, 0x19, 0x00); + if(ivideo->chip == XGI_40) { + outSISIDXREG(SISSR, 0x16, bios[0x540]); + outSISIDXREG(SISSR, 0x16, bios[0x541]); + } else { + outSISIDXREG(SISSR, 0x16, 0x05); + outSISIDXREG(SISSR, 0x16, 0x85); + } + outSISIDXREG(SISSR, 0x1b, 0x00); + } + + regb = 0; /* ! */ + v1 = 0x03; + if(ivideo->haveXGIROM) { + v1 = bios[0x110 + regb]; + } + outSISIDXREG(SISSR, 0x1b, v1); + + /* RAM size */ + v1 = 0x00; v2 = 0x00; + if(ivideo->haveXGIROM) { + v1 = bios[0x62]; + v2 = bios[0x63]; } + regb = 0; /* ! */ + regd = 1 << regb; + if((v1 & 0x40) && (v2 & regd) && ivideo->haveXGIROM) { + + outSISIDXREG(SISSR, 0x13, bios[regb + 0xe0]); + outSISIDXREG(SISSR, 0x14, bios[regb + 0xe0 + 8]); + + } else { + + /* Set default mode, don't clear screen */ + ivideo->SiS_Pr.SiS_UseOEM = FALSE; + SiS_SetEnableDstn(&ivideo->SiS_Pr, FALSE); + SiS_SetEnableFstn(&ivideo->SiS_Pr, FALSE); + ivideo->curFSTN = ivideo->curDSTN = 0; + ivideo->SiS_Pr.VideoMemorySize = 8 << 20; + SiSSetMode(&ivideo->SiS_Pr, 0x2e | 0x80); + + outSISIDXREG(SISSR, 0x05, 0x86); + + /* Disable read-cache */ + andSISIDXREG(SISSR, 0x21, 0xdf); + sisfb_post_xgi_ramsize(ivideo); + /* Enable read-cache */ + orSISIDXREG(SISSR, 0x21, 0x20); - /* AGP (Missing: Checks for VIA and AMD hosts) */ - v1 = 0xA5; v2 = 0xFB; - if(ivideo->sishw_ext.UseROM) { - v1 = ivideo->sishw_ext.pjVirtualRomBase[0x9A]; - v2 = ivideo->sishw_ext.pjVirtualRomBase[0x9B]; } - outSISIDXREG(SISSR,0x21,v1); - outSISIDXREG(SISSR,0x22,v2); +#if 0 + printk(KERN_DEBUG "-----------------\n"); + for(i = 0; i < 0xff; i++) { + inSISIDXREG(SISCR, i, reg); + printk(KERN_DEBUG "CR%02x(%x) = 0x%02x\n", i, SISCR, reg); + } + for(i = 0; i < 0x40; i++) { + inSISIDXREG(SISSR, i, reg); + printk(KERN_DEBUG "SR%02x(%x) = 0x%02x\n", i, SISSR, reg); + } + printk(KERN_DEBUG "-----------------\n"); #endif - return; + + /* Sense CRT1 */ + if(ivideo->chip == XGI_20) { + orSISIDXREG(SISCR, 0x32, 0x20); + } else { + inSISIDXREG(SISPART4, 0x00, reg); + if((reg == 1) || (reg == 2)) { + sisfb_sense_crt1(ivideo); + } else { + orSISIDXREG(SISCR, 0x32, 0x20); + } + } + + /* Set default mode, don't clear screen */ + ivideo->SiS_Pr.SiS_UseOEM = FALSE; + SiS_SetEnableDstn(&ivideo->SiS_Pr, FALSE); + SiS_SetEnableFstn(&ivideo->SiS_Pr, FALSE); + ivideo->curFSTN = ivideo->curDSTN = 0; + SiSSetMode(&ivideo->SiS_Pr, 0x2e | 0x80); + + outSISIDXREG(SISSR, 0x05, 0x86); + + /* Display off */ + orSISIDXREG(SISSR, 0x01, 0x20); + + /* Save mode number in CR34 */ + outSISIDXREG(SISCR, 0x34, 0x2e); + + /* Let everyone know what the current mode is */ + ivideo->modeprechange = 0x2e; + + if(ivideo->chip == XGI_40) { + inSISIDXREG(SISCR, 0xca, reg); + inSISIDXREG(SISCR, 0xcc, v1); + if((reg & 0x10) && (!(v1 & 0x04))) { + printk(KERN_ERR + "sisfb: Please connect power to the card.\n"); + return 0; + } + } + + return 1; } #endif - -static int __devinit sisfb_probe(struct pci_dev *pdev, - const struct pci_device_id *ent) +static int __devinit +sisfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { - struct sisfb_chip_info *chipinfo = &sisfb_chip_info[ent->driver_data]; - struct sis_video_info *ivideo = NULL; - struct fb_info *sis_fb_info = NULL; + struct sisfb_chip_info *chipinfo = &sisfb_chip_info[ent->driver_data]; + struct sis_video_info *ivideo = NULL; + struct fb_info *sis_fb_info = NULL; u16 reg16; u8 reg; - int sisvga_enabled = 0, i; + int i, ret; - if(sisfb_off) return -ENXIO; + if(sisfb_off) + return -ENXIO; #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,3)) sis_fb_info = framebuffer_alloc(sizeof(*ivideo), &pdev->dev); - if(!sis_fb_info) return -ENOMEM; + if(!sis_fb_info) + return -ENOMEM; #else sis_fb_info = kmalloc(sizeof(*sis_fb_info) + sizeof(*ivideo), GFP_KERNEL); - if(!sis_fb_info) return -ENOMEM; + if(!sis_fb_info) + return -ENOMEM; memset(sis_fb_info, 0, sizeof(*sis_fb_info) + sizeof(*ivideo)); sis_fb_info->par = ((char *)sis_fb_info + sizeof(*sis_fb_info)); #endif @@ -4787,27 +5890,34 @@ static int __devinit sisfb_probe(struct pci_dev *pdev, ivideo = (struct sis_video_info *)sis_fb_info->par; ivideo->memyselfandi = sis_fb_info; + ivideo->sisfb_id = SISFB_ID; + if(card_list == NULL) { - ivideo->cardnumber = 0; + ivideo->cardnumber = 0; } else { - struct sis_video_info *countvideo = card_list; - ivideo->cardnumber = 1; - while((countvideo = countvideo->next) != NULL) ivideo->cardnumber++; + struct sis_video_info *countvideo = card_list; + ivideo->cardnumber = 1; + while((countvideo = countvideo->next) != 0) + ivideo->cardnumber++; } strncpy(ivideo->myid, chipinfo->chip_name, 30); ivideo->warncount = 0; ivideo->chip_id = pdev->device; + ivideo->chip_vendor = pdev->vendor; pci_read_config_byte(pdev, PCI_REVISION_ID, &ivideo->revision_id); - ivideo->sishw_ext.jChipRevision = ivideo->revision_id; + ivideo->SiS_Pr.ChipRevision = ivideo->revision_id; pci_read_config_word(pdev, PCI_COMMAND, ®16); - sisvga_enabled = reg16 & 0x01; + ivideo->sisvga_enabled = reg16 & 0x01; ivideo->pcibus = pdev->bus->number; ivideo->pcislot = PCI_SLOT(pdev->devfn); ivideo->pcifunc = PCI_FUNC(pdev->devfn); ivideo->subsysvendor = pdev->subsystem_vendor; ivideo->subsysdevice = pdev->subsystem_device; +#ifdef SIS_OLD_CONFIG_COMPAT + ivideo->ioctl32registered = 0; +#endif #ifndef MODULE if(sisfb_mode_idx == -1) { @@ -4827,6 +5937,24 @@ static int __devinit sisfb_probe(struct pci_dev *pdev, ivideo->sisfb_thismonitor.datavalid = FALSE; + ivideo->current_base = 0; + + ivideo->engineok = 0; + + ivideo->sisfb_was_boot_device = 0; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12)) + if(pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW) { + if(ivideo->sisvga_enabled) + ivideo->sisfb_was_boot_device = 1; + else { + printk(KERN_DEBUG "sisfb: PCI device is disabled, " + "but marked as boot video device ???\n"); + printk(KERN_DEBUG "sisfb: I will not accept this " + "as the primary VGA device\n"); + } + } +#endif + ivideo->sisfb_parm_mem = sisfb_parm_mem; ivideo->sisfb_accel = sisfb_accel; ivideo->sisfb_ypan = sisfb_ypan; @@ -4846,7 +5974,6 @@ static int __devinit sisfb_probe(struct pci_dev *pdev, ivideo->sisfb_tvstd = sisfb_tvstd; ivideo->tvxpos = sisfb_tvxposoffset; ivideo->tvypos = sisfb_tvyposoffset; - ivideo->sisfb_filter = sisfb_filter; ivideo->sisfb_nocrt2rate = sisfb_nocrt2rate; #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0) ivideo->sisfb_inverse = sisfb_inverse; @@ -4854,7 +5981,7 @@ static int __devinit sisfb_probe(struct pci_dev *pdev, ivideo->refresh_rate = 0; if(ivideo->sisfb_parm_rate != -1) { - ivideo->refresh_rate = ivideo->sisfb_parm_rate; + ivideo->refresh_rate = ivideo->sisfb_parm_rate; } ivideo->SiS_Pr.UsePanelScaler = sisfb_scalelcd; @@ -4863,8 +5990,8 @@ static int __devinit sisfb_probe(struct pci_dev *pdev, ivideo->SiS_Pr.LVDSHL = sisfb_lvdshl; ivideo->SiS_Pr.SiS_Backup70xx = 0xff; - ivideo->SiS_Pr.SiS_CHOverScan = -1; - ivideo->SiS_Pr.SiS_ChSW = FALSE; + ivideo->SiS_Pr.SiS_CHOverScan = -1; + ivideo->SiS_Pr.SiS_ChSW = FALSE; ivideo->SiS_Pr.SiS_UseLCDA = FALSE; ivideo->SiS_Pr.HaveEMI = FALSE; ivideo->SiS_Pr.HaveEMILCD = FALSE; @@ -4873,12 +6000,13 @@ static int __devinit sisfb_probe(struct pci_dev *pdev, ivideo->SiS_Pr.SiS_MyCR63 = 0x63; ivideo->SiS_Pr.PDC = -1; ivideo->SiS_Pr.PDCA = -1; + ivideo->SiS_Pr.DDCPortMixup = FALSE; #ifdef CONFIG_FB_SIS_315 if(ivideo->chip >= SIS_330) { - ivideo->SiS_Pr.SiS_MyCR63 = 0x53; - if(ivideo->chip >= SIS_661) { - ivideo->SiS_Pr.SiS_SensibleSR11 = TRUE; - } + ivideo->SiS_Pr.SiS_MyCR63 = 0x53; + if(ivideo->chip >= SIS_661) { + ivideo->SiS_Pr.SiS_SensibleSR11 = TRUE; + } } #endif @@ -4891,9 +6019,9 @@ static int __devinit sisfb_probe(struct pci_dev *pdev, switch(ivideo->nbridge->device) { #ifdef CONFIG_FB_SIS_300 case PCI_DEVICE_ID_SI_730: - ivideo->chip = SIS_730; + ivideo->chip = SIS_730; strcpy(ivideo->myid, "SiS 730"); - break; + break; #endif #ifdef CONFIG_FB_SIS_315 case PCI_DEVICE_ID_SI_651: @@ -4901,22 +6029,28 @@ static int __devinit sisfb_probe(struct pci_dev *pdev, strcpy(ivideo->myid, "SiS 651"); break; case PCI_DEVICE_ID_SI_740: - ivideo->chip = SIS_740; + ivideo->chip = SIS_740; strcpy(ivideo->myid, "SiS 740"); break; case PCI_DEVICE_ID_SI_661: - ivideo->chip = SIS_661; + ivideo->chip = SIS_661; strcpy(ivideo->myid, "SiS 661"); break; case PCI_DEVICE_ID_SI_741: - ivideo->chip = SIS_741; + ivideo->chip = SIS_741; strcpy(ivideo->myid, "SiS 741"); break; case PCI_DEVICE_ID_SI_760: - ivideo->chip = SIS_760; + ivideo->chip = SIS_760; strcpy(ivideo->myid, "SiS 760"); break; + case PCI_DEVICE_ID_SI_761: + ivideo->chip = SIS_761; + strcpy(ivideo->myid, "SiS 761"); + break; #endif + default: + break; } } @@ -4924,71 +6058,83 @@ static int __devinit sisfb_probe(struct pci_dev *pdev, strcpy(sis_fb_info->modename, ivideo->myid); #endif - ivideo->sishw_ext.jChipType = ivideo->chip; + ivideo->SiS_Pr.ChipType = ivideo->chip; + + ivideo->SiS_Pr.ivideo = (void *)ivideo; #ifdef CONFIG_FB_SIS_315 - if((ivideo->sishw_ext.jChipType == SIS_315PRO) || - (ivideo->sishw_ext.jChipType == SIS_315)) { - ivideo->sishw_ext.jChipType = SIS_315H; + if((ivideo->SiS_Pr.ChipType == SIS_315PRO) || + (ivideo->SiS_Pr.ChipType == SIS_315)) { + ivideo->SiS_Pr.ChipType = SIS_315H; } #endif + if(!ivideo->sisvga_enabled) { + if(pci_enable_device(pdev)) { + if(ivideo->nbridge) SIS_PCI_PUT_DEVICE(ivideo->nbridge); + pci_set_drvdata(pdev, NULL); + kfree(sis_fb_info); + return -EIO; + } + } + ivideo->video_base = pci_resource_start(pdev, 0); ivideo->mmio_base = pci_resource_start(pdev, 1); ivideo->mmio_size = pci_resource_len(pdev, 1); ivideo->SiS_Pr.RelIO = pci_resource_start(pdev, 2) + 0x30; - ivideo->sishw_ext.ulIOAddress = ivideo->vga_base = ivideo->SiS_Pr.RelIO; + ivideo->SiS_Pr.IOAddress = ivideo->vga_base = ivideo->SiS_Pr.RelIO; - if(!sisvga_enabled) { - if(pci_enable_device(pdev)) { - pci_set_drvdata(pdev, NULL); - kfree(sis_fb_info); - return -EIO; - } - } - - SiSRegInit(&ivideo->SiS_Pr, ivideo->sishw_ext.ulIOAddress); + SiSRegInit(&ivideo->SiS_Pr, ivideo->SiS_Pr.IOAddress); #ifdef CONFIG_FB_SIS_300 /* Find PCI systems for Chrontel/GPIO communication setup */ if(ivideo->chip == SIS_630) { - i=0; - do { - if(mychswtable[i].subsysVendor == ivideo->subsysvendor && - mychswtable[i].subsysCard == ivideo->subsysdevice) { - ivideo->SiS_Pr.SiS_ChSW = TRUE; - printk(KERN_DEBUG "sisfb: Identified [%s %s] requiring Chrontel/GPIO setup\n", - mychswtable[i].vendorName, mychswtable[i].cardName); - break; - } - i++; - } while(mychswtable[i].subsysVendor != 0); + i = 0; + do { + if(mychswtable[i].subsysVendor == ivideo->subsysvendor && + mychswtable[i].subsysCard == ivideo->subsysdevice) { + ivideo->SiS_Pr.SiS_ChSW = TRUE; + printk(KERN_DEBUG "sisfb: Identified [%s %s] " + "requiring Chrontel/GPIO setup\n", + mychswtable[i].vendorName, + mychswtable[i].cardName); + ivideo->lpcdev = SIS_PCI_GET_DEVICE(PCI_VENDOR_ID_SI, 0x0008, NULL); + break; + } + i++; + } while(mychswtable[i].subsysVendor != 0); + } +#endif + +#ifdef CONFIG_FB_SIS_315 + if((ivideo->chip == SIS_760) && (ivideo->nbridge)) { + ivideo->lpcdev = SIS_PCI_GET_SLOT(ivideo->nbridge->bus, (2 << 3)); } #endif - outSISIDXREG(SISSR, 0x05, 0x86); + outSISIDXREG(SISSR, 0x05, 0x86); - if( (!sisvga_enabled) + if( (!ivideo->sisvga_enabled) #if !defined(__i386__) && !defined(__x86_64__) - || (sisfb_resetcard) + || (sisfb_resetcard) #endif - ) { - for(i = 0x30; i <= 0x3f; i++) { - outSISIDXREG(SISCR,i,0x00); - } + ) { + for(i = 0x30; i <= 0x3f; i++) { + outSISIDXREG(SISCR, i, 0x00); + } } /* Find out about current video mode */ ivideo->modeprechange = 0x03; - inSISIDXREG(SISCR,0x34,reg); + inSISIDXREG(SISCR, 0x34, reg); if(reg & 0x7f) { ivideo->modeprechange = reg & 0x7f; - } else if(sisvga_enabled) { + } else if(ivideo->sisvga_enabled) { #if defined(__i386__) || defined(__x86_64__) - unsigned char SIS_IOTYPE2 *tt = ioremap(0, 0x1000); + unsigned char SIS_IOTYPE2 *tt = ioremap(0x400, 0x100); if(tt) { - ivideo->modeprechange = readb(tt + 0x449); - iounmap(tt); + ivideo->modeprechange = readb(tt + 0x49); + iounmap(tt); } #endif } @@ -4996,219 +6142,221 @@ static int __devinit sisfb_probe(struct pci_dev *pdev, #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) #ifdef MODULE if((reg & 0x80) && (reg != 0xff)) { - if((sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni]) != 0xFF) { - printk(KERN_INFO "sisfb: Cannot initialize display mode, X server is active\n"); - pci_set_drvdata(pdev, NULL); - kfree(sis_fb_info); - return -EBUSY; - } + if((sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni]) + != 0xFF) { + printk(KERN_INFO "sisfb: Cannot initialize display mode, " + "X server is active\n"); + ret = -EBUSY; + goto error_4; + } } -#endif #endif - - ivideo->sishw_ext.bIntegratedMMEnabled = TRUE; -#ifdef CONFIG_FB_SIS_300 - if(ivideo->sisvga_engine == SIS_300_VGA) { - if(ivideo->chip != SIS_300) { - inSISIDXREG(SISSR, 0x1a, reg); - if(!(reg & 0x10)) { - ivideo->sishw_ext.bIntegratedMMEnabled = FALSE; - } - } - } #endif + /* Search and copy ROM image */ ivideo->bios_abase = NULL; + ivideo->SiS_Pr.VirtualRomBase = NULL; + ivideo->SiS_Pr.UseROM = FALSE; + ivideo->haveXGIROM = ivideo->SiS_Pr.SiS_XGIROM = FALSE; if(ivideo->sisfb_userom) { - ivideo->sishw_ext.pjVirtualRomBase = sis_find_rom(pdev); - ivideo->bios_abase = ivideo->sishw_ext.pjVirtualRomBase; - if(ivideo->sishw_ext.pjVirtualRomBase) { - printk(KERN_INFO "sisfb: Video ROM found and copied\n"); - ivideo->sishw_ext.UseROM = TRUE; - } else { - ivideo->sishw_ext.UseROM = FALSE; - printk(KERN_INFO "sisfb: Video ROM not found\n"); - } + ivideo->SiS_Pr.VirtualRomBase = sisfb_find_rom(pdev); + ivideo->bios_abase = ivideo->SiS_Pr.VirtualRomBase; + ivideo->SiS_Pr.UseROM = (ivideo->SiS_Pr.VirtualRomBase) ? TRUE : FALSE; + printk(KERN_INFO "sisfb: Video ROM %sfound\n", + ivideo->SiS_Pr.UseROM ? "" : "not "); + if((ivideo->SiS_Pr.UseROM) && (ivideo->chip >= XGI_20)) { + ivideo->SiS_Pr.UseROM = FALSE; + ivideo->haveXGIROM = ivideo->SiS_Pr.SiS_XGIROM = TRUE; + if( (ivideo->revision_id == 2) && + (!(ivideo->bios_abase[0x1d1] & 0x01)) ) { + ivideo->SiS_Pr.DDCPortMixup = TRUE; + } + } } else { - ivideo->sishw_ext.pjVirtualRomBase = NULL; - ivideo->sishw_ext.UseROM = FALSE; - printk(KERN_INFO "sisfb: Video ROM usage disabled\n"); + printk(KERN_INFO "sisfb: Video ROM usage disabled\n"); } - /* Find systems for special custom timing */ + /* Find systems for special custom timing */ if(ivideo->SiS_Pr.SiS_CustomT == CUT_NONE) { - int j; - unsigned char *biosver = NULL; - unsigned char *biosdate = NULL; - BOOLEAN footprint; - u32 chksum = 0; - - if(ivideo->sishw_ext.UseROM) { - biosver = ivideo->sishw_ext.pjVirtualRomBase + 0x06; - biosdate = ivideo->sishw_ext.pjVirtualRomBase + 0x2c; - for(i=0; i<32768; i++) chksum += ivideo->sishw_ext.pjVirtualRomBase[i]; - } - - i=0; - do { - if( (mycustomttable[i].chipID == ivideo->chip) && - ((!strlen(mycustomttable[i].biosversion)) || - (ivideo->sishw_ext.UseROM && - (!strncmp(mycustomttable[i].biosversion, biosver, strlen(mycustomttable[i].biosversion))))) && - ((!strlen(mycustomttable[i].biosdate)) || - (ivideo->sishw_ext.UseROM && - (!strncmp(mycustomttable[i].biosdate, biosdate, strlen(mycustomttable[i].biosdate))))) && - ((!mycustomttable[i].bioschksum) || - (ivideo->sishw_ext.UseROM && - (mycustomttable[i].bioschksum == chksum))) && - (mycustomttable[i].pcisubsysvendor == ivideo->subsysvendor) && - (mycustomttable[i].pcisubsyscard == ivideo->subsysdevice) ) { - footprint = TRUE; - for(j = 0; j < 5; j++) { - if(mycustomttable[i].biosFootprintAddr[j]) { - if(ivideo->sishw_ext.UseROM) { - if(ivideo->sishw_ext.pjVirtualRomBase[mycustomttable[i].biosFootprintAddr[j]] != - mycustomttable[i].biosFootprintData[j]) { - footprint = FALSE; - } - } else footprint = FALSE; - } - } - if(footprint) { - ivideo->SiS_Pr.SiS_CustomT = mycustomttable[i].SpecialID; - printk(KERN_DEBUG "sisfb: Identified [%s %s], special timing applies\n", - mycustomttable[i].vendorName, - mycustomttable[i].cardName); - printk(KERN_DEBUG "sisfb: [specialtiming parameter name: %s]\n", - mycustomttable[i].optionName); - break; - } - } - i++; - } while(mycustomttable[i].chipID); + sisfb_detect_custom_timing(ivideo); } -#ifdef CONFIG_FB_SIS_300 - if(ivideo->sisvga_engine == SIS_300_VGA) { - if( (!sisvga_enabled) + /* POST card in case this has not been done by the BIOS */ + if( (!ivideo->sisvga_enabled) #if !defined(__i386__) && !defined(__x86_64__) - || (sisfb_resetcard) + || (sisfb_resetcard) #endif - ) { + ) { +#ifdef CONFIG_FB_SIS_300 + if(ivideo->sisvga_engine == SIS_300_VGA) { if(ivideo->chip == SIS_300) { sisfb_post_sis300(pdev); + ivideo->sisfb_can_post = 1; } } - } #endif #ifdef CONFIG_FB_SIS_315 - if(ivideo->sisvga_engine == SIS_315_VGA) { - if( (!sisvga_enabled) -#if !defined(__i386__) && !defined(__x86_64__) - || (sisfb_resetcard) -#endif - ) { - if((ivideo->chip == SIS_315H) || + if(ivideo->sisvga_engine == SIS_315_VGA) { + int result = 1; + /* if((ivideo->chip == SIS_315H) || (ivideo->chip == SIS_315) || (ivideo->chip == SIS_315PRO) || (ivideo->chip == SIS_330)) { sisfb_post_sis315330(pdev); + } else */ if(ivideo->chip == XGI_20) { + result = sisfb_post_xgi(pdev); + ivideo->sisfb_can_post = 1; + } else if((ivideo->chip == XGI_40) && ivideo->haveXGIROM) { + result = sisfb_post_xgi(pdev); + ivideo->sisfb_can_post = 1; + } else { + printk(KERN_INFO "sisfb: Card is not " + "POSTed and sisfb can't do this either.\n"); + } + if(!result) { + printk(KERN_ERR "sisfb: Failed to POST card\n"); + ret = -ENODEV; + goto error_3; } } - } #endif + } + ivideo->sisfb_card_posted = 1; + + /* Find out about RAM size */ if(sisfb_get_dram_size(ivideo)) { - printk(KERN_INFO "sisfb: Fatal error: Unable to determine RAM size.\n"); - if(ivideo->bios_abase) vfree(ivideo->bios_abase); - pci_set_drvdata(pdev, NULL); - kfree(sis_fb_info); - return -ENODEV; + printk(KERN_INFO "sisfb: Fatal error: Unable to determine VRAM size.\n"); + ret = -ENODEV; + goto error_3; } + + /* Enable PCI addressing and MMIO */ if((ivideo->sisfb_mode_idx < 0) || ((sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni]) != 0xFF)) { - /* Enable PCI_LINEAR_ADDRESSING and MMIO_ENABLE */ - orSISIDXREG(SISSR, IND_SIS_PCI_ADDRESS_SET, (SIS_PCI_ADDR_ENABLE | SIS_MEM_MAP_IO_ENABLE)); - /* Enable 2D accelerator engine */ - orSISIDXREG(SISSR, IND_SIS_MODULE_ENABLE, SIS_ENABLE_2D); + /* Enable PCI_LINEAR_ADDRESSING and MMIO_ENABLE */ + orSISIDXREG(SISSR, IND_SIS_PCI_ADDRESS_SET, (SIS_PCI_ADDR_ENABLE | SIS_MEM_MAP_IO_ENABLE)); + /* Enable 2D accelerator engine */ + orSISIDXREG(SISSR, IND_SIS_MODULE_ENABLE, SIS_ENABLE_2D); } if(sisfb_pdc != 0xff) { - if(ivideo->sisvga_engine == SIS_300_VGA) sisfb_pdc &= 0x3c; - else sisfb_pdc &= 0x1f; - ivideo->SiS_Pr.PDC = sisfb_pdc; + if(ivideo->sisvga_engine == SIS_300_VGA) + sisfb_pdc &= 0x3c; + else + sisfb_pdc &= 0x1f; + ivideo->SiS_Pr.PDC = sisfb_pdc; } #ifdef CONFIG_FB_SIS_315 if(ivideo->sisvga_engine == SIS_315_VGA) { - if(sisfb_pdca != 0xff) ivideo->SiS_Pr.PDCA = sisfb_pdca & 0x1f; + if(sisfb_pdca != 0xff) + ivideo->SiS_Pr.PDCA = sisfb_pdca & 0x1f; } #endif if(!request_mem_region(ivideo->video_base, ivideo->video_size, "sisfb FB")) { - printk(KERN_ERR "sisfb: Fatal error: Unable to reserve frame buffer memory\n"); + printk(KERN_ERR "sisfb: Fatal error: Unable to reserve %dMB framebuffer memory\n", + (int)(ivideo->video_size >> 20)); printk(KERN_ERR "sisfb: Is there another framebuffer driver active?\n"); - if(ivideo->bios_abase) vfree(ivideo->bios_abase); - pci_set_drvdata(pdev, NULL); - kfree(sis_fb_info); - return -ENODEV; + ret = -ENODEV; + goto error_3; } if(!request_mem_region(ivideo->mmio_base, ivideo->mmio_size, "sisfb MMIO")) { printk(KERN_ERR "sisfb: Fatal error: Unable to reserve MMIO region\n"); - release_mem_region(ivideo->video_base, ivideo->video_size); - if(ivideo->bios_abase) vfree(ivideo->bios_abase); - pci_set_drvdata(pdev, NULL); - kfree(sis_fb_info); - return -ENODEV; + ret = -ENODEV; + goto error_2; } ivideo->video_vbase = ioremap(ivideo->video_base, ivideo->video_size); - ivideo->sishw_ext.pjVideoMemoryAddress = ivideo->video_vbase; + ivideo->SiS_Pr.VideoMemoryAddress = ivideo->video_vbase; if(!ivideo->video_vbase) { - printk(KERN_ERR "sisfb: Fatal error: Unable to map frame buffer memory\n"); - release_mem_region(ivideo->video_base, ivideo->video_size); - release_mem_region(ivideo->mmio_base, ivideo->mmio_size); - if(ivideo->bios_abase) vfree(ivideo->bios_abase); - pci_set_drvdata(pdev, NULL); - kfree(sis_fb_info); - return -ENODEV; + printk(KERN_ERR "sisfb: Fatal error: Unable to map framebuffer memory\n"); + ret = -ENODEV; + goto error_1; } ivideo->mmio_vbase = ioremap(ivideo->mmio_base, ivideo->mmio_size); if(!ivideo->mmio_vbase) { - printk(KERN_ERR "sisfb: Fatal error: Unable to map MMIO region\n"); - iounmap(ivideo->video_vbase); - release_mem_region(ivideo->video_base, ivideo->video_size); - release_mem_region(ivideo->mmio_base, ivideo->mmio_size); - if(ivideo->bios_abase) vfree(ivideo->bios_abase); + printk(KERN_ERR "sisfb: Fatal error: Unable to map MMIO region\n"); + ret = -ENODEV; +error_0: iounmap(ivideo->video_vbase); +error_1: release_mem_region(ivideo->video_base, ivideo->video_size); +error_2: release_mem_region(ivideo->mmio_base, ivideo->mmio_size); +error_3: vfree(ivideo->bios_abase); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) +error_4: +#endif + if(ivideo->lpcdev) + SIS_PCI_PUT_DEVICE(ivideo->lpcdev); + if(ivideo->nbridge) + SIS_PCI_PUT_DEVICE(ivideo->nbridge); pci_set_drvdata(pdev, NULL); - kfree(sis_fb_info); - return -ENODEV; + if(!ivideo->sisvga_enabled) + pci_disable_device(pdev); + kfree(sis_fb_info); + return ret; } - printk(KERN_INFO "sisfb: Framebuffer at 0x%lx, mapped to 0x%lx, size %ldk\n", - ivideo->video_base, (ULONG)ivideo->video_vbase, ivideo->video_size / 1024); + printk(KERN_INFO "sisfb: Video RAM at 0x%lx, mapped to 0x%lx, size %ldk\n", + ivideo->video_base, (unsigned long)ivideo->video_vbase, ivideo->video_size / 1024); + + if(ivideo->video_offset) { + printk(KERN_INFO "sisfb: Viewport offset %ldk\n", + ivideo->video_offset / 1024); + } printk(KERN_INFO "sisfb: MMIO at 0x%lx, mapped to 0x%lx, size %ldk\n", - ivideo->mmio_base, (ULONG)ivideo->mmio_vbase, ivideo->mmio_size / 1024); + ivideo->mmio_base, (unsigned long)ivideo->mmio_vbase, ivideo->mmio_size / 1024); + + /* Determine the size of the command queue */ + if(ivideo->sisvga_engine == SIS_300_VGA) { + ivideo->cmdQueueSize = TURBO_QUEUE_AREA_SIZE; + } else { + if(ivideo->chip == XGI_20) { + ivideo->cmdQueueSize = COMMAND_QUEUE_AREA_SIZE_Z7; + } else { + ivideo->cmdQueueSize = COMMAND_QUEUE_AREA_SIZE; + } + } + + /* Engines are no longer initialized here; this is + * now done after the first mode-switch (if the + * submitted var has its acceleration flags set). + */ + + /* Calculate the base of the (unused) hw cursor */ + ivideo->hwcursor_vbase = ivideo->video_vbase + + ivideo->video_size + - ivideo->cmdQueueSize + - ivideo->hwcursor_size; + ivideo->caps |= HW_CURSOR_CAP; + + /* Initialize offscreen memory manager */ if((ivideo->havenoheap = sisfb_heap_init(ivideo))) { printk(KERN_WARNING "sisfb: Failed to initialize offscreen memory heap\n"); } /* Used for clearing the screen only, therefore respect our mem limit */ - ivideo->sishw_ext.ulVideoMemorySize = ivideo->sisfb_mem; + ivideo->SiS_Pr.VideoMemoryAddress += ivideo->video_offset; + ivideo->SiS_Pr.VideoMemorySize = ivideo->sisfb_mem; - ivideo->mtrr = 0; + ivideo->mtrr = -1; ivideo->vbflags = 0; ivideo->lcddefmodeidx = DEFAULT_LCDMODE; ivideo->tvdefmodeidx = DEFAULT_TVMODE; ivideo->defmodeidx = DEFAULT_MODE; - ivideo->newrom = SiSDetermineROMLayout661(&ivideo->SiS_Pr, &ivideo->sishw_ext); + ivideo->newrom = 0; + if(ivideo->chip < XGI_20) { + if(ivideo->bios_abase) { + ivideo->newrom = SiSDetermineROMLayout661(&ivideo->SiS_Pr); + } + } if((ivideo->sisfb_mode_idx < 0) || ((sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni]) != 0xFF)) { @@ -5217,192 +6365,57 @@ static int __devinit sisfb_probe(struct pci_dev *pdev, sisfb_get_VB_type(ivideo); - if(ivideo->vbflags & VB_VIDEOBRIDGE) { + if(ivideo->vbflags2 & VB2_VIDEOBRIDGE) { sisfb_detect_VB_connect(ivideo); } ivideo->currentvbflags = ivideo->vbflags & (VB_VIDEOBRIDGE | TV_STANDARD); - if(ivideo->vbflags & VB_VIDEOBRIDGE) { - if(ivideo->sisfb_crt2type != -1) { - if((ivideo->sisfb_crt2type == CRT2_LCD) && (ivideo->vbflags & CRT2_LCD)) { - ivideo->currentvbflags |= CRT2_LCD; - } else if(ivideo->sisfb_crt2type != CRT2_LCD) { - ivideo->currentvbflags |= ivideo->sisfb_crt2type; - } - } else { - /* Chrontel 700x TV detection often unreliable, therefore use a - * different default order on such machines - */ - if((ivideo->sisvga_engine == SIS_300_VGA) && (ivideo->vbflags & VB_CHRONTEL)) { - if(ivideo->vbflags & CRT2_LCD) ivideo->currentvbflags |= CRT2_LCD; - else if(ivideo->vbflags & CRT2_TV) ivideo->currentvbflags |= CRT2_TV; - else if(ivideo->vbflags & CRT2_VGA) ivideo->currentvbflags |= CRT2_VGA; - } else { - if(ivideo->vbflags & CRT2_TV) ivideo->currentvbflags |= CRT2_TV; - else if(ivideo->vbflags & CRT2_LCD) ivideo->currentvbflags |= CRT2_LCD; - else if(ivideo->vbflags & CRT2_VGA) ivideo->currentvbflags |= CRT2_VGA; - } - } + /* Decide on which CRT2 device to use */ + if(ivideo->vbflags2 & VB2_VIDEOBRIDGE) { + if(ivideo->sisfb_crt2type != -1) { + if((ivideo->sisfb_crt2type == CRT2_LCD) && + (ivideo->vbflags & CRT2_LCD)) { + ivideo->currentvbflags |= CRT2_LCD; + } else if(ivideo->sisfb_crt2type != CRT2_LCD) { + ivideo->currentvbflags |= ivideo->sisfb_crt2type; + } + } else { + /* Chrontel 700x TV detection often unreliable, therefore + * use a different default order on such machines + */ + if((ivideo->sisvga_engine == SIS_300_VGA) && + (ivideo->vbflags2 & VB2_CHRONTEL)) { + if(ivideo->vbflags & CRT2_LCD) + ivideo->currentvbflags |= CRT2_LCD; + else if(ivideo->vbflags & CRT2_TV) + ivideo->currentvbflags |= CRT2_TV; + else if(ivideo->vbflags & CRT2_VGA) + ivideo->currentvbflags |= CRT2_VGA; + } else { + if(ivideo->vbflags & CRT2_TV) + ivideo->currentvbflags |= CRT2_TV; + else if(ivideo->vbflags & CRT2_LCD) + ivideo->currentvbflags |= CRT2_LCD; + else if(ivideo->vbflags & CRT2_VGA) + ivideo->currentvbflags |= CRT2_VGA; + } + } } if(ivideo->vbflags & CRT2_LCD) { - inSISIDXREG(SISCR, 0x36, reg); - reg &= 0x0f; - if(ivideo->sisvga_engine == SIS_300_VGA) { - ivideo->CRT2LCDType = sis300paneltype[reg]; - } else if(ivideo->chip >= SIS_661) { - ivideo->CRT2LCDType = sis661paneltype[reg]; - } else { - ivideo->CRT2LCDType = sis310paneltype[reg]; - if((ivideo->chip == SIS_550) && (sisfb_fstn)) { - if((ivideo->CRT2LCDType != LCD_640x480_2) && - (ivideo->CRT2LCDType != LCD_640x480_3)) { - ivideo->CRT2LCDType = LCD_320x480; - } - } - } - if(ivideo->CRT2LCDType == LCD_UNKNOWN) { - /* For broken BIOSes: Assume 1024x768, RGB18 */ - ivideo->CRT2LCDType = LCD_1024x768; - setSISIDXREG(SISCR,0x36,0xf0,0x02); - setSISIDXREG(SISCR,0x37,0xee,0x01); - printk(KERN_DEBUG "sisfb: Invalid panel ID (%02x), assuming 1024x768, RGB18\n", reg); - } - for(i = 0; i < SIS_LCD_NUMBER; i++) { - if(ivideo->CRT2LCDType == sis_lcd_data[i].lcdtype) { - ivideo->lcdxres = sis_lcd_data[i].xres; - ivideo->lcdyres = sis_lcd_data[i].yres; - ivideo->lcddefmodeidx = sis_lcd_data[i].default_mode_idx; - break; - } - } - if(ivideo->SiS_Pr.SiS_CustomT == CUT_BARCO1366) { - ivideo->lcdxres = 1360; ivideo->lcdyres = 1024; ivideo->lcddefmodeidx = 99; - } else if(ivideo->SiS_Pr.SiS_CustomT == CUT_PANEL848) { - ivideo->lcdxres = 848; ivideo->lcdyres = 480; ivideo->lcddefmodeidx = 47; - } - printk(KERN_DEBUG "sisfb: Detected %dx%d flat panel\n", - ivideo->lcdxres, ivideo->lcdyres); - } - -#ifdef CONFIG_FB_SIS_300 - /* Save the current PanelDelayCompensation if the LCD is currently used */ - if(ivideo->sisvga_engine == SIS_300_VGA) { - if(ivideo->vbflags & (VB_LVDS | VB_30xBDH)) { - int tmp; - inSISIDXREG(SISCR,0x30,tmp); - if(tmp & 0x20) { - /* Currently on LCD? If yes, read current pdc */ - inSISIDXREG(SISPART1,0x13,ivideo->detectedpdc); - ivideo->detectedpdc &= 0x3c; - if(ivideo->SiS_Pr.PDC == -1) { - /* Let option override detection */ - ivideo->SiS_Pr.PDC = ivideo->detectedpdc; - } - printk(KERN_INFO "sisfb: Detected LCD PDC 0x%02x\n", - ivideo->detectedpdc); - } - if((ivideo->SiS_Pr.PDC != -1) && (ivideo->SiS_Pr.PDC != ivideo->detectedpdc)) { - printk(KERN_INFO "sisfb: Using LCD PDC 0x%02x\n", - ivideo->SiS_Pr.PDC); - } - } + sisfb_detect_lcd_type(ivideo); } -#endif - -#ifdef CONFIG_FB_SIS_315 - if(ivideo->sisvga_engine == SIS_315_VGA) { - - /* Try to find about LCDA */ - if(ivideo->vbflags & (VB_301C | VB_302B | VB_301LV | VB_302LV | VB_302ELV)) { - int tmp; - inSISIDXREG(SISPART1,0x13,tmp); - if(tmp & 0x04) { - ivideo->SiS_Pr.SiS_UseLCDA = TRUE; - ivideo->detectedlcda = 0x03; - } - } - - /* Save PDC */ - if(ivideo->vbflags & (VB_301LV | VB_302LV | VB_302ELV)) { - int tmp; - inSISIDXREG(SISCR,0x30,tmp); - if((tmp & 0x20) || (ivideo->detectedlcda != 0xff)) { - /* Currently on LCD? If yes, read current pdc */ - u8 pdc; - inSISIDXREG(SISPART1,0x2D,pdc); - ivideo->detectedpdc = (pdc & 0x0f) << 1; - ivideo->detectedpdca = (pdc & 0xf0) >> 3; - inSISIDXREG(SISPART1,0x35,pdc); - ivideo->detectedpdc |= ((pdc >> 7) & 0x01); - inSISIDXREG(SISPART1,0x20,pdc); - ivideo->detectedpdca |= ((pdc >> 6) & 0x01); - if(ivideo->newrom) { - /* New ROM invalidates other PDC resp. */ - if(ivideo->detectedlcda != 0xff) { - ivideo->detectedpdc = 0xff; - } else { - ivideo->detectedpdca = 0xff; - } - } - if(ivideo->SiS_Pr.PDC == -1) { - if(ivideo->detectedpdc != 0xff) { - ivideo->SiS_Pr.PDC = ivideo->detectedpdc; - } - } - if(ivideo->SiS_Pr.PDCA == -1) { - if(ivideo->detectedpdca != 0xff) { - ivideo->SiS_Pr.PDCA = ivideo->detectedpdca; - } - } - if(ivideo->detectedpdc != 0xff) { - printk(KERN_INFO - "sisfb: Detected LCD PDC 0x%02x (for LCD=CRT2)\n", - ivideo->detectedpdc); - } - if(ivideo->detectedpdca != 0xff) { - printk(KERN_INFO - "sisfb: Detected LCD PDC1 0x%02x (for LCD=CRT1)\n", - ivideo->detectedpdca); - } - } - - /* Save EMI */ - if(ivideo->vbflags & (VB_302LV | VB_302ELV)) { - inSISIDXREG(SISPART4,0x30,ivideo->SiS_Pr.EMI_30); - inSISIDXREG(SISPART4,0x31,ivideo->SiS_Pr.EMI_31); - inSISIDXREG(SISPART4,0x32,ivideo->SiS_Pr.EMI_32); - inSISIDXREG(SISPART4,0x33,ivideo->SiS_Pr.EMI_33); - ivideo->SiS_Pr.HaveEMI = TRUE; - if((tmp & 0x20) || (ivideo->detectedlcda != 0xff)) { - ivideo->SiS_Pr.HaveEMILCD = TRUE; - } - } - } - - /* Let user override detected PDCs (all bridges) */ - if(ivideo->vbflags & (VB_301B | VB_301C | VB_301LV | VB_302LV | VB_302ELV)) { - if((ivideo->SiS_Pr.PDC != -1) && (ivideo->SiS_Pr.PDC != ivideo->detectedpdc)) { - printk(KERN_INFO "sisfb: Using LCD PDC 0x%02x (for LCD=CRT2)\n", - ivideo->SiS_Pr.PDC); - } - if((ivideo->SiS_Pr.PDCA != -1) && (ivideo->SiS_Pr.PDCA != ivideo->detectedpdca)) { - printk(KERN_INFO "sisfb: Using LCD PDC1 0x%02x (for LCD=CRT1)\n", - ivideo->SiS_Pr.PDCA); - } - } - } -#endif + sisfb_save_pdc_emi(ivideo); if(!ivideo->sisfb_crt1off) { - sisfb_handle_ddc(ivideo, &ivideo->sisfb_thismonitor, 0); + sisfb_handle_ddc(ivideo, &ivideo->sisfb_thismonitor, 0); } else { - if((ivideo->vbflags & (VB_301|VB_301B|VB_301C|VB_302B)) && - (ivideo->vbflags & (CRT2_VGA | CRT2_LCD))) { - sisfb_handle_ddc(ivideo, &ivideo->sisfb_thismonitor, 1); - } + if((ivideo->vbflags2 & VB2_SISTMDSBRIDGE) && + (ivideo->vbflags & (CRT2_VGA | CRT2_LCD))) { + sisfb_handle_ddc(ivideo, &ivideo->sisfb_thismonitor, 1); + } } if(ivideo->sisfb_mode_idx >= 0) { @@ -5434,7 +6447,8 @@ static int __devinit sisfb_probe(struct pci_dev *pdev, ivideo->mode_no = sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni]; if(ivideo->refresh_rate != 0) { - sisfb_search_refresh_rate(ivideo, ivideo->refresh_rate, ivideo->sisfb_mode_idx); + sisfb_search_refresh_rate(ivideo, ivideo->refresh_rate, + ivideo->sisfb_mode_idx); } if(ivideo->rate_idx == 0) { @@ -5443,9 +6457,12 @@ static int __devinit sisfb_probe(struct pci_dev *pdev, } if(ivideo->sisfb_thismonitor.datavalid) { - if(!sisfb_verify_rate(ivideo, &ivideo->sisfb_thismonitor, ivideo->sisfb_mode_idx, - ivideo->rate_idx, ivideo->refresh_rate)) { - printk(KERN_INFO "sisfb: WARNING: Refresh rate exceeds monitor specs!\n"); + if(!sisfb_verify_rate(ivideo, &ivideo->sisfb_thismonitor, + ivideo->sisfb_mode_idx, + ivideo->rate_idx, + ivideo->refresh_rate)) { + printk(KERN_INFO "sisfb: WARNING: Refresh rate " + "exceeds monitor specs!\n"); } } @@ -5454,28 +6471,34 @@ static int __devinit sisfb_probe(struct pci_dev *pdev, ivideo->video_height = sisbios_mode[ivideo->sisfb_mode_idx].yres; sisfb_set_vparms(ivideo); - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - /* ---------------- For 2.4: Now switch the mode ------------------ */ - - printk(KERN_INFO "sisfb: Mode is %dx%dx%d (%dHz)\n", - ivideo->video_width, ivideo->video_height, ivideo->video_bpp, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) + + /* ---------------- For 2.4: Now switch the mode ------------------ */ + + printk(KERN_INFO "sisfb: Setting mode %dx%dx%d (%dHz)\n", + ivideo->video_width, ivideo->video_height, ivideo->video_bpp, ivideo->refresh_rate); + /* Determine whether or not acceleration is to be + * used. Need to know before pre/post_set_mode() + */ + ivideo->accel = 0; + ivideo->default_var.accel_flags &= ~FB_ACCELF_TEXT; + if(ivideo->sisfb_accel) { + ivideo->accel = -1; + ivideo->default_var.accel_flags |= FB_ACCELF_TEXT; + } + + /* Now switch the mode */ sisfb_pre_setmode(ivideo); - if(SiSSetMode(&ivideo->SiS_Pr, &ivideo->sishw_ext, ivideo->mode_no) == 0) { + if(SiSSetMode(&ivideo->SiS_Pr, ivideo->mode_no) == 0) { printk(KERN_ERR "sisfb: Fatal error: Setting mode[0x%x] failed\n", ivideo->mode_no); - iounmap(ivideo->video_vbase); + ret = -EINVAL; iounmap(ivideo->mmio_vbase); - release_mem_region(ivideo->video_base, ivideo->video_size); - release_mem_region(ivideo->mmio_base, ivideo->mmio_size); - if(ivideo->bios_abase) vfree(ivideo->bios_abase); - pci_set_drvdata(pdev, NULL); - kfree(sis_fb_info); - return -EINVAL; + goto error_0; } outSISIDXREG(SISSR, IND_SIS_PASSWORD, SIS_PASSWORD); @@ -5488,18 +6511,17 @@ static int __devinit sisfb_probe(struct pci_dev *pdev, /* Force reset of x virtual in crtc_to_var */ ivideo->default_var.xres_virtual = 0; + /* Copy mode timing to var */ sisfb_crtc_to_var(ivideo, &ivideo->default_var); + /* Find out about screen pitch */ sisfb_calc_pitch(ivideo, &ivideo->default_var); sisfb_set_pitch(ivideo); - ivideo->accel = 0; - if(ivideo->sisfb_accel) { - ivideo->accel = -1; - ivideo->default_var.accel_flags |= FB_ACCELF_TEXT; - } + /* Init the accelerator (does nothing currently) */ sisfb_initaccel(ivideo); - + + /* Init some fbinfo entries */ sis_fb_info->node = -1; sis_fb_info->flags = FBINFO_FLAG_DEFAULT; sis_fb_info->fbops = &sisfb_ops; @@ -5515,41 +6537,42 @@ static int __devinit sisfb_probe(struct pci_dev *pdev, #else /* --------- For 2.6: Setup a somewhat sane default var ------------ */ printk(KERN_INFO "sisfb: Default mode is %dx%dx%d (%dHz)\n", - ivideo->video_width, ivideo->video_height, ivideo->video_bpp, + ivideo->video_width, ivideo->video_height, ivideo->video_bpp, ivideo->refresh_rate); + /* Set up the default var according to chosen default display mode */ ivideo->default_var.xres = ivideo->default_var.xres_virtual = ivideo->video_width; ivideo->default_var.yres = ivideo->default_var.yres_virtual = ivideo->video_height; ivideo->default_var.bits_per_pixel = ivideo->video_bpp; sisfb_bpp_to_var(ivideo, &ivideo->default_var); - + ivideo->default_var.pixclock = (u32) (1000000000 / - sisfb_mode_rate_to_dclock(&ivideo->SiS_Pr, &ivideo->sishw_ext, - ivideo->mode_no, ivideo->rate_idx)); - - if(sisfb_mode_rate_to_ddata(&ivideo->SiS_Pr, &ivideo->sishw_ext, - ivideo->mode_no, ivideo->rate_idx, &ivideo->default_var)) { - if((ivideo->default_var.vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) { - ivideo->default_var.pixclock <<= 1; - } - } + sisfb_mode_rate_to_dclock(&ivideo->SiS_Pr, ivideo->mode_no, ivideo->rate_idx)); + + if(sisfb_mode_rate_to_ddata(&ivideo->SiS_Pr, ivideo->mode_no, + ivideo->rate_idx, &ivideo->default_var)) { + if((ivideo->default_var.vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) { + ivideo->default_var.pixclock <<= 1; + } + } if(ivideo->sisfb_ypan) { - /* Maximize regardless of sisfb_max at startup */ - ivideo->default_var.yres_virtual = sisfb_calc_maxyres(ivideo, &ivideo->default_var); - if(ivideo->default_var.yres_virtual < ivideo->default_var.yres) { - ivideo->default_var.yres_virtual = ivideo->default_var.yres; - } + /* Maximize regardless of sisfb_max at startup */ + ivideo->default_var.yres_virtual = + sisfb_calc_maxyres(ivideo, &ivideo->default_var); + if(ivideo->default_var.yres_virtual < ivideo->default_var.yres) { + ivideo->default_var.yres_virtual = ivideo->default_var.yres; + } } sisfb_calc_pitch(ivideo, &ivideo->default_var); ivideo->accel = 0; if(ivideo->sisfb_accel) { - ivideo->accel = -1; + ivideo->accel = -1; #ifdef STUPID_ACCELF_TEXT_SHIT - ivideo->default_var.accel_flags |= FB_ACCELF_TEXT; + ivideo->default_var.accel_flags |= FB_ACCELF_TEXT; #endif } sisfb_initaccel(ivideo); @@ -5566,21 +6589,21 @@ static int __devinit sisfb_probe(struct pci_dev *pdev, #endif sis_fb_info->var = ivideo->default_var; sis_fb_info->fix = ivideo->sisfb_fix; - sis_fb_info->screen_base = ivideo->video_vbase; + sis_fb_info->screen_base = ivideo->video_vbase + ivideo->video_offset; sis_fb_info->fbops = &sisfb_ops; sisfb_get_fix(&sis_fb_info->fix, -1, sis_fb_info); sis_fb_info->pseudo_palette = ivideo->pseudo_palette; - + fb_alloc_cmap(&sis_fb_info->cmap, 256 , 0); #endif /* 2.6 */ - printk(KERN_DEBUG "sisfb: Initial vbflags 0x%lx\n", (unsigned long)ivideo->vbflags); + printk(KERN_DEBUG "sisfb: Initial vbflags 0x%x\n", (int)ivideo->vbflags); #ifdef CONFIG_MTRR ivideo->mtrr = mtrr_add(ivideo->video_base, ivideo->video_size, MTRR_TYPE_WRCOMB, 1); - if(!ivideo->mtrr) { + if(ivideo->mtrr < 0) { printk(KERN_DEBUG "sisfb: Failed to add MTRRs\n"); } #endif @@ -5591,14 +6614,9 @@ static int __devinit sisfb_probe(struct pci_dev *pdev, if(register_framebuffer(sis_fb_info) < 0) { printk(KERN_ERR "sisfb: Fatal error: Failed to register framebuffer\n"); - iounmap(ivideo->video_vbase); + ret = -EINVAL; iounmap(ivideo->mmio_vbase); - release_mem_region(ivideo->video_base, ivideo->video_size); - release_mem_region(ivideo->mmio_base, ivideo->mmio_size); - if(ivideo->bios_abase) vfree(ivideo->bios_abase); - pci_set_drvdata(pdev, NULL); - kfree(sis_fb_info); - return -EINVAL; + goto error_0; } ivideo->registered = 1; @@ -5607,21 +6625,47 @@ static int __devinit sisfb_probe(struct pci_dev *pdev, ivideo->next = card_list; card_list = ivideo; +#ifdef SIS_OLD_CONFIG_COMPAT + { + int ret; + /* Our ioctls are all "32/64bit compatible" */ + ret = register_ioctl32_conversion(FBIO_ALLOC, NULL); + ret |= register_ioctl32_conversion(FBIO_FREE, NULL); + ret |= register_ioctl32_conversion(FBIOGET_VBLANK, NULL); + ret |= register_ioctl32_conversion(SISFB_GET_INFO_SIZE, NULL); + ret |= register_ioctl32_conversion(SISFB_GET_INFO, NULL); + ret |= register_ioctl32_conversion(SISFB_GET_TVPOSOFFSET, NULL); + ret |= register_ioctl32_conversion(SISFB_SET_TVPOSOFFSET, NULL); + ret |= register_ioctl32_conversion(SISFB_SET_LOCK, NULL); + ret |= register_ioctl32_conversion(SISFB_GET_VBRSTATUS, NULL); + ret |= register_ioctl32_conversion(SISFB_GET_AUTOMAXIMIZE, NULL); + ret |= register_ioctl32_conversion(SISFB_SET_AUTOMAXIMIZE, NULL); + ret |= register_ioctl32_conversion(SISFB_COMMAND, NULL); + if(ret) + printk(KERN_ERR + "sisfb: Error registering ioctl32 translations\n"); + else + ivideo->ioctl32registered = 1; + } +#endif + printk(KERN_INFO "sisfb: 2D acceleration is %s, y-panning %s\n", - ivideo->sisfb_accel ? "enabled" : "disabled", - ivideo->sisfb_ypan ? - (ivideo->sisfb_max ? "enabled (auto-max)" : "enabled (no auto-max)") : "disabled"); + ivideo->sisfb_accel ? "enabled" : "disabled", + ivideo->sisfb_ypan ? + (ivideo->sisfb_max ? "enabled (auto-max)" : + "enabled (no auto-max)") : + "disabled"); - printk(KERN_INFO "fb%d: %s frame buffer device, Version %d.%d.%d\n", + printk(KERN_INFO "fb%d: %s frame buffer device version %d.%d.%d\n", #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - GET_FB_IDX(sis_fb_info->node), + GET_FB_IDX(sis_fb_info->node), #else - sis_fb_info->node, + sis_fb_info->node, #endif ivideo->myid, VER_MAJOR, VER_MINOR, VER_LEVEL); - printk(KERN_INFO "sisfb: (C) 2001-2004 Thomas Winischhofer.\n"); + printk(KERN_INFO "sisfb: Copyright (C) 2001-2005 Thomas Winischhofer\n"); } /* if mode = "none" */ @@ -5634,26 +6678,62 @@ static int __devinit sisfb_probe(struct pci_dev *pdev, static void __devexit sisfb_remove(struct pci_dev *pdev) { - struct sis_video_info *ivideo = pci_get_drvdata(pdev); - struct fb_info *sis_fb_info = ivideo->memyselfandi; - int registered = ivideo->registered; + struct sis_video_info *ivideo = pci_get_drvdata(pdev); + struct fb_info *sis_fb_info = ivideo->memyselfandi; + int registered = ivideo->registered; + int modechanged = ivideo->modechanged; + +#ifdef SIS_OLD_CONFIG_COMPAT + if(ivideo->ioctl32registered) { + int ret; + ret = unregister_ioctl32_conversion(FBIO_ALLOC); + ret |= unregister_ioctl32_conversion(FBIO_FREE); + ret |= unregister_ioctl32_conversion(FBIOGET_VBLANK); + ret |= unregister_ioctl32_conversion(SISFB_GET_INFO_SIZE); + ret |= unregister_ioctl32_conversion(SISFB_GET_INFO); + ret |= unregister_ioctl32_conversion(SISFB_GET_TVPOSOFFSET); + ret |= unregister_ioctl32_conversion(SISFB_SET_TVPOSOFFSET); + ret |= unregister_ioctl32_conversion(SISFB_SET_LOCK); + ret |= unregister_ioctl32_conversion(SISFB_GET_VBRSTATUS); + ret |= unregister_ioctl32_conversion(SISFB_GET_AUTOMAXIMIZE); + ret |= unregister_ioctl32_conversion(SISFB_SET_AUTOMAXIMIZE); + ret |= unregister_ioctl32_conversion(SISFB_COMMAND); + if(ret) + printk(KERN_ERR + "sisfb: Error unregistering ioctl32 translations\n"); + } +#endif /* Unmap */ - iounmap(ivideo->video_vbase); iounmap(ivideo->mmio_vbase); - vfree(ivideo->bios_abase); + iounmap(ivideo->video_vbase); /* Release mem regions */ release_mem_region(ivideo->video_base, ivideo->video_size); release_mem_region(ivideo->mmio_base, ivideo->mmio_size); + vfree(ivideo->bios_abase); + + if(ivideo->lpcdev) + SIS_PCI_PUT_DEVICE(ivideo->lpcdev); + + if(ivideo->nbridge) + SIS_PCI_PUT_DEVICE(ivideo->nbridge); + #ifdef CONFIG_MTRR /* Release MTRR region */ - if(ivideo->mtrr) { + if(ivideo->mtrr >= 0) mtrr_del(ivideo->mtrr, ivideo->video_base, ivideo->video_size); - } #endif + pci_set_drvdata(pdev, NULL); + + /* If device was disabled when starting, disable + * it when quitting. + */ + if(!ivideo->sisvga_enabled) + pci_disable_device(pdev); + /* Unregister the framebuffer */ if(ivideo->registered) { unregister_framebuffer(sis_fb_info); @@ -5664,7 +6744,7 @@ static void __devexit sisfb_remove(struct pci_dev *pdev) #endif } - pci_set_drvdata(pdev, NULL); + /* OK, our ivideo is gone for good from here. */ /* TODO: Restore the initial mode * This sounds easy but is as good as impossible @@ -5673,15 +6753,15 @@ static void __devexit sisfb_remove(struct pci_dev *pdev) * from machine to machine. Depends on the type * of integration between chipset and bridge. */ - if(registered) { - printk(KERN_INFO "sisfb: Restoring of text mode not supported yet\n"); - } + if(registered && modechanged) + printk(KERN_INFO + "sisfb: Restoring of text mode not supported yet\n"); }; static struct pci_driver sisfb_driver = { .name = "sisfb", .id_table = sisfb_pci_table, - .probe = sisfb_probe, + .probe = sisfb_probe, .remove = __devexit_p(sisfb_remove) }; @@ -5693,10 +6773,11 @@ SISINITSTATIC int __init sisfb_init(void) if(fb_get_options("sisfb", &options)) return -ENODEV; + sisfb_setup(options); #endif #endif - return(pci_register_driver(&sisfb_driver)); + return pci_register_driver(&sisfb_driver); } #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,8) @@ -5711,36 +6792,129 @@ module_init(sisfb_init); #ifdef MODULE -static char *mode = NULL; -static int vesa = -1; -static unsigned int rate = 0; -static unsigned int crt1off = 1; -static unsigned int mem = 0; -static char *forcecrt2type = NULL; -static int forcecrt1 = -1; -static int pdc = -1; -static int pdc1 = -1; -static int noaccel = -1; -static int noypan = -1; -static int nomax = -1; +static char *mode = NULL; +static int vesa = -1; +static unsigned int rate = 0; +static unsigned int crt1off = 1; +static unsigned int mem = 0; +static char *forcecrt2type = NULL; +static int forcecrt1 = -1; +static int pdc = -1; +static int pdc1 = -1; +static int noaccel = -1; +static int noypan = -1; +static int nomax = -1; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) +static int inverse = 0; +#endif +static int userom = -1; +static int useoem = -1; +static char *tvstandard = NULL; +static int nocrt2rate = 0; +static int scalelcd = -1; +static char *specialtiming = NULL; +static int lvdshl = -1; +static int tvxposoffset = 0, tvyposoffset = 0; +#if !defined(__i386__) && !defined(__x86_64__) +static int resetcard = 0; +static int videoram = 0; +#endif + +static int __init sisfb_init_module(void) +{ + sisfb_setdefaultparms(); + + if(rate) + sisfb_parm_rate = rate; + + if((scalelcd == 0) || (scalelcd == 1)) + sisfb_scalelcd = scalelcd ^ 1; + + /* Need to check crt2 type first for fstn/dstn */ + + if(forcecrt2type) + sisfb_search_crt2type(forcecrt2type); + + if(tvstandard) + sisfb_search_tvstd(tvstandard); + + if(mode) + sisfb_search_mode(mode, FALSE); + else if(vesa != -1) + sisfb_search_vesamode(vesa, FALSE); + + sisfb_crt1off = (crt1off == 0) ? 1 : 0; + + sisfb_forcecrt1 = forcecrt1; + if(forcecrt1 == 1) + sisfb_crt1off = 0; + else if(forcecrt1 == 0) + sisfb_crt1off = 1; + + if(noaccel == 1) + sisfb_accel = 0; + else if(noaccel == 0) + sisfb_accel = 1; + + if(noypan == 1) + sisfb_ypan = 0; + else if(noypan == 0) + sisfb_ypan = 1; + + if(nomax == 1) + sisfb_max = 0; + else if(nomax == 0) + sisfb_max = 1; + #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -static int inverse = 0; -#endif -static int userom = -1; -static int useoem = -1; -static char *tvstandard = NULL; -static int nocrt2rate = 0; -static int scalelcd = -1; -static char *specialtiming = NULL; -static int lvdshl = -1; -static int tvxposoffset = 0, tvyposoffset = 0; -static int filter = -1; + if(inverse) sisfb_inverse = 1; +#endif + + if(mem) + sisfb_parm_mem = mem; + + if(userom != -1) + sisfb_userom = userom; + + if(useoem != -1) + sisfb_useoem = useoem; + + if(pdc != -1) + sisfb_pdc = (pdc & 0x7f); + + if(pdc1 != -1) + sisfb_pdca = (pdc1 & 0x1f); + + sisfb_nocrt2rate = nocrt2rate; + + if(specialtiming) + sisfb_search_specialtiming(specialtiming); + + if((lvdshl >= 0) && (lvdshl <= 3)) + sisfb_lvdshl = lvdshl; + + sisfb_tvxposoffset = tvxposoffset; + sisfb_tvyposoffset = tvyposoffset; + #if !defined(__i386__) && !defined(__x86_64__) -static int resetcard = 0; -static int videoram = 0; + sisfb_resetcard = (resetcard) ? 1 : 0; + if(videoram) + sisfb_videoram = videoram; #endif -MODULE_DESCRIPTION("SiS 300/540/630/730/315/550/65x/661/74x/330/760 framebuffer device driver"); + return sisfb_init(); +} + +static void __exit sisfb_remove_module(void) +{ + pci_unregister_driver(&sisfb_driver); + printk(KERN_DEBUG "sisfb: Module unloaded\n"); +} + +module_init(sisfb_init_module); +module_exit(sisfb_remove_module); + +MODULE_DESCRIPTION("SiS 300/540/630/730/315/55x/65x/661/74x/330/76x/34x, XGI V3XT/V5/V8/Z7 framebuffer device driver"); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Thomas Winischhofer <thomas@winischhofer.net>, Others"); @@ -5764,7 +6938,6 @@ MODULE_PARM(lvdshl, "i"); MODULE_PARM(tvstandard, "s"); MODULE_PARM(tvxposoffset, "i"); MODULE_PARM(tvyposoffset, "i"); -MODULE_PARM(filter, "i"); MODULE_PARM(nocrt2rate, "i"); MODULE_PARM(inverse, "i"); #if !defined(__i386__) && !defined(__x86_64__) @@ -5793,7 +6966,6 @@ module_param(lvdshl, int, 0); module_param(tvstandard, charp, 0); module_param(tvxposoffset, int, 0); module_param(tvyposoffset, int, 0); -module_param(filter, int, 0); module_param(nocrt2rate, int, 0); #if !defined(__i386__) && !defined(__x86_64__) module_param(resetcard, int, 0); @@ -5801,25 +6973,35 @@ module_param(videoram, int, 0); #endif #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) MODULE_PARM_DESC(mem, "\nDetermines the beginning of the video memory heap in KB. This heap is used\n" "for video RAM management for eg. DRM/DRI. On 300 series, the default depends\n" "on the amount of video RAM available. If 8MB of video RAM or less is available,\n" "the heap starts at 4096KB, if between 8 and 16MB are available at 8192KB,\n" - "otherwise at 12288KB. On 315 and Xabre series, the heap size is 32KB by default.\n" + "otherwise at 12288KB. On 315/330/340 series, the heap size is 32KB by default.\n" "The value is to be specified without 'KB' and must match the MaxXFBMem setting\n" "for XFree86 4.x/X.org 6.7 and later.\n"); +#else +MODULE_PARM_DESC(mem, + "\nDetermines the beginning of the video memory heap in KB. This heap is used\n" + "for video RAM management for eg. DRM/DRI. On 300 series, the default depends\n" + "on the amount of video RAM available. If 8MB of video RAM or less is available,\n" + "the heap starts at 4096KB, if between 8 and 16MB are available at 8192KB,\n" + "otherwise at 12288KB. On 315/330/340 series, the heap size is 32KB by default.\n" + "The value is to be specified without 'KB'.\n"); +#endif MODULE_PARM_DESC(noaccel, - "\nIf set to anything other than 0, 2D acceleration will be disabled.\n" + "\nIf set to anything other than 0, 2D acceleration will be disabled.\n" "(default: 0)\n"); MODULE_PARM_DESC(noypan, - "\nIf set to anything other than 0, y-panning will be disabled and scrolling\n" - "will be performed by redrawing the screen. (default: 0)\n"); + "\nIf set to anything other than 0, y-panning will be disabled and scrolling\n" + "will be performed by redrawing the screen. (default: 0)\n"); MODULE_PARM_DESC(nomax, - "\nIf y-panning is enabled, sisfb will by default use the entire available video\n" + "\nIf y-panning is enabled, sisfb will by default use the entire available video\n" "memory for the virtual screen in order to optimize scrolling performance. If\n" "this is set to anything other than 0, sisfb will not do this and thereby \n" "enable the user to positively specify a virtual Y size of the screen using\n" @@ -5827,30 +7009,30 @@ MODULE_PARM_DESC(nomax, #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) MODULE_PARM_DESC(mode, - "\nSelects the desired display mode in the format [X]x[Y]x[Depth], eg.\n" - "1024x768x16. Other formats supported include XxY-Depth and\n" - "XxY-Depth@Rate. If the parameter is only one (decimal or hexadecimal)\n" + "\nSelects the desired display mode in the format [X]x[Y]x[Depth], eg.\n" + "1024x768x16. Other formats supported include XxY-Depth and\n" + "XxY-Depth@Rate. If the parameter is only one (decimal or hexadecimal)\n" "number, it will be interpreted as a VESA mode number. (default: none if\n" "sisfb is a module; this leaves the console untouched and the driver will\n" "only do the video memory management for eg. DRM/DRI; 800x600x8 if sisfb\n" "is in the kernel)\n"); MODULE_PARM_DESC(vesa, - "\nSelects the desired display mode by VESA defined mode number, eg. 0x117\n" - "(default: 0x0000 if sisfb is a module; this leaves the console untouched\n" + "\nSelects the desired display mode by VESA defined mode number, eg. 0x117\n" + "(default: 0x0000 if sisfb is a module; this leaves the console untouched\n" "and the driver will only do the video memory management for eg. DRM/DRI;\n" "0x0103 if sisfb is in the kernel)\n"); #endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) MODULE_PARM_DESC(mode, - "\nSelects the desired default display mode in the format XxYxDepth,\n" - "eg. 1024x768x16. Other formats supported include XxY-Depth and\n" + "\nSelects the desired default display mode in the format XxYxDepth,\n" + "eg. 1024x768x16. Other formats supported include XxY-Depth and\n" "XxY-Depth@Rate. If the parameter is only one (decimal or hexadecimal)\n" "number, it will be interpreted as a VESA mode number. (default: 800x600x8)\n"); MODULE_PARM_DESC(vesa, - "\nSelects the desired default display mode by VESA defined mode number, eg.\n" - "0x117 (default: 0x0103)\n"); + "\nSelects the desired default display mode by VESA defined mode number, eg.\n" + "0x117 (default: 0x0103)\n"); #endif MODULE_PARM_DESC(rate, @@ -5880,16 +7062,16 @@ MODULE_PARM_DESC(scalelcd, "themselves. Default: 1 on LVDS panels, 0 on TMDS panels\n"); MODULE_PARM_DESC(pdc, - "\nThis is for manually selecting the LCD panel delay compensation. The driver\n" + "\nThis is for manually selecting the LCD panel delay compensation. The driver\n" "should detect this correctly in most cases; however, sometimes this is not\n" "possible. If you see 'small waves' on the LCD, try setting this to 4, 32 or 24\n" - "on a 300 series chipset; 6 on a 315 series chipset. If the problem persists,\n" - "try other values (on 300 series: between 4 and 60 in steps of 4; on 315 series:\n" - "any value from 0 to 31). (default: autodetected, if LCD is active during start)\n"); + "on a 300 series chipset; 6 on other chipsets. If the problem persists, try\n" + "other values (on 300 series: between 4 and 60 in steps of 4; otherwise: any\n" + "value from 0 to 31). (default: autodetected, if LCD is active during start)\n"); #ifdef CONFIG_FB_SIS_315 MODULE_PARM_DESC(pdc1, - "\nThis is same as pdc, but for LCD-via CRT1. Hence, this is for the 315/330\n" + "\nThis is same as pdc, but for LCD-via CRT1. Hence, this is for the 315/330/340\n" "series only. (default: autodetected if LCD is in LCD-via-CRT1 mode during\n" "startup) - Note: currently, this has no effect because LCD-via-CRT1 is not\n" "implemented yet.\n"); @@ -5913,17 +7095,13 @@ MODULE_PARM_DESC(tvyposoffset, "\nRelocate TV output vertically. Possible parameters: -32 through 32.\n" "Default: 0\n"); -MODULE_PARM_DESC(filter, - "\nSelects TV flicker filter type (only for systems with a SiS301 video bridge).\n" - "(Possible values 0-7, default: [no filter])\n"); - MODULE_PARM_DESC(nocrt2rate, "\nSetting this to 1 will force the driver to use the default refresh rate for\n" "CRT2 if CRT2 type is VGA. (default: 0, use same rate as CRT1)\n"); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) MODULE_PARM_DESC(inverse, - "\nSetting this to anything but 0 should invert the display colors, but this\n" + "\nSetting this to anything but 0 should invert the display colors, but this\n" "does not seem to work. (default: 0)\n"); #endif @@ -5931,98 +7109,23 @@ MODULE_PARM_DESC(inverse, #ifdef CONFIG_FB_SIS_300 MODULE_PARM_DESC(resetcard, "\nSet this to 1 in order to reset (POST) the card on non-x86 machines where\n" - "the BIOS did not POST the card (only supported for SiS 300/305 currently).\n" - "Default: 0\n"); + "the BIOS did not POST the card (only supported for SiS 300/305 and XGI cards\n" + "currently). Default: 0\n"); MODULE_PARM_DESC(videoram, "\nSet this to the amount of video RAM (in kilobyte) the card has. Required on\n" "some non-x86 architectures where the memory auto detection fails. Only\n" - "relevant if resetcard is set, too. Default: [auto-detect]\n"); -#endif + "relevant if resetcard is set, too. SiS300/305 only. Default: [auto-detect]\n"); #endif - -static int __devinit sisfb_init_module(void) -{ - sisfb_setdefaultparms(); - - if(rate) sisfb_parm_rate = rate; - - if((scalelcd == 0) || (scalelcd == 1)) { - sisfb_scalelcd = scalelcd ^ 1; - } - - /* Need to check crt2 type first for fstn/dstn */ - - if(forcecrt2type) - sisfb_search_crt2type(forcecrt2type); - - if(tvstandard) - sisfb_search_tvstd(tvstandard); - - if(mode) - sisfb_search_mode(mode, FALSE); - else if(vesa != -1) - sisfb_search_vesamode(vesa, FALSE); - - sisfb_crt1off = (crt1off == 0) ? 1 : 0; - - sisfb_forcecrt1 = forcecrt1; - if(forcecrt1 == 1) sisfb_crt1off = 0; - else if(forcecrt1 == 0) sisfb_crt1off = 1; - - if(noaccel == 1) sisfb_accel = 0; - else if(noaccel == 0) sisfb_accel = 1; - - if(noypan == 1) sisfb_ypan = 0; - else if(noypan == 0) sisfb_ypan = 1; - - if(nomax == 1) sisfb_max = 0; - else if(nomax == 0) sisfb_max = 1; - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - if(inverse) sisfb_inverse = 1; #endif - if(mem) sisfb_parm_mem = mem; - - if(userom != -1) sisfb_userom = userom; - if(useoem != -1) sisfb_useoem = useoem; - - if(pdc != -1) sisfb_pdc = (pdc & 0x7f); - if(pdc1 != -1) sisfb_pdca = (pdc1 & 0x1f); - - sisfb_nocrt2rate = nocrt2rate; - - if(specialtiming) - sisfb_search_specialtiming(specialtiming); - - if((lvdshl >= 0) && (lvdshl <= 3)) sisfb_lvdshl = lvdshl; - - if(filter != -1) sisfb_filter = filter; - - sisfb_tvxposoffset = tvxposoffset; - sisfb_tvyposoffset = tvyposoffset; - -#if !defined(__i386__) && !defined(__x86_64__) - sisfb_resetcard = (resetcard) ? 1 : 0; - if(videoram) sisfb_videoram = videoram; -#endif - - return(sisfb_init()); -} - -static void __exit sisfb_remove_module(void) -{ - pci_unregister_driver(&sisfb_driver); - printk(KERN_DEBUG "sisfb: Module unloaded\n"); -} - -module_init(sisfb_init_module); -module_exit(sisfb_remove_module); - #endif /* /MODULE */ +/* _GPL only for new symbols. */ EXPORT_SYMBOL(sis_malloc); EXPORT_SYMBOL(sis_free); +EXPORT_SYMBOL_GPL(sis_malloc_new); +EXPORT_SYMBOL_GPL(sis_free_new); + diff --git a/drivers/video/sis/sis_main.h b/drivers/video/sis/sis_main.h index a6678a7aff3..445bcbba03a 100644 --- a/drivers/video/sis/sis_main.h +++ b/drivers/video/sis/sis_main.h @@ -1,9 +1,10 @@ /* - * SiS 300/305/540/630(S)/730(S) - * SiS 315(H/PRO)/55x/(M)65x/(M)661(F/M)X/740/741(GX)/330/(M)760 + * SiS 300/305/540/630(S)/730(S), + * SiS 315[E|PRO]/550/[M]65x/[M]66x[F|M|G]X/[M]74x[GX]/330/[M]76x[GX], + * XGI V3XT/V5/V8, Z7 * frame buffer driver for Linux kernels >=2.4.14 and >=2.6.3 * - * Copyright (C) 2001-2004 Thomas Winischhofer, Vienna, Austria. + * Copyright (C) 2001-2005 Thomas Winischhofer, Vienna, Austria. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,13 +24,9 @@ #ifndef _SISFB_MAIN #define _SISFB_MAIN -#include <linux/spinlock.h> - #include "vstruct.h" #include "sis.h" -#define MODE_INDEX_NONE 0 /* index for mode=none */ - /* Fbcon stuff */ static struct fb_var_screeninfo my_default_var = { .xres = 0, @@ -60,6 +57,8 @@ static struct fb_var_screeninfo my_default_var = { .vmode = FB_VMODE_NONINTERLACED, }; +#define MODE_INDEX_NONE 0 /* index for mode=none */ + /* Boot-time parameters */ static int sisfb_off = 0; static int sisfb_parm_mem = 0; @@ -93,7 +92,6 @@ static int sisfb_tvplug = -1; /* Tv plug type (for overriding autodetection) */ static int sisfb_tvstd = -1; static int sisfb_tvxposoffset = 0; static int sisfb_tvyposoffset = 0; -static int sisfb_filter = -1; static int sisfb_nocrt2rate = 0; #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) static int sisfb_inverse = 0; @@ -106,12 +104,12 @@ static int sisfb_videoram = 0; /* List of supported chips */ static struct sisfb_chip_info { - int chip; - int vgaengine; + int chip; + int vgaengine; int mni; - int hwcursor_size; + int hwcursor_size; int CRT2_write_enable; - const char *chip_name; + const char *chip_name; } sisfb_chip_info[] __devinitdata = { { SIS_300, SIS_300_VGA, 0, HW_CURSOR_AREA_SIZE_300 * 2, SIS_CRT2_WENABLE_300, "SiS 300/305" }, { SIS_540, SIS_300_VGA, 0, HW_CURSOR_AREA_SIZE_300 * 2, SIS_CRT2_WENABLE_300, "SiS 540" }, @@ -123,6 +121,8 @@ static struct sisfb_chip_info { { SIS_650, SIS_315_VGA, 1, HW_CURSOR_AREA_SIZE_315 * 4, SIS_CRT2_WENABLE_315, "SiS 650" }, { SIS_330, SIS_315_VGA, 1, HW_CURSOR_AREA_SIZE_315 * 4, SIS_CRT2_WENABLE_315, "SiS 330" }, { SIS_660, SIS_315_VGA, 1, HW_CURSOR_AREA_SIZE_315 * 4, SIS_CRT2_WENABLE_315, "SiS 660" }, + { XGI_20, SIS_315_VGA, 1, HW_CURSOR_AREA_SIZE_315 * 4, SIS_CRT2_WENABLE_315, "XGI Z7" }, + { XGI_40, SIS_315_VGA, 1, HW_CURSOR_AREA_SIZE_315 * 4, SIS_CRT2_WENABLE_315, "XGI V3XT/V5/V8" }, }; static struct pci_device_id __devinitdata sisfb_pci_table[] = { @@ -139,6 +139,8 @@ static struct pci_device_id __devinitdata sisfb_pci_table[] = { { PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_650_VGA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 7}, { PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_330, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 8}, { PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_660_VGA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 9}, + { PCI_VENDOR_ID_XGI,PCI_DEVICE_ID_XGI_20, PCI_ANY_ID, PCI_ANY_ID, 0, 0,10}, + { PCI_VENDOR_ID_XGI,PCI_DEVICE_ID_XGI_40, PCI_ANY_ID, PCI_ANY_ID, 0, 0,11}, #endif { 0 } }; @@ -147,13 +149,12 @@ MODULE_DEVICE_TABLE(pci, sisfb_pci_table); static struct sis_video_info *card_list = NULL; -/* TODO: This is not handled card-wise because the DRM - does not refer to a unique fb when calling sis_alloc - or sis_free. Therefore, this is handled globally for - now (hoping that nobody is crazy enough to run two - SiS cards at the same time). +/* The memory heap is now handled card-wise, by using + sis_malloc_new/sis_free_new. However, the DRM does + not do this yet. Until it does, we keep a "global" + heap which is actually the first card's one. */ -static SIS_HEAP sisfb_heap; +static struct SIS_HEAP *sisfb_heap; #define MD_SIS300 1 #define MD_SIS315 2 @@ -181,8 +182,10 @@ static const struct _sisbios_mode { {"320x240x16", {0x56,0x56}, 0x0135, 0x0000, 320, 240, 16, 1, 40, 15, MD_SIS300|MD_SIS315}, {"320x240x24", {0x53,0x53}, 0x0000, 0x0000, 320, 240, 32, 1, 40, 15, MD_SIS300|MD_SIS315}, {"320x240x32", {0x53,0x53}, 0x0000, 0x0000, 320, 240, 32, 1, 40, 15, MD_SIS300|MD_SIS315}, - {"320x240x8", {0x5a,0x5a}, 0x0132, 0x0000, 320, 480, 8, 1, 40, 30, MD_SIS315}, /* FSTN */ -/*10*/ {"320x240x16", {0x5b,0x5b}, 0x0135, 0x0000, 320, 480, 16, 1, 40, 30, MD_SIS315}, /* FSTN */ +#define MODE_FSTN_8 9 +#define MODE_FSTN_16 10 + {"320x240x8", {0x5a,0x5a}, 0x0132, 0x0000, 320, 240, 8, 1, 40, 15, MD_SIS315}, /* FSTN */ +/*10*/ {"320x240x16", {0x5b,0x5b}, 0x0135, 0x0000, 320, 240, 16, 1, 40, 15, MD_SIS315}, /* FSTN */ {"400x300x8", {0x51,0x51}, 0x0133, 0x0000, 400, 300, 8, 1, 50, 18, MD_SIS300|MD_SIS315}, {"400x300x16", {0x57,0x57}, 0x0136, 0x0000, 400, 300, 16, 1, 50, 18, MD_SIS300|MD_SIS315}, {"400x300x24", {0x54,0x54}, 0x0000, 0x0000, 400, 300, 32, 1, 50, 18, MD_SIS300|MD_SIS315}, @@ -215,18 +218,20 @@ static const struct _sisbios_mode { /*40*/ {"800x480x16", {0x7a,0x7a}, 0x0000, 0x0000, 800, 480, 16, 1, 100, 30, MD_SIS300|MD_SIS315}, {"800x480x24", {0x76,0x76}, 0x0000, 0x0000, 800, 480, 32, 1, 100, 30, MD_SIS300|MD_SIS315}, {"800x480x32", {0x76,0x76}, 0x0000, 0x0000, 800, 480, 32, 1, 100, 30, MD_SIS300|MD_SIS315}, -#define DEFAULT_MODE 43 /* index for 800x600x8 */ -#define DEFAULT_LCDMODE 43 /* index for 800x600x8 */ -#define DEFAULT_TVMODE 43 /* index for 800x600x8 */ +#define DEFAULT_MODE 43 /* index for 800x600x8 */ +#define DEFAULT_LCDMODE 43 /* index for 800x600x8 */ +#define DEFAULT_TVMODE 43 /* index for 800x600x8 */ {"800x600x8", {0x30,0x30}, 0x0103, 0x0103, 800, 600, 8, 2, 100, 37, MD_SIS300|MD_SIS315}, {"800x600x16", {0x47,0x47}, 0x0114, 0x0114, 800, 600, 16, 2, 100, 37, MD_SIS300|MD_SIS315}, {"800x600x24", {0x63,0x63}, 0x013b, 0x0115, 800, 600, 32, 2, 100, 37, MD_SIS300|MD_SIS315}, {"800x600x32", {0x63,0x63}, 0x013b, 0x0115, 800, 600, 32, 2, 100, 37, MD_SIS300|MD_SIS315}, {"848x480x8", {0x39,0x39}, 0x0000, 0x0000, 848, 480, 8, 2, 106, 30, MD_SIS300|MD_SIS315}, +#define DEFAULT_MODE_848 48 {"848x480x16", {0x3b,0x3b}, 0x0000, 0x0000, 848, 480, 16, 2, 106, 30, MD_SIS300|MD_SIS315}, {"848x480x24", {0x3e,0x3e}, 0x0000, 0x0000, 848, 480, 32, 2, 106, 30, MD_SIS300|MD_SIS315}, /*50*/ {"848x480x32", {0x3e,0x3e}, 0x0000, 0x0000, 848, 480, 32, 2, 106, 30, MD_SIS300|MD_SIS315}, {"856x480x8", {0x3f,0x3f}, 0x0000, 0x0000, 856, 480, 8, 2, 107, 30, MD_SIS300|MD_SIS315}, +#define DEFAULT_MODE_856 52 {"856x480x16", {0x42,0x42}, 0x0000, 0x0000, 856, 480, 16, 2, 107, 30, MD_SIS300|MD_SIS315}, {"856x480x24", {0x45,0x45}, 0x0000, 0x0000, 856, 480, 32, 2, 107, 30, MD_SIS300|MD_SIS315}, {"856x480x32", {0x45,0x45}, 0x0000, 0x0000, 856, 480, 32, 2, 107, 30, MD_SIS300|MD_SIS315}, @@ -270,42 +275,47 @@ static const struct _sisbios_mode { {"1280x800x16", {0x15,0x15}, 0x0000, 0x0000, 1280, 800, 16, 1, 160, 50, MD_SIS315}, {"1280x800x24", {0x16,0x16}, 0x0000, 0x0000, 1280, 800, 32, 1, 160, 50, MD_SIS315}, {"1280x800x32", {0x16,0x16}, 0x0000, 0x0000, 1280, 800, 32, 1, 160, 50, MD_SIS315}, + {"1280x854x8", {0x14,0x14}, 0x0000, 0x0000, 1280, 854, 8, 1, 160, 53, MD_SIS315}, + {"1280x854x16", {0x15,0x15}, 0x0000, 0x0000, 1280, 854, 16, 1, 160, 53, MD_SIS315}, + {"1280x854x24", {0x16,0x16}, 0x0000, 0x0000, 1280, 854, 32, 1, 160, 53, MD_SIS315}, + {"1280x854x32", {0x16,0x16}, 0x0000, 0x0000, 1280, 854, 32, 1, 160, 53, MD_SIS315}, {"1280x960x8", {0x7c,0x7c}, 0x0000, 0x0000, 1280, 960, 8, 1, 160, 60, MD_SIS300|MD_SIS315}, - {"1280x960x16", {0x7d,0x7d}, 0x0000, 0x0000, 1280, 960, 16, 1, 160, 60, MD_SIS300|MD_SIS315}, +/*100*/ {"1280x960x16", {0x7d,0x7d}, 0x0000, 0x0000, 1280, 960, 16, 1, 160, 60, MD_SIS300|MD_SIS315}, {"1280x960x24", {0x7e,0x7e}, 0x0000, 0x0000, 1280, 960, 32, 1, 160, 60, MD_SIS300|MD_SIS315}, {"1280x960x32", {0x7e,0x7e}, 0x0000, 0x0000, 1280, 960, 32, 1, 160, 60, MD_SIS300|MD_SIS315}, {"1280x1024x8", {0x3a,0x3a}, 0x0107, 0x0107, 1280, 1024, 8, 2, 160, 64, MD_SIS300|MD_SIS315}, -/*100*/ {"1280x1024x16", {0x4d,0x4d}, 0x011a, 0x011a, 1280, 1024, 16, 2, 160, 64, MD_SIS300|MD_SIS315}, + {"1280x1024x16", {0x4d,0x4d}, 0x011a, 0x011a, 1280, 1024, 16, 2, 160, 64, MD_SIS300|MD_SIS315}, {"1280x1024x24", {0x65,0x65}, 0x013d, 0x011b, 1280, 1024, 32, 2, 160, 64, MD_SIS300|MD_SIS315}, {"1280x1024x32", {0x65,0x65}, 0x013d, 0x011b, 1280, 1024, 32, 2, 160, 64, MD_SIS300|MD_SIS315}, {"1360x768x8", {0x48,0x48}, 0x0000, 0x0000, 1360, 768, 8, 1, 170, 48, MD_SIS300|MD_SIS315}, {"1360x768x16", {0x4b,0x4b}, 0x0000, 0x0000, 1360, 768, 16, 1, 170, 48, MD_SIS300|MD_SIS315}, {"1360x768x24", {0x4e,0x4e}, 0x0000, 0x0000, 1360, 768, 32, 1, 170, 48, MD_SIS300|MD_SIS315}, - {"1360x768x32", {0x4e,0x4e}, 0x0000, 0x0000, 1360, 768, 32, 1, 170, 48, MD_SIS300|MD_SIS315}, +/*110*/ {"1360x768x32", {0x4e,0x4e}, 0x0000, 0x0000, 1360, 768, 32, 1, 170, 48, MD_SIS300|MD_SIS315}, {"1360x1024x8", {0x67,0x67}, 0x0000, 0x0000, 1360, 1024, 8, 1, 170, 64, MD_SIS300 }, +#define DEFAULT_MODE_1360 112 {"1360x1024x16", {0x6f,0x6f}, 0x0000, 0x0000, 1360, 1024, 16, 1, 170, 64, MD_SIS300 }, {"1360x1024x24", {0x72,0x72}, 0x0000, 0x0000, 1360, 1024, 32, 1, 170, 64, MD_SIS300 }, -/*110*/ {"1360x1024x32", {0x72,0x72}, 0x0000, 0x0000, 1360, 1024, 32, 1, 170, 64, MD_SIS300 }, + {"1360x1024x32", {0x72,0x72}, 0x0000, 0x0000, 1360, 1024, 32, 1, 170, 64, MD_SIS300 }, {"1400x1050x8", {0x26,0x26}, 0x0000, 0x0000, 1400, 1050, 8, 1, 175, 65, MD_SIS315}, {"1400x1050x16", {0x27,0x27}, 0x0000, 0x0000, 1400, 1050, 16, 1, 175, 65, MD_SIS315}, {"1400x1050x24", {0x28,0x28}, 0x0000, 0x0000, 1400, 1050, 32, 1, 175, 65, MD_SIS315}, {"1400x1050x32", {0x28,0x28}, 0x0000, 0x0000, 1400, 1050, 32, 1, 175, 65, MD_SIS315}, {"1600x1200x8", {0x3c,0x3c}, 0x0130, 0x011c, 1600, 1200, 8, 1, 200, 75, MD_SIS300|MD_SIS315}, - {"1600x1200x16", {0x3d,0x3d}, 0x0131, 0x011e, 1600, 1200, 16, 1, 200, 75, MD_SIS300|MD_SIS315}, +/*120*/ {"1600x1200x16", {0x3d,0x3d}, 0x0131, 0x011e, 1600, 1200, 16, 1, 200, 75, MD_SIS300|MD_SIS315}, {"1600x1200x24", {0x66,0x66}, 0x013e, 0x011f, 1600, 1200, 32, 1, 200, 75, MD_SIS300|MD_SIS315}, {"1600x1200x32", {0x66,0x66}, 0x013e, 0x011f, 1600, 1200, 32, 1, 200, 75, MD_SIS300|MD_SIS315}, {"1680x1050x8", {0x17,0x17}, 0x0000, 0x0000, 1680, 1050, 8, 1, 210, 65, MD_SIS315}, -/*120*/ {"1680x1050x16", {0x18,0x18}, 0x0000, 0x0000, 1680, 1050, 16, 1, 210, 65, MD_SIS315}, + {"1680x1050x16", {0x18,0x18}, 0x0000, 0x0000, 1680, 1050, 16, 1, 210, 65, MD_SIS315}, {"1680x1050x24", {0x19,0x19}, 0x0000, 0x0000, 1680, 1050, 32, 1, 210, 65, MD_SIS315}, {"1680x1050x32", {0x19,0x19}, 0x0000, 0x0000, 1680, 1050, 32, 1, 210, 65, MD_SIS315}, {"1920x1080x8", {0x2c,0x2c}, 0x0000, 0x0000, 1920, 1080, 8, 1, 240, 67, MD_SIS315}, {"1920x1080x16", {0x2d,0x2d}, 0x0000, 0x0000, 1920, 1080, 16, 1, 240, 67, MD_SIS315}, {"1920x1080x24", {0x73,0x73}, 0x0000, 0x0000, 1920, 1080, 32, 1, 240, 67, MD_SIS315}, - {"1920x1080x32", {0x73,0x73}, 0x0000, 0x0000, 1920, 1080, 32, 1, 240, 67, MD_SIS315}, +/*130*/ {"1920x1080x32", {0x73,0x73}, 0x0000, 0x0000, 1920, 1080, 32, 1, 240, 67, MD_SIS315}, {"1920x1440x8", {0x68,0x68}, 0x013f, 0x0000, 1920, 1440, 8, 1, 240, 75, MD_SIS300|MD_SIS315}, {"1920x1440x16", {0x69,0x69}, 0x0140, 0x0000, 1920, 1440, 16, 1, 240, 75, MD_SIS300|MD_SIS315}, {"1920x1440x24", {0x6b,0x6b}, 0x0141, 0x0000, 1920, 1440, 32, 1, 240, 75, MD_SIS300|MD_SIS315}, -/*130*/ {"1920x1440x32", {0x6b,0x6b}, 0x0141, 0x0000, 1920, 1440, 32, 1, 240, 75, MD_SIS300|MD_SIS315}, + {"1920x1440x32", {0x6b,0x6b}, 0x0141, 0x0000, 1920, 1440, 32, 1, 240, 75, MD_SIS300|MD_SIS315}, {"2048x1536x8", {0x6c,0x6c}, 0x0000, 0x0000, 2048, 1536, 8, 1, 256, 96, MD_SIS315}, {"2048x1536x16", {0x6d,0x6d}, 0x0000, 0x0000, 2048, 1536, 16, 1, 256, 96, MD_SIS315}, {"2048x1536x24", {0x6e,0x6e}, 0x0000, 0x0000, 2048, 1536, 32, 1, 256, 96, MD_SIS315}, @@ -313,13 +323,13 @@ static const struct _sisbios_mode { {"\0", {0x00,0x00}, 0, 0, 0, 0, 0, 0, 0} }; -#define SIS_LCD_NUMBER 17 -static const struct _sis_lcd_data { +#define SIS_LCD_NUMBER 18 +static struct _sis_lcd_data { u32 lcdtype; u16 xres; u16 yres; u8 default_mode_idx; -} sis_lcd_data[] = { +} sis_lcd_data[] __devinitdata = { { LCD_640x480, 640, 480, 23 }, { LCD_800x600, 800, 600, 43 }, { LCD_1024x600, 1024, 600, 67 }, @@ -329,34 +339,38 @@ static const struct _sis_lcd_data { { LCD_1280x720, 1280, 720, 83 }, { LCD_1280x768, 1280, 768, 87 }, { LCD_1280x800, 1280, 800, 91 }, - { LCD_1280x960, 1280, 960, 95 }, - { LCD_1280x1024, 1280, 1024, 99 }, - { LCD_1400x1050, 1400, 1050, 111 }, - { LCD_1680x1050, 1680, 1050, 119 }, - { LCD_1600x1200, 1600, 1200, 115 }, - { LCD_640x480_2, 640, 480, 23 }, - { LCD_640x480_3, 640, 480, 23 }, - { LCD_320x480, 320, 480, 9 }, + { LCD_1280x854, 1280, 854, 95 }, + { LCD_1280x960, 1280, 960, 99 }, + { LCD_1280x1024, 1280, 1024, 103 }, + { LCD_1400x1050, 1400, 1050, 115 }, + { LCD_1680x1050, 1680, 1050, 123 }, + { LCD_1600x1200, 1600, 1200, 119 }, + { LCD_320x240_2, 320, 240, 9 }, + { LCD_320x240_3, 320, 240, 9 }, + { LCD_320x240, 320, 240, 9 }, }; /* CR36 evaluation */ -static const USHORT sis300paneltype[] = - { LCD_UNKNOWN, LCD_800x600, LCD_1024x768, LCD_1280x1024, - LCD_1280x960, LCD_640x480, LCD_1024x600, LCD_1152x768, - LCD_UNKNOWN, LCD_UNKNOWN, LCD_UNKNOWN, LCD_UNKNOWN, - LCD_UNKNOWN, LCD_UNKNOWN, LCD_UNKNOWN, LCD_UNKNOWN }; - -static const USHORT sis310paneltype[] = - { LCD_UNKNOWN, LCD_800x600, LCD_1024x768, LCD_1280x1024, - LCD_640x480, LCD_1024x600, LCD_1152x864, LCD_1280x960, - LCD_1152x768, LCD_1400x1050, LCD_1280x768, LCD_1600x1200, - LCD_640x480_2, LCD_640x480_3, LCD_UNKNOWN, LCD_UNKNOWN }; - -static const USHORT sis661paneltype[] = - { LCD_UNKNOWN, LCD_800x600, LCD_1024x768, LCD_1280x1024, - LCD_640x480, LCD_1024x600, LCD_1152x864, LCD_1280x960, - LCD_1152x768, LCD_1400x1050, LCD_1280x768, LCD_1600x1200, - LCD_1280x800, LCD_1680x1050, LCD_1280x720, LCD_UNKNOWN }; +static unsigned short sis300paneltype[] __devinitdata = { + LCD_UNKNOWN, LCD_800x600, LCD_1024x768, LCD_1280x1024, + LCD_1280x960, LCD_640x480, LCD_1024x600, LCD_1152x768, + LCD_UNKNOWN, LCD_UNKNOWN, LCD_UNKNOWN, LCD_UNKNOWN, + LCD_UNKNOWN, LCD_UNKNOWN, LCD_UNKNOWN, LCD_UNKNOWN +}; + +static unsigned short sis310paneltype[] __devinitdata = { + LCD_UNKNOWN, LCD_800x600, LCD_1024x768, LCD_1280x1024, + LCD_640x480, LCD_1024x600, LCD_1152x864, LCD_1280x960, + LCD_1152x768, LCD_1400x1050, LCD_1280x768, LCD_1600x1200, + LCD_320x240_2, LCD_320x240_3, LCD_UNKNOWN, LCD_UNKNOWN +}; + +static unsigned short sis661paneltype[] __devinitdata = { + LCD_UNKNOWN, LCD_800x600, LCD_1024x768, LCD_1280x1024, + LCD_640x480, LCD_1024x600, LCD_1152x864, LCD_1280x960, + LCD_1280x854, LCD_1400x1050, LCD_1280x768, LCD_1600x1200, + LCD_1280x800, LCD_1680x1050, LCD_1280x720, LCD_UNKNOWN +}; #define FL_550_DSTN 0x01 #define FL_550_FSTN 0x02 @@ -413,7 +427,6 @@ static const struct _sis_vrate { } sisfb_vrate[] = { {1, 320, 200, 70, TRUE}, {1, 320, 240, 60, TRUE}, - {1, 320, 480, 60, TRUE}, {1, 400, 300, 60, TRUE}, {1, 512, 384, 60, TRUE}, {1, 640, 400, 72, TRUE}, @@ -437,10 +450,11 @@ static const struct _sis_vrate { {4, 1024, 768, 75, FALSE}, {5, 1024, 768, 85, TRUE}, {6, 1024, 768, 100, TRUE}, {7, 1024, 768, 120, TRUE}, {1, 1152, 768, 60, TRUE}, - {1, 1152, 864, 60, TRUE}, {1, 1152, 864, 75, TRUE}, {2, 1152, 864, 84, TRUE}, + {1, 1152, 864, 60, TRUE}, {2, 1152, 864, 75, TRUE}, {3, 1152, 864, 84, TRUE}, {1, 1280, 720, 60, TRUE}, {2, 1280, 720, 75, TRUE}, {3, 1280, 720, 85, TRUE}, {1, 1280, 768, 60, TRUE}, {1, 1280, 800, 60, TRUE}, + {1, 1280, 854, 60, TRUE}, {1, 1280, 960, 60, TRUE}, {2, 1280, 960, 85, TRUE}, {1, 1280, 1024, 43, TRUE}, {2, 1280, 1024, 60, TRUE}, {3, 1280, 1024, 75, TRUE}, {4, 1280, 1024, 85, TRUE}, @@ -459,12 +473,12 @@ static const struct _sis_vrate { {0, 0, 0, 0, FALSE} }; -static const struct _sisfbddcsmodes { +static struct _sisfbddcsmodes { u32 mask; u16 h; u16 v; u32 d; -} sisfb_ddcsmodes[] = { +} sisfb_ddcsmodes[] __devinitdata = { { 0x10000, 67, 75, 108000}, { 0x08000, 48, 72, 50000}, { 0x04000, 46, 75, 49500}, @@ -480,49 +494,49 @@ static const struct _sisfbddcsmodes { { 0x00001, 38, 60, 40000} }; -static const struct _sisfbddcfmodes { +static struct _sisfbddcfmodes { u16 x; u16 y; u16 v; u16 h; u32 d; -} sisfb_ddcfmodes[] = { - { 1280, 1024, 85, 92, 157500}, - { 1600, 1200, 60, 75, 162000}, - { 1600, 1200, 65, 82, 175500}, - { 1600, 1200, 70, 88, 189000}, - { 1600, 1200, 75, 94, 202500}, - { 1600, 1200, 85, 107,229500}, - { 1920, 1440, 60, 90, 234000}, - { 1920, 1440, 75, 113,297000} +} sisfb_ddcfmodes[] __devinitdata = { + { 1280, 1024, 85, 92, 157500}, + { 1600, 1200, 60, 75, 162000}, + { 1600, 1200, 65, 82, 175500}, + { 1600, 1200, 70, 88, 189000}, + { 1600, 1200, 75, 94, 202500}, + { 1600, 1200, 85, 107,229500}, + { 1920, 1440, 60, 90, 234000}, + { 1920, 1440, 75, 113,297000} }; #ifdef CONFIG_FB_SIS_300 static struct _chswtable { - u16 subsysVendor; - u16 subsysCard; - char *vendorName; - char *cardName; + u16 subsysVendor; + u16 subsysCard; + char *vendorName; + char *cardName; } mychswtable[] __devinitdata = { - { 0x1631, 0x1002, "Mitachi", "0x1002" }, + { 0x1631, 0x1002, "Mitachi", "0x1002" }, { 0x1071, 0x7521, "Mitac" , "7521P" }, { 0, 0, "" , "" } }; #endif static struct _customttable { - u16 chipID; - char *biosversion; - char *biosdate; - u32 bioschksum; - u16 biosFootprintAddr[5]; - u8 biosFootprintData[5]; - u16 pcisubsysvendor; - u16 pcisubsyscard; - char *vendorName; - char *cardName; - u32 SpecialID; - char *optionName; + u16 chipID; + char *biosversion; + char *biosdate; + u32 bioschksum; + u16 biosFootprintAddr[5]; + u8 biosFootprintData[5]; + u16 pcisubsysvendor; + u16 pcisubsyscard; + char *vendorName; + char *cardName; + u32 SpecialID; + char *optionName; } mycustomttable[] __devinitdata = { { SIS_630, "2.00.07", "09/27/2002-13:38:25", 0x3240A8, @@ -643,6 +657,13 @@ static struct _customttable { 0, 0, "Generic", "LVDS/Parallel 848x480", CUT_PANEL848, "PANEL848x480" }, + { 4322, "", "", /* never autodetected */ + 0, + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + 0, 0, + "Generic", "LVDS/Parallel 856x480", CUT_PANEL856, "PANEL856x480" + }, { 0, "", "", 0, { 0, 0, 0, 0 }, @@ -652,155 +673,6 @@ static struct _customttable { } }; -static const struct _sis_TV_filter { - u8 filter[9][4]; -} sis_TV_filter[] = { - { {{0x00,0x00,0x00,0x40}, /* NTSCFilter_0 */ - {0x00,0xE0,0x10,0x60}, - {0x00,0xEE,0x10,0x44}, - {0x00,0xF4,0x10,0x38}, - {0xF8,0xF4,0x18,0x38}, - {0xFC,0xFB,0x14,0x2A}, - {0x00,0x00,0x10,0x20}, - {0x00,0x04,0x10,0x18}, - {0xFF,0xFF,0xFF,0xFF} }}, - { {{0x00,0x00,0x00,0x40}, /* NTSCFilter_1 */ - {0x00,0xE0,0x10,0x60}, - {0x00,0xEE,0x10,0x44}, - {0x00,0xF4,0x10,0x38}, - {0xF8,0xF4,0x18,0x38}, - {0xFC,0xFB,0x14,0x2A}, - {0x00,0x00,0x10,0x20}, - {0x00,0x04,0x10,0x18}, - {0xFF,0xFF,0xFF,0xFF} }}, - { {{0x00,0x00,0x00,0x40}, /* NTSCFilter_2 */ - {0xF5,0xEE,0x1B,0x44}, - {0xF8,0xF4,0x18,0x38}, - {0xEB,0x04,0x25,0x18}, - {0xF1,0x05,0x1F,0x16}, - {0xF6,0x06,0x1A,0x14}, - {0xFA,0x06,0x16,0x14}, - {0x00,0x04,0x10,0x18}, - {0xFF,0xFF,0xFF,0xFF} }}, - { {{0x00,0x00,0x00,0x40}, /* NTSCFilter_3 */ - {0xF1,0x04,0x1F,0x18}, - {0xEE,0x0D,0x22,0x06}, - {0xF7,0x06,0x19,0x14}, - {0xF4,0x0B,0x1C,0x0A}, - {0xFA,0x07,0x16,0x12}, - {0xF9,0x0A,0x17,0x0C}, - {0x00,0x07,0x10,0x12}, - {0xFF,0xFF,0xFF,0xFF} }}, - { {{0x00,0x00,0x00,0x40}, /* NTSCFilter_4 - 320 */ - {0x00,0xE0,0x10,0x60}, - {0x00,0xEE,0x10,0x44}, - {0x00,0xF4,0x10,0x38}, - {0xF8,0xF4,0x18,0x38}, - {0xFC,0xFB,0x14,0x2A}, - {0x00,0x00,0x10,0x20}, - {0x00,0x04,0x10,0x18}, - {0xFF,0xFF,0xFF,0xFF} }}, - { {{0x00,0x00,0x00,0x40}, /* NTSCFilter_5 - 640 */ - {0xF5,0xEE,0x1B,0x44}, - {0xF8,0xF4,0x18,0x38}, - {0xEB,0x04,0x25,0x18}, - {0xF1,0x05,0x1F,0x16}, - {0xF6,0x06,0x1A,0x14}, - {0xFA,0x06,0x16,0x14}, - {0x00,0x04,0x10,0x18}, - {0xFF,0xFF,0xFF,0xFF} }}, - { {{0x00,0x00,0x00,0x40}, /* NTSCFilter_6 - 720 */ - {0xEB,0x04,0x25,0x18}, - {0xE7,0x0E,0x29,0x04}, - {0xEE,0x0C,0x22,0x08}, - {0xF6,0x0B,0x1A,0x0A}, - {0xF9,0x0A,0x17,0x0C}, - {0xFC,0x0A,0x14,0x0C}, - {0x00,0x08,0x10,0x10}, - {0xFF,0xFF,0xFF,0xFF} }}, - { {{0x00,0x00,0x00,0x40}, /* NTSCFilter_7 - 800 */ - {0xEC,0x02,0x24,0x1C}, - {0xF2,0x04,0x1E,0x18}, - {0xEB,0x15,0x25,0xF6}, - {0xF4,0x10,0x1C,0x00}, - {0xF8,0x0F,0x18,0x02}, - {0x00,0x04,0x10,0x18}, - {0x01,0x06,0x0F,0x14}, - {0xFF,0xFF,0xFF,0xFF} }}, - { {{0x00,0x00,0x00,0x40}, /* PALFilter_0 */ - {0x00,0xE0,0x10,0x60}, - {0x00,0xEE,0x10,0x44}, - {0x00,0xF4,0x10,0x38}, - {0xF8,0xF4,0x18,0x38}, - {0xFC,0xFB,0x14,0x2A}, - {0x00,0x00,0x10,0x20}, - {0x00,0x04,0x10,0x18}, - {0xFF,0xFF,0xFF,0xFF} }}, - { {{0x00,0x00,0x00,0x40}, /* PALFilter_1 */ - {0x00,0xE0,0x10,0x60}, - {0x00,0xEE,0x10,0x44}, - {0x00,0xF4,0x10,0x38}, - {0xF8,0xF4,0x18,0x38}, - {0xFC,0xFB,0x14,0x2A}, - {0x00,0x00,0x10,0x20}, - {0x00,0x04,0x10,0x18}, - {0xFF,0xFF,0xFF,0xFF} }}, - { {{0x00,0x00,0x00,0x40}, /* PALFilter_2 */ - {0xF5,0xEE,0x1B,0x44}, - {0xF8,0xF4,0x18,0x38}, - {0xF1,0xF7,0x01,0x32}, - {0xF5,0xFB,0x1B,0x2A}, - {0xF9,0xFF,0x17,0x22}, - {0xFB,0x01,0x15,0x1E}, - {0x00,0x04,0x10,0x18}, - {0xFF,0xFF,0xFF,0xFF} }}, - { {{0x00,0x00,0x00,0x40}, /* PALFilter_3 */ - {0xF5,0xFB,0x1B,0x2A}, - {0xEE,0xFE,0x22,0x24}, - {0xF3,0x00,0x1D,0x20}, - {0xF9,0x03,0x17,0x1A}, - {0xFB,0x02,0x14,0x1E}, - {0xFB,0x04,0x15,0x18}, - {0x00,0x06,0x10,0x14}, - {0xFF,0xFF,0xFF,0xFF} }}, - { {{0x00,0x00,0x00,0x40}, /* PALFilter_4 - 320 */ - {0x00,0xE0,0x10,0x60}, - {0x00,0xEE,0x10,0x44}, - {0x00,0xF4,0x10,0x38}, - {0xF8,0xF4,0x18,0x38}, - {0xFC,0xFB,0x14,0x2A}, - {0x00,0x00,0x10,0x20}, - {0x00,0x04,0x10,0x18}, - {0xFF,0xFF,0xFF,0xFF} }}, - { {{0x00,0x00,0x00,0x40}, /* PALFilter_5 - 640 */ - {0xF5,0xEE,0x1B,0x44}, - {0xF8,0xF4,0x18,0x38}, - {0xF1,0xF7,0x1F,0x32}, - {0xF5,0xFB,0x1B,0x2A}, - {0xF9,0xFF,0x17,0x22}, - {0xFB,0x01,0x15,0x1E}, - {0x00,0x04,0x10,0x18}, - {0xFF,0xFF,0xFF,0xFF} }}, - { {{0x00,0x00,0x00,0x40}, /* PALFilter_6 - 720 */ - {0xF5,0xEE,0x1B,0x2A}, - {0xEE,0xFE,0x22,0x24}, - {0xF3,0x00,0x1D,0x20}, - {0xF9,0x03,0x17,0x1A}, - {0xFB,0x02,0x14,0x1E}, - {0xFB,0x04,0x15,0x18}, - {0x00,0x06,0x10,0x14}, - {0xFF,0xFF,0xFF,0xFF} }}, - { {{0x00,0x00,0x00,0x40}, /* PALFilter_7 - 800 */ - {0xF5,0xEE,0x1B,0x44}, - {0xF8,0xF4,0x18,0x38}, - {0xFC,0xFB,0x14,0x2A}, - {0xEB,0x05,0x25,0x16}, - {0xF1,0x05,0x1F,0x16}, - {0xFA,0x07,0x16,0x12}, - {0x00,0x07,0x10,0x12}, - {0xFF,0xFF,0xFF,0xFF} }} -}; - /* ---------------------- Prototypes ------------------------- */ /* Interface used by the world */ @@ -811,145 +683,159 @@ SISINITSTATIC int sisfb_setup(char *options); /* Interface to the low level console driver */ SISINITSTATIC int sisfb_init(void); - /* fbdev routines */ -static int sisfb_get_fix(struct fb_fix_screeninfo *fix, int con, - struct fb_info *info); +static int sisfb_get_fix(struct fb_fix_screeninfo *fix, int con, + struct fb_info *info); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -static int sisfb_get_fix(struct fb_fix_screeninfo *fix, - int con, - struct fb_info *info); -static int sisfb_get_var(struct fb_var_screeninfo *var, - int con, - struct fb_info *info); -static int sisfb_set_var(struct fb_var_screeninfo *var, - int con, - struct fb_info *info); -static void sisfb_crtc_to_var(struct sis_video_info *ivideo, - struct fb_var_screeninfo *var); -static int sisfb_get_cmap(struct fb_cmap *cmap, - int kspc, - int con, - struct fb_info *info); -static int sisfb_set_cmap(struct fb_cmap *cmap, - int kspc, - int con, - struct fb_info *info); -static int sisfb_update_var(int con, - struct fb_info *info); -static int sisfb_switch(int con, +static int sisfb_get_fix(struct fb_fix_screeninfo *fix, + int con, + struct fb_info *info); +static int sisfb_get_var(struct fb_var_screeninfo *var, + int con, + struct fb_info *info); +static int sisfb_set_var(struct fb_var_screeninfo *var, + int con, + struct fb_info *info); +static void sisfb_crtc_to_var(struct sis_video_info *ivideo, + struct fb_var_screeninfo *var); +static int sisfb_get_cmap(struct fb_cmap *cmap, + int kspc, + int con, + struct fb_info *info); +static int sisfb_set_cmap(struct fb_cmap *cmap, + int kspc, + int con, + struct fb_info *info); +static int sisfb_update_var(int con, + struct fb_info *info); +static int sisfb_switch(int con, struct fb_info *info); -static void sisfb_blank(int blank, - struct fb_info *info); -static void sisfb_set_disp(int con, - struct fb_var_screeninfo *var, - struct fb_info *info); -static int sis_getcolreg(unsigned regno, unsigned *red, unsigned *green, - unsigned *blue, unsigned *transp, - struct fb_info *fb_info); -static void sisfb_do_install_cmap(int con, - struct fb_info *info); -static int sisfb_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg, int con, - struct fb_info *info); -#endif +static void sisfb_blank(int blank, + struct fb_info *info); +static void sisfb_set_disp(int con, + struct fb_var_screeninfo *var, + struct fb_info *info); +static int sis_getcolreg(unsigned regno, unsigned *red, unsigned *green, + unsigned *blue, unsigned *transp, + struct fb_info *fb_info); +static void sisfb_do_install_cmap(int con, + struct fb_info *info); +static int sisfb_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg, int con, + struct fb_info *info); +#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) -static int sisfb_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg, - struct fb_info *info); -static int sisfb_set_par(struct fb_info *info); -static int sisfb_blank(int blank, - struct fb_info *info); -extern void fbcon_sis_fillrect(struct fb_info *info, - const struct fb_fillrect *rect); -extern void fbcon_sis_copyarea(struct fb_info *info, - const struct fb_copyarea *area); -extern int fbcon_sis_sync(struct fb_info *info); +static int sisfb_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg, + struct fb_info *info); +static int sisfb_set_par(struct fb_info *info); +static int sisfb_blank(int blank, + struct fb_info *info); +extern void fbcon_sis_fillrect(struct fb_info *info, + const struct fb_fillrect *rect); +extern void fbcon_sis_copyarea(struct fb_info *info, + const struct fb_copyarea *area); +extern int fbcon_sis_sync(struct fb_info *info); #endif - + /* Internal 2D accelerator functions */ -extern int sisfb_initaccel(struct sis_video_info *ivideo); -extern void sisfb_syncaccel(struct sis_video_info *ivideo); +extern int sisfb_initaccel(struct sis_video_info *ivideo); +extern void sisfb_syncaccel(struct sis_video_info *ivideo); /* Internal general routines */ -static void sisfb_search_mode(char *name, BOOLEAN quiet); -static int sisfb_validate_mode(struct sis_video_info *ivideo, int modeindex, u32 vbflags); -static u8 sisfb_search_refresh_rate(struct sis_video_info *ivideo, unsigned int rate, - int index); -static int sisfb_setcolreg(unsigned regno, unsigned red, unsigned green, - unsigned blue, unsigned transp, - struct fb_info *fb_info); -static int sisfb_do_set_var(struct fb_var_screeninfo *var, int isactive, - struct fb_info *info); -static void sisfb_pre_setmode(struct sis_video_info *ivideo); -static void sisfb_post_setmode(struct sis_video_info *ivideo); -static BOOLEAN sisfb_CheckVBRetrace(struct sis_video_info *ivideo); -static BOOLEAN sisfbcheckvretracecrt2(struct sis_video_info *ivideo); -static BOOLEAN sisfbcheckvretracecrt1(struct sis_video_info *ivideo); -static BOOLEAN sisfb_bridgeisslave(struct sis_video_info *ivideo); -static void sisfb_detect_VB_connect(struct sis_video_info *ivideo); -static void sisfb_get_VB_type(struct sis_video_info *ivideo); -static void sisfb_set_TVxposoffset(struct sis_video_info *ivideo, int val); -static void sisfb_set_TVyposoffset(struct sis_video_info *ivideo, int val); +static void sisfb_search_mode(char *name, BOOLEAN quiet); +static int sisfb_validate_mode(struct sis_video_info *ivideo, int modeindex, u32 vbflags); +static u8 sisfb_search_refresh_rate(struct sis_video_info *ivideo, unsigned int rate, + int index); +static int sisfb_setcolreg(unsigned regno, unsigned red, unsigned green, + unsigned blue, unsigned transp, + struct fb_info *fb_info); +static int sisfb_do_set_var(struct fb_var_screeninfo *var, int isactive, + struct fb_info *info); +static void sisfb_pre_setmode(struct sis_video_info *ivideo); +static void sisfb_post_setmode(struct sis_video_info *ivideo); +static BOOLEAN sisfb_CheckVBRetrace(struct sis_video_info *ivideo); +static BOOLEAN sisfbcheckvretracecrt2(struct sis_video_info *ivideo); +static BOOLEAN sisfbcheckvretracecrt1(struct sis_video_info *ivideo); +static BOOLEAN sisfb_bridgeisslave(struct sis_video_info *ivideo); +static void sisfb_detect_VB_connect(struct sis_video_info *ivideo); +static void sisfb_get_VB_type(struct sis_video_info *ivideo); +static void sisfb_set_TVxposoffset(struct sis_video_info *ivideo, int val); +static void sisfb_set_TVyposoffset(struct sis_video_info *ivideo, int val); +#ifdef CONFIG_FB_SIS_300 +unsigned int sisfb_read_nbridge_pci_dword(struct SiS_Private *SiS_Pr, int reg); +void sisfb_write_nbridge_pci_dword(struct SiS_Private *SiS_Pr, int reg, unsigned int val); +unsigned int sisfb_read_lpc_pci_dword(struct SiS_Private *SiS_Pr, int reg); +#endif +#ifdef CONFIG_FB_SIS_315 +void sisfb_write_nbridge_pci_byte(struct SiS_Private *SiS_Pr, int reg, unsigned char val); +unsigned int sisfb_read_mio_pci_word(struct SiS_Private *SiS_Pr, int reg); +#endif /* SiS-specific exported functions */ -void sis_malloc(struct sis_memreq *req); -void sis_free(u32 base); +void sis_malloc(struct sis_memreq *req); +void sis_malloc_new(struct pci_dev *pdev, struct sis_memreq *req); +void sis_free(u32 base); +void sis_free_new(struct pci_dev *pdev, u32 base); /* Internal heap routines */ -static int sisfb_heap_init(struct sis_video_info *ivideo); -static SIS_OH *sisfb_poh_new_node(void); -static SIS_OH *sisfb_poh_allocate(u32 size); -static void sisfb_delete_node(SIS_OH *poh); -static void sisfb_insert_node(SIS_OH *pohList, SIS_OH *poh); -static SIS_OH *sisfb_poh_free(u32 base); -static void sisfb_free_node(SIS_OH *poh); - -/* Sensing routines */ -static void SiS_Sense30x(struct sis_video_info *ivideo); -static void SiS_SenseCh(struct sis_video_info *ivideo); +static int sisfb_heap_init(struct sis_video_info *ivideo); +static struct SIS_OH * sisfb_poh_new_node(struct SIS_HEAP *memheap); +static struct SIS_OH * sisfb_poh_allocate(struct SIS_HEAP *memheap, u32 size); +static void sisfb_delete_node(struct SIS_OH *poh); +static void sisfb_insert_node(struct SIS_OH *pohList, struct SIS_OH *poh); +static struct SIS_OH * sisfb_poh_free(struct SIS_HEAP *memheap, u32 base); +static void sisfb_free_node(struct SIS_HEAP *memheap, struct SIS_OH *poh); /* Routines from init.c/init301.c */ -extern USHORT SiS_GetModeID_LCD(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth, - BOOLEAN FSTN, USHORT CustomT, int LCDwith, int LCDheight); -extern USHORT SiS_GetModeID_TV(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth); -extern USHORT SiS_GetModeID_VGA2(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth); - -extern void SiSRegInit(SiS_Private *SiS_Pr, SISIOADDRESS BaseAddr); -extern BOOLEAN SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwDeviceInfo, USHORT ModeNo); -extern void SiS_SetEnableDstn(SiS_Private *SiS_Pr, int enable); -extern void SiS_SetEnableFstn(SiS_Private *SiS_Pr, int enable); - -extern BOOLEAN SiSDetermineROMLayout661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); - -extern BOOLEAN sisfb_gettotalfrommode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwDeviceExtension, - unsigned char modeno, int *htotal, int *vtotal, unsigned char rateindex); +extern unsigned short SiS_GetModeID_LCD(int VGAEngine, unsigned int VBFlags, int HDisplay, + int VDisplay, int Depth, BOOLEAN FSTN, unsigned short CustomT, + int LCDwith, int LCDheight, unsigned int VBFlags2); +extern unsigned short SiS_GetModeID_TV(int VGAEngine, unsigned int VBFlags, int HDisplay, + int VDisplay, int Depth, unsigned int VBFlags2); +extern unsigned short SiS_GetModeID_VGA2(int VGAEngine, unsigned int VBFlags, int HDisplay, + int VDisplay, int Depth, unsigned int VBFlags2); +extern void SiSRegInit(struct SiS_Private *SiS_Pr, SISIOADDRESS BaseAddr); +extern BOOLEAN SiSSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo); +extern void SiS_SetEnableDstn(struct SiS_Private *SiS_Pr, int enable); +extern void SiS_SetEnableFstn(struct SiS_Private *SiS_Pr, int enable); + +extern BOOLEAN SiSDetermineROMLayout661(struct SiS_Private *SiS_Pr); + +extern BOOLEAN sisfb_gettotalfrommode(struct SiS_Private *SiS_Pr, unsigned char modeno, + int *htotal, int *vtotal, unsigned char rateindex); #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) -extern int sisfb_mode_rate_to_dclock(SiS_Private *SiS_Pr, - PSIS_HW_INFO HwDeviceExtension, - unsigned char modeno, unsigned char rateindex); -extern int sisfb_mode_rate_to_ddata(SiS_Private *SiS_Pr, PSIS_HW_INFO HwDeviceExtension, - unsigned char modeno, unsigned char rateindex, - struct fb_var_screeninfo *var); +extern int sisfb_mode_rate_to_dclock(struct SiS_Private *SiS_Pr, + unsigned char modeno, unsigned char rateindex); +extern int sisfb_mode_rate_to_ddata(struct SiS_Private *SiS_Pr, unsigned char modeno, + unsigned char rateindex, struct fb_var_screeninfo *var); +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) +extern void SiS_Generic_ConvertCRData(struct SiS_Private *SiS_Pr, unsigned char *crdata, int xres, + int yres, struct fb_var_screeninfo *var, BOOLEAN writeres); #endif /* Chrontel TV, DDC and DPMS functions */ -extern USHORT SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempbx); -extern void SiS_SetCH700x(SiS_Private *SiS_Pr, USHORT tempbx); -extern USHORT SiS_GetCH701x(SiS_Private *SiS_Pr, USHORT tempbx); -extern void SiS_SetCH701x(SiS_Private *SiS_Pr, USHORT tempbx); -extern void SiS_SetCH70xxANDOR(SiS_Private *SiS_Pr, USHORT tempax,USHORT tempbh); -extern void SiS_DDC2Delay(SiS_Private *SiS_Pr, USHORT delaytime); -extern void SiS_SetChrontelGPIO(SiS_Private *SiS_Pr, USHORT myvbinfo); -extern USHORT SiS_HandleDDC(SiS_Private *SiS_Pr, ULONG VBFlags, int VGAEngine, - USHORT adaptnum, USHORT DDCdatatype, unsigned char *buffer); -extern USHORT SiS_ReadDDC1Bit(SiS_Private *SiS_Pr); -extern void SiS_Chrontel701xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwDeviceInfo); -extern void SiS_Chrontel701xBLOff(SiS_Private *SiS_Pr); -extern void SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwDeviceInfo); -extern void SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwDeviceInfo); +extern unsigned short SiS_GetCH700x(struct SiS_Private *SiS_Pr, unsigned short reg); +extern void SiS_SetCH700x(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val); +extern unsigned short SiS_GetCH701x(struct SiS_Private *SiS_Pr, unsigned short reg); +extern void SiS_SetCH701x(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val); +extern void SiS_SetCH70xxANDOR(struct SiS_Private *SiS_Pr, unsigned short reg, + unsigned char myor, unsigned char myand); +extern void SiS_DDC2Delay(struct SiS_Private *SiS_Pr, unsigned int delaytime); +extern void SiS_SetChrontelGPIO(struct SiS_Private *SiS_Pr, unsigned short myvbinfo); +extern unsigned short SiS_HandleDDC(struct SiS_Private *SiS_Pr, unsigned int VBFlags, int VGAEngine, + unsigned short adaptnum, unsigned short DDCdatatype, unsigned char *buffer, + unsigned int VBFlags2); +extern unsigned short SiS_ReadDDC1Bit(struct SiS_Private *SiS_Pr); +#ifdef CONFIG_FB_SIS_315 +extern void SiS_Chrontel701xBLOn(struct SiS_Private *SiS_Pr); +extern void SiS_Chrontel701xBLOff(struct SiS_Private *SiS_Pr); +#endif +extern void SiS_SiS30xBLOn(struct SiS_Private *SiS_Pr); +extern void SiS_SiS30xBLOff(struct SiS_Private *SiS_Pr); #endif diff --git a/drivers/video/sis/vgatypes.h b/drivers/video/sis/vgatypes.h index 507bba1a71b..831b9f42264 100644 --- a/drivers/video/sis/vgatypes.h +++ b/drivers/video/sis/vgatypes.h @@ -3,7 +3,7 @@ /* * General type definitions for universal mode switching modules * - * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2005 by Thomas Winischhofer, Vienna, Austria * * If distributed as part of the Linux kernel, the following license terms * apply: @@ -50,11 +50,10 @@ * */ -#ifndef _VGATYPES_ -#define _VGATYPES_ +#ifndef _VGATYPES_H_ +#define _VGATYPES_H_ -#ifdef LINUX_KERNEL /* We don't want the X driver to depend on kernel source */ -#include <linux/ioctl.h> +#ifdef SIS_LINUX_KERNEL #include <linux/version.h> #endif @@ -66,41 +65,13 @@ #define TRUE 1 #endif -#ifndef NULL -#define NULL 0 -#endif - -#ifndef CHAR -typedef char CHAR; -#endif - -#ifndef SHORT -typedef short SHORT; -#endif - -#ifndef LONG -typedef long LONG; -#endif - -#ifndef UCHAR -typedef unsigned char UCHAR; -#endif - -#ifndef USHORT -typedef unsigned short USHORT; -#endif - -#ifndef ULONG -typedef unsigned long ULONG; -#endif - #ifndef BOOLEAN -typedef unsigned char BOOLEAN; +typedef unsigned int BOOLEAN; #endif #define SISIOMEMTYPE -#ifdef LINUX_KERNEL +#ifdef SIS_LINUX_KERNEL typedef unsigned long SISIOADDRESS; #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,8) #include <linux/types.h> /* Need __iomem */ @@ -109,7 +80,7 @@ typedef unsigned long SISIOADDRESS; #endif #endif -#ifdef LINUX_XF86 +#ifdef SIS_XORG_XF86 #if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,0,0,0) typedef unsigned long IOADDRESS; typedef unsigned long SISIOADDRESS; @@ -118,7 +89,7 @@ typedef IOADDRESS SISIOADDRESS; #endif #endif -enum _SIS_CHIP_TYPE { +typedef enum _SIS_CHIP_TYPE { SIS_VGALegacy = 0, SIS_530, SIS_OLD, @@ -128,115 +99,27 @@ enum _SIS_CHIP_TYPE { SIS_540, SIS_315H, /* SiS 310 */ SIS_315, - SIS_315PRO, + SIS_315PRO, /* SiS 325 */ SIS_550, SIS_650, SIS_740, SIS_330, SIS_661, SIS_741, - SIS_660, + SIS_670, + SIS_660 = 35, SIS_760, SIS_761, - SIS_340, + SIS_762, + SIS_770, + SIS_340 = 55, + SIS_341, + SIS_342, + XGI_20 = 75, + XGI_40, MAX_SIS_CHIP -}; - -#ifndef SIS_HW_INFO -typedef struct _SIS_HW_INFO SIS_HW_INFO, *PSIS_HW_INFO; - -struct _SIS_HW_INFO -{ -#ifdef LINUX_XF86 - PCITAG PciTag; /* PCI Tag */ -#endif - - UCHAR *pjVirtualRomBase; /* ROM image */ - - BOOLEAN UseROM; /* Use the ROM image if provided */ - -#ifdef LINUX_KERNEL - UCHAR SISIOMEMTYPE *pjVideoMemoryAddress; - /* base virtual memory address */ - /* of Linear VGA memory */ - - ULONG ulVideoMemorySize; /* size, in bytes, of the memory on the board */ -#endif - - SISIOADDRESS ulIOAddress; /* base I/O address of VGA ports (0x3B0; relocated) */ - - UCHAR jChipType; /* Used to Identify SiS Graphics Chip */ - /* defined in the enum "SIS_CHIP_TYPE" (above or sisfb.h) */ +} SIS_CHIP_TYPE; - UCHAR jChipRevision; /* Used to Identify SiS Graphics Chip Revision */ - - BOOLEAN bIntegratedMMEnabled;/* supporting integration MM enable */ -}; -#endif - -/* Addtional IOCTLs for communication sisfb <> X driver */ -/* If changing this, sisfb.h must also be changed (for sisfb) */ - -#ifdef LINUX_XF86 /* We don't want the X driver to depend on the kernel source */ - -/* ioctl for identifying and giving some info (esp. memory heap start) */ -#define SISFB_GET_INFO_SIZE 0x8004f300 -#define SISFB_GET_INFO 0x8000f301 /* Must be patched with result from ..._SIZE at D[29:16] */ -/* deprecated ioctl number (for older versions of sisfb) */ -#define SISFB_GET_INFO_OLD 0x80046ef8 - -/* ioctls for tv parameters (position) */ -#define SISFB_SET_TVPOSOFFSET 0x4004f304 - -/* lock sisfb from register access */ -#define SISFB_SET_LOCK 0x4004f306 - -/* Structure argument for SISFB_GET_INFO ioctl */ -typedef struct _SISFB_INFO sisfb_info, *psisfb_info; - -struct _SISFB_INFO { - CARD32 sisfb_id; /* for identifying sisfb */ -#ifndef SISFB_ID -#define SISFB_ID 0x53495346 /* Identify myself with 'SISF' */ -#endif - CARD32 chip_id; /* PCI ID of detected chip */ - CARD32 memory; /* video memory in KB which sisfb manages */ - CARD32 heapstart; /* heap start (= sisfb "mem" argument) in KB */ - CARD8 fbvidmode; /* current sisfb mode */ - - CARD8 sisfb_version; - CARD8 sisfb_revision; - CARD8 sisfb_patchlevel; - - CARD8 sisfb_caps; /* sisfb's capabilities */ - - CARD32 sisfb_tqlen; /* turbo queue length (in KB) */ - - CARD32 sisfb_pcibus; /* The card's PCI ID */ - CARD32 sisfb_pcislot; - CARD32 sisfb_pcifunc; - - CARD8 sisfb_lcdpdc; - - CARD8 sisfb_lcda; - - CARD32 sisfb_vbflags; - CARD32 sisfb_currentvbflags; - - CARD32 sisfb_scalelcd; - CARD32 sisfb_specialtiming; - - CARD8 sisfb_haveemi; - CARD8 sisfb_emi30,sisfb_emi31,sisfb_emi32,sisfb_emi33; - CARD8 sisfb_haveemilcd; - - CARD8 sisfb_lcdpdca; - - CARD16 sisfb_tvxpos, sisfb_tvypos; /* Warning: Values + 32 ! */ - - CARD8 reserved[208]; /* for future use */ -}; -#endif #endif diff --git a/drivers/video/sis/vstruct.h b/drivers/video/sis/vstruct.h index d4d55c98bce..9ae32923c14 100644 --- a/drivers/video/sis/vstruct.h +++ b/drivers/video/sis/vstruct.h @@ -3,7 +3,7 @@ /* * General structure definitions for universal mode switching modules * - * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2005 by Thomas Winischhofer, Vienna, Austria * * If distributed as part of the Linux kernel, the following license terms * apply: @@ -50,627 +50,514 @@ * */ -#ifndef _VSTRUCT_ -#define _VSTRUCT_ - -typedef struct _SiS_PanelDelayTblStruct -{ - UCHAR timer[2]; -} SiS_PanelDelayTblStruct; - -typedef struct _SiS_LCDDataStruct -{ - USHORT RVBHCMAX; - USHORT RVBHCFACT; - USHORT VGAHT; - USHORT VGAVT; - USHORT LCDHT; - USHORT LCDVT; -} SiS_LCDDataStruct; - -typedef struct _SiS_TVDataStruct -{ - USHORT RVBHCMAX; - USHORT RVBHCFACT; - USHORT VGAHT; - USHORT VGAVT; - USHORT TVHDE; - USHORT TVVDE; - USHORT RVBHRS; - UCHAR FlickerMode; - USHORT HALFRVBHRS; - UCHAR RY1COE; - UCHAR RY2COE; - UCHAR RY3COE; - UCHAR RY4COE; -} SiS_TVDataStruct; - -typedef struct _SiS_LVDSDataStruct -{ - USHORT VGAHT; - USHORT VGAVT; - USHORT LCDHT; - USHORT LCDVT; -} SiS_LVDSDataStruct; - -typedef struct _SiS_LVDSDesStruct -{ - USHORT LCDHDES; - USHORT LCDVDES; -} SiS_LVDSDesStruct; - -typedef struct _SiS_LVDSCRT1DataStruct -{ - UCHAR CR[15]; -} SiS_LVDSCRT1DataStruct; - -typedef struct _SiS_LCDACRT1DataStruct -{ - UCHAR CR[17]; -} SiS_LCDACRT1DataStruct; - -typedef struct _SiS_CHTVRegDataStruct -{ - UCHAR Reg[16]; -} SiS_CHTVRegDataStruct; - -typedef struct _SiS_StStruct -{ - UCHAR St_ModeID; - USHORT St_ModeFlag; - UCHAR St_StTableIndex; - UCHAR St_CRT2CRTC; - UCHAR St_ResInfo; - UCHAR VB_StTVFlickerIndex; - UCHAR VB_StTVEdgeIndex; - UCHAR VB_StTVYFilterIndex; - UCHAR St_PDC; -} SiS_StStruct; - -typedef struct _SiS_VBModeStruct -{ - UCHAR ModeID; - UCHAR VB_TVDelayIndex; - UCHAR VB_TVFlickerIndex; - UCHAR VB_TVPhaseIndex; - UCHAR VB_TVYFilterIndex; - UCHAR VB_LCDDelayIndex; - UCHAR _VB_LCDHIndex; - UCHAR _VB_LCDVIndex; -} SiS_VBModeStruct; - -typedef struct _SiS_StandTableStruct -{ - UCHAR CRT_COLS; - UCHAR ROWS; - UCHAR CHAR_HEIGHT; - USHORT CRT_LEN; - UCHAR SR[4]; - UCHAR MISC; - UCHAR CRTC[0x19]; - UCHAR ATTR[0x14]; - UCHAR GRC[9]; -} SiS_StandTableStruct; - -typedef struct _SiS_ExtStruct -{ - UCHAR Ext_ModeID; - USHORT Ext_ModeFlag; - USHORT Ext_VESAID; - UCHAR Ext_RESINFO; - UCHAR VB_ExtTVFlickerIndex; - UCHAR VB_ExtTVEdgeIndex; - UCHAR VB_ExtTVYFilterIndex; - UCHAR VB_ExtTVYFilterIndexROM661; - UCHAR REFindex; - CHAR ROMMODEIDX661; -} SiS_ExtStruct; - -typedef struct _SiS_Ext2Struct -{ - USHORT Ext_InfoFlag; - UCHAR Ext_CRT1CRTC; - UCHAR Ext_CRTVCLK; - UCHAR Ext_CRT2CRTC; - UCHAR Ext_CRT2CRTC_NS; - UCHAR ModeID; - USHORT XRes; - USHORT YRes; - UCHAR Ext_PDC; -} SiS_Ext2Struct; - -typedef struct _SiS_Part2PortTblStruct -{ - UCHAR CR[12]; -} SiS_Part2PortTblStruct; - -typedef struct _SiS_CRT1TableStruct -{ - UCHAR CR[17]; -} SiS_CRT1TableStruct; - -typedef struct _SiS_MCLKDataStruct -{ - UCHAR SR28,SR29,SR2A; - USHORT CLOCK; -} SiS_MCLKDataStruct; - -typedef struct _SiS_VCLKDataStruct -{ - UCHAR SR2B,SR2C; - USHORT CLOCK; -} SiS_VCLKDataStruct; - -typedef struct _SiS_VBVCLKDataStruct -{ - UCHAR Part4_A,Part4_B; - USHORT CLOCK; -} SiS_VBVCLKDataStruct; - -typedef struct _SiS_StResInfoStruct -{ - USHORT HTotal; - USHORT VTotal; -} SiS_StResInfoStruct; - -typedef struct _SiS_ModeResInfoStruct -{ - USHORT HTotal; - USHORT VTotal; - UCHAR XChar; - UCHAR YChar; -} SiS_ModeResInfoStruct; - - - -typedef UCHAR DRAM4Type[4]; +#ifndef _VSTRUCT_H_ +#define _VSTRUCT_H_ + +struct SiS_PanelDelayTbl { + unsigned char timer[2]; +}; + +struct SiS_LCDData { + unsigned short RVBHCMAX; + unsigned short RVBHCFACT; + unsigned short VGAHT; + unsigned short VGAVT; + unsigned short LCDHT; + unsigned short LCDVT; +}; + +struct SiS_TVData { + unsigned short RVBHCMAX; + unsigned short RVBHCFACT; + unsigned short VGAHT; + unsigned short VGAVT; + unsigned short TVHDE; + unsigned short TVVDE; + unsigned short RVBHRS; + unsigned char FlickerMode; + unsigned short HALFRVBHRS; + unsigned short RVBHRS2; + unsigned char RY1COE; + unsigned char RY2COE; + unsigned char RY3COE; + unsigned char RY4COE; +}; + +struct SiS_LVDSData { + unsigned short VGAHT; + unsigned short VGAVT; + unsigned short LCDHT; + unsigned short LCDVT; +}; + +struct SiS_LVDSDes { + unsigned short LCDHDES; + unsigned short LCDVDES; +}; + +struct SiS_LVDSCRT1Data { + unsigned char CR[15]; +}; + +struct SiS_CHTVRegData { + unsigned char Reg[16]; +}; + +struct SiS_St { + unsigned char St_ModeID; + unsigned short St_ModeFlag; + unsigned char St_StTableIndex; + unsigned char St_CRT2CRTC; + unsigned char St_ResInfo; + unsigned char VB_StTVFlickerIndex; + unsigned char VB_StTVEdgeIndex; + unsigned char VB_StTVYFilterIndex; + unsigned char St_PDC; +}; + +struct SiS_VBMode { + unsigned char ModeID; + unsigned char VB_TVDelayIndex; + unsigned char VB_TVFlickerIndex; + unsigned char VB_TVPhaseIndex; + unsigned char VB_TVYFilterIndex; + unsigned char VB_LCDDelayIndex; + unsigned char _VB_LCDHIndex; + unsigned char _VB_LCDVIndex; +}; + +struct SiS_StandTable_S { + unsigned char CRT_COLS; + unsigned char ROWS; + unsigned char CHAR_HEIGHT; + unsigned short CRT_LEN; + unsigned char SR[4]; + unsigned char MISC; + unsigned char CRTC[0x19]; + unsigned char ATTR[0x14]; + unsigned char GRC[9]; +}; + +struct SiS_Ext { + unsigned char Ext_ModeID; + unsigned short Ext_ModeFlag; + unsigned short Ext_VESAID; + unsigned char Ext_RESINFO; + unsigned char VB_ExtTVFlickerIndex; + unsigned char VB_ExtTVEdgeIndex; + unsigned char VB_ExtTVYFilterIndex; + unsigned char VB_ExtTVYFilterIndexROM661; + unsigned char REFindex; + char ROMMODEIDX661; +}; + +struct SiS_Ext2 { + unsigned short Ext_InfoFlag; + unsigned char Ext_CRT1CRTC; + unsigned char Ext_CRTVCLK; + unsigned char Ext_CRT2CRTC; + unsigned char Ext_CRT2CRTC_NS; + unsigned char ModeID; + unsigned short XRes; + unsigned short YRes; + unsigned char Ext_PDC; + unsigned char Ext_FakeCRT2CRTC; + unsigned char Ext_FakeCRT2Clk; + unsigned char Ext_CRT1CRTC_NORM; + unsigned char Ext_CRTVCLK_NORM; + unsigned char Ext_CRT1CRTC_WIDE; + unsigned char Ext_CRTVCLK_WIDE; +}; + +struct SiS_Part2PortTbl { + unsigned char CR[12]; +}; + +struct SiS_CRT1Table { + unsigned char CR[17]; +}; + +struct SiS_MCLKData { + unsigned char SR28,SR29,SR2A; + unsigned short CLOCK; +}; + +struct SiS_VCLKData { + unsigned char SR2B,SR2C; + unsigned short CLOCK; +}; + +struct SiS_VBVCLKData { + unsigned char Part4_A,Part4_B; + unsigned short CLOCK; +}; + +struct SiS_StResInfo_S { + unsigned short HTotal; + unsigned short VTotal; +}; + +struct SiS_ModeResInfo_S { + unsigned short HTotal; + unsigned short VTotal; + unsigned char XChar; + unsigned char YChar; +}; /* Defines for SiS_CustomT */ /* Never change these for sisfb compatibility */ -#define CUT_NONE 0 -#define CUT_FORCENONE 1 -#define CUT_BARCO1366 2 -#define CUT_BARCO1024 3 -#define CUT_COMPAQ1280 4 -#define CUT_COMPAQ12802 5 -#define CUT_PANEL848 6 -#define CUT_CLEVO1024 7 -#define CUT_CLEVO10242 8 -#define CUT_CLEVO1400 9 -#define CUT_CLEVO14002 10 -#define CUT_UNIWILL1024 11 -#define CUT_ASUSL3000D 12 -#define CUT_UNIWILL10242 13 -#define CUT_ACER1280 14 -#define CUT_COMPAL1400_1 15 -#define CUT_COMPAL1400_2 16 -#define CUT_ASUSA2H_1 17 -#define CUT_ASUSA2H_2 18 - -typedef struct _SiS_Private +#define CUT_NONE 0 +#define CUT_FORCENONE 1 +#define CUT_BARCO1366 2 +#define CUT_BARCO1024 3 +#define CUT_COMPAQ1280 4 +#define CUT_COMPAQ12802 5 +#define CUT_PANEL848 6 +#define CUT_CLEVO1024 7 +#define CUT_CLEVO10242 8 +#define CUT_CLEVO1400 9 +#define CUT_CLEVO14002 10 +#define CUT_UNIWILL1024 11 +#define CUT_ASUSL3000D 12 +#define CUT_UNIWILL10242 13 +#define CUT_ACER1280 14 +#define CUT_COMPAL1400_1 15 +#define CUT_COMPAL1400_2 16 +#define CUT_ASUSA2H_1 17 +#define CUT_ASUSA2H_2 18 +#define CUT_UNKNOWNLCD 19 +#define CUT_AOP8060 20 +#define CUT_PANEL856 21 + +struct SiS_Private { -#ifdef LINUX_KERNEL - SISIOADDRESS RelIO; + unsigned char ChipType; + unsigned char ChipRevision; +#ifdef SIS_XORG_XF86 + PCITAG PciTag; #endif - SISIOADDRESS SiS_P3c4; - SISIOADDRESS SiS_P3d4; - SISIOADDRESS SiS_P3c0; - SISIOADDRESS SiS_P3ce; - SISIOADDRESS SiS_P3c2; - SISIOADDRESS SiS_P3ca; - SISIOADDRESS SiS_P3c6; - SISIOADDRESS SiS_P3c7; - SISIOADDRESS SiS_P3c8; - SISIOADDRESS SiS_P3c9; - SISIOADDRESS SiS_P3cb; - SISIOADDRESS SiS_P3cd; - SISIOADDRESS SiS_P3da; - SISIOADDRESS SiS_Part1Port; - SISIOADDRESS SiS_Part2Port; - SISIOADDRESS SiS_Part3Port; - SISIOADDRESS SiS_Part4Port; - SISIOADDRESS SiS_Part5Port; - SISIOADDRESS SiS_VidCapt; - SISIOADDRESS SiS_VidPlay; - USHORT SiS_IF_DEF_LVDS; - USHORT SiS_IF_DEF_CH70xx; - USHORT SiS_IF_DEF_CONEX; - USHORT SiS_IF_DEF_TRUMPION; - USHORT SiS_IF_DEF_DSTN; - USHORT SiS_IF_DEF_FSTN; - USHORT SiS_SysFlags; - UCHAR SiS_VGAINFO; -#ifdef LINUX_XF86 - USHORT SiS_CP1, SiS_CP2, SiS_CP3, SiS_CP4; +#ifdef SIS_LINUX_KERNEL + void *ivideo; #endif - BOOLEAN SiS_UseROM; - BOOLEAN SiS_ROMNew; - BOOLEAN SiS_NeedRomModeData; - BOOLEAN PanelSelfDetected; - int SiS_CHOverScan; - BOOLEAN SiS_CHSOverScan; - BOOLEAN SiS_ChSW; - BOOLEAN SiS_UseLCDA; - int SiS_UseOEM; - ULONG SiS_CustomT; - USHORT SiS_Backup70xx; - BOOLEAN HaveEMI; - BOOLEAN HaveEMILCD; - BOOLEAN OverruleEMI; - UCHAR EMI_30,EMI_31,EMI_32,EMI_33; - USHORT SiS_EMIOffset; - SHORT PDC, PDCA; - UCHAR SiS_MyCR63; - USHORT SiS_CRT1Mode; - USHORT SiS_flag_clearbuffer; - int SiS_RAMType; - UCHAR SiS_ChannelAB; - UCHAR SiS_DataBusWidth; - USHORT SiS_ModeType; - USHORT SiS_VBInfo; - USHORT SiS_TVMode; - USHORT SiS_LCDResInfo; - USHORT SiS_LCDTypeInfo; - USHORT SiS_LCDInfo; - USHORT SiS_LCDInfo661; - USHORT SiS_VBType; - USHORT SiS_VBExtInfo; - USHORT SiS_YPbPr; - USHORT SiS_SelectCRT2Rate; - USHORT SiS_SetFlag; - USHORT SiS_RVBHCFACT; - USHORT SiS_RVBHCMAX; - USHORT SiS_RVBHRS; - USHORT SiS_VGAVT; - USHORT SiS_VGAHT; - USHORT SiS_VT; - USHORT SiS_HT; - USHORT SiS_VGAVDE; - USHORT SiS_VGAHDE; - USHORT SiS_VDE; - USHORT SiS_HDE; - USHORT SiS_NewFlickerMode; - USHORT SiS_RY1COE; - USHORT SiS_RY2COE; - USHORT SiS_RY3COE; - USHORT SiS_RY4COE; - USHORT SiS_LCDHDES; - USHORT SiS_LCDVDES; - USHORT SiS_DDC_Port; - USHORT SiS_DDC_Index; - USHORT SiS_DDC_Data; - USHORT SiS_DDC_NData; - USHORT SiS_DDC_Clk; - USHORT SiS_DDC_NClk; - USHORT SiS_DDC_DeviceAddr; - USHORT SiS_DDC_ReadAddr; - USHORT SiS_DDC_SecAddr; - USHORT SiS_ChrontelInit; - BOOLEAN SiS_SensibleSR11; - USHORT SiS661LCD2TableSize; - - USHORT SiS_PanelMinLVDS; - USHORT SiS_PanelMin301; - - const SiS_StStruct *SiS_SModeIDTable; - const SiS_StandTableStruct *SiS_StandTable; - const SiS_ExtStruct *SiS_EModeIDTable; - const SiS_Ext2Struct *SiS_RefIndex; - const SiS_VBModeStruct *SiS_VBModeIDTable; - const SiS_CRT1TableStruct *SiS_CRT1Table; - const SiS_MCLKDataStruct *SiS_MCLKData_0; - const SiS_MCLKDataStruct *SiS_MCLKData_1; - SiS_VCLKDataStruct *SiS_VCLKData; - SiS_VBVCLKDataStruct *SiS_VBVCLKData; - const SiS_StResInfoStruct *SiS_StResInfo; - const SiS_ModeResInfoStruct *SiS_ModeResInfo; - - const UCHAR *pSiS_OutputSelect; - const UCHAR *pSiS_SoftSetting; - - const DRAM4Type *SiS_SR15; /* pointer : point to array */ -#ifdef LINUX_KERNEL - UCHAR *pSiS_SR07; - const DRAM4Type *SiS_CR40; /* pointer : point to array */ - UCHAR *SiS_CR49; - UCHAR *SiS_SR25; - UCHAR *pSiS_SR1F; - UCHAR *pSiS_SR21; - UCHAR *pSiS_SR22; - UCHAR *pSiS_SR23; - UCHAR *pSiS_SR24; - UCHAR *pSiS_SR31; - UCHAR *pSiS_SR32; - UCHAR *pSiS_SR33; - UCHAR *pSiS_CRT2Data_1_2; - UCHAR *pSiS_CRT2Data_4_D; - UCHAR *pSiS_CRT2Data_4_E; - UCHAR *pSiS_CRT2Data_4_10; - const USHORT *pSiS_RGBSenseData; - const USHORT *pSiS_VideoSenseData; - const USHORT *pSiS_YCSenseData; - const USHORT *pSiS_RGBSenseData2; - const USHORT *pSiS_VideoSenseData2; - const USHORT *pSiS_YCSenseData2; + unsigned char *VirtualRomBase; + BOOLEAN UseROM; +#ifdef SIS_LINUX_KERNEL + unsigned char SISIOMEMTYPE *VideoMemoryAddress; + unsigned int VideoMemorySize; #endif + SISIOADDRESS IOAddress; + SISIOADDRESS IOAddress2; /* For dual chip XGI volari */ - const SiS_PanelDelayTblStruct *SiS_PanelDelayTbl; - const SiS_PanelDelayTblStruct *SiS_PanelDelayTblLVDS; +#ifdef SIS_LINUX_KERNEL + SISIOADDRESS RelIO; +#endif + SISIOADDRESS SiS_P3c4; + SISIOADDRESS SiS_P3d4; + SISIOADDRESS SiS_P3c0; + SISIOADDRESS SiS_P3ce; + SISIOADDRESS SiS_P3c2; + SISIOADDRESS SiS_P3ca; + SISIOADDRESS SiS_P3c6; + SISIOADDRESS SiS_P3c7; + SISIOADDRESS SiS_P3c8; + SISIOADDRESS SiS_P3c9; + SISIOADDRESS SiS_P3cb; + SISIOADDRESS SiS_P3cc; + SISIOADDRESS SiS_P3cd; + SISIOADDRESS SiS_P3da; + SISIOADDRESS SiS_Part1Port; + SISIOADDRESS SiS_Part2Port; + SISIOADDRESS SiS_Part3Port; + SISIOADDRESS SiS_Part4Port; + SISIOADDRESS SiS_Part5Port; + SISIOADDRESS SiS_VidCapt; + SISIOADDRESS SiS_VidPlay; + unsigned short SiS_IF_DEF_LVDS; + unsigned short SiS_IF_DEF_CH70xx; + unsigned short SiS_IF_DEF_CONEX; + unsigned short SiS_IF_DEF_TRUMPION; + unsigned short SiS_IF_DEF_DSTN; + unsigned short SiS_IF_DEF_FSTN; + unsigned short SiS_SysFlags; + unsigned char SiS_VGAINFO; +#ifdef SIS_XORG_XF86 + unsigned short SiS_CP1, SiS_CP2, SiS_CP3, SiS_CP4; +#endif + BOOLEAN SiS_UseROM; + BOOLEAN SiS_ROMNew; + BOOLEAN SiS_XGIROM; + BOOLEAN SiS_NeedRomModeData; + BOOLEAN PanelSelfDetected; + BOOLEAN DDCPortMixup; + int SiS_CHOverScan; + BOOLEAN SiS_CHSOverScan; + BOOLEAN SiS_ChSW; + BOOLEAN SiS_UseLCDA; + int SiS_UseOEM; + unsigned int SiS_CustomT; + int SiS_UseWide, SiS_UseWideCRT2; + int SiS_TVBlue; + unsigned short SiS_Backup70xx; + BOOLEAN HaveEMI; + BOOLEAN HaveEMILCD; + BOOLEAN OverruleEMI; + unsigned char EMI_30,EMI_31,EMI_32,EMI_33; + unsigned short SiS_EMIOffset; + unsigned short SiS_PWDOffset; + short PDC, PDCA; + unsigned char SiS_MyCR63; + unsigned short SiS_CRT1Mode; + unsigned short SiS_flag_clearbuffer; + int SiS_RAMType; + unsigned char SiS_ChannelAB; + unsigned char SiS_DataBusWidth; + unsigned short SiS_ModeType; + unsigned short SiS_VBInfo; + unsigned short SiS_TVMode; + unsigned short SiS_LCDResInfo; + unsigned short SiS_LCDTypeInfo; + unsigned short SiS_LCDInfo; + unsigned short SiS_LCDInfo661; + unsigned short SiS_VBType; + unsigned short SiS_VBExtInfo; + unsigned short SiS_YPbPr; + unsigned short SiS_SelectCRT2Rate; + unsigned short SiS_SetFlag; + unsigned short SiS_RVBHCFACT; + unsigned short SiS_RVBHCMAX; + unsigned short SiS_RVBHRS; + unsigned short SiS_RVBHRS2; + unsigned short SiS_VGAVT; + unsigned short SiS_VGAHT; + unsigned short SiS_VT; + unsigned short SiS_HT; + unsigned short SiS_VGAVDE; + unsigned short SiS_VGAHDE; + unsigned short SiS_VDE; + unsigned short SiS_HDE; + unsigned short SiS_NewFlickerMode; + unsigned short SiS_RY1COE; + unsigned short SiS_RY2COE; + unsigned short SiS_RY3COE; + unsigned short SiS_RY4COE; + unsigned short SiS_LCDHDES; + unsigned short SiS_LCDVDES; + unsigned short SiS_DDC_Port; + unsigned short SiS_DDC_Index; + unsigned short SiS_DDC_Data; + unsigned short SiS_DDC_NData; + unsigned short SiS_DDC_Clk; + unsigned short SiS_DDC_NClk; + unsigned short SiS_DDC_DeviceAddr; + unsigned short SiS_DDC_ReadAddr; + unsigned short SiS_DDC_SecAddr; + unsigned short SiS_ChrontelInit; + BOOLEAN SiS_SensibleSR11; + unsigned short SiS661LCD2TableSize; + + unsigned short SiS_PanelMinLVDS; + unsigned short SiS_PanelMin301; + + const struct SiS_St *SiS_SModeIDTable; + const struct SiS_StandTable_S *SiS_StandTable; + const struct SiS_Ext *SiS_EModeIDTable; + const struct SiS_Ext2 *SiS_RefIndex; + const struct SiS_VBMode *SiS_VBModeIDTable; + const struct SiS_CRT1Table *SiS_CRT1Table; + const struct SiS_MCLKData *SiS_MCLKData_0; + const struct SiS_MCLKData *SiS_MCLKData_1; + struct SiS_VCLKData *SiS_VCLKData; + struct SiS_VBVCLKData *SiS_VBVCLKData; + const struct SiS_StResInfo_S *SiS_StResInfo; + const struct SiS_ModeResInfo_S *SiS_ModeResInfo; + + const unsigned char *pSiS_OutputSelect; + const unsigned char *pSiS_SoftSetting; + + const unsigned char *SiS_SR15; + + const struct SiS_PanelDelayTbl *SiS_PanelDelayTbl; + const struct SiS_PanelDelayTbl *SiS_PanelDelayTblLVDS; /* SiS bridge */ - const UCHAR *SiS_NTSCPhase; - const UCHAR *SiS_PALPhase; - const UCHAR *SiS_NTSCPhase2; - const UCHAR *SiS_PALPhase2; - const UCHAR *SiS_PALMPhase; - const UCHAR *SiS_PALNPhase; - const UCHAR *SiS_PALMPhase2; - const UCHAR *SiS_PALNPhase2; - const UCHAR *SiS_SpecialPhase; - const UCHAR *SiS_SpecialPhaseM; - const UCHAR *SiS_SpecialPhaseJ; - const SiS_LCDDataStruct *SiS_ExtLCD1024x768Data; - const SiS_LCDDataStruct *SiS_St2LCD1024x768Data; - const SiS_LCDDataStruct *SiS_LCD1280x720Data; - const SiS_LCDDataStruct *SiS_StLCD1280x768_2Data; - const SiS_LCDDataStruct *SiS_ExtLCD1280x768_2Data; - const SiS_LCDDataStruct *SiS_LCD1280x800Data; - const SiS_LCDDataStruct *SiS_LCD1280x800_2Data; - const SiS_LCDDataStruct *SiS_LCD1280x960Data; - const SiS_LCDDataStruct *SiS_ExtLCD1280x1024Data; - const SiS_LCDDataStruct *SiS_St2LCD1280x1024Data; - const SiS_LCDDataStruct *SiS_StLCD1400x1050Data; - const SiS_LCDDataStruct *SiS_ExtLCD1400x1050Data; - const SiS_LCDDataStruct *SiS_StLCD1600x1200Data; - const SiS_LCDDataStruct *SiS_ExtLCD1600x1200Data; - const SiS_LCDDataStruct *SiS_LCD1680x1050Data; - const SiS_LCDDataStruct *SiS_NoScaleData; - const SiS_TVDataStruct *SiS_StPALData; - const SiS_TVDataStruct *SiS_ExtPALData; - const SiS_TVDataStruct *SiS_StNTSCData; - const SiS_TVDataStruct *SiS_ExtNTSCData; - const SiS_TVDataStruct *SiS_St1HiTVData; - const SiS_TVDataStruct *SiS_St2HiTVData; - const SiS_TVDataStruct *SiS_ExtHiTVData; - const SiS_TVDataStruct *SiS_St525iData; - const SiS_TVDataStruct *SiS_St525pData; - const SiS_TVDataStruct *SiS_St750pData; - const SiS_TVDataStruct *SiS_Ext525iData; - const SiS_TVDataStruct *SiS_Ext525pData; - const SiS_TVDataStruct *SiS_Ext750pData; - const UCHAR *SiS_NTSCTiming; - const UCHAR *SiS_PALTiming; - const UCHAR *SiS_HiTVExtTiming; - const UCHAR *SiS_HiTVSt1Timing; - const UCHAR *SiS_HiTVSt2Timing; - const UCHAR *SiS_HiTVGroup3Data; - const UCHAR *SiS_HiTVGroup3Simu; + const struct SiS_LCDData *SiS_ExtLCD1024x768Data; + const struct SiS_LCDData *SiS_St2LCD1024x768Data; + const struct SiS_LCDData *SiS_LCD1280x720Data; + const struct SiS_LCDData *SiS_StLCD1280x768_2Data; + const struct SiS_LCDData *SiS_ExtLCD1280x768_2Data; + const struct SiS_LCDData *SiS_LCD1280x800Data; + const struct SiS_LCDData *SiS_LCD1280x800_2Data; + const struct SiS_LCDData *SiS_LCD1280x854Data; + const struct SiS_LCDData *SiS_LCD1280x960Data; + const struct SiS_LCDData *SiS_ExtLCD1280x1024Data; + const struct SiS_LCDData *SiS_St2LCD1280x1024Data; + const struct SiS_LCDData *SiS_StLCD1400x1050Data; + const struct SiS_LCDData *SiS_ExtLCD1400x1050Data; + const struct SiS_LCDData *SiS_StLCD1600x1200Data; + const struct SiS_LCDData *SiS_ExtLCD1600x1200Data; + const struct SiS_LCDData *SiS_LCD1680x1050Data; + const struct SiS_LCDData *SiS_NoScaleData; + const struct SiS_TVData *SiS_StPALData; + const struct SiS_TVData *SiS_ExtPALData; + const struct SiS_TVData *SiS_StNTSCData; + const struct SiS_TVData *SiS_ExtNTSCData; + const struct SiS_TVData *SiS_St1HiTVData; + const struct SiS_TVData *SiS_St2HiTVData; + const struct SiS_TVData *SiS_ExtHiTVData; + const struct SiS_TVData *SiS_St525iData; + const struct SiS_TVData *SiS_St525pData; + const struct SiS_TVData *SiS_St750pData; + const struct SiS_TVData *SiS_Ext525iData; + const struct SiS_TVData *SiS_Ext525pData; + const struct SiS_TVData *SiS_Ext750pData; + const unsigned char *SiS_NTSCTiming; + const unsigned char *SiS_PALTiming; + const unsigned char *SiS_HiTVExtTiming; + const unsigned char *SiS_HiTVSt1Timing; + const unsigned char *SiS_HiTVSt2Timing; + const unsigned char *SiS_HiTVGroup3Data; + const unsigned char *SiS_HiTVGroup3Simu; #if 0 - const UCHAR *SiS_HiTVTextTiming; - const UCHAR *SiS_HiTVGroup3Text; + const unsigned char *SiS_HiTVTextTiming; + const unsigned char *SiS_HiTVGroup3Text; #endif - const SiS_Part2PortTblStruct *SiS_CRT2Part2_1024x768_1; - const SiS_Part2PortTblStruct *SiS_CRT2Part2_1280x1024_1; - const SiS_Part2PortTblStruct *SiS_CRT2Part2_1024x768_2; - const SiS_Part2PortTblStruct *SiS_CRT2Part2_1280x1024_2; - const SiS_Part2PortTblStruct *SiS_CRT2Part2_1024x768_3; - const SiS_Part2PortTblStruct *SiS_CRT2Part2_1280x1024_3; + const struct SiS_Part2PortTbl *SiS_CRT2Part2_1024x768_1; + const struct SiS_Part2PortTbl *SiS_CRT2Part2_1024x768_2; + const struct SiS_Part2PortTbl *SiS_CRT2Part2_1024x768_3; /* LVDS, Chrontel */ - const SiS_LVDSDataStruct *SiS_LVDS800x600Data_1; - const SiS_LVDSDataStruct *SiS_LVDS800x600Data_2; - const SiS_LVDSDataStruct *SiS_LVDS1024x768Data_1; - const SiS_LVDSDataStruct *SiS_LVDS1024x768Data_2; - const SiS_LVDSDataStruct *SiS_LVDS1280x1024Data_1; - const SiS_LVDSDataStruct *SiS_LVDS1280x1024Data_2; - const SiS_LVDSDataStruct *SiS_LVDS1280x960Data_1; - const SiS_LVDSDataStruct *SiS_LVDS1280x960Data_2; - const SiS_LVDSDataStruct *SiS_LVDS1400x1050Data_1; - const SiS_LVDSDataStruct *SiS_LVDS1400x1050Data_2; - const SiS_LVDSDataStruct *SiS_LVDS1600x1200Data_1; - const SiS_LVDSDataStruct *SiS_LVDS1600x1200Data_2; - const SiS_LVDSDataStruct *SiS_LVDS1280x768Data_1; - const SiS_LVDSDataStruct *SiS_LVDS1280x768Data_2; - const SiS_LVDSDataStruct *SiS_LVDS1024x600Data_1; - const SiS_LVDSDataStruct *SiS_LVDS1024x600Data_2; - const SiS_LVDSDataStruct *SiS_LVDS1152x768Data_1; - const SiS_LVDSDataStruct *SiS_LVDS1152x768Data_2; - const SiS_LVDSDataStruct *SiS_LVDS640x480Data_1; - const SiS_LVDSDataStruct *SiS_LVDS640x480Data_2; - const SiS_LVDSDataStruct *SiS_LVDS320x480Data_1; - const SiS_LVDSDataStruct *SiS_LVDSXXXxXXXData_1; - const SiS_LVDSDataStruct *SiS_LVDSBARCO1366Data_1; - const SiS_LVDSDataStruct *SiS_LVDSBARCO1366Data_2; - const SiS_LVDSDataStruct *SiS_LVDSBARCO1024Data_1; - const SiS_LVDSDataStruct *SiS_LVDSBARCO1024Data_2; - const SiS_LVDSDataStruct *SiS_LVDS848x480Data_1; - const SiS_LVDSDataStruct *SiS_LVDS848x480Data_2; - const SiS_LVDSDataStruct *SiS_CHTVUNTSCData; - const SiS_LVDSDataStruct *SiS_CHTVONTSCData; - const SiS_LVDSDataStruct *SiS_CHTVUPALData; - const SiS_LVDSDataStruct *SiS_CHTVOPALData; - const SiS_LVDSDataStruct *SiS_CHTVUPALMData; - const SiS_LVDSDataStruct *SiS_CHTVOPALMData; - const SiS_LVDSDataStruct *SiS_CHTVUPALNData; - const SiS_LVDSDataStruct *SiS_CHTVOPALNData; - const SiS_LVDSDataStruct *SiS_CHTVSOPALData; - - const SiS_LVDSDesStruct *SiS_PanelType00_1; - const SiS_LVDSDesStruct *SiS_PanelType01_1; - const SiS_LVDSDesStruct *SiS_PanelType02_1; - const SiS_LVDSDesStruct *SiS_PanelType03_1; - const SiS_LVDSDesStruct *SiS_PanelType04_1; - const SiS_LVDSDesStruct *SiS_PanelType05_1; - const SiS_LVDSDesStruct *SiS_PanelType06_1; - const SiS_LVDSDesStruct *SiS_PanelType07_1; - const SiS_LVDSDesStruct *SiS_PanelType08_1; - const SiS_LVDSDesStruct *SiS_PanelType09_1; - const SiS_LVDSDesStruct *SiS_PanelType0a_1; - const SiS_LVDSDesStruct *SiS_PanelType0b_1; - const SiS_LVDSDesStruct *SiS_PanelType0c_1; - const SiS_LVDSDesStruct *SiS_PanelType0d_1; - const SiS_LVDSDesStruct *SiS_PanelType0e_1; - const SiS_LVDSDesStruct *SiS_PanelType0f_1; - const SiS_LVDSDesStruct *SiS_PanelTypeNS_1; - const SiS_LVDSDesStruct *SiS_PanelType00_2; - const SiS_LVDSDesStruct *SiS_PanelType01_2; - const SiS_LVDSDesStruct *SiS_PanelType02_2; - const SiS_LVDSDesStruct *SiS_PanelType03_2; - const SiS_LVDSDesStruct *SiS_PanelType04_2; - const SiS_LVDSDesStruct *SiS_PanelType05_2; - const SiS_LVDSDesStruct *SiS_PanelType06_2; - const SiS_LVDSDesStruct *SiS_PanelType07_2; - const SiS_LVDSDesStruct *SiS_PanelType08_2; - const SiS_LVDSDesStruct *SiS_PanelType09_2; - const SiS_LVDSDesStruct *SiS_PanelType0a_2; - const SiS_LVDSDesStruct *SiS_PanelType0b_2; - const SiS_LVDSDesStruct *SiS_PanelType0c_2; - const SiS_LVDSDesStruct *SiS_PanelType0d_2; - const SiS_LVDSDesStruct *SiS_PanelType0e_2; - const SiS_LVDSDesStruct *SiS_PanelType0f_2; - const SiS_LVDSDesStruct *SiS_PanelTypeNS_2; - const SiS_LVDSDesStruct *SiS_CHTVUNTSCDesData; - const SiS_LVDSDesStruct *SiS_CHTVONTSCDesData; - const SiS_LVDSDesStruct *SiS_CHTVUPALDesData; - const SiS_LVDSDesStruct *SiS_CHTVOPALDesData; - - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1800x600_1; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11024x768_1; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11280x1024_1; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11400x1050_1; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11280x768_1; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11024x600_1; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11152x768_1; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11600x1200_1; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1800x600_1_H; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11024x768_1_H; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11280x1024_1_H; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11400x1050_1_H; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11280x768_1_H; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11024x600_1_H; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11152x768_1_H; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11600x1200_1_H; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1800x600_2; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11024x768_2; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11280x1024_2; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11400x1050_2; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11280x768_2; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11024x600_2; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11152x768_2; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11600x1200_2; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1800x600_2_H; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11024x768_2_H; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11280x1024_2_H; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11400x1050_2_H; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11280x768_2_H; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11024x600_2_H; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11152x768_2_H; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT11600x1200_2_H; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1XXXxXXX_1; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1XXXxXXX_1_H; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1640x480_1; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1640x480_1_H; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1640x480_2; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1640x480_2_H; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1640x480_3; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1640x480_3_H; - const SiS_LVDSCRT1DataStruct *SiS_LVDSCRT1320x480_1; - const SiS_LVDSCRT1DataStruct *SiS_CHTVCRT1UNTSC; - const SiS_LVDSCRT1DataStruct *SiS_CHTVCRT1ONTSC; - const SiS_LVDSCRT1DataStruct *SiS_CHTVCRT1UPAL; - const SiS_LVDSCRT1DataStruct *SiS_CHTVCRT1OPAL; - const SiS_LVDSCRT1DataStruct *SiS_CHTVCRT1SOPAL; - - const SiS_CHTVRegDataStruct *SiS_CHTVReg_UNTSC; - const SiS_CHTVRegDataStruct *SiS_CHTVReg_ONTSC; - const SiS_CHTVRegDataStruct *SiS_CHTVReg_UPAL; - const SiS_CHTVRegDataStruct *SiS_CHTVReg_OPAL; - const SiS_CHTVRegDataStruct *SiS_CHTVReg_UPALM; - const SiS_CHTVRegDataStruct *SiS_CHTVReg_OPALM; - const SiS_CHTVRegDataStruct *SiS_CHTVReg_UPALN; - const SiS_CHTVRegDataStruct *SiS_CHTVReg_OPALN; - const SiS_CHTVRegDataStruct *SiS_CHTVReg_SOPAL; - - const UCHAR *SiS_CHTVVCLKUNTSC; - const UCHAR *SiS_CHTVVCLKONTSC; - const UCHAR *SiS_CHTVVCLKUPAL; - const UCHAR *SiS_CHTVVCLKOPAL; - const UCHAR *SiS_CHTVVCLKUPALM; - const UCHAR *SiS_CHTVVCLKOPALM; - const UCHAR *SiS_CHTVVCLKUPALN; - const UCHAR *SiS_CHTVVCLKOPALN; - const UCHAR *SiS_CHTVVCLKSOPAL; - - USHORT PanelXRes, PanelHT; - USHORT PanelYRes, PanelVT; - USHORT PanelHRS, PanelHRE; - USHORT PanelVRS, PanelVRE; - USHORT PanelVCLKIdx300; - USHORT PanelVCLKIdx315; - - BOOLEAN UseCustomMode; - BOOLEAN CRT1UsesCustomMode; - USHORT CHDisplay; - USHORT CHSyncStart; - USHORT CHSyncEnd; - USHORT CHTotal; - USHORT CHBlankStart; - USHORT CHBlankEnd; - USHORT CVDisplay; - USHORT CVSyncStart; - USHORT CVSyncEnd; - USHORT CVTotal; - USHORT CVBlankStart; - USHORT CVBlankEnd; - ULONG CDClock; - ULONG CFlags; - UCHAR CCRT1CRTC[17]; - UCHAR CSR2B; - UCHAR CSR2C; - USHORT CSRClock; - USHORT CSRClock_CRT1; - USHORT CModeFlag; - USHORT CModeFlag_CRT1; - USHORT CInfoFlag; - - int LVDSHL; - - BOOLEAN Backup; - UCHAR Backup_Mode; - UCHAR Backup_14; - UCHAR Backup_15; - UCHAR Backup_16; - UCHAR Backup_17; - UCHAR Backup_18; - UCHAR Backup_19; - UCHAR Backup_1a; - UCHAR Backup_1b; - UCHAR Backup_1c; - UCHAR Backup_1d; - - int UsePanelScaler; - int CenterScreen; - - USHORT CP_Vendor, CP_Product; - BOOLEAN CP_HaveCustomData; - int CP_PreferredX, CP_PreferredY, CP_PreferredIndex; - int CP_MaxX, CP_MaxY, CP_MaxClock; - UCHAR CP_PrefSR2B, CP_PrefSR2C; - USHORT CP_PrefClock; - BOOLEAN CP_Supports64048075; - int CP_HDisplay[7], CP_VDisplay[7]; /* For Custom LCD panel dimensions */ - int CP_HTotal[7], CP_VTotal[7]; - int CP_HSyncStart[7], CP_VSyncStart[7]; - int CP_HSyncEnd[7], CP_VSyncEnd[7]; - int CP_HBlankStart[7], CP_VBlankStart[7]; - int CP_HBlankEnd[7], CP_VBlankEnd[7]; - int CP_Clock[7]; - BOOLEAN CP_DataValid[7]; - BOOLEAN CP_HSync_P[7], CP_VSync_P[7], CP_SyncValid[7]; -} SiS_Private; + const struct SiS_LVDSData *SiS_LVDS320x240Data_1; + const struct SiS_LVDSData *SiS_LVDS320x240Data_2; + const struct SiS_LVDSData *SiS_LVDS640x480Data_1; + const struct SiS_LVDSData *SiS_LVDS800x600Data_1; + const struct SiS_LVDSData *SiS_LVDS1024x600Data_1; + const struct SiS_LVDSData *SiS_LVDS1024x768Data_1; + const struct SiS_LVDSData *SiS_LVDSBARCO1366Data_1; + const struct SiS_LVDSData *SiS_LVDSBARCO1366Data_2; + const struct SiS_LVDSData *SiS_LVDSBARCO1024Data_1; + const struct SiS_LVDSData *SiS_LVDS848x480Data_1; + const struct SiS_LVDSData *SiS_LVDS848x480Data_2; + const struct SiS_LVDSData *SiS_CHTVUNTSCData; + const struct SiS_LVDSData *SiS_CHTVONTSCData; + const struct SiS_LVDSData *SiS_CHTVUPALData; + const struct SiS_LVDSData *SiS_CHTVOPALData; + const struct SiS_LVDSData *SiS_CHTVUPALMData; + const struct SiS_LVDSData *SiS_CHTVOPALMData; + const struct SiS_LVDSData *SiS_CHTVUPALNData; + const struct SiS_LVDSData *SiS_CHTVOPALNData; + const struct SiS_LVDSData *SiS_CHTVSOPALData; + + const struct SiS_LVDSDes *SiS_PanelType04_1a; + const struct SiS_LVDSDes *SiS_PanelType04_2a; + const struct SiS_LVDSDes *SiS_PanelType04_1b; + const struct SiS_LVDSDes *SiS_PanelType04_2b; + + const struct SiS_LVDSCRT1Data *SiS_LVDSCRT1320x240_1; + const struct SiS_LVDSCRT1Data *SiS_LVDSCRT1320x240_2; + const struct SiS_LVDSCRT1Data *SiS_LVDSCRT1320x240_2_H; + const struct SiS_LVDSCRT1Data *SiS_LVDSCRT1320x240_3; + const struct SiS_LVDSCRT1Data *SiS_LVDSCRT1320x240_3_H; + const struct SiS_LVDSCRT1Data *SiS_LVDSCRT1640x480_1; + const struct SiS_LVDSCRT1Data *SiS_LVDSCRT1640x480_1_H; + const struct SiS_LVDSCRT1Data *SiS_CHTVCRT1UNTSC; + const struct SiS_LVDSCRT1Data *SiS_CHTVCRT1ONTSC; + const struct SiS_LVDSCRT1Data *SiS_CHTVCRT1UPAL; + const struct SiS_LVDSCRT1Data *SiS_CHTVCRT1OPAL; + const struct SiS_LVDSCRT1Data *SiS_CHTVCRT1SOPAL; + + const struct SiS_CHTVRegData *SiS_CHTVReg_UNTSC; + const struct SiS_CHTVRegData *SiS_CHTVReg_ONTSC; + const struct SiS_CHTVRegData *SiS_CHTVReg_UPAL; + const struct SiS_CHTVRegData *SiS_CHTVReg_OPAL; + const struct SiS_CHTVRegData *SiS_CHTVReg_UPALM; + const struct SiS_CHTVRegData *SiS_CHTVReg_OPALM; + const struct SiS_CHTVRegData *SiS_CHTVReg_UPALN; + const struct SiS_CHTVRegData *SiS_CHTVReg_OPALN; + const struct SiS_CHTVRegData *SiS_CHTVReg_SOPAL; + + const unsigned char *SiS_CHTVVCLKUNTSC; + const unsigned char *SiS_CHTVVCLKONTSC; + const unsigned char *SiS_CHTVVCLKUPAL; + const unsigned char *SiS_CHTVVCLKOPAL; + const unsigned char *SiS_CHTVVCLKUPALM; + const unsigned char *SiS_CHTVVCLKOPALM; + const unsigned char *SiS_CHTVVCLKUPALN; + const unsigned char *SiS_CHTVVCLKOPALN; + const unsigned char *SiS_CHTVVCLKSOPAL; + + unsigned short PanelXRes, PanelHT; + unsigned short PanelYRes, PanelVT; + unsigned short PanelHRS, PanelHRE; + unsigned short PanelVRS, PanelVRE; + unsigned short PanelVCLKIdx300; + unsigned short PanelVCLKIdx315; + BOOLEAN Alternate1600x1200; + + BOOLEAN UseCustomMode; + BOOLEAN CRT1UsesCustomMode; + unsigned short CHDisplay; + unsigned short CHSyncStart; + unsigned short CHSyncEnd; + unsigned short CHTotal; + unsigned short CHBlankStart; + unsigned short CHBlankEnd; + unsigned short CVDisplay; + unsigned short CVSyncStart; + unsigned short CVSyncEnd; + unsigned short CVTotal; + unsigned short CVBlankStart; + unsigned short CVBlankEnd; + unsigned int CDClock; + unsigned int CFlags; + unsigned char CCRT1CRTC[17]; + unsigned char CSR2B; + unsigned char CSR2C; + unsigned short CSRClock; + unsigned short CSRClock_CRT1; + unsigned short CModeFlag; + unsigned short CModeFlag_CRT1; + unsigned short CInfoFlag; + + int LVDSHL; + + BOOLEAN Backup; + unsigned char Backup_Mode; + unsigned char Backup_14; + unsigned char Backup_15; + unsigned char Backup_16; + unsigned char Backup_17; + unsigned char Backup_18; + unsigned char Backup_19; + unsigned char Backup_1a; + unsigned char Backup_1b; + unsigned char Backup_1c; + unsigned char Backup_1d; + + unsigned char Init_P4_0E; + + int UsePanelScaler; + int CenterScreen; + + unsigned short CP_Vendor, CP_Product; + BOOLEAN CP_HaveCustomData; + int CP_PreferredX, CP_PreferredY, CP_PreferredIndex; + int CP_MaxX, CP_MaxY, CP_MaxClock; + unsigned char CP_PrefSR2B, CP_PrefSR2C; + unsigned short CP_PrefClock; + BOOLEAN CP_Supports64048075; + int CP_HDisplay[7], CP_VDisplay[7]; /* For Custom LCD panel dimensions */ + int CP_HTotal[7], CP_VTotal[7]; + int CP_HSyncStart[7], CP_VSyncStart[7]; + int CP_HSyncEnd[7], CP_VSyncEnd[7]; + int CP_HBlankStart[7], CP_VBlankStart[7]; + int CP_HBlankEnd[7], CP_VBlankEnd[7]; + int CP_Clock[7]; + BOOLEAN CP_DataValid[7]; + BOOLEAN CP_HSync_P[7], CP_VSync_P[7], CP_SyncValid[7]; +}; #endif diff --git a/drivers/video/tridentfb.c b/drivers/video/tridentfb.c index 698ca9232e7..81a6d9f188c 100644 --- a/drivers/video/tridentfb.c +++ b/drivers/video/tridentfb.c @@ -1061,6 +1061,11 @@ static int __devinit trident_pci_probe(struct pci_dev * dev, const struct pci_de chip_id = id->device; + if(chip_id == CYBERBLADEi1) + output("*** Please do use cyblafb, Cyberblade/i1 support " + "will soon be removed from tridentfb!\n"); + + /* If PCI id is 0x9660 then further detect chip type */ if (chip_id == TGUI9660) { diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c index a272592b037..1ca80264c7b 100644 --- a/drivers/video/vesafb.c +++ b/drivers/video/vesafb.c @@ -19,6 +19,7 @@ #include <linux/fb.h> #include <linux/ioport.h> #include <linux/init.h> +#include <video/vga.h> #include <asm/io.h> #include <asm/mtrr.h> @@ -54,6 +55,7 @@ static unsigned short *pmi_base = NULL; static void (*pmi_start)(void); static void (*pmi_pal)(void); static int depth; +static int vga_compat; /* --------------------------------------------------------------------- */ @@ -86,6 +88,37 @@ static int vesafb_pan_display(struct fb_var_screeninfo *var, return 0; } +static int vesafb_blank(int blank, struct fb_info *info) +{ + int err = 1; + + if (vga_compat) { + int loop = 10000; + u8 seq = 0, crtc17 = 0; + + err = 0; + + if (blank) { + seq = 0x20; + crtc17 = 0x00; + } else { + seq = 0x00; + crtc17 = 0x80; + } + + vga_wseq(NULL, 0x00, 0x01); + seq |= vga_rseq(NULL, 0x01) & ~0x20; + vga_wseq(NULL, 0x00, seq); + + crtc17 |= vga_rcrt(NULL, 0x17) & ~0x80; + while (loop--); + vga_wcrt(NULL, 0x17, crtc17); + vga_wseq(NULL, 0x00, 0x03); + } + + return err; +} + static void vesa_setpalette(int regno, unsigned red, unsigned green, unsigned blue) { @@ -176,6 +209,7 @@ static struct fb_ops vesafb_ops = { .owner = THIS_MODULE, .fb_setcolreg = vesafb_setcolreg, .fb_pan_display = vesafb_pan_display, + .fb_blank = vesafb_blank, .fb_fillrect = cfb_fillrect, .fb_copyarea = cfb_copyarea, .fb_imageblit = cfb_imageblit, @@ -429,6 +463,10 @@ static int __init vesafb_probe(struct device *device) info->flags = FBINFO_FLAG_DEFAULT | (ypan) ? FBINFO_HWACCEL_YPAN : 0; + vga_compat = (screen_info.capabilities & 2) ? 0 : 1; + printk("vesafb: Mode is %sVGA compatible\n", + (vga_compat) ? "" : "not "); + if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) { err = -ENOMEM; goto err; diff --git a/drivers/video/vgastate.c b/drivers/video/vgastate.c index 0ea62d8bc70..ca92940f394 100644 --- a/drivers/video/vgastate.c +++ b/drivers/video/vgastate.c @@ -342,16 +342,11 @@ static void vga_cleanup(struct vgastate *state) if (state->vidstate != NULL) { struct regstate *saved = (struct regstate *) state->vidstate; - if (saved->vga_font0) - vfree(saved->vga_font0); - if (saved->vga_font1) - vfree(saved->vga_font1); - if (saved->vga_text) - vfree(saved->vga_text); - if (saved->vga_cmap) - vfree(saved->vga_cmap); - if (saved->attr) - vfree(saved->attr); + vfree(saved->vga_font0); + vfree(saved->vga_font1); + vfree(saved->vga_text); + vfree(saved->vga_cmap); + vfree(saved->attr); kfree(saved); state->vidstate = NULL; } diff --git a/drivers/w1/w1_ds2433.c b/drivers/w1/w1_ds2433.c index b7c24b34d27..279e0e0363d 100644 --- a/drivers/w1/w1_ds2433.c +++ b/drivers/w1/w1_ds2433.c @@ -15,6 +15,10 @@ #include <linux/delay.h> #ifdef CONFIG_W1_F23_CRC #include <linux/crc16.h> + +#define CRC16_INIT 0 +#define CRC16_VALID 0xb001 + #endif #include "w1.h" @@ -214,7 +218,7 @@ static ssize_t w1_f23_write_bin(struct kobject *kobj, char *buf, loff_t off, #ifdef CONFIG_W1_F23_CRC /* can only write full blocks in cached mode */ if ((off & W1_PAGE_MASK) || (count & W1_PAGE_MASK)) { - dev_err(&sl->dev, "invalid offset/count off=%d cnt=%d\n", + dev_err(&sl->dev, "invalid offset/count off=%d cnt=%zd\n", (int)off, count); return -EINVAL; } |