MythTV  master
eldutils.h
Go to the documentation of this file.
1 /*
2  * Universal Interface for Intel High Definition Audio Codec
3  *
4  * Local helper functions
5  *
6  * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
7  *
8  * This program is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License as published by the Free
10  * Software Foundation; either version 2 of the License, or (at your option)
11  * any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16  * more details.
17  *
18  * You should have received a copy of the GNU General Public License along with
19  * this program; if not, write to the Free Software Foundation, Inc., 51
20  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #ifndef ELDUTILS_H
24 #define ELDUTILS_H
25 
26 #include <cstdint>
27 #include <QString>
28 #include "libmyth/mythexp.h"
29 
30 static constexpr uint8_t ELD_FIXED_BYTES { 20 };
31 static constexpr size_t ELD_MAX_SAD { 16 };
32 
33 static constexpr uint8_t PRINT_RATES_ADVISED_BUFSIZE { 80 };
34 static constexpr uint8_t PRINT_BITS_ADVISED_BUFSIZE { 16 };
35 static constexpr uint8_t PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE { 80 };
36 
37 class MPUBLIC eld
38 {
39  public:
40  eld(const char *buf, int size);
41  eld(const eld& rhs) = default;
42  eld();
43  ~eld()= default;
44  eld& operator=(const eld& /*rhs*/);
45  void show();
46  QString eld_version_name() const;
47  QString edid_version_name() const;
48  QString info_desc() const;
49  QString channel_allocation_desc() const;
50  QString product_name() const;
51  QString connection_name() const;
52  bool isValid() const;
53  int maxLPCMChannels();
54  int maxChannels();
55  QString codecs_desc() const;
56 
57  enum cea_audio_coding_types : std::uint8_t {
58  TYPE_REF_STREAM_HEADER = 0,
59  TYPE_LPCM = 1,
60  TYPE_AC3 = 2,
61  TYPE_MPEG1 = 3,
62  TYPE_MP3 = 4,
63  TYPE_MPEG2 = 5,
64  TYPE_AACLC = 6,
65  TYPE_DTS = 7,
66  TYPE_ATRAC = 8,
67  TYPE_SACD = 9,
68  TYPE_EAC3 = 10,
69  TYPE_DTS_HD = 11,
70  TYPE_MLP = 12,
71  TYPE_DST = 13,
72  TYPE_WMAPRO = 14,
73  TYPE_REF_CXT = 15,
74  /* also include valid xtypes below */
75  TYPE_HE_AAC = 15,
76  TYPE_HE_AAC2 = 16,
77  TYPE_MPEG_SURROUND = 17,
78  };
79 
80  private:
81 
82  // private methods
83  int update_eld(const char *buf, int size);
84  void update_sad(int index, const char *buf);
85  QString sad_desc(int index);
86  static QString print_pcm_rates(int pcm);
87  static QString print_pcm_bits(int pcm);
88 
89  /*
90  * CEA Short Audio Descriptor data
91  */
92  struct cea_sad {
93  int channels;
94  int format; /* (format == 0) indicates invalid SAD */
95  int rates;
96  int sample_bits; /* for LPCM */
97  int max_bitrate; /* for AC3...ATRAC */
98  int profile; /* for WMAPRO */
99  };
100 
101  /*
102  * ELD: EDID Like Data
103  */
104  struct eld_data {
105  bool eld_valid { false };
106  int eld_size { 0 };
107  int baseline_len { 0 };
108  int eld_ver { 0 };
109  int cea_edid_ver { 0 };
110  QString monitor_name;
111  int manufacture_id { 0 };
112  int product_id { 0 };
113  uint64_t port_id { 0 };
114  uint64_t formats { 0 };
115  int support_hdcp { 0 };
116  int support_ai { 0 };
117  int conn_type { 0 };
118  int aud_synch_delay { 0 };
119  int spk_alloc { 0 };
120  int sad_count { 0 };
121  // NOLINTNEXTLINE(modernize-avoid-c-arrays)
122  struct cea_sad sad[ELD_MAX_SAD] {};
123  eld_data() = default;
124  };
126 };
127 
128 #endif /* ELDUTILSL_H */
PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE
static constexpr uint8_t PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE
Definition: eldutils.h:35
MPUBLIC
#define MPUBLIC
Definition: mythexp.h:10
eld::cea_audio_coding_types
cea_audio_coding_types
Definition: eldutils.h:57
ELD_FIXED_BYTES
static constexpr uint8_t ELD_FIXED_BYTES
Definition: eldutils.h:30
mythexp.h
eld::cea_sad::profile
int profile
Definition: eldutils.h:98
eld
Definition: eldutils.h:37
eld::cea_sad::format
int format
Definition: eldutils.h:94
eld::m_e
eld_data m_e
Definition: eldutils.h:125
show
static void show(uint8_t *buf, int length)
Definition: ringbuffer.cpp:341
eld::cea_sad::rates
int rates
Definition: eldutils.h:95
formats
const std::array< const std::string, 8 > formats
Definition: vbilut.cpp:189
eld::cea_sad::sample_bits
int sample_bits
Definition: eldutils.h:96
ELD_MAX_SAD
static constexpr size_t ELD_MAX_SAD
Definition: eldutils.h:31
eld::eld_data
Definition: eldutils.h:104
eld::eld_data::monitor_name
QString monitor_name
Definition: eldutils.h:110
eld::cea_sad
Definition: eldutils.h:92
eld::cea_sad::max_bitrate
int max_bitrate
Definition: eldutils.h:97
PRINT_RATES_ADVISED_BUFSIZE
static constexpr uint8_t PRINT_RATES_ADVISED_BUFSIZE
Definition: eldutils.h:33
PRINT_BITS_ADVISED_BUFSIZE
static constexpr uint8_t PRINT_BITS_ADVISED_BUFSIZE
Definition: eldutils.h:34
eld::cea_sad::channels
int channels
Definition: eldutils.h:93