isight             88 sound/firewire/isight.c static void isight_update_pointers(struct isight *isight, unsigned int count)
isight             90 sound/firewire/isight.c 	struct snd_pcm_runtime *runtime = isight->pcm->runtime;
isight             95 sound/firewire/isight.c 	ptr = isight->buffer_pointer;
isight             99 sound/firewire/isight.c 	WRITE_ONCE(isight->buffer_pointer, ptr);
isight            101 sound/firewire/isight.c 	isight->period_counter += count;
isight            102 sound/firewire/isight.c 	if (isight->period_counter >= runtime->period_size) {
isight            103 sound/firewire/isight.c 		isight->period_counter -= runtime->period_size;
isight            104 sound/firewire/isight.c 		snd_pcm_period_elapsed(isight->pcm);
isight            108 sound/firewire/isight.c static void isight_samples(struct isight *isight,
isight            114 sound/firewire/isight.c 	if (!READ_ONCE(isight->pcm_running))
isight            117 sound/firewire/isight.c 	runtime = isight->pcm->runtime;
isight            118 sound/firewire/isight.c 	if (isight->buffer_pointer + count <= runtime->buffer_size) {
isight            119 sound/firewire/isight.c 		memcpy(runtime->dma_area + isight->buffer_pointer * 4,
isight            122 sound/firewire/isight.c 		count1 = runtime->buffer_size - isight->buffer_pointer;
isight            123 sound/firewire/isight.c 		memcpy(runtime->dma_area + isight->buffer_pointer * 4,
isight            129 sound/firewire/isight.c 	isight_update_pointers(isight, count);
isight            132 sound/firewire/isight.c static void isight_pcm_abort(struct isight *isight)
isight            134 sound/firewire/isight.c 	if (READ_ONCE(isight->pcm_active))
isight            135 sound/firewire/isight.c 		snd_pcm_stop_xrun(isight->pcm);
isight            138 sound/firewire/isight.c static void isight_dropped_samples(struct isight *isight, unsigned int total)
isight            144 sound/firewire/isight.c 	if (!READ_ONCE(isight->pcm_running))
isight            147 sound/firewire/isight.c 	runtime = isight->pcm->runtime;
isight            148 sound/firewire/isight.c 	dropped = total - isight->total_samples;
isight            150 sound/firewire/isight.c 		if (isight->buffer_pointer + dropped <= runtime->buffer_size) {
isight            151 sound/firewire/isight.c 			memset(runtime->dma_area + isight->buffer_pointer * 4,
isight            154 sound/firewire/isight.c 			count1 = runtime->buffer_size - isight->buffer_pointer;
isight            155 sound/firewire/isight.c 			memset(runtime->dma_area + isight->buffer_pointer * 4,
isight            159 sound/firewire/isight.c 		isight_update_pointers(isight, dropped);
isight            161 sound/firewire/isight.c 		isight_pcm_abort(isight);
isight            168 sound/firewire/isight.c 	struct isight *isight = data;
isight            173 sound/firewire/isight.c 	if (isight->packet_index < 0)
isight            175 sound/firewire/isight.c 	index = isight->packet_index;
isight            176 sound/firewire/isight.c 	payload = isight->buffer.packets[index].buffer;
isight            184 sound/firewire/isight.c 			if (unlikely(total != isight->total_samples)) {
isight            185 sound/firewire/isight.c 				if (!isight->first_packet)
isight            186 sound/firewire/isight.c 					isight_dropped_samples(isight, total);
isight            187 sound/firewire/isight.c 				isight->first_packet = false;
isight            188 sound/firewire/isight.c 				isight->total_samples = total;
isight            191 sound/firewire/isight.c 			isight_samples(isight, payload->samples, count);
isight            192 sound/firewire/isight.c 			isight->total_samples += count;
isight            196 sound/firewire/isight.c 	err = fw_iso_context_queue(isight->context, &audio_packet,
isight            197 sound/firewire/isight.c 				   &isight->buffer.iso_buffer,
isight            198 sound/firewire/isight.c 				   isight->buffer.packets[index].offset);
isight            200 sound/firewire/isight.c 		dev_err(&isight->unit->device, "queueing error: %d\n", err);
isight            201 sound/firewire/isight.c 		isight_pcm_abort(isight);
isight            202 sound/firewire/isight.c 		isight->packet_index = -1;
isight            205 sound/firewire/isight.c 	fw_iso_context_queue_flush(isight->context);
isight            209 sound/firewire/isight.c 	isight->packet_index = index;
isight            212 sound/firewire/isight.c static int isight_connect(struct isight *isight)
isight            218 sound/firewire/isight.c 	ch = fw_iso_resources_allocate(&isight->resources,
isight            220 sound/firewire/isight.c 				       isight->device->max_speed);
isight            226 sound/firewire/isight.c 	value = cpu_to_be32(ch | (isight->device->max_speed << SPEED_SHIFT));
isight            227 sound/firewire/isight.c 	err = snd_fw_transaction(isight->unit, TCODE_WRITE_QUADLET_REQUEST,
isight            228 sound/firewire/isight.c 				 isight->audio_base + REG_ISO_TX_CONFIG,
isight            230 sound/firewire/isight.c 				 isight->resources.generation);
isight            232 sound/firewire/isight.c 		fw_iso_resources_free(&isight->resources);
isight            241 sound/firewire/isight.c 	fw_iso_resources_free(&isight->resources);
isight            266 sound/firewire/isight.c 	struct isight *isight = substream->private_data;
isight            270 sound/firewire/isight.c 	return iso_packets_buffer_init(&isight->buffer, isight->unit,
isight            278 sound/firewire/isight.c 	struct isight *isight = substream->private_data;
isight            280 sound/firewire/isight.c 	iso_packets_buffer_destroy(&isight->buffer, isight->unit);
isight            288 sound/firewire/isight.c 	struct isight *isight = substream->private_data;
isight            296 sound/firewire/isight.c 	WRITE_ONCE(isight->pcm_active, true);
isight            301 sound/firewire/isight.c static int reg_read(struct isight *isight, int offset, __be32 *value)
isight            303 sound/firewire/isight.c 	return snd_fw_transaction(isight->unit, TCODE_READ_QUADLET_REQUEST,
isight            304 sound/firewire/isight.c 				  isight->audio_base + offset, value, 4, 0);
isight            307 sound/firewire/isight.c static int reg_write(struct isight *isight, int offset, __be32 value)
isight            309 sound/firewire/isight.c 	return snd_fw_transaction(isight->unit, TCODE_WRITE_QUADLET_REQUEST,
isight            310 sound/firewire/isight.c 				  isight->audio_base + offset, &value, 4, 0);
isight            313 sound/firewire/isight.c static void isight_stop_streaming(struct isight *isight)
isight            317 sound/firewire/isight.c 	if (!isight->context)
isight            320 sound/firewire/isight.c 	fw_iso_context_stop(isight->context);
isight            321 sound/firewire/isight.c 	fw_iso_context_destroy(isight->context);
isight            322 sound/firewire/isight.c 	isight->context = NULL;
isight            323 sound/firewire/isight.c 	fw_iso_resources_free(&isight->resources);
isight            325 sound/firewire/isight.c 	snd_fw_transaction(isight->unit, TCODE_WRITE_QUADLET_REQUEST,
isight            326 sound/firewire/isight.c 			   isight->audio_base + REG_AUDIO_ENABLE,
isight            332 sound/firewire/isight.c 	struct isight *isight = substream->private_data;
isight            334 sound/firewire/isight.c 	WRITE_ONCE(isight->pcm_active, false);
isight            336 sound/firewire/isight.c 	mutex_lock(&isight->mutex);
isight            337 sound/firewire/isight.c 	isight_stop_streaming(isight);
isight            338 sound/firewire/isight.c 	mutex_unlock(&isight->mutex);
isight            343 sound/firewire/isight.c static int isight_start_streaming(struct isight *isight)
isight            348 sound/firewire/isight.c 	if (isight->context) {
isight            349 sound/firewire/isight.c 		if (isight->packet_index < 0)
isight            350 sound/firewire/isight.c 			isight_stop_streaming(isight);
isight            355 sound/firewire/isight.c 	err = reg_write(isight, REG_SAMPLE_RATE, cpu_to_be32(RATE_48000));
isight            359 sound/firewire/isight.c 	err = isight_connect(isight);
isight            363 sound/firewire/isight.c 	err = reg_write(isight, REG_AUDIO_ENABLE, cpu_to_be32(AUDIO_ENABLE));
isight            367 sound/firewire/isight.c 	isight->context = fw_iso_context_create(isight->device->card,
isight            369 sound/firewire/isight.c 						isight->resources.channel,
isight            370 sound/firewire/isight.c 						isight->device->max_speed,
isight            371 sound/firewire/isight.c 						4, isight_packet, isight);
isight            372 sound/firewire/isight.c 	if (IS_ERR(isight->context)) {
isight            373 sound/firewire/isight.c 		err = PTR_ERR(isight->context);
isight            374 sound/firewire/isight.c 		isight->context = NULL;
isight            379 sound/firewire/isight.c 		err = fw_iso_context_queue(isight->context, &audio_packet,
isight            380 sound/firewire/isight.c 					   &isight->buffer.iso_buffer,
isight            381 sound/firewire/isight.c 					   isight->buffer.packets[i].offset);
isight            386 sound/firewire/isight.c 	isight->first_packet = true;
isight            387 sound/firewire/isight.c 	isight->packet_index = 0;
isight            389 sound/firewire/isight.c 	err = fw_iso_context_start(isight->context, -1, 0,
isight            397 sound/firewire/isight.c 	fw_iso_context_destroy(isight->context);
isight            398 sound/firewire/isight.c 	isight->context = NULL;
isight            400 sound/firewire/isight.c 	fw_iso_resources_free(&isight->resources);
isight            401 sound/firewire/isight.c 	reg_write(isight, REG_AUDIO_ENABLE, 0);
isight            408 sound/firewire/isight.c 	struct isight *isight = substream->private_data;
isight            411 sound/firewire/isight.c 	isight->buffer_pointer = 0;
isight            412 sound/firewire/isight.c 	isight->period_counter = 0;
isight            414 sound/firewire/isight.c 	mutex_lock(&isight->mutex);
isight            415 sound/firewire/isight.c 	err = isight_start_streaming(isight);
isight            416 sound/firewire/isight.c 	mutex_unlock(&isight->mutex);
isight            423 sound/firewire/isight.c 	struct isight *isight = substream->private_data;
isight            427 sound/firewire/isight.c 		WRITE_ONCE(isight->pcm_running, true);
isight            430 sound/firewire/isight.c 		WRITE_ONCE(isight->pcm_running, false);
isight            440 sound/firewire/isight.c 	struct isight *isight = substream->private_data;
isight            442 sound/firewire/isight.c 	return READ_ONCE(isight->buffer_pointer);
isight            445 sound/firewire/isight.c static int isight_create_pcm(struct isight *isight)
isight            461 sound/firewire/isight.c 	err = snd_pcm_new(isight->card, "iSight", 0, 0, 1, &pcm);
isight            464 sound/firewire/isight.c 	pcm->private_data = isight;
isight            466 sound/firewire/isight.c 	isight->pcm = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream;
isight            467 sound/firewire/isight.c 	isight->pcm->ops = &ops;
isight            475 sound/firewire/isight.c 	struct isight *isight = ctl->private_data;
isight            479 sound/firewire/isight.c 	info->value.integer.min = isight->gain_min;
isight            480 sound/firewire/isight.c 	info->value.integer.max = isight->gain_max;
isight            488 sound/firewire/isight.c 	struct isight *isight = ctl->private_data;
isight            492 sound/firewire/isight.c 	err = reg_read(isight, REG_GAIN, &gain);
isight            504 sound/firewire/isight.c 	struct isight *isight = ctl->private_data;
isight            506 sound/firewire/isight.c 	if (value->value.integer.value[0] < isight->gain_min ||
isight            507 sound/firewire/isight.c 	    value->value.integer.value[0] > isight->gain_max)
isight            510 sound/firewire/isight.c 	return reg_write(isight, REG_GAIN,
isight            517 sound/firewire/isight.c 	struct isight *isight = ctl->private_data;
isight            521 sound/firewire/isight.c 	err = reg_read(isight, REG_MUTE, &mute);
isight            533 sound/firewire/isight.c 	struct isight *isight = ctl->private_data;
isight            535 sound/firewire/isight.c 	return reg_write(isight, REG_MUTE,
isight            539 sound/firewire/isight.c static int isight_create_mixer(struct isight *isight)
isight            561 sound/firewire/isight.c 	err = reg_read(isight, REG_GAIN_RAW_START, &value);
isight            564 sound/firewire/isight.c 	isight->gain_min = be32_to_cpu(value);
isight            566 sound/firewire/isight.c 	err = reg_read(isight, REG_GAIN_RAW_END, &value);
isight            569 sound/firewire/isight.c 	isight->gain_max = be32_to_cpu(value);
isight            571 sound/firewire/isight.c 	isight->gain_tlv[SNDRV_CTL_TLVO_TYPE] = SNDRV_CTL_TLVT_DB_MINMAX;
isight            572 sound/firewire/isight.c 	isight->gain_tlv[SNDRV_CTL_TLVO_LEN] = 2 * sizeof(unsigned int);
isight            574 sound/firewire/isight.c 	err = reg_read(isight, REG_GAIN_DB_START, &value);
isight            577 sound/firewire/isight.c 	isight->gain_tlv[SNDRV_CTL_TLVO_DB_MINMAX_MIN] =
isight            580 sound/firewire/isight.c 	err = reg_read(isight, REG_GAIN_DB_END, &value);
isight            583 sound/firewire/isight.c 	isight->gain_tlv[SNDRV_CTL_TLVO_DB_MINMAX_MAX] =
isight            586 sound/firewire/isight.c 	ctl = snd_ctl_new1(&gain_control, isight);
isight            588 sound/firewire/isight.c 		ctl->tlv.p = isight->gain_tlv;
isight            589 sound/firewire/isight.c 	err = snd_ctl_add(isight->card, ctl);
isight            593 sound/firewire/isight.c 	err = snd_ctl_add(isight->card, snd_ctl_new1(&mute_control, isight));
isight            602 sound/firewire/isight.c 	struct isight *isight = card->private_data;
isight            604 sound/firewire/isight.c 	fw_iso_resources_destroy(&isight->resources);
isight            624 sound/firewire/isight.c 	struct isight *isight;
isight            628 sound/firewire/isight.c 			   sizeof(*isight), &card);
isight            632 sound/firewire/isight.c 	isight = card->private_data;
isight            633 sound/firewire/isight.c 	isight->card = card;
isight            634 sound/firewire/isight.c 	mutex_init(&isight->mutex);
isight            635 sound/firewire/isight.c 	isight->unit = fw_unit_get(unit);
isight            636 sound/firewire/isight.c 	isight->device = fw_dev;
isight            637 sound/firewire/isight.c 	isight->audio_base = get_unit_base(unit);
isight            638 sound/firewire/isight.c 	if (!isight->audio_base) {
isight            643 sound/firewire/isight.c 	fw_iso_resources_init(&isight->resources, unit);
isight            655 sound/firewire/isight.c 	err = isight_create_pcm(isight);
isight            659 sound/firewire/isight.c 	err = isight_create_mixer(isight);
isight            667 sound/firewire/isight.c 	dev_set_drvdata(&unit->device, isight);
isight            673 sound/firewire/isight.c 	mutex_destroy(&isight->mutex);
isight            674 sound/firewire/isight.c 	fw_unit_put(isight->unit);
isight            681 sound/firewire/isight.c 	struct isight *isight = dev_get_drvdata(&unit->device);
isight            683 sound/firewire/isight.c 	if (fw_iso_resources_update(&isight->resources) < 0) {
isight            684 sound/firewire/isight.c 		isight_pcm_abort(isight);
isight            686 sound/firewire/isight.c 		mutex_lock(&isight->mutex);
isight            687 sound/firewire/isight.c 		isight_stop_streaming(isight);
isight            688 sound/firewire/isight.c 		mutex_unlock(&isight->mutex);
isight            694 sound/firewire/isight.c 	struct isight *isight = dev_get_drvdata(&unit->device);
isight            696 sound/firewire/isight.c 	isight_pcm_abort(isight);
isight            698 sound/firewire/isight.c 	snd_card_disconnect(isight->card);
isight            700 sound/firewire/isight.c 	mutex_lock(&isight->mutex);
isight            701 sound/firewire/isight.c 	isight_stop_streaming(isight);
isight            702 sound/firewire/isight.c 	mutex_unlock(&isight->mutex);
isight            705 sound/firewire/isight.c 	snd_card_free(isight->card);
isight            707 sound/firewire/isight.c 	mutex_destroy(&isight->mutex);
isight            708 sound/firewire/isight.c 	fw_unit_put(isight->unit);