comparison vidix/mga_vid.c @ 26753:502f04b67653

cosmetics: Remove useless parentheses from return statements.
author diego
date Fri, 16 May 2008 00:13:03 +0000
parents 3abd1629658b
children df448e1248b2
comparison
equal deleted inserted replaced
26752:65f61607e32f 26753:502f04b67653
362 #ifdef CRTC2 362 #ifdef CRTC2
363 crtc2_frame_sel(mga_next_frame); 363 crtc2_frame_sel(mga_next_frame);
364 #endif 364 #endif
365 } 365 }
366 366
367 return(0); 367 return 0;
368 } 368 }
369 369
370 370
371 static void mga_vid_write_regs(int restore) 371 static void mga_vid_write_regs(int restore)
372 { 372 {
663 dw, dh, x, y, sw, sh, config->fourcc); 663 dw, dh, x, y, sw, sh, config->fourcc);
664 664
665 if ((sw < 4) || (sh < 4) || (dw < 4) || (dh < 4)) 665 if ((sw < 4) || (sh < 4) || (dw < 4) || (dh < 4))
666 { 666 {
667 printf("[mga] Invalid src/dest dimensions\n"); 667 printf("[mga] Invalid src/dest dimensions\n");
668 return(EINVAL); 668 return EINVAL;
669 } 669 }
670 670
671 //FIXME check that window is valid and inside desktop 671 //FIXME check that window is valid and inside desktop
672 672
673 sw+=sw&1; 673 sw+=sw&1;
683 case IMGFMT_UYVY: 683 case IMGFMT_UYVY:
684 config->frame_size = ((sw + 31) & ~31) * sh * 2; 684 config->frame_size = ((sw + 31) & ~31) * sh * 2;
685 break; 685 break;
686 default: 686 default:
687 printf("[mga] Unsupported pixel format: %x\n", config->fourcc); 687 printf("[mga] Unsupported pixel format: %x\n", config->fourcc);
688 return(ENOTSUP); 688 return ENOTSUP;
689 } 689 }
690 690
691 config->offsets[0] = 0; 691 config->offsets[0] = 0;
692 for (i = 1; i < config->num_frames+1; i++) 692 for (i = 1; i < config->num_frames+1; i++)
693 config->offsets[i] = i*config->frame_size; 693 config->offsets[i] = i*config->frame_size;
705 705
706 mga_src_base = (mga_ram_size*0x100000-config->num_frames*config->frame_size); 706 mga_src_base = (mga_ram_size*0x100000-config->num_frames*config->frame_size);
707 if (mga_src_base < 0) 707 if (mga_src_base < 0)
708 { 708 {
709 printf("[mga] not enough memory for frames!\n"); 709 printf("[mga] not enough memory for frames!\n");
710 return(EFAULT); 710 return EFAULT;
711 } 711 }
712 mga_src_base &= (~0xFFFF); /* 64k boundary */ 712 mga_src_base &= (~0xFFFF); /* 64k boundary */
713 if (mga_verbose > 1) printf("[mga] YUV buffer base: %#x\n", mga_src_base); 713 if (mga_verbose > 1) printf("[mga] YUV buffer base: %#x\n", mga_src_base);
714 714
715 config->dga_addr = mga_mem_base + mga_src_base; 715 config->dga_addr = mga_mem_base + mga_src_base;
1041 cregs.c2vparam=((vdispend - 1) << 16) | (vtotal - 1); 1041 cregs.c2vparam=((vdispend - 1) << 16) | (vtotal - 1);
1042 cregs.c2vsync=((vsyncend - 1) << 16) | (vsyncstart - 1); 1042 cregs.c2vsync=((vsyncend - 1) << 16) | (vsyncstart - 1);
1043 #endif /* CRTC2 */ 1043 #endif /* CRTC2 */
1044 1044
1045 mga_vid_write_regs(0); 1045 mga_vid_write_regs(0);
1046 return(0); 1046 return 0;
1047 } 1047 }
1048 1048
1049 static int mga_playback_on(void) 1049 static int mga_playback_on(void)
1050 { 1050 {
1051 if (mga_verbose) printf("[mga] playback on\n"); 1051 if (mga_verbose) printf("[mga] playback on\n");
1060 if (mga_irq != -1) 1060 if (mga_irq != -1)
1061 enable_irq(); 1061 enable_irq();
1062 #endif 1062 #endif
1063 mga_next_frame=0; 1063 mga_next_frame=0;
1064 1064
1065 return(0); 1065 return 0;
1066 } 1066 }
1067 1067
1068 static int mga_playback_off(void) 1068 static int mga_playback_off(void)
1069 { 1069 {
1070 if (mga_verbose) printf("[mga] playback off\n"); 1070 if (mga_verbose) printf("[mga] playback off\n");
1076 #endif 1076 #endif
1077 regs.besctl &= ~1; 1077 regs.besctl &= ~1;
1078 regs.besglobctl &= ~(1<<6); /* UYVY format selected */ 1078 regs.besglobctl &= ~(1<<6); /* UYVY format selected */
1079 mga_vid_write_regs(0); 1079 mga_vid_write_regs(0);
1080 1080
1081 return(0); 1081 return 0;
1082 } 1082 }
1083 1083
1084 static int mga_probe(int verbose,int force) 1084 static int mga_probe(int verbose,int force)
1085 { 1085 {
1086 pciinfo_t lst[MAX_PCI_DEVICES]; 1086 pciinfo_t lst[MAX_PCI_DEVICES];
1095 1095
1096 err = pci_scan(lst, &num_pci); 1096 err = pci_scan(lst, &num_pci);
1097 if (err) 1097 if (err)
1098 { 1098 {
1099 printf("[mga] Error occurred during pci scan: %s\n", strerror(err)); 1099 printf("[mga] Error occurred during pci scan: %s\n", strerror(err));
1100 return(err); 1100 return err;
1101 } 1101 }
1102 1102
1103 if (mga_verbose) 1103 if (mga_verbose)
1104 printf("[mga] found %d pci devices\n", num_pci); 1104 printf("[mga] found %d pci devices\n", num_pci);
1105 1105
1140 } 1140 }
1141 1141
1142 if (is_g400 == -1) 1142 if (is_g400 == -1)
1143 { 1143 {
1144 if (verbose) printf("[mga] Can't find chip\n"); 1144 if (verbose) printf("[mga] Can't find chip\n");
1145 return(ENXIO); 1145 return ENXIO;
1146 } 1146 }
1147 1147
1148 card_found: 1148 card_found:
1149 probed = 1; 1149 probed = 1;
1150 memcpy(&pci_info, &lst[i], sizeof(pciinfo_t)); 1150 memcpy(&pci_info, &lst[i], sizeof(pciinfo_t));
1151 1151
1152 mga_cap.device_id = pci_info.device; /* set device id in capabilites */ 1152 mga_cap.device_id = pci_info.device; /* set device id in capabilites */
1153 1153
1154 return(0); 1154 return 0;
1155 } 1155 }
1156 1156
1157 static int mga_init(void) 1157 static int mga_init(void)
1158 { 1158 {
1159 unsigned int card_option = 0; 1159 unsigned int card_option = 0;
1169 #endif 1169 #endif
1170 1170
1171 if (!probed) 1171 if (!probed)
1172 { 1172 {
1173 printf("[mga] driver was not probed but is being initializing\n"); 1173 printf("[mga] driver was not probed but is being initializing\n");
1174 return(EINTR); 1174 return EINTR;
1175 } 1175 }
1176 1176
1177 #ifdef MGA_PCICONFIG_MEMDETECT 1177 #ifdef MGA_PCICONFIG_MEMDETECT
1178 pci_config_read(pci_info.bus, pci_info.card, pci_info.func, 1178 pci_config_read(pci_info.bus, pci_info.card, pci_info.func,
1179 0x40, 4, &card_option); 1179 0x40, 4, &card_option);
1224 if (mga_ram_size) 1224 if (mga_ram_size)
1225 { 1225 {
1226 if ((mga_ram_size < 4) || (mga_ram_size > 64)) 1226 if ((mga_ram_size < 4) || (mga_ram_size > 64))
1227 { 1227 {
1228 printf("[mga] invalid RAMSIZE: %d MB\n", mga_ram_size); 1228 printf("[mga] invalid RAMSIZE: %d MB\n", mga_ram_size);
1229 return(EINVAL); 1229 return EINVAL;
1230 } 1230 }
1231 } 1231 }
1232 1232
1233 if (mga_verbose > 1) printf("[mga] hardware addresses: mmio: %#x, framebuffer: %#x\n", 1233 if (mga_verbose > 1) printf("[mga] hardware addresses: mmio: %#x, framebuffer: %#x\n",
1234 pci_info.base1, pci_info.base0); 1234 pci_info.base1, pci_info.base0);
1262 #else 1262 #else
1263 printf("syncfb (mga): IRQ disabled in mga_vid.c\n"); 1263 printf("syncfb (mga): IRQ disabled in mga_vid.c\n");
1264 mga_irq=-1; 1264 mga_irq=-1;
1265 #endif 1265 #endif
1266 1266
1267 return(0); 1267 return 0;
1268 } 1268 }
1269 1269
1270 static void mga_destroy(void) 1270 static void mga_destroy(void)
1271 { 1271 {
1272 if (mga_verbose) printf("[mga] destroy\n"); 1272 if (mga_verbose) printf("[mga] destroy\n");
1302 case IMGFMT_YUY2: 1302 case IMGFMT_YUY2:
1303 case IMGFMT_UYVY: 1303 case IMGFMT_UYVY:
1304 break; 1304 break;
1305 default: 1305 default:
1306 to->depth = to->flags = 0; 1306 to->depth = to->flags = 0;
1307 return(ENOTSUP); 1307 return ENOTSUP;
1308 } 1308 }
1309 1309
1310 to->depth = VID_DEPTH_12BPP | 1310 to->depth = VID_DEPTH_12BPP |
1311 VID_DEPTH_15BPP | VID_DEPTH_16BPP | 1311 VID_DEPTH_15BPP | VID_DEPTH_16BPP |
1312 VID_DEPTH_24BPP | VID_DEPTH_32BPP; 1312 VID_DEPTH_24BPP | VID_DEPTH_32BPP;
1313 to->flags = VID_CAP_EXPAND | VID_CAP_SHRINK | VID_CAP_COLORKEY; 1313 to->flags = VID_CAP_EXPAND | VID_CAP_SHRINK | VID_CAP_COLORKEY;
1314 return(0); 1314 return 0;
1315 } 1315 }
1316 1316
1317 static int mga_get_caps(vidix_capability_t *to) 1317 static int mga_get_caps(vidix_capability_t *to)
1318 { 1318 {
1319 memcpy(to, &mga_cap, sizeof(vidix_capability_t)); 1319 memcpy(to, &mga_cap, sizeof(vidix_capability_t));
1320 return(0); 1320 return 0;
1321 } 1321 }
1322 1322
1323 static int mga_get_gkeys(vidix_grkey_t *grkey) 1323 static int mga_get_gkeys(vidix_grkey_t *grkey)
1324 { 1324 {
1325 memcpy(grkey, &mga_grkey, sizeof(vidix_grkey_t)); 1325 memcpy(grkey, &mga_grkey, sizeof(vidix_grkey_t));
1326 return(0); 1326 return 0;
1327 } 1327 }
1328 1328
1329 static int mga_set_gkeys(const vidix_grkey_t *grkey) 1329 static int mga_set_gkeys(const vidix_grkey_t *grkey)
1330 { 1330 {
1331 memcpy(&mga_grkey, grkey, sizeof(vidix_grkey_t)); 1331 memcpy(&mga_grkey, grkey, sizeof(vidix_grkey_t));
1332 mga_vid_write_regs(0); 1332 mga_vid_write_regs(0);
1333 return(0); 1333 return 0;
1334 } 1334 }
1335 1335
1336 static int mga_set_eq( const vidix_video_eq_t * eq) 1336 static int mga_set_eq( const vidix_video_eq_t * eq)
1337 { 1337 {
1338 /* contrast and brightness control isn't supported on G200 - alex */ 1338 /* contrast and brightness control isn't supported on G200 - alex */
1339 if (!is_g400) 1339 if (!is_g400)
1340 { 1340 {
1341 if (mga_verbose) printf("[mga] equalizer isn't supported with G200\n"); 1341 if (mga_verbose) printf("[mga] equalizer isn't supported with G200\n");
1342 return(ENOTSUP); 1342 return ENOTSUP;
1343 } 1343 }
1344 1344
1345 // only brightness&contrast are supported: 1345 // only brightness&contrast are supported:
1346 if(!(eq->cap & (VEQ_CAP_BRIGHTNESS|VEQ_CAP_CONTRAST))) 1346 if(!(eq->cap & (VEQ_CAP_BRIGHTNESS|VEQ_CAP_CONTRAST)))
1347 return(ENOTSUP); 1347 return ENOTSUP;
1348 1348
1349 //regs.beslumactl = readl(mga_mmio_base + BESLUMACTL); 1349 //regs.beslumactl = readl(mga_mmio_base + BESLUMACTL);
1350 if (eq->cap & VEQ_CAP_BRIGHTNESS) { 1350 if (eq->cap & VEQ_CAP_BRIGHTNESS) {
1351 regs.beslumactl &= 0xFFFF; 1351 regs.beslumactl &= 0xFFFF;
1352 regs.beslumactl |= (eq->brightness*255/2000)<<16; 1352 regs.beslumactl |= (eq->brightness*255/2000)<<16;
1355 regs.beslumactl &= 0xFFFF0000; 1355 regs.beslumactl &= 0xFFFF0000;
1356 regs.beslumactl |= (128+eq->contrast*255/2000)&0xFFFF; 1356 regs.beslumactl |= (128+eq->contrast*255/2000)&0xFFFF;
1357 } 1357 }
1358 writel(regs.beslumactl,mga_mmio_base + BESLUMACTL); 1358 writel(regs.beslumactl,mga_mmio_base + BESLUMACTL);
1359 1359
1360 return(0); 1360 return 0;
1361 } 1361 }
1362 1362
1363 static int mga_get_eq( vidix_video_eq_t * eq) 1363 static int mga_get_eq( vidix_video_eq_t * eq)
1364 { 1364 {
1365 /* contrast and brightness control isn't supported on G200 - alex */ 1365 /* contrast and brightness control isn't supported on G200 - alex */
1366 if (!is_g400) 1366 if (!is_g400)
1367 { 1367 {
1368 if (mga_verbose) printf("[mga] equalizer isn't supported with G200\n"); 1368 if (mga_verbose) printf("[mga] equalizer isn't supported with G200\n");
1369 return(ENOTSUP); 1369 return ENOTSUP;
1370 } 1370 }
1371 1371
1372 eq->brightness = (signed short int)(regs.beslumactl >> 16) * 1000 / 128; 1372 eq->brightness = (signed short int)(regs.beslumactl >> 16) * 1000 / 128;
1373 eq->contrast = (signed short int)(regs.beslumactl & 0xFFFF) * 1000 / 128 - 1000; 1373 eq->contrast = (signed short int)(regs.beslumactl & 0xFFFF) * 1000 / 128 - 1000;
1374 eq->cap = VEQ_CAP_BRIGHTNESS | VEQ_CAP_CONTRAST; 1374 eq->cap = VEQ_CAP_BRIGHTNESS | VEQ_CAP_CONTRAST;
1375 1375
1376 printf("MGA GET_EQ: br=%d c=%d \n",eq->brightness,eq->contrast); 1376 printf("MGA GET_EQ: br=%d c=%d \n",eq->brightness,eq->contrast);
1377 1377
1378 return(0); 1378 return 0;
1379 } 1379 }
1380 1380
1381 #ifndef CRTC2 1381 #ifndef CRTC2
1382 VDXDriver mga_drv = { 1382 VDXDriver mga_drv = {
1383 "mga", 1383 "mga",