示例#1
0
void SwitchConsole_int(CONSOLE *which){ //this one doesn't sti
    __asm("cli");
    CurrentConsole=which;
    ProcessConsole=which; //just for now..
    write_regs(which->vga_registers);
    write_font(which->font,which->text_height);
    RefreshConsole();
}
示例#2
0
void SetConsoleMode(unsigned char video_mode){
     ProcessConsole->video_mode=video_mode;
     ProcessConsole->vga_registers=video_modes[video_mode];
    //must resolve the font for each video mode
    switch(video_mode){ //set appropriate fonts, and sizes
        case 0:
        ProcessConsole->font=g_8x8_font;
        ProcessConsole->text_height=8;
        ProcessConsole->width=90;
        ProcessConsole->height=60;
        ProcessConsole->size=90*60*2;
        break;
        case 1:
        ProcessConsole->font=g_8x16_font;
        ProcessConsole->text_height=16;
        ProcessConsole->width=80;
        ProcessConsole->height=25;
        ProcessConsole->size=80*25*2;
        break;
        case 2:
        ProcessConsole->font=g_8x16_font;
        ProcessConsole->text_height=16;
        ProcessConsole->width=90;
        ProcessConsole->height=30;
        ProcessConsole->size=90*30*2;
        break;
        case 3:
        ProcessConsole->font=g_8x8_font;
        ProcessConsole->text_height=8;
        ProcessConsole->width=80;
        ProcessConsole->height=50;
        ProcessConsole->size=80*50*2;
        break;
        case 4:
        ProcessConsole->font=g_8x8_font;
        ProcessConsole->text_height=8;
        ProcessConsole->width=40;
        ProcessConsole->height=50;
        ProcessConsole->size=40*50*2;
        break;
        case 5:
        ProcessConsole->font=g_8x16_font;
        ProcessConsole->text_height=16;
        ProcessConsole->width=40;
        ProcessConsole->height=25;
        ProcessConsole->size=40*25*2;
        break;
    }
     free(ProcessConsole->buffer);
     ProcessConsole->size=(ProcessConsole->width*2*ProcessConsole->height);
     ProcessConsole->buffer=malloc(ProcessConsole->size);
     cls();
     __asm("cli");
    write_regs(ProcessConsole->vga_registers);
    write_font(ProcessConsole->font,ProcessConsole->text_height);
    RefreshConsole();
    __asm("sti");
}
示例#3
0
文件: except.cpp 项目: daib/workspace
void except::behavior(hw_thread_ptr & hardware_thread) {
#else
void except::behavior() {
    hw_thread_ptr hardware_thread = in.read();
#endif /* _NO_SYSTEMC_ */

    /* Check if the hardware thread is enabled */
    if (_is_not_valid_hwthread(hardware_thread)) {
        return;
    }
    /* Everytime an instruction goes through this stage, increase its
       cycle count to 6 */
    hardware_thread->cnt_cycles += 6;

    /* If fetch stage is stalled then just increment the cycle count
    and return. */
    if (hardware_thread->is_fetch_stalled()) {
        return;
    }

    debug(hardware_thread);

    /* If the current instruction is a double word then set a flag to
       note it */
    set_dword_state(hardware_thread);

    /* If deadline is causing a stall then let skip out of this stage */
    if (dead_stalled(hardware_thread)) {
        return;
    }

    /* If the instruction fetch caused a stall then skip out of this
       stage */
    if (fetch_stalled(hardware_thread)) {
        return;
    }
    /* If memory is causing a stall then skip out of this stage */
    if (mem_stalled(hardware_thread)) {
        return;
    }

    if (!hardware_thread->is_db_word_stalled()) {
        /* Increment the PC based */
        inc_pc(hardware_thread);
    }

    write_regs(hardware_thread);
    write_special_regs(hardware_thread);

    /* Increment the number of instructions executed */
    hardware_thread->cnt_instr++;

}
示例#4
0
static int wis_saa7115_detect(struct i2c_adapter *adapter, int addr, int kind)
{
    struct i2c_client *client;
    struct wis_saa7115 *dec;

    if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
        return 0;

    client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
    if (client == NULL)
        return -ENOMEM;
    memcpy(client, &wis_saa7115_client_templ,
           sizeof(wis_saa7115_client_templ));
    client->adapter = adapter;
    client->addr = addr;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
    client->id = wis_saa7115_i2c_id++;
#endif

    dec = kmalloc(sizeof(struct wis_saa7115), GFP_KERNEL);
    if (dec == NULL) {
        kfree(client);
        return -ENOMEM;
    }
    dec->norm = VIDEO_MODE_NTSC;
    dec->brightness = 128;
    dec->contrast = 64;
    dec->saturation = 64;
    dec->hue = 0;
    i2c_set_clientdata(client, dec);

    printk(KERN_DEBUG
           "wis-saa7115: initializing SAA7115 at address %d on %s\n",
           addr, adapter->name);

    if (write_regs(client, initial_registers) < 0)
    {
        printk(KERN_ERR
               "wis-saa7115: error initializing SAA7115\n");
        kfree(client);
        kfree(dec);
        return 0;
    }

    i2c_attach_client(client);
    return 0;
}
示例#5
0
int ModbusSlave232::preset_multiple_registers(unsigned int start_addr,
unsigned char count, 
unsigned char *query,
int *regs) 
{
        unsigned char function = FC_WRITE_REGS;	/* Preset Multiple Registers */
        int status = 0;
        unsigned char packet[RESPONSE_SIZE + CHECKSUM_SIZE];

        build_write_packet(function, start_addr, count, packet);

        if (write_regs(start_addr, query, regs)) {
                status = send_reply(packet, RESPONSE_SIZE);
        }

        return (status);
}
示例#6
0
static int wis_ov7640_probe(struct i2c_client *client,
			    const struct i2c_device_id *id)
{
	struct i2c_adapter *adapter = client->adapter;

	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
		return -ENODEV;

	client->flags = I2C_CLIENT_SCCB;

	printk(KERN_DEBUG
		"wis-ov7640: initializing OV7640 at address %d on %s\n",
		client->addr, adapter->name);

	if (write_regs(client, initial_registers) < 0) {
		printk(KERN_ERR "wis-ov7640: error initializing OV7640\n");
		return -ENODEV;
	}

	return 0;
}
示例#7
0
static void vga_generic_unset_mode(vgageneric_handle_t *dev)
{
	set_plane(0);
	memcpy(0xC00A0000, dev->mem0, 128*1024);
	set_plane(1);
	memcpy(0xC00A0000, dev->mem1, 128*1024);
	set_plane(2);
	memcpy(0xC00A0000, dev->mem2, 128*1024);
	set_plane(3);	
	memcpy(0xC00A0000, dev->mem3, 128*1024);
	set_plane(0);

	free(dev->mem0);
	free(dev->mem1);
	free(dev->mem2);
	free(dev->mem3);

	write_regs(dev->regs);
	free(dev->regs);
	dev->regs = 0;
}
示例#8
0
文件: smb_clock.c 项目: Nuand/bladeRF
static inline int smb_mode_output(struct bladerf *dev)
{
    int status;
    uint8_t val;

    status = dev->backend->si5338_read(dev, 39, &val);
    if (status != 0) {
        return status;
    }

    val |= 1;
    status = dev->backend->si5338_write(dev, 39, val);
    if (status != 0) {
        return status;
    }

    status = write_regs(dev, output_config, ARRAY_SIZE(output_config));
    if (status != 0) {
        return status;
    }

    return status;
}
示例#9
0
static inline int smb_mode_output(struct bladerf *dev)
{
    int status;
    uint8_t val;

    status = SI5338_READ(dev, 39, &val);
    if (status != 0) {
        return status;
    }

    val |= 1;
    status = SI5338_WRITE(dev, 39, val);
    if (status != 0) {
        return status;
    }

    status = write_regs(dev, output_config, ARRAY_SIZE(output_config));
    if (status != 0) {
        return status;
    }

    return status;
}
示例#10
0
////////////////////////////////////////////////////////////////////////////////
// Functions
////////////////////////////////////////////////////////////////////////////////
static int vga_generic_set_mode(vgageneric_handle_t *dev, int width, int height, int bpp)
{
	dev->regs = malloc(128);
	read_regs(dev->regs);

	write_regs(g_640x480x16);

	dev->mem0 = malloc(128*1024);
	dev->mem1 = malloc(128*1024);
	dev->mem2 = malloc(128*1024);
	dev->mem3 = malloc(128*1024);

	set_plane(0);
	memcpy(dev->mem0, 0xC00A0000, 128*1024);
	set_plane(1);
	memcpy(dev->mem1, 0xC00A0000, 128*1024);
	set_plane(2);
	memcpy(dev->mem2, 0xC00A0000, 128*1024);
	set_plane(3);	
	memcpy(dev->mem3, 0xC00A0000, 128*1024);

	return 1;
}
示例#11
0
static int tw2804_s_std(struct v4l2_subdev *sd, v4l2_std_id norm)
{
	struct tw2804 *dec = to_state(sd);
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	bool is_60hz = norm & V4L2_STD_525_60;
	u8 regs[] = {
		0x01, is_60hz ? 0xc4 : 0x84,
		0x09, is_60hz ? 0x07 : 0x04,
		0x0a, is_60hz ? 0xf0 : 0x20,
		0x0b, is_60hz ? 0x07 : 0x04,
		0x0c, is_60hz ? 0xf0 : 0x20,
		0x0d, is_60hz ? 0x40 : 0x4a,
		0x16, is_60hz ? 0x00 : 0x40,
		0x17, is_60hz ? 0x00 : 0x40,
		0x20, is_60hz ? 0x07 : 0x0f,
		0x21, is_60hz ? 0x07 : 0x0f,
		0xff, 0xff,
	};

	write_regs(client, regs, dec->channel);
	dec->norm = norm;
	return 0;
}
示例#12
0
文件: smb_clock.c 项目: Nuand/bladeRF
static inline int smb_mode_input(struct bladerf *dev)
{
    int status;
    uint8_t val;

    status = write_regs(dev, input_config, ARRAY_SIZE(input_config));
    if (status != 0) {
        return status;
    }

    /* Turn off any SMB connector output */
    status = dev->backend->si5338_read(dev, 39, &val);
    if (status != 0) {
        return status;
    }

    val &= ~(1);
    status = dev->backend->si5338_write(dev, 39, val);
    if (status != 0) {
        return status;
    }

    return status;
}
示例#13
0
int SCOPE
post_ioctl(const struct syscall_regs * regs)
{
	INJ_TRACE("ioctl: fd=%d, cmd=0x%x, arg=0x%x\n",
			regs->ebx, regs->ecx, regs->edx);
	write_regs(regs);
	int fd = regs->ebx;
	int cmd = regs->ecx;
	int arg = regs->edx;

	write_eax(regs);

	switch (_IOC_TYPE(cmd)) {
		case 'T':
			return post_tty_ioctl(fd, cmd, arg, regs);
		case 0x12:
			return post_blk_ioctl(fd, cmd, arg, regs);
		default:
			INJ_ERROR("no such ioctl command: 0x%x\n", cmd);
			__exit(-1);
	}

	return 0;
}
示例#14
0
文件: smb_clock.c 项目: Nuand/bladeRF
static inline int smb_mode_disabled(struct bladerf *dev)
{
    return write_regs(dev, default_config, ARRAY_SIZE(default_config));
}
示例#15
0
static int wis_tw2804_command(struct i2c_client *client,
				unsigned int cmd, void *arg)
{
	struct wis_tw2804 *dec = i2c_get_clientdata(client);

	if (cmd == DECODER_SET_CHANNEL) {
		int *input = arg;

		if (*input < 0 || *input > 3) {
			printk(KERN_ERR "wis-tw2804: channel %d is not "
					"between 0 and 3!\n", *input);
			return 0;
		}
		dec->channel = *input;
		printk(KERN_DEBUG "wis-tw2804: initializing TW2804 "
				"channel %d\n", dec->channel);
		if (dec->channel == 0 &&
				write_regs(client, global_registers, 0) < 0) {
			printk(KERN_ERR "wis-tw2804: error initializing "
					"TW2804 global registers\n");
			return 0;
		}
		if (write_regs(client, channel_registers, dec->channel) < 0) {
			printk(KERN_ERR "wis-tw2804: error initializing "
					"TW2804 channel %d\n", dec->channel);
			return 0;
		}
		return 0;
	}

	if (dec->channel < 0) {
		printk(KERN_DEBUG "wis-tw2804: ignoring command %08x until "
				"channel number is set\n", cmd);
		return 0;
	}

	switch (cmd) {
	case VIDIOC_S_STD:
	{
		v4l2_std_id *input = arg;
		u8 regs[] = {
			0x01, *input & V4L2_STD_NTSC ? 0xc4 : 0x84,
			0x09, *input & V4L2_STD_NTSC ? 0x07 : 0x04,
			0x0a, *input & V4L2_STD_NTSC ? 0xf0 : 0x20,
			0x0b, *input & V4L2_STD_NTSC ? 0x07 : 0x04,
			0x0c, *input & V4L2_STD_NTSC ? 0xf0 : 0x20,
			0x0d, *input & V4L2_STD_NTSC ? 0x40 : 0x4a,
			0x16, *input & V4L2_STD_NTSC ? 0x00 : 0x40,
			0x17, *input & V4L2_STD_NTSC ? 0x00 : 0x40,
			0x20, *input & V4L2_STD_NTSC ? 0x07 : 0x0f,
			0x21, *input & V4L2_STD_NTSC ? 0x07 : 0x0f,
			0xff,	0xff,
		};
		write_regs(client, regs, dec->channel);
		dec->norm = *input;
		break;
	}
	case VIDIOC_QUERYCTRL:
	{
		struct v4l2_queryctrl *ctrl = arg;

		switch (ctrl->id) {
		case V4L2_CID_BRIGHTNESS:
			ctrl->type = V4L2_CTRL_TYPE_INTEGER;
			strncpy(ctrl->name, "Brightness", sizeof(ctrl->name));
			ctrl->minimum = 0;
			ctrl->maximum = 255;
			ctrl->step = 1;
			ctrl->default_value = 128;
			ctrl->flags = 0;
			break;
		case V4L2_CID_CONTRAST:
			ctrl->type = V4L2_CTRL_TYPE_INTEGER;
			strncpy(ctrl->name, "Contrast", sizeof(ctrl->name));
			ctrl->minimum = 0;
			ctrl->maximum = 255;
			ctrl->step = 1;
			ctrl->default_value = 128;
			ctrl->flags = 0;
			break;
		case V4L2_CID_SATURATION:
			ctrl->type = V4L2_CTRL_TYPE_INTEGER;
			strncpy(ctrl->name, "Saturation", sizeof(ctrl->name));
			ctrl->minimum = 0;
			ctrl->maximum = 255;
			ctrl->step = 1;
			ctrl->default_value = 128;
			ctrl->flags = 0;
			break;
		case V4L2_CID_HUE:
			ctrl->type = V4L2_CTRL_TYPE_INTEGER;
			strncpy(ctrl->name, "Hue", sizeof(ctrl->name));
			ctrl->minimum = 0;
			ctrl->maximum = 255;
			ctrl->step = 1;
			ctrl->default_value = 128;
			ctrl->flags = 0;
			break;
		}
		break;
	}
	case VIDIOC_S_CTRL:
	{
		struct v4l2_control *ctrl = arg;

		switch (ctrl->id) {
		case V4L2_CID_BRIGHTNESS:
			if (ctrl->value > 255)
				dec->brightness = 255;
			else if (ctrl->value < 0)
				dec->brightness = 0;
			else
				dec->brightness = ctrl->value;
			write_reg(client, 0x12, dec->brightness, dec->channel);
			break;
		case V4L2_CID_CONTRAST:
			if (ctrl->value > 255)
				dec->contrast = 255;
			else if (ctrl->value < 0)
				dec->contrast = 0;
			else
				dec->contrast = ctrl->value;
			write_reg(client, 0x11, dec->contrast, dec->channel);
			break;
		case V4L2_CID_SATURATION:
			if (ctrl->value > 255)
				dec->saturation = 255;
			else if (ctrl->value < 0)
				dec->saturation = 0;
			else
				dec->saturation = ctrl->value;
			write_reg(client, 0x10, dec->saturation, dec->channel);
			break;
		case V4L2_CID_HUE:
			if (ctrl->value > 255)
				dec->hue = 255;
			else if (ctrl->value < 0)
				dec->hue = 0;
			else
				dec->hue = ctrl->value;
			write_reg(client, 0x0f, dec->hue, dec->channel);
			break;
		}
		break;
	}
	case VIDIOC_G_CTRL:
	{
		struct v4l2_control *ctrl = arg;

		switch (ctrl->id) {
		case V4L2_CID_BRIGHTNESS:
			ctrl->value = dec->brightness;
			break;
		case V4L2_CID_CONTRAST:
			ctrl->value = dec->contrast;
			break;
		case V4L2_CID_SATURATION:
			ctrl->value = dec->saturation;
			break;
		case V4L2_CID_HUE:
			ctrl->value = dec->hue;
			break;
		}
		break;
	}
	default:
		break;
	}
	return 0;
}
static int s2250_detect(struct i2c_adapter *adapter, int addr, int kind)
{
	struct i2c_client *client;
	struct s2250 *dec;
	u8 *data;
	struct go7007 *go = i2c_get_adapdata(adapter);
	struct go7007_usb *usb = go->hpi_context;

	client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
	if (client == NULL)
		return -ENOMEM;
	memcpy(client, &s2250_client_templ,
	       sizeof(s2250_client_templ));
	client->adapter = adapter;

	dec = kmalloc(sizeof(struct s2250), GFP_KERNEL);
	if (dec == NULL) {
		kfree(client);
		return -ENOMEM;
	}

	dec->std = V4L2_STD_NTSC;
	dec->brightness = 50;
	dec->contrast = 50;
	dec->saturation = 50;
	dec->hue = 0;
	client->addr = TLV320_ADDRESS;
	i2c_set_clientdata(client, dec);

	printk(KERN_DEBUG
	       "s2250: initializing video decoder on %s\n",
	       adapter->name);

	/* initialize the audio */
	client->addr = TLV320_ADDRESS;
	if (write_regs(client, aud_regs) < 0) {
		printk(KERN_ERR
		       "s2250: error initializing audio\n");
		kfree(client);
		kfree(dec);
		return 0;
	}
	client->addr = S2250_VIDDEC;
	i2c_set_clientdata(client, dec);

	if (write_regs(client, vid_regs) < 0) {
		printk(KERN_ERR
		       "s2250: error initializing decoder\n");
		kfree(client);
		kfree(dec);
		return 0;
	}
	if (write_regs_fp(client, vid_regs_fp) < 0) {
		printk(KERN_ERR
		       "s2250: error initializing decoder\n");
		kfree(client);
		kfree(dec);
		return 0;
	}
	/* set default channel */
	/* composite */
	write_reg_fp(client, 0x20, 0x020 | 1);
	write_reg_fp(client, 0x21, 0x662);
	write_reg_fp(client, 0x140, 0x060);

	/* set default audio input */
	dec->audio_input = 0;
	write_reg(client, 0x08, 0x02); /* Line In */

	if (down_interruptible(&usb->i2c_lock) == 0) {
		data = kzalloc(16, GFP_KERNEL);
		if (data != NULL) {
			int rc;
			rc = go7007_usb_vendor_request(go, 0x41, 0, 0,
						       data, 16, 1);
			if (rc > 0) {
				u8 mask;
				data[0] = 0;
				mask = 1<<5;
				data[0] &= ~mask;
				data[1] |= mask;
				go7007_usb_vendor_request(go, 0x40, 0,
							  (data[1]<<8)
							  + data[1],
							  data, 16, 0);
			}
			kfree(data);
		}
		up(&usb->i2c_lock);
	}

	i2c_attach_client(client);
	printk("s2250: initialized successfully\n");
	return 0;
}
示例#17
0
static int s2250_probe(struct i2c_client *client,
		       const struct i2c_device_id *id)
{
	struct i2c_client *audio;
	struct i2c_adapter *adapter = client->adapter;
	struct s2250 *dec;
	u8 *data;
	struct go7007 *go = i2c_get_adapdata(adapter);
	struct go7007_usb *usb = go->hpi_context;

	audio = i2c_new_dummy(adapter, TLV320_ADDRESS >> 1);
	if (audio == NULL)
		return -ENOMEM;

	dec = kmalloc(sizeof(struct s2250), GFP_KERNEL);
	if (dec == NULL) {
		i2c_unregister_device(audio);
		return -ENOMEM;
	}

	dec->std = V4L2_STD_NTSC;
	dec->brightness = 50;
	dec->contrast = 50;
	dec->saturation = 50;
	dec->hue = 0;
	dec->audio = audio;
	i2c_set_clientdata(client, dec);

	printk(KERN_DEBUG
	       "s2250: initializing video decoder on %s\n",
	       adapter->name);

	/* initialize the audio */
	if (write_regs(audio, aud_regs) < 0) {
		printk(KERN_ERR
		       "s2250: error initializing audio\n");
		i2c_unregister_device(audio);
		kfree(dec);
		return 0;
	}

	if (write_regs(client, vid_regs) < 0) {
		printk(KERN_ERR
		       "s2250: error initializing decoder\n");
		i2c_unregister_device(audio);
		kfree(dec);
		return 0;
	}
	if (write_regs_fp(client, vid_regs_fp) < 0) {
		printk(KERN_ERR
		       "s2250: error initializing decoder\n");
		i2c_unregister_device(audio);
		kfree(dec);
		return 0;
	}
	/* set default channel */
	/* composite */
	write_reg_fp(client, 0x20, 0x020 | 1);
	write_reg_fp(client, 0x21, 0x662);
	write_reg_fp(client, 0x140, 0x060);

	/* set default audio input */
	dec->audio_input = 0;
	write_reg(client, 0x08, 0x02); /* Line In */

	if (mutex_lock_interruptible(&usb->i2c_lock) == 0) {
		data = kzalloc(16, GFP_KERNEL);
		if (data != NULL) {
			int rc;
			rc = go7007_usb_vendor_request(go, 0x41, 0, 0,
						       data, 16, 1);
			if (rc > 0) {
				u8 mask;
				data[0] = 0;
				mask = 1<<5;
				data[0] &= ~mask;
				data[1] |= mask;
				go7007_usb_vendor_request(go, 0x40, 0,
							  (data[1]<<8)
							  + data[1],
							  data, 16, 0);
			}
			kfree(data);
		}
		mutex_unlock(&usb->i2c_lock);
	}

	printk("s2250: initialized successfully\n");
	return 0;
}
示例#18
0
static int wis_saa7115_command(struct i2c_client *client,
				unsigned int cmd, void *arg)
{
	struct wis_saa7115 *dec = i2c_get_clientdata(client);

	switch (cmd) {
	case VIDIOC_S_INPUT:
	{
		int *input = arg;

		i2c_smbus_write_byte_data(client, 0x02, 0xC0 | *input);
		i2c_smbus_write_byte_data(client, 0x09,
				*input < 6 ? 0x40 : 0xC0);
		break;
	}
	case DECODER_SET_RESOLUTION:
	{
		struct video_decoder_resolution *res = arg;
		/* Course-grained scaler */
		int h_integer_scaler = res->width < 704 ? 704 / res->width : 1;
		/* Fine-grained scaler to take care of remainder */
		int h_scaling_increment = (704 / h_integer_scaler) *
					1024 / res->width;
		/* Fine-grained scaler only */
		int v_scaling_increment = (dec->norm & V4L2_STD_NTSC ?
				240 : 288) * 1024 / res->height;
		u8 regs[] = {
			0x88,	0xc0,
			0x9c,	res->width & 0xff,
			0x9d,	res->width >> 8,
			0x9e,	res->height & 0xff,
			0x9f,	res->height >> 8,
			0xa0,	h_integer_scaler,
			0xa1,	1,
			0xa2,	1,
			0xa8,	h_scaling_increment & 0xff,
			0xa9,	h_scaling_increment >> 8,
			0xac,	(h_scaling_increment / 2) & 0xff,
			0xad,	(h_scaling_increment / 2) >> 8,
			0xb0,	v_scaling_increment & 0xff,
			0xb1,	v_scaling_increment >> 8,
			0xb2,	v_scaling_increment & 0xff,
			0xb3,	v_scaling_increment >> 8,
			0xcc,	res->width & 0xff,
			0xcd,	res->width >> 8,
			0xce,	res->height & 0xff,
			0xcf,	res->height >> 8,
			0xd0,	h_integer_scaler,
			0xd1,	1,
			0xd2,	1,
			0xd8,	h_scaling_increment & 0xff,
			0xd9,	h_scaling_increment >> 8,
			0xdc,	(h_scaling_increment / 2) & 0xff,
			0xdd,	(h_scaling_increment / 2) >> 8,
			0xe0,	v_scaling_increment & 0xff,
			0xe1,	v_scaling_increment >> 8,
			0xe2,	v_scaling_increment & 0xff,
			0xe3,	v_scaling_increment >> 8,
			0x88,	0xf0,
			0,	0,
		};
		write_regs(client, regs);
		break;
	}
	case VIDIOC_S_STD:
	{
		v4l2_std_id *input = arg;
		u8 regs[] = {
			0x88,	0xc0,
			0x98,	*input & V4L2_STD_NTSC ? 0x12 : 0x16,
			0x9a,	*input & V4L2_STD_NTSC ? 0xf2 : 0x20,
			0x9b,	*input & V4L2_STD_NTSC ? 0x00 : 0x01,
			0xc8,	*input & V4L2_STD_NTSC ? 0x12 : 0x16,
			0xca,	*input & V4L2_STD_NTSC ? 0xf2 : 0x20,
			0xcb,	*input & V4L2_STD_NTSC ? 0x00 : 0x01,
			0x88,	0xf0,
			0x30,	*input & V4L2_STD_NTSC ? 0x66 : 0x00,
			0x31,	*input & V4L2_STD_NTSC ? 0x90 : 0xe0,
			0,	0,
		};
		write_regs(client, regs);
		dec->norm = *input;
		break;
	}
	case VIDIOC_QUERYCTRL:
	{
		struct v4l2_queryctrl *ctrl = arg;

		switch (ctrl->id) {
		case V4L2_CID_BRIGHTNESS:
			ctrl->type = V4L2_CTRL_TYPE_INTEGER;
			strncpy(ctrl->name, "Brightness", sizeof(ctrl->name));
			ctrl->minimum = 0;
			ctrl->maximum = 255;
			ctrl->step = 1;
			ctrl->default_value = 128;
			ctrl->flags = 0;
			break;
		case V4L2_CID_CONTRAST:
			ctrl->type = V4L2_CTRL_TYPE_INTEGER;
			strncpy(ctrl->name, "Contrast", sizeof(ctrl->name));
			ctrl->minimum = 0;
			ctrl->maximum = 127;
			ctrl->step = 1;
			ctrl->default_value = 64;
			ctrl->flags = 0;
			break;
		case V4L2_CID_SATURATION:
			ctrl->type = V4L2_CTRL_TYPE_INTEGER;
			strncpy(ctrl->name, "Saturation", sizeof(ctrl->name));
			ctrl->minimum = 0;
			ctrl->maximum = 127;
			ctrl->step = 1;
			ctrl->default_value = 64;
			ctrl->flags = 0;
			break;
		case V4L2_CID_HUE:
			ctrl->type = V4L2_CTRL_TYPE_INTEGER;
			strncpy(ctrl->name, "Hue", sizeof(ctrl->name));
			ctrl->minimum = -128;
			ctrl->maximum = 127;
			ctrl->step = 1;
			ctrl->default_value = 0;
			ctrl->flags = 0;
			break;
		}
		break;
	}
	case VIDIOC_S_CTRL:
	{
		struct v4l2_control *ctrl = arg;

		switch (ctrl->id) {
		case V4L2_CID_BRIGHTNESS:
			if (ctrl->value > 255)
				dec->brightness = 255;
			else if (ctrl->value < 0)
				dec->brightness = 0;
			else
				dec->brightness = ctrl->value;
			write_reg(client, 0x0a, dec->brightness);
			break;
		case V4L2_CID_CONTRAST:
			if (ctrl->value > 127)
				dec->contrast = 127;
			else if (ctrl->value < 0)
				dec->contrast = 0;
			else
				dec->contrast = ctrl->value;
			write_reg(client, 0x0b, dec->contrast);
			break;
		case V4L2_CID_SATURATION:
			if (ctrl->value > 127)
				dec->saturation = 127;
			else if (ctrl->value < 0)
				dec->saturation = 0;
			else
				dec->saturation = ctrl->value;
			write_reg(client, 0x0c, dec->saturation);
			break;
		case V4L2_CID_HUE:
			if (ctrl->value > 127)
				dec->hue = 127;
			else if (ctrl->value < -128)
				dec->hue = -128;
			else
				dec->hue = ctrl->value;
			write_reg(client, 0x0d, dec->hue);
			break;
		}
		break;
	}
	case VIDIOC_G_CTRL:
	{
		struct v4l2_control *ctrl = arg;

		switch (ctrl->id) {
		case V4L2_CID_BRIGHTNESS:
			ctrl->value = dec->brightness;
			break;
		case V4L2_CID_CONTRAST:
			ctrl->value = dec->contrast;
			break;
		case V4L2_CID_SATURATION:
			ctrl->value = dec->saturation;
			break;
		case V4L2_CID_HUE:
			ctrl->value = dec->hue;
			break;
		}
		break;
	}
	default:
		break;
	}
	return 0;
}
示例#19
0
int init_vda(int vdaccir, int vdanorm, int vdamaster)
{

    if ((vdaccir == VIDEO_MODE_CCIR656) && (vdanorm == VIDEO_NORM_PAL))
    {
        if (write_regs((unsigned char*)&init_656_PAL, sizeof(init_656_PAL)) != 0)
        {
            goto err_out;
        }
    }
    else if ((vdaccir == VIDEO_MODE_CCIR656) && (vdanorm == VIDEO_NORM_NTSC))
    {
        if (write_regs((unsigned char*)&init_656_NTSC, sizeof(init_656_NTSC)) != 0)
        {
            goto err_out;
        }
    }
    else if ((vdaccir == VIDEO_MODE_CCIR601) && (vdanorm == VIDEO_NORM_PAL))
    {
        if (vdamaster == VIDEO_MODE_MASTER)
        {
            init_601_PAL[15] |= VIDEO_MODE_MASTER;
        }
        else if (vdamaster == VIDEO_MODE_SLAVER)
        {
            init_601_PAL[15] &= ~VIDEO_MODE_MASTER;
        }

        if (write_regs((unsigned char*)&init_601_PAL, sizeof(init_601_PAL))  != 0)
        {
            goto err_out;
        }
    }
    else if ((vdaccir == VIDEO_MODE_CCIR601) && (vdanorm == VIDEO_NORM_NTSC))
    {
        if (vdamaster == VIDEO_MODE_MASTER)
        {
            init_601_NTSC[15] |= VIDEO_MODE_MASTER;
        }
        if (vdamaster == VIDEO_MODE_SLAVER)
        {
            init_601_NTSC[15] &= ~VIDEO_MODE_MASTER;
        }

        if (write_regs((unsigned char*)&init_601_NTSC, sizeof(init_601_NTSC))  != 0)
        {
            goto err_out;
        }
    }

    if (vdaccir == VIDEO_MODE_CCIR656)
    {
        I2CWriteByte(I2C_ADV7179, 0x07, (TR0MODE_656 | TR0RST));
        I2CWriteByte(I2C_ADV7179, 0x07, TR0MODE_656);
    }
    else if (vdaccir == VIDEO_MODE_CCIR601)
    {
        if (vdamaster == VIDEO_MODE_MASTER)
        {
            I2CWriteByte(I2C_ADV7179, 0x07, (TR0MODE_601 | TR0RST | VIDEO_MODE_MASTER));
            I2CWriteByte(I2C_ADV7179, 0x07, (TR0MODE_601 | VIDEO_MODE_MASTER));
        }
        else
        {
            I2CWriteByte(I2C_ADV7179, 0x07, (TR0MODE_601 | TR0RST));
            I2CWriteByte(I2C_ADV7179, 0x07, TR0MODE_601);
        }
    }

    return (0);

err_out:
    printk("err_out\n");
    return -1;
}
示例#20
0
static int wis_tw9903_command(struct i2c_client *client,
				unsigned int cmd, void *arg)
{
	struct wis_tw9903 *dec = i2c_get_clientdata(client);

	switch (cmd) {
	case VIDIOC_S_INPUT:
	{
		int *input = arg;

		i2c_smbus_write_byte_data(client, 0x02, 0x40 | (*input << 1));
		break;
	}
	case VIDIOC_S_STD:
	{
		v4l2_std_id *input = arg;
		u8 regs[] = {
			0x05, *input & V4L2_STD_NTSC ? 0x80 : 0x00,
			0x07, *input & V4L2_STD_NTSC ? 0x02 : 0x12,
			0x08, *input & V4L2_STD_NTSC ? 0x14 : 0x18,
			0x09, *input & V4L2_STD_NTSC ? 0xf0 : 0x20,
			0,	0,
		};
		write_regs(client, regs);
		dec->norm = *input;
		break;
	}
	case VIDIOC_QUERYCTRL:
	{
		struct v4l2_queryctrl *ctrl = arg;

		switch (ctrl->id) {
		case V4L2_CID_BRIGHTNESS:
			ctrl->type = V4L2_CTRL_TYPE_INTEGER;
			strncpy(ctrl->name, "Brightness", sizeof(ctrl->name));
			ctrl->minimum = -128;
			ctrl->maximum = 127;
			ctrl->step = 1;
			ctrl->default_value = 0x00;
			ctrl->flags = 0;
			break;
		case V4L2_CID_CONTRAST:
			ctrl->type = V4L2_CTRL_TYPE_INTEGER;
			strncpy(ctrl->name, "Contrast", sizeof(ctrl->name));
			ctrl->minimum = 0;
			ctrl->maximum = 255;
			ctrl->step = 1;
			ctrl->default_value = 0x60;
			ctrl->flags = 0;
			break;
		case V4L2_CID_HUE:
			ctrl->type = V4L2_CTRL_TYPE_INTEGER;
			strncpy(ctrl->name, "Hue", sizeof(ctrl->name));
			ctrl->minimum = -128;
			ctrl->maximum = 127;
			ctrl->step = 1;
			ctrl->default_value = 0;
			ctrl->flags = 0;
			break;
		}
		break;
	}
	case VIDIOC_S_CTRL:
	{
		struct v4l2_control *ctrl = arg;

		switch (ctrl->id) {
		case V4L2_CID_BRIGHTNESS:
			if (ctrl->value > 127)
				dec->brightness = 127;
			else if (ctrl->value < -128)
				dec->brightness = -128;
			else
				dec->brightness = ctrl->value;
			write_reg(client, 0x10, dec->brightness);
			break;
		case V4L2_CID_CONTRAST:
			if (ctrl->value > 255)
				dec->contrast = 255;
			else if (ctrl->value < 0)
				dec->contrast = 0;
			else
				dec->contrast = ctrl->value;
			write_reg(client, 0x11, dec->contrast);
			break;
		case V4L2_CID_HUE:
			if (ctrl->value > 127)
				dec->hue = 127;
			else if (ctrl->value < -128)
				dec->hue = -128;
			else
				dec->hue = ctrl->value;
			write_reg(client, 0x15, dec->hue);
			break;
		}
		break;
	}
	case VIDIOC_G_CTRL:
	{
		struct v4l2_control *ctrl = arg;

		switch (ctrl->id) {
		case V4L2_CID_BRIGHTNESS:
			ctrl->value = dec->brightness;
			break;
		case V4L2_CID_CONTRAST:
			ctrl->value = dec->contrast;
			break;
		case V4L2_CID_HUE:
			ctrl->value = dec->hue;
			break;
		}
		break;
	}
	default:
		break;
	}
	return 0;
}
示例#21
0
/*
 * adv7179 ioctl routine.
 * @param inode: pointer of the node;
 * @param file: pointer of the file;
 *
 * @param cmd: command from the app:
 * ENCODER_SET_NORM(2):set adv7179's work mode.
 *
 * @param arg:arg from app layer.
 *
 * @return value:0-- set success; -1-- set error.
 *
 */
static long adv7179_ioctl(struct file* file, unsigned int cmd, unsigned long arg)
{

    switch (cmd)
    {

        case ENCODER_SET_NORM:
        {
            int iarg = (int) arg;


            switch (iarg)
            {
                case VIDEO_MODE_656_PAL:
                    write_regs((unsigned char*)&init_656_PAL, sizeof(init_656_PAL));

                    I2CWriteByte(I2C_ADV7179, 0x07, (TR0MODE_656 | TR0RST));
                    I2CWriteByte(I2C_ADV7179, 0x07, TR0MODE_656);
                    break;

                case VIDEO_MODE_656_NTSC:
                    write_regs((unsigned char*)&init_656_NTSC, sizeof(init_656_NTSC));

                    I2CWriteByte(I2C_ADV7179, 0x07, (TR0MODE_656 | TR0RST));
                    I2CWriteByte(I2C_ADV7179, 0x07, TR0MODE_656);
                    break;

                case VIDEO_MODE_601_PAL_MASTER:
                    init_601_PAL[15] |= VIDEO_MODE_MASTER;
                    write_regs((unsigned char*)&init_601_PAL, sizeof(init_601_PAL));

                    I2CWriteByte(I2C_ADV7179, 0x07, (TR0MODE_601 | TR0RST | VIDEO_MODE_MASTER));
                    I2CWriteByte(I2C_ADV7179, 0x07, (TR0MODE_601 | VIDEO_MODE_MASTER));
                    break;


                case VIDEO_MODE_601_NTSC_MASTER:
                    init_601_NTSC[15] |= VIDEO_MODE_MASTER;
                    write_regs((unsigned char*)&init_601_NTSC, sizeof(init_601_NTSC));

                    I2CWriteByte(I2C_ADV7179, 0x07, (TR0MODE_601 | TR0RST | VIDEO_MODE_MASTER));
                    I2CWriteByte(I2C_ADV7179, 0x07, (TR0MODE_601 | VIDEO_MODE_MASTER));
                    break;

                case VIDEO_MODE_601_PAL_SLAVER:
                    init_601_PAL[15] &= ~VIDEO_MODE_MASTER;
                    write_regs((unsigned char*)&init_601_PAL, sizeof(init_601_PAL));

                    I2CWriteByte(I2C_ADV7179, 0x07, (TR0MODE_601 | TR0RST));
                    I2CWriteByte(I2C_ADV7179, 0x07, TR0MODE_601);
                    break;

                case VIDEO_MODE_601_NTSC_SLAVER:
                    init_601_NTSC[15] &= ~VIDEO_MODE_MASTER;
                    write_regs((unsigned char*)&init_601_NTSC, sizeof(init_601_NTSC));

                    I2CWriteByte(I2C_ADV7179, 0x07, (TR0MODE_601 | TR0RST));
                    I2CWriteByte(I2C_ADV7179, 0x07, TR0MODE_601);
                    break;

                default:
                    return -1;

            }

        }
        break;

        default:
            return -1;
    }

    return 0;
}