comparison drivers/radeon/radeon_vid.c @ 3247:7cec2396bde3

Tune up driver through reading and writing /dev/radeon_vid ;)
author nick
date Sat, 01 Dec 2001 17:08:37 +0000
parents 5eae81895171
children 61b1441c0f8c
comparison
equal deleted inserted replaced
3246:f03adf755028 3247:7cec2396bde3
128 uint32_t p23_h_accum_init; 128 uint32_t p23_h_accum_init;
129 uint32_t scale_cntl; 129 uint32_t scale_cntl;
130 uint32_t exclusive_horz; 130 uint32_t exclusive_horz;
131 uint32_t auto_flip_cntl; 131 uint32_t auto_flip_cntl;
132 uint32_t filter_cntl; 132 uint32_t filter_cntl;
133 uint32_t colour_cntl; 133 int brightness;
134 int saturation;
134 uint32_t graphics_key_msk; 135 uint32_t graphics_key_msk;
135 uint32_t graphics_key_clr; 136 uint32_t graphics_key_clr;
136 uint32_t key_cntl; 137 uint32_t key_cntl;
137 uint32_t test; 138 uint32_t test;
138 } bes_registers_t; 139 } bes_registers_t;
184 static uint32_t radeon_vid_in_use = 0; 185 static uint32_t radeon_vid_in_use = 0;
185 186
186 static uint8_t *radeon_mmio_base = 0; 187 static uint8_t *radeon_mmio_base = 0;
187 static uint32_t radeon_mem_base = 0; 188 static uint32_t radeon_mem_base = 0;
188 static int32_t radeon_overlay_off = 0; 189 static int32_t radeon_overlay_off = 0;
189 190 static int radeon_double_buff=1;
190 static uint32_t radeon_ram_size = 0; 191 static uint32_t radeon_ram_size = 0;
191 192
192 static mga_vid_config_t radeon_config; 193 static mga_vid_config_t radeon_config;
193 194
194 #undef DEBUG 195 #undef DEBUG
332 OUTREG(OV0_P1_H_ACCUM_INIT, besr.p1_h_accum_init); 333 OUTREG(OV0_P1_H_ACCUM_INIT, besr.p1_h_accum_init);
333 OUTREG(OV0_P23_H_ACCUM_INIT, besr.p23_h_accum_init); 334 OUTREG(OV0_P23_H_ACCUM_INIT, besr.p23_h_accum_init);
334 OUTREG(OV0_P23_V_ACCUM_INIT, besr.p23_v_accum_init); 335 OUTREG(OV0_P23_V_ACCUM_INIT, besr.p23_v_accum_init);
335 336
336 bes_flags = SCALER_ENABLE | 337 bes_flags = SCALER_ENABLE |
337 SCALER_DOUBLE_BUFFER |
338 SCALER_ADAPTIVE_DEINT | 338 SCALER_ADAPTIVE_DEINT |
339 SCALER_SMART_SWITCH | 339 SCALER_SMART_SWITCH |
340 SCALER_HORZ_PICK_NEAREST; 340 SCALER_HORZ_PICK_NEAREST;
341 if(radeon_double_buff) bes_flags |= SCALER_DOUBLE_BUFFER;
341 #ifdef RAGE128 342 #ifdef RAGE128
342 bes_flags |= SCALER_BURST_PER_PLANE; 343 bes_flags |= SCALER_BURST_PER_PLANE;
343 #endif 344 #endif
344 switch(besr.fourcc) 345 switch(besr.fourcc)
345 { 346 {
547 } 548 }
548 549
549 static void radeon_vid_frame_sel(int frame) 550 static void radeon_vid_frame_sel(int frame)
550 { 551 {
551 uint32_t off0,off1,off2; 552 uint32_t off0,off1,off2;
553 if(!radeon_double_buff) return;
552 if(frame%2) 554 if(frame%2)
553 { 555 {
554 off0 = besr.vid_buf3_base_adrs; 556 off0 = besr.vid_buf3_base_adrs;
555 off1 = besr.vid_buf4_base_adrs; 557 off1 = besr.vid_buf4_base_adrs;
556 off2 = besr.vid_buf5_base_adrs; 558 off2 = besr.vid_buf5_base_adrs;
565 while(!(INREG(OV0_REG_LOAD_CNTL)&REG_LD_CTL_LOCK_READBACK)); 567 while(!(INREG(OV0_REG_LOAD_CNTL)&REG_LD_CTL_LOCK_READBACK));
566 OUTREG(OV0_VID_BUF0_BASE_ADRS, off0); 568 OUTREG(OV0_VID_BUF0_BASE_ADRS, off0);
567 OUTREG(OV0_VID_BUF1_BASE_ADRS, off1); 569 OUTREG(OV0_VID_BUF1_BASE_ADRS, off1);
568 OUTREG(OV0_VID_BUF2_BASE_ADRS, off2); 570 OUTREG(OV0_VID_BUF2_BASE_ADRS, off2);
569 OUTREG(OV0_REG_LOAD_CNTL, 0); 571 OUTREG(OV0_REG_LOAD_CNTL, 0);
572 }
573
574 static void radeon_vid_preset(void)
575 {
576 unsigned tmp;
577 tmp = INREG(OV0_COLOUR_CNTL);
578 besr.saturation = (tmp>>8)&0x1f;
579 besr.brightness = tmp & 0x7f;
570 } 580 }
571 581
572 static int video_on = 0; 582 static int video_on = 0;
573 583
574 static int radeon_vid_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) 584 static int radeon_vid_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
728 { PCI_DEVICE_ID_R200_QL, "Radeon2 8500 QL " }, 738 { PCI_DEVICE_ID_R200_QL, "Radeon2 8500 QL " },
729 { PCI_DEVICE_ID_RV200_QW, "Radeon2 7500 QW " } 739 { PCI_DEVICE_ID_RV200_QW, "Radeon2 7500 QW " }
730 #endif 740 #endif
731 }; 741 };
732 742
743 static int detected_chip;
744
733 static int radeon_vid_config_card(void) 745 static int radeon_vid_config_card(void)
734 { 746 {
735 struct pci_dev *dev = NULL; 747 struct pci_dev *dev = NULL;
736 size_t i; 748 size_t i;
737 749
754 radeon_ram_size = INREG(CONFIG_MEMSIZE); 766 radeon_ram_size = INREG(CONFIG_MEMSIZE);
755 767
756 /* mem size is bits [28:0], mask off the rest. Range: from 1Mb up to 512 Mb */ 768 /* mem size is bits [28:0], mask off the rest. Range: from 1Mb up to 512 Mb */
757 radeon_ram_size &= CONFIG_MEMSIZE_MASK; 769 radeon_ram_size &= CONFIG_MEMSIZE_MASK;
758 radeon_ram_size /= 0x100000; 770 radeon_ram_size /= 0x100000;
771 detected_chip = i;
759 printk(RVID_MSG"Found %s (%uMb memory)\n",ati_card_ids[i].name,radeon_ram_size); 772 printk(RVID_MSG"Found %s (%uMb memory)\n",ati_card_ids[i].name,radeon_ram_size);
760 773
761 return TRUE; 774 return TRUE;
762 } 775 }
763 776
777 #define PARAM_BRIGHTNESS "brightness="
778 #define PARAM_SATURATION "saturation="
779 #define PARAM_DOUBLE_BUFF "double_buff="
764 780
765 static ssize_t radeon_vid_read(struct file *file, char *buf, size_t count, loff_t *ppos) 781 static ssize_t radeon_vid_read(struct file *file, char *buf, size_t count, loff_t *ppos)
766 { 782 {
767 return -EINVAL; 783 unsigned len,saturation;
784 long brightness;
785 brightness = besr.brightness;
786 saturation = besr.saturation;
787 len = 0;
788 len += sprintf(&buf[len],"Chip: %s\n",ati_card_ids[detected_chip].name);
789 len += sprintf(&buf[len],"Memory: %p:%x\n",radeon_mem_base,radeon_ram_size*0x100000);
790 len += sprintf(&buf[len],"MMIO: %p\n",radeon_mmio_base);
791 len += sprintf(&buf[len],"Configurable stuff:\n");
792 len += sprintf(&buf[len],PARAM_DOUBLE_BUFF"%s\n",radeon_double_buff?"on":"off");
793 len += sprintf(&buf[len],PARAM_BRIGHTNESS"%i\n",brightness);
794 len += sprintf(&buf[len],PARAM_SATURATION"%u\n",saturation);
795 return len;
768 } 796 }
769 797
770 static ssize_t radeon_vid_write(struct file *file, const char *buf, size_t count, loff_t *ppos) 798 static ssize_t radeon_vid_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
771 { 799 {
772 return -EINVAL; 800 if(memcmp(buf,PARAM_BRIGHTNESS,min(count,strlen(PARAM_BRIGHTNESS))) == 0)
801 {
802 long brightness;
803 brightness=simple_strtol(&buf[strlen(PARAM_BRIGHTNESS)],NULL,10);
804 if(brightness >= -64 && brightness <= 63)
805 OUTREG(OV0_COLOUR_CNTL, (brightness & 0x7f) |
806 (besr.saturation << 8) |
807 (besr.saturation << 16));
808 }
809 else
810 if(memcmp(buf,PARAM_SATURATION,min(count,strlen(PARAM_SATURATION))) == 0)
811 {
812 long saturation;
813 saturation=simple_strtol(&buf[strlen(PARAM_SATURATION)],NULL,10);
814 if(saturation >= 0 && saturation <= 31)
815 OUTREG(OV0_COLOUR_CNTL, (besr.brightness & 0x7f) |
816 (saturation << 8) |
817 (saturation << 16));
818 }
819 else
820 if(memcmp(buf,PARAM_DOUBLE_BUFF,min(count,strlen(PARAM_DOUBLE_BUFF))) == 0)
821 {
822 if(memcmp(&buf[strlen(PARAM_DOUBLE_BUFF)],"on",2) == 0) radeon_double_buff = 1;
823 else radeon_double_buff = 0;
824 }
825 radeon_vid_preset();
826 return count;
773 } 827 }
774 828
775 static int radeon_vid_mmap(struct file *file, struct vm_area_struct *vma) 829 static int radeon_vid_mmap(struct file *file, struct vm_area_struct *vma)
776 { 830 {
777 831
866 printk(RVID_MSG"can't configure this card\n"); 920 printk(RVID_MSG"can't configure this card\n");
867 unregister_chrdev(RADEON_VID_MAJOR, "radeon_vid"); 921 unregister_chrdev(RADEON_VID_MAJOR, "radeon_vid");
868 return -EINVAL; 922 return -EINVAL;
869 } 923 }
870 radeon_vid_save_state(); 924 radeon_vid_save_state();
925 radeon_vid_preset();
871 return(0); 926 return(0);
872 } 927 }
873 928
874 int init_module(void) 929 int init_module(void)
875 { 930 {