int issp_read_block(struct issp_host *host, uint8_t block_idx, uint8_t addr,
			uint8_t *buf, int len)
{
	int blk_size, i;
	int ret;

	blk_size = host->pdata->block_size;
	len = len + addr > blk_size ? blk_size - addr : len;
	if (!len)
		return 0;

	ret = issp_block_verify_setup(host, block_idx);
	if (ret)
		return ret;

	ret = issp_check_status(host);
	if (ret)
		return ret;

	send_vector(host, vec_sync_enable, bits_sync_enable);
	send_vector(host, vec_read_write_setup, bits_read_write_setup);

	for (i = 0; i < len; i++)
		buf[i] = issp_read_byte_at(host, addr++);

	send_vector(host, vec_sync_disable, bits_sync_disable);

	return len;
}
static int issp_prog_verify_block(struct issp_host *host, uint8_t idx)
{
	send_vector(host, vec_sync_enable, bits_sync_enable);
	send_vector(host, vec_set_block_num, bits_set_block_num);
	pin_data_out(host);
	send_bits(host, &idx, 8);
	send_vector(host, vec_set_block_num_end, bits_set_block_num_end);
	send_vector(host, vec_sync_disable, bits_sync_disable);
	send_vector(host, vec_program_and_verify, bits_program_and_verify);

	return wait_and_poll(host);
}
static void issp_send_block(struct issp_host *host)
{
	uint8_t addr = 0;

	send_vector(host, vec_sync_enable, bits_sync_enable);
	send_vector(host, vec_read_write_setup, bits_read_write_setup);

	pin_data_out(host);
	while (addr < host->pdata->block_size)
		issp_write_byte(host, addr++, issp_fw_get_byte(host));
	pin_data_z(host);
}
static uint8_t issp_read_byte_at(struct issp_host *host, uint8_t addr)
{
	uint8_t address = addr << 1, data;

	send_vector(host, vec_read_byte_v[0], bits_read_byte_v[0]);
	pin_data_out(host);
	send_bits(host, &address, 7);
	generate_clocks(host, 2);
	data = read_byte(host);
	send_vector(host, vec_read_byte_v[1], bits_read_byte_v[1]);

	return data;
}
static void set_meters_on(struct echoaudio *chip, char on)
{
	if (on && !chip->meters_enabled) {
		send_vector(chip, DSP_VC_METERS_ON);
		chip->meters_enabled = 1;
	} else if (!on && chip->meters_enabled) {
		send_vector(chip, DSP_VC_METERS_OFF);
		chip->meters_enabled = 0;
		memset((s8 *)chip->comm_page->vu_meter, ECHOGAIN_MUTED,
		       DSP_MAXPIPES);
		memset((s8 *)chip->comm_page->peak_meter, ECHOGAIN_MUTED,
		       DSP_MAXPIPES);
	}
}
Beispiel #6
0
static int restore_dsp_rettings(struct echoaudio *chip)
{
	int err;
	DE_INIT(("restore_dsp_settings\n"));

	if ((err = check_asic_status(chip)) < 0)
		return err;

	/* @ Gina20/Darla20 only. Should be harmless for other cards. */
	chip->comm_page->gd_clock_state = GD_CLOCK_UNDEF;
	chip->comm_page->gd_spdif_status = GD_SPDIF_STATUS_UNDEF;
	chip->comm_page->handshake = 0xffffffff;

	if ((err = set_sample_rate(chip, chip->sample_rate)) < 0)
		return err;

	if (chip->meters_enabled)
		if (send_vector(chip, DSP_VC_METERS_ON) < 0)
			return -EIO;

#ifdef ECHOCARD_HAS_EXTERNAL_CLOCK
	if (set_input_clock(chip, chip->input_clock) < 0)
		return -EIO;
#endif

#ifdef ECHOCARD_HAS_OUTPUT_CLOCK_SWITCH
	if (set_output_clock(chip, chip->output_clock) < 0)
		return -EIO;
#endif

	if (update_output_line_level(chip) < 0)
		return -EIO;

	if (update_input_line_level(chip) < 0)
		return -EIO;

#ifdef ECHOCARD_HAS_VMIXER
	if (update_vmixer_level(chip) < 0)
		return -EIO;
#endif

	if (wait_handshake(chip) < 0)
		return -EIO;
	clear_handshake(chip);

	DE_INIT(("restore_dsp_rettings done\n"));
	return send_vector(chip, DSP_VC_UPDATE_FLAGS);
}
void GameObjectMessage::send(uint32_t object_id, GameObject *game_object) {
  send_uint32(socket_, object_id);
  send_vector(socket_, game_object->body().position());
  send_char(socket_, game_object->game_object_type());
  send_object_points(socket_, game_object->characteristic_points());
  send_bool(socket_, game_object->alive());
}
static int check_asic_status(struct echoaudio *chip)
{
	u32 box_status;

	if (wait_handshake(chip))
		return -EIO;

	chip->comm_page->ext_box_status =
		__constant_cpu_to_le32(E3G_ASIC_NOT_LOADED);
	chip->asic_loaded = FALSE;
	clear_handshake(chip);
	send_vector(chip, DSP_VC_TEST_ASIC);

	if (wait_handshake(chip)) {
		chip->dsp_code = NULL;
		return -EIO;
	}

	box_status = le32_to_cpu(chip->comm_page->ext_box_status);
	DE_INIT(("box_status=%x\n", box_status));
	if (box_status == E3G_ASIC_NOT_LOADED)
		return -ENODEV;

	chip->asic_loaded = TRUE;
	return box_status & E3G_BOX_TYPE_MASK;
}
Beispiel #9
0
/* ASIC status check - some cards have one or two ASICs that need to be
loaded.  Once that load is complete, this function is called to see if
the load was successful.
If this load fails, it does not necessarily mean that the hardware is
defective - the external box may be disconnected or turned off.
This routine sometimes fails for Layla20; for Layla20, the loop runs
5 times and succeeds if it wins on three of the loops. */
static int check_asic_status(struct echoaudio *chip)
{
	u32 asic_status;
	int goodcnt, i;

	chip->asic_loaded = FALSE;
	for (i = goodcnt = 0; i < 5; i++) {
		send_vector(chip, DSP_VC_TEST_ASIC);

		/* The DSP will return a value to indicate whether or not
		   the ASIC is currently loaded */
		if (read_dsp(chip, &asic_status) < 0) {
			DE_ACT(("check_asic_status: failed on read_dsp\n"));
			return -EIO;
		}

		if (asic_status == ASIC_ALREADY_LOADED) {
			if (++goodcnt == 3) {
				chip->asic_loaded = TRUE;
				return 0;
			}
		}
	}
	return -EIO;
}
Beispiel #10
0
/* Tell the DSP to reread the flags from the comm page */
static int update_flags(struct echoaudio *chip)
{
	if (wait_handshake(chip))
		return -EIO;
	clear_handshake(chip);
	return send_vector(chip, DSP_VC_UPDATE_FLAGS);
}
Beispiel #11
0
static int set_input_clock(struct echoaudio *chip, u16 clock)
{
	DE_ACT(("set_input_clock:\n"));

	switch (clock) {
	case ECHO_CLOCK_INTERNAL:
		/* Reset the audio state to unknown (just in case) */
		chip->clock_state = GD_CLOCK_UNDEF;
		chip->spdif_status = GD_SPDIF_STATUS_UNDEF;
		set_sample_rate(chip, chip->sample_rate);
		chip->input_clock = clock;
		DE_ACT(("Set Gina clock to INTERNAL\n"));
		break;
	case ECHO_CLOCK_SPDIF:
		chip->comm_page->gd_clock_state = GD_CLOCK_SPDIFIN;
		chip->comm_page->gd_spdif_status = GD_SPDIF_STATUS_NOCHANGE;
		clear_handshake(chip);
		send_vector(chip, DSP_VC_SET_GD_AUDIO_STATE);
		chip->clock_state = GD_CLOCK_SPDIFIN;
		DE_ACT(("Set Gina20 clock to SPDIF\n"));
		chip->input_clock = clock;
		break;
	default:
		return -EINVAL;
	}

	return 0;
}
static int update_input_line_level(struct echoaudio *chip)
{
	if (wait_handshake(chip))
		return -EIO;
	clear_handshake(chip);
	return send_vector(chip, DSP_VC_UPDATE_INGAIN);
}
static int issp_set_security(struct issp_host *host)
{
	uint8_t addr = 0;

	send_vector(host, vec_sync_enable, bits_sync_enable);
	send_vector(host, vec_read_write_setup, bits_read_write_setup);

	pin_data_out(host);
	while (addr < host->pdata->security_size)
		issp_write_byte(host, addr++, issp_fw_get_byte(host));
	pin_data_z(host);

	send_vector(host, vec_secure, bits_secure);

	return wait_and_poll(host);
}
Beispiel #14
0
/* Tell the DSP to read and update virtual mixer levels in comm page. */
static int update_vmixer_level(struct echoaudio *chip)
{
	if (wait_handshake(chip))
		return -EIO;
	clear_handshake(chip);
	return send_vector(chip, DSP_VC_SET_VMIXER_GAIN);
}
void GameObjectMessage::send_object_points(Socket* socket, const std::vector<Vector> &points) {
  char points_size = static_cast<char>(points.size());
  send_char(socket, points_size);
  for (std::vector<Vector>::const_iterator it = points.begin();
       it != points.end();
       it++) {
    send_vector(socket_, *it);
  }
}
Beispiel #16
0
static int set_sample_rate(struct echoaudio *chip, u32 rate)
{
	if (wait_handshake(chip))
		return -EIO;

	chip->sample_rate = rate;
	chip->comm_page->sample_rate = cpu_to_le32(rate);
	clear_handshake(chip);
	return send_vector(chip, DSP_VC_UPDATE_CLOCKS);
}
static int issp_check_status(struct issp_host *host)
{
	uint8_t status;
	int ret;

	send_vector(host, vec_sync_enable, bits_sync_enable);
	send_vector(host, vec_read_status, bits_read_status);
	generate_clocks(host, 2);
	status = read_byte(host);
	send_vector(host, vec_read_status_end, bits_read_status_end);
	send_vector(host, vec_sync_disable, bits_sync_disable);

	switch (status) {
	case 0x00:
		ret = 0;
		break;
	case 0x01:
		dev_err(&host->pdev->dev, "ReadStatus: " \
			"Not allowed because of block level protection\n");
		ret = -EACCES;
		break;
	case 0x03:
		dev_err(&host->pdev->dev, "ReadStatus: Fatal error\n");
		ret = -EIO;
		break;
	case 0x04:
		dev_err(&host->pdev->dev, "ReadStatus: Checksum failure\n");
		ret = -EIO;
		break;
	case 0x06:
		dev_err(&host->pdev->dev, "ReadStatus: Caliberate failure\n");
		ret = -EIO;
		break;
	default:
		dev_err(&host->pdev->dev,
			"ReadStatus: Failed 0x%02x\n", status);
		ret = -EIO;
		break;
	}

	return ret;
}
Beispiel #18
0
static int set_sample_rate(struct echoaudio *chip, u32 rate)
{
	u8 clock;

	switch (rate) {
	case 96000:
		clock = GD24_96000;
		break;
	case 88200:
		clock = GD24_88200;
		break;
	case 48000:
		clock = GD24_48000;
		break;
	case 44100:
		clock = GD24_44100;
		break;
	case 32000:
		clock = GD24_32000;
		break;
	case 22050:
		clock = GD24_22050;
		break;
	case 16000:
		clock = GD24_16000;
		break;
	case 11025:
		clock = GD24_11025;
		break;
	case 8000:
		clock = GD24_8000;
		break;
	default:
		DE_ACT(("set_sample_rate: Error, invalid sample rate %d\n",
			rate));
		return -EINVAL;
	}

	if (wait_handshake(chip))
		return -EIO;

	DE_ACT(("set_sample_rate: %d clock %d\n", rate, clock));
	chip->sample_rate = rate;

	/* Override the sample rate if this card is set to Echo sync. */
	if (chip->input_clock == ECHO_CLOCK_ESYNC)
		clock = GD24_EXT_SYNC;

	chip->comm_page->sample_rate = cpu_to_le32(rate);	/* ignored by the DSP ? */
	chip->comm_page->gd_clock_state = clock;
	clear_handshake(chip);
	return send_vector(chip, DSP_VC_SET_GD_AUDIO_STATE);
}
static int issp_block_read_compare(struct issp_host *host)
{
	uint8_t addr = 0;
	int ret = 0;

	send_vector(host, vec_sync_enable, bits_sync_enable);
	send_vector(host, vec_read_write_setup, bits_read_write_setup);

	while (addr < host->pdata->block_size) {
		uint8_t data = issp_read_byte_at(host, addr++);
		if (data != issp_fw_get_byte(host)) {
			dev_err(&host->pdev->dev, "Data compare failed!\n");
			ret =  -EIO;
			break;
		}
	}

	send_vector(host, vec_sync_disable, bits_sync_disable);

	return ret;
}
static int issp_get_id(struct issp_host *host)
{
	int i, ret;

	send_vector(host, vec_id_setup_1, bits_id_setup_1);
	ret = wait_and_poll(host);
	if (ret)
		return ret;
	send_vector(host, vec_id_setup_2, bits_id_setup_2);
	ret = wait_and_poll(host);
	if (ret)
		return ret;
	send_vector(host, vec_sync_enable, bits_sync_enable);

	for (i = 0; i < 4; i++) {
		send_vector(host, vec_read_id_v[i], bits_read_id_v[i]);
		generate_clocks(host, 2);
		host->si_id[i] = read_byte(host);
	}
	send_vector(host, vec_read_id_v[4], bits_read_id_v[4]);

	send_vector(host, vec_sync_disable, bits_sync_disable);

	return 0;
}
Beispiel #21
0
int send_create_object(const char *filename)
{
    int i;

    if ((i = new_object()) >= 0)
    {
        struct object      *o = get_object(i);
        struct object_mesh *m = NULL;

        if (read_obj(filename, o))
        {
            int j, n = vecnum(o->mv);

            o->count = 1;

            /* Send the object header. */

            send_event(EVENT_CREATE_OBJECT);
            send_index(n);

            /* Send the vertices and meshes. */

            send_vector(o->vv);

            for (j = 0; j < n; ++j)
            {
                m = (struct object_mesh *) vecget(o->mv, j);

                send_index (m->brush);
                send_vector(m->fv);
                send_vector(m->ev);
            }

            /* Encapsulate this object in an entity. */

            return send_create_entity(TYPE_OBJECT, i);
        }
    }
    return -1;
}
static int check_asic_status(struct echoaudio *chip)
{
	u32 asic_status;

	send_vector(chip, DSP_VC_TEST_ASIC);

	if (read_dsp(chip, &asic_status) < 0) {
		DE_INIT(("check_asic_status: failed on read_dsp\n"));
		chip->asic_loaded = FALSE;
		return -EIO;
	}

	chip->asic_loaded = (asic_status == ASIC_ALREADY_LOADED);
	return chip->asic_loaded ? 0 : -EIO;
}
Beispiel #23
0
static int check_asic_status(struct echoaudio *chip)
{
	u32 asic_status;

	send_vector(chip, DSP_VC_TEST_ASIC);

	/* The DSP will return a value to indicate whether or not the
	   ASIC is currently loaded */
	if (read_dsp(chip, &asic_status) < 0) {
		DE_INIT(("check_asic_status: failed on read_dsp\n"));
		chip->asic_loaded = FALSE;
		return -EIO;
	}

	chip->asic_loaded = (asic_status == ASIC_ALREADY_LOADED);
	return chip->asic_loaded ? 0 : -EIO;
}
/* Start and stop Midi input */
static int enable_midi_input(struct echoaudio *chip, char enable)
{
	DE_MID(("enable_midi_input(%d)\n", enable));

	if (wait_handshake(chip))
		return -EIO;

	if (enable) {
		chip->mtc_state = MIDI_IN_STATE_NORMAL;
		chip->comm_page->flags |=
			cpu_to_le32(DSP_FLAG_MIDI_INPUT);
	} else
		chip->comm_page->flags &=
			~cpu_to_le32(DSP_FLAG_MIDI_INPUT);

	clear_handshake(chip);
	return send_vector(chip, DSP_VC_UPDATE_FLAGS);
}
static int issp_block_verify_setup(struct issp_host *host, uint8_t idx)
{
	send_vector(host, vec_read_write_setup, bits_read_write_setup);
	send_vector(host, vec_sync_enable, bits_sync_enable);
	send_vector(host, vec_set_block_num, bits_set_block_num);
	pin_data_out(host);
	send_bits(host, &idx, 8);
	send_vector(host, vec_set_block_num_end, bits_set_block_num_end);
	send_vector(host, vec_sync_disable, bits_sync_disable);
	send_vector(host, vec_verify_setup, bits_verify_setup);

	return wait_and_poll(host);
}
Beispiel #26
0
static int set_sample_rate(struct echoaudio *chip, u32 rate)
{
	u32 clock, control_reg, old_control_reg;

	if (wait_handshake(chip))
		return -EIO;

	old_control_reg = le32_to_cpu(chip->comm_page->control_register);
	control_reg = old_control_reg & ~INDIGO_EXPRESS_CLOCK_MASK;

	switch (rate) {
	case 32000:
		clock = INDIGO_EXPRESS_32000;
		break;
	case 44100:
		clock = INDIGO_EXPRESS_44100;
		break;
	case 48000:
		clock = INDIGO_EXPRESS_48000;
		break;
	case 64000:
		clock = INDIGO_EXPRESS_32000|INDIGO_EXPRESS_DOUBLE_SPEED;
		break;
	case 88200:
		clock = INDIGO_EXPRESS_44100|INDIGO_EXPRESS_DOUBLE_SPEED;
		break;
	case 96000:
		clock = INDIGO_EXPRESS_48000|INDIGO_EXPRESS_DOUBLE_SPEED;
		break;
	default:
		return -EINVAL;
	}

	control_reg |= clock;
	if (control_reg != old_control_reg) {
		DE_ACT(("set_sample_rate: %d clock %d\n", rate, clock));
		chip->comm_page->control_register = cpu_to_le32(control_reg);
		chip->sample_rate = rate;
		clear_handshake(chip);
		return send_vector(chip, DSP_VC_UPDATE_CLOCKS);
	}
	return 0;
}
Beispiel #27
0
/* This is low level part of the interrupt handler.
It returns -1 if the IRQ is not ours, or N>=0 if it is, where N is the number
of midi data in the input queue. */
static int service_irq(struct echoaudio *chip)
{
	int st;

	/* Read the DSP status register and see if this DSP generated this interrupt */
	if (get_dsp_register(chip, CHI32_STATUS_REG) & CHI32_STATUS_IRQ) {
		st = 0;
#ifdef ECHOCARD_HAS_MIDI
		/* Get and parse midi data if present */
		if (chip->comm_page->midi_input[0])	/* The count is at index 0 */
			st = midi_service_irq(chip);	/* Returns how many midi bytes we received */
#endif
		/* Clear the hardware interrupt */
		chip->comm_page->midi_input[0] = 0;
		send_vector(chip, DSP_VC_ACK_INT);
		return st;
	}
	return -1;
}
static int service_irq(struct echoaudio *chip)
{
	int st;

	/*                                                                           */
	if (get_dsp_register(chip, CHI32_STATUS_REG) & CHI32_STATUS_IRQ) {
		st = 0;
#ifdef ECHOCARD_HAS_MIDI
		/*                                    */
		if (chip->comm_page->midi_input[0])	/*                         */
			st = midi_service_irq(chip);	/*                                         */
#endif
		/*                              */
		chip->comm_page->midi_input[0] = 0;
		send_vector(chip, DSP_VC_ACK_INT);
		return st;
	}
	return -1;
}
static int set_sample_rate(struct echoaudio *chip, u32 rate)
{
	u32 control_reg;

	switch (rate) {
	case 96000:
		control_reg = MIA_96000;
		break;
	case 88200:
		control_reg = MIA_88200;
		break;
	case 48000:
		control_reg = MIA_48000;
		break;
	case 44100:
		control_reg = MIA_44100;
		break;
	case 32000:
		control_reg = MIA_32000;
		break;
	default:
		DE_ACT(("set_sample_rate: %d invalid!\n", rate));
		return -EINVAL;
	}

	/* Override the clock setting if this Mia is set to S/PDIF clock */
	if (chip->input_clock == ECHO_CLOCK_SPDIF)
		control_reg |= MIA_SPDIF;

	/* Set the control register if it has changed */
	if (control_reg != le32_to_cpu(chip->comm_page->control_register)) {
		if (wait_handshake(chip))
			return -EIO;

		chip->comm_page->sample_rate = cpu_to_le32(rate);	/* ignored by the DSP */
		chip->comm_page->control_register = cpu_to_le32(control_reg);
		chip->sample_rate = rate;

		clear_handshake(chip);
		return send_vector(chip, DSP_VC_UPDATE_CLOCKS);
	}
	return 0;
}
Beispiel #30
0
static int set_sample_rate(struct echoaudio *chip, u32 rate)
{
	u8 clock_state, spdif_status;

	if (wait_handshake(chip))
		return -EIO;

	switch (rate) {
	case 44100:
		clock_state = GD_CLOCK_44;
		spdif_status = GD_SPDIF_STATUS_44;
		break;
	case 48000:
		clock_state = GD_CLOCK_48;
		spdif_status = GD_SPDIF_STATUS_48;
		break;
	default:
		clock_state = GD_CLOCK_NOCHANGE;
		spdif_status = GD_SPDIF_STATUS_NOCHANGE;
		break;
	}

	if (chip->clock_state == clock_state)
		clock_state = GD_CLOCK_NOCHANGE;
	if (spdif_status == chip->spdif_status)
		spdif_status = GD_SPDIF_STATUS_NOCHANGE;

	chip->comm_page->sample_rate = cpu_to_le32(rate);
	chip->comm_page->gd_clock_state = clock_state;
	chip->comm_page->gd_spdif_status = spdif_status;
	chip->comm_page->gd_resampler_state = 3;	/* magic number - should always be 3 */

	/* Save the new audio state if it changed */
	if (clock_state != GD_CLOCK_NOCHANGE)
		chip->clock_state = clock_state;
	if (spdif_status != GD_SPDIF_STATUS_NOCHANGE)
		chip->spdif_status = spdif_status;
	chip->sample_rate = rate;

	clear_handshake(chip);
	return send_vector(chip, DSP_VC_SET_GD_AUDIO_STATE);
}