Lines Matching refs:iodev
43 static int update_supported_formats(struct cras_iodev *iodev) in update_supported_formats() argument
45 struct hfp_io *hfpio = (struct hfp_io *)iodev; in update_supported_formats()
48 iodev->format->format = SND_PCM_FORMAT_S16_LE; in update_supported_formats()
50 free(iodev->supported_rates); in update_supported_formats()
51 iodev->supported_rates = (size_t *)malloc(2 * sizeof(size_t)); in update_supported_formats()
53 iodev->supported_rates[0] = in update_supported_formats()
57 iodev->supported_rates[1] = 0; in update_supported_formats()
59 free(iodev->supported_channel_counts); in update_supported_formats()
60 iodev->supported_channel_counts = (size_t *)malloc(2 * sizeof(size_t)); in update_supported_formats()
61 iodev->supported_channel_counts[0] = 1; in update_supported_formats()
62 iodev->supported_channel_counts[1] = 0; in update_supported_formats()
64 free(iodev->supported_formats); in update_supported_formats()
65 iodev->supported_formats = in update_supported_formats()
67 iodev->supported_formats[0] = SND_PCM_FORMAT_S16_LE; in update_supported_formats()
68 iodev->supported_formats[1] = 0; in update_supported_formats()
73 static int no_stream(struct cras_iodev *iodev, int enable) in no_stream() argument
75 struct hfp_io *hfpio = (struct hfp_io *)iodev; in no_stream()
80 if (iodev->direction != CRAS_STREAM_OUTPUT) in no_stream()
83 hw_level = iodev->frames_queued(iodev, &hw_tstamp); in no_stream()
88 hfpio->info, iodev->buffer_size); in no_stream()
93 level_target = iodev->min_cb_level; in no_stream()
114 static int frames_queued(const struct cras_iodev *iodev, in frames_queued() argument
117 struct hfp_io *hfpio = (struct hfp_io *)iodev; in frames_queued()
125 return hfp_buf_queued(hfpio->info, iodev->direction); in frames_queued()
128 static int configure_dev(struct cras_iodev *iodev) in configure_dev() argument
130 struct hfp_io *hfpio = (struct hfp_io *)iodev; in configure_dev()
134 if (iodev->format == NULL) in configure_dev()
136 iodev->format->format = SND_PCM_FORMAT_S16_LE; in configure_dev()
137 cras_iodev_init_audio_area(iodev, iodev->format->num_channels); in configure_dev()
158 hfp_info_add_iodev(hfpio->info, iodev->direction, iodev->format); in configure_dev()
161 iodev->buffer_size = hfp_buf_size(hfpio->info, iodev->direction); in configure_dev()
169 static int close_dev(struct cras_iodev *iodev) in close_dev() argument
171 struct hfp_io *hfpio = (struct hfp_io *)iodev; in close_dev()
173 hfp_info_rm_iodev(hfpio->info, iodev->direction); in close_dev()
179 cras_iodev_free_format(iodev); in close_dev()
180 cras_iodev_free_audio_area(iodev); in close_dev()
184 static void set_hfp_volume(struct cras_iodev *iodev) in set_hfp_volume() argument
187 struct hfp_io *hfpio = (struct hfp_io *)iodev; in set_hfp_volume()
190 if (iodev->active_node) in set_hfp_volume()
191 volume = cras_iodev_adjust_node_volume(iodev->active_node, in set_hfp_volume()
197 static int delay_frames(const struct cras_iodev *iodev) in delay_frames() argument
201 return frames_queued(iodev, &tstamp); in delay_frames()
204 static int get_buffer(struct cras_iodev *iodev, struct cras_audio_area **area, in get_buffer() argument
207 struct hfp_io *hfpio = (struct hfp_io *)iodev; in get_buffer()
213 hfp_buf_acquire(hfpio->info, iodev->direction, &dst, frames); in get_buffer()
215 iodev->area->frames = *frames; in get_buffer()
217 iodev->area->channels[0].step_bytes = in get_buffer()
218 cras_get_format_bytes(iodev->format); in get_buffer()
219 iodev->area->channels[0].buf = dst; in get_buffer()
221 *area = iodev->area; in get_buffer()
225 static int put_buffer(struct cras_iodev *iodev, unsigned nwritten) in put_buffer() argument
227 struct hfp_io *hfpio = (struct hfp_io *)iodev; in put_buffer()
232 hfp_buf_release(hfpio->info, iodev->direction, nwritten); in put_buffer()
236 static int flush_buffer(struct cras_iodev *iodev) in flush_buffer() argument
238 struct hfp_io *hfpio = (struct hfp_io *)iodev; in flush_buffer()
241 if (iodev->direction == CRAS_STREAM_INPUT) { in flush_buffer()
242 nframes = hfp_buf_queued(hfpio->info, iodev->direction); in flush_buffer()
243 hfp_buf_release(hfpio->info, iodev->direction, nframes); in flush_buffer()
248 static void update_active_node(struct cras_iodev *iodev, unsigned node_idx, in update_active_node() argument
274 struct cras_iodev *iodev; in hfp_iodev_create() local
282 iodev = &hfpio->base; in hfp_iodev_create()
283 iodev->direction = dir; in hfp_iodev_create()
293 snprintf(iodev->info.name, sizeof(iodev->info.name), "%s", name); in hfp_iodev_create()
294 iodev->info.name[ARRAY_SIZE(iodev->info.name) - 1] = 0; in hfp_iodev_create()
295 iodev->info.stable_id = in hfp_iodev_create()
300 iodev->configure_dev = configure_dev; in hfp_iodev_create()
301 iodev->frames_queued = frames_queued; in hfp_iodev_create()
302 iodev->delay_frames = delay_frames; in hfp_iodev_create()
303 iodev->get_buffer = get_buffer; in hfp_iodev_create()
304 iodev->put_buffer = put_buffer; in hfp_iodev_create()
305 iodev->flush_buffer = flush_buffer; in hfp_iodev_create()
306 iodev->no_stream = no_stream; in hfp_iodev_create()
307 iodev->close_dev = close_dev; in hfp_iodev_create()
308 iodev->update_supported_formats = update_supported_formats; in hfp_iodev_create()
309 iodev->update_active_node = update_active_node; in hfp_iodev_create()
310 iodev->set_volume = set_hfp_volume; in hfp_iodev_create()
313 node->dev = iodev; in hfp_iodev_create()
314 strcpy(node->name, iodev->info.name); in hfp_iodev_create()
321 cras_bt_device_append_iodev(device, iodev, profile); in hfp_iodev_create()
322 cras_iodev_add_node(iodev, node); in hfp_iodev_create()
323 cras_iodev_set_active_node(iodev, node); in hfp_iodev_create()
327 return iodev; in hfp_iodev_create()
337 void hfp_iodev_destroy(struct cras_iodev *iodev) in hfp_iodev_destroy() argument
339 struct hfp_io *hfpio = (struct hfp_io *)iodev; in hfp_iodev_destroy()
341 cras_bt_device_rm_iodev(hfpio->device, iodev); in hfp_iodev_destroy()