Пример #1
0
/*
 * Finalize the GO7007 hardware setup, register the on-board I2C adapter
 * (if used on this board), load the I2C client driver for the sensor
 * (SAA7115 or whatever) and other devices, and register the ALSA and V4L2
 * interfaces.
 *
 * Must NOT be called with the hw_lock held.
 */
int go7007_register_encoder(struct go7007 *go)
{
	int i, ret;

	printk(KERN_INFO "go7007: registering new %s\n", go->name);

	down(&go->hw_lock);
	ret = go7007_init_encoder(go);
	up(&go->hw_lock);
	if (ret < 0)
		return -1;

	if (!go->i2c_adapter_online &&
			go->board_info->flags & GO7007_BOARD_USE_ONBOARD_I2C) {
		if (go7007_i2c_init(go) < 0)
			return -1;
		go->i2c_adapter_online = 1;
	}
	if (go->i2c_adapter_online) {
		for (i = 0; i < go->board_info->num_i2c_devs; ++i)
			init_i2c_module(&go->i2c_adapter,
					go->board_info->i2c_devs[i].type,
					go->board_info->i2c_devs[i].id,
					go->board_info->i2c_devs[i].addr);
		if (go->board_id == GO7007_BOARDID_ADLINK_MPG24)
			i2c_clients_command(&go->i2c_adapter,
				DECODER_SET_CHANNEL, &go->channel_number);
	}
	if (go->board_info->flags & GO7007_BOARD_HAS_AUDIO) {
		go->audio_enabled = 1;
		go7007_snd_init(go);
	}
	return go7007_v4l2_init(go);
}
Пример #2
0
float read_temperature(void)
{
    int ret;

    unsigned int u32DeviceAddress = TEMPERATURE_I2C_ADDR;
    unsigned int u32I2cNum  = I2C_DEVICE_NUM;
    unsigned int u32RegAddr = 0;
    unsigned int u32RegAddrCount = 1;
    unsigned int u32ReadNumber = 2;
    unsigned char *pData = NULL;
    unsigned short sdata, stmperature;
    float temp;

    ret = init_i2c_module();
    if (ret <= 0)
    {
        M_TRACE(ERROR_TRACE, SYS_MODE, "open i2c module failure\n");
        return -256;
    }

    pData =(unsigned char *) &(sdata);
    ret = i2c_read(u32I2cNum, u32DeviceAddress,
               u32RegAddr, u32RegAddrCount,
               pData, u32ReadNumber);
    if (ret <= 0)
    {
        M_TRACE(DEBUG_TRACE, SYS_MODE, "read i2c failure\n");
        return -256;
    }

    close_i2c_module();

    stmperature = pData[0];
	stmperature = (stmperature<< 8) + pData[1];
	temp =  SHIFT(stmperature, 4) / 16 +
			SHIFT(stmperature, 5) / 8 +
			SHIFT(stmperature, 6) / 4 +
			SHIFT(stmperature, 7) / 2 +
			SHIFT(stmperature, 8) +
			SHIFT(stmperature, 9) * 2 +
			SHIFT(stmperature, 10) * 4 +
			SHIFT(stmperature, 11) * 8 +
			SHIFT(stmperature, 12) * 16 +
			SHIFT(stmperature, 13) * 32 +
			SHIFT(stmperature, 14) * 64;

	if (stmperature & 0x8000)
	{
        temp = -1.0 * temp;
	}

    //M_TRACE(DEBUG_TRACE, SYS_MODE, "%3.4f\n", temp);

    return temp;
}
Пример #3
0
/*
 * Finalize the GO7007 hardware setup, register the on-board I2C adapter
 * (if used on this board), load the I2C client driver for the sensor
 * (SAA7115 or whatever) and other devices, and register the ALSA and V4L2
 * interfaces.
 *
 * Must NOT be called with the hw_lock held.
 */
int go7007_register_encoder(struct go7007 *go)
{
	int i, ret;

	printk(KERN_INFO "go7007: registering new %s\n", go->name);

	down(&go->hw_lock);
	ret = go7007_init_encoder(go);
	up(&go->hw_lock);
	if (ret < 0)
		return -1;

	if (!go->i2c_adapter_online &&
			go->board_info->flags & GO7007_BOARD_USE_ONBOARD_I2C) {
		if (go7007_i2c_init(go) < 0)
			return -1;
		go->i2c_adapter_online = 1;
	}
	if (go->i2c_adapter_online) {
		for (i = 0; i < go->board_info->num_i2c_devs; ++i)
			init_i2c_module(&go->i2c_adapter,
					go->board_info->i2c_devs[i].id,
					go->board_info->i2c_devs[i].addr);
#ifdef TUNER_SET_TYPE_ADDR
		if (go->tuner_type >= 0) {
			struct tuner_setup tun_setup = {
				.mode_mask	= T_ANALOG_TV,
				.addr		= ADDR_UNSET,
				.type		= go->tuner_type
			};
			i2c_clients_command(&go->i2c_adapter,
				TUNER_SET_TYPE_ADDR, &tun_setup);
		}
#else
		if (go->tuner_type >= 0)
			i2c_clients_command(&go->i2c_adapter,
				TUNER_SET_TYPE, &go->tuner_type);
#endif
		if (go->board_id == GO7007_BOARDID_ADLINK_MPG24)
			i2c_clients_command(&go->i2c_adapter,
				DECODER_SET_CHANNEL, &go->channel_number);
	}
	if (go->board_info->flags & GO7007_BOARD_HAS_AUDIO) {
		go->audio_enabled = 1;
		go7007_snd_init(go);
	}
	return go7007_v4l2_init(go);
}
EXPORT_SYMBOL(go7007_register_encoder);

/*
 * Send the encode firmware to the encoder, which will cause it
 * to immediately start delivering the video and audio streams.
 *
 * Must be called with the hw_lock held.
 */
int go7007_start_encoder(struct go7007 *go)
{
	u8 *fw;
	int fw_len, rv = 0, i;
	u16 intr_val, intr_data;

	go->modet_enable = 0;
	if (!go->dvd_mode)
		for (i = 0; i < 4; ++i) {
			if (go->modet[i].enable) {
				go->modet_enable = 1;
				continue;
			}
			go->modet[i].pixel_threshold = 32767;
			go->modet[i].motion_threshold = 32767;
			go->modet[i].mb_threshold = 32767;
		}

	if (go7007_construct_fw_image(go, &fw, &fw_len) < 0)
		return -1;

	if (go7007_send_firmware(go, fw, fw_len) < 0 ||
			go7007_read_interrupt(go, &intr_val, &intr_data) < 0) {
		printk(KERN_ERR "go7007: error transferring firmware\n");
		rv = -1;
		goto start_error;
	}

	go->state = STATE_DATA;
	go->parse_length = 0;
	go->seen_frame = 0;
	if (go7007_stream_start(go) < 0) {
		printk(KERN_ERR "go7007: error starting stream transfer\n");
		rv = -1;
		goto start_error;
	}

start_error:
	kfree(fw);
	return rv;
}