00001
00006 #include "edtinc.h"
00007 #include "clsim_lib.h"
00008
00030 void pdv_cls_set_size(PdvDev *pdv_p,
00031 int taps,
00032 int depth ,
00033 int width,
00034 int height,
00035 int hblank,
00036 int totalwidth,
00037 int vblank,
00038 int totalheight)
00039
00040 {
00041 PdvDependent *dd_p = pdv_p->dd_p;
00042 int clocks;
00043
00044
00045 if (taps == 0)
00046 taps = 1;
00047
00048 clocks = width / taps;
00049
00050 if (hblank)
00051 {
00052 totalwidth = clocks + hblank;
00053 pdv_p->dd_p->cls.hblank = hblank;
00054 }
00055
00056 if (vblank)
00057 {
00058 totalheight = height + vblank;
00059 pdv_p->dd_p->cls.vblank = vblank;
00060 }
00061
00062
00063
00064 edt_reg_write(pdv_p, PDV_CLSIM_HCNTMAX, totalwidth-1);
00065 edt_reg_write(pdv_p, PDV_CLSIM_VACTV, height-1);
00066 edt_reg_write(pdv_p, PDV_CLSIM_VCNTMAX, totalheight-1);
00067
00068 edt_reg_write(pdv_p, PDV_CL_DATA_PATH, dd_p->cl_data_path);
00069
00070 edt_reg_write(pdv_p, PDV_CFG, 0);
00071
00072 dd_p->width = width;
00073 dd_p->height = height;
00074 dd_p->depth = depth;
00075 dd_p->imagesize = dd_p->height * pdv_get_pitch(pdv_p);
00076 dd_p->cls.taps = taps;
00077 }
00078
00096 void
00097 pdv_cls_set_line_timing(PdvDev *pdv_p,
00098 int width,
00099 int taps,
00100 int Hfvstart,
00101 int Hfvend,
00102 int Hlvstart,
00103 int Hlvend,
00104 int Hrvstart,
00105 int Hrvend)
00106
00107 {
00108 ClSimControl *cls = &pdv_p->dd_p->cls;
00109 int clocks;
00110
00111 if (taps == 0)
00112 taps = 1;
00113
00114 clocks = width / taps;
00115
00116 cls->Hfvstart = Hfvstart;
00117 cls->Hfvend = (Hfvend)?Hfvend:Hfvstart+clocks;
00118
00119 cls->Hlvstart = Hlvstart;
00120 cls->Hlvend = (Hlvend)?Hlvend:Hlvstart+clocks;
00121
00122 cls->Hrvstart = Hrvstart;
00123 cls->Hrvend = (Hrvend)?Hrvend:Hrvstart+clocks;
00124
00125 edt_reg_write(pdv_p, PDV_CLSIM_HFVSTART, cls->Hfvstart);
00126 edt_reg_write(pdv_p, PDV_CLSIM_HFVEND, cls->Hfvend);
00127
00128 edt_reg_write(pdv_p, PDV_CLSIM_HLVSTART, cls->Hlvstart);
00129 edt_reg_write(pdv_p, PDV_CLSIM_HLVEND, cls->Hlvend);
00130
00131 edt_reg_write(pdv_p, PDV_CLSIM_HRVSTART, cls->Hrvstart);
00132 edt_reg_write(pdv_p, PDV_CLSIM_HRVEND, cls->Hrvend);
00133
00134 pdv_p->dd_p->width = width;
00135 pdv_p->dd_p->cls.taps = taps;
00136
00137 }
00138
00139
00146 int
00147 pdv_cls_get_hgap(PdvDev *pdv_p)
00148
00149 {
00150 int totalcnt;
00151 int clocks;
00152 int taps;
00153 int rgb;
00154
00155 rgb = pdv_p->dd_p->cl_cfg & PDV_CL_CFG_RGB;
00156
00157 totalcnt = edt_reg_read(pdv_p, PDV_CLSIM_HCNTMAX) + 1;
00158
00159 if (rgb)
00160 taps = 1;
00161 else if (pdv_get_depth(pdv_p) > 8)
00162 taps = 1;
00163 else
00164 taps = (edt_reg_read(pdv_p, PDV_CL_DATA_PATH) >> 4) + 1;
00165
00166 clocks = pdv_get_width(pdv_p) / taps;
00167
00168 return totalcnt - clocks;
00169
00170 }
00171
00178 int
00179 pdv_cls_get_vgap(PdvDev *pdv_p)
00180
00181 {
00182 int totalcnt;
00183 int vactv;
00184
00185 totalcnt = edt_reg_read(pdv_p, PDV_CLSIM_VCNTMAX) + 1;
00186
00187 vactv = edt_reg_read(pdv_p, PDV_CLSIM_VACTV) + 1;
00188
00189 return totalcnt - vactv;
00190
00191 }
00192
00201 void
00202 pdv_cls_init_serial(PdvDev *pdv_p)
00203
00204 {
00205 pdv_reset_serial(pdv_p);
00206
00207 edt_reg_write(pdv_p, PDV_CMD, 1);
00208
00209 edt_reg_write(pdv_p, PDV_SERIAL_DATA_CNTL, 3);
00210 edt_reg_write(pdv_p, PDV_BYTESWAP, 0);
00211
00212 pdv_serial_read_enable(pdv_p);
00213 }
00214
00224 void pdv_cls_set_cfg_bit(PdvDev *pdv_p,
00225 int reg,
00226 int mask,
00227 int state)
00228
00229 {
00230 int cfg = edt_reg_read(pdv_p, reg);
00231
00232 cfg = (cfg & ~mask) | ((state)? mask : 0);
00233
00234 edt_reg_write(pdv_p, reg, cfg);
00235 }
00236
00247 void
00248 pdv_cls_set_linescan(PdvDev *pdv_p, int state)
00249
00250 {
00251 pdv_cls_set_cfg_bit(pdv_p, PDV_CLSIM_CFGA, 0x80, state);
00252 }
00253
00266 void
00267 pdv_cls_set_lvcont(PdvDev *pdv_p, int state)
00268
00269 {
00270 pdv_cls_set_cfg_bit(pdv_p, PDV_CLSIM_CFGA, 0x40, state);
00271 }
00272
00289 void
00290 pdv_cls_set_rven(PdvDev *pdv_p, int state)
00291
00292 {
00293 pdv_cls_set_cfg_bit(pdv_p, PDV_CLSIM_CFGA, 0x20, state);
00294 }
00295
00307 void
00308 pdv_cls_set_uartloop(PdvDev *pdv_p, int state)
00309
00310 {
00311 pdv_cls_set_cfg_bit(pdv_p, PDV_CLSIM_CFGA, 0x10, state);
00312 }
00313
00326 void
00327 pdv_cls_set_smallok(PdvDev *pdv_p, int state)
00328
00329 {
00330 pdv_cls_set_cfg_bit(pdv_p, PDV_CLSIM_CFGA, 8, state);
00331 }
00332
00353 void
00354 pdv_cls_set_intlven(PdvDev *pdv_p, int state)
00355
00356 {
00357 pdv_cls_set_cfg_bit(pdv_p, PDV_CLSIM_CFGA, 4, state);
00358 }
00359
00373 void
00374 pdv_cls_set_firstfc(PdvDev *pdv_p, int state)
00375
00376 {
00377 pdv_cls_set_cfg_bit(pdv_p, PDV_CLSIM_CFGA, 2, state);
00378 }
00379
00399 void
00400 pdv_cls_set_datacnt(PdvDev *pdv_p, int state)
00401
00402 {
00403 pdv_cls_set_cfg_bit(pdv_p, PDV_CLSIM_CFGA, 1, state);
00404 }
00405
00411 void
00412 pdv_cls_set_led(PdvDev *pdv_p, int state)
00413
00414 {
00415 pdv_cls_set_cfg_bit(pdv_p, PDV_CLSIM_CFGC, 0x80,state);
00416 }
00417
00429 void
00430 pdv_cls_set_trigsrc(PdvDev *pdv_p, int select)
00431
00432 {
00433 pdv_cls_set_cfg_bit(pdv_p, PDV_CLSIM_CFGC, 0x08, select);
00434 }
00435
00447 void
00448 pdv_cls_set_trigpol(PdvDev *pdv_p, int polarity)
00449
00450 {
00451 pdv_cls_set_cfg_bit(pdv_p, PDV_CLSIM_CFGC, 0x04, polarity);
00452 }
00453
00464 void
00465 pdv_cls_set_trigframe(PdvDev *pdv_p, int state)
00466
00467 {
00468 pdv_cls_set_cfg_bit(pdv_p, PDV_CLSIM_CFGC, 0x02, state);
00469 }
00470
00482 void
00483 pdv_cls_set_trigline(PdvDev *pdv_p, int state)
00484
00485 {
00486 pdv_cls_set_cfg_bit(pdv_p, PDV_CLSIM_CFGC, 1,state);
00487 }
00488
00497 void
00498 pdv_cls_sim_start(PdvDev *pdv_p)
00499
00500 {
00501 edt_reg_write(pdv_p, PDV_CFG, 0);
00502 }
00503
00511 void
00512 pdv_cls_sim_stop(PdvDev *pdv_p)
00513
00514 {
00515
00516 edt_reg_write(pdv_p, PDV_CFG, 8);
00517 }
00518
00532 void
00533 pdv_cls_set_width(PdvDev *pdv_p, int width, int hblank)
00534
00535 {
00536 Dependent *dd_p = pdv_p->dd_p;
00537 int totalwidth;
00538 int taps = edt_reg_read(pdv_p, PDV_CL_DATA_PATH);
00539 int rgb = pdv_p->dd_p->cl_cfg & PDV_CL_CFG_RGB;
00540 int clocks;
00541
00542 taps = (taps >> 4) + 1;
00543
00544 if ((taps == 0) || rgb)
00545 taps = 1;
00546
00547 clocks = width / taps;
00548
00549 dd_p->width = width;
00550 dd_p->cls.taps = taps;
00551
00552 if (hblank)
00553 {
00554 totalwidth = clocks + hblank;
00555 pdv_p->dd_p->cls.hblank = hblank;
00556 }
00557 else totalwidth = width / taps;
00558
00559 dd_p->imagesize = dd_p->height * pdv_get_pitch(pdv_p);
00560
00561
00562
00563 edt_reg_write(pdv_p, PDV_CLSIM_HCNTMAX, totalwidth-1);
00564
00565
00566 pdv_cls_set_line_timing(pdv_p,
00567 width,
00568 taps,
00569 dd_p->cls.Hfvstart, dd_p->cls.Hfvend,
00570 0,0,
00571 0,0);
00572
00573 dd_p->imagesize = dd_p->height * pdv_get_pitch(pdv_p);
00574 edt_set_dependent(pdv_p, dd_p);
00575 }
00576
00591 void
00592 pdv_cls_set_width_lval_rval(PdvDev *pdv_p, int width, int hblank, int hlvstart, int hlvend, int hrvstart, int hrvend)
00593
00594 {
00595 Dependent *dd_p = pdv_p->dd_p;
00596 int totalwidth;
00597 int taps = edt_reg_read(pdv_p, PDV_CL_DATA_PATH);
00598 int rgb = pdv_p->dd_p->cl_cfg & PDV_CL_CFG_RGB;
00599 int clocks;
00600
00601 taps = (taps >> 4) + 1;
00602
00603 if ((taps == 0) || rgb)
00604 taps = 1;
00605
00606 clocks = width / taps;
00607
00608 dd_p->width = width;
00609 dd_p->cls.taps = taps;
00610
00611 if (hblank)
00612 {
00613 totalwidth = clocks + hblank;
00614 pdv_p->dd_p->cls.hblank = hblank;
00615 }
00616 else totalwidth = width / taps;
00617
00618 dd_p->imagesize = dd_p->height * pdv_get_pitch(pdv_p);
00619
00620
00621
00622 edt_reg_write(pdv_p, PDV_CLSIM_HCNTMAX, totalwidth-1);
00623
00624 pdv_cls_set_line_timing(pdv_p,
00625 width,
00626 taps,
00627 dd_p->cls.Hfvstart, dd_p->cls.Hfvend,
00628 hlvstart,hlvend,
00629 hrvstart, hrvend);
00630
00631 dd_p->imagesize = dd_p->height * pdv_get_pitch(pdv_p);
00632 edt_set_dependent(pdv_p, dd_p);
00633 }
00634
00635
00643 void
00644 pdv_cls_set_height(PdvDev *pdv_p, int height, int vblank)
00645 {
00646 Dependent *dd_p = pdv_p->dd_p;
00647
00648 dd_p->height = height;
00649 dd_p->cls.vblank = vblank;
00650
00651 edt_reg_write(pdv_p, PDV_CLSIM_VACTV, height-1);
00652 edt_reg_write(pdv_p, PDV_CLSIM_VCNTMAX, (height + vblank) - 1);
00653
00654 dd_p->imagesize = dd_p->height * pdv_get_pitch(pdv_p);
00655 edt_set_dependent(pdv_p, dd_p);
00656
00657 }
00658
00659 void
00660 pdv_cls_set_depth(PdvDev * pdv_p, int value)
00661 {
00662 Dependent *dd_p = pdv_p->dd_p;
00663
00664 dd_p->depth = value;
00665
00666
00667
00668
00669
00670 if (pdv_is_cameralink(pdv_p))
00671 {
00672 int reg;
00673
00674 if ((value >= 8) && (value <= 16))
00675 reg = value-1;
00676 else if (value == 24 || value == 32)
00677 reg = 0x7;
00678 else if (value == 30)
00679 reg = 0x9;
00680 else reg = 0;
00681
00682 if (reg)
00683 {
00684 if (dd_p->dual_channel)
00685 reg |= 0x10;
00686 dd_p->dual_channel = reg;
00687 edt_reg_write(pdv_p, PDV_CL_DATA_PATH, dd_p->cl_data_path);
00688 }
00689 }
00690
00691 dd_p->imagesize = dd_p->height * pdv_get_pitch(pdv_p);
00692 edt_set_dependent(pdv_p, dd_p);
00693
00694 }
00695
00706 void
00707 pdv_cls_set_clock(PdvDev *pdv_p, double freq)
00708
00709 {
00710 int hex,
00711 bit,
00712 dbit,
00713 m,
00714 n,
00715 n2,
00716 b,
00717 m_best,
00718 n_best;
00719 double ref=14.0;
00720 double targ35,
00721 best35,
00722 current35;
00723 double err_current35, err_best35, err1x;
00724 int mmin = (int) (0.99 + 800*4/ref);
00725 int mmax = (int) (1800*4/ref);
00726
00727
00728
00729 if (freq == 0.0)
00730 {
00731 edt_reg_write(pdv_p, EDT_SS_PLL_CTL, 0);
00732 pdv_p->dd_p->cls.pixel_clock = (float)freq;
00733 return;
00734 }
00735 else if (freq<19.9 || freq>85.1)
00736 printf("WARNING: %3.4f is not in range of 20 to 85 MHz\n", freq);
00737
00738 pdv_p->dd_p->cls.pixel_clock = (float)freq;
00739 pdv_p->dd_p->pclock_speed = (int)(pdv_p->dd_p->cls.pixel_clock + 0.5);
00740
00741
00742 if ((pdv_p->devid == PE8DVCLS_ID)
00743 || (pdv_p->devid == PE4DVVLSIM_ID))
00744 {
00745 if (pdv_p->channel_no == 0)
00746 pe8dvcls_set_clock(pdv_p, (double)freq);
00747 return;
00748 }
00749
00750
00751 if (mmax > 511)
00752 mmax=511;
00753
00754 targ35 = freq*3.5;
00755 best35 = 0.0;
00756 m_best=0;
00757 n_best=0;
00758 err_best35=100.0;
00759
00760 for (m=mmin; m<=mmax; m++)
00761 {
00762 for (n=1; n<=8; n*=2)
00763 {
00764 current35 = ref/8 * m / n;
00765 err_current35 = targ35 - current35;
00766 if (err_current35 < 0)
00767 err_current35 = -err_current35;
00768 if (err_current35 < err_best35)
00769 {
00770 best35=current35;
00771 m_best=m;
00772 n_best=n;
00773 err_best35=err_current35;
00774 }
00775 }
00776 }
00777 if (n_best==1)
00778 n2=3;
00779 else if (n_best==2)
00780 n2=0;
00781 else if (n_best==4)
00782 n2=1;
00783 else if (n_best==8)
00784 n2=2;
00785 hex = n2<<9 | m_best;
00786
00787 err1x = (best35-targ35)/3.5;
00788 if (err1x < 0.0)
00789 err1x = - err1x;
00790 if (err1x > 0.00090)
00791 {
00792 printf("req:%3.4f got:%3.4f err:%3.4f ecl:%3.4f vco:%3.4f m:%d n:%d h:%04x\n",
00793 freq,
00794 best35/3.5,
00795 (best35-targ35)/3.5,
00796 best35,best35*2*n_best,
00797 m_best,n_best,hex);
00798 }
00799
00800 edt_reg_write(pdv_p, EDT_SS_PLL_CTL, 0);
00801 for (bit=13; bit>=0; bit--)
00802 {
00803 b = hex & (1<<bit);
00804 if (b)
00805 dbit=EDT_SS_PLL_DATA;
00806 else
00807 dbit=0;
00808 edt_reg_write(pdv_p, EDT_SS_PLL_CTL, dbit) ;
00809 edt_reg_write(pdv_p, EDT_SS_PLL_CTL, dbit | EDT_SS_PLL_CLK);
00810 }
00811 edt_reg_write(pdv_p, EDT_SS_PLL_CTL, EDT_SS_PLL_STROBE0);
00812 edt_reg_write(pdv_p, EDT_SS_PLL_CTL, 0);
00813 edt_set_dependent(pdv_p, pdv_p->dd_p);
00814 }
00815
00816 #include "edt_si570.h"
00817
00825 void
00826 pe8dvcls_set_clock(PdvDev *pdv_p, double target)
00827 {
00828 u_int base_desc = 0x70;
00829 u_int device = 0;
00830 EdtSI570 clock_parms;
00831 int do_reset = 0;
00832
00833 if (target < 100)
00834 target *= 1000000.0;
00835
00836 if (pdv_p->dd_p->cls.si570_nominal == 0)
00837 {
00838 u_short stat;
00839 if (edt_flash_prom_detect(pdv_p, &stat) == AMD_XC5VLX30T_A)
00840 pdv_p->dd_p->cls.si570_nominal = 125000000.0;
00841 else pdv_p->dd_p->cls.si570_nominal = 100000000.0;
00842 }
00843 else if (pdv_p->dd_p->cls.si570_nominal < 2000.0)
00844 pdv_p->dd_p->cls.si570_nominal *= 1000000.0;
00845
00846 edt_si570_set_clock(pdv_p, base_desc, device, pdv_p->dd_p->cls.si570_nominal, target, &clock_parms);
00847
00848 edt_set_dependent(pdv_p, pdv_p->dd_p);
00849
00850 }
00851
00852
00853
00862 void pdv_cls_set_dvalid(PdvDev *pdv_p, u_char skip, u_char mode)
00863 {
00864 edt_reg_write(pdv_p, PDV_CLSIM_CFGB, (skip << 4) | (mode & 3));
00865 }
00866
00875 void pdv_cls_set_fill(PdvDev *pdv_p, u_char left, u_char right)
00876 {
00877
00878 edt_reg_write(pdv_p, PDV_CLSIM_FILLA, left);
00879 edt_reg_write(pdv_p, PDV_CLSIM_FILLB, right);
00880 }
00881
00889 void pdv_cls_set_readvalid(PdvDev *pdv_p,
00890 u_short HrvStart, u_short HrvEnd)
00891 {
00892 edt_reg_write(pdv_p, PDV_CLSIM_HRVSTART, HrvStart);
00893 edt_reg_write(pdv_p, PDV_CLSIM_HRVEND, HrvEnd);
00894 pdv_p->dd_p->cls.Hrvstart = HrvStart;
00895 pdv_p->dd_p->cls.Hrvend = HrvEnd;
00896 }
00897
00898
00915 void pdv_cls_setup_interleave(PdvDev *pdv_p,
00916 short tap0start, short tap0delta,
00917 short tap1start, short tap1delta,
00918 short tap2start, short tap2delta,
00919 short tap3start, short tap3delta)
00920
00921 {
00922 edt_reg_write(pdv_p, PDV_CLSIM_TAP0START, tap0start);
00923 edt_reg_write(pdv_p, PDV_CLSIM_TAP0DELTA, tap0delta);
00924
00925 edt_reg_write(pdv_p, PDV_CLSIM_TAP1START, tap1start);
00926 edt_reg_write(pdv_p, PDV_CLSIM_TAP1DELTA, tap1delta);
00927
00928 edt_reg_write(pdv_p, PDV_CLSIM_TAP2START, tap2start);
00929 edt_reg_write(pdv_p, PDV_CLSIM_TAP2DELTA, tap2delta);
00930
00931 edt_reg_write(pdv_p, PDV_CLSIM_TAP3START, tap3start);
00932 edt_reg_write(pdv_p, PDV_CLSIM_TAP3DELTA, tap3delta);
00933
00934 }
00935
00936
00943 int
00944 pdv_cls_set_dep(PdvDev *pdv_p)
00945
00946 {
00947 PdvDependent *dd_p = (PdvDependent *) pdv_p->dd_p;
00948 ClSimControl *cls = &dd_p->cls;
00949 int rgb = pdv_p->dd_p->cl_cfg & PDV_CL_CFG_RGB;
00950
00951 edt_startdma_action(pdv_p, EDT_ACT_NEVER);
00952
00953 pdv_cls_sim_stop(pdv_p);
00954
00955
00956 if ((cls->pixel_clock != 0) && ((cls->pixel_clock < 19.9) || (cls->pixel_clock > 85.1)))
00957 printf("WARNING: %3.4f is not in range of 20 to 85 MHz\n", cls->pixel_clock);
00958
00959
00960 pdv_cls_set_depth(pdv_p, dd_p->depth);
00961 pdv_cls_set_width_lval_rval(pdv_p, dd_p->width, cls->hblank, cls->Hlvstart, cls->Hlvend, cls->Hrvstart, cls->Hrvend);
00962 pdv_cls_set_height(pdv_p, dd_p->height, cls->vblank);
00963
00964 pdv_set_cam_width(pdv_p, dd_p->width);
00965 pdv_set_cam_height(pdv_p, dd_p->height);
00966
00967 pdv_check_fpga_rev(pdv_p);
00968 pdv_set_baud(pdv_p, dd_p->serial_baud);
00969
00970
00971
00972
00973
00974
00975
00976 if ((pdv_p->dd_p->depth == 24) && (pdv_p->dd_p->extdepth == 24))
00977 cls->taps = 1;
00978 else if (cls->taps == 0)
00979 cls->taps = (dd_p->cl_data_path >> 4) + 1;
00980 else if (dd_p->cl_data_path == 0)
00981 dd_p->cl_data_path = ((cls->taps - 1) << 4) + 7;
00982
00983 if (cls->hblank == 0 && cls->Hcntmax == 0)
00984 cls->hblank = PDV_CLS_DEFAULT_HGAP;
00985
00986 if (cls->vblank == 0 && cls->Vcntmax == 0)
00987 cls->vblank = PDV_CLS_DEFAULT_VGAP;
00988
00989 pdv_cls_set_size(pdv_p,
00990 cls->taps,
00991 dd_p->depth,
00992 dd_p->width,
00993 dd_p->height,
00994 cls->hblank, cls->Hcntmax,
00995 cls->vblank, cls->Vcntmax);
00996
00997 pdv_cls_set_line_timing(pdv_p,
00998 dd_p->width,
00999 cls->taps,
01000 cls->Hfvstart,
01001 cls->Hfvend,
01002 cls->Hlvstart,
01003 cls->Hlvend,
01004 cls->Hrvstart,
01005 cls->Hrvend);
01006
01007
01008
01009 if ((cls->Hrvend - cls->Hrvstart) > dd_p->width)
01010 {
01011 int rvwidth = cls->Hrvend - cls->Hrvstart;
01012
01013 if (rvwidth > cls->Hlvend - cls->Hlvstart)
01014 {
01015 cls->Hlvstart = cls->Hrvstart;
01016 cls->Hlvend = cls->Hrvend;
01017 }
01018 pdv_cls_set_width_lval_rval(pdv_p, rvwidth, cls->hblank, cls->Hlvstart, cls->Hlvend, cls->Hrvstart, cls->Hrvend);
01019 }
01020
01021
01022
01023 pdv_cls_set_linescan(pdv_p, cls->flags.Cfg.linescan);
01024 pdv_cls_set_lvcont(pdv_p, cls->flags.Cfg.lvcont);
01025 pdv_cls_set_rven(pdv_p, cls->flags.Cfg.rven);
01026 pdv_cls_set_uartloop(pdv_p, cls->flags.Cfg.uartloop);
01027 pdv_cls_set_smallok(pdv_p, cls->flags.Cfg.smallok);
01028 pdv_cls_set_intlven(pdv_p, cls->flags.Cfg.intlven);
01029 pdv_cls_set_firstfc(pdv_p, cls->flags.Cfg.firstfc);
01030 pdv_cls_set_datacnt(pdv_p, cls->flags.Cfg.datacnt);
01031
01032 pdv_cls_set_dvalid(pdv_p, cls->flags.Cfg.dvskip, cls->flags.Cfg.dvmode);
01033
01034 pdv_cls_set_led(pdv_p, cls->flags.Cfg.led);
01035 pdv_cls_set_trigsrc(pdv_p, cls->flags.Cfg.trigsrc);
01036 pdv_cls_set_trigpol(pdv_p, cls->flags.Cfg.trigpol);
01037 pdv_cls_set_trigframe(pdv_p, cls->flags.Cfg.trigframe);
01038 pdv_cls_set_trigline(pdv_p, cls->flags.Cfg.trigline);
01039
01040 pdv_cls_set_fill(pdv_p,cls->FillA, cls->FillB);
01041
01042 edt_reg_write(pdv_p, PDV_CLSIM_EXSYNCDLY, cls->Exsyncdly);
01043
01044 if (dd_p->n_intlv_taps == 4)
01045 {
01046 pdv_cls_setup_interleave(pdv_p,
01047 dd_p->intlv_taps[0].startx,
01048 dd_p->intlv_taps[0].dx,
01049 dd_p->intlv_taps[1].startx,
01050 dd_p->intlv_taps[1].dx,
01051 dd_p->intlv_taps[2].startx,
01052 dd_p->intlv_taps[2].dx,
01053 dd_p->intlv_taps[3].startx,
01054 dd_p->intlv_taps[3].dx);
01055 }
01056 else
01057 {
01058 pdv_cls_set_intlven(pdv_p, 0);
01059 }
01060
01061 pdv_cls_sim_start(pdv_p);
01062
01063 pdv_cls_set_clock(pdv_p, cls->pixel_clock);
01064
01065 return 0;
01066
01067 }
01068
01080 int
01081 pdv_cls_dep_sanity_check(PdvDev *pdv_p)
01082
01083 {
01084 return 0;
01085 }
01086
01093 double
01094 pdv_cls_frame_time(PdvDev *pdv_p)
01095
01096 {
01097 double clock = pdv_p->dd_p->cls.pixel_clock;
01098
01099 if (clock != 0.0)
01100 {
01101 double msecs;
01102 double frameclocks, lineclocks;
01103
01104 msecs = 1.0 / (clock * 1000.0);
01105
01106 lineclocks = edt_reg_read(pdv_p, PDV_CLSIM_HCNTMAX) * msecs;
01107
01108 frameclocks = edt_reg_read(pdv_p, PDV_CLSIM_VCNTMAX) * lineclocks;
01109
01110 return frameclocks;
01111 }
01112
01113 return 0.0;
01114 }
01115
01120 void
01121 pdv_cls_dump_state(PdvDev *pdv_p)
01122
01123 {
01124 int val;
01125 double clock;
01126 val = edt_reg_read(pdv_p, PDV_CL_DATA_PATH);
01127
01128 printf("Taps: %d\n", (val >> 4) + 1);
01129
01130 val = edt_reg_read(pdv_p, PDV_CLSIM_CFGA);
01131 printf("CfgA:\n");
01132 printf(" linescan: %s\n", (val & 0x80)? "enabled":"off");
01133 printf(" lvcont : %s\n", (val & 0x40)? "enabled":"off");
01134 printf(" rven : %s\n", (val & 0x20)? "enabled":"off");
01135 printf(" uartloop: %s\n", (val & 0x10)? "enabled":"off");
01136 printf(" smallok : %s\n", (val & 8)? "enabled":"off");
01137 printf(" intlven : %s\n", (val & 4)? "enabled":"off");
01138 printf(" firstfc : %s\n", (val & 2)? "enabled":"off");
01139 printf(" datacnt : %s\n", (val & 1)? "enabled":"off");
01140 val = edt_reg_read(pdv_p, PDV_CLSIM_CFGB);
01141 printf("CfgB:\n");
01142 printf(" dvskip : %d\n", (val >> 4));
01143 printf(" dvmode : %d\n", (val & 3));
01144 val = edt_reg_read(pdv_p, PDV_CLSIM_CFGC);
01145 printf("CfgC:\n");
01146 printf(" led : %s\n", (val & 0x80)? "enabled":"off");
01147 printf(" trigsrc : %s\n", (val & 8)? "enabled":"off");
01148 printf(" trigpol : %s\n", (val & 4)? "enabled":"off");
01149 printf(" trigfram: %s\n", (val & 2)? "enabled":"off");
01150 printf(" trigline: %s\n", (val & 1)? "enabled":"off");
01151
01152 printf("\nFillA : 0x%x\n", edt_reg_read(pdv_p, PDV_CLSIM_FILLA));
01153 printf("FillB : 0x%x\n\n", edt_reg_read(pdv_p, PDV_CLSIM_FILLB));
01154
01155
01156 val = edt_reg_read(pdv_p, PDV_CLSIM_HCNTMAX);
01157 printf("Hcntmax : %d clocks\n", val+1);
01158
01159 val = edt_reg_read(pdv_p, PDV_CLSIM_VACTV);
01160 printf("Vactv : %d lines\n", val+1);
01161
01162 val = edt_reg_read(pdv_p, PDV_CLSIM_VCNTMAX);
01163 printf("Vcntmax : %d lines\n", val+1);
01164
01165 printf("Hfvstart: %d\n", edt_reg_read(pdv_p, PDV_CLSIM_HFVSTART));
01166 printf("Hfvend : %d\n", edt_reg_read(pdv_p, PDV_CLSIM_HFVEND));
01167 printf("Hlvstart: %d\n", edt_reg_read(pdv_p, PDV_CLSIM_HLVSTART));
01168 printf("Hlvend : %d\n", edt_reg_read(pdv_p, PDV_CLSIM_HLVEND));
01169 printf("Hrvstart: %d\n", edt_reg_read(pdv_p, PDV_CLSIM_HRVSTART));
01170 printf("Hrvend : %d\n", edt_reg_read(pdv_p, PDV_CLSIM_HRVEND));
01171
01172 printf("hblank : %d\n", pdv_cls_get_hgap(pdv_p));
01173 printf("vblank : %d\n", pdv_cls_get_vgap(pdv_p));
01174
01175 if (edt_reg_read(pdv_p, PDV_CLSIM_CFGA) & 4)
01176 {
01177 printf("\nInterleave\n");
01178
01179 printf("Tap 0 : Start %4d Delta %4d\n", edt_reg_read(pdv_p, PDV_CLSIM_TAP0START),
01180 edt_reg_read(pdv_p, PDV_CLSIM_TAP0DELTA));
01181 printf("Tap 1 : Start %4d Delta %4d\n", edt_reg_read(pdv_p, PDV_CLSIM_TAP1START),
01182 edt_reg_read(pdv_p, PDV_CLSIM_TAP1DELTA));
01183 printf("Tap 2 : Start %4d Delta %4d\n", edt_reg_read(pdv_p, PDV_CLSIM_TAP2START),
01184 edt_reg_read(pdv_p, PDV_CLSIM_TAP2DELTA));
01185 printf("Tap 3 : Start %4d Delta %4d\n", edt_reg_read(pdv_p, PDV_CLSIM_TAP3START),
01186 edt_reg_read(pdv_p, PDV_CLSIM_TAP3DELTA));
01187 }
01188
01189 clock = pdv_p->dd_p->cls.pixel_clock;
01190
01191 if (clock != 0.0)
01192 {
01193 double msecs;
01194 double frameclocks, lineclocks;
01195
01196 printf("\nPixel clock : %10.4f MHz\n", pdv_p->dd_p->cls.pixel_clock);
01197
01198 msecs = 1.0 / (clock * 1000.0);
01199
01200 lineclocks = edt_reg_read(pdv_p, PDV_CLSIM_HCNTMAX) * msecs;
01201 printf("Line time : %10.4f msecs\n", lineclocks);
01202
01203 frameclocks = edt_reg_read(pdv_p, PDV_CLSIM_VACTV) * lineclocks;
01204 printf("Active frame time : %10.4f msecs\n", frameclocks);
01205
01206 frameclocks = edt_reg_read(pdv_p, PDV_CLSIM_VCNTMAX) * lineclocks;
01207 printf("Frame time : %10.4f msecs\n", frameclocks);
01208
01209 if (frameclocks)
01210 printf("Frame rate : %10.4f fps\n",1000.0 / frameclocks);
01211
01212 }
01213 }
01214
01215
01222 void
01223 pdv_cls_dump_geometry(PdvDev *pdv_p)
01224 {
01225 int val;
01226 val = edt_reg_read(pdv_p, PDV_CL_DATA_PATH);
01227
01228 printf("\nFillA : 0x%x\n", edt_reg_read(pdv_p, PDV_CLSIM_FILLA));
01229 printf("FillB : 0x%x\n\n", edt_reg_read(pdv_p, PDV_CLSIM_FILLB));
01230
01231
01232 val = edt_reg_read(pdv_p, PDV_CLSIM_HCNTMAX);
01233 printf("Hcntmax : %d clocks\n", val+1);
01234
01235 val = edt_reg_read(pdv_p, PDV_CLSIM_VACTV);
01236 printf("Vactv : %d lines\n", val+1);
01237
01238 val = edt_reg_read(pdv_p, PDV_CLSIM_VCNTMAX);
01239 printf("Vcntmax : %d lines\n", val+1);
01240
01241 printf("Hfvstart: %d\n", edt_reg_read(pdv_p, PDV_CLSIM_HFVSTART));
01242 printf("Hfvend : %d\n", edt_reg_read(pdv_p, PDV_CLSIM_HFVEND));
01243 printf("Hlvstart: %d\n", edt_reg_read(pdv_p, PDV_CLSIM_HLVSTART));
01244 printf("Hlvend : %d\n", edt_reg_read(pdv_p, PDV_CLSIM_HLVEND));
01245 printf("Hrvstart: %d\n", edt_reg_read(pdv_p, PDV_CLSIM_HRVSTART));
01246 printf("Hrvend : %d\n", edt_reg_read(pdv_p, PDV_CLSIM_HRVEND));
01247
01248 printf("hblank : %d\n", pdv_cls_get_hgap(pdv_p));
01249 printf("vblank : %d\n", pdv_cls_get_vgap(pdv_p));
01250
01251 }
01252
01253