1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<HTML>
3<HEAD>
4<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
5<META name="GENERATOR" content="IBM WebSphere Studio Homepage Builder Version 7.0.1.0 for Windows">
6<META http-equiv="Content-Style-Type" content="text/css">
7<TITLE>PM_GetAmpGainLevel</TITLE>
8<LINK rel="stylesheet" href="../../css/nitro.css" type="text/css">
9</HEAD>
10<BODY>
11<H1 align="left">PM_GetAmpGainLevel <IMG src="../../image/TWL.gif" width="24" height="12" border="0" align="middle"></H1>
12<H2>Syntax</H2>
13<DL>
14  <DD>
15  <PRE><CODE>#include &lt;twl/spi.h&gt;</CODE></PRE>
16  <PRE><CODE>u32 PM_GetAmpGainLevel( u8* levelBuf );
17  </CODE></PRE>
18</DL>
19<H2>Arguments</H2>
20<TABLE border="1" width="100%">
21  <TBODY>
22    <TR>
23<TD width="13%"><SPAN class="argument">levelBuf</SPAN></TD>
24<TD width="87%">Buffer to store the obtained results for settings values that determine the amp gain.</TD>
25    </TR>
26  </TBODY>
27</TABLE>
28<H2>Return Values</H2>
29<P>If <CODE>PM_RESULT_SUCCESS</CODE>, the command was run successfully.</P>
30<P>If <CODE>PM_RESULT_BUSY</CODE>, the SPI was occupied by other processing and unable to process this function.</P>
31<H2>Description</H2>
32<P>Gets the current setting for the programmable amp gain.</P>
33<P>It saves a <CODE>u8</CODE> value in <SPAN class="argument">levelBuf</SPAN>. The values it can obtain are in the range of 0 to 119 (120 levels).
34</P>
35<TABLE border="1">
36  <TBODY>
37    <TR>
38<TH>Value Stored in <SPAN class="argument">levelBuf</SPAN></TH>
39<TH>Gain</TH>
40    </TR>
41    <TR>
42      <TD> 0</TD>
43<TD> 10.5 dB</TD>
44    </TR>
45    <TR>
46      <TD> 1</TD>
47<TD> 11.0 dB</TD>
48    </TR>
49    <TR>
50      <TD> 2</TD>
51<TD> 11.5 dB</TD>
52    </TR>
53    <TR>
54      <TD> :</TD>
55      <TD> :</TD>
56    </TR>
57    <TR>
58<TD> n</TD>
59<TD>10.5 + (<I>n</I> x 0.5) dB</TD>
60    </TR>
61    <TR>
62      <TD> :</TD>
63      <TD> :</TD>
64    </TR>
65    <TR>
66      <TD> 119</TD>
67<TD> 70.0 dB</TD>
68    </TR>
69  </TBODY>
70</TABLE>
71<P>This function uses PXI to send a command to execute the operation in question on the ARM7 processor. Once it receives that command, the ARM7 executes it by manipulating the PMIC.</P>
72<P> <B>Note</B></P>
73<P>Before you use this function, use the <A href="PM_Init.html"><CODE>PM_Init</CODE></A> function to initialize the PM library. (The <code>PM_Init()</code> function has to be called only once. Also, when you call the <a href="../../os/init/OS_Init.html"><code>OS_Init</code></a> function, there is no need to call the <a href="PM_Init.html"><code>PM_Init</code></a> function separately because it is called from inside <code>OS_Init</code>.)</P>
74<P> <B>About <CODE>PM_RESULT_BUSY</CODE></B></P>
75<P>The SPI is used for various other processes besides power management. If you call this function while another process is using it, this function sends a command to the ARM7; there, the SPI is determined to be BUSY, and <CODE>PM_RESULT_BUSY</CODE> is notified to the ARM9 without actually processing this function. Likewise, if you call this function while another PM process is running, that fact is determined on the ARM9 side and this function returns <CODE>PM_RESULT_BUSY</CODE>. (In this case, the determination is made before notification is sent to the ARM7.)</P>
76<P>Accordingly, if you want to make certain that this function will succeed, make it loop until it succeeds as shown below. (This example does not take into account mistakes such as wrong arguments.)</P>
77<BLOCKQUOTE style="background-color:#ffffcc"><B>Example:</B><BR> <CODE>while( PM_GetAmpGainLevel( ... ) != PM_RESULT_SUCCESS )<BR> {<BR> }</CODE></BLOCKQUOTE>
78<P> <B>Differences Between the <CODE>PM_GetAmpGain</A></CODE> and <A href="PM_GetAmpGainLevel.html"><CODE>PM_GetAmpGainLevel</CODE></A> Functions</B></P>
79<P>There are two types of functions to get the gain settings: <A href="PM_GetAmpGain.html"><CODE>PM_GetAmpGain</CODE></A> and <CODE>PM_GetAmpGainLevel</CODE> (this function). The former has existed since the old Nintendo DS and can get four gain levels. (Four gain levels can be set, as well.) The latter is explained in this reference page; it is new, has been added for the TWL system, and can get 120 gain levels.</P>
80<P>The <A href="PM_GetAmpGain.html"><CODE>PM_GetAmpGain</CODE></A> function can get four levels and is usable in any mode.</P>
81<P>The <CODE>PM_GetAmpGainLevel</CODE> function can get 120 levels and is usable only in TWL HYBRID and TWL LIMITED mode. The CODEC mode decides whether 120 levels are actually configured internally. The codec will be configured with 120 levels when it is running in TWL mode (this should always be TWL mode).</P>
82<P>If 4 levels have been configured internally, this function will obtain a setting value that corresponds to 120 levels. On the other hand, if 120 levels have been configured internally and the <A href="PM_GetAmpGain.html"><CODE>PM_GetAmpGain</CODE></A> function attempts to get a 4-level value, the 120 levels will be divided into 4 sections, from which an approximate 4-level value will be returned.</P>
83<P>The following table shows the 120-level values obtained from the <A href="PM_GetAmpGainLevel.html"><CODE>PM_GetAmpGainLevel</CODE></A> function when 4 levels are configured internally.
84</P>
85<TABLE border="1">
86  <TBODY>
87    <TR>
88<TH width="272">Configured Value</TH>
89<TH width="466">Gain (120 Levels)</TH>
90    </TR>
91    <TR>
92<TD width="272"><CODE>PM_AMPGAIN_20</CODE></TD>
93<TD width="466"> 31 (26.0 dB) </TD>
94    </TR>
95    <TR>
96<TD width="272"><CODE>PM_AMPGAIN_40</CODE></TD>
97<TD width="466"> 43 (32.0 dB)</TD>
98    </TR>
99    <TR>
100<TD width="272"><CODE>PM_AMPGAIN_80</CODE></TD>
101<TD width="466"> 55 (38.0 dB)</TD>
102    </TR>
103    <TR>
104<TD width="272"><CODE>PM_AMPGAIN_160</CODE></TD>
105<TD width="466"> 67 (44.0 dB)</TD>
106    </TR>
107  </TBODY>
108</TABLE>
109<P><BR>The values 31, 43, 55, and 67 are given the constant definitions <CODE>PM_AMPGAIN_LEVEL_DS0</CODE>, <CODE>PM_AMPGAIN_LEVEL_DS1</CODE>, <CODE>PM_AMPGAIN_LEVEL_DS2</CODE>, and <CODE>PM_AMPGAIN_LEVEL_DS3</CODE>, respectively.</P>
110<H2>Internal Operation</H2>
111<P>On NITRO hardware, reads the value of the PMIC register PGA_GAIN. On TWL hardware, reads the codec value.</P>
112<H2>See Also</H2>
113<P><A href="PM_Init.html"><CODE>PM_Init</CODE></A><BR> <A href="PM_SetAmpGain.html"><CODE>PM_SetAmpGainLevel*</CODE></A><BR> <A href="PM_GetAmpGain.html"><CODE>PM_GetAmpGain</CODE></A></P>
114<H2>Revision History</H2>
115<P>2008/08/23 Elaborated on <CODE>PM_RESULT_BUSY</CODE>.<BR> 2008/05/01 Branched from <CODE>PM_GetAmpGain</CODE>.</P>
116<hr><p>CONFIDENTIAL</p></body>
117</HTML>