232{
234 int i;
235 int res;
236 int mode_index = 0;
237 char card_name[128] = "";
238
241
242 if (s == NULL) {
243 debug_msg(
"Unable to allocate DVS state\n");
245 }
246
250
254 free(s);
256 }
257
260
261 if (isdigit(
fmt[0])) {
264 fprintf(stderr,
"Wrong config %s\n",
fmt);
266 free(s);
268 }
269 mode_index = atoi(
item);
273 break;
274 }
275 }
276 if(s->
mode == NULL) {
277 fprintf(stderr, "dvs: unknown video mode: %d\n", mode_index);
279 free(s);
281 }
282
283 item = strtok(NULL,
":");
285 fprintf(stderr,
"Wrong config %s\n",
fmt);
287 free(s);
289 }
290
293 fprintf(stderr,
"dvs: unknown codec: %s\n",
item);
295 free(s);
297 }
298
299
300 item = strtok(NULL,
":");
302 snprintf(card_name,
sizeof card_name,
"PCI,card:%s",
item);
303 printf("[DVS] Choosen card: %s.\n", card_name);
304 }
305 } else {
307 while ((
item = strtok(tmp,
":"))) {
308 if (strncmp(
item,
"mode=",
sizeof(
"mode=")) == 0) {
309 mode_index = atoi(strchr(
item,
'=') + 1);
313 break;
314 }
315 }
316 if(s->
mode == NULL) {
317 fprintf(stderr, "dvs: unknown video mode: %d\n", mode_index);
319 free(s);
321 }
322 }
else if (strncmp(
item,
"device=",
sizeof(
"device=")) == 0) {
323 snprintf(card_name,
sizeof card_name,
"PCI,card:%s", strchr(
item,
'=') + 1);
324 printf("[DVS] Choosen card: %s.\n", card_name);
325 }
else if (strncmp(
item,
"codec=",
sizeof(
"codec=")) == 0) {
328 fprintf(stderr,
"dvs: unknown codec: %s\n",
item);
330 free(s);
332 }
333 } else {
336 free(s);
338 }
339 }
340 }
341
343 }
344
345 gettimeofday(&s->
t0, NULL);
346
347 res = sv_openex(&s->
sv, card_name, SV_OPENPROGRAM_DEFAULT, SV_OPENTYPE_DEFAULT, 0, 0);
349 printf
350 ("Unable to open grabber: sv_open() failed (no card present or driver not loaded?)\n");
351 printf("Error %s\n", sv_geterrortext(res));
352 free(s);
354 }
355
358 } else {
360 free(s);
362 }
364 }
365
367
371 s->
hd_video_mode |= SV_MODE_COLOR_YUV422 | SV_MODE_NBIT_10BDVS;
372 break;
375 break;
378 break;
381 break;
382 default:
383 fprintf(stderr, "[dvs] Unsupported video codec passed!");
384 free(s);
386 }
387
389 } else {
391 int res;
392 res = sv_query(s->
sv, SV_QUERY_INPUTRASTER, 0, &
val);
393 if(res != SV_OK) {
394 printf("[DVS] Could not detect video format %s\n",
395 sv_geterrortext(res));
396 goto error_detect;
397 }
399 printf("[DVS] No signal detected, cannot autodetect format.\n");
400 goto error_detect;
401 }
405 break;
406 }
407 }
409 if (s->
mode == NULL) {
411 goto error_detect;
412 }
414
415 res = sv_query(s->
sv, SV_QUERY_IOMODE, 0, &
val);
416 if(res != SV_OK) {
417 printf("Could not detect IO mode %s\n",
418 sv_geterrortext(res));
419 goto error_detect;
420 }
421 printf(
"[DVS] Autodetected IO mode: %d.\n",
val);
422
424 case SV_IOMODE_YUV422:
425 case SV_IOMODE_YUV444:
426 case SV_IOMODE_YUV422A:
427 case SV_IOMODE_YUV444A:
428 case SV_IOMODE_YUV422_12:
429 case SV_IOMODE_YUV444_12:
432 break;
433 case SV_IOMODE_RGB:
434 case SV_IOMODE_RGB_12:
437 break;
438 case SV_IOMODE_RGBA:
441 break;
442 }
443 }
445
453 break;
456 break;
457 }
458
459
462
463
464
466 if (res != SV_OK) {
468 }
469 res = sv_black(s->
sv);
470 if (res != SV_OK) {
472 }
473
475
477 int i;
478 res = sv_option(s->
sv, SV_OPTION_AUDIOINPUT, SV_AUDIOINPUT_AIV);
479 if (res != SV_OK) {
481 }
484 fprintf(stderr, "[DVS cap.] Invalid channel count %d. "
485 "Currently only 1 or 2 channels are supported.\n",
488 }
489 res = sv_option(s->
sv, SV_OPTION_AUDIOCHANNELS, 1);
490 if (res != SV_OK) {
492 }
493
494 sv_query(s->
sv, SV_QUERY_AUDIOBITS, 0, &i);
496 sv_query(s->
sv, SV_QUERY_AUDIOFREQ, 0, &i);
499
500
503
505
508 }
509
511 }
512
513 res = sv_fifo_init(s->
sv, &(s->
fifo), 1,
514 0,
515 SV_FIFO_DMA_ON,
516 SV_FIFO_FLAG_NODMAADDR,
517 0
518 );
519 if (res != SV_OK) {
521 }
522 res = sv_fifo_start(s->
sv, s->
fifo);
523 if (res != SV_OK) {
525 }
526
527 pthread_mutex_init(&(s->
lock), NULL);
528 pthread_cond_init(&(s->
boss_cv), NULL);
529 pthread_cond_init(&(s->
worker_cv), NULL);
530
538
539 if (pthread_create
541 perror("Unable to create grabbing thread");
543 }
544
546
547 debug_msg(
"DVS capture device enabled\n");
550error_detect:
553 free(s);
554 printf("Error %s\n", sv_geterrortext(res));
555 debug_msg(
"Unable to open grabber: %s\n", sv_geterrortext(res));
557}
struct video_frame * vf_alloc(int count)
Allocates blank video frame.
int vc_get_linesize(unsigned int width, codec_t codec)
codec_t get_codec_from_name(const char *name)
#define LOG_LEVEL_NOTICE
information that may be interesting
#define LOG_LEVEL_ERROR
general errors
#define debug_msg(...)
#define debug_msg(...) log_msg(LOG_LEVEL_DEBUG, "[pid/%d +%d %s] ", getpid(), LINE,...
#define VIDCAP_INIT_NOERR
state not initialized, other action performed (typically help)
#define VIDCAP_INIT_OK
initialization successful
#define VIDCAP_INIT_FAIL
error ocured
#define VIDCAP_INIT_AUDIO_NOT_SUPPORTED
card does not support audio
unsigned int audio_capture_channels
#define DEFAULT_AUDIO_CAPTURE_CHANNELS
const hdsp_mode_table_t * mode
enum interlacing_t interlacing
@ PROGRESSIVE
progressive frame
@ INTERLACED_MERGED
Columngs of both fields are interlaced together.
static void * vidcap_dvs_grab_thread(void *arg)
static void show_help(void)
const char * vidcap_params_get_fmt(const struct vidcap_params *params)
unsigned int vidcap_params_get_flags(const struct vidcap_params *params)
#define VIDCAP_FLAG_AUDIO_ANY
#define VIDCAP_FLAG_AUDIO_EMBEDDED
HD-SDI embedded audio.
double get_bpp(codec_t codec)
struct tile * vf_get_tile(struct video_frame *buf, int pos)
Returns pointer to n-th tile from video frame Equivalent to &video_frame::tiles[pos].