~ubuntu-branches/ubuntu/precise/alsa-driver/precise

« back to all changes in this revision

Viewing changes to alsa-kernel/pci/hda/hda_eld.c

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2011-02-21 18:06:40 UTC
  • mfrom: (1.1.15 upstream)
  • Revision ID: james.westby@ubuntu.com-20110221180640-a8p2yxtvgf7xbxub
Tags: 1.0.24+dfsg-0ubuntu1
* New upstream release
* Refreshed patches:
  - distinguish_kernel_makefile_and_source_dirs.patch
  - debian_dfsg_configure.patch
* debian/control: Update Vcs-bzr field to point to new branch location

Show diffs side-by-side

added added

removed removed

Lines of Context:
189
189
        a->channels = GRAB_BITS(buf, 0, 0, 3);
190
190
        a->channels++;
191
191
 
 
192
        a->sample_bits = 0;
 
193
        a->max_bitrate = 0;
 
194
 
192
195
        a->format = GRAB_BITS(buf, 0, 3, 4);
193
196
        switch (a->format) {
194
197
        case AUDIO_CODING_TYPE_REF_STREAM_HEADER:
198
201
 
199
202
        case AUDIO_CODING_TYPE_LPCM:
200
203
                val = GRAB_BITS(buf, 2, 0, 3);
201
 
                a->sample_bits = 0;
202
204
                for (i = 0; i < 3; i++)
203
205
                        if (val & (1 << i))
204
206
                                a->sample_bits |= cea_sample_sizes[i + 1];
332
334
        return snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_HDMI_DIP_SIZE,
333
335
                                                 AC_DIPSIZE_ELD_BUF);
334
336
}
335
 
EXPORT_SYMBOL_HDA(snd_hdmi_get_eld_size);
336
337
 
337
338
int snd_hdmi_get_eld(struct hdmi_eld *eld,
338
339
                     struct hda_codec *codec, hda_nid_t nid)
368
369
        kfree(buf);
369
370
        return ret;
370
371
}
371
 
EXPORT_SYMBOL_HDA(snd_hdmi_get_eld);
372
372
 
373
373
static void hdmi_show_short_audio_desc(struct cea_sad *a)
374
374
{
381
381
        snd_print_pcm_rates(a->rates, buf, sizeof(buf));
382
382
 
383
383
        if (a->format == AUDIO_CODING_TYPE_LPCM)
384
 
                snd_print_pcm_bits(a->sample_bits, buf2 + 8, sizeof(buf2 - 8));
 
384
                snd_print_pcm_bits(a->sample_bits, buf2 + 8, sizeof(buf2) - 8);
385
385
        else if (a->max_bitrate)
386
386
                snprintf(buf2, sizeof(buf2),
387
387
                                ", max bitrate = %d", a->max_bitrate);
407
407
        }
408
408
        buf[j] = '\0';  /* necessary when j == 0 */
409
409
}
410
 
EXPORT_SYMBOL_HDA(snd_print_channel_allocation);
411
410
 
412
411
void snd_hdmi_show_eld(struct hdmi_eld *e)
413
412
{
426
425
        for (i = 0; i < e->sad_count; i++)
427
426
                hdmi_show_short_audio_desc(e->sad + i);
428
427
}
429
 
EXPORT_SYMBOL_HDA(snd_hdmi_show_eld);
430
428
 
431
429
#ifdef CONFIG_PROC_FS
432
430
 
585
583
 
586
584
        return 0;
587
585
}
588
 
EXPORT_SYMBOL_HDA(snd_hda_eld_proc_new);
589
586
 
590
587
void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld)
591
588
{
594
591
                eld->proc_entry = NULL;
595
592
        }
596
593
}
597
 
EXPORT_SYMBOL_HDA(snd_hda_eld_proc_free);
598
594
 
599
595
#endif /* CONFIG_PROC_FS */
 
596
 
 
597
/* update PCM info based on ELD */
 
598
void hdmi_eld_update_pcm_info(struct hdmi_eld *eld, struct hda_pcm_stream *pcm,
 
599
                              struct hda_pcm_stream *codec_pars)
 
600
{
 
601
        int i;
 
602
 
 
603
        /* assume basic audio support (the basic audio flag is not in ELD;
 
604
         * however, all audio capable sinks are required to support basic
 
605
         * audio) */
 
606
        pcm->rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000;
 
607
        pcm->formats = SNDRV_PCM_FMTBIT_S16_LE;
 
608
        pcm->maxbps = 16;
 
609
        pcm->channels_max = 2;
 
610
        for (i = 0; i < eld->sad_count; i++) {
 
611
                struct cea_sad *a = &eld->sad[i];
 
612
                pcm->rates |= a->rates;
 
613
                if (a->channels > pcm->channels_max)
 
614
                        pcm->channels_max = a->channels;
 
615
                if (a->format == AUDIO_CODING_TYPE_LPCM) {
 
616
                        if (a->sample_bits & AC_SUPPCM_BITS_20) {
 
617
                                pcm->formats |= SNDRV_PCM_FMTBIT_S32_LE;
 
618
                                if (pcm->maxbps < 20)
 
619
                                        pcm->maxbps = 20;
 
620
                        }
 
621
                        if (a->sample_bits & AC_SUPPCM_BITS_24) {
 
622
                                pcm->formats |= SNDRV_PCM_FMTBIT_S32_LE;
 
623
                                if (pcm->maxbps < 24)
 
624
                                        pcm->maxbps = 24;
 
625
                        }
 
626
                }
 
627
        }
 
628
 
 
629
        if (!codec_pars)
 
630
                return;
 
631
 
 
632
        /* restrict the parameters by the values the codec provides */
 
633
        pcm->rates &= codec_pars->rates;
 
634
        pcm->formats &= codec_pars->formats;
 
635
        pcm->channels_max = min(pcm->channels_max, codec_pars->channels_max);
 
636
        pcm->maxbps = min(pcm->maxbps, codec_pars->maxbps);
 
637
}