Mercurial > mplayer.hg
comparison vidix/ivtv_vid.c @ 37107:3c5c93a30fb7
vidix: Replace printf with mp_msg
- Make MPlayer more quiet when requested (e.g. when using -really-quiet)
- Additionally change some minor capitalization and "bla:" to "[bla]"
Patch-by: Arne Bochem >arneb.mp ccan de<
Patch-also-OKed-by: Reimar
author | al |
---|---|
date | Sat, 17 May 2014 01:38:00 +0000 |
parents | 945eab072c9d |
children |
comparison
equal
deleted
inserted
replaced
37106:1b9907dfe2f4 | 37107:3c5c93a30fb7 |
---|---|
41 #include "vidix.h" | 41 #include "vidix.h" |
42 #include "fourcc.h" | 42 #include "fourcc.h" |
43 #include "dha.h" | 43 #include "dha.h" |
44 #include "pci_ids.h" | 44 #include "pci_ids.h" |
45 #include "pci_names.h" | 45 #include "pci_names.h" |
46 #include "mp_msg.h" | |
46 | 47 |
47 #define VIDIX_STATIC ivtv_ | 48 #define VIDIX_STATIC ivtv_ |
48 | 49 |
49 #define IVTV_MSG "[ivtv-vid] " | 50 #define IVTV_MSG "[ivtv-vid] " |
50 #define MAXLINE 128 | 51 #define MAXLINE 128 |
233 unsigned int i, num_pci = 0; | 234 unsigned int i, num_pci = 0; |
234 unsigned char yuv_device_number = 48, yuv_device = 48 + fb_number; | 235 unsigned char yuv_device_number = 48, yuv_device = 48 + fb_number; |
235 char yuv_device_name[] = "/dev/videoXXX\0"; | 236 char yuv_device_name[] = "/dev/videoXXX\0"; |
236 | 237 |
237 if(verbose) | 238 if(verbose) |
238 printf(IVTV_MSG"probe\n"); | 239 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"probe\n"); |
239 | 240 |
240 ivtv_verbose = verbose; | 241 ivtv_verbose = verbose; |
241 | 242 |
242 err = pci_scan(lst, &num_pci); | 243 err = pci_scan(lst, &num_pci); |
243 if(err) { | 244 if(err) { |
244 printf(IVTV_MSG"Error occured during pci scan: %s\n", strerror(err)); | 245 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"Error occured during pci scan: %s\n", strerror(err)); |
245 return err; | 246 return err; |
246 } | 247 } |
247 | 248 |
248 if(ivtv_verbose) | 249 if(ivtv_verbose) |
249 printf(IVTV_MSG"Found %d pci devices\n", num_pci); | 250 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"Found %d pci devices\n", num_pci); |
250 | 251 |
251 for(i = 0; i < num_pci; i++) { | 252 for(i = 0; i < num_pci; i++) { |
252 if(2 == ivtv_verbose) | 253 if(2 == ivtv_verbose) |
253 printf(IVTV_MSG"Found chip [%04X:%04X] '%s' '%s'\n" | 254 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"Found chip [%04X:%04X] '%s' '%s'\n" |
254 ,lst[i].vendor | 255 ,lst[i].vendor |
255 ,lst[i].device | 256 ,lst[i].device |
256 ,pci_vendor_name(lst[i].vendor) | 257 ,pci_vendor_name(lst[i].vendor) |
257 ,pci_device_name(lst[i].vendor,lst[i].device)); | 258 ,pci_device_name(lst[i].vendor,lst[i].device)); |
258 if(VENDOR_INTERNEXT == lst[i].vendor) { | 259 if(VENDOR_INTERNEXT == lst[i].vendor) { |
259 switch(lst[i].device) | 260 switch(lst[i].device) |
260 { | 261 { |
261 case DEVICE_INTERNEXT_ITVC15_MPEG_2_ENCODER: | 262 case DEVICE_INTERNEXT_ITVC15_MPEG_2_ENCODER: |
262 if(ivtv_verbose) | 263 if(ivtv_verbose) |
263 printf(IVTV_MSG"Found PVR 350\n"); | 264 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"Found PVR 350\n"); |
264 goto card_found; | 265 goto card_found; |
265 } | 266 } |
266 } | 267 } |
267 } | 268 } |
268 | 269 |
269 if(ivtv_verbose) | 270 if(ivtv_verbose) |
270 printf(IVTV_MSG"Can't find chip\n"); | 271 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"Can't find chip\n"); |
271 return ENXIO; | 272 return ENXIO; |
272 | 273 |
273 card_found: | 274 card_found: |
274 | 275 |
275 device_name = getenv("FRAMEBUFFER"); | 276 device_name = getenv("FRAMEBUFFER"); |
280 fb_number = atoi(device_name+strlen("/dev/fb")); | 281 fb_number = atoi(device_name+strlen("/dev/fb")); |
281 | 282 |
282 fbdev = open(device_name, O_RDWR); | 283 fbdev = open(device_name, O_RDWR); |
283 if(-1 != fbdev) { | 284 if(-1 != fbdev) { |
284 if(ioctl(fbdev, FBIOGET_VSCREENINFO, &vinfo) < 0) { | 285 if(ioctl(fbdev, FBIOGET_VSCREENINFO, &vinfo) < 0) { |
285 printf(IVTV_MSG"Unable to read screen info\n"); | 286 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"Unable to read screen info\n"); |
286 close(fbdev); | 287 close(fbdev); |
287 return ENXIO; | 288 return ENXIO; |
288 } else { | 289 } else { |
289 fb_width = vinfo.xres; | 290 fb_width = vinfo.xres; |
290 fb_height = vinfo.yres; | 291 fb_height = vinfo.yres; |
291 if(2 == ivtv_verbose) { | 292 if(2 == ivtv_verbose) { |
292 printf(IVTV_MSG"framebuffer width : %3.0f\n",fb_width); | 293 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"framebuffer width : %3.0f\n",fb_width); |
293 printf(IVTV_MSG"framebuffer height: %3.0f\n",fb_height); | 294 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"framebuffer height: %3.0f\n",fb_height); |
294 } | 295 } |
295 } | 296 } |
296 if(NULL != (alpha = getenv("VIDIXIVTVALPHA"))) { | 297 if(NULL != (alpha = getenv("VIDIXIVTVALPHA"))) { |
297 if(0 == strcmp(alpha, "disable")) { | 298 if(0 == strcmp(alpha, "disable")) { |
298 alpha_disable = 1; | 299 alpha_disable = 1; |
299 } | 300 } |
300 } | 301 } |
301 } else { | 302 } else { |
302 printf(IVTV_MSG"Failed to open /dev/fb%u\n", fb_number); | 303 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"Failed to open /dev/fb%u\n", fb_number); |
303 return ENXIO; | 304 return ENXIO; |
304 } | 305 } |
305 | 306 |
306 /* Try to find YUV device */ | 307 /* Try to find YUV device */ |
307 do { | 308 do { |
308 sprintf(yuv_device_name, "/dev/video%u", yuv_device); | 309 sprintf(yuv_device_name, "/dev/video%u", yuv_device); |
309 yuvdev = open(yuv_device_name, O_RDWR); | 310 yuvdev = open(yuv_device_name, O_RDWR); |
310 if(-1 != yuvdev) { | 311 if(-1 != yuvdev) { |
311 if(ivtv_verbose) | 312 if(ivtv_verbose) |
312 printf(IVTV_MSG"YUV device found /dev/video%u\n", yuv_device); | 313 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"YUV device found /dev/video%u\n", yuv_device); |
313 goto yuv_found; | 314 goto yuv_found; |
314 } else { | 315 } else { |
315 if(ivtv_verbose) | 316 if(ivtv_verbose) |
316 printf(IVTV_MSG"YUV device not found: /dev/video%u\n", yuv_device); | 317 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"YUV device not found: /dev/video%u\n", yuv_device); |
317 } | 318 } |
318 } while(yuv_device-- > yuv_device_number); | 319 } while(yuv_device-- > yuv_device_number); |
319 return ENXIO; | 320 return ENXIO; |
320 | 321 |
321 yuv_found: | 322 yuv_found: |
322 if(0 == alpha_disable) { | 323 if(0 == alpha_disable) { |
323 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) | 324 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) |
324 if(ioctl(fbdev, IVTVFB_IOCTL_GET_STATE, &fb_state_old) < 0) { | 325 if(ioctl(fbdev, IVTVFB_IOCTL_GET_STATE, &fb_state_old) < 0) { |
325 printf(IVTV_MSG"Unable to read fb state\n"); | 326 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"Unable to read fb state\n"); |
326 close(yuvdev); | 327 close(yuvdev); |
327 close(fbdev); | 328 close(fbdev); |
328 return ENXIO; | 329 return ENXIO; |
329 } else { | 330 } else { |
330 if(ivtv_verbose) { | 331 if(ivtv_verbose) { |
331 printf(IVTV_MSG"old alpha : %ld\n",fb_state_old.alpha); | 332 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"old alpha : %ld\n",fb_state_old.alpha); |
332 printf(IVTV_MSG"old status: 0x%lx\n",fb_state_old.status); | 333 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"old status: 0x%lx\n",fb_state_old.status); |
333 } | 334 } |
334 fb_state_hide.alpha = 0; | 335 fb_state_hide.alpha = 0; |
335 fb_state_hide.status = fb_state_old.status | IVTVFB_STATUS_GLOBAL_ALPHA; | 336 fb_state_hide.status = fb_state_old.status | IVTVFB_STATUS_GLOBAL_ALPHA; |
336 } | 337 } |
337 #else | 338 #else |
338 memset(&format_old, 0, sizeof(format_old)); | 339 memset(&format_old, 0, sizeof(format_old)); |
339 format_old.type = format_hide.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY; | 340 format_old.type = format_hide.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY; |
340 if(ioctl(yuvdev, VIDIOC_G_FMT , &format_old) < 0) { | 341 if(ioctl(yuvdev, VIDIOC_G_FMT , &format_old) < 0) { |
341 printf(IVTV_MSG"Unable to read fb state\n"); | 342 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"Unable to read fb state\n"); |
342 close(yuvdev); | 343 close(yuvdev); |
343 close(fbdev); | 344 close(fbdev); |
344 return ENXIO; | 345 return ENXIO; |
345 } else { | 346 } else { |
346 if(ivtv_verbose) { | 347 if(ivtv_verbose) { |
347 printf(IVTV_MSG"old alpha : %d\n",format_old.fmt.win.global_alpha); | 348 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"old alpha : %d\n",format_old.fmt.win.global_alpha); |
348 } | 349 } |
349 memcpy(&format_hide, &format_old, sizeof(format_old)); | 350 memcpy(&format_hide, &format_old, sizeof(format_old)); |
350 format_hide.fmt.win.global_alpha = 0; | 351 format_hide.fmt.win.global_alpha = 0; |
351 } | 352 } |
352 #endif | 353 #endif |
356 } | 357 } |
357 | 358 |
358 int ivtv_init(const char *args) | 359 int ivtv_init(const char *args) |
359 { | 360 { |
360 if(ivtv_verbose) | 361 if(ivtv_verbose) |
361 printf(IVTV_MSG"init\n"); | 362 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"init\n"); |
362 | 363 |
363 if (!probed) { | 364 if (!probed) { |
364 if(ivtv_verbose) | 365 if(ivtv_verbose) |
365 printf(IVTV_MSG"Driver was not probed but is being initialized\n"); | 366 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"Driver was not probed but is being initialized\n"); |
366 return EINTR; | 367 return EINTR; |
367 } | 368 } |
368 outbuf = malloc((IVTVMAXHEIGHT * IVTVMAXWIDTH) + (IVTVMAXHEIGHT * IVTVMAXWIDTH / 2)); | 369 outbuf = malloc((IVTVMAXHEIGHT * IVTVMAXWIDTH) + (IVTVMAXHEIGHT * IVTVMAXWIDTH / 2)); |
369 if(NULL == outbuf) { | 370 if(NULL == outbuf) { |
370 if(ivtv_verbose) | 371 if(ivtv_verbose) |
371 printf(IVTV_MSG"Not enough memory availabe!\n"); | 372 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"Not enough memory availabe!\n"); |
372 return EINTR; | 373 return EINTR; |
373 } | 374 } |
374 return 0; | 375 return 0; |
375 } | 376 } |
376 | 377 |
377 void ivtv_destroy(void) | 378 void ivtv_destroy(void) |
378 { | 379 { |
379 if(ivtv_verbose) | 380 if(ivtv_verbose) |
380 printf(IVTV_MSG"destroy\n"); | 381 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"destroy\n"); |
381 if(-1 != yuvdev) | 382 if(-1 != yuvdev) |
382 close(yuvdev); | 383 close(yuvdev); |
383 if(-1 != fbdev) | 384 if(-1 != fbdev) |
384 close(fbdev); | 385 close(fbdev); |
385 free(outbuf); | 386 free(outbuf); |
387 } | 388 } |
388 | 389 |
389 int ivtv_get_caps(vidix_capability_t *to) | 390 int ivtv_get_caps(vidix_capability_t *to) |
390 { | 391 { |
391 if(ivtv_verbose) | 392 if(ivtv_verbose) |
392 printf(IVTV_MSG"GetCap\n"); | 393 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"GetCap\n"); |
393 memcpy(to, &ivtv_cap, sizeof(vidix_capability_t)); | 394 memcpy(to, &ivtv_cap, sizeof(vidix_capability_t)); |
394 return 0; | 395 return 0; |
395 } | 396 } |
396 | 397 |
397 int ivtv_query_fourcc(vidix_fourcc_t *to) | 398 int ivtv_query_fourcc(vidix_fourcc_t *to) |
398 { | 399 { |
399 int supports = 0; | 400 int supports = 0; |
400 | 401 |
401 if(ivtv_verbose) | 402 if(ivtv_verbose) |
402 printf(IVTV_MSG"query fourcc (%x)\n", to->fourcc); | 403 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"query fourcc (%x)\n", to->fourcc); |
403 | 404 |
404 switch(to->fourcc) | 405 switch(to->fourcc) |
405 { | 406 { |
406 case IMGFMT_YV12: | 407 case IMGFMT_YV12: |
407 supports = 1; | 408 supports = 1; |
420 } | 421 } |
421 | 422 |
422 int ivtv_config_playback(vidix_playback_t *info) | 423 int ivtv_config_playback(vidix_playback_t *info) |
423 { | 424 { |
424 if(ivtv_verbose) | 425 if(ivtv_verbose) |
425 printf(IVTV_MSG"config playback\n"); | 426 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"config playback\n"); |
426 | 427 |
427 if(2 == ivtv_verbose){ | 428 if(2 == ivtv_verbose){ |
428 printf(IVTV_MSG"src : x:%d y:%d w:%d h:%d\n", | 429 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"src : x:%d y:%d w:%d h:%d\n", |
429 info->src.x, info->src.y, info->src.w, info->src.h); | 430 info->src.x, info->src.y, info->src.w, info->src.h); |
430 printf(IVTV_MSG"dest: x:%d y:%d w:%d h:%d\n", | 431 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"dest: x:%d y:%d w:%d h:%d\n", |
431 info->dest.x, info->dest.y, info->dest.w, info->dest.h); | 432 info->dest.x, info->dest.y, info->dest.w, info->dest.h); |
432 } | 433 } |
433 | 434 |
434 memcpy(&destVideo, &info->dest, sizeof(vidix_rect_t)); | 435 memcpy(&destVideo, &info->dest, sizeof(vidix_rect_t)); |
435 memcpy(&srcVideo, &info->src, sizeof(vidix_rect_t)); | 436 memcpy(&srcVideo, &info->src, sizeof(vidix_rect_t)); |
443 info->offset.y = 0; | 444 info->offset.y = 0; |
444 info->offset.u = info->src.w * info->src.h; | 445 info->offset.u = info->src.w * info->src.h; |
445 info->offset.v = info->offset.u + ((info->src.w * info->src.h)/4); | 446 info->offset.v = info->offset.u + ((info->src.w * info->src.h)/4); |
446 info->dga_addr = memBase = malloc(info->num_frames*info->frame_size); | 447 info->dga_addr = memBase = malloc(info->num_frames*info->frame_size); |
447 if(ivtv_verbose) | 448 if(ivtv_verbose) |
448 printf(IVTV_MSG"frame_size: %d, dga_addr: %p\n", | 449 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"frame_size: %d, dga_addr: %p\n", |
449 info->frame_size, info->dga_addr); | 450 info->frame_size, info->dga_addr); |
450 return 0; | 451 return 0; |
451 } | 452 } |
452 | 453 |
453 int ivtv_playback_on(void) | 454 int ivtv_playback_on(void) |
454 { | 455 { |
455 if(ivtv_verbose) | 456 if(ivtv_verbose) |
456 printf(IVTV_MSG"playback on\n"); | 457 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"playback on\n"); |
457 | 458 |
458 if(0 == alpha_disable) { | 459 if(0 == alpha_disable) { |
459 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) | 460 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) |
460 if (-1 != fbdev) { | 461 if (-1 != fbdev) { |
461 if (ioctl(fbdev, IVTVFB_IOCTL_SET_STATE, &fb_state_hide) < 0) | 462 if (ioctl(fbdev, IVTVFB_IOCTL_SET_STATE, &fb_state_hide) < 0) |
462 printf (IVTV_MSG"Failed to set fb state\n"); | 463 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"Failed to set fb state\n"); |
463 } | 464 } |
464 #else | 465 #else |
465 if (-1 != yuvdev) { | 466 if (-1 != yuvdev) { |
466 if (ioctl(yuvdev, VIDIOC_S_FMT, &format_hide) < 0) | 467 if (ioctl(yuvdev, VIDIOC_S_FMT, &format_hide) < 0) |
467 printf (IVTV_MSG"Failed to set fb state\n"); | 468 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"Failed to set fb state\n"); |
468 } | 469 } |
469 #endif | 470 #endif |
470 } | 471 } |
471 return 0; | 472 return 0; |
472 } | 473 } |
473 | 474 |
474 int ivtv_playback_off(void) | 475 int ivtv_playback_off(void) |
475 { | 476 { |
476 if(ivtv_verbose) | 477 if(ivtv_verbose) |
477 printf(IVTV_MSG"playback off\n"); | 478 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"playback off\n"); |
478 | 479 |
479 if(0 == alpha_disable) { | 480 if(0 == alpha_disable) { |
480 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) | 481 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) |
481 if (-1 != fbdev) { | 482 if (-1 != fbdev) { |
482 if (ioctl(fbdev, IVTVFB_IOCTL_SET_STATE, &fb_state_old) < 0) | 483 if (ioctl(fbdev, IVTVFB_IOCTL_SET_STATE, &fb_state_old) < 0) |
483 printf (IVTV_MSG"Failed to restore fb state\n"); | 484 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"Failed to restore fb state\n"); |
484 } | 485 } |
485 #else | 486 #else |
486 if (-1 != yuvdev) { | 487 if (-1 != yuvdev) { |
487 if (ioctl(yuvdev, VIDIOC_S_FMT, &format_old) < 0) | 488 if (ioctl(yuvdev, VIDIOC_S_FMT, &format_old) < 0) |
488 printf (IVTV_MSG"Failed to restore fb state\n"); | 489 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"Failed to restore fb state\n"); |
489 } | 490 } |
490 #endif | 491 #endif |
491 } | 492 } |
492 return 0; | 493 return 0; |
493 } | 494 } |
539 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) | 540 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) |
540 if(ioctl(yuvdev, IVTV_IOC_PREP_FRAME_YUV, &args) == -1) { | 541 if(ioctl(yuvdev, IVTV_IOC_PREP_FRAME_YUV, &args) == -1) { |
541 #else | 542 #else |
542 if(ioctl(yuvdev, IVTV_IOC_DMA_FRAME, &args) == -1) { | 543 if(ioctl(yuvdev, IVTV_IOC_DMA_FRAME, &args) == -1) { |
543 #endif | 544 #endif |
544 printf("Ioctl IVTV_IOC_DMA_FRAME returned failed Error\n"); | 545 mp_msg(MSGT_VO, MSGL_STATUS, IVTV_MSG"Ioctl IVTV_IOC_DMA_FRAME returned failed Error\n"); |
545 } | 546 } |
546 return 0; | 547 return 0; |
547 } | 548 } |
548 | 549 |
549 VDXDriver ivtv_drv = { | 550 VDXDriver ivtv_drv = { |