Пример #1
0
/*
 * Read a register/address on the GO7007SB.
 *
 * Must be called with the hw_lock held.
 */
int go7007_read_addr(struct go7007 *go, u16 addr, u16 *data)
{
	int count = 100;
	u16 value;

	if (go7007_write_interrupt(go, 0x0010, addr) < 0)
		return -EIO;
	while (count-- > 0) {
		if (go7007_read_interrupt(go, &value, data) == 0 &&
				value == 0xa000)
			return 0;
	}
	return -EIO;
}
Пример #2
0
/*
 * 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;
}
Пример #3
0
/*
 * Send the boot firmware to the encoder, which just wakes it up and lets
 * us talk to the GPIO pins and on-board I2C adapter.
 *
 * Must be called with the hw_lock held.
 */
static int go7007_load_encoder(struct go7007 *go)
{
	const struct firmware *fw_entry;
	char fw_name[] = "go7007fw.bin";
	void *bounce;
	int fw_len, rv = 0;
	u16 intr_val, intr_data;

	if (request_firmware(&fw_entry, fw_name, go->dev)) {
		printk(KERN_ERR
			"go7007: unable to load firmware from file \"%s\"\n",
			fw_name);
		return -1;
	}
	if (fw_entry->size < 16 || memcmp(fw_entry->data, "WISGO7007FW", 11)) {
		printk(KERN_ERR "go7007: file \"%s\" does not appear to be "
				"go7007 firmware\n", fw_name);
		release_firmware(fw_entry);
		return -1;
	}
	fw_len = fw_entry->size - 16;
	bounce = kmalloc(fw_len, GFP_KERNEL);
	if (bounce == NULL) {
		printk(KERN_ERR "go7007: unable to allocate %d bytes for "
				"firmware transfer\n", fw_len);
		release_firmware(fw_entry);
		return -1;
	}
	memcpy(bounce, fw_entry->data + 16, fw_len);
	release_firmware(fw_entry);
	if (go7007_interface_reset(go) < 0 ||
			go7007_send_firmware(go, bounce, fw_len) < 0 ||
			go7007_read_interrupt(go, &intr_val, &intr_data) < 0 ||
			(intr_val & ~0x1) != 0x5a5a) {
		printk(KERN_ERR "go7007: error transferring firmware\n");
		rv = -1;
	}
	kfree(bounce);
	return rv;
}
Пример #4
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;
}