00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 #include <sys/ioctl.h>
00067
00068 #include "config.h"
00069 #include "plugin.h"
00070 #include "glbvars.h"
00071 #include "xsmhard.h"
00072
00073 #include "plug-ins/hard/modules/ccd.h"
00074
00075
00076
00077 #define THIS_HWI_PLUGIN_NAME "TC211-CCD"
00078
00079
00080 static void tc211_ccd_init( void );
00081 static void tc211_ccd_about( void );
00082 static void tc211_ccd_configure( void );
00083 static void tc211_ccd_cleanup( void );
00084
00085
00086 GxsmPlugin tc211_ccd_pi = {
00087 NULL,
00088 NULL,
00089 0,
00090 NULL,
00091
00092
00093
00094
00095 "tc211_ccd-"
00096 "HW-INT-1S-SHORT",
00097
00098
00099
00100 THIS_HWI_PLUGIN_NAME,
00101
00102 "TC211 CCD interface.",
00103
00104 "Percy Zahl",
00105
00106 N_("Hardware/"),
00107
00108 N_(THIS_HWI_PLUGIN_NAME"-HwI"),
00109
00110 N_("This is the "THIS_HWI_PLUGIN_NAME" - GXSM Hardware Interface"),
00111
00112 "N/A",
00113 NULL,
00114 NULL,
00115
00116
00117 tc211_ccd_init,
00118
00119
00120 NULL,
00121
00122
00123 tc211_ccd_about,
00124
00125
00126 tc211_ccd_configure,
00127
00128
00129 NULL,
00130
00131
00132 tc211_ccd_cleanup
00133 };
00134
00135
00136
00137 static const char *about_text = N_("GXSM tc211_ccd Plugin\n\n"
00138 "Video for Linux frame grabber.");
00139
00140
00141
00142
00143
00144
00145
00146
00147 class gxsm_TC211_CCD : public XSM_Hardware{
00148 public:
00149 gxsm_TC211_CCD();
00150 virtual ~gxsm_TC211_CCD();
00151
00152
00153 virtual long GetMaxPointsPerLine(){ return CCD_Xpixel; };
00154 virtual long GetMaxLines(){ return CCD_Ypixel; };
00155 virtual long GetMaxChannels(){ return 1L; };
00156 virtual void SetDxDy(int dx, int dy);
00157 virtual void SetOffset(long x, long y);
00158 virtual void SetNx(long nx);
00159 virtual void SetAlpha(double alpha);
00160
00161 virtual void MovetoXY(long x, long y);
00162 virtual void StartScan2D();
00163 virtual void ScanLineM(int yindex, int xdir, int muxmode, Mem2d *Mob[MAX_SRCS_CHANNELS], int ix0=0 );
00164 virtual void EndScan2D();
00165
00166 virtual gchar* get_info(){
00167 return g_strdup("*--GXSM HwI Plugin: TC211_CCD::XSM_Hardware --*\n"
00168 "CCD TC211 on /dev/ccd is connected!\n"
00169 "*--Features--*\n"
00170 "SCAN: Yes\n"
00171 "*--ExecCMD options--*\n"
00172 "MONITORENABLE, EXPOSURE\n"
00173 "*--EOF--*\n"
00174 );
00175 };
00176 void ExecCmd(int Cmd);
00177
00178 double CCD_exptime;
00179 private:
00180 int ccd;
00181 SHT ccdline[CCD_Xpixel];
00182 };
00183
00184
00185
00186
00187
00188 gxsm_TC211_CCD *TC211_CCD_hardware = NULL;
00189
00190
00191
00192
00193 gxsm_TC211_CCD::gxsm_TC211_CCD():XSM_Hardware(){
00194 CCD_exptime = 1.;
00195 ccd = open(xsmres.DSPDev, O_RDWR);
00196 if(ccd <= 0){
00197 printf("open %s failed, err=%d\ndo you need root to do \"insmod ccd\" ?\n", xsmres.DSPDev, ccd);
00198 exit(0);
00199 }
00200 ioctl(ccd, CCD_CMD_MONITORENABLE, 0);
00201 }
00202
00203
00204
00205
00206
00207 gxsm_TC211_CCD::~gxsm_TC211_CCD(){
00208 close(ccd);
00209 }
00210
00211
00212
00213
00214
00215 void gxsm_TC211_CCD::ExecCmd(int Cmd){
00216 switch(Cmd){
00217 case CCD_CMD_MONITORENABLE:
00218 ioctl(ccd, CCD_CMD_MONITORENABLE, 0);
00219 break;
00220 case CCD_CMD_EXPOSURE:
00221 ioctl(ccd, CCD_CMD_EXPOSURE, (unsigned long)(CCD_exptime));
00222 break;
00223 }
00224 }
00225 void gxsm_TC211_CCD::MovetoXY(long x, long y){ rx=x; ry=y; }
00226 void gxsm_TC211_CCD::SetDxDy(int dx, int dy){
00227 Dx = dx;
00228 Dy = dy;
00229 }
00230 void gxsm_TC211_CCD::SetOffset(long x, long y){
00231 rotoffx = x; rotoffy = y;
00232 }
00233 void gxsm_TC211_CCD::SetAlpha(double alpha){
00234 Alpha=M_PI*alpha/180.;
00235 rotmyy = rotmxx = cos(Alpha);
00236 rotmyx = -(rotmxy = sin(Alpha));
00237 }
00238 void gxsm_TC211_CCD::SetNx(long nx){
00239 Nx=nx;
00240 }
00241
00242
00243 void gxsm_TC211_CCD::StartScan2D(){
00244 XSM_DEBUG (DBG_L4, "CCD belichten");
00245
00246 ioctl(ccd, CCD_CMD_CLEAR, 0);
00247
00248 ioctl(ccd, CCD_CMD_EXPOSURE, (unsigned long)(CCD_exptime));
00249 ioctl(ccd, CCD_CMD_INITLESEN, 0);
00250 }
00251
00252 void gxsm_TC211_CCD::EndScan2D(){
00253 ioctl(ccd, CCD_CMD_MONITORENABLE, 0);
00254 XSM_DEBUG (DBG_L4, "CCD gelesen");
00255 }
00256
00257
00258
00259
00260 void gxsm_TC211_CCD::ScanLineM(int yindex, int xdir, int muxmode, Mem2d *Mob[MAX_SRCS_CHANNELS], int ix0 ){
00261 if (yindex < 0){
00262 if (yindex != -1) return;
00263 if(Mob[0])
00264 for(int j=0; j<CCD_Ypixel && j<Mob[0]->GetNy (); j++){
00265 for(int i=0; i<CCD_Xpixel && i < Mob[0]->GetNx (); i++)
00266 Mob[0]->PutDataPkt ((double)ioctl (ccd, CCD_CMD_GETPIXEL,0), i, j);
00267 if(!(j%32))
00268 gapp->check_events();
00269 }
00270 return;
00271 }
00272
00273 if(yindex >= CCD_Ypixel)
00274 return;
00275
00276 if(Mob[0])
00277 for(int i=0; i<CCD_Xpixel && i < Mob[0]->GetNx (); i++)
00278 Mob[0]->PutDataPkt((double)ioctl(ccd, CCD_CMD_GETPIXEL,0),i,yindex);
00279
00280 if(!(yindex%32))
00281 gapp->check_events();
00282 }
00283
00284
00285
00286
00287
00288
00289
00290
00291 GxsmPlugin *get_gxsm_plugin_info ( void ){
00292 tc211_ccd_pi.description = g_strdup_printf(N_("GXSM HwI tc211_ccd plugin %s"), VERSION);
00293 return &tc211_ccd_pi;
00294 }
00295
00296
00297
00298 XSM_Hardware *get_gxsm_hwi_hardware_class ( void *data ) {
00299 return TC211_CCD_hardware;
00300 }
00301
00302
00303 static void tc211_ccd_init(void)
00304 {
00305 PI_DEBUG (DBG_L2, "tc211_ccd Plugin Init");
00306 TC211_CCD_hardware = new gxsm_TC211_CCD ();
00307 }
00308
00309
00310 static void tc211_ccd_about(void)
00311 {
00312 const gchar *authors[] = { tc211_ccd_pi.authors, NULL};
00313 gtk_widget_show(gnome_about_new ( tc211_ccd_pi.name,
00314 VERSION,
00315 N_("(C) 2000 the Free Software Foundation"),
00316 about_text,
00317 authors,
00318 NULL, NULL, NULL
00319 ));
00320 }
00321
00322
00323 static void tc211_ccd_configure(void)
00324 {
00325 if(tc211_ccd_pi.app)
00326 tc211_ccd_pi.app->message("tc211_ccd Plugin Configuration");
00327 }
00328
00329
00330 static void tc211_ccd_cleanup(void)
00331 {
00332 PI_DEBUG (DBG_L2, "tc211_ccd Plugin Cleanup");
00333 delete TC211_CCD_hardware;
00334 TC211_CCD_hardware = NULL;
00335 }
00336
00337
00338