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_SetAmpGainLevel*</TITLE> 8<LINK rel="stylesheet" href="../../css/nitro.css" type="text/css"> 9</HEAD> 10<BODY> 11<H1 align="left">PM_SetAmpGainLevel* <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 <twl/spi.h></CODE></PRE> 16 <PRE><CODE>u32 PM_SetAmpGainLevel( u8 level ); 17 18u32 PM_SetAmpGainLevelAsync( u8 level, PMCallback callback, void* arg ); 19 </CODE></PRE> 20</DL> 21<H2>Arguments</H2> 22<TABLE border="1" width="100%"> 23 <TBODY> 24 <TR> 25<TD width="13%"><EM><STRONG>level</STRONG></EM></TD> 26<TD width="87%">Setting value that determines the amp gain.</TD> 27 </TR> 28 <TR> 29<TD><EM><STRONG>callback</STRONG></EM></TD> 30<TD>Callback that is called when the command finishes.</TD> 31 </TR> 32 <TR> 33<TD><EM><STRONG>arg</STRONG></EM></TD> 34<TD>Argument that is used when calling the callback.</TD> 35 </TR> 36 </TBODY> 37</TABLE> 38<H2>Return Values</H2> 39<P>If <CODE>PM_RESULT_SUCCESS</CODE>, the command execution has succeeded (for synchronous functions), or the command was successfully sent to the ARM7 processor (for asynchronous functions).</P> 40<P>If <CODE>PM_RESULT_BUSY</CODE>, the SPI was occupied by other processing and unable to process this function.</P> 41<H2>Description</H2> 42<P>Sets the gain of the programmable amp gain. This function can only be used when the operating mode is TWL mode.</P> 43<P>The <SPAN class="argument">level</SPAN> argument is a <CODE>u8</CODE> value; specify a value in the range of 0 to 119.</P> 44<P><BR> <BR> <B>Differences Between the <A href="PM_SetAmpGain.html"><CODE>PM_SetAmpGain*</CODE></A> and <CODE>PM_SetAmpGainLevel*</CODE> Functions</B> 45 46 47<P>There are two types of setter functions: <A href="PM_SetAmpGain.html"><CODE>PM_SetAmpGain*</CODE></A> and <CODE>PM_SetAmpGainLevel*</CODE>. The former has existed since the Nintendo DS and can specify four gain levels. The latter is explained in this reference page; it is new, has been added for the TWL system, and can set 120 gain levels. 48 49<P>The <CODE><A href="PM_SetAmpGain.html">PM_SetAmpGain*</A></CODE> functions can specify four levels and are usable in any mode. The specified value is always set unchanged. 50 51 52<P>The <CODE>PM_SetAmpGainLevel*</CODE> functions can specify 120 levels and are usable only in TWL HYBRID and TWL LIMITED mode. The CODEC mode decides whether the value is actually configured as one of 120 levels, as specified. When the CODEC is running in TWL mode (which should always be the operating mode in this case), a 120-level specification is set, unchanged, to 120 levels. However, at all other times, values specified for 120 levels will be averaged to 4 levels. These four levels conform to the four levels set with the <CODE><A href="PM_SetAmpGain.html">PM_SetAmpGain</A></CODE> function. 53 54 55<P><BR> <BR> <B>Value of <SPAN class="argument">level</SPAN> and the Gain to Set</B> 56 57 58<P>The value of the <SPAN class="argument">level</SPAN> argument and the actual amp gain that is set are shown below. 59 60 61 62<BLOCKQUOTE> 63<P>When the codec is in TWL mode:</P> 64<TABLE border="1"> 65 <TBODY> 66 <TR> 67<TH width="254"><I>level</I></TH> 68<TH width="725">Gain to Set </TH> 69 </TR> 70 <TR> 71 <TD width="254"> 0</TD> 72<TD width="725"> 10.5 dB</TD> 73 </TR> 74 <TR> 75 <TD width="254"> 1</TD> 76<TD width="725"> 11.0 dB</TD> 77 </TR> 78 <TR> 79 <TD width="254"> 2</TD> 80<TD width="725"> 11.5 dB</TD> 81 </TR> 82 <TR> 83 <TD width="254"> :</TD> 84 <TD width="725"> :</TD> 85 </TR> 86 <TR> 87<TD> n</TD> 88<TD>10.5 + (<I>n</I> x 0.5) dB</TD> 89 </TR> 90 <TR> 91 <TD> :</TD> 92 <TD> :</TD> 93 </TR> 94 <TR> 95 <TD width="254"> 119</TD> 96<TD width="725"> 70.0 dB</TD> 97 </TR> 98 </TBODY> 99</TABLE> 100</BLOCKQUOTE> 101<BLOCKQUOTE> 102<P>When the codec is in DS mode:</P> 103<TABLE border="1"> 104 <TBODY> 105 <TR> 106<TH width="249"><I>level</I></TH> 107<TH width="730">Gain to Set</TH> 108 </TR> 109 <TR> 110 <TD width="249"> 0 ~ 36</TD> 111<TD width="730"> 26.0 dB (equivalent to 31 in the 120-level notation)</TD> 112 </TR> 113 <TR> 114 <TD width="249"> 37 ~ 48</TD> 115<TD width="730"> 32.0 dB (equivalent to 43 in the 120-level notation)</TD> 116 </TR> 117 <TR> 118 <TD width="249"> 49 ~ 60</TD> 119<TD width="730"> 38.0 dB (equivalent to 55 in the 120-level notation)</TD> 120 </TR> 121 <TR> 122 <TD width="249"> 61 ~ 119</TD> 123<TD width="730"> 44.0 dB (equivalent to 67 in the 120-level notation)</TD> 124 </TR> 125 </TBODY> 126</TABLE> 127</BLOCKQUOTE> 128<P><BR> <BR> <BR> <B>Asynchronous Functions</B></P> 129<P>This function uses PXI to send the command that performs the corresponding operation in the ARM7 processor. The ARM7 side that receives that command is executed by operating the PMIC. Therefore, this function may not operate instantly after you call it. A synchronous function that waits for the operation to finish, as well as an asynchronous function that only sends commands to the ARM7, are provided. Use either of the functions depending on your operational requirements. (The asynchronous function has "Async" appended to the function name.)</P> 130<P>When an asynchronous function is called, the specified <SPAN class="argument">callback</SPAN> is called when processing on the ARM7 side finishes. The callback type <CODE>PMCallback</CODE> is defined by:</P> 131<BLOCKQUOTE> <CODE><code>typedef void ( *PMCallback )( u32 result, void* arg )</code>;</CODE></BLOCKQUOTE> 132<P> This callback is called from inside the PXI interrupt handler.</P> 133<P>The callback's first argument, <SPAN class="argument">result</SPAN>, indicates the result of the command. This is either <code>PM_RESULT_SUCCESS</code> or <code>PM_RESULT_BUSY</code>. The second argument in the callback returns the value <SPAN class="argument">arg</SPAN>.</P> 134<P><BR> <BR> <B>About <CODE>PM_RESULT_BUSY</CODE></B></P> 135<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 dispatched 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, and this function returns <CODE>PM_RESULT_BUSY</CODE>. (In this case, the determination is made before notification is sent to the ARM7.)</P> 136<P>Accordingly, if you want to ensure that this function succeeds, make it loop until it succeeds as shown below. (This example does not take into account mistakes such as wrong arguments.)</P> 137<BLOCKQUOTE style="background-color:#ffffcc"><B>Example</B><BR> <CODE>while( PM_SetAmpGainLevel( ... ) != PM_RESULT_SUCCESS )<BR> {<BR> }</CODE></BLOCKQUOTE> 138<P>When using the <CODE>Async</CODE> version of this function, you could do this with code similar to the following.</P> 139<BLOCKQUOTE style="background-color:#ffffcc"><B>Example</B><BR> <CODE>void setResult( u32 result, void* arg )<BR> {<BR> if ( arg )<BR> {<BR> *(u32*)arg = result;<BR> }<BR> }<BR> <BR> while(1)<BR> {<BR> volatile u32 result = PM_RESULT_NONE; // Value that is not returned as a result<BR> <BR> while ( PM_SetAmpGainLevelAsync(..., setResult, (void*)&result ) != PM_RESULT_SUCCESS )<BR> {<BR> }<BR> <BR> // Some other process<BR> otherProcess();<BR> <BR> // Wait for processing to finish<BR> while( result == PM_RESULT_NONE )<BR> {<BR> }<BR> <BR> // Exit from the loop on success<BR> if ( result == PM_RESULT_SUCCESS )<BR> {<BR> break;<BR> }<BR> }</CODE></BLOCKQUOTE> 140 141<H2>Internal Operation</H2> 142<P>On NITRO hardware, this function manipulates the PMIC register PGA_GAIN. On TWL hardware it manipulates the codec.</P> 143<H2>See Also</H2> 144<P><A href="PM_Init.html"><CODE>PM_Init</CODE></A><BR> <A href="PM_SetAmp.html"><CODE>PM_SetAmp*</CODE></A><BR> <A href="PM_SetAmpGain.html"><CODE>PM_SetAmpGain*</CODE></A><BR> <A href="PM_GetAmpGainLevel.html"><CODE>PM_GetAmpGainLevel</CODE></A></P> 145<H2>Revision History</H2> 146<P>2009/06/03 Removed a description of the <CODE>PM_Init</CODE> function (because <CODE>OS_Init</CODE> is now required). <BR>2008/05/01 Initial version. Branched off from the <CODE>PM_SetAmpGain*</CODE> functions.</P> 147<hr><p>CONFIDENTIAL</p></body> 148</HTML>