Lines Matching refs:tuner

99     struct stub_radio_tuner *tuner;  member
126 static int send_command_l(struct stub_radio_tuner *tuner, in send_command_l() argument
157 list_add_tail(&tuner->command_list, &cmd->node); in send_command_l()
158 pthread_cond_signal(&tuner->cond); in send_command_l()
196 static int prepare_metadata(struct stub_radio_tuner *tuner, in prepare_metadata() argument
211 ret = radio_metadata_allocate(metadata, tuner->program.channel, 0); in prepare_metadata()
255 struct stub_radio_tuner *tuner = (struct stub_radio_tuner *)context; in callback_thread_loop() local
262 pthread_mutex_lock(&tuner->lock); in callback_thread_loop()
276 if (list_empty(&tuner->command_list) || ts.tv_sec != 0) { in callback_thread_loop()
280 pthread_cond_timedwait(&tuner->cond, &tuner->lock, &ts); in callback_thread_loop()
283 pthread_cond_wait(&tuner->cond, &tuner->lock); in callback_thread_loop()
291 list_for_each_safe(item, tmp, &tuner->command_list) { in callback_thread_loop()
320 tuner->config = cmd->config; in callback_thread_loop()
322 event.config = tuner->config; in callback_thread_loop()
324 __func__, tuner->config.type, in callback_thread_loop()
325 tuner->config.lower_limit, tuner->config.upper_limit); in callback_thread_loop()
326 if (tuner->config.type == RADIO_BAND_FM) { in callback_thread_loop()
329 tuner->config.fm.stereo, tuner->config.fm.rds, in callback_thread_loop()
330 tuner->config.fm.ta, tuner->config.fm.af, in callback_thread_loop()
331 tuner->config.fm.ea); in callback_thread_loop()
333 ALOGV(" - stereo %d", tuner->config.am.stereo); in callback_thread_loop()
339 frequency = tuner->program.channel; in callback_thread_loop()
341 frequency += tuner->config.spacings[0]; in callback_thread_loop()
343 frequency -= tuner->config.spacings[0]; in callback_thread_loop()
345 if (frequency > (int)tuner->config.upper_limit) { in callback_thread_loop()
346 frequency = tuner->config.lower_limit; in callback_thread_loop()
348 if (frequency < (int)tuner->config.lower_limit) { in callback_thread_loop()
349 frequency = tuner->config.upper_limit; in callback_thread_loop()
351 tuner->program.channel = frequency; in callback_thread_loop()
352 tuner->program.tuned = (frequency / (tuner->config.spacings[0] * 5)) % 2; in callback_thread_loop()
353 tuner->program.signal_strength = 20; in callback_thread_loop()
354 if (tuner->config.type == RADIO_BAND_FM) in callback_thread_loop()
355 tuner->program.stereo = false; in callback_thread_loop()
357 tuner->program.stereo = false; in callback_thread_loop()
360 event.info = tuner->program; in callback_thread_loop()
365 frequency = tuner->program.channel; in callback_thread_loop()
367 frequency += tuner->config.spacings[0] * 25; in callback_thread_loop()
369 frequency -= tuner->config.spacings[0] * 25; in callback_thread_loop()
371 if (frequency > (int)tuner->config.upper_limit) { in callback_thread_loop()
372 frequency = tuner->config.lower_limit; in callback_thread_loop()
374 if (frequency < (int)tuner->config.lower_limit) { in callback_thread_loop()
375 frequency = tuner->config.upper_limit; in callback_thread_loop()
377 tuner->program.channel = (unsigned int)frequency; in callback_thread_loop()
378 tuner->program.tuned = true; in callback_thread_loop()
379 if (tuner->config.type == RADIO_BAND_FM) in callback_thread_loop()
380 tuner->program.stereo = tuner->config.fm.stereo; in callback_thread_loop()
382 tuner->program.stereo = tuner->config.am.stereo; in callback_thread_loop()
383 tuner->program.signal_strength = 50; in callback_thread_loop()
386 event.info = tuner->program; in callback_thread_loop()
391 tuner->program.channel = cmd->param; in callback_thread_loop()
392 tuner->program.tuned = (tuner->program.channel / in callback_thread_loop()
393 (tuner->config.spacings[0] * 5)) % 2; in callback_thread_loop()
395 if (tuner->program.tuned) { in callback_thread_loop()
396 prepare_metadata(tuner, &tuner->program.metadata, true); in callback_thread_loop()
397 send_command_l(tuner, CMD_ANNOUNCEMENTS, 1000, NULL); in callback_thread_loop()
399 if (tuner->program.metadata != NULL) in callback_thread_loop()
400 radio_metadata_deallocate(tuner->program.metadata); in callback_thread_loop()
401 tuner->program.metadata = NULL; in callback_thread_loop()
403 tuner->program.signal_strength = 100; in callback_thread_loop()
404 if (tuner->config.type == RADIO_BAND_FM) in callback_thread_loop()
405 tuner->program.stereo = in callback_thread_loop()
406 tuner->program.tuned ? tuner->config.fm.stereo : false; in callback_thread_loop()
408 tuner->program.stereo = in callback_thread_loop()
409 tuner->program.tuned ? tuner->config.am.stereo : false; in callback_thread_loop()
411 event.info = tuner->program; in callback_thread_loop()
416 int ret = prepare_metadata(tuner, &metadata, false); in callback_thread_loop()
433 ea_state, tuner->config.type, tuner->config.fm.ea); in callback_thread_loop()
434 if (tuner->config.type == RADIO_BAND_FM || in callback_thread_loop()
435 tuner->config.type == RADIO_BAND_FM_HD) { in callback_thread_loop()
439 } else if (tuner->config.fm.ea) { in callback_thread_loop()
445 if (tuner->config.fm.ea) { in callback_thread_loop()
446 send_command_l(tuner, CMD_ANNOUNCEMENTS, 5000, NULL); in callback_thread_loop()
451 if (event.type != RADIO_EVENT_HW_FAILURE && tuner->callback != NULL) { in callback_thread_loop()
452 pthread_mutex_unlock(&tuner->lock); in callback_thread_loop()
453 tuner->callback(&event, tuner->cookie); in callback_thread_loop()
454 pthread_mutex_lock(&tuner->lock); in callback_thread_loop()
473 list_for_each_safe(item, tmp, &tuner->command_list) { in callback_thread_loop()
480 send_command_l(tuner, CMD_METADATA, 1000, NULL); in callback_thread_loop()
485 pthread_mutex_unlock(&tuner->lock); in callback_thread_loop()
493 static int tuner_set_configuration(const struct radio_tuner *tuner, in tuner_set_configuration() argument
496 struct stub_radio_tuner *stub_tuner = (struct stub_radio_tuner *)tuner; in tuner_set_configuration()
513 static int tuner_get_configuration(const struct radio_tuner *tuner, in tuner_get_configuration() argument
516 struct stub_radio_tuner *stub_tuner = (struct stub_radio_tuner *)tuner; in tuner_get_configuration()
542 static int tuner_step(const struct radio_tuner *tuner, in tuner_step() argument
545 struct stub_radio_tuner *stub_tuner = (struct stub_radio_tuner *)tuner; in tuner_step()
556 static int tuner_scan(const struct radio_tuner *tuner, in tuner_scan() argument
559 struct stub_radio_tuner *stub_tuner = (struct stub_radio_tuner *)tuner; in tuner_scan()
570 static int tuner_tune(const struct radio_tuner *tuner, in tuner_tune() argument
573 struct stub_radio_tuner *stub_tuner = (struct stub_radio_tuner *)tuner; in tuner_tune()
589 static int tuner_cancel(const struct radio_tuner *tuner) in tuner_cancel() argument
591 struct stub_radio_tuner *stub_tuner = (struct stub_radio_tuner *)tuner; in tuner_cancel()
601 static int tuner_get_program_information(const struct radio_tuner *tuner, in tuner_get_program_information() argument
604 struct stub_radio_tuner *stub_tuner = (struct stub_radio_tuner *)tuner; in tuner_get_program_information()
642 const struct radio_tuner **tuner) in rdev_open_tuner() argument
650 if (rdev->tuner != NULL) { in rdev_open_tuner()
655 if (config == NULL || callback == NULL || tuner == NULL) { in rdev_open_tuner()
660 rdev->tuner = (struct stub_radio_tuner *)calloc(1, sizeof(struct stub_radio_tuner)); in rdev_open_tuner()
661 if (rdev->tuner == NULL) { in rdev_open_tuner()
666 rdev->tuner->interface.set_configuration = tuner_set_configuration; in rdev_open_tuner()
667 rdev->tuner->interface.get_configuration = tuner_get_configuration; in rdev_open_tuner()
668 rdev->tuner->interface.scan = tuner_scan; in rdev_open_tuner()
669 rdev->tuner->interface.step = tuner_step; in rdev_open_tuner()
670 rdev->tuner->interface.tune = tuner_tune; in rdev_open_tuner()
671 rdev->tuner->interface.cancel = tuner_cancel; in rdev_open_tuner()
672 rdev->tuner->interface.get_program_information = tuner_get_program_information; in rdev_open_tuner()
674 rdev->tuner->audio = audio; in rdev_open_tuner()
675 rdev->tuner->callback = callback; in rdev_open_tuner()
676 rdev->tuner->cookie = cookie; in rdev_open_tuner()
678 rdev->tuner->dev = rdev; in rdev_open_tuner()
680 pthread_mutex_init(&rdev->tuner->lock, (const pthread_mutexattr_t *) NULL); in rdev_open_tuner()
681 pthread_cond_init(&rdev->tuner->cond, (const pthread_condattr_t *) NULL); in rdev_open_tuner()
682 pthread_create(&rdev->tuner->callback_thread, (const pthread_attr_t *) NULL, in rdev_open_tuner()
683 callback_thread_loop, rdev->tuner); in rdev_open_tuner()
684 list_init(&rdev->tuner->command_list); in rdev_open_tuner()
686 pthread_mutex_lock(&rdev->tuner->lock); in rdev_open_tuner()
687 send_command_l(rdev->tuner, CMD_CONFIG, 500, (void *)config); in rdev_open_tuner()
688 pthread_mutex_unlock(&rdev->tuner->lock); in rdev_open_tuner()
690 *tuner = &rdev->tuner->interface; in rdev_open_tuner()
699 const struct radio_tuner *tuner) in rdev_close_tuner() argument
702 struct stub_radio_tuner *stub_tuner = (struct stub_radio_tuner *)tuner; in rdev_close_tuner()
705 ALOGI("%s tuner %p", __func__, tuner); in rdev_close_tuner()
708 if (tuner == NULL) { in rdev_close_tuner()
723 rdev->tuner = NULL; in rdev_close_tuner()
734 free(rdev->tuner); in rdev_close()