void init_busyboard(struct busyboard *b, const char *devnode) { int i; b->fd = open_parport(devnode); b->trimask = 0; for (i = 0; i < BUSYBOARD_N_PORTS; ++i) b->out_state[i] = 0; set_bit(b->fd, BIT_DATA, 0); set_bit(b->fd, BIT_LATCH_OUT, 0); set_bit(b->fd, BIT_LATCH_IN, 0); set_bit(b->fd, BIT_STROBE, 0); set_bit(b->fd, BIT_N_LD_IN, 1); }
int init_genlock(SINGLE_QSP_ARG_DECL) { int n,i; if( genlock_active ){ WARN("init_genlock: genlock is already active!?"); return -1; } n=HOW_MANY("number of frame buffers to genlock"); if( n < 1 || n > MAX_HEADS ){ sprintf(ERROR_STRING,"do_genlock: number of frame buffers (%d) must be between 1 and %d",n,MAX_HEADS); WARN(ERROR_STRING); return -1; } gli1.gli_n_heads = n; for(i=0;i<n;i++){ gli1.gli_fbip[i] = pick_fbi("frame buffer for VSYNC"); gli1.gli_fb_latency[i] = (-1); gli1.gli_pp_latency[i] = (-1); gli1.gli_refractory[i]=GL_REFRACTORY; /* wait before adjusting */ } for(i=0;i<n;i++) if( gli1.gli_fbip[i] == NULL ) return -1; if( the_ppp == NULL ){ the_ppp=open_parport(NULL); /* use default */ if( the_ppp == NULL ) return -1; } gli1.gli_ppp = the_ppp; gli1.gli_qsp = THIS_QSP; genlock_active=1; return 0; }
static void test_parport(void) { int n,s; Data_Obj *dp; u_long *lp; FB_Info *fbip; pthread_attr_t attr1; VBoard_Info vbi1; PPort_Info ppti1; u_long l; pthread_attr_init(&attr1); /* initialize to default values */ pthread_attr_setinheritsched(&attr1,PTHREAD_INHERIT_SCHED); fbip = pick_fbi("frame buffer for VSYNC"); dp = pick_obj("data vector for latencies"); if( fbip == NULL || dp == NULL ) return; INSIST_RAM_OBJ(dp,"test_parport") if( OBJ_PREC(dp) != PREC_UDI ){ sprintf(ERROR_STRING,"latency vector %s (%s) should have precision %s", OBJ_NAME(dp),PREC_NAME(OBJ_PREC_PTR(dp)), NAME_FOR_PREC_CODE(PREC_UDI)); WARN(ERROR_STRING); return; } if( OBJ_COMPS(dp) != 2 ){ sprintf(ERROR_STRING,"latency vector %s (%d) should have 2 components", OBJ_NAME(dp),OBJ_COMPS(dp)); WARN(ERROR_STRING); return; } if( ! IS_CONTIGUOUS(dp) ){ sprintf(ERROR_STRING,"latency vector %s should be contiguous",OBJ_NAME(dp)); WARN(ERROR_STRING); return; } n = OBJ_N_MACH_ELTS(dp)/2; lp = (u_long *) OBJ_DATA_PTR(dp); vbi1.vbi_fbip = fbip; vbi1.vbi_buf = lp; vbi1.vbi_count = n; vbi1.vbi_inc = 2; #ifdef THREAD_SAFE_QUERY vbi1.vbi_qsp = THIS_QSP; #endif // THREAD_SAFE_QUERY lp ++; if( the_ppp == NULL ){ the_ppp=open_parport(NULL); /* use default */ if( the_ppp == NULL ) return; } ppti1.ppti_ppp = the_ppp; ppti1.ppti_buf = lp; ppti1.ppti_count = n; ppti1.ppti_inc = 2; tvp = NULL; /* force re-zero */ s=read_til_transition(the_ppp,8); if( s==0 ) s=read_til_transition(the_ppp,8); /* should now be in the one state */ /* this is the end of the (negative) pulse */ l = delta_usecs(); /* zero the clock */ pthread_create(&vboard_thr,&attr1,vboard_daemon,&vbi1); pthread_create(&pport_thr,&attr1,pport_logger,&ppti1); /* should wait for threads here... */ if( pthread_join(vboard_thr,NULL) != 0 ){ perror("pthread_join"); WARN("error joining video board thread"); } if( pthread_join(pport_thr,NULL) != 0 ){ perror("pthread_join"); WARN("error joining parallel port thread"); } }