static int ov76be_set_control(struct i2c_client *c, struct ovcamchip_control *ctl) { struct ovcamchip *ov = i2c_get_clientdata(c); struct ov76be *s = ov->spriv; int rc; int v = ctl->value; switch (ctl->id) { case OVCAMCHIP_CID_BRIGHT: rc = ov_write(c, REG_BRT, v >> 8); break; case OVCAMCHIP_CID_SAT: rc = ov_write(c, REG_SAT, v >> 8); break; case OVCAMCHIP_CID_EXP: rc = ov_write(c, REG_EXP, v); break; case OVCAMCHIP_CID_FREQ: { int sixty = (v == 60); rc = ov_write_mask(c, 0x2a, sixty?0x00:0x80, 0x80); if (rc < 0) goto out; rc = ov_write(c, 0x2b, sixty?0x00:0xac); if (rc < 0) goto out; rc = ov_write_mask(c, 0x76, 0x01, 0x01); break; } case OVCAMCHIP_CID_BANDFILT: rc = ov_write_mask(c, 0x2d, v?0x04:0x00, 0x04); s->bandfilt = v; break; case OVCAMCHIP_CID_AUTOBRIGHT: rc = ov_write_mask(c, 0x2d, v?0x10:0x00, 0x10); s->auto_brt = v; break; case OVCAMCHIP_CID_AUTOEXP: rc = ov_write_mask(c, 0x13, v?0x01:0x00, 0x01); s->auto_exp = v; break; case OVCAMCHIP_CID_MIRROR: rc = ov_write_mask(c, 0x12, v?0x40:0x00, 0x40); s->mirror = v; break; default: DDEBUG(2, &c->dev, "control not supported: %d", ctl->id); return -EPERM; } out: DDEBUG(3, &c->dev, "id=%d, arg=%d, rc=%d", ctl->id, v, rc); return rc; }
static int ov6x20_get_control(struct i2c_client *c, struct ovcamchip_control *ctl) { struct ovcamchip *ov = i2c_get_clientdata(c); struct ov6x20 *s = ov->spriv; int rc = 0; unsigned char val = 0; switch (ctl->id) { case OVCAMCHIP_CID_CONT: rc = ov_read(c, REG_CNT, &val); ctl->value = val << 8; break; case OVCAMCHIP_CID_BRIGHT: rc = ov_read(c, REG_BRT, &val); ctl->value = val << 8; break; case OVCAMCHIP_CID_SAT: rc = ov_read(c, REG_SAT, &val); ctl->value = val << 8; break; case OVCAMCHIP_CID_HUE: rc = ov_read(c, REG_BLUE, &val); ctl->value = val << 8; break; case OVCAMCHIP_CID_EXP: rc = ov_read(c, REG_EXP, &val); ctl->value = val; break; case OVCAMCHIP_CID_BANDFILT: ctl->value = s->bandfilt; break; case OVCAMCHIP_CID_AUTOBRIGHT: ctl->value = s->auto_brt; break; case OVCAMCHIP_CID_AUTOEXP: ctl->value = s->auto_exp; break; case OVCAMCHIP_CID_BACKLIGHT: ctl->value = s->backlight; break; case OVCAMCHIP_CID_MIRROR: ctl->value = s->mirror; break; default: DDEBUG(2, &c->dev, "control not supported: %d", ctl->id); return -EPERM; } DDEBUG(3, &c->dev, "id=%d, arg=%d, rc=%d", ctl->id, ctl->value, rc); return rc; }
/* This initializes the OV6x20 camera chip and relevant variables. */ static int ov6x20_init(struct i2c_client *c) { struct ovcamchip *ov = i2c_get_clientdata(c); struct ov6x20 *s; int rc; DDEBUG(4, &c->dev, "entered"); switch (c->adapter->id) { case I2C_ALGO_SMBUS | I2C_HW_SMBUS_OV511: rc = ov_write_regvals(c, regvals_init_6x20_511); break; case I2C_ALGO_SMBUS | I2C_HW_SMBUS_OV518: rc = ov_write_regvals(c, regvals_init_6x20_518); break; default: dev_err(&c->dev, "ov6x20: Unsupported adapter\n"); rc = -ENODEV; } if (rc < 0) return rc; ov->spriv = s = kmalloc(sizeof *s, GFP_KERNEL); if (!s) return -ENOMEM; memset(s, 0, sizeof *s); s->auto_brt = 1; s->auto_exp = 1; return rc; }
unsigned long dispatch_gemdos(char * _args) { TOSARG(short, callnum); long rv; /* Allocate a program structure if needed */ if (prog == NULL) { prog = new_program (); } /* Check for possible MiNT call */ if (prog->emulate_mint && callnum >= 255) { rv = dispatch_mint(_args - 2); } else if (callnum < 0 || callnum > arraysize(gemdos_syscalls) || !gemdos_syscalls[callnum]) { DDEBUG( "call to invalid GEMDOS function #%d\n", callnum ); rv = TOS_EINVFN; } else { STRACE_BEGIN(gemdos, _args); rv = gemdos_syscalls[ callnum ](_args); STRACE_END( gemdos, _args, rv ); } return rv; }
static int ov76be_command(struct i2c_client *c, unsigned int cmd, void *arg) { switch (cmd) { case OVCAMCHIP_CMD_S_CTRL: return ov76be_set_control(c, arg); case OVCAMCHIP_CMD_G_CTRL: return ov76be_get_control(c, arg); case OVCAMCHIP_CMD_S_MODE: return ov76be_set_window(c, arg); default: DDEBUG(2, &c->dev, "command not supported: %d", cmd); return -ENOIOCTLCMD; } }
static int ov76be_init(struct i2c_client *c) { struct ovcamchip *ov = i2c_get_clientdata(c); struct ov76be *s; int rc; DDEBUG(4, &c->dev, "entered"); rc = ov_write_regvals(c, regvals_init_76be); if (rc < 0) return rc; ov->spriv = s = kzalloc(sizeof *s, GFP_KERNEL); if (!s) return -ENOMEM; s->auto_brt = 1; s->auto_exp = 1; return rc; }
TosProgram *load_tos_program( char *filename ) { TosProgram * prog; TosExecHeader *hdr; TosBasepage *bp; void *prg, *buf; ulong size; FILE *fp; char *env, *src, *dest; char ascii_num[ 4 ]; /* Allocate a new program structure */ prog = new_program (); /* Set up the MiNT emulation flag */ DDEBUG( "Environment: %s\n", Opt_environment ); prog->emulate_mint = Opt_MiNT; /* Set up GEM flag, if program name ends on .app or .prg and Opt_GEM is not set to "no" */ /* Use case insensitive compare */ if(Opt_GEM && (!strncasecmp(filename+strlen(filename)-4, ".app", 4) || !strncasecmp(filename+strlen(filename)-4, ".prg", 4))) prog->gem = 1; else prog->gem = 0; /* Set up the environment */ if( strcmp( Opt_environment, "-" ) == 0 ) { env = NULL; } else { env = (char *)mymalloc( strlen( Opt_environment ) + 2 ); for( src = Opt_environment, dest = env ; *src ; src++ ) { if( *src == '\\' ) { src++; if( *src >= '0' && *src <= '9' ) { ascii_num[ 0 ] = *src++; ascii_num[ 1 ] = *src++; ascii_num[ 2 ] = *src; ascii_num[ 3 ] = 0; *dest++ = strtol( ascii_num, NULL, 8 ); } else { switch( *src ) { case 'n': *dest++ = '\n'; break; case 'r': *dest++ = '\r'; break; default: *dest++ = *src; break; } } } else if( *src == ',' ) { *dest++ = '\0'; } else { *dest++ = *src; } } *dest++ = 0; *dest++ = 0; } /* Set up the trace flag */ prog->trace = Opt_trace; if( (fp = fopen( filename, "r" )) == NULL ){ fprintf( stderr, "Can't open %s: %s\n", filename, strerror(errno) ); return NULL; } /* read the header */ hdr = (TosExecHeader *)mymalloc( sizeof(TosExecHeader) ); if (fread( hdr, sizeof(TosExecHeader), 1, fp ) != 1 || ntohs(hdr->magic) != TOS_PROGRAM_MAGIC) { fprintf( stderr, "%s: no GEMDOS executable\n", filename ); free( hdr ); fclose( fp ); return NULL; } /* calculate size of TPA */ size = sizeof(TosBasepage) + ntohl(hdr->tsize) + ntohl(hdr->dsize) + ntohl(hdr->bsize) + Opt_extra_mem*1024; buf = (void *)mymalloc( size ); bp = (TosBasepage *)buf; prg = (void *)(bp + 1); /* read program text + data */ if(fread(prg, sizeof(char), ntohl(hdr->tsize) + ntohl(hdr->dsize), fp ) != ntohl(hdr->tsize) + ntohl(hdr->dsize)) { fprintf( stderr, "%s: short executable!\n", filename ); err_ret: free( buf ); free( hdr ); fclose( fp ); return NULL; } /* initialize basepage */ bp->lowtpa = htonl((UInt32)bp); bp->hitpa = htonl((UInt32)buf + size); bp->tbase = htonl(TEXT_SEGMENT(hdr,prg)); bp->tlen = hdr->tsize; bp->dbase = htonl(DATA_SEGMENT(hdr,prg)); bp->dlen = hdr->dsize; bp->bbase = htonl(BSS_SEGMENT(hdr,prg)); bp->blen = hdr->bsize; bp->parent = (Ptr32)NULL; bp->env = (char *)htonl((UInt32)env); bp->cmdlin[ 0 ] = 0; /* patch_program( hdr ); */ if (relocate_program( bp, hdr, fp ) < 0) { fprintf( stderr, "%s: relocation failed\n", filename ); goto err_ret; } fclose( fp ); /* clear BSS and maybe rest of TPA */ memset((void *)BSS_SEGMENT(hdr,prg), 0, ntohl(hdr->bsize) + ((ntohl(hdr->prgflags) & TOS_PRGFLAG_FASTLOAD) ? 0 : Opt_extra_mem*1024) ); prog->text = TEXT_SEGMENT(hdr,prg); prog->data = DATA_SEGMENT(hdr,prg); prog->bss = BSS_SEGMENT(hdr,prg); prog->size = size; prog->basepage = bp; prog->basepage->dta = (Dta *)ntohl((UInt32)prog->basepage->cmdlin); prog->dta = (Dta *)ntohl((UInt32)prog->basepage->dta); /* The program starts in user mode */ prog->super = 0; /* The program starts in the TOS domain */ prog->domain = 0; #ifdef DEBUG_STACK start_stack = BSS_SEGMENT(hdr,prg) + ntohl(hdr->bsize); #endif free(hdr); return prog; }