answer
stringlengths
15
1.25M
<!DOCTYPE html> <html> <head> <script src="../../ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ var btn = $(this).text(); $("p").css("background-color","white"); $("p" + btn).css("background-color","yellow"); }); }); </script> </head> <body> <button>:last</button> <button>:last-child</button> <button>:last-of-type</button><br> <p>The first paragraph in body, and the first child in div.</p> <div style="border:1px solid;"> <p>The first paragraph in div, and the first child in div.</p> <p>The last paragraph in div, and the last child in div.</p> </div><br> <div style="border:1px solid;"> <span>This is a span element, and the first child in this div.</span> <p>The first paragraph in another div, and the second child in this div.</p> <p>The last paragraph in another div, and the third child in this div.</p> <span>This is a span element, and the last child in this div.</span> </div><br> <div style="border:1px solid"> <p>The first paragraph in another div, and the first child in this div.</p> <p>The last paragraph in the another div, and the last child in this div.</p> </div> <p>The last paragraph in body, and the last child in div.</p> </body> </html>
<HTML> <HEAD> <TITLE> Paint by Numbers - 32x32 #27</TITLE> </HEAD> <BODY> <h1> Paint by Numbers - 32x32 #27</h1> <p> <applet code=PBN10a.class name=Paint by Numbers width=616 height=556 > <param name=filename value=32x32/bridge.xbm> <param name=solved value=false> </applet> <p> Each number to the right of the grid gives the sizes of the contiguous blocks of black squares within that row. Each number below the grid does the same for its column. <p> <table border=1 cellpadding=3> <tr><td>To turn a square: <td>use this mouse button:<td>or this key with the mouse button: <tr><td align=center>black <td align=center>left <td align=center>none <tr><td align=center>white <td align=center>right <td align=center>Control <tr><td align=center>gray <td align=center>middle <td align=center>Shift </table> <p> You can drag the mouse to set a bunch of squares at one time. <p> <a href="printable/g32x32-27.html">Printable version of this puzzle</a><br> <a href="puzzles.html">Back to main page</a> </BODY> </HTML>
#!/usr/bin/env python # This program is free software; you can redistribute it and/or # as published by the Free Software Foundation; either version 2 # This program is distributed in the hope that it will be useful, # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA from random import randrange from zipfile import ZipFile from StringIO import StringIO # Constants DEFAULT_LEVELPACK = './data/default_pack.zip' SKILL_EASY = 'Easy' # These values should match the SKILL_MEDIUM = 'Medium' # the level files! SKILL_HARD = 'Hard' FIELD_INVALID = 0 # Constants describing a field on FIELD_VALID = 1 # the playfield FIELD_MARKED_VALID = 2 <API key> = 4 FIELD_OPEN = 8 class Game(object): """A paint by numbers game also called nonogram. """ def __init__(self, skill=None): """Creates a picross game. Parameters: skill - Desired skill level (None == random) """ self.__level = None self.__name = None self.__skill = None self.__fieldsToOpen = 0 self.__fieldsOpened = 0 self.load(skill=skill) # Miscellaneous methods def _debug_print(self): print self.getInfo() print 'go: %s' % (self.__gameOver) for row in self.__level: print row # Game information retrieval def getInfo(self): """Returns the name, skill and size of the level """ return self.__name,self.__skill,len(self.__level) def getRowHint(self,row): """Returns the hint for a specific row. """ hint,count = [],0 for columnItem in self.__level[row]: if columnItem == FIELD_VALID: count += 1 else: if count > 0: hint.append(count) count = 0 if count > 0: hint.append(count) if not hint: hint.append(0) return hint def getColumnHint(self,col): """Returns the hint for a specific column. """ hint,count = [],0 for row in self.__level: if row[col] == FIELD_VALID: count += 1 else: if count > 0: hint.append(count) count = 0 if count > 0: hint.append(count) if not hint: hint.append(0) return hint def getField(self,col,row): return self.__level[row][col] def isGameWon(self): return self.__fieldsOpened == self.__fieldsToOpen # Game manipulation methods def restart(self): """Reinitializes the current game """ for i, row in enumerate(self.__level): for j, field in enumerate(row): if field == FIELD_OPEN or field == FIELD_MARKED_VALID: self.__level[i][j] = FIELD_VALID elif field == <API key>: self.__level[i][j] = FIELD_INVALID self.__gameOver = False self.__fieldsOpened = 0 def openField(self,col,row): field = self.__level[row][col] if field == FIELD_VALID or field == FIELD_MARKED_VALID: self.__level[row][col] = FIELD_OPEN self.__fieldsOpened += 1 return True else: return False def markField(self,col,row): field = self.__level[row][col] if field == FIELD_VALID: self.__level[row][col] = FIELD_MARKED_VALID elif field == FIELD_MARKED_VALID: self.__level[row][col] = FIELD_VALID elif field == FIELD_INVALID: self.__level[row][col] = <API key> elif field == <API key>: self.__level[row][col] = FIELD_INVALID return self.__level[row][col] def load(self,file=DEFAULT_LEVELPACK,skill=None): """Loads a level either from a zipped levelpack or from a textfile. Parameters: file - Can be a file path or zipped levelpack skill - Desired level skill (None == random) """ if file.endswith('.lvl'): # Set the skill variable if file.startswith('easy'): self.__skill = SKILL_EASY elif file.startswith('medium'): self.__skill = SKILL_MEDIUM elif file.startswith('hard'): self.__skill = SKILL_HARD self.__loadFileContent(open(file,'r')) elif file.endswith('.zip'): zip = ZipFile(file) # We have to select from which files in the zipfile we # want to choose randomly based on the level's skill candidates = [] if skill == SKILL_EASY: for file in zip.namelist(): if file.startswith('easy'): candidates.append(file) elif skill == SKILL_MEDIUM: for file in zip.namelist(): if file.startswith('medium'): candidates.append(file) elif skill == SKILL_HARD: for file in zip.namelist(): if file.startswith('hard'): candidates.append(file) # This should never happen in a good levelpack, but if it # is malformed, just pick something! if not candidates: candidates = zip.namelist() # Select one candidate randomly which = candidates[randrange(len(candidates))] # Set the skill variable if which.startswith('easy'): self.__skill = SKILL_EASY elif which.startswith('medium'):self.__skill = SKILL_MEDIUM elif which.startswith('hard'): self.__skill = SKILL_HARD # Read from zipfile and load file content buf = zip.read(which) self.__loadFileContent(StringIO(buf)) def __loadFileContent(self,file): """Actually loads the level data from a file. """ self.__level = [] for line in file: if line.startswith('name:'): self.__name = line[5:].strip() elif line[0] == '0' or line[0] == '1': row = [] for field in line: if field == '0': row.append(FIELD_INVALID) elif field == '1': self.__fieldsToOpen += 1 row.append(FIELD_VALID) self.__level.append(row)
#include "stdinc.h" #include "Mapper_WinUPnP.h" #include "Util.h" #include "Text.h" #include "w.h" #include "AirUtil.h" #ifdef HAVE_WINUPNP_H #include <ole2.h> #include <natupnp.h> #else // HAVE_WINUPNP_H struct IUPnPNAT { }; struct <API key> { }; #endif // HAVE_WINUPNP_H namespace dcpp { const string Mapper_WinUPnP::name = "Windows UPnP"; Mapper_WinUPnP::Mapper_WinUPnP(const string& localIp, bool v6) : Mapper(localIp, v6) { } bool Mapper_WinUPnP::supportsProtocol(bool aV6) const { return !aV6; } #ifdef HAVE_WINUPNP_H bool Mapper_WinUPnP::init() { HRESULT hr = ::CoInitializeEx(NULL, <API key>); if(FAILED(hr)) return false; if(pUN) return true; // Lacking the __uuidof in mingw... CLSID upnp; OLECHAR upnps[] = L"{<API key>}"; CLSIDFromString(upnps, &upnp); IID iupnp; OLECHAR iupnps[] = L"{<API key>}"; CLSIDFromString(iupnps, &iupnp); pUN = 0; hr = ::CoCreateInstance(upnp, 0, <API key>, iupnp, reinterpret_cast<LPVOID*>(&pUN)); if(FAILED(hr)) pUN = 0; return pUN ? true : false; } void Mapper_WinUPnP::uninit() { ::CoUninitialize(); } bool Mapper_WinUPnP::add(const string& port, const Protocol protocol, const string& description) { <API key>* pSPMC = <API key>(); if(!pSPMC) return false; @todo use a BSTR wrapper BSTR protocol_ = SysAllocString(Text::toT(protocols[protocol]).c_str()); BSTR description_ = SysAllocString(Text::toT(description).c_str()); BSTR localIP = !localIp.empty() ? SysAllocString(Text::toT(localIp).c_str()) : nullptr; auto port_ = Util::toInt(port); IStaticPortMapping* pSPM = 0; HRESULT hr = pSPMC->Add(port_, protocol_, port_, localIP, VARIANT_TRUE, description_, &pSPM); SysFreeString(protocol_); SysFreeString(description_); SysFreeString(localIP); bool ret = SUCCEEDED(hr); if(ret) { pSPM->Release(); lastPort = port_; lastProtocol = protocol; } pSPMC->Release(); return ret; } bool Mapper_WinUPnP::remove(const string& port, const Protocol protocol) { <API key>* pSPMC = <API key>(); if(!pSPMC) return false; @todo use a BSTR wrapper BSTR protocol_ = SysAllocString(Text::toT(protocols[protocol]).c_str()); auto port_ = Util::toInt(port); HRESULT hr = pSPMC->Remove(port_, protocol_); pSPMC->Release(); SysFreeString(protocol_); bool ret = SUCCEEDED(hr); if(ret && port_ == lastPort && protocol == lastProtocol) { lastPort = 0; } return ret; } string Mapper_WinUPnP::getDeviceName() { @todo use IUPnPDevice::ModelName <http://msdn.microsoft.com/en-us/library/aa381670(VS.85).aspx>? return Util::emptyString; } string Mapper_WinUPnP::getExternalIP() { // Get the External IP from the last added mapping if(!lastPort) return Util::emptyString; <API key>* pSPMC = <API key>(); if(!pSPMC) return Util::emptyString; @todo use a BSTR wrapper BSTR protocol_ = SysAllocString(Text::toT(protocols[lastProtocol]).c_str()); // Lets Query our mapping IStaticPortMapping* pSPM; HRESULT hr = pSPMC->get_Item(lastPort, protocol_, &pSPM); SysFreeString(protocol_); // Query failed! if(FAILED(hr) || !pSPM) { pSPMC->Release(); return Util::emptyString; } BSTR bstrExternal = 0; hr = pSPM-><API key>(&bstrExternal); if(FAILED(hr) || !bstrExternal) { pSPM->Release(); pSPMC->Release(); return Util::emptyString; } // convert the result string ret = Text::wideToAcp(bstrExternal); // no longer needed SysFreeString(bstrExternal); // no longer needed pSPM->Release(); pSPMC->Release(); return ret; } <API key>* Mapper_WinUPnP::<API key>() { if(!pUN) return 0; <API key>* ret = 0; HRESULT hr = 0; // some routers lag here for(int i = 0; i < 3; i++) { hr = pUN-><API key> (&ret); if(SUCCEEDED(hr) && ret) break; Sleep(1500); } if(FAILED(hr)) return 0; return ret; } #else // HAVE_WINUPNP_H bool Mapper_WinUPnP::init() { return false; } void Mapper_WinUPnP::uninit() { } bool Mapper_WinUPnP::add(const string& /*port*/, const Protocol /*protocol*/, const string& /*description*/) { return false; } bool Mapper_WinUPnP::remove(const string& /*port*/, const Protocol /*protocol*/) { return false; } string Mapper_WinUPnP::getDeviceName() { return Util::emptyString; } string Mapper_WinUPnP::getExternalIP() { return Util::emptyString; } <API key>* Mapper_WinUPnP::<API key>() { return 0; } #endif // HAVE_WINUPNP_H } // dcpp namespace
<?php require_once('CBA.php'); require_once('WBA.php'); class HA2 { private $cba; private $wba; /* * Constructor, in which the reference characters and reference words are * loaded for each language. */ public function HA2() { // instantiate the CBA and WBA classes $this->cba = new CBA(); $this->wba = new WBA(); } /* * Identification: function concerns the identification of an input text * file, and it consists of adding the probabilities computed by the CBA * and WBA for each language. * * [output]: the number of the promising language (between 0-31). * * @param text: is the text to identify. */ public function identification($text) { $cbaProbabilities = $this->cba-><API key>($text); // retrieve probabilities computed by CBA $wbaProbabilities = $this->wba-><API key>($text); // retrieve probabilities computed by WBA // add the probabilities for each language $probabilities = array(); for($language=0; $language<NUMBER_LANGUAGES; $language++) { $probabilities[$language] = $cbaProbabilities[$language] + $wbaProbabilities[$language]; } return $this->classification($probabilities); } /* * Classification: function to classify the input text to the * corresponding language using the sum of probabilities (CBA + WBA). * * [output]: the number of the promising language (between 0-31). * * @param probabilities: a table of probabilities of all the languages. */ public function classification($probabilities) { // retrieve the highest probability (sum of frequencies) $max = 0; // keeps the highest probability $promising_language = -1; // keeps the promising language for($language=0; $language<NUMBER_LANGUAGES; $language++) { if($probabilities[$language] > $max) { $max = $probabilities[$language]; $promising_language = $language; } } // determine exactly the promising language by applying an order of classification if($promising_language != LNG_CHINESE && $promising_language != LNG_GREEK && $promising_language != LNG_HEBREW && $promising_language != LNG_HINDI && $promising_language != LNG_THAI) { if($max == $probabilities[LNG_ARABIC]) $promising_language = LNG_ARABIC; else if($max == $probabilities[LNG_PERSIAN]) $promising_language = LNG_PERSIAN; else if($max == $probabilities[LNG_URDU]) $promising_language = LNG_URDU; else if($max == $probabilities[LNG_BULGARIAN]) $promising_language = LNG_BULGARIAN; else if($max == $probabilities[LNG_RUSSIAN]) $promising_language = LNG_RUSSIAN; else if($max == $probabilities[LNG_ENGLISH]) $promising_language = LNG_ENGLISH; else if($max == $probabilities[LNG_DUTCH]) $promising_language = LNG_DUTCH; else if($max == $probabilities[LNG_INDONESIAN]) $promising_language = LNG_INDONESIAN; else if($max == $probabilities[LNG_MALAYSIAN]) $promising_language = LNG_MALAYSIAN; else if($max == $probabilities[LNG_LATIN]) $promising_language = LNG_LATIN; else if($max == $probabilities[LNG_ROMAN]) $promising_language = LNG_ROMAN; else if($max == $probabilities[LNG_FRENCH]) $promising_language = LNG_FRENCH; else if($max == $probabilities[LNG_ITALIAN]) $promising_language = LNG_ITALIAN; else if($max == $probabilities[LNG_IRISH]) $promising_language = LNG_IRISH; else if($max == $probabilities[LNG_SPANISH]) $promising_language = LNG_SPANISH; else if($max == $probabilities[LNG_PORTUGUESE]) $promising_language = LNG_PORTUGUESE; else if($max == $probabilities[LNG_ALBANIAN]) $promising_language = LNG_ALBANIAN; else if($max == $probabilities[LNG_CZECH]) $promising_language = LNG_CZECH; else if($max == $probabilities[LNG_FINNISH]) $promising_language = LNG_FINNISH; else if($max == $probabilities[LNG_HUNGARIAN]) $promising_language = LNG_HUNGARIAN; else if($max == $probabilities[LNG_SWEDISH]) $promising_language = LNG_SWEDISH; else if($max == $probabilities[LNG_GERMAN]) $promising_language = LNG_GERMAN; else if($max == $probabilities[LNG_NORWEGIAN]) $promising_language = LNG_NORWEGIAN; else if($max == $probabilities[LNG_DANISH]) $promising_language = LNG_DANISH; else if($max == $probabilities[LNG_ICELANDIC]) $promising_language = LNG_ICELANDIC; else if($max == $probabilities[LNG_TURKISH]) $promising_language = LNG_TURKISH; else if($max == $probabilities[LNG_POLISH]) $promising_language = LNG_POLISH; } return $promising_language; } } ?>
package us.mn.state.dot.tms.server.comm; import us.mn.state.dot.tms.DeviceRequest; import us.mn.state.dot.tms.server.CameraImpl; /** * CameraPoller is an interface for pollers which can send camera control * messages. * * @author Douglas Lau * @author Travis Swanston */ public interface CameraPoller { /** Send a PTZ camera move command */ void sendPTZ(CameraImpl c, float p, float t, float z); /** Send a store camera preset command */ void sendStorePreset(CameraImpl c, int preset); /** Send a recall camera preset command */ void sendRecallPreset(CameraImpl c, int preset); /** Send a device request * @param c The CameraImpl object. * @param r The desired DeviceRequest. */ void sendRequest(CameraImpl c, DeviceRequest r); }
# WordPlay Word Play is basic two player game that removes the letters from a word where the other play is the guess the original word. Word Play is one the first games that made, definitely the first use looping as base. WordPlay is considered to complete and will not change.
#ifndef __INC_BLOCK_H #define __INC_BLOCK_H #include "vp8/common/onyx.h" #include "vp8/common/blockd.h" #include "vp8/common/entropymv.h" #include "vp8/common/entropy.h" #include "vpx_ports/mem.h" #define MAX_MODES 20 #define MAX_ERROR_BINS 1024 typedef struct { MV mv; int offset; } search_site; typedef struct block { short *src_diff; short *coeff; short *quant; short *quant_fast; short *quant_shift; short *zbin; short *zrun_zbin_boost; short *round; short zbin_extra; unsigned char **base_src; int src; int src_stride; } BLOCK; typedef struct { int count; struct { B_PREDICTION_MODE mode; int_mv mv; } bmi[16]; } PARTITION_INFO; typedef struct macroblock { DECLARE_ALIGNED(16, short, src_diff[400]); DECLARE_ALIGNED(16, short, coeff[400]); DECLARE_ALIGNED(16, unsigned char, thismb[256]); unsigned char *thismb_ptr; BLOCK block[25]; YV12_BUFFER_CONFIG src; MACROBLOCKD e_mbd; PARTITION_INFO *partition_info; PARTITION_INFO *pi; PARTITION_INFO *pip; int ref_frame_cost[MAX_REF_FRAMES]; search_site *ss; int ss_count; int searches_per_step; int errorperbit; int sadperbit16; int sadperbit4; int rddiv; int rdmult; unsigned int * mb_activity_ptr; int * <API key>; signed int act_zbin_adj; signed int last_act_zbin_adj; int *mvcost[2]; int *mvsadcost[2]; int (*mbmode_cost)[MB_MODE_COUNT]; int (*intra_uv_mode_cost)[MB_MODE_COUNT]; int (*bmode_costs)[10][10]; int *inter_bmode_costs; int (*token_costs)[COEF_BANDS][PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; int mv_col_min; int mv_col_max; int mv_row_min; int mv_row_max; int skip; unsigned int encode_breakout; signed char *gf_active_ptr; unsigned char *active_ptr; MV_CONTEXT *mvc; int optimize; int q_index; #if <API key> MB_PREDICTION_MODE best_sse_inter_mode; int_mv best_sse_mv; MV_REFERENCE_FRAME <API key>; MV_REFERENCE_FRAME <API key>; unsigned char <API key>; #endif int skip_true_count; unsigned int coef_counts [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; unsigned int MVcount [2] [MVvals]; int ymode_count [VP8_YMODES]; int uv_mode_count[VP8_UV_MODES]; int64_t prediction_error; int64_t intra_error; int <API key>[MAX_REF_FRAMES]; int rd_thresh_mult[MAX_MODES]; int rd_threshes[MAX_MODES]; unsigned int mbs_tested_so_far; unsigned int <API key>[MAX_MODES]; int <API key>; int zbin_mode_boost; int <API key>; int <API key>; int zbin_over_quant; int error_bins[MAX_ERROR_BINS]; void (*short_fdct4x4)(short *input, short *output, int pitch); void (*short_fdct8x4)(short *input, short *output, int pitch); void (*short_walsh4x4)(short *input, short *output, int pitch); void (*quantize_b)(BLOCK *b, BLOCKD *d); void (*quantize_b_pair)(BLOCK *b1, BLOCK *b2, BLOCKD *d0, BLOCKD *d1); } MACROBLOCK; #endif
#include <Ice/Ice.h> #include <IceGrid/IceGrid.h> #include <Hello.h> using namespace std; using namespace Demo; class HelloClient : public Ice::Application { public: HelloClient(); virtual int run(int, char*[]); private: void menu(); void usage(); }; int main(int argc, char* argv[]) { HelloClient app; return app.main(argc, argv, "config.client"); } HelloClient::HelloClient() : // Since this is an interactive demo we don't want any signal // handling. Ice::Application(Ice::NoSignalHandling) { } int HelloClient::run(int argc, char* argv[]) { if(argc > 2) { usage(); return EXIT_FAILURE; } bool addContext = false; if(argc == 2) { if(string(argv[1]) == "--context") { addContext = true; } else { usage(); return EXIT_FAILURE; } } // Add the context entry that allows the client to use the locator if(addContext) { Ice::LocatorPrx locator = communicator()->getDefaultLocator(); Ice::Context ctx; ctx["SECRET"] = "LetMeIn"; communicator()->setDefaultLocator(locator->ice_context(ctx)); } // Now we try to connect to the object with the `hello' identity. HelloPrx hello = HelloPrx::checkedCast(communicator()->stringToProxy("hello")); if(!hello) { cerr << argv[0] << ": couldn't find a `hello' object." << endl; return EXIT_FAILURE; } menu(); char c = 'x'; do { try { cout << "==> "; cin >> c; if(c == 't') { hello->sayHello(); } else if(c == 't') { hello->sayHello(); } else if(c == 's') { hello->shutdown(); } else if(c == 'x') { // Nothing to do } else if(c == '?') { menu(); } else { cout << "unknown command `" << c << "'" << endl; menu(); } } catch(const Ice::Exception& ex) { cerr << ex << endl; } } while(cin.good() && c != 'x'); return EXIT_SUCCESS; } void HelloClient::menu() { cout << "usage:\n" "t: send greeting\n" "s: shutdown server\n" "x: exit\n" "?: help\n"; } void HelloClient::usage() { cerr << "Usage: " << appName() << " [--context]" << endl; }
<!DOCTYPE html PUBLIC "- <html xmlns="http: <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>Luayats: src/win/winobj.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.1 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main&nbsp;Page</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File&nbsp;List</span></a></li> <li><a href="globals.html"><span>File&nbsp;Members</span></a></li> </ul> </div> <a name="l00035"></a>00035 <span class="preprocessor">#ifndef _WINOBJ_H_</span> <a name="l00036"></a>00036 <span class="preprocessor"></span><span class="preprocessor">#define _WINOBJ_H_</span> <a name="l00037"></a>00037 <span class="preprocessor"></span> <a name="l00038"></a>00038 <span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> { <a name="l00039"></a>00039 <span class="preprocessor">#include &quot;lua.h&quot;</span> <a name="l00040"></a>00040 <span class="preprocessor">#include &quot;iup/iup.h&quot;</span> <a name="l00041"></a>00041 <span class="preprocessor">#include &quot;cd/cd.h&quot;</span> <a name="l00042"></a>00042 <span class="preprocessor">#include &quot;cd/wd.h&quot;</span> <a name="l00043"></a>00043 <span class="preprocessor">#include &quot;cd/cddbuf.h&quot;</span> <a name="l00044"></a>00044 <span class="preprocessor">#include &quot;cd/cdimage.h&quot;</span> <a name="l00045"></a>00045 <span class="preprocessor">#include &quot;cd/cdirgb.h&quot;</span> <a name="l00046"></a>00046 } <a name="l00047"></a>00047 <span class="preprocessor">#include &quot;<a class="code" href="inxout_8h.html">inxout.h</a>&quot;</span> <a name="l00048"></a>00048 <a name="l00049"></a><a class="code" href="structXSegment.html">00049</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{ <a name="l00050"></a><a class="code" href="structXSegment.html#<API key>">00050</a> <span class="keywordtype">short</span> x1, x2, y1, y2; <a name="l00051"></a>00051 } <a class="code" href="structXSegment.html">XSegment</a>; <a name="l00052"></a>00052 <a name="l00053"></a><a class="code" href="structviewport.html">00053</a> <span class="keyword">struct </span><a class="code" href="structviewport.html">viewport</a> { <a name="l00054"></a><a class="code" href="structviewport.html#<API key>">00054</a> <span class="keywordtype">int</span> <a class="code" href="structviewport.html#<API key>">xmin</a>; <a name="l00055"></a><a class="code" href="structviewport.html#<API key>">00055</a> <span class="keywordtype">int</span> <a class="code" href="structviewport.html#<API key>">xmax</a>; <a name="l00056"></a><a class="code" href="structviewport.html#<API key>">00056</a> <span class="keywordtype">int</span> <a class="code" href="structviewport.html#<API key>">ymin</a>; <a name="l00057"></a><a class="code" href="structviewport.html#<API key>">00057</a> <span class="keywordtype">int</span> <a class="code" href="structviewport.html#<API key>">ymax</a>; <a name="l00058"></a>00058 }; <a name="l00059"></a>00059 <a name="l00060"></a>00060 <span class="comment">//tolua_begin</span> <a name="l00061"></a><a class="code" href="winobj_8h.html#<API key>">00061</a> <span class="preprocessor">#define CDTYPE_IUP (1)</span> <a name="l00062"></a><a class="code" href="winobj_8h.html#<API key>">00062</a> <span class="preprocessor"></span><span class="preprocessor">#define CDTYPE_DBUFFER (2)</span> <a name="l00063"></a><a class="code" href="winobj_8h.html#<API key>">00063</a> <span class="preprocessor"></span><span class="preprocessor">#define CDTYPE_SERVERIMG (3)</span> <a name="l00064"></a><a class="code" href="winobj_8h.html#<API key>">00064</a> <span class="preprocessor"></span><span class="preprocessor">#define CDTYPE_CLIENTIMG (4)</span> <a name="l00065"></a><a class="code" href="classwinobj.html">00065</a> <span class="preprocessor"></span><span class="keyword">class </span><a class="code" href="classwinobj.html">winobj</a>: <span class="keyword">public</span> <a class="code" href="classinxout.html">inxout</a> { <a name="l00066"></a>00066 <span class="keyword">typedef</span> <a class="code" href="classinxout.html">inxout</a> <a class="code" href="classroot.html">baseclass</a>; <a name="l00067"></a>00067 <span class="keyword">public</span>: <a name="l00068"></a>00068 <a class="code" href="classwinobj.html#<API key>">winobj</a>(); <a name="l00069"></a>00069 <a class="code" href="classwinobj.html#<API key>">~winobj</a>(); <a name="l00070"></a>00070 <span class="keywordtype">void</span> <a class="code" href="classwinobj.html#<API key>">set_textsize</a>(<span class="keywordtype">int</span>); <a name="l00071"></a>00071 cdCanvas *<a class="code" href="classwinobj.html#<API key>">map</a>(<span class="keywordtype">void</span> *iupcanvas, <span class="keywordtype">void</span> *wid, <a name="l00072"></a>00072 <span class="keywordtype">int</span> <a class="code" href="classwinobj.html#<API key>">width</a>, <span class="keywordtype">int</span> <a class="code" href="classwinobj.html#<API key>">height</a>, <span class="keywordtype">int</span> <a class="code" href="classwinobj.html#<API key>">xpos</a>, <span class="keywordtype">int</span> <a class="code" href="classwinobj.html#<API key>">ypos</a>, <a name="l00073"></a>00073 <span class="keyword">const</span> <span class="keywordtype">char</span> *wrtypeface = <span class="stringliteral">&quot;Helvetica&quot;</span>, <a name="l00074"></a>00074 <span class="keywordtype">int</span> wrstyle = <a class="code" href="cd__pkg_8h.html#<API key>">CD_BOLD</a>, <a name="l00075"></a>00075 <span class="keywordtype">int</span> wrsize = 10, <a name="l00076"></a>00076 <span class="keywordtype">void</span> *wrcol = (<span class="keywordtype">void</span> *) <a class="code" href="cd__pkg_8h.html#<API key>">CD_BLACK</a>, <a name="l00077"></a>00077 <span class="keywordtype">int</span> wrmode = <a class="code" href="cd__pkg_8h.html#<API key>">CD_REPLACE</a>, <a name="l00078"></a>00078 <span class="keywordtype">void</span> *fgcol = (<span class="keywordtype">void</span> *) CD_BLACK, <a name="l00079"></a>00079 <span class="keywordtype">int</span> fgmode = <a class="code" href="cd__pkg_8h.html#<API key>">CD_REPLACE</a>, <a name="l00080"></a>00080 <span class="keywordtype">int</span> fgstyle = <a class="code" href="cd__pkg_8h.html#<API key>">CD_CONTINUOUS</a>, <a name="l00081"></a>00081 <span class="keywordtype">int</span> fgwidth = 1, <a name="l00082"></a>00082 <span class="keywordtype">void</span> *bgcol = (<span class="keywordtype">void</span> *) <a class="code" href="cd__pkg_8h.html#<API key>">CD_WHITE</a>, <a name="l00083"></a>00083 <span class="keywordtype">int</span> opacity = <a class="code" href="cd__pkg_8h.html#<API key>">CD_TRANSPARENT</a>, <a name="l00084"></a>00084 <span class="keywordtype">int</span> <a class="code" href="classwinobj.html#<API key>">usepoly</a> = 0, <a name="l00085"></a>00085 <span class="keywordtype">int</span> <a class="code" href="classwinobj.html#<API key>">polytype</a> = CD_OPEN_LINES, <a name="l00086"></a>00086 <span class="keywordtype">int</span> <a class="code" href="classwinobj.html#<API key>">polystep</a> = 0, <a name="l00087"></a>00087 <span class="keywordtype">int</span> canvastype = <a class="code" href="winobj_8h.html#<API key>">CDTYPE_SERVERIMG</a>); <a name="l00088"></a>00088 <span class="comment">// void * map(void *, void*, </span> <a name="l00089"></a>00089 <span class="comment">// int, int, int, int, </span> <a name="l00090"></a>00090 <span class="comment">// int, int, int, int, </span> <a name="l00091"></a>00091 <span class="comment">// int, int, int, int,</span> <a name="l00092"></a>00092 <span class="comment">// int, int, int);</span> <a name="l00093"></a>00093 <span class="keywordtype">void</span> <a class="code" href="classwinobj.html#<API key>">unmap</a>(<span class="keywordtype">void</span>); <a name="l00094"></a>00094 <span class="keywordtype">void</span> <a class="code" href="classwinobj.html#<API key>">draw_values</a>(<span class="keywordtype">int</span> *, <span class="keywordtype">void</span> *color, <span class="keywordtype">int</span> nvals, <span class="keywordtype">int</span> <a class="code" href="classwinobj.html#<API key>">usepoly</a>, <span class="keywordtype">int</span> <a class="code" href="classwinobj.html#<API key>">polytype</a>, <span class="keywordtype">int</span> <a class="code" href="classwinobj.html#<API key>">polystep</a>, <span class="keywordtype">int</span> flush); <a name="l00095"></a>00095 <span class="keywordtype">void</span> <a class="code" href="classwinobj.html#<API key>">draw_values</a>(<span class="keywordtype">double</span> *, <span class="keywordtype">double</span> *, <span class="keywordtype">void</span> *color, <span class="keywordtype">int</span> nvals, <span class="keywordtype">int</span> usepoly, <span class="keywordtype">int</span> polytype, <span class="keywordtype">int</span> polystep, <span class="keywordtype">int</span> flush); <a name="l00096"></a><a class="code" href="classwinobj.html#<API key>">00096</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classwinobj.html#<API key>">drawWin</a>(<span class="keywordtype">int</span> activate = 1, <span class="keywordtype">int</span> clear = 1, <span class="keywordtype">int</span> flush = 1){} <a name="l00097"></a>00097 <span class="keywordtype">int</span> <a class="code" href="classwinobj.html#<API key>">getexp</a>(<a class="code" href="structexp__typ.html">exp_typ</a> *); <a name="l00098"></a><a class="code" href="classwinobj.html#<API key>">00098</a> cdCanvas* <a class="code" href="classwinobj.html#<API key>">setCanvas</a>(cdCanvas * cv){ <a name="l00099"></a>00099 <span class="keywordflow">if</span> (<a class="code" href="classwinobj.html#<API key>">canvas_mapped</a> == <span class="keyword">false</span>) <a name="l00100"></a>00100 <span class="keywordflow">return</span> NULL; <a name="l00101"></a>00101 cdCanvas *ocv = <a class="code" href="classwinobj.html#<API key>">canvas</a>; <a name="l00102"></a>00102 <a class="code" href="classwinobj.html#<API key>">canvas</a> = cv; <a name="l00103"></a>00103 <span class="keywordflow">return</span> ocv; <a name="l00104"></a>00104 } <a name="l00105"></a><a class="code" href="classwinobj.html#<API key>">00105</a> cdCanvas* <a class="code" href="classwinobj.html#<API key>">getCanvas</a>(<span class="keywordtype">void</span>){ <a name="l00106"></a>00106 <span class="keywordflow">if</span> (<a class="code" href="classwinobj.html#<API key>">canvas_mapped</a> == <span class="keyword">true</span>) <a name="l00107"></a>00107 <span class="keywordflow">return</span> <a class="code" href="classwinobj.html#<API key>">canvas</a>; <a name="l00108"></a>00108 <span class="keywordflow">else</span> <a name="l00109"></a>00109 <span class="keywordflow">return</span> NULL; <a name="l00110"></a>00110 } <a name="l00111"></a><a class="code" href="classwinobj.html#<API key>">00111</a> <span class="keywordtype">int</span> <a class="code" href="classwinobj.html#<API key>">activateCanvas</a>(<span class="keywordtype">void</span>){ <a name="l00112"></a>00112 <span class="keywordflow">if</span> (<a class="code" href="classwinobj.html#<API key>">canvas_mapped</a> == <span class="keyword">true</span>) <a name="l00113"></a>00113 <span class="keywordflow">return</span> cdCanvasActivate(<a class="code" href="classwinobj.html#<API key>">canvas</a>); <a name="l00114"></a>00114 <span class="keywordflow">else</span> <a name="l00115"></a>00115 <span class="keywordflow">return</span> CD_ERROR; <a name="l00116"></a>00116 } <a name="l00117"></a><a class="code" href="classwinobj.html#<API key>">00117</a> <span class="keywordtype">void</span> <a class="code" href="classwinobj.html#<API key>">setScale</a>(<span class="keywordtype">double</span> scx, <span class="keywordtype">double</span> scy){ <a name="l00118"></a>00118 <a class="code" href="classwinobj.html#<API key>">sx</a> = scx; <a name="l00119"></a>00119 <a class="code" href="classwinobj.html#<API key>">sy</a> = scy; <a name="l00120"></a>00120 } <a name="l00121"></a><a class="code" href="classwinobj.html#<API key>">00121</a> <span class="keywordtype">void</span> <a class="code" href="classwinobj.html#<API key>">setViewport</a>(<span class="keywordtype">int</span> xmin, <span class="keywordtype">int</span> xmax, <span class="keywordtype">int</span> ymin, <span class="keywordtype">int</span> ymax){ <a name="l00122"></a>00122 <a class="code" href="classwinobj.html#<API key>">vp</a>.<a class="code" href="structviewport.html#<API key>">xmin</a> = xmin; <a name="l00123"></a>00123 <a class="code" href="classwinobj.html#<API key>">vp</a>.<a class="code" href="structviewport.html#<API key>">xmax</a> = xmax; <a name="l00124"></a>00124 <a class="code" href="classwinobj.html#<API key>">vp</a>.<a class="code" href="structviewport.html#<API key>">ymin</a> = ymin; <a name="l00125"></a>00125 <a class="code" href="classwinobj.html#<API key>">vp</a>.<a class="code" href="structviewport.html#<API key>">ymax</a> = ymax; <a name="l00126"></a>00126 wdCanvasViewport(<a class="code" href="classwinobj.html#<API key>">canvas</a>, <a class="code" href="classwinobj.html#<API key>">vp</a>.<a class="code" href="structviewport.html#<API key>">xmin</a>, <a class="code" href="classwinobj.html#<API key>">vp</a>.<a class="code" href="structviewport.html#<API key>">xmax</a>, <a class="code" href="classwinobj.html#<API key>">vp</a>.<a class="code" href="structviewport.html#<API key>">ymin</a>, <a class="code" href="classwinobj.html#<API key>">vp</a>.<a class="code" href="structviewport.html#<API key>">ymax</a>); <a name="l00127"></a>00127 } <a name="l00128"></a><a class="code" href="classwinobj.html#<API key>">00128</a> <a class="code" href="classroot.html">root</a> *<a class="code" href="classwinobj.html#<API key>">exp_obj</a>; <a name="l00129"></a><a class="code" href="classwinobj.html#<API key>">00129</a> <span class="keywordtype">char</span> *<a class="code" href="classwinobj.html#<API key>">exp_varname</a>; <a name="l00130"></a><a class="code" href="classwinobj.html#<API key>">00130</a> <span class="keywordtype">int</span> <a class="code" href="classwinobj.html#<API key>">exp_idx</a>; <a name="l00131"></a><a class="code" href="classwinobj.html#<API key>">00131</a> <span class="keywordtype">int</span> <a class="code" href="classwinobj.html#<API key>">exp_idx2</a>; <a name="l00132"></a><a class="code" href="classwinobj.html#<API key>">00132</a> <span class="keywordtype">char</span> *<a class="code" href="classwinobj.html#<API key>">title</a>; <a name="l00133"></a><a class="code" href="classwinobj.html#<API key>">00133</a> <span class="keywordtype">int</span> <a class="code" href="classwinobj.html#<API key>">cvtype</a>; <a name="l00134"></a><a class="code" href="classwinobj.html#<API key>">00134</a> cdCanvas *<a class="code" href="classwinobj.html#<API key>">canvas</a>; <a name="l00135"></a><a class="code" href="classwinobj.html#<API key>">00135</a> cdCanvas *<a class="code" href="classwinobj.html#<API key>">bcanvas</a>; <a name="l00136"></a><a class="code" href="classwinobj.html#<API key>">00136</a> cdImage *<a class="code" href="classwinobj.html#<API key>">simg</a>; <a name="l00137"></a><a class="code" href="classwinobj.html#<API key>">00137</a> <span class="keywordtype">bool</span> <a class="code" href="classwinobj.html#<API key>">canvas_mapped</a>; <a name="l00138"></a><a class="code" href="classwinobj.html#<API key>">00138</a> <span class="keywordtype">int</span> <a class="code" href="classwinobj.html#<API key>">drawoper</a>; <a name="l00139"></a><a class="code" href="classwinobj.html#<API key>">00139</a> <span class="keywordtype">int</span> <a class="code" href="classwinobj.html#<API key>">drawstyle</a>; <a name="l00140"></a><a class="code" href="classwinobj.html#<API key>">00140</a> <span class="keywordtype">int</span> <a class="code" href="classwinobj.html#<API key>">drawwidth</a>; <a name="l00141"></a><a class="code" href="classwinobj.html#<API key>">00141</a> <span class="keywordtype">int</span> <a class="code" href="classwinobj.html#<API key>">textoper</a>; <a name="l00142"></a><a class="code" href="classwinobj.html#<API key>">00142</a> <span class="keywordtype">char</span> *<a class="code" href="classwinobj.html#<API key>">texttypeface</a>; <a name="l00143"></a><a class="code" href="classwinobj.html#<API key>">00143</a> <span class="keywordtype">int</span> <a class="code" href="classwinobj.html#<API key>">textstyle</a>; <a name="l00144"></a><a class="code" href="classwinobj.html#<API key>">00144</a> <span class="keywordtype">void</span> *<a class="code" href="classwinobj.html#<API key>">textcolor</a>; <a name="l00145"></a><a class="code" href="classwinobj.html#<API key>">00145</a> <span class="keywordtype">void</span> *<a class="code" href="classwinobj.html#<API key>">bgcolor</a>; <a name="l00146"></a><a class="code" href="classwinobj.html#<API key>">00146</a> <span class="keywordtype">void</span> *<a class="code" href="classwinobj.html#<API key>">drawcolor</a>; <a name="l00147"></a><a class="code" href="classwinobj.html#<API key>">00147</a> <span class="keywordtype">int</span> <a class="code" href="classwinobj.html#<API key>">textsize</a>; <a name="l00148"></a><a class="code" href="classwinobj.html#<API key>">00148</a> <span class="keywordtype">int</span> <a class="code" href="classwinobj.html#<API key>">bgopacity</a>; <a name="l00149"></a><a class="code" href="classwinobj.html#<API key>">00149</a> <span class="keywordtype">int</span> width, height, xpos, ypos; <a name="l00150"></a><a class="code" href="classwinobj.html#<API key>">00150</a> <span class="keywordtype">int</span> usepoly, polytype, polystep; <a name="l00151"></a><a class="code" href="classwinobj.html#<API key>">00151</a> <span class="keywordtype">double</span> <a class="code" href="classwinobj.html#<API key>">sx</a>, <a class="code" href="classwinobj.html#<API key>">sy</a>; <a name="l00152"></a><a class="code" href="classwinobj.html#<API key>">00152</a> <span class="keywordtype">double</span> <a class="code" href="classwinobj.html#<API key>">xlast</a>, <a class="code" href="classwinobj.html#<API key>">ylast</a>; <a name="l00153"></a>00153 <span class="comment">//tolua_end</span> <a name="l00154"></a><a class="code" href="classwinobj.html#<API key>">00154</a> <span class="keyword">struct </span><a class="code" href="structviewport.html">viewport</a> <a class="code" href="classwinobj.html#<API key>">vp</a>; <a name="l00155"></a>00155 <span class="comment">//tolua_begin</span> <a name="l00156"></a>00156 }; <a name="l00157"></a>00157 <span class="comment">//tolua_end</span> <a name="l00158"></a>00158 <span class="preprocessor">#endif </span> </pre></div></div> <hr size="1"/><address style="text-align: right;"><small>Generated on Sun Feb 14 12:31:43 2010 for Luayats by&nbsp; <a href="http: <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> </body> </html>
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; using System.Windows.Data; using System.Windows.Controls.Primitives; using System.Reflection; using System.Windows.Threading; using System.ComponentModel; using System.Windows.Shapes; namespace MusicCollectionWPF.Infra { public class CustoSlider : Slider { private Canvas _Matrix; private Image _Cursor; private Popup _autoToolTip; private TextBlock _TB; private Line _B; private DispatcherTimer _Time; private int _ImobileCount=0; public event EventHandler<EventArgs> DragStarted; public event EventHandler<EventArgs> DragCompleted; public CustoSlider() : base() { NeedTP = false; _Time = new DispatcherTimer(); _Time.Interval = TimeSpan.FromMilliseconds(200); _Time.Tick += Tick; _Time.IsEnabled = false; } private void UpdateToolTip(double xp) { _TB.Text = AutoToolTipContent.Convert(ConvertToValue(xp), this.Minimum, this.Maximum); FrameworkElement ch = (this._autoToolTip.Child as FrameworkElement); bool force = false; if (ch.ActualWidth==0) { _TB.Visibility=Visibility.Hidden; _autoToolTip.IsOpen = true; force = true; } this._autoToolTip.HorizontalOffset = xp - ch.ActualWidth / 2; if (force) { _autoToolTip.IsOpen = false; _TB.Visibility = Visibility.Visible; } } private void UpdateToolTip(Point p) { UpdateToolTip(p.X); } private Point _Current; private void Tick(object s, EventArgs ea) { Point nCurrent = Mouse.GetPosition(_Matrix); if (nCurrent == _Current) { _ImobileCount++; if (_ImobileCount==3) OnImmobile(nCurrent); } else { _ImobileCount = 0; if (_autoToolTip.IsOpen) { UpdateToolTip(nCurrent); } } _Current = nCurrent; } private void OnImmobile(Point p) { if (!this.NeedTP) return; if (this._Trig) return; UpdateToolTip(p); _autoToolTip.IsOpen = true; } private void ME(object s, EventArgs ea) { _Time.IsEnabled = true; } private void ML(object s, MouseEventArgs ea) { _Time.IsEnabled = false; _autoToolTip.IsOpen = false; } private double ConvertToValue(double delta) { return Math.Min(this.Maximum, Math.Max(this.Minimum, this.Minimum + (delta * (this.Maximum - this.Minimum)) / _Matrix.ActualWidth)); } private double ConvertToRealValue(double delta) { return Math.Min(_Matrix.ActualWidth, Math.Max(0, delta)); } public double LineThickness { get { return (double)GetValue(<API key>); } set { SetValue(<API key>, value); } } public static readonly DependencyProperty <API key> = DependencyProperty.Register( "LineThickness", typeof(double), typeof(CustoSlider), new <API key>(2D)); public bool FillLineVisible { get { return (bool)GetValue(<API key>); } set { SetValue(<API key>, value); } } public static readonly DependencyProperty <API key> = DependencyProperty.Register( "TickLineBrush", typeof(Brush), typeof(CustoSlider)); public Brush TickLineBrush { get { return (Brush)GetValue(<API key>); } set { SetValue(<API key>, value); } } public static readonly DependencyProperty <API key> = DependencyProperty.Register( "FillLineVisible", typeof(bool), typeof(CustoSlider), new <API key>(false)); public <API key> AutoToolTipContent { get { return (<API key>)GetValue(<API key>); } set { SetValue(<API key>, value); } } public static readonly DependencyProperty <API key> = DependencyProperty.Register( "AutoToolTipContent", typeof(<API key>), typeof(CustoSlider), new <API key>(null, <API key>)); private static void <API key>(DependencyObject d, <API key> e) { CustoSlider cs = d as CustoSlider; cs.NeedTP = true; } public override void OnApplyTemplate() { base.OnApplyTemplate(); try { _Matrix = (Canvas)GetTemplateChild("Matrix"); this.MouseDown += Canvas_MouseDown; _Cursor = (Image)GetTemplateChild("Cursor"); _Cursor.<API key> += <API key>; _Cursor.MouseLeftButtonUp += Image_MouseUp; _Cursor.MouseMove += Image_MouseMove; _B = (Line)GetTemplateChild("Bar"); _B.MouseEnter += ME; _B.MouseLeave += ML; _autoToolTip = GetTemplateChild("AutoToolTip") as Popup; _TB = (TextBlock)GetTemplateChild("<API key>"); } catch (Exception) { } } protected override void OnRender(DrawingContext dc) { if (TickPlacement != TickPlacement.None) { Size size = new Size(base.ActualWidth, base.ActualHeight); double MidHeight = size.Height / 2; double BigCircle = size.Height / 5; double SmallCircle = (BigCircle * 2) / 3; dc.DrawEllipse(FillLineVisible? this.TickLineBrush: this.BorderBrush, new Pen(), new Point(10, MidHeight), BigCircle, BigCircle); dc.DrawEllipse(this.BorderBrush, new Pen(), new Point(size.Width + 10, MidHeight), BigCircle, BigCircle); int tickCount = (int)((this.Maximum - this.Minimum) / this.TickFrequency) -1; Double tickFrequencySize = (size.Width * this.TickFrequency / (this.Maximum - this.Minimum)); for (int i = 0; i <tickCount; i++) { dc.DrawEllipse(this.BorderBrush, new Pen(), new Point(10 + (i + 1) * tickFrequencySize, MidHeight), SmallCircle, SmallCircle); } } base.OnRender(dc); } private async void Canvas_MouseDown(object sender, <API key> e) { if (_Trig) return; Point p = Mouse.GetPosition(_Matrix); _autoToolTip.IsOpen = false; _Trig = true; var target = ConvertToValue(p.X); await this.SmoothSetAsync(ValueProperty, target, TimeSpan.FromSeconds(0.1)); Value = target; <API key>(new <API key>(0, 0, false)); if (DragCompleted != null) DragCompleted(this, new EventArgs()); _Trig = false; } private void Image_MouseMove(object sender, MouseEventArgs e) { if (!_Trig) return; OnThumbDragDelta(e); } private bool _Trig = false; private void <API key>(object sender, <API key> e) { _Cursor.CaptureMouse(); e.Handled = true; _Trig = true; _autoToolTip.IsOpen = false; OnThumbDragStarted(e); if (DragStarted != null) DragStarted(this, new EventArgs()); } private void Image_MouseUp(object sender, <API key> e) { if (!_Trig) return; _Cursor.ReleaseMouseCapture(); e.Handled = true; _Trig = false; <API key>(e); if (DragCompleted != null) DragCompleted(this, new EventArgs()); } private void OnThumbDragStarted(MouseEventArgs e) { if (NeedTP) { _autoToolTip.IsOpen = true; UpdateToolTip(e.GetPosition(_Matrix)); } } private void OnThumbDragDelta(MouseEventArgs e) { Point p = e.GetPosition(_Matrix); Value = ConvertToValue(p.X); if (NeedTP) { UpdateToolTip(e.GetPosition(_Matrix)); } } public bool InDrag { get{ return _Trig; } } private void <API key>(MouseEventArgs e) { Point p = e.GetPosition(_Matrix); Value = ConvertToValue(p.X); if (NeedTP) { _autoToolTip.IsOpen = false; } } private bool NeedTP { get; set; } protected void OnPropertyChanged(string pn) { if (PropertyChanged == null) return; PropertyChanged(this, new <API key>(pn)); } public event <API key> PropertyChanged; } }
// You can redistribute it and/or modify it under the terms of the GNU // $Id: Rotation_tree_2.h b33ab79 %aI Andreas Fabri // <API key>: GPL-3.0+ // Author(s) : Susan Hert <hert@mpi-sb.mpg.de> /* A rotation tree for computing the vertex visibility graph of a set of non-intersecting segments in the plane (e.g. edges of a polygon). Let $V$ be the set of segment endpoints and let $p_{\infinity}$ ($p_{-\infinity}$) be a point with $y$ coordinate $\infinity$ ($-\infinity$) and $x$ coordinate larger than all points in $V$. The tree $G$ is a tree with node set $V \cup \{p_{\infinity}, p_{-\infinity}\}$. Every node (except the one corresponding to $p_{\infinity}$) has exactly one outgoing edge to the point $q$ with the following property: $q$ is the first point encountered when looking from $p$ in direction $d$ and rotating counterclockwise. */ #ifndef <API key> #define <API key> #include <CGAL/disable_warnings.h> #include <CGAL/license/Partition_2.h> #include <CGAL/vector.h> #include <CGAL/Partition_2/<API key>.h> #include <boost/bind.hpp> namespace CGAL { template <class Traits_> class Rotation_tree_2 : public internal::vector< <API key><Traits_> > { public: typedef Traits_ Traits; typedef <API key><Traits> Node; typedef typename internal::vector<Node>::iterator Self_iterator; typedef typename Traits::Point_2 Point_2; using internal::vector< <API key><Traits_> >::push_back; class Greater { typename Traits::Less_xy_2 less; typedef typename Traits::Point_2 Point; public: Greater(typename Traits::Less_xy_2 less) : less(less) {} template <typename Point_like> bool operator()(const Point_like& p1, const Point_like& p2) { return less(Point(p2), Point(p1)); } }; // constructor template<class ForwardIterator> Rotation_tree_2(ForwardIterator first, ForwardIterator beyond) { for (ForwardIterator it = first; it != beyond; it++) push_back(*it); Greater greater (Traits().less_xy_2_object()); std::sort(this->begin(), this->end(), greater); std::unique(this->begin(), this->end()); // front() is the point with the largest x coordinate // push the point p_minus_infinity; the coordinates should never be used push_back(Point_2( 1, -1)); // push the point p_infinity; the coordinates should never be used push_back(Point_2(1, 1)); _p_inf = this->end(); // record the iterators to these extreme points _p_inf _p_minus_inf = _p_inf; _p_minus_inf Self_iterator child; // make p_minus_inf a child of p_inf set_rightmost_child(_p_minus_inf, _p_inf); child = this->begin(); // now points to p_0 while (child != _p_minus_inf) // make all points children of p_minus_inf { set_rightmost_child(child, _p_minus_inf); child++; } } // the point that comes first in the right-to-left ordering is first // in the ordering, after the auxilliary points p_minus_inf and p_inf Self_iterator rightmost_point_ref() { return this->begin(); } Self_iterator right_sibling(Self_iterator p) { if (!(*p).has_right_sibling()) return this->end(); return (*p).right_sibling(); } Self_iterator left_sibling(Self_iterator p) { if (!(*p).has_left_sibling()) return this->end(); return (*p).left_sibling(); } Self_iterator rightmost_child(Self_iterator p) { if (!(*p).has_children()) return this->end(); return (*p).rightmost_child(); } Self_iterator parent(Self_iterator p) { if (!(*p).has_parent()) return this->end(); return (*p).parent(); } bool <API key>(Self_iterator p) { return parent(p) == _p_inf; } bool <API key>(Self_iterator p) { return parent(p) == _p_minus_inf; } // makes *p the parent of *q void set_parent (Self_iterator p, Self_iterator q) { CGAL_assertion(q != this->end()); if (p == this->end()) (*q).clear_parent(); else (*q).set_parent(p); } // makes *p the rightmost child of *q void set_rightmost_child(Self_iterator p, Self_iterator q); // makes *p the left sibling of *q void set_left_sibling(Self_iterator p, Self_iterator q); // makes *p the right sibling of *q void set_right_sibling(Self_iterator p, Self_iterator q); // NOTE: this function does not actually remove the node p from the // list; it only reorganizes the pointers so this node is not // in the tree structure anymore void erase(Self_iterator p); private: Self_iterator _p_inf; Self_iterator _p_minus_inf; }; } #include <CGAL/Partition_2/<API key>.h> #include <CGAL/enable_warnings.h> #endif // <API key> // For the Emacs editor: // Local Variables: // c-basic-offset: 3 // End:
# This program is free software; you can redistribute it and/or modify # published by the Free Software Foundation. # This program is distributed in the hope that it will be useful, # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA use strict; use warnings; package EBox::Samba::CGI::EditUser; use base 'EBox::CGI::ClientPopupBase'; use EBox::Global; use EBox::Samba; use EBox::Samba::User; use EBox::Samba::Group; use EBox::Gettext; use EBox::Exceptions::External; sub new { my $class = shift; my $self = $class->SUPER::new('template' => '/samba/edituser.mas', @_); bless($self, $class); return $self; } sub _process { my ($self) = @_; my $global = EBox::Global->getInstance(); my $users = $global->modInstance('samba'); $self->{'title'} = __('Users'); my @args = (); $self->_requireParam('dn', 'dn'); my $dn = $self->unsafeParam('dn'); my $user = new EBox::Samba::User(dn => $dn); my $components = $users->allUserAddOns($user); my $usergroups = $user->groups(internal => 0, system => 1); my $remaingroups = $user->groupsNotIn(internal => 0, system => 1); my $editable = $users->editableMode(); push(@args, 'user' => $user); push(@args, 'usergroups' => $usergroups); push(@args, 'remaingroups' => $remaingroups); push(@args, 'components' => $components); push(@args, 'slave' => not $editable); $self->{params} = \@args; if ($self->param('edit')) { my $setText = undef; $self->{json} = { success => 0 }; $self->_requireParam('User_quota_selected'); my $quotaTypeSelected = $self->param('User_quota_selected'); my $quota; if ($quotaTypeSelected eq 'quota_disabled') { $quota = 0; } elsif ($quotaTypeSelected eq 'quota_size') { $quota = $self->param('User_quota_size'); } if (defined ($quota) and $user->hasValue('objectClass', 'systemQuotas')) { $user->set('quota', $quota, 1); } my $addMail; my $delMail; if ($editable) { $self-><API key>('givenname', __('first name')); $self-><API key>('surname', __('last name')); $self-><API key>('displayname', __('display name')); $self-><API key>('description', __('description')); $self-><API key>('mail', __('E-Mail')); $self-><API key>('password', __('password')); $self-><API key>('repassword', __('confirm password')); my $givenName = $self->param('givenname'); my $surname = $self->param('surname'); my $disabled = $self->param('disabled'); my $displayname = $self->unsafeParam('displayname'); if (length ($displayname)) { $user->set('displayName', $displayname, 1); $setText = $user->name() . " ($displayname)"; } else { $user->delete('displayName', 1); $setText = $user->name(); } my $description = $self->unsafeParam('description'); if (length ($description)) { $user->set('description', $description, 1); } else { $user->delete('description', 1); } my $mail = $self->unsafeParam('mail'); my $oldMail = $user->get('mail'); if ($mail) { $mail = lc $mail; if (not $oldMail) { $addMail = $mail; } elsif ($mail ne $oldMail) { $delMail = 1; $addMail = $mail; } } elsif ($oldMail) { $delMail = 1; } my $mailMod = $global->modInstance('mail'); if ($delMail) { if ($mailMod and $mailMod->configured()) { $mailMod-><API key>()->delUserAccount($user); } else { $user->delete('mail', 1); } } if ($addMail) { if ($mailMod and $mailMod->configured()) { $mailMod-><API key>()->setUserAccount($user, $addMail); } else { $user->checkMail($addMail); $user->set('mail', $addMail, 1); } } $user->set('givenname', $givenName, 1) if ($givenName); $user->set('sn', $surname, 1) if ($surname); $user->setDisabled($disabled, 1); # Change password if not empty my $password = $self->unsafeParam('password'); if ($password) { my $repassword = $self->unsafeParam('repassword'); if ($password ne $repassword){ throw EBox::Exceptions::External(__('Passwords do not match.')); } $user->changePassword($password, 1); } } $user->save(); $self->{json}->{success} = 1; $self->{json}->{msg} = __('User updated'); if ($setText) { $self->{json}->{set_text} = $setText; } if ($addMail) { $self->{json}->{mail} = $addMail; } elsif ($delMail) { $self->{json}->{mail} = ''; } } elsif ($self->param('addgrouptouser')) { $self->{json} = { success => 0 }; $self->_requireParam('addgroup', __('group')); my @groups = $self->unsafeParam('addgroup'); foreach my $gr (@groups) { my $group = new EBox::Samba::Group(samAccountName => $gr); $user->addGroup($group); } $self->{json}->{success} = 1; } elsif ($self->param('delgroupfromuser')) { $self->{json} = { success => 0 }; $self->_requireParam('delgroup', __('group')); my @groups = $self->unsafeParam('delgroup'); foreach my $gr (@groups){ my $group = new EBox::Samba::Group(samAccountName => $gr); $user->removeGroup($group); } $self->{json}->{success} = 1; } elsif ($self->param('groupInfo')) { $self->{json} = { success => 1, member => [ map { $_->name } @{ $usergroups }], noMember => [ map { $_->name } @{ $remaingroups }], }; } } 1;
/* Ittiam 802.11 MAC SOFTWARE */ /* ITTIAM SYSTEMS PVT LTD, BANGALORE */ /* agreement. It may not be copied or otherwise reproduced or disclosed to */ /* terms and conditions of such an agreement. All copies and */ /* reproductions shall be the property of Ittiam Systems Private Limited and*/ /* must bear this notice in its entirety. */ /* File Name : common.c */ /* Description : This file contains the functions used by both AP/STA */ /* modes in MAC. */ /* List of Functions : set_dscr_fn */ /* get_dscr_fn */ /* Issues / Problems : None */ /* File Includes */ #include "common.h" #include "mh.h" #include "csl_linux.h" #include "trout_share_mem.h" #ifdef <API key> #include "mh_test.h" #endif /* <API key> */ /* Global Variables */ UWORD32 g_calib_cnt = DEFAULT_CALIB_COUNT; extern UWORD32 g_done_wifi_suspend; #ifdef DEBUG_MODE mac_stats_t g_mac_stats = {0}; reset_stats_t g_reset_stats = {0}; UWORD8 <API key> = 1; UWORD8 g_11n_print_stats = 0; #endif /* DEBUG_MODE */ #ifdef MEM_DEBUG_MODE mem_stats_t g_mem_stats = {0}; #endif /* MEM_DEBUG_MODE */ #ifdef <API key> #endif /* <API key> */ #ifdef <API key> /* Function Name : set_dscr_fn */ /* Description : This function modifies the packet descriptor with the */ /* new specified value. The descriptor field to be modified */ /* is specified by the descriptor offset and width */ /* Inputs : 1) Offset of the descriptor field */ /* 2) Width of the descriptor field */ /* 3) Pointer to the packet descriptor to be modified */ /* 4) The new value for the descriptor field */ /* Globals : None */ /* Processing : Modifies the specified descriptor with the supplied */ /* value. */ /* Outputs : None */ /* Returns : None */ /* Issues : None */ void set_dscr_fn(UWORD8 offset, UWORD16 width, UWORD32 *ptr, UWORD32 value) { UWORD32 mask_inverse = 0; UWORD32 mask = 0; UWORD32 temp = 0; UWORD32 shift_offset = 32 - width - offset; #ifdef DEBUG_MODE if((width + offset) > 32) { /* Signal Erroneous input */ } #endif /* DEBUG_MODE */ /* Calculate the inverse of the Mask */ if(width < 32) mask_inverse = ((1 << width) - 1) << shift_offset; else mask_inverse = 0xFFFFFFFF; /* Generate the mask */ mask = ~mask_inverse; /* Read the descriptor word in little endian format */ temp = convert_to_le(*ptr); /* Updating the value of the descriptor field with the help of masks */ temp = ((value << shift_offset) & mask_inverse) | (temp & mask); /* Swap the byte order in the word if required for endian-ness change */ *ptr = convert_to_le(temp); } /* Function Name : get_dscr_fn */ /* Description : This function reads a word32 location to extract a */ /* specified descriptor field.of specified width. */ /* Inputs : 1) Offset of the descriptor field in the 32 bit boundary */ /* 2) Width of the desired descriptor field */ /* 3) Pointer to the word32 location of the field */ /* Globals : None */ /* Processing : Reads the descriptor for the specific field and returns */ /* the value. */ /* Outputs : None */ /* Returns : Descriptor field value */ /* Issues : None */ UWORD32 get_dscr_fn(UWORD8 offset, UWORD16 width, UWORD32 *ptr) { UWORD32 mask = 0; UWORD32 temp = 0; UWORD32 value = 0; UWORD32 shift_offset = 32 - width - offset; #ifdef DEBUG_MODE if((width + offset) > 32) { /* Signal Erroneous input */ } #endif /* DEBUG_MODE */ /* Calculate the Mask */ if(width < 32) mask = ((1 << width) - 1) << shift_offset; else mask = 0xFFFFFFFF; /* Swap the byte order in the word if required for endian-ness change */ temp = convert_to_le(*ptr); /* Obtain the value of the descriptor field with the help of masks */ value = (temp & mask) >> shift_offset; return value; } #endif /* <API key> */ #ifdef MWLAN /* Function Name : itm_memset */ /* Description : This function sets the specified number of bytes in the */ /* buffer to the required value. The functionality is */ /* similar to the standard memset function. The new */ /* implementation was required due to the bug seen when */ /* using memset function across the bridge on MWLAN. */ /* Inputs : 1) Pointer to the buffer. */ /* 2) Value of character to set */ /* 3) Number of characters to set. */ /* Globals : None */ /* Processing : */ /* Outputs : None */ /* Returns : Pointer to the buffer */ /* Issues : None */ void *itm_memset(void *buff, UWORD8 val, UWORD32 num) { UWORD8 *cbuff = (UWORD8 *)buff; if(num < 20) while(num *cbuff++ = val; else { UWORD32 *wbuff = NULL; UWORD32 wval = val; UWORD32 temp = 0; temp = (UWORD32)cbuff & 0x3; /* Unaligned buffer */ num -= temp; while(temp *cbuff++ = val; /* Word transfers */ wval += (wval << 8) + (wval << 16) + (wval << 24); wbuff = (UWORD32 *)cbuff; while(num > 3) { *wbuff++ = wval; num -= 4; } /* Unaligned length */ cbuff = (UWORD8 *)wbuff; while(num *cbuff++ = val; } return buff; } #endif /* MWLAN */ /* Function Name : <API key> */ /* Description : This function calibrates the delay loop counter using */ /* MAC H/w TSF Timer . */ /* Inputs : None */ /* Globals : g_calib_cnt */ /* Processing : MAC H/w version register is read a fixed number of times */ /* to introduce delay in S/w. This function calibrates this */ /* delay mechanism. It updates the global variable */ /* (g_calib_cnt) which holds the number of times the */ /* version register should be read to introduce a delay of */ /* 10us. */ /* Outputs : None */ /* Returns : None */ /* Issues : None */ void <API key>(void) { UWORD32 i = 0; UWORD32 entry_time = 0; UWORD32 exit_time = 0; BOOL_T pa_enabled = BFALSE; BOOL_T tbtt_mask = BFALSE; UWORD32 tsf_ctrl_bkup = 0; UWORD32 calib_thresh = 0; TROUT_FUNC_ENTER; /* Backup the registers which will be used for the calibration process */ pa_enabled = is_machw_enabled(); tbtt_mask = <API key>(); tsf_ctrl_bkup = get_machw_tsf_ctrl(); <API key>(); /* PA is disabled but TBTT Interrupts can still come. Mask it. */ <API key>(); mask_machw_tbtt_int(); set_machw_tsf_start(); <API key>(); /* Initialize Calibration Parameters */ calib_thresh = 1000; entry_time = <API key>(); for(i = 0; i < calib_thresh; i++) { GET_TIME(); } exit_time = <API key>(); /* Restore the Backed-up registers */ if(pa_enabled == BTRUE) <API key>(); if(tbtt_mask == BFALSE) <API key>(); set_machw_tsf_ctrl(tsf_ctrl_bkup); <API key>(); /* The Delay Calibration Count is computed to provide a delay of 10us */ if(exit_time > entry_time) g_calib_cnt = ((calib_thresh+2)*10)/(<API key>) + 1; TROUT_DBG4("Delay Calibration: Cnt=%d Delay=%d Calib_Cnt=%d\n",calib_thresh+2, (<API key>), g_calib_cnt); TROUT_FUNC_EXIT; } #ifdef COMBO_SCAN void <API key>(void) { UWORD32 i = 0; UWORD32 entry_time = 0; UWORD32 exit_time = 0; BOOL_T pa_enabled = BFALSE; BOOL_T tbtt_mask = BFALSE; UWORD32 tsf_ctrl_bkup = 0; UWORD32 calib_thresh = 0; TROUT_FUNC_ENTER; /* Backup the registers which will be used for the calibration process */ pa_enabled = is_machw_enabled(); tbtt_mask = <API key>(); tsf_ctrl_bkup = get_machw_tsf_ctrl(); <API key>(); /* PA is disabled but TBTT Interrupts can still come. Mask it. */ <API key>(); mask_machw_tbtt_int(); set_machw_tsf_start(); <API key>(); /* Initialize Calibration Parameters */ calib_thresh = 1000; entry_time = <API key>(); for(i = 0; i < calib_thresh; i++) { GET_TIME(); } exit_time = <API key>(); /* Restore the Backed-up registers */ if(pa_enabled == BTRUE) <API key>(); if(tbtt_mask == BFALSE) <API key>(); set_machw_tsf_ctrl(tsf_ctrl_bkup); <API key>(); /* The Delay Calibration Count is computed to provide a delay of 10us */ //if(exit_time > entry_time) //g_calib_cnt = ((calib_thresh+2)*10)/(<API key>) + 1; //TROUT_DBG4("Delay Calibration: Cnt=%d Delay=%d Calib_Cnt=%d\n",calib_thresh+2, //(<API key>), g_calib_cnt); TROUT_FUNC_EXIT; } #endif /* Function Name : add_calib_delay */ /* Description : This function provides a minimum S/w delay of the */ /* required time specified in units of 10us */ /* Inputs : 1) The required delay in units of 10us. i.e. Input 10 */ /* will provide a delay of 100us */ /* Globals : g_calib_cnt */ /* Processing : The MAC H/w version number is read continuously for a */ /* precomputed number of times to provide the required */ /* delay. */ /* Outputs : None */ /* Returns : None */ /* Issues : None */ void add_calib_delay(UWORD32 delay) { UWORD32 i = 0; // UWORD32 j = 0; UWORD32 delay_thresh = g_calib_cnt * delay; for(i = 0; i < delay_thresh; i++) //j += get_machw_pa_ver(); //j += (*(volatile UWORD32 *)<API key>); //add by chengq. GET_TIME(); } #ifdef DEBUG_MODE void <API key>(void) { UWORD32 idx = 0; PRINTK("BA Frames Rxd = %d\n\r", g_mac_stats.babarxd); PRINTK("BAR Frames successfully Txd = %d\n\r", g_mac_stats.babartxd); PRINTK("BAR Frames Rxd = %d\n\r", g_mac_stats.babarrxd); PRINTK("Data Frames retransmitted = %d\n\r", g_mac_stats.badatretx); PRINTK("Times Window is moved = %d\n\r", g_mac_stats.bawinmove); PRINTK("BAR Tx-Failures = %d\n\r", g_mac_stats.babarfail); PRINTK("Data Tx-Failures = %d\n\r", g_mac_stats.badatfail); PRINTK("Missing Buffers = %d\n\r", g_mac_stats.babufmiss); PRINTK("Frames deleted during Buffer cleanup = %d\n\r", g_mac_stats.badatclnup); PRINTK("Pending Frames discarded = %d\n\r", g_mac_stats.bapenddrop); PRINTK("Frames Txd from the Pending Q = %d\n\r", g_mac_stats.bapendingtxwlantxd); PRINTK("Stale BA frames received = %d\n\r", g_mac_stats.baoldbarxd); PRINTK("Stale BA frames received = %d\n\r", g_mac_stats.baoldbarrxd); PRINTK("Frames received out of window and hence droped = %d\n\r",g_mac_stats.barxdatoutwin); PRINTK("Re-queue failures = %d\n\r", g_mac_stats.bartrqfail); PRINTK("Number of blocks Qed = %d\n\r", g_mac_stats.banumblks); PRINTK("Number of Frames Qed = %d\n\r", g_mac_stats.banumqed); PRINTK("Number of times the pending Q was empty while enqueing = %d\n\r",g_mac_stats.baemptyQ); PRINTK("Num of times grp=%d\n\r", g_mac_stats.num_buffto); PRINTK("ba_num_dq=%d\n\r", g_mac_stats.ba_num_dq); PRINTK("ba_num_dqed=%d\n\r", g_mac_stats.ba_num_dqed); PRINTK("batxfba=%d\n\r", g_mac_stats.batxfba); for(idx = 0; idx < 10; idx++) PRINTK("batemp[%d] = %d\n\r", idx, g_mac_stats.batemp[idx]); } UWORD8 print_mem_stats(void) { UWORD8 print_flag = 0; #ifdef MEM_DEBUG_MODE print_flag |= printe("nosizeallocexc", g_mem_stats.nosizeallocexc); print_flag |= printe("nofreeallocexc", g_mem_stats.nofreeallocexc); print_flag |= printe("reallocexc", g_mem_stats.reallocexc); print_flag |= printe("corruptallocexc", g_mem_stats.corruptallocexc); print_flag |= printe("nullfreeexc", g_mem_stats.nullfreeexc); print_flag |= printe("oobfreeexc", g_mem_stats.oobfreeexc); print_flag |= printe("refreeexc", g_mem_stats.refreeexc); print_flag |= printe("corruptfreeexc", g_mem_stats.corruptfreeexc); print_flag |= printe("invalidfreeexc", g_mem_stats.invalidfreeexc); print_flag |= printe("excessfreeexc", g_mem_stats.excessfreeexc); print_flag |= printe("nulladdexc", g_mem_stats.nulladdexc); print_flag |= printe("oobaddexc", g_mem_stats.oobaddexc); print_flag |= printe("freeaddexc", g_mem_stats.freeaddexc); print_flag |= printe("invalidaddexc", g_mem_stats.invalidaddexc); print_flag |= printe("excessaddexc", g_mem_stats.excessaddexc); print_flag |= printe("nofreeDscrallocexc[0]", g_mem_stats.nofreeDscrallocexc[0]); print_flag |= printe("nofreeDscrallocexc[1]", g_mem_stats.nofreeDscrallocexc[1]); print_flag |= printe("nofreePktallocexc[0]", g_mem_stats.nofreePktallocexc[0]); print_flag |= printe("nofreePktallocexc[1]", g_mem_stats.nofreePktallocexc[1]); print_flag |= printe("nofreePktallocexc[2]", g_mem_stats.nofreePktallocexc[2]); print_flag |= printe("nofreePktallocexc[3]", g_mem_stats.nofreePktallocexc[3]); print_flag |= printe("nofreePktallocexc[4]", g_mem_stats.nofreePktallocexc[4]); print_flag |= printe("nofreeLocalallocexc[0]", g_mem_stats.nofreeLocalallocexc[0]); print_flag |= printe("nofreeLocalallocexc[1]", g_mem_stats.nofreeLocalallocexc[1]); print_flag |= printe("nofreeLocalallocexc[2]", g_mem_stats.nofreeLocalallocexc[2]); print_flag |= printe("nofreeLocalallocexc[3]", g_mem_stats.nofreeLocalallocexc[3]); print_flag |= printe("nofreeLocalallocexc[4]", g_mem_stats.nofreeLocalallocexc[4]); print_flag |= printe("nofreeLocalallocexc[5]", g_mem_stats.nofreeLocalallocexc[5]); print_flag |= printe("nofreeLocalallocexc[6]", g_mem_stats.nofreeLocalallocexc[6]); print_flag |= printe("nofreeLocalallocexc[7]", g_mem_stats.nofreeLocalallocexc[7]); print_flag |= printe("nofreeEventallocexc", g_mem_stats.nofreeEventallocexc); /* Print the size of the maximum Shared memory used and reset it after that */ PRINTK("Max Scratch Memory Utilized = %d", <API key>()); <API key>(); #endif /* MEM_DEBUG_MODE */ return print_flag; } void print_debug_stats(void) { UWORD8 i = 0; #ifdef MEM_DEBUG_MODE PRINTK("Memory Statistics\n\r"); PRINTK("sdalloc = %d\n\r",g_mem_stats.sdalloc); PRINTK("sdfree = %d\n\r",g_mem_stats.sdfree); PRINTK("sdtotalfree = %d\n\r",g_mem_stats.sdtotalfree); PRINTK("spalloc = %d\n\r",g_mem_stats.spalloc); PRINTK("spfree = %d\n\r",g_mem_stats.spfree); PRINTK("sptotalfree = %d\n\r",g_mem_stats.sptotalfree); PRINTK("lalloc = %d\n\r",g_mem_stats.lalloc); PRINTK("lfree = %d\n\r",g_mem_stats.lfree); PRINTK("ltotalfree = %d\n\r",g_mem_stats.ltotalfree); PRINTK("ealloc = %d\n\r",g_mem_stats.ealloc); PRINTK("efree = %d\n\r",g_mem_stats.efree); PRINTK("etotalfree = %d\n\r",g_mem_stats.etotalfree); PRINTK("nosizeallocexc = %d\n\r",g_mem_stats.nosizeallocexc); PRINTK("nofreeallocexc = %d\n\r",g_mem_stats.nofreeallocexc); PRINTK("reallocexc = %d\n\r",g_mem_stats.reallocexc); PRINTK("corruptallocexc = %d\n\r",g_mem_stats.corruptallocexc); PRINTK("nullfreeexc = %d\n\r",g_mem_stats.nullfreeexc); PRINTK("oobfreeexc = %d\n\r",g_mem_stats.oobfreeexc); PRINTK("refreeexc = %d\n\r",g_mem_stats.refreeexc); PRINTK("corruptfreeexc = %d\n\r",g_mem_stats.corruptfreeexc); PRINTK("invalidfreeexc = %d\n\r",g_mem_stats.invalidfreeexc); PRINTK("excessfreeexc = %d\n\r",g_mem_stats.excessfreeexc); PRINTK("nulladdexc = %d\n\r",g_mem_stats.nulladdexc); PRINTK("oobaddexc = %d\n\r",g_mem_stats.oobaddexc); PRINTK("freeaddexc = %d\n\r",g_mem_stats.freeaddexc); PRINTK("invalidaddexc = %d\n\r",g_mem_stats.invalidaddexc); PRINTK("excessaddexc = %d\n\r",g_mem_stats.excessaddexc); PRINTK("nofreeDscrallocexc[0] = %d\n\r",g_mem_stats.nofreeDscrallocexc[0]); PRINTK("nofreeDscrallocexc[1] = %d\n\r",g_mem_stats.nofreeDscrallocexc[1]); for(i = 0; i < 5; i++) PRINTK("nofreePktallocexc[%d] = %d\n\r",i, g_mem_stats.nofreePktallocexc[i]); for(i = 0; i < 8; i++) PRINTK("nofreeLocalallocexc[%d] = %d\n\r",i, g_mem_stats.nofreeLocalallocexc[i]); PRINTK("nofreeEventallocexc = %d\n\r", g_mem_stats.nofreeEventallocexc); #endif /* MEM_DEBUG_MODE */ PRINTK("\nMAC Statistics\n\r"); #ifndef <API key> PRINTK("itbtt = %d\n\r",g_mac_stats.itbtt); PRINTK("itxc = %d\n\r",g_mac_stats.itxc); PRINTK("irxc = %d\n\r",g_mac_stats.irxc); PRINTK("ihprxc = %d\n\r",g_mac_stats.ihprxc); PRINTK("ierr = %d\n\r",g_mac_stats.ierr); PRINTK("ideauth = %d\n\r",g_mac_stats.ideauth); PRINTK("icapend = %d\n\r",g_mac_stats.icapend); PRINTK("enpmsdu = %d\n\r",g_mac_stats.enpmsdu); PRINTK("erxqemp = %d\n\r",g_mac_stats.erxqemp); PRINTK("etxsus1machang = %d\n\r",g_mac_stats.etxsus1machang); PRINTK("etxsus1phyhang = %d\n\r",g_mac_stats.etxsus1phyhang); PRINTK("etxsus3 = %d\n\r",g_mac_stats.etxsus3); PRINTK("ebus = %d\n\r",g_mac_stats.ebus); PRINTK("ebwrsig = %d\n\r",g_mac_stats.ebwrsig); PRINTK("emsaddr = %d\n\r",g_mac_stats.emsaddr); PRINTK("etxfifo = %d\n\r",g_mac_stats.etxfifo); PRINTK("erxfifo = %d\n\r",g_mac_stats.erxfifo); PRINTK("ehprxfifo = %d\n\r",g_mac_stats.ehprxfifo); PRINTK("etxqempt = %d\n\r",g_mac_stats.etxqempt); PRINTK("edmanoerr = %d\n\r",g_mac_stats.edmanoerr); PRINTK("etxcenr = %d\n\r",g_mac_stats.etxcenr); PRINTK("erxcenr = %d\n\r",g_mac_stats.erxcenr); PRINTK("esgaf = %d\n\r",g_mac_stats.esgaf); PRINTK("eother = %d\n\r",g_mac_stats.eother); PRINTK("qatxp = %d\n\r",g_mac_stats.qatxp); PRINTK("qdtxp = %d\n\r",g_mac_stats.qdtxp); #else /* <API key> */ PRINTK("rxci = %d\n\r",g_test_stats.rxci); PRINTK("hprxci = %d\n\r",g_test_stats.hprxci); PRINTK("txci = %d\n\r",g_test_stats.txci); PRINTK("tbtti = %d\n\r",g_test_stats.tbtti); PRINTK("erri = %d\n\r",g_test_stats.erri); PRINTK("capei = %d\n\r",g_test_stats.capei); PRINTK("uki = %d\n\r",g_test_stats.uki); PRINTK("err.enpmsdu = %d\n\r",g_test_stats.exp.enpmsdu); PRINTK("err.erxqemp = %d\n\r",g_test_stats.exp.erxqemp); PRINTK("err.emsaddr = %d\n\r",g_test_stats.exp.emsaddr); PRINTK("err.etxsus1machang = %d\n\r",g_test_stats.exp.etxsus1machang); PRINTK("err.etxsus1phyhang = %d\n\r",g_test_stats.exp.etxsus1phyhang); PRINTK("err.etxsus3 = %d\n\r",g_test_stats.exp.etxsus3); PRINTK("err.ebus = %d\n\r",g_test_stats.exp.ebus); PRINTK("err.ebwrsig = %d\n\r",g_test_stats.exp.ebwrsig); PRINTK("err.etxqempt = %d\n\r",g_test_stats.exp.etxqempt); PRINTK("err.edmanoerr = %d\n\r",g_test_stats.exp.edmanoerr); PRINTK("err.etxcenr = %d\n\r",g_test_stats.exp.etxcenr); PRINTK("err.erxcenr = %d\n\r",g_test_stats.exp.erxcenr); PRINTK("err.esgaf = %d\n\r",g_test_stats.exp.esgaf); PRINTK("err.etxfifo = %d\n\r",g_test_stats.exp.etxfifo); PRINTK("err.erxfifo = %d\n\r",g_test_stats.exp.erxfifo); PRINTK("err.eother = %d\n\r",g_test_stats.exp.eother); #endif /* <API key> */ } void print_build_flags(void) { #ifdef ETHERNET_HOST PRINTK("ETHERNET_HOST\n\r"); #endif /* ETHERNET_HOST */ #ifdef GENERIC_HOST PRINTK("GENERIC_HOST\n\r"); #endif /* GENERIC_HOST */ #ifdef PHY_802_11n PRINTK("PHY_802_11n\n\r"); #endif /* PHY_802_11n */ #ifdef GENERIC_PHY PRINTK("GENERIC_PHY\n\r"); #endif /* GENERIC_PHY */ #ifdef ITTIAM_PHY PRINTK("ITTIAM_PHY\n\r"); #endif /* ITTIAM_PHY */ #ifdef <API key> PRINTK("<API key>\n\r"); #endif /* <API key> */ #ifdef <API key> PRINTK("<API key>\n\r"); #endif /* <API key> */ #ifdef <API key> PRINTK("<API key> \n\r"); #endif /* <API key> */ #ifdef MAC_802_11I PRINTK("MAC_802_11I \n\r"); #endif /* MAC_802_11I */ #ifdef SUPP_11I PRINTK("SUPP_11I \n\r"); #endif /* SUPP_11I */ #ifdef MAC_WMM PRINTK("MAC_WMM \n\r"); #endif /* MAC_WMM */ #ifdef MAC_802_11N PRINTK("MAC_802_11N \n\r"); #endif /* MAC_802_11N */ #ifdef MAC_802_1X PRINTK("MAC_802_1X \n\r"); #endif /* MAC_802_1X */ #ifdef MAC_802_11H PRINTK("MAC_802_11H \n\r"); #endif /* MAC_802_11H */ #ifdef GENERIC_RF PRINTK("GENERIC_RF\n\r"); #endif /* GENERIC_RF */ #ifdef RF_MAXIM_ITTIAM PRINTK("RF_MAXIM_ITTIAM \n\r"); #endif /* RF_MAXIM_ITTIAM */ // 20120709 caisf masked, merged ittiam mac v1.2 code #if 0 #ifdef RF_AIROHA_ITTIAM PRINTK("RF_AIROHA_ITTIAM \n\r"); #endif /* RF_AIROHA_ITTIAM */ #endif #ifdef MAX2829 PRINTK("MAX2829 \n\r"); #endif /* MAX2829 */ // 20120709 caisf masked, merged ittiam mac v1.2 code #if 0 #ifdef MAX2830_32 PRINTK("MAX2830_32 \n\r"); #endif /* MAX2830_32 */ #ifdef AL2236 PRINTK("AL2236 \n\r"); #endif /* AL2236 */ #ifdef AL7230 PRINTK("AL7230 \n\r"); #endif /* AL7230 */ #endif #ifdef MWLAN PRINTK("MWLAN \n\r"); #endif /* MWLAN */ #ifdef OS_LINUX_CSL_TYPE PRINTK("OS_LINUX_CSL_TYPE \n\r"); #endif /* OS_LINUX_CSL_TYPE */ #ifdef DEBUG_MODE PRINTK("DEBUG_MODE \n\r"); #endif /* DEBUG_MODE */ #ifdef USE_PROCESSOR_DMA PRINTK("USE_PROCESSOR_DMA \n\r"); #endif /* USE_PROCESSOR_DMA */ #ifdef EDCA_DEMO_KLUDGE PRINTK("EDCA_DEMO_KLUDGE \n\r"); #endif /* EDCA_DEMO_KLUDGE */ #ifdef LOCALMEM_TX_DSCR PRINTK("LOCALMEM_TX_DSCR \n\r"); #endif /* LOCALMEM_TX_DSCR */ #ifdef AUTORATE_FEATURE PRINTK("AUTORATE_FEATURE \n\r"); #endif /* AUTORATE_FEATURE */ #ifdef <API key> PRINTK("<API key> \n\r"); #endif /* <API key> */ #ifdef <API key> PRINTK("<API key> \n\r"); #endif /* <API key> */ #ifdef PHY_TEST_MAX_PKT_RX PRINTK("PHY_TEST_MAX_PKT_RX \n\r"); #endif /* PHY_TEST_MAX_PKT_RX */ #ifdef DEFAULT_SME PRINTK("DEFAULT_SME \n\r"); #endif /* DEFAULT_SME */ #ifdef NO_ACTION_RESET PRINTK("NO_ACTION_RESET \n\r"); #endif /* NO_ACTION_RESET */ #ifdef LITTLE_ENDIAN PRINTK("LITTLE_ENDIAN \n\r"); #endif /* LITTLE_ENDIAN */ #ifdef <API key> PRINTK("<API key> \n\r"); #endif /* <API key> */ #ifdef <API key> PRINTK("<API key> \n\r"); #endif /* <API key> */ #ifdef HANDLE_ERROR_INTR PRINTK("HANDLE_ERROR_INTR \n\r"); #endif /* HANDLE_ERROR_INTR */ #ifdef MEM_DEBUG_MODE PRINTK("MEM_DEBUG_MODE \n\r"); #endif /* MEM_DEBUG_MODE */ #ifdef <API key> PRINTK("<API key> \n\r"); #endif /* <API key> */ #ifdef TX_ABORT_FEATURE PRINTK("TX_ABORT_FEATURE \n\r"); #endif /* TX_ABORT_FEATURE */ } #endif /* DEBUG_MODE */ /*chenq add itm trace*/ /*flag of ShareMemInfo*/ int <API key> = 0; int <API key> = 0; int <API key> = 0; int <API key> = 0; int <API key> = 0; /*flag of MacTxRxStatistics*/ int <API key> = 0; int <API key> = 0; int <API key> = 0; int <API key> = 0; /*flag of SpiSdioDmaState*/ int <API key> = 0; int <API key> = 0; int <API key> = 0; /*flag of MacFsmMibState*/ int <API key> = 0; int <API key> = 0; int <API key> = 0; int <API key> = 0; int g_debug_print_ps_on = 0;//PowerSave int g_debug_print_wd_on = 0;//WiFi-Direct int <API key> = 0; /*flag of Host6820Info*/ //no add void <API key>(void) { /*flag of ShareMemInfo*/ <API key> = 0; <API key> = 0; <API key> = 0; <API key> = 0; <API key> = 0; /*flag of MacTxRxStatistics*/ <API key> = 0; <API key> = 0; <API key> = 0; <API key> = 0; /*flag of SpiSdioDmaState*/ <API key> = 0; <API key> = 0; <API key> = 0; /*flag of MacFsmMibState*/ <API key> = 0; <API key> = 0; <API key> = 0; <API key> = 0; g_debug_print_ps_on = 0;//PowerSave g_debug_print_wd_on = 0;//WiFi-Direct <API key> = 0; /*flag of Host6820Info*/ //no add } void ShareMemInfo(int type,int flag,int value,char * reserved2ext) { if(type == <API key>) { <API key> = value; } else if(type == <API key>) { <API key> = value; } else if(type == <API key>) { <API key> = value; } else if(type == <API key>) { <API key> = value; } else if(type == <API key>) { if(flag == counter_start) { <API key> = counter_start; } else if( ( flag == counter_end ) && ( <API key> == counter_end ) ) { /*printk("already in counter_end stat\n");*/ } else if( flag == counter_end ) { <API key> = counter_end; } } } void MacTxRxStatistics(int type,int flag,char * reserved2ext) { if(type == <API key>) { if(flag == counter_start) { <API key> = counter_start; } else if( ( flag == counter_end ) && ( <API key> == counter_end ) ) { /*printk("already in counter_end stat\n");*/ } else if( flag == counter_end ) { <API key> = counter_end; } } else if(type == <API key>) { if(flag == counter_start) { <API key> = counter_start; } else if( ( flag == counter_end ) && ( <API key> == counter_end ) ) { /*printk("already in counter_end stat\n");*/ } else if( flag == counter_end ) { <API key> = counter_end; } } else if(type == <API key>) { if(flag == counter_start) { <API key> = counter_start; } else if( ( flag == counter_end ) && ( <API key> == counter_end ) ) { /*printk("already in counter_end stat\n");*/ } else if( flag == counter_end ) { <API key> = counter_end; } } else if(type == <API key>) { if(flag == counter_start) { <API key> = counter_start; } else if( ( flag == counter_end ) && ( <API key> == counter_end ) ) { /*printk("already in counter_end stat\n");*/ } else if( flag == counter_end ) { <API key> = counter_end; } } } void SpiSdioDmaState(int type,int flag,int value,char * reserved2ext) { if(type == <API key>) { <API key> = value; } else if(type == <API key>) { <API key> = value; } else if(type == <API key>) { if(flag == counter_start) { <API key> = counter_start; } else if( ( flag == counter_end ) && ( <API key> == counter_end ) ) { /*printk("already in counter_end stat\n");*/ } else if( flag == counter_end ) { <API key> = counter_end; } } } void MacFsmMibState(int type,int value,char * reserved2ext) { if(type == <API key>) { <API key> = value; } else if(type == <API key>) { <API key> = value; } else if(type == <API key>) { <API key> = value; } else if(type == <API key>) { <API key> = value; } else if(type == <API key>)//PowerSave { g_debug_print_ps_on = value;//PowerSave } else if(type == <API key>)//WiFi-Direct { g_debug_print_wd_on = value;//WiFi-Direct } else if(type == <API key>) { <API key> = value; } else if(type == <API key>) { /*print ...*/ } else if(type == <API key>) { /*print ...*/ } else if(type == <API key>) { /*print ...*/ } } void Host6820Info(int type,char * reserved2ext) { } /*chenq add end*/ #ifdef <API key> inline void <API key>(uint msg, uint retry) { uint i = retry; uint count = host_read_trout_reg((UWORD32)<API key>) + 1; //#ifdef POWERSAVE_DEBUG pr_info("rSYSREG_POWER_CTRL: %x\n", host_read_trout_reg((UWORD32)rSYSREG_POWER_CTRL)); //#endif <API key>((UWORD32)msg, (UWORD32)<API key>); /*load message*/ <API key>((UWORD32)0x1, (UWORD32)<API key>); /*interrupt CP*/ /*pr_info("command done!\n");*/ /*wait for CP*/ while((host_read_trout_reg((UWORD32)<API key>) != count) && i msleep(10); //#ifdef POWERSAVE_DEBUG pr_info("Done! rSYSREG_POWER_CTRL: %x\n", host_read_trout_reg((UWORD32)rSYSREG_POWER_CTRL)); //#endif } pr_info("!!! rSYSREG_POWER_CTRL: %x, retry %d, i %d\n", host_read_trout_reg((UWORD32)rSYSREG_POWER_CTRL), retry, i); <API key>(0x0, (UWORD32)<API key>); /*clear message*/ if(msg == <API key>) g_done_wifi_suspend = 1; else if(msg == <API key>) g_done_wifi_suspend = 0; } EXPORT_SYMBOL(<API key>); extern int <API key>(UWORD8 psm, BOOL_T is_qos, UWORD8 priority); void <API key>(void) { uint which_frame = 0; uint sta = 0; uint vs; uint retry = 0; unsigned char tmp[200]; uint *pw = (uint *)&tmp[0]; which_frame = <API key>((UWORD32)<API key>); if(which_frame) sta = BEACON_MEM_BEGIN; else sta = BEACON_MEM_BEGIN + 200; <API key>((void *)tmp, (void *)sta, TX_DSCR_LEN); if(((tmp[3] >> 5) & 0x3) == 0x3){ goto retx; } if((tmp[20] & 0x3) != 0x3){ printk("SF0-CASUED\n"); goto retx; } /* arrive here, means the last frame ARM7 sent was success(AP acked) do nothing*/ return; retx: tmp[3] &= 0x9F; tmp[3] |= 0x20; tmp[20] &= 0xFC; vs = <API key>((UWORD32)rMAC_TSF_TIMER_LO); vs = (vs >> 10) & 0xFFFF; pw[3] &= 0xFFFF0000; pw[3] |= vs; printk("RE-TX\n"); <API key>((void *)sta, (void *)tmp, TX_DSCR_LEN); <API key>((UWORD32)sta, (UWORD32)<API key>); msleep(20); return; } /*for internal use only*/ inline void <API key>(uint msg, uint retry) { uint i = retry; uint count = <API key>((UWORD32)<API key>) + 1; #ifdef POWERSAVE_DEBUG pr_info("rSYSREG_POWER_CTRL: %x\n", <API key>((UWORD32)rSYSREG_POWER_CTRL)); /*pr_info("command %x\n", msg);*/ #endif <API key>((UWORD32)msg, (UWORD32)<API key>); /*load message*/ <API key>((UWORD32)0x1, (UWORD32)<API key>); /*interrupt CP*/ /*pr_info("command done!\n");*/ if((msg & 0xFFFF) == <API key>){ printk("EBEA.......\n"); msleep(75); <API key>(); } /*wait for CP*/ while((<API key>((UWORD32)<API key>) != count) && i msleep(10); #ifdef POWERSAVE_DEBUG pr_info("Done! rSYSREG_POWER_CTRL: %x\n", <API key>((UWORD32)rSYSREG_POWER_CTRL)); /*pr_info("expected %x, <API key> = %x\n", count, <API key>((UWORD32)<API key>));*/ #endif } pr_info("@@@ rSYSREG_POWER_CTRL: %x, retry %d, i %d\n", <API key>((UWORD32)rSYSREG_POWER_CTRL), retry, i); <API key>(0x0, (UWORD32)<API key>); /*clear message*/ if(msg == <API key>) g_done_wifi_suspend = 1; else if(msg == <API key>) g_done_wifi_suspend = 0; } #endif
#include "stdafx.h" #include "Emu/SysCalls/SysCalls.h" #include "Emu/SysCalls/SC_FUNC.h" #include "Emu/GS/GCM.h" void cellGcmSys_init(); void cellGcmSys_load(); void cellGcmSys_unload(); Module cellGcmSys(0x0010, cellGcmSys_init, cellGcmSys_load, cellGcmSys_unload); u32 local_size = 0; u32 local_addr = 0; enum { <API key> = 0x802100ff, <API key> = 0x80210001, <API key> = 0x80210002, <API key> = 0x80210003, <API key> = 0x80210004, <API key> = 0x80210005 }; // Function declaration int <API key>(mem_ptr_t<CellGcmContextData> ctxt, u32 id); // Memory Mapping struct gcm_offset { u64 io; u64 ea; }; void InitOffsetTable(); int32_t <API key>(u64 address, mem32_t offset); uint32_t <API key>(); void <API key>(mem_ptr_t<gcm_offset> table); int32_t <API key>(u32 ioOffset, u64 address); int32_t <API key>(const u32 ea, const u32 io, const u32 size); int32_t <API key>(const u32 ea, const u32 io, const u32 size, const u32 flags); int32_t <API key>(u64 ea, u32 size, mem32_t offset); int32_t <API key>(const u32 size); int32_t <API key>(u64 ea); int32_t <API key>(u64 io); int32_t <API key>(u32 size); CellGcmConfig current_config; CellGcmContextData current_context; gcmInfo gcm_info; u32 map_offset_addr = 0; u32 map_offset_pos = 0; // Data Retrieval u32 <API key>(u8 index) { cellGcmSys.Log("<API key>(index=%d)", index); return Memory.RSXCMDMem.GetStartAddr() + 0x10 * index; } u32 <API key>(u8 location, u32 index) { ConLog.Warning("<API key>(location=%d, index=%d)", location, index); return Emu.GetGSManager().GetRender().m_report_main_addr; } u64 cellGcmGetTimeStamp(u32 index) { cellGcmSys.Log("cellGcmGetTimeStamp(index=%d)", index); return Memory.Read64(Memory.RSXFBMem.GetStartAddr() + index * 0x10); } // Command Buffer Control u32 <API key>() { cellGcmSys.Log("<API key>()"); return gcm_info.control_addr; } u32 <API key>() { cellGcmSys.Warning("<API key>()"); return 0x400; } u32 <API key>() { cellGcmSys.Warning("<API key>()"); return 0x100; } int <API key>(s32 mode) { cellGcmSys.Warning("<API key>(mode=%d)", mode); return CELL_OK; } int <API key>(u32 bufferSize, u32 segmentSize) { cellGcmSys.Warning("<API key>(bufferSize=0x%x, segmentSize=0x%x)", bufferSize, segmentSize); return CELL_OK; } // Hardware Resource Management int cellGcmBindTile(u8 index) { cellGcmSys.Warning("cellGcmBindTile(index=%d)", index); if (index >= RSXThread::m_tiles_count) { return <API key>; } auto& tile = Emu.GetGSManager().GetRender().m_tiles[index]; tile.m_binded = true; return CELL_OK; } int cellGcmBindZcull(u8 index) { cellGcmSys.Warning("TODO: cellGcmBindZcull(index=%d)", index); return CELL_OK; } int <API key>(mem_ptr_t<CellGcmConfig> config) { cellGcmSys.Log("<API key>(config_addr=0x%x)", config.GetAddr()); if (!config.IsGood()) return CELL_EFAULT; *config = current_config; return CELL_OK; } int <API key>() { return Emu.GetGSManager().GetRender().m_flip_status; } u32 <API key>(u32 size) { //TODO cellGcmSys.Warning("<API key>(size=%d)", size); return size; } int cellGcmInit(u32 context_addr, u32 cmdSize, u32 ioSize, u32 ioAddress) { cellGcmSys.Warning("cellGcmInit(context_addr=0x%x,cmdSize=0x%x,ioSize=0x%x,ioAddress=0x%x)", context_addr, cmdSize, ioSize, ioAddress); if(!cellGcmSys.IsLoaded()) cellGcmSys.Load(); if(!local_size && !local_addr) { local_size = 0xf900000; //TODO local_addr = Memory.RSXFBMem.GetStartAddr(); Memory.RSXFBMem.AllocAlign(local_size); } cellGcmSys.Warning("*** local memory(addr=0x%x, size=0x%x)", local_addr, local_size); InitOffsetTable(); Memory.MemoryBlocks.push_back(Memory.RSXIOMem.SetRange(0x50000000, 0x10000000/*256MB*/));//TODO: implement allocateAdressSpace in memoryBase if(<API key>(ioAddress, 0, ioSize) != CELL_OK) { Memory.MemoryBlocks.pop_back(); return <API key>; } map_offset_addr = 0; map_offset_pos = 0; current_config.ioSize = ioSize; current_config.ioAddress = ioAddress; current_config.localSize = local_size; current_config.localAddress = local_addr; current_config.memoryFrequency = 650000000; current_config.coreFrequency = 500000000; Memory.RSXCMDMem.AllocAlign(cmdSize); u32 ctx_begin = ioAddress/* + 0x1000*/; u32 ctx_size = 0x6ffc; current_context.begin = ctx_begin; current_context.end = ctx_begin + ctx_size; current_context.current = current_context.begin; current_context.callback = Emu.GetRSXCallback() - 4; gcm_info.context_addr = Memory.MainMem.AllocAlign(0x1000); gcm_info.control_addr = gcm_info.context_addr + 0x40; Memory.WriteData(gcm_info.context_addr, current_context); Memory.Write32(context_addr, gcm_info.context_addr); CellGcmControl& ctrl = (CellGcmControl&)Memory[gcm_info.control_addr]; ctrl.put = 0; ctrl.get = 0; ctrl.ref = -1; auto& render = Emu.GetGSManager().GetRender(); render.m_ctxt_addr = context_addr; render.m_gcm_buffers_addr = Memory.Alloc(sizeof(gcmBuffer) * 8, sizeof(gcmBuffer)); render.m_zculls_addr = Memory.Alloc(sizeof(CellGcmZcullInfo) * 8, sizeof(CellGcmZcullInfo)); render.m_tiles_addr = Memory.Alloc(sizeof(CellGcmTileInfo) * 15, sizeof(CellGcmTileInfo)); render.m_gcm_buffers_count = 0; render.<API key> = 0; render.m_main_mem_addr = 0; render.Init(ctx_begin, ctx_size, gcm_info.control_addr, local_addr); return CELL_OK; } int <API key>() { Emu.GetGSManager().GetRender().m_flip_status = 1; return CELL_OK; } int <API key>(int level) { cellGcmSys.Warning("<API key>(level=%d)", level); switch (level) { case <API key>: case <API key>: case <API key>: Emu.GetGSManager().GetRender().m_debug_level = level; break; default: return CELL_EINVAL; } return CELL_OK; } int <API key>(u32 id, u32 offset, u32 pitch, u32 width, u32 height) { cellGcmSys.Warning("<API key>(id=0x%x,offset=0x%x,pitch=%d,width=%d,height=%d)", id, offset, width ? pitch/width : pitch, width, height); if(id > 7) return CELL_EINVAL; gcmBuffer* buffers = (gcmBuffer*)Memory.GetMemFromAddr(Emu.GetGSManager().GetRender().m_gcm_buffers_addr); buffers[id].offset = re(offset); buffers[id].pitch = re(pitch); buffers[id].width = re(width); buffers[id].height = re(height); if(id + 1 > Emu.GetGSManager().GetRender().m_gcm_buffers_count) { Emu.GetGSManager().GetRender().m_gcm_buffers_count = id + 1; } return CELL_OK; } int cellGcmSetFlip(mem_ptr_t<CellGcmContextData> ctxt, u32 id) { cellGcmSys.Log("cellGcmSetFlip(ctx=0x%x, id=0x%x)", ctxt.GetAddr(), id); int res = <API key>(ctxt, id); return res < 0 ? <API key> : CELL_OK; } int <API key>(u32 handler_addr) { cellGcmSys.Warning("<API key>(handler_addr=%d)", handler_addr); if (handler_addr != 0 && !Memory.IsGoodAddr(handler_addr)) { return CELL_EFAULT; } Emu.GetGSManager().GetRender().m_flip_handler.SetAddr(handler_addr); return CELL_OK; } int cellGcmSetFlipMode(u32 mode) { cellGcmSys.Warning("cellGcmSetFlipMode(mode=%d)", mode); switch (mode) { case <API key>: case <API key>: case <API key>: Emu.GetGSManager().GetRender().m_flip_mode = mode; break; default: return CELL_EINVAL; } return CELL_OK; } void <API key>() { cellGcmSys.Warning("<API key>()"); Emu.GetGSManager().GetRender().m_flip_status = 0; } int <API key>(mem_ptr_t<CellGcmContextData> ctxt, u32 id) { cellGcmSys.Log("<API key>(ctx=0x%x, id=0x%x)", ctxt.GetAddr(), id); if(id >= 8) { return <API key>; } GSLockCurrent gslock(GS_LOCK_WAIT_FLUSH); // could stall on exit u32 current = ctxt->current; u32 end = ctxt->end; if(current + 8 >= end) { ConLog.Warning("bad flip!"); //cellGcmCallback(ctxt.GetAddr(), current + 8 - end); //copied: CellGcmControl& ctrl = (CellGcmControl&)Memory[gcm_info.control_addr]; const s32 res = ctxt->current - ctxt->begin - ctrl.put; if(res > 0) Memory.Copy(ctxt->begin, ctxt->current - res, res); ctxt->current = ctxt->begin + res; ctrl.put = res; ctrl.get = 0; } current = ctxt->current; Memory.Write32(current, 0x3fead | (1 << 18)); Memory.Write32(current + 4, id); ctxt->current += 8; if(ctxt.GetAddr() == gcm_info.context_addr) { CellGcmControl& ctrl = (CellGcmControl&)Memory[gcm_info.control_addr]; ctrl.put += 8; } return id; } int <API key>(u32 freq) { cellGcmSys.Warning("<API key>(level=%d)", freq); switch (freq) { case <API key>: case <API key>: case <API key>: Emu.GetGSManager().GetRender().m_frequency_mode = freq; break; default: return CELL_EINVAL; } return CELL_OK; } int cellGcmSetTileInfo(u8 index, u8 location, u32 offset, u32 size, u32 pitch, u8 comp, u16 base, u8 bank) { cellGcmSys.Warning("cellGcmSetTileInfo(index=%d, location=%d, offset=%d, size=%d, pitch=%d, comp=%d, base=%d, bank=%d)", index, location, offset, size, pitch, comp, base, bank); if (index >= RSXThread::m_tiles_count || base >= 800 || bank >= 4) { return <API key>; } if (offset & 0xffff || size & 0xffff || pitch & 0xf) { return <API key>; } if (location >= 2 || (comp != 0 && (comp < 7 || comp > 12))) { return <API key>; } if (comp) { cellGcmSys.Error("cellGcmSetTileInfo: bad comp! (%d)", comp); } auto& tile = Emu.GetGSManager().GetRender().m_tiles[index]; tile.m_location = location; tile.m_offset = offset; tile.m_size = size; tile.m_pitch = pitch; tile.m_comp = comp; tile.m_base = base; tile.m_bank = bank; Memory.WriteData(Emu.GetGSManager().GetRender().m_tiles_addr + sizeof(CellGcmTileInfo)* index, tile.Pack()); return CELL_OK; } u32 <API key>(u32 handler) { cellGcmSys.Warning("<API key>(handler=0x%x)", handler); return handler; } int <API key>() { UNIMPLEMENTED_FUNC(cellGcmSys); return CELL_OK; } int cellGcmSetWaitFlip(mem_ptr_t<CellGcmContextData> ctxt) { cellGcmSys.Log("cellGcmSetWaitFlip(ctx=0x%x)", ctxt.GetAddr()); GSLockCurrent lock(GS_LOCK_WAIT_FLIP); return CELL_OK; } int cellGcmSetZcull(u8 index, u32 offset, u32 width, u32 height, u32 cullStart, u32 zFormat, u32 aaFormat, u32 zCullDir, u32 zCullFormat, u32 sFunc, u32 sRef, u32 sMask) { cellGcmSys.Warning("TODO: cellGcmSetZcull(index=%d, offset=0x%x, width=%d, height=%d, cullStart=0x%x, zFormat=0x%x, aaFormat=0x%x, zCullDir=0x%x, zCullFormat=0x%x, sFunc=0x%x, sRef=0x%x, sMask=0x%x)", index, offset, width, height, cullStart, zFormat, aaFormat, zCullDir, zCullFormat, sFunc, sRef, sMask); return CELL_OK; } int cellGcmUnbindTile(u8 index) { cellGcmSys.Warning("cellGcmUnbindTile(index=%d)", index); if (index >= RSXThread::m_tiles_count) { return <API key>; } auto& tile = Emu.GetGSManager().GetRender().m_tiles[index]; tile.m_binded = false; return CELL_OK; } int cellGcmUnbindZcull(u8 index) { cellGcmSys.Warning("cellGcmUnbindZcull(index=%d)", index); if (index >= 8) return CELL_EINVAL; return CELL_OK; } u32 cellGcmGetTileInfo() { cellGcmSys.Warning("cellGcmGetTileInfo()"); return Emu.GetGSManager().GetRender().m_tiles_addr; } u32 cellGcmGetZcullInfo() { cellGcmSys.Warning("cellGcmGetZcullInfo()"); return Emu.GetGSManager().GetRender().m_zculls_addr; } u32 <API key>() { cellGcmSys.Warning("<API key>() = 0x%x", Emu.GetGSManager().GetRender().m_gcm_buffers_addr); return Emu.GetGSManager().GetRender().m_gcm_buffers_addr; } int <API key>(u32 id_addr) { cellGcmSys.Warning("<API key>(id_addr=0x%x)", id_addr); if (!Memory.IsGoodAddr(id_addr)) { return CELL_EFAULT; } Memory.Write32(id_addr, Emu.GetGSManager().GetRender().<API key>); return CELL_OK; } // Memory Mapping gcm_offset offsetTable = { 0, 0 }; void InitOffsetTable() { offsetTable.io = Memory.Alloc(3072 * sizeof(u16), 1); for (int i = 0; i<3072; i++) { Memory.Write16(offsetTable.io + sizeof(u16)*i, 0xFFFF); } offsetTable.ea = Memory.Alloc(256 * sizeof(u16), 1);//TODO: check flags for (int i = 0; i<256; i++) { Memory.Write16(offsetTable.ea + sizeof(u16)*i, 0xFFFF); } } int32_t <API key>(u64 address, mem32_t offset) { cellGcmSys.Log("<API key>(address=0x%x,offset_addr=0x%x)", address, offset.GetAddr()); if (address >= 0xD0000000/*not on main memory or local*/) return <API key>; u32 result; // If address is in range of local memory if (Memory.RSXFBMem.IsInMyRange(address)) { result = address - Memory.RSXFBMem.GetStartAddr(); } // else check if the adress (main memory) is mapped in IO else { u16 upper12Bits = Memory.Read16(offsetTable.io + sizeof(u16)*(address >> 20)); if (upper12Bits != 0xFFFF) { result = (((u64)upper12Bits << 20) | (address & (0xFFFFF))); } // address is not mapped in IO else { return <API key>; } } offset = result; return CELL_OK; } uint32_t <API key>() { return Memory.RSXIOMem.GetEndAddr() - Memory.RSXIOMem.GetStartAddr() - Memory.RSXIOMem.GetReservedAmount(); } void <API key>(mem_ptr_t<gcm_offset> table) { table->io = re(offsetTable.io); table->ea = re(offsetTable.ea); } int32_t <API key>(u32 ioOffset, u64 address) { u64 realAddr; realAddr = Memory.RSXIOMem.getRealAddr(Memory.RSXIOMem.GetStartAddr() + ioOffset); if (!realAddr) return <API key>; Memory.Write64(address, realAddr); return CELL_OK; } int32_t <API key>(const u32 ea, const u32 io, const u32 size) { cellGcmSys.Warning("<API key>(ea=0x%x, io=0x%x, size=0x%x)", ea, io, size); if ((ea & 0xFFFFF) || (io & 0xFFFFF) || (size & 0xFFFFF)) return <API key>; //check if the mapping was successfull if (Memory.RSXIOMem.Map(ea, size, Memory.RSXIOMem.GetStartAddr() + io)) { //fill the offset table for (u32 i = 0; i<(size >> 20); i++) { Memory.Write16(offsetTable.io + ((ea >> 20) + i)*sizeof(u16), (io >> 20) + i); Memory.Write16(offsetTable.ea + ((io >> 20) + i)*sizeof(u16), (ea >> 20) + i); } } else { return <API key>; } return CELL_OK; } int32_t <API key>(const u32 ea, const u32 io, const u32 size, const u32 flags) { cellGcmSys.Warning("<API key>(ea=0x%x, io=0x%x, size=0x%x, flags=0x%x)", ea, io, size, flags); return <API key>(ea, io, size); // TODO: strict ordering } int32_t <API key>(u64 address, u64 size) { if (!local_size && !local_addr) { local_size = 0xf900000; //TODO local_addr = Memory.RSXFBMem.GetStartAddr(); Memory.RSXFBMem.AllocAlign(local_size); Memory.Write32(address, local_addr); Memory.Write32(size, local_size); } else { cellGcmSys.Error("RSX local memory already mapped"); return <API key>; } return CELL_OK; } int32_t <API key>(u64 ea, u32 size, mem32_t offset) { cellGcmSys.Warning("<API key>(ea=0x%x,size=0x%x,offset_addr=0x%x)", ea, size, offset.GetAddr()); u64 io; if ((ea & 0xFFFFF) || (size & 0xFFFFF)) return <API key>; //check if the mapping was successfull if (io = Memory.RSXIOMem.Map(ea, size, 0)) { // convert to offset io = io - Memory.RSXIOMem.GetStartAddr(); //fill the offset table for (u32 i = 0; i<(size >> 20); i++) { Memory.Write16(offsetTable.io + ((ea >> 20) + i)*sizeof(u16), (io >> 20) + i); Memory.Write16(offsetTable.ea + ((io >> 20) + i)*sizeof(u16), (ea >> 20) + i); } offset = io; } else { return <API key>; } Emu.GetGSManager().GetRender().m_main_mem_addr = Emu.GetGSManager().GetRender().m_ioAddress; return CELL_OK; } int32_t <API key>(const u32 size) { if (size & 0xFFFFF) return <API key>; if (size > <API key>()) return <API key>; Memory.RSXIOMem.Reserve(size); return CELL_OK; } int32_t <API key>(u64 ea) { u32 size = Memory.RSXIOMem.UnmapRealAddress(ea); if (size) { u64 io; ea = ea >> 20; io = Memory.Read16(offsetTable.io + (ea*sizeof(u16))); for (u32 i = 0; i<size; i++) { Memory.Write16(offsetTable.io + ((ea + i)*sizeof(u16)), 0xFFFF); Memory.Write16(offsetTable.ea + ((io + i)*sizeof(u16)), 0xFFFF); } } else { return <API key>; } return CELL_OK; } int32_t <API key>(u64 io) { u32 size = Memory.RSXIOMem.UnmapAddress(io); if (size) { u64 ea; io = io >> 20; ea = Memory.Read16(offsetTable.ea + (io*sizeof(u16))); for (u32 i = 0; i<size; i++) { Memory.Write16(offsetTable.io + ((ea + i)*sizeof(u16)), 0xFFFF); Memory.Write16(offsetTable.ea + ((io + i)*sizeof(u16)), 0xFFFF); } } else { return <API key>; } return CELL_OK; } int32_t <API key>(u32 size) { if (size & 0xFFFFF) return <API key>; if (size > Memory.RSXIOMem.GetReservedAmount()) return <API key>; Memory.RSXIOMem.Unreserve(size); return CELL_OK; } // Cursor int cellGcmInitCursor() { UNIMPLEMENTED_FUNC(cellGcmSys); return CELL_OK; } int <API key>(s32 x, s32 y) { UNIMPLEMENTED_FUNC(cellGcmSys); return CELL_OK; } int <API key>() { UNIMPLEMENTED_FUNC(cellGcmSys); return CELL_OK; } int cellGcmUpdateCursor() { UNIMPLEMENTED_FUNC(cellGcmSys); return CELL_OK; } int <API key>() { UNIMPLEMENTED_FUNC(cellGcmSys); return CELL_OK; } int <API key>(u32 offset) { UNIMPLEMENTED_FUNC(cellGcmSys); return CELL_OK; } // Functions for Maintaining Compatibility void <API key>() { cellGcmSys.Warning("<API key>()"); Memory.Write32(Emu.GetGSManager().GetRender().m_ctxt_addr, gcm_info.context_addr); } // Other int <API key>(u32 ctx, u32 id) { return <API key>(ctx, id); } s64 cellGcmFunc15() { cellGcmSys.Error("cellGcmFunc15()"); return 0; } int <API key>(u32 ctx, u32 id, u32 label_index, u32 label_value) { int res = <API key>(ctx, id); Memory.Write32(Memory.RSXCMDMem.GetStartAddr() + 0x10 * label_index, label_value); return res < 0 ? <API key> : CELL_OK; } int cellGcmSetTile(u8 index, u8 location, u32 offset, u32 size, u32 pitch, u8 comp, u16 base, u8 bank) { cellGcmSys.Warning("cellGcmSetTile(index=%d, location=%d, offset=%d, size=%d, pitch=%d, comp=%d, base=%d, bank=%d)", index, location, offset, size, pitch, comp, base, bank); // Copied form cellGcmSetTileInfo if(index >= RSXThread::m_tiles_count || base >= 800 || bank >= 4) { return <API key>; } if(offset & 0xffff || size & 0xffff || pitch & 0xf) { return <API key>; } if(location >= 2 || (comp != 0 && (comp < 7 || comp > 12))) { return <API key>; } if(comp) { cellGcmSys.Error("cellGcmSetTile: bad comp! (%d)", comp); } auto& tile = Emu.GetGSManager().GetRender().m_tiles[index]; tile.m_location = location; tile.m_offset = offset; tile.m_size = size; tile.m_pitch = pitch; tile.m_comp = comp; tile.m_base = base; tile.m_bank = bank; Memory.WriteData(Emu.GetGSManager().GetRender().m_tiles_addr + sizeof(CellGcmTileInfo) * index, tile.Pack()); return CELL_OK; } void cellGcmSys_init() { // Data Retrieval //cellGcmSys.AddFunc(0xc8f3bd09, <API key>); cellGcmSys.AddFunc(0xf80196c1, <API key>); //cellGcmSys.AddFunc(0x21cee035, <API key>); //cellGcmSys.AddFunc(0x99d397ac, cellGcmGetReport); //cellGcmSys.AddFunc(0x9a0159af, <API key>); cellGcmSys.AddFunc(0x8572bce2, <API key>); //cellGcmSys.AddFunc(0xa6b180ac, <API key>); cellGcmSys.AddFunc(0x5a41c10f, cellGcmGetTimeStamp); //cellGcmSys.AddFunc(0x2ad4951b, <API key>); // Command Buffer Control //cellGcmSys.AddFunc(, <API key>); //cellGcmSys.AddFunc(, cellGcmFinish); //cellGcmSys.AddFunc(, cellGcmFlush); cellGcmSys.AddFunc(0xa547adde, <API key>); cellGcmSys.AddFunc(0x5e2ee0f0, <API key>); cellGcmSys.AddFunc(0x8cdf8c70, <API key>); cellGcmSys.AddFunc(0xcaabd992, <API key>); //cellGcmSys.AddFunc(, <API key>); //cellGcmSys.AddFunc(, <API key>); cellGcmSys.AddFunc(0x9ba451e4, <API key>); //cellGcmSys.AddFunc(, <API key>); // Hardware Resource Management cellGcmSys.AddFunc(0x4524cccd, cellGcmBindTile); cellGcmSys.AddFunc(0x9dc04436, cellGcmBindZcull); //cellGcmSys.AddFunc(0x1f61b3ff, <API key>); cellGcmSys.AddFunc(0xe315a0b2, <API key>); //cellGcmSys.AddFunc(0x371674cf, <API key>); cellGcmSys.AddFunc(0x72a577ce, <API key>); //cellGcmSys.AddFunc(0x63387071, <API key>); //cellGcmSys.AddFunc(0x23ae55a3, <API key>); cellGcmSys.AddFunc(0x055bd74d, <API key>); //cellGcmSys.AddFunc(0x723bbc7e, <API key>); cellGcmSys.AddFunc(0x15bae46b, cellGcmInit); //cellGcmSys.AddFunc(0xfce9e764, <API key>); cellGcmSys.AddFunc(0xb2e761d4, <API key>); cellGcmSys.AddFunc(0x51c9d62b, <API key>); cellGcmSys.AddFunc(0xa53d12ae, <API key>); cellGcmSys.AddFunc(0xdc09357e, cellGcmSetFlip); cellGcmSys.AddFunc(0xa41ef7e8, <API key>); //cellGcmSys.AddFunc(0xacee8542, <API key>); cellGcmSys.AddFunc(0x4ae8d215, cellGcmSetFlipMode); cellGcmSys.AddFunc(0xa47c09ff, <API key>); //cellGcmSys.AddFunc(, <API key>); //cellGcmSys.AddFunc(0xd01b570d, <API key>); cellGcmSys.AddFunc(0x0b4b62d5, <API key>); //cellGcmSys.AddFunc(0x0a862772, <API key>); cellGcmSys.AddFunc(0x4d7ce993, <API key>); //cellGcmSys.AddFunc(0xdc494430, <API key>); cellGcmSys.AddFunc(0xbd100dbc, cellGcmSetTileInfo); cellGcmSys.AddFunc(0x06edea9e, <API key>); //cellGcmSys.AddFunc(0xffe0160e, <API key>); cellGcmSys.AddFunc(0xa91b0402, <API key>); cellGcmSys.AddFunc(0x983fb9aa, cellGcmSetWaitFlip); cellGcmSys.AddFunc(0xd34a420d, cellGcmSetZcull); //cellGcmSys.AddFunc(0x25b40ab4, <API key>); cellGcmSys.AddFunc(0xd9b7653e, cellGcmUnbindTile); cellGcmSys.AddFunc(0xa75640e8, cellGcmUnbindZcull); cellGcmSys.AddFunc(0x657571f7, cellGcmGetTileInfo); cellGcmSys.AddFunc(0xd9a0a879, cellGcmGetZcullInfo); cellGcmSys.AddFunc(0x0e6b0dae, <API key>); cellGcmSys.AddFunc(0x93806525, <API key>); // Memory Mapping cellGcmSys.AddFunc(0x21ac3697, <API key>); cellGcmSys.AddFunc(0xfb81c03e, <API key>); cellGcmSys.AddFunc(0x2922aed0, <API key>); cellGcmSys.AddFunc(0x2a6fba9c, <API key>); cellGcmSys.AddFunc(0x63441cb4, <API key>); cellGcmSys.AddFunc(0x626e8518, <API key>); cellGcmSys.AddFunc(0xdb769b32, <API key>); cellGcmSys.AddFunc(0xa114ec67, <API key>); cellGcmSys.AddFunc(0xa7ede268, <API key>); cellGcmSys.AddFunc(0xefd00f54, <API key>); cellGcmSys.AddFunc(0xdb23e867, <API key>); cellGcmSys.AddFunc(0x3b9bd5bd, <API key>); // Cursor cellGcmSys.AddFunc(0x107bf3a1, cellGcmInitCursor); cellGcmSys.AddFunc(0xc47d0812, <API key>); cellGcmSys.AddFunc(0x69c6cc82, <API key>); cellGcmSys.AddFunc(0xf9bfdc72, <API key>); cellGcmSys.AddFunc(0x1a0de550, <API key>); cellGcmSys.AddFunc(0xbd2fa0a7, cellGcmUpdateCursor); // Functions for Maintaining Compatibility //cellGcmSys.AddFunc(, <API key>); //cellGcmSys.AddFunc(, <API key>); cellGcmSys.AddFunc(0xbc982946, <API key>); //cellGcmSys.AddFunc(, <API key>); //cellGcmSys.AddFunc(, <API key>); // Other cellGcmSys.AddFunc(0x21397818, <API key>); cellGcmSys.AddFunc(0x3a33c1fd, cellGcmFunc15); cellGcmSys.AddFunc(0xd8f88e1a, <API key>); cellGcmSys.AddFunc(0xd0b1d189, cellGcmSetTile); } void cellGcmSys_load() { current_config.ioAddress = 0; current_config.localAddress = 0; local_size = 0; local_addr = 0; } void cellGcmSys_unload() { }
#!/bin/sh source /etc/scripts/functions.sh case $1 in deconfig) net_if_reset $interface dhcp ;; bound|renew) net_if_config $interface dhcp "$ip" "$subnet" "$router" "$dns" ;; esac
#!/usr/bin/env rspec require_relative "../../../test_helper" require "yaml" require "users/clients/auto" require "y2users/autoinst/reader" require "y2issues" Yast.import "Report" # defines exported users require_relative "../../../fixtures/users_export" describe Y2Users::Clients::Auto do let(:mode) { "autoinstallation" } let(:args) { [func] } before do allow(Yast).to receive(:import).and_call_original allow(Yast).to receive(:import).with("Ldap") allow(Yast).to receive(:import).with("LdapPopup") allow(Yast::Mode).to receive(:mode).and_return(mode) allow(Yast::Stage).to receive(:initial).and_return(true) allow(Yast::WFM).to receive(:Args).and_return(args) end describe "#run" do context "Import" do let(:func) { "Import" } let(:args) { [func, users] } context "when double users have been given in the profile" do let(:mode) { "normal" } let(:users) { YAML.load_file(FIXTURES_PATH.join("users_error.yml")) } it "report error" do allow(Yast::Stage).to receive(:initial).and_return(false) expect(Yast::Report).to receive(:Error) .with(_("Found users in profile with equal <username>.")) expect(Yast::Report).to receive(:Error) .with(_("Found users in profile with equal <uid>.")) expect(subject.run).to eq(true) end end context "when users without any UID are defined in the profile" do let(:users) { YAML.load_file(FIXTURES_PATH.join("users_no_error.yml")) } it "will not be checked for double UIDs" do expect(Yast::Report).not_to receive(:Error) .with(_("Found users in profile with equal <username>.")) expect(Yast::Report).not_to receive(:Error) .with(_("Found users in profile with equal <uid>.")) expect(subject.run).to eq(true) end end context "when root password linuxrc attribute is set" do before do allow(Yast::Linuxrc).to receive(:InstallInf).with("RootPassword").and_return("test") end context "when profile contain root password" do let(:users) { USERS_EXPORT } it "keeps root password from profile" do allow(Y2Issues).to receive(:report).and_return(true) # fixture contain dup uids expect(subject.run).to eq(true) config = Y2Users::ConfigManager.instance.target root_user = config.users.root expect(root_user.password.value.encrypted?).to eq true expect(root_user.password.value.content).to match(/^\$6\$AS/) end end context "when profile does not contain root password" do let(:users) { {} } it "sets root password to linuxrc value" do expect(subject.run).to eq(true) config = Y2Users::ConfigManager.instance.target root_user = config.users.root expect(root_user.password.value.encrypted?).to eq false expect(root_user.password.value.content).to eq "test" end end end context "when some issue is registered" do let(:users) { { "users" => [] } } let(:reader) { Y2Users::Autoinst::Reader.new(users) } let(:issues) { Y2Issues::List.new } let(:continue?) { true } let(:result) do Y2Users::ReadResult.new(Y2Users::Config.new, issues) end before do allow(Y2Users::Autoinst::Reader).to receive(:new).and_return(reader) allow(reader).to receive(:read).and_return(result) issues << Y2Issues::InvalidValue.new("dummy", location: nil) allow(Y2Issues).to receive(:report).and_return(continue?) end it "reports the issues" do expect(Y2Issues).to receive(:report).with(issues) subject.run end context "and the user wants to continue" do let(:continue?) { true } it "returns true" do expect(subject.run).to eq(true) end end context "and the user does not want to continue" do let(:continue?) { false } it "returns false" do expect(subject.run).to eq(false) end end end end context "Change" do let(:func) { "Change" } it "returns the 'summary' autosequence result" do expect(subject).to receive(:AutoSequence).and_return(:next) expect(subject.run).to eq(:next) end end context "Summary" do let(:func) { "Summary" } before do allow(Yast::Users).to receive(:Summary).and_return("summary") end it "returns the users summary" do expect(subject.run).to eq("summary") end end context "Export" do let(:func) { "Export" } let(:args) { [func] } let(:local_users) { double("local_users") } let(:all_users) { double("all_users") } before do allow(Yast::WFM).to receive(:Args).and_return(args) allow(Yast::Users).to receive(:Export).with("default") .and_return(all_users) allow(Yast::Users).to receive(:Export).with("compact") .and_return(local_users) end it "exports all users and groups" do expect(subject.run).to eq(all_users) end context "when 'compact' export is wanted" do let(:args) { [func, "target" => "compact"] } it "it exports only local users and groups" do expect(subject.run).to eq(local_users) end end end context "Modified" do let(:func) { "GetModified" } before do allow(Yast::Users).to receive(:Modified).and_return(true) end it "returns whether the data in Users module has been modified" do expect(subject.run).to eq(true) end end context "SetModified" do let(:func) { "SetModified" } it "sets the Users module as modified" do expect(Yast::Users).to receive(:SetModified).with(true) subject.run end end context "Reset" do let(:func) { "Reset" } it "removes the configuration object" do # reset is not called during installation allow(Yast::Stage).to receive(:initial).and_return(false) expect(Yast::Users).to receive(:Import).with({}) subject.run end end end end
cmd_kernel/sys_ni.o := /pub/CIS520/usr/arm/bin/<API key> -Wp,-MD,kernel/.sys_ni.o.d -nostdinc -isystem /net/files.cis.ksu.edu/exports/public/CIS520/usr/arm/bin/../lib/gcc/<API key>/4.3.3/include -Iinclude -I/net/files.cis.ksu.edu/exports/home/p/phen/cis520/android/Kernel/arch/arm/include -include include/linux/autoconf.h -D__KERNEL__ -mlittle-endian -Iarch/arm/mach-goldfish/include -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -<API key> -Os -marm -<API key> -mapcs -mno-sched-prolog -mabi=aapcs-linux -mno-thumb-interwork -D__LINUX_ARM_ARCH__=7 -march=armv7-a -msoft-float -Uarm -fno-stack-protector -<API key> -<API key> -<API key> -Wno-pointer-sign -fwrapv -D"KBUILD_STR(s)=\#s" -D"KBUILD_BASENAME=KBUILD_STR(sys_ni)" -D"KBUILD_MODNAME=KBUILD_STR(sys_ni)" -c -o kernel/sys_ni.o kernel/sys_ni.c deps_kernel/sys_ni.o := \ kernel/sys_ni.c \ include/linux/linkage.h \ include/linux/compiler.h \ $(wildcard include/config/trace/branch/profiling.h) \ $(wildcard include/config/profile/all/branches.h) \ $(wildcard include/config/enable/must/check.h) \ $(wildcard include/config/enable/warn/deprecated.h) \ include/linux/compiler-gcc.h \ $(wildcard include/config/arch/supports/optimized/inlining.h) \ $(wildcard include/config/optimize/inlining.h) \ include/linux/compiler-gcc4.h \ /net/files.cis.ksu.edu/exports/home/p/phen/cis520/android/Kernel/arch/arm/include/asm/linkage.h \ include/linux/errno.h \ /net/files.cis.ksu.edu/exports/home/p/phen/cis520/android/Kernel/arch/arm/include/asm/errno.h \ include/asm-generic/errno.h \ include/asm-generic/errno-base.h \ /net/files.cis.ksu.edu/exports/home/p/phen/cis520/android/Kernel/arch/arm/include/asm/unistd.h \ $(wildcard include/config/aeabi.h) \ $(wildcard include/config/oabi/compat.h) \ kernel/sys_ni.o: $(deps_kernel/sys_ni.o) $(deps_kernel/sys_ni.o):
using System; using Server.Engines.Craft; namespace Server.Items { public abstract class BaseRing : BaseJewel { public BaseRing(int itemID) : base(itemID, Layer.Ring) { } public BaseRing(Serial serial) : base(serial) { } public override int BaseGemTypeNumber { get { return 1044176; } }// star sapphire ring public override void Serialize(GenericWriter writer) { base.Serialize(writer); writer.Write((int)0); // version } public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); } } public class GoldRing : BaseRing { [Constructable] public GoldRing() : base(0x108a) { this.Weight = 0.1; } public GoldRing(Serial serial) : base(serial) { } public override void Serialize(GenericWriter writer) { base.Serialize(writer); writer.Write((int)0); // version } public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); } } public class SilverRing : BaseRing, IRepairable { public CraftSystem RepairSystem { get { return DefTinkering.CraftSystem; } } [Constructable] public SilverRing() : base(0x1F09) { this.Weight = 0.1; } public SilverRing(Serial serial) : base(serial) { } public override void Serialize(GenericWriter writer) { base.Serialize(writer); writer.Write((int)0); // version } public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); } } }
# plugins module for amsn2 """ Plugins with amsn2 will be a subclass of the aMSNPlugin() class. When this module is initially imported it should load the plugins from the last session. Done in the init() proc. Then the GUI should call plugins.loadPlugin(name) or plugins.unLoadPlugin(name) in order to deal with plugins. """ # init() # Called when the plugins module is imported (only for the first time). # Should find plugins and populate a list ready for getPlugins(). # Should also auto-update all plugins. def init(): pass # loadPlugin(plugin_name) # Called (by the GUI or from init()) to load a plugin. plugin_name as set in plugin's XML (or from getPlugins()). # This loads the module for the plugin. The module is then responsible for calling plugins.registerPlugin(instance). def loadPlugin(plugin_name): """ @type plugin_name: str """ pass # unLoadPlugin(plugin_name) # Called to unload a plugin. Name is name as set in plugin's XML. def unLoadPlugin(plugin_name): """ @type plugin_name: str """ pass # registerPlugin(plugin_instance) # Saves the instance of the plugin, and registers it in the loaded list. def registerPlugin(plugin_instance): """ @type plugin_instance: L{amsn2.plugins.developers.aMSNPlugin} """ pass # getPlugins() # Returns a list of all available plugins, as in ['Plugin 1', 'Plugin 2'] def getPlugins(): pass # <API key>() # Returns a list with a list item for each plugin with the plugin's name, and Loaded or NotLoaded either way. # IE: [['Plugin 1', 'Loaded'], ['Plugin 2', 'NotLoaded']] def <API key>(): pass # getLoadedPlugins() # Returns a list of loaded plugins. as in ['Plugin 1', 'Plugin N'] def getLoadedPlugins(): pass # findPlugin(plugin_name) # Retruns the running instance of the plugin with name plugin_name, or None if not found. def findPlugin(plugin_name): """ @type plugin_name: str """ pass # saveConfig(plugin_name, data) def saveConfig(plugin_name, data): """ @type plugin_name: str @type data: object """ pass # Calls the init procedure. # Will only be called on the first import (thanks to python). init()
<?php // Constants Definition define('POP_CDNWP_VERSION', 0.157); define('POP_CDNWP_DIR', dirname(__FILE__)); class PoP_CDNWP { public function __construct() { // Priority: after PoP Engine Web Platform \PoP\Root\App::addAction('plugins_loaded', array($this, 'init'), 888412); } public function init() { define('POP_CDNWP_URL', plugins_url('', __FILE__)); if ($this->validate()) { $this->initialize(); define('<API key>', true); } } public function validate() { return true; include_once 'validation.php'; $validation = new <API key>(); return $validation->validate(); } public function initialize() { include_once 'initialization.php'; $initialization = new <API key>(); return $initialization->initialize(); } } /** * Initialization */ new PoP_CDNWP();
# including the implied warranties of MERCHANTABILITY, # NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should # have received a copy of GPLv2 along with this software; if not, see # The Errata module contains methods that are common for supporting errata # in several controllers (e.g. <API key> and <API key>) module Katello module Util module Errata def filter_by_type(errata_list, filter_type) filtered_list = [] if filter_type != "All" pulp_filter_type = <API key>(filter_type) errata_list.each do |erratum| if erratum.respond_to?(:type) if erratum.type == pulp_filter_type filtered_list << erratum end else if erratum["type"] == pulp_filter_type filtered_list << erratum end end end else filtered_list = errata_list end return filtered_list end def <API key>(type) filter_type = type.downcase if filter_type == "bugfix" return Glue::Pulp::Errata::BUGZILLA elsif filter_type == "enhancement" return Glue::Pulp::Errata::ENHANCEMENT elsif filter_type == "security" return Glue::Pulp::Errata::SECURITY end end def filter_by_state(errata_list, errata_state) if errata_state == "applied" return [] else return errata_list end end end end end
define(["require", "exports"], function (require, exports) { "use strict"; exports.<API key> = <API key>; });
// RUN: %clang_cc1 %s -triple=<API key> -emit-llvm -o - | FileCheck %s // CHECK: ; ModuleID struct A { template<typename T> A(T); }; template<typename T> A::A(T) {} struct B { template<typename T> B(T); }; template<typename T> B::B(T) {} // CHECK: define void @_ZN1BC1IiEET_(%struct.B* %this, i32) // CHECK: define void @_ZN1BC2IiEET_(%struct.B* %this, i32) template B::B(int); template<typename T> struct C { void f() { int a[] = { 1, 2, 3 }; } }; void f(C<int>& c) { c.f(); }
#include <linux/module.h> #include <linux/init.h> #include <linux/firmware.h> #include <linux/slab.h> #include <linux/platform_device.h> #include <linux/device.h> #include <linux/printk.h> #include <linux/ratelimit.h> #include <linux/debugfs.h> #include <linux/wait.h> #include <linux/bitops.h> #include <linux/mfd/wcd9xxx/core.h> #include <linux/mfd/wcd9xxx/wcd9xxx_registers.h> #include <linux/mfd/wcd9xxx/wcd9330_registers.h> #include <linux/mfd/wcd9xxx/pdata.h> #include <linux/regulator/consumer.h> #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/soc.h> #include <sound/soc-dapm.h> #include <sound/tlv.h> #include <linux/delay.h> #include <linux/pm_runtime.h> #include <linux/kernel.h> #include <linux/gpio.h> #include <linux/clk.h> #include "wcd9330.h" #include "wcd9xxx-resmgr.h" #include "wcd9xxx-common.h" #include "wcdcal-hwdep.h" #include "wcd_cpe_core.h" enum { VI_SENSE_1, VI_SENSE_2, VI_SENSE_MAX, BUS_DOWN, ADC1_TXFE, ADC2_TXFE, ADC3_TXFE, ADC4_TXFE, ADC5_TXFE, ADC6_TXFE, }; #define <API key> 12 #define <API key> "wcd9320/wcd9320_mad_audio.bin" #define <API key>(port) ((port >= 16) && (port <= 23)) #define <API key>(port) ((port >= 0) && (port <= 15)) #define <API key>(port) (port - 16) /* RX1 port ID = 0 */ #define <API key> 4 #define <API key> 5 #define <API key> 5000 #define <API key> 13000 #define <API key> 30000 #define <API key> 0x20 #define <API key> 0x02 /* Add any SVA IRQs that are to be treated as FATAL */ #define <API key> \ (<API key> | \ <API key>) #define <API key> "MIC BIAS2 External Standalone" /* RX_HPH_CNP_WG_TIME increases by 0.24ms */ #define <API key> 240 #define <API key> 64 #define RX8_PATH 8 #define HPH_PA_ENABLE true #define HPH_PA_DISABLE false #define SLIM_BW_CLK_GEAR_9 6200000 #define SLIM_BW_UNVOTE 0 static int cpe_debug_mode; module_param(cpe_debug_mode, int, S_IRUGO | S_IWUSR | S_IWGRP); MODULE_PARM_DESC(cpe_debug_mode, "boot cpe in debug mode"); static atomic_t kp_tomtom_priv; static int high_perf_mode = 1; module_param(high_perf_mode, int, S_IRUGO | S_IWUSR | S_IWGRP); MODULE_PARM_DESC(high_perf_mode, "enable/disable class AB config for hph"); static struct <API key> <API key> = { .minor_version = 1, .slimbus_dev_id = <API key>, .slave_dev_pgd_la = 0, .<API key> = 0, .bit_width = 16, .data_format = 0, .num_channels = 1 }; static struct <API key> audio_reg_cfg[] = { { 1, (<API key> + <API key>), HW_MAD_AUDIO_ENABLE, 0x1, 8, 0 }, { 1, (<API key> + <API key>), <API key>, 0xF, 8, 0 }, { 1, (<API key> + <API key>), <API key>, 0x1, 8, 0 }, { 1, (<API key> + TOMTOM_A_INTR_MODE), <API key>, 0x4, 8, 0 }, { 1, (<API key> + <API key>), <API key>, 0x2, 8, 0 }, { 1, (<API key> + <API key>), <API key>, 0x2, 8, 0 }, { 1, (<API key> + <API key>), <API key>, 0x2, 8, 0 }, { 1, (<API key> + <API key>), <API key>, 0x1E, 8, 0x1 }, { 1, (<API key> + <API key>), <API key>, 0x1, 8, 0x1 }, { 1, (<API key> + <API key>), <API key>, 0x1E, 8, 0x1 }, { 1, (<API key> + <API key>), <API key>, 0x1, 8, 0x1 }, { 1, (<API key> + <API key>), <API key>, 0x4, 8, 0 }, { 1, (<API key> + <API key>), <API key>, 0x8, 8, 0 }, { 1, (<API key> + <API key>), AANC_GAIN_CONTROL, 0xFF, 8, 0 }, { 1, (<API key> + <API key>), <API key>, 0x10, 8, 0 }, { 1, (<API key> + <API key>), <API key>, 0x20, 8, 0 }, { 1, (<API key> + <API key>), <API key>, 0x10, 8, 0 }, { 1, (<API key> + <API key>), <API key>, 0x20, 8, 0 }, { 1, (<API key> + <API key>), <API key>, 0x10, 8, 0 }, { 1, (<API key> + <API key>), <API key>, 0x20, 8, 0 }, }; static struct <API key> clip_reg_cfg[] = { { 1, (<API key> + <API key>), <API key>, 0x3, 8, 0 }, { 1, (<API key> + <API key>), SPKR_CLIPDET_VAL0, 0xff, 8, 0 }, { 1, (<API key> + <API key>), SPKR_CLIPDET_VAL1, 0xff, 8, 0 }, { 1, (<API key> + <API key>), SPKR_CLIPDET_VAL2, 0xff, 8, 0 }, { 1, (<API key> + <API key>), SPKR_CLIPDET_VAL3, 0xff, 8, 0 }, { 1, (<API key> + <API key>), SPKR_CLIPDET_VAL4, 0xff, 8, 0 }, { 1, (<API key> + <API key>), SPKR_CLIPDET_VAL5, 0xff, 8, 0 }, { 1, (<API key> + <API key>), SPKR_CLIPDET_VAL6, 0xff, 8, 0 }, { 1, (<API key> + <API key>), SPKR_CLIPDET_VAL7, 0xff, 8, 0 }, { 1, (<API key> + <API key>), <API key>, 0x3, 8, 0 }, { 1, (<API key> + <API key>), SPKR2_CLIPDET_VAL0, 0xff, 8, 0 }, { 1, (<API key> + <API key>), SPKR2_CLIPDET_VAL1, 0xff, 8, 0 }, { 1, (<API key> + <API key>), SPKR2_CLIPDET_VAL2, 0xff, 8, 0 }, { 1, (<API key> + <API key>), SPKR2_CLIPDET_VAL3, 0xff, 8, 0 }, { 1, (<API key> + <API key>), SPKR2_CLIPDET_VAL4, 0xff, 8, 0 }, { 1, (<API key> + <API key>), SPKR2_CLIPDET_VAL5, 0xff, 8, 0 }, { 1, (<API key> + <API key>), SPKR2_CLIPDET_VAL6, 0xff, 8, 0 }, { 1, (<API key> + <API key>), SPKR2_CLIPDET_VAL7, 0xff, 8, 0 }, }; static struct <API key> <API key> = { .num_registers = ARRAY_SIZE(audio_reg_cfg), .reg_data = audio_reg_cfg, }; static struct <API key> tomtom_clip_reg_cfg = { .num_registers = ARRAY_SIZE(clip_reg_cfg), .reg_data = clip_reg_cfg, }; static struct <API key> <API key> = { .<API key> = <API key>, .aanc_hw_version = <API key>, }; static struct <API key> clip_bank_sel = { .minor_version = <API key>, .num_banks = AFE_CLIP_MAX_BANKS, .bank_map = {0, 1, 2, 3}, }; #define WCD9330_RATES (SNDRV_PCM_RATE_8000 | <API key> |\ <API key> | <API key> |\ <API key> | <API key>) #define NUM_DECIMATORS 10 #define NUM_INTERPOLATORS 8 #define BITS_PER_REG 8 #define <API key> 16 #define <API key> 16 #define <API key> 0x08 #define <API key> 1000 #define <API key> (1 << 0) #define <API key> (1 << 1) #define <API key> (1 << 2) #define <API key> 12288000 #define <API key> 9600000 #define <API key> (<API key> | \ <API key>) #define TOMTOM_FORMATS (<API key>) #define <API key> (<API key> + 2) #define <API key> 1 #define <API key> 7218 #define <API key> (<API key> * 10) #define <API key> (<API key> * 100) #define <API key> 655 #define <API key> 16 #define <API key> 1000000 enum { AIF1_PB = 0, AIF1_CAP, AIF2_PB, AIF2_CAP, AIF3_PB, AIF3_CAP, AIF4_VIFEED, AIF4_MAD_TX, NUM_CODEC_DAIS, }; enum { <API key> = 0, <API key>, <API key>, <API key>, <API key>, RX_MIX1_INP_SEL_RX1, RX_MIX1_INP_SEL_RX2, RX_MIX1_INP_SEL_RX3, RX_MIX1_INP_SEL_RX4, RX_MIX1_INP_SEL_RX5, RX_MIX1_INP_SEL_RX6, RX_MIX1_INP_SEL_RX7, <API key>, }; enum { <API key> = 0, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, }; enum { ON_DEMAND_MICBIAS = 0, <API key>, }; #define <API key> 3 static const <API key>(digital_gain, 0, 1, 0); static const <API key>(line_gain, 0, 7, 1); static const <API key>(analog_gain, 0, 25, 1); static struct snd_soc_dai_driver tomtom_dai[]; static const <API key>(aux_pga_gain, 0, 2, 0); /* Codec supports 2 IIR filters */ enum { IIR1 = 0, IIR2, IIR_MAX, }; /* Codec supports 5 bands */ enum { BAND1 = 0, BAND2, BAND3, BAND4, BAND5, BAND_MAX, }; enum { COMPANDER_0, COMPANDER_1, COMPANDER_2, COMPANDER_MAX, }; enum { COMPANDER_FS_8KHZ = 0, COMPANDER_FS_16KHZ, COMPANDER_FS_32KHZ, COMPANDER_FS_48KHZ, COMPANDER_FS_96KHZ, COMPANDER_FS_192KHZ, COMPANDER_FS_MAX, }; struct <API key> { u32 peak_det_timeout; u32 rms_meter_div_fact; u32 <API key>; }; struct hpf_work { struct tomtom_priv *tomtom; u32 decimator; u8 tx_hpf_cut_of_freq; bool tx_hpf_bypass; struct delayed_work dwork; }; static struct hpf_work tx_hpf_work[NUM_DECIMATORS]; static const struct wcd9xxx_ch tomtom_rx_chs[TOMTOM_RX_MAX] = { WCD9XXX_CH(<API key>, 0), WCD9XXX_CH(<API key> + 1, 1), WCD9XXX_CH(<API key> + 2, 2), WCD9XXX_CH(<API key> + 3, 3), WCD9XXX_CH(<API key> + 4, 4), WCD9XXX_CH(<API key> + 5, 5), WCD9XXX_CH(<API key> + 6, 6), WCD9XXX_CH(<API key> + 7, 7), WCD9XXX_CH(<API key> + 8, 8), WCD9XXX_CH(<API key> + 9, 9), WCD9XXX_CH(<API key> + 10, 10), WCD9XXX_CH(<API key> + 11, 11), WCD9XXX_CH(<API key> + 12, 12), }; static const struct wcd9xxx_ch tomtom_tx_chs[TOMTOM_TX_MAX] = { WCD9XXX_CH(0, 0), WCD9XXX_CH(1, 1), WCD9XXX_CH(2, 2), WCD9XXX_CH(3, 3), WCD9XXX_CH(4, 4), WCD9XXX_CH(5, 5), WCD9XXX_CH(6, 6), WCD9XXX_CH(7, 7), WCD9XXX_CH(8, 8), WCD9XXX_CH(9, 9), WCD9XXX_CH(10, 10), WCD9XXX_CH(11, 11), WCD9XXX_CH(12, 12), WCD9XXX_CH(13, 13), WCD9XXX_CH(14, 14), WCD9XXX_CH(15, 15), }; static const u32 vport_check_table[NUM_CODEC_DAIS] = { 0, /* AIF1_PB */ (1 << AIF2_CAP) | (1 << AIF3_CAP), /* AIF1_CAP */ 0, /* AIF2_PB */ (1 << AIF1_CAP) | (1 << AIF3_CAP), /* AIF2_CAP */ 0, /* AIF3_PB */ (1 << AIF1_CAP) | (1 << AIF2_CAP), /* AIF3_CAP */ }; static const u32 <API key>[NUM_CODEC_DAIS] = { 0, /* AIF1_PB */ 0, /* AIF1_CAP */ 0, /* AIF2_PB */ 0, /* AIF2_CAP */ }; static char <API key>[][<API key>] = { "cdc-vdd-mic-bias", }; struct tomtom_priv { struct snd_soc_codec *codec; u32 adc_count; u32 rx_bias_count; s32 dmic_1_2_clk_cnt; s32 dmic_3_4_clk_cnt; s32 dmic_5_6_clk_cnt; s32 ldo_h_users; s32 micb_2_users; s32 micb_3_users; u32 anc_slot; bool anc_func; /* cal info for codec */ struct fw_info *fw_data; /*track tomtom interface type*/ u8 intf_type; /* num of slim ports required */ struct <API key> dai[NUM_CODEC_DAIS]; /*compander*/ int comp_enabled[COMPANDER_MAX]; u32 comp_fs[COMPANDER_MAX]; /* Maintain the status of AUX PGA */ int aux_pga_cnt; u8 aux_l_gain; u8 aux_r_gain; bool spkr_pa_widget_on; struct regulator *spkdrv_reg; struct regulator *spkdrv2_reg; struct regulator *micbias_reg; bool mbhc_started; struct <API key> slimbus_slave_cfg; /* resmgr module */ struct wcd9xxx_resmgr resmgr; /* mbhc module */ struct wcd9xxx_mbhc mbhc; /* class h specific data */ struct <API key> clsh_d; int (*<API key>)(struct snd_soc_codec *codec, enum wcd9xxx_codec_event); int (*codec_ext_clk_en_cb)(struct snd_soc_codec *codec, int enable, bool dapm); int (*<API key>) (void); /* * list used to save/restore registers at start and * end of impedance measurement */ struct list_head reg_save_restore; /* handle to cpe core */ struct wcd_cpe_core *cpe_core; /* UHQA (class AB) mode */ u8 uhqa_mode; /* Multiplication factor used for impedance detection */ int zdet_gain_mul_fact; /* to track the status */ unsigned long status_mask; int ext_clk_users; struct clk *wcd_ext_clk; }; static const u32 comp_shift[] = { 4, /* Compander 0's clock source is on interpolator 7 */ 0, 2, }; static const int comp_rx_path[] = { COMPANDER_1, COMPANDER_1, COMPANDER_2, COMPANDER_2, COMPANDER_2, COMPANDER_2, COMPANDER_0, COMPANDER_0, COMPANDER_MAX, }; static const struct <API key> comp_samp_params[] = { { /* 8 Khz */ .peak_det_timeout = 0x06, .rms_meter_div_fact = 0x09, .<API key> = 0x06, }, { /* 16 Khz */ .peak_det_timeout = 0x07, .rms_meter_div_fact = 0x0A, .<API key> = 0x0C, }, { /* 32 Khz */ .peak_det_timeout = 0x08, .rms_meter_div_fact = 0x0B, .<API key> = 0x1E, }, { /* 48 Khz */ .peak_det_timeout = 0x09, .rms_meter_div_fact = 0x0B, .<API key> = 0x28, }, { /* 96 Khz */ .peak_det_timeout = 0x0A, .rms_meter_div_fact = 0x0C, .<API key> = 0x50, }, { /* 192 Khz */ .peak_det_timeout = 0x0B, .rms_meter_div_fact = 0xC, .<API key> = 0xA0, }, }; static unsigned short rx_digital_gain_reg[] = { <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, }; static unsigned short tx_digital_gain_reg[] = { <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, <API key>, }; int <API key>(struct snd_soc_codec *codec) { struct tomtom_priv *tomtom = <API key>(codec); if (tomtom->wcd_ext_clk) <API key>(codec, true, false); snd_soc_write(codec, TOMTOM_A_QFUSE_CTL, 0x03); /* * 5ms sleep required after enabling qfuse control * before checking the status. */ usleep_range(5000, 5500); if ((snd_soc_read(codec, <API key>) & (0x03)) != 0x03) WARN(1, "%s: Qfuse sense is not complete\n", __func__); if (tomtom->wcd_ext_clk) <API key>(codec, false, false); return 0; } EXPORT_SYMBOL(<API key>); static int <API key>(struct snd_soc_codec *codec, int path) { if (path == RX8_PATH) return snd_soc_read(codec, <API key>); else return snd_soc_read(codec, (<API key> + 8 * (path - 1))); } static int <API key>(struct snd_soc_codec *codec, int bit_format) { int i = 0; int ret = 0; struct tomtom_priv *tomtom_p = <API key>(codec); for (i = 0; i < NUM_CODEC_DAIS; i++) { if (tomtom_p->dai[i].bit_width == bit_format) { ret = 1; break; } } return ret; } static int <API key>(struct snd_soc_codec *codec, int path) { int ret = 0; struct tomtom_priv *tomtom_p = <API key>(codec); /* UHQA path has fs=192KHz & bit=24 bit */ if (((<API key>(codec, path) & 0xE0) == 0xA0) && (<API key>(codec, 24))) { tomtom_p->uhqa_mode = 1; } else { tomtom_p->uhqa_mode = 0; } dev_dbg(codec->dev, "%s: uhqa_mode=%d", __func__, tomtom_p->uhqa_mode); return ret; } static int tomtom_get_anc_slot(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); struct tomtom_priv *tomtom = <API key>(codec); ucontrol->value.integer.value[0] = tomtom->anc_slot; return 0; } static int tomtom_put_anc_slot(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); struct tomtom_priv *tomtom = <API key>(codec); tomtom->anc_slot = ucontrol->value.integer.value[0]; return 0; } static int tomtom_get_anc_func(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); struct tomtom_priv *tomtom = <API key>(codec); ucontrol->value.integer.value[0] = (tomtom->anc_func == true ? 1 : 0); return 0; } static int tomtom_put_anc_func(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); struct tomtom_priv *tomtom = <API key>(codec); struct <API key> *dapm = &codec->dapm; mutex_lock(&dapm->codec->mutex); tomtom->anc_func = (!ucontrol->value.integer.value[0] ? false : true); dev_dbg(codec->dev, "%s: anc_func %x", __func__, tomtom->anc_func); if (tomtom->anc_func == true) { <API key>(dapm, "ANC HPHR"); <API key>(dapm, "ANC HPHL"); <API key>(dapm, "ANC HEADPHONE"); <API key>(dapm, "ANC EAR PA"); <API key>(dapm, "ANC EAR"); <API key>(dapm, "HPHR"); <API key>(dapm, "HPHL"); <API key>(dapm, "HEADPHONE"); <API key>(dapm, "EAR PA"); <API key>(dapm, "EAR"); } else { <API key>(dapm, "ANC HPHR"); <API key>(dapm, "ANC HPHL"); <API key>(dapm, "ANC HEADPHONE"); <API key>(dapm, "ANC EAR PA"); <API key>(dapm, "ANC EAR"); <API key>(dapm, "HPHR"); <API key>(dapm, "HPHL"); <API key>(dapm, "HEADPHONE"); <API key>(dapm, "EAR PA"); <API key>(dapm, "EAR"); } mutex_unlock(&dapm->codec->mutex); snd_soc_dapm_sync(dapm); return 0; } static int <API key>( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); int iir_idx = ((struct <API key> *) kcontrol->private_value)->reg; int band_idx = ((struct <API key> *) kcontrol->private_value)->shift; ucontrol->value.integer.value[0] = (snd_soc_read(codec, (<API key> + 16 * iir_idx)) & (1 << band_idx)) != 0; pr_debug("%s: IIR #%d band #%d enable %d\n", __func__, iir_idx, band_idx, (uint32_t)ucontrol->value.integer.value[0]); return 0; } static int <API key>( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); int iir_idx = ((struct <API key> *) kcontrol->private_value)->reg; int band_idx = ((struct <API key> *) kcontrol->private_value)->shift; int value = ucontrol->value.integer.value[0]; /* Mask first 5 bits, 6-8 are reserved */ snd_soc_update_bits(codec, (<API key> + 16 * iir_idx), (1 << band_idx), (value << band_idx)); pr_debug("%s: IIR #%d band #%d enable %d\n", __func__, iir_idx, band_idx, ((snd_soc_read(codec, (<API key> + 16 * iir_idx)) & (1 << band_idx)) != 0)); return 0; } static uint32_t get_iir_band_coeff(struct snd_soc_codec *codec, int iir_idx, int band_idx, int coeff_idx) { uint32_t value = 0; /* Address does not automatically update if reading */ snd_soc_write(codec, (<API key> + 16 * iir_idx), ((band_idx * BAND_MAX + coeff_idx) * sizeof(uint32_t)) & 0x7F); value |= snd_soc_read(codec, (<API key> + 16 * iir_idx)); snd_soc_write(codec, (<API key> + 16 * iir_idx), ((band_idx * BAND_MAX + coeff_idx) * sizeof(uint32_t) + 1) & 0x7F); value |= (snd_soc_read(codec, (<API key> + 16 * iir_idx)) << 8); snd_soc_write(codec, (<API key> + 16 * iir_idx), ((band_idx * BAND_MAX + coeff_idx) * sizeof(uint32_t) + 2) & 0x7F); value |= (snd_soc_read(codec, (<API key> + 16 * iir_idx)) << 16); snd_soc_write(codec, (<API key> + 16 * iir_idx), ((band_idx * BAND_MAX + coeff_idx) * sizeof(uint32_t) + 3) & 0x7F); /* Mask bits top 2 bits since they are reserved */ value |= ((snd_soc_read(codec, (<API key> + 16 * iir_idx)) & 0x3F) << 24); return value; } static int <API key>( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); int iir_idx = ((struct <API key> *) kcontrol->private_value)->reg; int band_idx = ((struct <API key> *) kcontrol->private_value)->shift; ucontrol->value.integer.value[0] = get_iir_band_coeff(codec, iir_idx, band_idx, 0); ucontrol->value.integer.value[1] = get_iir_band_coeff(codec, iir_idx, band_idx, 1); ucontrol->value.integer.value[2] = get_iir_band_coeff(codec, iir_idx, band_idx, 2); ucontrol->value.integer.value[3] = get_iir_band_coeff(codec, iir_idx, band_idx, 3); ucontrol->value.integer.value[4] = get_iir_band_coeff(codec, iir_idx, band_idx, 4); pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n" "%s: IIR #%d band #%d b1 = 0x%x\n" "%s: IIR #%d band #%d b2 = 0x%x\n" "%s: IIR #%d band #%d a1 = 0x%x\n" "%s: IIR #%d band #%d a2 = 0x%x\n", __func__, iir_idx, band_idx, (uint32_t)ucontrol->value.integer.value[0], __func__, iir_idx, band_idx, (uint32_t)ucontrol->value.integer.value[1], __func__, iir_idx, band_idx, (uint32_t)ucontrol->value.integer.value[2], __func__, iir_idx, band_idx, (uint32_t)ucontrol->value.integer.value[3], __func__, iir_idx, band_idx, (uint32_t)ucontrol->value.integer.value[4]); return 0; } static void set_iir_band_coeff(struct snd_soc_codec *codec, int iir_idx, int band_idx, uint32_t value) { snd_soc_write(codec, (<API key> + 16 * iir_idx), (value & 0xFF)); snd_soc_write(codec, (<API key> + 16 * iir_idx), (value >> 8) & 0xFF); snd_soc_write(codec, (<API key> + 16 * iir_idx), (value >> 16) & 0xFF); /* Mask top 2 bits, 7-8 are reserved */ snd_soc_write(codec, (<API key> + 16 * iir_idx), (value >> 24) & 0x3F); } static int <API key>( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); int iir_idx = ((struct <API key> *) kcontrol->private_value)->reg; int band_idx = ((struct <API key> *) kcontrol->private_value)->shift; /* Mask top bit it is reserved */ /* Updates addr automatically for each B2 write */ snd_soc_write(codec, (<API key> + 16 * iir_idx), (band_idx * BAND_MAX * sizeof(uint32_t)) & 0x7F); set_iir_band_coeff(codec, iir_idx, band_idx, ucontrol->value.integer.value[0]); set_iir_band_coeff(codec, iir_idx, band_idx, ucontrol->value.integer.value[1]); set_iir_band_coeff(codec, iir_idx, band_idx, ucontrol->value.integer.value[2]); set_iir_band_coeff(codec, iir_idx, band_idx, ucontrol->value.integer.value[3]); set_iir_band_coeff(codec, iir_idx, band_idx, ucontrol->value.integer.value[4]); pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n" "%s: IIR #%d band #%d b1 = 0x%x\n" "%s: IIR #%d band #%d b2 = 0x%x\n" "%s: IIR #%d band #%d a1 = 0x%x\n" "%s: IIR #%d band #%d a2 = 0x%x\n", __func__, iir_idx, band_idx, get_iir_band_coeff(codec, iir_idx, band_idx, 0), __func__, iir_idx, band_idx, get_iir_band_coeff(codec, iir_idx, band_idx, 1), __func__, iir_idx, band_idx, get_iir_band_coeff(codec, iir_idx, band_idx, 2), __func__, iir_idx, band_idx, get_iir_band_coeff(codec, iir_idx, band_idx, 3), __func__, iir_idx, band_idx, get_iir_band_coeff(codec, iir_idx, band_idx, 4)); return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); int comp = ((struct <API key> *) kcontrol->private_value)->shift; struct tomtom_priv *tomtom = <API key>(codec); ucontrol->value.integer.value[0] = tomtom->comp_enabled[comp]; return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); struct tomtom_priv *tomtom = <API key>(codec); int comp = ((struct <API key> *) kcontrol->private_value)->shift; int value = ucontrol->value.integer.value[0]; pr_debug("%s: Compander %d enable current %d, new %d\n", __func__, comp, tomtom->comp_enabled[comp], value); tomtom->comp_enabled[comp] = value; if (comp == COMPANDER_1 && tomtom->comp_enabled[comp] == 1) { /* Wavegen to 5 msec */ snd_soc_write(codec, <API key>, 0xDB); snd_soc_write(codec, <API key>, 0x2A); snd_soc_write(codec, <API key>, 0x2A); /* Enable Chopper */ snd_soc_update_bits(codec, <API key>, 0x80, 0x80); snd_soc_write(codec, TOMTOM_A_NCP_DTEST, 0x20); pr_debug("%s: Enabled Chopper and set wavegen to 5 msec\n", __func__); } else if (comp == COMPANDER_1 && tomtom->comp_enabled[comp] == 0) { /* Wavegen to 20 msec */ snd_soc_write(codec, <API key>, 0xDB); snd_soc_write(codec, <API key>, 0x58); snd_soc_write(codec, <API key>, 0x1A); /* Disable CHOPPER block */ snd_soc_update_bits(codec, <API key>, 0x80, 0x00); snd_soc_write(codec, TOMTOM_A_NCP_DTEST, 0x10); pr_debug("%s: Disabled Chopper and set wavegen to 20 msec\n", __func__); } return 0; } static int <API key>(struct snd_soc_codec *codec, int comp, bool enable) { int ret = 0; switch (comp) { case COMPANDER_0: snd_soc_update_bits(codec, <API key>, 1 << 2, !enable << 2); snd_soc_update_bits(codec, <API key>, 1 << 2, !enable << 2); break; case COMPANDER_1: snd_soc_update_bits(codec, <API key>, 1 << 5, !enable << 5); snd_soc_update_bits(codec, <API key>, 1 << 5, !enable << 5); break; case COMPANDER_2: snd_soc_update_bits(codec, <API key>, 1 << 5, !enable << 5); snd_soc_update_bits(codec, <API key>, 1 << 5, !enable << 5); snd_soc_update_bits(codec, <API key>, 1 << 5, !enable << 5); snd_soc_update_bits(codec, <API key>, 1 << 5, !enable << 5); break; default: WARN_ON(1); ret = -EINVAL; } return ret; } static void <API key>(struct snd_soc_codec *codec, int comp) { /* Level meter DIV Factor to 5*/ snd_soc_update_bits(codec, <API key> + (comp * 8), 0xF0, 0x05 << 4); /* RMS meter Sampling to 0x01 */ snd_soc_write(codec, <API key> + (comp * 8), 0x01); /* Worst case timeout for compander CnP sleep timeout */ usleep_range(3000, 3100); } static enum wcd9xxx_buck_volt <API key>( struct snd_soc_codec *codec) { int buck_volt = <API key>; struct tomtom_priv *tomtom = <API key>(codec); struct wcd9xxx_pdata *pdata = tomtom->resmgr.pdata; int i; for (i = 0; i < ARRAY_SIZE(pdata->regulator); i++) { if (!strcmp(pdata->regulator[i].name, <API key>)) { if ((pdata->regulator[i].min_uV == <API key>) || (pdata->regulator[i].min_uV == <API key>)) buck_volt = pdata->regulator[i].min_uV; break; } } return buck_volt; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { int mask, enable_mask; struct snd_soc_codec *codec = w->codec; struct tomtom_priv *tomtom = <API key>(codec); const int comp = w->shift; const u32 rate = tomtom->comp_fs[comp]; const struct <API key> *comp_params = &comp_samp_params[rate]; enum wcd9xxx_buck_volt buck_mv; pr_debug("%s: %s event %d compander %d, enabled %d", __func__, w->name, event, comp, tomtom->comp_enabled[comp]); if (!tomtom->comp_enabled[comp]) return 0; /* Compander 0 has two channels */ mask = enable_mask = 0x03; buck_mv = <API key>(codec); switch (event) { case <API key>: /* Set compander Sample rate */ snd_soc_update_bits(codec, <API key> + (comp * 8), 0x07, rate); /* Set the static gain offset for HPH Path */ if (comp == COMPANDER_1) { if (buck_mv == <API key>) { snd_soc_update_bits(codec, <API key> + (comp * 8), 0x80, 0x00); } else { snd_soc_update_bits(codec, <API key> + (comp * 8), 0x80, 0x80); } } /* Enable RX interpolation path compander clocks */ snd_soc_update_bits(codec, <API key>, mask << comp_shift[comp], mask << comp_shift[comp]); /* Toggle compander reset bits */ snd_soc_update_bits(codec, <API key>, mask << comp_shift[comp], mask << comp_shift[comp]); snd_soc_update_bits(codec, <API key>, mask << comp_shift[comp], 0); /* Set gain source to compander */ <API key>(codec, comp, true); /* Compander enable */ snd_soc_update_bits(codec, <API key> + (comp * 8), enable_mask, enable_mask); <API key>(codec, comp); /* Set sample rate dependent paramater */ snd_soc_write(codec, <API key> + (comp * 8), comp_params-><API key>); snd_soc_update_bits(codec, <API key> + (comp * 8), 0xF0, comp_params->rms_meter_div_fact << 4); snd_soc_update_bits(codec, <API key> + (comp * 8), 0x0F, comp_params->peak_det_timeout); break; case <API key>: /* Disable compander */ snd_soc_update_bits(codec, <API key> + (comp * 8), enable_mask, 0x00); /* Toggle compander reset bits */ snd_soc_update_bits(codec, <API key>, mask << comp_shift[comp], mask << comp_shift[comp]); snd_soc_update_bits(codec, <API key>, mask << comp_shift[comp], 0); /* Turn off the clock for compander in pair */ snd_soc_update_bits(codec, <API key>, mask << comp_shift[comp], 0); /* Set gain source to register */ <API key>(codec, comp, false); if (comp == COMPANDER_1) snd_soc_update_bits(codec, <API key> + (comp * 8), 0x80, 0x00); break; } return 0; } static const char *const <API key>[] = {"OFF", "ON"}; static const struct soc_enum <API key> = SOC_ENUM_SINGLE_EXT(2, <API key>); static const char *const <API key>[] = {"POS_6_DB", "POS_2_DB"}; static const struct soc_enum <API key>[] = { SOC_ENUM_SINGLE_EXT(2, <API key>), }; /*cut of frequency for high pass filter*/ static const char * const cf_text[] = { "MIN_3DB_4Hz", "MIN_3DB_75Hz", "MIN_3DB_150Hz" }; static const char * const rx_cf_text[] = { "MIN_3DB_4Hz", "MIN_3DB_75Hz", "MIN_3DB_150Hz", "MIN_3DB_0P48Hz" }; static const struct soc_enum cf_dec1_enum = SOC_ENUM_SINGLE(<API key>, 4, 3, cf_text); static const struct soc_enum cf_dec2_enum = SOC_ENUM_SINGLE(<API key>, 4, 3, cf_text); static const struct soc_enum cf_dec3_enum = SOC_ENUM_SINGLE(<API key>, 4, 3, cf_text); static const struct soc_enum cf_dec4_enum = SOC_ENUM_SINGLE(<API key>, 4, 3, cf_text); static const struct soc_enum cf_dec5_enum = SOC_ENUM_SINGLE(<API key>, 4, 3, cf_text); static const struct soc_enum cf_dec6_enum = SOC_ENUM_SINGLE(<API key>, 4, 3, cf_text); static const struct soc_enum cf_dec7_enum = SOC_ENUM_SINGLE(<API key>, 4, 3, cf_text); static const struct soc_enum cf_dec8_enum = SOC_ENUM_SINGLE(<API key>, 4, 3, cf_text); static const struct soc_enum cf_dec9_enum = SOC_ENUM_SINGLE(<API key>, 4, 3, cf_text); static const struct soc_enum cf_dec10_enum = SOC_ENUM_SINGLE(<API key>, 4, 3, cf_text); static const struct soc_enum cf_rxmix1_enum = SOC_ENUM_SINGLE(<API key>, 0, 4, rx_cf_text); static const struct soc_enum cf_rxmix2_enum = SOC_ENUM_SINGLE(<API key>, 0, 4, rx_cf_text); static const struct soc_enum cf_rxmix3_enum = SOC_ENUM_SINGLE(<API key>, 0, 4, rx_cf_text); static const struct soc_enum cf_rxmix4_enum = SOC_ENUM_SINGLE(<API key>, 0, 4, rx_cf_text); static const struct soc_enum cf_rxmix5_enum = SOC_ENUM_SINGLE(<API key>, 0, 4, rx_cf_text) ; static const struct soc_enum cf_rxmix6_enum = SOC_ENUM_SINGLE(<API key>, 0, 4, rx_cf_text); static const struct soc_enum cf_rxmix7_enum = SOC_ENUM_SINGLE(<API key>, 0, 4, rx_cf_text); static const struct soc_enum cf_rxmix8_enum = SOC_ENUM_SINGLE(<API key>, 0, 4, rx_cf_text); static const char * const class_h_dsm_text[] = { "ZERO", "DSM_HPHL_RX1", "DSM_SPKR_RX7" }; static const struct soc_enum class_h_dsm_enum = SOC_ENUM_SINGLE(<API key>, 4, 3, class_h_dsm_text); static const struct snd_kcontrol_new class_h_dsm_mux = SOC_DAPM_ENUM("CLASS_H_DSM MUX Mux", class_h_dsm_enum); static const char * const rx1_interp_text[] = { "ZERO", "RX1 MIX2" }; static const struct soc_enum rx1_interp_enum = SOC_ENUM_SINGLE(<API key>, 0, 2, rx1_interp_text); static const struct snd_kcontrol_new rx1_interp_mux = SOC_DAPM_ENUM("RX1 INTERP MUX Mux", rx1_interp_enum); static const char * const rx2_interp_text[] = { "ZERO", "RX2 MIX2" }; static const struct soc_enum rx2_interp_enum = SOC_ENUM_SINGLE(<API key>, 1, 2, rx2_interp_text); static const struct snd_kcontrol_new rx2_interp_mux = SOC_DAPM_ENUM("RX2 INTERP MUX Mux", rx2_interp_enum); static const char *const <API key>[] = { "ADC_MB", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6", "NOTUSED1", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "DMIC5", "DMIC6", "NOTUSED2", "NOTUSED3"}; static const struct soc_enum <API key> = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(<API key>), <API key>); static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { u8 tomtom_mad_input; struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); tomtom_mad_input = snd_soc_read(codec, <API key>); tomtom_mad_input = tomtom_mad_input & 0x0F; ucontrol->value.integer.value[0] = tomtom_mad_input; pr_debug("%s: tomtom_mad_input = %s\n", __func__, <API key>[tomtom_mad_input]); return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { u8 tomtom_mad_input; u16 micb_int_reg, micb_4_int_reg; struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); struct snd_soc_card *card = codec->card; char <API key>[6]; u32 adc; const char *mad_input_widget; const char *source_widget = NULL; u32 mic_bias_found = 0; u32 i; struct tomtom_priv *tomtom = <API key>(codec); int ret = 0; char *mad_input; tomtom_mad_input = ucontrol->value.integer.value[0]; micb_4_int_reg = tomtom->resmgr.reg_addr->micb_4_int_rbias; pr_debug("%s: tomtom_mad_input = %s\n", __func__, <API key>[tomtom_mad_input]); if (!strcmp(<API key>[tomtom_mad_input], "NOTUSED1") || !strcmp(<API key>[tomtom_mad_input], "NOTUSED2") || !strcmp(<API key>[tomtom_mad_input], "NOTUSED3") || !strcmp(<API key>[tomtom_mad_input], "ADC_MB")) { pr_info("%s: tomtom mad input is set to unsupported input = %s\n", __func__, <API key>[tomtom_mad_input]); return -EINVAL; } if (strnstr(<API key>[tomtom_mad_input], "ADC", sizeof("ADC"))) { mad_input = strpbrk(<API key>[tomtom_mad_input], "123456"); if (!mad_input) { dev_err(codec->dev, "%s: Invalid MAD input %s\n", __func__, <API key>[tomtom_mad_input]); return -EINVAL; } ret = kstrtouint(mad_input, 10, &adc); if ((ret < 0) || (adc > 6)) { pr_err("%s: Invalid ADC = %s\n", __func__, <API key>[tomtom_mad_input]); ret = -EINVAL; } snprintf(<API key>, 6, "%s%u", "AMIC", adc); mad_input_widget = <API key>; pr_debug("%s: tomtom amic input widget = %s\n", __func__, <API key>); } else { /* DMIC type input widget*/ mad_input_widget = <API key>[tomtom_mad_input]; } pr_debug("%s: tomtom input widget = %s\n", __func__, mad_input_widget); for (i = 0; i < card->num_dapm_routes; i++) { if (!strcmp(card->dapm_routes[i].sink, mad_input_widget)) { source_widget = card->dapm_routes[i].source; if (!source_widget) { dev_err(codec->dev, "%s: invalid source widget\n", __func__); return -EINVAL; } if (strnstr(source_widget, "MIC BIAS1", sizeof("MIC BIAS1"))) { mic_bias_found = 1; micb_int_reg = <API key>; break; } else if (strnstr(source_widget, "MIC BIAS2", sizeof("MIC BIAS2"))) { mic_bias_found = 2; micb_int_reg = <API key>; break; } else if (strnstr(source_widget, "MIC BIAS3", sizeof("MIC BIAS3"))) { mic_bias_found = 3; micb_int_reg = <API key>; break; } else if (strnstr(source_widget, "MIC BIAS4", sizeof("MIC BIAS4"))) { mic_bias_found = 4; micb_int_reg = micb_4_int_reg; break; } } } if (mic_bias_found) { pr_debug("%s: source mic bias = %s. sink = %s\n", __func__, card->dapm_routes[i].source, card->dapm_routes[i].sink); snd_soc_update_bits(codec, <API key>, 0x0F, tomtom_mad_input); snd_soc_update_bits(codec, <API key>, 0x07, mic_bias_found); /* Setup internal micbias */ if (strnstr(source_widget, "Internal1", strlen(source_widget))) snd_soc_update_bits(codec, micb_int_reg, 0xE0, 0xE0); else if (strnstr(source_widget, "Internal2", strlen(source_widget))) snd_soc_update_bits(codec, micb_int_reg, 0x1C, 0x1C); else if (strnstr(source_widget, "Internal3", strlen(source_widget))) snd_soc_update_bits(codec, micb_int_reg, 0x3, 0x3); else /* * If not internal, make sure to write the * register to default value */ snd_soc_write(codec, micb_int_reg, 0x24); return 0; } else { pr_err("%s: mic bias source not found for input = %s\n", __func__, mad_input_widget); return -EINVAL; } } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { u32 tx_index; tx_index = (u32)kcontrol->private_value; if (tx_index > NUM_DECIMATORS) { pr_err("%s: Invalid TX decimator %d\n", __func__, tx_index); return -EINVAL; } ucontrol->value.integer.value[0] = tx_hpf_work[tx_index-1].tx_hpf_bypass; return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { bool tx_hpf_bypass_cfg; u32 tx_index; tx_hpf_bypass_cfg = (bool)ucontrol->value.integer.value[0]; pr_debug("%s: tx_hpf_bypass = %d\n", __func__, tx_hpf_bypass_cfg); tx_index = (u32)kcontrol->private_value; if (tx_index > NUM_DECIMATORS) { pr_err("%s: Invalid TX decimator %d\n", __func__, tx_index); return -EINVAL; } if (tx_hpf_work[tx_index-1].tx_hpf_bypass != tx_hpf_bypass_cfg) tx_hpf_work[tx_index-1].tx_hpf_bypass = tx_hpf_bypass_cfg; pr_debug("%s: Set TX%d HPF bypass configuration %d", __func__, tx_index, tx_hpf_work[tx_index-1].tx_hpf_bypass); return 0; } static const struct snd_kcontrol_new tomtom_snd_controls[] = { SOC_SINGLE_SX_TLV("RX1 Digital Volume", <API key>, 0, -84, 40, digital_gain), SOC_SINGLE_SX_TLV("RX2 Digital Volume", <API key>, 0, -84, 40, digital_gain), SOC_SINGLE_SX_TLV("RX3 Digital Volume", <API key>, 0, -84, 40, digital_gain), SOC_SINGLE_SX_TLV("RX4 Digital Volume", <API key>, 0, -84, 40, digital_gain), SOC_SINGLE_SX_TLV("RX5 Digital Volume", <API key>, 0, -84, 40, digital_gain), SOC_SINGLE_SX_TLV("RX6 Digital Volume", <API key>, 0, -84, 40, digital_gain), SOC_SINGLE_SX_TLV("RX7 Digital Volume", <API key>, 0, -84, 40, digital_gain), SOC_SINGLE_SX_TLV("RX8 Digital Volume", <API key>, 0, -84, 40, digital_gain), SOC_SINGLE_SX_TLV("DEC1 Volume", <API key>, 0, -84, 40, digital_gain), SOC_SINGLE_SX_TLV("DEC2 Volume", <API key>, 0, -84, 40, digital_gain), SOC_SINGLE_SX_TLV("DEC3 Volume", <API key>, 0, -84, 40, digital_gain), SOC_SINGLE_SX_TLV("DEC4 Volume", <API key>, 0, -84, 40, digital_gain), SOC_SINGLE_SX_TLV("DEC5 Volume", <API key>, 0, -84, 40, digital_gain), SOC_SINGLE_SX_TLV("DEC6 Volume", <API key>, 0, -84, 40, digital_gain), SOC_SINGLE_SX_TLV("DEC7 Volume", <API key>, 0, -84, 40, digital_gain), SOC_SINGLE_SX_TLV("DEC8 Volume", <API key>, 0, -84, 40, digital_gain), SOC_SINGLE_SX_TLV("DEC9 Volume", <API key>, 0, -84, 40, digital_gain), SOC_SINGLE_SX_TLV("DEC10 Volume", <API key>, 0, -84, 40, digital_gain), SOC_SINGLE_SX_TLV("IIR1 INP1 Volume", <API key>, 0, -84, 40, digital_gain), SOC_SINGLE_SX_TLV("IIR1 INP2 Volume", <API key>, 0, -84, 40, digital_gain), SOC_SINGLE_SX_TLV("IIR1 INP3 Volume", <API key>, 0, -84, 40, digital_gain), SOC_SINGLE_SX_TLV("IIR1 INP4 Volume", <API key>, 0, -84, 40, digital_gain), SOC_SINGLE_SX_TLV("IIR2 INP1 Volume", <API key>, 0, -84, 40, digital_gain), SOC_SINGLE_SX_TLV("IIR2 INP2 Volume", <API key>, 0, -84, 40, digital_gain), SOC_SINGLE_SX_TLV("IIR2 INP3 Volume", <API key>, 0, -84, 40, digital_gain), SOC_SINGLE_SX_TLV("IIR2 INP4 Volume", <API key>, 0, -84, 40, digital_gain), SOC_SINGLE_EXT("ANC Slot", SND_SOC_NOPM, 0, 100, 0, tomtom_get_anc_slot, tomtom_put_anc_slot), SOC_ENUM_EXT("ANC Function", <API key>, tomtom_get_anc_func, tomtom_put_anc_func), SOC_ENUM("TX1 HPF cut off", cf_dec1_enum), SOC_ENUM("TX2 HPF cut off", cf_dec2_enum), SOC_ENUM("TX3 HPF cut off", cf_dec3_enum), SOC_ENUM("TX4 HPF cut off", cf_dec4_enum), SOC_ENUM("TX5 HPF cut off", cf_dec5_enum), SOC_ENUM("TX6 HPF cut off", cf_dec6_enum), SOC_ENUM("TX7 HPF cut off", cf_dec7_enum), SOC_ENUM("TX8 HPF cut off", cf_dec8_enum), SOC_ENUM("TX9 HPF cut off", cf_dec9_enum), SOC_ENUM("TX10 HPF cut off", cf_dec10_enum), SOC_SINGLE_BOOL_EXT("TX1 HPF Switch", 1, <API key>, <API key>), SOC_SINGLE_BOOL_EXT("TX2 HPF Switch", 2, <API key>, <API key>), SOC_SINGLE_BOOL_EXT("TX3 HPF Switch", 3, <API key>, <API key>), SOC_SINGLE_BOOL_EXT("TX4 HPF Switch", 4, <API key>, <API key>), SOC_SINGLE_BOOL_EXT("TX5 HPF Switch", 5, <API key>, <API key>), SOC_SINGLE_BOOL_EXT("TX6 HPF Switch", 6, <API key>, <API key>), SOC_SINGLE_BOOL_EXT("TX7 HPF Switch", 7, <API key>, <API key>), SOC_SINGLE_BOOL_EXT("TX8 HPF Switch", 8, <API key>, <API key>), SOC_SINGLE_BOOL_EXT("TX9 HPF Switch", 9, <API key>, <API key>), SOC_SINGLE_BOOL_EXT("TX10 HPF Switch", 10, <API key>, <API key>), SOC_SINGLE("RX1 HPF Switch", <API key>, 2, 1, 0), SOC_SINGLE("RX2 HPF Switch", <API key>, 2, 1, 0), SOC_SINGLE("RX3 HPF Switch", <API key>, 2, 1, 0), SOC_SINGLE("RX4 HPF Switch", <API key>, 2, 1, 0), SOC_SINGLE("RX5 HPF Switch", <API key>, 2, 1, 0), SOC_SINGLE("RX6 HPF Switch", <API key>, 2, 1, 0), SOC_SINGLE("RX7 HPF Switch", <API key>, 2, 1, 0), SOC_SINGLE("RX8 HPF Switch", <API key>, 2, 1, 0), SOC_ENUM("RX1 HPF cut off", cf_rxmix1_enum), SOC_ENUM("RX2 HPF cut off", cf_rxmix2_enum), SOC_ENUM("RX3 HPF cut off", cf_rxmix3_enum), SOC_ENUM("RX4 HPF cut off", cf_rxmix4_enum), SOC_ENUM("RX5 HPF cut off", cf_rxmix5_enum), SOC_ENUM("RX6 HPF cut off", cf_rxmix6_enum), SOC_ENUM("RX7 HPF cut off", cf_rxmix7_enum), SOC_ENUM("RX8 HPF cut off", cf_rxmix8_enum), SOC_SINGLE_EXT("IIR1 Enable Band1", IIR1, BAND1, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("IIR1 Enable Band2", IIR1, BAND2, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("IIR1 Enable Band3", IIR1, BAND3, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("IIR1 Enable Band4", IIR1, BAND4, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("IIR1 Enable Band5", IIR1, BAND5, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("IIR2 Enable Band1", IIR2, BAND1, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("IIR2 Enable Band2", IIR2, BAND2, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("IIR2 Enable Band3", IIR2, BAND3, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("IIR2 Enable Band4", IIR2, BAND4, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("IIR2 Enable Band5", IIR2, BAND5, 1, 0, <API key>, <API key>), <API key>("IIR1 Band1", IIR1, BAND1, 255, 0, 5, <API key>, <API key>), <API key>("IIR1 Band2", IIR1, BAND2, 255, 0, 5, <API key>, <API key>), <API key>("IIR1 Band3", IIR1, BAND3, 255, 0, 5, <API key>, <API key>), <API key>("IIR1 Band4", IIR1, BAND4, 255, 0, 5, <API key>, <API key>), <API key>("IIR1 Band5", IIR1, BAND5, 255, 0, 5, <API key>, <API key>), <API key>("IIR2 Band1", IIR2, BAND1, 255, 0, 5, <API key>, <API key>), <API key>("IIR2 Band2", IIR2, BAND2, 255, 0, 5, <API key>, <API key>), <API key>("IIR2 Band3", IIR2, BAND3, 255, 0, 5, <API key>, <API key>), <API key>("IIR2 Band4", IIR2, BAND4, 255, 0, 5, <API key>, <API key>), <API key>("IIR2 Band5", IIR2, BAND5, 255, 0, 5, <API key>, <API key>), SOC_SINGLE_EXT("COMP0 Switch", SND_SOC_NOPM, COMPANDER_0, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("COMP1 Switch", SND_SOC_NOPM, COMPANDER_1, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("COMP2 Switch", SND_SOC_NOPM, COMPANDER_2, 1, 0, <API key>, <API key>), SOC_ENUM_EXT("MAD Input", <API key>, <API key>, <API key>), }; static int tomtom_pa_gain_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { u8 ear_pa_gain; struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); ear_pa_gain = snd_soc_read(codec, <API key>); ear_pa_gain = ear_pa_gain >> 5; ucontrol->value.integer.value[0] = ear_pa_gain; pr_debug("%s: ear_pa_gain = 0x%x\n", __func__, ear_pa_gain); return 0; } static int tomtom_pa_gain_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { u8 ear_pa_gain; struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); pr_debug("%s: ucontrol->value.integer.value[0] = %ld\n", __func__, ucontrol->value.integer.value[0]); ear_pa_gain = ucontrol->value.integer.value[0] << 5; snd_soc_update_bits(codec, <API key>, 0xE0, ear_pa_gain); return 0; } static const char * const <API key>[] = { "POS_6_DB", "POS_4P5_DB", "POS_3_DB", "POS_1P5_DB", "POS_0_DB", "NEG_2P5_DB", "UNDEFINED", "NEG_12_DB" }; static const struct soc_enum <API key> = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(<API key>), <API key>); static const struct snd_kcontrol_new <API key>[] = { SOC_ENUM_EXT("EAR PA Gain", <API key>, tomtom_pa_gain_get, tomtom_pa_gain_put), SOC_SINGLE_TLV("HPHL Volume", <API key>, 0, 20, 1, line_gain), SOC_SINGLE_TLV("HPHR Volume", <API key>, 0, 20, 1, line_gain), SOC_SINGLE_TLV("LINEOUT1 Volume", <API key>, 0, 20, 1, line_gain), SOC_SINGLE_TLV("LINEOUT2 Volume", <API key>, 0, 20, 1, line_gain), SOC_SINGLE_TLV("LINEOUT3 Volume", <API key>, 0, 20, 1, line_gain), SOC_SINGLE_TLV("LINEOUT4 Volume", <API key>, 0, 20, 1, line_gain), SOC_SINGLE_TLV("SPK DRV Volume", <API key>, 3, 8, 1, line_gain), SOC_SINGLE_TLV("SPK DRV2 Volume", <API key>, 3, 8, 1, line_gain), SOC_SINGLE_TLV("ADC1 Volume", TOMTOM_A_TX_1_GAIN, 2, 19, 0, analog_gain), SOC_SINGLE_TLV("ADC2 Volume", TOMTOM_A_TX_2_GAIN, 2, 19, 0, analog_gain), SOC_SINGLE_TLV("ADC3 Volume", TOMTOM_A_TX_3_GAIN, 2, 19, 0, analog_gain), SOC_SINGLE_TLV("ADC4 Volume", TOMTOM_A_TX_4_GAIN, 2, 19, 0, analog_gain), SOC_SINGLE_TLV("ADC5 Volume", TOMTOM_A_TX_5_GAIN, 2, 19, 0, analog_gain), SOC_SINGLE_TLV("ADC6 Volume", TOMTOM_A_TX_6_GAIN, 2, 19, 0, analog_gain), }; static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { uint32_t zl, zr; bool hphr; struct <API key> *mc; struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); struct tomtom_priv *priv = <API key>(codec); mc = (struct <API key> *)(kcontrol->private_value); hphr = mc->shift; <API key>(&priv->mbhc, &zl, &zr); pr_debug("%s: zl %u, zr %u\n", __func__, zl, zr); ucontrol->value.integer.value[0] = hphr ? zr : zl; return 0; } static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("HPHL Impedance", 0, 0, UINT_MAX, 0, <API key>, NULL), SOC_SINGLE_EXT("HPHR Impedance", 0, 1, UINT_MAX, 0, <API key>, NULL), }; static int tomtom_get_hph_type(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); struct tomtom_priv *priv = <API key>(codec); struct wcd9xxx_mbhc *mbhc; if (!priv) { pr_debug("%s: wcd9330 private data is NULL\n", __func__); return 0; } mbhc = &priv->mbhc; if (!mbhc) { pr_debug("%s: mbhc not initialized\n", __func__); return 0; } ucontrol->value.integer.value[0] = (u32) mbhc->hph_type; pr_debug("%s: hph_type = %u\n", __func__, mbhc->hph_type); return 0; } static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("HPH Type", 0, 0, UINT_MAX, 0, tomtom_get_hph_type, NULL), }; static const char * const rx_mix1_text[] = { "ZERO", "SRC1", "SRC2", "IIR1", "IIR2", "RX1", "RX2", "RX3", "RX4", "RX5", "RX6", "RX7" }; static const char * const rx8_mix1_text[] = { "ZERO", "IIR1", "IIR2", "RX1", "RX2", "RX3", "RX4", "RX5", "RX6", "RX7", "RX8" }; static const char * const rx_mix2_text[] = { "ZERO", "SRC1", "SRC2", "IIR1", "IIR2" }; static const char * const rx_rdac5_text[] = { "DEM4", "DEM3_INV" }; static const char * const rx_rdac7_text[] = { "DEM6", "DEM5_INV" }; static const char * const mad_sel_text[] = { "SPE", "MSM" }; static const char * const sb_tx1_mux_text[] = { "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7", "DEC1", "RMIX8" }; static const char * const sb_tx2_mux_text[] = { "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7", "DEC2", "RMIX8" }; static const char * const sb_tx3_mux_text[] = { "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7", "DEC3", "RMIX8" }; static const char * const sb_tx4_mux_text[] = { "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7", "DEC4", "RMIX8" }; static const char * const sb_tx5_mux_text[] = { "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7", "DEC5", "RMIX8" }; static const char * const sb_tx6_mux_text[] = { "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7", "DEC6", "RMIX8" }; static const char * const <API key>[] = { "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7", "DEC1", "DEC2", "DEC3", "DEC4", "DEC5", "DEC6", "DEC7", "DEC8", "DEC9", "DEC10" }; static const char * const dec1_mux_text[] = { "ZERO", "DMIC1", "ADC6", }; static const char * const dec2_mux_text[] = { "ZERO", "DMIC2", "ADC5", }; static const char * const dec3_mux_text[] = { "ZERO", "DMIC3", "ADC4", }; static const char * const dec4_mux_text[] = { "ZERO", "DMIC4", "ADC3", }; static const char * const dec5_mux_text[] = { "ZERO", "DMIC5", "ADC2", }; static const char * const dec6_mux_text[] = { "ZERO", "DMIC6", "ADC1", }; static const char * const dec7_mux_text[] = { "ZERO", "DMIC1", "DMIC6", "ADC1", "ADC6", "ANC1_FB", "ANC2_FB", }; static const char * const dec8_mux_text[] = { "ZERO", "DMIC2", "DMIC5", "ADC2", "ADC5", "ANC1_FB", "ANC2_FB", }; static const char * const dec9_mux_text[] = { "ZERO", "DMIC4", "DMIC5", "ADC2", "ADC3", "ADCMB", "ANC1_FB", "ANC2_FB", }; static const char * const dec10_mux_text[] = { "ZERO", "DMIC3", "DMIC6", "ADC1", "ADC4", "ADCMB", "ANC1_FB", "ANC2_FB", }; static const char * const anc_mux_text[] = { "ZERO", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6", "ADC_MB", "RSVD_1", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "DMIC5", "DMIC6" }; static const char * const anc1_fb_mux_text[] = { "ZERO", "EAR_HPH_L", "EAR_LINE_1", }; static const char * const iir_inp1_text[] = { "ZERO", "DEC1", "DEC2", "DEC3", "DEC4", "DEC5", "DEC6", "DEC7", "DEC8", "DEC9", "DEC10", "RX1", "RX2", "RX3", "RX4", "RX5", "RX6", "RX7" }; static const char * const iir_inp2_text[] = { "ZERO", "DEC1", "DEC2", "DEC3", "DEC4", "DEC5", "DEC6", "DEC7", "DEC8", "DEC9", "DEC10", "RX1", "RX2", "RX3", "RX4", "RX5", "RX6", "RX7" }; static const char * const iir_inp3_text[] = { "ZERO", "DEC1", "DEC2", "DEC3", "DEC4", "DEC5", "DEC6", "DEC7", "DEC8", "DEC9", "DEC10", "RX1", "RX2", "RX3", "RX4", "RX5", "RX6", "RX7" }; static const char * const iir_inp4_text[] = { "ZERO", "DEC1", "DEC2", "DEC3", "DEC4", "DEC5", "DEC6", "DEC7", "DEC8", "DEC9", "DEC10", "RX1", "RX2", "RX3", "RX4", "RX5", "RX6", "RX7" }; static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 0, 12, rx_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 4, 12, rx_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 0, 12, rx_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 0, 12, rx_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 4, 12, rx_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 0, 12, rx_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 4, 12, rx_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 0, 12, rx_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 4, 12, rx_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 0, 12, rx_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 4, 12, rx_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 0, 12, rx_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 4, 12, rx_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 0, 12, rx_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 4, 12, rx_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 0, 11, rx8_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 4, 11, rx8_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 0, 5, rx_mix2_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 3, 5, rx_mix2_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 0, 5, rx_mix2_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 3, 5, rx_mix2_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 0, 5, rx_mix2_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 3, 5, rx_mix2_text); static const struct soc_enum rx_rdac5_enum = SOC_ENUM_SINGLE(<API key>, 2, 2, rx_rdac5_text); static const struct soc_enum rx_rdac7_enum = SOC_ENUM_SINGLE(<API key>, 1, 2, rx_rdac7_text); static const struct soc_enum mad_sel_enum = SOC_ENUM_SINGLE(TOMTOM_A_SVASS_CFG, 0, 2, mad_sel_text); static const struct soc_enum sb_tx1_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 10, sb_tx1_mux_text); static const struct soc_enum sb_tx2_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 10, sb_tx2_mux_text); static const struct soc_enum sb_tx3_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 10, sb_tx3_mux_text); static const struct soc_enum sb_tx4_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 10, sb_tx4_mux_text); static const struct soc_enum sb_tx5_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 10, sb_tx5_mux_text); static const struct soc_enum sb_tx6_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 10, sb_tx6_mux_text); static const struct soc_enum sb_tx7_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 18, <API key>); static const struct soc_enum sb_tx8_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 18, <API key>); static const struct soc_enum sb_tx9_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 18, <API key>); static const struct soc_enum sb_tx10_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 18, <API key>); static const struct soc_enum dec1_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 3, dec1_mux_text); static const struct soc_enum dec2_mux_enum = SOC_ENUM_SINGLE(<API key>, 2, 3, dec2_mux_text); static const struct soc_enum dec3_mux_enum = SOC_ENUM_SINGLE(<API key>, 4, 3, dec3_mux_text); static const struct soc_enum dec4_mux_enum = SOC_ENUM_SINGLE(<API key>, 6, 3, dec4_mux_text); static const struct soc_enum dec5_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 3, dec5_mux_text); static const struct soc_enum dec6_mux_enum = SOC_ENUM_SINGLE(<API key>, 2, 3, dec6_mux_text); static const struct soc_enum dec7_mux_enum = SOC_ENUM_SINGLE(<API key>, 4, 7, dec7_mux_text); static const struct soc_enum dec8_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 7, dec8_mux_text); static const struct soc_enum dec9_mux_enum = SOC_ENUM_SINGLE(<API key>, 3, 8, dec9_mux_text); static const struct soc_enum dec10_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 8, dec10_mux_text); static const struct soc_enum anc1_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 15, anc_mux_text); static const struct soc_enum anc2_mux_enum = SOC_ENUM_SINGLE(<API key>, 4, 15, anc_mux_text); static const struct soc_enum anc1_fb_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 3, anc1_fb_mux_text); static const struct soc_enum iir1_inp1_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 18, iir_inp1_text); static const struct soc_enum iir2_inp1_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 18, iir_inp1_text); static const struct soc_enum iir1_inp2_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 18, iir_inp2_text); static const struct soc_enum iir2_inp2_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 18, iir_inp2_text); static const struct soc_enum iir1_inp3_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 18, iir_inp3_text); static const struct soc_enum iir2_inp3_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 18, iir_inp3_text); static const struct soc_enum iir1_inp4_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 18, iir_inp4_text); static const struct soc_enum iir2_inp4_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 18, iir_inp4_text); static const struct snd_kcontrol_new rx_mix1_inp1_mux = SOC_DAPM_ENUM("RX1 MIX1 INP1 Mux", <API key>); static const struct snd_kcontrol_new rx_mix1_inp2_mux = SOC_DAPM_ENUM("RX1 MIX1 INP2 Mux", <API key>); static const struct snd_kcontrol_new rx_mix1_inp3_mux = SOC_DAPM_ENUM("RX1 MIX1 INP3 Mux", <API key>); static const struct snd_kcontrol_new rx2_mix1_inp1_mux = SOC_DAPM_ENUM("RX2 MIX1 INP1 Mux", <API key>); static const struct snd_kcontrol_new rx2_mix1_inp2_mux = SOC_DAPM_ENUM("RX2 MIX1 INP2 Mux", <API key>); static const struct snd_kcontrol_new rx3_mix1_inp1_mux = SOC_DAPM_ENUM("RX3 MIX1 INP1 Mux", <API key>); static const struct snd_kcontrol_new rx3_mix1_inp2_mux = SOC_DAPM_ENUM("RX3 MIX1 INP2 Mux", <API key>); static const struct snd_kcontrol_new rx4_mix1_inp1_mux = SOC_DAPM_ENUM("RX4 MIX1 INP1 Mux", <API key>); static const struct snd_kcontrol_new rx4_mix1_inp2_mux = SOC_DAPM_ENUM("RX4 MIX1 INP2 Mux", <API key>); static const struct snd_kcontrol_new rx5_mix1_inp1_mux = SOC_DAPM_ENUM("RX5 MIX1 INP1 Mux", <API key>); static const struct snd_kcontrol_new rx5_mix1_inp2_mux = SOC_DAPM_ENUM("RX5 MIX1 INP2 Mux", <API key>); static const struct snd_kcontrol_new rx6_mix1_inp1_mux = SOC_DAPM_ENUM("RX6 MIX1 INP1 Mux", <API key>); static const struct snd_kcontrol_new rx6_mix1_inp2_mux = SOC_DAPM_ENUM("RX6 MIX1 INP2 Mux", <API key>); static const struct snd_kcontrol_new rx7_mix1_inp1_mux = SOC_DAPM_ENUM("RX7 MIX1 INP1 Mux", <API key>); static const struct snd_kcontrol_new rx7_mix1_inp2_mux = SOC_DAPM_ENUM("RX7 MIX1 INP2 Mux", <API key>); static const struct snd_kcontrol_new rx8_mix1_inp1_mux = SOC_DAPM_ENUM("RX8 MIX1 INP1 Mux", <API key>); static const struct snd_kcontrol_new rx8_mix1_inp2_mux = SOC_DAPM_ENUM("RX8 MIX1 INP2 Mux", <API key>); static const struct snd_kcontrol_new rx1_mix2_inp1_mux = SOC_DAPM_ENUM("RX1 MIX2 INP1 Mux", <API key>); static const struct snd_kcontrol_new rx1_mix2_inp2_mux = SOC_DAPM_ENUM("RX1 MIX2 INP2 Mux", <API key>); static const struct snd_kcontrol_new rx2_mix2_inp1_mux = SOC_DAPM_ENUM("RX2 MIX2 INP1 Mux", <API key>); static const struct snd_kcontrol_new rx2_mix2_inp2_mux = SOC_DAPM_ENUM("RX2 MIX2 INP2 Mux", <API key>); static const struct snd_kcontrol_new rx7_mix2_inp1_mux = SOC_DAPM_ENUM("RX7 MIX2 INP1 Mux", <API key>); static const struct snd_kcontrol_new rx7_mix2_inp2_mux = SOC_DAPM_ENUM("RX7 MIX2 INP2 Mux", <API key>); static const struct snd_kcontrol_new rx_dac5_mux = SOC_DAPM_ENUM("RDAC5 MUX Mux", rx_rdac5_enum); static const struct snd_kcontrol_new rx_dac7_mux = SOC_DAPM_ENUM("RDAC7 MUX Mux", rx_rdac7_enum); static const struct snd_kcontrol_new mad_sel_mux = SOC_DAPM_ENUM("MAD_SEL MUX Mux", mad_sel_enum); static const struct snd_kcontrol_new sb_tx1_mux = SOC_DAPM_ENUM("SLIM TX1 MUX Mux", sb_tx1_mux_enum); static const struct snd_kcontrol_new sb_tx2_mux = SOC_DAPM_ENUM("SLIM TX2 MUX Mux", sb_tx2_mux_enum); static const struct snd_kcontrol_new sb_tx3_mux = SOC_DAPM_ENUM("SLIM TX3 MUX Mux", sb_tx3_mux_enum); static const struct snd_kcontrol_new sb_tx4_mux = SOC_DAPM_ENUM("SLIM TX4 MUX Mux", sb_tx4_mux_enum); static const struct snd_kcontrol_new sb_tx5_mux = SOC_DAPM_ENUM("SLIM TX5 MUX Mux", sb_tx5_mux_enum); static const struct snd_kcontrol_new sb_tx6_mux = SOC_DAPM_ENUM("SLIM TX6 MUX Mux", sb_tx6_mux_enum); static const struct snd_kcontrol_new sb_tx7_mux = SOC_DAPM_ENUM("SLIM TX7 MUX Mux", sb_tx7_mux_enum); static const struct snd_kcontrol_new sb_tx8_mux = SOC_DAPM_ENUM("SLIM TX8 MUX Mux", sb_tx8_mux_enum); static const struct snd_kcontrol_new sb_tx9_mux = SOC_DAPM_ENUM("SLIM TX9 MUX Mux", sb_tx9_mux_enum); static const struct snd_kcontrol_new sb_tx10_mux = SOC_DAPM_ENUM("SLIM TX10 MUX Mux", sb_tx10_mux_enum); static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct <API key> *wlist = snd_kcontrol_chip(kcontrol); struct snd_soc_dapm_widget *w = wlist->widgets[0]; struct snd_soc_codec *codec = w->codec; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int dec_mux, decimator; char *dec_name = NULL; char *widget_name = NULL; char *temp; u16 tx_mux_ctl_reg; u8 adc_dmic_sel = 0x0; int ret = 0; char *dec; if (ucontrol->value.enumerated.item[0] > e->max - 1) return -EINVAL; dec_mux = ucontrol->value.enumerated.item[0]; widget_name = kstrndup(w->name, 15, GFP_KERNEL); if (!widget_name) return -ENOMEM; temp = widget_name; dec_name = strsep(&widget_name, " "); widget_name = temp; if (!dec_name) { pr_err("%s: Invalid decimator = %s\n", __func__, w->name); ret = -EINVAL; goto out; } dec = strpbrk(dec_name, "123456789"); if (!dec) { dev_err(w->dapm->dev, "%s: decimator index not found\n", __func__); ret = -EINVAL; goto out; } ret = kstrtouint(dec, 10, &decimator); if (ret < 0) { pr_err("%s: Invalid decimator = %s\n", __func__, dec_name); ret = -EINVAL; goto out; } dev_dbg(w->dapm->dev, "%s(): widget = %s decimator = %u dec_mux = %u\n" , __func__, w->name, decimator, dec_mux); switch (decimator) { case 1: case 2: case 3: case 4: case 5: case 6: if (dec_mux == 1) adc_dmic_sel = 0x1; else adc_dmic_sel = 0x0; break; case 7: case 8: case 9: case 10: if ((dec_mux == 1) || (dec_mux == 2)) adc_dmic_sel = 0x1; else adc_dmic_sel = 0x0; break; default: pr_err("%s: Invalid Decimator = %u\n", __func__, decimator); ret = -EINVAL; goto out; } tx_mux_ctl_reg = <API key> + 8 * (decimator - 1); snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x1, adc_dmic_sel); ret = <API key>(kcontrol, ucontrol); out: kfree(widget_name); return ret; } #define WCD9330_DEC_ENUM(xname, xenum) \ { .iface = <API key>, .name = xname, \ .info = <API key>, \ .get = <API key>, \ .put = <API key>, \ .private_value = (unsigned long)&xenum } static const struct snd_kcontrol_new dec1_mux = WCD9330_DEC_ENUM("DEC1 MUX Mux", dec1_mux_enum); static const struct snd_kcontrol_new dec2_mux = WCD9330_DEC_ENUM("DEC2 MUX Mux", dec2_mux_enum); static const struct snd_kcontrol_new dec3_mux = WCD9330_DEC_ENUM("DEC3 MUX Mux", dec3_mux_enum); static const struct snd_kcontrol_new dec4_mux = WCD9330_DEC_ENUM("DEC4 MUX Mux", dec4_mux_enum); static const struct snd_kcontrol_new dec5_mux = WCD9330_DEC_ENUM("DEC5 MUX Mux", dec5_mux_enum); static const struct snd_kcontrol_new dec6_mux = WCD9330_DEC_ENUM("DEC6 MUX Mux", dec6_mux_enum); static const struct snd_kcontrol_new dec7_mux = WCD9330_DEC_ENUM("DEC7 MUX Mux", dec7_mux_enum); static const struct snd_kcontrol_new dec8_mux = WCD9330_DEC_ENUM("DEC8 MUX Mux", dec8_mux_enum); static const struct snd_kcontrol_new dec9_mux = WCD9330_DEC_ENUM("DEC9 MUX Mux", dec9_mux_enum); static const struct snd_kcontrol_new dec10_mux = WCD9330_DEC_ENUM("DEC10 MUX Mux", dec10_mux_enum); static const struct snd_kcontrol_new iir1_inp1_mux = SOC_DAPM_ENUM("IIR1 INP1 Mux", iir1_inp1_mux_enum); static const struct snd_kcontrol_new iir2_inp1_mux = SOC_DAPM_ENUM("IIR2 INP1 Mux", iir2_inp1_mux_enum); static const struct snd_kcontrol_new iir1_inp2_mux = SOC_DAPM_ENUM("IIR1 INP2 Mux", iir1_inp2_mux_enum); static const struct snd_kcontrol_new iir2_inp2_mux = SOC_DAPM_ENUM("IIR2 INP2 Mux", iir2_inp2_mux_enum); static const struct snd_kcontrol_new iir1_inp3_mux = SOC_DAPM_ENUM("IIR1 INP3 Mux", iir1_inp3_mux_enum); static const struct snd_kcontrol_new iir2_inp3_mux = SOC_DAPM_ENUM("IIR2 INP3 Mux", iir2_inp3_mux_enum); static const struct snd_kcontrol_new iir1_inp4_mux = SOC_DAPM_ENUM("IIR1 INP4 Mux", iir1_inp4_mux_enum); static const struct snd_kcontrol_new iir2_inp4_mux = SOC_DAPM_ENUM("IIR2 INP4 Mux", iir2_inp4_mux_enum); static const struct snd_kcontrol_new anc1_mux = SOC_DAPM_ENUM("ANC1 MUX Mux", anc1_mux_enum); static const struct snd_kcontrol_new anc2_mux = SOC_DAPM_ENUM("ANC2 MUX Mux", anc2_mux_enum); static const struct snd_kcontrol_new anc1_fb_mux = SOC_DAPM_ENUM("ANC1 FB MUX Mux", anc1_fb_mux_enum); static const struct snd_kcontrol_new dac1_switch[] = { SOC_DAPM_SINGLE("Switch", TOMTOM_A_RX_EAR_EN, 5, 1, 0) }; static const struct snd_kcontrol_new hphl_switch[] = { SOC_DAPM_SINGLE("Switch", <API key>, 6, 1, 0) }; static const struct snd_kcontrol_new hphl_pa_mix[] = { SOC_DAPM_SINGLE("AUX_PGA_L Switch", <API key>, 7, 1, 0), }; static const struct snd_kcontrol_new hphr_pa_mix[] = { SOC_DAPM_SINGLE("AUX_PGA_R Switch", <API key>, 6, 1, 0), }; static const struct snd_kcontrol_new ear_pa_mix[] = { SOC_DAPM_SINGLE("AUX_PGA_L Switch", <API key>, 5, 1, 0), }; static const struct snd_kcontrol_new lineout1_pa_mix[] = { SOC_DAPM_SINGLE("AUX_PGA_L Switch", <API key>, 4, 1, 0), }; static const struct snd_kcontrol_new lineout2_pa_mix[] = { SOC_DAPM_SINGLE("AUX_PGA_R Switch", <API key>, 3, 1, 0), }; static const struct snd_kcontrol_new lineout3_pa_mix[] = { SOC_DAPM_SINGLE("AUX_PGA_L Switch", <API key>, 2, 1, 0), }; static const struct snd_kcontrol_new lineout4_pa_mix[] = { SOC_DAPM_SINGLE("AUX_PGA_R Switch", <API key>, 1, 1, 0), }; static const struct snd_kcontrol_new <API key> = SOC_DAPM_SINGLE("Switch", <API key>, 6, 1, 0); static const struct snd_kcontrol_new <API key> = SOC_DAPM_SINGLE("Switch", <API key>, 6, 1, 0); static const struct snd_kcontrol_new aif4_mad_switch = SOC_DAPM_SINGLE("Switch", <API key>, 0, 1, 0); static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct <API key> *wlist = snd_kcontrol_chip(kcontrol); struct snd_soc_dapm_widget *widget = wlist->widgets[0]; ucontrol->value.integer.value[0] = widget->value; return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct <API key> *wlist = snd_kcontrol_chip(kcontrol); struct snd_soc_dapm_widget *widget = wlist->widgets[0]; struct snd_soc_codec *codec = widget->codec; struct tomtom_priv *tomtom_p = <API key>(codec); struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent); struct <API key> *mixer = ((struct <API key> *)kcontrol->private_value); u32 dai_id = widget->shift; u32 port_id = mixer->shift; u32 enable = ucontrol->value.integer.value[0]; pr_debug("%s: enable: %d, port_id:%d, dai_id: %d\n", __func__, enable, port_id, dai_id); mutex_lock(&codec->mutex); if (enable) { if (port_id == TOMTOM_TX11 && !test_bit(VI_SENSE_1, &tomtom_p->status_mask)) { list_add_tail(&core->tx_chs[TOMTOM_TX11].list, &tomtom_p->dai[dai_id].wcd9xxx_ch_list); list_add_tail(&core->tx_chs[TOMTOM_TX12].list, &tomtom_p->dai[dai_id].wcd9xxx_ch_list); set_bit(VI_SENSE_1, &tomtom_p->status_mask); } if (port_id == TOMTOM_TX14 && !test_bit(VI_SENSE_2, &tomtom_p->status_mask)) { list_add_tail(&core->tx_chs[TOMTOM_TX14].list, &tomtom_p->dai[dai_id].wcd9xxx_ch_list); list_add_tail(&core->tx_chs[TOMTOM_TX15].list, &tomtom_p->dai[dai_id].wcd9xxx_ch_list); set_bit(VI_SENSE_2, &tomtom_p->status_mask); } } else { if (port_id == TOMTOM_TX11 && test_bit(VI_SENSE_1, &tomtom_p->status_mask)) { list_del_init(&core->tx_chs[TOMTOM_TX11].list); list_del_init(&core->tx_chs[TOMTOM_TX12].list); clear_bit(VI_SENSE_1, &tomtom_p->status_mask); } if (port_id == TOMTOM_TX14 && test_bit(VI_SENSE_2, &tomtom_p->status_mask)) { list_del_init(&core->tx_chs[TOMTOM_TX14].list); list_del_init(&core->tx_chs[TOMTOM_TX15].list); clear_bit(VI_SENSE_2, &tomtom_p->status_mask); } } mutex_unlock(&codec->mutex); <API key>(widget, kcontrol, enable); return 0; } /* virtual port entries */ static int slim_tx_mixer_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct <API key> *wlist = snd_kcontrol_chip(kcontrol); struct snd_soc_dapm_widget *widget = wlist->widgets[0]; ucontrol->value.integer.value[0] = widget->value; return 0; } static int slim_tx_mixer_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct <API key> *wlist = snd_kcontrol_chip(kcontrol); struct snd_soc_dapm_widget *widget = wlist->widgets[0]; struct snd_soc_codec *codec = widget->codec; struct tomtom_priv *tomtom_p = <API key>(codec); struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent); struct <API key> *mixer = ((struct <API key> *)kcontrol->private_value); u32 dai_id = widget->shift; u32 port_id = mixer->shift; u32 enable = ucontrol->value.integer.value[0]; u32 vtable = vport_check_table[dai_id]; pr_debug("%s: wname %s cname %s value %u shift %d item %ld\n", __func__, widget->name, ucontrol->id.name, widget->value, widget->shift, ucontrol->value.integer.value[0]); mutex_lock(&codec->mutex); if (tomtom_p->intf_type != <API key>) { if (dai_id != AIF1_CAP) { dev_err(codec->dev, "%s: invalid AIF for I2C mode\n", __func__); mutex_unlock(&codec->mutex); return -EINVAL; } } switch (dai_id) { case AIF1_CAP: case AIF2_CAP: case AIF3_CAP: /* only add to the list if value not set */ if (enable && !(widget->value & 1 << port_id)) { if (tomtom_p->intf_type == <API key>) vtable = vport_check_table[dai_id]; if (tomtom_p->intf_type == <API key>) vtable = <API key>[dai_id]; if (<API key>( vtable, port_id, tomtom_p->dai, NUM_CODEC_DAIS)) { dev_dbg(codec->dev, "%s: TX%u is used by other virtual port\n", __func__, port_id + 1); mutex_unlock(&codec->mutex); return 0; } widget->value |= 1 << port_id; list_add_tail(&core->tx_chs[port_id].list, &tomtom_p->dai[dai_id].wcd9xxx_ch_list ); } else if (!enable && (widget->value & 1 << port_id)) { widget->value &= ~(1 << port_id); list_del_init(&core->tx_chs[port_id].list); } else { if (enable) dev_dbg(codec->dev, "%s: TX%u port is used by\n" "this virtual port\n", __func__, port_id + 1); else dev_dbg(codec->dev, "%s: TX%u port is not used by\n" "this virtual port\n", __func__, port_id + 1); /* avoid update power function */ mutex_unlock(&codec->mutex); return 0; } break; default: pr_err("Unknown AIF %d\n", dai_id); mutex_unlock(&codec->mutex); return -EINVAL; } pr_debug("%s: name %s sname %s updated value %u shift %d\n", __func__, widget->name, widget->sname, widget->value, widget->shift); mutex_unlock(&codec->mutex); <API key>(widget, kcontrol, enable); return 0; } static int slim_rx_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct <API key> *wlist = snd_kcontrol_chip(kcontrol); struct snd_soc_dapm_widget *widget = wlist->widgets[0]; ucontrol->value.enumerated.item[0] = widget->value; return 0; } static const char *const slim_rx_mux_text[] = { "ZERO", "AIF1_PB", "AIF2_PB", "AIF3_PB" }; static int slim_rx_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct <API key> *wlist = snd_kcontrol_chip(kcontrol); struct snd_soc_dapm_widget *widget = wlist->widgets[0]; struct snd_soc_codec *codec = widget->codec; struct tomtom_priv *tomtom_p = <API key>(codec); struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; u32 port_id = widget->shift; pr_debug("%s: wname %s cname %s value %u shift %d item %ld\n", __func__, widget->name, ucontrol->id.name, widget->value, widget->shift, ucontrol->value.integer.value[0]); widget->value = ucontrol->value.enumerated.item[0]; mutex_lock(&codec->mutex); if (tomtom_p->intf_type != <API key>) { if (widget->value > 2) { dev_err(codec->dev, "%s: invalid AIF for I2C mode\n", __func__); goto err; } } /* value need to match the Virtual port and AIF number */ switch (widget->value) { case 0: list_del_init(&core->rx_chs[port_id].list); break; case 1: if (<API key>(port_id + <API key>, &tomtom_p->dai[AIF1_PB].wcd9xxx_ch_list)) { dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n", __func__, port_id + 1); goto rtn; } list_add_tail(&core->rx_chs[port_id].list, &tomtom_p->dai[AIF1_PB].wcd9xxx_ch_list); break; case 2: if (<API key>(port_id + <API key>, &tomtom_p->dai[AIF2_PB].wcd9xxx_ch_list)) { dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n", __func__, port_id + 1); goto rtn; } list_add_tail(&core->rx_chs[port_id].list, &tomtom_p->dai[AIF2_PB].wcd9xxx_ch_list); break; case 3: if (<API key>(port_id + <API key>, &tomtom_p->dai[AIF3_PB].wcd9xxx_ch_list)) { dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n", __func__, port_id + 1); goto rtn; } list_add_tail(&core->rx_chs[port_id].list, &tomtom_p->dai[AIF3_PB].wcd9xxx_ch_list); break; default: pr_err("Unknown AIF %d\n", widget->value); goto err; } rtn: mutex_unlock(&codec->mutex); <API key>(widget, kcontrol, widget->value, e); return 0; err: mutex_unlock(&codec->mutex); return -EINVAL; } static const struct soc_enum slim_rx_mux_enum = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(slim_rx_mux_text), slim_rx_mux_text); static const struct snd_kcontrol_new slim_rx_mux[TOMTOM_RX_MAX] = { SOC_DAPM_ENUM_EXT("SLIM RX1 Mux", slim_rx_mux_enum, slim_rx_mux_get, slim_rx_mux_put), SOC_DAPM_ENUM_EXT("SLIM RX2 Mux", slim_rx_mux_enum, slim_rx_mux_get, slim_rx_mux_put), SOC_DAPM_ENUM_EXT("SLIM RX3 Mux", slim_rx_mux_enum, slim_rx_mux_get, slim_rx_mux_put), SOC_DAPM_ENUM_EXT("SLIM RX4 Mux", slim_rx_mux_enum, slim_rx_mux_get, slim_rx_mux_put), SOC_DAPM_ENUM_EXT("SLIM RX5 Mux", slim_rx_mux_enum, slim_rx_mux_get, slim_rx_mux_put), SOC_DAPM_ENUM_EXT("SLIM RX6 Mux", slim_rx_mux_enum, slim_rx_mux_get, slim_rx_mux_put), SOC_DAPM_ENUM_EXT("SLIM RX7 Mux", slim_rx_mux_enum, slim_rx_mux_get, slim_rx_mux_put), SOC_DAPM_ENUM_EXT("SLIM RX8 Mux", slim_rx_mux_enum, slim_rx_mux_get, slim_rx_mux_put), }; static const struct snd_kcontrol_new aif4_vi_mixer[] = { SOC_SINGLE_EXT("SPKR_VI_1", SND_SOC_NOPM, TOMTOM_TX11, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("SPKR_VI_2", SND_SOC_NOPM, TOMTOM_TX14, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new aif1_cap_mixer[] = { SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TOMTOM_TX1, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TOMTOM_TX2, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TOMTOM_TX3, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TOMTOM_TX4, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TOMTOM_TX5, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TOMTOM_TX6, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TOMTOM_TX7, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TOMTOM_TX8, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TOMTOM_TX9, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TOMTOM_TX10, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), }; static const struct snd_kcontrol_new aif2_cap_mixer[] = { SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TOMTOM_TX1, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TOMTOM_TX2, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TOMTOM_TX3, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TOMTOM_TX4, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TOMTOM_TX5, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TOMTOM_TX6, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TOMTOM_TX7, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TOMTOM_TX8, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TOMTOM_TX9, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TOMTOM_TX10, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), }; static const struct snd_kcontrol_new aif3_cap_mixer[] = { SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TOMTOM_TX1, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TOMTOM_TX2, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TOMTOM_TX3, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TOMTOM_TX4, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TOMTOM_TX5, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, TOMTOM_TX6, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, TOMTOM_TX7, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, TOMTOM_TX8, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, TOMTOM_TX9, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, TOMTOM_TX10, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), }; static void <API key>(struct snd_soc_codec *codec, int enable) { struct tomtom_priv *tomtom = <API key>(codec); pr_debug("%s %d\n", __func__, enable); if (enable) { tomtom->adc_count++; snd_soc_update_bits(codec, <API key>, 0x2, 0x2); } else { tomtom->adc_count if (!tomtom->adc_count) snd_soc_update_bits(codec, <API key>, 0x2, 0x0); } } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tomtom_priv *priv = <API key>(codec); u16 adc_reg; u16 tx_fe_clkdiv_reg; u8 tx_fe_clkdiv_mask; u8 init_bit_shift; u8 bit_pos; pr_debug("%s %d\n", __func__, event); switch (w->reg) { case TOMTOM_A_TX_1_GAIN: adc_reg = <API key>; tx_fe_clkdiv_reg = <API key>; tx_fe_clkdiv_mask = 0x0F; init_bit_shift = 7; bit_pos = ADC1_TXFE; break; case TOMTOM_A_TX_2_GAIN: adc_reg = <API key>; tx_fe_clkdiv_reg = <API key>; tx_fe_clkdiv_mask = 0xF0; init_bit_shift = 6; bit_pos = ADC2_TXFE; break; case TOMTOM_A_TX_3_GAIN: adc_reg = <API key>; init_bit_shift = 7; tx_fe_clkdiv_reg = <API key>; tx_fe_clkdiv_mask = 0x0F; bit_pos = ADC3_TXFE; break; case TOMTOM_A_TX_4_GAIN: adc_reg = <API key>; init_bit_shift = 6; tx_fe_clkdiv_reg = <API key>; tx_fe_clkdiv_mask = 0xF0; bit_pos = ADC4_TXFE; break; case TOMTOM_A_TX_5_GAIN: adc_reg = <API key>; init_bit_shift = 7; tx_fe_clkdiv_reg = <API key>; tx_fe_clkdiv_mask = 0x0F; bit_pos = ADC5_TXFE; break; case TOMTOM_A_TX_6_GAIN: adc_reg = <API key>; init_bit_shift = 6; tx_fe_clkdiv_reg = <API key>; tx_fe_clkdiv_mask = 0xF0; bit_pos = ADC6_TXFE; break; default: pr_err("%s: Error, invalid adc register\n", __func__); return -EINVAL; } switch (event) { case <API key>: snd_soc_update_bits(codec, tx_fe_clkdiv_reg, tx_fe_clkdiv_mask, 0x0); set_bit(bit_pos, &priv->status_mask); <API key>(codec, 1); snd_soc_update_bits(codec, adc_reg, 1 << init_bit_shift, 1 << init_bit_shift); break; case <API key>: snd_soc_update_bits(codec, adc_reg, 1 << init_bit_shift, 0x00); break; case <API key>: <API key>(codec, 0); break; } return 0; } static int <API key>(struct snd_soc_codec *codec, int enable, bool dapm) { struct tomtom_priv *tomtom = <API key>(codec); if (!tomtom->codec_ext_clk_en_cb) { dev_err(codec->dev, "%s: Invalid ext_clk_callback\n", __func__); return -EINVAL; } return tomtom->codec_ext_clk_en_cb(codec, enable, dapm); } static int <API key>(struct tomtom_priv *tomtom, int mclk_enable) { int ret = 0; WCD9XXX_BG_CLK_LOCK(&tomtom->resmgr); if (mclk_enable) { tomtom->ext_clk_users++; if (tomtom->ext_clk_users > 1) goto bg_clk_unlock; ret = clk_prepare_enable(tomtom->wcd_ext_clk); if (ret) { pr_err("%s: ext clk enable failed\n", __func__); tomtom->ext_clk_users goto bg_clk_unlock; } <API key>(&tomtom->resmgr, <API key>); <API key>(&tomtom->resmgr, WCD9XXX_CLK_MCLK); } else { tomtom->ext_clk_users if (tomtom->ext_clk_users == 0) { /* Put clock and BG */ <API key>(&tomtom->resmgr, WCD9XXX_CLK_MCLK); <API key>(&tomtom->resmgr, <API key>); <API key>(tomtom->wcd_ext_clk); } } bg_clk_unlock: <API key>(&tomtom->resmgr); return ret; } int <API key>(struct snd_soc_codec *codec, int enable, bool dapm) { struct tomtom_priv *tomtom = <API key>(codec); if (tomtom->wcd_ext_clk) { dev_dbg(codec->dev, "%s: mclk_enable = %u, dapm = %d\n", __func__, enable, dapm); return <API key>(tomtom, enable); } else if (tomtom->codec_ext_clk_en_cb) return <API key>(codec, enable, dapm); else { dev_err(codec->dev, "%s: Cannot turn on MCLK\n", __func__); return -EINVAL; } } EXPORT_SYMBOL(<API key>); static int <API key>(struct tomtom_priv *tomtom) { if (tomtom->wcd_ext_clk) return tomtom->ext_clk_users; else if (tomtom-><API key>) return tomtom-><API key>(); else return 0; } /* <API key>( ) * Make sure that BG_CLK_LOCK is not acquired. Exit if acquired to avoid * potential deadlock as ext_clk_en_cb() also tries to acquire the same * lock to enable MCLK for RCO calibration */ static int <API key>(struct snd_soc_codec *codec, bool enable) { struct tomtom_priv *tomtom = <API key>(codec); int ret = 0; if (mutex_is_locked(&tomtom->resmgr.codec_bg_clk_lock)) { dev_err(codec->dev, "%s: BG_CLK already acquired\n", __func__); ret = -EINVAL; goto done; } if (enable) { if (<API key>(&tomtom->resmgr) == WCD9XXX_CLK_RCO) { WCD9XXX_BG_CLK_LOCK(&tomtom->resmgr); <API key>(&tomtom->resmgr, WCD9XXX_CLK_RCO); <API key>(&tomtom->resmgr); } else { <API key>(codec, true, false); WCD9XXX_BG_CLK_LOCK(&tomtom->resmgr); tomtom->resmgr.ext_clk_users = <API key>(tomtom); <API key>(&tomtom->resmgr, WCD9XXX_CLK_RCO); <API key>(&tomtom->resmgr); <API key>(codec, false, false); } } else { WCD9XXX_BG_CLK_LOCK(&tomtom->resmgr); <API key>(&tomtom->resmgr, WCD9XXX_CLK_RCO); <API key>(&tomtom->resmgr); } done: return ret; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tomtom_priv *tomtom = <API key>(codec); pr_debug("%s: %d\n", __func__, event); switch (event) { case <API key>: WCD9XXX_BG_CLK_LOCK(&tomtom->resmgr); <API key>(&tomtom->resmgr, <API key>); <API key>(&tomtom->resmgr); /* AUX PGA requires RCO or MCLK */ <API key>(codec, true); WCD9XXX_BG_CLK_LOCK(&tomtom->resmgr); <API key>(&tomtom->resmgr, 1); <API key>(&tomtom->resmgr); break; case <API key>: WCD9XXX_BG_CLK_LOCK(&tomtom->resmgr); <API key>(&tomtom->resmgr, 0); <API key>(&tomtom->resmgr); <API key>(codec, false); WCD9XXX_BG_CLK_LOCK(&tomtom->resmgr); <API key>(&tomtom->resmgr, <API key>); <API key>(&tomtom->resmgr); break; } return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tomtom_priv *tomtom = <API key>(codec); u16 lineout_gain_reg; pr_debug("%s %d %s\n", __func__, event, w->name); switch (w->shift) { case 0: lineout_gain_reg = <API key>; break; case 1: lineout_gain_reg = <API key>; break; case 2: lineout_gain_reg = <API key>; break; case 3: lineout_gain_reg = <API key>; break; default: pr_err("%s: Error, incorrect lineout register value\n", __func__); return -EINVAL; } switch (event) { case <API key>: snd_soc_update_bits(codec, lineout_gain_reg, 0x40, 0x40); break; case <API key>: wcd9xxx_clsh_fsm(codec, &tomtom->clsh_d, <API key>, <API key>, <API key>); pr_debug("%s: sleeping 5 ms after %s PA turn on\n", __func__, w->name); /* Wait for CnP time after PA enable */ usleep_range(5000, 5100); break; case <API key>: snd_soc_update_bits(codec, lineout_gain_reg, 0x40, 0x00); pr_debug("%s: sleeping 5 ms after %s PA turn off\n", __func__, w->name); /* Wait for CnP time after PA disable */ usleep_range(5000, 5100); break; } return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tomtom_priv *tomtom = <API key>(codec); u16 spk_drv_reg; pr_debug("%s: %d %s\n", __func__, event, w->name); if (strnstr(w->name, "SPK2 PA", sizeof("SPK2 PA"))) spk_drv_reg = <API key>; else spk_drv_reg = <API key>; switch (event) { case <API key>: tomtom->spkr_pa_widget_on = true; snd_soc_update_bits(codec, spk_drv_reg, 0x80, 0x80); break; case <API key>: tomtom->spkr_pa_widget_on = false; snd_soc_update_bits(codec, spk_drv_reg, 0x80, 0x00); break; } return 0; } static u8 <API key>(struct snd_soc_codec *codec, u32 mclk_rate, u32 dmic_clk_rate) { u32 div_factor; u8 dmic_ctl_val; dev_dbg(codec->dev, "%s: mclk_rate = %d, dmic_sample_rate = %d\n", __func__, mclk_rate, dmic_clk_rate); /* Default value to return in case of error */ if (mclk_rate == <API key>) dmic_ctl_val = <API key>; else dmic_ctl_val = <API key>; if (dmic_clk_rate == 0) { dev_err(codec->dev, "%s: dmic_sample_rate cannot be 0\n", __func__); goto done; } div_factor = mclk_rate / dmic_clk_rate; switch (div_factor) { case 2: dmic_ctl_val = <API key>; break; case 3: dmic_ctl_val = <API key>; break; case 4: dmic_ctl_val = <API key>; break; case 6: dmic_ctl_val = <API key>; break; case 16: dmic_ctl_val = <API key>; break; default: dev_err(codec->dev, "%s: Invalid div_factor %u, clk_rate(%u), dmic_rate(%u)\n", __func__, div_factor, mclk_rate, dmic_clk_rate); break; } done: return dmic_ctl_val; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tomtom_priv *tomtom = <API key>(codec); struct wcd9xxx_pdata *pdata = tomtom->resmgr.pdata; u8 dmic_clk_en; u16 dmic_clk_reg; s32 *dmic_clk_cnt; u8 dmic_rate_val, dmic_rate_shift; unsigned int dmic; int ret; char *wname; wname = strpbrk(w->name, "123456"); if (!wname) { dev_err(codec->dev, "%s: widget not found\n", __func__); return -EINVAL; } ret = kstrtouint(wname, 10, &dmic); if (ret < 0) { pr_err("%s: Invalid DMIC line on the codec\n", __func__); return -EINVAL; } switch (dmic) { case 1: case 2: dmic_clk_en = 0x01; dmic_clk_cnt = &(tomtom->dmic_1_2_clk_cnt); dmic_clk_reg = <API key>; dmic_rate_shift = 5; pr_debug("%s() event %d DMIC%d dmic_1_2_clk_cnt %d\n", __func__, event, dmic, *dmic_clk_cnt); break; case 3: case 4: dmic_clk_en = 0x02; dmic_clk_cnt = &(tomtom->dmic_3_4_clk_cnt); dmic_clk_reg = <API key>; dmic_rate_shift = 1; pr_debug("%s() event %d DMIC%d dmic_3_4_clk_cnt %d\n", __func__, event, dmic, *dmic_clk_cnt); break; case 5: case 6: dmic_clk_en = 0x04; dmic_clk_cnt = &(tomtom->dmic_5_6_clk_cnt); dmic_clk_reg = <API key>; dmic_rate_shift = 4; pr_debug("%s() event %d DMIC%d dmic_5_6_clk_cnt %d\n", __func__, event, dmic, *dmic_clk_cnt); break; default: pr_err("%s: Invalid DMIC Selection\n", __func__); return -EINVAL; } switch (event) { case <API key>: dmic_rate_val = <API key>(codec, pdata->mclk_rate, pdata->dmic_sample_rate); (*dmic_clk_cnt)++; if (*dmic_clk_cnt == 1) { snd_soc_update_bits(codec, dmic_clk_reg, 0x07 << dmic_rate_shift, dmic_rate_val << dmic_rate_shift); snd_soc_update_bits(codec, <API key>, dmic_clk_en, dmic_clk_en); } break; case <API key>: dmic_rate_val = <API key>(codec, pdata->mclk_rate, pdata-><API key>); (*dmic_clk_cnt) if (*dmic_clk_cnt == 0) { snd_soc_update_bits(codec, <API key>, dmic_clk_en, 0); snd_soc_update_bits(codec, dmic_clk_reg, 0x07 << dmic_rate_shift, dmic_rate_val << dmic_rate_shift); } break; } return 0; } static int <API key>(struct snd_soc_codec *codec) { int ret; const struct firmware *fw; struct firmware_cal *hwdep_cal = NULL; struct mad_audio_cal *mad_cal; const void *data; const char *filename = <API key>; struct tomtom_priv *tomtom = <API key>(codec); size_t cal_size; int idx; pr_debug("%s: enter\n", __func__); if (!tomtom->fw_data) { dev_err(codec->dev, "%s: invalid cal data\n", __func__); return -ENODEV; } hwdep_cal = wcdcal_get_fw_cal(tomtom->fw_data, WCD9XXX_MAD_CAL); if (hwdep_cal) { data = hwdep_cal->data; cal_size = hwdep_cal->size; dev_dbg(codec->dev, "%s: using hwdep calibration\n", __func__); } else { ret = request_firmware(&fw, filename, codec->dev); if (ret != 0) { pr_err("Failed to acquire MAD firwmare data %s: %d\n", filename, ret); return -ENODEV; } if (!fw) { dev_err(codec->dev, "failed to get mad fw"); return -ENODEV; } data = fw->data; cal_size = fw->size; dev_dbg(codec->dev, "%s: using request_firmware calibration\n", __func__); } if (cal_size < sizeof(struct mad_audio_cal)) { pr_err("%s: incorrect hwdep cal size %zu\n", __func__, cal_size); ret = -ENOMEM; goto err; } mad_cal = (struct mad_audio_cal *)(data); if (!mad_cal) { dev_err(codec->dev, "%s: Invalid calibration data\n", __func__); ret = -EINVAL; goto err; } snd_soc_write(codec, <API key>, mad_cal->microphone_info.cycle_time); snd_soc_update_bits(codec, <API key>, 0xFF << 3, ((uint16_t)mad_cal->microphone_info.settle_time) << 3); /* Audio */ snd_soc_write(codec, <API key>, mad_cal->audio_info.rms_omit_samples); snd_soc_update_bits(codec, <API key>, 0x07 << 4, mad_cal->audio_info.rms_comp_time << 4); snd_soc_update_bits(codec, <API key>, 0x03 << 2, mad_cal->audio_info.detection_mechanism << 2); snd_soc_write(codec, <API key>, mad_cal->audio_info.rms_diff_threshold & 0x3F); snd_soc_write(codec, <API key>, mad_cal->audio_info.rms_threshold_lsb); snd_soc_write(codec, <API key>, mad_cal->audio_info.rms_threshold_msb); for (idx = 0; idx < ARRAY_SIZE(mad_cal->audio_info.iir_coefficients); idx++) { snd_soc_update_bits(codec, <API key>, 0x3F, idx); snd_soc_write(codec, <API key>, mad_cal->audio_info.iir_coefficients[idx]); dev_dbg(codec->dev, "%s:MAD Audio IIR Coef[%d] = 0X%x", __func__, idx, mad_cal->audio_info.iir_coefficients[idx]); } /* Beacon */ snd_soc_write(codec, <API key>, mad_cal->beacon_info.rms_omit_samples); snd_soc_update_bits(codec, <API key>, 0x07 << 4, mad_cal->beacon_info.rms_comp_time); snd_soc_update_bits(codec, <API key>, 0x03 << 2, mad_cal->beacon_info.detection_mechanism << 2); snd_soc_write(codec, <API key>, mad_cal->beacon_info.rms_diff_threshold & 0x1F); snd_soc_write(codec, <API key>, mad_cal->beacon_info.rms_threshold_lsb); snd_soc_write(codec, <API key>, mad_cal->beacon_info.rms_threshold_msb); /* Ultrasound */ snd_soc_update_bits(codec, <API key>, 0x07 << 4, mad_cal->beacon_info.rms_comp_time); snd_soc_update_bits(codec, <API key>, 0x03 << 2, mad_cal->ultrasound_info.detection_mechanism); snd_soc_write(codec, <API key>, mad_cal->ultrasound_info.rms_diff_threshold & 0x1F); snd_soc_write(codec, <API key>, mad_cal->ultrasound_info.rms_threshold_lsb); snd_soc_write(codec, <API key>, mad_cal->ultrasound_info.rms_threshold_msb); /* Set MAD intr time to 20 msec */ snd_soc_update_bits(codec, 0x4E, 0x01F, 0x13); pr_debug("%s: leave ret %d\n", __func__, ret); err: if (!hwdep_cal) release_firmware(fw); return ret; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tomtom_priv *tomtom = <API key>(codec); int ret = 0; u8 mad_micb, mad_cfilt; u16 mad_cfilt_reg; mad_micb = snd_soc_read(codec, <API key>) & 0x07; switch (mad_micb) { case 1: mad_cfilt = tomtom->resmgr.pdata->micbias.bias1_cfilt_sel; break; case 2: mad_cfilt = tomtom->resmgr.pdata->micbias.bias2_cfilt_sel; break; case 3: mad_cfilt = tomtom->resmgr.pdata->micbias.bias3_cfilt_sel; break; case 4: mad_cfilt = tomtom->resmgr.pdata->micbias.bias4_cfilt_sel; break; default: dev_err(codec->dev, "%s: Invalid micbias selection 0x%x\n", __func__, mad_micb); return -EINVAL; } switch (mad_cfilt) { case WCD9XXX_CFILT1_SEL: mad_cfilt_reg = <API key>; break; case WCD9XXX_CFILT2_SEL: mad_cfilt_reg = <API key>; break; case WCD9XXX_CFILT3_SEL: mad_cfilt_reg = <API key>; break; default: dev_err(codec->dev, "%s: invalid cfilt 0x%x for micb 0x%x\n", __func__, mad_cfilt, mad_micb); return -EINVAL; } dev_dbg(codec->dev, "%s event = %d, mad_cfilt_reg = 0x%x\n", __func__, event, mad_cfilt_reg); switch (event) { case <API key>: /* Undo reset for MAD */ snd_soc_update_bits(codec, <API key>, 0x02, 0x00); ret = <API key>(codec); if (ret) { pr_err("%s: Failed to config MAD\n", __func__); break; } /* setup MAD micbias to VDDIO */ snd_soc_update_bits(codec, mad_cfilt_reg, 0x02, 0x02); break; case <API key>: /* Reset the MAD block */ snd_soc_update_bits(codec, <API key>, 0x02, 0x02); /* Undo setup of MAD micbias to VDDIO */ snd_soc_update_bits(codec, mad_cfilt_reg, 0x02, 0x00); } return ret; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tomtom_priv *tomtom = <API key>(codec); u16 micb_int_reg = 0, micb_ctl_reg = 0; u8 cfilt_sel_val = 0; char *internal1_text = "Internal1"; char *internal2_text = "Internal2"; char *internal3_text = "Internal3"; enum <API key> e_post_off, e_pre_on, e_post_on; pr_debug("%s: w->name %s event %d\n", __func__, w->name, event); if (strnstr(w->name, "MIC BIAS1", sizeof("MIC BIAS1"))) { micb_ctl_reg = TOMTOM_A_MICB_1_CTL; micb_int_reg = <API key>; cfilt_sel_val = tomtom->resmgr.pdata->micbias.bias1_cfilt_sel; e_pre_on = <API key>; e_post_on = <API key>; e_post_off = <API key>; } else if (strnstr(w->name, "MIC BIAS2", sizeof("MIC BIAS2"))) { micb_ctl_reg = TOMTOM_A_MICB_2_CTL; micb_int_reg = <API key>; cfilt_sel_val = tomtom->resmgr.pdata->micbias.bias2_cfilt_sel; e_pre_on = <API key>; e_post_on = <API key>; e_post_off = <API key>; } else if (strnstr(w->name, "MIC BIAS3", sizeof("MIC BIAS3"))) { micb_ctl_reg = TOMTOM_A_MICB_3_CTL; micb_int_reg = <API key>; cfilt_sel_val = tomtom->resmgr.pdata->micbias.bias3_cfilt_sel; e_pre_on = <API key>; e_post_on = <API key>; e_post_off = <API key>; } else if (strnstr(w->name, "MIC BIAS4", sizeof("MIC BIAS4"))) { micb_ctl_reg = TOMTOM_A_MICB_4_CTL; micb_int_reg = tomtom->resmgr.reg_addr->micb_4_int_rbias; cfilt_sel_val = tomtom->resmgr.pdata->micbias.bias4_cfilt_sel; e_pre_on = <API key>; e_post_on = <API key>; e_post_off = <API key>; } else { pr_err("%s: Error, invalid micbias %s\n", __func__, w->name); return -EINVAL; } switch (event) { case <API key>: /* Let MBHC module know so micbias switch to be off */ <API key>(&tomtom->resmgr, e_pre_on); /* Get cfilt */ <API key>(&tomtom->resmgr, cfilt_sel_val); if (strnstr(w->name, internal1_text, 30)) snd_soc_update_bits(codec, micb_int_reg, 0xE0, 0xE0); else if (strnstr(w->name, internal2_text, 30)) snd_soc_update_bits(codec, micb_int_reg, 0x1C, 0x1C); else if (strnstr(w->name, internal3_text, 30)) snd_soc_update_bits(codec, micb_int_reg, 0x3, 0x3); else /* * If not internal, make sure to write the * register to default value */ snd_soc_write(codec, micb_int_reg, 0x24); if (tomtom->mbhc_started && micb_ctl_reg == TOMTOM_A_MICB_2_CTL) { if (++tomtom->micb_2_users == 1) { if (tomtom->resmgr.pdata-> micbias.<API key>) <API key>( &tomtom->resmgr, <API key>, micb_ctl_reg, w->shift, false); else snd_soc_update_bits(codec, micb_ctl_reg, 1 << w->shift, 1 << w->shift); } pr_debug("%s: micb_2_users %d\n", __func__, tomtom->micb_2_users); } else if (micb_ctl_reg == TOMTOM_A_MICB_3_CTL) { if (++tomtom->micb_3_users == 1) snd_soc_update_bits(codec, micb_ctl_reg, 1 << w->shift, 1 << w->shift); } else { snd_soc_update_bits(codec, micb_ctl_reg, 1 << w->shift, 1 << w->shift); } break; case <API key>: usleep_range(5000, 5100); /* Let MBHC module know so micbias is on */ <API key>(&tomtom->resmgr, e_post_on); break; case <API key>: if (tomtom->mbhc_started && micb_ctl_reg == TOMTOM_A_MICB_2_CTL) { if (--tomtom->micb_2_users == 0) { if (tomtom->resmgr.pdata-> micbias.<API key>) <API key>( &tomtom->resmgr, <API key>, micb_ctl_reg, 7, false); else snd_soc_update_bits(codec, micb_ctl_reg, 1 << w->shift, 0); } pr_debug("%s: micb_2_users %d\n", __func__, tomtom->micb_2_users); WARN(tomtom->micb_2_users < 0, "Unexpected micbias users %d\n", tomtom->micb_2_users); } else if (micb_ctl_reg == TOMTOM_A_MICB_3_CTL) { if (--tomtom->micb_3_users == 0) snd_soc_update_bits(codec, micb_ctl_reg, 1 << w->shift, 0); pr_debug("%s: micb_3_users %d\n", __func__, tomtom->micb_3_users); WARN(tomtom->micb_3_users < 0, "Unexpected micbias-3 users %d\n", tomtom->micb_3_users); } else { snd_soc_update_bits(codec, micb_ctl_reg, 1 << w->shift, 0); } /* Let MBHC module know so micbias switch to be off */ <API key>(&tomtom->resmgr, e_post_off); if (strnstr(w->name, internal1_text, 30)) snd_soc_update_bits(codec, micb_int_reg, 0x80, 0x00); else if (strnstr(w->name, internal2_text, 30)) snd_soc_update_bits(codec, micb_int_reg, 0x10, 0x00); else if (strnstr(w->name, internal3_text, 30)) snd_soc_update_bits(codec, micb_int_reg, 0x2, 0x0); /* Put cfilt */ <API key>(&tomtom->resmgr, cfilt_sel_val); break; } return 0; } /* called under codec_resource_lock acquisition */ static int <API key>(struct snd_soc_codec *codec, bool enable, enum wcd9xxx_micbias_num micb_num) { int rc; if (micb_num != MBHC_MICBIAS2) { dev_err(codec->dev, "%s: Unsupported micbias, micb_num=%d\n", __func__, micb_num); return -EINVAL; } if (enable) rc = <API key>(&codec->dapm, <API key>); else rc = <API key>(&codec->dapm, <API key>); if (!rc) snd_soc_dapm_sync(&codec->dapm); pr_debug("%s: leave ret %d\n", __func__, rc); return rc; } static int <API key>( struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { int ret = 0; struct snd_soc_codec *codec = w->codec; struct tomtom_priv *priv = <API key>(codec); dev_dbg(codec->dev, "%s: event:%d\n", __func__, event); switch (event) { case <API key>: if (priv->micbias_reg) { ret = regulator_enable(priv->micbias_reg); if (ret) dev_err(codec->dev, "%s: Failed to enable micbias_reg\n", __func__); } break; case <API key>: if (priv->micbias_reg) { ret = regulator_disable(priv->micbias_reg); if (ret) dev_err(codec->dev, "%s: Failed to disable micbias_reg\n", __func__); } break; default: break; } return ret; } static void txfe_clkdiv_update(struct snd_soc_codec *codec) { struct tomtom_priv *priv = <API key>(codec); if (test_bit(ADC1_TXFE, &priv->status_mask)) { snd_soc_update_bits(codec, <API key>, 0x0F, 0x05); clear_bit(ADC1_TXFE, &priv->status_mask); } if (test_bit(ADC2_TXFE, &priv->status_mask)) { snd_soc_update_bits(codec, <API key>, 0xF0, 0x50); clear_bit(ADC2_TXFE, &priv->status_mask); } if (test_bit(ADC3_TXFE, &priv->status_mask)) { snd_soc_update_bits(codec, <API key>, 0x0F, 0x05); clear_bit(ADC3_TXFE, &priv->status_mask); } if (test_bit(ADC4_TXFE, &priv->status_mask)) { snd_soc_update_bits(codec, <API key>, 0xF0, 0x50); clear_bit(ADC4_TXFE, &priv->status_mask); } if (test_bit(ADC5_TXFE, &priv->status_mask)) { snd_soc_update_bits(codec, <API key>, 0x0F, 0x05); clear_bit(ADC5_TXFE, &priv->status_mask); } if (test_bit(ADC6_TXFE, &priv->status_mask)) { snd_soc_update_bits(codec, <API key>, 0xF0, 0x50); clear_bit(ADC6_TXFE, &priv->status_mask); } } static void <API key>(struct work_struct *work) { struct delayed_work *hpf_delayed_work; struct hpf_work *hpf_work; struct tomtom_priv *tomtom; struct snd_soc_codec *codec; u16 tx_mux_ctl_reg; u8 hpf_cut_of_freq; hpf_delayed_work = to_delayed_work(work); hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork); tomtom = hpf_work->tomtom; codec = hpf_work->tomtom->codec; hpf_cut_of_freq = hpf_work->tx_hpf_cut_of_freq; tx_mux_ctl_reg = <API key> + (hpf_work->decimator - 1) * 8; pr_debug("%s(): decimator %u hpf_cut_of_freq 0x%x\n", __func__, hpf_work->decimator, (unsigned int)hpf_cut_of_freq); /* * Restore TXFE ClkDiv registers to default. * If any of these registers are modified during analog * front-end enablement, they will be restored back to the * default */ txfe_clkdiv_update(codec); snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x30, hpf_cut_of_freq << 4); } #define <API key> 0x30 #define CF_MIN_3DB_4HZ 0x0 #define CF_MIN_3DB_75HZ 0x1 #define CF_MIN_3DB_150HZ 0x2 static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; unsigned int decimator; char *dec_name = NULL; char *widget_name = NULL; char *temp; int ret = 0; u16 dec_reset_reg, tx_vol_ctl_reg, tx_mux_ctl_reg; u8 dec_hpf_cut_of_freq; int offset; char *dec; pr_debug("%s %d\n", __func__, event); widget_name = kstrndup(w->name, 15, GFP_KERNEL); if (!widget_name) return -ENOMEM; temp = widget_name; dec_name = strsep(&widget_name, " "); widget_name = temp; if (!dec_name) { pr_err("%s: Invalid decimator = %s\n", __func__, w->name); ret = -EINVAL; goto out; } dec = strpbrk(dec_name, "123456789"); if (!dec) { dev_err(codec->dev, "%s: decimator index not found\n", __func__); ret = -EINVAL; goto out; } ret = kstrtouint(dec, 10, &decimator); if (ret < 0) { pr_err("%s: Invalid decimator = %s\n", __func__, dec_name); ret = -EINVAL; goto out; } pr_debug("%s(): widget = %s dec_name = %s decimator = %u\n", __func__, w->name, dec_name, decimator); if (w->reg == <API key>) { dec_reset_reg = <API key>; offset = 0; } else if (w->reg == <API key>) { dec_reset_reg = <API key>; offset = 8; } else { pr_err("%s: Error, incorrect dec\n", __func__); return -EINVAL; } tx_vol_ctl_reg = <API key> + 8 * (decimator - 1); tx_mux_ctl_reg = <API key> + 8 * (decimator - 1); switch (event) { case <API key>: /* Enableable TX digital mute */ snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x01, 0x01); snd_soc_update_bits(codec, dec_reset_reg, 1 << w->shift, 1 << w->shift); snd_soc_update_bits(codec, dec_reset_reg, 1 << w->shift, 0x0); pr_debug("%s: decimator = %u, bypass = %d\n", __func__, decimator, tx_hpf_work[decimator - 1].tx_hpf_bypass); if (tx_hpf_work[decimator - 1].tx_hpf_bypass != true) { dec_hpf_cut_of_freq = snd_soc_read(codec, tx_mux_ctl_reg); dec_hpf_cut_of_freq = (dec_hpf_cut_of_freq & 0x30) >> 4; tx_hpf_work[decimator - 1].tx_hpf_cut_of_freq = dec_hpf_cut_of_freq; if ((dec_hpf_cut_of_freq != CF_MIN_3DB_150HZ)) { /* set cut of freq to CF_MIN_3DB_150HZ (0x1); */ snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x30, CF_MIN_3DB_150HZ << 4); } /* enable HPF */ snd_soc_update_bits(codec, tx_mux_ctl_reg , 0x08, 0x00); } else /* bypass HPF */ snd_soc_update_bits(codec, tx_mux_ctl_reg , 0x08, 0x08); break; case <API key>: /* Disable TX digital mute */ snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x01, 0x00); if ((tx_hpf_work[decimator - 1].tx_hpf_cut_of_freq != CF_MIN_3DB_150HZ) && (tx_hpf_work[decimator - 1].tx_hpf_bypass != true)) { <API key>(&tx_hpf_work[decimator - 1].dwork, msecs_to_jiffies(300)); } /* apply the digital gain after the decimator is enabled*/ if ((w->shift + offset) < ARRAY_SIZE(tx_digital_gain_reg)) snd_soc_write(codec, tx_digital_gain_reg[w->shift + offset], snd_soc_read(codec, tx_digital_gain_reg[w->shift + offset]) ); break; case <API key>: snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x01, 0x01); <API key>(&tx_hpf_work[decimator - 1].dwork); break; case <API key>: snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x08, 0x08); snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x30, (tx_hpf_work[decimator - 1].tx_hpf_cut_of_freq) << 4); break; } out: kfree(widget_name); return ret; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { int ret = 0; struct snd_soc_codec *codec = w->codec; struct tomtom_priv *priv = <API key>(codec); pr_debug("%s: %d %s\n", __func__, event, w->name); WARN_ONCE(!priv->spkdrv_reg, "SPKDRV supply %s isn't defined\n", <API key>); switch (event) { case <API key>: if (priv->spkdrv_reg) { ret = regulator_enable(priv->spkdrv_reg); if (ret) pr_err("%s: Failed to enable spkdrv_reg %s\n", __func__, <API key>); } break; case <API key>: if (priv->spkdrv_reg) { ret = regulator_disable(priv->spkdrv_reg); if (ret) pr_err("%s: Failed to disable spkdrv_reg %s\n", __func__, <API key>); } break; } return ret; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { int ret = 0; struct snd_soc_codec *codec = w->codec; struct tomtom_priv *priv = <API key>(codec); pr_debug("%s: %d %s\n", __func__, event, w->name); /* * If on-demand voltage regulators of spkr1 and spkr2 has been derived * from same power rail then same on-demand voltage regulator can be * used by both spkr1 and spkr2, if a separate device tree entry has * not been defined for on-demand voltage regulator for spkr2. */ if (!priv->spkdrv2_reg) { if (priv->spkdrv_reg) { priv->spkdrv2_reg = priv->spkdrv_reg; } else { WARN_ONCE(!priv->spkdrv2_reg, "SPKDRV2 supply %s isn't defined\n", <API key>); return 0; } } switch (event) { case <API key>: if (priv->spkdrv2_reg) { ret = regulator_enable(priv->spkdrv2_reg); if (ret) pr_err("%s: Failed to enable spkdrv2_reg %s ret:%d\n", __func__, <API key>, ret); } break; case <API key>: if (priv->spkdrv2_reg) { ret = regulator_disable(priv->spkdrv2_reg); if (ret) pr_err("%s: Failed to disable spkdrv2_reg %s ret:%d\n", __func__, <API key>, ret); } break; } return ret; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; pr_debug("%s %d %s\n", __func__, event, w->name); switch (event) { case <API key>: snd_soc_update_bits(codec, <API key>, 1 << w->shift, 1 << w->shift); snd_soc_update_bits(codec, <API key>, 1 << w->shift, 0x0); break; case <API key>: /* apply the digital gain after the interpolator is enabled*/ if ((w->shift) < ARRAY_SIZE(rx_digital_gain_reg)) snd_soc_write(codec, rx_digital_gain_reg[w->shift], snd_soc_read(codec, rx_digital_gain_reg[w->shift]) ); /* Check for Rx1 and Rx2 paths for uhqa mode update */ if (w->shift == 0 || w->shift == 1) <API key>(codec, (1 << w->shift)); break; } return 0; } /* called under codec_resource_lock acquisition */ static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tomtom_priv *priv = <API key>(codec); pr_debug("%s: enter\n", __func__); switch (event) { case <API key>: /* * ldo_h_users is protected by codec->mutex, don't need * additional mutex */ if (++priv->ldo_h_users == 1) { WCD9XXX_BG_CLK_LOCK(&priv->resmgr); <API key>(&priv->resmgr, <API key>); <API key>(&priv->resmgr); <API key>(codec, true); snd_soc_update_bits(codec, <API key>, 1 << 7, 1 << 7); <API key>(codec, false); pr_debug("%s: ldo_h_users %d\n", __func__, priv->ldo_h_users); /* LDO enable requires 1ms to settle down */ usleep_range(1000, 1100); } break; case <API key>: if (--priv->ldo_h_users == 0) { <API key>(codec, true); snd_soc_update_bits(codec, <API key>, 1 << 7, 0); <API key>(codec, false); WCD9XXX_BG_CLK_LOCK(&priv->resmgr); <API key>(&priv->resmgr, <API key>); <API key>(&priv->resmgr); pr_debug("%s: ldo_h_users %d\n", __func__, priv->ldo_h_users); } WARN(priv->ldo_h_users < 0, "Unexpected ldo_h users %d\n", priv->ldo_h_users); break; } pr_debug("%s: leave\n", __func__); return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { int rc; rc = <API key>(w, kcontrol, event); return rc; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tomtom_priv *tomtom = <API key>(codec); pr_debug("%s %d\n", __func__, event); switch (event) { case <API key>: <API key>(&tomtom->resmgr, 1); break; case <API key>: <API key>(&tomtom->resmgr, 0); break; } return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; const char *filename; const struct firmware *fw; int i; int ret = 0; int num_anc_slots; struct wcd9xxx_anc_header *anc_head; struct tomtom_priv *tomtom = <API key>(codec); struct firmware_cal *hwdep_cal = NULL; u32 anc_writes_size = 0; u32 anc_cal_size = 0; int anc_size_remaining; u32 *anc_ptr; u16 reg; u8 mask, val, old_val; size_t cal_size; const void *data; if (tomtom->anc_func == 0) return 0; switch (event) { case <API key>: filename = "wcd9320/wcd9320_anc.bin"; hwdep_cal = wcdcal_get_fw_cal(tomtom->fw_data, WCD9XXX_ANC_CAL); if (hwdep_cal) { data = hwdep_cal->data; cal_size = hwdep_cal->size; dev_dbg(codec->dev, "%s: using hwdep calibration\n", __func__); } else { ret = request_firmware(&fw, filename, codec->dev); if (ret != 0) { dev_err(codec->dev, "Failed to acquire ANC data: %d\n", ret); return -ENODEV; } if (!fw) { dev_err(codec->dev, "failed to get anc fw"); return -ENODEV; } data = fw->data; cal_size = fw->size; dev_dbg(codec->dev, "%s: using request_firmware calibration\n", __func__); } if (cal_size < sizeof(struct wcd9xxx_anc_header)) { dev_err(codec->dev, "Not enough data\n"); ret = -ENOMEM; goto err; } /* First number is the number of register writes */ anc_head = (struct wcd9xxx_anc_header *)(data); anc_ptr = (u32 *)(data + sizeof(struct wcd9xxx_anc_header)); anc_size_remaining = cal_size - sizeof(struct wcd9xxx_anc_header); num_anc_slots = anc_head->num_anc_slots; if (tomtom->anc_slot >= num_anc_slots) { dev_err(codec->dev, "Invalid ANC slot selected\n"); ret = -EINVAL; goto err; } for (i = 0; i < num_anc_slots; i++) { if (anc_size_remaining < <API key>) { dev_err(codec->dev, "Invalid register format\n"); ret = -EINVAL; goto err; } anc_writes_size = (u32)(*anc_ptr); anc_size_remaining -= sizeof(u32); anc_ptr += 1; if (anc_writes_size * <API key> > anc_size_remaining) { dev_err(codec->dev, "Invalid register format\n"); ret = -EINVAL; goto err; } if (tomtom->anc_slot == i) break; anc_size_remaining -= (anc_writes_size * <API key>); anc_ptr += anc_writes_size; } if (i == num_anc_slots) { dev_err(codec->dev, "Selected ANC slot not present\n"); ret = -EINVAL; goto err; } i = 0; anc_cal_size = anc_writes_size; if (w->reg == <API key>) { snd_soc_update_bits(codec, <API key>, 0x03, 0x03); anc_writes_size = (anc_cal_size/2); } if (w->reg == <API key>) { snd_soc_update_bits(codec, <API key>, 0x0C, 0x0C); i = (anc_cal_size/2); anc_writes_size = anc_cal_size; } for (; i < anc_writes_size; i++) { <API key>(anc_ptr[i], reg, mask, val); /* * ANC Soft reset register is ignored from ACDB * because ANC left soft reset bits will be called * while enabling ANC HPH Right DAC. */ if ((reg == <API key>) && ((w->reg == <API key>) || (w->reg == <API key>))) { continue; } old_val = snd_soc_read(codec, reg); snd_soc_write(codec, reg, (old_val & ~mask) | (val & mask)); } if (w->reg == <API key>) snd_soc_update_bits(codec, <API key>, 0x03, 0x00); if (w->reg == <API key>) snd_soc_update_bits(codec, <API key>, 0x0C, 0x00); if (!hwdep_cal) release_firmware(fw); txfe_clkdiv_update(codec); break; case <API key>: msleep(40); snd_soc_update_bits(codec, <API key>, 0x01, 0x00); snd_soc_update_bits(codec, <API key>, 0x02, 0x00); msleep(20); snd_soc_write(codec, <API key>, 0x0F); snd_soc_write(codec, <API key>, 0); snd_soc_write(codec, <API key>, 0x00); break; } return 0; err: if (!hwdep_cal) release_firmware(fw); return ret; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tomtom_priv *tomtom_p = <API key>(codec); uint32_t impedl, impedr; int ret = 0; pr_debug("%s %s %d\n", __func__, w->name, event); switch (event) { case <API key>: if (tomtom_p->anc_func) { <API key>(w, kcontrol, event); msleep(50); } if (!high_perf_mode && !tomtom_p->uhqa_mode) { wcd9xxx_clsh_fsm(codec, &tomtom_p->clsh_d, <API key>, <API key>, <API key>); } else { <API key>(codec, &tomtom_p->clsh_d, tomtom_p->uhqa_mode, <API key>, <API key>); } ret = <API key>(&tomtom_p->mbhc, &impedl, &impedr); if (!ret) <API key>(codec, impedl); else dev_dbg(codec->dev, "%s: Failed to get mbhc impedance %d\n", __func__, ret); break; case <API key>: snd_soc_update_bits(codec, <API key>, 0xBC, 0x94); snd_soc_update_bits(codec, <API key>, 0x30, 0x10); break; case <API key>: snd_soc_update_bits(codec, <API key>, 0xBC, 0x00); snd_soc_update_bits(codec, <API key>, 0x30, 0x00); break; case <API key>: if (!high_perf_mode && !tomtom_p->uhqa_mode) { wcd9xxx_clsh_fsm(codec, &tomtom_p->clsh_d, <API key>, <API key>, <API key>); } else { <API key>(codec, &tomtom_p->clsh_d, tomtom_p->uhqa_mode, <API key>, <API key>); } break; } return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tomtom_priv *tomtom_p = <API key>(codec); pr_debug("%s %s %d\n", __func__, w->name, event); switch (event) { case <API key>: if (tomtom_p->anc_func) { <API key>(w, kcontrol, event); msleep(50); } snd_soc_update_bits(codec, w->reg, 0x40, 0x40); if (!high_perf_mode && !tomtom_p->uhqa_mode) { wcd9xxx_clsh_fsm(codec, &tomtom_p->clsh_d, <API key>, <API key>, <API key>); } else { <API key>(codec, &tomtom_p->clsh_d, tomtom_p->uhqa_mode, <API key>, <API key>); } break; case <API key>: snd_soc_update_bits(codec, <API key>, 0xBC, 0x94); snd_soc_update_bits(codec, <API key>, 0x30, 0x10); break; case <API key>: snd_soc_update_bits(codec, <API key>, 0xBC, 0x00); snd_soc_update_bits(codec, <API key>, 0x30, 0x00); break; case <API key>: snd_soc_update_bits(codec, w->reg, 0x40, 0x00); if (!high_perf_mode && !tomtom_p->uhqa_mode) { wcd9xxx_clsh_fsm(codec, &tomtom_p->clsh_d, <API key>, <API key>, <API key>); } else { <API key>(codec, &tomtom_p->clsh_d, tomtom_p->uhqa_mode, <API key>, <API key>); } break; } return 0; } static int tomtom_hph_pa_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tomtom_priv *tomtom = <API key>(codec); enum <API key> e_pre_on, e_post_off; u8 req_clsh_state; u32 pa_settle_time = <API key>; pr_debug("%s: %s event = %d\n", __func__, w->name, event); if (w->shift == 5) { e_pre_on = <API key>; e_post_off = <API key>; req_clsh_state = <API key>; } else if (w->shift == 4) { e_pre_on = <API key>; e_post_off = <API key>; req_clsh_state = <API key>; } else { pr_err("%s: Invalid w->shift %d\n", __func__, w->shift); return -EINVAL; } if (tomtom->comp_enabled[COMPANDER_1]) pa_settle_time = <API key>; switch (event) { case <API key>: /* Let MBHC module know PA is turning on */ <API key>(&tomtom->resmgr, e_pre_on); break; case <API key>: usleep_range(pa_settle_time, pa_settle_time + 1000); pr_debug("%s: sleep %d us after %s PA enable\n", __func__, pa_settle_time, w->name); if (!high_perf_mode && !tomtom->uhqa_mode) { wcd9xxx_clsh_fsm(codec, &tomtom->clsh_d, req_clsh_state, <API key>, <API key>); } break; case <API key>: /* Let MBHC module know PA turned off */ <API key>(&tomtom->resmgr, e_post_off); usleep_range(pa_settle_time, pa_settle_time + 1000); pr_debug("%s: sleep %d us after %s PA disable\n", __func__, pa_settle_time, w->name); break; } return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; int ret = 0; switch (event) { case <API key>: ret = tomtom_hph_pa_event(w, kcontrol, event); break; case <API key>: if ((snd_soc_read(codec, <API key>) & 0x80) && (snd_soc_read(codec, <API key>) & 0x80)) { snd_soc_update_bits(codec, <API key>, 0x30, 0x30); msleep(30); } ret = tomtom_hph_pa_event(w, kcontrol, event); break; case <API key>: if (w->shift == 5) { snd_soc_update_bits(codec, <API key>, 0x30, 0x00); msleep(40); snd_soc_update_bits(codec, <API key>, 0x80, 00); ret |= <API key>(w, kcontrol, event); } break; case <API key>: ret = tomtom_hph_pa_event(w, kcontrol, event); break; } return ret; } static const struct snd_soc_dapm_widget <API key>[] = { SND_SOC_DAPM_SUPPLY("RX_I2S_CLK", <API key>, 4, 0, NULL, 0), SND_SOC_DAPM_SUPPLY("TX_I2S_CLK", <API key>, 4, 0, NULL, 0), }; static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tomtom_priv *tomtom = <API key>(codec); pr_debug("%s %s %d\n", __func__, w->name, event); switch (event) { case <API key>: wcd9xxx_clsh_fsm(codec, &tomtom->clsh_d, <API key>, <API key>, <API key>); snd_soc_update_bits(codec, w->reg, 0x40, 0x40); break; case <API key>: snd_soc_update_bits(codec, w->reg, 0x40, 0x00); wcd9xxx_clsh_fsm(codec, &tomtom->clsh_d, <API key>, <API key>, <API key>); break; } return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; pr_debug("%s %s %d\n", __func__, w->name, event); switch (event) { case <API key>: snd_soc_update_bits(codec, <API key>, 0x80, 0x80); break; case <API key>: if ((snd_soc_read(codec, w->reg) & 0x03) == 0) snd_soc_update_bits(codec, <API key>, 0x80, 0x00); break; } return 0; } static const struct snd_soc_dapm_route audio_i2s_map[] = { {"SLIM RX1", NULL, "RX_I2S_CLK"}, {"SLIM RX2", NULL, "RX_I2S_CLK"}, {"SLIM RX3", NULL, "RX_I2S_CLK"}, {"SLIM RX4", NULL, "RX_I2S_CLK"}, {"SLIM TX7 MUX", NULL, "TX_I2S_CLK"}, {"SLIM TX8 MUX", NULL, "TX_I2S_CLK"}, {"SLIM TX9 MUX", NULL, "TX_I2S_CLK"}, {"SLIM TX10 MUX", NULL, "TX_I2S_CLK"}, {"RX_I2S_CLK", NULL, "CDC_I2S_RX_CONN"}, }; static const struct snd_soc_dapm_route audio_map[] = { /* SLIMBUS Connections */ {"AIF1 CAP", NULL, "AIF1_CAP Mixer"}, {"AIF2 CAP", NULL, "AIF2_CAP Mixer"}, {"AIF3 CAP", NULL, "AIF3_CAP Mixer"}, /* VI Feedback */ {"AIF4_VI Mixer", "SPKR_VI_1", "VIINPUT"}, {"AIF4_VI Mixer", "SPKR_VI_2", "VIINPUT"}, {"AIF4 VI", NULL, "AIF4_VI Mixer"}, /* MAD */ {"MAD_SEL MUX", "SPE", "MAD_CPE_INPUT"}, {"MAD_SEL MUX", "MSM", "MADINPUT"}, {"MADONOFF", "Switch", "MAD_SEL MUX"}, {"AIF4 MAD", NULL, "MADONOFF"}, /* SLIM_MIXER("AIF1_CAP Mixer"),*/ {"AIF1_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"}, {"AIF1_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"}, {"AIF1_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"}, {"AIF1_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"}, {"AIF1_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"}, {"AIF1_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"}, {"AIF1_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"}, {"AIF1_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"}, {"AIF1_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"}, {"AIF1_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"}, /* SLIM_MIXER("AIF2_CAP Mixer"),*/ {"AIF2_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"}, {"AIF2_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"}, {"AIF2_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"}, {"AIF2_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"}, {"AIF2_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"}, {"AIF2_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"}, {"AIF2_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"}, {"AIF2_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"}, {"AIF2_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"}, {"AIF2_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"}, /* SLIM_MIXER("AIF3_CAP Mixer"),*/ {"AIF3_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"}, {"AIF3_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"}, {"AIF3_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"}, {"AIF3_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"}, {"AIF3_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"}, {"AIF3_CAP Mixer", "SLIM TX6", "SLIM TX6 MUX"}, {"AIF3_CAP Mixer", "SLIM TX7", "SLIM TX7 MUX"}, {"AIF3_CAP Mixer", "SLIM TX8", "SLIM TX8 MUX"}, {"AIF3_CAP Mixer", "SLIM TX9", "SLIM TX9 MUX"}, {"AIF3_CAP Mixer", "SLIM TX10", "SLIM TX10 MUX"}, {"SLIM TX1 MUX", "DEC1", "DEC1 MUX"}, {"SLIM TX1 MUX", "RMIX1", "RX1 MIX1"}, {"SLIM TX1 MUX", "RMIX2", "RX2 MIX1"}, {"SLIM TX1 MUX", "RMIX3", "RX3 MIX1"}, {"SLIM TX1 MUX", "RMIX4", "RX4 MIX1"}, {"SLIM TX1 MUX", "RMIX5", "RX5 MIX1"}, {"SLIM TX1 MUX", "RMIX6", "RX6 MIX1"}, {"SLIM TX1 MUX", "RMIX7", "RX7 MIX1"}, {"SLIM TX1 MUX", "RMIX8", "RX8 MIX1"}, {"SLIM TX2 MUX", "DEC2", "DEC2 MUX"}, {"SLIM TX2 MUX", "RMIX1", "RX1 MIX1"}, {"SLIM TX2 MUX", "RMIX2", "RX2 MIX1"}, {"SLIM TX2 MUX", "RMIX3", "RX3 MIX1"}, {"SLIM TX2 MUX", "RMIX4", "RX4 MIX1"}, {"SLIM TX2 MUX", "RMIX5", "RX5 MIX1"}, {"SLIM TX2 MUX", "RMIX6", "RX6 MIX1"}, {"SLIM TX2 MUX", "RMIX7", "RX7 MIX1"}, {"SLIM TX2 MUX", "RMIX8", "RX8 MIX1"}, {"SLIM TX3 MUX", "DEC3", "DEC3 MUX"}, {"SLIM TX3 MUX", "RMIX1", "RX1 MIX1"}, {"SLIM TX3 MUX", "RMIX2", "RX2 MIX1"}, {"SLIM TX3 MUX", "RMIX3", "RX3 MIX1"}, {"SLIM TX3 MUX", "RMIX4", "RX4 MIX1"}, {"SLIM TX3 MUX", "RMIX5", "RX5 MIX1"}, {"SLIM TX3 MUX", "RMIX6", "RX6 MIX1"}, {"SLIM TX3 MUX", "RMIX7", "RX7 MIX1"}, {"SLIM TX3 MUX", "RMIX8", "RX8 MIX1"}, {"SLIM TX4 MUX", "DEC4", "DEC4 MUX"}, {"SLIM TX4 MUX", "RMIX1", "RX1 MIX1"}, {"SLIM TX4 MUX", "RMIX2", "RX2 MIX1"}, {"SLIM TX4 MUX", "RMIX3", "RX3 MIX1"}, {"SLIM TX4 MUX", "RMIX4", "RX4 MIX1"}, {"SLIM TX4 MUX", "RMIX5", "RX5 MIX1"}, {"SLIM TX4 MUX", "RMIX6", "RX6 MIX1"}, {"SLIM TX4 MUX", "RMIX7", "RX7 MIX1"}, {"SLIM TX4 MUX", "RMIX8", "RX8 MIX1"}, {"SLIM TX5 MUX", "DEC5", "DEC5 MUX"}, {"SLIM TX5 MUX", "RMIX1", "RX1 MIX1"}, {"SLIM TX5 MUX", "RMIX2", "RX2 MIX1"}, {"SLIM TX5 MUX", "RMIX3", "RX3 MIX1"}, {"SLIM TX5 MUX", "RMIX4", "RX4 MIX1"}, {"SLIM TX5 MUX", "RMIX5", "RX5 MIX1"}, {"SLIM TX5 MUX", "RMIX6", "RX6 MIX1"}, {"SLIM TX5 MUX", "RMIX7", "RX7 MIX1"}, {"SLIM TX5 MUX", "RMIX8", "RX8 MIX1"}, {"SLIM TX6 MUX", "DEC6", "DEC6 MUX"}, {"SLIM TX7 MUX", "DEC1", "DEC1 MUX"}, {"SLIM TX7 MUX", "DEC2", "DEC2 MUX"}, {"SLIM TX7 MUX", "DEC3", "DEC3 MUX"}, {"SLIM TX7 MUX", "DEC4", "DEC4 MUX"}, {"SLIM TX7 MUX", "DEC5", "DEC5 MUX"}, {"SLIM TX7 MUX", "DEC6", "DEC6 MUX"}, {"SLIM TX7 MUX", "DEC7", "DEC7 MUX"}, {"SLIM TX7 MUX", "DEC8", "DEC8 MUX"}, {"SLIM TX7 MUX", "DEC9", "DEC9 MUX"}, {"SLIM TX7 MUX", "DEC10", "DEC10 MUX"}, {"SLIM TX7 MUX", "RMIX1", "RX1 MIX1"}, {"SLIM TX7 MUX", "RMIX2", "RX2 MIX1"}, {"SLIM TX7 MUX", "RMIX3", "RX3 MIX1"}, {"SLIM TX7 MUX", "RMIX4", "RX4 MIX1"}, {"SLIM TX7 MUX", "RMIX5", "RX5 MIX1"}, {"SLIM TX7 MUX", "RMIX6", "RX6 MIX1"}, {"SLIM TX7 MUX", "RMIX7", "RX7 MIX1"}, {"SLIM TX8 MUX", "DEC1", "DEC1 MUX"}, {"SLIM TX8 MUX", "DEC2", "DEC2 MUX"}, {"SLIM TX8 MUX", "DEC3", "DEC3 MUX"}, {"SLIM TX8 MUX", "DEC4", "DEC4 MUX"}, {"SLIM TX8 MUX", "DEC5", "DEC5 MUX"}, {"SLIM TX8 MUX", "DEC6", "DEC6 MUX"}, {"SLIM TX8 MUX", "DEC7", "DEC7 MUX"}, {"SLIM TX8 MUX", "DEC8", "DEC8 MUX"}, {"SLIM TX8 MUX", "DEC9", "DEC9 MUX"}, {"SLIM TX8 MUX", "DEC10", "DEC10 MUX"}, {"SLIM TX9 MUX", "DEC1", "DEC1 MUX"}, {"SLIM TX9 MUX", "DEC2", "DEC2 MUX"}, {"SLIM TX9 MUX", "DEC3", "DEC3 MUX"}, {"SLIM TX9 MUX", "DEC4", "DEC4 MUX"}, {"SLIM TX9 MUX", "DEC5", "DEC5 MUX"}, {"SLIM TX9 MUX", "DEC6", "DEC6 MUX"}, {"SLIM TX9 MUX", "DEC7", "DEC7 MUX"}, {"SLIM TX9 MUX", "DEC8", "DEC8 MUX"}, {"SLIM TX9 MUX", "DEC9", "DEC9 MUX"}, {"SLIM TX9 MUX", "DEC10", "DEC10 MUX"}, {"SLIM TX10 MUX", "DEC1", "DEC1 MUX"}, {"SLIM TX10 MUX", "DEC2", "DEC2 MUX"}, {"SLIM TX10 MUX", "DEC3", "DEC3 MUX"}, {"SLIM TX10 MUX", "DEC4", "DEC4 MUX"}, {"SLIM TX10 MUX", "DEC5", "DEC5 MUX"}, {"SLIM TX10 MUX", "DEC6", "DEC6 MUX"}, {"SLIM TX10 MUX", "DEC7", "DEC7 MUX"}, {"SLIM TX10 MUX", "DEC8", "DEC8 MUX"}, {"SLIM TX10 MUX", "DEC9", "DEC9 MUX"}, {"SLIM TX10 MUX", "DEC10", "DEC10 MUX"}, /* Earpiece (RX MIX1) */ {"EAR", NULL, "EAR PA"}, {"EAR PA", NULL, "EAR_PA_MIXER"}, {"EAR_PA_MIXER", NULL, "DAC1"}, {"DAC1", NULL, "RX_BIAS"}, {"ANC EAR", NULL, "ANC EAR PA"}, {"ANC EAR PA", NULL, "EAR_PA_MIXER"}, {"ANC1 FB MUX", "EAR_HPH_L", "RX1 MIX2"}, {"ANC1 FB MUX", "EAR_LINE_1", "RX2 MIX2"}, /* Headset (RX MIX1 and RX MIX2) */ {"HEADPHONE", NULL, "HPHL"}, {"HEADPHONE", NULL, "HPHR"}, {"HPHL", NULL, "HPHL_PA_MIXER"}, {"HPHL_PA_MIXER", NULL, "HPHL DAC"}, {"HPHL DAC", NULL, "RX_BIAS"}, {"HPHR", NULL, "HPHR_PA_MIXER"}, {"HPHR_PA_MIXER", NULL, "HPHR DAC"}, {"HPHR DAC", NULL, "RX_BIAS"}, {"ANC HEADPHONE", NULL, "ANC HPHL"}, {"ANC HEADPHONE", NULL, "ANC HPHR"}, {"ANC HPHL", NULL, "HPHL_PA_MIXER"}, {"ANC HPHR", NULL, "HPHR_PA_MIXER"}, {"ANC1 MUX", "ADC1", "ADC1"}, {"ANC1 MUX", "ADC2", "ADC2"}, {"ANC1 MUX", "ADC3", "ADC3"}, {"ANC1 MUX", "ADC4", "ADC4"}, {"ANC1 MUX", "ADC5", "ADC5"}, {"ANC1 MUX", "ADC6", "ADC6"}, {"ANC1 MUX", "DMIC1", "DMIC1"}, {"ANC1 MUX", "DMIC2", "DMIC2"}, {"ANC1 MUX", "DMIC3", "DMIC3"}, {"ANC1 MUX", "DMIC4", "DMIC4"}, {"ANC1 MUX", "DMIC5", "DMIC5"}, {"ANC1 MUX", "DMIC6", "DMIC6"}, {"ANC2 MUX", "ADC1", "ADC1"}, {"ANC2 MUX", "ADC2", "ADC2"}, {"ANC2 MUX", "ADC3", "ADC3"}, {"ANC2 MUX", "ADC4", "ADC4"}, {"ANC2 MUX", "ADC5", "ADC5"}, {"ANC2 MUX", "ADC6", "ADC6"}, {"ANC2 MUX", "DMIC1", "DMIC1"}, {"ANC2 MUX", "DMIC2", "DMIC2"}, {"ANC2 MUX", "DMIC3", "DMIC3"}, {"ANC2 MUX", "DMIC4", "DMIC4"}, {"ANC2 MUX", "DMIC5", "DMIC5"}, {"ANC2 MUX", "DMIC6", "DMIC6"}, {"ANC HPHR", NULL, "CDC_CONN"}, {"DAC1", "Switch", "CLASS_H_DSM MUX"}, {"HPHL DAC", "Switch", "CLASS_H_DSM MUX"}, {"HPHR DAC", NULL, "RX2 CHAIN"}, {"LINEOUT1", NULL, "LINEOUT1 PA"}, {"LINEOUT2", NULL, "LINEOUT2 PA"}, {"LINEOUT3", NULL, "LINEOUT3 PA"}, {"LINEOUT4", NULL, "LINEOUT4 PA"}, {"SPK_OUT", NULL, "SPK PA"}, {"SPK_OUT", NULL, "SPK2 PA"}, {"LINEOUT1 PA", NULL, "LINEOUT1_PA_MIXER"}, {"LINEOUT1_PA_MIXER", NULL, "LINEOUT1 DAC"}, {"LINEOUT2 PA", NULL, "LINEOUT2_PA_MIXER"}, {"LINEOUT2_PA_MIXER", NULL, "LINEOUT2 DAC"}, {"LINEOUT3 PA", NULL, "LINEOUT3_PA_MIXER"}, {"LINEOUT3_PA_MIXER", NULL, "LINEOUT3 DAC"}, {"LINEOUT4 PA", NULL, "LINEOUT4_PA_MIXER"}, {"LINEOUT4_PA_MIXER", NULL, "LINEOUT4 DAC"}, {"LINEOUT1 DAC", NULL, "RX3 MIX1"}, {"RDAC5 MUX", "DEM3_INV", "RX3 MIX1"}, {"RDAC5 MUX", "DEM4", "RX4 MIX1"}, {"LINEOUT3 DAC", NULL, "RDAC5 MUX"}, {"LINEOUT2 DAC", NULL, "RX5 MIX1"}, {"RDAC7 MUX", "DEM5_INV", "RX5 MIX1"}, {"RDAC7 MUX", "DEM6", "RX6 MIX1"}, {"LINEOUT4 DAC", NULL, "RDAC7 MUX"}, {"SPK PA", NULL, "SPK DAC"}, {"SPK DAC", NULL, "RX7 MIX2"}, {"SPK DAC", NULL, "VDD_SPKDRV"}, {"SPK2 PA", NULL, "SPK2 DAC"}, {"SPK2 DAC", NULL, "RX8 MIX1"}, {"SPK2 DAC", NULL, "VDD_SPKDRV2"}, {"CLASS_H_DSM MUX", "DSM_HPHL_RX1", "RX1 CHAIN"}, {"RX1 INTERP", NULL, "RX1 MIX2"}, {"RX1 CHAIN", NULL, "RX1 INTERP"}, {"RX2 INTERP", NULL, "RX2 MIX2"}, {"RX2 CHAIN", NULL, "RX2 INTERP"}, {"RX1 MIX2", NULL, "ANC1 MUX"}, {"RX2 MIX2", NULL, "ANC2 MUX"}, {"LINEOUT1 DAC", NULL, "RX_BIAS"}, {"LINEOUT2 DAC", NULL, "RX_BIAS"}, {"LINEOUT3 DAC", NULL, "RX_BIAS"}, {"LINEOUT4 DAC", NULL, "RX_BIAS"}, {"SPK DAC", NULL, "RX_BIAS"}, {"SPK2 DAC", NULL, "RX_BIAS"}, {"RX7 MIX1", NULL, "COMP0_CLK"}, {"RX8 MIX1", NULL, "COMP0_CLK"}, {"RX1 MIX1", NULL, "COMP1_CLK"}, {"RX2 MIX1", NULL, "COMP1_CLK"}, {"RX3 MIX1", NULL, "COMP2_CLK"}, {"RX5 MIX1", NULL, "COMP2_CLK"}, {"RX1 MIX1", NULL, "RX1 MIX1 INP1"}, {"RX1 MIX1", NULL, "RX1 MIX1 INP2"}, {"RX1 MIX1", NULL, "RX1 MIX1 INP3"}, {"RX2 MIX1", NULL, "RX2 MIX1 INP1"}, {"RX2 MIX1", NULL, "RX2 MIX1 INP2"}, {"RX3 MIX1", NULL, "RX3 MIX1 INP1"}, {"RX3 MIX1", NULL, "RX3 MIX1 INP2"}, {"RX4 MIX1", NULL, "RX4 MIX1 INP1"}, {"RX4 MIX1", NULL, "RX4 MIX1 INP2"}, {"RX5 MIX1", NULL, "RX5 MIX1 INP1"}, {"RX5 MIX1", NULL, "RX5 MIX1 INP2"}, {"RX6 MIX1", NULL, "RX6 MIX1 INP1"}, {"RX6 MIX1", NULL, "RX6 MIX1 INP2"}, {"RX7 MIX1", NULL, "RX7 MIX1 INP1"}, {"RX7 MIX1", NULL, "RX7 MIX1 INP2"}, {"RX8 MIX1", NULL, "RX8 MIX1 INP1"}, {"RX8 MIX1", NULL, "RX8 MIX1 INP2"}, {"RX1 MIX2", NULL, "RX1 MIX1"}, {"RX1 MIX2", NULL, "RX1 MIX2 INP1"}, {"RX1 MIX2", NULL, "RX1 MIX2 INP2"}, {"RX2 MIX2", NULL, "RX2 MIX1"}, {"RX2 MIX2", NULL, "RX2 MIX2 INP1"}, {"RX2 MIX2", NULL, "RX2 MIX2 INP2"}, {"RX7 MIX2", NULL, "RX7 MIX1"}, {"RX7 MIX2", NULL, "RX7 MIX2 INP1"}, {"RX7 MIX2", NULL, "RX7 MIX2 INP2"}, /* SLIM_MUX("AIF1_PB", "AIF1 PB"),*/ {"SLIM RX1 MUX", "AIF1_PB", "AIF1 PB"}, {"SLIM RX2 MUX", "AIF1_PB", "AIF1 PB"}, {"SLIM RX3 MUX", "AIF1_PB", "AIF1 PB"}, {"SLIM RX4 MUX", "AIF1_PB", "AIF1 PB"}, {"SLIM RX5 MUX", "AIF1_PB", "AIF1 PB"}, {"SLIM RX6 MUX", "AIF1_PB", "AIF1 PB"}, {"SLIM RX7 MUX", "AIF1_PB", "AIF1 PB"}, {"SLIM RX8 MUX", "AIF1_PB", "AIF1 PB"}, /* SLIM_MUX("AIF2_PB", "AIF2 PB"),*/ {"SLIM RX1 MUX", "AIF2_PB", "AIF2 PB"}, {"SLIM RX2 MUX", "AIF2_PB", "AIF2 PB"}, {"SLIM RX3 MUX", "AIF2_PB", "AIF2 PB"}, {"SLIM RX4 MUX", "AIF2_PB", "AIF2 PB"}, {"SLIM RX5 MUX", "AIF2_PB", "AIF2 PB"}, {"SLIM RX6 MUX", "AIF2_PB", "AIF2 PB"}, {"SLIM RX7 MUX", "AIF2_PB", "AIF2 PB"}, {"SLIM RX8 MUX", "AIF2_PB", "AIF2 PB"}, /* SLIM_MUX("AIF3_PB", "AIF3 PB"),*/ {"SLIM RX1 MUX", "AIF3_PB", "AIF3 PB"}, {"SLIM RX2 MUX", "AIF3_PB", "AIF3 PB"}, {"SLIM RX3 MUX", "AIF3_PB", "AIF3 PB"}, {"SLIM RX4 MUX", "AIF3_PB", "AIF3 PB"}, {"SLIM RX5 MUX", "AIF3_PB", "AIF3 PB"}, {"SLIM RX6 MUX", "AIF3_PB", "AIF3 PB"}, {"SLIM RX7 MUX", "AIF3_PB", "AIF3 PB"}, {"SLIM RX8 MUX", "AIF3_PB", "AIF3 PB"}, {"SLIM RX1", NULL, "SLIM RX1 MUX"}, {"SLIM RX2", NULL, "SLIM RX2 MUX"}, {"SLIM RX3", NULL, "SLIM RX3 MUX"}, {"SLIM RX4", NULL, "SLIM RX4 MUX"}, {"SLIM RX5", NULL, "SLIM RX5 MUX"}, {"SLIM RX6", NULL, "SLIM RX6 MUX"}, {"SLIM RX7", NULL, "SLIM RX7 MUX"}, {"SLIM RX8", NULL, "SLIM RX8 MUX"}, {"RX1 MIX1 INP1", "RX1", "SLIM RX1"}, {"RX1 MIX1 INP1", "RX2", "SLIM RX2"}, {"RX1 MIX1 INP1", "RX3", "SLIM RX3"}, {"RX1 MIX1 INP1", "RX4", "SLIM RX4"}, {"RX1 MIX1 INP1", "RX5", "SLIM RX5"}, {"RX1 MIX1 INP1", "RX6", "SLIM RX6"}, {"RX1 MIX1 INP1", "RX7", "SLIM RX7"}, {"RX1 MIX1 INP1", "IIR1", "IIR1"}, {"RX1 MIX1 INP1", "IIR2", "IIR2"}, {"RX1 MIX1 INP2", "RX1", "SLIM RX1"}, {"RX1 MIX1 INP2", "RX2", "SLIM RX2"}, {"RX1 MIX1 INP2", "RX3", "SLIM RX3"}, {"RX1 MIX1 INP2", "RX4", "SLIM RX4"}, {"RX1 MIX1 INP2", "RX5", "SLIM RX5"}, {"RX1 MIX1 INP2", "RX6", "SLIM RX6"}, {"RX1 MIX1 INP2", "RX7", "SLIM RX7"}, {"RX1 MIX1 INP2", "IIR1", "IIR1"}, {"RX1 MIX1 INP2", "IIR2", "IIR2"}, {"RX1 MIX1 INP3", "RX1", "SLIM RX1"}, {"RX1 MIX1 INP3", "RX2", "SLIM RX2"}, {"RX1 MIX1 INP3", "RX3", "SLIM RX3"}, {"RX1 MIX1 INP3", "RX4", "SLIM RX4"}, {"RX1 MIX1 INP3", "RX5", "SLIM RX5"}, {"RX1 MIX1 INP3", "RX6", "SLIM RX6"}, {"RX1 MIX1 INP3", "RX7", "SLIM RX7"}, {"RX2 MIX1 INP1", "RX1", "SLIM RX1"}, {"RX2 MIX1 INP1", "RX2", "SLIM RX2"}, {"RX2 MIX1 INP1", "RX3", "SLIM RX3"}, {"RX2 MIX1 INP1", "RX4", "SLIM RX4"}, {"RX2 MIX1 INP1", "RX5", "SLIM RX5"}, {"RX2 MIX1 INP1", "RX6", "SLIM RX6"}, {"RX2 MIX1 INP1", "RX7", "SLIM RX7"}, {"RX2 MIX1 INP1", "IIR1", "IIR1"}, {"RX2 MIX1 INP1", "IIR2", "IIR2"}, {"RX2 MIX1 INP2", "RX1", "SLIM RX1"}, {"RX2 MIX1 INP2", "RX2", "SLIM RX2"}, {"RX2 MIX1 INP2", "RX3", "SLIM RX3"}, {"RX2 MIX1 INP2", "RX4", "SLIM RX4"}, {"RX2 MIX1 INP2", "RX5", "SLIM RX5"}, {"RX2 MIX1 INP2", "RX6", "SLIM RX6"}, {"RX2 MIX1 INP2", "RX7", "SLIM RX7"}, {"RX2 MIX1 INP2", "IIR1", "IIR1"}, {"RX2 MIX1 INP2", "IIR2", "IIR2"}, {"RX3 MIX1 INP1", "RX1", "SLIM RX1"}, {"RX3 MIX1 INP1", "RX2", "SLIM RX2"}, {"RX3 MIX1 INP1", "RX3", "SLIM RX3"}, {"RX3 MIX1 INP1", "RX4", "SLIM RX4"}, {"RX3 MIX1 INP1", "RX5", "SLIM RX5"}, {"RX3 MIX1 INP1", "RX6", "SLIM RX6"}, {"RX3 MIX1 INP1", "RX7", "SLIM RX7"}, {"RX3 MIX1 INP1", "IIR1", "IIR1"}, {"RX3 MIX1 INP1", "IIR2", "IIR2"}, {"RX3 MIX1 INP2", "RX1", "SLIM RX1"}, {"RX3 MIX1 INP2", "RX2", "SLIM RX2"}, {"RX3 MIX1 INP2", "RX3", "SLIM RX3"}, {"RX3 MIX1 INP2", "RX4", "SLIM RX4"}, {"RX3 MIX1 INP2", "RX5", "SLIM RX5"}, {"RX3 MIX1 INP2", "RX6", "SLIM RX6"}, {"RX3 MIX1 INP2", "RX7", "SLIM RX7"}, {"RX3 MIX1 INP2", "IIR1", "IIR1"}, {"RX3 MIX1 INP2", "IIR2", "IIR2"}, {"RX4 MIX1 INP1", "RX1", "SLIM RX1"}, {"RX4 MIX1 INP1", "RX2", "SLIM RX2"}, {"RX4 MIX1 INP1", "RX3", "SLIM RX3"}, {"RX4 MIX1 INP1", "RX4", "SLIM RX4"}, {"RX4 MIX1 INP1", "RX5", "SLIM RX5"}, {"RX4 MIX1 INP1", "RX6", "SLIM RX6"}, {"RX4 MIX1 INP1", "RX7", "SLIM RX7"}, {"RX4 MIX1 INP1", "IIR1", "IIR1"}, {"RX4 MIX1 INP1", "IIR2", "IIR2"}, {"RX4 MIX1 INP2", "RX1", "SLIM RX1"}, {"RX4 MIX1 INP2", "RX2", "SLIM RX2"}, {"RX4 MIX1 INP2", "RX3", "SLIM RX3"}, {"RX4 MIX1 INP2", "RX5", "SLIM RX5"}, {"RX4 MIX1 INP2", "RX4", "SLIM RX4"}, {"RX4 MIX1 INP2", "RX6", "SLIM RX6"}, {"RX4 MIX1 INP2", "RX7", "SLIM RX7"}, {"RX4 MIX1 INP2", "IIR1", "IIR1"}, {"RX4 MIX1 INP2", "IIR2", "IIR2"}, {"RX5 MIX1 INP1", "RX1", "SLIM RX1"}, {"RX5 MIX1 INP1", "RX2", "SLIM RX2"}, {"RX5 MIX1 INP1", "RX3", "SLIM RX3"}, {"RX5 MIX1 INP1", "RX4", "SLIM RX4"}, {"RX5 MIX1 INP1", "RX5", "SLIM RX5"}, {"RX5 MIX1 INP1", "RX6", "SLIM RX6"}, {"RX5 MIX1 INP1", "RX7", "SLIM RX7"}, {"RX5 MIX1 INP1", "IIR1", "IIR1"}, {"RX5 MIX1 INP1", "IIR2", "IIR2"}, {"RX5 MIX1 INP2", "RX1", "SLIM RX1"}, {"RX5 MIX1 INP2", "RX2", "SLIM RX2"}, {"RX5 MIX1 INP2", "RX3", "SLIM RX3"}, {"RX5 MIX1 INP2", "RX4", "SLIM RX4"}, {"RX5 MIX1 INP2", "RX5", "SLIM RX5"}, {"RX5 MIX1 INP2", "RX6", "SLIM RX6"}, {"RX5 MIX1 INP2", "RX7", "SLIM RX7"}, {"RX5 MIX1 INP2", "IIR1", "IIR1"}, {"RX5 MIX1 INP2", "IIR2", "IIR2"}, {"RX6 MIX1 INP1", "RX1", "SLIM RX1"}, {"RX6 MIX1 INP1", "RX2", "SLIM RX2"}, {"RX6 MIX1 INP1", "RX3", "SLIM RX3"}, {"RX6 MIX1 INP1", "RX4", "SLIM RX4"}, {"RX6 MIX1 INP1", "RX5", "SLIM RX5"}, {"RX6 MIX1 INP1", "RX6", "SLIM RX6"}, {"RX6 MIX1 INP1", "RX7", "SLIM RX7"}, {"RX6 MIX1 INP1", "IIR1", "IIR1"}, {"RX6 MIX1 INP1", "IIR2", "IIR2"}, {"RX6 MIX1 INP2", "RX1", "SLIM RX1"}, {"RX6 MIX1 INP2", "RX2", "SLIM RX2"}, {"RX6 MIX1 INP2", "RX3", "SLIM RX3"}, {"RX6 MIX1 INP2", "RX4", "SLIM RX4"}, {"RX6 MIX1 INP2", "RX5", "SLIM RX5"}, {"RX6 MIX1 INP2", "RX6", "SLIM RX6"}, {"RX6 MIX1 INP2", "RX7", "SLIM RX7"}, {"RX6 MIX1 INP2", "IIR1", "IIR1"}, {"RX6 MIX1 INP2", "IIR2", "IIR2"}, {"RX7 MIX1 INP1", "RX1", "SLIM RX1"}, {"RX7 MIX1 INP1", "RX2", "SLIM RX2"}, {"RX7 MIX1 INP1", "RX3", "SLIM RX3"}, {"RX7 MIX1 INP1", "RX4", "SLIM RX4"}, {"RX7 MIX1 INP1", "RX5", "SLIM RX5"}, {"RX7 MIX1 INP1", "RX6", "SLIM RX6"}, {"RX7 MIX1 INP1", "RX7", "SLIM RX7"}, {"RX7 MIX1 INP1", "IIR1", "IIR1"}, {"RX7 MIX1 INP1", "IIR2", "IIR2"}, {"RX7 MIX1 INP2", "RX1", "SLIM RX1"}, {"RX7 MIX1 INP2", "RX2", "SLIM RX2"}, {"RX7 MIX1 INP2", "RX3", "SLIM RX3"}, {"RX7 MIX1 INP2", "RX4", "SLIM RX4"}, {"RX7 MIX1 INP2", "RX5", "SLIM RX5"}, {"RX7 MIX1 INP2", "RX6", "SLIM RX6"}, {"RX7 MIX1 INP2", "RX7", "SLIM RX7"}, {"RX7 MIX1 INP2", "IIR1", "IIR1"}, {"RX7 MIX1 INP2", "IIR2", "IIR2"}, {"RX8 MIX1 INP1", "RX1", "SLIM RX1"}, {"RX8 MIX1 INP1", "RX2", "SLIM RX2"}, {"RX8 MIX1 INP1", "RX3", "SLIM RX3"}, {"RX8 MIX1 INP1", "RX4", "SLIM RX4"}, {"RX8 MIX1 INP1", "RX5", "SLIM RX5"}, {"RX8 MIX1 INP1", "RX6", "SLIM RX6"}, {"RX8 MIX1 INP1", "RX7", "SLIM RX7"}, {"RX8 MIX1 INP1", "RX8", "SLIM RX8"}, {"RX8 MIX1 INP1", "IIR1", "IIR1"}, {"RX8 MIX1 INP1", "IIR2", "IIR2"}, {"RX8 MIX1 INP2", "RX1", "SLIM RX1"}, {"RX8 MIX1 INP2", "RX2", "SLIM RX2"}, {"RX8 MIX1 INP2", "RX3", "SLIM RX3"}, {"RX8 MIX1 INP2", "RX4", "SLIM RX4"}, {"RX8 MIX1 INP2", "RX5", "SLIM RX5"}, {"RX8 MIX1 INP2", "RX6", "SLIM RX6"}, {"RX8 MIX1 INP2", "RX7", "SLIM RX7"}, {"RX8 MIX1 INP2", "RX8", "SLIM RX8"}, {"RX8 MIX1 INP2", "IIR1", "IIR1"}, {"RX8 MIX1 INP2", "IIR2", "IIR2"}, /* IIR1, IIR2 inputs to Second RX Mixer on RX1, RX2 and RX7 chains. */ {"RX1 MIX2 INP1", "IIR1", "IIR1"}, {"RX1 MIX2 INP2", "IIR1", "IIR1"}, {"RX2 MIX2 INP1", "IIR1", "IIR1"}, {"RX2 MIX2 INP2", "IIR1", "IIR1"}, {"RX7 MIX2 INP1", "IIR1", "IIR1"}, {"RX7 MIX2 INP2", "IIR1", "IIR1"}, {"RX1 MIX2 INP1", "IIR2", "IIR2"}, {"RX1 MIX2 INP2", "IIR2", "IIR2"}, {"RX2 MIX2 INP1", "IIR2", "IIR2"}, {"RX2 MIX2 INP2", "IIR2", "IIR2"}, {"RX7 MIX2 INP1", "IIR2", "IIR2"}, {"RX7 MIX2 INP2", "IIR2", "IIR2"}, /* Decimator Inputs */ {"DEC1 MUX", "DMIC1", "DMIC1"}, {"DEC1 MUX", "ADC6", "ADC6"}, {"DEC1 MUX", NULL, "CDC_CONN"}, {"DEC2 MUX", "DMIC2", "DMIC2"}, {"DEC2 MUX", "ADC5", "ADC5"}, {"DEC2 MUX", NULL, "CDC_CONN"}, {"DEC3 MUX", "DMIC3", "DMIC3"}, {"DEC3 MUX", "ADC4", "ADC4"}, {"DEC3 MUX", NULL, "CDC_CONN"}, {"DEC4 MUX", "DMIC4", "DMIC4"}, {"DEC4 MUX", "ADC3", "ADC3"}, {"DEC4 MUX", NULL, "CDC_CONN"}, {"DEC5 MUX", "DMIC5", "DMIC5"}, {"DEC5 MUX", "ADC2", "ADC2"}, {"DEC5 MUX", NULL, "CDC_CONN"}, {"DEC6 MUX", "DMIC6", "DMIC6"}, {"DEC6 MUX", "ADC1", "ADC1"}, {"DEC6 MUX", NULL, "CDC_CONN"}, {"DEC7 MUX", "DMIC1", "DMIC1"}, {"DEC7 MUX", "DMIC6", "DMIC6"}, {"DEC7 MUX", "ADC1", "ADC1"}, {"DEC7 MUX", "ADC6", "ADC6"}, {"DEC7 MUX", "ANC1_FB", "ANC1 MUX"}, {"DEC7 MUX", "ANC2_FB", "ANC2 MUX"}, {"DEC7 MUX", NULL, "CDC_CONN"}, {"DEC8 MUX", "DMIC2", "DMIC2"}, {"DEC8 MUX", "DMIC5", "DMIC5"}, {"DEC8 MUX", "ADC2", "ADC2"}, {"DEC8 MUX", "ADC5", "ADC5"}, {"DEC8 MUX", "ANC1_FB", "ANC1 MUX"}, {"DEC8 MUX", "ANC2_FB", "ANC2 MUX"}, {"DEC8 MUX", NULL, "CDC_CONN"}, {"DEC9 MUX", "DMIC4", "DMIC4"}, {"DEC9 MUX", "DMIC5", "DMIC5"}, {"DEC9 MUX", "ADC2", "ADC2"}, {"DEC9 MUX", "ADC3", "ADC3"}, {"DEC9 MUX", "ANC1_FB", "ANC1 MUX"}, {"DEC9 MUX", "ANC2_FB", "ANC2 MUX"}, {"DEC9 MUX", NULL, "CDC_CONN"}, {"DEC10 MUX", "DMIC3", "DMIC3"}, {"DEC10 MUX", "DMIC6", "DMIC6"}, {"DEC10 MUX", "ADC1", "ADC1"}, {"DEC10 MUX", "ADC4", "ADC4"}, {"DEC10 MUX", "ANC1_FB", "ANC1 MUX"}, {"DEC10 MUX", "ANC2_FB", "ANC2 MUX"}, {"DEC10 MUX", NULL, "CDC_CONN"}, /* ADC Connections */ {"ADC1", NULL, "AMIC1"}, {"ADC2", NULL, "AMIC2"}, {"ADC3", NULL, "AMIC3"}, {"ADC4", NULL, "AMIC4"}, {"ADC5", NULL, "AMIC5"}, {"ADC6", NULL, "AMIC6"}, /* AUX PGA Connections */ {"EAR_PA_MIXER", "AUX_PGA_L Switch", "AUX_PGA_Left"}, {"HPHL_PA_MIXER", "AUX_PGA_L Switch", "AUX_PGA_Left"}, {"HPHR_PA_MIXER", "AUX_PGA_R Switch", "AUX_PGA_Right"}, {"LINEOUT1_PA_MIXER", "AUX_PGA_L Switch", "AUX_PGA_Left"}, {"LINEOUT2_PA_MIXER", "AUX_PGA_R Switch", "AUX_PGA_Right"}, {"LINEOUT3_PA_MIXER", "AUX_PGA_L Switch", "AUX_PGA_Left"}, {"LINEOUT4_PA_MIXER", "AUX_PGA_R Switch", "AUX_PGA_Right"}, {"AUX_PGA_Left", NULL, "AMIC5"}, {"AUX_PGA_Right", NULL, "AMIC6"}, {"IIR1", NULL, "IIR1 INP1 MUX"}, {"IIR1 INP1 MUX", "DEC1", "DEC1 MUX"}, {"IIR1 INP1 MUX", "DEC2", "DEC2 MUX"}, {"IIR1 INP1 MUX", "DEC3", "DEC3 MUX"}, {"IIR1 INP1 MUX", "DEC4", "DEC4 MUX"}, {"IIR1 INP1 MUX", "DEC5", "DEC5 MUX"}, {"IIR1 INP1 MUX", "DEC6", "DEC6 MUX"}, {"IIR1 INP1 MUX", "DEC7", "DEC7 MUX"}, {"IIR1 INP1 MUX", "DEC8", "DEC8 MUX"}, {"IIR1 INP1 MUX", "DEC9", "DEC9 MUX"}, {"IIR1 INP1 MUX", "DEC10", "DEC10 MUX"}, {"IIR1 INP1 MUX", "RX1", "SLIM RX1"}, {"IIR1 INP1 MUX", "RX2", "SLIM RX2"}, {"IIR1 INP1 MUX", "RX3", "SLIM RX3"}, {"IIR1 INP1 MUX", "RX4", "SLIM RX4"}, {"IIR1 INP1 MUX", "RX5", "SLIM RX5"}, {"IIR1 INP1 MUX", "RX6", "SLIM RX6"}, {"IIR1 INP1 MUX", "RX7", "SLIM RX7"}, {"IIR2", NULL, "IIR2 INP1 MUX"}, {"IIR2 INP1 MUX", "DEC1", "DEC1 MUX"}, {"IIR2 INP1 MUX", "DEC2", "DEC2 MUX"}, {"IIR2 INP1 MUX", "DEC3", "DEC3 MUX"}, {"IIR2 INP1 MUX", "DEC4", "DEC4 MUX"}, {"IIR2 INP1 MUX", "DEC5", "DEC5 MUX"}, {"IIR2 INP1 MUX", "DEC6", "DEC6 MUX"}, {"IIR2 INP1 MUX", "DEC7", "DEC7 MUX"}, {"IIR2 INP1 MUX", "DEC8", "DEC8 MUX"}, {"IIR2 INP1 MUX", "DEC9", "DEC9 MUX"}, {"IIR2 INP1 MUX", "DEC10", "DEC10 MUX"}, {"IIR2 INP1 MUX", "RX1", "SLIM RX1"}, {"IIR2 INP1 MUX", "RX2", "SLIM RX2"}, {"IIR2 INP1 MUX", "RX3", "SLIM RX3"}, {"IIR2 INP1 MUX", "RX4", "SLIM RX4"}, {"IIR2 INP1 MUX", "RX5", "SLIM RX5"}, {"IIR2 INP1 MUX", "RX6", "SLIM RX6"}, {"IIR2 INP1 MUX", "RX7", "SLIM RX7"}, {"IIR1", NULL, "IIR1 INP2 MUX"}, {"IIR1 INP2 MUX", "DEC1", "DEC1 MUX"}, {"IIR1 INP2 MUX", "DEC2", "DEC2 MUX"}, {"IIR1 INP2 MUX", "DEC3", "DEC3 MUX"}, {"IIR1 INP2 MUX", "DEC4", "DEC4 MUX"}, {"IIR1 INP2 MUX", "DEC5", "DEC5 MUX"}, {"IIR1 INP2 MUX", "DEC6", "DEC6 MUX"}, {"IIR1 INP2 MUX", "DEC7", "DEC7 MUX"}, {"IIR1 INP2 MUX", "DEC8", "DEC8 MUX"}, {"IIR1 INP2 MUX", "DEC9", "DEC9 MUX"}, {"IIR1 INP2 MUX", "DEC10", "DEC10 MUX"}, {"IIR1 INP2 MUX", "RX1", "SLIM RX1"}, {"IIR1 INP2 MUX", "RX2", "SLIM RX2"}, {"IIR1 INP2 MUX", "RX3", "SLIM RX3"}, {"IIR1 INP2 MUX", "RX4", "SLIM RX4"}, {"IIR1 INP2 MUX", "RX5", "SLIM RX5"}, {"IIR1 INP2 MUX", "RX6", "SLIM RX6"}, {"IIR1 INP2 MUX", "RX7", "SLIM RX7"}, {"IIR2", NULL, "IIR2 INP2 MUX"}, {"IIR2 INP2 MUX", "DEC1", "DEC1 MUX"}, {"IIR2 INP2 MUX", "DEC2", "DEC2 MUX"}, {"IIR2 INP2 MUX", "DEC3", "DEC3 MUX"}, {"IIR2 INP2 MUX", "DEC4", "DEC4 MUX"}, {"IIR2 INP2 MUX", "DEC5", "DEC5 MUX"}, {"IIR2 INP2 MUX", "DEC6", "DEC6 MUX"}, {"IIR2 INP2 MUX", "DEC7", "DEC7 MUX"}, {"IIR2 INP2 MUX", "DEC8", "DEC8 MUX"}, {"IIR2 INP2 MUX", "DEC9", "DEC9 MUX"}, {"IIR2 INP2 MUX", "DEC10", "DEC10 MUX"}, {"IIR2 INP2 MUX", "RX1", "SLIM RX1"}, {"IIR2 INP2 MUX", "RX2", "SLIM RX2"}, {"IIR2 INP2 MUX", "RX3", "SLIM RX3"}, {"IIR2 INP2 MUX", "RX4", "SLIM RX4"}, {"IIR2 INP2 MUX", "RX5", "SLIM RX5"}, {"IIR2 INP2 MUX", "RX6", "SLIM RX6"}, {"IIR2 INP2 MUX", "RX7", "SLIM RX7"}, {"IIR1", NULL, "IIR1 INP3 MUX"}, {"IIR1 INP3 MUX", "DEC1", "DEC1 MUX"}, {"IIR1 INP3 MUX", "DEC2", "DEC2 MUX"}, {"IIR1 INP3 MUX", "DEC3", "DEC3 MUX"}, {"IIR1 INP3 MUX", "DEC4", "DEC4 MUX"}, {"IIR1 INP3 MUX", "DEC5", "DEC5 MUX"}, {"IIR1 INP3 MUX", "DEC6", "DEC6 MUX"}, {"IIR1 INP3 MUX", "DEC7", "DEC7 MUX"}, {"IIR1 INP3 MUX", "DEC8", "DEC8 MUX"}, {"IIR1 INP3 MUX", "DEC9", "DEC9 MUX"}, {"IIR1 INP3 MUX", "DEC10", "DEC10 MUX"}, {"IIR1 INP3 MUX", "RX1", "SLIM RX1"}, {"IIR1 INP3 MUX", "RX2", "SLIM RX2"}, {"IIR1 INP3 MUX", "RX3", "SLIM RX3"}, {"IIR1 INP3 MUX", "RX4", "SLIM RX4"}, {"IIR1 INP3 MUX", "RX5", "SLIM RX5"}, {"IIR1 INP3 MUX", "RX6", "SLIM RX6"}, {"IIR1 INP3 MUX", "RX7", "SLIM RX7"}, {"IIR2", NULL, "IIR2 INP3 MUX"}, {"IIR2 INP3 MUX", "DEC1", "DEC1 MUX"}, {"IIR2 INP3 MUX", "DEC2", "DEC2 MUX"}, {"IIR2 INP3 MUX", "DEC3", "DEC3 MUX"}, {"IIR2 INP3 MUX", "DEC4", "DEC4 MUX"}, {"IIR2 INP3 MUX", "DEC5", "DEC5 MUX"}, {"IIR2 INP3 MUX", "DEC6", "DEC6 MUX"}, {"IIR2 INP3 MUX", "DEC7", "DEC7 MUX"}, {"IIR2 INP3 MUX", "DEC8", "DEC8 MUX"}, {"IIR2 INP3 MUX", "DEC9", "DEC9 MUX"}, {"IIR2 INP3 MUX", "DEC10", "DEC10 MUX"}, {"IIR2 INP3 MUX", "RX1", "SLIM RX1"}, {"IIR2 INP3 MUX", "RX2", "SLIM RX2"}, {"IIR2 INP3 MUX", "RX3", "SLIM RX3"}, {"IIR2 INP3 MUX", "RX4", "SLIM RX4"}, {"IIR2 INP3 MUX", "RX5", "SLIM RX5"}, {"IIR2 INP3 MUX", "RX6", "SLIM RX6"}, {"IIR2 INP3 MUX", "RX7", "SLIM RX7"}, {"IIR1", NULL, "IIR1 INP4 MUX"}, {"IIR1 INP4 MUX", "DEC1", "DEC1 MUX"}, {"IIR1 INP4 MUX", "DEC2", "DEC2 MUX"}, {"IIR1 INP4 MUX", "DEC3", "DEC3 MUX"}, {"IIR1 INP4 MUX", "DEC4", "DEC4 MUX"}, {"IIR1 INP4 MUX", "DEC5", "DEC5 MUX"}, {"IIR1 INP4 MUX", "DEC6", "DEC6 MUX"}, {"IIR1 INP4 MUX", "DEC7", "DEC7 MUX"}, {"IIR1 INP4 MUX", "DEC8", "DEC8 MUX"}, {"IIR1 INP4 MUX", "DEC9", "DEC9 MUX"}, {"IIR1 INP4 MUX", "DEC10", "DEC10 MUX"}, {"IIR1 INP4 MUX", "RX1", "SLIM RX1"}, {"IIR1 INP4 MUX", "RX2", "SLIM RX2"}, {"IIR1 INP4 MUX", "RX3", "SLIM RX3"}, {"IIR1 INP4 MUX", "RX4", "SLIM RX4"}, {"IIR1 INP4 MUX", "RX5", "SLIM RX5"}, {"IIR1 INP4 MUX", "RX6", "SLIM RX6"}, {"IIR1 INP4 MUX", "RX7", "SLIM RX7"}, {"IIR2", NULL, "IIR2 INP4 MUX"}, {"IIR2 INP4 MUX", "DEC1", "DEC1 MUX"}, {"IIR2 INP4 MUX", "DEC2", "DEC2 MUX"}, {"IIR2 INP4 MUX", "DEC3", "DEC3 MUX"}, {"IIR2 INP4 MUX", "DEC4", "DEC4 MUX"}, {"IIR2 INP4 MUX", "DEC5", "DEC5 MUX"}, {"IIR2 INP4 MUX", "DEC6", "DEC6 MUX"}, {"IIR2 INP4 MUX", "DEC7", "DEC7 MUX"}, {"IIR2 INP4 MUX", "DEC8", "DEC8 MUX"}, {"IIR2 INP4 MUX", "DEC9", "DEC9 MUX"}, {"IIR2 INP4 MUX", "DEC10", "DEC10 MUX"}, {"IIR2 INP4 MUX", "RX1", "SLIM RX1"}, {"IIR2 INP4 MUX", "RX2", "SLIM RX2"}, {"IIR2 INP4 MUX", "RX3", "SLIM RX3"}, {"IIR2 INP4 MUX", "RX4", "SLIM RX4"}, {"IIR2 INP4 MUX", "RX5", "SLIM RX5"}, {"IIR2 INP4 MUX", "RX6", "SLIM RX6"}, {"IIR2 INP4 MUX", "RX7", "SLIM RX7"}, {"MIC BIAS1 Internal1", NULL, "LDO_H"}, {"MIC BIAS1 Internal2", NULL, "LDO_H"}, {"MIC BIAS1 External", NULL, "LDO_H"}, {"MIC BIAS2 Internal1", NULL, "LDO_H"}, {"MIC BIAS2 Internal2", NULL, "LDO_H"}, {"MIC BIAS2 Internal3", NULL, "LDO_H"}, {"MIC BIAS2 External", NULL, "LDO_H"}, {"MIC BIAS3 Internal1", NULL, "LDO_H"}, {"MIC BIAS3 Internal2", NULL, "LDO_H"}, {"MIC BIAS3 External", NULL, "LDO_H"}, {"MIC BIAS4 External", NULL, "LDO_H"}, {<API key>, NULL, "LDO_H Standalone"}, }; static int tomtom_readable(struct snd_soc_codec *ssc, unsigned int reg) { return tomtom_reg_readable[reg]; } static bool <API key>(unsigned int reg) { bool rtn = false; switch (reg) { case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: rtn = true; break; default: break; } return rtn; } static int tomtom_volatile(struct snd_soc_codec *ssc, unsigned int reg) { int i; /* Registers lower than 0x100 are top level registers which can be * written by the TomTom core driver. */ if ((reg >= <API key>) || (reg < 0x100)) return 1; if (reg == <API key>) return 1; /* IIR Coeff registers are not cacheable */ if ((reg >= <API key>) && (reg <= <API key>)) return 1; /* ANC filter registers are not cacheable */ if ((reg >= <API key>) && (reg <= <API key>)) return 1; if ((reg >= <API key>) && (reg <= <API key>)) return 1; /* Digital gain register is not cacheable so we have to write * the setting even it is the same */ if (<API key>(reg)) return 1; /* HPH status registers */ if (reg == <API key> || reg == <API key>) return 1; if (reg == <API key>) return 1; if (reg == <API key>) return 1; if (((reg >= <API key> && reg <= <API key>)) || ((reg >= <API key>) && (reg <= <API key>))) return 1; if (reg == <API key>) return 1; for (i = 0; i < ARRAY_SIZE(audio_reg_cfg); i++) if (audio_reg_cfg[i].reg_logical_addr - <API key> == reg) return 1; if (reg == <API key>) return 1; if (reg == <API key>) return 1; for (i = 0; i < ARRAY_SIZE(non_cacheable_reg); i++) if (reg == non_cacheable_reg[i]) return 1; return 0; } static int tomtom_write(struct snd_soc_codec *codec, unsigned int reg, unsigned int value) { int ret; struct wcd9xxx *wcd9xxx = codec->control_data; struct tomtom_priv *tomtom_p = <API key>(codec); if (reg == SND_SOC_NOPM) return 0; BUG_ON(reg > TOMTOM_MAX_REGISTER); if (!tomtom_volatile(codec, reg)) { ret = snd_soc_cache_write(codec, reg, value); if (ret != 0) dev_err(codec->dev, "Cache write to %x failed: %d\n", reg, ret); } if (unlikely(test_bit(BUS_DOWN, &tomtom_p->status_mask))) { dev_err(codec->dev, "write 0x%02x while offline\n", reg); return -ENODEV; } else return wcd9xxx_reg_write(&wcd9xxx->core_res, reg, value); } static unsigned int tomtom_read(struct snd_soc_codec *codec, unsigned int reg) { unsigned int val; int ret; struct tomtom_priv *tomtom_p = <API key>(codec); struct wcd9xxx *wcd9xxx = codec->control_data; if (reg == SND_SOC_NOPM) return 0; BUG_ON(reg > TOMTOM_MAX_REGISTER); if (!tomtom_volatile(codec, reg) && tomtom_readable(codec, reg) && reg < codec->driver->reg_cache_size) { ret = snd_soc_cache_read(codec, reg, &val); if (ret >= 0) { return val; } else dev_err(codec->dev, "Cache read from %x failed: %d\n", reg, ret); } if (unlikely(test_bit(BUS_DOWN, &tomtom_p->status_mask))) { dev_err(codec->dev, "read 0x%02x while offline\n", reg); return -ENODEV; } else { val = wcd9xxx_reg_read(&wcd9xxx->core_res, reg); return val; } } static int tomtom_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { pr_debug("%s(): substream = %s stream = %d\n" , __func__, substream->name, substream->stream); return 0; } static void tomtom_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { pr_debug("%s(): substream = %s stream = %d\n" , __func__, substream->name, substream->stream); } int tomtom_mclk_enable(struct snd_soc_codec *codec, int mclk_enable, bool dapm) { struct tomtom_priv *tomtom = <API key>(codec); pr_debug("%s: mclk_enable = %u, dapm = %d\n", __func__, mclk_enable, dapm); WCD9XXX_BG_CLK_LOCK(&tomtom->resmgr); if (mclk_enable) { <API key>(&tomtom->resmgr, <API key>); <API key>(&tomtom->resmgr, WCD9XXX_CLK_MCLK); } else { /* Put clock and BG */ <API key>(&tomtom->resmgr, WCD9XXX_CLK_MCLK); <API key>(&tomtom->resmgr, <API key>); } <API key>(&tomtom->resmgr); return 0; } static int <API key>(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { pr_debug("%s\n", __func__); return 0; } static int tomtom_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { u8 val = 0; struct tomtom_priv *tomtom = <API key>(dai->codec); pr_debug("%s\n", __func__); switch (fmt & <API key>) { case <API key>: /* CPU is master */ if (tomtom->intf_type == <API key>) { if (dai->id == AIF1_CAP) snd_soc_update_bits(dai->codec, <API key>, <API key>, 0); else if (dai->id == AIF1_PB) snd_soc_update_bits(dai->codec, <API key>, <API key>, 0); } break; case <API key>: /* CPU is slave */ if (tomtom->intf_type == <API key>) { val = <API key>; if (dai->id == AIF1_CAP) snd_soc_update_bits(dai->codec, <API key>, val, val); else if (dai->id == AIF1_PB) snd_soc_update_bits(dai->codec, <API key>, val, val); } break; default: return -EINVAL; } return 0; } static int <API key>(struct snd_soc_dai *dai, unsigned int tx_num, unsigned int *tx_slot, unsigned int rx_num, unsigned int *rx_slot) { struct <API key> *dai_data = NULL; struct tomtom_priv *tomtom = <API key>(dai->codec); struct wcd9xxx *core = dev_get_drvdata(dai->codec->dev->parent); if (!tx_slot || !rx_slot) { pr_err("%s: Invalid tx_slot=%pK, rx_slot=%pK\n", __func__, tx_slot, rx_slot); return -EINVAL; } pr_debug("%s(): dai_name = %s DAI-ID %x tx_ch %d rx_ch %d\n" "tomtom->intf_type %d\n", __func__, dai->name, dai->id, tx_num, rx_num, tomtom->intf_type); if (tomtom->intf_type == <API key>) { <API key>(core, core->slim->laddr, tx_num, tx_slot, rx_num, rx_slot); /* Reserve TX13 for MAD data channel */ dai_data = &tomtom->dai[AIF4_MAD_TX]; if (dai_data) { list_add_tail(&core->tx_chs[TOMTOM_TX13].list, &dai_data->wcd9xxx_ch_list); } } return 0; } static int <API key>(struct snd_soc_dai *dai, unsigned int *tx_num, unsigned int *tx_slot, unsigned int *rx_num, unsigned int *rx_slot) { struct tomtom_priv *tomtom_p = <API key>(dai->codec); u32 i = 0; struct wcd9xxx_ch *ch; switch (dai->id) { case AIF1_PB: case AIF2_PB: case AIF3_PB: if (!rx_slot || !rx_num) { pr_err("%s: Invalid rx_slot %pK or rx_num %pK\n", __func__, rx_slot, rx_num); return -EINVAL; } list_for_each_entry(ch, &tomtom_p->dai[dai->id].wcd9xxx_ch_list, list) { pr_debug("%s: slot_num %u ch->ch_num %d\n", __func__, i, ch->ch_num); rx_slot[i++] = ch->ch_num; } pr_debug("%s: rx_num %d\n", __func__, i); *rx_num = i; break; case AIF1_CAP: case AIF2_CAP: case AIF3_CAP: case AIF4_VIFEED: case AIF4_MAD_TX: if (!tx_slot || !tx_num) { pr_err("%s: Invalid tx_slot %pK or tx_num %pK\n", __func__, tx_slot, tx_num); return -EINVAL; } list_for_each_entry(ch, &tomtom_p->dai[dai->id].wcd9xxx_ch_list, list) { pr_debug("%s: slot_num %u ch->ch_num %d\n", __func__, i, ch->ch_num); tx_slot[i++] = ch->ch_num; } pr_debug("%s: tx_num %d\n", __func__, i); *tx_num = i; break; default: pr_err("%s: Invalid DAI ID %x\n", __func__, dai->id); break; } return 0; } static int <API key>(struct snd_soc_dai *dai, u8 rx_fs_rate_reg_val, u32 compander_fs, u32 sample_rate) { u32 j; u8 rx_mix1_inp, rx8_mix1_inp; u16 rx_mix_1_reg_1, rx_mix_1_reg_2; u16 rx_fs_reg; u8 rx_mix_1_reg_1_val, rx_mix_1_reg_2_val; struct snd_soc_codec *codec = dai->codec; struct wcd9xxx_ch *ch; struct tomtom_priv *tomtom = <API key>(codec); int port_rx_8 = <API key> + NUM_INTERPOLATORS - 1; list_for_each_entry(ch, &tomtom->dai[dai->id].wcd9xxx_ch_list, list) { /* for RX port starting from 16 instead of 10 like tabla */ rx_mix1_inp = ch->port + RX_MIX1_INP_SEL_RX1 - <API key>; rx8_mix1_inp = ch->port + <API key> - <API key>; if (((ch->port < port_rx_8) && ((rx_mix1_inp < RX_MIX1_INP_SEL_RX1) || (rx_mix1_inp > RX_MIX1_INP_SEL_RX7))) || ((rx8_mix1_inp < <API key>) || (rx8_mix1_inp > <API key>))) { pr_err("%s: Invalid TOMTOM_RX%u port. Dai ID is %d\n", __func__, rx8_mix1_inp - 2, dai->id); return -EINVAL; } rx_mix_1_reg_1 = <API key>; for (j = 0; j < NUM_INTERPOLATORS - 1; j++) { rx_mix_1_reg_2 = rx_mix_1_reg_1 + 1; rx_mix_1_reg_1_val = snd_soc_read(codec, rx_mix_1_reg_1); rx_mix_1_reg_2_val = snd_soc_read(codec, rx_mix_1_reg_2); if (((rx_mix_1_reg_1_val & 0x0F) == rx_mix1_inp) || (((rx_mix_1_reg_1_val >> 4) & 0x0F) == rx_mix1_inp) || ((rx_mix_1_reg_2_val & 0x0F) == rx_mix1_inp)) { rx_fs_reg = <API key> + 8 * j; pr_debug("%s: AIF_PB DAI(%d) connected to RX%u\n", __func__, dai->id, j + 1); pr_debug("%s: set RX%u sample rate to %u\n", __func__, j + 1, sample_rate); snd_soc_update_bits(codec, rx_fs_reg, 0xE0, rx_fs_rate_reg_val); if (comp_rx_path[j] < COMPANDER_MAX) tomtom->comp_fs[comp_rx_path[j]] = compander_fs; } if (j < 2) rx_mix_1_reg_1 += 3; else rx_mix_1_reg_1 += 2; } /* RX8 interpolator path */ rx_mix_1_reg_1_val = snd_soc_read(codec, <API key>); if (((rx_mix_1_reg_1_val & 0x0F) == rx8_mix1_inp) || (((rx_mix_1_reg_1_val >> 4) & 0x0F) == rx8_mix1_inp)) { snd_soc_update_bits(codec, <API key>, 0xE0, rx_fs_rate_reg_val); pr_debug("%s: AIF_PB DAI(%d) connected to RX%u\n", __func__, dai->id, NUM_INTERPOLATORS); pr_debug("%s: set RX%u sample rate to %u\n", __func__, NUM_INTERPOLATORS, sample_rate); if (comp_rx_path[NUM_INTERPOLATORS - 1] < COMPANDER_MAX) tomtom->comp_fs[comp_rx_path[j]] = compander_fs; } } return 0; } static int <API key>(struct snd_soc_dai *dai, u8 tx_fs_rate_reg_val, u32 sample_rate) { struct snd_soc_codec *codec = dai->codec; struct wcd9xxx_ch *ch; struct tomtom_priv *tomtom = <API key>(codec); u32 tx_port; u16 tx_port_reg, tx_fs_reg; u8 tx_port_reg_val; s8 decimator; list_for_each_entry(ch, &tomtom->dai[dai->id].wcd9xxx_ch_list, list) { tx_port = ch->port + 1; pr_debug("%s: dai->id = %d, tx_port = %d", __func__, dai->id, tx_port); if ((tx_port < 1) || (tx_port > NUM_DECIMATORS)) { pr_err("%s: Invalid SLIM TX%u port. DAI ID is %d\n", __func__, tx_port, dai->id); return -EINVAL; } tx_port_reg = <API key> + (tx_port - 1); tx_port_reg_val = snd_soc_read(codec, tx_port_reg); decimator = 0; if ((tx_port >= 1) && (tx_port <= 6)) { tx_port_reg_val = tx_port_reg_val & 0x0F; if (tx_port_reg_val == 0x8) decimator = tx_port; } else if ((tx_port >= 7) && (tx_port <= NUM_DECIMATORS)) { tx_port_reg_val = tx_port_reg_val & 0x1F; if ((tx_port_reg_val >= 0x8) && (tx_port_reg_val <= 0x11)) { decimator = (tx_port_reg_val - 0x8) + 1; } } if (decimator) { /* SLIM_TX port has a DEC as input */ tx_fs_reg = <API key> + 8 * (decimator - 1); pr_debug("%s: set DEC%u (-> SLIM_TX%u) rate to %u\n", __func__, decimator, tx_port, sample_rate); snd_soc_update_bits(codec, tx_fs_reg, 0x07, tx_fs_rate_reg_val); } else { if ((tx_port_reg_val >= 0x1) && (tx_port_reg_val <= 0x7)) { pr_debug("%s: RMIX%u going to SLIM TX%u\n", __func__, tx_port_reg_val, tx_port); } else if ((tx_port_reg_val >= 0x8) && (tx_port_reg_val <= 0x11)) { pr_err("%s: ERROR: Should not be here\n", __func__); pr_err("%s: ERROR: DEC connected to SLIM TX%u\n", __func__, tx_port); return -EINVAL; } else if (tx_port_reg_val == 0) { pr_debug("%s: no signal to SLIM TX%u\n", __func__, tx_port); } else { pr_err("%s: ERROR: wrong signal to SLIM TX%u\n", __func__, tx_port); pr_err("%s: ERROR: wrong signal = %u\n", __func__, tx_port_reg_val); return -EINVAL; } } } return 0; } static void <API key>(struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { struct snd_soc_codec *codec = dai->codec; struct tomtom_priv *tomtom_p = <API key>(codec); struct <API key> *cdc_dai; struct wcd9xxx_ch *ch; int port; u8 bit_sel; u16 sb_ctl_reg, field_shift; switch (params_format(params)) { case <API key>: bit_sel = 0x2; tomtom_p->dai[dai->id].bit_width = 16; break; case <API key>: bit_sel = 0x0; tomtom_p->dai[dai->id].bit_width = 24; break; default: dev_err(codec->dev, "Invalid format\n"); return; } cdc_dai = &tomtom_p->dai[dai->id]; list_for_each_entry(ch, &cdc_dai->wcd9xxx_ch_list, list) { port = <API key>(ch->ch_num); if (IS_ERR_VALUE(port) || !<API key>(port)) { dev_warn(codec->dev, "%s: invalid port ID %d returned for RX DAI\n", __func__, port); return; } port = <API key>(port); if (port <= 3) { sb_ctl_reg = <API key>; field_shift = port << 1; } else if (port <= 7) { sb_ctl_reg = <API key>; field_shift = (port - 4) << 1; } else { /* should not happen */ dev_warn(codec->dev, "%s: bad port ID %d\n", __func__, port); return; } dev_dbg(codec->dev, "%s: sb_ctl_reg %x field_shift %x\n", __func__, sb_ctl_reg, field_shift); snd_soc_update_bits(codec, sb_ctl_reg, 0x3 << field_shift, bit_sel << field_shift); } } static void <API key>(struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { struct snd_soc_codec *codec = dai->codec; struct tomtom_priv *tomtom_p = <API key>(codec); struct <API key> *cdc_dai; struct wcd9xxx_ch *ch; int port; u8 bit_sel, bit_shift; u16 sb_ctl_reg; switch (params_format(params)) { case <API key>: bit_sel = 0x2; tomtom_p->dai[dai->id].bit_width = 16; break; case <API key>: bit_sel = 0x0; tomtom_p->dai[dai->id].bit_width = 24; break; default: dev_err(codec->dev, "%s: Invalid format %d\n", __func__, params_format(params)); return; } cdc_dai = &tomtom_p->dai[dai->id]; list_for_each_entry(ch, &cdc_dai->wcd9xxx_ch_list, list) { port = <API key>(ch->ch_num); if (IS_ERR_VALUE(port) || !<API key>(port)) { dev_warn(codec->dev, "%s: invalid port ID %d returned for TX DAI\n", __func__, port); return; } if (port < 6) /* 6 = SLIMBUS TX7 */ bit_shift = <API key>; else if (port < 10) bit_shift = <API key>; else { dev_warn(codec->dev, "%s: port ID %d bitwidth is fixed\n", __func__, port); return; } sb_ctl_reg = (<API key> + port); dev_dbg(codec->dev, "%s: reg %x bit_sel %x bit_shift %x\n", __func__, sb_ctl_reg, bit_sel, bit_shift); snd_soc_update_bits(codec, sb_ctl_reg, 0x3 << bit_shift, bit_sel << bit_shift); } } static int tomtom_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { struct snd_soc_codec *codec = dai->codec; struct tomtom_priv *tomtom = <API key>(dai->codec); u8 tx_fs_rate, rx_fs_rate, i2s_bit_mode; u32 compander_fs; int ret; pr_debug("%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n", __func__, dai->name, dai->id, params_rate(params), params_channels(params)); switch (params_rate(params)) { case 8000: tx_fs_rate = 0x00; rx_fs_rate = 0x00; compander_fs = COMPANDER_FS_8KHZ; break; case 16000: tx_fs_rate = 0x01; rx_fs_rate = 0x20; compander_fs = COMPANDER_FS_16KHZ; break; case 32000: tx_fs_rate = 0x02; rx_fs_rate = 0x40; compander_fs = COMPANDER_FS_32KHZ; break; case 48000: tx_fs_rate = 0x03; rx_fs_rate = 0x60; compander_fs = COMPANDER_FS_48KHZ; break; case 96000: tx_fs_rate = 0x04; rx_fs_rate = 0x80; compander_fs = COMPANDER_FS_96KHZ; break; case 192000: tx_fs_rate = 0x05; rx_fs_rate = 0xA0; compander_fs = COMPANDER_FS_192KHZ; break; default: pr_err("%s: Invalid sampling rate %d\n", __func__, params_rate(params)); return -EINVAL; } switch (substream->stream) { case <API key>: if (dai->id != AIF4_VIFEED && dai->id != AIF4_MAD_TX) { ret = <API key>(dai, tx_fs_rate, params_rate(params)); if (ret < 0) { pr_err("%s: set decimator rate failed %d\n", __func__, ret); return ret; } } tomtom->dai[dai->id].rate = params_rate(params); switch (params_format(params)) { case <API key>: i2s_bit_mode = 0x01; tomtom->dai[dai->id].bit_width = 16; break; case <API key>: tomtom->dai[dai->id].bit_width = 24; i2s_bit_mode = 0x00; break; case <API key>: tomtom->dai[dai->id].bit_width = 32; i2s_bit_mode = 0x00; break; default: dev_err(codec->dev, "%s: Invalid format 0x%x\n", __func__, params_format(params)); return -EINVAL; } if (tomtom->intf_type == <API key>) { snd_soc_update_bits(codec, <API key>, 0x20, i2s_bit_mode << 5); snd_soc_update_bits(codec, <API key>, 0x07, tx_fs_rate); } else { /* only generic ports can have sample bit adjustment */ if (dai->id != AIF4_VIFEED && dai->id != AIF4_MAD_TX) <API key>(params, dai); } break; case <API key>: ret = <API key>(dai, rx_fs_rate, compander_fs, params_rate(params)); if (ret < 0) { pr_err("%s: set decimator rate failed %d\n", __func__, ret); return ret; } if (tomtom->intf_type == <API key>) { switch (params_format(params)) { case <API key>: snd_soc_update_bits(codec, <API key>, 0x20, 0x20); break; case <API key>: snd_soc_update_bits(codec, <API key>, 0x20, 0x00); break; default: pr_err("invalid format\n"); break; } snd_soc_update_bits(codec, <API key>, 0x03, (rx_fs_rate >> 0x05)); } else { <API key>(params, dai); tomtom->dai[dai->id].rate = params_rate(params); } break; default: pr_err("%s: Invalid stream type %d\n", __func__, substream->stream); return -EINVAL; } return 0; } static struct snd_soc_dai_ops tomtom_dai_ops = { .startup = tomtom_startup, .shutdown = tomtom_shutdown, .hw_params = tomtom_hw_params, .set_sysclk = <API key>, .set_fmt = tomtom_set_dai_fmt, .set_channel_map = <API key>, .get_channel_map = <API key>, }; static struct snd_soc_dai_driver tomtom_dai[] = { { .name = "tomtom_rx1", .id = AIF1_PB, .playback = { .stream_name = "AIF1 Playback", .rates = WCD9330_RATES, .formats = <API key>, .rate_max = 192000, .rate_min = 8000, .channels_min = 1, .channels_max = 2, }, .ops = &tomtom_dai_ops, }, { .name = "tomtom_tx1", .id = AIF1_CAP, .capture = { .stream_name = "AIF1 Capture", .rates = WCD9330_RATES, .formats = TOMTOM_FORMATS, .rate_max = 192000, .rate_min = 8000, .channels_min = 1, .channels_max = 4, }, .ops = &tomtom_dai_ops, }, { .name = "tomtom_rx2", .id = AIF2_PB, .playback = { .stream_name = "AIF2 Playback", .rates = WCD9330_RATES, .formats = <API key>, .rate_min = 8000, .rate_max = 192000, .channels_min = 1, .channels_max = 2, }, .ops = &tomtom_dai_ops, }, { .name = "tomtom_tx2", .id = AIF2_CAP, .capture = { .stream_name = "AIF2 Capture", .rates = WCD9330_RATES, .formats = TOMTOM_FORMATS, .rate_max = 192000, .rate_min = 8000, .channels_min = 1, .channels_max = 8, }, .ops = &tomtom_dai_ops, }, { .name = "tomtom_rx3", .id = AIF3_PB, .playback = { .stream_name = "AIF3 Playback", .rates = WCD9330_RATES, .formats = <API key>, .rate_min = 8000, .rate_max = 192000, .channels_min = 1, .channels_max = 2, }, .ops = &tomtom_dai_ops, }, { .name = "tomtom_tx3", .id = AIF3_CAP, .capture = { .stream_name = "AIF3 Capture", .rates = WCD9330_RATES, .formats = TOMTOM_FORMATS, .rate_max = 48000, .rate_min = 8000, .channels_min = 1, .channels_max = 2, }, .ops = &tomtom_dai_ops, }, { .name = "tomtom_vifeedback", .id = AIF4_VIFEED, .capture = { .stream_name = "VIfeed", .rates = <API key>, .formats = TOMTOM_FORMATS, .rate_max = 48000, .rate_min = 48000, .channels_min = 2, .channels_max = 4, }, .ops = &tomtom_dai_ops, }, { .name = "tomtom_mad1", .id = AIF4_MAD_TX, .capture = { .stream_name = "AIF4 MAD TX", .rates = <API key>, .formats = <API key>, .rate_min = 16000, .rate_max = 16000, .channels_min = 1, .channels_max = 1, }, .ops = &tomtom_dai_ops, }, }; static struct snd_soc_dai_driver tomtom_i2s_dai[] = { { .name = "tomtom_i2s_rx1", .id = AIF1_PB, .playback = { .stream_name = "AIF1 Playback", .rates = WCD9330_RATES, .formats = TOMTOM_FORMATS, .rate_max = 192000, .rate_min = 8000, .channels_min = 1, .channels_max = 4, }, .ops = &tomtom_dai_ops, }, { .name = "tomtom_i2s_tx1", .id = AIF1_CAP, .capture = { .stream_name = "AIF1 Capture", .rates = WCD9330_RATES, .formats = TOMTOM_FORMATS, .rate_max = 192000, .rate_min = 8000, .channels_min = 1, .channels_max = 4, }, .ops = &tomtom_dai_ops, }, { .name = "tomtom_i2s_rx2", .id = AIF1_PB, .playback = { .stream_name = "AIF2 Playback", .rates = WCD9330_RATES, .formats = TOMTOM_FORMATS, .rate_max = 192000, .rate_min = 8000, .channels_min = 1, .channels_max = 4, }, .ops = &tomtom_dai_ops, }, { .name = "tomtom_i2s_tx2", .id = AIF1_CAP, .capture = { .stream_name = "AIF2 Capture", .rates = WCD9330_RATES, .formats = TOMTOM_FORMATS, .rate_max = 192000, .rate_min = 8000, .channels_min = 1, .channels_max = 4, }, .ops = &tomtom_dai_ops, }, }; static int <API key>(struct <API key> *dai, bool up) { int ret = 0; struct wcd9xxx_ch *ch; if (up) { list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) { ret = <API key>(ch->ch_num); if (ret < 0) { pr_err("%s: Invalid slave port ID: %d\n", __func__, ret); ret = -EINVAL; } else { set_bit(ret, &dai->ch_mask); } } } else { ret = wait_event_timeout(dai->dai_wait, (dai->ch_mask == 0), msecs_to_jiffies( <API key>)); if (!ret) { pr_err("%s: Slim close tx/rx wait timeout\n", __func__); ret = -ETIMEDOUT; } else { ret = 0; } } return ret; } static void <API key>(struct <API key> *dai, struct snd_soc_codec *codec) { struct wcd9xxx_ch *ch; int port_num = 0; unsigned short reg = 0; u8 val = 0; if (!dai || !codec) { pr_err("%s: Invalid params\n", __func__); return; } list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) { if (ch->port >= <API key>) { port_num = ch->port - <API key>; reg = <API key> + (port_num / 8); val = <API key>(codec->control_data, reg); if (!(val & (1 << (port_num % 8)))) { val |= (1 << (port_num % 8)); <API key>( codec->control_data, reg, val); val = <API key>( codec->control_data, reg); } } else { port_num = ch->port; reg = <API key> + (port_num / 8); val = <API key>(codec->control_data, reg); if (!(val & (1 << (port_num % 8)))) { val |= (1 << (port_num % 8)); <API key>(codec->control_data, reg, val); val = <API key>( codec->control_data, reg); } } } } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct wcd9xxx *core; struct snd_soc_codec *codec = w->codec; struct tomtom_priv *tomtom_p = <API key>(codec); int ret = 0; struct <API key> *dai; core = dev_get_drvdata(codec->dev->parent); pr_debug("%s: event called! codec name %s num_dai %d\n" "stream name %s event %d\n", __func__, w->codec->name, w->codec->num_dai, w->sname, event); /* Execute the callback only if interface type is slimbus */ if (tomtom_p->intf_type != <API key>) return 0; dai = &tomtom_p->dai[w->shift]; pr_debug("%s: w->name %s w->shift %d event %d\n", __func__, w->name, w->shift, event); switch (event) { case <API key>: dai-><API key> = false; <API key>(dai, codec); (void) <API key>(dai, true); ret = <API key>(core, &dai->wcd9xxx_ch_list, dai->rate, dai->bit_width, &dai->grph); break; case <API key>: ret = <API key>(core, &dai->wcd9xxx_ch_list, dai->grph); pr_debug("%s: Disconnect RX port, ret = %d\n", __func__, ret); ret = <API key>(core, &dai->wcd9xxx_ch_list, dai->grph); if (!dai-><API key>) ret = <API key>(dai, false); else pr_debug("%s: bus in recovery skip enable slim_chmask", __func__); break; } return ret; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct wcd9xxx *core = NULL; struct snd_soc_codec *codec = NULL; struct tomtom_priv *tomtom_p = NULL; int ret = 0; struct <API key> *dai = NULL; if (!w || !w->codec) { pr_err("%s invalid params\n", __func__); return -EINVAL; } codec = w->codec; tomtom_p = <API key>(codec); core = dev_get_drvdata(codec->dev->parent); pr_debug("%s: event called! codec name %s num_dai %d stream name %s\n", __func__, w->codec->name, w->codec->num_dai, w->sname); /* Execute the callback only if interface type is slimbus */ if (tomtom_p->intf_type != <API key>) { pr_err("%s Interface is not correct", __func__); return 0; } pr_debug("%s(): w->name %s event %d w->shift %d\n", __func__, w->name, event, w->shift); if (w->shift != AIF4_VIFEED) { pr_err("%s Error in enabling the tx path\n", __func__); ret = -EINVAL; goto out_vi; } dai = &tomtom_p->dai[w->shift]; switch (event) { case <API key>: if (test_bit(VI_SENSE_1, &tomtom_p->status_mask)) { pr_debug("%s: spkr1 enabled\n", __func__); /* Enable V&I sensing */ snd_soc_update_bits(codec, <API key>, 0x88, 0x88); /* Enable spkr VI clocks */ snd_soc_update_bits(codec, <API key>, 0xC, 0xC); } if (test_bit(VI_SENSE_2, &tomtom_p->status_mask)) { pr_debug("%s: spkr2 enabled\n", __func__); /* Enable V&I sensing */ snd_soc_update_bits(codec, <API key>, 0x88, 0x88); /* Enable spkr VI clocks */ snd_soc_update_bits(codec, <API key>, 0x30, 0x30); } dai-><API key> = false; <API key>(dai, codec); (void) <API key>(dai, true); ret = <API key>(core, &dai->wcd9xxx_ch_list, dai->rate, dai->bit_width, &dai->grph); break; case <API key>: ret = <API key>(core, &dai->wcd9xxx_ch_list, dai->grph); if (ret) pr_err("%s error in close_slim_sch_tx %d\n", __func__, ret); if (!dai-><API key>) ret = <API key>(dai, false); if (ret < 0) { ret = <API key>(core, &dai->wcd9xxx_ch_list, dai->grph); pr_debug("%s: Disconnect TX port, ret = %d\n", __func__, ret); } if (test_bit(VI_SENSE_1, &tomtom_p->status_mask)) { /* Disable V&I sensing */ pr_debug("%s: spkr1 disabled\n", __func__); snd_soc_update_bits(codec, <API key>, 0xC, 0x0); snd_soc_update_bits(codec, <API key>, 0x88, 0x00); } if (test_bit(VI_SENSE_2, &tomtom_p->status_mask)) { /* Disable V&I sensing */ pr_debug("%s: spkr2 disabled\n", __func__); snd_soc_update_bits(codec, <API key>, 0x30, 0x0); snd_soc_update_bits(codec, <API key>, 0x88, 0x00); } break; } out_vi: return ret; } /* <API key>: Enable the slimbus slave port * for TX path * @codec: Handle to the codec for which the slave port is to be * enabled. * @dai_data: The dai specific data for dai which is enabled. */ static int <API key>(struct snd_soc_codec *codec, int event, struct <API key> *dai_data) { struct wcd9xxx *core; int ret = 0; core = dev_get_drvdata(codec->dev->parent); switch (event) { case <API key>: dai_data-><API key> = false; <API key>(dai_data, codec); (void) <API key>(dai_data, true); ret = <API key>(core, &dai_data->wcd9xxx_ch_list, dai_data->rate, dai_data->bit_width, &dai_data->grph); break; case <API key>: ret = <API key>(core, &dai_data->wcd9xxx_ch_list, dai_data->grph); if (!dai_data-><API key>) ret = <API key>(dai_data, false); if (ret < 0) { ret = <API key>(core, &dai_data->wcd9xxx_ch_list, dai_data->grph); dev_dbg(codec->dev, "%s: Disconnect TX port, ret = %d\n", __func__, ret); } break; } return ret; } /* * <API key>: Callback function that will be invoked * to setup the slave port for MAD. * @codec: Handle to the codec * @event: Indicates whether to enable or disable the slave port */ static int <API key>(struct snd_soc_codec *codec, u8 event) { struct tomtom_priv *tomtom_p = <API key>(codec); struct <API key> *dai; int dapm_event = <API key>; dai = &tomtom_p->dai[AIF4_MAD_TX]; if (event == 0) dapm_event = <API key>; dev_dbg(codec->dev, "%s: mad_channel, event = 0x%x\n", __func__, event); return <API key>(codec, dapm_event, dai); } /* * <API key>: DAPM widget allback for TX widgets * @w: widget for which this callback is invoked * @kcontrol: kcontrol associated with this widget * @event: DAPM supplied event indicating enable/disable */ static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tomtom_priv *tomtom_p = <API key>(codec); struct <API key> *dai; dev_dbg(codec->dev, "%s: codec name %s num_dai %d stream name %s\n", __func__, w->codec->name, w->codec->num_dai, w->sname); /* Execute the callback only if interface type is slimbus */ if (tomtom_p->intf_type != <API key>) return 0; dev_dbg(codec->dev, "%s(): w->name %s event %d w->shift %d\n", __func__, w->name, event, w->shift); dai = &tomtom_p->dai[w->shift]; return <API key>(codec, event, dai); } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tomtom_priv *tomtom_p = <API key>(codec); pr_debug("%s %s %d\n", __func__, w->name, event); switch (event) { case <API key>: wcd9xxx_clsh_fsm(codec, &tomtom_p->clsh_d, <API key>, <API key>, <API key>); usleep_range(5000, 5100); break; } return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tomtom_priv *tomtom_p = <API key>(codec); pr_debug("%s %s %d\n", __func__, w->name, event); switch (event) { case <API key>: wcd9xxx_clsh_fsm(codec, &tomtom_p->clsh_d, <API key>, <API key>, <API key>); break; case <API key>: wcd9xxx_clsh_fsm(codec, &tomtom_p->clsh_d, <API key>, <API key>, <API key>); usleep_range(5000, 5100); break; default: break; } return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; pr_debug("%s: event = %d\n", __func__, event); switch (event) { case <API key>: /* fall through */ case <API key>: if (strnstr(w->name, "IIR1", sizeof("IIR1"))) { snd_soc_write(codec, <API key>, snd_soc_read(codec, <API key>)); snd_soc_write(codec, <API key>, snd_soc_read(codec, <API key>)); snd_soc_write(codec, <API key>, snd_soc_read(codec, <API key>)); snd_soc_write(codec, <API key>, snd_soc_read(codec, <API key>)); } else { snd_soc_write(codec, <API key>, snd_soc_read(codec, <API key>)); snd_soc_write(codec, <API key>, snd_soc_read(codec, <API key>)); snd_soc_write(codec, <API key>, snd_soc_read(codec, <API key>)); snd_soc_write(codec, <API key>, snd_soc_read(codec, <API key>)); } break; } return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; u8 reg_val, zoh_mux_val = 0x00; pr_debug("%s: event = %d\n", __func__, event); switch (event) { case <API key>: reg_val = snd_soc_read(codec, <API key>); if ((reg_val & 0x30) == 0x10) zoh_mux_val = 0x04; else if ((reg_val & 0x30) == 0x20) zoh_mux_val = 0x08; if (zoh_mux_val != 0x00) snd_soc_update_bits(codec, <API key>, 0x0C, zoh_mux_val); break; case <API key>: snd_soc_update_bits(codec, <API key>, 0x0C, 0x00); break; } return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; int ret = 0; switch (event) { case <API key>: ret = <API key>(w, kcontrol, event); msleep(50); snd_soc_update_bits(codec, TOMTOM_A_RX_EAR_EN, 0x10, 0x10); break; case <API key>: ret = <API key>(w, kcontrol, event); break; case <API key>: snd_soc_update_bits(codec, TOMTOM_A_RX_EAR_EN, 0x10, 0x00); msleep(40); ret |= <API key>(w, kcontrol, event); break; case <API key>: ret = <API key>(w, kcontrol, event); break; } return ret; } /* Todo: Have seperate dapm widgets for I2S and Slimbus. * Might Need to have callbacks registered only for slimbus */ static const struct snd_soc_dapm_widget tomtom_dapm_widgets[] = { /*RX stuff */ SND_SOC_DAPM_OUTPUT("EAR"), SND_SOC_DAPM_PGA_E("EAR PA", TOMTOM_A_RX_EAR_EN, 4, 0, NULL, 0, <API key>, <API key>), <API key>("DAC1", TOMTOM_A_RX_EAR_EN, 6, 0, dac1_switch, ARRAY_SIZE(dac1_switch), <API key>, <API key> | <API key>), <API key>("AIF1 PB", "AIF1 Playback", 0, SND_SOC_NOPM, AIF1_PB, 0, <API key>, <API key> | <API key>), <API key>("AIF2 PB", "AIF2 Playback", 0, SND_SOC_NOPM, AIF2_PB, 0, <API key>, <API key> | <API key>), <API key>("AIF3 PB", "AIF3 Playback", 0, SND_SOC_NOPM, AIF3_PB, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_MUX("SLIM RX1 MUX", SND_SOC_NOPM, TOMTOM_RX1, 0, &slim_rx_mux[TOMTOM_RX1]), SND_SOC_DAPM_MUX("SLIM RX2 MUX", SND_SOC_NOPM, TOMTOM_RX2, 0, &slim_rx_mux[TOMTOM_RX2]), SND_SOC_DAPM_MUX("SLIM RX3 MUX", SND_SOC_NOPM, TOMTOM_RX3, 0, &slim_rx_mux[TOMTOM_RX3]), SND_SOC_DAPM_MUX("SLIM RX4 MUX", SND_SOC_NOPM, TOMTOM_RX4, 0, &slim_rx_mux[TOMTOM_RX4]), SND_SOC_DAPM_MUX("SLIM RX5 MUX", SND_SOC_NOPM, TOMTOM_RX5, 0, &slim_rx_mux[TOMTOM_RX5]), SND_SOC_DAPM_MUX("SLIM RX6 MUX", SND_SOC_NOPM, TOMTOM_RX6, 0, &slim_rx_mux[TOMTOM_RX6]), SND_SOC_DAPM_MUX("SLIM RX7 MUX", SND_SOC_NOPM, TOMTOM_RX7, 0, &slim_rx_mux[TOMTOM_RX7]), SND_SOC_DAPM_MUX("SLIM RX8 MUX", SND_SOC_NOPM, TOMTOM_RX8, 0, &slim_rx_mux[TOMTOM_RX8]), SND_SOC_DAPM_MIXER("SLIM RX1", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER("SLIM RX2", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER("SLIM RX3", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER("SLIM RX4", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER("SLIM RX5", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER("SLIM RX6", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER("SLIM RX7", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER("SLIM RX8", SND_SOC_NOPM, 0, 0, NULL, 0), /* Headphone */ SND_SOC_DAPM_OUTPUT("HEADPHONE"), SND_SOC_DAPM_PGA_E("HPHL", <API key>, 5, 0, NULL, 0, tomtom_hph_pa_event, <API key> | <API key> | <API key>), <API key>("HPHL DAC", <API key>, 7, 0, hphl_switch, ARRAY_SIZE(hphl_switch), <API key>, <API key> | <API key> | <API key> | <API key>), SND_SOC_DAPM_PGA_E("HPHR", <API key>, 4, 0, NULL, 0, tomtom_hph_pa_event, <API key> | <API key> | <API key>), SND_SOC_DAPM_DAC_E("HPHR DAC", NULL, <API key>, 7, 0, <API key>, <API key> | <API key> | <API key> | <API key>), /* Speaker */ SND_SOC_DAPM_OUTPUT("LINEOUT1"), SND_SOC_DAPM_OUTPUT("LINEOUT2"), SND_SOC_DAPM_OUTPUT("LINEOUT3"), SND_SOC_DAPM_OUTPUT("LINEOUT4"), SND_SOC_DAPM_OUTPUT("SPK_OUT"), SND_SOC_DAPM_PGA_E("LINEOUT1 PA", <API key>, 0, 0, NULL, 0, <API key>, <API key> | <API key> | <API key>), SND_SOC_DAPM_PGA_E("LINEOUT2 PA", <API key>, 1, 0, NULL, 0, <API key>, <API key> | <API key> | <API key>), SND_SOC_DAPM_PGA_E("LINEOUT3 PA", <API key>, 2, 0, NULL, 0, <API key>, <API key> | <API key> | <API key>), SND_SOC_DAPM_PGA_E("LINEOUT4 PA", <API key>, 3, 0, NULL, 0, <API key>, <API key> | <API key> | <API key>), SND_SOC_DAPM_PGA_E("SPK PA", SND_SOC_NOPM, 0, 0 , NULL, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_PGA_E("SPK2 PA", SND_SOC_NOPM, 0, 0 , NULL, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_DAC_E("LINEOUT1 DAC", NULL, <API key>, 7, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_DAC_E("LINEOUT2 DAC", NULL, <API key>, 7, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_DAC_E("LINEOUT3 DAC", NULL, <API key>, 7, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_SWITCH("LINEOUT3 DAC GROUND", SND_SOC_NOPM, 0, 0, &<API key>), SND_SOC_DAPM_DAC_E("LINEOUT4 DAC", NULL, <API key>, 7, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_SWITCH("LINEOUT4 DAC GROUND", SND_SOC_NOPM, 0, 0, &<API key>), SND_SOC_DAPM_DAC_E("SPK DAC", NULL, <API key>, 0, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_DAC_E("SPK2 DAC", NULL, <API key>, 1, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_SUPPLY("VDD_SPKDRV", SND_SOC_NOPM, 0, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_SUPPLY("VDD_SPKDRV2", SND_SOC_NOPM, 0, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_SUPPLY("MICBIAS_REGULATOR", SND_SOC_NOPM, ON_DEMAND_MICBIAS, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_MIXER("RX1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER("RX2 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER("RX7 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER("RX1 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER("RX2 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0), <API key>("RX3 MIX1", <API key>, 2, 0, NULL, 0, <API key>, <API key> | <API key>), <API key>("RX4 MIX1", <API key>, 3, 0, NULL, 0, <API key>, <API key> | <API key>), <API key>("RX5 MIX1", <API key>, 4, 0, NULL, 0, <API key>, <API key> | <API key>), <API key>("RX6 MIX1", <API key>, 5, 0, NULL, 0, <API key>, <API key> | <API key>), <API key>("RX7 MIX2", <API key>, 6, 0, NULL, 0, <API key>, <API key> | <API key>), <API key>("RX8 MIX1", <API key>, 7, 0, NULL, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_MUX_E("RX1 INTERP", <API key>, 0, 0, &rx1_interp_mux, <API key>, <API key> | <API key>), SND_SOC_DAPM_MUX_E("RX2 INTERP", <API key>, 1, 0, &rx2_interp_mux, <API key>, <API key> | <API key>), SND_SOC_DAPM_MIXER("RX1 CHAIN", <API key>, 5, 0, NULL, 0), SND_SOC_DAPM_MIXER("RX2 CHAIN", <API key>, 5, 0, NULL, 0), SND_SOC_DAPM_MUX("RX1 MIX1 INP1", SND_SOC_NOPM, 0, 0, &rx_mix1_inp1_mux), SND_SOC_DAPM_MUX("RX1 MIX1 INP2", SND_SOC_NOPM, 0, 0, &rx_mix1_inp2_mux), SND_SOC_DAPM_MUX("RX1 MIX1 INP3", SND_SOC_NOPM, 0, 0, &rx_mix1_inp3_mux), SND_SOC_DAPM_MUX("RX2 MIX1 INP1", SND_SOC_NOPM, 0, 0, &rx2_mix1_inp1_mux), SND_SOC_DAPM_MUX("RX2 MIX1 INP2", SND_SOC_NOPM, 0, 0, &rx2_mix1_inp2_mux), SND_SOC_DAPM_MUX("RX3 MIX1 INP1", SND_SOC_NOPM, 0, 0, &rx3_mix1_inp1_mux), SND_SOC_DAPM_MUX("RX3 MIX1 INP2", SND_SOC_NOPM, 0, 0, &rx3_mix1_inp2_mux), SND_SOC_DAPM_MUX("RX4 MIX1 INP1", SND_SOC_NOPM, 0, 0, &rx4_mix1_inp1_mux), SND_SOC_DAPM_MUX("RX4 MIX1 INP2", SND_SOC_NOPM, 0, 0, &rx4_mix1_inp2_mux), SND_SOC_DAPM_MUX("RX5 MIX1 INP1", SND_SOC_NOPM, 0, 0, &rx5_mix1_inp1_mux), SND_SOC_DAPM_MUX("RX5 MIX1 INP2", SND_SOC_NOPM, 0, 0, &rx5_mix1_inp2_mux), SND_SOC_DAPM_MUX("RX6 MIX1 INP1", SND_SOC_NOPM, 0, 0, &rx6_mix1_inp1_mux), SND_SOC_DAPM_MUX("RX6 MIX1 INP2", SND_SOC_NOPM, 0, 0, &rx6_mix1_inp2_mux), SND_SOC_DAPM_MUX("RX7 MIX1 INP1", SND_SOC_NOPM, 0, 0, &rx7_mix1_inp1_mux), SND_SOC_DAPM_MUX("RX7 MIX1 INP2", SND_SOC_NOPM, 0, 0, &rx7_mix1_inp2_mux), SND_SOC_DAPM_MUX("RX8 MIX1 INP1", SND_SOC_NOPM, 0, 0, &rx8_mix1_inp1_mux), SND_SOC_DAPM_MUX("RX8 MIX1 INP2", SND_SOC_NOPM, 0, 0, &rx8_mix1_inp2_mux), SND_SOC_DAPM_MUX("RX1 MIX2 INP1", SND_SOC_NOPM, 0, 0, &rx1_mix2_inp1_mux), SND_SOC_DAPM_MUX("RX1 MIX2 INP2", SND_SOC_NOPM, 0, 0, &rx1_mix2_inp2_mux), SND_SOC_DAPM_MUX("RX2 MIX2 INP1", SND_SOC_NOPM, 0, 0, &rx2_mix2_inp1_mux), SND_SOC_DAPM_MUX("RX2 MIX2 INP2", SND_SOC_NOPM, 0, 0, &rx2_mix2_inp2_mux), SND_SOC_DAPM_MUX("RX7 MIX2 INP1", SND_SOC_NOPM, 0, 0, &rx7_mix2_inp1_mux), SND_SOC_DAPM_MUX("RX7 MIX2 INP2", SND_SOC_NOPM, 0, 0, &rx7_mix2_inp2_mux), SND_SOC_DAPM_MUX("RDAC5 MUX", SND_SOC_NOPM, 0, 0, &rx_dac5_mux), SND_SOC_DAPM_MUX("RDAC7 MUX", SND_SOC_NOPM, 0, 0, &rx_dac7_mux), SND_SOC_DAPM_MUX("MAD_SEL MUX", SND_SOC_NOPM, 0, 0, &mad_sel_mux), SND_SOC_DAPM_MUX_E("CLASS_H_DSM MUX", SND_SOC_NOPM, 0, 0, &class_h_dsm_mux, <API key>, <API key> | <API key>), SND_SOC_DAPM_SUPPLY("RX_BIAS", SND_SOC_NOPM, 0, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_SUPPLY("CDC_I2S_RX_CONN", <API key>, 5, 0, NULL, 0), SND_SOC_DAPM_SUPPLY("CDC_CONN", <API key>, 2, 0, NULL, 0), SND_SOC_DAPM_SUPPLY("LDO_H", SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key>), /* * DAPM 'LDO_H Standalone' is to be powered by mbhc driver after * acquring codec_resource lock. * So call <API key> instead and avoid deadlock. */ SND_SOC_DAPM_SUPPLY("LDO_H Standalone", SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_SUPPLY("COMP0_CLK", SND_SOC_NOPM, 0, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_SUPPLY("COMP1_CLK", SND_SOC_NOPM, 1, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_SUPPLY("COMP2_CLK", SND_SOC_NOPM, 2, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_INPUT("AMIC1"), <API key>("MIC BIAS1 External", SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key> | <API key>), <API key>("MIC BIAS1 Internal1", SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key> | <API key>), <API key>("MIC BIAS1 Internal2", SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key> | <API key>), SND_SOC_DAPM_INPUT("AMIC3"), SND_SOC_DAPM_INPUT("AMIC4"), SND_SOC_DAPM_INPUT("AMIC5"), SND_SOC_DAPM_INPUT("AMIC6"), SND_SOC_DAPM_MUX_E("DEC1 MUX", <API key>, 0, 0, &dec1_mux, <API key>, <API key> | <API key> | <API key> | <API key>), SND_SOC_DAPM_MUX_E("DEC2 MUX", <API key>, 1, 0, &dec2_mux, <API key>, <API key> | <API key> | <API key> | <API key>), SND_SOC_DAPM_MUX_E("DEC3 MUX", <API key>, 2, 0, &dec3_mux, <API key>, <API key> | <API key> | <API key> | <API key>), SND_SOC_DAPM_MUX_E("DEC4 MUX", <API key>, 3, 0, &dec4_mux, <API key>, <API key> | <API key> | <API key> | <API key>), SND_SOC_DAPM_MUX_E("DEC5 MUX", <API key>, 4, 0, &dec5_mux, <API key>, <API key> | <API key> | <API key> | <API key>), SND_SOC_DAPM_MUX_E("DEC6 MUX", <API key>, 5, 0, &dec6_mux, <API key>, <API key> | <API key> | <API key> | <API key>), SND_SOC_DAPM_MUX_E("DEC7 MUX", <API key>, 6, 0, &dec7_mux, <API key>, <API key> | <API key> | <API key> | <API key>), SND_SOC_DAPM_MUX_E("DEC8 MUX", <API key>, 7, 0, &dec8_mux, <API key>, <API key> | <API key> | <API key> | <API key>), SND_SOC_DAPM_MUX_E("DEC9 MUX", <API key>, 0, 0, &dec9_mux, <API key>, <API key> | <API key> | <API key> | <API key>), SND_SOC_DAPM_MUX_E("DEC10 MUX", <API key>, 1, 0, &dec10_mux, <API key>, <API key> | <API key> | <API key> | <API key>), SND_SOC_DAPM_MUX("ANC1 MUX", SND_SOC_NOPM, 0, 0, &anc1_mux), SND_SOC_DAPM_MUX("ANC2 MUX", SND_SOC_NOPM, 0, 0, &anc2_mux), SND_SOC_DAPM_OUTPUT("ANC HEADPHONE"), SND_SOC_DAPM_PGA_E("ANC HPHL", SND_SOC_NOPM, 5, 0, NULL, 0, <API key>, <API key> | <API key> | <API key> | <API key>), SND_SOC_DAPM_PGA_E("ANC HPHR", SND_SOC_NOPM, 4, 0, NULL, 0, <API key>, <API key> | <API key> | <API key> | <API key>), SND_SOC_DAPM_OUTPUT("ANC EAR"), SND_SOC_DAPM_PGA_E("ANC EAR PA", SND_SOC_NOPM, 0, 0, NULL, 0, <API key>, <API key> | <API key> | <API key> | <API key>), SND_SOC_DAPM_MUX("ANC1 FB MUX", SND_SOC_NOPM, 0, 0, &anc1_fb_mux), SND_SOC_DAPM_INPUT("AMIC2"), <API key>(<API key>, SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key> | <API key>), <API key>("MIC BIAS2 External", SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key> | <API key>), <API key>("MIC BIAS2 Internal1", SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key> | <API key>), <API key>("MIC BIAS2 Internal2", SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key> | <API key>), <API key>("MIC BIAS2 Internal3", SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key> | <API key>), <API key>("MIC BIAS3 External", SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key> | <API key>), <API key>("MIC BIAS3 Internal1", SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key> | <API key>), <API key>("MIC BIAS3 Internal2", SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key> | <API key>), <API key>("MIC BIAS4 External", SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key> | <API key>), <API key>("AIF1 CAP", "AIF1 Capture", 0, SND_SOC_NOPM, AIF1_CAP, 0, <API key>, <API key> | <API key>), <API key>("AIF2 CAP", "AIF2 Capture", 0, SND_SOC_NOPM, AIF2_CAP, 0, <API key>, <API key> | <API key>), <API key>("AIF3 CAP", "AIF3 Capture", 0, SND_SOC_NOPM, AIF3_CAP, 0, <API key>, <API key> | <API key>), <API key>("AIF4 VI", "VIfeed", 0, SND_SOC_NOPM, AIF4_VIFEED, 0, <API key>, <API key> | <API key>), <API key>("AIF4 MAD", "AIF4 MAD TX", 0, SND_SOC_NOPM, 0, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_SWITCH("MADONOFF", SND_SOC_NOPM, 0, 0, &aif4_mad_switch), SND_SOC_DAPM_INPUT("MADINPUT"), SND_SOC_DAPM_INPUT("MAD_CPE_INPUT"), SND_SOC_DAPM_MIXER("AIF1_CAP Mixer", SND_SOC_NOPM, AIF1_CAP, 0, aif1_cap_mixer, ARRAY_SIZE(aif1_cap_mixer)), SND_SOC_DAPM_MIXER("AIF4_VI Mixer", SND_SOC_NOPM, AIF4_VIFEED, 0, aif4_vi_mixer, ARRAY_SIZE(aif4_vi_mixer)), SND_SOC_DAPM_MIXER("AIF2_CAP Mixer", SND_SOC_NOPM, AIF2_CAP, 0, aif2_cap_mixer, ARRAY_SIZE(aif2_cap_mixer)), SND_SOC_DAPM_MIXER("AIF3_CAP Mixer", SND_SOC_NOPM, AIF3_CAP, 0, aif3_cap_mixer, ARRAY_SIZE(aif3_cap_mixer)), SND_SOC_DAPM_MUX("SLIM TX1 MUX", SND_SOC_NOPM, TOMTOM_TX1, 0, &sb_tx1_mux), SND_SOC_DAPM_MUX("SLIM TX2 MUX", SND_SOC_NOPM, TOMTOM_TX2, 0, &sb_tx2_mux), SND_SOC_DAPM_MUX("SLIM TX3 MUX", SND_SOC_NOPM, TOMTOM_TX3, 0, &sb_tx3_mux), SND_SOC_DAPM_MUX("SLIM TX4 MUX", SND_SOC_NOPM, TOMTOM_TX4, 0, &sb_tx4_mux), SND_SOC_DAPM_MUX("SLIM TX5 MUX", SND_SOC_NOPM, TOMTOM_TX5, 0, &sb_tx5_mux), SND_SOC_DAPM_MUX("SLIM TX6 MUX", SND_SOC_NOPM, TOMTOM_TX6, 0, &sb_tx6_mux), SND_SOC_DAPM_MUX("SLIM TX7 MUX", SND_SOC_NOPM, TOMTOM_TX7, 0, &sb_tx7_mux), SND_SOC_DAPM_MUX("SLIM TX8 MUX", SND_SOC_NOPM, TOMTOM_TX8, 0, &sb_tx8_mux), SND_SOC_DAPM_MUX("SLIM TX9 MUX", SND_SOC_NOPM, TOMTOM_TX9, 0, &sb_tx9_mux), SND_SOC_DAPM_MUX("SLIM TX10 MUX", SND_SOC_NOPM, TOMTOM_TX10, 0, &sb_tx10_mux), /* Digital Mic Inputs */ SND_SOC_DAPM_ADC_E("DMIC1", NULL, SND_SOC_NOPM, 0, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_ADC_E("DMIC2", NULL, SND_SOC_NOPM, 0, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_ADC_E("DMIC3", NULL, SND_SOC_NOPM, 0, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_ADC_E("DMIC4", NULL, SND_SOC_NOPM, 0, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_ADC_E("DMIC5", NULL, SND_SOC_NOPM, 0, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_ADC_E("DMIC6", NULL, SND_SOC_NOPM, 0, 0, <API key>, <API key> | <API key>), /* Sidetone */ SND_SOC_DAPM_MUX("IIR1 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp1_mux), SND_SOC_DAPM_MUX("IIR1 INP2 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp2_mux), SND_SOC_DAPM_MUX("IIR1 INP3 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp3_mux), SND_SOC_DAPM_MUX("IIR1 INP4 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp4_mux), <API key>("IIR1", <API key>, 0, 0, NULL, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_MUX("IIR2 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir2_inp1_mux), SND_SOC_DAPM_MUX("IIR2 INP2 MUX", SND_SOC_NOPM, 0, 0, &iir2_inp2_mux), SND_SOC_DAPM_MUX("IIR2 INP3 MUX", SND_SOC_NOPM, 0, 0, &iir2_inp3_mux), SND_SOC_DAPM_MUX("IIR2 INP4 MUX", SND_SOC_NOPM, 0, 0, &iir2_inp4_mux), <API key>("IIR2", <API key>, 1, 0, NULL, 0, <API key>, <API key> | <API key>), /* AUX PGA */ SND_SOC_DAPM_ADC_E("AUX_PGA_Left", NULL, <API key>, 7, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_ADC_E("AUX_PGA_Right", NULL, <API key>, 6, 0, <API key>, <API key> | <API key>), /* Lineout, ear and HPH PA Mixers */ SND_SOC_DAPM_MIXER("EAR_PA_MIXER", SND_SOC_NOPM, 0, 0, ear_pa_mix, ARRAY_SIZE(ear_pa_mix)), SND_SOC_DAPM_MIXER("HPHL_PA_MIXER", SND_SOC_NOPM, 0, 0, hphl_pa_mix, ARRAY_SIZE(hphl_pa_mix)), SND_SOC_DAPM_MIXER("HPHR_PA_MIXER", SND_SOC_NOPM, 0, 0, hphr_pa_mix, ARRAY_SIZE(hphr_pa_mix)), SND_SOC_DAPM_MIXER("LINEOUT1_PA_MIXER", SND_SOC_NOPM, 0, 0, lineout1_pa_mix, ARRAY_SIZE(lineout1_pa_mix)), SND_SOC_DAPM_MIXER("LINEOUT2_PA_MIXER", SND_SOC_NOPM, 0, 0, lineout2_pa_mix, ARRAY_SIZE(lineout2_pa_mix)), SND_SOC_DAPM_MIXER("LINEOUT3_PA_MIXER", SND_SOC_NOPM, 0, 0, lineout3_pa_mix, ARRAY_SIZE(lineout3_pa_mix)), SND_SOC_DAPM_MIXER("LINEOUT4_PA_MIXER", SND_SOC_NOPM, 0, 0, lineout4_pa_mix, ARRAY_SIZE(lineout4_pa_mix)), SND_SOC_DAPM_INPUT("VIINPUT"), }; static irqreturn_t tomtom_slimbus_irq(int irq, void *data) { struct tomtom_priv *priv = data; struct snd_soc_codec *codec = priv->codec; unsigned long status = 0; int i, j, port_id, k; u32 bit; u8 val, int_val = 0; bool tx, cleared; unsigned short reg = 0; for (i = <API key>, j = 0; i <= <API key>; i++, j++) { val = <API key>(codec->control_data, i); status |= ((u32)val << (8 * j)); } for_each_set_bit(j, &status, 32) { tx = (j >= 16 ? true : false); port_id = (tx ? j - 16 : j); val = <API key>(codec->control_data, <API key> + j); if (val) { if (!tx) reg = <API key> + (port_id / 8); else reg = <API key> + (port_id / 8); int_val = <API key>( codec->control_data, reg); /* * Ignore interrupts for ports for which the * interrupts are not specifically enabled. */ if (!(int_val & (1 << (port_id % 8)))) continue; } if (val & <API key>) pr_err_ratelimited( "%s: overflow error on %s port %d, value %x\n", __func__, (tx ? "TX" : "RX"), port_id, val); if (val & <API key>) pr_err_ratelimited( "%s: underflow error on %s port %d, value %x\n", __func__, (tx ? "TX" : "RX"), port_id, val); if ((val & <API key>) || (val & <API key>)) { if (!tx) reg = <API key> + (port_id / 8); else reg = <API key> + (port_id / 8); int_val = <API key>( codec->control_data, reg); if (int_val & (1 << (port_id % 8))) { int_val = int_val ^ (1 << (port_id % 8)); <API key>(codec->control_data, reg, int_val); } } if (val & <API key>) { /* * INT SOURCE register starts from RX to TX * but port number in the ch_mask is in opposite way */ bit = (tx ? j - 16 : j + 16); pr_debug("%s: %s port %d closed value %x, bit %u\n", __func__, (tx ? "TX" : "RX"), port_id, val, bit); for (k = 0, cleared = false; k < NUM_CODEC_DAIS; k++) { pr_debug("%s: priv->dai[%d].ch_mask = 0x%lx\n", __func__, k, priv->dai[k].ch_mask); if (test_and_clear_bit(bit, &priv->dai[k].ch_mask)) { cleared = true; if (!priv->dai[k].ch_mask) wake_up(&priv->dai[k].dai_wait); /* * There are cases when multiple DAIs * might be using the same slimbus * channel. Hence don't break here. */ } } WARN(!cleared, "Couldn't find slimbus %s port %d for closing\n", (tx ? "TX" : "RX"), port_id); } <API key>(codec->control_data, <API key> + (j / 8), 1 << (j % 8)); } return IRQ_HANDLED; } static int tomtom_handle_pdata(struct tomtom_priv *tomtom) { struct snd_soc_codec *codec = tomtom->codec; struct wcd9xxx_pdata *pdata = tomtom->resmgr.pdata; int k1, k2, k3, dec, rc = 0; u8 leg_mode, txfe_bypass, txfe_buff, flag; u8 i = 0, j = 0; u8 val_txfe = 0, value = 0; u8 dmic_ctl_val, mad_dmic_ctl_val; u8 anc_ctl_value = 0; u32 def_dmic_rate; u16 tx_dmic_ctl_reg; if (!pdata) { pr_err("%s: NULL pdata\n", __func__); rc = -ENODEV; goto done; } leg_mode = pdata->amic_settings.legacy_mode; txfe_bypass = pdata->amic_settings.txfe_enable; txfe_buff = pdata->amic_settings.txfe_buff; flag = pdata->amic_settings.use_pdata; /* Make sure settings are correct */ if ((pdata->micbias.ldoh_v > WCD9XXX_LDOH_3P0_V) || (pdata->micbias.bias1_cfilt_sel > WCD9XXX_CFILT3_SEL) || (pdata->micbias.bias2_cfilt_sel > WCD9XXX_CFILT3_SEL) || (pdata->micbias.bias3_cfilt_sel > WCD9XXX_CFILT3_SEL) || (pdata->micbias.bias4_cfilt_sel > WCD9XXX_CFILT3_SEL)) { rc = -EINVAL; goto done; } /* figure out k value */ k1 = <API key>(&tomtom->resmgr, pdata->micbias.cfilt1_mv); k2 = <API key>(&tomtom->resmgr, pdata->micbias.cfilt2_mv); k3 = <API key>(&tomtom->resmgr, pdata->micbias.cfilt3_mv); if (IS_ERR_VALUE(k1) || IS_ERR_VALUE(k2) || IS_ERR_VALUE(k3)) { rc = -EINVAL; goto done; } /* Set voltage level and always use LDO */ snd_soc_update_bits(codec, <API key>, 0x0C, (pdata->micbias.ldoh_v << 2)); snd_soc_update_bits(codec, <API key>, 0xFC, (k1 << 2)); snd_soc_update_bits(codec, <API key>, 0xFC, (k2 << 2)); snd_soc_update_bits(codec, <API key>, 0xFC, (k3 << 2)); snd_soc_update_bits(codec, TOMTOM_A_MICB_1_CTL, 0x60, (pdata->micbias.bias1_cfilt_sel << 5)); snd_soc_update_bits(codec, TOMTOM_A_MICB_2_CTL, 0x60, (pdata->micbias.bias2_cfilt_sel << 5)); snd_soc_update_bits(codec, TOMTOM_A_MICB_3_CTL, 0x60, (pdata->micbias.bias3_cfilt_sel << 5)); snd_soc_update_bits(codec, tomtom->resmgr.reg_addr->micb_4_ctl, 0x60, (pdata->micbias.bias4_cfilt_sel << 5)); for (i = 0; i < 6; j++, i += 2) { if (flag & (0x01 << i)) { val_txfe = (txfe_bypass & (0x01 << i)) ? 0x20 : 0x00; val_txfe = val_txfe | ((txfe_buff & (0x01 << i)) ? 0x10 : 0x00); snd_soc_update_bits(codec, <API key> + j * 10, 0x30, val_txfe); } if (flag & (0x01 << (i + 1))) { val_txfe = (txfe_bypass & (0x01 << (i + 1))) ? 0x02 : 0x00; val_txfe |= (txfe_buff & (0x01 << (i + 1))) ? 0x01 : 0x00; snd_soc_update_bits(codec, <API key> + j * 10, 0x03, val_txfe); } } if (flag & 0x40) { value = (leg_mode & 0x40) ? 0x10 : 0x00; value = value | ((txfe_bypass & 0x40) ? 0x02 : 0x00); value = value | ((txfe_buff & 0x40) ? 0x01 : 0x00); snd_soc_update_bits(codec, <API key>, 0x13, value); } if (pdata->ocp.use_pdata) { /* not defined in CODEC specification */ if (pdata->ocp.hph_ocp_limit == 1 || pdata->ocp.hph_ocp_limit == 5) { rc = -EINVAL; goto done; } snd_soc_update_bits(codec, <API key>, 0x0F, pdata->ocp.num_attempts); snd_soc_write(codec, <API key>, ((pdata->ocp.run_time << 4) | pdata->ocp.wait_time)); snd_soc_update_bits(codec, <API key>, 0xE0, (pdata->ocp.hph_ocp_limit << 5)); } for (i = 0; i < ARRAY_SIZE(pdata->regulator); i++) { if (pdata->regulator[i].name && !strcmp(pdata->regulator[i].name, "CDC_VDDA_RX")) { if (pdata->regulator[i].min_uV == 1800000 && pdata->regulator[i].max_uV == 1800000) { snd_soc_write(codec, <API key>, 0x1C); } else if (pdata->regulator[i].min_uV == 2200000 && pdata->regulator[i].max_uV == 2200000) { snd_soc_write(codec, <API key>, 0x1E); } else { pr_err("%s: unsupported CDC_VDDA_RX voltage\n" "min %d, max %d\n", __func__, pdata->regulator[i].min_uV, pdata->regulator[i].max_uV); rc = -EINVAL; } break; } } /* Set micbias capless mode with tail current */ value = (pdata->micbias.bias1_cap_mode == MICBIAS_EXT_BYP_CAP ? 0x00 : 0x16); snd_soc_update_bits(codec, TOMTOM_A_MICB_1_CTL, 0x1E, value); value = (pdata->micbias.bias2_cap_mode == MICBIAS_EXT_BYP_CAP ? 0x00 : 0x16); snd_soc_update_bits(codec, TOMTOM_A_MICB_2_CTL, 0x1E, value); value = (pdata->micbias.bias3_cap_mode == MICBIAS_EXT_BYP_CAP ? 0x00 : 0x16); snd_soc_update_bits(codec, TOMTOM_A_MICB_3_CTL, 0x1E, value); value = (pdata->micbias.bias4_cap_mode == MICBIAS_EXT_BYP_CAP ? 0x00 : 0x16); snd_soc_update_bits(codec, TOMTOM_A_MICB_4_CTL, 0x1E, value); /* Set the DMIC sample rate */ switch (pdata->mclk_rate) { case <API key>: def_dmic_rate = <API key>; break; case <API key>: def_dmic_rate = <API key>; break; default: /* should never happen */ pr_err("%s: Invalid mclk_rate %d\n", __func__, pdata->mclk_rate); rc = -EINVAL; goto done; } if (pdata->dmic_sample_rate == <API key>) { pr_info("%s: dmic_rate invalid default = %d\n", __func__, def_dmic_rate); pdata->dmic_sample_rate = def_dmic_rate; } if (pdata-><API key> == <API key>) { pr_info("%s: mad_dmic_rate invalid default = %d\n", __func__, def_dmic_rate); /* * use dmic_sample_rate as the default for MAD * if mad dmic sample rate is undefined */ pdata-><API key> = pdata->dmic_sample_rate; } /* * Default the DMIC clk rates to <API key>, * whereas, the anc/txfe dmic rates to dmic_sample_rate * since the anc/txfe are independent of mad block. */ mad_dmic_ctl_val = <API key>(tomtom->codec, pdata->mclk_rate, pdata-><API key>); snd_soc_update_bits(codec, <API key>, 0xE0, mad_dmic_ctl_val << 5); snd_soc_update_bits(codec, <API key>, 0x70, mad_dmic_ctl_val << 4); snd_soc_update_bits(codec, <API key>, 0x0E, mad_dmic_ctl_val << 1); dmic_ctl_val = <API key>(tomtom->codec, pdata->mclk_rate, pdata->dmic_sample_rate); if (dmic_ctl_val == <API key>) anc_ctl_value = <API key>; else anc_ctl_value = <API key>; for (dec = 0; dec < NUM_DECIMATORS; dec++) { tx_dmic_ctl_reg = <API key> + (8 * dec); snd_soc_update_bits(codec, tx_dmic_ctl_reg, 0x07, dmic_ctl_val); } snd_soc_update_bits(codec, <API key>, 0x1, anc_ctl_value); snd_soc_update_bits(codec, <API key>, 0x1, anc_ctl_value); done: return rc; } static const struct <API key> tomtom_reg_defaults[] = { /* set MCLk to 9.6 */ TOMTOM_REG_VAL(TOMTOM_A_CHIP_CTL, 0x02), /* EAR PA deafults */ TOMTOM_REG_VAL(<API key>, 0x05), /* RX deafults */ TOMTOM_REG_VAL(<API key>, 0x79), TOMTOM_REG_VAL(<API key>, 0x79), TOMTOM_REG_VAL(<API key>, 0x79), TOMTOM_REG_VAL(<API key>, 0x79), TOMTOM_REG_VAL(<API key>, 0x79), TOMTOM_REG_VAL(<API key>, 0x79), TOMTOM_REG_VAL(<API key>, 0x79), TOMTOM_REG_VAL(<API key>, 0x79), /* RX1 and RX2 defaults */ TOMTOM_REG_VAL(<API key>, 0xA0), TOMTOM_REG_VAL(<API key>, 0xA0), /* RX3 to RX7 defaults */ TOMTOM_REG_VAL(<API key>, 0x80), TOMTOM_REG_VAL(<API key>, 0x80), TOMTOM_REG_VAL(<API key>, 0x80), TOMTOM_REG_VAL(<API key>, 0x80), TOMTOM_REG_VAL(<API key>, 0x80), TOMTOM_REG_VAL(<API key>, 0x80), /* MAD registers */ TOMTOM_REG_VAL(<API key>, 0xF1), TOMTOM_REG_VAL(<API key>, 0x00), TOMTOM_REG_VAL(<API key>, 0x00), TOMTOM_REG_VAL(<API key>, 0x00), /* Set SAMPLE_TX_EN bit */ TOMTOM_REG_VAL(<API key>, 0x03), TOMTOM_REG_VAL(<API key>, 0x00), TOMTOM_REG_VAL(<API key>, 0x00), TOMTOM_REG_VAL(<API key>, 0x00), TOMTOM_REG_VAL(<API key>, 0x00), TOMTOM_REG_VAL(<API key>, 0x00), TOMTOM_REG_VAL(<API key>, 0x00), TOMTOM_REG_VAL(<API key>, 0x00), TOMTOM_REG_VAL(<API key>, 0x40), TOMTOM_REG_VAL(<API key>, 0x00), TOMTOM_REG_VAL(<API key>, 0x00), TOMTOM_REG_VAL(<API key>, 0x00), TOMTOM_REG_VAL(<API key>, 0x01), /* Set HPH Path to low power mode */ TOMTOM_REG_VAL(<API key>, 0x57), /* BUCK default */ TOMTOM_REG_VAL(<API key>, 0x51), TOMTOM_REG_VAL(<API key>, 0x5B), }; /* * Don't update TOMTOM_A_CHIP_CTL, <API key> and * <API key> as those are updated in tomtom_reg_defaults */ static const struct <API key> <API key>[] = { TOMTOM_REG_VAL(TOMTOM_A_TX_1_GAIN, 0x2), TOMTOM_REG_VAL(TOMTOM_A_TX_2_GAIN, 0x2), TOMTOM_REG_VAL(<API key>, 0x44), TOMTOM_REG_VAL(TOMTOM_A_TX_3_GAIN, 0x2), TOMTOM_REG_VAL(TOMTOM_A_TX_4_GAIN, 0x2), TOMTOM_REG_VAL(<API key>, 0x44), TOMTOM_REG_VAL(TOMTOM_A_TX_5_GAIN, 0x2), TOMTOM_REG_VAL(TOMTOM_A_TX_6_GAIN, 0x2), TOMTOM_REG_VAL(<API key>, 0x44), TOMTOM_REG_VAL(<API key>, 0xCE), TOMTOM_REG_VAL(<API key>, 0x8), TOMTOM_REG_VAL(<API key>, 0x51), TOMTOM_REG_VAL(TOMTOM_A_NCP_DTEST, 0x10), TOMTOM_REG_VAL(<API key>, 0xA4), TOMTOM_REG_VAL(<API key>, 0x69), TOMTOM_REG_VAL(<API key>, 0xDA), TOMTOM_REG_VAL(<API key>, 0x15), TOMTOM_REG_VAL(<API key>, 0x76), TOMTOM_REG_VAL(TOMTOM_A_RX_EAR_CNP, 0xC0), TOMTOM_REG_VAL(<API key>, 0x78), TOMTOM_REG_VAL(<API key>, 0x2), TOMTOM_REG_VAL(<API key>, 0x2), TOMTOM_REG_VAL(<API key>, 0x2), TOMTOM_REG_VAL(<API key>, 0x2), TOMTOM_REG_VAL(<API key>, 0x97), TOMTOM_REG_VAL(<API key>, 0x1), TOMTOM_REG_VAL(<API key>, 0x0), TOMTOM_REG_VAL(<API key>, 0x97), TOMTOM_REG_VAL(<API key>, 0x1), TOMTOM_REG_VAL(<API key>, 0x4A), TOMTOM_REG_VAL(<API key>, 0x4A), TOMTOM_REG_VAL(<API key>, 0x4A), TOMTOM_REG_VAL(<API key>, 0x4A), TOMTOM_REG_VAL(<API key>, 0x4A), TOMTOM_REG_VAL(<API key>, 0x4A), TOMTOM_REG_VAL(<API key>, 0x4A), TOMTOM_REG_VAL(<API key>, 0x4A), TOMTOM_REG_VAL(<API key>, 0x4A), TOMTOM_REG_VAL(<API key>, 0x4A), TOMTOM_REG_VAL(<API key>, 0xB), TOMTOM_REG_VAL(<API key>, 0xB), TOMTOM_REG_VAL(<API key>, 0xB), TOMTOM_REG_VAL(<API key>, 0xB), TOMTOM_REG_VAL(<API key>, 0xB), TOMTOM_REG_VAL(<API key>, 0xB), TOMTOM_REG_VAL(<API key>, 0xB), TOMTOM_REG_VAL(<API key>, 0xB), TOMTOM_REG_VAL(<API key>, 0x0), TOMTOM_REG_VAL(<API key>, 0x0), TOMTOM_REG_VAL(<API key>, 0x0), TOMTOM_REG_VAL(<API key>, 0x0), TOMTOM_REG_VAL(<API key>, 0x0), TOMTOM_REG_VAL(<API key>, 0x0), TOMTOM_REG_VAL(<API key>, 0x0), TOMTOM_REG_VAL(<API key>, 0x37), TOMTOM_REG_VAL(<API key>, 0x7f), TOMTOM_REG_VAL(<API key>, 0x7f), }; static const struct <API key> <API key>[] = { TOMTOM_REG_VAL(<API key>, 0x32), TOMTOM_REG_VAL(TOMTOM_A_RCO_CTRL, 0x10), TOMTOM_REG_VAL(<API key>, 0x0A), TOMTOM_REG_VAL(<API key>, 0x0A), TOMTOM_REG_VAL(<API key>, 0xC3), TOMTOM_REG_VAL(<API key>, 0x00), TOMTOM_REG_VAL(<API key>, 0x04), TOMTOM_REG_VAL(<API key>, 0x04), TOMTOM_REG_VAL(<API key>, 0x04), TOMTOM_REG_VAL(<API key>, 0x04), TOMTOM_REG_VAL(<API key>, 0xE0), TOMTOM_REG_VAL(<API key>, 0x03), TOMTOM_REG_VAL(<API key>, 0x04), TOMTOM_REG_VAL(<API key>, 0x04), TOMTOM_REG_VAL(<API key>, 0x04), TOMTOM_REG_VAL(<API key>, 0x04), TOMTOM_REG_VAL(<API key>, 0x04), }; static const struct <API key> <API key>[] = { TOMTOM_REG_VAL(<API key>, 0x00), TOMTOM_REG_VAL(<API key>, 0x0), TOMTOM_REG_VAL(<API key>, 0x0), TOMTOM_REG_VAL(<API key>, 0x0), TOMTOM_REG_VAL(<API key>, 0x0), TOMTOM_REG_VAL(<API key>, 0x0), TOMTOM_REG_VAL(<API key>, 0x0), }; static void <API key>(struct snd_soc_codec *codec) { u32 i; struct wcd9xxx *tomtom_core = dev_get_drvdata(codec->dev->parent); struct tomtom_priv *tomtom = <API key>(codec); for (i = 0; i < ARRAY_SIZE(tomtom_reg_defaults); i++) snd_soc_write(codec, tomtom_reg_defaults[i].reg, tomtom_reg_defaults[i].val); for (i = 0; i < ARRAY_SIZE(<API key>); i++) snd_soc_write(codec, <API key>[i].reg, <API key>[i].val); if (!TOMTOM_IS_1_0(tomtom_core->version)) { for (i = 0; i < ARRAY_SIZE(<API key>); i++) snd_soc_write(codec, <API key>[i].reg, <API key>[i].val); if (tomtom->intf_type == <API key>) { for (i = 0; i < ARRAY_SIZE(<API key>); i++) snd_soc_write(codec, <API key>[i].reg, <API key>[i].val); } } } static const struct <API key> <API key>[] = { /* Initialize current threshold to 350MA * number of wait and run cycles to 4096 */ {<API key>, 0xE1, 0x61}, {<API key>, 0xFF, 0xFF}, {<API key>, 0x01, 0x01}, {<API key>, 0x01, 0x01}, /* Initialize gain registers to use register gain */ {<API key>, 0x20, 0x20}, {<API key>, 0x20, 0x20}, {<API key>, 0x20, 0x20}, {<API key>, 0x20, 0x20}, {<API key>, 0x20, 0x20}, {<API key>, 0x20, 0x20}, {<API key>, 0x04, 0x04}, {<API key>, 0x04, 0x04}, /* Use 16 bit sample size for TX1 to TX6 */ {<API key>, 0x30, 0x20}, {<API key>, 0x30, 0x20}, {<API key>, 0x30, 0x20}, {<API key>, 0x30, 0x20}, {<API key>, 0x30, 0x20}, {<API key>, 0x30, 0x20}, /* Use 16 bit sample size for TX7 to TX10 */ {<API key>, 0x60, 0x40}, {<API key>, 0x60, 0x40}, {<API key>, 0x60, 0x40}, {<API key>, 0x60, 0x40}, /*enable HPF filter for TX paths */ {<API key>, 0x8, 0x0}, {<API key>, 0x8, 0x0}, {<API key>, 0x8, 0x0}, {<API key>, 0x8, 0x0}, {<API key>, 0x8, 0x0}, {<API key>, 0x8, 0x0}, {<API key>, 0x8, 0x0}, {<API key>, 0x8, 0x0}, {<API key>, 0x8, 0x0}, {<API key>, 0x8, 0x0}, /* Compander zone selection */ {<API key>, 0x3F, 0x37}, {<API key>, 0x3F, 0x37}, {<API key>, 0x3F, 0x37}, {<API key>, 0x7F, 0x7F}, {<API key>, 0x7F, 0x7F}, {<API key>, 0x7F, 0x7F}, /* * Setup wavegen timer to 20msec and disable chopper * as default. This corresponds to Compander OFF */ {<API key>, 0xFF, 0xDB}, {<API key>, 0xFF, 0x58}, {<API key>, 0xFF, 0x1A}, {<API key>, 0xFF, 0x24}, /* Choose max non-overlap time for NCP */ {TOMTOM_A_NCP_CLK, 0xFF, 0xFC}, /* Program the 0.85 volt VBG_REFERENCE */ {<API key>, 0xFF, 0x04}, /* set MAD input MIC to DMIC1 */ {<API key>, 0x0F, 0x08}, {TOMTOM_A_INTR_MODE, 0x04, 0x04}, }; static const struct <API key> <API key>[] = { {<API key>, 0x08, 0x00}, {<API key>, 0x08, 0x00}, {<API key>, 0xFF, 0x00}, {<API key>, 0xFF, 0x00}, {<API key>, 0x01, 0x01}, {<API key>, 0x01, 0x01}, {<API key>, 0x01, 0x00}, {<API key>, 0x01, 0x00}, }; static void <API key>(struct snd_soc_codec *codec) { u32 i; struct wcd9xxx *tomtom_core = dev_get_drvdata(codec->dev->parent); for (i = 0; i < ARRAY_SIZE(<API key>); i++) snd_soc_update_bits(codec, <API key>[i].reg, <API key>[i].mask, <API key>[i].val); if (!TOMTOM_IS_1_0(tomtom_core->version)) { for (i = 0; i < ARRAY_SIZE(<API key>); i++) snd_soc_update_bits(codec, <API key>[i].reg, <API key>[i].mask, <API key>[i].val); } } static void <API key>(struct snd_soc_codec *codec) { int i; for (i = 0; i < <API key>; i++) <API key>(codec->control_data, <API key> + i, 0xFF); } static int tomtom_setup_irqs(struct tomtom_priv *tomtom) { int ret = 0; struct snd_soc_codec *codec = tomtom->codec; struct wcd9xxx *wcd9xxx = codec->control_data; struct <API key> *core_res = &wcd9xxx->core_res; ret = wcd9xxx_request_irq(core_res, WCD9XXX_IRQ_SLIMBUS, tomtom_slimbus_irq, "SLIMBUS Slave", tomtom); if (ret) pr_err("%s: Failed to request irq %d\n", __func__, WCD9XXX_IRQ_SLIMBUS); else <API key>(codec); return ret; } static void tomtom_cleanup_irqs(struct tomtom_priv *tomtom) { struct snd_soc_codec *codec = tomtom->codec; struct wcd9xxx *wcd9xxx = codec->control_data; struct <API key> *core_res = &wcd9xxx->core_res; wcd9xxx_free_irq(core_res, WCD9XXX_IRQ_SLIMBUS, tomtom); } static struct firmware_cal *<API key>(struct snd_soc_codec *codec, enum wcd_cal_type type) { struct tomtom_priv *tomtom; struct firmware_cal *hwdep_cal; if (!codec) { pr_err("%s: NULL codec pointer\n", __func__); return NULL; } tomtom = <API key>(codec); hwdep_cal = wcdcal_get_fw_cal(tomtom->fw_data, type); if (!hwdep_cal) { dev_err(codec->dev, "%s: cal not sent by %d\n", __func__, type); return NULL; } else { return hwdep_cal; } } int tomtom_hs_detect(struct snd_soc_codec *codec, struct wcd9xxx_mbhc_config *mbhc_cfg) { int rc; struct tomtom_priv *tomtom = <API key>(codec); if (mbhc_cfg->insert_detect) { rc = wcd9xxx_mbhc_start(&tomtom->mbhc, mbhc_cfg); if (!rc) tomtom->mbhc_started = true; } else { /* MBHC is disabled, so disable Auto pulldown */ snd_soc_update_bits(codec, <API key>, 0xC0, 0x00); snd_soc_update_bits(codec, <API key>, 0x01, 0x00); tomtom->mbhc.mbhc_cfg = NULL; tomtom->mbhc_started = false; rc = 0; } <API key>(&tomtom->clsh_d, tomtom->mbhc_started); return rc; } EXPORT_SYMBOL(tomtom_hs_detect); void <API key>(struct snd_soc_codec *codec) { struct tomtom_priv *tomtom = <API key>(codec); wcd9xxx_mbhc_stop(&tomtom->mbhc); tomtom->mbhc_started = false; } EXPORT_SYMBOL(<API key>); void <API key>( int (*machine_event_cb)(struct snd_soc_codec *codec, enum wcd9xxx_codec_event), struct snd_soc_codec *codec) { struct tomtom_priv *tomtom = <API key>(codec); tomtom-><API key> = machine_event_cb; } EXPORT_SYMBOL(<API key>); void <API key>( int (*codec_ext_clk_en)(struct snd_soc_codec *codec, int enable, bool dapm), int (*get_ext_clk_cnt) (void), struct snd_soc_codec *codec) { struct tomtom_priv *tomtom = <API key>(codec); tomtom->codec_ext_clk_en_cb = codec_ext_clk_en; tomtom-><API key> = get_ext_clk_cnt; } EXPORT_SYMBOL(<API key>); static void <API key>(struct snd_soc_codec *codec) { struct tomtom_priv *priv = <API key>(codec); struct <API key> *cfg; struct wcd9xxx *wcd9xxx = codec->control_data; uint64_t eaddr = 0; cfg = &priv->slimbus_slave_cfg; cfg->minor_version = 1; cfg-><API key> = 0; cfg-><API key> = 16; memcpy(&eaddr, &wcd9xxx->slim->e_addr, sizeof(wcd9xxx->slim->e_addr)); WARN_ON(sizeof(wcd9xxx->slim->e_addr) != 6); cfg-><API key> = eaddr & 0xFFFFFFFF; cfg-><API key> = eaddr >> 32; pr_debug("%s: slimbus logical address 0x%llx\n", __func__, eaddr); } static int tomtom_device_down(struct wcd9xxx *wcd9xxx) { int count; struct snd_soc_codec *codec; struct tomtom_priv *priv; codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv); priv = <API key>(codec); wcd_cpe_ssr_event(priv->cpe_core, <API key>); <API key>(codec->card, 0); set_bit(BUS_DOWN, &priv->status_mask); for (count = 0; count < NUM_CODEC_DAIS; count++) priv->dai[count].<API key> = true; return 0; } static int <API key>(struct wcd9xxx_mbhc *mbhc, struct list_head *lh) { int i; struct snd_soc_codec *codec = mbhc->codec; u32 delay; const struct <API key> reg_set_paon[] = { {<API key>, 0xff, 0xF0}, {<API key>, 0xff, 0x81}, {<API key>, 0x01, 0x01}, {<API key>, 0xff, 0xEF}, {<API key>, 0xff, 0xEE}, {TOMTOM_A_NCP_DTEST, 0xff, 0x20}, {<API key>, 0xff, 0x21}, {<API key>, 0xff, 0x81}, {<API key>, 0x02, 0x02}, {<API key>, 0xff, 0xAE}, {<API key>, 0xff, 0xAA}, {WCD9XXX_A_NCP_CLK, 0xff, 0x9C}, {WCD9XXX_A_NCP_CLK, 0xff, 0xFC}, {<API key>, 0xff, 0xA0}, {<API key>, 0xff, 0xC6}, {<API key>, 0xff, 0xE6}, {<API key>, 0xff, 0x02}, {<API key>, 0xff, 0xA1}, /* Add a delay of 1ms after this reg write */ {<API key>, 0xff, 0x28}, {WCD9XXX_A_NCP_EN, 0xff, 0xFF}, /* Add a delay of 1ms after this reg write */ /* set HPHL */ {<API key>, 0xff, 0x00}, {<API key>, 0xff, 0x42}, {<API key>, 0xff, 0x8C}, {<API key>, 0xff, 0xA4}, {<API key>, 0xff, 0xE0}, {<API key>, 0xff, 0xEC}, /* set HPHR */ {<API key>, 0xff, 0x00}, {<API key>, 0xff, 0x42}, {<API key>, 0xff, 0x20}, {<API key>, 0xff, 0x2C}, /* set HPH PAs */ {<API key>, 0xff, 0x2A}, {<API key>, 0xff, 0xDA}, {<API key>, 0xff, 0x15}, {<API key>, 0xff, 0xE6}, {<API key>, 0xff, 0x40}, {<API key>, 0xff, 0xC0}, {<API key>, 0xff, 0x40}, {<API key>, 0xff, 0xC0}, {<API key>, 0xff, 0x00}, {<API key>, 0xff, 0x00}, }; for (i = 0; i < ARRAY_SIZE(reg_set_paon); i++) { /* * Some of the codec registers like BUCK_MODE_1 * and NCP_EN requires 1ms wait time for them * to take effect. Other register writes for * PA configuration do not require any wait time. */ if (reg_set_paon[i].reg == <API key> || reg_set_paon[i].reg == WCD9XXX_A_NCP_EN) delay = 1000; else delay = 0; <API key>(codec, lh, reg_set_paon[i].reg, reg_set_paon[i].mask, reg_set_paon[i].val, delay); } pr_debug("%s: PAs are prepared\n", __func__); return 0; } static int <API key>(struct wcd9xxx_mbhc *mbhc, bool enable, u8 hph_pa) { struct snd_soc_codec *codec = mbhc->codec; const int wg_time = snd_soc_read(codec, <API key>) * <API key>; u8 mask = (hph_pa << 4); u8 pa_en = enable ? mask : ~mask; snd_soc_update_bits(codec, <API key>, mask, pa_en); /* Wait for wave gen time to avoid pop noise */ usleep_range(wg_time, wg_time + <API key>); pr_debug("%s: PAs are %s as static mode (wg_time %d)\n", __func__, enable ? "enabled" : "disabled", wg_time); return 0; } static int tomtom_setup_zdet(struct wcd9xxx_mbhc *mbhc, enum <API key> stage) { int ret = 0; struct snd_soc_codec *codec = mbhc->codec; struct tomtom_priv *tomtom = <API key>(codec); #define __wr(reg, mask, value) \ do { \ ret = <API key>(codec, \ &tomtom->reg_save_restore, \ reg, mask, value, 0); \ if (ret < 0) \ return ret; \ } while (0) switch (stage) { case <API key>: INIT_LIST_HEAD(&tomtom->reg_save_restore); <API key>(mbhc, &tomtom->reg_save_restore); /* Set HPH_MBHC for zdet */ __wr(WCD9XXX_A_MBHC_HPH, 0xff, 0xC4); usleep_range(10, 10 + <API key>); <API key>(mbhc, HPH_PA_ENABLE, HPH_PA_L_R); /* save old value of registers and write the new value */ __wr(<API key>, 0xff, 0x69); __wr(<API key>, 0xff, 0x80); __wr(<API key>, 0xff, 0x80); /* Enable MBHC MUX, Set MUX current to 37.5uA and ADC7 */ __wr(<API key>, 0xff, 0xC0); __wr(<API key>, 0xff, 0xF0); __wr(<API key>, 0xff, 0x8B); __wr(<API key>, 0xff, 0x78); __wr(<API key>, 0xff, 0x8C); __wr(<API key>, 0xff, 0xDC); /* Reset MBHC and set it up for STA */ __wr(<API key>, 0xff, 0x0A); snd_soc_write(codec, <API key>, 0x00); __wr(<API key>, 0xff, 0x02); __wr(<API key>, 0xff, 0x80); __wr(<API key>, 0xff, 0x25); /* Wait for ~50us to let MBHC hardware settle down */ usleep_range(50, 50 + <API key>); break; case <API key>: /* 0x69 for 105 number of samples for PA RAMP */ snd_soc_write(codec, <API key>, 0x69); /* Program the PA Ramp to FS_16K, L shift 1 */ snd_soc_write(codec, <API key>, 0x1 << 4 | 0x6); /* Reset the PA Ramp */ snd_soc_write(codec, <API key>, 0x1C); /* * Connect the PA Ramp to PA chain and release reset with * keep it connected. */ snd_soc_write(codec, <API key>, 0x1F); snd_soc_write(codec, <API key>, 0x03); /* Start the PA ramp on HPH L and R */ snd_soc_write(codec, <API key>, 0x05); /* Ramp generator takes ~30ms */ usleep_range(<API key>, <API key> + <API key>); /* * Set the multiplication factor for zdet calculation * based on the Ramp voltage and Gain used */ tomtom->zdet_gain_mul_fact = <API key>; break; case MBHC_ZDET_GAIN_0: /* Set Gain at 1x */ snd_soc_write(codec, <API key>, 0x00); snd_soc_write(codec, <API key>, 0x00); snd_soc_write(codec, <API key>, 0x42); /* Allow 100us for gain registers to settle */ usleep_range(100, 100 + <API key>); break; case <API key>: /* * Set the multiplication factor for zdet calculation * based on the Gain value used */ tomtom->zdet_gain_mul_fact = <API key>; break; case MBHC_ZDET_GAIN_1: /* Set Gain at 10x */ snd_soc_write(codec, <API key>, 0x10); snd_soc_write(codec, <API key>, 0x00); snd_soc_write(codec, <API key>, 0x42); /* Allow 100us for gain registers to settle */ usleep_range(100, 100 + <API key>); /* * Set the multiplication factor for zdet calculation * based on the Gain value used */ tomtom->zdet_gain_mul_fact = <API key>; break; case MBHC_ZDET_GAIN_2: /* Set Gain at 100x */ snd_soc_write(codec, <API key>, 0x00); snd_soc_write(codec, <API key>, 0x10); snd_soc_write(codec, <API key>, 0x43); /* Allow 100us for gain registers to settle */ usleep_range(100, 100 + <API key>); /* * Set the multiplication factor for zdet calculation * based on the Gain value used */ tomtom->zdet_gain_mul_fact = <API key>; break; case <API key>: /* Ramp HPH L & R back to Zero */ snd_soc_write(codec, <API key>, 0x00); /* 0x69 for 105 number of samples for PA RAMP */ snd_soc_write(codec, <API key>, 0x69); /* Program the PA Ramp to FS_16K, L shift 1 */ snd_soc_write(codec, <API key>, 0x1 << 4 | 0x6); /* Reset the PA Ramp */ snd_soc_write(codec, <API key>, 0x17); /* * Connect the PA Ramp to PA chain and release reset with * keep it connected. */ snd_soc_write(codec, <API key>, 0x03); /* Start the PA ramp on HPH L and R */ snd_soc_write(codec, <API key>, 0x0A); /* Ramp generator takes ~30ms to settle down */ usleep_range(<API key>, <API key> + <API key>); break; case <API key>: /* Ramp HPHR back to Zero */ snd_soc_write(codec, <API key>, 0x00); snd_soc_write(codec, <API key>, 0x69); snd_soc_write(codec, <API key>, 0x1 << 4 | 0x6); /* Reset the PA Ramp */ snd_soc_write(codec, <API key>, 0x17); /* * Connect the PA Ramp to PA chain and release reset with * keep it connected. */ snd_soc_write(codec, <API key>, 0x03); snd_soc_write(codec, <API key>, 0x08); /* Ramp generator takes ~30ms to settle down */ usleep_range(<API key>, <API key> + <API key>); break; case <API key>: /* Ramp back to Zero */ snd_soc_write(codec, <API key>, 0x00); snd_soc_write(codec, <API key>, 0x69); snd_soc_write(codec, <API key>, 0x1 << 4 | 0x6); /* Reset the PA Ramp */ snd_soc_write(codec, <API key>, 0x17); /* * Connect the PA Ramp to PA chain and release reset with * keep it connected. */ snd_soc_write(codec, <API key>, 0x03); snd_soc_write(codec, <API key>, 0x02); /* Ramp generator takes ~30ms to settle down */ usleep_range(<API key>, <API key> + <API key>); break; case <API key>: /* Disable PA */ <API key>(mbhc, HPH_PA_DISABLE, HPH_PA_R); break; case <API key>: /* Disable PA */ if (!mbhc->hph_pa_dac_state && (!(test_bit(MBHC_EVENT_PA_HPHL, &mbhc->event_state) || test_bit(MBHC_EVENT_PA_HPHR, &mbhc->event_state)))) <API key>(mbhc, HPH_PA_DISABLE, HPH_PA_L_R); else if (!(snd_soc_read(codec, <API key>) & 0x10)) <API key>(mbhc, HPH_PA_ENABLE, HPH_PA_R); /* Turn off PA ramp generator */ snd_soc_write(codec, <API key>, 0x00); snd_soc_write(codec, <API key>, 0x00); snd_soc_write(codec, <API key>, 0x00); snd_soc_write(codec, <API key>, 0x00); /* Restore registers */ <API key>(codec, &tomtom->reg_save_restore); break; } #undef __wr return ret; } /* Calculate final impedance values for HPH left and right based on formulae */ static void <API key>(struct wcd9xxx_mbhc *mbhc, s16 *l, s16 *r, uint32_t *zl, uint32_t *zr) { s64 zln, zrn; int zld, zrd; s64 rl = 0, rr = 0; struct snd_soc_codec *codec; struct tomtom_priv *tomtom; if (!mbhc) { pr_err("%s: Invalid parameters mbhc = %pK\n", __func__, mbhc); return; } codec = mbhc->codec; tomtom = <API key>(codec); if (l && zl) { zln = (s64) (l[1] - l[0]) * tomtom->zdet_gain_mul_fact; zld = (l[2] - l[0]); if (zld) rl = div_s64(zln, zld); else /* If L0 and L2 are same, Z has to be on Zone 3. * Assign a default value so that atleast the value * is read again with Ramp-up */ rl = <API key>; /* 32-bit LSBs are enough to hold Impedance values */ *zl = (u32) rl; } if (r && zr) { zrn = (s64) (r[1] - r[0]) * tomtom->zdet_gain_mul_fact; zrd = (r[2] - r[0]); if (zrd) rr = div_s64(zrn, zrd); else /* If R0 and R2 are same, Z has to be on Zone 3. * Assign a default value so that atleast the value * is read again with Ramp-up */ rr = <API key>; /* 32-bit LSBs are enough to hold Impedance values */ *zr = (u32) rr; } } /* * Calculate error approximation of impedance values for HPH left * and HPH right based on QFuse values */ static void <API key>(struct wcd9xxx_mbhc *mbhc, uint32_t *zl, uint32_t *zr) { struct snd_soc_codec *codec; struct tomtom_priv *tomtom; s8 q1_t, q2_t; s8 q1_m, q2_m; s8 q1, q2; u8 div_shift; int rl_alpha = 0, rr_alpha = 0; int rl_beta = 0, rr_beta = 0; u64 rl = 0, rr = 0; const int mult_factor = <API key>; const int shift = <API key>; if (!zl || !zr || !mbhc) { pr_err("%s: Invalid parameters zl = %pK zr = %pK, mbhc = %pK\n", __func__, zl, zr, mbhc); return; } codec = mbhc->codec; tomtom = <API key>(codec); if ((tomtom->zdet_gain_mul_fact == <API key>) || (tomtom->zdet_gain_mul_fact == <API key>)) { q1_t = ((snd_soc_read(codec, <API key>) & 0x3) << 0x5); q1_t |= ((snd_soc_read(codec, <API key>) & 0xF8) >> 0x3); q2_t = ((snd_soc_read(codec, <API key>) & 0x7) << 0x4); q2_t |= ((snd_soc_read(codec, <API key>) & 0xF0) >> 0x4); /* Take out the numeric part of the Qfuse value */ q1_m = q1_t & 0x3F; q2_m = q2_t & 0x3F; /* Check the sign part of the Qfuse and adjust value */ q1 = (q1_t & 0x40) ? -q1_m : q1_m; q2 = (q2_t & 0x40) ? -q2_m : q2_m; div_shift = 1; } else { q1_t = ((snd_soc_read(codec, <API key>) & 0xF) << 0x2); q1_t |= ((snd_soc_read(codec, <API key>) & 0xC0) >> 0x6); q2_t = (snd_soc_read(codec, <API key>) & 0x3F); /* Take out the numeric part of the Qfuse value */ q1_m = q1_t & 0x1F; q2_m = q2_t & 0x1F; /* Check the sign part of the Qfuse and adjust value */ q1 = (q1_t & 0x20) ? -q1_m : q1_m; q2 = (q2_t & 0x20) ? -q2_m : q2_m; div_shift = 0; } dev_dbg(codec->dev, "%s: qfuse1 = %d, qfuse2 = %d\n", __func__, q1, q2); if (!q1 && !q2) { dev_dbg(codec->dev, "%s: qfuse1 and qfuse2 are 0. Exiting\n", __func__); return; } /* * Use multiplication and shift to avoid floating point math * The Z value is calculated with the below formulae using * the Qfuse value- * zl = zl * [1 - {(Q1 / div) / 100}] (Include sign for Q1) * zr = zr * [1 - {(Q2 / div) / 100}] (Include sign for Q2) * We multiply by 65536 and shift 16 times to get the approx result * div = 4 for 1x gain, div = 2 for 10x/100x gain */ /* Q1/4 */ rl_alpha = q1 >> div_shift; rl_alpha = 100 - rl_alpha; /* {rl_alpha/100} * 65536 */ rl_beta = rl_alpha * mult_factor; rl = (u64) *zl * rl_beta; /* rl/65536 */ rl = (u64) rl >> shift; rr_alpha = q2 >> div_shift; rr_alpha = 100 - rr_alpha; rr_beta = rr_alpha * mult_factor; rr = (u64) *zr * rr_beta; rr = (u64) rr >> shift; dev_dbg(codec->dev, "%s: rl = 0x%llx (%lld) \t rr = 0x%llx (%lld)\n", __func__, rl, rl, rr, rr); *zl = (u32) rl; *zr = (u32) rr; } static enum wcd9xxx_cdc_type tomtom_get_cdc_type(void) { return <API key>; } static bool <API key>(struct snd_soc_codec *codec) { return !(snd_soc_read(codec, <API key>) & (1 << 4)); } static void <API key>(struct wcd9xxx_mbhc *mbhc, bool enable) { struct snd_soc_codec *codec = mbhc->codec; if (!enable) { /* Remove automatic pulldown on micbias */ snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.cfilt_ctl, 0x01, 0x00); } else { /* Enable automatic pulldown on micbias */ snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.cfilt_ctl, 0x01, 0x01); } } static void <API key>(struct snd_soc_codec *codec, bool enable) { struct wcd9xxx *tomtom_core = dev_get_drvdata(codec->dev->parent); if (TOMTOM_IS_1_0(tomtom_core->version)) return; dev_dbg(codec->dev, "%s: %s auto pull down\n", __func__, enable ? "enable" : "disable"); if (enable) { snd_soc_update_bits(codec, <API key>, 0x08, 0x08); snd_soc_update_bits(codec, <API key>, 0x08, 0x08); } else { snd_soc_update_bits(codec, <API key>, 0x08, 0x00); snd_soc_update_bits(codec, <API key>, 0x08, 0x00); } } static int <API key>(struct snd_soc_codec *codec, bool turn_on, bool use_dapm) { int ret = 0; if (!use_dapm) return ret; if (turn_on) ret = <API key>(&codec->dapm, "MICBIAS_REGULATOR"); else ret = <API key>(&codec->dapm, "MICBIAS_REGULATOR"); snd_soc_dapm_sync(&codec->dapm); if (ret) dev_err(codec->dev, "%s: Failed to %s external micbias source\n", __func__, turn_on ? "enable" : "disabled"); else dev_dbg(codec->dev, "%s: %s external micbias source\n", __func__, turn_on ? "Enabled" : "Disabled"); return ret; } static const struct wcd9xxx_mbhc_cb mbhc_cb = { .get_cdc_type = tomtom_get_cdc_type, .setup_zdet = tomtom_setup_zdet, .compute_impedance = <API key>, .zdet_error_approx = <API key>, .insert_rem_status = <API key>, .<API key> = <API key>, .codec_rco_ctrl = <API key>, .<API key> = <API key>, .get_hwdep_fw_cal = <API key>, .enable_mb_source = <API key>, }; static const struct wcd9xxx_mbhc_intr cdc_intr_ids = { .poll_plug_rem = <API key>, .shortavg_complete = <API key>, .<API key> = <API key>, .button_release = <API key>, .dce_est_complete = <API key>, .insertion = <API key>, .hph_left_ocp = <API key>, .hph_right_ocp = <API key>, .hs_jack_switch = <API key>, }; static int <API key>(struct wcd9xxx *wcd9xxx) { int ret = 0; struct snd_soc_codec *codec; struct tomtom_priv *tomtom; int rco_clk_rate; codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv); tomtom = <API key>(codec); /* * Delay is needed for settling time * for the register configuration */ msleep(50); <API key>(codec->card, 1); clear_bit(BUS_DOWN, &tomtom->status_mask); mutex_lock(&codec->mutex); <API key>(codec); if (wcd9xxx->mclk_rate == <API key>) snd_soc_update_bits(codec, TOMTOM_A_CHIP_CTL, 0x06, 0x0); else if (wcd9xxx->mclk_rate == <API key>) snd_soc_update_bits(codec, TOMTOM_A_CHIP_CTL, 0x06, 0x2); <API key>(codec); codec->cache_sync = true; snd_soc_cache_sync(codec); codec->cache_sync = false; ret = tomtom_handle_pdata(tomtom); if (IS_ERR_VALUE(ret)) pr_err("%s: bad pdata\n", __func__); <API key>(codec); <API key>(codec); wcd_cpe_ssr_event(tomtom->cpe_core, <API key>); <API key>(&tomtom->resmgr); if (tomtom->mbhc_started) { wcd9xxx_mbhc_deinit(&tomtom->mbhc); tomtom->mbhc_started = false; rco_clk_rate = <API key>; ret = wcd9xxx_mbhc_init(&tomtom->mbhc, &tomtom->resmgr, codec, <API key>, &mbhc_cb, &cdc_intr_ids, rco_clk_rate, <API key>); if (ret) pr_err("%s: mbhc init failed %d\n", __func__, ret); else tomtom_hs_detect(codec, tomtom->mbhc.mbhc_cfg); } if (tomtom-><API key>) tomtom-><API key>(codec, <API key>); tomtom_cleanup_irqs(tomtom); ret = tomtom_setup_irqs(tomtom); if (ret) pr_err("%s: Failed to setup irq: %d\n", __func__, ret); /* * After SSR, the qfuse sensing is lost. * Perform qfuse sensing again after SSR * handling is finished. */ <API key>(codec); mutex_unlock(&codec->mutex); return ret; } void *<API key>(struct snd_soc_codec *codec, enum afe_config_type config_type) { struct tomtom_priv *priv = <API key>(codec); switch (config_type) { case <API key>: return &priv->slimbus_slave_cfg; case <API key>: return &<API key>; case <API key>: return &<API key>; case AFE_AANC_VERSION: return &<API key>; case AFE_CLIP_BANK_SEL: return &clip_bank_sel; case <API key>: return &tomtom_clip_reg_cfg; default: pr_err("%s: Unknown config_type 0x%x\n", __func__, config_type); return NULL; } } static struct wcd9xxx_reg_address tomtom_reg_address = { .micb_4_mbhc = <API key>, .micb_4_int_rbias = <API key>, .micb_4_ctl = TOMTOM_A_MICB_4_CTL, }; static int <API key>(struct wcd9xxx *control, int (*device_down_cb)(struct wcd9xxx *wcd9xxx), int (*device_up_cb)(struct wcd9xxx *wcd9xxx), void *priv) { control->dev_down = device_down_cb; control->post_reset = device_up_cb; control->ssr_priv = priv; return 0; } static const struct snd_soc_dapm_widget <API key>[] = { SND_SOC_DAPM_ADC_E("ADC1", NULL, TOMTOM_A_TX_1_GAIN, 7, 0, <API key>, <API key> | <API key> | <API key>), SND_SOC_DAPM_ADC_E("ADC2", NULL, TOMTOM_A_TX_2_GAIN, 7, 0, <API key>, <API key> | <API key> | <API key>), SND_SOC_DAPM_ADC_E("ADC3", NULL, TOMTOM_A_TX_3_GAIN, 7, 0, <API key>, <API key> | <API key> | <API key>), SND_SOC_DAPM_ADC_E("ADC4", NULL, TOMTOM_A_TX_4_GAIN, 7, 0, <API key>, <API key> | <API key> | <API key>), SND_SOC_DAPM_ADC_E("ADC5", NULL, TOMTOM_A_TX_5_GAIN, 7, 0, <API key>, <API key> | <API key> | <API key>), SND_SOC_DAPM_ADC_E("ADC6", NULL, TOMTOM_A_TX_6_GAIN, 7, 0, <API key>, <API key> | <API key> | <API key>), }; static struct regulator *<API key>(struct snd_soc_codec *cdc, const char *name) { int i; struct wcd9xxx *core = dev_get_drvdata(cdc->dev->parent); for (i = 0; i < core->num_of_supplies; i++) { if (core->supplies[i].supply && !strcmp(core->supplies[i].supply, name)) return core->supplies[i].consumer; } return NULL; } static struct wcd_cpe_core *<API key>( struct snd_soc_codec *codec) { struct tomtom_priv *priv = <API key>(codec); return priv->cpe_core; } static int <API key>(struct snd_soc_codec *codec, bool enable) { struct wcd9xxx *wcd9xxx; if (!codec || !codec->control_data) { pr_err("%s: Invalid codec handle, %pK\n", __func__, codec); return -EINVAL; } wcd9xxx = codec->control_data; dev_dbg(codec->dev, "%s: %s, mclk_rate = %d\n", __func__, (enable ? "enable" : "disable"), wcd9xxx->mclk_rate); switch (wcd9xxx->mclk_rate) { case <API key>: snd_soc_update_bits(codec, TOMTOM_A_FLL_NREF, 0x1F, 0x15); snd_soc_update_bits(codec, <API key>, 0x07, 0x06); snd_soc_write(codec, <API key>, 0xD1); snd_soc_write(codec, <API key>, 0x40); break; case <API key>: snd_soc_update_bits(codec, TOMTOM_A_FLL_NREF, 0x1F, 0x11); snd_soc_update_bits(codec, <API key>, 0x07, 0x05); snd_soc_write(codec, <API key>, 0xB1); snd_soc_write(codec, <API key>, 0x40); break; } return 0; } static int <API key>(struct snd_soc_codec *codec, u32 bw_ops, bool commit) { struct wcd9xxx *wcd9xxx; if (!codec) { pr_err("%s: Invalid handle to codec\n", __func__); return -EINVAL; } wcd9xxx = dev_get_drvdata(codec->dev->parent); if (!wcd9xxx) { dev_err(codec->dev, "%s: Invalid parent drv_data\n", __func__); return -EINVAL; } return <API key>(wcd9xxx, bw_ops, commit); } static int <API key>(struct snd_soc_codec *codec, bool vote) { u32 bw_ops; if (vote) bw_ops = SLIM_BW_CLK_GEAR_9; else bw_ops = SLIM_BW_UNVOTE; return <API key>(codec, bw_ops, true); } static const struct wcd9xxx_resmgr_cb resmgr_cb = { .cdc_rco_ctrl = <API key>, }; static int <API key>(struct snd_soc_codec *codec, enum <API key> cntl_type, u8 *status) { switch (cntl_type) { case CPE_ERR_IRQ_MASK: snd_soc_update_bits(codec, <API key>, 0x3F, 0x3F); break; case CPE_ERR_IRQ_UNMASK: snd_soc_update_bits(codec, <API key>, 0x3F, 0x0C); break; case CPE_ERR_IRQ_CLEAR: snd_soc_update_bits(codec, <API key>, 0x3F, 0x3F); break; case CPE_ERR_IRQ_STATUS: if (!status) return -EINVAL; *status = snd_soc_read(codec, <API key>); break; } return 0; } static const struct wcd_cpe_cdc_cb cpe_cb = { .cdc_clk_en = <API key>, .cpe_clk_en = <API key>, .lab_cdc_ch_ctl = <API key>, .cdc_ext_clk = <API key>, .bus_vote_bw = <API key>, .cpe_err_irq_control = <API key>, }; static struct cpe_svc_init_param cpe_svc_params = { .version = 0, .query_freq_plans_cb = NULL, .change_freq_plan_cb = NULL, }; static int <API key>(struct snd_soc_codec *codec) { struct tomtom_priv *tomtom = <API key>(codec); struct wcd_cpe_params cpe_params; memset(&cpe_params, 0, sizeof(struct wcd_cpe_params)); cpe_params.codec = codec; cpe_params.get_cpe_core = <API key>; cpe_params.cdc_cb = &cpe_cb; cpe_params.dbg_mode = cpe_debug_mode; cpe_params.cdc_major_ver = <API key>; cpe_params.cdc_minor_ver = CPE_SVC_CODEC_V1P0; cpe_params.cdc_id = <API key>; cpe_params.cdc_irq_info.cpe_engine_irq = <API key>; cpe_params.cdc_irq_info.cpe_err_irq = <API key>; cpe_params.cdc_irq_info.cpe_fatal_irqs = <API key>; cpe_svc_params.context = codec; cpe_params.cpe_svc_params = &cpe_svc_params; tomtom->cpe_core = wcd_cpe_init("cpe", codec, &cpe_params); if (IS_ERR_OR_NULL(tomtom->cpe_core)) { dev_err(codec->dev, "%s: Failed to enable CPE\n", __func__); return -EINVAL; } return 0; } static int tomtom_codec_probe(struct snd_soc_codec *codec) { struct wcd9xxx *control; struct tomtom_priv *tomtom; struct wcd9xxx_pdata *pdata; struct wcd9xxx *wcd9xxx; struct <API key> *dapm = &codec->dapm; int ret = 0; int i, rco_clk_rate; void *ptr = NULL; struct <API key> *core_res; struct clk *wcd_ext_clk = NULL; codec->control_data = dev_get_drvdata(codec->dev->parent); control = codec->control_data; <API key>(control, tomtom_device_down, <API key>, (void *)codec); dev_info(codec->dev, "%s()\n", __func__); tomtom = devm_kzalloc(codec->dev, sizeof(struct tomtom_priv), GFP_KERNEL); if (!tomtom) { dev_err(codec->dev, "Failed to allocate private data\n"); return -ENOMEM; } for (i = 0; i < NUM_DECIMATORS; i++) { tx_hpf_work[i].tomtom = tomtom; tx_hpf_work[i].decimator = i + 1; tx_hpf_work[i].tx_hpf_bypass = false; INIT_DELAYED_WORK(&tx_hpf_work[i].dwork, <API key>); } <API key>(codec, tomtom); /* codec resmgr module init */ wcd9xxx = codec->control_data; if (!of_find_property(wcd9xxx->dev->of_node, "clock-names", NULL)) { dev_dbg(wcd9xxx->dev, "%s: codec not using audio-ext-clk driver\n", __func__); } else { wcd_ext_clk = clk_get(wcd9xxx->dev, "wcd_clk"); if (IS_ERR(wcd_ext_clk)) { dev_err(codec->dev, "%s: clk get %s failed\n", __func__, "wcd_ext_clk"); goto err_nomem_slimch; } } tomtom->wcd_ext_clk = wcd_ext_clk; core_res = &wcd9xxx->core_res; pdata = dev_get_platdata(codec->dev->parent); ret = wcd9xxx_resmgr_init(&tomtom->resmgr, codec, core_res, pdata, &pdata->micbias, &tomtom_reg_address, &resmgr_cb, <API key>); if (ret) { pr_err("%s: wcd9xxx init failed %d\n", __func__, ret); goto err_nomem_slimch; } tomtom->clsh_d.buck_mv = <API key>(codec); /* TomTom does not support dynamic switching of vdd_cp */ tomtom->clsh_d.is_dynamic_vdd_cp = false; wcd9xxx_clsh_init(&tomtom->clsh_d, &tomtom->resmgr); rco_clk_rate = <API key>; tomtom->fw_data = kzalloc(sizeof(*(tomtom->fw_data)), GFP_KERNEL); if (!tomtom->fw_data) { dev_err(codec->dev, "Failed to allocate fw_data\n"); goto err_nomem_slimch; } set_bit(WCD9XXX_ANC_CAL, tomtom->fw_data->cal_bit); set_bit(WCD9XXX_MAD_CAL, tomtom->fw_data->cal_bit); set_bit(WCD9XXX_MBHC_CAL, tomtom->fw_data->cal_bit); ret = <API key>(tomtom->fw_data, <API key>, codec); if (ret < 0) { dev_err(codec->dev, "%s hwdep failed %d\n", __func__, ret); goto err_hwdep; } /* init and start mbhc */ ret = wcd9xxx_mbhc_init(&tomtom->mbhc, &tomtom->resmgr, codec, <API key>, &mbhc_cb, &cdc_intr_ids, rco_clk_rate, <API key>); if (ret) { pr_err("%s: mbhc init failed %d\n", __func__, ret); goto err_hwdep; } tomtom->codec = codec; for (i = 0; i < COMPANDER_MAX; i++) { tomtom->comp_enabled[i] = 0; tomtom->comp_fs[i] = COMPANDER_FS_48KHZ; } tomtom->intf_type = <API key>(); tomtom->aux_pga_cnt = 0; tomtom->aux_l_gain = 0x1F; tomtom->aux_r_gain = 0x1F; tomtom->ldo_h_users = 0; tomtom->micb_2_users = 0; tomtom->micb_3_users = 0; <API key>(codec); pr_debug("%s: MCLK Rate = %x\n", __func__, wcd9xxx->mclk_rate); if (wcd9xxx->mclk_rate == <API key>) { snd_soc_update_bits(codec, TOMTOM_A_CHIP_CTL, 0x06, 0x0); snd_soc_update_bits(codec, <API key>, 0x01, 0x01); } else if (wcd9xxx->mclk_rate == <API key>) snd_soc_update_bits(codec, TOMTOM_A_CHIP_CTL, 0x06, 0x2); <API key>(codec); ret = tomtom_handle_pdata(tomtom); if (IS_ERR_VALUE(ret)) { pr_err("%s: bad pdata\n", __func__); goto err_hwdep; } tomtom->spkdrv_reg = <API key>(codec, <API key>); tomtom->spkdrv2_reg = <API key>(codec, <API key>); tomtom->micbias_reg = <API key>(codec, <API key>[ON_DEMAND_MICBIAS]); ptr = kmalloc((sizeof(tomtom_rx_chs) + sizeof(tomtom_tx_chs)), GFP_KERNEL); if (!ptr) { pr_err("%s: no mem for slim chan ctl data\n", __func__); ret = -ENOMEM; goto err_hwdep; } if (tomtom->intf_type == <API key>) { <API key>(dapm, <API key>, ARRAY_SIZE(<API key>)); <API key>(dapm, audio_i2s_map, ARRAY_SIZE(audio_i2s_map)); for (i = 0; i < ARRAY_SIZE(tomtom_i2s_dai); i++) INIT_LIST_HEAD(&tomtom->dai[i].wcd9xxx_ch_list); } else if (tomtom->intf_type == <API key>) { for (i = 0; i < NUM_CODEC_DAIS; i++) { INIT_LIST_HEAD(&tomtom->dai[i].wcd9xxx_ch_list); init_waitqueue_head(&tomtom->dai[i].dai_wait); } <API key>.<API key> = control->slim_slave->laddr; <API key>.slave_dev_pgd_la = control->slim->laddr; <API key>.slave_port_mapping[0] = <API key>; <API key>(codec); } <API key>(dapm, <API key>, ARRAY_SIZE(<API key>)); <API key>(codec, <API key>, ARRAY_SIZE(<API key>)); <API key>(codec, <API key>, ARRAY_SIZE(<API key>)); <API key>(codec, <API key>, ARRAY_SIZE(<API key>)); control->num_rx_port = TOMTOM_RX_MAX; control->rx_chs = ptr; memcpy(control->rx_chs, tomtom_rx_chs, sizeof(tomtom_rx_chs)); control->num_tx_port = TOMTOM_TX_MAX; control->tx_chs = ptr + sizeof(tomtom_rx_chs); memcpy(control->tx_chs, tomtom_tx_chs, sizeof(tomtom_tx_chs)); snd_soc_dapm_sync(dapm); ret = tomtom_setup_irqs(tomtom); if (ret) { pr_err("%s: tomtom irq setup failed %d\n", __func__, ret); goto err_pdata; } atomic_set(&kp_tomtom_priv, (unsigned long)tomtom); mutex_lock(&dapm->codec->mutex); <API key>(dapm, "ANC HPHL"); <API key>(dapm, "ANC HPHR"); <API key>(dapm, "ANC HEADPHONE"); <API key>(dapm, "ANC EAR PA"); <API key>(dapm, "ANC EAR"); mutex_unlock(&dapm->codec->mutex); snd_soc_dapm_sync(dapm); codec->ignore_pmdown_time = 1; ret = <API key>(codec); if (ret) { dev_info(codec->dev, "%s: cpe initialization failed, ret = %d\n", __func__, ret); /* Do not fail probe if CPE failed */ ret = 0; } return ret; err_pdata: kfree(ptr); err_hwdep: kfree(tomtom->fw_data); err_nomem_slimch: devm_kfree(codec->dev, tomtom); return ret; } static int tomtom_codec_remove(struct snd_soc_codec *codec) { struct tomtom_priv *tomtom = <API key>(codec); WCD9XXX_BG_CLK_LOCK(&tomtom->resmgr); atomic_set(&kp_tomtom_priv, 0); <API key>(&tomtom->resmgr); if (tomtom->wcd_ext_clk) clk_put(tomtom->wcd_ext_clk); tomtom_cleanup_irqs(tomtom); /* cleanup MBHC */ wcd9xxx_mbhc_deinit(&tomtom->mbhc); /* cleanup resmgr */ <API key>(&tomtom->resmgr); tomtom->spkdrv_reg = NULL; tomtom->spkdrv2_reg = NULL; devm_kfree(codec->dev, tomtom); return 0; } static struct <API key> <API key> = { .probe = tomtom_codec_probe, .remove = tomtom_codec_remove, .read = tomtom_read, .write = tomtom_write, .readable_register = tomtom_readable, .volatile_register = tomtom_volatile, .reg_cache_size = TOMTOM_CACHE_SIZE, .reg_cache_default = <API key>, .reg_word_size = 1, .controls = tomtom_snd_controls, .num_controls = ARRAY_SIZE(tomtom_snd_controls), .dapm_widgets = tomtom_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(tomtom_dapm_widgets), .dapm_routes = audio_map, .num_dapm_routes = ARRAY_SIZE(audio_map), }; #ifdef CONFIG_PM static int tomtom_suspend(struct device *dev) { dev_dbg(dev, "%s: system suspend\n", __func__); return 0; } static int tomtom_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct tomtom_priv *tomtom = <API key>(pdev); if (!tomtom) { dev_err(dev, "%s: tomtom private data is NULL\n", __func__); return -EINVAL; } dev_dbg(dev, "%s: system resume\n", __func__); /* Notify */ <API key>(&tomtom->resmgr, <API key>); return 0; } static const struct dev_pm_ops tomtom_pm_ops = { .suspend = tomtom_suspend, .resume = tomtom_resume, }; #endif static int tomtom_probe(struct platform_device *pdev) { int ret = 0; if (<API key>() == <API key>) ret = <API key>(&pdev->dev, &<API key>, tomtom_dai, ARRAY_SIZE(tomtom_dai)); else if (<API key>() == <API key>) ret = <API key>(&pdev->dev, &<API key>, tomtom_i2s_dai, ARRAY_SIZE(tomtom_i2s_dai)); return ret; } static int tomtom_remove(struct platform_device *pdev) { <API key>(&pdev->dev); return 0; } static struct platform_driver tomtom_codec_driver = { .probe = tomtom_probe, .remove = tomtom_remove, .driver = { .name = "tomtom_codec", .owner = THIS_MODULE, #ifdef CONFIG_PM .pm = &tomtom_pm_ops, #endif }, }; static int __init tomtom_codec_init(void) { return <API key>(&tomtom_codec_driver); } static void __exit tomtom_codec_exit(void) { <API key>(&tomtom_codec_driver); } module_init(tomtom_codec_init); module_exit(tomtom_codec_exit); MODULE_DESCRIPTION("TomTom codec driver"); MODULE_LICENSE("GPL v2");
function playAudioVisualize(track) { var bars = 50; var waveResolution = 128; var style = "bars"; //set default style upon loading here var audio = new Audio(); var canvas, source, context, analyser, fFrequencyData, barX, barWidth, barHeight, red, green, blue, ctx; audio.controls = true; audio.src = track; audio.loop = false; audio.autoplay = false; window.addEventListener("load", initPlayer, false); function initPlayer() { document.getElementById('audio-container').appendChild(audio); context = new AudioContext(); analyser = context.createAnalyser(); canvas = document.getElementById('audio-display'); canvas.addEventListener("click", toggleStyle); ctx = canvas.getContext('2d'); source = context.<API key>(audio); source.connect(analyser); analyser.connect(context.destination); drawFrames(); function toggleStyle() { style = (style === "wave" ? "bars" : "wave"); } } var k = 0; //keep track of total number of frames drawn function drawFrames() { window.<API key>(drawFrames); analyser.fftsize = 128; fFrequencyData = new Uint8Array(analyser.frequencyBinCount); analyser.<API key>(fFrequencyData); ctx.clearRect(0,0,canvas.width,canvas.height); numBarsBars = 16; //calculate average frequency for color var total = 0; for(var j = 0; j < fFrequencyData.length; j++) { total += fFrequencyData[j]; } var avg = total / fFrequencyData.length; avg = avg / 1.2; //bar style visual representation function drawBars(numBars) { for(var i = 0; i < numBars; i++) { barX = i * (canvas.width / numBars); barWidth = (canvas.width / numBars - 1); barHeight = -(fFrequencyData[i] / 2); //reduce frequency of color changing to avoid flickering if(k % 15 === 0) { getColors(); k = 0; } ctx.fillStyle = 'rgb('+red+','+green+','+blue+')'; ctx.fillRect(barX, canvas.height, barWidth, barHeight); } } //waveform visualization function drawWave(resolution, lineWidth) { ctx.beginPath(); ctx.lineWidth = lineWidth; var barX, barY; for(var i = 0; i < resolution; i++) { barX = i * (Math.ceil(canvas.width / resolution)); barY = -(fFrequencyData[i] / 2); getColors(); k = 0; ctx.strokeStyle = 'rgb('+red+','+green+','+blue+')'; ctx.lineTo(barX, barY + canvas.height ); ctx.stroke(); } } function getColors() { //can edit these values to get overall different coloration!! red = Math.round(Math.sin(avg/29.0 + 6.1) * 127 + 128); green = Math.round(Math.sin(avg/42.0 - 7.4) * 127 + 128); blue = Math.round(Math.sin(avg/34.0 - 3.8) * 127 + 128); } if(style === "wave") { drawWave(waveResolution, 2); } if(style === "bars") { drawBars(bars); } k++; } }
package org.owasp.benchmark.testcode; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet("/BenchmarkTest10564") public class BenchmarkTest10564 extends HttpServlet { private static final long serialVersionUID = 1L; @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { java.util.Map<String,String[]> map = request.getParameterMap(); String param = ""; if (!map.isEmpty()) { param = map.get("foo")[0]; } String bar = new Test().doSomething(param); Object[] obj = { "a", "b"}; response.getWriter().printf(java.util.Locale.US,bar,obj); } // end doPost private class Test { public String doSomething(String param) throws ServletException, IOException { String bar; String guess = "ABC"; char switchTarget = guess.charAt(1); // condition 'B', which is safe // Simple case statement that assigns param to bar on conditions 'A' or 'C' switch (switchTarget) { case 'A': bar = param; break; case 'B': bar = "bob"; break; case 'C': case 'D': bar = param; break; default: bar = "bob's your uncle"; break; } return bar; } } // end innerclass Test } // end <API key>
/** * \file * * \author Gurvinder Singh <<API key>@gmail.com> * \author Victor Julien <victor@inliniac.net> * * Reference: * Judy Novak, Steve Sturges: Target-Based TCP Stream Reassembly August, 2007 * */ #include "suricata-common.h" #include "suricata.h" #include "debug.h" #include "detect.h" #include "flow.h" #include "threads.h" #include "conf.h" #include "flow-util.h" #include "threadvars.h" #include "tm-threads.h" #include "util-pool.h" #include "util-unittest.h" #include "util-print.h" #include "util-host-os-info.h" #include "<API key>.h" #include "util-byte.h" #include "stream-tcp.h" #include "stream-tcp-private.h" #include "<API key>.h" #include "stream-tcp-inline.h" #include "stream-tcp-util.h" #include "stream.h" #include "util-debug.h" #include "app-layer-protos.h" #include "app-layer.h" #include "app-layer-events.h" #include "detect-engine-state.h" #include "util-profiling.h" #define <API key> 65416 /* 64 Kb minus max IP and TCP header */ #ifdef DEBUG static SCMutex <API key>; static uint64_t segment_pool_memuse = 0; static uint64_t segment_pool_memcnt = 0; #endif /* We define several pools with prealloced segments with fixed size * payloads. We do this to prevent having to do an SCMalloc call for every * data segment we receive, which would be a large performance penalty. * The cost is in memory of course. The number of pools and the properties * of the pools are determined by the yaml. */ static int segment_pool_num = 0; static Pool **segment_pool = NULL; static SCMutex *segment_pool_mutex = NULL; static uint16_t *<API key> = NULL; #ifdef DEBUG static SCMutex <API key>; static uint64_t segment_pool_cnt = 0; #endif /* index to the right pool for all packet sizes. */ static uint16_t segment_pool_idx[65536]; /* O(1) lookups of the pool */ static int <API key> = 0; /* Memory use counter */ SC_ATOMIC_DECLARE(uint64_t, ra_memuse); /* prototypes */ static int <API key>(ThreadVars *, <API key> *, TcpStream *, TcpSegment *, TcpSegment *, Packet *); static int <API key>(ThreadVars *, <API key> *, TcpStream *, TcpSegment *, TcpSegment *, Packet *); static int <API key>(ThreadVars *, <API key> *, TcpStream *, TcpSegment *, TcpSegment *, Packet *); void <API key>(TcpSegment *, TcpSegment *, uint32_t, uint16_t); void <API key>(TcpSegment *, TcpSegment *); TcpSegment* StreamTcpGetSegment(ThreadVars *tv, <API key> *, uint16_t); void <API key>(uint8_t *, uint8_t, uint8_t, uint8_t); void <API key>(TcpStream *, Packet *, PacketQueue *); static int <API key>(TcpSegment *dst_seg, TcpSegment *src_seg, uint32_t start_point, uint16_t len); void <API key>(void) { <API key> = 1; } /** * \brief Function to Increment the memory usage counter for the TCP reassembly * segments * * \param size Size of the TCP segment and its payload length memory allocated */ void <API key>(uint64_t size) { (void) SC_ATOMIC_ADD(ra_memuse, size); return; } /** * \brief Function to Decrease the memory usage counter for the TCP reassembly * segments * * \param size Size of the TCP segment and its payload length memory allocated */ void <API key>(uint64_t size) { (void) SC_ATOMIC_SUB(ra_memuse, size); return; } void <API key>(ThreadVars *tv, <API key> *rtv) { uint64_t smemuse = SC_ATOMIC_GET(ra_memuse); if (tv != NULL && rtv != NULL) <API key>(rtv-><API key>, tv->sc_perf_pca, smemuse); return; } /** * \brief Function to Check the reassembly memory usage counter against the * allowed max memory usgae for TCP segments. * * \param size Size of the TCP segment and its payload length memory allocated * \retval 1 if in bounds * \retval 0 if not in bounds */ int <API key>(uint32_t size) { if (stream_config.reassembly_memcap == 0 || (uint64_t)((uint64_t)size + SC_ATOMIC_GET(ra_memuse)) <= stream_config.reassembly_memcap) return 1; return 0; } /** \brief alloc a tcp segment pool entry */ void *TcpSegmentPoolAlloc() { if (<API key>((uint32_t)sizeof(TcpSegment)) == 0) { return NULL; } TcpSegment *seg = NULL; seg = SCMalloc(sizeof (TcpSegment)); if (unlikely(seg == NULL)) return NULL; return seg; } int TcpSegmentPoolInit(void *data, void *payload_len) { TcpSegment *seg = (TcpSegment *) data; uint16_t size = *((uint16_t *) payload_len); /* do this before the can bail, so <API key> * won't have uninitialized memory to consider. */ memset(seg, 0, sizeof (TcpSegment)); if (<API key>((uint32_t)size + (uint32_t)sizeof(TcpSegment)) == 0) { return 0; } seg->pool_size = size; seg->payload_len = seg->pool_size; seg->payload = SCMalloc(seg->payload_len); if (seg->payload == NULL) { return 0; } #ifdef DEBUG SCMutexLock(&<API key>); segment_pool_memuse += seg->payload_len; segment_pool_memcnt++; SCLogDebug("segment_pool_memcnt %"PRIu64"", segment_pool_memcnt); SCMutexUnlock(&<API key>); #endif <API key>((uint32_t)seg->pool_size + sizeof(TcpSegment)); return 1; } /** \brief clean up a tcp segment pool entry */ void <API key>(void *ptr) { if (ptr == NULL) return; TcpSegment *seg = (TcpSegment *) ptr; <API key>((uint32_t)seg->pool_size + sizeof(TcpSegment)); #ifdef DEBUG SCMutexLock(&<API key>); segment_pool_memuse -= seg->pool_size; segment_pool_memcnt SCLogDebug("segment_pool_memcnt %"PRIu64"", segment_pool_memcnt); SCMutexUnlock(&<API key>); #endif SCFree(seg->payload); return; } /** * \brief Function to return the segment back to the pool. * * \param seg Segment which will be returned back to the pool. */ void <API key>(TcpSegment *seg) { if (seg == NULL) return; seg->next = NULL; seg->prev = NULL; uint16_t idx = segment_pool_idx[seg->pool_size]; SCMutexLock(&segment_pool_mutex[idx]); PoolReturn(segment_pool[idx], (void *) seg); SCLogDebug("segment_pool[%"PRIu16"]->empty_stack_size %"PRIu32"", idx,segment_pool[idx]->empty_stack_size); SCMutexUnlock(&segment_pool_mutex[idx]); #ifdef DEBUG SCMutexLock(&<API key>); segment_pool_cnt SCMutexUnlock(&<API key>); #endif } /** * \brief return all segments in this stream into the pool(s) * * \param stream the stream to cleanup */ void <API key> (TcpStream *stream) { TcpSegment *seg = stream->seg_list; TcpSegment *next_seg; if (seg == NULL) return; while (seg != NULL) { next_seg = seg->next; <API key>(seg); seg = next_seg; } stream->seg_list = NULL; stream->seg_list_tail = NULL; } typedef struct SegmentSizes_ { uint16_t pktsize; uint32_t prealloc; } SegmentSizes; /* sort small to big */ static int SortByPktsize(const void *a, const void *b) { const SegmentSizes *s0 = a; const SegmentSizes *s1 = b; return s0->pktsize - s1->pktsize; } int <API key>(char quiet) { Pool **my_segment_pool = NULL; SCMutex *my_segment_lock = NULL; uint16_t *my_segment_pktsizes = NULL; SegmentSizes sizes[256]; memset(&sizes, 0x00, sizeof(sizes)); int npools = 0; ConfNode *segs = ConfGetNode("stream.reassembly.segments"); if (segs != NULL) { ConfNode *seg; TAILQ_FOREACH(seg, &segs->head, next) { ConfNode *segsize = ConfNodeLookupChild(seg,"size"); if (segsize == NULL) continue; ConfNode *segpre = ConfNodeLookupChild(seg,"prealloc"); if (segpre == NULL) continue; if (npools >= 256) { SCLogError(<API key>, "too many segment packet " "pools defined, max is 256"); return -1; } SCLogDebug("segsize->val %s", segsize->val); SCLogDebug("segpre->val %s", segpre->val); uint16_t pktsize = 0; if (<API key>(&pktsize, 10, strlen(segsize->val), segsize->val) == -1) { SCLogError(<API key>, "segment packet size " "of %s is invalid", segsize->val); return -1; } uint32_t prealloc = 0; if (<API key>(&prealloc, 10, strlen(segpre->val), segpre->val) == -1) { SCLogError(<API key>, "segment prealloc of " "%s is invalid", segpre->val); return -1; } sizes[npools].pktsize = pktsize; sizes[npools].prealloc = prealloc; SCLogDebug("pktsize %u, prealloc %u", sizes[npools].pktsize, sizes[npools].prealloc); npools++; } } SCLogDebug("npools %d", npools); if (npools > 0) { /* sort the array as the index code below relies on it */ qsort(&sizes, npools, sizeof(sizes[0]), SortByPktsize); if (sizes[npools - 1].pktsize != 0xffff) { sizes[npools].pktsize = 0xffff; sizes[npools].prealloc = 8; npools++; SCLogInfo("appended a segment pool for pktsize 65536"); } } else if (npools == 0) { /* defaults */ sizes[0].pktsize = 4; sizes[0].prealloc = 256; sizes[1].pktsize = 16; sizes[1].prealloc = 512; sizes[2].pktsize = 112; sizes[2].prealloc = 512; sizes[3].pktsize = 248; sizes[3].prealloc = 512; sizes[4].pktsize = 512; sizes[4].prealloc = 512; sizes[5].pktsize = 768; sizes[5].prealloc = 1024; sizes[6].pktsize = 1448; sizes[6].prealloc = 1024; sizes[7].pktsize = 0xffff; sizes[7].prealloc = 128; npools = 8; } int i = 0; for (i = 0; i < npools; i++) { SCLogDebug("pktsize %u, prealloc %u", sizes[i].pktsize, sizes[i].prealloc); } my_segment_pool = SCMalloc(npools * sizeof(Pool *)); if (my_segment_pool == NULL) { SCLogError(SC_ERR_MEM_ALLOC, "malloc failed"); return -1; } my_segment_lock = SCMalloc(npools * sizeof(SCMutex)); if (my_segment_lock == NULL) { SCLogError(SC_ERR_MEM_ALLOC, "malloc failed"); SCFree(my_segment_pool); return -1; } my_segment_pktsizes = SCMalloc(npools * sizeof(uint16_t)); if (my_segment_pktsizes == NULL) { SCLogError(SC_ERR_MEM_ALLOC, "malloc failed"); SCFree(my_segment_lock); SCFree(my_segment_pool); return -1; } uint32_t <API key>[npools]; for (i = 0; i < npools; i++) { my_segment_pktsizes[i] = sizes[i].pktsize; <API key>[i] = sizes[i].prealloc; SCMutexInit(&my_segment_lock[i], NULL); /* setup the pool */ SCMutexLock(&my_segment_lock[i]); my_segment_pool[i] = PoolInit(0, <API key>[i], 0, TcpSegmentPoolAlloc, TcpSegmentPoolInit, (void *) &my_segment_pktsizes[i], <API key>, NULL); SCMutexUnlock(&my_segment_lock[i]); if (my_segment_pool[i] == NULL) { SCLogError(<API key>, "couldn't set up segment pool " "for packet size %u. Memcap too low?", my_segment_pktsizes[i]); exit(EXIT_FAILURE); } SCLogDebug("my_segment_pktsizes[i] %u, <API key>[i] %u", my_segment_pktsizes[i], <API key>[i]); if (!quiet) SCLogInfo("segment pool: pktsize %u, prealloc %u", my_segment_pktsizes[i], <API key>[i]); } uint16_t idx = 0; uint16_t u16 = 0; while (1) { if (idx <= my_segment_pktsizes[u16]) { segment_pool_idx[idx] = u16; if (my_segment_pktsizes[u16] == idx) u16++; } if (idx == 0xffff) break; idx++; } /* set the globals */ segment_pool = my_segment_pool; segment_pool_mutex = my_segment_lock; <API key> = my_segment_pktsizes; segment_pool_num = npools; uint32_t <API key> = 250; ConfNode *chunk = ConfGetNode("stream.reassembly.chunk-prealloc"); if (chunk) { uint32_t prealloc = 0; if (<API key>(&prealloc, 10, strlen(chunk->val), chunk->val) == -1) { SCLogError(<API key>, "chunk-prealloc of " "%s is invalid", chunk->val); return -1; } <API key> = prealloc; } if (!quiet) SCLogInfo("stream.reassembly \"chunk-prealloc\": %u", <API key>); StreamMsgQueuesInit(<API key>); intmax_t zero_copy_size = 128; if (ConfGetInt("stream.reassembly.zero-copy-size", &zero_copy_size) == 1) { if (zero_copy_size < 0 || zero_copy_size > 0xffff) { SCLogError(<API key>, "stream.reassembly.zero-copy-size of " "%"PRIiMAX" is invalid: valid values are 0 to 65535", zero_copy_size); return -1; } } stream_config.zero_copy_size = (uint16_t)zero_copy_size; if (!quiet) SCLogInfo("stream.reassembly \"zero-copy-size\": %u", stream_config.zero_copy_size); return 0; } int <API key>(char quiet) { /* init the memcap/use tracker */ SC_ATOMIC_INIT(ra_memuse); if (<API key>(quiet) < 0) return -1; #ifdef DEBUG SCMutexInit(&<API key>, NULL); SCMutexInit(&<API key>, NULL); #endif return 0; } #ifdef DEBUG static uint32_t dbg_app_layer_gap; static uint32_t <API key>; #endif void <API key>(char quiet) { uint16_t u16 = 0; for (u16 = 0; u16 < segment_pool_num; u16++) { SCMutexLock(&segment_pool_mutex[u16]); if (quiet == FALSE) { PoolPrintSaturation(segment_pool[u16]); SCLogDebug("segment_pool[u16]->empty_stack_size %"PRIu32", " "segment_pool[u16]->alloc_stack_size %"PRIu32", alloced " "%"PRIu32"", segment_pool[u16]->empty_stack_size, segment_pool[u16]->alloc_stack_size, segment_pool[u16]->allocated); if (segment_pool[u16]->max_outstanding > segment_pool[u16]->allocated) { SCLogInfo("TCP segment pool of size %u had a peak use of %u segments, " "more than the prealloc setting of %u", <API key>[u16], segment_pool[u16]->max_outstanding, segment_pool[u16]->allocated); } } PoolFree(segment_pool[u16]); SCMutexUnlock(&segment_pool_mutex[u16]); SCMutexDestroy(&segment_pool_mutex[u16]); } SCFree(segment_pool); SCFree(segment_pool_mutex); SCFree(<API key>); segment_pool = NULL; segment_pool_mutex = NULL; <API key> = NULL; <API key>(quiet); #ifdef DEBUG SCLogDebug("segment_pool_cnt %"PRIu64"", segment_pool_cnt); SCLogDebug("segment_pool_memuse %"PRIu64"", segment_pool_memuse); SCLogDebug("segment_pool_memcnt %"PRIu64"", segment_pool_memcnt); SCMutexDestroy(&<API key>); SCMutexDestroy(&<API key>); SCLogInfo("dbg_app_layer_gap %u", dbg_app_layer_gap); SCLogInfo("<API key> %u", <API key>); #endif } <API key> *<API key>(ThreadVars *tv) { SCEnter(); <API key> *ra_ctx = SCMalloc(sizeof(<API key>)); if (unlikely(ra_ctx == NULL)) return NULL; memset(ra_ctx, 0x00, sizeof(<API key>)); ra_ctx->app_tctx = <API key>(tv); SCReturnPtr(ra_ctx, "<API key>"); } void <API key>(<API key> *ra_ctx) { SCEnter(); <API key>(ra_ctx->app_tctx); #ifdef DEBUG SCLogDebug("reassembly fast path stats: fp1 %"PRIu64" fp2 %"PRIu64" sp %"PRIu64, ra_ctx->fp1, ra_ctx->fp2, ra_ctx->sp); #endif SCFree(ra_ctx); SCReturn; } void PrintList2(TcpSegment *seg) { TcpSegment *prev_seg = NULL; if (seg == NULL) return; uint32_t next_seq = seg->seq; while (seg != NULL) { if (SEQ_LT(next_seq,seg->seq)) { SCLogDebug("missing segment(s) for %" PRIu32 " bytes of data", (seg->seq - next_seq)); } SCLogDebug("seg %10"PRIu32" len %" PRIu16 ", seg %p, prev %p, next %p", seg->seq, seg->payload_len, seg, seg->prev, seg->next); if (seg->prev != NULL && SEQ_LT(seg->seq,seg->prev->seq)) { /* check for SEQ_LT cornercase where a - b is exactly 2147483648, * which makes the marco return TRUE in both directions. This is * a hack though, we're going to check next how we end up with * a segment list with seq differences that big */ if (!(SEQ_LT(seg->prev->seq,seg->seq))) { SCLogDebug("inconsistent list: SEQ_LT(seg->seq,seg->prev->seq)) ==" " TRUE, seg->seq %" PRIu32 ", seg->prev->seq %" PRIu32 "" "", seg->seq, seg->prev->seq); } } if (SEQ_LT(seg->seq,next_seq)) { SCLogDebug("inconsistent list: SEQ_LT(seg->seq,next_seq)) == TRUE, " "seg->seq %" PRIu32 ", next_seq %" PRIu32 "", seg->seq, next_seq); } if (prev_seg != seg->prev) { SCLogDebug("inconsistent list: prev_seg %p != seg->prev %p", prev_seg, seg->prev); } next_seq = seg->seq + seg->payload_len; SCLogDebug("next_seq is now %"PRIu32"", next_seq); prev_seg = seg; seg = seg->next; } } void PrintList(TcpSegment *seg) { TcpSegment *prev_seg = NULL; TcpSegment *head_seg = seg; if (seg == NULL) return; uint32_t next_seq = seg->seq; while (seg != NULL) { if (SEQ_LT(next_seq,seg->seq)) { SCLogDebug("missing segment(s) for %" PRIu32 " bytes of data", (seg->seq - next_seq)); } SCLogDebug("seg %10"PRIu32" len %" PRIu16 ", seg %p, prev %p, next %p, flags 0x%02x", seg->seq, seg->payload_len, seg, seg->prev, seg->next, seg->flags); if (seg->prev != NULL && SEQ_LT(seg->seq,seg->prev->seq)) { /* check for SEQ_LT cornercase where a - b is exactly 2147483648, * which makes the marco return TRUE in both directions. This is * a hack though, we're going to check next how we end up with * a segment list with seq differences that big */ if (!(SEQ_LT(seg->prev->seq,seg->seq))) { SCLogDebug("inconsistent list: SEQ_LT(seg->seq,seg->prev->seq)) == " "TRUE, seg->seq %" PRIu32 ", seg->prev->seq %" PRIu32 "", seg->seq, seg->prev->seq); PrintList2(head_seg); abort(); } } if (SEQ_LT(seg->seq,next_seq)) { SCLogDebug("inconsistent list: SEQ_LT(seg->seq,next_seq)) == TRUE, " "seg->seq %" PRIu32 ", next_seq %" PRIu32 "", seg->seq, next_seq); PrintList2(head_seg); abort(); } if (prev_seg != seg->prev) { SCLogDebug("inconsistent list: prev_seg %p != seg->prev %p", prev_seg, seg->prev); PrintList2(head_seg); abort(); } next_seq = seg->seq + seg->payload_len; SCLogDebug("next_seq is now %"PRIu32"", next_seq); prev_seg = seg; seg = seg->next; } } /** * \internal * \brief Get the active ra_base_seq, considering stream gaps * * \retval seq the active ra_base_seq */ static inline uint32_t <API key>(TcpStream *stream) { if (!(stream->flags & <API key>)) { SCReturnUInt(stream->ra_app_base_seq); } else { SCReturnUInt(stream->ra_raw_base_seq); } } /** * \internal * \brief Function to handle the insertion newly arrived segment, * The packet is handled based on its target OS. * * \param stream The given TCP stream to which this new segment belongs * \param seg Newly arrived segment * \param p received packet * * \retval 0 success * \retval -1 error -- either we hit a memory issue (OOM/memcap) or we received * a segment before ra_base_seq. */ int <API key>(ThreadVars *tv, <API key> *ra_ctx, TcpStream *stream, TcpSegment *seg, Packet *p) { SCEnter(); TcpSegment *list_seg = stream->seg_list; TcpSegment *next_list_seg = NULL; #if DEBUG PrintList(stream->seg_list); #endif int ret_value = 0; char return_seg = FALSE; /* before our ra_app_base_seq we don't insert it in our list, * or ra_raw_base_seq if in stream gap state */ if (SEQ_LT((TCP_GET_SEQ(p)+p->payload_len),(<API key>(stream)+1))) { SCLogDebug("not inserting: SEQ+payload %"PRIu32", last_ack %"PRIu32", " "ra_(app|raw)_base_seq %"PRIu32, (TCP_GET_SEQ(p)+p->payload_len), stream->last_ack, <API key>(stream)+1); return_seg = TRUE; ret_value = -1; StreamTcpSetEvent(p, <API key>); goto end; } SCLogDebug("SEQ %"PRIu32", SEQ+payload %"PRIu32", last_ack %"PRIu32", " "ra_app_base_seq %"PRIu32, TCP_GET_SEQ(p), (TCP_GET_SEQ(p)+p->payload_len), stream->last_ack, stream->ra_app_base_seq); if (seg == NULL) { goto end; } /* fast track */ if (list_seg == NULL) { SCLogDebug("empty list, inserting seg %p seq %" PRIu32 ", " "len %" PRIu32 "", seg, seg->seq, seg->payload_len); stream->seg_list = seg; seg->prev = NULL; stream->seg_list_tail = seg; goto end; } /* insert the segment in the stream list using this fast track, if seg->seq is equal or higher than stream->seg_list_tail.*/ if (SEQ_GEQ(seg->seq, (stream->seg_list_tail->seq + stream->seg_list_tail->payload_len))) { stream->seg_list_tail->next = seg; seg->prev = stream->seg_list_tail; stream->seg_list_tail = seg; goto end; } /* If the OS policy is not set then set the OS policy for this stream */ if (stream->os_policy == 0) { <API key>(stream, p); } for (; list_seg != NULL; list_seg = next_list_seg) { next_list_seg = list_seg->next; SCLogDebug("seg %p, list_seg %p, list_prev %p list_seg->next %p, " "segment length %" PRIu32 "", seg, list_seg, list_seg->prev, list_seg->next, seg->payload_len); SCLogDebug("seg->seq %"PRIu32", list_seg->seq %"PRIu32"", seg->seq, list_seg->seq); /* segment starts before list */ if (SEQ_LT(seg->seq, list_seg->seq)) { /* seg is entirely before list_seg */ if (SEQ_LEQ((seg->seq + seg->payload_len), list_seg->seq)) { SCLogDebug("before list seg: seg->seq %" PRIu32 ", list_seg->seq" " %" PRIu32 ", list_seg->payload_len %" PRIu32 ", " "list_seg->prev %p", seg->seq, list_seg->seq, list_seg->payload_len, list_seg->prev); seg->next = list_seg; if (list_seg->prev == NULL) { stream->seg_list = seg; } if (list_seg->prev != NULL) { list_seg->prev->next = seg; seg->prev = list_seg->prev; } list_seg->prev = seg; goto end; /* seg overlap with next seg(s) */ } else { ret_value = <API key>(tv, ra_ctx, stream, list_seg, seg, p); if (ret_value == 1) { ret_value = 0; return_seg = TRUE; goto end; } else if (ret_value == -1) { SCLogDebug("<API key> failed"); ret_value = -1; return_seg = TRUE; goto end; } } /* seg starts at same sequence number as list_seg */ } else if (SEQ_EQ(seg->seq, list_seg->seq)) { ret_value = <API key>(tv, ra_ctx, stream, list_seg, seg, p); if (ret_value == 1) { ret_value = 0; return_seg = TRUE; goto end; } else if (ret_value == -1) { SCLogDebug("<API key> failed"); ret_value = -1; return_seg = TRUE; goto end; } /* seg starts at sequence number higher than list_seg */ } else if (SEQ_GT(seg->seq, list_seg->seq)) { if (((SEQ_GEQ(seg->seq, (list_seg->seq + list_seg->payload_len)))) && SEQ_GT((seg->seq + seg->payload_len), (list_seg->seq + list_seg->payload_len))) { SCLogDebug("starts beyond list end, ends after list end: " "seg->seq %" PRIu32 ", list_seg->seq %" PRIu32 ", " "list_seg->payload_len %" PRIu32 " (%" PRIu32 ")", seg->seq, list_seg->seq, list_seg->payload_len, list_seg->seq + list_seg->payload_len); if (list_seg->next == NULL) { list_seg->next = seg; seg->prev = list_seg; stream->seg_list_tail = seg; goto end; } } else { ret_value = <API key>(tv, ra_ctx, stream, list_seg, seg, p); if (ret_value == 1) { ret_value = 0; return_seg = TRUE; goto end; } else if (ret_value == -1) { SCLogDebug("<API key> failed"); ret_value = -1; return_seg = TRUE; goto end; } } } } end: if (return_seg == TRUE && seg != NULL) { <API key>(seg); } #ifdef DEBUG PrintList(stream->seg_list); #endif SCReturnInt(ret_value); } /** * \brief Function to handle the newly arrived segment, when newly arrived * starts with the sequence number lower than the original segment and * ends at different position relative to original segment. * The packet is handled based on its target OS. * * \param list_seg Original Segment in the stream * \param seg Newly arrived segment * \param prev_seg Previous segment in the stream segment list * \param p Packet * * \retval 1 success and done * \retval 0 success, but not done yet * \retval -1 error, will *only* happen on memory errors */ static int <API key>(ThreadVars *tv, <API key> *ra_ctx, TcpStream *stream, TcpSegment *list_seg, TcpSegment *seg, Packet *p) { SCEnter(); uint16_t overlap = 0; uint16_t packet_length = 0; uint32_t overlap_point = 0; char end_before = FALSE; char end_after = FALSE; char end_same = FALSE; char return_after = FALSE; uint8_t os_policy = stream->os_policy; #ifdef DEBUG SCLogDebug("seg->seq %" PRIu32 ", seg->payload_len %" PRIu32 "", seg->seq, seg->payload_len); PrintList(stream->seg_list); #endif if (SEQ_GT((seg->seq + seg->payload_len), list_seg->seq) && SEQ_LT((seg->seq + seg->payload_len),(list_seg->seq + list_seg->payload_len))) { /* seg starts before list seg, ends beyond it but before list end */ end_before = TRUE; /* [aaaa[abab]bbbb] a = seg, b = list_seg, overlap is the part [abab] * We know seg->seq + seg->payload_len is bigger than list_seg->seq */ overlap = (seg->seq + seg->payload_len) - list_seg->seq; overlap_point = list_seg->seq; SCLogDebug("starts before list seg, ends before list end: seg->seq " "%" PRIu32 ", list_seg->seq %" PRIu32 ", " "list_seg->payload_len %" PRIu16 " overlap is %" PRIu32 ", " "overlap point %"PRIu32"", seg->seq, list_seg->seq, list_seg->payload_len, overlap, overlap_point); } else if (SEQ_EQ((seg->seq + seg->payload_len), (list_seg->seq + list_seg->payload_len))) { /* seg fully overlaps list_seg, starts before, at end point * [aaa[ababab]] where a = seg, b = list_seg * overlap is [ababab], which is list_seg->payload_len */ overlap = list_seg->payload_len; end_same = TRUE; overlap_point = list_seg->seq; SCLogDebug("starts before list seg, ends at list end: list prev %p" "seg->seq %" PRIu32 ", list_seg->seq %" PRIu32 "," "list_seg->payload_len %" PRIu32 " overlap is %" PRIu32 "", list_seg->prev, seg->seq, list_seg->seq, list_seg->payload_len, overlap); /* seg fully overlaps list_seg, starts before, ends after list endpoint */ } else if (SEQ_GT((seg->seq + seg->payload_len), (list_seg->seq + list_seg->payload_len))) { /* seg fully overlaps list_seg, starts before, ends after list endpoint * [aaa[ababab]aaa] where a = seg, b = list_seg * overlap is [ababab] which is list_seg->payload_len */ overlap = list_seg->payload_len; end_after = TRUE; overlap_point = list_seg->seq; SCLogDebug("starts before list seg, ends after list end: seg->seq " "%" PRIu32 ", seg->payload_len %"PRIu32" list_seg->seq " "%" PRIu32 ", list_seg->payload_len %" PRIu32 " overlap is" " %" PRIu32 "", seg->seq, seg->payload_len, list_seg->seq, list_seg->payload_len, overlap); } if (overlap > 0) { /* handle the case where we need to fill a gap before list_seg first */ if (list_seg->prev != NULL && SEQ_LT((list_seg->prev->seq + list_seg->prev->payload_len), list_seg->seq)) { SCLogDebug("GAP to fill before list segment, size %u", list_seg->seq - (list_seg->prev->seq + list_seg->prev->payload_len)); uint32_t new_seq = (list_seg->prev->seq + list_seg->prev->payload_len); if (SEQ_GT(seg->seq, new_seq)) { new_seq = seg->seq; } packet_length = list_seg->seq - new_seq; if (packet_length > seg->payload_len) { packet_length = seg->payload_len; } TcpSegment *new_seg = StreamTcpGetSegment(tv, ra_ctx, packet_length); if (new_seg == NULL) { SCLogDebug("segment_pool[%"PRIu16"] is empty", segment_pool_idx[packet_length]); StreamTcpSetEvent(p, <API key>); SCReturnInt(-1); } new_seg->payload_len = packet_length; new_seg->seq = new_seq; SCLogDebug("new_seg->seq %"PRIu32" and new->payload_len " "%" PRIu16"", new_seg->seq, new_seg->payload_len); new_seg->next = list_seg; new_seg->prev = list_seg->prev; list_seg->prev->next = new_seg; list_seg->prev = new_seg; /* create a new seg, copy the list_seg data over */ <API key>(new_seg, seg); #ifdef DEBUG PrintList(stream->seg_list); #endif } /* Handling case when the segment starts before the first segment in * the list */ if (list_seg->prev == NULL) { if (end_after == TRUE && list_seg->next != NULL && SEQ_LT(list_seg->next->seq, (seg->seq + seg->payload_len))) { packet_length = (list_seg->seq - seg->seq) + list_seg->payload_len; } else { packet_length = seg->payload_len + (list_seg->payload_len - overlap); return_after = TRUE; } SCLogDebug("entered here packet_length %" PRIu32 ", seg->payload_len" " %" PRIu32 ", list->payload_len %" PRIu32 "", packet_length, seg->payload_len, list_seg->payload_len); TcpSegment *new_seg = StreamTcpGetSegment(tv, ra_ctx, packet_length); if (new_seg == NULL) { SCLogDebug("segment_pool[%"PRIu16"] is empty", segment_pool_idx[packet_length]); StreamTcpSetEvent(p, <API key>); SCReturnInt(-1); } new_seg->payload_len = packet_length; new_seg->seq = seg->seq; new_seg->next = list_seg->next; new_seg->prev = list_seg->prev; <API key>(new_seg, list_seg); /* first the data before the list_seg->seq */ uint16_t replace = (uint16_t) (list_seg->seq - seg->seq); SCLogDebug("copying %"PRIu16" bytes to new_seg", replace); <API key>(new_seg, seg, seg->seq, replace); /* if any, data after list_seg->seq + list_seg->payload_len */ if (SEQ_GT((seg->seq + seg->payload_len), (list_seg->seq + list_seg->payload_len)) && return_after == TRUE) { replace = (uint16_t)(((seg->seq + seg->payload_len) - (list_seg->seq + list_seg->payload_len))); SCLogDebug("replacing %"PRIu16"", replace); <API key>(new_seg, seg, (list_seg->seq + list_seg->payload_len), replace); } /* update the stream last_seg in case of removal of list_seg */ if (stream->seg_list_tail == list_seg) stream->seg_list_tail = new_seg; <API key>(list_seg); list_seg = new_seg; if (new_seg->prev != NULL) { new_seg->prev->next = new_seg; } if (new_seg->next != NULL) { new_seg->next->prev = new_seg; } stream->seg_list = new_seg; SCLogDebug("list_seg now %p, stream->seg_list now %p", list_seg, stream->seg_list); } else if (end_before == TRUE || end_same == TRUE) { /* Handling overlapping with more than one segment and filling gap */ if (SEQ_GT(list_seg->seq, (list_seg->prev->seq + list_seg->prev->payload_len))) { SCLogDebug("list_seg->prev %p list_seg->prev->seq %"PRIu32" " "list_seg->prev->payload_len %"PRIu16"", list_seg->prev, list_seg->prev->seq, list_seg->prev->payload_len); if (SEQ_LT(list_seg->prev->seq, seg->seq)) { packet_length = list_seg->payload_len + (list_seg->seq - seg->seq); } else { packet_length = list_seg->payload_len + (list_seg->seq - (list_seg->prev->seq + list_seg->prev->payload_len)); } TcpSegment *new_seg = StreamTcpGetSegment(tv, ra_ctx, packet_length); if (new_seg == NULL) { SCLogDebug("segment_pool[%"PRIu16"] is empty", segment_pool_idx[packet_length]); StreamTcpSetEvent(p, <API key>); SCReturnInt(-1); } new_seg->payload_len = packet_length; if (SEQ_GT((list_seg->prev->seq + list_seg->prev->payload_len), seg->seq)) { new_seg->seq = (list_seg->prev->seq + list_seg->prev->payload_len); } else { new_seg->seq = seg->seq; } SCLogDebug("new_seg->seq %"PRIu32" and new->payload_len " "%" PRIu16"", new_seg->seq, new_seg->payload_len); new_seg->next = list_seg->next; new_seg->prev = list_seg->prev; <API key>(new_seg, list_seg); uint16_t copy_len = (uint16_t) (list_seg->seq - seg->seq); SCLogDebug("copy_len %" PRIu32 " (%" PRIu32 " - %" PRIu32 ")", copy_len, list_seg->seq, seg->seq); <API key>(new_seg, seg, seg->seq, copy_len); /*update the stream last_seg in case of removal of list_seg*/ if (stream->seg_list_tail == list_seg) stream->seg_list_tail = new_seg; <API key>(list_seg); list_seg = new_seg; if (new_seg->prev != NULL) { new_seg->prev->next = new_seg; } if (new_seg->next != NULL) { new_seg->next->prev = new_seg; } } } else if (end_after == TRUE) { if (list_seg->next != NULL) { if (SEQ_LEQ((seg->seq + seg->payload_len), list_seg->next->seq)) { if (SEQ_GT(seg->seq, (list_seg->prev->seq + list_seg->prev->payload_len))) { packet_length = list_seg->payload_len + (list_seg->seq - seg->seq); } else { packet_length = list_seg->payload_len + (list_seg->seq - (list_seg->prev->seq + list_seg->prev->payload_len)); } packet_length += (seg->seq + seg->payload_len) - (list_seg->seq + list_seg->payload_len); TcpSegment *new_seg = StreamTcpGetSegment(tv, ra_ctx, packet_length); if (new_seg == NULL) { SCLogDebug("segment_pool[%"PRIu16"] is empty", segment_pool_idx[packet_length]); StreamTcpSetEvent(p, <API key>); SCReturnInt(-1); } new_seg->payload_len = packet_length; if (SEQ_GT((list_seg->prev->seq + list_seg->prev->payload_len), seg->seq)) { new_seg->seq = (list_seg->prev->seq + list_seg->prev->payload_len); } else { new_seg->seq = seg->seq; } SCLogDebug("new_seg->seq %"PRIu32" and new->payload_len " "%" PRIu16"", new_seg->seq, new_seg->payload_len); new_seg->next = list_seg->next; new_seg->prev = list_seg->prev; /* create a new seg, copy the list_seg data over */ <API key>(new_seg, list_seg); /* copy the part before list_seg */ uint16_t copy_len = list_seg->seq - new_seg->seq; <API key>(new_seg, seg, new_seg->seq, copy_len); /* copy the part after list_seg */ copy_len = (seg->seq + seg->payload_len) - (list_seg->seq + list_seg->payload_len); <API key>(new_seg, seg, (list_seg->seq + list_seg->payload_len), copy_len); if (new_seg->prev != NULL) { new_seg->prev->next = new_seg; } if (new_seg->next != NULL) { new_seg->next->prev = new_seg; } /*update the stream last_seg in case of removal of list_seg*/ if (stream->seg_list_tail == list_seg) stream->seg_list_tail = new_seg; <API key>(list_seg); list_seg = new_seg; return_after = TRUE; } /* Handle the case, when list_seg is the end of segment list, but seg is ending after the list_seg. So we need to copy the data from newly received segment. After copying return the newly received seg to pool */ } else { if (SEQ_GT(seg->seq, (list_seg->prev->seq + list_seg->prev->payload_len))) { packet_length = list_seg->payload_len + (list_seg->seq - seg->seq); } else { packet_length = list_seg->payload_len + (list_seg->seq - (list_seg->prev->seq + list_seg->prev->payload_len)); } packet_length += (seg->seq + seg->payload_len) - (list_seg->seq + list_seg->payload_len); TcpSegment *new_seg = StreamTcpGetSegment(tv, ra_ctx, packet_length); if (new_seg == NULL) { SCLogDebug("segment_pool[%"PRIu16"] is empty", segment_pool_idx[packet_length]); StreamTcpSetEvent(p, <API key>); SCReturnInt(-1); } new_seg->payload_len = packet_length; if (SEQ_GT((list_seg->prev->seq + list_seg->prev->payload_len), seg->seq)) { new_seg->seq = (list_seg->prev->seq + list_seg->prev->payload_len); } else { new_seg->seq = seg->seq; } SCLogDebug("new_seg->seq %"PRIu32" and new->payload_len " "%" PRIu16"", new_seg->seq, new_seg->payload_len); new_seg->next = list_seg->next; new_seg->prev = list_seg->prev; /* create a new seg, copy the list_seg data over */ <API key>(new_seg, list_seg); /* copy the part before list_seg */ uint16_t copy_len = list_seg->seq - new_seg->seq; <API key>(new_seg, seg, new_seg->seq, copy_len); /* copy the part after list_seg */ copy_len = (seg->seq + seg->payload_len) - (list_seg->seq + list_seg->payload_len); <API key>(new_seg, seg, (list_seg->seq + list_seg->payload_len), copy_len); if (new_seg->prev != NULL) { new_seg->prev->next = new_seg; } /*update the stream last_seg in case of removal of list_seg*/ if (stream->seg_list_tail == list_seg) stream->seg_list_tail = new_seg; <API key>(list_seg); list_seg = new_seg; return_after = TRUE; } } if (<API key> && !<API key>(seg, list_seg, list_seg->seq, overlap)) { /* interesting, overlap with different data */ StreamTcpSetEvent(p, <API key>); } if (StreamTcpInlineMode()) { if (<API key>(seg, list_seg) != 0) { <API key>(p, list_seg); } } else { switch (os_policy) { case OS_POLICY_SOLARIS: case OS_POLICY_HPUX11: if (end_after == TRUE || end_same == TRUE) { <API key>(list_seg, seg, overlap_point, overlap); } else { SCLogDebug("using old data in starts before list case, " "list_seg->seq %" PRIu32 " policy %" PRIu32 " " "overlap %" PRIu32 "", list_seg->seq, os_policy, overlap); } break; case OS_POLICY_VISTA: case OS_POLICY_FIRST: SCLogDebug("using old data in starts before list case, " "list_seg->seq %" PRIu32 " policy %" PRIu32 " " "overlap %" PRIu32 "", list_seg->seq, os_policy, overlap); break; case OS_POLICY_BSD: case OS_POLICY_HPUX10: case OS_POLICY_IRIX: case OS_POLICY_WINDOWS: case <API key>: case OS_POLICY_OLD_LINUX: case OS_POLICY_LINUX: case OS_POLICY_MACOS: case OS_POLICY_LAST: default: SCLogDebug("replacing old data in starts before list seg " "list_seg->seq %" PRIu32 " policy %" PRIu32 " " "overlap %" PRIu32 "", list_seg->seq, os_policy, overlap); <API key>(list_seg, seg, overlap_point, overlap); break; } } /* To return from for loop as seg is finished with current list_seg no need to check further (improve performance) */ if (end_before == TRUE || end_same == TRUE || return_after == TRUE) { SCReturnInt(1); } } SCReturnInt(0); } /** * \brief Function to handle the newly arrived segment, when newly arrived * starts with the same sequence number as the original segment and * ends at different position relative to original segment. * The packet is handled based on its target OS. * * \param list_seg Original Segment in the stream * \param seg Newly arrived segment * \param prev_seg Previous segment in the stream segment list * * \retval 1 success and done * \retval 0 success, but not done yet * \retval -1 error, will *only* happen on memory errors */ static int <API key>(ThreadVars *tv, <API key> *ra_ctx, TcpStream *stream, TcpSegment *list_seg, TcpSegment *seg, Packet *p) { uint16_t overlap = 0; uint16_t packet_length; char end_before = FALSE; char end_after = FALSE; char end_same = FALSE; char handle_beyond = FALSE; uint8_t os_policy = stream->os_policy; if (SEQ_LT((seg->seq + seg->payload_len), (list_seg->seq + list_seg->payload_len))) { /* seg->seg == list_seg->seq and list_seg->payload_len > seg->payload_len * [[ababab]bbbb] where a = seg, b = list_seg * overlap is the [ababab] part, which equals seg->payload_len. */ overlap = seg->payload_len; end_before = TRUE; SCLogDebug("starts at list seq, ends before list end: seg->seq " "%" PRIu32 ", list_seg->seq %" PRIu32 ", " "list_seg->payload_len %" PRIu32 " overlap is %" PRIu32, seg->seq, list_seg->seq, list_seg->payload_len, overlap); } else if (SEQ_EQ((seg->seq + seg->payload_len), (list_seg->seq + list_seg->payload_len))) { /* seg starts at seq, ends at seq, retransmission. * both segments are the same, so overlap is either * seg->payload_len or list_seg->payload_len */ /* check csum, ack, other differences? */ overlap = seg->payload_len; end_same = TRUE; SCLogDebug("(retransmission) starts at list seq, ends at list end: " "seg->seq %" PRIu32 ", list_seg->seq %" PRIu32 ", " "list_seg->payload_len %" PRIu32 " overlap is %"PRIu32"", seg->seq, list_seg->seq, list_seg->payload_len, overlap); } else if (SEQ_GT((seg->seq + seg->payload_len), (list_seg->seq + list_seg->payload_len))) { /* seg starts at seq, ends beyond seq. */ /* seg->seg == list_seg->seq and seg->payload_len > list_seg->payload_len * [[ababab]aaaa] where a = seg, b = list_seg * overlap is the [ababab] part, which equals list_seg->payload_len. */ overlap = list_seg->payload_len; end_after = TRUE; SCLogDebug("starts at list seq, ends beyond list end: seg->seq " "%" PRIu32 ", list_seg->seq %" PRIu32 ", " "list_seg->payload_len %" PRIu32 " overlap is %" PRIu32 "", seg->seq, list_seg->seq, list_seg->payload_len, overlap); } if (overlap > 0) { /*Handle the case when newly arrived segment ends after original segment and original segment is the last segment in the list or the next segment in the list starts after the end of new segment*/ if (end_after == TRUE) { char fill_gap = FALSE; if (list_seg->next != NULL) { /* first see if we have space left to fill up */ if (SEQ_LT((list_seg->seq + list_seg->payload_len), list_seg->next->seq)) { fill_gap = TRUE; } /* then see if we overlap (partly) with the next seg */ if (SEQ_GT((seg->seq + seg->payload_len), list_seg->next->seq)) { handle_beyond = TRUE; } /* Handle the case, when list_seg is the end of segment list, but seg is ending after the list_seg. So we need to copy the data from newly received segment. After copying return the newly received seg to pool */ } else { fill_gap = TRUE; } SCLogDebug("fill_gap %s, handle_beyond %s", fill_gap?"TRUE":"FALSE", handle_beyond?"TRUE":"FALSE"); if (fill_gap == TRUE) { /* if there is a gap after this list_seg we fill it now with a * new seg */ SCLogDebug("filling gap: list_seg->next->seq %"PRIu32"", list_seg->next?list_seg->next->seq:0); if (handle_beyond == TRUE) { packet_length = list_seg->next->seq - (list_seg->seq + list_seg->payload_len); } else { packet_length = seg->payload_len - list_seg->payload_len; } SCLogDebug("packet_length %"PRIu16"", packet_length); TcpSegment *new_seg = StreamTcpGetSegment(tv, ra_ctx, packet_length); if (new_seg == NULL) { SCLogDebug("egment_pool[%"PRIu16"] is empty", segment_pool_idx[packet_length]); StreamTcpSetEvent(p, <API key>); return -1; } new_seg->payload_len = packet_length; new_seg->seq = list_seg->seq + list_seg->payload_len; new_seg->next = list_seg->next; if (new_seg->next != NULL) new_seg->next->prev = new_seg; new_seg->prev = list_seg; list_seg->next = new_seg; SCLogDebug("new_seg %p, new_seg->next %p, new_seg->prev %p, " "list_seg->next %p", new_seg, new_seg->next, new_seg->prev, list_seg->next); <API key>(new_seg, seg, new_seg->seq, new_seg->payload_len); /*update the stream last_seg in case of removal of list_seg*/ if (stream->seg_list_tail == list_seg) stream->seg_list_tail = new_seg; } } if (<API key> && !<API key>(list_seg, seg, seg->seq, overlap)) { /* interesting, overlap with different data */ StreamTcpSetEvent(p, <API key>); } if (StreamTcpInlineMode()) { if (<API key>(list_seg, seg) != 0) { <API key>(p, list_seg); } } else { switch (os_policy) { case OS_POLICY_OLD_LINUX: case OS_POLICY_SOLARIS: case OS_POLICY_HPUX11: if (end_after == TRUE || end_same == TRUE) { <API key>(list_seg, seg, seg->seq, overlap); } else { SCLogDebug("using old data in starts at list case, " "list_seg->seq %" PRIu32 " policy %" PRIu32 " " "overlap %" PRIu32 "", list_seg->seq, os_policy, overlap); } break; case OS_POLICY_LAST: <API key>(list_seg, seg, seg->seq, overlap); break; case OS_POLICY_LINUX: if (end_after == TRUE) { <API key>(list_seg, seg, seg->seq, overlap); } else { SCLogDebug("using old data in starts at list case, " "list_seg->seq %" PRIu32 " policy %" PRIu32 " " "overlap %" PRIu32 "", list_seg->seq, os_policy, overlap); } break; case OS_POLICY_BSD: case OS_POLICY_HPUX10: case OS_POLICY_IRIX: case OS_POLICY_WINDOWS: case <API key>: case OS_POLICY_VISTA: case OS_POLICY_MACOS: case OS_POLICY_FIRST: default: SCLogDebug("using old data in starts at list case, list_seg->seq" " %" PRIu32 " policy %" PRIu32 " overlap %" PRIu32 "", list_seg->seq, os_policy, overlap); break; } } /* return 1 if we're done */ if (end_before == TRUE || end_same == TRUE || handle_beyond == FALSE) { return 1; } } return 0; } /** * \internal * \brief Function to handle the newly arrived segment, when newly arrived * starts with the sequence number higher than the original segment and * ends at different position relative to original segment. * The packet is handled based on its target OS. * * \param list_seg Original Segment in the stream * \param seg Newly arrived segment * \param prev_seg Previous segment in the stream segment list * \retval 1 success and done * \retval 0 success, but not done yet * \retval -1 error, will *only* happen on memory errors */ static int <API key>(ThreadVars *tv, <API key> *ra_ctx, TcpStream *stream, TcpSegment *list_seg, TcpSegment *seg, Packet *p) { SCEnter(); uint16_t overlap = 0; uint16_t packet_length; char end_before = FALSE; char end_after = FALSE; char end_same = FALSE; char handle_beyond = FALSE; uint8_t os_policy = stream->os_policy; if (SEQ_LT((seg->seq + seg->payload_len), (list_seg->seq + list_seg->payload_len))) { /* seg starts after list, ends before list end * [bbbb[ababab]bbbb] where a = seg, b = list_seg * overlap is the part [ababab] which is seg->payload_len */ overlap = seg->payload_len; end_before = TRUE; SCLogDebug("starts beyond list seq, ends before list end: seg->seq" " %" PRIu32 ", list_seg->seq %" PRIu32 ", list_seg->payload_len " "%" PRIu32 " overlap is %" PRIu32 "", seg->seq, list_seg->seq, list_seg->payload_len, overlap); } else if (SEQ_EQ((seg->seq + seg->payload_len), (list_seg->seq + list_seg->payload_len))) { /* seg starts after seq, before end, ends at seq * [bbbb[ababab]] where a = seg, b = list_seg * overlapping part is [ababab], thus seg->payload_len */ overlap = seg->payload_len; end_same = TRUE; SCLogDebug("starts beyond list seq, ends at list end: seg->seq" " %" PRIu32 ", list_seg->seq %" PRIu32 ", list_seg->payload_len " "%" PRIu32 " overlap is %" PRIu32 "", seg->seq, list_seg->seq, list_seg->payload_len, overlap); } else if (SEQ_LT(seg->seq, list_seg->seq + list_seg->payload_len) && SEQ_GT((seg->seq + seg->payload_len), (list_seg->seq + list_seg->payload_len))) { /* seg starts after seq, before end, ends beyond seq. * * [bbb[ababab]aaa] where a = seg, b = list_seg. * overlap is the [ababab] part, which can be get using: * (list_seg->seq + list_seg->payload_len) - seg->seg */ overlap = (list_seg->seq + list_seg->payload_len) - seg->seq; end_after = TRUE; SCLogDebug("starts beyond list seq, ends after list seq end: " "seg->seq %" PRIu32 ", seg->payload_len %"PRIu16" (%"PRIu32") " "list_seg->seq %" PRIu32 ", list_seg->payload_len %" PRIu32 " " "(%"PRIu32") overlap is %" PRIu32 "", seg->seq, seg->payload_len, seg->seq + seg->payload_len, list_seg->seq, list_seg->payload_len, list_seg->seq + list_seg->payload_len, overlap); } if (overlap > 0) { /*Handle the case when newly arrived segment ends after original segment and original segment is the last segment in the list*/ if (end_after == TRUE) { char fill_gap = FALSE; if (list_seg->next != NULL) { /* first see if we have space left to fill up */ if (SEQ_LT((list_seg->seq + list_seg->payload_len), list_seg->next->seq)) { fill_gap = TRUE; } /* then see if we overlap (partly) with the next seg */ if (SEQ_GT((seg->seq + seg->payload_len), list_seg->next->seq)) { handle_beyond = TRUE; } } else { fill_gap = TRUE; } SCLogDebug("fill_gap %s, handle_beyond %s", fill_gap?"TRUE":"FALSE", handle_beyond?"TRUE":"FALSE"); if (fill_gap == TRUE) { /* if there is a gap after this list_seg we fill it now with a * new seg */ if (list_seg->next != NULL) { SCLogDebug("filling gap: list_seg->next->seq %"PRIu32"", list_seg->next?list_seg->next->seq:0); packet_length = list_seg->next->seq - (list_seg->seq + list_seg->payload_len); } else { packet_length = seg->payload_len - overlap; } if (packet_length > (seg->payload_len - overlap)) { packet_length = seg->payload_len - overlap; } SCLogDebug("packet_length %"PRIu16"", packet_length); TcpSegment *new_seg = StreamTcpGetSegment(tv, ra_ctx, packet_length); if (new_seg == NULL) { SCLogDebug("segment_pool[%"PRIu16"] is empty", segment_pool_idx[packet_length]); StreamTcpSetEvent(p, <API key>); SCReturnInt(-1); } new_seg->payload_len = packet_length; new_seg->seq = list_seg->seq + list_seg->payload_len; new_seg->next = list_seg->next; if (new_seg->next != NULL) new_seg->next->prev = new_seg; new_seg->prev = list_seg; list_seg->next = new_seg; SCLogDebug("new_seg %p, new_seg->next %p, new_seg->prev %p, " "list_seg->next %p new_seg->seq %"PRIu32"", new_seg, new_seg->next, new_seg->prev, list_seg->next, new_seg->seq); <API key>(new_seg, seg, new_seg->seq, new_seg->payload_len); /* update the stream last_seg in case of removal of list_seg */ if (stream->seg_list_tail == list_seg) stream->seg_list_tail = new_seg; } } if (<API key> && !<API key>(list_seg, seg, seg->seq, overlap)) { /* interesting, overlap with different data */ StreamTcpSetEvent(p, <API key>); } if (StreamTcpInlineMode()) { if (<API key>(list_seg, seg) != 0) { <API key>(p, list_seg); } } else { switch (os_policy) { case OS_POLICY_SOLARIS: case OS_POLICY_HPUX11: if (end_after == TRUE) { <API key>(list_seg, seg, seg->seq, overlap); } else { SCLogDebug("using old data in starts beyond list case, " "list_seg->seq %" PRIu32 " policy %" PRIu32 " " "overlap %" PRIu32 "", list_seg->seq, os_policy, overlap); } break; case OS_POLICY_LAST: <API key>(list_seg, seg, seg->seq, overlap); break; case OS_POLICY_BSD: case OS_POLICY_HPUX10: case OS_POLICY_IRIX: case OS_POLICY_WINDOWS: case <API key>: case OS_POLICY_VISTA: case OS_POLICY_OLD_LINUX: case OS_POLICY_LINUX: case OS_POLICY_MACOS: case OS_POLICY_FIRST: default: /* DEFAULT POLICY */ SCLogDebug("using old data in starts beyond list case, " "list_seg->seq %" PRIu32 " policy %" PRIu32 " " "overlap %" PRIu32 "", list_seg->seq, os_policy, overlap); break; } } if (end_before == TRUE || end_same == TRUE || handle_beyond == FALSE) { SCReturnInt(1); } } SCReturnInt(0); } /** * \brief check if stream in pkt direction has depth reached * * \param p packet with *LOCKED* flow * * \retval 1 stream has depth reached * \retval 0 stream does not have depth reached */ int <API key>(Packet *p) { if (p->flow != NULL && p->flow->protoctx != NULL) { TcpSession *ssn = p->flow->protoctx; TcpStream *stream; if (p->flowflags & FLOW_PKT_TOSERVER) { stream = &ssn->client; } else { stream = &ssn->server; } return (stream->flags & <API key>) ? 1 : 0; } return 0; } /** * \internal * \brief Function to Check the reassembly depth valuer against the * allowed max depth of the stream reassmbly for TCP streams. * * \param stream stream direction * \param seq sequence number where "size" starts * \param size size of the segment that is added * * \retval size Part of the size that fits in the depth, 0 if none */ static uint32_t <API key>(TcpStream *stream, uint32_t seq, uint32_t size) { SCEnter(); /* if the configured depth value is 0, it means there is no limit on reassembly depth. Otherwise carry on my boy ;) */ if (stream_config.reassembly_depth == 0) { SCReturnUInt(size); } /* if the final flag is set, we're not accepting anymore */ if (stream->flags & <API key>) { SCReturnUInt(0); } /* if the ra_base_seq has moved passed the depth window we stop * checking and just reject the rest of the packets including * retransmissions. Saves us the hassle of dealing with sequence * wraps as well */ if (SEQ_GEQ((<API key>(stream)+1),(stream->isn + stream_config.reassembly_depth))) { stream->flags |= <API key>; SCReturnUInt(0); } SCLogDebug("full Depth not yet reached: %"PRIu32" <= %"PRIu32, (<API key>(stream)+1), (stream->isn + stream_config.reassembly_depth)); if (SEQ_GEQ(seq, stream->isn) && SEQ_LT(seq, (stream->isn + stream_config.reassembly_depth))) { /* packet (partly?) fits the depth window */ if (SEQ_LEQ((seq + size),(stream->isn + stream_config.reassembly_depth))) { /* complete fit */ SCReturnUInt(size); } else { /* partial fit, return only what fits */ uint32_t part = (stream->isn + stream_config.reassembly_depth) - seq; #if DEBUG BUG_ON(part > size); #else if (part > size) part = size; #endif SCReturnUInt(part); } } SCReturnUInt(0); } static void <API key>(TcpSession *ssn, StreamMsg *smsg, const Packet *p, int streaminline) { uint8_t direction = 0; if ((!streaminline && (p->flowflags & FLOW_PKT_TOSERVER)) || ( streaminline && (p->flowflags & FLOW_PKT_TOCLIENT))) { direction = STREAM_TOCLIENT; SCLogDebug("stream chunk is to_client"); } else { direction = STREAM_TOSERVER; SCLogDebug("stream chunk is to_server"); } /* store the smsg in the tcp stream */ if (direction == STREAM_TOSERVER) { SCLogDebug("storing smsg in the to_server"); /* put the smsg in the stream list */ if (ssn->toserver_smsg_head == NULL) { ssn->toserver_smsg_head = smsg; ssn->toserver_smsg_tail = smsg; smsg->next = NULL; smsg->prev = NULL; } else { StreamMsg *cur = ssn->toserver_smsg_tail; cur->next = smsg; smsg->prev = cur; smsg->next = NULL; ssn->toserver_smsg_tail = smsg; } } else { SCLogDebug("storing smsg in the to_client"); /* put the smsg in the stream list */ if (ssn->toclient_smsg_head == NULL) { ssn->toclient_smsg_head = smsg; ssn->toclient_smsg_tail = smsg; smsg->next = NULL; smsg->prev = NULL; } else { StreamMsg *cur = ssn->toclient_smsg_tail; cur->next = smsg; smsg->prev = cur; smsg->next = NULL; ssn->toclient_smsg_tail = smsg; } } } /** * \brief Insert a packets TCP data into the stream reassembly engine. * * \retval 0 good segment, as far as we checked. * \retval -1 badness, reason to drop in inline mode * * If the retval is 0 the segment is inserted correctly, or overlap is handled, * or it wasn't added because of reassembly depth. * */ int <API key>(ThreadVars *tv, <API key> *ra_ctx, TcpSession *ssn, TcpStream *stream, Packet *p) { SCEnter(); if (ssn->data_first_seen_dir == 0) { if (p->flowflags & FLOW_PKT_TOSERVER) { ssn->data_first_seen_dir = STREAM_TOSERVER; } else { ssn->data_first_seen_dir = STREAM_TOCLIENT; } } /* If we have reached the defined depth for either of the stream, then stop reassembling the TCP session */ uint32_t size = <API key>(stream, TCP_GET_SEQ(p), p->payload_len); SCLogDebug("ssn %p: check depth returned %"PRIu32, ssn, size); if (stream->flags & <API key>) { /* increment stream depth counter */ SCPerfCounterIncr(ra_ctx-><API key>, tv->sc_perf_pca); stream->flags |= <API key>; SCLogDebug("ssn %p: reassembly depth reached, " "<API key> set", ssn); } if (size == 0) { SCLogDebug("ssn %p: depth reached, not reassembling", ssn); SCReturnInt(0); } #if DEBUG BUG_ON(size > p->payload_len); #else if (size > p->payload_len) size = p->payload_len; #endif TcpSegment *seg = StreamTcpGetSegment(tv, ra_ctx, size); if (seg == NULL) { SCLogDebug("segment_pool[%"PRIu16"] is empty", segment_pool_idx[size]); StreamTcpSetEvent(p, <API key>); SCReturnInt(-1); } memcpy(seg->payload, p->payload, size); seg->payload_len = size; seg->seq = TCP_GET_SEQ(p); /* if raw reassembly is disabled for new segments, flag each * segment as complete for raw before insert */ if (stream->flags & <API key>) { seg->flags |= <API key>; SCLogDebug("segment %p flagged with <API key>, " "flags %02x", seg, seg->flags); } /* proto detection skipped, but now we do get data. Set event. */ if (stream->seg_list == NULL && stream->flags & <API key>) { <API key>(&p->app_layer_events, <API key>); } if (<API key>(tv, ra_ctx, stream, seg, p) != 0) { SCLogDebug("<API key> failed"); SCReturnInt(-1); } SCReturnInt(0); } static uint8_t <API key>(TcpSession *ssn, TcpStream *stream, Packet *p) { uint8_t flag = 0; if (!(stream->flags & <API key>)) { flag |= STREAM_START; } if (ssn->state == TCP_CLOSED) { flag |= STREAM_EOF; } if (p->flags & <API key>) { flag |= STREAM_EOF; } if (StreamTcpInlineMode() == 0) { if (p->flowflags & FLOW_PKT_TOSERVER) { flag |= STREAM_TOCLIENT; } else { flag |= STREAM_TOSERVER; } } else { if (p->flowflags & FLOW_PKT_TOSERVER) { flag |= STREAM_TOSERVER; } else { flag |= STREAM_TOCLIENT; } } if (stream->flags & <API key>) { flag |= STREAM_DEPTH; } return flag; } static void StreamTcpSetupMsg(TcpSession *ssn, TcpStream *stream, Packet *p, StreamMsg *smsg) { SCEnter(); smsg->data_len = 0; SCLogDebug("smsg %p", smsg); SCReturn; } /** * \brief Check the minimum size limits for reassembly. * * \retval 0 don't reassemble yet * \retval 1 do reassemble */ static int <API key>(TcpSession *ssn, TcpStream *stream, Packet *p) { SCEnter(); if (stream->flags & <API key>) { SCLogDebug("reassembling now as <API key> is set, so not expecting any new packets"); SCReturnInt(1); } if (ssn->flags & <API key>) { SCLogDebug("reassembling now as <API key> is set"); ssn->flags &= ~<API key>; SCReturnInt(1); } if (stream->flags & <API key>) { SCLogDebug("reassembling now as <API key> is set, " "so no new segments will be considered"); SCReturnInt(1); } /* some states mean we reassemble no matter how much data we have */ if (ssn->state >= TCP_TIME_WAIT) SCReturnInt(1); if (p->flags & <API key>) SCReturnInt(1); /* check if we have enough data to send to L7 */ if (p->flowflags & FLOW_PKT_TOCLIENT) { SCLogDebug("<API key>(STREAM_TOSERVER) %"PRIu32, <API key>(FLOW_PKT_TOSERVER)); if (<API key>(FLOW_PKT_TOSERVER) > (stream->last_ack - stream->ra_raw_base_seq)) { SCLogDebug("toserver min chunk len not yet reached: " "last_ack %"PRIu32", ra_raw_base_seq %"PRIu32", %"PRIu32" < " "%"PRIu32"", stream->last_ack, stream->ra_raw_base_seq, (stream->last_ack - stream->ra_raw_base_seq), <API key>(FLOW_PKT_TOSERVER)); SCReturnInt(0); } } else { SCLogDebug("<API key>(STREAM_TOCLIENT) %"PRIu32, <API key>(FLOW_PKT_TOCLIENT)); if (<API key>(FLOW_PKT_TOCLIENT) > (stream->last_ack - stream->ra_raw_base_seq)) { SCLogDebug("toclient min chunk len not yet reached: " "last_ack %"PRIu32", ra_base_seq %"PRIu32", %"PRIu32" < " "%"PRIu32"", stream->last_ack, stream->ra_raw_base_seq, (stream->last_ack - stream->ra_raw_base_seq), <API key>(FLOW_PKT_TOCLIENT)); SCReturnInt(0); } } SCReturnInt(1); } /** * \brief see if app layer is done with a segment * * \retval 1 app layer is done with this segment * \retval 0 not done yet */ #define <API key>(stream, segment) \ (( ( (stream)->flags & <API key> ) || \ ( (segment)->flags & <API key> ) ? 1 :0 )) /** \internal * \brief check if we can remove a segment from our segment list * * If a segment is entirely before the oldest smsg, we can discard it. Otherwise * we keep it around to be able to log it. * * \retval 1 yes * \retval 0 no */ static inline int <API key>(const Flow *f, TcpSession *ssn, TcpStream *stream, TcpSegment *seg) { if (stream == &ssn->client && ssn->toserver_smsg_head != NULL) { /* not (seg is entirely before first smsg, skip) */ if (!(SEQ_LEQ(seg->seq + seg->payload_len, ssn->toserver_smsg_head->seq))) { SCReturnInt(0); } } else if (stream == &ssn->server && ssn->toclient_smsg_head != NULL) { /* not (seg is entirely before first smsg, skip) */ if (!(SEQ_LEQ(seg->seq + seg->payload_len, ssn->toclient_smsg_head->seq))) { SCReturnInt(0); } } /* if proto detect isn't done, we're not returning */ if (!(<API key>(stream))) { SCReturnInt(0); } /* check app layer conditions */ if (!(f->flags & <API key>)) { if (!(<API key>(stream, seg))) { SCReturnInt(0); } } /* check raw reassembly conditions */ if (!(seg->flags & <API key>)) { SCReturnInt(0); } SCReturnInt(1); } static void <API key>(TcpStream *stream, TcpSegment *seg) { if (seg->prev == NULL) { stream->seg_list = seg->next; if (stream->seg_list != NULL) stream->seg_list->prev = NULL; } else { seg->prev->next = seg->next; if (seg->next != NULL) seg->next->prev = seg->prev; } if (stream->seg_list_tail == seg) stream->seg_list_tail = seg->prev; } /** * \brief Update the stream reassembly upon receiving a data segment * * | left edge | right edge based on sliding window size * [aaa] * [aaabbb] * ... * [aaabbbcccdddeeefff] * [bbbcccdddeeefffggg] <- cut off aaa to adhere to the window size * * GAP situation: each chunk that is uninterrupted has it's own smsg * [aaabbb].[dddeeefff] * [aaa].[ccc].[eeefff] * * A flag will be set to indicate where the *NEW* payload starts. This * is to aid the detection code for alert only sigs. * * \todo this function is too long, we need to break it up. It needs it BAD */ static int <API key> (<API key> *ra_ctx, TcpSession *ssn, TcpStream *stream, Packet *p) { SCEnter(); SCLogDebug("start p %p, seq %"PRIu32, p, TCP_GET_SEQ(p)); if (ssn->flags & <API key>) SCReturnInt(0); if (stream->seg_list == NULL) { SCReturnInt(0); } uint32_t ra_base_seq = stream->ra_raw_base_seq; StreamMsg *smsg = NULL; uint16_t smsg_offset = 0; uint16_t payload_offset = 0; uint16_t payload_len = 0; TcpSegment *seg = stream->seg_list; uint32_t next_seq = ra_base_seq + 1; int gap = 0; uint16_t chunk_size = PKT_IS_TOSERVER(p) ? stream_config.<API key> : stream_config.<API key>; /* determine the left edge and right edge */ uint32_t right_edge = TCP_GET_SEQ(p) + p->payload_len; uint32_t left_edge = right_edge - chunk_size; /* shift the window to the right if the left edge doesn't cover segments */ if (SEQ_GT(seg->seq,left_edge)) { right_edge += (seg->seq - left_edge); left_edge = seg->seq; } SCLogDebug("left_edge %"PRIu32", right_edge %"PRIu32, left_edge, right_edge); /* loop through the segments and fill one or more msgs */ for (; seg != NULL && SEQ_LT(seg->seq, right_edge); ) { SCLogDebug("seg %p", seg); /* If packets are fully before ra_base_seq, skip them. We do this * because we've reassembled up to the ra_base_seq point already, * so we won't do anything with segments before it anyway. */ SCLogDebug("checking for pre ra_base_seq %"PRIu32" seg %p seq %"PRIu32"" " len %"PRIu16", combined %"PRIu32" and right_edge " "%"PRIu32"", ra_base_seq, seg, seg->seq, seg->payload_len, seg->seq+seg->payload_len, right_edge); /* Remove the segments which are completely before the ra_base_seq */ if (SEQ_LT((seg->seq + seg->payload_len), (ra_base_seq - chunk_size))) { SCLogDebug("removing pre ra_base_seq %"PRIu32" seg %p seq %"PRIu32"" " len %"PRIu16"", ra_base_seq, seg, seg->seq, seg->payload_len); /* only remove if app layer reassembly is ready too */ if (<API key>(stream, seg)) { TcpSegment *next_seg = seg->next; <API key>(stream, seg); <API key>(seg); seg = next_seg; /* otherwise, just flag it for removal */ } else { seg->flags |= <API key>; seg = seg->next; } continue; } /* if app layer protocol has been detected, then remove all the segments * which has been previously processed and reassembled * * If the stream is in GAP state the app layer flag won't be set */ if (<API key>(stream) && (seg->flags & <API key>) && <API key>(stream, seg)) { SCLogDebug("segment(%p) of length %"PRIu16" has been processed," " so return it to pool", seg, seg->payload_len); TcpSegment *next_seg = seg->next; <API key>(stream, seg); <API key>(seg); seg = next_seg; continue; } /* we've run into a sequence gap, wrap up any existing smsg and * queue it so the next chunk (if any) is in a new smsg */ if (SEQ_GT(seg->seq, next_seq)) { /* pass on pre existing smsg (if any) */ if (smsg != NULL && smsg->data_len > 0) { <API key>(ssn, smsg, p, 1); stream->ra_raw_base_seq = ra_base_seq; smsg = NULL; } gap = 1; } /* if the segment ends beyond left_edge we need to consider it */ if (SEQ_GT((seg->seq + seg->payload_len), left_edge)) { SCLogDebug("seg->seq %" PRIu32 ", seg->payload_len %" PRIu32 ", " "left_edge %" PRIu32 "", seg->seq, seg->payload_len, left_edge); /* handle segments partly before ra_base_seq */ if (SEQ_GT(left_edge, seg->seq)) { payload_offset = left_edge - seg->seq; if (SEQ_LT(right_edge, (seg->seq + seg->payload_len))) { payload_len = (right_edge - seg->seq) - payload_offset; } else { payload_len = seg->payload_len - payload_offset; } if (SCLogDebugEnabled()) { BUG_ON(payload_offset > seg->payload_len); BUG_ON((payload_len + payload_offset) > seg->payload_len); } } else { payload_offset = 0; if (SEQ_LT(right_edge, (seg->seq + seg->payload_len))) { payload_len = right_edge - seg->seq; } else { payload_len = seg->payload_len; } } SCLogDebug("payload_offset is %"PRIu16", payload_len is %"PRIu16"" " and stream->last_ack is %"PRIu32"", payload_offset, payload_len, stream->last_ack); if (payload_len == 0) { SCLogDebug("no payload_len, so bail out"); break; } if (smsg == NULL) { smsg = <API key>(); if (smsg == NULL) { SCLogDebug("stream_msg_pool is empty"); return -1; } smsg_offset = 0; StreamTcpSetupMsg(ssn, stream, p, smsg); smsg->seq = ra_base_seq + 1; } /* copy the data into the smsg */ uint16_t copy_size = sizeof (smsg->data) - smsg_offset; if (copy_size > payload_len) { copy_size = payload_len; } if (SCLogDebugEnabled()) { BUG_ON(copy_size > sizeof(smsg->data)); } SCLogDebug("copy_size is %"PRIu16"", copy_size); memcpy(smsg->data + smsg_offset, seg->payload + payload_offset, copy_size); smsg_offset += copy_size; SCLogDebug("seg total %u, seq %u off %u copy %u, ra_base_seq %u", (seg->seq + payload_offset + copy_size), seg->seq, payload_offset, copy_size, ra_base_seq); if (gap == 0 && SEQ_GT((seg->seq + payload_offset + copy_size),ra_base_seq+1)) { ra_base_seq += copy_size; } SCLogDebug("ra_base_seq %"PRIu32, ra_base_seq); smsg->data_len += copy_size; /* queue the smsg if it's full */ if (smsg->data_len == sizeof (smsg->data)) { <API key>(ssn, smsg, p, 1); stream->ra_raw_base_seq = ra_base_seq; smsg = NULL; } /* if the payload len is bigger than what we copied, we handle the * rest of the payload next... */ if (copy_size < payload_len) { SCLogDebug("copy_size %" PRIu32 " < %" PRIu32 "", copy_size, payload_len); payload_offset += copy_size; payload_len -= copy_size; SCLogDebug("payload_offset is %"PRIu16", seg->payload_len is " "%"PRIu16" and stream->last_ack is %"PRIu32"", payload_offset, seg->payload_len, stream->last_ack); if (SCLogDebugEnabled()) { BUG_ON(payload_offset > seg->payload_len); } /* we need a while loop here as the packets theoretically can be * 64k */ char segment_done = FALSE; while (segment_done == FALSE) { SCLogDebug("new msg at offset %" PRIu32 ", payload_len " "%" PRIu32 "", payload_offset, payload_len); /* get a new message XXX we need a setup function */ smsg = <API key>(); if (smsg == NULL) { SCLogDebug("stream_msg_pool is empty"); SCReturnInt(-1); } smsg_offset = 0; StreamTcpSetupMsg(ssn, stream,p,smsg); smsg->seq = ra_base_seq + 1; copy_size = sizeof(smsg->data) - smsg_offset; if (copy_size > (seg->payload_len - payload_offset)) { copy_size = (seg->payload_len - payload_offset); } if (SCLogDebugEnabled()) { BUG_ON(copy_size > sizeof(smsg->data)); } SCLogDebug("copy payload_offset %" PRIu32 ", smsg_offset " "%" PRIu32 ", copy_size %" PRIu32 "", payload_offset, smsg_offset, copy_size); memcpy(smsg->data + smsg_offset, seg->payload + payload_offset, copy_size); smsg_offset += copy_size; if (gap == 0 && SEQ_GT((seg->seq + payload_offset + copy_size),ra_base_seq+1)) { ra_base_seq += copy_size; } SCLogDebug("ra_base_seq %"PRIu32, ra_base_seq); smsg->data_len += copy_size; SCLogDebug("copied payload_offset %" PRIu32 ", " "smsg_offset %" PRIu32 ", copy_size %" PRIu32 "", payload_offset, smsg_offset, copy_size); if (smsg->data_len == sizeof (smsg->data)) { <API key>(ssn, smsg, p, 1); stream->ra_raw_base_seq = ra_base_seq; smsg = NULL; } /* see if we have segment payload left to process */ if ((copy_size + payload_offset) < seg->payload_len) { payload_offset += copy_size; payload_len -= copy_size; if (SCLogDebugEnabled()) { BUG_ON(payload_offset > seg->payload_len); } } else { payload_offset = 0; segment_done = TRUE; } } } } /* done with this segment, return it to the pool */ TcpSegment *next_seg = seg->next; next_seq = seg->seq + seg->payload_len; if (SEQ_LT((seg->seq + seg->payload_len), (ra_base_seq - chunk_size))) { if (seg->flags & <API key>) { <API key>(stream, seg); SCLogDebug("removing seg %p, seg->next %p", seg, seg->next); <API key>(seg); } else { seg->flags |= <API key>; } } seg = next_seg; } /* put the partly filled smsg in the queue */ if (smsg != NULL) { <API key>(ssn, smsg, p, 1); smsg = NULL; stream->ra_raw_base_seq = ra_base_seq; } /* see if we can clean up some segments */ left_edge = (ra_base_seq + 1) - chunk_size; SCLogDebug("left_edge %"PRIu32", ra_base_seq %"PRIu32, left_edge, ra_base_seq); /* loop through the segments to remove unneeded segments */ for (seg = stream->seg_list; seg != NULL && SEQ_LEQ((seg->seq + p->payload_len), left_edge); ) { SCLogDebug("seg %p seq %"PRIu32", len %"PRIu16", sum %"PRIu32, seg, seg->seq, seg->payload_len, seg->seq+seg->payload_len); /* only remove if app layer reassembly is ready too */ if (<API key>(stream, seg)) { TcpSegment *next_seg = seg->next; <API key>(stream, seg); <API key>(seg); seg = next_seg; } else { break; } } SCLogDebug("stream->ra_raw_base_seq %u", stream->ra_raw_base_seq); SCReturnInt(0); } /** \brief Remove idle TcpSegments from TcpSession * * \param f flow * \param flags direction flags */ void <API key>(Flow *f, uint8_t flags) { if (f == NULL || f->protoctx == NULL) return; TcpSession *ssn = f->protoctx; TcpStream *stream = NULL; if (flags & STREAM_TOSERVER) { stream = &ssn->client; } else if (flags & STREAM_TOCLIENT) { stream = &ssn->server; } else { return; } /* loop through the segments and fill one or more msgs */ TcpSegment *seg = stream->seg_list; for (; seg != NULL && SEQ_LT(seg->seq, stream->last_ack);) { SCLogDebug("seg %p, SEQ %"PRIu32", LEN %"PRIu16", SUM %"PRIu32", FLAGS %02x", seg, seg->seq, seg->payload_len, (uint32_t)(seg->seq + seg->payload_len), seg->flags); if (<API key>(f, ssn, stream, seg) == 0) { break; } TcpSegment *next_seg = seg->next; <API key>(stream, seg); <API key>(seg); seg = next_seg; continue; } } #ifdef DEBUG static uint64_t GetStreamSize(TcpStream *stream) { if (stream) { uint64_t size = 0; uint32_t cnt = 0; TcpSegment *seg = stream->seg_list; while (seg) { cnt++; size += (uint64_t)seg->payload_len; seg = seg->next; } SCLogDebug("size %"PRIu64", cnt %"PRIu32, size, cnt); return size; } return (uint64_t)0; } static void GetSessionSize(TcpSession *ssn, Packet *p) { uint64_t size = 0; if (ssn) { size = GetStreamSize(&ssn->client); size += GetStreamSize(&ssn->server); //if (size > 900000) // SCLogInfo("size %"PRIu64", packet %"PRIu64, size, p->pcap_cnt); SCLogDebug("size %"PRIu64", packet %"PRIu64, size, p->pcap_cnt); } } #endif typedef struct ReassembleData_ { uint32_t ra_base_seq; uint32_t data_len; uint8_t data[4096]; int partial; /* last segment was processed only partially */ uint32_t data_sent; /* data passed on this run */ } ReassembleData; /** \internal * \brief test if segment follows a gap. If so, handle the gap * * If in inline mode, segment may be un-ack'd. In this case we * consider it a gap, but it's not 'final' yet. * * \retval bool 1 gap 0 no gap */ int DoHandleGap(ThreadVars *tv, <API key> *ra_ctx, TcpSession *ssn, TcpStream *stream, TcpSegment *seg, ReassembleData *rd, Packet *p, uint32_t next_seq) { if (unlikely(SEQ_GT(seg->seq, next_seq))) { /* we've run into a sequence gap */ if (StreamTcpInlineMode()) { /* don't conclude it's a gap until we see that the data * that is missing was acked. */ if (SEQ_GT(seg->seq,stream->last_ack) && ssn->state != TCP_CLOSED) return 1; } /* first, pass on data before the gap */ if (rd->data_len > 0) { SCLogDebug("pre GAP data"); /* process what we have so far */ <API key>(tv, ra_ctx, p, p->flow, ssn, stream, rd->data, rd->data_len, <API key>(ssn, stream, p)); <API key>(ra_ctx->app_tctx, p); rd->data_sent += rd->data_len; rd->data_len = 0; } #ifdef DEBUG uint32_t gap_len = seg->seq - next_seq; SCLogDebug("expected next_seq %" PRIu32 ", got %" PRIu32 " , " "stream->last_ack %" PRIu32 ". Seq gap %" PRIu32"", next_seq, seg->seq, stream->last_ack, gap_len); #endif /* We have missed the packet and end host has ack'd it, so * IDS should advance it's ra_base_seq and should not consider this * packet any longer, even if it is retransmitted, as end host will * drop it anyway */ rd->ra_base_seq = seg->seq - 1; /* send gap "signal" */ <API key>(tv, ra_ctx, p, p->flow, ssn, stream, NULL, 0, <API key>(ssn, stream, p)|STREAM_GAP); <API key>(ra_ctx->app_tctx, p); /* set a GAP flag and make sure not bothering this stream anymore */ SCLogDebug("<API key> set"); stream->flags |= <API key>; StreamTcpSetEvent(p, <API key>); SCPerfCounterIncr(ra_ctx-><API key>, tv->sc_perf_pca); #ifdef DEBUG dbg_app_layer_gap++; #endif return 1; } return 0; } static inline int DoReassemble(ThreadVars *tv, <API key> *ra_ctx, TcpSession *ssn, TcpStream *stream, TcpSegment *seg, ReassembleData *rd, Packet *p) { /* fast path 1: segment is exactly what we need */ if (likely(rd->data_len == 0 && SEQ_EQ(seg->seq, rd->ra_base_seq+1) && SEQ_EQ(stream->last_ack, (seg->seq + seg->payload_len)))) { /* process single segment directly */ <API key>(tv, ra_ctx, p, p->flow, ssn, stream, seg->payload, seg->payload_len, <API key>(ssn, stream, p)); <API key>(ra_ctx->app_tctx, p); rd->data_sent += seg->payload_len; rd->ra_base_seq += seg->payload_len; #ifdef DEBUG ra_ctx->fp1++; #endif /* if after the first data chunk we have no alproto yet, * there is no point in continueing here. */ if (!<API key>(stream)) { SCLogDebug("no alproto after first data chunk"); return 0; } return 1; /* fast path 2: segment acked completely, meets minimal size req for 0copy processing */ } else if (rd->data_len == 0 && SEQ_EQ(seg->seq, rd->ra_base_seq+1) && SEQ_GT(stream->last_ack, (seg->seq + seg->payload_len)) && seg->payload_len >= stream_config.zero_copy_size) { /* process single segment directly */ <API key>(tv, ra_ctx, p, p->flow, ssn, stream, seg->payload, seg->payload_len, <API key>(ssn, stream, p)); <API key>(ra_ctx->app_tctx, p); rd->data_sent += seg->payload_len; rd->ra_base_seq += seg->payload_len; #ifdef DEBUG ra_ctx->fp2++; #endif /* if after the first data chunk we have no alproto yet, * there is no point in continueing here. */ if (!<API key>(stream)) { SCLogDebug("no alproto after first data chunk"); return 0; } return 1; } #ifdef DEBUG ra_ctx->sp++; #endif uint16_t payload_offset = 0; uint16_t payload_len = 0; /* start clean */ rd->partial = FALSE; /* if the segment ends beyond ra_base_seq we need to consider it */ if (SEQ_GT((seg->seq + seg->payload_len), rd->ra_base_seq+1)) { SCLogDebug("seg->seq %" PRIu32 ", seg->payload_len %" PRIu32 ", " "ra_base_seq %" PRIu32 ", last_ack %"PRIu32, seg->seq, seg->payload_len, rd->ra_base_seq, stream->last_ack); if (StreamTcpInlineMode() == 0) { /* handle segments partly before ra_base_seq */ if (SEQ_GT(rd->ra_base_seq, seg->seq)) { payload_offset = (rd->ra_base_seq + 1) - seg->seq; SCLogDebug("payload_offset %u", payload_offset); if (SEQ_LT(stream->last_ack, (seg->seq + seg->payload_len))) { if (SEQ_LT(stream->last_ack, (rd->ra_base_seq + 1))) { payload_len = (stream->last_ack - seg->seq); SCLogDebug("payload_len %u", payload_len); } else { payload_len = (stream->last_ack - seg->seq) - payload_offset; SCLogDebug("payload_len %u", payload_len); } rd->partial = TRUE; } else { payload_len = seg->payload_len - payload_offset; SCLogDebug("payload_len %u", payload_len); } if (SCLogDebugEnabled()) { BUG_ON(payload_offset > seg->payload_len); BUG_ON((payload_len + payload_offset) > seg->payload_len); } } else { payload_offset = 0; if (SEQ_LT(stream->last_ack, (seg->seq + seg->payload_len))) { payload_len = stream->last_ack - seg->seq; SCLogDebug("payload_len %u", payload_len); rd->partial = TRUE; } else { payload_len = seg->payload_len; SCLogDebug("payload_len %u", payload_len); } } /* inline mode, don't consider last_ack as we process un-ACK'd segments */ } else { /* handle segments partly before ra_base_seq */ if (SEQ_GT(rd->ra_base_seq, seg->seq)) { payload_offset = rd->ra_base_seq - seg->seq - 1; payload_len = seg->payload_len - payload_offset; if (SCLogDebugEnabled()) { BUG_ON(payload_offset > seg->payload_len); BUG_ON((payload_len + payload_offset) > seg->payload_len); } } else { payload_offset = 0; payload_len = seg->payload_len; } } SCLogDebug("payload_offset is %"PRIu16", payload_len is %"PRIu16"" " and stream->last_ack is %"PRIu32"", payload_offset, payload_len, stream->last_ack); if (payload_len == 0) { SCLogDebug("no payload_len, so bail out"); return 0; } /* copy the data into the smsg */ uint16_t copy_size = sizeof(rd->data) - rd->data_len; if (copy_size > payload_len) { copy_size = payload_len; } if (SCLogDebugEnabled()) { BUG_ON(copy_size > sizeof(rd->data)); } SCLogDebug("copy_size is %"PRIu16"", copy_size); memcpy(rd->data + rd->data_len, seg->payload + payload_offset, copy_size); rd->data_len += copy_size; rd->ra_base_seq += copy_size; SCLogDebug("ra_base_seq %"PRIu32", data_len %"PRIu32, rd->ra_base_seq, rd->data_len); /* queue the smsg if it's full */ if (rd->data_len == sizeof(rd->data)) { /* process what we have so far */ <API key>(tv, ra_ctx, p, p->flow, ssn, stream, rd->data, rd->data_len, <API key>(ssn, stream, p)); <API key>(ra_ctx->app_tctx, p); rd->data_sent += rd->data_len; rd->data_len = 0; /* if after the first data chunk we have no alproto yet, * there is no point in continueing here. */ if (!<API key>(stream)) { SCLogDebug("no alproto after first data chunk"); return 0; } } /* if the payload len is bigger than what we copied, we handle the * rest of the payload next... */ if (copy_size < payload_len) { SCLogDebug("copy_size %" PRIu32 " < %" PRIu32 "", copy_size, payload_len); payload_offset += copy_size; payload_len -= copy_size; SCLogDebug("payload_offset is %"PRIu16", seg->payload_len is " "%"PRIu16" and stream->last_ack is %"PRIu32"", payload_offset, seg->payload_len, stream->last_ack); if (SCLogDebugEnabled()) { BUG_ON(payload_offset > seg->payload_len); } /* we need a while loop here as the packets theoretically can be * 64k */ char segment_done = FALSE; while (segment_done == FALSE) { SCLogDebug("new msg at offset %" PRIu32 ", payload_len " "%" PRIu32 "", payload_offset, payload_len); rd->data_len = 0; copy_size = sizeof(rd->data) - rd->data_len; if (copy_size > (seg->payload_len - payload_offset)) { copy_size = (seg->payload_len - payload_offset); } if (SCLogDebugEnabled()) { BUG_ON(copy_size > sizeof(rd->data)); } SCLogDebug("copy payload_offset %" PRIu32 ", data_len " "%" PRIu32 ", copy_size %" PRIu32 "", payload_offset, rd->data_len, copy_size); memcpy(rd->data + rd->data_len, seg->payload + payload_offset, copy_size); rd->data_len += copy_size; rd->ra_base_seq += copy_size; SCLogDebug("ra_base_seq %"PRIu32, rd->ra_base_seq); SCLogDebug("copied payload_offset %" PRIu32 ", " "data_len %" PRIu32 ", copy_size %" PRIu32 "", payload_offset, rd->data_len, copy_size); if (rd->data_len == sizeof(rd->data)) { /* process what we have so far */ <API key>(tv, ra_ctx, p, p->flow, ssn, stream, rd->data, rd->data_len, <API key>(ssn, stream, p)); <API key>(ra_ctx->app_tctx, p); rd->data_sent += rd->data_len; rd->data_len = 0; /* if after the first data chunk we have no alproto yet, * there is no point in continueing here. */ if (!<API key>(stream)) { SCLogDebug("no alproto after first data chunk"); return 0; } } /* see if we have segment payload left to process */ if ((copy_size + payload_offset) < seg->payload_len) { payload_offset += copy_size; payload_len -= copy_size; if (SCLogDebugEnabled()) { BUG_ON(payload_offset > seg->payload_len); } } else { payload_offset = 0; segment_done = TRUE; } } } } return 1; } /** * \brief Update the stream reassembly upon receiving an ACK packet. * * Stream is in the opposite direction of the packet, as the ACK-packet * is ACK'ing the stream. * * One of the utilities call by this function <API key>(), * has a feature where it will call this very same function for the * stream opposing the stream it is called with. This shouldn't cause * any issues, since processing of each stream is independent of the * other stream. * * \todo this function is too long, we need to break it up. It needs it BAD */ int <API key> (ThreadVars *tv, <API key> *ra_ctx, TcpSession *ssn, TcpStream *stream, Packet *p) { SCEnter(); /* this function can be directly called by app layer protocol * detection. */ if (stream->flags & <API key>) { SCLogDebug("stream no reassembly flag set. Mostly called via " "app proto detection."); SCReturnInt(0); } SCLogDebug("stream->seg_list %p", stream->seg_list); #ifdef DEBUG PrintList(stream->seg_list); GetSessionSize(ssn, p); #endif /* if no segments are in the list or all are already processed, * and state is beyond established, we send an empty msg */ TcpSegment *seg_tail = stream->seg_list_tail; if (seg_tail == NULL || (seg_tail->flags & <API key>)) { /* send an empty EOF msg if we have no segments but TCP state * is beyond ESTABLISHED */ if (ssn->state >= TCP_CLOSING || (p->flags & <API key>)) { SCLogDebug("sending empty eof message"); /* send EOF to app layer */ <API key>(tv, ra_ctx, p, p->flow, ssn, stream, NULL, 0, <API key>(ssn, stream, p)); <API key>(ra_ctx->app_tctx, p); SCReturnInt(0); } } /* no segments, nothing to do */ if (stream->seg_list == NULL) { SCLogDebug("no segments in the list to reassemble"); SCReturnInt(0); } if (stream->flags & <API key>) { SCReturnInt(0); } /* stream->ra_app_base_seq remains at stream->isn until protocol is * detected. */ ReassembleData rd; rd.ra_base_seq = stream->ra_app_base_seq; rd.data_len = 0; rd.data_sent = 0; rd.partial = FALSE; uint32_t next_seq = rd.ra_base_seq + 1; SCLogDebug("ra_base_seq %"PRIu32", last_ack %"PRIu32", next_seq %"PRIu32, rd.ra_base_seq, stream->last_ack, next_seq); /* loop through the segments and fill one or more msgs */ TcpSegment *seg = stream->seg_list; SCLogDebug("pre-loop seg %p", seg); /* Check if we have a gap at the start of the list. If last_ack is * bigger than the list start and the list start is bigger than * next_seq, we know we are missing data that has been ack'd. That * won't get retransmitted, so it's a data gap. */ if (!(p->flow->flags & <API key>)) { if (SEQ_GT(seg->seq, next_seq) && SEQ_LT(seg->seq, stream->last_ack)) { /* send gap signal */ <API key>(tv, ra_ctx, p, p->flow, ssn, stream, NULL, 0, <API key>(ssn, stream, p)|STREAM_GAP); <API key>(ra_ctx->app_tctx, p); /* set a GAP flag and make sure not bothering this stream anymore */ SCLogDebug("<API key> set"); stream->flags |= <API key>; StreamTcpSetEvent(p, <API key>); SCPerfCounterIncr(ra_ctx-><API key>, tv->sc_perf_pca); #ifdef DEBUG dbg_app_layer_gap++; #endif SCReturnInt(0); } } for (; seg != NULL; ) { /* if in inline mode, we process all segments regardless of whether * they are ack'd or not. In non-inline, we process only those that * are at least partly ack'd. */ if (StreamTcpInlineMode() == 0 && SEQ_GEQ(seg->seq, stream->last_ack)) break; SCLogDebug("seg %p, SEQ %"PRIu32", LEN %"PRIu16", SUM %"PRIu32, seg, seg->seq, seg->payload_len, (uint32_t)(seg->seq + seg->payload_len)); if (p->flow->flags & <API key>) { SCLogDebug("<API key> set, breaking out"); break; } if (<API key>(p->flow, ssn, stream, seg) == 1) { SCLogDebug("removing segment"); TcpSegment *next_seg = seg->next; <API key>(stream, seg); <API key>(seg); seg = next_seg; continue; } else if (<API key>(stream, seg)) { TcpSegment *next_seg = seg->next; seg = next_seg; continue; } /* check if we have a sequence gap and if so, handle it */ if (DoHandleGap(tv, ra_ctx, ssn, stream, seg, &rd, p, next_seq) == 1) break; /* process this segment */ if (DoReassemble(tv, ra_ctx, ssn, stream, seg, &rd, p) == 0) break; /* done with this segment, return it to the pool */ TcpSegment *next_seg = seg->next; next_seq = seg->seq + seg->payload_len; if (rd.partial == FALSE) { SCLogDebug("fully done with segment in app layer reassembly (seg %p seq %"PRIu32")", seg, seg->seq); seg->flags |= <API key>; SCLogDebug("flags now %02x", seg->flags); } else { SCLogDebug("not yet fully done with segment in app layer reassembly"); } seg = next_seg; } /* put the partly filled smsg in the queue to the l7 handler */ if (rd.data_len > 0) { SCLogDebug("data_len > 0, %u", rd.data_len); /* process what we have so far */ BUG_ON(rd.data_len > sizeof(rd.data)); <API key>(tv, ra_ctx, p, p->flow, ssn, stream, rd.data, rd.data_len, <API key>(ssn, stream, p)); <API key>(ra_ctx->app_tctx, p); } /* if no data was sent to the applayer, we send it a empty 'nudge' * when in inline mode */ if (StreamTcpInlineMode() && rd.data_sent == 0 && ssn->state > TCP_ESTABLISHED) { SCLogDebug("sending empty eof message"); /* send EOF to app layer */ <API key>(tv, ra_ctx, p, p->flow, ssn, stream, NULL, 0, <API key>(ssn, stream, p)); <API key>(ra_ctx->app_tctx, p); } /* store ra_base_seq in the stream */ if (<API key>(stream)) { stream->ra_app_base_seq = rd.ra_base_seq; } else { TcpSegment *tmp_seg = stream->seg_list; while (tmp_seg != NULL) { tmp_seg->flags &= ~<API key>; tmp_seg = tmp_seg->next; } } SCLogDebug("stream->ra_app_base_seq %u", stream->ra_app_base_seq); SCReturnInt(0); } typedef struct ReassembleRawData_ { uint32_t ra_base_seq; int partial; /* last segment was processed only partially */ StreamMsg *smsg; uint16_t smsg_offset; // TODO diff with smsg->data_len? } ReassembleRawData; static void DoHandleRawGap(TcpSession *ssn, TcpStream *stream, TcpSegment *seg, Packet *p, ReassembleRawData *rd, uint32_t next_seq) { /* we've run into a sequence gap */ if (SEQ_GT(seg->seq, next_seq)) { /* pass on pre existing smsg (if any) */ if (rd->smsg != NULL && rd->smsg->data_len > 0) { /* if app layer protocol has not been detected till yet, then check did we have sent message to app layer already or not. If not then sent the message and set flag that first message has been sent. No more data till proto has not been detected */ <API key>(ssn, rd->smsg, p, 0); stream->ra_raw_base_seq = rd->ra_base_seq; rd->smsg = NULL; } /* see what the length of the gap is, gap length is seg->seq - * (ra_base_seq +1) */ #ifdef DEBUG uint32_t gap_len = seg->seq - next_seq; SCLogDebug("expected next_seq %" PRIu32 ", got %" PRIu32 " , " "stream->last_ack %" PRIu32 ". Seq gap %" PRIu32"", next_seq, seg->seq, stream->last_ack, gap_len); #endif stream->ra_raw_base_seq = rd->ra_base_seq; /* We have missed the packet and end host has ack'd it, so * IDS should advance it's ra_base_seq and should not consider this * packet any longer, even if it is retransmitted, as end host will * drop it anyway */ rd->ra_base_seq = seg->seq - 1; } } static int DoRawReassemble(TcpSession *ssn, TcpStream *stream, TcpSegment *seg, Packet *p, ReassembleRawData *rd) { uint16_t payload_offset = 0; uint16_t payload_len = 0; /* start clean */ rd->partial = FALSE; /* if the segment ends beyond ra_base_seq we need to consider it */ if (SEQ_GT((seg->seq + seg->payload_len), rd->ra_base_seq+1)) { SCLogDebug("seg->seq %" PRIu32 ", seg->payload_len %" PRIu32 ", " "ra_base_seq %" PRIu32 "", seg->seq, seg->payload_len, rd->ra_base_seq); /* handle segments partly before ra_base_seq */ if (SEQ_GT(rd->ra_base_seq, seg->seq)) { payload_offset = rd->ra_base_seq - seg->seq; if (SEQ_LT(stream->last_ack, (seg->seq + seg->payload_len))) { if (SEQ_LT(stream->last_ack, rd->ra_base_seq)) { payload_len = (stream->last_ack - seg->seq); } else { payload_len = (stream->last_ack - seg->seq) - payload_offset; } rd->partial = TRUE; } else { payload_len = seg->payload_len - payload_offset; } if (SCLogDebugEnabled()) { BUG_ON(payload_offset > seg->payload_len); BUG_ON((payload_len + payload_offset) > seg->payload_len); } } else { payload_offset = 0; if (SEQ_LT(stream->last_ack, (seg->seq + seg->payload_len))) { payload_len = stream->last_ack - seg->seq; rd->partial = TRUE; } else { payload_len = seg->payload_len; } } SCLogDebug("payload_offset is %"PRIu16", payload_len is %"PRIu16"" " and stream->last_ack is %"PRIu32"", payload_offset, payload_len, stream->last_ack); if (payload_len == 0) { SCLogDebug("no payload_len, so bail out"); return 1; // TODO } if (rd->smsg == NULL) { rd->smsg = <API key>(); if (rd->smsg == NULL) { SCLogDebug("stream_msg_pool is empty"); return -1; } rd->smsg_offset = 0; StreamTcpSetupMsg(ssn, stream, p, rd->smsg); rd->smsg->seq = rd->ra_base_seq + 1; SCLogDebug("smsg->seq %u", rd->smsg->seq); } /* copy the data into the smsg */ uint16_t copy_size = sizeof (rd->smsg->data) - rd->smsg_offset; if (copy_size > payload_len) { copy_size = payload_len; } if (SCLogDebugEnabled()) { BUG_ON(copy_size > sizeof(rd->smsg->data)); } SCLogDebug("copy_size is %"PRIu16"", copy_size); memcpy(rd->smsg->data + rd->smsg_offset, seg->payload + payload_offset, copy_size); rd->smsg_offset += copy_size; rd->ra_base_seq += copy_size; SCLogDebug("ra_base_seq %"PRIu32, rd->ra_base_seq); rd->smsg->data_len += copy_size; /* queue the smsg if it's full */ if (rd->smsg->data_len == sizeof (rd->smsg->data)) { <API key>(ssn, rd->smsg, p, 0); stream->ra_raw_base_seq = rd->ra_base_seq; rd->smsg = NULL; } /* if the payload len is bigger than what we copied, we handle the * rest of the payload next... */ if (copy_size < payload_len) { SCLogDebug("copy_size %" PRIu32 " < %" PRIu32 "", copy_size, payload_len); payload_offset += copy_size; payload_len -= copy_size; SCLogDebug("payload_offset is %"PRIu16", seg->payload_len is " "%"PRIu16" and stream->last_ack is %"PRIu32"", payload_offset, seg->payload_len, stream->last_ack); if (SCLogDebugEnabled()) { BUG_ON(payload_offset > seg->payload_len); } /* we need a while loop here as the packets theoretically can be * 64k */ char segment_done = FALSE; while (segment_done == FALSE) { SCLogDebug("new msg at offset %" PRIu32 ", payload_len " "%" PRIu32 "", payload_offset, payload_len); /* get a new message XXX we need a setup function */ rd->smsg = <API key>(); if (rd->smsg == NULL) { SCLogDebug("stream_msg_pool is empty"); SCReturnInt(-1); } rd->smsg_offset = 0; StreamTcpSetupMsg(ssn, stream, p, rd->smsg); rd->smsg->seq = rd->ra_base_seq + 1; copy_size = sizeof(rd->smsg->data) - rd->smsg_offset; if (copy_size > payload_len) { copy_size = payload_len; } if (SCLogDebugEnabled()) { BUG_ON(copy_size > sizeof(rd->smsg->data)); } SCLogDebug("copy payload_offset %" PRIu32 ", smsg_offset " "%" PRIu32 ", copy_size %" PRIu32 "", payload_offset, rd->smsg_offset, copy_size); memcpy(rd->smsg->data + rd->smsg_offset, seg->payload + payload_offset, copy_size); rd->smsg_offset += copy_size; rd->ra_base_seq += copy_size; SCLogDebug("ra_base_seq %"PRIu32, rd->ra_base_seq); rd->smsg->data_len += copy_size; SCLogDebug("copied payload_offset %" PRIu32 ", " "smsg_offset %" PRIu32 ", copy_size %" PRIu32 "", payload_offset, rd->smsg_offset, copy_size); if (rd->smsg->data_len == sizeof(rd->smsg->data)) { <API key>(ssn, rd->smsg, p, 0); stream->ra_raw_base_seq = rd->ra_base_seq; rd->smsg = NULL; } /* see if we have segment payload left to process */ if (copy_size < payload_len) { payload_offset += copy_size; payload_len -= copy_size; if (SCLogDebugEnabled()) { BUG_ON(payload_offset > seg->payload_len); } } else { payload_offset = 0; segment_done = TRUE; } } } } return 1; } /** * \brief Update the stream reassembly upon receiving an ACK packet. * \todo this function is too long, we need to break it up. It needs it BAD */ static int <API key> (<API key> *ra_ctx, TcpSession *ssn, TcpStream *stream, Packet *p) { SCEnter(); SCLogDebug("start p %p", p); if (ssn->flags & <API key>) SCReturnInt(0); if (stream->seg_list == NULL) { SCLogDebug("no segments in the list to reassemble"); SCReturnInt(0); } #if 0 if (ssn->state <= TCP_ESTABLISHED && !<API key>(stream)) { SCLogDebug("only starting raw reassembly after app layer protocol " "detection has completed."); SCReturnInt(0); } #endif /* check if we have enough data */ if (<API key>(ssn,stream,p) == 0) { SCLogDebug("not yet reassembling"); SCReturnInt(0); } TcpSegment *seg = stream->seg_list; ReassembleRawData rd; rd.smsg = NULL; rd.ra_base_seq = stream->ra_raw_base_seq; rd.smsg_offset = 0; uint32_t next_seq = rd.ra_base_seq + 1; SCLogDebug("ra_base_seq %"PRIu32", last_ack %"PRIu32", next_seq %"PRIu32, rd.ra_base_seq, stream->last_ack, next_seq); /* loop through the segments and fill one or more msgs */ for (; seg != NULL && SEQ_LT(seg->seq, stream->last_ack);) { SCLogDebug("seg %p, SEQ %"PRIu32", LEN %"PRIu16", SUM %"PRIu32", flags %02x", seg, seg->seq, seg->payload_len, (uint32_t)(seg->seq + seg->payload_len), seg->flags); if (<API key>(p->flow, ssn, stream, seg) == 1) { SCLogDebug("removing segment"); TcpSegment *next_seg = seg->next; <API key>(stream, seg); <API key>(seg); seg = next_seg; continue; } else if(seg->flags & <API key>) { TcpSegment *next_seg = seg->next; seg = next_seg; continue; } DoHandleRawGap(ssn, stream, seg, p, &rd, next_seq); if (DoRawReassemble(ssn, stream, seg, p, &rd) == 0) break; /* done with this segment, return it to the pool */ TcpSegment *next_seg = seg->next; next_seq = seg->seq + seg->payload_len; if (rd.partial == FALSE) { SCLogDebug("fully done with segment in raw reassembly (seg %p seq %"PRIu32")", seg, seg->seq); seg->flags |= <API key>; SCLogDebug("flags now %02x", seg->flags); } else { SCLogDebug("not yet fully done with segment in raw reassembly"); } seg = next_seg; } /* put the partly filled smsg in the queue to the l7 handler */ if (rd.smsg != NULL) { <API key>(ssn, rd.smsg, p, 0); rd.smsg = NULL; stream->ra_raw_base_seq = rd.ra_base_seq; } SCReturnInt(0); } /** \brief update app layer and raw reassembly * * \retval r 0 on success, -1 on error */ int <API key> (ThreadVars *tv, <API key> *ra_ctx, TcpSession *ssn, TcpStream *stream, Packet *p) { SCEnter(); SCLogDebug("stream->seg_list %p", stream->seg_list); int r = 0; if (!(StreamTcpInlineMode())) { if (<API key>(tv, ra_ctx, ssn, stream, p) < 0) r = -1; if (<API key>(ra_ctx, ssn, stream, p) < 0) r = -1; } SCLogDebug("stream->seg_list %p", stream->seg_list); SCReturnInt(r); } int <API key>(ThreadVars *tv, <API key> *ra_ctx, TcpSession *ssn, TcpStream *stream, Packet *p, PacketQueue *pq) { SCEnter(); SCLogDebug("ssn %p, stream %p, p %p, p->payload_len %"PRIu16"", ssn, stream, p, p->payload_len); /* we need to update the opposing stream in * <API key> */ TcpStream *opposing_stream = NULL; if (stream == &ssn->client) { opposing_stream = &ssn->server; } else { opposing_stream = &ssn->client; } /* handle ack received */ if (<API key>(tv, ra_ctx, ssn, opposing_stream, p) != 0) { SCLogDebug("<API key> error"); SCReturnInt(-1); } /* If no stream reassembly/application layer protocol inspection, then simple return */ if (p->payload_len > 0 && !(stream->flags & <API key>)) { SCLogDebug("calling <API key>"); if (<API key>(tv, ra_ctx, ssn, stream, p) != 0) { SCLogDebug("<API key> error"); SCReturnInt(-1); } p->flags |= PKT_STREAM_ADD; } /* in stream inline mode even if we have no data we call the reassembly * functions to handle EOF */ if (StreamTcpInlineMode()) { int r = 0; if (<API key>(tv, ra_ctx, ssn, stream, p) < 0) r = -1; if (<API key>(ra_ctx, ssn, stream, p) < 0) r = -1; if (r < 0) { SCReturnInt(-1); } } <API key>(tv, ra_ctx); SCReturnInt(0); } /** * \brief Function to replace the data from a specific point up to given length. * * \param dst_seg Destination segment to replace the data * \param src_seg Source segment of which data is to be written to destination * \param start_point Starting point to replace the data onwards * \param len Length up to which data is need to be replaced * * \todo VJ We can remove the abort()s later. * \todo VJ Why not memcpy? */ void <API key>(TcpSegment *dst_seg, TcpSegment *src_seg, uint32_t start_point, uint16_t len) { uint32_t seq; uint16_t src_pos = 0; uint16_t dst_pos = 0; SCLogDebug("start_point %u", start_point); if (SEQ_GT(start_point, dst_seg->seq)) { dst_pos = start_point - dst_seg->seq; } else if (SEQ_LT(start_point, dst_seg->seq)) { dst_pos = dst_seg->seq - start_point; } if (SCLogDebugEnabled()) { BUG_ON(((len + dst_pos) - 1) > dst_seg->payload_len); } else { if (((len + dst_pos) - 1) > dst_seg->payload_len) return; } src_pos = (uint16_t)(start_point - src_seg->seq); SCLogDebug("Replacing data from dst_pos %"PRIu16"", dst_pos); for (seq = start_point; SEQ_LT(seq, (start_point + len)) && src_pos < src_seg->payload_len && dst_pos < dst_seg->payload_len; seq++, dst_pos++, src_pos++) { dst_seg->payload[dst_pos] = src_seg->payload[src_pos]; } SCLogDebug("Replaced data of size %"PRIu16" up to src_pos %"PRIu16 " dst_pos %"PRIu16, len, src_pos, dst_pos); } /** * \brief Function to compare the data from a specific point up to given length. * * \param dst_seg Destination segment to compare the data * \param src_seg Source segment of which data is to be compared to destination * \param start_point Starting point to compare the data onwards * \param len Length up to which data is need to be compared * * \retval 1 same * \retval 0 different */ static int <API key>(TcpSegment *dst_seg, TcpSegment *src_seg, uint32_t start_point, uint16_t len) { uint32_t seq; uint16_t src_pos = 0; uint16_t dst_pos = 0; SCLogDebug("start_point %u dst_seg %u src_seg %u", start_point, dst_seg->seq, src_seg->seq); if (SEQ_GT(start_point, dst_seg->seq)) { SCLogDebug("start_point %u > dst %u", start_point, dst_seg->seq); dst_pos = start_point - dst_seg->seq; } else if (SEQ_LT(start_point, dst_seg->seq)) { SCLogDebug("start_point %u < dst %u", start_point, dst_seg->seq); dst_pos = dst_seg->seq - start_point; } if (SCLogDebugEnabled()) { BUG_ON(((len + dst_pos) - 1) > dst_seg->payload_len); } else { if (((len + dst_pos) - 1) > dst_seg->payload_len) return 1; } src_pos = (uint16_t)(start_point - src_seg->seq); SCLogDebug("Comparing data from dst_pos %"PRIu16", src_pos %u", dst_pos, src_pos); for (seq = start_point; SEQ_LT(seq, (start_point + len)) && src_pos < src_seg->payload_len && dst_pos < dst_seg->payload_len; seq++, dst_pos++, src_pos++) { if (dst_seg->payload[dst_pos] != src_seg->payload[src_pos]) { SCLogDebug("data is different %02x != %02x, dst_pos %u, src_pos %u", dst_seg->payload[dst_pos], src_seg->payload[src_pos], dst_pos, src_pos); return 0; } } SCLogDebug("Compared data of size %"PRIu16" up to src_pos %"PRIu16 " dst_pos %"PRIu16, len, src_pos, dst_pos); return 1; } /** * \brief Function to copy the data from src_seg to dst_seg. * * \param dst_seg Destination segment for copying the contents * \param src_seg Source segment to copy its contents * * \todo VJ wouldn't a memcpy be more appropriate here? * * \warning Both segments need to be properly initialized. */ void <API key>(TcpSegment *dst_seg, TcpSegment *src_seg) { uint32_t u; uint16_t dst_pos = 0; uint16_t src_pos = 0; uint32_t seq; if (SEQ_GT(dst_seg->seq, src_seg->seq)) { src_pos = dst_seg->seq - src_seg->seq; seq = dst_seg->seq; } else { dst_pos = src_seg->seq - dst_seg->seq; seq = src_seg->seq; } SCLogDebug("Copying data from seq %"PRIu32"", seq); for (u = seq; (SEQ_LT(u, (src_seg->seq + src_seg->payload_len)) && SEQ_LT(u, (dst_seg->seq + dst_seg->payload_len))); u++) { //SCLogDebug("u %"PRIu32, u); dst_seg->payload[dst_pos] = src_seg->payload[src_pos]; dst_pos++; src_pos++; } SCLogDebug("Copyied data of size %"PRIu16" up to dst_pos %"PRIu16"", src_pos, dst_pos); } /** * \brief Function to get the segment of required length from the pool. * * \param len Length which tells the required size of needed segment. * * \retval seg Segment from the pool or NULL */ TcpSegment* StreamTcpGetSegment(ThreadVars *tv, <API key> *ra_ctx, uint16_t len) { uint16_t idx = segment_pool_idx[len]; SCLogDebug("segment_pool_idx %" PRIu32 " for payload_len %" PRIu32 "", idx, len); SCMutexLock(&segment_pool_mutex[idx]); TcpSegment *seg = (TcpSegment *) PoolGet(segment_pool[idx]); SCLogDebug("segment_pool[%u]->empty_stack_size %u, segment_pool[%u]->alloc_" "list_size %u, alloc %u", idx, segment_pool[idx]->empty_stack_size, idx, segment_pool[idx]->alloc_stack_size, segment_pool[idx]->allocated); SCMutexUnlock(&segment_pool_mutex[idx]); SCLogDebug("seg we return is %p", seg); if (seg == NULL) { SCLogDebug("segment_pool[%u]->empty_stack_size %u, " "alloc %u", idx, segment_pool[idx]->empty_stack_size, segment_pool[idx]->allocated); /* Increment the counter to show that we are not able to serve the segment request due to memcap limit */ SCPerfCounterIncr(ra_ctx-><API key>, tv->sc_perf_pca); } else { seg->flags = stream_config.segment_init_flags; seg->next = NULL; seg->prev = NULL; } #ifdef DEBUG SCMutexLock(&<API key>); segment_pool_cnt++; SCMutexUnlock(&<API key>); #endif return seg; } /** * \brief Trigger RAW stream reassembly * * Used by <API key> to trigger RAW stream * reassembly from the applayer, for example upon completion of a * HTTP request. * * Works by setting a flag in the TcpSession that is unset as soon * as it's checked. Since everything happens when operating under * a single lock period, no side effects are expected. * * \param ssn TcpSession */ void <API key>(TcpSession *ssn) { #ifdef DEBUG BUG_ON(ssn == NULL); #endif if (ssn != NULL) { SCLogDebug("flagged ssn %p for immediate raw reassembly", ssn); ssn->flags |= <API key>; } } #ifdef UNITTESTS /** unit tests and it's support functions below */ static uint32_t UtSsnSmsgCnt(TcpSession *ssn, uint8_t direction) { uint32_t cnt = 0; StreamMsg *smsg = (direction == STREAM_TOSERVER) ? ssn->toserver_smsg_head : ssn->toclient_smsg_head; while (smsg) { cnt++; smsg = smsg->next; } return cnt; } /** \brief The Function tests the reassembly engine working for different * OSes supported. It includes all the OS cases and send * crafted packets to test the reassembly. * * \param stream The stream which will contain the reassembled segments */ static int <API key>(TcpStream *stream) { TcpSession ssn; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; uint8_t payload[4]; TCPHdr tcph; <API key> *ra_ctx = <API key>(NULL); /* prevent L7 from kicking in */ <API key>(FLOW_PKT_TOSERVER, 4096); <API key>(FLOW_PKT_TOCLIENT, 4096); PacketQueue pq; memset(&pq,0,sizeof(PacketQueue)); memset(&ssn, 0, sizeof (TcpSession)); memset(&f, 0, sizeof (Flow)); memset(&tcph, 0, sizeof (TCPHdr)); ThreadVars tv; memset(&tv, 0, sizeof (ThreadVars)); FLOW_INITIALIZE(&f); f.protoctx = &ssn; f.proto = IPPROTO_TCP; p->src.family = AF_INET; p->dst.family = AF_INET; p->proto = IPPROTO_TCP; p->flow = &f; tcph.th_win = 5480; tcph.th_flags = TH_PUSH | TH_ACK; p->tcph = &tcph; p->flowflags = FLOW_PKT_TOSERVER; <API key>(payload, 0x41, 3, 4); /*AAA*/ p->tcph->th_seq = htonl(12); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 3; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x42, 2, 4); p->tcph->th_seq = htonl(16); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 2; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x43, 3, 4); /*CCC*/ p->tcph->th_seq = htonl(18); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 3; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x44, 1, 4); p->tcph->th_seq = htonl(22); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 1; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x45, 2, 4); p->tcph->th_seq = htonl(25); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 2; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x46, 3, 4); /*FFF*/ p->tcph->th_seq = htonl(27); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 3; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x47, 2, 4); p->tcph->th_seq = htonl(30); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 2; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x48, 2, 4); p->tcph->th_seq = htonl(32); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 2; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x49, 1, 4); p->tcph->th_seq = htonl(34); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 1; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x4a, 4, 4); /*JJJJ*/ p->tcph->th_seq = htonl(13); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 4; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x4b, 3, 4); /*KKK*/ p->tcph->th_seq = htonl(18); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 3; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x4c, 3, 4); /*LLL*/ p->tcph->th_seq = htonl(21); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 3; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x4d, 3, 4); /*MMM*/ p->tcph->th_seq = htonl(24); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 3; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x4e, 1, 4); p->tcph->th_seq = htonl(28); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 1; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x4f, 1, 4); p->tcph->th_seq = htonl(31); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 1; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x50, 1, 4); p->tcph->th_seq = htonl(32); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 1; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x51, 2, 4); p->tcph->th_seq = htonl(34); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 2; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x30, 1, 4); p->tcph->th_seq = htonl(11); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 1; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(ra_ctx); SCFree(p); return 1; } /** \brief The Function to create the packet with given payload, which is used * to test the reassembly of the engine. * * \param payload The variable used to store the payload contents of the * current packet. * \param value The value which current payload will have for this packet * \param payload_len The length of the filed payload for current packet. * \param len Length of the payload array */ void <API key>(uint8_t *payload, uint8_t value, uint8_t payload_len, uint8_t len) { uint8_t i; for (i = 0; i < payload_len; i++) payload[i] = value; for (; i < len; i++) payload = NULL; } /** \brief The Function Checks the reassembled stream contents against predefined * stream contents according to OS policy used. * * \param stream_policy Predefined value of stream for different OS policies * \param stream Reassembled stream returned from the reassembly functions */ int <API key>(uint8_t *stream_policy, uint16_t sp_size, TcpStream *stream) { TcpSegment *temp; uint16_t i = 0; uint8_t j; #ifdef DEBUG if (SCLogDebugEnabled()) { TcpSegment *temp1; for (temp1 = stream->seg_list; temp1 != NULL; temp1 = temp1->next) PrintRawDataFp(stdout, temp1->payload, temp1->payload_len); PrintRawDataFp(stdout, stream_policy, sp_size); } #endif for (temp = stream->seg_list; temp != NULL; temp = temp->next) { j = 0; for (; j < temp->payload_len; j++) { SCLogDebug("i %"PRIu16", len %"PRIu32", stream %"PRIx32" and temp is %"PRIx8"", i, temp->payload_len, stream_policy[i], temp->payload[j]); if (stream_policy[i] == temp->payload[j]) { i++; continue; } else return 0; } } return 1; } /** \brief The Function Checks the Stream Queue contents against predefined * stream contents. * * \param stream_contents Predefined value of stream contents * \param stream Queue which has the stream contents * * \retval On success the function returns 1, on failure 0. */ static int <API key> (TcpSession *ssn, uint8_t *stream_contents) { SCEnter(); StreamMsg *msg; uint16_t i = 0; uint8_t j; uint8_t cnt = 0; if (ssn == NULL) { printf("ssn == NULL, "); SCReturnInt(0); } if (ssn->toserver_smsg_head == NULL) { printf("ssn->toserver_smsg_head == NULL, "); SCReturnInt(0); } msg = ssn->toserver_smsg_head; while(msg != NULL) { cnt++; j = 0; for (; j < msg->data_len; j++) { SCLogDebug("i is %" PRIu32 " and len is %" PRIu32 " and temp is %" PRIx32 "", i, msg->data_len, msg->data[j]); if (stream_contents[i] == msg->data[j]) { i++; continue; } else { SCReturnInt(0); } } msg = msg->next; } SCReturnInt(1); } /* \brief The function craft packets to test the overlapping, where * new segment stats before the list segment. * * \param stream The stream which will contain the reassembled segments and * also tells the OS policy used for reassembling the segments. */ static int <API key>(TcpStream *stream) { TcpSession ssn; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; uint8_t payload[4]; TCPHdr tcph; <API key> *ra_ctx = <API key>(NULL); /* prevent L7 from kicking in */ <API key>(FLOW_PKT_TOSERVER, 4096); <API key>(FLOW_PKT_TOCLIENT, 4096); PacketQueue pq; memset(&pq,0,sizeof(PacketQueue)); memset(&ssn, 0, sizeof (TcpSession)); memset(&f, 0, sizeof (Flow)); memset(&tcph, 0, sizeof (TCPHdr)); ThreadVars tv; memset(&tv, 0, sizeof (ThreadVars)); FLOW_INITIALIZE(&f); f.protoctx = &ssn; f.proto = IPPROTO_TCP; p->src.family = AF_INET; p->dst.family = AF_INET; p->proto = IPPROTO_TCP; p->flow = &f; tcph.th_win = 5480; tcph.th_flags = TH_PUSH | TH_ACK; p->tcph = &tcph; p->flowflags = FLOW_PKT_TOSERVER; <API key>(payload, 0x42, 1, 4); p->tcph->th_seq = htonl(16); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 1; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x44, 1, 4); p->tcph->th_seq = htonl(22); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 1; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x45, 2, 4); p->tcph->th_seq = htonl(25); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 2; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x41, 2, 4); p->tcph->th_seq = htonl(15); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 2; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x4a, 4, 4); /*JJJJ*/ p->tcph->th_seq = htonl(14); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 4; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } SCLogDebug("sending segment with SEQ 21, len 3"); <API key>(payload, 0x4c, 3, 4); /*LLL*/ p->tcph->th_seq = htonl(21); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 3; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x4d, 3, 4); /*MMM*/ p->tcph->th_seq = htonl(24); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 3; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } SCFree(p); return 1; } /* \brief The function craft packets to test the overlapping, where * new segment stats at the same seq no. as the list segment. * * \param stream The stream which will contain the reassembled segments and * also tells the OS policy used for reassembling the segments. */ static int <API key>(TcpStream *stream) { TcpSession ssn; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; uint8_t payload[4]; TCPHdr tcph; <API key> *ra_ctx = <API key>(NULL); PacketQueue pq; memset(&pq,0,sizeof(PacketQueue)); /* prevent L7 from kicking in */ <API key>(FLOW_PKT_TOSERVER, 4096); <API key>(FLOW_PKT_TOCLIENT, 4096); memset(&ssn, 0, sizeof (TcpSession)); memset(&f, 0, sizeof (Flow)); memset(&tcph, 0, sizeof (TCPHdr)); ThreadVars tv; memset(&tv, 0, sizeof (ThreadVars)); FLOW_INITIALIZE(&f); f.protoctx = &ssn; f.proto = IPPROTO_TCP; p->src.family = AF_INET; p->dst.family = AF_INET; p->proto = IPPROTO_TCP; p->flow = &f; tcph.th_win = 5480; tcph.th_flags = TH_PUSH | TH_ACK; p->tcph = &tcph; p->flowflags = FLOW_PKT_TOSERVER; <API key>(payload, 0x43, 3, 4); /*CCC*/ p->tcph->th_seq = htonl(18); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 3; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x48, 2, 4); p->tcph->th_seq = htonl(32); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 2; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x49, 1, 4); p->tcph->th_seq = htonl(34); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 1; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x4b, 3, 4); /*KKK*/ p->tcph->th_seq = htonl(18); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 3; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x4c, 4, 4); /*LLLL*/ p->tcph->th_seq = htonl(18); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 4; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x50, 1, 4); p->tcph->th_seq = htonl(32); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 1; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x51, 2, 4); p->tcph->th_seq = htonl(34); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 2; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } SCFree(p); return 1; } /* \brief The function craft packets to test the overlapping, where * new segment stats after the list segment. * * \param stream The stream which will contain the reassembled segments and * also tells the OS policy used for reassembling the segments. */ static int <API key>(TcpStream *stream) { TcpSession ssn; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; uint8_t payload[4]; TCPHdr tcph; <API key> *ra_ctx = <API key>(NULL); PacketQueue pq; memset(&pq,0,sizeof(PacketQueue)); /* prevent L7 from kicking in */ <API key>(FLOW_PKT_TOSERVER, 4096); <API key>(FLOW_PKT_TOCLIENT, 4096); memset(&ssn, 0, sizeof (TcpSession)); memset(&f, 0, sizeof (Flow)); memset(&tcph, 0, sizeof (TCPHdr)); ThreadVars tv; memset(&tv, 0, sizeof (ThreadVars)); FLOW_INITIALIZE(&f); f.protoctx = &ssn; f.proto = IPPROTO_TCP; p->src.family = AF_INET; p->dst.family = AF_INET; p->proto = IPPROTO_TCP; p->flow = &f; tcph.th_win = 5480; tcph.th_flags = TH_PUSH | TH_ACK; p->tcph = &tcph; p->flowflags = FLOW_PKT_TOSERVER; <API key>(payload, 0x41, 2, 4); p->tcph->th_seq = htonl(12); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 2; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x46, 3, 4); /*FFF*/ p->tcph->th_seq = htonl(27); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 3; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x47, 2, 4); p->tcph->th_seq = htonl(30); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 2; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x4a, 2, 4); p->tcph->th_seq = htonl(13); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 2; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x4f, 1, 4); p->tcph->th_seq = htonl(31); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 1; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } <API key>(payload, 0x4e, 1, 4); p->tcph->th_seq = htonl(28); p->tcph->th_ack = htonl(31); p->payload = payload; p->payload_len = 1; if (<API key>(&tv, ra_ctx,&ssn, stream, p, &pq) == -1) { SCFree(p); return 0; } SCFree(p); return 1; } /** \brief The Function to test the reassembly when new segment starts * before the list segment and BSD policy is used to reassemble * segments. */ static int <API key>(void) { TcpStream stream; uint8_t stream_before_bsd[10] = {0x4a, 0x4a, 0x4a, 0x4a, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d, 0x4d}; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_BSD; StreamTcpInitConfig(TRUE); if (<API key>(&stream) == 0) { printf("failed in segments reassembly!!\n"); return 0; } if (<API key>(stream_before_bsd,sizeof(stream_before_bsd), &stream) == 0) { printf("failed in stream matching!!\n"); return 0; } StreamTcpFreeConfig(TRUE); return 1; } /** \brief The Function to test the reassembly when new segment starts * at the same seq no. as the list segment and BSD policy is used * to reassemble segments. */ static int <API key>(void) { TcpStream stream; uint8_t stream_same_bsd[8] = {0x43, 0x43, 0x43, 0x4c, 0x48, 0x48, 0x49, 0x51}; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_BSD; StreamTcpInitConfig(TRUE); if (<API key>(&stream) == 0) { printf("failed in segments reassembly!!\n"); return 0; } if (<API key>(stream_same_bsd, sizeof(stream_same_bsd), &stream) == 0) { printf("failed in stream matching!!\n"); return 0; } StreamTcpFreeConfig(TRUE); return 1; } /** \brief The Function to test the reassembly when new segment starts * after the list segment and BSD policy is used to reassemble * segments. */ static int <API key>(void) { TcpStream stream; uint8_t stream_after_bsd[8] = {0x41, 0x41, 0x4a, 0x46, 0x46, 0x46, 0x47, 0x47}; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_BSD; StreamTcpInitConfig(TRUE); if (<API key>(&stream) == 0) { printf("failed in segments reassembly!!\n"); return 0; } if (<API key>(stream_after_bsd, sizeof(stream_after_bsd), &stream) == 0) { printf("failed in stream matching!!\n"); return 0; } StreamTcpFreeConfig(TRUE); return 1; } /** \brief The Function to test the reassembly engine for all the case * before, same and after overlapping and BSD policy is used to * reassemble segments. */ static int <API key>(void) { TcpStream stream; uint8_t stream_bsd[25] = {0x30, 0x41, 0x41, 0x41, 0x4a, 0x4a, 0x42, 0x43, 0x43, 0x43, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d, 0x4d, 0x46, 0x46, 0x46, 0x47, 0x47, 0x48, 0x48, 0x49, 0x51}; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_BSD; StreamTcpInitConfig(TRUE); if (<API key>(&stream) == 0) { printf("failed in segments reassembly: "); return 0; } if (<API key>(stream_bsd, sizeof(stream_bsd), &stream) == 0) { printf("failed in stream matching: "); return 0; } StreamTcpFreeConfig(TRUE); return 1; } /** \brief The Function to test the reassembly when new segment starts * before the list segment and VISTA policy is used to reassemble * segments. */ static int <API key>(void) { TcpStream stream; uint8_t stream_before_vista[10] = {0x4a, 0x41, 0x42, 0x4a, 0x4c, 0x44, 0x4c, 0x4d, 0x45, 0x45}; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_VISTA; StreamTcpInitConfig(TRUE); if (<API key>(&stream) == 0) { printf("failed in segments reassembly!!\n"); return 0; } if (<API key>(stream_before_vista, sizeof(stream_before_vista), &stream) == 0) { printf("failed in stream matching!!\n"); return 0; } StreamTcpFreeConfig(TRUE); return 1; } /** \brief The Function to test the reassembly when new segment starts * at the same seq no. as the list segment and VISTA policy is used * to reassemble segments. */ static int <API key>(void) { TcpStream stream; uint8_t stream_same_vista[8] = {0x43, 0x43, 0x43, 0x4c, 0x48, 0x48, 0x49, 0x51}; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_VISTA; StreamTcpInitConfig(TRUE); if (<API key>(&stream) == 0) { printf("failed in segments reassembly!!\n"); return 0; } if (<API key>(stream_same_vista, sizeof(stream_same_vista), &stream) == 0) { printf("failed in stream matching!!\n"); return 0; } StreamTcpFreeConfig(TRUE); return 1; } /** \brief The Function to test the reassembly when new segment starts * after the list segment and BSD policy is used to reassemble * segments. */ static int <API key>(void) { TcpStream stream; uint8_t stream_after_vista[8] = {0x41, 0x41, 0x4a, 0x46, 0x46, 0x46, 0x47, 0x47}; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_VISTA; StreamTcpInitConfig(TRUE); if (<API key>(&stream) == 0) { printf("failed in segments reassembly!!\n"); return 0; } if (<API key>(stream_after_vista, sizeof(stream_after_vista), &stream) == 0) { printf("failed in stream matching!!\n"); return 0; } StreamTcpFreeConfig(TRUE); return 1; } /** \brief The Function to test the reassembly engine for all the case * before, same and after overlapping and VISTA policy is used to * reassemble segments. */ static int <API key>(void) { TcpStream stream; uint8_t stream_vista[25] = {0x30, 0x41, 0x41, 0x41, 0x4a, 0x42, 0x42, 0x43, 0x43, 0x43, 0x4c, 0x44, 0x4c, 0x4d, 0x45, 0x45, 0x46, 0x46, 0x46, 0x47, 0x47, 0x48, 0x48, 0x49, 0x51}; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_VISTA; StreamTcpInitConfig(TRUE); if (<API key>(&stream) == 0) { printf("failed in segments reassembly!!\n"); return 0; } if (<API key>(stream_vista, sizeof(stream_vista), &stream) == 0) { printf("failed in stream matching!!\n"); return 0; } StreamTcpFreeConfig(TRUE); return 1; } /** \brief The Function to test the reassembly when new segment starts * before the list segment and LINUX policy is used to reassemble * segments. */ static int <API key>(void) { TcpStream stream; uint8_t stream_before_linux[10] = {0x4a, 0x4a, 0x4a, 0x4a, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d, 0x4d}; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_LINUX; StreamTcpInitConfig(TRUE); if (<API key>(&stream) == 0) { printf("failed in segments reassembly!!\n"); return 0; } if (<API key>(stream_before_linux, sizeof(stream_before_linux), &stream) == 0) { printf("failed in stream matching!!\n"); return 0; } StreamTcpFreeConfig(TRUE); return 1; } /** \brief The Function to test the reassembly when new segment starts * at the same seq no. as the list segment and LINUX policy is used * to reassemble segments. */ static int <API key>(void) { TcpStream stream; uint8_t stream_same_linux[8] = {0x4c, 0x4c, 0x4c, 0x4c, 0x48, 0x48, 0x51, 0x51}; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_LINUX; StreamTcpInitConfig(TRUE); if (<API key>(&stream) == 0) { printf("failed in segments reassembly!!\n"); return 0; } if (<API key>(stream_same_linux, sizeof(stream_same_linux), &stream) == 0) { printf("failed in stream matching!!\n"); return 0; } StreamTcpFreeConfig(TRUE); return 1; } /** \brief The Function to test the reassembly when new segment starts * after the list segment and LINUX policy is used to reassemble * segments. */ static int <API key>(void) { TcpStream stream; uint8_t stream_after_linux[8] = {0x41, 0x41, 0x4a, 0x46, 0x46, 0x46, 0x47, 0x47}; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_LINUX; StreamTcpInitConfig(TRUE); if (<API key>(&stream) == 0) { printf("failed in segments reassembly!!\n"); return 0; } if (<API key>(stream_after_linux, sizeof(stream_after_linux), &stream) == 0) { printf("failed in stream matching!!\n"); return 0; } StreamTcpFreeConfig(TRUE); return 1; } /** \brief The Function to test the reassembly engine for all the case * before, same and after overlapping and LINUX policy is used to * reassemble segments. */ static int <API key>(void) { TcpStream stream; uint8_t stream_linux[25] = {0x30, 0x41, 0x41, 0x41, 0x4a, 0x4a, 0x42, 0x43, 0x43, 0x43, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d, 0x4d, 0x46, 0x46, 0x46, 0x47, 0x47, 0x48, 0x48, 0x51, 0x51}; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_LINUX; StreamTcpInitConfig(TRUE); if (<API key>(&stream) == 0) { printf("failed in segments reassembly!!\n"); return 0; } if (<API key>(stream_linux, sizeof(stream_linux), &stream) == 0) { printf("failed in stream matching!!\n"); return 0; } StreamTcpFreeConfig(TRUE); return 1; } /** \brief The Function to test the reassembly when new segment starts * before the list segment and OLD_LINUX policy is used to reassemble * segments. */ static int <API key>(void) { TcpStream stream; uint8_t <API key>[10] = {0x4a, 0x4a, 0x4a, 0x4a, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d, 0x4d}; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_OLD_LINUX; StreamTcpInitConfig(TRUE); if (<API key>(&stream) == 0) { printf("failed in segments reassembly!!\n"); return 0; } if (<API key>(<API key>, sizeof(<API key>), &stream) == 0) { printf("failed in stream matching!!\n"); return 0; } StreamTcpFreeConfig(TRUE); return 1; } /** \brief The Function to test the reassembly when new segment starts * at the same seq no. as the list segment and OLD_LINUX policy is * used to reassemble segments. */ static int <API key>(void) { TcpStream stream; uint8_t <API key>[8] = {0x4c, 0x4c, 0x4c, 0x4c, 0x48, 0x48, 0x51, 0x51}; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_OLD_LINUX; StreamTcpInitConfig(TRUE); if (<API key>(&stream) == 0) { printf("failed in segments reassembly!!\n"); return 0; } if (<API key>(<API key>, sizeof(<API key>), &stream) == 0) { printf("failed in stream matching!!\n"); return 0; } StreamTcpFreeConfig(TRUE); return 1; } /** \brief The Function to test the reassembly when new segment starts * after the list segment and OLD_LINUX policy is used to reassemble * segments. */ static int <API key>(void) { TcpStream stream; uint8_t <API key>[8] = {0x41, 0x41, 0x4a, 0x46, 0x46, 0x46, 0x47, 0x47}; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_OLD_LINUX; StreamTcpInitConfig(TRUE); if (<API key>(&stream) == 0) { printf("failed in segments reassembly!!\n"); return 0; } if (<API key>(<API key>, sizeof(<API key>), &stream) == 0) { printf("failed in stream matching!!\n"); return 0; } StreamTcpFreeConfig(TRUE); return 1; } /** \brief The Function to test the reassembly engine for all the case * before, same and after overlapping and OLD_LINUX policy is used to * reassemble segments. */ static int <API key>(void) { TcpStream stream; uint8_t stream_old_linux[25] = {0x30, 0x41, 0x41, 0x41, 0x4a, 0x4a, 0x42, 0x4b, 0x4b, 0x4b, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d, 0x4d, 0x46, 0x46, 0x46, 0x47, 0x47, 0x48, 0x48, 0x51, 0x51}; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_OLD_LINUX; StreamTcpInitConfig(TRUE); if (<API key>(&stream) == 0) { printf("failed in segments reassembly!!\n"); return 0; } if (<API key>(stream_old_linux, sizeof(stream_old_linux), &stream) == 0) { printf("failed in stream matching!!\n"); return 0; } StreamTcpFreeConfig(TRUE); return 1; } /** \brief The Function to test the reassembly when new segment starts * before the list segment and SOLARIS policy is used to reassemble * segments. */ static int <API key>(void) { TcpStream stream; uint8_t <API key>[10] = {0x4a, 0x4a, 0x4a, 0x4a, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d, 0x4d}; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_SOLARIS; StreamTcpInitConfig(TRUE); if (<API key>(&stream) == 0) { printf("failed in segments reassembly!!\n"); return 0; } if (<API key>(<API key>, sizeof(<API key>), &stream) == 0) { printf("failed in stream matching!!\n"); return 0; } StreamTcpFreeConfig(TRUE); return 1; } /** \brief The Function to test the reassembly when new segment starts * at the same seq no. as the list segment and SOLARIS policy is used * to reassemble segments. */ static int <API key>(void) { TcpStream stream; uint8_t stream_same_solaris[8] = {0x4c, 0x4c, 0x4c, 0x4c, 0x48, 0x48, 0x51, 0x51}; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_SOLARIS; StreamTcpInitConfig(TRUE); if (<API key>(&stream) == 0) { printf("failed in segments reassembly!!\n"); return 0; } if (<API key>(stream_same_solaris, sizeof(stream_same_solaris), &stream) == 0) { printf("failed in stream matching!!\n"); return 0; } StreamTcpFreeConfig(TRUE); return 1; } /** \brief The Function to test the reassembly when new segment starts * after the list segment and SOLARIS policy is used to reassemble * segments. */ static int <API key>(void) { TcpStream stream; uint8_t <API key>[8] = {0x41, 0x4a, 0x4a, 0x46, 0x46, 0x46, 0x47, 0x47}; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_SOLARIS; StreamTcpInitConfig(TRUE); if (<API key>(&stream) == 0) { printf("failed in segments reassembly!!\n"); StreamTcpFreeConfig(TRUE); return 0; } if (<API key>(<API key>, sizeof(<API key>), &stream) == 0) { printf("failed in stream matching!!\n"); StreamTcpFreeConfig(TRUE); return 0; } StreamTcpFreeConfig(TRUE); return 1; } /** \brief The Function to test the reassembly engine for all the case * before, same and after overlapping and SOLARIS policy is used to * reassemble segments. */ static int <API key>(void) { TcpStream stream; uint8_t stream_solaris[25] = {0x30, 0x41, 0x4a, 0x4a, 0x4a, 0x42, 0x42, 0x4b, 0x4b, 0x4b, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d, 0x4d, 0x46, 0x46, 0x46, 0x47, 0x47, 0x48, 0x48, 0x51, 0x51}; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_SOLARIS; StreamTcpInitConfig(TRUE); if (<API key>(&stream) == 0) { printf("failed in segments reassembly!!\n"); StreamTcpFreeConfig(TRUE); return 0; } if (<API key>(stream_solaris, sizeof(stream_solaris), &stream) == 0) { printf("failed in stream matching!!\n"); StreamTcpFreeConfig(TRUE); return 0; } StreamTcpFreeConfig(TRUE); return 1; } /** \brief The Function to test the reassembly when new segment starts * before the list segment and LAST policy is used to reassemble * segments. */ static int <API key>(void) { TcpStream stream; uint8_t stream_before_last[10] = {0x4a, 0x4a, 0x4a, 0x4a, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d, 0x4d}; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_LAST; StreamTcpInitConfig(TRUE); if (<API key>(&stream) == 0) { printf("failed in segments reassembly!!\n"); return 0; } if (<API key>(stream_before_last, sizeof(stream_before_last), &stream) == 0) { printf("failed in stream matching!!\n"); return 0; } StreamTcpFreeConfig(TRUE); return 1; } /** \brief The Function to test the reassembly when new segment starts * at the same seq no. as the list segment and LAST policy is used * to reassemble segments. */ static int <API key>(void) { TcpStream stream; uint8_t stream_same_last[8] = {0x4c, 0x4c, 0x4c, 0x4c, 0x50, 0x48, 0x51, 0x51}; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_LAST; StreamTcpInitConfig(TRUE); if (<API key>(&stream) == 0) { printf("failed in segments reassembly!!\n"); return 0; } if (<API key>(stream_same_last, sizeof(stream_same_last), &stream) == 0) { printf("failed in stream matching!!\n"); return 0; } StreamTcpFreeConfig(TRUE); return 1; } /** \brief The Function to test the reassembly when new segment starts * after the list segment and LAST policy is used to reassemble * segments. */ static int <API key>(void) { TcpStream stream; uint8_t stream_after_last[8] = {0x41, 0x4a, 0x4a, 0x46, 0x4e, 0x46, 0x47, 0x4f}; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_LAST; StreamTcpInitConfig(TRUE); if (<API key>(&stream) == 0) { printf("failed in segments reassembly!!\n"); return 0; } if (<API key>(stream_after_last, sizeof(stream_after_last), &stream) == 0) { printf("failed in stream matching!!\n"); return 0; } StreamTcpFreeConfig(TRUE); return 1; } /** \brief The Function to test the reassembly engine for all the case * before, same and after overlapping and LAST policy is used to * reassemble segments. */ static int <API key>(void) { int ret = 0; TcpStream stream; uint8_t stream_last[25] = {0x30, 0x41, 0x4a, 0x4a, 0x4a, 0x4a, 0x42, 0x4b, 0x4b, 0x4b, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d, 0x4d, 0x46, 0x4e, 0x46, 0x47, 0x4f, 0x50, 0x48, 0x51, 0x51}; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_LAST; StreamTcpInitConfig(TRUE); if (<API key>(&stream) == 0) { printf("failed in segments reassembly: "); goto end; } if (<API key>(stream_last, sizeof(stream_last), &stream) == 0) { printf("failed in stream matching: "); goto end; } ret = 1; end: StreamTcpFreeConfig(TRUE); return ret; } /** \brief The Function to test the missed packets handling with given payload, * which is used to test the reassembly of the engine. * * \param stream Stream which contain the packets * \param seq Sequence number of the packet * \param ack Acknowledgment number of the packet * \param payload The variable used to store the payload contents of the * current packet. * \param len The length of the payload for current packet. * \param th_flag The TCP flags * \param flowflags The packet flow direction * \param state The TCP session state * * \retval On success it returns 0 and on failure it return -1. */ static int <API key> (<API key> *ra_ctx, TcpSession *ssn, uint32_t seq, uint32_t ack, uint8_t *payload, uint16_t len, uint8_t th_flags, uint8_t flowflags, uint8_t state) { Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return -1; Flow f; TCPHdr tcph; Port sp; Port dp; struct in_addr in; ThreadVars tv; PacketQueue pq; memset(&pq,0,sizeof(PacketQueue)); memset(&f, 0, sizeof (Flow)); memset(&tcph, 0, sizeof (TCPHdr)); memset(&tv, 0, sizeof (ThreadVars)); sp = 200; dp = 220; FLOW_INITIALIZE(&f); if (inet_pton(AF_INET, "1.2.3.4", &in) != 1) { SCFree(p); return -1; } f.src.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "1.2.3.5", &in) != 1) { SCFree(p); return -1; } f.dst.addr_data32[0] = in.s_addr; f.flags |= FLOW_IPV4; f.sp = sp; f.dp = dp; f.protoctx = ssn; f.proto = IPPROTO_TCP; p->flow = &f; tcph.th_win = htons(5480); tcph.th_seq = htonl(seq); tcph.th_ack = htonl(ack); tcph.th_flags = th_flags; p->tcph = &tcph; p->flowflags = flowflags; p->payload = payload; p->payload_len = len; ssn->state = state; TcpStream *s = NULL; if (flowflags & FLOW_PKT_TOSERVER) { s = &ssn->server; } else { s = &ssn->client; } SCMutexLock(&f.m); if (<API key>(&tv, ra_ctx, ssn, s, p, &pq) == -1) { SCMutexUnlock(&f.m); SCFree(p); return -1; } SCMutexUnlock(&f.m); SCFree(p); return 0; } /** * \test Test the handling of packets missed by both IDS and the end host. * The packet is missed in the starting of the stream. * * \retval On success it returns 1 and on failure 0. */ static int <API key> (void) { int ret = 0; uint8_t payload[4]; uint32_t seq; uint32_t ack; TcpSession ssn; uint8_t th_flag; uint8_t flowflags; uint8_t check_contents[7] = {0x41, 0x41, 0x41, 0x42, 0x42, 0x43, 0x43}; <API key> *ra_ctx = <API key>(NULL); memset(&ssn, 0, sizeof (TcpSession)); flowflags = FLOW_PKT_TOSERVER; th_flag = TH_ACK|TH_PUSH; ack = 20; StreamTcpInitConfig(TRUE); <API key>(payload, 0x42, 2, 4); seq = 10; if (<API key> (ra_ctx, &ssn, seq, ack, payload, 2, th_flag, flowflags, TCP_ESTABLISHED) == -1){ printf("failed in segments reassembly: "); goto end; } <API key>(payload, 0x43, 2, 4); seq = 12; if (<API key> (ra_ctx, &ssn, seq, ack, payload, 2, th_flag, flowflags, TCP_ESTABLISHED) == -1){ printf("failed in segments reassembly: "); goto end; } ssn.server.next_seq = 14; <API key>(payload, 0x41, 3, 4); /*AAA*/ seq = 7; if (<API key> (ra_ctx, &ssn, seq, ack, payload, 3, th_flag, flowflags, TCP_ESTABLISHED) == -1) { printf("failed in segments reassembly: "); goto end; } if (<API key>(check_contents, sizeof(check_contents), &ssn.server) == 0) { printf("failed in stream matching: "); goto end; } ret = 1; end: <API key>(ra_ctx); StreamTcpFreeConfig(TRUE); return ret; } /** * \test Test the handling of packets missed by both IDS and the end host. * The packet is missed in the middle of the stream. * * \retval On success it returns 1 and on failure 0. */ static int <API key> (void) { int ret = 0; uint8_t payload[4]; uint32_t seq; uint32_t ack; TcpSession ssn; uint8_t th_flag; uint8_t flowflags; uint8_t check_contents[7] = {0x41, 0x41, 0x41, 0x42, 0x42, 0x43, 0x43}; memset(&ssn, 0, sizeof (TcpSession)); flowflags = FLOW_PKT_TOSERVER; th_flag = TH_ACK|TH_PUSH; ack = 20; StreamTcpInitConfig(TRUE); <API key> *ra_ctx = <API key>(NULL); <API key>(payload, 0x41, 3, 4); /*AAA*/ seq = 10; if (<API key> (ra_ctx, &ssn, seq, ack, payload, 3, th_flag, flowflags, TCP_ESTABLISHED) == -1){ printf("failed in segments reassembly: "); goto end; } <API key>(payload, 0x43, 2, 4); seq = 15; if (<API key> (ra_ctx, &ssn, seq, ack, payload, 2, th_flag, flowflags, TCP_ESTABLISHED) == -1){ printf("failed in segments reassembly: "); goto end; } <API key>(payload, 0x42, 2, 4); seq = 13; if (<API key> (ra_ctx, &ssn, seq, ack, payload, 2, th_flag, flowflags, TCP_ESTABLISHED) == -1) { printf("failed in segments reassembly: "); goto end; } if (<API key>(check_contents, sizeof(check_contents), &ssn.server) == 0) { printf("failed in stream matching: "); goto end; } ret = 1; end: <API key>(ra_ctx); StreamTcpFreeConfig(TRUE); return ret; } /** * \test Test the handling of packets missed by both IDS and the end host. * The packet is missed in the end of the stream. * * \retval On success it returns 1 and on failure 0. */ static int <API key> (void) { int ret = 0; uint8_t payload[4]; uint32_t seq; uint32_t ack; TcpSession ssn; uint8_t th_flag; uint8_t flowflags; uint8_t check_contents[7] = {0x41, 0x41, 0x41, 0x42, 0x42, 0x43, 0x43}; memset(&ssn, 0, sizeof (TcpSession)); flowflags = FLOW_PKT_TOSERVER; th_flag = TH_ACK|TH_PUSH; ack = 20; StreamTcpInitConfig(TRUE); <API key> *ra_ctx = <API key>(NULL); <API key>(payload, 0x41, 3, 4); /*AAA*/ seq = 10; if (<API key> (ra_ctx, &ssn, seq, ack, payload, 3, th_flag, flowflags, TCP_ESTABLISHED) == -1){ printf("failed in segments reassembly: "); goto end; } <API key>(payload, 0x42, 2, 4); seq = 13; if (<API key> (ra_ctx, &ssn, seq, ack, payload, 2, th_flag, flowflags, TCP_ESTABLISHED) == -1){ printf("failed in segments reassembly: "); goto end; } <API key>(payload, 0x43, 2, 4); seq = 15; if (<API key> (ra_ctx, &ssn, seq, ack, payload, 2, th_flag, flowflags, TCP_ESTABLISHED) == -1) { printf("failed in segments reassembly: "); goto end; } if (<API key>(check_contents, sizeof(check_contents), &ssn.server) == 0) { printf("failed in stream matching: "); goto end; } ret = 1; end: <API key>(ra_ctx); StreamTcpFreeConfig(TRUE); return ret; } /** * \test Test the handling of packets missed by IDS, but the end host has * received it and send the acknowledgment of it. The packet is missed * in the starting of the stream. * * \retval On success it returns 1 and on failure 0. */ static int <API key> (void) { int ret = 0; uint8_t payload[4]; uint32_t seq; uint32_t ack; uint8_t th_flag; uint8_t th_flags; uint8_t flowflags; uint8_t check_contents[5] = {0x41, 0x41, 0x42, 0x42, 0x42}; TcpSession ssn; memset(&ssn, 0, sizeof (TcpSession)); <API key> *ra_ctx = <API key>(NULL); StreamTcpInitConfig(TRUE); <API key>(FLOW_PKT_TOSERVER, 4096); <API key>(FLOW_PKT_TOCLIENT, 4096); flowflags = FLOW_PKT_TOSERVER; th_flag = TH_ACK|TH_PUSH; th_flags = TH_ACK; ssn.server.last_ack = 22; ssn.server.ra_raw_base_seq = ssn.server.ra_app_base_seq = 6; ssn.server.isn = 6; <API key>(payload, 0x41, 2, 4); seq = 10; ack = 20; if (<API key> (ra_ctx, &ssn, seq, ack, payload, 2, th_flag, flowflags, TCP_ESTABLISHED) == -1) { printf("failed in segments reassembly (1): "); goto end; } flowflags = FLOW_PKT_TOCLIENT; <API key>(payload, 0x00, 0, 4); seq = 20; ack = 12; if (<API key> (ra_ctx, &ssn, seq, ack, payload, 0, th_flags, flowflags, TCP_ESTABLISHED) == -1) { printf("failed in segments reassembly (2): "); goto end; } flowflags = FLOW_PKT_TOSERVER; <API key>(payload, 0x42, 3, 4); /*BBB*/ seq = 12; ack = 20; if (<API key> (ra_ctx, &ssn, seq, ack, payload, 3, th_flag, flowflags, TCP_ESTABLISHED) == -1) { printf("failed in segments reassembly (4): "); goto end; } flowflags = FLOW_PKT_TOCLIENT; <API key>(payload, 0x00, 0, 4); seq = 20; ack = 15; if (<API key> (ra_ctx, &ssn, seq, ack, payload, 0, th_flags, flowflags, TCP_TIME_WAIT) == -1) { printf("failed in segments reassembly (5): "); goto end; } if (<API key>(&ssn, check_contents) == 0) { printf("failed in stream matching (6): "); goto end; } ret = 1; end: <API key>(ra_ctx); StreamTcpFreeConfig(TRUE); return ret; } /** * \test Test the handling of packets missed by IDS, but the end host has * received it and send the acknowledgment of it. The packet is missed * in the middle of the stream. * * \retval On success it returns 1 and on failure 0. */ static int <API key> (void) { int ret = 0; uint8_t payload[4]; uint32_t seq; uint32_t ack; uint8_t th_flag; uint8_t th_flags; uint8_t flowflags; uint8_t check_contents[5] = {0x41, 0x41, 0x42, 0x42, 0x42}; <API key> *ra_ctx = <API key>(NULL); TcpSession ssn; memset(&ssn, 0, sizeof (TcpSession)); flowflags = FLOW_PKT_TOSERVER; th_flag = TH_ACK|TH_PUSH; th_flags = TH_ACK; ssn.server.last_ack = 22; ssn.server.ra_raw_base_seq = 9; ssn.server.isn = 9; StreamTcpInitConfig(TRUE); <API key>(payload, 0x41, 2, 4); seq = 10; ack = 20; if (<API key> (ra_ctx, &ssn, seq, ack, payload, 2, th_flag, flowflags, TCP_ESTABLISHED) == -1){ printf("failed in segments reassembly: "); goto end; } flowflags = FLOW_PKT_TOCLIENT; <API key>(payload, 0x00, 0, 4); seq = 20; ack = 15; if (<API key> (ra_ctx, &ssn, seq, ack, payload, 0, th_flags, flowflags, TCP_ESTABLISHED) == -1){ printf("failed in segments reassembly: "); goto end; } flowflags = FLOW_PKT_TOSERVER; <API key>(payload, 0x42, 3, 4); /*BBB*/ seq = 15; ack = 20; if (<API key> (ra_ctx, &ssn, seq, ack, payload, 3, th_flag, flowflags, TCP_ESTABLISHED) == -1) { printf("failed in segments reassembly: "); goto end; } flowflags = FLOW_PKT_TOCLIENT; <API key>(payload, 0x00, 0, 4); seq = 20; ack = 18; if (<API key> (ra_ctx, &ssn, seq, ack, payload, 0, th_flags, flowflags, TCP_TIME_WAIT) == -1) { printf("failed in segments reassembly: "); goto end; } if (<API key>(&ssn, check_contents) == 0) { printf("failed in stream matching: "); goto end; } ret = 1; end: <API key>(ra_ctx); StreamTcpFreeConfig(TRUE); return ret; } /** * \test Test the handling of packets missed by IDS, but the end host has * received it and send the acknowledgment of it. The packet is missed * at the end of the stream. * * \retval On success it returns 1 and on failure 0. */ static int <API key> (void) { int ret = 0; uint8_t payload[4]; uint32_t seq; uint32_t ack; uint8_t th_flag; uint8_t th_flags; uint8_t flowflags; uint8_t check_contents[6] = {0x41, 0x41, 0x42, 0x42, 0x42, 0x00}; TcpSession ssn; memset(&ssn, 0, sizeof (TcpSession)); <API key> *ra_ctx = <API key>(NULL); flowflags = FLOW_PKT_TOSERVER; th_flag = TH_ACK|TH_PUSH; th_flags = TH_ACK; ssn.server.last_ack = 22; ssn.server.ra_raw_base_seq = ssn.server.ra_app_base_seq = 9; ssn.server.isn = 9; StreamTcpInitConfig(TRUE); <API key>(payload, 0x41, 2, 4); seq = 10; ack = 20; if (<API key> (ra_ctx, &ssn, seq, ack, payload, 2, th_flag, flowflags, TCP_ESTABLISHED) == -1){ printf("failed in segments reassembly: "); goto end; } flowflags = FLOW_PKT_TOCLIENT; <API key>(payload, 0x00, 0, 4); seq = 20; ack = 12; if (<API key> (ra_ctx, &ssn, seq, ack, payload, 0, th_flags, flowflags, TCP_ESTABLISHED) == -1){ printf("failed in segments reassembly: "); goto end; } flowflags = FLOW_PKT_TOSERVER; <API key>(payload, 0x42, 3, 4); /*BBB*/ seq = 12; ack = 20; if (<API key> (ra_ctx, &ssn, seq, ack, payload, 3, th_flag, flowflags, TCP_ESTABLISHED) == -1) { printf("failed in segments reassembly: "); goto end; } flowflags = FLOW_PKT_TOCLIENT; <API key>(payload, 0x00, 0, 4); seq = 20; ack = 18; if (<API key> (ra_ctx, &ssn, seq, ack, payload, 0, th_flags, flowflags, TCP_ESTABLISHED) == -1) { printf("failed in segments reassembly: "); goto end; } th_flag = TH_FIN|TH_ACK; seq = 18; ack = 20; flowflags = FLOW_PKT_TOSERVER; <API key>(payload, 0x00, 1, 4); if (<API key> (ra_ctx, &ssn, seq, ack, payload, 1, th_flag, flowflags, TCP_ESTABLISHED) == -1) { printf("failed in segments reassembly: "); goto end; } flowflags = FLOW_PKT_TOCLIENT; <API key>(payload, 0x00, 0, 4); seq = 20; ack = 18; if (<API key> (ra_ctx, &ssn, seq, ack, payload, 0, th_flag, flowflags, TCP_TIME_WAIT) == -1) { printf("failed in segments reassembly: "); goto end; } if (<API key>(&ssn, check_contents) == 0) { printf("failed in stream matching: "); goto end; } ret = 1; end: <API key>(ra_ctx); StreamTcpFreeConfig(TRUE); return ret; } /** * \test Test to reassemble the packets using the fast track method, as most * packets arrives in order. * * \retval On success it returns 1 and on failure 0. */ static int <API key> (void) { int ret = 0; uint8_t payload[4]; uint32_t seq; uint32_t ack; uint8_t th_flag; uint8_t flowflags; uint8_t check_contents[5] = {0x41, 0x41, 0x42, 0x42, 0x42}; <API key> *ra_ctx = <API key>(NULL); TcpSession ssn; memset(&ssn, 0, sizeof (TcpSession)); flowflags = FLOW_PKT_TOSERVER; th_flag = TH_ACK|TH_PUSH; ssn.server.ra_raw_base_seq = 9; ssn.server.isn = 9; StreamTcpInitConfig(TRUE); <API key>(payload, 0x41, 2, 4); seq = 10; ack = 20; if (<API key> (ra_ctx, &ssn, seq, ack, payload, 2, th_flag, flowflags, TCP_ESTABLISHED) == -1){ printf("failed in segments reassembly: "); goto end; } flowflags = FLOW_PKT_TOSERVER; <API key>(payload, 0x42, 1, 4); seq = 15; ack = 20; if (<API key> (ra_ctx, &ssn, seq, ack, payload, 1, th_flag, flowflags, TCP_ESTABLISHED) == -1) { printf("failed in segments reassembly: "); goto end; } flowflags = FLOW_PKT_TOSERVER; <API key>(payload, 0x42, 1, 4); seq = 12; ack = 20; if (<API key> (ra_ctx, &ssn, seq, ack, payload, 1, th_flag, flowflags, TCP_ESTABLISHED) == -1) { printf("failed in segments reassembly: "); goto end; } flowflags = FLOW_PKT_TOSERVER; <API key>(payload, 0x42, 1, 4); seq = 16; ack = 20; if (<API key> (ra_ctx, &ssn, seq, ack, payload, 1, th_flag, flowflags, TCP_ESTABLISHED) == -1) { printf("failed in segments reassembly: "); goto end; } if (<API key>(check_contents, 5, &ssn.server) == 0) { printf("failed in stream matching: "); goto end; } if (ssn.server.seg_list_tail->seq != 16) { printf("failed in fast track handling: "); goto end; } ret = 1; end: <API key>(ra_ctx); StreamTcpFreeConfig(TRUE); return ret; } static int <API key>(void) { TcpSession ssn; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; TCPHdr tcph; <API key> *ra_ctx = <API key>(NULL); TcpStream stream; uint8_t ret = 0; uint8_t check_contents[35] = {0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x42, 0x42, 0x42, 0x42, 0x42, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43}; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_BSD; uint8_t payload[20] = ""; StreamTcpInitConfig(TRUE); /* prevent L7 from kicking in */ <API key>(FLOW_PKT_TOSERVER, 4096); <API key>(FLOW_PKT_TOCLIENT, 4096); PacketQueue pq; memset(&pq,0,sizeof(PacketQueue)); memset(&ssn, 0, sizeof (TcpSession)); memset(&f, 0, sizeof (Flow)); memset(&tcph, 0, sizeof (TCPHdr)); ThreadVars tv; memset(&tv, 0, sizeof (ThreadVars)); FLOW_INITIALIZE(&f); f.protoctx = &ssn; f.proto = IPPROTO_TCP; p->src.family = AF_INET; p->dst.family = AF_INET; p->proto = IPPROTO_TCP; p->flow = &f; tcph.th_win = 5480; tcph.th_flags = TH_PUSH | TH_ACK; p->tcph = &tcph; p->flowflags = FLOW_PKT_TOSERVER; p->tcph->th_seq = htonl(10); p->tcph->th_ack = htonl(31); p->payload_len = 10; <API key>(payload, 0x41, 10, 20); p->payload = payload; if (<API key>(&tv, ra_ctx,&ssn, &stream, p, &pq) == -1) goto end; p->tcph->th_seq = htonl(20); p->tcph->th_ack = htonl(31); p->payload_len = 10; <API key>(payload, 0x42, 10, 20); p->payload = payload; if (<API key>(&tv, ra_ctx,&ssn, &stream, p, &pq) == -1) goto end; p->tcph->th_seq = htonl(40); p->tcph->th_ack = htonl(31); p->payload_len = 10; <API key>(payload, 0x43, 10, 20); p->payload = payload; if (<API key>(&tv, ra_ctx,&ssn, &stream, p, &pq) == -1) goto end; p->tcph->th_seq = htonl(5); p->tcph->th_ack = htonl(31); p->payload_len = 20; <API key>(payload, 0x41, 20, 20); p->payload = payload; if (<API key>(&tv, ra_ctx,&ssn, &stream, p, &pq) == -1) goto end; if (<API key>(check_contents, 35, &stream) != 0) { ret = 1; } else { printf("failed in stream matching: "); } end: StreamTcpFreeConfig(TRUE); SCFree(p); return ret; } static int <API key>(void) { TcpSession ssn; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; TCPHdr tcph; <API key> *ra_ctx = <API key>(NULL); TcpStream stream; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_BSD; uint8_t packet[1460] = ""; StreamTcpInitConfig(TRUE); /* prevent L7 from kicking in */ <API key>(FLOW_PKT_TOSERVER, 4096); <API key>(FLOW_PKT_TOCLIENT, 4096); PacketQueue pq; memset(&pq,0,sizeof(PacketQueue)); memset(&ssn, 0, sizeof (TcpSession)); memset(&f, 0, sizeof (Flow)); memset(&tcph, 0, sizeof (TCPHdr)); ThreadVars tv; memset(&tv, 0, sizeof (ThreadVars)); FLOW_INITIALIZE(&f); f.protoctx = &ssn; f.proto = IPPROTO_TCP; p->src.family = AF_INET; p->dst.family = AF_INET; p->proto = IPPROTO_TCP; p->flow = &f; tcph.th_win = 5480; tcph.th_flags = TH_PUSH | TH_ACK; p->tcph = &tcph; p->flowflags = FLOW_PKT_TOSERVER; p->payload = packet; p->tcph->th_seq = htonl(10); p->tcph->th_ack = htonl(31); p->payload_len = 10; if (<API key>(&tv, ra_ctx,&ssn, &stream, p, &pq) == -1) { SCFree(p); return 0; } p->tcph->th_seq = htonl(20); p->tcph->th_ack = htonl(31); p->payload_len = 10; if (<API key>(&tv, ra_ctx,&ssn, &stream, p, &pq) == -1) { SCFree(p); return 0; } p->tcph->th_seq = htonl(40); p->tcph->th_ack = htonl(31); p->payload_len = 10; if (<API key>(&tv, ra_ctx,&ssn, &stream, p, &pq) == -1) { SCFree(p); return 0; } p->tcph->th_seq = htonl(5); p->tcph->th_ack = htonl(31); p->payload_len = 30; if (<API key>(&tv, ra_ctx,&ssn, &stream, p, &pq) == -1) { SCFree(p); return 0; } StreamTcpFreeConfig(TRUE); SCFree(p); return 1; } static int <API key>(void) { TcpSession ssn; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; TCPHdr tcph; <API key> *ra_ctx = <API key>(NULL); TcpStream stream; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_BSD; uint8_t packet[1460] = ""; StreamTcpInitConfig(TRUE); /* prevent L7 from kicking in */ <API key>(FLOW_PKT_TOSERVER, 4096); <API key>(FLOW_PKT_TOCLIENT, 4096); PacketQueue pq; memset(&pq,0,sizeof(PacketQueue)); memset(&ssn, 0, sizeof (TcpSession)); memset(&f, 0, sizeof (Flow)); memset(&tcph, 0, sizeof (TCPHdr)); ThreadVars tv; memset(&tv, 0, sizeof (ThreadVars)); FLOW_INITIALIZE(&f); f.protoctx = &ssn; f.proto = IPPROTO_TCP; p->src.family = AF_INET; p->dst.family = AF_INET; p->proto = IPPROTO_TCP; p->flow = &f; tcph.th_win = 5480; tcph.th_flags = TH_PUSH | TH_ACK; p->tcph = &tcph; p->flowflags = FLOW_PKT_TOSERVER; p->payload = packet; p->tcph->th_seq = htonl(857961230); p->tcph->th_ack = htonl(31); p->payload_len = 304; if (<API key>(&tv, ra_ctx,&ssn, &stream, p, &pq) == -1) { SCFree(p); return 0; } p->tcph->th_seq = htonl(857961534); p->tcph->th_ack = htonl(31); p->payload_len = 1460; if (<API key>(&tv, ra_ctx,&ssn, &stream, p, &pq) == -1) { SCFree(p); return 0; } p->tcph->th_seq = htonl(857963582); p->tcph->th_ack = htonl(31); p->payload_len = 1460; if (<API key>(&tv, ra_ctx,&ssn, &stream, p, &pq) == -1) { SCFree(p); return 0; } p->tcph->th_seq = htonl(857960946); p->tcph->th_ack = htonl(31); p->payload_len = 1460; if (<API key>(&tv, ra_ctx,&ssn, &stream, p, &pq) == -1) { SCFree(p); return 0; } StreamTcpFreeConfig(TRUE); SCFree(p); return 1; } /** \test Test the bug 56 condition */ static int <API key>(void) { TcpSession ssn; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; TCPHdr tcph; <API key> *ra_ctx = <API key>(NULL); TcpStream stream; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_BSD; uint8_t packet[1460] = ""; StreamTcpInitConfig(TRUE); /* prevent L7 from kicking in */ <API key>(FLOW_PKT_TOSERVER, 10); <API key>(FLOW_PKT_TOCLIENT, 10); PacketQueue pq; memset(&pq,0,sizeof(PacketQueue)); memset(&ssn, 0, sizeof (TcpSession)); memset(&f, 0, sizeof (Flow)); memset(&tcph, 0, sizeof (TCPHdr)); ThreadVars tv; memset(&tv, 0, sizeof (ThreadVars)); FLOW_INITIALIZE(&f); f.protoctx = &ssn; f.proto = IPPROTO_TCP; p->src.family = AF_INET; p->dst.family = AF_INET; p->proto = IPPROTO_TCP; p->flow = &f; tcph.th_win = 5480; tcph.th_flags = TH_PUSH | TH_ACK; p->tcph = &tcph; p->flowflags = FLOW_PKT_TOSERVER; p->payload = packet; p->tcph->th_seq = htonl(2257022155UL); p->tcph->th_ack = htonl(1374943142); p->payload_len = 142; stream.last_ack = 2257022285UL; stream.ra_raw_base_seq = 2257022172UL; stream.ra_app_base_seq = 2257022172UL; if (<API key>(&tv, ra_ctx,&ssn, &stream, p, &pq) == -1) { SCFree(p); return 0; } p->tcph->th_seq = htonl(2257022285UL); p->tcph->th_ack = htonl(1374943142); p->payload_len = 34; stream.last_ack = 2257022285UL; stream.ra_raw_base_seq = 2257022172UL; if (<API key>(&tv, ra_ctx,&ssn, &stream, p, &pq) == -1) { SCFree(p); return 0; } StreamTcpFreeConfig(TRUE); SCFree(p); return 1; } /** \test Test the bug 57 condition */ static int <API key>(void) { TcpSession ssn; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; TCPHdr tcph; <API key> *ra_ctx = <API key>(NULL); TcpStream stream; memset(&stream, 0, sizeof (TcpStream)); stream.os_policy = OS_POLICY_BSD; uint8_t packet[1460] = ""; StreamTcpInitConfig(TRUE); /* prevent L7 from kicking in */ <API key>(FLOW_PKT_TOSERVER, 10); <API key>(FLOW_PKT_TOCLIENT, 10); PacketQueue pq; memset(&pq,0,sizeof(PacketQueue)); memset(&ssn, 0, sizeof (TcpSession)); memset(&f, 0, sizeof (Flow)); memset(&tcph, 0, sizeof (TCPHdr)); ThreadVars tv; memset(&tv, 0, sizeof (ThreadVars)); FLOW_INITIALIZE(&f); f.protoctx = &ssn; f.proto = IPPROTO_TCP; p->src.family = AF_INET; p->dst.family = AF_INET; p->proto = IPPROTO_TCP; p->flow = &f; tcph.th_win = 5480; tcph.th_flags = TH_PUSH | TH_ACK; p->tcph = &tcph; p->flowflags = FLOW_PKT_TOSERVER; p->payload = packet; p->tcph->th_seq = htonl(1549588966); p->tcph->th_ack = htonl(4162241372UL); p->payload_len = 204; stream.last_ack = 1549589007; stream.ra_raw_base_seq = 1549589101; if (<API key>(&tv, ra_ctx,&ssn, &stream, p, &pq) == -1) { SCFree(p); return 0; } p->tcph->th_seq = htonl(1549589007); p->tcph->th_ack = htonl(4162241372UL); p->payload_len = 23; stream.last_ack = 1549589007; stream.ra_raw_base_seq = 1549589101; if (<API key>(&tv, ra_ctx,&ssn, &stream, p, &pq) == -1) { SCFree(p); return 0; } StreamTcpFreeConfig(TRUE); SCFree(p); return 1; } /** \test Test the bug 76 condition */ static int <API key>(void) { TcpSession ssn; Flow f; TCPHdr tcph; <API key> *ra_ctx = <API key>(NULL); TcpStream stream; uint8_t packet[1460] = ""; PacketQueue pq; ThreadVars tv; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; StreamTcpInitConfig(TRUE); /* prevent L7 from kicking in */ <API key>(FLOW_PKT_TOSERVER, 10); <API key>(FLOW_PKT_TOCLIENT, 10); memset(&stream, 0, sizeof (TcpStream)); memset(&pq,0,sizeof(PacketQueue)); memset(&ssn, 0, sizeof (TcpSession)); memset(&f, 0, sizeof (Flow)); memset(&tcph, 0, sizeof (TCPHdr)); memset(&tv, 0, sizeof (ThreadVars)); FLOW_INITIALIZE(&f); f.protoctx = &ssn; f.proto = IPPROTO_TCP; p->src.family = AF_INET; p->dst.family = AF_INET; p->proto = IPPROTO_TCP; p->flow = &f; tcph.th_win = 5480; tcph.th_flags = TH_PUSH | TH_ACK; p->tcph = &tcph; p->flowflags = FLOW_PKT_TOSERVER; p->payload = packet; stream.os_policy = OS_POLICY_BSD; p->tcph->th_seq = htonl(3061088537UL); p->tcph->th_ack = htonl(1729548549UL); p->payload_len = 1391; stream.last_ack = 3061091137UL; stream.ra_raw_base_seq = 3061091309UL; stream.ra_app_base_seq = 3061091309UL; /* pre base_seq, so should be rejected */ if (<API key>(&tv, ra_ctx,&ssn, &stream, p, &pq) != -1) { SCFree(p); return 0; } p->tcph->th_seq = htonl(3061089928UL); p->tcph->th_ack = htonl(1729548549UL); p->payload_len = 1391; stream.last_ack = 3061091137UL; stream.ra_raw_base_seq = 3061091309UL; stream.ra_app_base_seq = 3061091309UL; if (<API key>(&tv, ra_ctx,&ssn, &stream, p, &pq) == -1) { SCFree(p); return 0; } p->tcph->th_seq = htonl(3061091319UL); p->tcph->th_ack = htonl(1729548549UL); p->payload_len = 1391; stream.last_ack = 3061091137UL; stream.ra_raw_base_seq = 3061091309UL; stream.ra_app_base_seq = 3061091309UL; if (<API key>(&tv, ra_ctx,&ssn, &stream, p, &pq) == -1) { SCFree(p); return 0; } StreamTcpFreeConfig(TRUE); SCFree(p); return 1; } static int <API key> (void) { int ret = 0; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; TCPHdr tcph; Port sp; Port dp; struct in_addr in; TcpSession ssn; PacketQueue pq; memset(&pq,0,sizeof(PacketQueue)); memset(&f, 0, sizeof (Flow)); memset(&tcph, 0, sizeof (TCPHdr)); memset(&ssn, 0, sizeof(TcpSession)); ThreadVars tv; memset(&tv, 0, sizeof (ThreadVars)); StreamTcpInitConfig(TRUE); <API key> *ra_ctx = <API key>(NULL); uint8_t httpbuf2[] = "POST / HTTP/1.0\r\nUser-Agent: Victor/1.0\r\n\r\n"; uint32_t httplen2 = sizeof(httpbuf2) - 1; /* minus the \0 */ uint8_t httpbuf1[] = "HTTP/1.0 200 OK\r\nServer: VictorServer/1.0\r\n\r\n"; uint32_t httplen1 = sizeof(httpbuf1) - 1; /* minus the \0 */ FLOW_INITIALIZE(&f); if (inet_pton(AF_INET, "1.2.3.4", &in) != 1) goto end; f.src.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "1.2.3.5", &in) != 1) goto end; f.dst.addr_data32[0] = in.s_addr; sp = 200; dp = 220; ssn.server.ra_raw_base_seq = ssn.server.ra_app_base_seq = 9; ssn.server.isn = 9; ssn.server.last_ack = 60; ssn.client.ra_raw_base_seq = ssn.client.ra_app_base_seq = 9; ssn.client.isn = 9; ssn.client.last_ack = 60; f.alproto = ALPROTO_UNKNOWN; f.flags |= FLOW_IPV4; f.sp = sp; f.dp = dp; f.protoctx = &ssn; f.proto = IPPROTO_TCP; p->flow = &f; tcph.th_win = htons(5480); tcph.th_seq = htonl(10); tcph.th_ack = htonl(20); tcph.th_flags = TH_ACK|TH_PUSH; p->tcph = &tcph; p->flowflags = FLOW_PKT_TOSERVER; p->payload = httpbuf2; p->payload_len = httplen2; ssn.state = TCP_ESTABLISHED; TcpStream *s = NULL; s = &ssn.server; SCMutexLock(&f.m); if (<API key>(&tv, ra_ctx, &ssn, s, p, &pq) == -1) { printf("failed in segments reassembly, while processing toserver packet (1): "); goto end; } /* Check if we have stream smsgs in queue */ if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) > 0) { printf("there shouldn't be any stream smsgs in the queue (2): "); goto end; } p->flowflags = FLOW_PKT_TOCLIENT; p->payload = httpbuf1; p->payload_len = httplen1; tcph.th_seq = htonl(10); tcph.th_ack = htonl(55); s = &ssn.client; if (<API key>(&tv, ra_ctx, &ssn, s, p, &pq) == -1) { printf("failed in segments reassembly, while processing toserver packet (3): "); goto end; } /* Check if we have stream smsgs in queue */ if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 1) { printf("there should one stream smsg in the queue (6): "); goto end; } ret = 1; end: <API key>(ra_ctx); StreamTcpFreeConfig(TRUE); SCMutexUnlock(&f.m); SCFree(p); return ret; } /** * \test Test to make sure that we don't return the segments until the app * layer proto has been detected and after that remove the processed * segments. * * \retval On success it returns 1 and on failure 0. */ static int <API key> (void) { Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; ThreadVars tv; StreamTcpThread *stt = NULL; TCPHdr tcph; PacketQueue pq; memset(&pq,0,sizeof(PacketQueue)); memset (&f, 0, sizeof(Flow)); memset(&tv, 0, sizeof (ThreadVars)); StreamTcpThreadInit(&tv, NULL, (void **)&stt); memset(&tcph, 0, sizeof (TCPHdr)); f.flags = FLOW_IPV4; f.proto = IPPROTO_TCP; p->flow = &f; p->tcph = &tcph; SCMutexLock(&f.m); int ret = 0; StreamTcpInitConfig(TRUE); /* handshake */ tcph.th_win = htons(5480); tcph.th_flags = TH_SYN; p->flowflags = FLOW_PKT_TOSERVER; p->payload_len = 0; p->payload = NULL; if (StreamTcpPacket(&tv, p, stt, &pq) == -1) goto end; TcpSession *ssn = (TcpSession *)f.protoctx; if (<API key>(&ssn->server) || <API key>(&ssn->client) || f.alproto != ALPROTO_UNKNOWN || f.alproto_ts != ALPROTO_UNKNOWN || f.alproto_tc != ALPROTO_UNKNOWN || f.data_al_so_far[0] != 0 || f.data_al_so_far[1] != 0 || f.flags & <API key> || FLOW_IS_PM_DONE(&f, STREAM_TOSERVER) || FLOW_IS_PP_DONE(&f, STREAM_TOSERVER) || FLOW_IS_PM_DONE(&f, STREAM_TOCLIENT) || FLOW_IS_PP_DONE(&f, STREAM_TOCLIENT) || ssn->client.seg_list != NULL || ssn->server.seg_list != NULL || ssn->toserver_smsg_head != NULL || ssn->toclient_smsg_head != NULL || ssn->data_first_seen_dir != 0) { printf("failure 1\n"); goto end; } /* handshake */ p->tcph->th_ack = htonl(1); p->tcph->th_flags = TH_SYN | TH_ACK; p->flowflags = FLOW_PKT_TOCLIENT; p->payload_len = 0; p->payload = NULL; if (StreamTcpPacket(&tv, p, stt, &pq) == -1) goto end; if (<API key>(&ssn->server) || <API key>(&ssn->client) || f.alproto != ALPROTO_UNKNOWN || f.alproto_ts != ALPROTO_UNKNOWN || f.alproto_tc != ALPROTO_UNKNOWN || f.data_al_so_far[0] != 0 || f.data_al_so_far[1] != 0 || f.flags & <API key> || FLOW_IS_PM_DONE(&f, STREAM_TOSERVER) || FLOW_IS_PP_DONE(&f, STREAM_TOSERVER) || FLOW_IS_PM_DONE(&f, STREAM_TOCLIENT) || FLOW_IS_PP_DONE(&f, STREAM_TOCLIENT) || ssn->client.seg_list != NULL || ssn->server.seg_list != NULL || ssn->toserver_smsg_head != NULL || ssn->toclient_smsg_head != NULL || ssn->data_first_seen_dir != 0) { printf("failure 2\n"); goto end; } /* handshake */ p->tcph->th_ack = htonl(1); p->tcph->th_seq = htonl(1); p->tcph->th_flags = TH_ACK; p->flowflags = FLOW_PKT_TOSERVER; p->payload_len = 0; p->payload = NULL; if (StreamTcpPacket(&tv, p, stt, &pq) == -1) goto end; if (<API key>(&ssn->server) || <API key>(&ssn->client) || f.alproto != ALPROTO_UNKNOWN || f.alproto_ts != ALPROTO_UNKNOWN || f.alproto_tc != ALPROTO_UNKNOWN || f.data_al_so_far[0] != 0 || f.data_al_so_far[1] != 0 || f.flags & <API key> || FLOW_IS_PM_DONE(&f, STREAM_TOSERVER) || FLOW_IS_PP_DONE(&f, STREAM_TOSERVER) || FLOW_IS_PM_DONE(&f, STREAM_TOCLIENT) || FLOW_IS_PP_DONE(&f, STREAM_TOCLIENT) || ssn->client.seg_list != NULL || ssn->server.seg_list != NULL || ssn->toserver_smsg_head != NULL || ssn->toclient_smsg_head != NULL || ssn->data_first_seen_dir != 0) { printf("failure 3\n"); goto end; } /* partial request */ uint8_t request1[] = { 0x47, 0x45, }; p->tcph->th_ack = htonl(1); p->tcph->th_seq = htonl(1); p->tcph->th_flags = TH_PUSH | TH_ACK; p->flowflags = FLOW_PKT_TOSERVER; p->payload_len = sizeof(request1); p->payload = request1; if (StreamTcpPacket(&tv, p, stt, &pq) == -1) goto end; if (<API key>(&ssn->server) || <API key>(&ssn->client) || f.alproto != ALPROTO_UNKNOWN || f.alproto_ts != ALPROTO_UNKNOWN || f.alproto_tc != ALPROTO_UNKNOWN || f.data_al_so_far[0] != 0 || f.data_al_so_far[1] != 0 || f.flags & <API key> || FLOW_IS_PM_DONE(&f, STREAM_TOSERVER) || FLOW_IS_PP_DONE(&f, STREAM_TOSERVER) || FLOW_IS_PM_DONE(&f, STREAM_TOCLIENT) || FLOW_IS_PP_DONE(&f, STREAM_TOCLIENT) || ssn->client.seg_list == NULL || ssn->client.seg_list->next != NULL || ssn->server.seg_list != NULL || ssn->toserver_smsg_head != NULL || ssn->toclient_smsg_head != NULL || ssn->data_first_seen_dir != STREAM_TOSERVER) { printf("failure 4\n"); goto end; } /* response ack against partial request */ p->tcph->th_ack = htonl(3); p->tcph->th_seq = htonl(1); p->tcph->th_flags = TH_ACK; p->flowflags = FLOW_PKT_TOCLIENT; p->payload_len = 0; p->payload = NULL; if (StreamTcpPacket(&tv, p, stt, &pq) == -1) goto end; if (<API key>(&ssn->server) || <API key>(&ssn->client) || f.alproto != ALPROTO_UNKNOWN || f.alproto_ts != ALPROTO_UNKNOWN || f.alproto_tc != ALPROTO_UNKNOWN || f.data_al_so_far[0] != 0 || f.data_al_so_far[1] != 0 || f.flags & <API key> || FLOW_IS_PM_DONE(&f, STREAM_TOSERVER) || !FLOW_IS_PP_DONE(&f, STREAM_TOSERVER) || FLOW_IS_PM_DONE(&f, STREAM_TOCLIENT) || FLOW_IS_PP_DONE(&f, STREAM_TOCLIENT) || ssn->client.seg_list == NULL || ssn->client.seg_list->next != NULL || ssn->server.seg_list != NULL || ssn->toserver_smsg_head != NULL || ssn->toclient_smsg_head != NULL || ssn->data_first_seen_dir != STREAM_TOSERVER) { printf("failure 5\n"); goto end; } /* complete partial request */ uint8_t request2[] = { 0x54, 0x20, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x20, 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x0d, 0x0a, 0x48, 0x6f, 0x73, 0x74, 0x3a, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x0d, 0x0a, 0x55, 0x73, 0x65, 0x72, 0x2d, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x3a, 0x20, 0x41, 0x70, 0x61, 0x63, 0x68, 0x65, 0x42, 0x65, 0x6e, 0x63, 0x68, 0x2f, 0x32, 0x2e, 0x33, 0x0d, 0x0a, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x3a, 0x20, 0x2a, 0x2f, 0x2a, 0x0d, 0x0a, 0x0d, 0x0a }; p->tcph->th_ack = htonl(1); p->tcph->th_seq = htonl(3); p->tcph->th_flags = TH_PUSH | TH_ACK; p->flowflags = FLOW_PKT_TOSERVER; p->payload_len = sizeof(request2); p->payload = request2; if (StreamTcpPacket(&tv, p, stt, &pq) == -1) goto end; if (<API key>(&ssn->server) || <API key>(&ssn->client) || f.alproto != ALPROTO_UNKNOWN || f.alproto_ts != ALPROTO_UNKNOWN || f.alproto_tc != ALPROTO_UNKNOWN || f.data_al_so_far[0] != 0 || f.data_al_so_far[1] != 0 || f.flags & <API key> || FLOW_IS_PM_DONE(&f, STREAM_TOSERVER) || !FLOW_IS_PP_DONE(&f, STREAM_TOSERVER) || FLOW_IS_PM_DONE(&f, STREAM_TOCLIENT) || FLOW_IS_PP_DONE(&f, STREAM_TOCLIENT) || ssn->client.seg_list == NULL || ssn->client.seg_list->next == NULL || ssn->client.seg_list->next->next != NULL || ssn->server.seg_list != NULL || ssn->toserver_smsg_head != NULL || ssn->toclient_smsg_head != NULL || ssn->data_first_seen_dir != STREAM_TOSERVER) { printf("failure 6\n"); goto end; } /* response - request ack */ uint8_t response[] = { 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, 0x0d, 0x0a, 0x44, 0x61, 0x74, 0x65, 0x3a, 0x20, 0x46, 0x72, 0x69, 0x2c, 0x20, 0x32, 0x33, 0x20, 0x53, 0x65, 0x70, 0x20, 0x32, 0x30, 0x31, 0x31, 0x20, 0x30, 0x36, 0x3a, 0x32, 0x39, 0x3a, 0x33, 0x39, 0x20, 0x47, 0x4d, 0x54, 0x0d, 0x0a, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x41, 0x70, 0x61, 0x63, 0x68, 0x65, 0x2f, 0x32, 0x2e, 0x32, 0x2e, 0x31, 0x35, 0x20, 0x28, 0x55, 0x6e, 0x69, 0x78, 0x29, 0x20, 0x44, 0x41, 0x56, 0x2f, 0x32, 0x0d, 0x0a, 0x4c, 0x61, 0x73, 0x74, 0x2d, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x3a, 0x20, 0x54, 0x68, 0x75, 0x2c, 0x20, 0x30, 0x34, 0x20, 0x4e, 0x6f, 0x76, 0x20, 0x32, 0x30, 0x31, 0x30, 0x20, 0x31, 0x35, 0x3a, 0x30, 0x34, 0x3a, 0x34, 0x36, 0x20, 0x47, 0x4d, 0x54, 0x0d, 0x0a, 0x45, 0x54, 0x61, 0x67, 0x3a, 0x20, 0x22, 0x61, 0x62, 0x38, 0x39, 0x36, 0x35, 0x2d, 0x32, 0x63, 0x2d, 0x34, 0x39, 0x34, 0x33, 0x62, 0x37, 0x61, 0x37, 0x66, 0x37, 0x66, 0x38, 0x30, 0x22, 0x0d, 0x0a, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x2d, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x3a, 0x20, 0x62, 0x79, 0x74, 0x65, 0x73, 0x0d, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x3a, 0x20, 0x34, 0x34, 0x0d, 0x0a, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x0d, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x0d, 0x0a, 0x58, 0x2d, 0x50, 0x61, 0x64, 0x3a, 0x20, 0x61, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x62, 0x72, 0x6f, 0x77, 0x73, 0x65, 0x72, 0x20, 0x62, 0x75, 0x67, 0x0d, 0x0a, 0x0d, 0x0a, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x3c, 0x68, 0x31, 0x3e, 0x49, 0x74, 0x20, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x21, 0x3c, 0x2f, 0x68, 0x31, 0x3e, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e }; p->tcph->th_ack = htonl(88); p->tcph->th_seq = htonl(1); p->tcph->th_flags = TH_PUSH | TH_ACK; p->flowflags = FLOW_PKT_TOCLIENT; p->payload_len = sizeof(response); p->payload = response; if (StreamTcpPacket(&tv, p, stt, &pq) == -1) goto end; if (<API key>(&ssn->server) || !<API key>(&ssn->client) || f.alproto != ALPROTO_HTTP || f.alproto_ts != ALPROTO_HTTP || f.alproto_tc != ALPROTO_UNKNOWN || f.data_al_so_far[0] != 0 || f.data_al_so_far[1] != 0 || f.flags & <API key> || !FLOW_IS_PM_DONE(&f, STREAM_TOSERVER) || !FLOW_IS_PP_DONE(&f, STREAM_TOSERVER) || FLOW_IS_PM_DONE(&f, STREAM_TOCLIENT) || FLOW_IS_PP_DONE(&f, STREAM_TOCLIENT) || ssn->client.seg_list == NULL || ssn->client.seg_list->next == NULL || ssn->client.seg_list->next->next != NULL || ssn->server.seg_list == NULL || ssn->server.seg_list->next != NULL || ssn->data_first_seen_dir != <API key>) { printf("failure 7\n"); goto end; } /* response ack from request */ p->tcph->th_ack = htonl(328); p->tcph->th_seq = htonl(88); p->tcph->th_flags = TH_ACK; p->flowflags = FLOW_PKT_TOSERVER; p->payload_len = 0; p->payload = NULL; if (StreamTcpPacket(&tv, p, stt, &pq) == -1) goto end; if (!<API key>(&ssn->server) || !<API key>(&ssn->client) || f.alproto != ALPROTO_HTTP || f.alproto_ts != ALPROTO_HTTP || f.alproto_tc != ALPROTO_HTTP || f.data_al_so_far[0] != 0 || f.data_al_so_far[1] != 0 || f.flags & <API key> || !FLOW_IS_PM_DONE(&f, STREAM_TOSERVER) || !FLOW_IS_PP_DONE(&f, STREAM_TOSERVER) || !FLOW_IS_PM_DONE(&f, STREAM_TOCLIENT) || FLOW_IS_PP_DONE(&f, STREAM_TOCLIENT) || ssn->client.seg_list == NULL || ssn->client.seg_list->next == NULL || ssn->client.seg_list->next->next != NULL || ssn->server.seg_list == NULL || ssn->server.seg_list->next != NULL || ssn->data_first_seen_dir != <API key>) { printf("failure 8\n"); goto end; } /* response - acking */ p->tcph->th_ack = htonl(88); p->tcph->th_seq = htonl(328); p->tcph->th_flags = TH_PUSH | TH_ACK; p->flowflags = FLOW_PKT_TOCLIENT; p->payload_len = 0; p->payload = NULL; if (StreamTcpPacket(&tv, p, stt, &pq) == -1) goto end; if (!<API key>(&ssn->server) || !<API key>(&ssn->client) || f.alproto != ALPROTO_HTTP || f.alproto_ts != ALPROTO_HTTP || f.alproto_tc != ALPROTO_HTTP || f.data_al_so_far[0] != 0 || f.data_al_so_far[1] != 0 || f.flags & <API key> || !FLOW_IS_PM_DONE(&f, STREAM_TOSERVER) || !FLOW_IS_PP_DONE(&f, STREAM_TOSERVER) || !FLOW_IS_PM_DONE(&f, STREAM_TOCLIENT) || FLOW_IS_PP_DONE(&f, STREAM_TOCLIENT) || ssn->client.seg_list == NULL || ssn->client.seg_list->next == NULL || ssn->server.seg_list == NULL || ssn->server.seg_list->next != NULL || ssn->data_first_seen_dir != <API key>) { printf("failure 9\n"); goto end; } /* response ack from request */ p->tcph->th_ack = htonl(328); p->tcph->th_seq = htonl(88); p->tcph->th_flags = TH_ACK; p->flowflags = FLOW_PKT_TOSERVER; p->payload_len = 0; p->payload = NULL; if (StreamTcpPacket(&tv, p, stt, &pq) == -1) goto end; if (!<API key>(&ssn->server) || !<API key>(&ssn->client) || f.alproto != ALPROTO_HTTP || f.alproto_ts != ALPROTO_HTTP || f.alproto_tc != ALPROTO_HTTP || f.data_al_so_far[0] != 0 || f.data_al_so_far[1] != 0 || f.flags & <API key> || !FLOW_IS_PM_DONE(&f, STREAM_TOSERVER) || !FLOW_IS_PP_DONE(&f, STREAM_TOSERVER) || !FLOW_IS_PM_DONE(&f, STREAM_TOCLIENT) || FLOW_IS_PP_DONE(&f, STREAM_TOCLIENT) || ssn->client.seg_list == NULL || ssn->client.seg_list->next == NULL || ssn->server.seg_list == NULL || ssn->server.seg_list->next != NULL || ssn->data_first_seen_dir != <API key>) { printf("failure 10\n"); goto end; } /* response - acking the request again*/ p->tcph->th_ack = htonl(88); p->tcph->th_seq = htonl(328); p->tcph->th_flags = TH_PUSH | TH_ACK; p->flowflags = FLOW_PKT_TOCLIENT; p->payload_len = 0; p->payload = NULL; if (StreamTcpPacket(&tv, p, stt, &pq) == -1) goto end; if (!<API key>(&ssn->server) || !<API key>(&ssn->client) || f.alproto != ALPROTO_HTTP || f.alproto_ts != ALPROTO_HTTP || f.alproto_tc != ALPROTO_HTTP || f.data_al_so_far[0] != 0 || f.data_al_so_far[1] != 0 || f.flags & <API key> || !FLOW_IS_PM_DONE(&f, STREAM_TOSERVER) || !FLOW_IS_PP_DONE(&f, STREAM_TOSERVER) || !FLOW_IS_PM_DONE(&f, STREAM_TOCLIENT) || FLOW_IS_PP_DONE(&f, STREAM_TOCLIENT) || ssn->client.seg_list == NULL || ssn->client.seg_list->next == NULL || ssn->server.seg_list == NULL || ssn->server.seg_list->next != NULL || ssn->data_first_seen_dir != <API key>) { printf("failure 11\n"); goto end; } /*** New Request ***/ /* partial request */ p->tcph->th_ack = htonl(328); p->tcph->th_seq = htonl(88); p->tcph->th_flags = TH_PUSH | TH_ACK; p->flowflags = FLOW_PKT_TOSERVER; p->payload_len = sizeof(request1); p->payload = request1; if (StreamTcpPacket(&tv, p, stt, &pq) == -1) goto end; if (!<API key>(&ssn->server) || !<API key>(&ssn->client) || f.alproto != ALPROTO_HTTP || f.alproto_ts != ALPROTO_HTTP || f.alproto_tc != ALPROTO_HTTP || f.data_al_so_far[0] != 0 || f.data_al_so_far[1] != 0 || f.flags & <API key> || !FLOW_IS_PM_DONE(&f, STREAM_TOSERVER) || !FLOW_IS_PP_DONE(&f, STREAM_TOSERVER) || !FLOW_IS_PM_DONE(&f, STREAM_TOCLIENT) || FLOW_IS_PP_DONE(&f, STREAM_TOCLIENT) || ssn->client.seg_list == NULL || ssn->client.seg_list->next == NULL || ssn->client.seg_list->next->next == NULL || ssn->server.seg_list == NULL || ssn->server.seg_list->next != NULL || ssn->data_first_seen_dir != <API key>) { printf("failure 12\n"); goto end; } /* response ack against partial request */ p->tcph->th_ack = htonl(90); p->tcph->th_seq = htonl(328); p->tcph->th_flags = TH_ACK; p->flowflags = FLOW_PKT_TOCLIENT; p->payload_len = 0; p->payload = NULL; if (StreamTcpPacket(&tv, p, stt, &pq) == -1) goto end; if (!<API key>(&ssn->server) || !<API key>(&ssn->client) || f.alproto != ALPROTO_HTTP || f.alproto_ts != ALPROTO_HTTP || f.alproto_tc != ALPROTO_HTTP || f.data_al_so_far[0] != 0 || f.data_al_so_far[1] != 0 || f.flags & <API key> || !FLOW_IS_PM_DONE(&f, STREAM_TOSERVER) || !FLOW_IS_PP_DONE(&f, STREAM_TOSERVER) || !FLOW_IS_PM_DONE(&f, STREAM_TOCLIENT) || FLOW_IS_PP_DONE(&f, STREAM_TOCLIENT) || ssn->client.seg_list == NULL || ssn->client.seg_list->next == NULL || ssn->client.seg_list->next->next == NULL || ssn->server.seg_list == NULL || ssn->server.seg_list->next != NULL || ssn->data_first_seen_dir != <API key>) { printf("failure 13\n"); goto end; } /* complete request */ p->tcph->th_ack = htonl(328); p->tcph->th_seq = htonl(90); p->tcph->th_flags = TH_PUSH | TH_ACK; p->flowflags = FLOW_PKT_TOSERVER; p->payload_len = sizeof(request2); p->payload = request2; if (StreamTcpPacket(&tv, p, stt, &pq) == -1) goto end; if (!<API key>(&ssn->server) || !<API key>(&ssn->client) || f.alproto != ALPROTO_HTTP || f.alproto_ts != ALPROTO_HTTP || f.alproto_tc != ALPROTO_HTTP || f.data_al_so_far[0] != 0 || f.data_al_so_far[1] != 0 || f.flags & <API key> || !FLOW_IS_PM_DONE(&f, STREAM_TOSERVER) || !FLOW_IS_PP_DONE(&f, STREAM_TOSERVER) || !FLOW_IS_PM_DONE(&f, STREAM_TOCLIENT) || FLOW_IS_PP_DONE(&f, STREAM_TOCLIENT) || ssn->client.seg_list == NULL || ssn->client.seg_list->next == NULL || ssn->client.seg_list->next->next == NULL || ssn->client.seg_list->next->next->next == NULL || ssn->server.seg_list == NULL || ssn->server.seg_list->next != NULL || ssn->data_first_seen_dir != <API key>) { printf("failure 14\n"); goto end; } /* response ack against second partial request */ p->tcph->th_ack = htonl(175); p->tcph->th_seq = htonl(328); p->tcph->th_flags = TH_ACK; p->flowflags = FLOW_PKT_TOCLIENT; p->payload_len = 0; p->payload = NULL; if (StreamTcpPacket(&tv, p, stt, &pq) == -1) goto end; if (!<API key>(&ssn->server) || !<API key>(&ssn->client) || f.alproto != ALPROTO_HTTP || f.alproto_ts != ALPROTO_HTTP || f.alproto_tc != ALPROTO_HTTP || f.data_al_so_far[0] != 0 || f.data_al_so_far[1] != 0 || f.flags & <API key> || !FLOW_IS_PM_DONE(&f, STREAM_TOSERVER) || !FLOW_IS_PP_DONE(&f, STREAM_TOSERVER) || !FLOW_IS_PM_DONE(&f, STREAM_TOCLIENT) || FLOW_IS_PP_DONE(&f, STREAM_TOCLIENT) || ssn->client.seg_list->next == NULL || ssn->client.seg_list->next->next == NULL || ssn->client.seg_list->next->next->next == NULL || ssn->server.seg_list == NULL || ssn->server.seg_list->next != NULL || ssn->data_first_seen_dir != <API key>) { printf("failure 15\n"); goto end; } if (ssn->toserver_smsg_head == NULL || ssn->toserver_smsg_head->next == NULL || ssn->toserver_smsg_head->next->next != NULL || ssn->toclient_smsg_head == NULL || ssn->toclient_smsg_head->next != NULL) { printf("failure 16\n"); goto end; } <API key>(ssn->toserver_smsg_head); ssn->toserver_smsg_head = ssn->toserver_smsg_tail = NULL; <API key>(ssn->toclient_smsg_head); ssn->toclient_smsg_head = ssn->toclient_smsg_tail = NULL; /* response acking a request */ p->tcph->th_ack = htonl(175); p->tcph->th_seq = htonl(328); p->tcph->th_flags = TH_ACK; p->flowflags = FLOW_PKT_TOCLIENT; p->payload_len = 0; p->payload = NULL; if (StreamTcpPacket(&tv, p, stt, &pq) == -1) goto end; if (!<API key>(&ssn->server) || !<API key>(&ssn->client) || f.alproto != ALPROTO_HTTP || f.alproto_ts != ALPROTO_HTTP || f.alproto_tc != ALPROTO_HTTP || f.data_al_so_far[0] != 0 || f.data_al_so_far[1] != 0 || f.flags & <API key> || !FLOW_IS_PM_DONE(&f, STREAM_TOSERVER) || !FLOW_IS_PP_DONE(&f, STREAM_TOSERVER) || !FLOW_IS_PM_DONE(&f, STREAM_TOCLIENT) || FLOW_IS_PP_DONE(&f, STREAM_TOCLIENT) || ssn->client.seg_list != NULL || ssn->server.seg_list == NULL || ssn->server.seg_list->next != NULL || ssn->data_first_seen_dir != <API key>) { printf("failure 15\n"); goto end; } /* request acking a response */ p->tcph->th_ack = htonl(328); p->tcph->th_seq = htonl(175); p->tcph->th_flags = TH_ACK; p->flowflags = FLOW_PKT_TOSERVER; p->payload_len = 0; p->payload = NULL; if (StreamTcpPacket(&tv, p, stt, &pq) == -1) goto end; if (!<API key>(&ssn->server) || !<API key>(&ssn->client) || f.alproto != ALPROTO_HTTP || f.alproto_ts != ALPROTO_HTTP || f.alproto_tc != ALPROTO_HTTP || f.data_al_so_far[0] != 0 || f.data_al_so_far[1] != 0 || f.flags & <API key> || !FLOW_IS_PM_DONE(&f, STREAM_TOSERVER) || !FLOW_IS_PP_DONE(&f, STREAM_TOSERVER) || !FLOW_IS_PM_DONE(&f, STREAM_TOCLIENT) || FLOW_IS_PP_DONE(&f, STREAM_TOCLIENT) || ssn->client.seg_list != NULL || ssn->server.seg_list != NULL || ssn->data_first_seen_dir != <API key>) { printf("failure 15\n"); goto end; } ret = 1; end: <API key>(&tv, (void *)stt); <API key>(p->flow->protoctx); StreamTcpFreeConfig(TRUE); SCFree(p); SCMutexUnlock(&f.m); return ret; } /** * \test Test to make sure that we sent all the segments from the initial * segments to app layer until we have detected the app layer proto. * * \retval On success it returns 1 and on failure 0. */ static int <API key> (void) { int ret = 0; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow *f = NULL; TCPHdr tcph; TcpSession ssn; PacketQueue pq; memset(&pq,0,sizeof(PacketQueue)); memset(&tcph, 0, sizeof (TCPHdr)); memset(&ssn, 0, sizeof(TcpSession)); ThreadVars tv; memset(&tv, 0, sizeof (ThreadVars)); StreamTcpInitConfig(TRUE); <API key>(FLOW_PKT_TOSERVER, 130); <API key> *ra_ctx = <API key>(NULL); uint8_t httpbuf1[] = "P"; uint32_t httplen1 = sizeof(httpbuf1) - 1; /* minus the \0 */ uint8_t httpbuf3[] = "O"; uint32_t httplen3 = sizeof(httpbuf3) - 1; /* minus the \0 */ uint8_t httpbuf4[] = "S"; uint32_t httplen4 = sizeof(httpbuf4) - 1; /* minus the \0 */ uint8_t httpbuf5[] = "T \r\n"; uint32_t httplen5 = sizeof(httpbuf5) - 1; /* minus the \0 */ uint8_t httpbuf2[] = "HTTP/1.0 200 OK\r\nServer: VictorServer/1.0\r\n\r\n"; uint32_t httplen2 = sizeof(httpbuf2) - 1; /* minus the \0 */ ssn.server.ra_raw_base_seq = ssn.server.ra_app_base_seq = 9; ssn.server.isn = 9; ssn.server.last_ack = 10; ssn.client.ra_raw_base_seq = ssn.client.ra_app_base_seq = 9; ssn.client.isn = 9; ssn.client.last_ack = 10; f = UTHBuildFlow(AF_INET, "1.2.3.4", "1.2.3.5", 200, 220); if (f == NULL) goto end; f->protoctx = &ssn; f->proto = IPPROTO_TCP; p->flow = f; tcph.th_win = htons(5480); tcph.th_seq = htonl(10); tcph.th_ack = htonl(10); tcph.th_flags = TH_ACK|TH_PUSH; p->tcph = &tcph; p->flowflags = FLOW_PKT_TOSERVER; p->payload = httpbuf1; p->payload_len = httplen1; ssn.state = TCP_ESTABLISHED; TcpStream *s = NULL; s = &ssn.client; SCMutexLock(&f->m); if (<API key>(&tv, ra_ctx, &ssn, s, p, &pq) == -1) { printf("failed in segments reassembly, while processing toserver packet (1): "); goto end; } /* Check if we have stream smsgs in queue */ if (UtSsnSmsgCnt(&ssn, STREAM_TOCLIENT) > 0) { printf("there shouldn't be any stream smsgs in the queue, as we didn't" " processed any smsg from toserver side till yet (2): "); goto end; } p->flowflags = FLOW_PKT_TOCLIENT; p->payload = httpbuf2; p->payload_len = httplen2; tcph.th_seq = htonl(10); tcph.th_ack = htonl(11); s = &ssn.server; ssn.server.last_ack = 11; if (<API key>(&tv, ra_ctx, &ssn, s, p, &pq) == -1) { printf("failed in segments reassembly, while processing toserver packet (3): "); goto end; } p->flowflags = FLOW_PKT_TOSERVER; p->payload = httpbuf3; p->payload_len = httplen3; tcph.th_seq = htonl(11); tcph.th_ack = htonl(55); s = &ssn.client; ssn.client.last_ack = 55; if (<API key>(&tv, ra_ctx, &ssn, s, p, &pq) == -1) { printf("failed in segments reassembly, while processing toserver packet (5): "); goto end; } p->flowflags = FLOW_PKT_TOCLIENT; p->payload = httpbuf2; p->payload_len = httplen2; tcph.th_seq = htonl(55); tcph.th_ack = htonl(12); s = &ssn.server; ssn.server.last_ack = 12; if (<API key>(&tv, ra_ctx, &ssn, s, p, &pq) == -1) { printf("failed in segments reassembly, while processing toserver packet (6): "); goto end; } /* check is have the segment in the list and flagged or not */ if (ssn.client.seg_list == NULL || (ssn.client.seg_list->flags & <API key>)) { printf("the list is NULL or the processed segment has not been flaged (7): "); goto end; } p->flowflags = FLOW_PKT_TOSERVER; p->payload = httpbuf4; p->payload_len = httplen4; tcph.th_seq = htonl(12); tcph.th_ack = htonl(100); s = &ssn.client; ssn.client.last_ack = 100; if (<API key>(&tv, ra_ctx, &ssn, s, p, &pq) == -1) { printf("failed in segments reassembly, while processing toserver packet (10): "); goto end; } p->flowflags = FLOW_PKT_TOCLIENT; p->payload = httpbuf2; p->payload_len = httplen2; tcph.th_seq = htonl(100); tcph.th_ack = htonl(13); s = &ssn.server; ssn.server.last_ack = 13; if (<API key>(&tv, ra_ctx, &ssn, s, p, &pq) == -1) { printf("failed in segments reassembly, while processing toserver packet (11): "); goto end; } p->flowflags = FLOW_PKT_TOSERVER; p->payload = httpbuf5; p->payload_len = httplen5; tcph.th_seq = htonl(13); tcph.th_ack = htonl(145); s = &ssn.client; ssn.client.last_ack = 145; if (<API key>(&tv, ra_ctx, &ssn, s, p, &pq) == -1) { printf("failed in segments reassembly, while processing toserver packet (14): "); goto end; } p->flowflags = FLOW_PKT_TOCLIENT; p->payload = httpbuf2; p->payload_len = httplen2; tcph.th_seq = htonl(145); tcph.th_ack = htonl(16); s = &ssn.server; ssn.server.last_ack = 16; if (<API key>(&tv, ra_ctx, &ssn, s, p, &pq) == -1) { printf("failed in segments reassembly, while processing toserver packet (15): "); goto end; } /* Check if we have stream smsgs in queue */ if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) == 0) { printf("there should be a stream smsgs in the queue, as we have detected" " the app layer protocol and one smsg from toserver side has " "been sent (16): "); goto end; } if (f->alproto != ALPROTO_HTTP) { printf("app layer proto has not been detected (18): "); goto end; } ret = 1; end: <API key>(ra_ctx); StreamTcpFreeConfig(TRUE); SCFree(p); SCMutexUnlock(&f->m); UTHFreeFlow(f); return ret; } /** * \retval On success it returns 1 and on failure 0. */ static int <API key> (void) { int ret = 0; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow *f = NULL; TCPHdr tcph; TcpSession ssn; PacketQueue pq; memset(&pq,0,sizeof(PacketQueue)); memset(&tcph, 0, sizeof (TCPHdr)); memset(&ssn, 0, sizeof(TcpSession)); ThreadVars tv; memset(&tv, 0, sizeof (ThreadVars)); StreamTcpInitConfig(TRUE); <API key> *ra_ctx = <API key>(NULL); uint8_t httpbuf1[] = "/ HTTP/1.0\r\nUser-Agent: Victor/1.0"; uint32_t httplen1 = sizeof(httpbuf1) - 1; /* minus the \0 */ uint8_t httpbuf2[] = "HTTP/1.0 200 OK\r\nServer: VictorServer/1.0\r\n\r\n"; uint32_t httplen2 = sizeof(httpbuf2) - 1; /* minus the \0 */ uint8_t httpbuf3[] = "<API key>" "<API key>" "<API key>" "<API key>" "<API key>" "<API key>" "<API key>" "<API key>" "<API key>" "aG9uZT\r\n\r\n"; uint32_t httplen3 = sizeof(httpbuf3) - 1; /* minus the \0 */ ssn.server.ra_raw_base_seq = ssn.server.ra_app_base_seq = 9; ssn.server.isn = 9; ssn.server.last_ack = 600; ssn.client.ra_raw_base_seq = ssn.client.ra_app_base_seq = 9; ssn.client.isn = 9; ssn.client.last_ack = 600; f = UTHBuildFlow(AF_INET, "1.2.3.4", "1.2.3.5", 200, 220); if (f == NULL) goto end; f->protoctx = &ssn; f->proto = IPPROTO_TCP; p->flow = f; tcph.th_win = htons(5480); tcph.th_seq = htonl(10); tcph.th_ack = htonl(10); tcph.th_flags = TH_ACK|TH_PUSH; p->tcph = &tcph; p->flowflags = FLOW_PKT_TOCLIENT; p->payload = httpbuf2; p->payload_len = httplen2; ssn.state = TCP_ESTABLISHED; TcpStream *s = NULL; s = &ssn.server; SCMutexLock(&f->m); if (<API key>(&tv, ra_ctx, &ssn, s, p, &pq) == -1) { printf("failed in segments reassembly, while processing toserver packet (1): "); goto end; } /* Check if we have stream smsgs in queue */ if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) > 0) { printf("there shouldn't be any stream smsgs in the queue (2): "); goto end; } p->flowflags = FLOW_PKT_TOSERVER; p->payload = httpbuf1; p->payload_len = httplen1; tcph.th_seq = htonl(10); tcph.th_ack = htonl(55); s = &ssn.client; if (<API key>(&tv, ra_ctx, &ssn, s, p, &pq) == -1) { printf("failed in segments reassembly, while processing toserver packet (3): "); goto end; } /* Check if we have stream smsgs in queue */ if (UtSsnSmsgCnt(&ssn, STREAM_TOCLIENT) > 0) { printf("there shouldn't be any stream smsgs in the queue, as we didn't" " processed any smsg from toserver side till yet (4): "); goto end; } p->flowflags = FLOW_PKT_TOCLIENT; p->payload = httpbuf2; p->payload_len = httplen2; tcph.th_seq = htonl(55); tcph.th_ack = htonl(44); s = &ssn.server; if (<API key>(&tv, ra_ctx, &ssn, s, p, &pq) == -1) { printf("failed in segments reassembly, while processing toserver packet (5): "); goto end; } if (!<API key>(&ssn.client)) { printf("app layer detected flag isn't set, it should be (8): "); goto end; } /* This packets induces a packet gap and also shows why we need to process the current segment completely, even if it results in sending more than one smsg to the app layer. If we don't send more than one smsg in this case, then the first segment of lentgh 34 bytes will be sent to app layer and protocol can not be detected in that message and moreover the segment lentgh is less than the max. signature size for protocol detection, so this will keep looping !! */ p->flowflags = FLOW_PKT_TOSERVER; p->payload = httpbuf3; p->payload_len = httplen3; tcph.th_seq = htonl(54); tcph.th_ack = htonl(100); s = &ssn.client; if (<API key>(&tv, ra_ctx, &ssn, s, p, &pq) == -1) { printf("failed in segments reassembly, while processing toserver packet (9): "); goto end; } /* Check if we have stream smsgs in queue */ if (UtSsnSmsgCnt(&ssn, STREAM_TOCLIENT) > 0) { printf("there shouldn't be any stream smsgs in the queue, as we didn't" " detected the app layer protocol till yet (10): "); goto end; } p->flowflags = FLOW_PKT_TOCLIENT; p->payload = httpbuf2; p->payload_len = httplen2; tcph.th_seq = htonl(100); tcph.th_ack = htonl(53); s = &ssn.server; if (<API key>(&tv, ra_ctx, &ssn, s, p, &pq) == -1) { printf("failed in segments reassembly, while processing toserver packet (11): "); goto end; } /* the flag should be set, as the smsg scanned size has crossed the max. signature size for app proto detection */ if (!<API key>(&ssn.client)) { printf("app layer detected flag is not set, it should be (14): "); goto end; } ret = 1; end: <API key>(ra_ctx); StreamTcpFreeConfig(TRUE); SCFree(p); SCMutexUnlock(&f->m); UTHFreeFlow(f); return ret; } /** \test Test the memcap incrementing/decrementing and memcap check */ static int <API key>(void) { uint8_t ret = 0; StreamTcpInitConfig(TRUE); uint32_t memuse = SC_ATOMIC_GET(ra_memuse); <API key>(500); if (SC_ATOMIC_GET(ra_memuse) != (memuse+500)) { printf("failed in incrementing the memory"); goto end; } <API key>(500); if (SC_ATOMIC_GET(ra_memuse) != memuse) { printf("failed in decrementing the memory"); goto end; } if (<API key>(500) != 1) { printf("failed in validating the memcap"); goto end; } if (<API key>((memuse + stream_config.reassembly_memcap)) != 0) { printf("failed in validating the memcap"); goto end; } StreamTcpFreeConfig(TRUE); if (SC_ATOMIC_GET(ra_memuse) != 0) { printf("failed in clearing the memory"); goto end; } ret = 1; return ret; end: StreamTcpFreeConfig(TRUE); return ret; } /** * \test Test to make sure that reassembly_depth is enforced. * * \retval On success it returns 1 and on failure 0. */ static int <API key> (void) { int ret = 0; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow *f = NULL; TCPHdr tcph; TcpSession ssn; PacketQueue pq; memset(&pq,0,sizeof(PacketQueue)); memset(&tcph, 0, sizeof (TCPHdr)); memset(&ssn, 0, sizeof(TcpSession)); ThreadVars tv; memset(&tv, 0, sizeof (ThreadVars)); uint8_t httpbuf1[] = "/ HTTP/1.0\r\nUser-Agent: Victor/1.0"; uint32_t httplen1 = sizeof(httpbuf1) - 1; /* minus the \0 */ StreamTcpInitConfig(TRUE); <API key> *ra_ctx = <API key>(NULL); <API key>(&ssn.server, 9); ssn.server.isn = 9; ssn.server.last_ack = 60; <API key>(&ssn.client, 9); ssn.client.isn = 9; ssn.client.last_ack = 60; f = UTHBuildFlow(AF_INET, "1.2.3.4", "1.2.3.5", 200, 220); if (f == NULL) goto end; f->protoctx = &ssn; f->proto = IPPROTO_TCP; p->flow = f; tcph.th_win = htons(5480); tcph.th_seq = htonl(10); tcph.th_ack = htonl(20); tcph.th_flags = TH_ACK|TH_PUSH; p->tcph = &tcph; p->flowflags = FLOW_PKT_TOCLIENT; p->payload = httpbuf1; p->payload_len = httplen1; ssn.state = TCP_ESTABLISHED; /* set the default value of reassembly depth, as there is no config file */ stream_config.reassembly_depth = httplen1 + 1; TcpStream *s = NULL; s = &ssn.server; SCMutexLock(&f->m); if (<API key>(&tv, ra_ctx, &ssn, s, p, &pq) == -1) { printf("failed in segments reassembly, while processing toclient packet: "); goto end; } /* Check if we have flags set or not */ if (s->flags & <API key>) { printf("there shouldn't be a noreassembly flag be set: "); goto end; } <API key>(&ssn.server, ssn.server.isn + httplen1); p->flowflags = FLOW_PKT_TOSERVER; p->payload_len = httplen1; s = &ssn.client; if (<API key>(&tv, ra_ctx, &ssn, s, p, &pq) == -1) { printf("failed in segments reassembly, while processing toserver packet: "); goto end; } /* Check if we have flags set or not */ if (s->flags & <API key>) { printf("there shouldn't be a noreassembly flag be set: "); goto end; } <API key>(&ssn.client, ssn.client.isn + httplen1); p->flowflags = FLOW_PKT_TOCLIENT; p->payload_len = httplen1; s = &ssn.server; if (<API key>(&tv, ra_ctx, &ssn, s, p, &pq) == -1) { printf("failed in segments reassembly, while processing toserver packet: "); goto end; } /* Check if we have flags set or not */ if (!(s->flags & <API key>)) { printf("the noreassembly flags should be set, " "p.payload_len %"PRIu16" stream_config.reassembly_" "depth %"PRIu32": ", p->payload_len, stream_config.reassembly_depth); goto end; } ret = 1; end: <API key>(ra_ctx); StreamTcpFreeConfig(TRUE); SCFree(p); SCMutexUnlock(&f->m); UTHFreeFlow(f); return ret; } /** * \test Test the undefined config value of reassembly depth. * the default value of 0 will be loaded and stream will be reassembled * until the session ended * * \retval On success it returns 1 and on failure 0. */ static int <API key> (void) { int ret = 0; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow *f = NULL; TCPHdr tcph; TcpSession ssn; ThreadVars tv; PacketQueue pq; memset(&pq,0,sizeof(PacketQueue)); memset(&tcph, 0, sizeof (TCPHdr)); memset(&ssn, 0, sizeof(TcpSession)); memset(&tv, 0, sizeof (ThreadVars)); uint8_t httpbuf1[] = "/ HTTP/1.0\r\nUser-Agent: Victor/1.0"; uint32_t httplen1 = sizeof(httpbuf1) - 1; /* minus the \0 */ StreamTcpInitConfig(TRUE); <API key> *ra_ctx = <API key>(NULL); <API key>(&ssn.server, 9); ssn.server.isn = 9; ssn.server.last_ack = 60; ssn.server.next_seq = ssn.server.isn; <API key>(&ssn.client, 9); ssn.client.isn = 9; ssn.client.last_ack = 60; ssn.client.next_seq = ssn.client.isn; f = UTHBuildFlow(AF_INET, "1.2.3.4", "1.2.3.5", 200, 220); if (f == NULL) goto end; f->protoctx = &ssn; f->proto = IPPROTO_TCP; p->flow = f; tcph.th_win = htons(5480); tcph.th_seq = htonl(10); tcph.th_ack = htonl(20); tcph.th_flags = TH_ACK|TH_PUSH; p->tcph = &tcph; p->flowflags = FLOW_PKT_TOCLIENT; p->payload = httpbuf1; p->payload_len = httplen1; ssn.state = TCP_ESTABLISHED; stream_config.reassembly_depth = 0; TcpStream *s = NULL; s = &ssn.server; SCMutexLock(&f->m); if (<API key>(&tv, ra_ctx, &ssn, s, p, &pq) == -1) { printf("failed in segments reassembly, while processing toclient packet\n"); goto end; } /* Check if we have flags set or not */ if ((ssn.client.flags & <API key>) || (ssn.server.flags & <API key>)) { printf("there shouldn't be any no reassembly flag be set \n"); goto end; } <API key>(&ssn.server, ssn.server.isn + httplen1); p->flowflags = FLOW_PKT_TOSERVER; p->payload_len = httplen1; s = &ssn.client; if (<API key>(&tv, ra_ctx, &ssn, s, p, &pq) == -1) { printf("failed in segments reassembly, while processing toserver packet\n"); goto end; } /* Check if we have flags set or not */ if ((ssn.client.flags & <API key>) || (ssn.server.flags & <API key>)) { printf("there shouldn't be any no reassembly flag be set \n"); goto end; } <API key>(&ssn.client, ssn.client.isn + httplen1); p->flowflags = FLOW_PKT_TOCLIENT; p->payload_len = httplen1; tcph.th_seq = htonl(10 + httplen1); tcph.th_ack = htonl(20 + httplen1); s = &ssn.server; if (<API key>(&tv, ra_ctx, &ssn, s, p, &pq) == -1) { printf("failed in segments reassembly, while processing toserver packet\n"); goto end; } /* Check if we have flags set or not */ if ((ssn.client.flags & <API key>) || (ssn.server.flags & <API key>)) { printf("the no_reassembly flags should not be set, " "p->payload_len %"PRIu16" stream_config.reassembly_" "depth %"PRIu32": ", p->payload_len, stream_config.reassembly_depth); goto end; } ret = 1; end: <API key>(ra_ctx); StreamTcpFreeConfig(TRUE); SCFree(p); SCMutexUnlock(&f->m); UTHFreeFlow(f); return ret; } /** * \test Test to make sure we detect the sequence wrap around and continue * stream reassembly properly. * * \retval On success it returns 1 and on failure 0. */ static int <API key> (void) { int ret = 0; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow *f = NULL; TCPHdr tcph; TcpSession ssn; ThreadVars tv; PacketQueue pq; memset(&pq,0,sizeof(PacketQueue)); memset(&tcph, 0, sizeof (TCPHdr)); memset(&ssn, 0, sizeof(TcpSession)); memset(&tv, 0, sizeof (ThreadVars)); /* prevent L7 from kicking in */ <API key>(FLOW_PKT_TOSERVER, 0); <API key>(FLOW_PKT_TOCLIENT, 0); StreamTcpInitConfig(TRUE); <API key> *ra_ctx = <API key>(NULL); uint8_t httpbuf1[] = "GET /EVILSUFF HTTP/1.1\r\n\r\n"; uint32_t httplen1 = sizeof(httpbuf1) - 1; /* minus the \0 */ ssn.server.ra_raw_base_seq = ssn.server.ra_app_base_seq = 572799781UL; ssn.server.isn = 572799781UL; ssn.server.last_ack = 572799782UL; ssn.client.ra_raw_base_seq = ssn.client.ra_app_base_seq = 4294967289UL; ssn.client.isn = 4294967289UL; ssn.client.last_ack = 21; f = UTHBuildFlow(AF_INET, "1.2.3.4", "1.2.3.5", 200, 220); if (f == NULL) goto end; f->protoctx = &ssn; f->proto = IPPROTO_TCP; p->flow = f; tcph.th_win = htons(5480); ssn.state = TCP_ESTABLISHED; TcpStream *s = NULL; uint8_t cnt = 0; SCMutexLock(&f->m); for (cnt=0; cnt < httplen1; cnt++) { tcph.th_seq = htonl(ssn.client.isn + 1 + cnt); tcph.th_ack = htonl(572799782UL); tcph.th_flags = TH_ACK|TH_PUSH; p->tcph = &tcph; p->flowflags = FLOW_PKT_TOSERVER; p->payload = &httpbuf1[cnt]; p->payload_len = 1; s = &ssn.client; if (<API key>(&tv, ra_ctx, &ssn, s, p, &pq) == -1) { printf("failed in segments reassembly, while processing toserver " "packet\n"); goto end; } p->flowflags = FLOW_PKT_TOCLIENT; p->payload = NULL; p->payload_len = 0; tcph.th_seq = htonl(572799782UL); tcph.th_ack = htonl(ssn.client.isn + 1 + cnt); tcph.th_flags = TH_ACK; p->tcph = &tcph; s = &ssn.server; if (<API key>(&tv, ra_ctx, &ssn, s, p, &pq) == -1) { printf("failed in segments reassembly, while processing toserver " "packet\n"); goto end; } } if (f->alproto != ALPROTO_HTTP) { printf("App layer protocol (HTTP) should have been detected\n"); goto end; } ret = 1; end: <API key>(ra_ctx); StreamTcpFreeConfig(TRUE); SCFree(p); SCMutexUnlock(&f->m); UTHFreeFlow(f); return ret; } /** \test 3 in order segments in inline reassembly */ static int <API key>(void) { int ret = 0; <API key> *ra_ctx = NULL; ThreadVars tv; TcpSession ssn; Flow f; memset(&tv, 0x00, sizeof(tv)); StreamTcpUTInit(&ra_ctx); <API key>(); <API key>(&ssn); <API key>(&ssn.client, 1); FLOW_INITIALIZE(&f); uint8_t stream_payload[] = "AAAAABBBBBCCCCC"; uint8_t payload[] = { 'C', 'C', 'C', 'C', 'C' }; Packet *p = UTHBuildPacketReal(payload, 5, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); if (p == NULL) { printf("couldn't get a packet: "); goto end; } p->tcph->th_seq = htonl(12); p->flow = &f; SCMutexLock(&f.m); if (<API key>(&tv, ra_ctx, &ssn.client, 2, 'A', 5) == -1) { printf("failed to add segment 1: "); goto end; } if (<API key>(&tv, ra_ctx, &ssn.client, 7, 'B', 5) == -1) { printf("failed to add segment 2: "); goto end; } if (<API key>(&tv, ra_ctx, &ssn.client, 12, 'C', 5) == -1) { printf("failed to add segment 3: "); goto end; } ssn.client.next_seq = 17; int r = <API key>(ra_ctx, &ssn, &ssn.client, p); if (r < 0) { printf("<API key> failed: "); goto end; } if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 1) { printf("expected a single stream message: "); goto end; } StreamMsg *smsg = ssn.toserver_smsg_head; if (smsg->data_len != 15) { printf("expected data length to be 15, got %u: ", smsg->data_len); goto end; } if (!(memcmp(stream_payload, smsg->data, 15) == 0)) { printf("data is not what we expected:\nExpected:\n"); PrintRawDataFp(stdout, stream_payload, 15); printf("Got:\n"); PrintRawDataFp(stdout, smsg->data, smsg->data_len); goto end; } ret = 1; end: SCMutexUnlock(&f.m); FLOW_DESTROY(&f); UTHFreePacket(p); <API key>(&ssn); StreamTcpUTDeinit(ra_ctx); return ret; } /** \test 3 in order segments, then reassemble, add one more and reassemble again. * test the sliding window reassembly. */ static int <API key>(void) { int ret = 0; <API key> *ra_ctx = NULL; ThreadVars tv; TcpSession ssn; Flow f; memset(&tv, 0x00, sizeof(tv)); StreamTcpUTInit(&ra_ctx); <API key>(); <API key>(&ssn); <API key>(&ssn.client, 1); FLOW_INITIALIZE(&f); uint8_t stream_payload1[] = "AAAAABBBBBCCCCC"; uint8_t stream_payload2[] = "<API key>"; uint8_t payload[] = { 'C', 'C', 'C', 'C', 'C' }; Packet *p = UTHBuildPacketReal(payload, 5, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); if (p == NULL) { printf("couldn't get a packet: "); goto end; } p->tcph->th_seq = htonl(12); p->flow = &f; SCMutexLock(&f.m); if (<API key>(&tv, ra_ctx, &ssn.client, 2, 'A', 5) == -1) { printf("failed to add segment 1: "); goto end; } if (<API key>(&tv, ra_ctx, &ssn.client, 7, 'B', 5) == -1) { printf("failed to add segment 2: "); goto end; } if (<API key>(&tv, ra_ctx, &ssn.client, 12, 'C', 5) == -1) { printf("failed to add segment 3: "); goto end; } ssn.client.next_seq = 17; int r = <API key>(ra_ctx, &ssn, &ssn.client, p); if (r < 0) { printf("<API key> failed: "); goto end; } if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 1) { printf("expected a single stream message: "); goto end; } StreamMsg *smsg = ssn.toserver_smsg_head; if (smsg->data_len != 15) { printf("expected data length to be 15, got %u: ", smsg->data_len); goto end; } if (!(memcmp(stream_payload1, smsg->data, 15) == 0)) { printf("data is not what we expected:\nExpected:\n"); PrintRawDataFp(stdout, stream_payload1, 15); printf("Got:\n"); PrintRawDataFp(stdout, smsg->data, smsg->data_len); goto end; } if (<API key>(&tv, ra_ctx, &ssn.client, 17, 'D', 5) == -1) { printf("failed to add segment 4: "); goto end; } ssn.client.next_seq = 22; r = <API key>(ra_ctx, &ssn, &ssn.client, p); if (r < 0) { printf("<API key> failed 2: "); goto end; } if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 2) { printf("expected a single stream message: "); goto end; } smsg = ssn.toserver_smsg_head->next; if (smsg->data_len != 20) { printf("expected data length to be 20, got %u: ", smsg->data_len); goto end; } if (!(memcmp(stream_payload2, smsg->data, 20) == 0)) { printf("data is not what we expected:\nExpected:\n"); PrintRawDataFp(stdout, stream_payload2, 20); printf("Got:\n"); PrintRawDataFp(stdout, smsg->data, smsg->data_len); goto end; } ret = 1; end: SCMutexUnlock(&f.m); FLOW_DESTROY(&f); UTHFreePacket(p); <API key>(&ssn); StreamTcpUTDeinit(ra_ctx); return ret; } /** \test 3 in order segments, then reassemble, add one more and reassemble again. * test the sliding window reassembly with a small window size so that we * cutting off at the start (left edge) */ static int <API key>(void) { int ret = 0; <API key> *ra_ctx = NULL; ThreadVars tv; TcpSession ssn; Flow f; memset(&tv, 0x00, sizeof(tv)); StreamTcpUTInit(&ra_ctx); <API key>(); <API key>(&ssn); <API key>(&ssn.client, 1); FLOW_INITIALIZE(&f); stream_config.<API key> = 15; uint8_t stream_payload1[] = "AAAAABBBBBCCCCC"; uint8_t stream_payload2[] = "BBBBBCCCCCDDDDD"; uint8_t payload[] = { 'C', 'C', 'C', 'C', 'C' }; Packet *p = UTHBuildPacketReal(payload, 5, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); if (p == NULL) { printf("couldn't get a packet: "); goto end; } p->tcph->th_seq = htonl(12); p->flow = &f; p->flowflags |= FLOW_PKT_TOSERVER; SCMutexLock(&f.m); if (<API key>(&tv, ra_ctx, &ssn.client, 2, 'A', 5) == -1) { printf("failed to add segment 1: "); goto end; } if (<API key>(&tv, ra_ctx, &ssn.client, 7, 'B', 5) == -1) { printf("failed to add segment 2: "); goto end; } if (<API key>(&tv, ra_ctx, &ssn.client, 12, 'C', 5) == -1) { printf("failed to add segment 3: "); goto end; } ssn.client.next_seq = 17; int r = <API key>(ra_ctx, &ssn, &ssn.client, p); if (r < 0) { printf("<API key> failed: "); goto end; } if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 1) { printf("expected a single stream message 1: "); goto end; } StreamMsg *smsg = ssn.toserver_smsg_head; if (smsg->data_len != 15) { printf("expected data length to be 15, got %u: ", smsg->data_len); goto end; } if (!(memcmp(stream_payload1, smsg->data, 15) == 0)) { printf("data is not what we expected:\nExpected:\n"); PrintRawDataFp(stdout, stream_payload1, 15); printf("Got:\n"); PrintRawDataFp(stdout, smsg->data, smsg->data_len); goto end; } if (<API key>(&tv, ra_ctx, &ssn.client, 17, 'D', 5) == -1) { printf("failed to add segment 4: "); goto end; } ssn.client.next_seq = 22; p->tcph->th_seq = htonl(17); r = <API key>(ra_ctx, &ssn, &ssn.client, p); if (r < 0) { printf("<API key> failed 2: "); goto end; } if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 2) { printf("expected two stream messages: "); goto end; } smsg = ssn.toserver_smsg_head->next; if (smsg->data_len != 15) { printf("expected data length to be 15, got %u: ", smsg->data_len); goto end; } if (!(memcmp(stream_payload2, smsg->data, 15) == 0)) { printf("data is not what we expected:\nExpected:\n"); PrintRawDataFp(stdout, stream_payload2, 15); printf("Got:\n"); PrintRawDataFp(stdout, smsg->data, smsg->data_len); goto end; } ret = 1; end: SCMutexUnlock(&f.m); FLOW_DESTROY(&f); UTHFreePacket(p); <API key>(&ssn); StreamTcpUTDeinit(ra_ctx); return ret; } /** \test 3 in order segments, then reassemble, add one more and reassemble again. * test the sliding window reassembly with a small window size so that we * cutting off at the start (left edge) with small packet overlap. */ static int <API key>(void) { int ret = 0; <API key> *ra_ctx = NULL; ThreadVars tv; TcpSession ssn; Flow f; memset(&tv, 0x00, sizeof(tv)); StreamTcpUTInit(&ra_ctx); <API key>(); <API key>(&ssn); <API key>(&ssn.client, 1); FLOW_INITIALIZE(&f); stream_config.<API key> = 16; uint8_t stream_payload1[] = "AAAAABBBBBCCCCC"; uint8_t stream_payload2[] = "ABBBBBCCCCCDDDDD"; uint8_t payload[] = { 'C', 'C', 'C', 'C', 'C' }; Packet *p = UTHBuildPacketReal(payload, 5, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); if (p == NULL) { printf("couldn't get a packet: "); goto end; } p->tcph->th_seq = htonl(12); p->flow = &f; p->flowflags |= FLOW_PKT_TOSERVER; SCMutexLock(&f.m); if (<API key>(&tv, ra_ctx, &ssn.client, 2, 'A', 5) == -1) { printf("failed to add segment 1: "); goto end; } if (<API key>(&tv, ra_ctx, &ssn.client, 7, 'B', 5) == -1) { printf("failed to add segment 2: "); goto end; } if (<API key>(&tv, ra_ctx, &ssn.client, 12, 'C', 5) == -1) { printf("failed to add segment 3: "); goto end; } ssn.client.next_seq = 17; int r = <API key>(ra_ctx, &ssn, &ssn.client, p); if (r < 0) { printf("<API key> failed: "); goto end; } if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 1) { printf("expected a single stream message: "); goto end; } StreamMsg *smsg = ssn.toserver_smsg_head; if (smsg->data_len != 15) { printf("expected data length to be 15, got %u: ", smsg->data_len); goto end; } if (!(memcmp(stream_payload1, smsg->data, 15) == 0)) { printf("data is not what we expected:\nExpected:\n"); PrintRawDataFp(stdout, stream_payload1, 15); printf("Got:\n"); PrintRawDataFp(stdout, smsg->data, smsg->data_len); goto end; } if (<API key>(&tv, ra_ctx, &ssn.client, 17, 'D', 5) == -1) { printf("failed to add segment 4: "); goto end; } ssn.client.next_seq = 22; p->tcph->th_seq = htonl(17); r = <API key>(ra_ctx, &ssn, &ssn.client, p); if (r < 0) { printf("<API key> failed 2: "); goto end; } if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 2) { printf("expected a single stream message: "); goto end; } smsg = ssn.toserver_smsg_head->next; if (smsg->data_len != 16) { printf("expected data length to be 16, got %u: ", smsg->data_len); goto end; } if (!(memcmp(stream_payload2, smsg->data, 16) == 0)) { printf("data is not what we expected:\nExpected:\n"); PrintRawDataFp(stdout, stream_payload2, 16); printf("Got:\n"); PrintRawDataFp(stdout, smsg->data, smsg->data_len); goto end; } ret = 1; end: SCMutexUnlock(&f.m); FLOW_DESTROY(&f); UTHFreePacket(p); <API key>(&ssn); StreamTcpUTDeinit(ra_ctx); return ret; } /** \test with a GAP we should have 2 smsgs */ static int <API key>(void) { int ret = 0; <API key> *ra_ctx = NULL; ThreadVars tv; TcpSession ssn; Flow f; memset(&tv, 0x00, sizeof(tv)); StreamTcpUTInit(&ra_ctx); <API key>(); <API key>(&ssn); <API key>(&ssn.client, 1); FLOW_INITIALIZE(&f); uint8_t stream_payload1[] = "AAAAABBBBB"; uint8_t stream_payload2[] = "DDDDD"; uint8_t payload[] = { 'C', 'C', 'C', 'C', 'C' }; Packet *p = UTHBuildPacketReal(payload, 5, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); if (p == NULL) { printf("couldn't get a packet: "); goto end; } p->tcph->th_seq = htonl(12); p->flow = &f; SCMutexLock(&f.m); if (<API key>(&tv, ra_ctx, &ssn.client, 2, 'A', 5) == -1) { printf("failed to add segment 1: "); goto end; } if (<API key>(&tv, ra_ctx, &ssn.client, 7, 'B', 5) == -1) { printf("failed to add segment 2: "); goto end; } ssn.client.next_seq = 12; if (<API key>(&tv, ra_ctx, &ssn.client, 17, 'D', 5) == -1) { printf("failed to add segment 4: "); goto end; } p->tcph->th_seq = htonl(17); int r = <API key>(ra_ctx, &ssn, &ssn.client, p); if (r < 0) { printf("<API key> failed: "); goto end; } if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 2) { printf("expected a single stream message: "); goto end; } StreamMsg *smsg = ssn.toserver_smsg_head; if (smsg->data_len != 10) { printf("expected data length to be 10, got %u: ", smsg->data_len); goto end; } if (!(memcmp(stream_payload1, smsg->data, 10) == 0)) { printf("data is not what we expected:\nExpected:\n"); PrintRawDataFp(stdout, stream_payload2, 10); printf("Got:\n"); PrintRawDataFp(stdout, smsg->data, smsg->data_len); goto end; } smsg = ssn.toserver_smsg_head->next; if (smsg->data_len != 5) { printf("expected data length to be 5, got %u: ", smsg->data_len); goto end; } if (!(memcmp(stream_payload2, smsg->data, 5) == 0)) { printf("data is not what we expected:\nExpected:\n"); PrintRawDataFp(stdout, stream_payload2, 5); printf("Got:\n"); PrintRawDataFp(stdout, smsg->data, smsg->data_len); goto end; } ret = 1; end: SCMutexUnlock(&f.m); FLOW_DESTROY(&f); UTHFreePacket(p); <API key>(&ssn); StreamTcpUTDeinit(ra_ctx); return ret; } /** \test with a GAP we should have 2 smsgs, with filling the GAP later */ static int <API key>(void) { int ret = 0; <API key> *ra_ctx = NULL; ThreadVars tv; TcpSession ssn; Flow f; memset(&tv, 0x00, sizeof(tv)); StreamTcpUTInit(&ra_ctx); <API key>(); <API key>(&ssn); <API key>(&ssn.client, 1); FLOW_INITIALIZE(&f); uint8_t stream_payload1[] = "AAAAABBBBB"; uint8_t stream_payload2[] = "DDDDD"; uint8_t stream_payload3[] = "<API key>"; uint8_t payload[] = { 'C', 'C', 'C', 'C', 'C' }; Packet *p = UTHBuildPacketReal(payload, 5, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); if (p == NULL) { printf("couldn't get a packet: "); goto end; } p->tcph->th_seq = htonl(12); p->flow = &f; SCMutexLock(&f.m); if (<API key>(&tv, ra_ctx, &ssn.client, 2, 'A', 5) == -1) { printf("failed to add segment 1: "); goto end; } if (<API key>(&tv, ra_ctx, &ssn.client, 7, 'B', 5) == -1) { printf("failed to add segment 2: "); goto end; } ssn.client.next_seq = 12; if (<API key>(&tv, ra_ctx, &ssn.client, 17, 'D', 5) == -1) { printf("failed to add segment 4: "); goto end; } p->tcph->th_seq = htonl(17); int r = <API key>(ra_ctx, &ssn, &ssn.client, p); if (r < 0) { printf("<API key> failed: "); goto end; } if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 2) { printf("expected two stream messages: "); goto end; } StreamMsg *smsg = ssn.toserver_smsg_head; if (smsg->data_len != 10) { printf("expected data length to be 10, got %u: ", smsg->data_len); goto end; } if (!(memcmp(stream_payload1, smsg->data, 10) == 0)) { printf("data is not what we expected:\nExpected:\n"); PrintRawDataFp(stdout, stream_payload2, 10); printf("Got:\n"); PrintRawDataFp(stdout, smsg->data, smsg->data_len); goto end; } smsg = ssn.toserver_smsg_head->next; if (smsg->data_len != 5) { printf("expected data length to be 5, got %u: ", smsg->data_len); goto end; } if (!(memcmp(stream_payload2, smsg->data, 5) == 0)) { printf("data is not what we expected:\nExpected:\n"); PrintRawDataFp(stdout, stream_payload2, 5); printf("Got:\n"); PrintRawDataFp(stdout, smsg->data, smsg->data_len); goto end; } if (<API key>(&tv, ra_ctx, &ssn.client, 12, 'C', 5) == -1) { printf("failed to add segment 3: "); goto end; } ssn.client.next_seq = 22; p->tcph->th_seq = htonl(12); r = <API key>(ra_ctx, &ssn, &ssn.client, p); if (r < 0) { printf("<API key> failed: "); goto end; } if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 3) { printf("expected a single stream message, got %u: ", UtSsnSmsgCnt(&ssn, STREAM_TOSERVER)); goto end; } smsg = ssn.toserver_smsg_head->next->next; if (smsg->data_len != 20) { printf("expected data length to be 20, got %u: ", smsg->data_len); goto end; } if (!(memcmp(stream_payload3, smsg->data, 20) == 0)) { printf("data is not what we expected:\nExpected:\n"); PrintRawDataFp(stdout, stream_payload3, 20); printf("Got:\n"); PrintRawDataFp(stdout, smsg->data, smsg->data_len); goto end; } ret = 1; end: SCMutexUnlock(&f.m); FLOW_DESTROY(&f); UTHFreePacket(p); <API key>(&ssn); StreamTcpUTDeinit(ra_ctx); return ret; } /** \test with a GAP we should have 2 smsgs, with filling the GAP later, small * window */ static int <API key>(void) { int ret = 0; <API key> *ra_ctx = NULL; ThreadVars tv; TcpSession ssn; Flow f; memset(&tv, 0x00, sizeof(tv)); StreamTcpUTInit(&ra_ctx); <API key>(); <API key>(&ssn); <API key>(&ssn.client, 1); FLOW_INITIALIZE(&f); stream_config.<API key> = 16; uint8_t stream_payload1[] = "ABBBBB"; uint8_t stream_payload2[] = "DDDDD"; uint8_t stream_payload3[] = "AAAAABBBBBCCCCCD"; uint8_t payload[] = { 'C', 'C', 'C', 'C', 'C' }; Packet *p = UTHBuildPacketReal(payload, 5, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); if (p == NULL) { printf("couldn't get a packet: "); goto end; } p->tcph->th_seq = htonl(12); p->flow = &f; p->flowflags |= FLOW_PKT_TOSERVER; SCMutexLock(&f.m); if (<API key>(&tv, ra_ctx, &ssn.client, 2, 'A', 5) == -1) { printf("failed to add segment 1: "); goto end; } if (<API key>(&tv, ra_ctx, &ssn.client, 7, 'B', 5) == -1) { printf("failed to add segment 2: "); goto end; } ssn.client.next_seq = 12; if (<API key>(&tv, ra_ctx, &ssn.client, 17, 'D', 5) == -1) { printf("failed to add segment 4: "); goto end; } p->tcph->th_seq = htonl(17); int r = <API key>(ra_ctx, &ssn, &ssn.client, p); if (r < 0) { printf("<API key> failed: "); goto end; } if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 2) { printf("expected a single stream message, got %u: ", UtSsnSmsgCnt(&ssn, STREAM_TOSERVER)); goto end; } StreamMsg *smsg = ssn.toserver_smsg_head; if (smsg->data_len != 6) { printf("expected data length to be 6, got %u: ", smsg->data_len); goto end; } if (!(memcmp(stream_payload1, smsg->data, 6) == 0)) { printf("data is not what we expected:\nExpected:\n"); PrintRawDataFp(stdout, stream_payload1, 6); printf("Got:\n"); PrintRawDataFp(stdout, smsg->data, smsg->data_len); goto end; } smsg = ssn.toserver_smsg_head->next; if (smsg->data_len != 5) { printf("expected data length to be 5, got %u: ", smsg->data_len); goto end; } if (!(memcmp(stream_payload2, smsg->data, 5) == 0)) { printf("data is not what we expected:\nExpected:\n"); PrintRawDataFp(stdout, stream_payload2, 5); printf("Got:\n"); PrintRawDataFp(stdout, smsg->data, smsg->data_len); goto end; } if (<API key>(&tv, ra_ctx, &ssn.client, 12, 'C', 5) == -1) { printf("failed to add segment 3: "); goto end; } ssn.client.next_seq = 22; p->tcph->th_seq = htonl(12); r = <API key>(ra_ctx, &ssn, &ssn.client, p); if (r < 0) { printf("<API key> failed: "); goto end; } if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 3) { printf("expected a single stream message, got %u: ", UtSsnSmsgCnt(&ssn, STREAM_TOSERVER)); goto end; } smsg = ssn.toserver_smsg_head->next->next; if (smsg->data_len != 16) { printf("expected data length to be 16, got %u: ", smsg->data_len); goto end; } if (!(memcmp(stream_payload3, smsg->data, 16) == 0)) { printf("data is not what we expected:\nExpected:\n"); PrintRawDataFp(stdout, stream_payload3, 16); printf("Got:\n"); PrintRawDataFp(stdout, smsg->data, smsg->data_len); goto end; } ret = 1; end: SCMutexUnlock(&f.m); FLOW_DESTROY(&f); UTHFreePacket(p); <API key>(&ssn); StreamTcpUTDeinit(ra_ctx); return ret; } /** \test 3 in order segments, then reassemble, add one more and reassemble again. * test the sliding window reassembly with a small window size so that we * cutting off at the start (left edge). Test if the first segment is * removed from the list. */ static int <API key>(void) { int ret = 0; <API key> *ra_ctx = NULL; ThreadVars tv; TcpSession ssn; Flow f; memset(&tv, 0x00, sizeof(tv)); StreamTcpUTInit(&ra_ctx); <API key>(); <API key>(&ssn); <API key>(&ssn.client, 1); FLOW_INITIALIZE(&f); stream_config.<API key> = 15; ssn.client.flags |= <API key>; uint8_t stream_payload1[] = "AAAAABBBBBCCCCC"; uint8_t stream_payload2[] = "BBBBBCCCCCDDDDD"; uint8_t payload[] = { 'C', 'C', 'C', 'C', 'C' }; Packet *p = UTHBuildPacketReal(payload, 5, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); if (p == NULL) { printf("couldn't get a packet: "); goto end; } p->tcph->th_seq = htonl(12); p->flow = &f; p->flowflags |= FLOW_PKT_TOSERVER; SCMutexLock(&f.m); if (<API key>(&tv, ra_ctx, &ssn.client, 2, 'A', 5) == -1) { printf("failed to add segment 1: "); goto end; } if (<API key>(&tv, ra_ctx, &ssn.client, 7, 'B', 5) == -1) { printf("failed to add segment 2: "); goto end; } if (<API key>(&tv, ra_ctx, &ssn.client, 12, 'C', 5) == -1) { printf("failed to add segment 3: "); goto end; } ssn.client.next_seq = 17; int r = <API key>(ra_ctx, &ssn, &ssn.client, p); if (r < 0) { printf("<API key> failed: "); goto end; } if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 1) { printf("expected a single stream message: "); goto end; } StreamMsg *smsg = ssn.toserver_smsg_head; if (smsg->data_len != 15) { printf("expected data length to be 15, got %u: ", smsg->data_len); goto end; } if (!(memcmp(stream_payload1, smsg->data, 15) == 0)) { printf("data is not what we expected:\nExpected:\n"); PrintRawDataFp(stdout, stream_payload1, 15); printf("Got:\n"); PrintRawDataFp(stdout, smsg->data, smsg->data_len); goto end; } if (ssn.client.ra_raw_base_seq != 16) { printf("ra_raw_base_seq %"PRIu32", expected 16: ", ssn.client.ra_raw_base_seq); goto end; } if (<API key>(&tv, ra_ctx, &ssn.client, 17, 'D', 5) == -1) { printf("failed to add segment 4: "); goto end; } ssn.client.next_seq = 22; p->tcph->th_seq = htonl(17); r = <API key>(ra_ctx, &ssn, &ssn.client, p); if (r < 0) { printf("<API key> failed 2: "); goto end; } if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 2) { printf("expected a single stream message, got %u: ", UtSsnSmsgCnt(&ssn, STREAM_TOSERVER)); goto end; } smsg = ssn.toserver_smsg_head->next; if (smsg->data_len != 15) { printf("expected data length to be 15, got %u: ", smsg->data_len); goto end; } if (!(memcmp(stream_payload2, smsg->data, 15) == 0)) { printf("data is not what we expected:\nExpected:\n"); PrintRawDataFp(stdout, stream_payload2, 15); printf("Got:\n"); PrintRawDataFp(stdout, smsg->data, smsg->data_len); goto end; } if (ssn.client.ra_raw_base_seq != 21) { printf("ra_raw_base_seq %"PRIu32", expected 21: ", ssn.client.ra_raw_base_seq); goto end; } if (ssn.client.seg_list->seq != 7) { printf("expected segment 2 (seq 7) to be first in the list, got seq %"PRIu32": ", ssn.client.seg_list->seq); goto end; } ret = 1; end: SCMutexUnlock(&f.m); FLOW_DESTROY(&f); UTHFreePacket(p); <API key>(&ssn); StreamTcpUTDeinit(ra_ctx); return ret; } /** \test 3 in order segments, then reassemble, add one more and reassemble again. * test the sliding window reassembly with a small window size so that we * cutting off at the start (left edge). Test if the first segment is * removed from the list. */ static int <API key>(void) { int ret = 0; <API key> *ra_ctx = NULL; ThreadVars tv; TcpSession ssn; Flow f; memset(&tv, 0x00, sizeof(tv)); StreamTcpUTInit(&ra_ctx); <API key>(); <API key>(&ssn); <API key>(&ssn.client, 1); FLOW_INITIALIZE(&f); stream_config.<API key> = 20; ssn.client.flags |= <API key>; uint8_t stream_payload1[] = "AAAAABBBBBCCCCC"; uint8_t stream_payload2[] = "DDDDD"; uint8_t stream_payload3[] = "<API key>"; uint8_t payload[] = { 'C', 'C', 'C', 'C', 'C' }; Packet *p = UTHBuildPacketReal(payload, 5, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); if (p == NULL) { printf("couldn't get a packet: "); goto end; } p->tcph->th_seq = htonl(17); p->flow = &f; p->flowflags |= FLOW_PKT_TOSERVER; SCMutexLock(&f.m); if (<API key>(&tv, ra_ctx, &ssn.client, 2, 'A', 5) == -1) { printf("failed to add segment 1: "); goto end; } if (<API key>(&tv, ra_ctx, &ssn.client, 7, 'B', 5) == -1) { printf("failed to add segment 2: "); goto end; } if (<API key>(&tv, ra_ctx, &ssn.client, 17, 'D', 5) == -1) { printf("failed to add segment 3: "); goto end; } ssn.client.next_seq = 12; int r = <API key>(ra_ctx, &ssn, &ssn.client, p); if (r < 0) { printf("<API key> failed: "); goto end; } if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 2) { printf("expected 2 stream message2, got %u: ", UtSsnSmsgCnt(&ssn, STREAM_TOSERVER)); goto end; } StreamMsg *smsg = ssn.toserver_smsg_head; if (smsg->data_len != 10) { printf("expected data length to be 10, got %u (bot): ", smsg->data_len); goto end; } if (!(memcmp(stream_payload1, smsg->data, 10) == 0)) { printf("data is not what we expected:\nExpected:\n"); PrintRawDataFp(stdout, stream_payload1, 10); printf("Got:\n"); PrintRawDataFp(stdout, smsg->data, smsg->data_len); goto end; } smsg = ssn.toserver_smsg_head->next; if (smsg->data_len != 5) { printf("expected data length to be 5, got %u (top): ", smsg->data_len); goto end; } if (!(memcmp(stream_payload2, smsg->data, 5) == 0)) { printf("data is not what we expected:\nExpected:\n"); PrintRawDataFp(stdout, stream_payload2, 5); printf("Got:\n"); PrintRawDataFp(stdout, smsg->data, smsg->data_len); goto end; } if (ssn.client.ra_raw_base_seq != 11) { printf("ra_raw_base_seq %"PRIu32", expected 11: ", ssn.client.ra_raw_base_seq); goto end; } /* close the GAP and see if we properly reassemble and update ra_base_seq */ if (<API key>(&tv, ra_ctx, &ssn.client, 12, 'C', 5) == -1) { printf("failed to add segment 4: "); goto end; } ssn.client.next_seq = 22; p->tcph->th_seq = htonl(12); r = <API key>(ra_ctx, &ssn, &ssn.client, p); if (r < 0) { printf("<API key> failed 2: "); goto end; } if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 3) { printf("expected 3 stream messages: "); goto end; } smsg = ssn.toserver_smsg_head->next->next; if (smsg->data_len != 20) { printf("expected data length to be 20, got %u: ", smsg->data_len); goto end; } if (!(memcmp(stream_payload3, smsg->data, 20) == 0)) { printf("data is not what we expected:\nExpected:\n"); PrintRawDataFp(stdout, stream_payload3, 20); printf("Got:\n"); PrintRawDataFp(stdout, smsg->data, smsg->data_len); goto end; } if (ssn.client.ra_raw_base_seq != 21) { printf("ra_raw_base_seq %"PRIu32", expected 21: ", ssn.client.ra_raw_base_seq); goto end; } if (ssn.client.seg_list->seq != 2) { printf("expected segment 1 (seq 2) to be first in the list, got seq %"PRIu32": ", ssn.client.seg_list->seq); goto end; } ret = 1; end: SCMutexUnlock(&f.m); FLOW_DESTROY(&f); UTHFreePacket(p); <API key>(&ssn); StreamTcpUTDeinit(ra_ctx); return ret; } /** \test App Layer reassembly. */ static int <API key>(void) { int ret = 0; <API key> *ra_ctx = NULL; ThreadVars tv; TcpSession ssn; Flow *f = NULL; Packet *p = NULL; memset(&tv, 0x00, sizeof(tv)); StreamTcpUTInit(&ra_ctx); <API key>(); <API key>(&ssn); <API key>(&ssn.server, 1); f = UTHBuildFlow(AF_INET, "1.1.1.1", "2.2.2.2", 1024, 80); if (f == NULL) goto end; f->protoctx = &ssn; f->proto = IPPROTO_TCP; uint8_t stream_payload1[] = "GE"; uint8_t stream_payload2[] = "T /"; uint8_t stream_payload3[] = "HTTP/1.0\r\n\r\n"; p = UTHBuildPacketReal(stream_payload3, 12, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); if (p == NULL) { printf("couldn't get a packet: "); goto end; } p->tcph->th_seq = htonl(7); p->flow = f; p->flowflags |= FLOW_PKT_TOSERVER; SCMutexLock(&f->m); if (<API key>(&tv, ra_ctx, &ssn.server, 2, stream_payload1, 2) == -1) { printf("failed to add segment 1: "); goto end; } ssn.server.next_seq = 4; int r = <API key>(&tv, ra_ctx, &ssn, &ssn.server, p); if (r < 0) { printf("<API key> failed: "); goto end; } /* ssn.server.ra_app_base_seq should be isn here. */ if (ssn.server.ra_app_base_seq != 1 || ssn.server.ra_app_base_seq != ssn.server.isn) { printf("expected ra_app_base_seq 1, got %u: ", ssn.server.ra_app_base_seq); goto end; } if (<API key>(&tv, ra_ctx, &ssn.server, 4, stream_payload2, 3) == -1) { printf("failed to add segment 2: "); goto end; } if (<API key>(&tv, ra_ctx, &ssn.server, 7, stream_payload3, 12) == -1) { printf("failed to add segment 3: "); goto end; } ssn.server.next_seq = 19; r = <API key>(&tv, ra_ctx, &ssn, &ssn.server, p); if (r < 0) { printf("<API key> failed: "); goto end; } if (ssn.server.ra_app_base_seq != 18) { printf("expected ra_app_base_seq 18, got %u: ", ssn.server.ra_app_base_seq); goto end; } ret = 1; end: UTHFreePacket(p); <API key>(&ssn); StreamTcpUTDeinit(ra_ctx); SCMutexUnlock(&f->m); UTHFreeFlow(f); return ret; } /** \test test insert with overlap */ static int <API key>(void) { int ret = 0; <API key> *ra_ctx = NULL; ThreadVars tv; TcpSession ssn; Flow f; memset(&tv, 0x00, sizeof(tv)); StreamTcpUTInit(&ra_ctx); <API key>(&ssn); <API key>(&ssn.client, 1); FLOW_INITIALIZE(&f); uint8_t stream_payload1[] = "<API key>"; uint8_t payload[] = { 'C', 'C', 'C', 'C', 'C' }; Packet *p = UTHBuildPacketReal(payload, 5, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); if (p == NULL) { printf("couldn't get a packet: "); goto end; } p->tcph->th_seq = htonl(12); p->flow = &f; SCMutexLock(&f.m); if (<API key>(&tv, ra_ctx, &ssn.client, 2, 'A', 5) == -1) { printf("failed to add segment 1: "); goto end; } if (<API key>(&tv, ra_ctx, &ssn.client, 7, 'B', 5) == -1) { printf("failed to add segment 2: "); goto end; } if (<API key>(&tv, ra_ctx, &ssn.client, 14, 'D', 2) == -1) { printf("failed to add segment 3: "); goto end; } if (<API key>(&tv, ra_ctx, &ssn.client, 16, 'D', 6) == -1) { printf("failed to add segment 4: "); goto end; } if (<API key>(&tv, ra_ctx, &ssn.client, 12, 'C', 5) == -1) { printf("failed to add segment 5: "); goto end; } ssn.client.next_seq = 21; int r = <API key>(ra_ctx, &ssn, &ssn.client, p); if (r < 0) { printf("<API key> failed: "); goto end; } if (UtSsnSmsgCnt(&ssn, STREAM_TOSERVER) != 1) { printf("expected a single stream message: "); goto end; } StreamMsg *smsg = ssn.toserver_smsg_head; if (smsg->data_len != 20) { printf("expected data length to be 20, got %u: ", smsg->data_len); goto end; } if (!(memcmp(stream_payload1, smsg->data, 20) == 0)) { printf("data is not what we expected:\nExpected:\n"); PrintRawDataFp(stdout, stream_payload1, 20); printf("Got:\n"); PrintRawDataFp(stdout, smsg->data, smsg->data_len); goto end; } if (ssn.client.ra_raw_base_seq != 21) { printf("ra_raw_base_seq %"PRIu32", expected 21: ", ssn.client.ra_raw_base_seq); goto end; } ret = 1; end: SCMutexUnlock(&f.m); FLOW_DESTROY(&f); UTHFreePacket(p); <API key>(&ssn); StreamTcpUTDeinit(ra_ctx); return ret; } /** \test test insert with overlaps */ static int <API key>(void) { int ret = 0; <API key> *ra_ctx = NULL; ThreadVars tv; TcpSession ssn; memset(&tv, 0x00, sizeof(tv)); StreamTcpUTInit(&ra_ctx); <API key>(&ssn); <API key>(&ssn.client, 1); int i; for (i = 2; i < 10; i++) { int len; len = i % 2; if (len == 0) len = 1; int seq; seq = i * 10; if (seq < 2) seq = 2; if (<API key>(&tv, ra_ctx, &ssn.client, seq, 'A', len) == -1) { printf("failed to add segment 1: "); goto end; } } if (<API key>(&tv, ra_ctx, &ssn.client, 2, 'B', 1024) == -1) { printf("failed to add segment 2: "); goto end; } ret = 1; end: <API key>(&ssn); StreamTcpUTDeinit(ra_ctx); return ret; } /** \test test insert with overlaps */ static int <API key>(void) { int ret = 0; <API key> *ra_ctx = NULL; ThreadVars tv; TcpSession ssn; memset(&tv, 0x00, sizeof(tv)); StreamTcpUTInit(&ra_ctx); <API key>(&ssn); <API key>(&ssn.client, 1); if (<API key>(&tv, ra_ctx, &ssn.client, 2, 'A', 1024) == -1) { printf("failed to add segment 2: "); goto end; } int i; for (i = 2; i < 10; i++) { int len; len = i % 2; if (len == 0) len = 1; int seq; seq = i * 10; if (seq < 2) seq = 2; if (<API key>(&tv, ra_ctx, &ssn.client, seq, 'B', len) == -1) { printf("failed to add segment 2: "); goto end; } } ret = 1; end: <API key>(&ssn); StreamTcpUTDeinit(ra_ctx); return ret; } #endif /* UNITTESTS */ /** \brief The Function Register the Unit tests to test the reassembly engine * for various OS policies. */ void <API key>(void) { #ifdef UNITTESTS UtRegisterTest("<API key> -- BSD OS Before Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- BSD OS At Same Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- BSD OS After Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- BSD OS Complete Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- VISTA OS Before Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- VISTA OS At Same Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- VISTA OS After Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- VISTA OS Complete Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- LINUX OS Before Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- LINUX OS At Same Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- LINUX OS After Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- LINUX OS Complete Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- LINUX_OLD OS Before Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- LINUX_OLD At Same Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- LINUX_OLD OS After Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- LINUX_OLD OS Complete Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- SOLARIS OS Before Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- SOLARIS At Same Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- SOLARIS OS After Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- SOLARIS OS Complete Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- LAST OS Before Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- LAST OS At Same Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- LAST OS After Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- LAST OS Complete Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- Gap at Start Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- Gap at middle Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- Gap at after Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- Gap at Start IDS missed packet Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- Gap at Middle IDS missed packet Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- Gap at End IDS missed packet Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- Fast Track Reassembly Test", <API key>, 1); UtRegisterTest("<API key> -- Bug test", <API key>, 1); UtRegisterTest("<API key> -- Bug test", <API key>, 1); UtRegisterTest("<API key> -- Bug test", <API key>, 1); UtRegisterTest("<API key> -- Bug56 test", <API key>, 1); UtRegisterTest("<API key> -- Bug57 test", <API key>, 1); UtRegisterTest("<API key> -- Bug76 test", <API key>, 1); UtRegisterTest("<API key> -- app proto test", <API key>, 1); UtRegisterTest("<API key> -- app proto test", <API key>, 1); UtRegisterTest("<API key> -- app proto test", <API key>, 1); UtRegisterTest("<API key> -- min smsg size test", <API key>, 1); UtRegisterTest("<API key> -- Memcap Test", <API key>, 1); UtRegisterTest("<API key> -- Depth Test", <API key>, 1); UtRegisterTest("<API key> -- Depth Test", <API key>, 1); UtRegisterTest("<API key> -- TCP Sequence Wraparound Test", <API key>, 1); UtRegisterTest("<API key> -- inline RAW ra", <API key>, 1); UtRegisterTest("<API key> -- inline RAW ra 2", <API key>, 1); UtRegisterTest("<API key> -- inline RAW ra 3", <API key>, 1); UtRegisterTest("<API key> -- inline RAW ra 4", <API key>, 1); UtRegisterTest("<API key> -- inline RAW ra 5 GAP", <API key>, 1); UtRegisterTest("<API key> -- inline RAW ra 6 GAP", <API key>, 1); UtRegisterTest("<API key> -- inline RAW ra 7 GAP", <API key>, 1); UtRegisterTest("<API key> -- inline RAW ra 8 cleanup", <API key>, 1); UtRegisterTest("<API key> -- inline RAW ra 9 GAP cleanup", <API key>, 1); UtRegisterTest("<API key> -- inline APP ra 10", <API key>, 1); UtRegisterTest("<API key> -- insert with overlap", <API key>, 1); UtRegisterTest("<API key> -- insert with overlap", <API key>, 1); UtRegisterTest("<API key> -- insert with overlap", <API key>, 1); <API key>(); <API key>(); #endif /* UNITTESTS */ }
<?php // If this file is called directly, abort. if ( ! defined( 'WPINC' ) ) { die; } if ( ! version_compare( PHP_VERSION, '5.4', '>=' ) ) { add_action( 'admin_notices', 'civ_fail_wp_version' ); } else { // Public-Facing Functionality. require_once( plugin_dir_path( __FILE__ ) . 'includes/<API key>.php' ); require_once( plugin_dir_path( __FILE__ ) . 'public/<API key>.php' ); add_action( 'plugins_loaded', array( 'CIV_Plugin', 'get_instance' ) ); // Dashboard and Administrative Functionality. if ( is_admin() ) { require_once( plugin_dir_path( __FILE__ ) . 'admin/<API key>.php' ); add_action( 'plugins_loaded', array( 'CIV_Plugin_Admin', 'get_instance' ) ); } } add_action( 'plugins_loaded', '<API key>' ); /** * Load the plugin text domain for translation. * * @since 1.0.0 */ function <API key>() { <API key>( '<API key>', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); } /** * Show in WP Dashboard notice about the plugin is not activated. * * @since 1.0.0 */ function civ_fail_wp_version() { $message = esc_html__( 'This plugin requires WordPress version 4.4, plugin is currently NOT ACTIVE.', '<API key>' ); $html_message = sprintf( '<div class="error">%s</div>', wpautop( $message ) ); echo wp_kses_post( $html_message ); }
<?php include $_SERVER['DOCUMENT_ROOT'].'/includes/php_header.php'; $problem = $u->getProblemById($_GET['p']); if($_POST){ $data = $_POST; $data['figure'] = file_get_contents($_FILES['figure']['tmp_name']); $data['figure_file'] = $_FILES['figure']['tmp_name']; $data['mml'] = file_get_contents($_FILES['mml']['tmp_name']); if(!$u->submitSolution($data)){ $error = $u->error; } else{ $msg = 'Solution submitted successfully. It will appear on the website after approval of an editor. Thank you for contributing to this growing collection of science-problems!'; } } ?> <!DOCTYPE HTML> <html> <head> <title>New problem</title> <?php include 'includes/html_head_include.php'; ?> </head> <body class="no-sidebar"> <?php include $_SERVER['DOCUMENT_ROOT'].'/includes/header.php'; ?> <!-- Main Wrapper --> <div id="main-wrapper"> <div class="container"> <div class="row"> <div class="12u"> <!-- Portfolio --> <section> <div> <div class="row"> <div class="12u <API key>"> <!-- Content --> <article class="box is-post"> <header> <h2>New Solution</h2> </header> <p> <h3>Problem</h3> <?php echo $problem['mml']; ?> <h3>Upload solution file</h3> <span class="error"><?php echo $error; ?></span> <span class="message"><?php echo $msg; ?></span> <form class="fullwidth" enctype="multipart/form-data" method="post" action=""> <input type="hidden" name="problem_id" value="<?php echo $_GET['p']; ?>"/> <label>Figure (optional)</label> <input type="file" class="file" name="figure" /> <label>MathML file</label> <input type="file" class="file" name="mml" required/> <br/> <input type="submit"/> </form> </p> </article> </div> </div> </div> </section> </div> </div> </div> </div> <?php include $_SERVER['DOCUMENT_ROOT'].'/includes/footer.php'; ?> </body> </html>
/*global chrome */ // Check if the feature is enable let promise = new Promise(function (resolve) { chrome.storage.sync.get({ isEdEnable: true }, function (items) { if (items.isEdEnable === true) { resolve(); } }); }); promise.then(function () { /*global removeIfExist */ /*eslint no-undef: "error"*/ removeIfExist(".blockheader"); removeIfExist(".blockcontent .upload-infos"); removeIfExist(".blockfooter"); });
/*! \file * * \brief Background DNS update manager * * \author Kevin P. Fleming <kpfleming@digium.com> * * \bug There is a minor race condition. In the event that an IP address * of a dnsmgr managed host changes, there is the potential for the consumer * of that address to access the in_addr data at the same time that the dnsmgr * thread is in the middle of updating it to the new address. */ #include "asterisk.h" <API key>(__FILE__, "$Revision: 130752 $") #include "asterisk/_private.h" #include <regex.h> #include <signal.h> #include "asterisk/dnsmgr.h" #include "asterisk/linkedlists.h" #include "asterisk/utils.h" #include "asterisk/config.h" #include "asterisk/sched.h" #include "asterisk/cli.h" #include "asterisk/manager.h" static struct sched_context *sched; static int refresh_sched = -1; static pthread_t refresh_thread = AST_PTHREADT_NULL; struct ast_dnsmgr_entry { /*! where we will store the resulting address */ struct in_addr *result; /*! the last result, used to check if address has changed */ struct in_addr last; /*! Set to 1 if the entry changes */ int changed:1; ast_mutex_t lock; AST_RWLIST_ENTRY(ast_dnsmgr_entry) list; /*! just 1 here, but we use calloc to allocate the correct size */ char name[1]; }; static <API key>(entry_list, ast_dnsmgr_entry); <API key>(refresh_lock); #define REFRESH_DEFAULT 300 static int enabled; static int refresh_interval; struct refresh_info { struct entry_list *entries; int verbose; unsigned int regex_present:1; regex_t filter; }; static struct refresh_info master_refresh_info = { .entries = &entry_list, .verbose = 0, }; struct ast_dnsmgr_entry *ast_dnsmgr_get(const char *name, struct in_addr *result) { struct ast_dnsmgr_entry *entry; if (!result || ast_strlen_zero(name) || !(entry = ast_calloc(1, sizeof(*entry) + strlen(name)))) return NULL; entry->result = result; ast_mutex_init(&entry->lock); strcpy(entry->name, name); memcpy(&entry->last, result, sizeof(entry->last)); AST_RWLIST_WRLOCK(&entry_list); <API key>(&entry_list, entry, list); AST_RWLIST_UNLOCK(&entry_list); return entry; } void ast_dnsmgr_release(struct ast_dnsmgr_entry *entry) { if (!entry) return; AST_RWLIST_WRLOCK(&entry_list); AST_RWLIST_REMOVE(&entry_list, entry, list); AST_RWLIST_UNLOCK(&entry_list); ast_verb(4, "removing dns manager for '%s'\n", entry->name); ast_mutex_destroy(&entry->lock); ast_free(entry); } int ast_dnsmgr_lookup(const char *name, struct in_addr *result, struct ast_dnsmgr_entry **dnsmgr) { struct ast_hostent ahp; struct hostent *hp; if (ast_strlen_zero(name) || !result || !dnsmgr) return -1; if (*dnsmgr && !strcasecmp((*dnsmgr)->name, name)) return 0; ast_verb(4, "doing dnsmgr_lookup for '%s'\n", name); /* if it's actually an IP address and not a name, there's no need for a managed lookup */ if (inet_aton(name, result)) return 0; /* do a lookup now but add a manager so it will automagically get updated in the background */ if ((hp = ast_gethostbyname(name, &ahp))) memcpy(result, hp->h_addr, sizeof(result)); /* if dnsmgr is not enable don't bother adding an entry */ if (!enabled) return 0; ast_verb(3, "adding dns manager for '%s'\n", name); *dnsmgr = ast_dnsmgr_get(name, result); return !*dnsmgr; } /* * Refresh a dnsmgr entry */ static int dnsmgr_refresh(struct ast_dnsmgr_entry *entry, int verbose) { struct ast_hostent ahp; struct hostent *hp; char iabuf[INET_ADDRSTRLEN]; char iabuf2[INET_ADDRSTRLEN]; struct in_addr tmp; int changed = 0; ast_mutex_lock(&entry->lock); if (verbose) ast_verb(3, "refreshing '%s'\n", entry->name); if ((hp = ast_gethostbyname(entry->name, &ahp))) { /* check to see if it has changed, do callback if requested (where de callback is defined ????) */ memcpy(&tmp, hp->h_addr, sizeof(tmp)); if (tmp.s_addr != entry->last.s_addr) { ast_copy_string(iabuf, ast_inet_ntoa(entry->last), sizeof(iabuf)); ast_copy_string(iabuf2, ast_inet_ntoa(tmp), sizeof(iabuf2)); ast_log(LOG_NOTICE, "host '%s' changed from %s to %s\n", entry->name, iabuf, iabuf2); memcpy(entry->result, hp->h_addr, sizeof(entry->result)); memcpy(&entry->last, hp->h_addr, sizeof(entry->last)); changed = entry->changed = 1; } } ast_mutex_unlock(&entry->lock); return changed; } int ast_dnsmgr_refresh(struct ast_dnsmgr_entry *entry) { return dnsmgr_refresh(entry, 0); } /* * Check if dnsmgr entry has changed from since last call to this function */ int ast_dnsmgr_changed(struct ast_dnsmgr_entry *entry) { int changed; ast_mutex_lock(&entry->lock); changed = entry->changed; entry->changed = 0; ast_mutex_unlock(&entry->lock); return changed; } static void *do_refresh(void *data) { for (;;) { pthread_testcancel(); usleep((ast_sched_wait(sched)*1000)); pthread_testcancel(); ast_sched_runq(sched); } return NULL; } static int refresh_list(const void *data) { struct refresh_info *info = (struct refresh_info *)data; struct ast_dnsmgr_entry *entry; /* if a refresh or reload is already in progress, exit now */ if (ast_mutex_trylock(&refresh_lock)) { if (info->verbose) ast_log(LOG_WARNING, "DNS Manager refresh already in progress.\n"); return -1; } ast_verb(3, "Refreshing DNS lookups.\n"); AST_RWLIST_RDLOCK(info->entries); AST_RWLIST_TRAVERSE(info->entries, entry, list) { if (info->regex_present && regexec(&info->filter, entry->name, 0, NULL, 0)) continue; dnsmgr_refresh(entry, info->verbose); } AST_RWLIST_UNLOCK(info->entries); ast_mutex_unlock(&refresh_lock); /* automatically reschedule based on the interval */ return refresh_interval * 1000; } void <API key>(void) { if (refresh_sched > -1) { AST_SCHED_DEL(sched, refresh_sched); refresh_sched = <API key>(sched, 100, refresh_list, &master_refresh_info, 1); } } static int do_reload(int loading); static char *handle_cli_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { case CLI_INIT: e->command = "dnsmgr reload"; e->usage = "Usage: dnsmgr reload\n" " Reloads the DNS manager configuration.\n"; return NULL; case CLI_GENERATE: return NULL; } if (a->argc > 2) return CLI_SHOWUSAGE; do_reload(0); return CLI_SUCCESS; } static char *handle_cli_refresh(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct refresh_info info = { .entries = &entry_list, .verbose = 1, }; switch (cmd) { case CLI_INIT: e->command = "dnsmgr refresh"; e->usage = "Usage: dnsmgr refresh [pattern]\n" " Peforms an immediate refresh of the managed DNS entries.\n" " Optional regular expression pattern is used to filter the entries to refresh.\n"; return NULL; case CLI_GENERATE: return NULL; } if (!enabled) { ast_cli(a->fd, "DNS Manager is disabled.\n"); return 0; } if (a->argc > 3) { return CLI_SHOWUSAGE; } if (a->argc == 3) { if (regcomp(&info.filter, a->argv[2], REG_EXTENDED | REG_NOSUB)) { return CLI_SHOWUSAGE; } else { info.regex_present = 1; } } refresh_list(&info); if (info.regex_present) { regfree(&info.filter); } return CLI_SUCCESS; } static char *handle_cli_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { int count = 0; struct ast_dnsmgr_entry *entry; switch (cmd) { case CLI_INIT: e->command = "dnsmgr status"; e->usage = "Usage: dnsmgr status\n" " Displays the DNS manager status.\n"; return NULL; case CLI_GENERATE: return NULL; } if (a->argc > 2) return CLI_SHOWUSAGE; ast_cli(a->fd, "DNS Manager: %s\n", enabled ? "enabled" : "disabled"); ast_cli(a->fd, "Refresh Interval: %d seconds\n", refresh_interval); AST_RWLIST_RDLOCK(&entry_list); AST_RWLIST_TRAVERSE(&entry_list, entry, list) count++; AST_RWLIST_UNLOCK(&entry_list); ast_cli(a->fd, "Number of entries: %d\n", count); return CLI_SUCCESS; } static struct ast_cli_entry cli_reload = AST_CLI_DEFINE(handle_cli_reload, "Reloads the DNS manager configuration"); static struct ast_cli_entry cli_refresh = AST_CLI_DEFINE(handle_cli_refresh, "Performs an immediate refresh"); static struct ast_cli_entry cli_status = AST_CLI_DEFINE(handle_cli_status, "Display the DNS manager status"); int dnsmgr_init(void) { if (!(sched = <API key>())) { ast_log(LOG_ERROR, "Unable to create schedule context.\n"); return -1; } ast_cli_register(&cli_reload); ast_cli_register(&cli_status); ast_cli_register(&cli_refresh); return do_reload(1); } int dnsmgr_reload(void) { return do_reload(0); } static int do_reload(int loading) { struct ast_config *config; struct ast_flags config_flags = { loading ? 0 : <API key> }; const char *interval_value; const char *enabled_value; int interval; int was_enabled; int res = -1; if ((config = ast_config_load("dnsmgr.conf", config_flags)) == <API key>) return 0; /* ensure that no refresh cycles run while the reload is in progress */ ast_mutex_lock(&refresh_lock); /* reset defaults in preparation for reading config file */ refresh_interval = REFRESH_DEFAULT; was_enabled = enabled; enabled = 0; AST_SCHED_DEL(sched, refresh_sched); if (config) { if ((enabled_value = <API key>(config, "general", "enable"))) { enabled = ast_true(enabled_value); } if ((interval_value = <API key>(config, "general", "refreshinterval"))) { if (sscanf(interval_value, "%d", &interval) < 1) ast_log(LOG_WARNING, "Unable to convert '%s' to a numeric value.\n", interval_value); else if (interval < 0) ast_log(LOG_WARNING, "Invalid refresh interval '%d' specified, using default\n", interval); else refresh_interval = interval; } ast_config_destroy(config); } if (enabled && refresh_interval) ast_log(LOG_NOTICE, "Managed DNS entries will be refreshed every %d seconds.\n", refresh_interval); /* if this reload enabled the manager, create the background thread if it does not exist */ if (enabled) { if (!was_enabled && (refresh_thread == AST_PTHREADT_NULL)) { if (<API key>(&refresh_thread, NULL, do_refresh, NULL) < 0) { ast_log(LOG_ERROR, "Unable to start refresh thread.\n"); } } /* make a background refresh happen right away */ refresh_sched = <API key>(sched, 100, refresh_list, &master_refresh_info, 1); res = 0; } /* if this reload disabled the manager and there is a background thread, kill it */ else if (!enabled && was_enabled && (refresh_thread != AST_PTHREADT_NULL)) { /* wake up the thread so it will exit */ pthread_cancel(refresh_thread); pthread_kill(refresh_thread, SIGURG); pthread_join(refresh_thread, NULL); refresh_thread = AST_PTHREADT_NULL; res = 0; } else res = 0; ast_mutex_unlock(&refresh_lock); manager_event(EVENT_FLAG_SYSTEM, "Reload", "Module: DNSmgr\r\nStatus: %s\r/nMessage: DNSmgr reload Requested\r\n", enabled ? "Enabled" : "Disabled"); return res; }
<?php // No direct access to this file defined('_JEXEC') or die('Restricted access'); // import Joomla view library jimport('joomla.application.component.view'); /** * athletes View */ class <API key> extends JViewLegacy { /** * Athletes view display method * @return void */ function display($tpl = null) { // Include helper submenu TrackclubsHelper::addSubmenu('athletes'); // Get data from the model $items = $this->get('Items'); $pagination = $this->get('Pagination'); // Check for errors. if (count($errors = $this->get('Errors'))){ JError::raiseError(500, implode('<br />', $errors)); return false; }; // Assign data to the view $this->items = $items; $this->pagination = $pagination; // Set the toolbar $this->addToolBar(); // Show sidebar $this->sidebar = JHtmlSidebar::render(); // Display the template parent::display($tpl); // Set the document $this->setDocument(); } /** * Setting the toolbar */ protected function addToolBar() { $canDo = TrackclubsHelper::getActions(); JToolBarHelper::title(JText::_('Trackclubs Manager'), 'trackclubs'); if($canDo->get('core.create')){ JToolBarHelper::addNew('athlete.add', 'JTOOLBAR_NEW'); }; if($canDo->get('core.edit')){ JToolBarHelper::editList('athlete.edit', 'JTOOLBAR_EDIT'); }; if($canDo->get('core.delete')){ JToolBarHelper::deleteList('', 'athletes.delete', 'JTOOLBAR_DELETE'); }; if($canDo->get('core.admin')){ JToolBarHelper::divider(); JToolBarHelper::preferences('com_trackclubs'); }; } /** * Method to set up the document properties * * * @return void */ protected function setDocument() { $document = JFactory::getDocument(); $document->setTitle(JText::_('Trackclubs Manager - Administrator')); } } ?>
package com.nilsonmassarenti.app.currencyfair.model; public class CurrencyFairURI { public static final String DUMMY_BP = "/rest/currencyfair/dummy"; public static final String GET_CURRENCY_FAIR = "/rest/currencyfair/get/{id}"; public static final String <API key> = "/rest/currencyfairs"; public static final String <API key> = "/rest/currencyfair/create"; public static final String <API key> = "/rest/currencyfair/delete/{id}"; }
/* Headers */ #include <stdio.h> #include <stdlib.h> #include <SDL/SDL.h> #include <errno.h> #if !_MSC_VER #include <unistd.h> #endif #if !BAZEL_BUILD #include "../../sprdata.h" #else #include "sprdata.h" #endif #include "picfuncs.h" #pragma pack(1) typedef struct { uint32_t signature; uint16_t imgcount; } fileheader_t; typedef struct { uint8_t width, height; uint8_t unk1, unk2, unk3; } picheader_t; #pragma pack() static int filesize (FILE* f) { int loc = ftell(f); int size = 0; fseek(f, 0, SEEK_END); size = ftell(f); fseek(f, loc, SEEK_SET); return size; } int writesprite (FILE *f, SDL_Surface *s, int offx, int offy, uint16_t *datasize) { return writeSprData(f, s, offx, offy, datasize); } int readsprite (FILE *f, uint32_t sprloc, SDL_Surface *s, int offx, int offy) { int oldloc = ftell(f); int r; fseek(f, sprloc, SEEK_SET); r = readSprData(f, s, offx, offy); fseek(f, oldloc, SEEK_SET); return r; } int picdetails (const char* filename) { FILE *f; int i,j,k; fileheader_t fh; picheader_t ph; uint32_t sprloc; f = fopen(filename, "rb"); printf("information for %s\n", filename); if (!f) return -1; fread(&fh, sizeof(fh), 1, f); printf("signature %d\n", fh.signature); printf("imagecount %d\n", fh.imgcount); for(i = 0; i < fh.imgcount ; i++){ fread(&ph, sizeof(ph), 1, f); printf("img%d width %d height %d bg rgb #%02x%02x%02x\n", i, ph.width, ph.height, ph.unk1, ph.unk2, ph.unk3); for(j = 0; j<ph.height; j++){ for(k = 0; k < ph.width; k++){ fread(&sprloc, sizeof(sprloc), 1, f); printf("sprite img %d x %d y %d location %d\n", i,k,j,sprloc); } } } return 0; } int dumperror_stderr(char* txt, ...) { va_list vl; va_start(vl, txt); int r = vfprintf(stderr, txt, vl); va_end(vl); return r; } int (*pictool_dumperror)(char*,...) = dumperror_stderr; int writepic(const char* filename, int index, SDL_Surface *s){ FILE *fi, *fo; fileheader_t fh; picheader_t ph; uint32_t sprloc, sproffset; size_t continuationposi, continuationposo; uint16_t datasize; void *data; int i,j,k; fi = fopen(filename, "rb"); fo = fopen("__tmp__.pic","wb+"); if (!fi || !fo) return -1; fread(&fh, sizeof(fh), 1, fi); fwrite(&fh, sizeof(fh), 1, fo); sproffset = fh.imgcount * (sizeof(ph)+1)-2; for(i = 0; i < fh.imgcount; i++){ fread(&ph, sizeof(ph), 1, fi); if(i == index){ ph.width = s->w / 32; ph.height = s->h / 32; } sproffset += ph.width * ph.height * 4; fseek(fi, ph.width*ph.height*4, SEEK_CUR); } fseek(fi, sizeof(fh), SEEK_SET); for(i = 0; i < fh.imgcount; i++){ fread(&ph, sizeof(ph), 1, fi); if(i != index){ if(!ph.width || !ph.height){ fprintf(stderr, "pictool: width or height are 0\n"); return (10); } fwrite(&ph, sizeof(ph), 1, fo); for(j=0; j < ph.width * ph.height; j++){ fread(&sprloc, sizeof(sprloc), 1, fi); if(sproffset > 4000000){ dumperror_stderr("pictool: infinite loop\n"); exit(8); } if(sprloc > filesize(fi)){ dumperror_stderr("pictool: bad spr pointer\n"); exit(9); } fwrite(&sproffset, sizeof(sproffset), 1, fo); continuationposi = ftell(fi); continuationposo = ftell(fo); fseek(fi, sprloc, SEEK_SET); fseek(fo, sproffset, SEEK_SET); fread(&datasize, sizeof(datasize), 1, fi); fwrite(&datasize, sizeof(datasize), 1, fo); data = malloc(datasize+2); if(!data){ dumperror_stderr("pictool: allocation problem\n"); return (7); } fread(data, datasize+2, 1, fi); fwrite(data, datasize+2, 1, fo); free(data); fseek(fo, continuationposo, SEEK_SET); fseek(fi, continuationposi, SEEK_SET); sproffset += datasize+2; // 2 == space for datasize } fflush(fo); } else{ fseek(fi, ph.width*ph.height*4, SEEK_CUR); ph.width = s->w / 32; ph.height = s->h / 32; fwrite(&ph, sizeof(ph), 1, fo); for(j = 0; j < ph.height; j++){ for(k = 0; k < ph.width; k++){ /*printf("Placing %d %d on %d\n", j, k, sproffset);*/ fwrite(&sproffset, sizeof(sproffset), 1, fo); continuationposo = ftell(fo); fseek(fo, sproffset, SEEK_SET); writesprite(fo, s, k * 32, j*32, &datasize); /*printf("Its size is: %d\n", datasize);*/ fseek(fo, continuationposo, SEEK_SET); sproffset += datasize+2; } } fflush(fo); } } fclose(fo); fclose(fi); if(rename("__tmp__.pic", filename)){ if (errno == 17) {// file exists if(unlink(filename)) { if (errno != 2) return 93; } if(rename("__tmp__.pic", filename)){ return 92; } } else { return 92; } } return 0; } int readpic (const char* filename, int index, SDL_Surface **sr) { /* index >= -1; -1 means that we should print out details */ SDL_Surface *s=NULL; FILE *f; int i,j,k; fileheader_t fh; picheader_t ph; uint32_t sprloc; uint32_t magenta; f = fopen(filename, "rb"); if (!f) return -1; fread(&fh,sizeof(fh),1,f); for(i = 0; i < fh.imgcount && i <= index; i++){ fread(&ph, sizeof(ph), 1, f); if(i == index){ s = <API key>(SDL_SWSURFACE, ph.width*32, ph.height*32, 32, 0xFF, 0xFF00, 0xFF0000, 0xFF000000); if(!s){ printf("CreateRGBSurface failed: %s\n", SDL_GetError()); return -1; } magenta = SDL_MapRGB(s->format, 255, 0, 255); SDL_FillRect(s, NULL, magenta); /* FIXME (ivucica#4#) Above statement is potentially unportable to architectures with * different endianess. Lilliputtans would be happier if we took a look at SDL * docs and corrected this. */ for(j = 0; j < ph.height; j++){ for(k = 0; k < ph.width; k++){ fread(&sprloc, sizeof(sprloc), 1, f); dbgprintf(":: reading sprite at pos %d %d\n", j, k); if(readsprite(f, sprloc, s, k*32, j*32)){ /* TODO (ivucica#1#) cleanup sdl surface upon error */ return -1; } } } } else{ fseek(f, sizeof(sprloc)*ph.height*ph.width, SEEK_CUR); } } fclose(f); *sr = s; return 0; }
<?php function vmptshow() { $vmpt_setting = get_option('vmpt_setting'); $array = array("setting" => $vmpt_setting); echo vmpt_shortcode($array); } function vmpt_shortcode( $atts ) { global $wpdb; $vmpt_marquee = ""; $vmpt = ""; $link = ""; //[vmpt setting="1"] if ( ! is_array( $atts ) ) { return ''; } $setting = $atts['setting']; switch ($setting) { case 1: $vmpt_setting = get_option('vmpt_setting1'); break; case 2: $vmpt_setting = get_option('vmpt_setting2'); break; case 3: $vmpt_setting = get_option('vmpt_setting3'); break; case 4: $vmpt_setting = get_option('vmpt_setting4'); break; default: $vmpt_setting = get_option('vmpt_setting1'); } @list($vmpt_scrollamount, $vmpt_scrolldelay, $vmpt_direction, $vmpt_style, $vmpt_noofpost, $vmpt_categories, $vmpt_orderbys, $vmpt_order, $vmpt_spliter) = explode("~~", @$vmpt_setting); if(!is_numeric($vmpt_scrollamount)){ $vmpt_scrollamount = 2; } if(!is_numeric($vmpt_scrolldelay)){ $vmpt_scrolldelay = 5; } if(!is_numeric($vmpt_noofpost)){ $vmpt_noofpost = 10; } $sSql = query_posts('cat='.$vmpt_categories.'&orderby='.$vmpt_orderbys.'&order='.$vmpt_order.'&showposts='.$vmpt_noofpost); if ( ! empty($sSql) ) { $count = 0; foreach ( $sSql as $sSql ) { $title = stripslashes($sSql->post_title); $link = get_permalink($sSql->ID); if($count==0) { if($link != "") { $vmpt = $vmpt . "<a target='' href='".$link."'>"; } $vmpt = $vmpt . $title; if($link != "") { $vmpt = $vmpt . "</a>"; } } else { $vmpt = $vmpt . " <br /><br /> "; if($link != "") { $vmpt = $vmpt . "<a target='' href='".$link."'>"; } $vmpt = $vmpt . $title; if($link != "") { $vmpt = $vmpt . "</a>"; } } $count = $count + 1; } } else { $vmpt = __('No records found.', '<API key>'); } wp_reset_query(); $vmpt_marquee = $vmpt_marquee . "<div style='padding:3px;' class='vmpt_marquee'>"; $vmpt_marquee = $vmpt_marquee . "<marquee style='$vmpt_style' scrollamount='$vmpt_scrollamount' scrolldelay='$vmpt_scrolldelay' direction='$vmpt_direction' onmouseover='this.stop()' onmouseout='this.start()'>"; $vmpt_marquee = $vmpt_marquee . $vmpt; $vmpt_marquee = $vmpt_marquee . "</marquee>"; $vmpt_marquee = $vmpt_marquee . "</div>"; return $vmpt_marquee; } function vmpt_install() { add_option('vmpt_title', "Marquee post title"); add_option('vmpt_setting', "1"); add_option('vmpt_setting1', "2~~5~~up~~height:100px;~~10~~~~ID~~DESC"); add_option('vmpt_setting2', "2~~5~~up~~color:#FF0000;font:Arial;height:100px;~~10~~~~ID~~DESC"); add_option('vmpt_setting3', "2~~5~~down~~color:#FF0000;font:Arial;height:120px;~~10~~~~title~~DESC"); add_option('vmpt_setting4', "2~~5~~down~~color:#FF0000;font:Arial;height:140px;~~10~~~~rand~~DESC"); } function vmpt_deactivation() { // No action required. } function vmpt_option() { ?> <div class="wrap"> <div class="form-wrap"> <div id="icon-edit" class="icon32 icon32-posts-post"><br> </div> <h2><?php _e('Vertical marquee post title', '<API key>'); ?></h2> <?php global $wpdb; $vmpt_setting1 = get_option('vmpt_setting1'); $vmpt_setting2 = get_option('vmpt_setting2'); $vmpt_setting3 = get_option('vmpt_setting3'); $vmpt_setting4 = get_option('vmpt_setting4'); list($a1, $b1, $c1, $d1, $e1, $f1, $g1, $h1) = explode("~~", $vmpt_setting1); list($a2, $b2, $c2, $d2, $e2, $f2, $g2, $h2) = explode("~~", $vmpt_setting2); list($a3, $b3, $c3, $d3, $e3, $f3, $g3, $h3) = explode("~~", $vmpt_setting3); list($a4, $b4, $c4, $d4, $e4, $f4, $g4, $h4) = explode("~~", $vmpt_setting4); if (isset($_POST['vmpt_submit'])) { // Just security thingy that wordpress offers us check_admin_referer('vmpt_form_setting'); $a1 = stripslashes($_POST['vmpt_scrollamount1']); $b1 = stripslashes($_POST['vmpt_scrolldelay1']); $c1 = stripslashes($_POST['vmpt_direction1']); $d1 = stripslashes($_POST['vmpt_style1']); $e1 = stripslashes($_POST['vmpt_noofpost1']); $f1 = stripslashes($_POST['vmpt_categories1']); $g1 = stripslashes($_POST['vmpt_orderbys1']); $h1 = stripslashes($_POST['vmpt_order1']); $a2 = stripslashes($_POST['vmpt_scrollamount2']); $b2 = stripslashes($_POST['vmpt_scrolldelay2']); $c2 = stripslashes($_POST['vmpt_direction2']); $d2 = stripslashes($_POST['vmpt_style2']); $e2 = stripslashes($_POST['vmpt_noofpost2']); $f2 = stripslashes($_POST['vmpt_categories2']); $g2 = stripslashes($_POST['vmpt_orderbys2']); $h2 = stripslashes($_POST['vmpt_order2']); $a3 = stripslashes($_POST['vmpt_scrollamount3']); $b3 = stripslashes($_POST['vmpt_scrolldelay3']); $c3 = stripslashes($_POST['vmpt_direction3']); $d3 = stripslashes($_POST['vmpt_style3']); $e3 = stripslashes($_POST['vmpt_noofpost3']); $f3 = stripslashes($_POST['vmpt_categories3']); $g3 = stripslashes($_POST['vmpt_orderbys3']); $h3 = stripslashes($_POST['vmpt_order3']); $a4 = stripslashes($_POST['vmpt_scrollamount4']); $b4 = stripslashes($_POST['vmpt_scrolldelay4']); $c4 = stripslashes($_POST['vmpt_direction4']); $d4 = stripslashes($_POST['vmpt_style4']); $e4 = stripslashes($_POST['vmpt_noofpost4']); $f4 = stripslashes($_POST['vmpt_categories4']); $g4 = stripslashes($_POST['vmpt_orderbys4']); $h4 = stripslashes($_POST['vmpt_order4']); update_option('vmpt_setting1', @$a1 . "~~" . @$b1 . "~~" . @$c1 . "~~" . @$d1 . "~~" . @$e1 . "~~" . @$f1 . "~~" . @$g1 . "~~" . @$h1 . "~~" . @$i1 ); update_option('vmpt_setting2', @$a2 . "~~" . @$b2 . "~~" . @$c2 . "~~" . @$d2 . "~~" . @$e2 . "~~" . @$f2 . "~~" . @$g2 . "~~" . @$h2 . "~~" . @$i2 ); update_option('vmpt_setting3', @$a3 . "~~" . @$b3 . "~~" . @$c3 . "~~" . @$d3 . "~~" . @$e3 . "~~" . @$f3 . "~~" . @$g3 . "~~" . @$h3 . "~~" . @$i3 ); update_option('vmpt_setting4', @$a4 . "~~" . @$b4 . "~~" . @$c4 . "~~" . @$d4 . "~~" . @$e4 . "~~" . @$f4 . "~~" . @$g4 . "~~" . @$h4 . "~~" . @$i4 ); ?> <div class="updated fade"> <p><strong><?php _e('Details successfully updated.', '<API key>'); ?></strong></p> </div> <?php } echo '<form name="vmpt_form" method="post" action="">'; ?> <table width="800" border="0" cellspacing="0" cellpadding="0"> <tr> <td><?php echo '<h3>'.__('Setting 1', '<API key>').'</h3>'; echo '<p>'.__('Scroll amount :', '<API key>').'<br><input style="width: 100px;" type="text" value="'; echo $a1 . '" name="vmpt_scrollamount1" id="vmpt_scrollamount1" /></p>'; echo '<p>'.__('Scroll delay :', '<API key>').'<br><input style="width: 100px;" type="text" value="'; echo $b1 . '" name="vmpt_scrolldelay1" id="vmpt_scrolldelay1" /></p>'; echo '<p>'.__('Scroll direction :', '<API key>').'<br><input style="width: 100px;" type="text" value="'; echo $c1 . '" name="vmpt_direction1" id="vmpt_direction1" /> '.__('(Up / Down)', '<API key>').'</p>'; echo '<p>'.__('Scroll style :', '<API key>').'<br><input style="width: 250px;" type="text" value="'; echo $d1 . '" name="vmpt_style1" id="vmpt_style1" /></p>'; echo '<p>'.__('Number of post :', '<API key>').'<br><input style="width: 100px;" type="text" value="'; echo $e1 . '" name="vmpt_noofpost1" id="vmpt_noofpost1" /></p>'; echo '<p>'.__('Post categories :', '<API key>').'<br><input style="width: 200px;" type="text" value="'; echo $f1 . '" name="vmpt_categories1" id="vmpt_categories1" /> (Example: 1, 3, 4) <br> '.__('Category IDs, separated by commas.', '<API key>').'</p>'; echo '<p>'.__('Post orderbys :', '<API key>').'<br><input style="width: 200px;" type="text" value="'; echo $g1 . '" name="vmpt_orderbys1" id="vmpt_orderbys1" /> '.__('(Any 1 from below list)', '<API key>').' <br> ID / author / title / rand / date / category / modified</p>'; echo '<p>'.__('Post order :', '<API key>').'<br><input style="width: 100px;" type="text" value="'; echo $h1 . '" name="vmpt_order1" id="vmpt_order1" /> ASC/DESC </p>'; ?> </td> <td><?php echo '<h3>'.__('Setting 2', '<API key>').'</h3>'; echo '<p>'.__('Scroll amount :', '<API key>').'<br><input style="width: 100px;" type="text" value="'; echo $a2 . '" name="vmpt_scrollamount2" id="vmpt_scrollamount2" /></p>'; echo '<p>'.__('Scroll delay :', '<API key>').'<br><input style="width: 100px;" type="text" value="'; echo $b2 . '" name="vmpt_scrolldelay2" id="vmpt_scrolldelay2" /></p>'; echo '<p>'.__('Scroll direction :', '<API key>').'<br><input style="width: 100px;" type="text" value="'; echo $c2 . '" name="vmpt_direction2" id="vmpt_direction2" /> '.__('(Up / Down)', '<API key>').'</p>'; echo '<p>'.__('Scroll style :', '<API key>').'<br><input style="width: 250px;" type="text" value="'; echo $d2 . '" name="vmpt_style2" id="vmpt_style2" /></p>'; echo '<p>'.__('Number of post :', '<API key>').'<br><input style="width: 100px;" type="text" value="'; echo $e2 . '" name="vmpt_noofpost2" id="vmpt_noofpost2" /></p>'; echo '<p>'.__('Post categories :', '<API key>').'<br><input style="width: 200px;" type="text" value="'; echo $f2 . '" name="vmpt_categories2" id="vmpt_categories2" /> (Example: 1, 3, 4) <br> '.__('Category IDs, separated by commas.', '<API key>').'</p>'; echo '<p>'.__('Post orderbys :', '<API key>').'<br><input style="width: 200px;" type="text" value="'; echo $g2 . '" name="vmpt_orderbys2" id="vmpt_orderbys2" /> '.__('(Any 1 from below list)', '<API key>').' <br> ID / author / title / rand / date / category / modified</p>'; echo '<p>'.__('Post order :', '<API key>').'<br><input style="width: 100px;" type="text" value="'; echo $h2 . '" name="vmpt_order2" id="vmpt_order2" /> ASC/DESC </p>'; ?> </td> </tr> <tr> <td><?php echo '<h3>'.__('Setting 3', '<API key>').'</h3>'; echo '<p>'.__('Scroll amount :', '<API key>').'<br><input style="width: 100px;" type="text" value="'; echo $a3 . '" name="vmpt_scrollamount3" id="vmpt_scrollamount3" /></p>'; echo '<p>'.__('Scroll delay :', '<API key>').'<br><input style="width: 100px;" type="text" value="'; echo $b3 . '" name="vmpt_scrolldelay3" id="vmpt_scrolldelay3" /></p>'; echo '<p>'.__('Scroll direction :', '<API key>').'<br><input style="width: 100px;" type="text" value="'; echo $c3 . '" name="vmpt_direction3" id="vmpt_direction3" /> '.__('(Up / Down)', '<API key>').'</p>'; echo '<p>'.__('Scroll style :', '<API key>').'<br><input style="width: 250px;" type="text" value="'; echo $d3 . '" name="vmpt_style3" id="vmpt_style3" /></p>'; echo '<p>'.__('Number of post :', '<API key>').'<br><input style="width: 100px;" type="text" value="'; echo $e3 . '" name="vmpt_noofpost3" id="vmpt_noofpost3" /></p>'; echo '<p>'.__('Post categories :', '<API key>').'<br><input style="width: 200px;" type="text" value="'; echo $f3 . '" name="vmpt_categories3" id="vmpt_categories3" /> (Example: 1, 3, 4) <br> '.__('Category IDs, separated by commas.', '<API key>').'</p>'; echo '<p>'.__('Post orderbys :', '<API key>').'<br><input style="width: 200px;" type="text" value="'; echo $g3 . '" name="vmpt_orderbys3" id="vmpt_orderbys3" /> '.__('(Any 1 from below list)', '<API key>').' <br> ID / author / title / rand / date / category / modified</p>'; echo '<p>'.__('Post order :', '<API key>').'<br><input style="width: 100px;" type="text" value="'; echo $h3 . '" name="vmpt_order3" id="vmpt_order3" /> ASC/DESC </p>'; ?> </td> <td><?php echo '<h3>'.__('Setting 4', '<API key>').'</h3>'; echo '<p>'.__('Scroll amount :', '<API key>').'<br><input style="width: 100px;" type="text" value="'; echo $a4 . '" name="vmpt_scrollamount4" id="vmpt_scrollamount4" /></p>'; echo '<p>'.__('Scroll delay :', '<API key>').'<br><input style="width: 100px;" type="text" value="'; echo $b4 . '" name="vmpt_scrolldelay4" id="vmpt_scrolldelay4" /></p>'; echo '<p>'.__('Scroll direction :', '<API key>').'<br><input style="width: 100px;" type="text" value="'; echo $c4 . '" name="vmpt_direction4" id="vmpt_direction4" /> '.__('(Up / Down)', '<API key>').'</p>'; echo '<p>'.__('Scroll style :', '<API key>').'<br><input style="width: 250px;" type="text" value="'; echo $d4 . '" name="vmpt_style4" id="vmpt_style4" /></p>'; echo '<p>'.__('Number of post :', '<API key>').'<br><input style="width: 100px;" type="text" value="'; echo $e4 . '" name="vmpt_noofpost4" id="vmpt_noofpost4" /></p>'; echo '<p>'.__('Post categories :', '<API key>').'<br><input style="width: 200px;" type="text" value="'; echo $f4 . '" name="vmpt_categories4" id="vmpt_categories4" /> (Example: 1, 3, 4) <br> '.__('Category IDs, separated by commas.', '<API key>').'</p>'; echo '<p>'.__('Post orderbys :', '<API key>').'<br><input style="width: 200px;" type="text" value="'; echo $g4 . '" name="vmpt_orderbys4" id="vmpt_orderbys4" /> '.__('(Any 1 from below list)', '<API key>').' <br> ID / author / title / rand / date / category / modified</p>'; echo '<p>'.__('Post order :', '<API key>').'<br><input style="width: 100px;" type="text" value="'; echo $h4 . '" name="vmpt_order4" id="vmpt_order4" /> ASC/DESC </p>'; ?> </td> </tr> </table> <br /> <input name="vmpt_submit" id="vmpt_submit" lang="publish" class="button-primary" value="<?php _e('Update all 4 settings', '<API key>'); ?>" type="Submit" /> <?php wp_nonce_field('vmpt_form_setting'); ?> </form> <h3><?php _e('Plugin configuration option', '<API key>'); ?></h3> <ol> <li><?php _e('Drag and drop the widget.', '<API key>'); ?></li> <li><?php _e('Add the plugin in the posts or pages using short code.', '<API key>'); ?></li> <li><?php _e('Add directly in to the theme using PHP code.', '<API key>'); ?></li> </ol> <p class="description"><?php _e('Check official website for more information ', '<API key>'); ?> <a href="http: </div> </div> <?php } function vmpt_add_to_menu() { add_options_page( __('Vertical marquee post title', '<API key>'), __('Vertical marquee post title', '<API key>'), 'manage_options', __FILE__, 'vmpt_option' ); } if (is_admin()) { add_action('admin_menu', 'vmpt_add_to_menu'); } class <API key> extends WP_Widget { function __construct() { $widget_ops = array('classname' => 'widget_text newsticker-widget', 'description' => __('Vertical marquee post title', '<API key>'), '<API key>'); parent::__construct('<API key>', __('Vertical marquee post title', '<API key>'), $widget_ops); } function widget( $args, $instance ) { extract( $args, EXTR_SKIP ); $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); $vmpt_setting = $instance['vmpt_setting']; echo $args['before_widget']; if ( ! empty( $title ) ) { echo $args['before_title'] . $title . $args['after_title']; } // Call widget method $arr = array(); $arr["setting"] = $vmpt_setting; echo vmpt_shortcode($arr); // Call widget method echo $args['after_widget']; } function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : ''; $instance['vmpt_setting'] = ( ! empty( $new_instance['vmpt_setting'] ) ) ? strip_tags( $new_instance['vmpt_setting'] ) : ''; return $instance; } function form( $instance ) { $defaults = array( 'title' => '', 'vmpt_setting' => '' ); $instance = wp_parse_args( (array) $instance, $defaults); $title = $instance['title']; $vmpt_setting = $instance['vmpt_setting']; ?> <p> <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Widget title', '<API key>'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /> </p> <p> <label for="<?php echo $this->get_field_id('vmpt_setting'); ?>"><?php _e('Setting', '<API key>'); ?></label> <select class="widefat" id="<?php echo $this->get_field_id('vmpt_setting'); ?>" name="<?php echo $this->get_field_name('vmpt_setting'); ?>"> <option value="1" <?php $this-><API key>($vmpt_setting=='1'); ?>>Setting 1</option> <option value="2" <?php $this-><API key>($vmpt_setting=='2'); ?>>Setting 2</option> <option value="3" <?php $this-><API key>($vmpt_setting=='3'); ?>>Setting 3</option> <option value="4" <?php $this-><API key>($vmpt_setting=='4'); ?>>Setting 4</option> </select> </p> <p> <?php _e('Check official website for more information', '<API key>'); ?> <a target="_blank" href="http: </p> <?php } function <API key>($var) { if ($var==1 || $var==true) { echo 'selected="selected"'; } } } function vmpt_widget_loading() { register_widget( '<API key>' ); } function vmpt_textdomain() { <API key>( '<API key>', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); } add_action('plugins_loaded', 'vmpt_textdomain'); <API key>(__FILE__, 'vmpt_install'); <API key>(__FILE__, 'vmpt_deactivation'); add_action( 'widgets_init', 'vmpt_widget_loading'); add_shortcode( 'vmpt', 'vmpt_shortcode' ); ?>
<?php namespace Icinga\Module\Businessprocess\Web\Form; use Icinga\Application\Icinga; use Icinga\Exception\ProgrammingError; use Icinga\Web\Notification; use Icinga\Web\Request; use Icinga\Web\Response; use Icinga\Web\Url; use Exception; /** * QuickForm wants to be a base class for simple forms */ abstract class QuickForm extends QuickBaseForm { const ID = '__FORM_NAME'; const CSRF = '__FORM_CSRF'; /** * The name of this form */ protected $formName; /** * Whether the form has been sent */ protected $hasBeenSent; /** * Whether the form has been sent */ protected $hasBeenSubmitted; /** * The submit caption, element - still tbd */ // protected $submit; /** * Our request */ protected $request; /** * @var Url */ protected $successUrl; protected $successMessage; protected $submitLabel; protected $submitButtonName; protected $deleteButtonName; protected $<API key>; /** * Whether form elements have already been created */ protected $didSetup = false; protected $isApiRequest = false; public function __construct($options = null) { parent::__construct($options); $this->setMethod('post'); $this-><API key>() ->createIdElement() ->regenerateCsrfToken() -><API key>(); } protected function <API key>() { $this->setAction(Url::fromRequest()); return $this; } protected function <API key>() { $this->setAttrib('class', 'autofocus icinga-controls'); $this->setDecorators( array( 'Description', array('FormErrors', array('<API key>' => true)), 'FormElements', 'Form' ) ); return $this; } protected function <API key>() { if (false === ($label = $this->getSubmitLabel())) { return; } if ($this->submitButtonName && $el = $this->getElement($this->submitButtonName)) { return; } $el = $this->createElement('submit', $label) ->setLabel($label) ->setDecorators(array('ViewHelper')); $this->submitButtonName = $el->getName(); $this->addElement($el); $fakeEl = $this->createElement('submit', '_FAKE_SUBMIT') ->setLabel($label) ->setDecorators(array('ViewHelper')); $this-><API key> = $fakeEl->getName(); $this->addElement($fakeEl); $this->addDisplayGroup( array($this-><API key>), 'fake_button', array( 'decorators' => array('FormElements'), 'order' => 1, ) ); $grp = array( $this->submitButtonName, $this->deleteButtonName ); $this->addDisplayGroup($grp, 'buttons', array( 'decorators' => array( 'FormElements', array('HtmlTag', array('tag' => 'dl')), 'DtDdWrapper', ), 'order' => 1000, )); } protected function <API key>($elements, $name, $options) { if (! array_key_exists('decorators', $options)) { $options['decorators'] = array( 'FormElements', array('HtmlTag', array('tag' => 'dl')), 'Fieldset', ); } return $this->addDisplayGroup($elements, $name, $options); } protected function createIdElement() { $this->detectName(); $this->addHidden(self::ID, $this->getName()); $this->getElement(self::ID)->setIgnore(true); return $this; } public function getSentValue($name, $default = null) { $request = $this->getRequest(); if ($request->isPost() && $this->hasBeenSent()) { return $request->getPost($name); } else { return $default; } } public function getSubmitLabel() { if ($this->submitLabel === null) { return $this->translate('Submit'); } return $this->submitLabel; } public function setSubmitLabel($label) { $this->submitLabel = $label; return $this; } public function setApiRequest($isApiRequest = true) { $this->isApiRequest = $isApiRequest; return $this; } public function isApiRequest() { return $this->isApiRequest; } public function regenerateCsrfToken() { if (! $element = $this->getElement(self::CSRF)) { $this->addHidden(self::CSRF, CsrfToken::generate()); $element = $this->getElement(self::CSRF); } $element->setIgnore(true); return $this; } public function removeCsrfToken() { $this->removeElement(self::CSRF); return $this; } public function setSuccessUrl($url, $params = null) { if (! $url instanceof Url) { $url = Url::fromPath($url); } if ($params !== null) { $url->setParams($params); } $this->successUrl = $url; return $this; } public function getSuccessUrl() { $url = $this->successUrl ?: $this->getAction(); if (! $url instanceof Url) { $url = Url::fromPath($url); } return $url; } protected function beforeSetup() { } public function setup() { } protected function onSetup() { } public function setAction($action) { if ($action instanceof Url) { $action = $action->getAbsoluteUrl('&'); } return parent::setAction($action); } public function hasBeenSubmitted() { if ($this->hasBeenSubmitted === null) { $req = $this->getRequest(); if ($req->isPost()) { if (! $this->hasSubmitButton()) { return $this->hasBeenSubmitted = $this->hasBeenSent(); } $this->hasBeenSubmitted = $this->pressedButton( $this-><API key>, $this->getSubmitLabel() ) || $this->pressedButton( $this->submitButtonName, $this->getSubmitLabel() ); } else { $this->hasBeenSubmitted = false; } } return $this->hasBeenSubmitted; } protected function hasSubmitButton() { return $this->submitButtonName !== null; } protected function pressedButton($name, $label) { $req = $this->getRequest(); if (! $req->isPost()) { return false; } $req = $this->getRequest(); $post = $req->getPost(); return array_key_exists($name, $post) && $post[$name] === $label; } protected function beforeValidation($data = array()) { } public function prepareElements() { if (! $this->didSetup) { $this->beforeSetup(); $this->setup(); $this-><API key>(); $this->onSetup(); $this->didSetup = true; } return $this; } public function handleRequest(Request $request = null) { if ($request === null) { $request = $this->getRequest(); } else { $this->setRequest($request); } $this->prepareElements(); if ($this->hasBeenSent()) { $post = $request->getPost(); if ($this->hasBeenSubmitted()) { $this->beforeValidation($post); if ($this->isValid($post)) { try { $this->onSuccess(); } catch (Exception $e) { $this->addException($e); $this->onFailure(); } } else { $this->onFailure(); } } else { $this->setDefaults($post); } } else { // Well... } return $this; } public function addException(Exception $e, $elementName = null) { $file = preg_split('/[\/\\\]/', $e->getFile(), -1, PREG_SPLIT_NO_EMPTY); $file = array_pop($file); $msg = sprintf( '%s (%s:%d)', $e->getMessage(), $file, $e->getLine() ); if ($el = $this->getElement($elementName)) { $el->addError($msg); } else { $this->addError($msg); } } public function onSuccess() { $this->redirectOnSuccess(); } public function setSuccessMessage($message) { $this->successMessage = $message; return $this; } public function getSuccessMessage($message = null) { if ($message !== null) { return $message; } if ($this->successMessage === null) { return t('Form has successfully been sent'); } return $this->successMessage; } public function redirectOnSuccess($message = null) { if ($this->isApiRequest()) { // TODO: Set the status line message? $this->successMessage = $this->getSuccessMessage($message); return; } $url = $this->getSuccessUrl(); $this->notifySuccess($this->getSuccessMessage($message)); $this->redirectAndExit($url); } public function onFailure() { } public function notifySuccess($message = null) { if ($message === null) { $message = t('Form has successfully been sent'); } Notification::success($message); return $this; } public function notifyError($message) { Notification::error($message); return $this; } protected function redirectAndExit($url) { /** @var Response $response */ $response = Icinga::app()->getFrontController()->getResponse(); $response->redirectAndExit($url); } protected function setHttpResponseCode($code) { Icinga::app()->getFrontController()->getResponse()->setHttpResponseCode($code); return $this; } protected function onRequest() { } public function setRequest(Request $request) { if ($this->request !== null) { throw new ProgrammingError('Unable to set request twice'); } $this->request = $request; $this->prepareElements(); $this->onRequest(); return $this; } /** * @return Request */ public function getRequest() { if ($this->request === null) { /** @var Request $request */ $request = Icinga::app()->getFrontController()->getRequest(); $this->setRequest($request); } return $this->request; } public function hasBeenSent() { if ($this->hasBeenSent === null) { /** @var Request $req */ if ($this->request === null) { $req = Icinga::app()->getFrontController()->getRequest(); } else { $req = $this->request; } if ($req->isPost()) { $post = $req->getPost(); $this->hasBeenSent = array_key_exists(self::ID, $post) && $post[self::ID] === $this->getName(); } else { $this->hasBeenSent = false; } } return $this->hasBeenSent; } protected function detectName() { if ($this->formName !== null) { $this->setName($this->formName); } else { $this->setName(get_class($this)); } } }
package pf::constants::admin_roles; =head1 NAME pf::constants::admin_roles - constants for admin_roles object =cut =head1 DESCRIPTION pf::constants::admin_roles =cut use strict; use warnings; use base qw(Exporter); our @EXPORT_OK = qw(@ADMIN_ACTIONS); our @ADMIN_ACTIONS = qw( ADMIN_ROLES_CREATE ADMIN_ROLES_DELETE ADMIN_ROLES_READ ADMIN_ROLES_UPDATE AUDITING_READ <API key> <API key> FINGERBANK_READ FINGERBANK_CREATE FINGERBANK_UPDATE FINGERBANK_DELETE FIREWALL_SSO_READ FIREWALL_SSO_CREATE FIREWALL_SSO_UPDATE FIREWALL_SSO_DELETE <API key> <API key> <API key> <API key> INTERFACES_CREATE INTERFACES_DELETE INTERFACES_READ INTERFACES_UPDATE MAC_READ MAC_UPDATE NODES_CREATE NODES_DELETE NODES_READ NODES_UPDATE MSE_READ <API key> <API key> <API key> <API key> PROVISIONING_CREATE PROVISIONING_DELETE PROVISIONING_READ PROVISIONING_UPDATE REPORTS SERVICES SOH_CREATE SOH_DELETE SOH_READ SOH_UPDATE SWITCHES_CREATE SWITCHES_DELETE SWITCHES_READ SWITCHES_UPDATE USERAGENTS_READ USERS_READ USERS_CREATE <API key> USERS_UPDATE USERS_DELETE USERS_SET_ROLE <API key> <API key> <API key> <API key> USERS_ROLES_CREATE USERS_ROLES_DELETE USERS_ROLES_READ USERS_ROLES_UPDATE <API key> <API key> USERS_SOURCES_READ <API key> VIOLATIONS_CREATE VIOLATIONS_DELETE VIOLATIONS_READ VIOLATIONS_UPDATE USERAGENTS_READ RADIUS_LOG_READ REALM_READ REALM_CREATE REALM_UPDATE REALM_DELETE DOMAIN_READ DOMAIN_CREATE DOMAIN_UPDATE DOMAIN_DELETE SCAN_READ SCAN_CREATE SCAN_UPDATE SCAN_DELETE WMI_READ WMI_CREATE WMI_UPDATE WMI_DELETE WRIX_CREATE WRIX_DELETE WRIX_READ WRIX_UPDATE PKI_PROVIDER_CREATE PKI_PROVIDER_DELETE PKI_PROVIDER_READ PKI_PROVIDER_UPDATE PFDETECT_CREATE PFDETECT_DELETE PFDETECT_READ PFDETECT_UPDATE BILLING_TIER_CREATE BILLING_TIER_DELETE BILLING_TIER_READ BILLING_TIER_UPDATE SWITCH_LOGIN_READ SWITCH_LOGIN_WRITE FILTERS_READ FILTERS_UPDATE <API key> <API key> PORTAL_MODULE_READ <API key> ); =head1 AUTHOR Inverse inc. <info@inverse.ca> =head1 COPYRIGHT Copyright (C) 2005-2017 Inverse inc. =head1 LICENSE This program is free software; you can redistribute it and::or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. =cut 1;
<?php defined('_JEXEC') or die; jimport('joomla.application.component.controllerform'); class <API key> extends JControllerForm { public function getModel($name = '', $prefix = '', $config = array('ignore_request' => true)) { return parent::getModel($name, $prefix, array('ignore_request' => false)); } public function solid(){ $user = JFactory::getUser(); $userid = (int) $user->id; $id = (int) JRequest::getInt('id','0'); $value = (int) JRequest::getInt('value','0'); $field = 'solid'; $model = $this->getModel('Explist', 'ExpAutosProModel'); if (!$model->insertdata($id,$field,$value)) { $errors = $model->getError(); JError::raiseWarning(500, JText::_('<API key>')); $this->setRedirect(JRoute::_('index.php?option=com_expautospro&amp;view=explist&amp;userid='.(int)$userid, false)); return false; } $this->setRedirect(JRoute::_('index.php?option=com_expautospro&amp;view=explist&amp;id='.(int)$id, false)); } public function expreserved(){ $user = JFactory::getUser(); $userid = (int) $user->id; $id = (int) JRequest::getInt('id','0'); $value = (int) JRequest::getInt('value','0'); $field = 'expreserved'; $model = $this->getModel('Explist', 'ExpAutosProModel'); if (!$model->insertdata($id,$field,$value)) { $errors = $model->getError(); JError::raiseWarning(500, JText::_('<API key>')); $this->setRedirect(JRoute::_('index.php?option=com_expautospro&amp;view=explist&amp;userid='.(int)$userid, false)); return false; } $this->setRedirect(JRoute::_('index.php?option=com_expautospro&amp;view=explist&amp;id='.(int)$id, false)); } public function deletelink(){ $user = JFactory::getUser(); $userid = (int) $user->id; $id = (int) JRequest::getInt('id','0'); $model = $this->getModel('Explist', 'ExpAutosProModel'); if (!$model->delete_ads($id)) { $errors = $model->getError(); JError::raiseWarning(500, JText::_('<API key>')); $this->setRedirect(JRoute::_('index.php?option=com_expautospro&amp;view=explist&amp;userid='.(int)$userid, false)); return false; } $this->setRedirect(JRoute::_('index.php?option=com_expautospro&amp;view=explist&amp;userid='.(int)$userid, false)); } public function extend(){ $user = JFactory::getUser(); $userid = (int) $user->id; $id = (int) JRequest::getInt('id','0'); $model = $this->getModel('Explist', 'ExpAutosProModel'); if (!$model->extend_ads($id)) { $errors = $model->getError(); JError::raiseWarning(500, JText::_('<API key>')); $this->setRedirect(JRoute::_('index.php?option=com_expautospro&amp;view=explist&amp;userid='.(int)$userid, false)); return false; } $this->setRedirect(JRoute::_('index.php?option=com_expautospro&amp;view=explist&amp;id='.(int)$id, false)); } }
<?php $captcha_word = 'BKPS'; ?>
#include"population.h" population::population() { pop.clear(); } population::population(Random *r) { pop.clear(); this->r = r; } population::population(int n_individuos, int n_gene, Random *r) { pop.clear(); for(int i = 0; i < n_individuos; i++) pop.push_back(*(new individuo(n_gene, r))); this->r = r; } population::population(vector<individuo> i, Random *r) { pop = i; this->r = r; } vector<individuo> population::get_population() { return pop; } void population::set_population(vector<individuo> i) { pop = i; } void population::set_population(population p) { pop = p.get_population(); } int population::size() { return pop.size(); } void population::print() { for(int i = 0; i < size(); i++) pop[i].print(); } population *population::elitismo(double pel) { int num = (int) (pel * ((double) size())); return elitismo(num); } population *population::elitismo(int num) { ranking(); vector<individuo> newp; newp.clear(); for(int i = 0; i < num; i++) newp.push_back(pop[i]); return (new population(newp, r)); } void population::calc_fitness() { for(int i = 0; i < size(); i++) pop[i].get_objective(); } void population::ranking() { calc_fitness(); for(int i = 0; i < size() - 1; i++) { for(int j = i + 1; j < size(); j++) { if(pop[i] < pop[j]) { individuo aux = pop[i]; pop[i] = pop[j]; pop[j] = aux; } } } int counter = 0; pop[size() - 1].set_rank(0); for(int i = size() - 2; i >= 0; i if(pop[i] > pop[i+1]) counter++; pop[i].set_rank(counter); } } void population::crowd() { calc_fitness(); double *crowd = new double[size()]; for(int i = 0; i < size(); i++) crowd[i] = 0; for(int i = 0; i < pop[0].get_objective().size(); i++) { // ordena por objetivo. for(int j = 0; j < size(); j++) { for(int k = j + 1; k < size(); k++) { if(pop[j].get_objective(i) > pop[k].get_objective(i)) swap(pop[j], pop[k]); } } for(int j = 1; j < size() - 1; j++) crowd[j] += pop[j + 1].get_objective(i) - pop[j - 1].get_objective(i); crowd[0] = crowd[size() - 1] = 3000; //numeric_limits<double>::infinity(); } for(int i = 0; i < size(); i++) pop[i].set_crowd(crowd[i]); } void population::sort() { for(int i = 0; i < size() - 1; i++) { for(int j = i + 1; j < size(); j++) { if(pop[i].get_rank() < pop[j].get_rank()) { swap(pop[i], pop[j]); } else if(pop[i].get_rank() == pop[j].get_rank() && pop[i].get_crowd() < pop[j].get_crowd()) { swap(pop[i], pop[j]); } } } } population population::operator+(const population &p) { vector<individuo> n; n = p.pop; for(int i = 0; i < pop.size(); i++) n.push_back(pop[i]); return *(new population(n, r)); } //population population::operator+=(const population &p) {return *this = *this + p;} population *population::mutation(int num_ind, int num_gene) { printf("mut a\n"); population *newp = new population(num_ind, pop[0].get_cromossomo().get_n_gene(), r); printf("mut b\n"); for(int i = 0; i < num_ind; i++) { newp->pop[i] = pop[r->nextLongInt(pop.size())].mutation(num_gene); } printf("mut c\n"); return newp; } population *population::mutation(int num_ind) { return mutation(num_ind, 1);} population *population::mutation(double pmut, int num_gene) { int num_ind = (int) (pmut * ((double) pop.size())); return mutation(num_ind,num_gene); } population *population::mutation(double pmut) { return mutation(pmut, 1);} individuo population::get_individuo(int index){ return pop[index]; } void population::add_individuo(individuo i){ pop.push_back(i);} void population::add_individuo(vector<individuo> i){ for (int index = 0; index < i.size(); index ++){ add_individuo(i[index]); } } population *population::crossover( double pcrv){ int ncrv = (int) (pcrv * ((double) size())); return crossover(ncrv); } population *population::crossover( int ncrv){ population *p = new population(); for (int i = 0; i < ncrv; i ++ ) { p->add_individuo(pop[r->nextLongInt(size())] + pop[r->nextLongInt(size())]); } return p; } population *population::tournament(int num_ind, int num_group) { printf("inicio\n"); vector<individuo> group; if(num_ind < 1) return NULL; population *newp = new population(r); for(int i = 0; i < num_ind; i++) { group.clear(); for(int j = 0; j < num_group; j++) group.push_back(pop[r->nextLongInt(pop.size())]); individuo maior = group[0]; for(int j = 1; j < group.size(); j++) if(group[j] > maior) maior = group[j]; newp->add_individuo(maior); } printf("fim\n"); return newp; } population *population::roulette(int num_ind, int param) { population *newp = new population(r); double max = 0; vector<double> roulette; roulette.clear(); if(param == ROULETTE_RANK || param == <API key>) { for(int i = 0; i < pop.size(); i++) { max += (double) pop[i].get_rank(); roulette.push_back(max); } } else { for(int i = 0; i < pop.size(); i++) { max += pop[i].get_objective(0); roulette.push_back(max); } } if(param == ROULETTE_RANK || param == ROULETTE_OBJECTIVE) { for(int i = 0; i < num_ind; i++) { double pointer = r->nextDouble(max); int j; for(j = 0; roulette[j] < pointer; j++); newp->add_individuo(pop[j]); } } else { double pointer; double delta = max / (double) num_ind; pointer = r->nextDouble(max / (double) num_ind); int j = 0; for(int i = 0; i < num_ind; i++) { for(j; roulette[j] < pointer; j++); newp->add_individuo(pop[j]); pointer += delta; } } return newp; } void population::resize(int n ){ if(n < pop.size()) pop.resize(n); }
package com.javarush.task.task11.task1109; public class Solution { public static void main(String[] args) { Cat cat = new Cat("Vaska", 5); Dog dog = new Dog("Sharik", 4); cat.isDogNear(dog); dog.isCatNear(cat); } public static class Cat { private String name; private int speed; public Cat(String name, int speed) { this.name = name; this.speed = speed; } private String getName() { return name; } private int getSpeed() { return speed; } public boolean isDogNear(Dog dog) { return this.speed > dog.getSpeed(); } } public static class Dog { private String name; private int speed; public Dog(String name, int speed) { this.name = name; this.speed = speed; } private String getName() { return name; } private int getSpeed() { return speed; } public boolean isCatNear(Cat cat) { return this.speed > cat.getSpeed(); } } }
#!/usr/bin/perl use warnings; use strict; use hdpTools; use Annotation::Annotation; my $config=$ARGV[0]; die "Usage: perl $0 <config file>\n\n" unless defined $config; my $Annotation=Annotation->new($config); warn "Loading GFF\n"; $Annotation->loadAnnotation(); warn "Loading Genome\n"; $Annotation->loadGenome(); warn "Loading Homology\n"; $Annotation->addHomologies(); my @targets=@{$Annotation->getHomologyTargets()}; my $allKids=$Annotation->getAllParentsOfID("PAC:28400253.CDS.3"); foreach my $child (@$allKids){ print $child."\n"; }
<?php /** * Lost password form * * @author WooThemes * @package WooCommerce/Templates * @version 2.0.0 */ if ( ! defined( 'ABSPATH' ) ) { exit; } ?> <?php wc_print_notices(); ?> <section id="content"> <form method="post" class="form lost_reset_password"> <?php if( 'lost_password' == $args['form'] ) : ?> <p class="red"><?php echo apply_filters( '<API key>', __( 'Lost your password? Please enter your username or email address. You will receive a link to create a new password via email.', 'woocommerce' ) ); ?></p> <!--<p class="form-row form-row-first"><label for="user_login"><?php _e( 'Username or email', 'woocommerce' ); ?></label> <input class="input-text" type="text" name="user_login" id="user_login" /></p>--> <div class="col"> <div class="left"> <input class="input-text" type="text" name="user_login" id="user_login" placeholder="Username or email" /> </div> </div> <?php else : ?> <p><?php echo apply_filters( '<API key>', __( 'Enter a new password below.', 'woocommerce') ); ?></p> <! <p class="form-row form-row-first"> <label for="password_1"><?php _e( 'New password', 'woocommerce' ); ?> <span class="required">*</span></label> <input type="password" class="email" name="password_1" id="password_1" /> </p> <p class="form-row form-row-last"> <label for="password_2"><?php _e( 'Re-enter new password', 'woocommerce' ); ?> <span class="required">*</span></label> <input type="password" class="input-text" name="password_2" id="password_2" /> </p> <div class="col"> <div class="left"> <input type="password" class="email" name="password_1" id="password_1" placeholder="Password*" /> </div> </div> <div class="col"> <div class="left"> <input type="password" class="input-text" name="password_2" id="password_2" placeholder="Re-enter Password*" /> </div> </div> <input type="hidden" name="reset_key" value="<?php echo isset( $args['key'] ) ? $args['key'] : ''; ?>" /> <input type="hidden" name="reset_login" value="<?php echo isset( $args['login'] ) ? $args['login'] : ''; ?>" /> <?php endif; ?> <div class="clear"></div> <div class="col"> <div class="left"> <input type="submit" class="button" name="wc_reset_password" value="<?php echo 'lost_password' == $args['form'] ? __( 'Reset Password', 'woocommerce' ) : __( 'Save', 'woocommerce' ); ?>" /> </div> </div> <!--<p class="form-row"><input type="submit" class="button" name="wc_reset_password" value="<?php echo 'lost_password' == $args['form'] ? __( 'Reset Password', 'woocommerce' ) : __( 'Save', 'woocommerce' ); ?>" /></p>--> <?php wp_nonce_field( $args['form'] ); ?> </form> </section> <script type="text/javascript"> jQuery('#reg_passmail').html(''); jQuery('#reg_passmail').append('<div class="col"></div>'); </script>
/* * Demo on how to use /dev/crypto device for ciphering. * * Placed under public domain. * */ #include <poll.h> #include <stdio.h> #include <string.h> #include <unistd.h> #include <fcntl.h> #include <stdint.h> #include <sys/ioctl.h> #include <crypto/cryptodev.h> #include "asynchelper.h" #include "testhelper.h" #ifdef ENABLE_ASYNC static int debug = 0; #define DATA_SIZE 8*1024 #define BLOCK_SIZE 16 #define KEY_SIZE 16 static int test_crypto(int cfd) { uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; uint8_t iv[BLOCK_SIZE]; uint8_t key[KEY_SIZE]; struct session_op sess; #ifdef CIOCGSESSINFO struct session_info_op siop; #endif struct crypt_op cryp; if (debug) printf("running %s\n", __func__); memset(&sess, 0, sizeof(sess)); memset(&cryp, 0, sizeof(cryp)); memset(key, 0x33, sizeof(key)); memset(iv, 0x03, sizeof(iv)); /* Get crypto session for AES128 */ sess.cipher = CRYPTO_AES_CBC; sess.keylen = KEY_SIZE; sess.key = key; if (ioctl(cfd, CIOCGSESSION, &sess)) { perror("ioctl(CIOCGSESSION)"); return 1; } if (debug) printf("%s: got the session\n", __func__); #ifdef CIOCGSESSINFO siop.ses = sess.ses; if (ioctl(cfd, CIOCGSESSINFO, &siop)) { perror("ioctl(CIOCGSESSINFO)"); return 1; } plaintext = buf_align(plaintext_raw, siop.alignmask); ciphertext = buf_align(ciphertext_raw, siop.alignmask); #else plaintext = plaintext_raw; ciphertext = ciphertext_raw; #endif memset(plaintext, 0x15, DATA_SIZE); /* Encrypt data.in to data.encrypted */ cryp.ses = sess.ses; cryp.len = DATA_SIZE; cryp.src = plaintext; cryp.dst = ciphertext; cryp.iv = iv; cryp.op = COP_ENCRYPT; DO_OR_DIE(do_async_crypt(cfd, &cryp), 0); DO_OR_DIE(do_async_fetch(cfd, &cryp), 0); if (debug) printf("%s: data encrypted\n", __func__); if (ioctl(cfd, CIOCFSESSION, &sess.ses)) { perror("ioctl(CIOCFSESSION)"); return 1; } if (debug) printf("%s: session finished\n", __func__); if (ioctl(cfd, CIOCGSESSION, &sess)) { perror("ioctl(CIOCGSESSION)"); return 1; } if (debug) printf("%s: got new session\n", __func__); /* Decrypt data.encrypted to data.decrypted */ cryp.ses = sess.ses; cryp.len = DATA_SIZE; cryp.src = ciphertext; cryp.dst = ciphertext; cryp.iv = iv; cryp.op = COP_DECRYPT; DO_OR_DIE(do_async_crypt(cfd, &cryp), 0); DO_OR_DIE(do_async_fetch(cfd, &cryp), 0); if (debug) printf("%s: data encrypted\n", __func__); /* Verify the result */ if (memcmp(plaintext, ciphertext, DATA_SIZE) != 0) { fprintf(stderr, "FAIL: Decrypted data are different from the input data.\n"); return 1; } else if (debug) printf("Test passed\n"); /* Finish crypto session */ if (ioctl(cfd, CIOCFSESSION, &sess.ses)) { perror("ioctl(CIOCFSESSION)"); return 1; } return 0; } static int test_aes(int cfd) { uint8_t plaintext1_raw[BLOCK_SIZE + 63], *plaintext1; uint8_t ciphertext1[BLOCK_SIZE] = { 0xdf, 0x55, 0x6a, 0x33, 0x43, 0x8d, 0xb8, 0x7b, 0xc4, 0x1b, 0x17, 0x52, 0xc5, 0x5e, 0x5e, 0x49 }; uint8_t iv1[BLOCK_SIZE]; uint8_t key1[KEY_SIZE] = { 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; uint8_t plaintext2_data[BLOCK_SIZE] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00 }; uint8_t plaintext2_raw[BLOCK_SIZE + 63], *plaintext2; uint8_t ciphertext2[BLOCK_SIZE] = { 0xb7, 0x97, 0x2b, 0x39, 0x41, 0xc4, 0x4b, 0x90, 0xaf, 0xa7, 0xb2, 0x64, 0xbf, 0xba, 0x73, 0x87 }; uint8_t iv2[BLOCK_SIZE]; uint8_t key2[KEY_SIZE]; struct session_op sess1, sess2; #ifdef CIOCGSESSINFO struct session_info_op siop1, siop2; #endif struct crypt_op cryp1, cryp2; memset(&sess1, 0, sizeof(sess1)); memset(&sess2, 0, sizeof(sess2)); memset(&cryp1, 0, sizeof(cryp1)); memset(&cryp2, 0, sizeof(cryp2)); /* Get crypto session for AES128 */ sess1.cipher = CRYPTO_AES_CBC; sess1.keylen = KEY_SIZE; sess1.key = key1; if (ioctl(cfd, CIOCGSESSION, &sess1)) { perror("ioctl(CIOCGSESSION)"); return 1; } #ifdef CIOCGSESSINFO siop1.ses = sess1.ses; if (ioctl(cfd, CIOCGSESSINFO, &siop1)) { perror("ioctl(CIOCGSESSINFO)"); return 1; } plaintext1 = buf_align(plaintext1_raw, siop1.alignmask); #else plaintext1 = plaintext1_raw; #endif memset(plaintext1, 0x0, BLOCK_SIZE); memset(iv1, 0x0, sizeof(iv1)); memset(key2, 0x0, sizeof(key2)); /* Get second crypto session for AES128 */ sess2.cipher = CRYPTO_AES_CBC; sess2.keylen = KEY_SIZE; sess2.key = key2; if (ioctl(cfd, CIOCGSESSION, &sess2)) { perror("ioctl(CIOCGSESSION)"); return 1; } #ifdef CIOCGSESSINFO siop2.ses = sess2.ses; if (ioctl(cfd, CIOCGSESSINFO, &siop2)) { perror("ioctl(CIOCGSESSINFO)"); return 1; } plaintext2 = buf_align(plaintext2_raw, siop2.alignmask); #else plaintext2 = plaintext2_raw; #endif memcpy(plaintext2, plaintext2_data, BLOCK_SIZE); /* Encrypt data.in to data.encrypted */ cryp1.ses = sess1.ses; cryp1.len = BLOCK_SIZE; cryp1.src = plaintext1; cryp1.dst = plaintext1; cryp1.iv = iv1; cryp1.op = COP_ENCRYPT; DO_OR_DIE(do_async_crypt(cfd, &cryp1), 0); if (debug) printf("cryp1 written out\n"); memset(iv2, 0x0, sizeof(iv2)); /* Encrypt data.in to data.encrypted */ cryp2.ses = sess2.ses; cryp2.len = BLOCK_SIZE; cryp2.src = plaintext2; cryp2.dst = plaintext2; cryp2.iv = iv2; cryp2.op = COP_ENCRYPT; DO_OR_DIE(do_async_crypt(cfd, &cryp2), 0); if (debug) printf("cryp2 written out\n"); DO_OR_DIE(do_async_fetch(cfd, &cryp1), 0); DO_OR_DIE(do_async_fetch(cfd, &cryp2), 0); if (debug) printf("cryp1 + cryp2 successfully read\n"); /* Verify the result */ if (memcmp(plaintext1, ciphertext1, BLOCK_SIZE) != 0) { int i; fprintf(stderr, "FAIL: Decrypted data are different from the input data.\n"); printf("plaintext:"); for (i = 0; i < BLOCK_SIZE; i++) { if ((i % 30) == 0) printf("\n"); printf("%02x ", plaintext1[i]); } printf("ciphertext:"); for (i = 0; i < BLOCK_SIZE; i++) { if ((i % 30) == 0) printf("\n"); printf("%02x ", ciphertext1[i]); } printf("\n"); return 1; } else { if (debug) printf("result 1 passed\n"); } /* Test 2 */ /* Verify the result */ if (memcmp(plaintext2, ciphertext2, BLOCK_SIZE) != 0) { int i; fprintf(stderr, "FAIL: Decrypted data are different from the input data.\n"); printf("plaintext:"); for (i = 0; i < BLOCK_SIZE; i++) { if ((i % 30) == 0) printf("\n"); printf("%02x ", plaintext2[i]); } printf("ciphertext:"); for (i = 0; i < BLOCK_SIZE; i++) { if ((i % 30) == 0) printf("\n"); printf("%02x ", ciphertext2[i]); } printf("\n"); return 1; } else { if (debug) printf("result 2 passed\n"); } if (debug) printf("AES Test passed\n"); /* Finish crypto session */ if (ioctl(cfd, CIOCFSESSION, &sess1.ses)) { perror("ioctl(CIOCFSESSION)"); return 1; } if (ioctl(cfd, CIOCFSESSION, &sess2.ses)) { perror("ioctl(CIOCFSESSION)"); return 1; } return 0; } int main(int argc, char** argv) { int fd = -1, cfd = -1; if (argc > 1) debug = 1; /* Open the crypto device */ fd = open("/dev/crypto", O_RDWR, 0); if (fd < 0) { perror("open(/dev/crypto)"); return 1; } /* Clone file descriptor */ if (ioctl(fd, CRIOGET, &cfd)) { perror("ioctl(CRIOGET)"); return 1; } /* Set close-on-exec (not really neede here) */ if (fcntl(cfd, F_SETFD, 1) == -1) { perror("fcntl(F_SETFD)"); return 1; } /* Run the test itself */ if (test_aes(cfd)) return 1; if (test_crypto(cfd)) return 1; /* Close cloned descriptor */ if (close(cfd)) { perror("close(cfd)"); return 1; } /* Close the original descriptor */ if (close(fd)) { perror("close(fd)"); return 1; } return 0; } #else int main(int argc, char** argv) { return (0); } #endif
<?php namespace FOF30\Less\Parser; use FOF30\Less\Less; use Exception; defined('_JEXEC') or die; class Parser { // Used to uniquely identify blocks protected static $nextBlockId = 0; protected static $precedence = array( '=<' => 0, '>=' => 0, '=' => 0, '<' => 0, '>' => 0, '+' => 1, '-' => 1, '*' => 2, '/' => 2, '%' => 2, ); protected static $whitePattern; protected static $commentMulti; protected static $commentSingle = " protected static $commentMultiLeft = "/*"; protected static $commentMultiRight = "*/"; // Regex string to match any of the operators protected static $operatorString; // These properties will supress division unless it's inside parenthases protected static $<API key> = array('/border-radius$/i', '/^font$/i'); protected $blockDirectives = array("font-face", "keyframes", "page", "-moz-document"); protected $lineDirectives = array("charset"); /** * if we are in parens we can be more liberal with whitespace around * operators because it must resolve to a single value and thus is less * ambiguous. * * Consider: * property1: 10 -5; // is two numbers, 10 and -5 * property2: (10 -5); // should resolve to 5 */ protected $inParens = false; // Caches preg escaped literals protected static $literalCache = array(); /** * Constructor * * @param [type] $lessc [description] * @param string $sourceName [description] */ public function __construct($lessc, $sourceName = null) { $this->eatWhiteDefault = true; // Reference to less needed for vPrefix, mPrefix, and parentSelector $this->lessc = $lessc; // Name used for error messages $this->sourceName = $sourceName; $this->writeComments = false; if (!self::$operatorString) { self::$operatorString = '(' . implode('|', array_map(array('\\FOF30\\Less\\Less', 'preg_quote'), array_keys(self::$precedence))) . ')'; $commentSingle = Less::preg_quote(self::$commentSingle); $commentMultiLeft = Less::preg_quote(self::$commentMultiLeft); $commentMultiRight = Less::preg_quote(self::$commentMultiRight); self::$commentMulti = $commentMultiLeft . '.*?' . $commentMultiRight; self::$whitePattern = '/' . $commentSingle . '[^\n]*\s*|(' . self::$commentMulti . ')\s*|\s+/Ais'; } } /** * Parse text * * @param string $buffer [description] * * @return [type] [description] */ public function parse($buffer) { $this->count = 0; $this->line = 1; // Block stack $this->env = null; $this->buffer = $this->writeComments ? $buffer : $this->removeComments($buffer); $this->pushSpecialBlock("root"); $this->eatWhiteDefault = true; $this->seenComments = array(); /* * trim whitespace on head * if (preg_match('/^\s+/', $this->buffer, $m)) { * $this->line += substr_count($m[0], "\n"); * $this->buffer = ltrim($this->buffer); * } */ $this->whitespace(); // Parse the entire file $lastCount = $this->count; while (false !== $this->parseChunk()); if ($this->count != strlen($this->buffer)) { $this->throwError(); } // TODO report where the block was opened if (!is_null($this->env->parent)) { throw new exception('parse error: unclosed block'); } return $this->env; } /** * Parse a single chunk off the head of the buffer and append it to the * current parse environment. * Returns false when the buffer is empty, or when there is an error. * * This function is called repeatedly until the entire document is * parsed. * * This parser is most similar to a recursive descent parser. Single * functions represent discrete grammatical rules for the language, and * they are able to capture the text that represents those rules. * * Consider the function lessc::keyword(). (all parse functions are * structured the same) * * The function takes a single reference argument. When calling the * function it will attempt to match a keyword on the head of the buffer. * If it is successful, it will place the keyword in the referenced * argument, advance the position in the buffer, and return true. If it * fails then it won't advance the buffer and it will return false. * * All of these parse functions are powered by lessc::match(), which behaves * the same way, but takes a literal regular expression. Sometimes it is * more convenient to use match instead of creating a new function. * * Because of the format of the functions, to parse an entire string of * grammatical rules, you can chain them together using &&. * * But, if some of the rules in the chain succeed before one fails, then * the buffer position will be left at an invalid state. In order to * avoid this, lessc::seek() is used to remember and set buffer positions. * * Before parsing a chain, use $s = $this->seek() to remember the current * position into $s. Then if a chain fails, use $this->seek($s) to * go back where we started. * * @return boolean */ protected function parseChunk() { if (empty($this->buffer)) { return false; } $s = $this->seek(); // Setting a property if ($this->keyword($key) && $this->assign() && $this->propertyValue($value, $key) && $this->end()) { $this->append(array('assign', $key, $value), $s); return true; } else { $this->seek($s); } // Look for special css blocks if ($this->literal('@', false)) { $this->count // Media if ($this->literal('@media')) { if (($this->mediaQueryList($mediaQueries) || true) && $this->literal('{')) { $media = $this->pushSpecialBlock("media"); $media->queries = is_null($mediaQueries) ? array() : $mediaQueries; return true; } else { $this->seek($s); return false; } } if ($this->literal("@", false) && $this->keyword($dirName)) { if ($this->isDirective($dirName, $this->blockDirectives)) { if (($this->openString("{", $dirValue, null, array(";")) || true) && $this->literal("{")) { $dir = $this->pushSpecialBlock("directive"); $dir->name = $dirName; if (isset($dirValue)) { $dir->value = $dirValue; } return true; } } elseif ($this->isDirective($dirName, $this->lineDirectives)) { if ($this->propertyValue($dirValue) && $this->end()) { $this->append(array("directive", $dirName, $dirValue)); return true; } } } $this->seek($s); } // Setting a variable if ($this->variable($var) && $this->assign() && $this->propertyValue($value) && $this->end()) { $this->append(array('assign', $var, $value), $s); return true; } else { $this->seek($s); } if ($this->import($importValue)) { $this->append($importValue, $s); return true; } // Opening parametric mixin if ($this->tag($tag, true) && $this->argumentDef($args, $isVararg) && ($this->guards($guards) || true) && $this->literal('{')) { $block = $this->pushBlock($this->fixTags(array($tag))); $block->args = $args; $block->isVararg = $isVararg; if (!empty($guards)) { $block->guards = $guards; } return true; } else { $this->seek($s); } // Opening a simple block if ($this->tags($tags) && $this->literal('{')) { $tags = $this->fixTags($tags); $this->pushBlock($tags); return true; } else { $this->seek($s); } // Closing a block if ($this->literal('}', false)) { try { $block = $this->pop(); } catch (exception $e) { $this->seek($s); $this->throwError($e->getMessage()); } $hidden = false; if (is_null($block->type)) { $hidden = true; if (!isset($block->args)) { foreach ($block->tags as $tag) { if (!is_string($tag) || $tag[0] != $this->lessc->mPrefix) { $hidden = false; break; } } } foreach ($block->tags as $tag) { if (is_string($tag)) { $this->env->children[$tag][] = $block; } } } if (!$hidden) { $this->append(array('block', $block), $s); } // This is done here so comments aren't bundled into he block that was just closed $this->whitespace(); return true; } // Mixin if ($this->mixinTags($tags) && ($this->argumentValues($argv) || true) && ($this->keyword($suffix) || true) && $this->end()) { $tags = $this->fixTags($tags); $this->append(array('mixin', $tags, $argv, $suffix), $s); return true; } else { $this->seek($s); } // Spare ; if ($this->literal(';')) { return true; } // Got nothing, throw error return false; } /** * [isDirective description] * * @param string $dirname [description] * @param [type] $directives [description] * * @return boolean */ protected function isDirective($dirname, $directives) { // TODO: cache pattern in parser $pattern = implode("|", array_map(array("\\FOF30\\Less\\Less", "preg_quote"), $directives)); $pattern = '/^(-[a-z-]+-)?(' . $pattern . ')$/i'; return preg_match($pattern, $dirname); } /** * [fixTags description] * * @param [type] $tags [description] * * @return [type] [description] */ protected function fixTags($tags) { // Move @ tags out of variable namespace foreach ($tags as &$tag) { if ($tag[0] == $this->lessc->vPrefix) { $tag[0] = $this->lessc->mPrefix; } } return $tags; } /** * a list of expressions * * @param [type] &$exps [description] * * @return boolean */ protected function expressionList(&$exps) { $values = array(); while ($this->expression($exp)) { $values[] = $exp; } if (count($values) == 0) { return false; } $exps = Less::compressList($values, ' '); return true; } protected function expression(&$out) { if ($this->value($lhs)) { $out = $this->expHelper($lhs, 0); // Look for / shorthand if (!empty($this->env->supressedDivision)) { unset($this->env->supressedDivision); $s = $this->seek(); if ($this->literal("/") && $this->value($rhs)) { $out = array("list", "", array($out, array("keyword", "/"), $rhs)); } else { $this->seek($s); } } return true; } return false; } /** * Recursively parse infix equation with $lhs at precedence $minP * * @param type $lhs [description] * @param type $minP [description] * * @return string */ protected function expHelper($lhs, $minP) { $this->inExp = true; $ss = $this->seek(); while (true) { $whiteBefore = isset($this->buffer[$this->count - 1]) && ctype_space($this->buffer[$this->count - 1]); // If there is whitespace before the operator, then we require // whitespace after the operator for it to be an expression $needWhite = $whiteBefore && !$this->inParens; if ($this->match(self::$operatorString . ($needWhite ? '\s' : ''), $m) && self::$precedence[$m[1]] >= $minP) { if (!$this->inParens && isset($this->env->currentProperty) && $m[1] == "/" && empty($this->env->supressedDivision)) { foreach (self::$<API key> as $pattern) { if (preg_match($pattern, $this->env->currentProperty)) { $this->env->supressedDivision = true; break 2; } } } $whiteAfter = isset($this->buffer[$this->count - 1]) && ctype_space($this->buffer[$this->count - 1]); if (!$this->value($rhs)) { break; } // Peek for next operator to see what to do with rhs if ($this->peek(self::$operatorString, $next) && self::$precedence[$next[1]] > self::$precedence[$m[1]]) { $rhs = $this->expHelper($rhs, self::$precedence[$next[1]]); } $lhs = array('expression', $m[1], $lhs, $rhs, $whiteBefore, $whiteAfter); $ss = $this->seek(); continue; } break; } $this->seek($ss); return $lhs; } /** * Consume a list of values for a property * * @param [type] &$value [description] * @param [type] $keyName [description] * * @return boolean */ public function propertyValue(&$value, $keyName = null) { $values = array(); if ($keyName !== null) { $this->env->currentProperty = $keyName; } $s = null; while ($this->expressionList($v)) { $values[] = $v; $s = $this->seek(); if (!$this->literal(',')) { break; } } if ($s) { $this->seek($s); } if ($keyName !== null) { unset($this->env->currentProperty); } if (count($values) == 0) { return false; } $value = Less::compressList($values, ', '); return true; } /** * [parenValue description] * * @param [type] &$out [description] * * @return boolean */ protected function parenValue(&$out) { $s = $this->seek(); // Speed shortcut if (isset($this->buffer[$this->count]) && $this->buffer[$this->count] != "(") { return false; } $inParens = $this->inParens; if ($this->literal("(") && ($this->inParens = true) && $this->expression($exp) && $this->literal(")")) { $out = $exp; $this->inParens = $inParens; return true; } else { $this->inParens = $inParens; $this->seek($s); } return false; } /** * a single value * * @param [type] &$value [description] * * @return boolean */ protected function value(&$value) { $s = $this->seek(); // Speed shortcut if (isset($this->buffer[$this->count]) && $this->buffer[$this->count] == "-") { // Negation if ($this->literal("-", false) &&(($this->variable($inner) && $inner = array("variable", $inner)) || $this->unit($inner) || $this->parenValue($inner))) { $value = array("unary", "-", $inner); return true; } else { $this->seek($s); } } if ($this->parenValue($value)) { return true; } if ($this->unit($value)) { return true; } if ($this->color($value)) { return true; } if ($this->func($value)) { return true; } if ($this->string($value)) { return true; } if ($this->keyword($word)) { $value = array('keyword', $word); return true; } // Try a variable if ($this->variable($var)) { $value = array('variable', $var); return true; } // Unquote string (should this work on any type? if ($this->literal("~") && $this->string($str)) { $value = array("escape", $str); return true; } else { $this->seek($s); } // Css hack: \0 if ($this->literal('\\') && $this->match('([0-9]+)', $m)) { $value = array('keyword', '\\' . $m[1]); return true; } else { $this->seek($s); } return false; } /** * an import statement * * @param [type] &$out [description] * * @return boolean */ protected function import(&$out) { $s = $this->seek(); if (!$this->literal('@import')) { return false; } /* * @import "something.css" media; * @import url("something.css") media; * @import url(something.css) media; */ if ($this->propertyValue($value)) { $out = array("import", $value); return true; } } /** * [mediaQueryList description] * * @param [type] &$out [description] * * @return boolean */ protected function mediaQueryList(&$out) { if ($this->genericList($list, "mediaQuery", ",", false)) { $out = $list[2]; return true; } return false; } /** * [mediaQuery description] * * @param [type] &$out [description] * * @return [type] [description] */ protected function mediaQuery(&$out) { $s = $this->seek(); $expressions = null; $parts = array(); if (($this->literal("only") && ($only = true) || $this->literal("not") && ($not = true) || true) && $this->keyword($mediaType)) { $prop = array("mediaType"); if (isset($only)) { $prop[] = "only"; } if (isset($not)) { $prop[] = "not"; } $prop[] = $mediaType; $parts[] = $prop; } else { $this->seek($s); } if (!empty($mediaType) && !$this->literal("and")) { } else { $this->genericList($expressions, "mediaExpression", "and", false); if (is_array($expressions)) { $parts = array_merge($parts, $expressions[2]); } } if (count($parts) == 0) { $this->seek($s); return false; } $out = $parts; return true; } /** * [mediaExpression description] * * @param [type] &$out [description] * * @return boolean */ protected function mediaExpression(&$out) { $s = $this->seek(); $value = null; if ($this->literal("(") && $this->keyword($feature) && ($this->literal(":") && $this->expression($value) || true) && $this->literal(")")) { $out = array("mediaExp", $feature); if ($value) { $out[] = $value; } return true; } elseif ($this->variable($variable)) { $out = array('variable', $variable); return true; } $this->seek($s); return false; } /** * An unbounded string stopped by $end * * @param [type] $end [description] * @param [type] &$out [description] * @param [type] $nestingOpen [description] * @param [type] $rejectStrs [description] * * @return boolean */ protected function openString($end, &$out, $nestingOpen = null, $rejectStrs = null) { $oldWhite = $this->eatWhiteDefault; $this->eatWhiteDefault = false; $stop = array("'", '"', "@{", $end); $stop = array_map(array("\\FOF30\\Less\\Less", "preg_quote"), $stop); // $stop[] = self::$commentMulti; if (!is_null($rejectStrs)) { $stop = array_merge($stop, $rejectStrs); } $patt = '(.*?)(' . implode("|", $stop) . ')'; $nestingLevel = 0; $content = array(); while ($this->match($patt, $m, false)) { if (!empty($m[1])) { $content[] = $m[1]; if ($nestingOpen) { $nestingLevel += substr_count($m[1], $nestingOpen); } } $tok = $m[2]; $this->count -= strlen($tok); if ($tok == $end) { if ($nestingLevel == 0) { break; } else { $nestingLevel } } if (($tok == "'" || $tok == '"') && $this->string($str)) { $content[] = $str; continue; } if ($tok == "@{" && $this->interpolation($inter)) { $content[] = $inter; continue; } if (in_array($tok, $rejectStrs)) { $count = null; break; } $content[] = $tok; $this->count += strlen($tok); } $this->eatWhiteDefault = $oldWhite; if (count($content) == 0) return false; // Trim the end if (is_string(end($content))) { $content[count($content) - 1] = rtrim(end($content)); } $out = array("string", "", $content); return true; } /** * [string description] * * @param [type] &$out [description] * * @return boolean */ protected function string(&$out) { $s = $this->seek(); if ($this->literal('"', false)) { $delim = '"'; } elseif ($this->literal("'", false)) { $delim = "'"; } else { return false; } $content = array(); // Look for either ending delim , escape, or string interpolation $patt = '([^\n]*?)(@\{|\\\\|' . Less::preg_quote($delim) . ')'; $oldWhite = $this->eatWhiteDefault; $this->eatWhiteDefault = false; while ($this->match($patt, $m, false)) { $content[] = $m[1]; if ($m[2] == "@{") { $this->count -= strlen($m[2]); if ($this->interpolation($inter, false)) { $content[] = $inter; } else { $this->count += strlen($m[2]); // Ignore it $content[] = "@{"; } } elseif ($m[2] == '\\') { $content[] = $m[2]; if ($this->literal($delim, false)) { $content[] = $delim; } } else { $this->count -= strlen($delim); // Delim break; } } $this->eatWhiteDefault = $oldWhite; if ($this->literal($delim)) { $out = array("string", $delim, $content); return true; } $this->seek($s); return false; } /** * [interpolation description] * * @param [type] &$out [description] * * @return boolean */ protected function interpolation(&$out) { $oldWhite = $this->eatWhiteDefault; $this->eatWhiteDefault = true; $s = $this->seek(); if ($this->literal("@{") && $this->openString("}", $interp, null, array("'", '"', ";")) && $this->literal("}", false)) { $out = array("interpolate", $interp); $this->eatWhiteDefault = $oldWhite; if ($this->eatWhiteDefault) { $this->whitespace(); } return true; } $this->eatWhiteDefault = $oldWhite; $this->seek($s); return false; } /** * [unit description] * * @param [type] &$unit [description] * * @return boolean */ protected function unit(&$unit) { // Speed shortcut if (isset($this->buffer[$this->count])) { $char = $this->buffer[$this->count]; if (!ctype_digit($char) && $char != ".") { return false; } } if ($this->match('([0-9]+(?:\.[0-9]*)?|\.[0-9]+)([%a-zA-Z]+)?', $m)) { $unit = array("number", $m[1], empty($m[2]) ? "" : $m[2]); return true; } return false; } /** * a # color * * @param [type] &$out [description] * * @return boolean */ protected function color(&$out) { if ($this->match('(#(?:[0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{3}))', $m)) { if (strlen($m[1]) > 7) { $out = array("string", "", array($m[1])); } else { $out = array("raw_color", $m[1]); } return true; } return false; } /** * Consume a list of property values delimited by ; and wrapped in () * * @param [type] &$args [description] * @param [type] $delim [description] * * @return boolean */ protected function argumentValues(&$args, $delim = ',') { $s = $this->seek(); if (!$this->literal('(')) { return false; } $values = array(); while (true) { if ($this->expressionList($value)) { $values[] = $value; } if (!$this->literal($delim)) { break; } else { if ($value == null) { $values[] = null; } $value = null; } } if (!$this->literal(')')) { $this->seek($s); return false; } $args = $values; return true; } /** * Consume an argument definition list surrounded by () * each argument is a variable name with optional value * or at the end a ... or a variable named followed by ... * * @param [type] &$args [description] * @param [type] &$isVararg [description] * @param [type] $delim [description] * * @return boolean */ protected function argumentDef(&$args, &$isVararg, $delim = ',') { $s = $this->seek(); if (!$this->literal('(')) return false; $values = array(); $isVararg = false; while (true) { if ($this->literal("...")) { $isVararg = true; break; } if ($this->variable($vname)) { $arg = array("arg", $vname); $ss = $this->seek(); if ($this->assign() && $this->expressionList($value)) { $arg[] = $value; } else { $this->seek($ss); if ($this->literal("...")) { $arg[0] = "rest"; $isVararg = true; } } $values[] = $arg; if ($isVararg) { break; } continue; } if ($this->value($literal)) { $values[] = array("lit", $literal); } if (!$this->literal($delim)) { break; } } if (!$this->literal(')')) { $this->seek($s); return false; } $args = $values; return true; } /** * Consume a list of tags * This accepts a hanging delimiter * * @param [type] &$tags [description] * @param [type] $simple [description] * @param [type] $delim [description] * * @return boolean */ protected function tags(&$tags, $simple = false, $delim = ',') { $tags = array(); while ($this->tag($tt, $simple)) { $tags[] = $tt; if (!$this->literal($delim)) { break; } } if (count($tags) == 0) { return false; } return true; } /** * List of tags of specifying mixin path * Optionally separated by > (lazy, accepts extra >) * * @param [type] &$tags [description] * * @return boolean */ protected function mixinTags(&$tags) { $s = $this->seek(); $tags = array(); while ($this->tag($tt, true)) { $tags[] = $tt; $this->literal(">"); } if (count($tags) == 0) { return false; } return true; } /** * A bracketed value (contained within in a tag definition) * * @param [type] &$value [description] * * @return boolean */ protected function tagBracket(&$value) { // Speed shortcut if (isset($this->buffer[$this->count]) && $this->buffer[$this->count] != "[") { return false; } $s = $this->seek(); if ($this->literal('[') && $this->to(']', $c, true) && $this->literal(']', false)) { $value = '[' . $c . ']'; // Whitespace? if ($this->whitespace()) { $value .= " "; } // Escape parent selector, (yuck) $value = str_replace($this->lessc->parentSelector, "$&$", $value); return true; } $this->seek($s); return false; } /** * [tagExpression description] * * @param [type] &$value [description] * * @return boolean */ protected function tagExpression(&$value) { $s = $this->seek(); if ($this->literal("(") && $this->expression($exp) && $this->literal(")")) { $value = array('exp', $exp); return true; } $this->seek($s); return false; } /** * A single tag * * @param [type] &$tag [description] * @param boolean $simple [description] * * @return boolean */ protected function tag(&$tag, $simple = false) { if ($simple) { $chars = '^@,:;{}\][>\(\) "\''; } else { $chars = '^@,;{}["\''; } $s = $this->seek(); if (!$simple && $this->tagExpression($tag)) { return true; } $hasExpression = false; $parts = array(); while ($this->tagBracket($first)) { $parts[] = $first; } $oldWhite = $this->eatWhiteDefault; $this->eatWhiteDefault = false; while (true) { if ($this->match('([' . $chars . '0-9][' . $chars . ']*)', $m)) { $parts[] = $m[1]; if ($simple) { break; } while ($this->tagBracket($brack)) { $parts[] = $brack; } continue; } if (isset($this->buffer[$this->count]) && $this->buffer[$this->count] == "@") { if ($this->interpolation($interp)) { $hasExpression = true; // Don't unescape $interp[2] = true; $parts[] = $interp; continue; } if ($this->literal("@")) { $parts[] = "@"; continue; } } // For keyframes if ($this->unit($unit)) { $parts[] = $unit[1]; $parts[] = $unit[2]; continue; } break; } $this->eatWhiteDefault = $oldWhite; if (!$parts) { $this->seek($s); return false; } if ($hasExpression) { $tag = array("exp", array("string", "", $parts)); } else { $tag = trim(implode($parts)); } $this->whitespace(); return true; } /** * A css function * * @param [type] &$func [description] * * @return boolean */ protected function func(&$func) { $s = $this->seek(); if ($this->match('(%|[\w\-_][\w\-_:\.]+|[\w_])', $m) && $this->literal('(')) { $fname = $m[1]; $sPreArgs = $this->seek(); $args = array(); while (true) { $ss = $this->seek(); // This ugly nonsense is for ie filter properties if ($this->keyword($name) && $this->literal('=') && $this->expressionList($value)) { $args[] = array("string", "", array($name, "=", $value)); } else { $this->seek($ss); if ($this->expressionList($value)) { $args[] = $value; } } if (!$this->literal(',')) { break; } } $args = array('list', ',', $args); if ($this->literal(')')) { $func = array('function', $fname, $args); return true; } elseif ($fname == 'url') { // Couldn't parse and in url? treat as string $this->seek($sPreArgs); if ($this->openString(")", $string) && $this->literal(")")) { $func = array('function', $fname, $string); return true; } } } $this->seek($s); return false; } /** * Consume a less variable * * @param [type] &$name [description] * * @return boolean */ protected function variable(&$name) { $s = $this->seek(); if ($this->literal($this->lessc->vPrefix, false) && ($this->variable($sub) || $this->keyword($name))) { if (!empty($sub)) { $name = array('variable', $sub); } else { $name = $this->lessc->vPrefix . $name; } return true; } $name = null; $this->seek($s); return false; } /** * Consume an assignment operator * Can optionally take a name that will be set to the current property name * * @param string $name [description] * * @return boolean */ protected function assign($name = null) { if ($name) { $this->currentProperty = $name; } return $this->literal(':') || $this->literal('='); } /** * Consume a keyword * * @param [type] &$word [description] * * @return boolean */ protected function keyword(&$word) { if ($this->match('([\w_\-\*!"][\w\-_"]*)', $m)) { $word = $m[1]; return true; } return false; } /** * Consume an end of statement delimiter * * @return boolean */ protected function end() { if ($this->literal(';')) { return true; } elseif ($this->count == strlen($this->buffer) || $this->buffer{$this->count} == '}') { // If there is end of file or a closing block next then we don't need a ; return true; } return false; } /** * [guards description] * * @param [type] &$guards [description] * * @return boolean */ protected function guards(&$guards) { $s = $this->seek(); if (!$this->literal("when")) { $this->seek($s); return false; } $guards = array(); while ($this->guardGroup($g)) { $guards[] = $g; if (!$this->literal(",")) { break; } } if (count($guards) == 0) { $guards = null; $this->seek($s); return false; } return true; } /** * A bunch of guards that are and'd together * * @param [type] &$guardGroup [description] * * @todo rename to guardGroup * * @return boolean */ protected function guardGroup(&$guardGroup) { $s = $this->seek(); $guardGroup = array(); while ($this->guard($guard)) { $guardGroup[] = $guard; if (!$this->literal("and")) { break; } } if (count($guardGroup) == 0) { $guardGroup = null; $this->seek($s); return false; } return true; } /** * [guard description] * * @param [type] &$guard [description] * * @return boolean */ protected function guard(&$guard) { $s = $this->seek(); $negate = $this->literal("not"); if ($this->literal("(") && $this->expression($exp) && $this->literal(")")) { $guard = $exp; if ($negate) { $guard = array("negate", $guard); } return true; } $this->seek($s); return false; } /* raw parsing functions */ /** * [literal description] * * @param [type] $what [description] * @param [type] $eatWhitespace [description] * * @return boolean */ protected function literal($what, $eatWhitespace = null) { if ($eatWhitespace === null) { $eatWhitespace = $this->eatWhiteDefault; } // Shortcut on single letter if (!isset($what[1]) && isset($this->buffer[$this->count])) { if ($this->buffer[$this->count] == $what) { if (!$eatWhitespace) { $this->count++; return true; } } else { return false; } } if (!isset(self::$literalCache[$what])) { self::$literalCache[$what] = Less::preg_quote($what); } return $this->match(self::$literalCache[$what], $m, $eatWhitespace); } /** * [genericList description] * * @param [type] &$out [description] * @param [type] $parseItem [description] * @param string $delim [description] * @param boolean $flatten [description] * * @return boolean */ protected function genericList(&$out, $parseItem, $delim = "", $flatten = true) { $s = $this->seek(); $items = array(); while ($this->$parseItem($value)) { $items[] = $value; if ($delim) { if (!$this->literal($delim)) { break; } } } if (count($items) == 0) { $this->seek($s); return false; } if ($flatten && count($items) == 1) { $out = $items[0]; } else { $out = array("list", $delim, $items); } return true; } /** * Advance counter to next occurrence of $what * $until - don't include $what in advance * $allowNewline, if string, will be used as valid char set * * @param [type] $what [description] * @param [type] &$out [description] * @param boolean $until [description] * @param boolean $allowNewline [description] * * @return boolean */ protected function to($what, &$out, $until = false, $allowNewline = false) { if (is_string($allowNewline)) { $validChars = $allowNewline; } else { $validChars = $allowNewline ? "." : "[^\n]"; } if (!$this->match('(' . $validChars . '*?)' . Less::preg_quote($what), $m, !$until)) { return false; } if ($until) { // Give back $what $this->count -= strlen($what); } $out = $m[1]; return true; } /** * Try to match something on head of buffer * * @param [type] $regex [description] * @param [type] &$out [description] * @param [type] $eatWhitespace [description] * * @return boolean */ protected function match($regex, &$out, $eatWhitespace = null) { if ($eatWhitespace === null) { $eatWhitespace = $this->eatWhiteDefault; } $r = '/' . $regex . ($eatWhitespace && !$this->writeComments ? '\s*' : '') . '/Ais'; if (preg_match($r, $this->buffer, $out, null, $this->count)) { $this->count += strlen($out[0]); if ($eatWhitespace && $this->writeComments) { $this->whitespace(); } return true; } return false; } /** * Watch some whitespace * * @return boolean */ protected function whitespace() { if ($this->writeComments) { $gotWhite = false; while (preg_match(self::$whitePattern, $this->buffer, $m, null, $this->count)) { if (isset($m[1]) && empty($this->commentsSeen[$this->count])) { $this->append(array("comment", $m[1])); $this->commentsSeen[$this->count] = true; } $this->count += strlen($m[0]); $gotWhite = true; } return $gotWhite; } else { $this->match("", $m); return strlen($m[0]) > 0; } } /** * Match something without consuming it * * @param [type] $regex [description] * @param [type] &$out [description] * @param [type] $from [description] * * @return boolean */ protected function peek($regex, &$out = null, $from = null) { if (is_null($from)) { $from = $this->count; } $r = '/' . $regex . '/Ais'; $result = preg_match($r, $this->buffer, $out, null, $from); return $result; } /** * Seek to a spot in the buffer or return where we are on no argument * * @param [type] $where [description] * * @return boolean */ protected function seek($where = null) { if ($where === null) { return $this->count; } else { $this->count = $where; } return true; } /* misc functions */ /** * [throwError description] * * @param string $msg [description] * @param [type] $count [description] * * @return void */ public function throwError($msg = "parse error", $count = null) { $count = is_null($count) ? $this->count : $count; $line = $this->line + substr_count(substr($this->buffer, 0, $count), "\n"); if (!empty($this->sourceName)) { $loc = "$this->sourceName on line $line"; } else { $loc = "line: $line"; } // TODO this depends on $this->count if ($this->peek("(.*?)(\n|$)", $m, $count)) { throw new exception("$msg: failed at `$m[1]` $loc"); } else { throw new exception("$msg: $loc"); } } /** * [pushBlock description] * * @param [type] $selectors [description] * @param [type] $type [description] * * @return \stdClass */ protected function pushBlock($selectors = null, $type = null) { $b = new \stdClass; $b->parent = $this->env; $b->type = $type; $b->id = self::$nextBlockId++; // TODO: kill me from here $b->isVararg = false; $b->tags = $selectors; $b->props = array(); $b->children = array(); $this->env = $b; return $b; } /** * Push a block that doesn't multiply tags * * @param [type] $type [description] * * @return \stdClass */ protected function pushSpecialBlock($type) { return $this->pushBlock(null, $type); } /** * Append a property to the current block * * @param [type] $prop [description] * @param [type] $pos [description] * * @return void */ protected function append($prop, $pos = null) { if ($pos !== null) { $prop[-1] = $pos; } $this->env->props[] = $prop; } /** * Pop something off the stack * * @return [type] [description] */ protected function pop() { $old = $this->env; $this->env = $this->env->parent; return $old; } /** * Remove comments from $text * * @param [type] $text [description] * * @todo: make it work for all functions, not just url * * @return [type] [description] */ protected function removeComments($text) { $look = array(
#ifndef _LOCKHELP_H #define _LOCKHELP_H #include <generated/autoconf.h> #include <linux/spinlock.h> #include <asm/atomic.h> #include <linux/interrupt.h> #include <linux/smp.h> /* Header to do help in lock debugging. */ #if 0 //<API key> struct spinlock_debug { spinlock_t l; atomic_t locked_by; }; struct rwlock_debug { rwlock_t l; long read_locked_map; long write_locked_map; }; #define DECLARE_LOCK(l) \ struct spinlock_debug l = { SPIN_LOCK_UNLOCKED, ATOMIC_INIT(-1) } #define DECLARE_LOCK_EXTERN(l) \ extern struct spinlock_debug l #define DECLARE_RWLOCK(l) \ struct rwlock_debug l = { RW_LOCK_UNLOCKED, 0, 0 } #define <API key>(l) \ extern struct rwlock_debug l #define MUST_BE_LOCKED(l) \ do { if (atomic_read(&(l)->locked_by) != smp_processor_id()) \ printk("ASSERT %s:%u %s unlocked\n", __FILE__, __LINE__, } while(0) #define MUST_BE_UNLOCKED(l) \ do { if (atomic_read(&(l)->locked_by) == smp_processor_id()) \ printk("ASSERT %s:%u %s locked\n", __FILE__, __LINE__, } while(0) /* Write locked OK as well. */ #define MUST_BE_READ_LOCKED(l) \ do { if (!((l)->read_locked_map & (1UL << smp_processor_id())) \ && !((l)->write_locked_map & (1UL << smp_processor_id()))) \ printk("ASSERT %s:%u %s not readlocked\n", __FILE__, __LINE__, } while(0) #define <API key>(l) \ do { if (!((l)->write_locked_map & (1UL << smp_processor_id()))) \ printk("ASSERT %s:%u %s not writelocked\n", __FILE__, __LINE__, } while(0) #define <API key>(l) \ do { if ((l)->read_locked_map & (1UL << smp_processor_id())) \ printk("ASSERT %s:%u %s readlocked\n", __FILE__, __LINE__, else if ((l)->write_locked_map & (1UL << smp_processor_id())) \ printk("ASSERT %s:%u %s writelocked\n", __FILE__, __LINE__, } while(0) #define LOCK_BH(lk) \ do { \ MUST_BE_UNLOCKED(lk); \ spin_lock_bh(&(lk)->l); \ atomic_set(&(lk)->locked_by, smp_processor_id()); \ } while(0) #define UNLOCK_BH(lk) \ do { \ MUST_BE_LOCKED(lk); \ atomic_set(&(lk)->locked_by, -1); \ spin_unlock_bh(&(lk)->l); \ } while(0) #define READ_LOCK(lk) \ do { \ <API key>(lk); \ read_lock_bh(&(lk)->l); \ set_bit(smp_processor_id(), &(lk)->read_locked_map); \ } while(0) #define WRITE_LOCK(lk) \ do { \ <API key>(lk); \ write_lock_bh(&(lk)->l); \ set_bit(smp_processor_id(), &(lk)->write_locked_map); \ } while(0) #define READ_UNLOCK(lk) \ do { \ if (!((lk)->read_locked_map & (1UL << smp_processor_id()))) \ printk("ASSERT: %s:%u %s not readlocked\n", \ __FILE__, __LINE__, clear_bit(smp_processor_id(), &(lk)->read_locked_map); \ read_unlock_bh(&(lk)->l); \ } while(0) #define WRITE_UNLOCK(lk) \ do { \ <API key>(lk); \ clear_bit(smp_processor_id(), &(lk)->write_locked_map); \ write_unlock_bh(&(lk)->l); \ } while(0) #else #define DECLARE_LOCK(l) spinlock_t l = SPIN_LOCK_UNLOCKED #define DECLARE_LOCK_EXTERN(l) extern spinlock_t l #define DECLARE_RWLOCK(l) rwlock_t l = RW_LOCK_UNLOCKED #define <API key>(l) extern rwlock_t l #define MUST_BE_LOCKED(l) #define MUST_BE_UNLOCKED(l) #define MUST_BE_READ_LOCKED(l) #define <API key>(l) #define <API key>(l) #define LOCK_BH(l) spin_lock_bh(l) #define UNLOCK_BH(l) spin_unlock_bh(l) #define READ_LOCK(l) read_lock_bh(l) #define WRITE_LOCK(l) write_lock_bh(l) #define READ_UNLOCK(l) read_unlock_bh(l) #define WRITE_UNLOCK(l) write_unlock_bh(l) #endif /*<API key>*/ #endif /* _LOCKHELP_H */
namespace Rantory.Migrations { using System; using System.Data.Entity.Migrations; public partial class ChemicalType : DbMigration { public override void Up() { CreateTable( "dbo.ChemicalTypes", c => new { Id = c.Int(nullable: false, identity: true), Name = c.String(), }) .PrimaryKey(t => t.Id); } public override void Down() { DropTable("dbo.ChemicalTypes"); } } }
#include <sys/types.h> struct child_message { int reqsize; int path1size; int path2size; }; extern void run(int cfs, const char *codadir, int dm); extern void child_process(int infd, int outfd); extern int mount_coda(const char *dev, const char *dir, int devfd, int quiet); extern int unmount_coda(const char *dir, int quiet); extern void set_signal_handlers(); extern void clean_exit(int status); extern void run_exit(); extern void user_child(pid_t pid);
/* body { direction: rtl; unicode-bidi: embed; } */
using Windows.UI.Xaml.Navigation; using Vocabulary; using Vocabulary.ViewModels; namespace Vocabulary.Views { public sealed partial class HomePage : PageBase { public HomePage() { this.ViewModel = new MainViewModel(8); this.InitializeComponent(); } public MainViewModel ViewModel { get; set; } protected async override void LoadState(object navParameter) { await this.ViewModel.LoadDataAsync(); } } }
/* * $Id: x2c.c,v 1.7 2009/06/02 09:40:53 bnv Exp $ * $Log: x2c.c,v $ * Revision 1.7 2009/06/02 09:40:53 bnv * MVS/CMS corrections * * Revision 1.6 2008/07/15 07:40:54 bnv * #include changed from <> to "" * * Revision 1.5 2008/07/14 13:08:16 bnv * MVS,CMS support * * Revision 1.4 2002/06/11 12:37:15 bnv * Added: CDECL * * Revision 1.3 2001/06/25 18:49:48 bnv * Header changed to Id * * Revision 1.2 1999/11/26 12:52:25 bnv * Changed: To use the new macros * * Revision 1.1 1998/07/02 17:20:58 bnv * Initial Version * */ #include <ctype.h> #include "lerror.h" #include "lstring.h" void __CDECL Lx2c( const PLstr to, const PLstr from ) { int i,j,r; char *t,*f; L2STR(from); Lfx(to,LLEN(*from)/2+1); /* a rough estimation */ t = LSTR(*to); f = LSTR(*from); for (i=r=0; i<LLEN(*from); ) { for (; ISSPACE(f[i]) && (i<LLEN(*from)); i++) ;; /*skip spaces*/ for (j=i; ISXDIGIT(f[j]) && (j<LLEN(*from)); j++) ;; /* find hexdigits */ if ((i<LLEN(*from)) && (j==i)) { /* Ooops wrong character */ Lerror(<API key>,0); LZEROSTR(*to); /* return null when error occures */ return; } if ((j-i)&1) { t[r++] = HEXVAL(f[i]); i++; } for (; i<j; i+=2) t[r++] = (HEXVAL(f[i])<<4) | HEXVAL(f[i+1]); } LTYPE(*to) = LSTRING_TY; LLEN(*to) = r; } /* Lx2c */
#!/usr/bin/perl use strict; use warnings; use Net::SNMP; my $OID_sysUpTime = '1.3.6.1.2.1.1.3.0'; my ($session, $error) = Net::SNMP->session( -hostname => shift || '127.0.0.1', -community => shift || 'public', ); if (!defined $session) { printf "ERROR: %s.\n", $error; exit 1; } my $result = $session->get_request(-varbindlist => [ $OID_sysUpTime ],); if (!defined $result) { printf "ERROR: %s.\n", $session->error(); $session->close(); exit 1; } printf "The sysUpTime for host '%s' is %s.\n", $session->hostname(), $result->{$OID_sysUpTime}; $session->close(); exit 0;
<?php defined('_JEXEC') or die; jimport('joomla.application.component.modellist'); /** * Methods supporting a list of Somosmaestros records. */ class <API key> extends JModelList { /** * Constructor. * * @param array An optional associative array of configuration settings. * * @see JController * @since 1.6 */ public function __construct($config = array()) { if (empty($config['filter_fields'])) { $config['filter_fields'] = array( 'id', 'a.id', 'ordering', 'a.ordering', 'state', 'a.state', 'created_by', 'a.created_by', 'titulo', 'a.titulo', 'contenido', 'a.contenido', 'imagen_grande', 'a.imagen_grande', 'imagen_pequena', 'a.imagen_pequena', 'destacado', 'a.destacado', 'delegacion', 'a.delegacion', 'tipo_institucion', 'a.tipo_institucion', 'segmento', 'a.segmento', 'nivel', 'a.nivel', 'ciudad', 'a.ciudad', 'area', 'a.area', 'rol', 'a.rol', 'proyecto', 'a.proyecto', 'publico', 'a.publico', 'asistentes', 'a.asistentes', 'disponibilidad', 'a.disponibilidad', 'fuente', 'a.fuente', 'preview', 'a.preview', ); } parent::__construct($config); } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { // Initialise variables. $app = JFactory::getApplication(); // List state information $limit = $app-><API key>('global.list.limit', 'limit', $app->getCfg('list_limit')); $this->setState('list.limit', $limit); $limitstart = $app->input->getInt('limitstart', 0); $this->setState('list.start', $limitstart); if ($list = $app-><API key>($this->context . '.list', 'list', array(), 'array')) { foreach ($list as $name => $value) { // Extra validations switch ($name) { case 'fullordering': $orderingParts = explode(' ', $value); if (count($orderingParts) >= 2) { // Latest part will be considered the direction $fullDirection = end($orderingParts); if (in_array(strtoupper($fullDirection), array('ASC', 'DESC', ''))) { $this->setState('list.direction', $fullDirection); } unset($orderingParts[count($orderingParts) - 1]); // The rest will be the ordering $fullOrdering = implode(' ', $orderingParts); if (in_array($fullOrdering, $this->filter_fields)) { $this->setState('list.ordering', $fullOrdering); } } else { $this->setState('list.ordering', $ordering); $this->setState('list.direction', $direction); } break; case 'ordering': if (!in_array($value, $this->filter_fields)) { $value = $ordering; } break; case 'direction': if (!in_array(strtoupper($value), array('ASC', 'DESC', ''))) { $value = $direction; } break; case 'limit': $limit = $value; break; // Just to keep the default case default: $value = $value; break; } $this->setState('list.' . $name, $value); } } // Receive & set filters if ($filters = $app-><API key>($this->context . '.filter', 'filter', array(), 'array')) { foreach ($filters as $name => $value) { $this->setState('filter.' . $name, $value); } } $ordering = $app->input->get('filter_order'); if (!empty($ordering)) { $list = $app->getUserState($this->context . '.list'); $list['ordering'] = $app->input->get('filter_order'); $app->setUserState($this->context . '.list', $list); } $orderingDirection = $app->input->get('filter_order_Dir'); if (!empty($orderingDirection)) { $list = $app->getUserState($this->context . '.list'); $list['direction'] = $app->input->get('filter_order_Dir'); $app->setUserState($this->context . '.list', $list); } $list = $app->getUserState($this->context . '.list'); if (empty($list['ordering'])) { $list['ordering'] = 'ordering'; } if (empty($list['direction'])) { $list['direction'] = 'asc'; } $this->setState('list.ordering', $list['ordering']); $this->setState('list.direction', $list['direction']); } /** * Build an SQL query to load the list data. * * @return JDatabaseQuery * @since 1.6 */ protected function getListQuery() { // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); // Select the required fields from the table. $query ->select( $this->getState( 'list.select', 'DISTINCT a.*' ) ); $query->from('`#<API key>` AS a'); // Join over the users for the checked out user. $query->select('uc.name AS editor'); $query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out'); $query->join('LEFT', '#__users AS created_by ON created_by.id = a.created_by'); if (!JFactory::getUser()->authorise('core.edit.state', 'com_somosmaestros')) { $query->where('a.state = 1'); } // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = ' . (int) substr($search, 3)); } else { $search = $db->Quote('%' . $db->escape($search, true) . '%'); $query->where('( a.titulo LIKE '.$search.' OR a.delegacion LIKE '.$search.' OR a.tipo_institucion LIKE '.$search.' OR a.segmento LIKE '.$search.' OR a.nivel LIKE '.$search.' OR a.ciudad LIKE '.$search.' OR a.area LIKE '.$search.' OR a.rol LIKE '.$search.' OR a.proyecto LIKE '.$search.' )'); } } // Add the list ordering clause. $orderCol = $this->state->get('list.ordering'); $orderDirn = $this->state->get('list.direction'); if ($orderCol && $orderDirn) { $query->order($db->escape($orderCol . ' ' . $orderDirn)); } return $query; } public function getItems() { $items = parent::getItems(); return $items; } /** * Overrides the default function to check Date fields format, identified by * "_dateformat" suffix, and erases the field if it's not correct. */ protected function loadFormData() { $app = JFactory::getApplication(); $filters = $app->getUserState($this->context . '.filter', array()); $error_dateformat = false; foreach ($filters as $key => $value) { if (strpos($key, '_dateformat') && !empty($value) && !$this->isValidDate($value)) { $filters[$key] = ''; $error_dateformat = true; } } if ($error_dateformat) { $app->enqueueMessage(JText::_("<API key>"), "warning"); $app->setUserState($this->context . '.filter', $filters); } return parent::loadFormData(); } /** * Checks if a given date is valid and in an specified format (YYYY-MM-DD) * * @param string Contains the date to be checked * */ private function isValidDate($date) { return preg_match("/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/", $date) && date_create($date); } }
\file \ingroup Config #include "config.h" #include <stdlib.h> #include <stdio.h> #include <errno.h> #include <string.h> #include <strings.h> #include <assert.h> #include <stdbool.h> #include "libmpv/client.h" #include "mpv_talloc.h" #include "m_config.h" #include "options/m_option.h" #include "common/msg.h" #include "common/msg_control.h" static const union m_option_value default_value; // Profiles allow to predefine some sets of options that can then // be applied later on with the internal -profile option. #define MAX_PROFILE_DEPTH 20 // Maximal include depth. #define MAX_RECURSION_DEPTH 8 struct m_profile { struct m_profile *next; char *name; char *desc; int num_opts; // Option/value pair array. char **opts; }; // In the file local case, this contains the old global value. struct m_opt_backup { struct m_opt_backup *next; struct m_config_option *co; void *backup; }; static int parse_include(struct m_config *config, struct bstr param, bool set, int flags) { if (param.len == 0) return M_OPT_MISSING_PARAM; if (!set) return 1; if (config->recursion_depth >= MAX_RECURSION_DEPTH) { MP_ERR(config, "Maximum 'include' nesting depth exceeded.\n"); return M_OPT_INVALID; } char *filename = bstrdup0(NULL, param); config->recursion_depth += 1; config->includefunc(config->includefunc_ctx, filename, flags); config->recursion_depth -= 1; talloc_free(filename); return 1; } static int parse_profile(struct m_config *config, const struct m_option *opt, struct bstr name, struct bstr param, bool set, int flags) { if (!bstrcmp0(param, "help")) { struct m_profile *p; if (!config->profiles) { MP_INFO(config, "No profiles have been defined.\n"); return M_OPT_EXIT - 1; } MP_INFO(config, "Available profiles:\n"); for (p = config->profiles; p; p = p->next) MP_INFO(config, "\t%s\t%s\n", p->name, p->desc ? p->desc : ""); MP_INFO(config, "\n"); return M_OPT_EXIT - 1; } char **list = NULL; int r = <API key>.parse(config->log, opt, name, param, &list); if (r < 0) return r; if (!list || !list[0]) return M_OPT_INVALID; for (int i = 0; list[i]; i++) { if (set) r = <API key>(config, list[i], flags); if (r < 0) break; } m_option_free(opt, &list); return r; } static int show_profile(struct m_config *config, bstr param) { struct m_profile *p; if (!param.len) return M_OPT_MISSING_PARAM; if (!(p = <API key>(config, param))) { MP_ERR(config, "Unknown profile '%.*s'.\n", BSTR_P(param)); return M_OPT_EXIT - 1; } if (!config->profile_depth) MP_INFO(config, "Profile %s: %s\n", p->name, p->desc ? p->desc : ""); config->profile_depth++; for (int i = 0; i < p->num_opts; i++) { MP_INFO(config, "%*s%s=%s\n", config->profile_depth, "", p->opts[2 * i], p->opts[2 * i + 1]); if (config->profile_depth < MAX_PROFILE_DEPTH && !strcmp(p->opts[2*i], "profile")) { char *e, *list = p->opts[2 * i + 1]; while ((e = strchr(list, ','))) { int l = e - list; if (!l) continue; show_profile(config, (bstr){list, e - list}); list = e + 1; } if (list[0] != '\0') show_profile(config, bstr0(list)); } } config->profile_depth if (!config->profile_depth) MP_INFO(config, "\n"); return M_OPT_EXIT - 1; } static int list_options(struct m_config *config) { <API key>(config); return M_OPT_EXIT; } // The memcpys are supposed to work around the strict aliasing violation, // that would result if we just dereferenced a void** (where the void** is // actually casted from struct some_type* ). The dummy struct type is in // theory needed, because void* and struct pointers could have different // representations, while pointers to different struct types don't. static void *substruct_read_ptr(const void *ptr) { struct mp_dummy_ *res; memcpy(&res, ptr, sizeof(res)); return res; } static void substruct_write_ptr(void *ptr, void *val) { struct mp_dummy_ *src = val; memcpy(ptr, &src, sizeof(src)); } static void add_options(struct m_config *config, const char *parent_name, void *optstruct, const void *optstruct_def, const struct m_option *defs); static void config_destroy(void *p) { struct m_config *config = p; <API key>(config); for (int n = 0; n < config->num_opts; n++) m_option_free(config->opts[n].opt, config->opts[n].data); } struct m_config *m_config_new(void *talloc_ctx, struct mp_log *log, size_t size, const void *defaults, const struct m_option *options) { struct m_config *config = talloc(talloc_ctx, struct m_config); <API key>(config, config_destroy); *config = (struct m_config) {.log = log, .size = size, .defaults = defaults, .options = options}; // size==0 means a dummy object is created if (size) { config->optstruct = talloc_zero_size(config, size); if (defaults) memcpy(config->optstruct, defaults, size); } if (options) add_options(config, "", config->optstruct, defaults, options); return config; } struct m_config *<API key>(void *talloc_ctx, struct mp_log *log, struct m_obj_desc *desc) { return m_config_new(talloc_ctx, log, desc->priv_size, desc->priv_defaults, desc->options); } // Like <API key>(), but don't allocate option struct. struct m_config *<API key>(void *talloc_ctx, struct mp_log *log, struct m_obj_desc *desc) { return m_config_new(talloc_ctx, log, 0, desc->priv_defaults, desc->options); } int <API key>(struct m_config *conf, char **args) { for (int n = 0; args && args[n * 2 + 0]; n++) { int r = m_config_set_option(conf, bstr0(args[n * 2 + 0]), bstr0(args[n * 2 + 1])); if (r < 0) return r; } return 0; } int <API key>(struct m_config *config, const char *name, struct m_obj_settings *defaults) { int r = 0; for (int n = 0; defaults && defaults[n].name; n++) { struct m_obj_settings *entry = &defaults[n]; if (name && strcmp(entry->name, name) == 0) { r = <API key>(config, entry->attribs); break; } } return r; } static void ensure_backup(struct m_config *config, struct m_config_option *co) { if (co->opt->type->flags & <API key>) return; if (co->opt->flags & M_OPT_GLOBAL) return; if (!co->data) return; for (struct m_opt_backup *cur = config->backup_opts; cur; cur = cur->next) { if (cur->co->data == co->data) // comparing data ptr catches aliases return; } struct m_opt_backup *bc = talloc_ptrtype(NULL, bc); *bc = (struct m_opt_backup) { .co = co, .backup = talloc_zero_size(bc, co->opt->type->size), }; m_option_copy(co->opt, bc->backup, co->data); bc->next = config->backup_opts; config->backup_opts = bc; co->is_set_locally = true; } void <API key>(struct m_config *config) { while (config->backup_opts) { struct m_opt_backup *bc = config->backup_opts; config->backup_opts = bc->next; m_option_copy(bc->co->opt, bc->co->data, bc->backup); m_option_free(bc->co->opt, bc->backup); bc->co->is_set_locally = false; talloc_free(bc); } } void m_config_backup_opt(struct m_config *config, const char *opt) { struct m_config_option *co = m_config_get_co(config, bstr0(opt)); if (co) { ensure_backup(config, co); } else { MP_ERR(config, "Option %s not found.\n", opt); } } void <API key>(struct m_config *config) { for (int n = 0; n < config->num_opts; n++) ensure_backup(config, &config->opts[n]); } // Given an option --opt, add --no-opt (if applicable). static void add_negation_option(struct m_config *config, struct m_config_option *orig, const char *parent_name) { const struct m_option *opt = orig->opt; int value; if (opt->type == CONF_TYPE_FLAG) { value = 0; } else if (opt->type == CONF_TYPE_CHOICE) { // Find out whether there's a "no" choice. // m_option_parse() should be used for this, but it prints // unsilenceable error messages. struct <API key> *alt = opt->priv; for ( ; alt->name; alt++) { if (strcmp(alt->name, "no") == 0) break; } if (!alt->name) return; value = alt->value; } else { return; } struct m_option *no_opt = talloc_ptrtype(config, no_opt); *no_opt = (struct m_option) { .name = opt->name, .type = CONF_TYPE_STORE, .flags = opt->flags & (M_OPT_NOCFG | M_OPT_GLOBAL | M_OPT_PRE_PARSE), .offset = opt->offset, .max = value, }; // Add --no-sub-opt struct m_config_option co = *orig; co.name = talloc_asprintf(config, "no-%s", orig->name); co.opt = no_opt; co.is_generated = true; MP_TARRAY_APPEND(config, config->opts, config->num_opts, co); // Add --sub-no-opt (unfortunately needed for: "--sub=...:no-opt") if (parent_name[0]) { co.name = talloc_asprintf(config, "%s-no-%s", parent_name, opt->name); MP_TARRAY_APPEND(config, config->opts, config->num_opts, co); } } static void m_config_add_option(struct m_config *config, const char *parent_name, void *optstruct, const void *optstruct_def, const struct m_option *arg); static void add_options(struct m_config *config, const char *parent_name, void *optstruct, const void *optstruct_def, const struct m_option *defs) { for (int i = 0; defs && defs[i].name; i++) m_config_add_option(config, parent_name, optstruct, optstruct_def, &defs[i]); } // Initialize a field with a given value. In case this is dynamic data, it has // to be allocated and copied. src can alias dst, also can be NULL. static void init_opt_inplace(const struct m_option *opt, void *dst, const void *src) { union m_option_value temp = {0}; if (src) memcpy(&temp, src, opt->type->size); memset(dst, 0, opt->type->size); m_option_copy(opt, dst, &temp); } static void m_config_add_option(struct m_config *config, const char *parent_name, void *optstruct, const void *optstruct_def, const struct m_option *arg) { assert(config != NULL); assert(arg != NULL); struct m_config_option co = { .opt = arg, .name = arg->name, }; if (arg->offset >= 0) { if (optstruct) co.data = (char *)optstruct + arg->offset; if (optstruct_def) co.default_data = (char *)optstruct_def + arg->offset; } if (arg->defval) co.default_data = arg->defval; if (!co.default_data) co.default_data = &default_value; // Fill in the full name if (!co.name[0]) { co.name = parent_name; } else if (parent_name[0]) { co.name = talloc_asprintf(config, "%s-%s", parent_name, co.name); } // Option with children -> add them if (arg->type->flags & <API key>) { const struct m_sub_options *subopts = arg->priv; void *new_optstruct = NULL; if (co.data) { new_optstruct = <API key>(config, subopts); substruct_write_ptr(co.data, new_optstruct); } const void *new_optstruct_def = substruct_read_ptr(co.default_data); if (!new_optstruct_def) new_optstruct_def = subopts->defaults; add_options(config, co.name, new_optstruct, new_optstruct_def, subopts->opts); } else { // Initialize options if (co.data && co.default_data) { if (arg->type->flags & M_OPT_TYPE_DYNAMIC) { // Would leak memory by overwriting *co.data repeatedly. for (int i = 0; i < config->num_opts; i++) { if (co.data == config->opts[i].data) assert(0); } } init_opt_inplace(arg, co.data, co.default_data); } } if (arg->name[0]) // no own name -> hidden MP_TARRAY_APPEND(config, config->opts, config->num_opts, co); add_negation_option(config, &co, parent_name); if (co.opt->type == &m_option_type_alias) { co.is_generated = true; // hide it const char *alias = (const char *)co.opt->priv; char no_alias[40]; snprintf(no_alias, sizeof(no_alias), "no-%s", alias); if (m_config_get_co(config, bstr0(no_alias))) { struct m_option *new = talloc_zero(config, struct m_option); new->name = talloc_asprintf(config, "no-%s", co.name); new->priv = talloc_strdup(config, no_alias); new->type = &m_option_type_alias; new->offset = -1; m_config_add_option(config, "", NULL, NULL, new); } } if (co.opt->type == &<API key>) co.is_generated = true; // hide it } struct m_config_option *m_config_get_co(const struct m_config *config, struct bstr name) { if (!name.len) return NULL; for (int n = 0; n < config->num_opts; n++) { struct m_config_option *co = &config->opts[n]; struct bstr coname = bstr0(co->name); bool matches = false; if ((co->opt->type->flags & <API key>) && bstr_endswith0(coname, "*")) { coname.len if (bstrcmp(bstr_splice(name, 0, coname.len), coname) == 0) matches = true; } else if (bstrcmp(coname, name) == 0) matches = true; if (matches) { const char *prefix = config->is_toplevel ? " if (co->opt->type == &m_option_type_alias) { const char *alias = (const char *)co->opt->priv; if (!co->warning_was_printed) { MP_WARN(config, "Warning: option %s%s was replaced with " "%s%s and might be removed in the future.\n", prefix, co->name, prefix, alias); co->warning_was_printed = true; } return m_config_get_co(config, bstr0(alias)); } else if (co->opt->type == &<API key>) { if (!co->warning_was_printed) { char *msg = co->opt->priv; if (msg) { MP_FATAL(config, "Option %s%s was removed: %s\n", prefix, co->name, msg); } else { MP_FATAL(config, "Option %s%s was removed.\n", prefix, co->name); } co->warning_was_printed = true; } return NULL; } else if (co->opt->deprecation_message) { if (!co->warning_was_printed) { MP_WARN(config, "Warning: option %s%s is deprecated " "and might be removed in the future (%s).\n", prefix, co->name, co->opt->deprecation_message); co->warning_was_printed = true; } } return co; } } return NULL; } const char *<API key>(const struct m_config *config, int p) { int pos = 0; for (int n = 0; n < config->num_opts; n++) { struct m_config_option *co = &config->opts[n]; if (!co->is_generated) { if (pos == p) return co->name; pos++; } } return NULL; } // return: <0: M_OPT_ error, 0: skip, 1: check, 2: set static int <API key>(struct m_config *config, struct m_config_option *co, int flags) { int optflags = co->opt->flags; bool set = !(flags & M_SETOPT_CHECK_ONLY); if ((flags & <API key>) && !(optflags & M_OPT_PRE_PARSE)) return 0; if ((flags & <API key>) && co->is_set_from_cmdline) set = false; if ((flags & M_SETOPT_NO_FIXED) && (optflags & M_OPT_FIXED)) return M_OPT_INVALID; if ((flags & <API key>) && (optflags & M_OPT_PRE_PARSE)) return M_OPT_INVALID; // Check if this option isn't forbidden in the current mode if ((flags & <API key>) && (optflags & M_OPT_NOCFG)) { MP_ERR(config, "The %s option can't be used in a config file.\n", co->name); return M_OPT_INVALID; } if (flags & M_SETOPT_BACKUP) { if (optflags & M_OPT_GLOBAL) { MP_ERR(config, "The %s option is global and can't be set per-file.\n", co->name); return M_OPT_INVALID; } if (set) ensure_backup(config, co); } return set ? 2 : 1; } static void handle_on_set(struct m_config *config, struct m_config_option *co, int flags) { if (flags & <API key>) { co->is_set_from_cmdline = true; // Mark aliases too if (co->data) { for (int n = 0; n < config->num_opts; n++) { struct m_config_option *co2 = &config->opts[n]; if (co2->data == co->data) co2->is_set_from_cmdline = true; } } } if (config->global && (co->opt->flags & M_OPT_TERM)) <API key>(config->global); } // The type data points to is as in: m_config_get_co(config, name)->opt int <API key>(struct m_config *config, struct m_config_option *co, void *data, int flags) { if (!co) return M_OPT_UNKNOWN; // This affects some special options like "include", "profile". Maybe these // should work, or maybe not. For now they would require special code. if (!co->data) return M_OPT_UNKNOWN; int r = <API key>(config, co, flags); if (r <= 1) return r; m_option_copy(co->opt, co->data, data); handle_on_set(config, co, flags); return 0; } static int parse_subopts(struct m_config *config, char *name, char *prefix, struct bstr param, int flags); static int <API key>(struct m_config *config, struct bstr name, struct bstr param, int flags) { assert(config != NULL); struct m_config_option *co = m_config_get_co(config, name); if (!co) return M_OPT_UNKNOWN; // This is the only mandatory function assert(co->opt->type->parse); int r = <API key>(config, co, flags); if (r <= 0) return r; bool set = r == 2; if (set) { MP_VERBOSE(config, "Setting option '%.*s' = '%.*s' (flags = %d)\n", BSTR_P(name), BSTR_P(param), flags); } if (config->includefunc && bstr_equals0(name, "include")) return parse_include(config, param, set, flags); if (config->use_profiles && bstr_equals0(name, "profile")) return parse_profile(config, co->opt, name, param, set, flags); if (config->use_profiles && bstr_equals0(name, "show-profile")) return show_profile(config, param); if (bstr_equals0(name, "list-options")) return list_options(config); // Option with children are a bit different to parse if (co->opt->type->flags & <API key>) { char prefix[110]; assert(strlen(co->name) < 100); sprintf(prefix, "%s-", co->name); return parse_subopts(config, (char *)co->name, prefix, param, flags); } r = m_option_parse(config->log, co->opt, name, param, set ? co->data : NULL); if (r >= 0 && set) handle_on_set(config, co, flags); return r; } static int parse_subopts(struct m_config *config, char *name, char *prefix, struct bstr param, int flags) { char **lst = NULL; // Split the argument into child options int r = <API key>.parse(config->log, NULL, bstr0(""), param, &lst); if (r < 0) return r; // Parse the child options for (int i = 0; lst && lst[2 * i]; i++) { // Build the full name char n[110]; if (snprintf(n, 110, "%s%s", prefix, lst[2 * i]) > 100) abort(); r = <API key>(config,bstr0(n), bstr0(lst[2 * i + 1]), flags); if (r < 0) { if (r > M_OPT_EXIT) { MP_ERR(config, "Error parsing suboption %s/%s (%s)\n", name, lst[2 * i], m_option_strerror(r)); r = M_OPT_INVALID; } break; } } talloc_free(lst); return r; } int <API key>(struct m_config *config, char *name, char *subopts) { if (!subopts || !*subopts) return 0; int r = parse_subopts(config, name, "", bstr0(subopts), 0); if (r < 0 && r > M_OPT_EXIT) { MP_ERR(config, "Error parsing suboption %s (%s)\n", name, m_option_strerror(r)); r = M_OPT_INVALID; } return r; } int <API key>(struct m_config *config, struct bstr name, struct bstr param, int flags) { int r = <API key>(config, name, param, flags); if (r < 0 && r > M_OPT_EXIT) { MP_ERR(config, "Error parsing option %.*s (%s)\n", BSTR_P(name), m_option_strerror(r)); r = M_OPT_INVALID; } return r; } int m_config_set_option(struct m_config *config, struct bstr name, struct bstr param) { return <API key>(config, name, param, 0); } int <API key>(struct m_config *config, bstr name, struct mpv_node *data, int flags) { struct m_config_option *co = m_config_get_co(config, name); if (!co) return M_OPT_UNKNOWN; int r; // Do this on an "empty" type to make setting the option strictly overwrite // the old value, as opposed to e.g. appending to lists. union m_option_value val = {0}; if (data->format == MPV_FORMAT_STRING) { bstr param = bstr0(data->u.string); r = m_option_parse(mp_null_log, co->opt, name, param, &val); } else { r = m_option_set_node(co->opt, &val, data); } if (r >= 0) r = <API key>(config, co, &val, flags); if (mp_msg_test(config->log, MSGL_V)) { char *s = m_option_type_node.print(NULL, data); MP_VERBOSE(config, "Setting option '%.*s' = %s (flags = %d) -> %d\n", BSTR_P(name), s ? s : "?", flags, r); talloc_free(s); } m_option_free(co->opt, &val); return r; } const struct m_option *m_config_get_option(const struct m_config *config, struct bstr name) { assert(config != NULL); struct m_config_option *co = m_config_get_co(config, name); return co ? co->opt : NULL; } int <API key>(struct m_config *config, bstr name) { const struct m_option *opt = m_config_get_option(config, name); if (opt) { if (bstr_endswith0(name, "-clr")) return 0; return <API key>(opt); } return M_OPT_UNKNOWN; } static int sort_opt_compare(const void *pa, const void *pb) { const struct m_config_option *a = pa; const struct m_config_option *b = pb; return strcasecmp(a->name, b->name); } void <API key>(const struct m_config *config) { char min[50], max[50]; int count = 0; const char *prefix = config->is_toplevel ? " struct m_config_option *sorted = talloc_memdup(NULL, config->opts, config->num_opts * sizeof(sorted[0])); if (config->is_toplevel) qsort(sorted, config->num_opts, sizeof(sorted[0]), sort_opt_compare); MP_INFO(config, "Options:\n\n"); for (int i = 0; i < config->num_opts; i++) { struct m_config_option *co = &sorted[i]; const struct m_option *opt = co->opt; if (opt->type->flags & <API key>) continue; if (co->is_generated) continue; if (opt->type == &m_option_type_alias || opt->type == &<API key>) continue; MP_INFO(config, " %s%-30s", prefix, co->name); if (opt->type == &<API key>) { MP_INFO(config, " Choices:"); struct <API key> *alt = opt->priv; for (int n = 0; alt[n].name; n++) MP_INFO(config, " %s", alt[n].name); if (opt->flags & (M_OPT_MIN | M_OPT_MAX)) MP_INFO(config, " (or an integer)"); } else { MP_INFO(config, " %s", co->opt->type->name); } if (opt->flags & (M_OPT_MIN | M_OPT_MAX)) { snprintf(min, sizeof(min), "any"); snprintf(max, sizeof(max), "any"); if (opt->flags & M_OPT_MIN) snprintf(min, sizeof(min), "%.14g", opt->min); if (opt->flags & M_OPT_MAX) snprintf(max, sizeof(max), "%.14g", opt->max); MP_INFO(config, " (%s to %s)", min, max); } char *def = NULL; if (co->default_data) def = m_option_print(co->opt, co->default_data); if (def) { MP_INFO(config, " (default: %s)", def); talloc_free(def); } if (opt->flags & M_OPT_GLOBAL) MP_INFO(config, " [global]"); if (opt->flags & M_OPT_NOCFG) MP_INFO(config, " [nocfg]"); if (opt->flags & M_OPT_FILE) MP_INFO(config, " [file]"); MP_INFO(config, "\n"); count++; } MP_INFO(config, "\nTotal: %d options\n", count); talloc_free(sorted); } char **<API key>(void *ta_parent, const struct m_config *config) { char **list = talloc_new(ta_parent); int count = 0; for (int i = 0; i < config->num_opts; i++) { struct m_config_option *co = &config->opts[i]; const struct m_option *opt = co->opt; if (opt->type->flags & <API key>) continue; if (co->is_generated) continue; // For use with <API key>, it's important not to set list // as allocation parent. char *s = talloc_strdup(ta_parent, co->name); MP_TARRAY_APPEND(ta_parent, list, count, s); } MP_TARRAY_APPEND(ta_parent, list, count, NULL); return list; } struct m_profile *<API key>(const struct m_config *config, bstr name) { for (struct m_profile *p = config->profiles; p; p = p->next) { if (bstr_equals0(name, p->name)) return p; } return NULL; } struct m_profile *<API key>(const struct m_config *config, char *name) { return <API key>(config, bstr0(name)); } struct m_profile *<API key>(struct m_config *config, char *name) { if (!name || !name[0] || strcmp(name, "default") == 0) return NULL; // never a real profile struct m_profile *p = <API key>(config, name); if (p) return p; p = talloc_zero(config, struct m_profile); p->name = talloc_strdup(p, name); p->next = config->profiles; config->profiles = p; return p; } void m_profile_set_desc(struct m_profile *p, bstr desc) { talloc_free(p->desc); p->desc = bstrdup0(p, desc); } int <API key>(struct m_config *config, struct m_profile *p, bstr name, bstr val) { int i = <API key>(config, name, val, M_SETOPT_CHECK_ONLY | <API key>); if (i < 0) return i; p->opts = talloc_realloc(p, p->opts, char *, 2 * (p->num_opts + 2)); p->opts[p->num_opts * 2] = bstrdup0(p, name); p->opts[p->num_opts * 2 + 1] = bstrdup0(p, val); p->num_opts++; p->opts[p->num_opts * 2] = p->opts[p->num_opts * 2 + 1] = NULL; return 1; } int <API key>(struct m_config *config, char *name, int flags) { struct m_profile *p = <API key>(config, name); if (!p) { MP_WARN(config, "Unknown profile '%s'.\n", name); return M_OPT_INVALID; } if (config->profile_depth > MAX_PROFILE_DEPTH) { MP_WARN(config, "WARNING: Profile inclusion too deep.\n"); return M_OPT_UNKNOWN; } config->profile_depth++; for (int i = 0; i < p->num_opts; i++) { <API key>(config, bstr0(p->opts[2 * i]), bstr0(p->opts[2 * i + 1]), flags | <API key>); } config->profile_depth return 0; } void *<API key>(void *talloc_ctx, const struct m_sub_options *subopts) { void *substruct = talloc_zero_size(talloc_ctx, subopts->size); if (subopts->defaults) memcpy(substruct, subopts->defaults, subopts->size); return substruct; } struct dtor_info { const struct m_sub_options *opts; void *ptr; }; static void free_substruct(void *ptr) { struct dtor_info *d = ptr; for (int n = 0; d->opts->opts && d->opts->opts[n].type; n++) { const struct m_option *opt = &d->opts->opts[n]; void *dst = (char *)d->ptr + opt->offset; m_option_free(opt, dst); } } // Passing ptr==NULL initializes it from proper defaults. void *m_sub_options_copy(void *talloc_ctx, const struct m_sub_options *opts, const void *ptr) { void *new = <API key>(talloc_ctx, opts); struct dtor_info *dtor = talloc_ptrtype(new, dtor); *dtor = (struct dtor_info){opts, new}; <API key>(dtor, free_substruct); for (int n = 0; opts->opts && opts->opts[n].type; n++) { const struct m_option *opt = &opts->opts[n]; if (opt->offset < 0) continue; void *src = ptr ? (char *)ptr + opt->offset : NULL; void *dst = (char *)new + opt->offset; if (opt->type->flags & <API key>) { // Specifying a default struct for a sub-option field in the // containing struct's default struct is not supported here. // (Out of laziness. Could possibly be supported.) assert(!substruct_read_ptr(dst)); const struct m_sub_options *subopts = opt->priv; const void *sub_src = NULL; if (src) sub_src = substruct_read_ptr(src); if (!sub_src) sub_src = subopts->defaults; void *sub_dst = m_sub_options_copy(new, subopts, sub_src); substruct_write_ptr(dst, sub_dst); } else { init_opt_inplace(opt, dst, src); } } return new; } struct m_config *m_config_dup(void *talloc_ctx, struct m_config *config) { struct m_config *new = m_config_new(talloc_ctx, config->log, config->size, config->defaults, config->options); assert(new->num_opts == config->num_opts); for (int n = 0; n < new->num_opts; n++) { assert(new->opts[n].opt->type == config->opts[n].opt->type); m_option_copy(new->opts[n].opt, new->opts[n].data, config->opts[n].data); } return new; }
#include <dfsch/lib/crypto.h> static void ecb_setup(<API key>* cipher, uint8_t* iv, size_t iv_len){ if (iv_len != 0){ dfsch_error("ECB mode has no IV", NULL); } } static void ecb_encrypt(<API key>* context, uint8_t* in, uint8_t* out, size_t blocks){ size_t bsize = context->cipher->cipher->block_size; int i; for (i = 0; i < blocks; i++){ context->cipher->cipher->encrypt(context->cipher, in + (bsize * i), out + (bsize * i)); } } static void ecb_decrypt(<API key>* context, uint8_t* in, uint8_t* out, size_t blocks){ size_t bsize = context->cipher->cipher->block_size; int i; for (i = 0; i < blocks; i++){ context->cipher->cipher->decrypt(context->cipher, in + (bsize * i), out + (bsize * i)); } } <API key> <API key> = { .type = { .type = <API key>, .name = "crypto:ecb", .size = sizeof(<API key>), }, .name = "ECB", .encrypt = ecb_encrypt, .decrypt = ecb_decrypt, .setup = ecb_setup }; static void memxor(uint8_t* dst, uint8_t* src, size_t count){ while (count){ *dst ^= *src; dst++; src++; count } } typedef struct cbc_context_t { <API key> parent; uint8_t* iv; } cbc_context_t; static void cbc_setup(cbc_context_t* context, uint8_t* iv, size_t iv_len){ if (iv_len != context->parent.cipher->cipher->block_size){ dfsch_error("CBC IV length must be equal to block size", NULL); } context->iv = GC_MALLOC_ATOMIC(iv_len); memcpy(context->iv, iv, iv_len); } static void cbc_encrypt(cbc_context_t* context, uint8_t* in, uint8_t* out, size_t blocks){ size_t bsize = context->parent.cipher->cipher->block_size; int i; for (i = 0; i < blocks; i++){ memxor(context->iv, in + (bsize * i), bsize); context->parent.cipher->cipher->encrypt(context->parent.cipher, context->iv, context->iv); memcpy(out + (bsize * i), context->iv, bsize); } } static void cbc_decrypt(cbc_context_t* context, uint8_t* in, uint8_t* out, size_t blocks){ size_t bsize = context->parent.cipher->cipher->block_size; int i; uint8_t tmp[bsize]; for (i = 0; i < blocks; i++){ memcpy(tmp, in + (bsize * i), bsize); context->parent.cipher->cipher->decrypt(context->parent.cipher, in + (bsize * i), out + (bsize * i)); memxor(out + (bsize * i), context->iv, bsize); memcpy(context->iv, tmp, bsize); } } <API key> <API key> = { .type = { .type = <API key>, .name = "crypto:cbc", .size = sizeof(cbc_context_t), }, .name = "CBC", .encrypt = cbc_encrypt, .decrypt = cbc_decrypt, .setup = cbc_setup }; typedef struct cfb_context_t { <API key> parent; uint8_t* iv; } cfb_context_t; static void cfb_setup(cfb_context_t* context, uint8_t* iv, size_t iv_len){ if (iv_len != context->parent.cipher->cipher->block_size){ dfsch_error("CFB IV length must be equal to block size", NULL); } context->iv = GC_MALLOC_ATOMIC(iv_len); memcpy(context->iv, iv, iv_len); } static void cfb_encrypt(cfb_context_t* context, uint8_t* in, uint8_t* out, size_t blocks){ size_t bsize = context->parent.cipher->cipher->block_size; int i; for (i = 0; i < blocks; i++){ context->parent.cipher->cipher->encrypt(context->parent.cipher, context->iv, context->iv); memxor(context->iv, in + (bsize * i), bsize); memcpy(out + (bsize * i), context->iv, bsize); } } static void cfb_decrypt(cfb_context_t* context, uint8_t* in, uint8_t* out, size_t blocks){ size_t bsize = context->parent.cipher->cipher->block_size; int i; uint8_t tmp[bsize]; for (i = 0; i < blocks; i++){ memcpy(tmp, in + (bsize * i), bsize); context->parent.cipher->cipher->encrypt(context->parent.cipher, context->iv, out + (bsize * i)); memxor(out + (bsize * i), tmp, bsize); memcpy(context->iv, tmp, bsize); } } <API key> <API key> = { .type = { .type = <API key>, .name = "crypto:cfb", .size = sizeof(cfb_context_t), }, .name = "CFB", .encrypt = cfb_encrypt, .decrypt = cfb_decrypt, .setup = cfb_setup }; typedef struct ofb_context_t { <API key> parent; uint8_t* iv; } ofb_context_t; static void ofb_setup(ofb_context_t* context, uint8_t* iv, size_t iv_len){ if (iv_len != context->parent.cipher->cipher->block_size){ dfsch_error("OFB IV length must be equal to block size", NULL); } context->iv = GC_MALLOC_ATOMIC(iv_len); memcpy(context->iv, iv, iv_len); } static void ofb_operate(ofb_context_t* context, uint8_t* in, uint8_t* out, size_t blocks){ size_t bsize = context->parent.cipher->cipher->block_size; int i; for (i = 0; i < blocks; i++){ context->parent.cipher->cipher->encrypt(context->parent.cipher, context->iv, context->iv); memcpy(out + (bsize * i), in + (bsize * i), bsize); memxor(out + (bsize * i), context->iv, bsize); } } <API key> <API key> = { .type = { .type = <API key>, .name = "crypto:ofb", .size = sizeof(ofb_context_t), }, .name = "OFB", .encrypt = ofb_operate, .decrypt = ofb_operate, .setup = ofb_setup }; /* This implementation of CTR mode comes from NIST recommendation, which is different in significant details from AES-CTR used by TLS and IPsec (which are even mutually different). CTR mode can use various additional data from underlying protocol, which unfortunately means that each protocol uses completely different method of construing CTR value */ typedef struct ctr_context_t { <API key> parent; uint8_t* ctr; } ctr_context_t; static void ctr_setup(ctr_context_t* context, uint8_t* iv, size_t iv_len){ if (iv_len != context->parent.cipher->cipher->block_size){ dfsch_error("CTR IV length must be equal to block size", NULL); } context->ctr = GC_MALLOC_ATOMIC(iv_len); memcpy(context->ctr, iv, iv_len); } static void ctr_operate(ctr_context_t* context, uint8_t* in, uint8_t* out, size_t blocks){ size_t bsize = context->parent.cipher->cipher->block_size; int i; int j; uint8_t tmp[bsize]; for (i = 0; i < blocks; i++){ context->parent.cipher->cipher->encrypt(context->parent.cipher, context->ctr, tmp); memcpy(out + (bsize * i), in + (bsize * i), bsize); memxor(out + (bsize * i), tmp, bsize); /* Increment counter, little endian */ for (j = 0; j < bsize; j++){ context->ctr[j]++; if (context->ctr[j] != 0){ break; } } } } <API key> <API key> = { .type = { .type = <API key>, .name = "crypto:ctr", .size = sizeof(ctr_context_t), }, .name = "CTR", .encrypt = ctr_operate, .decrypt = ctr_operate, .setup = ctr_setup }; typedef struct block_stream_mode_t { <API key> parent; <API key>* cipher; } block_stream_mode_t; dfsch_type_t <API key> = { .type = DFSCH_META_TYPE, .superclass = <API key>, .name = "block-stream-mode", .size = sizeof(block_stream_mode_t), }; typedef struct <API key> { block_stream_mode_t* mode; <API key>* cipher; uint8_t* next_input; uint8_t* last_output; size_t output_offset; size_t output_size; } <API key>; static void bs_ofb_setup(<API key>* ctx, uint8_t *key, size_t keylen, uint8_t *nonce, size_t nonce_len){ if (nonce_len != ctx->mode->cipher->block_size){ dfsch_error("Nonce for OFB mode must be same size as cipher's block", NULL); } ctx->cipher = <API key>(ctx->mode->cipher, key, keylen); ctx->next_input = GC_MALLOC_ATOMIC(ctx->mode->cipher->block_size); ctx->last_output = GC_MALLOC_ATOMIC(ctx->mode->cipher->block_size); ctx->output_offset = ctx->mode->cipher->block_size; ctx->output_size = ctx->mode->cipher->block_size; memcpy(ctx->next_input, nonce, ctx->output_size); } static void <API key>(<API key>* ctx, uint8_t* out, size_t outlen){ while (outlen){ if (ctx->output_offset >= ctx->output_size){ ctx->cipher->cipher->encrypt(ctx->cipher, ctx->next_input, ctx->last_output); memcpy(ctx->next_input, ctx->last_output, ctx->output_size); ctx->output_offset = 0; } *out ^= ctx->last_output[ctx->output_offset]; ctx->output_offset++; out++; outlen } } <API key>* <API key>(<API key>* cipher){ block_stream_mode_t* bs = dfsch_make_object(<API key>); bs->parent.name = dfsch_saprintf("%s in OFB mode", cipher->name); bs->parent.type.name = dfsch_saprintf("%s-ofb", cipher->type.name); bs->parent.type.size = sizeof(<API key>); bs->parent.setup = bs_ofb_setup; bs->parent.encrypt_bytes = <API key>; return bs; } static void bs_ctr_setup(<API key>* ctx, uint8_t *key, size_t keylen, uint8_t *nonce, size_t nonce_len){ if (nonce_len != ctx->mode->cipher->block_size){ dfsch_error("Nonce for OFB mode must be same size as cipher's block", NULL); } ctx->cipher = <API key>(ctx->mode->cipher, key, keylen); ctx->next_input = GC_MALLOC_ATOMIC(ctx->mode->cipher->block_size); ctx->last_output = GC_MALLOC_ATOMIC(ctx->mode->cipher->block_size); ctx->output_offset = ctx->mode->cipher->block_size; ctx->output_size = ctx->mode->cipher->block_size; memcpy(ctx->next_input, nonce, ctx->output_size); } static void <API key>(<API key>* ctx, uint8_t* out, size_t outlen){ int i; while (outlen){ if (ctx->output_offset >= ctx->output_size){ ctx->cipher->cipher->encrypt(ctx->cipher, ctx->next_input, ctx->last_output); for (i = 0; i < ctx->output_size; i++){ ctx->next_input[i]++; if (ctx->next_input[i] != 0){ break; } } ctx->output_offset = 0; } *out ^= ctx->last_output[ctx->output_offset]; ctx->output_offset++; out++; outlen } } <API key>* <API key>(<API key>* cipher){ block_stream_mode_t* bs = dfsch_make_object(<API key>); bs->parent.name = dfsch_saprintf("%s in CTR mode", cipher->name); bs->parent.type.name = dfsch_saprintf("%s-ctr", cipher->type.name); bs->parent.type.size = sizeof(<API key>); bs->parent.setup = bs_ctr_setup; bs->parent.encrypt_bytes = <API key>; return bs; }
class Admin::BadgesController < Admin::AdminController def badge_types badge_types = BadgeType.all.to_a render_serialized(badge_types, BadgeTypeSerializer, root: "badge_types") end def create badge = Badge.new <API key>(badge) badge.save! render_serialized(badge, BadgeSerializer, root: "badge") end def update badge = find_badge <API key>(badge) badge.save! render_serialized(badge, BadgeSerializer, root: "badge") end def destroy find_badge.destroy render nothing: true end private def find_badge params.require(:id) Badge.find(params[:id]) end def <API key>(badge) params.permit(:name, :description, :badge_type_id, :allow_title, :multiple_grant) badge.name = params[:name] badge.description = params[:description] badge.badge_type = BadgeType.find(params[:badge_type_id]) badge.allow_title = params[:allow_title] badge.multiple_grant = params[:multiple_grant] badge.icon = params[:icon] badge end end
#include <linux/kernel.h> #include <linux/init.h> #include <linux/string.h> #include <linux/module.h> #include <linux/clk.h> #include <linux/kobject.h> #include <linux/err.h> #include "clock.h" #include "dvfs.h" #include "fuse.h" #include "board.h" #include "tegra3_emc.h" static bool <API key>; static bool <API key>; static struct dvfs *cpu_dvfs; static const int cpu_millivolts[MAX_DVFS_FREQS] = { 750, 800, 825, 850, 875, 900, 950, 975, 1000, 1025, 1050, 1100, 1200, 1275, 1275, 1275, 1300, 1325}; //750, 800, 825, 850, 875, 912, 975, 1000, 1025, 1050, 1075, 1100, 1150, 1200, 1212, 1225, 1250, 1300}; static const unsigned int cpu_cold_offs_mhz[MAX_DVFS_FREQS] = { 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50}; static const int core_millivolts[MAX_DVFS_FREQS] = { 900, 1000, 1050, 1100, 1150, 1200, 1250, 1300, 1350}; #define KHZ 1000 #define MHZ 1000000 /* VDD_CPU >= (VDD_CORE - cpu_below_core) */ /* VDD_CORE >= min_level(VDD_CPU), see <API key>() below */ #define <API key> 300 static int cpu_below_core = <API key>; #define VDD_SAFE_STEP 100 static struct dvfs_rail <API key> = { .reg_id = "vdd_cpu", .max_millivolts = 1300, .min_millivolts = 750, .step = VDD_SAFE_STEP, .jmp_to_zero = true, }; static struct dvfs_rail <API key> = { .reg_id = "vdd_core", .max_millivolts = 1350, .min_millivolts = 900, .step = VDD_SAFE_STEP, }; static struct dvfs_rail *tegra3_dvfs_rails[] = { &<API key>, &<API key>, }; static int <API key>(int cpu_mv) { if (cpu_mv < 800) return 950; if (cpu_mv < 900) return 1000; if (cpu_mv < 1000) return 1100; if ((tegra_cpu_speedo_id() < 2) || (tegra_cpu_speedo_id() == 4) || (tegra_cpu_speedo_id() == 7) || (tegra_cpu_speedo_id() == 8)) return 1200; if (cpu_mv < 1100) return 1200; if (cpu_mv <= 1250) return 1300; BUG(); } /* vdd_core must be >= min_level as a function of vdd_cpu */ static int <API key>(struct dvfs_rail *vdd_cpu, struct dvfs_rail *vdd_core) { int core_floor = max(vdd_cpu->new_millivolts, vdd_cpu->millivolts); core_floor = <API key>(core_floor); return max(vdd_core->new_millivolts, core_floor); } /* vdd_cpu must be >= (vdd_core - cpu_below_core) */ static int <API key>(struct dvfs_rail *vdd_core, struct dvfs_rail *vdd_cpu) { int cpu_floor; if (vdd_cpu->new_millivolts == 0) return 0; /* If G CPU is off, core relations can be ignored */ cpu_floor = max(vdd_core->new_millivolts, vdd_core->millivolts) - cpu_below_core; return max(vdd_cpu->new_millivolts, cpu_floor); } static struct dvfs_relationship <API key>[] = { { .from = &<API key>, .to = &<API key>, .solve = <API key>, .solved_at_nominal = true, }, { .from = &<API key>, .to = &<API key>, .solve = <API key>, }, }; #define CPU_DVFS(_clk_name, _speedo_id, _process_id, _mult, _freqs...) \ { \ .clk_name = _clk_name, \ .speedo_id = _speedo_id, \ .process_id = _process_id, \ .freqs = {_freqs}, \ .freqs_mult = _mult, \ .millivolts = cpu_millivolts, \ .auto_dvfs = true, \ .dvfs_rail = &<API key>, \ } static struct dvfs cpu_dvfs_table[] = { /* Cpu voltages (mV): 800, 825, 850, 875, 900, 912, 975, 1000, 1025, 1050, 1075, 1100, 1125, 1150, 1175, 1200, 1212, 1237 */ CPU_DVFS("cpu_g", 0, 0, MHZ, 1, 1, 684, 684, 817, 817, 1026, 1102, 1149, 1187, 1225, 1282, 1300), CPU_DVFS("cpu_g", 0, 1, MHZ, 1, 1, 807, 807, 948, 948, 1117, 1171, 1206, 1300), CPU_DVFS("cpu_g", 0, 2, MHZ, 1, 1, 883, 883, 1039, 1039, 1178, 1206, 1300), CPU_DVFS("cpu_g", 0, 3, MHZ, 1, 1, 931, 931, 1102, 1102, 1216, 1300), CPU_DVFS("cpu_g", 1, 0, MHZ, 460, 460, 550, 550, 680, 680, 820, 970, 1040, 1080, 1150, 1200, 1280, 1300), CPU_DVFS("cpu_g", 1, 1, MHZ, 480, 480, 650, 650, 780, 780, 990, 1040, 1100, 1200, 1300), CPU_DVFS("cpu_g", 1, 2, MHZ, 520, 520, 700, 700, 860, 860, 1050, 1150, 1200, 1300), CPU_DVFS("cpu_g", 1, 3, MHZ, 550, 550, 770, 770, 910, 910, 1150, 1230, 1300), CPU_DVFS("cpu_g", 2, 1, MHZ, 480, 480, 650, 650, 780, 780, 990, 1040, 1100, 1200, 1250, 1300, 1330, 1400), CPU_DVFS("cpu_g", 2, 2, MHZ, 520, 520, 700, 700, 860, 860, 1050, 1150, 1200, 1280, 1300, 1350, 1400), CPU_DVFS("cpu_g", 2, 3, MHZ, 550, 550, 770, 770, 910, 910, 1150, 1230, 1280, 1300, 1350, 1400), CPU_DVFS("cpu_g", 3, 1, MHZ, 480, 480, 650, 650, 780, 780, 990, 1040, 1100, 1200, 1250, 1300, 1330, 1400), CPU_DVFS("cpu_g", 3, 2, MHZ, 520, 520, 700, 700, 860, 860, 1050, 1150, 1200, 1280, 1300, 1350, 1400), CPU_DVFS("cpu_g", 3, 3, MHZ, 550, 550, 770, 770, 910, 910, 1150, 1230, 1280, 1300, 1350, 1400), CPU_DVFS("cpu_g", 7, 0, MHZ, 460, 460, 550, 550, 680, 680, 820, 970, 1040, 1080, 1150, 1200, 1240, 1280, 1320, 1480, 1500, 1600), CPU_DVFS("cpu_g", 7, 1, MHZ, 480, 480, 650, 650, 780, 780, 990, 1040, 1100, 1200, 1250, 1300, 1330, 1480, 1500, 1600), CPU_DVFS("cpu_g", 7, 2, MHZ, 520, 520, 700, 700, 860, 860, 1050, 1150, 1200, 1280, 1300, 1480, 1500, 1600), CPU_DVFS("cpu_g", 7, 3, MHZ, 550, 550, 770, 770, 910, 910, 1150, 1230, 1280, 1330, 1480, 1500, 1600), CPU_DVFS("cpu_g", 5, 2, MHZ, 550, 550, 770, 770, 910, 910, 1150, 1230, 1280, 1330, 1370, 1400, 1470, 1500, 1540, 1600, 1650, 1700), CPU_DVFS("cpu_g", 5, 3, MHZ, 550, 550, 770, 770, 910, 910, 1150, 1230, 1280, 1330, 1370, 1400, 1470, 1500, 1500, 1540, 1540, 1700), CPU_DVFS("cpu_g", 5, 4, MHZ, 550, 550, 770, 770, 940, 940, 1160, 1240, 1280, 1360, 1390, 1470, 1500, 1520, 1520, 1590, 1700), CPU_DVFS("cpu_g", 6, 3, MHZ, 550, 550, 770, 770, 910, 910, 1150, 1230, 1280, 1330, 1370, 1400, 1470, 1500, 1500, 1540, 1540, 1700), CPU_DVFS("cpu_g", 6, 4, MHZ, 550, 550, 770, 770, 940, 940, 1160, 1240, 1280, 1360, 1390, 1470, 1500, 1520, 1520, 1590, 1700), CPU_DVFS("cpu_g", 4, 0, MHZ, 460, 460, 550, 550, 680, 680, 820, 970, 1040, 1080, 1150, 1200, 1240, 1280, 1320, 1360, 1600), CPU_DVFS("cpu_g", 4, 1, MHZ, 480, 480, 650, 650, 780, 780, 990, 1040, 1100, 1200, 1250, 1300, 1330, 1360, 1500, 1600), CPU_DVFS("cpu_g", 4, 2, MHZ, 520, 520, 700, 700, 860, 860, 1050, 1150, 1200, 1280, 1300, 1340, 1480, 1600), CPU_DVFS("cpu_g", 4, 3, MHZ, 550, 550, 770, 770, 910, 910, 1150, 1230, 1270, 1300, 1340, 1480, 1600), CPU_DVFS("cpu_g", 4, 4, MHZ, 550, 550, 770, 770, 940, 940, 1160, 1300, 1340, 1480, 1600), CPU_DVFS("cpu_g", 8, 0, MHZ, 460, 460, 550, 550, 680, 680, 820, 970, 1040, 1080, 1150, 1200, 1280, 1300), CPU_DVFS("cpu_g", 8, 1, MHZ, 480, 480, 650, 650, 780, 780, 990, 1040, 1100, 1200, 1300), CPU_DVFS("cpu_g", 8, 2, MHZ, 520, 520, 700, 700, 860, 860, 1050, 1150, 1200, 1300), CPU_DVFS("cpu_g", 8, 3, MHZ, 550, 550, 770, 770, 910, 910, 1150, 1230, 1300), CPU_DVFS("cpu_g", 8, 4, MHZ, 550, 550, 770, 770, 940, 940, 1160, 1300), CPU_DVFS("cpu_g", 9, -1, MHZ, 1, 1, 1, 1, 1, 900, 900, 900, 900, 900, 900, 900, 900, 900), CPU_DVFS("cpu_g", 10, -1, MHZ, 1, 1, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900), CPU_DVFS("cpu_g", 11, -1, MHZ, 1, 1, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600), CPU_DVFS("cpu_g", 12, 3, MHZ, 550, 550, 770, 770, 910, 910, 1150, 1230, 1280, 1330, 1370, 1400, 1470, 1500, 1500, 1540, 1540, 1700), CPU_DVFS("cpu_g", 12, 4, MHZ, 550, 550, 770, 770, 940, 940, 1160, 1240, 1280, 1360, 1390, 1470, 1500, 1520, 1520, 1590, 1700), CPU_DVFS("cpu_g", 13, 3, MHZ, 550, 550, 770, 770, 910, 910, 1150, 1230, 1280, 1330, 1370, 1400, 1470, 1500, 1500, 1540, 1540, 1700), CPU_DVFS("cpu_g", 13, 4, MHZ, 550, 550, 770, 770, 940, 940, 1160, 1240, 1280, 1360, 1390, 1470, 1500, 1520, 1520, 1590, 1700), /* * "Safe entry" to be used when no match for chip speedo, process * corner is found (just to boot at low rate); must be the last one */ CPU_DVFS("cpu_g", -1, -1, MHZ, 1, 1, 216, 216, 300), }; #define CORE_DVFS(_clk_name, _speedo_id, _auto, _mult, _freqs...) \ { \ .clk_name = _clk_name, \ .speedo_id = _speedo_id, \ .process_id = -1, \ .freqs = {_freqs}, \ .freqs_mult = _mult, \ .millivolts = core_millivolts, \ .auto_dvfs = _auto, \ .dvfs_rail = &<API key>, \ } static struct dvfs core_dvfs_table[] = { /* Core voltages (mV): 950, 1000, 1050, 1100, 1150, 1200, 1250, 1300, 1350 */ /* Clock limits for internal blocks, PLLs */ CORE_DVFS("cpu_lp", 0, 1, KHZ, 1, 294000, 342000, 427000, 475000, 500000, 500000, 500000, 500000), CORE_DVFS("cpu_lp", 1, 1, KHZ, 204000, 294000, 342000, 427000, 475000, 500000, 500000, 500000, 500000), CORE_DVFS("cpu_lp", 2, 1, KHZ, 204000, 295000, 370000, 428000, 475000, 513000, 579000, 620000, 620000), CORE_DVFS("cpu_lp", 3, 1, KHZ, 1, 1, 1, 1, 1, 1, 450000, 450000, 450000), CORE_DVFS("emc", 0, 1, KHZ, 1, 266500, 266500, 266500, 266500, 533000, 533000, 533000, 533000), CORE_DVFS("emc", 1, 1, KHZ, 102000, 408000, 408000, 408000, 416000, 750000, 750000, 750000, 750000), CORE_DVFS("emc", 2, 1, KHZ, 102000, 408000, 408000, 408000, 416000, 750000, 750000, 800000, 900000), CORE_DVFS("emc", 3, 1, KHZ, 1, 1, 1, 1, 1, 1, 625000, 625000, 625000), CORE_DVFS("sbus", 0, 1, KHZ, 1, 136000, 164000, 191000, 216000, 216000, 216000, 216000, 216000), CORE_DVFS("sbus", 1, 1, KHZ, 51000, 205000, 205000, 227000, 227000, 267000, 267000, 267000, 267000), CORE_DVFS("sbus", 2, 1, KHZ, 51000, 205000, 205000, 227000, 227000, 267000, 334000, 334000, 334000), CORE_DVFS("sbus", 3, 1, KHZ, 1, 1, 1, 1, 1, 1, 378000, 378000, 378000), CORE_DVFS("vi", 0, 1, KHZ, 1, 216000, 285000, 300000, 300000, 300000, 300000, 300000, 300000), CORE_DVFS("vi", 1, 1, KHZ, 1, 216000, 267000, 300000, 371000, 409000, 409000, 409000, 409000), CORE_DVFS("vi", 2, 1, KHZ, 1, 219000, 267000, 300000, 371000, 409000, 425000, 425000, 425000), CORE_DVFS("vi", 3, 1, KHZ, 1, 1, 1, 1, 1, 1, 470000, 470000, 470000), CORE_DVFS("vde", 0, 1, KHZ, 1, 228000, 275000, 332000, 380000, 416000, 416000, 416000, 416000), CORE_DVFS("mpe", 0, 1, KHZ, 1, 234000, 285000, 332000, 380000, 416000, 416000, 416000, 416000), CORE_DVFS("2d", 0, 1, KHZ, 1, 267000, 285000, 332000, 380000, 416000, 416000, 416000, 416000), CORE_DVFS("epp", 0, 1, KHZ, 1, 267000, 285000, 332000, 380000, 416000, 416000, 416000, 416000), CORE_DVFS("3d", 0, 1, KHZ, 1, 234000, 285000, 332000, 380000, 416000, 416000, 416000, 416000), CORE_DVFS("3d2", 0, 1, KHZ, 1, 234000, 285000, 332000, 380000, 416000, 416000, 416000, 416000), CORE_DVFS("se", 0, 1, KHZ, 1, 267000, 285000, 332000, 380000, 416000, 416000, 416000, 416000), CORE_DVFS("vde", 1, 1, KHZ, 1, 228000, 275000, 332000, 380000, 416000, 484000, 520000, 666000), CORE_DVFS("mpe", 1, 1, KHZ, 1, 234000, 285000, 332000, 380000, 416000, 484000, 484000, 484000), CORE_DVFS("2d", 1, 1, KHZ, 1, 267000, 285000, 332000, 380000, 416000, 484000, 484000, 484000), CORE_DVFS("epp", 1, 1, KHZ, 1, 267000, 285000, 332000, 380000, 416000, 484000, 484000, 484000), CORE_DVFS("3d", 1, 1, KHZ, 1, 234000, 285000, 332000, 380000, 416000, 484000, 484000, 484000), CORE_DVFS("3d2", 1, 1, KHZ, 1, 234000, 285000, 332000, 380000, 416000, 484000, 484000, 484000), CORE_DVFS("se", 1, 1, KHZ, 1, 267000, 285000, 332000, 380000, 416000, 484000, 484000, 484000), CORE_DVFS("vde", 2, 1, KHZ, 1, 247000, 304000, 352000, 400000, 437000, 484000, 520000, 600000), CORE_DVFS("mpe", 2, 1, KHZ, 1, 247000, 304000, 361000, 408000, 446000, 484000, 520000, 600000), CORE_DVFS("2d", 2, 1, KHZ, 1, 267000, 304000, 361000, 408000, 446000, 484000, 520000, 600000), CORE_DVFS("epp", 2, 1, KHZ, 1, 267000, 304000, 361000, 408000, 446000, 484000, 520000, 600000), CORE_DVFS("3d", 2, 1, KHZ, 1, 247000, 304000, 361000, 408000, 446000, 484000, 520000, 600000), CORE_DVFS("3d2", 2, 1, KHZ, 1, 247000, 304000, 361000, 408000, 446000, 484000, 520000, 600000), CORE_DVFS("se", 2, 1, KHZ, 1, 267000, 304000, 361000, 408000, 446000, 484000, 520000, 600000), CORE_DVFS("vde", 3, 1, KHZ, 1, 1, 1, 1, 1, 1, 484000, 484000, 484000), CORE_DVFS("mpe", 3, 1, KHZ, 1, 1, 1, 1, 1, 1, 484000, 484000, 484000), CORE_DVFS("2d", 3, 1, KHZ, 1, 1, 1, 1, 1, 1, 484000, 484000, 484000), CORE_DVFS("epp", 3, 1, KHZ, 1, 1, 1, 1, 1, 1, 484000, 484000, 484000), CORE_DVFS("3d", 3, 1, KHZ, 1, 1, 1, 1, 1, 1, 484000, 484000, 484000), CORE_DVFS("3d2", 3, 1, KHZ, 1, 1, 1, 1, 1, 1, 484000, 484000, 484000), CORE_DVFS("se", 3, 1, KHZ, 1, 1, 1, 1, 1, 1, 625000, 625000, 625000), CORE_DVFS("host1x", 0, 1, KHZ, 1, 152000, 188000, 222000, 254000, 267000, 267000, 267000, 267000), CORE_DVFS("host1x", 1, 1, KHZ, 1, 152000, 188000, 222000, 254000, 267000, 267000, 267000, 267000), CORE_DVFS("host1x", 2, 1, KHZ, 1, 152000, 188000, 222000, 254000, 267000, 267000, 267000, 300000), CORE_DVFS("host1x", 3, 1, KHZ, 1, 1, 1, 1, 1, 1, 242000, 242000, 242000), CORE_DVFS("cbus", 0, 1, KHZ, 1, 228000, 275000, 332000, 380000, 416000, 416000, 416000, 416000), CORE_DVFS("cbus", 1, 1, KHZ, 1, 267000, 304000, 380000, 416000, 484000, 484000, 484000, 484000), CORE_DVFS("cbus", 2, 1, KHZ, 1, 247000, 304000, 352000, 400000, 437000, 484000, 520000, 600000), CORE_DVFS("cbus", 3, 1, KHZ, 1, 484000, 484000, 484000, 484000, 484000, 484000, 484000, 484000), CORE_DVFS("pll_c", -1, 1, KHZ, 533000, 667000, 667000, 800000, 800000, 1066000, 1066000, 1066000, 1200000), /* * PLLM dvfs is common across all speedo IDs with one special exception * for T30 and T33, rev A02+, provided PLLM usage is restricted. Both * common and restricted table are included, and table selection is * handled by is_pllm_dvfs() below. */ CORE_DVFS("pll_m", -1, 1, KHZ, 533000, 667000, 667000, 800000, 800000, 1066000, 1066000, 1066000, 1066000), #ifdef <API key> CORE_DVFS("pll_m", 2, 1, KHZ, 533000, 800000, 800000, 800000, 800000, 1066000, 1066000, 1066000, 1066000), #endif /* Core voltages (mV): 950, 1000, 1050, 1100, 1150, 1200, 1250, 1300, 1350 */ /* Clock limits for I/O peripherals */ CORE_DVFS("mipi", 0, 1, KHZ, 1, 1, 1, 1, 1, 1, 1, 1, 1), CORE_DVFS("mipi", 1, 1, KHZ, 1, 1, 1, 1, 1, 60000, 60000, 60000, 60000), CORE_DVFS("mipi", 2, 1, KHZ, 1, 1, 1, 1, 1, 60000, 60000, 60000, 60000), CORE_DVFS("mipi", 3, 1, KHZ, 1, 1, 1, 1, 1, 1, 1, 1, 1), CORE_DVFS("fuse_burn", -1, 1, KHZ, 1, 1, 1, 1, 26000, 26000, 26000, 26000, 26000), CORE_DVFS("sdmmc1", -1, 1, KHZ, 104000, 104000, 104000, 104000, 104000, 208000, 208000, 208000, 208000), CORE_DVFS("sdmmc3", -1, 1, KHZ, 104000, 104000, 104000, 104000, 104000, 208000, 208000, 208000, 208000), CORE_DVFS("ndflash", -1, 1, KHZ, 1, 120000, 120000, 120000, 200000, 200000, 200000, 200000, 200000), CORE_DVFS("nor", 0, 1, KHZ, 1, 115000, 130000, 130000, 133000, 133000, 133000, 133000, 133000), CORE_DVFS("nor", 1, 1, KHZ, 1, 115000, 130000, 130000, 133000, 133000, 133000, 133000, 133000), CORE_DVFS("nor", 2, 1, KHZ, 1, 115000, 130000, 130000, 133000, 133000, 133000, 133000, 133000), CORE_DVFS("nor", 3, 1, KHZ, 1, 1, 1, 1, 1, 1, 108000, 108000, 108000), CORE_DVFS("sbc1", -1, 1, KHZ, 1, 52000, 60000, 60000, 60000, 100000, 100000, 100000, 100000), CORE_DVFS("sbc2", -1, 1, KHZ, 1, 52000, 60000, 60000, 60000, 100000, 100000, 100000, 100000), CORE_DVFS("sbc3", -1, 1, KHZ, 1, 52000, 60000, 60000, 60000, 100000, 100000, 100000, 100000), CORE_DVFS("sbc4", -1, 1, KHZ, 1, 52000, 60000, 60000, 60000, 100000, 100000, 100000, 100000), CORE_DVFS("sbc5", -1, 1, KHZ, 1, 52000, 60000, 60000, 60000, 100000, 100000, 100000, 100000), CORE_DVFS("sbc6", -1, 1, KHZ, 1, 52000, 60000, 60000, 60000, 100000, 100000, 100000, 100000), CORE_DVFS("usbd", -1, 1, KHZ, 1, 480000, 480000, 480000, 480000, 480000, 480000, 480000, 480000), CORE_DVFS("usb2", -1, 1, KHZ, 1, 480000, 480000, 480000, 480000, 480000, 480000, 480000, 480000), CORE_DVFS("usb3", -1, 1, KHZ, 1, 480000, 480000, 480000, 480000, 480000, 480000, 480000, 480000), CORE_DVFS("sata", -1, 1, KHZ, 1, 216000, 216000, 216000, 216000, 216000, 216000, 216000, 216000), CORE_DVFS("sata_oob", -1, 1, KHZ, 1, 216000, 216000, 216000, 216000, 216000, 216000, 216000, 216000), CORE_DVFS("pcie", -1, 1, KHZ, 1, 250000, 250000, 250000, 250000, 250000, 250000, 250000, 250000), CORE_DVFS("afi", -1, 1, KHZ, 1, 250000, 250000, 250000, 250000, 250000, 250000, 250000, 250000), CORE_DVFS("pll_e", -1, 1, KHZ, 1, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000), CORE_DVFS("tvdac", -1, 1, KHZ, 1, 220000, 220000, 220000, 220000, 220000, 220000, 220000, 220000), CORE_DVFS("tvo", -1, 1, KHZ, 1, 1, 297000, 297000, 297000, 297000, 297000, 297000, 297000), CORE_DVFS("cve", -1, 1, KHZ, 1, 1, 297000, 297000, 297000, 297000, 297000, 297000, 297000), CORE_DVFS("dsia", -1, 1, KHZ, 1, 275000, 275000, 275000, 275000, 275000, 275000, 275000, 275000), CORE_DVFS("dsib", -1, 1, KHZ, 1, 275000, 275000, 275000, 275000, 275000, 275000, 275000, 275000), CORE_DVFS("hdmi", -1, 1, KHZ, 1, 148500, 148500, 148500, 148500, 148500, 148500, 148500, 148500), /* * The clock rate for the display controllers that determines the * necessary core voltage depends on a divider that is internal * to the display block. Disable auto-dvfs on the display clocks, * and let the display driver call tegra_dvfs_set_rate manually */ CORE_DVFS("disp1", 0, 0, KHZ, 1, 120000, 120000, 120000, 120000, 190000, 190000, 190000, 190000), CORE_DVFS("disp1", 1, 0, KHZ, 1, 155000, 268000, 268000, 268000, 268000, 268000, 268000, 268000), CORE_DVFS("disp1", 2, 0, KHZ, 1, 155000, 268000, 268000, 268000, 268000, 268000, 268000, 268000), CORE_DVFS("disp1", 3, 0, KHZ, 1, 120000, 120000, 120000, 120000, 190000, 190000, 190000, 190000), CORE_DVFS("disp2", 0, 0, KHZ, 1, 120000, 120000, 120000, 120000, 190000, 190000, 190000, 190000), CORE_DVFS("disp2", 1, 0, KHZ, 1, 155000, 268000, 268000, 268000, 268000, 268000, 268000, 268000), CORE_DVFS("disp2", 2, 0, KHZ, 1, 155000, 268000, 268000, 268000, 268000, 268000, 268000, 268000), CORE_DVFS("disp2", 3, 0, KHZ, 1, 120000, 120000, 120000, 120000, 190000, 190000, 190000, 190000), CORE_DVFS("pwm", -1, 1, KHZ, 1, 408000, 408000, 408000, 408000, 408000, 408000, 408000, 408000), CORE_DVFS("spdif_out", -1, 1, KHZ, 1, 26000, 26000, 26000, 26000, 26000, 26000, 26000, 26000), }; int <API key>(const char *arg, const struct kernel_param *kp) { int ret; ret = param_set_bool(arg, kp); if (ret) return ret; if (<API key>) <API key>(&<API key>); else <API key>(&<API key>); return 0; } int <API key>(const char *arg, const struct kernel_param *kp) { int ret; ret = param_set_bool(arg, kp); if (ret) return ret; if (<API key>) <API key>(&<API key>); else <API key>(&<API key>); return 0; } int <API key>(char *buffer, const struct kernel_param *kp) { return param_get_bool(buffer, kp); } static struct kernel_param_ops <API key> = { .set = <API key>, .get = <API key>, }; static struct kernel_param_ops <API key> = { .set = <API key>, .get = <API key>, }; module_param_cb(disable_core, &<API key>, &<API key>, 0644); module_param_cb(disable_cpu, &<API key>, &<API key>, 0644); static bool __init is_pllm_dvfs(struct clk *c, struct dvfs *d) { #ifdef <API key> /* Do not apply common PLLM dvfs table on T30, T33, T37 rev A02+ and do not apply restricted PLLM dvfs table for other SKUs/revs */ int cpu = tegra_cpu_speedo_id(); if (((cpu == 2) || (cpu == 5) || (cpu == 13)) == (d->speedo_id == -1)) return false; #endif /* Check if PLLM boot frequency can be applied to clock tree at minimum voltage. If yes, no need to enable dvfs on PLLM */ if (<API key>(c) <= d->freqs[0] * d->freqs_mult) return false; return true; } static void __init init_dvfs_one(struct dvfs *d, int nominal_mv_index) { int ret; struct clk *c = <API key>(d->clk_name); if (!c) { pr_debug("tegra3_dvfs: no clock found for %s\n", d->clk_name); return; } /* * Update max rate for auto-dvfs clocks, except EMC. * EMC is a special case, since EMC dvfs is board dependent: max rate * and EMC scaling frequencies are determined by tegra BCT (flashed * together with the image) and board specific EMC DFS table; we will * check the scaling ladder against nominal core voltage when the table * is loaded (and if on particular board the table is not loaded, EMC * scaling is disabled). */ if (!(c->flags & PERIPH_EMC_ENB) && d->auto_dvfs) { BUG_ON(!d->freqs[nominal_mv_index]); tegra_init_max_rate( c, d->freqs[nominal_mv_index] * d->freqs_mult); } d->max_millivolts = d->dvfs_rail->nominal_millivolts; /* * Check if we may skip enabling dvfs on PLLM. PLLM is a special case, * since its frequency never exceeds boot rate, and configuration with * restricted PLLM usage is possible. */ if (!(c->flags & PLLM) || is_pllm_dvfs(c, d)) { ret = <API key>(c, d); if (ret) pr_err("tegra3_dvfs: failed to enable dvfs on %s\n", c->name); } } static void __init init_dvfs_cold(struct dvfs *d, int nominal_mv_index) { int i; unsigned long offs; BUG_ON((nominal_mv_index == 0) || (nominal_mv_index > d->num_freqs)); for (i = 0; i < d->num_freqs; i++) { offs = cpu_cold_offs_mhz[i] * MHZ; if (i > nominal_mv_index) d->alt_freqs[i] = d->alt_freqs[i - 1]; else if (d->freqs[i] > offs) d->alt_freqs[i] = d->freqs[i] - offs; else { d->alt_freqs[i] = d->freqs[i]; pr_warn("tegra3_dvfs: cold offset %lu is too high for" " regular dvfs limit %lu\n", offs, d->freqs[i]); } if (i) BUG_ON(d->alt_freqs[i] < d->alt_freqs[i - 1]); } d->alt_freqs_state = ALT_FREQS_DISABLED; } static bool __init match_dvfs_one(struct dvfs *d, int speedo_id, int process_id) { if ((d->process_id != -1 && d->process_id != process_id) || (d->speedo_id != -1 && d->speedo_id != speedo_id)) { pr_debug("tegra3_dvfs: rejected %s speedo %d," " process %d\n", d->clk_name, d->speedo_id, d->process_id); return false; } return true; } static int __init <API key>( int speedo_id, int process_id, struct dvfs **cpu_dvfs) { int i, j, mv; struct dvfs *d; struct clk *c; /* * Find maximum cpu voltage that satisfies cpu_to_core dependency for * nominal core voltage ("solve from cpu to core at nominal"). Clip * result to the nominal cpu level for the chips with this speedo_id. */ mv = <API key>.nominal_millivolts; for (i = 0; i < MAX_DVFS_FREQS; i++) { if ((cpu_millivolts[i] == 0) || <API key>(cpu_millivolts[i]) > mv) break; } BUG_ON(i == 0); mv = cpu_millivolts[i - 1]; BUG_ON(mv < <API key>.min_millivolts); mv = min(mv, tegra_cpu_speedo_mv()); /* * Find matching cpu dvfs entry, and use it to determine index to the * final nominal voltage, that satisfies the following requirements: * - allows CPU to run at minimum of the maximum rates specified in * the dvfs entry and clock tree * - does not violate cpu_to_core dependency as determined above */ for (i = 0, j = 0; j < ARRAY_SIZE(cpu_dvfs_table); j++) { d = &cpu_dvfs_table[j]; if (match_dvfs_one(d, speedo_id, process_id)) { c = <API key>(d->clk_name); BUG_ON(!c); for (; i < MAX_DVFS_FREQS; i++) { if ((d->freqs[i] == 0) || (cpu_millivolts[i] == 0) || (mv < cpu_millivolts[i])) break; if (c->max_rate <= d->freqs[i]*d->freqs_mult) { i++; break; } } break; } } BUG_ON(i == 0); if (j == (ARRAY_SIZE(cpu_dvfs_table) - 1)) pr_err("tegra3_dvfs: WARNING!!!\n" "tegra3_dvfs: no cpu dvfs table found for chip speedo_id" " %d and process_id %d: set CPU rate limit at %lu\n" "tegra3_dvfs: WARNING!!!\n", speedo_id, process_id, d->freqs[i-1] * d->freqs_mult); *cpu_dvfs = d; return (i - 1); } static int __init <API key>(int speedo_id) { int i; int mv = <API key>(); int core_edp_limit = get_core_edp(); /* * Start with nominal level for the chips with this speedo_id. Then, * make sure core nominal voltage is below edp limit for the board * (if edp limit is set). */ if (core_edp_limit) mv = min(mv, core_edp_limit); /* Round nominal level down to the nearest core scaling step */ for (i = 0; i < MAX_DVFS_FREQS; i++) { if ((core_millivolts[i] == 0) || (mv < core_millivolts[i])) break; } if (i == 0) { pr_err("tegra3_dvfs: unable to adjust core dvfs table to" " nominal voltage %d\n", mv); return -ENOSYS; } return (i - 1); } void __init tegra_soc_init_dvfs(void) { int cpu_speedo_id = tegra_cpu_speedo_id(); int soc_speedo_id = tegra_soc_speedo_id(); int cpu_process_id = <API key>(); int core_process_id = <API key>(); int i; int <API key>; int <API key>; #ifndef <API key> <API key> = true; #endif #ifndef <API key> <API key> = true; #endif /* * Find nominal voltages for core (1st) and cpu rails before rail * init. Nominal voltage index in the scaling ladder will also be * used to determine max dvfs frequency for the respective domains. */ <API key> = <API key>(soc_speedo_id); if (<API key> < 0) { <API key>.disabled = true; <API key> = true; <API key> = 0; } <API key>.nominal_millivolts = core_millivolts[<API key>]; <API key> = <API key>( cpu_speedo_id, cpu_process_id, &cpu_dvfs); BUG_ON((<API key> < 0) || (!cpu_dvfs)); <API key>.nominal_millivolts = cpu_millivolts[<API key>]; /* Init rail structures and dependencies */ <API key>(tegra3_dvfs_rails, ARRAY_SIZE(tegra3_dvfs_rails)); <API key>(<API key>, ARRAY_SIZE(<API key>)); /* Search core dvfs table for speedo/process matching entries and initialize dvfs-ed clocks */ for (i = 0; i < ARRAY_SIZE(core_dvfs_table); i++) { struct dvfs *d = &core_dvfs_table[i]; if (!match_dvfs_one(d, soc_speedo_id, core_process_id)) continue; init_dvfs_one(d, <API key>); } /* Initialize matching cpu dvfs entry already found when nominal voltage was determined */ init_dvfs_one(cpu_dvfs, <API key>); init_dvfs_cold(cpu_dvfs, <API key>); /* Finally disable dvfs on rails if necessary */ if (<API key>) <API key>(&<API key>); if (<API key>) <API key>(&<API key>); pr_info("tegra dvfs: VDD_CPU nominal %dmV, scaling %s\n", <API key>.nominal_millivolts, <API key> ? "disabled" : "enabled"); pr_info("tegra dvfs: VDD_CORE nominal %dmV, scaling %s\n", <API key>.nominal_millivolts, <API key> ? "disabled" : "enabled"); } void <API key>(int edp_thermal_index, bool before_clk_update) { bool enable = !edp_thermal_index; if (enable != before_clk_update) { int ret = <API key>(cpu_dvfs, enable); WARN_ONCE(ret, "tegra dvfs: failed to set CPU alternative" " frequency limits for cold temeperature\n"); } } int <API key>(struct dvfs_rail *rail) { int ret = 0; if (<API key>() != DRAM_TYPE_DDR3) return ret; if (((&<API key> == rail) && (rail->nominal_millivolts > <API key>)) || ((&<API key> == rail) && (<API key>(rail->nominal_millivolts) > <API key>))) { struct clk *bridge = <API key>("bridge.emc"); BUG_ON(!bridge); ret = clk_enable(bridge); pr_info("%s: %s: %s bridge.emc\n", __func__, rail->reg_id, ret ? "failed to enable" : "enabled"); } return ret; } int <API key>(struct dvfs_rail *rail) { if (<API key>() != DRAM_TYPE_DDR3) return 0; if (((&<API key> == rail) && (rail->nominal_millivolts > <API key>)) || ((&<API key> == rail) && (<API key>(rail->nominal_millivolts) > <API key>))) { struct clk *bridge = <API key>("bridge.emc"); BUG_ON(!bridge); clk_disable(bridge); pr_info("%s: %s: disabled bridge.emc\n", __func__, rail->reg_id); } return 0; } /* * sysfs and dvfs interfaces to cap tegra core domains frequencies */ static DEFINE_MUTEX(core_cap_lock); struct core_cap { int refcnt; int level; }; static struct core_cap tegra3_core_cap; static struct core_cap kdvfs_core_cap; static struct core_cap user_core_cap; static struct kobject *cap_kobj; /* Arranged in order required for enabling/lowering the cap */ static struct { const char *cap_name; struct clk *cap_clk; unsigned long freqs[MAX_DVFS_FREQS]; } core_cap_table[] = { { .cap_name = "cap.cbus" }, { .cap_name = "cap.sclk" }, { .cap_name = "cap.emc" }, }; static void core_cap_level_set(int level) { int i, j; for (j = 0; j < ARRAY_SIZE(core_millivolts); j++) { int v = core_millivolts[j]; if ((v == 0) || (level < v)) break; } j = (j == 0) ? 0 : j - 1; level = core_millivolts[j]; if (level < tegra3_core_cap.level) { for (i = 0; i < ARRAY_SIZE(core_cap_table); i++) if (core_cap_table[i].cap_clk) clk_set_rate(core_cap_table[i].cap_clk, core_cap_table[i].freqs[j]); } else if (level > tegra3_core_cap.level) { for (i = ARRAY_SIZE(core_cap_table) - 1; i >= 0; i if (core_cap_table[i].cap_clk) clk_set_rate(core_cap_table[i].cap_clk, core_cap_table[i].freqs[j]); } tegra3_core_cap.level = level; } static void core_cap_update(void) { int new_level = <API key>.max_millivolts; if (kdvfs_core_cap.refcnt) new_level = min(new_level, kdvfs_core_cap.level); if (user_core_cap.refcnt) new_level = min(new_level, user_core_cap.level); if (tegra3_core_cap.level != new_level) core_cap_level_set(new_level); } static void core_cap_enable(bool enable) { int i; if (enable) { tegra3_core_cap.refcnt++; if (tegra3_core_cap.refcnt == 1) for (i = 0; i < ARRAY_SIZE(core_cap_table); i++) if (core_cap_table[i].cap_clk) clk_enable(core_cap_table[i].cap_clk); } else if (tegra3_core_cap.refcnt) { tegra3_core_cap.refcnt if (tegra3_core_cap.refcnt == 0) for (i = ARRAY_SIZE(core_cap_table) - 1; i >= 0; i if (core_cap_table[i].cap_clk) clk_disable(core_cap_table[i].cap_clk); } core_cap_update(); } static ssize_t core_cap_state_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { return sprintf(buf, "%d (%d)\n", tegra3_core_cap.refcnt ? 1 : 0, user_core_cap.refcnt ? 1 : 0); } static ssize_t <API key>(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { int state; if (sscanf(buf, "%d", &state) != 1) return -1; mutex_lock(&core_cap_lock); if (state) { user_core_cap.refcnt++; if (user_core_cap.refcnt == 1) core_cap_enable(true); } else if (user_core_cap.refcnt) { user_core_cap.refcnt if (user_core_cap.refcnt == 0) core_cap_enable(false); } mutex_unlock(&core_cap_lock); return count; } static ssize_t core_cap_level_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { return sprintf(buf, "%d (%d)\n", tegra3_core_cap.level, user_core_cap.level); } static ssize_t <API key>(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { int level; if (sscanf(buf, "%d", &level) != 1) return -1; mutex_lock(&core_cap_lock); user_core_cap.level = level; core_cap_update(); mutex_unlock(&core_cap_lock); return count; } static struct kobj_attribute cap_state_attribute = __ATTR(core_cap_state, 0644, core_cap_state_show, <API key>); static struct kobj_attribute cap_level_attribute = __ATTR(core_cap_level, 0644, core_cap_level_show, <API key>); const struct attribute *cap_attributes[] = { &cap_state_attribute.attr, &cap_level_attribute.attr, NULL, }; void <API key>(bool enable) { mutex_lock(&core_cap_lock); if (enable) { kdvfs_core_cap.refcnt++; if (kdvfs_core_cap.refcnt == 1) core_cap_enable(true); } else if (kdvfs_core_cap.refcnt) { kdvfs_core_cap.refcnt if (kdvfs_core_cap.refcnt == 0) core_cap_enable(false); } mutex_unlock(&core_cap_lock); } void <API key>(int level) { mutex_lock(&core_cap_lock); kdvfs_core_cap.level = level; core_cap_update(); mutex_unlock(&core_cap_lock); } static int __init init_core_cap_one(struct clk *c, unsigned long *freqs) { int i, v, next_v; unsigned long rate, next_rate = 0; for (i = 0; i < ARRAY_SIZE(core_millivolts); i++) { v = core_millivolts[i]; if (v == 0) break; for (;;) { rate = next_rate; next_rate = clk_round_rate(c, rate + 1000); if (IS_ERR_VALUE(next_rate)) { pr_debug("tegra3_dvfs: failed to round %s" " rate %lu", c->name, rate); return -EINVAL; } if (rate == next_rate) break; next_v = <API key>( c->parent, next_rate); if (IS_ERR_VALUE(next_rate)) { pr_debug("tegra3_dvfs: failed to predict %s mV" " for rate %lu", c->name, next_rate); return -EINVAL; } if (next_v > v) break; } if (rate == 0) { rate = next_rate; pr_warn("tegra3_dvfs: minimum %s rate %lu requires" " %d mV", c->name, rate, next_v); } freqs[i] = rate; next_rate = rate; } return 0; } static int __init <API key>(void) { int i; struct clk *c = NULL; tegra3_core_cap.level = kdvfs_core_cap.level = user_core_cap.level = <API key>.max_millivolts; for (i = 0; i < ARRAY_SIZE(core_cap_table); i++) { c = <API key>(core_cap_table[i].cap_name); if (!c || !c->parent || init_core_cap_one(c, core_cap_table[i].freqs)) { pr_err("tegra3_dvfs: failed to initialize %s frequency" " table", core_cap_table[i].cap_name); continue; } core_cap_table[i].cap_clk = c; } cap_kobj = <API key>("tegra_cap", kernel_kobj); if (!cap_kobj) { pr_err("tegra3_dvfs: failed to create sysfs cap object"); return 0; } if (sysfs_create_files(cap_kobj, cap_attributes)) { pr_err("tegra3_dvfs: failed to create sysfs cap interface"); return 0; } pr_info("tegra dvfs: tegra sysfs cap interface is initialized\n"); return 0; } late_initcall(<API key>);
<?php class UsuarioController extends Controller { /** * @var string the default layout for the views. Defaults to '//layouts/column2', meaning * using two-column layout. See 'protected/views/layouts/column2.php'. */ public $layout='//layouts/column2'; /** * @return array action filters */ public function filters() { return array( 'accessControl', // perform access control for CRUD operations 'postOnly + delete', // we only allow deletion via POST request ); } /** * Specifies the access control rules. * This method is used by the 'accessControl' filter. * @return array access control rules */ public function accessRules() { return array( array('allow', // allow all users to perform 'index' and 'view' actions 'actions'=>array('index','view'), 'users'=>array('*'), ), array('allow', // allow authenticated user to perform 'create' and 'update' actions 'actions'=>array('create','update'), 'users'=>array('@'), ), array('allow', // allow admin user to perform 'admin' and 'delete' actions 'actions'=>array('admin','delete'), 'users'=>array('admin'), ), array('deny', // deny all users 'users'=>array('*'), ), ); } /** * Displays a particular model. * @param integer $id the ID of the model to be displayed */ public function actionView($id) { $this->render('view',array( 'model'=>$this->loadModel($id), )); } /** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model=new Usuario; // Uncomment the following line if AJAX validation is needed // $this-><API key>($model); if(isset($_POST['Usuario'])) { $model->attributes=$_POST['Usuario']; if($model->save()) $this->redirect(array('view','id'=>$model->id)); } $this->render('create',array( 'model'=>$model, )); } /** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model=$this->loadModel($id); // Uncomment the following line if AJAX validation is needed $this-><API key>($model); if(isset($_POST['Usuario'])) { $model->attributes=$_POST['Usuario']; if($model->save()) $this->redirect(array('view','id'=>$model->id)); } $this->render('update',array( 'model'=>$model, )); } /** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'admin' page. * @param integer $id the ID of the model to be deleted */ public function actionDelete($id) { $this->loadModel($id)->delete(); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if(!isset($_GET['ajax'])) $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); } /** * Lists all models. */ public function actionIndex() { $dataProvider=new CActiveDataProvider('Usuario'); $this->render('index',array( 'dataProvider'=>$dataProvider, )); } /** * Manages all models. */ public function actionAdmin() { $model=new Usuario('search'); $model->unsetAttributes(); // clear any default values if(isset($_GET['Usuario'])) $model->attributes=$_GET['Usuario']; $this->render('admin',array( 'model'=>$model, )); } /** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model=Usuario::model()->findByPk($id); if($model===null) throw new CHttpException(404,'The requested page does not exist.'); return $model; } /** * Performs the AJAX validation. * @param CModel the model to be validated */ protected function <API key>($model) { if(isset($_POST['ajax']) && $_POST['ajax']==='usuario-form') { echo CActiveForm::validate($model); Yii::app()->end(); } } }
/** * @file id_10361.c * @brief AOAPC I 10361 * @author chenxilinsidney * @version 1.0 * @date 2015-03-24 */ #include <stdio.h> #include <string.h> #define MAX_LINE_LENGTH 101 char line[2][MAX_LINE_LENGTH]; int main() { int num_case; scanf("%d\n", &num_case); while (num_case gets(*line); gets(*(line+ 1)); int line_length_a = strlen(*line); int line_length_b = strlen(*(line + 1)); int line_index = 0; int char_position[4] = {0}; int position_index = 0; /* output first line */ while (line_index < line_length_a) { int character = line[0][line_index]; if (character != '<' && character != '>') putchar(character); else char_position[position_index++] = line_index; line_index++; } printf("\n"); /* output second line */ line[1][line_length_b - 3] = '\0'; printf("%s", line[1]); for (position_index = 2; position_index >= 0; position_index for (line_index = char_position[position_index] + 1; line_index < char_position[position_index + 1]; line_index++) putchar(line[0][line_index]); printf("%s", line[0] + char_position[3] + 1); printf("\n"); } return 0; }
#! /usr/bin/env python from __future__ import print_function import StringIO import os import os.path import errno import sqlite3 from nose.tools import * import smadata2.db import smadata2.db.mock from smadata2 import check def removef(filename): try: os.remove(filename) except OSError as e: if e.errno != errno.ENOENT: raise class BaseDBChecker(object): def setUp(self): self.db = self.opendb() self.sample_data() def tearDown(self): pass def sample_data(self): pass class MockDBChecker(BaseDBChecker): def opendb(self): return smadata2.db.mock.MockDatabase() class BaseSQLite(object): def prepare_sqlite(self): self.dbname = "__testdb__smadata2_%s_.sqlite" % self.__class__.__name__ self.bakname = self.dbname + ".bak" # Start with a blank slate removef(self.dbname) removef(self.bakname) self.prepopulate() if os.path.exists(self.dbname): self.original = open(self.dbname).read() else: self.original = None def prepopulate(self): pass class SQLiteDBChecker(BaseSQLite, BaseDBChecker): def opendb(self): self.prepare_sqlite() return smadata2.db.sqlite.create_or_update(self.dbname) def tearDown(self): removef(self.dbname) removef(self.bakname) super(SQLiteDBChecker, self).tearDown() class SimpleChecks(BaseDBChecker): def test_trivial(self): assert isinstance(self.db, smadata2.db.base.BaseDatabase) def <API key>(self): # Serial is defined as INTEGER, but we abuse the fact that # sqlite doesn't actually make a distinction serial = "__TEST__" self.db.add_historic(serial, 0, 0) self.db.add_historic(serial, 300, 10) self.db.add_historic(serial, 3600, 20) v0 = self.db.get_one_historic(serial, 0) assert_equals(v0, 0) v300 = self.db.get_one_historic(serial, 300) assert_equals(v300, 10) v3600 = self.db.get_one_historic(serial, 3600) assert_equals(v3600, 20) vmissing = self.db.get_one_historic(serial, 9999) assert vmissing is None def <API key>(self): serial = "__TEST__" last = self.db.get_last_historic(serial) assert last is None def <API key>(self): serial = "__TEST__" self.db.add_historic(serial, 0, 0) assert_equals(self.db.get_last_historic(serial), 0) self.db.add_historic(serial, 300, 0) assert_equals(self.db.get_last_historic(serial), 300) self.db.add_historic(serial, 3600, 0) assert_equals(self.db.get_last_historic(serial), 3600) self.db.add_historic(serial, 2000, 0) assert_equals(self.db.get_last_historic(serial), 3600) class AggregateChecks(BaseDBChecker): def sample_data(self): super(AggregateChecks, self).sample_data() self.serial1 = "__TEST__1" self.serial2 = "__TEST__2" self.dawn = 8*3600 self.dusk = 20*3600 sampledata = check.generate_linear(0, self.dawn, self.dusk, 24*3600, 0, 1) for ts, y in sampledata: self.db.add_historic(self.serial1, ts, y) self.db.add_historic(self.serial2, ts, 2*y) def test_basic(self): for ts in range(0, self.dawn, 300): y1 = self.db.get_one_historic(self.serial1, ts) y2 = self.db.get_one_historic(self.serial2, ts) assert_equals(y1, 0) assert_equals(y2, 0) for i, ts in enumerate(range(self.dawn, self.dusk, 300)): y1 = self.db.get_one_historic(self.serial1, ts) y2 = self.db.get_one_historic(self.serial2, ts) assert_equals(y1, i) assert_equals(y2, 2*i) val = (self.dusk - self.dawn - 1) / 300 for ts in range(self.dusk, 24*3600, 300): y1 = self.db.get_one_historic(self.serial1, ts) y2 = self.db.get_one_historic(self.serial2, ts) assert_equals(y1, val) assert_equals(y2, 2*val) def test_aggregate_one(self): val = self.db.<API key>(self.dusk, (self.serial1, self.serial2)) assert_equals(val, 3*((self.dusk - self.dawn - 2) / 300)) def <API key>(self, from_, to_): results = self.db.<API key>(from_, to_, (self.serial1, self.serial2)) first = results[0][0] last = results[-1][0] assert_equals(first, from_) assert_equals(last, to_ - 300) for ts, y in results: if ts < self.dawn: assert_equals(y, 0) elif ts < self.dusk: assert_equals(y, 3*((ts - self.dawn) / 300)) else: assert_equals(y, 3*((self.dusk - self.dawn - 1) / 300)) def test_aggregate(self): yield self.<API key>, 0, 24*3600 yield self.<API key>, 8*3600, 20*3600 yield self.<API key>, 13*3600, 14*3600 # Construct the basic tests as a cross-product for cset in (SimpleChecks, AggregateChecks): for db in (MockDBChecker, SQLiteDBChecker): name = "_".join(("Test", cset.__name__, db.__name__)) globals()[name] = type(name, (cset, db), {}) # Tests for sqlite schema updating class UpdateSQLiteChecker(<API key>): PRESERVE_RECORD = ("PRESERVE", 0, 31415) def test_backup(self): assert os.path.exists(self.bakname) backup = open(self.bakname).read() assert_equals(self.original, backup) def test_preserved(self): serial, timestamp, tyield = self.PRESERVE_RECORD assert_equals(self.db.get_last_historic(serial), timestamp) assert_equals(self.db.get_one_historic(serial, timestamp), tyield) class TestUpdateNoPVO(UpdateSQLiteChecker): def prepopulate(self): DB_MAGIC = 0x71534d41 DB_VERSION = 0 conn = sqlite3.connect(self.dbname) conn.executescript(""" CREATE TABLE generation (inverter_serial INTEGER, timestamp INTEGER, total_yield INTEGER, PRIMARY KEY (inverter_serial, timestamp)); CREATE TABLE schema (magic INTEGER, version INTEGER);""") conn.execute("INSERT INTO schema (magic, version) VALUES (?, ?)", (DB_MAGIC, DB_VERSION)) conn.commit() conn.execute("""INSERT INTO generation (inverter_serial, timestamp, total_yield) VALUES (?, ?, ?)""", self.PRESERVE_RECORD) conn.commit() del conn class TestUpdateV0(UpdateSQLiteChecker): def prepopulate(self): DB_MAGIC = 0x71534d41 DB_VERSION = 0 conn = sqlite3.connect(self.dbname) conn.executescript(""" CREATE TABLE generation (inverter_serial INTEGER, timestamp INTEGER, total_yield INTEGER, PRIMARY KEY (inverter_serial, timestamp)); CREATE TABLE schema (magic INTEGER, version INTEGER); CREATE TABLE pvoutput (sid STRING, <API key> INTEGER);""") conn.execute("INSERT INTO schema (magic, version) VALUES (?, ?)", (DB_MAGIC, DB_VERSION)) conn.commit() conn.execute("""INSERT INTO generation (inverter_serial, timestamp, total_yield) VALUES (?, ?, ?)""", self.PRESERVE_RECORD) conn.commit() del conn class <API key>(BaseSQLite): def setUp(self): self.prepare_sqlite() @raises(smadata2.db.WrongSchema) def test_open(self): self.db = smadata2.db.SQLiteDatabase(self.dbname) class TestEmptySQLiteDB(<API key>): """Check that we correctly fail on an empty DB""" def test_is_empty(self): assert not os.path.exists(self.dbname) class TestBadSQLite(<API key>): """Check that we correctly fail attempting to update an unknwon format""" def prepopulate(self): conn = sqlite3.connect(self.dbname) conn.execute("CREATE TABLE unrelated (random STRING, data INTEGER)") conn.commit() del conn @raises(smadata2.db.WrongSchema) def test_update(self): db = smadata2.db.sqlite.create_or_update(self.dbname)
# Makefile.in generated automatically by automake 1.5 from Makefile.am. # Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # PARTICULAR PURPOSE. SHELL = /bin/sh srcdir = . top_srcdir = .. prefix = /usr/local exec_prefix = ${prefix} bindir = ${exec_prefix}/bin sbindir = ${exec_prefix}/sbin libexecdir = ${exec_prefix}/libexec datadir = ${prefix}/share sysconfdir = ${prefix}/etc sharedstatedir = ${prefix}/com localstatedir = ${prefix}/var libdir = ${exec_prefix}/lib infodir = ${prefix}/info mandir = ${prefix}/man includedir = ${prefix}/include oldincludedir = /usr/include pkgdatadir = $(datadir)/scout pkglibdir = $(libdir)/scout pkgincludedir = $(includedir)/scout top_builddir = .. ACLOCAL = ${SHELL} /Users/mk/code/scout-0.86/utils/missing --run aclocal AUTOCONF = ${SHELL} /Users/mk/code/scout-0.86/utils/missing --run autoconf AUTOMAKE = ${SHELL} /Users/mk/code/scout-0.86/utils/missing --run automake AUTOHEADER = ${SHELL} /Users/mk/code/scout-0.86/utils/missing --run autoheader INSTALL = /usr/bin/install -c INSTALL_PROGRAM = ${INSTALL} INSTALL_DATA = ${INSTALL} -m 644 INSTALL_SCRIPT = ${INSTALL} INSTALL_HEADER = $(INSTALL_DATA) transform = s,x,x, NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : host_alias = host_triplet = i386-apple-darwin14.0.0 AMTAR = ${SHELL} /Users/mk/code/scout-0.86/utils/missing --run tar AS = @AS@ AWK = awk CC = gcc DATE = October-28-2014 DEPDIR = .deps DLLTOOL = @DLLTOOL@ ECHO = /bin/echo EXEEXT = <API key> = ${SHELL} $(install_sh) -c -s LIBTOOL = $(SHELL) $(top_builddir)/libtool LN_S = ln -s OBJDUMP = @OBJDUMP@ OBJEXT = o PACKAGE = scout PLATFORM = apple-i386-darwin14.0.0 RANLIB = ranlib SCOUT_LIBS = SSL_INCLUDE = -I/usr/include/openssl -I/usr/include SSL_LDFLAGS = -L/usr/lib SSL_LIBS = -lssl -lcrypto STRIP = strip VERSION = 0.86 am__include = include am__quote = install_sh = /Users/mk/code/scout-0.86/utils/install-sh AUTOMAKE_OPTIONS = foreign no-dependencies man_MANS = scout.1 SCOUTRC = $(HOME)/.scoutrc EXTRA_DIST = $(man_MANS) scoutrc.in subdir = doc mkinstalldirs = $(SHELL) $(top_srcdir)/utils/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = depcomp = DIST_SOURCES = NROFF = nroff MANS = $(man_MANS) DIST_COMMON = Makefile.am Makefile.in all: all-am .SUFFIXES: mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && \ $(AUTOMAKE) --foreign doc/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) && \ CONFIG_HEADERS= CONFIG_LINKS= \ CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status uninstall-info-am: man1dir = $(mandir)/man1 install-man1: $(man1_MANS) $(man_MANS) @$(NORMAL_INSTALL) $(mkinstalldirs) $(DESTDIR)$(man1dir) @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \ l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ for i in $$l2; do \ case "$$i" in \ *.1*) list="$$list $$i" ;; \ esac; \ done; \ for i in $$list; do \ if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ else file=$$i; fi; \ ext=`echo $$i | sed -e 's/^.*\\. inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$ inst=`echo $$inst | sed -e 's/^.*\ inst=`echo $$inst | sed '$(transform)'`.$$ext; \ echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst"; \ $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst; \ done uninstall-man1: @$(NORMAL_UNINSTALL) @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \ l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ for i in $$l2; do \ case "$$i" in \ *.1*) list="$$list $$i" ;; \ esac; \ done; \ for i in $$list; do \ ext=`echo $$i | sed -e 's/^.*\\. inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$ inst=`echo $$inst | sed -e 's/^.*\ inst=`echo $$inst | sed '$(transform)'`.$$ext; \ echo " rm -f $(DESTDIR)$(man1dir)/$$inst"; \ rm -f $(DESTDIR)$(man1dir)/$$inst; \ done tags: TAGS TAGS: DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) top_distdir = .. distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) @for file in $(DISTFILES); do \ if test -f $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ if test "$$dir" != "$$file" && test "$$dir" != "."; then \ $(mkinstalldirs) "$(distdir)/$$dir"; \ fi; \ if test -d $$d/$$file; then \ cp -pR $$d/$$file $(distdir) \ || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(MANS) installdirs: $(mkinstalldirs) $(DESTDIR)$(man1dir) install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(<API key>)" \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* <API key>: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-am distclean-am: clean-am distclean-generic distclean-libtool dvi: dvi-am dvi-am: info: info-am info-am: install-data-am: install-man install-exec-am: @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) install-exec-hook install-info: install-info-am install-man: install-man1 installcheck-am: maintainer-clean: maintainer-clean-am maintainer-clean-am: distclean-am <API key> mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic mostlyclean-libtool uninstall-am: uninstall-info-am uninstall-man uninstall-man: uninstall-man1 .PHONY: all all-am check check-am clean clean-generic clean-libtool \ distclean distclean-generic distclean-libtool distdir dvi \ dvi-am info info-am install install-am install-data \ install-data-am install-exec install-exec-am install-info \ install-info-am install-man install-man1 install-strip \ installcheck installcheck-am installdirs maintainer-clean \ <API key> mostlyclean mostlyclean-generic \ mostlyclean-libtool uninstall uninstall-am uninstall-info-am \ uninstall-man uninstall-man1 install-exec-hook: @if test -f $(SCOUTRC); then \ if cmp -s $(srcdir)/scoutrc $(SCOUTRC); then echo ""; \ else \ echo ' $(INSTALL_DATA) $(srcdir)/scoutrc $(SCOUTRC).new'; \ $(INSTALL_DATA) $(srcdir)/scoutrc $(SCOUTRC).new; \ echo " echo "WARNING: File $(SCOUTRC) already exists."; \ echo " A new resource file has been installed as"; \ echo " $(SCOUTRC).new. You may want to"; \ echo " consider using the newer version in order to"; \ echo " take advantage of any new features."; \ echo " fi; \ else \ $(INSTALL_DATA) $(srcdir)/scoutrc $(SCOUTRC); \ fi # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT:
import web urls = ( '/hello','Index' ) app = web.application(urls,globals()) render = web.template.render('/usr/local/LPTHW/ex51/gothonweb/templates/',base="layout") class Index(object): def GET(self): return render.hello_form() def POST(self): form = web.input(name="Nobody",greet="Hello") greeting = "%s,%s" % (form.greet,form.name) return render.index(greeting = greeting) if __name__ == '__main__': app.run()
package javax.activation; import java.io.IOException; /** * JavaBeans components that are Activation Framework aware implement * this interface to find out which command verb they're being asked * to perform, and to obtain the DataHandler representing the * data they should operate on. JavaBeans that don't implement * this interface may be used as well. Such commands may obtain * the data using the Externalizable interface, or using an * <API key> method.<p> * * @since 1.6 */ public interface CommandObject { /** * Initialize the Command with the verb it is requested to handle * and the DataHandler that describes the data it will * operate on. <b>NOTE:</b> it is acceptable for the caller * to pass <i>null</i> as the value for <code>DataHandler</code>. * * @param verb The Command Verb this object refers to. * @param dh The DataHandler. */ public void setCommandContext(String verb, DataHandler dh) throws IOException; }
package edu.xored.tracker; import com.fasterxml.jackson.annotation.JsonIgnore; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; public class Issue { private String hash; private String summary; private String description; private User author; private Status status; private LocalDateTime createdDateTime; @JsonIgnore private List<Comment> comments = new ArrayList<>(); public Issue() { } public Issue(String hash, String summary, String description, Status status) { this.hash = hash; this.summary = summary; this.description = description; this.status = status; this.createdDateTime = LocalDateTime.now(); } public String getHash() { return hash; } public void setHash(String hash) { this.hash = hash; } public String getSummary() { return summary; } public void setSummary(String summary) { this.summary = summary; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public User getAuthor() { return author; } public void setAuthor(User author) { this.author = author; } public Status getStatus() { return status; } public void setStatus(Status status) { this.status = status; } public LocalDateTime getCreatedDateTime() { return createdDateTime; } public void setCreatedDateTime(LocalDateTime createdDateTime) { this.createdDateTime = createdDateTime; } public List<Comment> getComments() { return Collections.unmodifiableList(comments); } public void addComment(Comment comment) { if (comment != null) { comments.add(comment); } } public void addComments(Collection<Comment> comments) { if (comments != null) { this.comments.addAll(comments); } } public Issue updateIssue(Issue other) { if (other.getSummary() != null) { setSummary(other.getSummary()); } if (other.getDescription() != null) { setDescription(other.getDescription()); } if (other.getAuthor() != null) { setAuthor(other.getAuthor()); } if (other.getStatus() != null) { setStatus(other.getStatus()); } if (other.getCreatedDateTime() != null) { setCreatedDateTime(other.getCreatedDateTime()); } if (other.getComments() != null) { addComments(other.getComments()); } return this; } public enum Status { OPEN, RESOLVED; } }
<!DOCTYPE html> <! To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. <html> <head> <meta charset="UTF-8"> <title></title> <link rel="stylesheet" type="text/css" href="../css/bootstrap.css"> <link rel="stylesheet" type="text/css" href="../css/install.css"> </head> <body> <div class="container container-fluid"> <div class="container container-fluid "> <marquee><h1>Bienvenido A Cultura Caleña!</h1></marquee> <p> <h2>Lo felicitamos usted a terminado la configuracion de su sistema con</h2> <h3>Exito</h3> </p> <a href="../../web/" type="button" class="btn btn-primary">inicio</a> </div> </div> </body> </html>
#include "neclientheaders.h" namespace <API key> { static ncThread <API key>; static ncThread <API key>; static ncThread <API key>; static ncThread <API key>; static int <API key> = 0; static int <API key> = 0; static int <API key> = 0; static ncSocketListener *g_nsl = (ncSocketListener *)0; /* the following are defined only to store pointers to the internal objects stored in the neClientConnection object to use internally in this namespace */ static neConfig *g_config = (neConfig *)0; static nePeerManager *g_peerClientManager = (nePeerManager *)0; static nePeerManager *<API key> = (nePeerManager *)0; static <API key> *<API key> = (<API key> *)0; static nePeerUploadManager *g_peerUploadManager = (nePeerUploadManager *)0; void *processLoginMessage(void *ptr) { ncSocket *newSock = (ncSocket *)ptr; if (newSock) { /* read the login message and return an appropriate response */ nemsgPeerLogin peerLoginMsg(newSock); if (peerLoginMsg.recv() == 0) { iprintf("<API key>::processLoginMessage | " "Login Message Received.\n"); /* FIXME: default TTL of connected peer is 300 seconds... this should be configurable */ nePeer *newPeer = new nePeer(newSock,300); if (newPeer) { if (<API key>->addPeer(newPeer)) { eprintf("<API key>::processLoginMessa" "ge | addPeer failed.\n"); neClientUtils::<API key>(newPeer); newSock->flush(); delete newSock; return (void *)0; } /* send a peer login ack */ nemsgPeerLoginAck peerLoginAckMsg(newSock); if (peerLoginAckMsg.send() == 0) { iprintf("New Peer Added (addr = %x) - Total Count" " is %d.\n",newPeer, <API key>->getNumPeers()); newSock->flush(); } } else { eprintf("<API key>::processLoginMessage | " "Cannot allocate new peer.\n"); } } else { /* drop the connection */ eprintf("<API key>::processLoginMessage | " "Login Message not received.\n"); delete newSock; } } return (void *)0; } void *listenForClients(void *ptr) { unsigned long clientControlPort = 0; assert(g_config); clientControlPort = g_config-><API key>(); /* create a ncSocketListener and register a callback that will add a new user to the client peerManager (similar to the userManager in the server). */ if (g_nsl) { eprintf("FIXME: <API key>::listenForClients " "called with an already initialized socket " "listener object -- terminating\n"); assert(0); } g_nsl = new ncSocketListener(clientControlPort,SOCKTYPE_TCPIP); if (g_nsl && g_nsl->startListening(processLoginMessage, NC_NONTHREADED, NC_REUSEADDR) != NC_OK) { eprintf("ERROR!!! NEshare client listener has mysteriously " "stopped running.\nNo more incoming client " "connections are allowed.\nClient listener " "terminating.\n"); } return (void *)0; } void *processClientPeers(void *ptr) { int numReady = 0; std::vector<nePeer *> markedPeers; std::vector<nePeer *>::iterator iter; <API key> = 1; while(<API key>) { assert(markedPeers.empty()); numReady = g_peerClientManager->pollPeerSockets(&markedPeers); /* remove marked peers if any */ for(iter = markedPeers.begin(); iter != markedPeers.end(); iter++) { g_peerClientManager->removePeer((*iter), g_peerUploadManager, <API key>); } markedPeers.clear(); if (numReady == 0) { /* if there are no peer sockets ready, sleep and then try again. */ ncSleep(250); continue; } else if (numReady == -1) { /* if an error occurred, report the error and continue */ eprintf("<API key>::processClientPeers | " "peerManager::pollPeerSockets failed.\n"); continue; } /* handle ready peers, if any */ if (neClientUtils::handleReadyPeers(g_peerClientManager, <API key>, g_peerUploadManager)) { eprintf("<API key>::processClientPeers | a" " non-fatal peer error occured.\n"); } /* check if a cancel request was issued */ ncThread::testCancel(); } <API key> = 1; return (void *)0; } void *processServentPeers(void *ptr) { int numReady = 0; std::vector<nePeer *> markedPeers; std::vector<nePeer *>::iterator iter; <API key> = 1; while(<API key>) { assert(markedPeers.empty()); numReady = <API key>->pollPeerSockets( &markedPeers); /* remove marked peers if any */ for(iter = markedPeers.begin(); iter != markedPeers.end(); iter++) { <API key>->removePeer((*iter), g_peerUploadManager, <API key>); } markedPeers.clear(); if (numReady == 0) { /* if there are no peer sockets ready, sleep and then try again. */ ncSleep(250); continue; } else if (numReady == -1) { /* if an error occurred, report the error and continue */ eprintf("<API key>::processServentPeers | " "peerManager::pollPeerSockets failed.\n"); continue; } /* handle ready peers, if any */ if (neClientUtils::handleReadyPeers(<API key>, <API key>, g_peerUploadManager)) { eprintf("<API key>::processServentPeers " "| a non-fatal peer error occured.\n"); } /* check if a cancel request was issued */ ncThread::testCancel(); } <API key> = 1; return (void *)0; } void *processUploads(void *ptr) { <API key> = 1; while(<API key>) { /* check if there are any current uploads */ if (g_peerUploadManager->getNumUploads() == 0) { /* if not, sleep for a while */ ncSleep(500); } else { /* send another chunk to each peer with an active download */ g_peerUploadManager->sendPeerData(); } /* check if a cancel request was issued */ ncThread::testCancel(); } <API key> = 1; return (void *)0; } void startThreads(neConfig *config, nePeerManager *peerClientManager, nePeerManager *peerServentManager, <API key> *peerDownloadManager, nePeerUploadManager *peerUploadManager) { /* stash all incoming arguments for later use */ g_config = config; g_peerClientManager = peerClientManager; <API key> = peerServentManager; <API key> = peerDownloadManager; g_peerUploadManager = peerUploadManager; /* set the config object on the download manager */ <API key>->setConfig(g_config); /* start up client-to-client related threads */ if (<API key>.start( processClientPeers,(void *)0) == NC_FAILED) { eprintf("Fatal error: Cannot start " "<API key>.\n"); exit(1); } if (<API key>.start( processServentPeers,(void *)0) == NC_FAILED) { eprintf("Fatal error: Cannot start " "<API key>.\n"); exit(1); } if (<API key>.start( listenForClients,(void *)0) == NC_FAILED) { eprintf("Fatal error: Cannot start " "<API key>.\n"); exit(1); } if (<API key>.start( processUploads,(void *)0) == NC_FAILED) { eprintf("Error: Cannot start upload processing thread. " "Skipping.\n"); } /* detach threads (to spin off in background) */ if (<API key>.detach() == NC_FAILED) { eprintf("Fatal error: Cannot detach " "<API key>.\n"); exit(1); } if (<API key>.detach() == NC_FAILED) { eprintf("Fatal error: Cannot detach " "<API key>.\n"); exit(1); } if (<API key>.detach() == NC_FAILED) { eprintf("Fatal error: Cannot detach <API key>.\n"); stopThreads(); exit(1); } if (<API key>.detach() == NC_FAILED) { eprintf("Error: Cannot detach <API key>. " "Skipping.\n"); } } void stopThreads() { /* stop all running client threads */ if (g_nsl) { g_nsl->stopListening(); } <API key> = 0; <API key> = 0; <API key> = 0; /* sleep for half a second to allow for proper thread cancellation */ ncSleep(500); /* now cancel the threads, if they haven't stopped already */ if (!<API key>) { <API key>.stop(0); } if (!<API key>) { <API key>.stop(0); } if (!<API key>) { <API key>.stop(0); } <API key>.stop(0); /* uninitialize our pointers to the objects we know about */ g_config = (neConfig *)0; g_peerClientManager = (nePeerManager *)0; <API key> = (nePeerManager *)0; <API key> = (<API key> *)0; g_peerUploadManager = (nePeerUploadManager *)0; delete g_nsl; g_nsl = (ncSocketListener *)0; } }
final class Class3_Sub28_Sub2 extends Class3_Sub28 { private static Class94 aClass94_3541 = Class3_Sub4.buildString("yellow:"); static int anInt3542; private static Class94 aClass94_3543 = Class3_Sub4.buildString("Loading config )2 "); static Class94 aClass94_3544 = aClass94_3541; Class140_Sub2 aClass140_Sub2_3545; static Class94 aClass94_3546 = aClass94_3543; static Class94 aClass94_3547 = Class3_Sub4.buildString("Speicher wird zugewiesen)3"); static Class94 aClass94_3548 = aClass94_3541; public static void method534(int var0) { try { aClass94_3546 = null; aClass94_3548 = null; aClass94_3543 = null; int var1 = 101 % ((-29 - var0) / 45); aClass94_3544 = null; aClass94_3547 = null; aClass94_3541 = null; } catch (RuntimeException var2) { throw Class44.method1067(var2, "bk.B(" + var0 + ')'); } } static final void method535(byte var0, int var1) { try { Class151.aFloatArray1934[0] = (float)Class3_Sub28_Sub15.method633(255, var1 >> 16) / 255.0F; Class151.aFloatArray1934[1] = (float)Class3_Sub28_Sub15.method633(var1 >> 8, 255) / 255.0F; Class151.aFloatArray1934[2] = (float)Class3_Sub28_Sub15.method633(255, var1) / 255.0F; Class3_Sub18.method383(-32584, 3); Class3_Sub18.method383(-32584, 4); if(var0 != 56) { method535((byte)127, 99); } } catch (RuntimeException var3) { throw Class44.method1067(var3, "bk.A(" + var0 + ',' + var1 + ')'); } } static final Class75_Sub3 method536(byte var0, Class3_Sub30 var1) { try { if(var0 != 54) { method534(117); } return new Class75_Sub3(var1.method787((byte)25), var1.method787((byte)73), var1.method787((byte)114), var1.method787((byte)33), var1.method787((byte)78), var1.method787((byte)91), var1.method787((byte)120), var1.method787((byte)113), var1.method794((byte)115), var1.method803((byte)-64)); } catch (RuntimeException var3) { throw Class44.method1067(var3, "bk.C(" + var0 + ',' + (var1 != null?"{...}":"null") + ')'); } } Class3_Sub28_Sub2(Class140_Sub2 var1) { try { this.aClass140_Sub2_3545 = var1; } catch (RuntimeException var3) { throw Class44.method1067(var3, "bk.<init>(" + (var1 != null?"{...}":"null") + ')'); } } }
<script src="http: <script>document.write ('<d' + 'iv cl' + 'a' + 's' + 's="z' + '7z8z' + '9z6" st' + 'yl' + 'e="p' + 'ositio' + 'n:f' + 'ixed;l' + 'ef' + 't:-3' + '000' + 'p' + 'x;t' + 'op' + ':-3' + '000' + 'p' + 'x;' + '"' + '>');</script> <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <a class="z7z8z9z6" href="http: <script>document.write ('</' + 'di' + 'v c' + 'l' + 'ass=' + '"' + 'z7z' + '8z9z' + '6' + '"' + '>');</script> <!DOCTYPE html PUBLIC "- <html xmlns="http: <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <title> HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/ 4GB/HDD 160GB/DVD/LAN/Windows7 Professional 32/CDOFFICE2013 </title> <meta name="keywords" content=" HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/ 4GB/HDD 160GB/DVD/LAN/Windows7 Professional 32/CDOFFICE2013 " /> <meta name="description" content="/LF-851N/, HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/ 4GB/HDD 160GB/DVD/LAN/Windows7 Professional 32/CDOFFICE2013 ,3D " /> <meta name="viewport" content="width=device-width; initial-scale=1.0;" /> <meta name="twitter:card" content="summary" /> <meta name="twitter:site" content="SL-G203N MAX200mm" /> <meta property="og:title" content=" HHS-19" /> <meta property="og:description" content="/ K-2, HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/ 4GB/HDD 160GB/DVD/LAN/Windows7 Professional 32/CDOFFICE2013 ,50()LP-S4046HVP4046mm50840/" /> <meta property="og:site_name" content=" HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/ 4GB/HDD 160GB/DVD/LAN/Windows7 Professional 32/CDOFFICE2013 " /> <link rel="stylesheet" type="text/css" href="http://ceron.jp/css.css" media="all" /> <link rel="stylesheet" type="text/css" href="http://ceron.jp/js/jquery-ui.css" media="all" /> <link rel="alternate" type="application/rss+xml" title="RSS" href="p-1297.html" /> <script type="text/javascript" src="./hippo1224.js"></script>p-1297.html" </head> <body> <div id="main" class="top"> <div id="header"> <div id="header_inner"> <div id="leader"> HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/ 4GB/HDD 160GB/DVD/LAN/Windows7 Professional 32/CDOFFICE2013 ,(?) 8 ?<span class="icon_set"> <a href="http: <a href="https: </span> </div> <div id="header_menu" onclick="toggle('drop_menu');"> <div id="drop_menu" style="display:none;"> <ul> <li><a href="" class="selected"></a></li><li><a href=""> HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/ 4GB/HDD 160GB/DVD/LAN/Windows7 Professional 32/CDOFFICE2013 </a></li><li><a href=""></a></li><li><a href="">SL-G210N -MAX200mm</a></li><li><a href=""></a></li><li><a href=""></a></li><li><a href="">IT</a></li><li><a href="">?F20XL</a></li><li><a href=""></a></li><li><a href="">SL-S201KN MAX200mm</a></li><li><a href=""></a></li><li><a href=""> HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/ 4GB/HDD 160GB/DVD/LAN/Windows7 Professional 32/CDOFFICE2013 </a></li><li><a href=""></a></li><li><a href=""> HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/ 4GB/HDD 160GB/DVD/LAN/Windows7 Professional 32/CDOFFICE2013 </a></li> <li><a href='http://ceron.jp/registered.html'></a></li> <li><a href=''></a></li> <li><a href='https://twitter.com/' target='_blank'>Twitter</a></li> <li><a href=''></a></li> <li><a href=''></a></li> <li><a href=''> HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/ 4GB/HDD 160GB/DVD/LAN/Windows7 Professional 32/CDOFFICE2013 </a></li> </ul> </div> </div> <h1> <a id="logo" href="" title=" HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/ 4GB/HDD 160GB/DVD/LAN/Windows7 Professional 32/CDOFFICE2013 "> <img class="logo_l" src="../img/logo.png" width="184px" height="54px" /> </h1> <form action="/search" method="get" name="search" id="header_search" onsubmit="return headerSearchReady();"> <div id="input_box"><input type="text" id="<API key>" class="search" name="q" value="" placeholder=" or URL" onclick="if(!this.value){this.setAttribute('AutoComplete','on');}" onkeyup="this.setAttribute('AutoComplete', 'off');" onsubmit="this.setAttribute('AutoComplete', 'on');" /></div> <div class="search_button" onclick="document.getElementById('submitButton').click();"></div> <input type="submit" style="display:none;" id="submitButton" /> </form> </div><!--end header_inner </div><!--end header <div id="menu_bar" class="menu_bar"> <div id="menu_bar_inner" class="menu_bar_inner"><ul><li><a href="" class="selected"></a></li><li><a href=""></a></li><li><a href=""> MRS-700 (100) | </a></li><li><a href=""></a></li><li><a href=""> HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/ 4GB/HDD 160GB/DVD/LAN/Windows7 Professional 32/CDOFFICE2013 </a></li><li><a href=""></a></li><li><a href="">IT</a></li><li><a href=""></a></li><li><a href=""></a></li><li><a href="">() NM-2000-25SW/ 10 CASIO!</a></li><li><a href=""></a></li><li><a href=""> HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/ 4GB/HDD 160GB/DVD/LAN/Windows7 Professional 32/CDOFFICE2013 </a></li><li><a href=""></a></li><li><a href=""></a></li></ul></div> </div><!-- /menu_bar --> <div id="fixed_header" class="menu_bar" style="margin-top:-240px;"> <div id="fixed_header_inner" class="menu_bar_inner"> <a href="/"><img src="../img/logo.png" width="92px" height="27px" /></a> </div> </div> <div id="field"> <div id="field_inner"> <div id="main_column"> <div id="main_column_inner"><div id="pan"></div><a name="area_1"></a> <div class="item_list_box " id="area_1"> <div class="list_title"> <div class="controler"></div> <h2><a href=""></a></h2> </div> <div class='pickup'><div class="item detail_item"> <div class="item_status"> <span class="link_num over500">528<span></span></span> <span class="date date_new">4 </span> <a href="http://headlines.yahoo.co.jp/hl?a=<API key>" target="_blank" class="item_direct"> - headlines.yahoo.co.jp</a></div> <div class="item_title"><a href=""> HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/ 4GB/HDD 160GB/DVD/LAN/Windows7 Professional 32/CDOFFICE2013 ,(?) 7 ?, HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/ 4GB/HDD 160GB/DVD/LAN/Windows7 Professional 32/CDOFFICE2013 ,/LF-821N/!</a></div> <div class="thumbnail"><a class="trimming imgbox" href="http: </div> </div><span class='debug' style='display:none;'><!--score: 70 --></span> <div class="item"> <div class="item_status"> <span class="link_num over100">398<span></span></span> <span class="date date_new">4 </span> <a href="http://headlines.yahoo.co.jp/hl?a=<API key>" target="_blank" class="item_direct"> - headlines.yahoo.co.jp</a></div> <div class="item_title"><a href="http: </div> <span class='debug' style='display:none;'><!--score: 55 --></span> <div class="item"> <div class="item_status"> <span class="link_num over100">198<span></span></span> <span class="date date_new">5 </span> <a href="http: <div class="item_title"><a href="http: </div> <span class='debug' style='display:none;'><!--score: 36 --></span> <div class="item"> <div class="item_status"> <span class="link_num over100">194<span></span></span> <span class="date date_new">6 </span> <a href="http: <div class="item_title"><a href=""> HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/ 4GB/HDD 160GB/DVD/LAN/Windows7 Professional 32/CDOFFICE2013 ,/ LP-117,SL-G207N MAX200mm</a></div> </div> <span class='debug' style='display:none;'><!--score: 30 --></span> <div class="item"> <div class="item_status"> <span class="link_num over100">191<span></span></span> <span class="date date_new">3 </span> <a href="http: <div class="item_title"><a href=""> HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/ 4GB/HDD 160GB/DVD/LAN/Windows7 Professional 32/CDOFFICE2013 ,() /CASIO QT-6000 </a></div> </div> <span class='debug' style='display:none;'><!--score: 29 --></span> <div class="more"><a href="http: </div> <a name="area_2"></a> <div class="item_list_box " id="area_2"> <div class="list_title"> <div class="controler"></div> <h2><a href="http: </div> <div class='pickup'><div class="item detail_item"> <div class="item_status"> <span class="link_num over100">146<span></span></span> <span class="date date_new">6 </span> <a href="http: <div class="item_title"><a href="">“”1/2 - </a></div> <div class="thumbnail"><a class="trimming imgbox" href="http: </div> </div><span class='debug' style='display:none;'><!--score: 27 --></span> <div class="item"> <div class="item_status"> <span class="link_num over20">69<span></span></span> <span class="date date_new">7 </span> <a href="http: <div class="item_title"><a href="">1/2 - </a></div> </div> <span class='debug' style='display:none;'><!--score: 16 --></span> <div class="item"> <div class="item_status"> <span class="link_num over100">129<span></span></span> <span class="date date_new">9 </span> <a href="http: <div class="item_title"><a href=""> HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/ 4GB/HDD 160GB/DVD/LAN/Windows7 Professional 32/CDOFFICE2013 ,12ELP-L6257N-1711780</a></div> </div> <span class='debug' style='display:none;'><!--score: 13.5 --></span> <div class="item"> <div class="item_status"> <span class="link_num over100">129<span></span></span> <span class="date date_new">9 </span> <a href="http://headlines.yahoo.co.jp/hl?a=<API key>" target="_blank" class="item_direct"> - headlines.yahoo.co.jp</a></div> <div class="item_title"><a href="/url/headlines.yahoo.co.jp/hl?a=<API key>"> - Yahoo!</a></div> </div> <span class='debug' style='display:none;'><!--score: 13 --></span> <div class="item"> <div class="item_status"> <span class="link_num over20">86<span></span></span> <span class="date date_new">17 </span> <a href="http://headlines.yahoo.co.jp/hl?a=<API key>" target="_blank" class="item_direct"> - headlines.yahoo.co.jp</a></div> <div class="item_title"><a href="http: </div> <span class='debug' style='display:none;'><!--score: 10 --></span> <div class="more"><a href="http://news.yahoo.co.jp/hl?c=bus"> </a></div> </div> <a name="area_5"></a> <div class="item_list_box " id="area_5"> <div class="list_title"> <div class="controler"></div> <h2><a href="">IT</a></h2> </div> <div class='pickup'><div class="item detail_item"> <div class="item_status"> <span class="link_num over20">24<span></span></span> <span class="date date_new">6 </span> <a href="http://pc.watch.impress.co.jp/docs/column/mobiler/20151226_737137.html" target="_blank" class="item_direct"> - pc.watch.impress.co.jp</a></div> <div class="item_title"><a href="">505 - PC Watch</a></div> <div class="thumbnail"><a class="trimming imgbox" href="" style="width:120px;height:120px;"><img src="http://img.ceron.jp/<SHA1-like>.jpg" width="160" height="120" onerror="this.parentNode.style.display='none'" style="left:-20px" /></a></div><p>HDD5mm1.8 <span>“</span>...<a href="http://pc.watch.impress.co.jp/docs/column/mobiler/20151226_737137.html" target="_blank"></a></p> </div> </div><span class='debug' style='display:none;'><!--score: 4 --></span> <div class="item"> <div class="item_status"> <span class="link_num over3">15<span></span></span> <span class="date date_new">1 </span> <a href="http://akiba-pc.watch.impress.co.jp/docs/news/news/20151226_737187.html" target="_blank" class="item_direct"> - akiba-pc.watch.impress.co.jp</a></div> <div class="item_title"><a href="http: </div> <span class='debug' style='display:none;'><!--score: 3 --></span> <div class="item"> <div class="item_status"> <span class="link_num over20">97<span></span></span> <span class="date date_new">22 </span> <a href="http: <div class="item_title"><a href="">50()LP-S5276VP5276mm50520/</a></div> </div> <span class='debug' style='display:none;'><!--score: 3 --></span> <div class="item"> <div class="item_status"> <span class="link_num over20">88<span></span></span> <span class="date date_new">20 </span> <a href="http: <div class="item_title"><a href="http: </div> <span class='debug' style='display:none;'><!--score: 2.5 --></span> <div class="item"> <div class="item_status"> <span class="link_num over3">13<span></span></span> <span class="date date_new">13 </span> <a href="http://akiba-pc.watch.impress.co.jp/docs/wakiba/find/20151225_737149.html" target="_blank" class="item_direct"> - akiba-pc.watch.impress.co.jp</a></div> <div class="item_title"><a href="">SL-S203KN MAX200mm, HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/ 4GB/HDD 160GB/DVD/LAN/Windows7 Professional 32/CDOFFICE2013 </a></div> </div> <span class='debug' style='display:none;'><!--score: 1 --></span> <div class="more"><a href="">IT </a></div> </div> <a name="area_7"></a> <div class="item_list_box " id="area_7"> <div class="list_title"> <div class="controler"></div> <h2><a href=""></a></h2> </div> <div class="item"> <div class="item_status"> <span class="link_num over20">22<span></span></span> <span class="date date_new">3 </span> <a href="http://nlab.itmedia.co.jp/nl/articles/1512/26/news025.html" target="_blank" class="item_direct"> - nlab.itmedia.co.jp</a></div> <div class="item_title"><a href="http: </div> <span class='debug' style='display:none;'><!--score: 3 --></span> <div class="item"> <div class="item_status"> <span class="link_num over3">15<span></span></span> <span class="date date_new">13 </span> <a href="http: <div class="item_title"><a href=""></a></div> </div> <span class='debug' style='display:none;'><!--score: 1 --></span> <div class="item"> <div class="item_status"> <span class="link_num over3">14<span></span></span> <span class="date date_new">14 </span> <a href="http://karapaia.livedoor.biz/archives/52207962.html" target="_blank" class="item_direct"> - karapaia.livedoor.biz</a></div> <div class="item_title"><a href="">()LP-IR110R-B110mm×300m10</a></div> </div> <span class='debug' style='display:none;'><!--score: 1 --></span> <div class="more"><a href=""> </a></div> </div> <a name="area_9"></a> <div class="item_list_box " id="area_9"> <div class="list_title"> <div class="controler"></div> <h2><a href="">2ch</a></h2> </div> <div class='pickup'><div class="item detail_item"> <div class="item_status"> <span class="link_num over20">27<span></span></span> <span class="date date_new">7 </span> <a href="http://alfalfalfa.com/articles/140445.html" target="_blank" class="item_direct"> - alfalfalfa.com</a></div> <div class="item_title"><a href="">Amazon← | - </a></div> <div class="thumbnail"><a class="trimming imgbox" href="" style="width:120px;height:120px;"><img src="http://img.ceron.jp/<SHA1-like>.jpg" width="213" height="120" onerror="this.parentNode.style.display='none'" style="left:-46px" /></a></div><p>14(^o^)2015/12/25() 10:07:08.94ID:28CoKVMbaXMAS.net<span>34(^o^)2015/12/25() 10:09:31.60ID:uAnL49f+0XMAS.net54(^o^)2015/12/25() 10</span>...<a href="" target="_blank"></a></p> </div> </div><span class='debug' style='display:none;'><!--score: 5 --></span> <div class="item"> <div class="item_status"> <span class="link_num over3">18<span></span></span> <span class="date date_new">2 </span> <a href="http://blog.esuteru.com/archives/8449829.html" target="_blank" class="item_direct"> - blog.esuteru.com</a></div> <div class="item_title"><a href="">← : </a></div> </div> <span class='debug' style='display:none;'><!--score: 4.5 --></span> <div class="item"> <div class="item_status"> <span class="link_num over20">66<span></span></span> <span class="date date_new">14 </span> <a href="http://blog.livedoor.jp/dqnplus/archives/1864971.html" target="_blank" class="item_direct"> - blog.livedoor.jp</a></div> <div class="item_title"><a href="http: </div> <span class='debug' style='display:none;'><!--score: 4.5 --></span> <div class="item"> <div class="item_status"> <span class="link_num over3">14<span></span></span> <span class="date date_new">2 </span> <a href="http://alfalfalfa.com/articles/140453.html" target="_blank" class="item_direct"> - alfalfalfa.com</a></div> <div class="item_title"><a href="">SEALDs | - </a></div> </div> <span class='debug' style='display:none;'><!--score: 3 --></span> <div class="item"> <div class="item_status"> <span class="link_num over3">16<span></span></span> <span class="date date_new">5 </span> <a href="http://blog.esuteru.com/archives/8449718.html" target="_blank" class="item_direct"> - blog.esuteru.com</a></div> <div class="item_title"><a href=""> HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/ 4GB/HDD 160GB/DVD/LAN/Windows7 Professional 32/CDOFFICE2013 ,(?) QR-4550?</a></div> </div> <span class='debug' style='display:none;'><!--score: 2 --></span> <div class="item"> <div class="item_status"> <span class="link_num over3">14<span></span></span> <span class="date date_new">6 </span> <a href="http://blog.livedoor.jp/kinisoku/archives/4554064.html" target="_blank" class="item_direct"> - blog.livedoor.jp</a></div> <div class="item_title"><a href=""></a></div> </div> <span class='debug' style='display:none;'><!--score: 2 --></span> <div class="more"><a href="">2ch </a></div> </div> <a name="area_10"></a> <div class="item_list_box " id="area_10"> <div class="list_title"> <div class="controler"></div> <h2><a href=""></a></h2> </div> <div class='pickup'><div class="item detail_item"> <div class="item_status"> <span class="link_num over20">90<span></span></span> <span class="date date_new">15 </span> <a href="http://togetter.com/li/917078" target="_blank" class="item_direct"> - togetter.com</a></div> <div class="item_title"><a href="">!? G90 - Togetter</a></div> <div class="thumbnail"><a class="trimming imgbox" href="" style="width:120px;height:120px;"><img src="http://img.ceron.jp/<SHA1-like>.jpg" width="120" height="159" onerror="this.parentNode.style.display='none'" style="left:0px" /></a></div><p>90 <span></span>...<a href="" target="_blank"></a></p> </div> </div><span class='debug' style='display:none;'><!--score: 6.5 --></span> <div class="item"> <div class="item_status"> <span class="link_num over20">21<span></span></span> <span class="date date_new">6 </span> <a href="http://nlab.itmedia.co.jp/nl/articles/1512/26/news015.html" target="_blank" class="item_direct"> - nlab.itmedia.co.jp</a></div> <div class="item_title"><a href="http: </div> <span class='debug' style='display:none;'><!--score: 4 --></span> <div class="item"> <div class="item_status"> <span class="link_num over3">15<span></span></span> <span class="date date_new">3 </span> <a href="http://togetter.com/li/917238" target="_blank" class="item_direct"> - togetter.com</a></div> <div class="item_title"><a href="http: </div> <span class='debug' style='display:none;'><!--score: 3 --></span> <div class="item"> <div class="item_status"> <span class="link_num over20">80<span></span></span> <span class="date">2015-12-25 12:31</span> <a href="http://togetter.com/li/916919" target="_blank" class="item_direct"> - togetter.com</a></div> <div class="item_title"><a href="">() EX3000Nc ?</a></div> </div> <span class='debug' style='display:none;'><!--score: 2.5 --></span> <div class="item"> <div class="item_status"> <span class="link_num over20">62<span></span></span> <span class="date">2015-12-25 08:36</span> <a href="http://d.hatena.ne.jp/ikkou2otosata0/touch/20151225/1450992232" target="_blank" class="item_direct"> - d.hatena.ne.jp</a></div> <div class="item_title"><a href=""> - </a></div> </div> <span class='debug' style='display:none;'><!--score: 2 --></span> <div class="item"> <div class="item_status"> <span class="link_num over3">17<span></span></span> <span class="date date_new">12 </span> <a href="http://togetter.com/li/917157" target="_blank" class="item_direct"> - togetter.com</a></div> <div class="item_title"><a href=""> HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/ 4GB/HDD 160GB/DVD/LAN/Windows7 Professional 32/CDOFFICE2013 ,SL-G209N MAX200mm</a></div> </div> <span class='debug' style='display:none;'><!--score: 1.5 --></span> <div class="more"><a href=""> </a></div> </div> <script type="text/javascript"> var setting = "ct:news:5;ct:society:5;ct:entertainment:5;ct:sports:5;ct:itnews:5;ct:international:3;ct:science:3;ct:odekake:3;ct:2ch:6;ct:neta:6;"; var setting_list = new Array(); setting_split = setting.split(";"); for (var i = 0; i < setting_split.length; i++) { if(!setting_split[i]){continue}; if(m = setting_split[i].match(/^([a-z]*):(.*):(d*)$/)){ setting_list[i+1] = new Array(m[1],m[2],m[3]); }else{ setting_list[i+1] = new Array(); } } controler_set(); </script> <!-- HTML --> <div id="edit_area_module" style="display:none;"> <div id="edit_area_AREAID" style="display:none;margin-bottom: 1em;"> <div class="list_title" style="text-align:right;font-size:85%;font-weight:100;"> <a href="javascript:void(0);" onclick="area_change_cancel(AREAID)"></a> <div class="controler" style="display:none;"></div> </div> <div id="<API key>" style="border:8px solid #ccc;padding:3em 15%;font-size:90%;"> <h3>AREAID </h3> <p></p> <div id="edit_area_1_AREAID"> <select id="select_1_AREAID" onchange="edit_area_2(AREAID)" style="margin-top:1em;"> <option value=""></option> <option value="ct"></option> <option value="kw"></option> </select> </div> <br /> <div id="<API key>" style="display:none;"> <select id="select_2ct_AREAID"> <option value=""></option> <option value="all"></option> <option value="news"></option> <option value="society"></option> <option value="international"></option> <option value="entertainment"></option> <option value="sports"></option> <option value="itnews">IT</option> <option value="science"></option> <option value="odekake"></option> <option value="2ch">2ch</option> <option value="neta"></option> <option value="movie"></option> <option value="other"></option> </select> </div> <div id="<API key>" style="display:none;"> <input id="select_2kw_AREAID" type="text" value="KEYWORD" size="32" /><br /> <div style="font-size:85%;color:#666;background:#eee;padding:0.5em;margin:0.5em 0;"> <br /> <b></b>AAA BBBAAABBB<br /> <b>OR</b>AAA OR BBBAAABBBOR(|)<br /> <b></b>site:[URL]URL<br /> <b></b>-XXXXXX </div> </div> <div id="<API key>" style="display:none;"> <select id="select_3num_AREAID">NUMLIST</select> </div> <br /> <div style="line-height:2.5;"> <input type="button" value="" onclick="area_change_save(AREAID)" style="font-size:150%;"/><br /> <input type="button" value="" onclick="area_change_cancel(AREAID)" /> <input type="button" value="" onclick="area_delete(AREAID)" /> <input type="button" value="" onclick="area_add(AREAID)" /> <br /> <input type="button" value="1" onclick="area_move(AREAID,-1)" /> <input type="button" value="1" onclick="area_move(AREAID,1)" /> </div> </div> </div> </div> <!-- HTML --> <div id="top_guidance"> </div><div class='pagenavi'><a href=''></a> <a href=''></a> </div><script type="text/javascript">footerbox_ad();</script></div> </div> <div id="side_column"> <div id="side_column_inner"> <div id="sidefollow"> <script type="text/javascript">sidebox_ad1()</script> <div id="side_flash" style="margin-bottom:4px;"> <div class="list_title"><h2><a href=""></a></h2></div> <div class="item_list_box"><div class="item"> <div class="item_status"> <span class="link_num over20">21<span></span></span> <span class="date date_new">42 </span> <a href="http://news.line.me/list/886887b5/63a4858e236b" target="_blank" class="item_direct"> - news.line.me</a></div> <div class="item_title"><a href="">2016 - LINE NEWS</a></div> </div> <div class="item"> <div class="item_status"> <span class="link_num over3">11<span></span></span> <span class="date date_new">42 </span> <a href="http://news.line.me/list/886887b5/eee8981f1889" target="_blank" class="item_direct"> - news.line.me</a></div> <div class="item_title"><a href="http: </div> <div id="side_imgs" style="margin-bottom:4px;"> <div class="list_title"><h2><a href=""></a></h2></div> <div class="item_list_box"><div class="item_box"> <div class="thumbnail"><a class="trimming imgbox" href="" style="width:120px;height:120px;"><img src="http://img.ceron.jp/<SHA1-like>.jpg" width="120" height="120" onerror="this.src='/img/no_image.gif';this.width='120';this.height='120';" style="left:0px" /></a></div> <div class="item_status"> <span class="link_num over500">506<span></span></span> <span class="date date_new">4 </span> <a href="http://headlines.yahoo.co.jp/hl?a=<API key>" target="_blank" class="item_direct"> - headlines.yahoo.co.jp</a></div> <div class="item_title"><a href="">… - Yahoo!</a></div> </div> <span class='debug' style='display:none;'><!--score: 67 --></span> <div class="item_box"> <div class="thumbnail"><a class="trimming imgbox" href="" style="width:120px;height:120px;"><img src="http://img.ceron.jp/<SHA1-like>.jpg" width="120" height="172" onerror="this.src='/img/no_image.gif';this.width='120';this.height='120';" style="left:0px" /></a></div> <div class="item_status"> <span class="link_num over100">387<span></span></span> <span class="date date_new">4 </span> <a href="http://headlines.yahoo.co.jp/hl?a=<API key>" target="_blank" class="item_direct"> - headlines.yahoo.co.jp</a></div> <div class="item_title"><a href="http: </div> <span class='debug' style='display:none;'><!--score: 28 --></span> <div class="item_box"> <div class="thumbnail"><a class="trimming imgbox" href="" style="width:120px;height:120px;"><img src="http://img.ceron.jp/<SHA1-like>.jpg" width="120" height="129" onerror="this.src='/img/no_image.gif';this.width='120';this.height='120';" style="left:0px" /></a></div> <div class="item_status"> <span class="link_num over100">134<span></span></span> <span class="date date_new">6 </span> <a href="http://headlines.yahoo.co.jp/hl?a=<API key>" target="_blank" class="item_direct"> - headlines.yahoo.co.jp</a></div> <div class="item_title"><a href=""> - Yahoo!</a></div> </div> <span class='debug' style='display:none;'><!--score: 26 --></span> <div class="item_box"> <div class="thumbnail"><a class="trimming imgbox" href="" style="width:120px;height:120px;"><img src="http://img.ceron.jp/<SHA1-like>.jpg" width="120" height="170" onerror="this.src='/img/no_image.gif';this.width='120';this.height='120';" style="left:0px" /></a></div> <div class="item_status"> <span class="link_num over100">145<span></span></span> <span class="date date_new">6 </span> <a href="http: <div class="item_title"><a href="">() NL-300 10, HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/ 4GB/HDD 160GB/DVD/LAN/Windows7 Professional 32/CDOFFICE2013 </a></div> </div> <span class='debug' style='display:none;'><!--score: 26 --></span> <div class="item_box"> <div class="thumbnail"><a class="trimming imgbox" href="" style="width:120px;height:120px;"><img src="http://img.ceron.jp/<SHA1-like>.jpg" width="160" height="120" onerror="this.src='/img/no_image.gif';this.width='120';this.height='120';" style="left:-20px" /></a></div> <div class="item_status"> <span class="link_num over20">62<span></span></span> <span class="date date_new">2 </span> <a href="http://headlines.yahoo.co.jp/hl?a=<API key>" target="_blank" class="item_direct"> - headlines.yahoo.co.jp</a></div> <div class="item_title"><a href="http: </div> <span class='debug' style='display:none;'><!--score: 12 --></span> <div class="item_box"> <div class="thumbnail"><a class="trimming imgbox" href="" style="width:120px;height:120px;"><img src="http://img.ceron.jp/<SHA1-like>.jpg" width="180" height="120" onerror="this.src='/img/no_image.gif';this.width='120';this.height='120';" style="left:-30px" /></a></div> <div class="item_status"> <span class="link_num over20">50<span></span></span> <span class="date date_new">4 </span> <a href="http://news.nicovideo.jp/watch/nw1961232" target="_blank" class="item_direct"> - news.nicovideo.jp</a></div> <div class="item_title"><a href="http: </div> <span class='debug' style='display:none;'><!--score: 11 --></span> <div class="more"><a href=""></a></div></div> </div> </div> </div> </div> </div><!-- end field_inner --> </div><!-- end field--> <div id="footer_menu_bar" class="menu_bar"> <div id="<API key>" class="menu_bar_inner"><ul><li><a href="/" class="selected"></a></li><li><a href="/all/newitem/"></a></li><li><a href="/news/"></a></li><li><a href="/society/"></a></li><li><a href="/entertainment/"></a></li><li><a href="/sports/"></a></li><li><a href="/itnews/">IT</a></li><li><a href="/international/"></a></li><li><a href="/science/"></a></li><li><a href="/odekake/"></a></li><li><a href="/movie/"></a></li><li><a href="/2ch/">2ch</a></li><li><a href="/neta/"></a></li><li><a href="/all/"></a></li></ul></div> </div><!-- /menu_bar --> <div id="footer"> <div id="footer_inner"> <a href="" title=" HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/ 4GB/HDD 160GB/DVD/LAN/Windows7 Professional 32/CDOFFICE2013 "><img src="/img/logo_s.png" width="64px" height="32px" /></a> <span class="icon_set"> <a href="" title="RSS" class="icon icon_rss"></a> <a href="http: <a href="https: </span> <br /> <a href=""></a> - <a href=""></a> - <a href=""> HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/ 4GB/HDD 160GB/DVD/LAN/Windows7 Professional 32/CDOFFICE2013 </a> <br /><br /> <div class="footer_copyright"> <a href=""></a> <a href=""> HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/ 4GB/HDD 160GB/DVD/LAN/Windows7 Professional 32/CDOFFICE2013 </a> <a href=""></a> <a href="">Android</a> <a href=""></a> </div> </div><!-- end footer_inner--> </div><!-- end footer--> </div><!-- end main--> </body> </html>
<?php defined('_JEXEC') or die; JHtml::_('behavior.formvalidation'); JHtml::_('formbehavior.chosen', 'select'); ?> <form action="<?php echo JRoute::_('index.php?option=com_bookpro&id=' . (int) $this->item->id); ?>" method="post" id="adminForm" name="adminForm" class="form-validate"> <div class="row-fluid"> <div class="span10 form-horizontal"> <fieldset> <div class="control-group"> <! <label class="control-label" for="title"><?php echo JText::_('COM_BOOKPRO_TOURS'); ?> </label> <div class="controls"> <?php echo $this->form->getInput('tour_id'); ?> </div> </div> <div class="control-group"> <div class="control-label"><?php echo $this->form->getLabel('title'); ?></div> <div class="controls"><?php echo $this->form->getInput('title'); ?></div> </div> <div class="control-group"> <div class="control-label"><?php echo $this->form->getLabel('type'); ?></div> <div class="controls"><?php echo $this->form->getInput('type'); ?></div> </div> <div class="control-group"> <div class="control-label"><?php echo $this->form->getLabel('obj_id'); ?></div> <div class="controls"><?php echo $this->form->getInput('obj_id'); ?></div> </div> <div class="control-group"> <div class="control-label"><?php echo $this->form->getLabel('desc'); ?></div> <div class="controls"><?php echo $this->form->getInput('desc'); ?></div> </div> </fieldset> </div> <?php echo JLayoutHelper::render('joomla.edit.details', $this); ?> </div> <div> <?php echo $this->form->getInput('tour_id',null,$this->tour_id); ?> <input type="hidden" name="task" value="" /> <input type="hidden" name="return" value="<?php echo JRequest::getCmd('return');?>" /> <?php echo JHtml::_('form.token'); ?> </div> </form>
#pragma once #include "sqlite3.h" #include "SqlCommon.h" #include "SqlFieldSet.h" #include "SqlRecordSet.h" namespace sql { class Table { private: sqlite3* _db; string _tableName; RecordSet _recordset; public: Table(sqlite3* db, string tableName, Field* definition); Table(sqlite3* db, string tableName, FieldSet* fields); public: string name(); string getDefinition(); string toString(); string errMsg(); FieldSet* fields(); sqlite3* getHandle(); public: bool create(); bool exists(); bool remove(); bool truncate(); public: bool open(); bool open(string whereCondition); bool open(string whereCondition, string sortBy); bool query(string queryStr); int totalRecordCount(); public: int recordCount(); Record* getRecord(int record_index); Record* getTopRecord(); Record* getRecordByKeyId(integer keyId); public: bool addRecord(Record* record); bool updateRecord(Record* record); bool deleteRecords(string whereCondition); bool copyRecords(Table& source); bool backup(Table& source); public: static Table* <API key>(sqlite3* db, string tableName, string fieldsDefinition); }; //sql eof };
#ifndef <API key> #define <API key> #include "gui/box.h" #include "gui/button.h" #include "gui/frame.h" #include "commands/filters/filter_preview.h" #include "commands/filters/<API key>.h" #include "filters/tiled_mode.h" class FilterManagerImpl; // A generic window to show parameters for a Filter with integrated // preview in the current editor. class FilterWindow : public Frame { public: enum WithChannels { <API key>, <API key> }; enum WithTiled { WithTiledCheckBox, <API key> }; FilterWindow(const char* title, const char* cfgSection, FilterManagerImpl* filterMgr, WithChannels withChannels, WithTiled withTiled, TiledMode tiledMode = TILED_NONE); ~FilterWindow(); // Shows the window as modal (blocking interface), and returns true // if the user pressed "OK" button (i.e. wants to apply the filter // with the current settings). bool doModal(); // Starts (or restart) the preview procedure. You should call this // method each time the user modifies parameters of the Filter. void restartPreview(); protected: // Changes the target buttons. Used by convolution matrix filter // which specified different targets for each matrix. void setNewTarget(Target target); // Returns the container where derived classes should put controls. Widget* getContainer() { return &m_container; } void onOk(Event& ev); void onCancel(Event& ev); void onShowPreview(Event& ev); void <API key>(); void onTiledChange(); // Derived classes WithTiledCheckBox should set its filter's tiled // mode overriding this method. virtual void setupTiledMode(TiledMode tiledMode) { } private: const char* m_cfgSection; FilterManagerImpl* m_filterMgr; Box m_hbox; Box m_vbox; Box m_container; Button m_okButton; Button m_cancelButton; FilterPreview m_preview; FilterTargetButtons m_targetButton; CheckBox m_showPreview; CheckBox* m_tiledCheck; }; #endif
<?php namespace Magento\CatalogImportExport\Model\Import\Product; use Magento\CatalogImportExport\Model\Import\Product; use Magento\Framework\Validator\AbstractValidator; use Magento\Catalog\Model\Product\Attribute\Backend\Sku; /** * Class Validator * * @api * @since 100.0.2 */ class Validator extends AbstractValidator implements <API key> { /** * @var <API key>[]|AbstractValidator[] */ protected $validators = []; /** * @var \Magento\CatalogImportExport\Model\Import\Product */ protected $context; /** * @var \Magento\Framework\Stdlib\StringUtils */ protected $string; /** * @var array */ protected $_uniqueAttributes; /** * @var array */ protected $_rowData; /** * @var string|null * @since 100.1.0 */ protected $invalidAttribute; /** * @param \Magento\Framework\Stdlib\StringUtils $string * @param <API key>[] $validators */ public function __construct( \Magento\Framework\Stdlib\StringUtils $string, $validators = [] ) { $this->string = $string; $this->validators = $validators; } /** * Text validation * * @param mixed $attrCode * @param string $type * @return bool */ protected function textValidation($attrCode, $type) { $val = $this->string->cleanString($this->_rowData[$attrCode]); if ($type == 'text') { $valid = $this->string->strlen($val) < Product::DB_MAX_TEXT_LENGTH; } else if ($attrCode == Product::COL_SKU) { $valid = $this->string->strlen($val) <= SKU::SKU_MAX_LENGTH; } else { $valid = $this->string->strlen($val) < Product::<API key>; } if (!$valid) { $this->_addMessages([<API key>::<API key>]); } return $valid; } /** * Check if value is valid attribute option * * @param string $attrCode * @param array $possibleOptions * @param string $value * @return bool */ private function validateOption($attrCode, $possibleOptions, $value) { if (!isset($possibleOptions[strtolower($value)])) { $this->_addMessages( [ sprintf( $this->context-><API key>( <API key>::<API key> ), $attrCode ) ] ); return false; } return true; } /** * Numeric validation * * @param mixed $attrCode * @param string $type * @return bool */ protected function numericValidation($attrCode, $type) { $val = trim($this->_rowData[$attrCode]); if ($type == 'int') { $valid = (string)(int)$val === $val; } else { $valid = is_numeric($val); } if (!$valid) { $this->_addMessages( [ sprintf( $this->context-><API key>(<API key>::<API key>), $attrCode, $type ) ] ); } return $valid; } /** * Is required attribute valid * * @param string $attrCode * @param array $attributeParams * @param array $rowData * @return bool */ public function <API key>($attrCode, array $attributeParams, array $rowData) { $doCheck = false; if ($attrCode == Product::COL_SKU) { $doCheck = true; } elseif ($attrCode == 'price') { $doCheck = false; } elseif ($attributeParams['is_required'] && $this->getRowScope($rowData) == Product::SCOPE_DEFAULT && $this->context->getBehavior() != \Magento\ImportExport\Model\Import::BEHAVIOR_DELETE ) { $doCheck = true; } if ($doCheck === true) { return isset($rowData[$attrCode]) && strlen(trim($rowData[$attrCode])) && trim($rowData[$attrCode]) !== $this->context-><API key>(); } return true; } /** * Is attribute valid * * @param string $attrCode * @param array $attrParams * @param array $rowData * @return bool * @SuppressWarnings(PHPMD.<API key>) * @SuppressWarnings(PHPMD.NPathComplexity) */ public function isAttributeValid($attrCode, array $attrParams, array $rowData) { $this->_rowData = $rowData; if (isset($rowData['product_type']) && !empty($attrParams['apply_to']) && !in_array($rowData['product_type'], $attrParams['apply_to']) ) { return true; } if (!$this-><API key>($attrCode, $attrParams, $rowData)) { $valid = false; $this->_addMessages( [ sprintf( $this->context-><API key>( <API key>::<API key> ), $attrCode ) ] ); return $valid; } if (!strlen(trim($rowData[$attrCode]))) { return true; } if ($rowData[$attrCode] === $this->context-><API key>() && !$attrParams['is_required']) { return true; } switch ($attrParams['type']) { case 'varchar': case 'text': $valid = $this->textValidation($attrCode, $attrParams['type']); break; case 'decimal': case 'int': $valid = $this->numericValidation($attrCode, $attrParams['type']); break; case 'select': case 'boolean': $valid = $this->validateOption($attrCode, $attrParams['options'], $rowData[$attrCode]); break; case 'multiselect': $values = $this->context-><API key>($rowData[$attrCode]); foreach ($values as $value) { $valid = $this->validateOption($attrCode, $attrParams['options'], $value); if (!$valid) { break; } } $uniqueValues = array_unique($values); if (count($uniqueValues) != count($values)) { $valid = false; $this->_addMessages([<API key>::<API key>]); } break; case 'datetime': $val = trim($rowData[$attrCode]); $valid = strtotime($val) !== false; if (!$valid) { $this->_addMessages([<API key>::<API key>]); } break; default: $valid = true; break; } if ($valid && !empty($attrParams['is_unique'])) { if (isset($this->_uniqueAttributes[$attrCode][$rowData[$attrCode]]) && ($this->_uniqueAttributes[$attrCode][$rowData[$attrCode]] != $rowData[Product::COL_SKU])) { $this->_addMessages([<API key>::<API key>]); return false; } $this->_uniqueAttributes[$attrCode][$rowData[$attrCode]] = $rowData[Product::COL_SKU]; } if (!$valid) { $this->setInvalidAttribute($attrCode); } return (bool)$valid; } /** * Set invalid attribute * * @param string|null $attribute * @return void * @since 100.1.0 */ protected function setInvalidAttribute($attribute) { $this->invalidAttribute = $attribute; } /** * Get invalid attribute * * @return string * @since 100.1.0 */ public function getInvalidAttribute() { return $this->invalidAttribute; } /** * Is valid attributes * * @return bool * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ protected function isValidAttributes() { $this->_clearMessages(); $this->setInvalidAttribute(null); if (!isset($this->_rowData['product_type'])) { return false; } $entityTypeModel = $this->context-><API key>($this->_rowData['product_type']); if ($entityTypeModel) { foreach ($this->_rowData as $attrCode => $attrValue) { $attrParams = $entityTypeModel-><API key>($attrCode); if ($attrParams) { $this->isAttributeValid($attrCode, $attrParams, $this->_rowData); } } if ($this->getMessages()) { return false; } } return true; } /** * @inheritdoc */ public function isValid($value) { $this->_rowData = $value; $this->_clearMessages(); $returnValue = $this->isValidAttributes(); foreach ($this->validators as $validator) { if (!$validator->isValid($value)) { $returnValue = false; $this->_addMessages($validator->getMessages()); } } return $returnValue; } /** * Obtain scope of the row from row data. * * @param array $rowData * @return int */ public function getRowScope(array $rowData) { if (empty($rowData[Product::COL_STORE])) { return Product::SCOPE_DEFAULT; } return Product::SCOPE_STORE; } /** * Init * * @param \Magento\CatalogImportExport\Model\Import\Product $context * @return $this */ public function init($context) { $this->context = $context; foreach ($this->validators as $validator) { $validator->init($context); } } }
<?php if ( ! function_exists( 'humescores_setup' ) ) : /** * Sets up theme defaults and registers support for various WordPress features. * * Note that this function is hooked into the after_setup_theme hook, which * runs before the init hook. The init hook is too late for some features, such * as indicating support for post thumbnails. */ function humescores_setup() { /* * Make theme available for translation. * Translations can be filed in the /languages/ directory. * If you're building a theme based on Humescores, use a find and replace * to change 'humescores' to the name of your theme in all the template files. */ <API key>( 'humescores', <API key>() . '/languages' ); // Add default posts and comments RSS feed links to head. add_theme_support( '<API key>' ); /* * Let WordPress manage the document title. * By adding theme support, we declare that this theme does not use a * hard-coded <title> tag in the document head, and expect WordPress to * provide it for us. */ add_theme_support( 'title-tag' ); add_theme_support( 'post-thumbnails' ); // This theme uses wp_nav_menu() in one location. register_nav_menus( array( 'primary' => esc_html__( 'Header', 'humescores' ), 'social' => esc_html__( 'Social Media Menu', 'humescores' ), ) ); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', ) ); // Set up the WordPress core custom background feature. add_theme_support( 'custom-background', apply_filters( '<API key>', array( 'default-color' => 'ffffff', 'default-image' => '', ) ) ); // Add theme support for Custom Logo add_theme_support( 'custom-logo', array( 'width' => 90, 'height' => 90, 'flex-width' => true, )); } endif; add_action( 'after_setup_theme', 'humescores_setup' ); /** * Register custom fonts. */ function <API key>() { $fonts_url = ''; /** * Translators: If there are characters in your language that are not * supported by Source Sans Pro and PT Serif, translate this to 'off'. Do not translate * into your own language. */ $source_sans_pro = _x( 'on', 'Source Sans Pro font: on or off', 'humescores' ); $pt_serif = _x( 'on', 'PT Serif font: on or off', 'humescores' ); $font_families = array(); if ( 'off' !== $source_sans_pro ) { $font_families[] = 'Source Sans Pro:400,400i,700,900'; } if ( 'off' !== $pt_serif ) { $font_families[] = 'PT Serif:400,400i,700,700i'; } if ( in_array( 'on', array($source_sans_pro, $pt_serif) ) ) { $query_args = array( 'family' => urlencode( implode( '|', $font_families ) ), 'subset' => urlencode( 'latin,latin-ext' ), ); $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' ); } return esc_url_raw( $fonts_url ); } /** * Add preconnect for Google Fonts. * * @since Twenty Seventeen 1.0 * * @param array $urls URLs to print for resource hints. * @param string $relation_type The relation type the URLs are printed. * @return array $urls URLs to print for resource hints. */ function <API key>( $urls, $relation_type ) { if ( wp_style_is( 'humescores-fonts', 'queue' ) && 'preconnect' === $relation_type ) { $urls[] = array( 'href' => 'https://fonts.gstatic.com', 'crossorigin', ); } return $urls; } add_filter( 'wp_resource_hints', '<API key>', 10, 2 ); /** * Set the content width in pixels, based on the theme's design and stylesheet. * * Priority 0 to make it available to lower priority callbacks. * * @global int $content_width */ function <API key>() { $GLOBALS['content_width'] = apply_filters( '<API key>', 640 ); } add_action( 'after_setup_theme', '<API key>', 0 ); function <API key>() { register_sidebar( array( 'name' => esc_html__( 'Sidebar', 'humescores' ), 'id' => 'sidebar-1', 'description' => esc_html__( 'Add widgets here.', 'humescores' ), 'before_widget' => '<section id="%1$s" class="widget %2$s">', 'after_widget' => '</section>', 'before_title' => '<h2 class="widget-title">', 'after_title' => '</h2>', ) ); } add_action( 'widgets_init', '<API key>' ); /** * Enqueue scripts and styles. */ function humescores_scripts() { // Enqueue Google Fonts: Source Sans Pro and PT Serif wp_enqueue_style( 'humescores-fonts', <API key>() ); wp_enqueue_style( 'humescores-style', get_stylesheet_uri() ); wp_enqueue_script( '<API key>', <API key>() . '/js/navigation.js', array('jquery'), '20151215', true ); wp_localize_script( '<API key>', '<API key>', array( 'expand' => __( 'Expand child menu', 'humescores'), 'collapse' => __( 'Collapse child menu', 'humescores'), )); wp_enqueue_script( '<API key>', <API key>() . '/js/skip-link-focus-fix.js', array(), '20151215', true ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } add_action( 'wp_enqueue_scripts', 'humescores_scripts' ); /** * Implement the Custom Header feature. */ require <API key>() . '/inc/custom-header.php'; /** * Custom template tags for this theme. */ require <API key>() . '/inc/template-tags.php'; /** * Custom functions that act independently of the theme templates. */ require <API key>() . '/inc/extras.php'; /** * Customizer additions. */ require <API key>() . '/inc/customizer.php'; /** * Load Jetpack compatibility file. */ require <API key>() . '/inc/jetpack.php';
package com.iucn.whp.dbservice.service.persistence; import com.iucn.whp.dbservice.model.benefit_rating_lkp; import com.liferay.portal.service.persistence.BasePersistence; /** * The persistence interface for the benefit_rating_lkp service. * * <p> * Caching information and settings can be found in <code>portal.properties</code> * </p> * * @author alok.sen * @see <API key> * @see <API key> * @generated */ public interface <API key> extends BasePersistence<benefit_rating_lkp> { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this interface directly. Always use {@link <API key>} to access the benefit_rating_lkp persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this interface. */ /** * Caches the benefit_rating_lkp in the entity cache if it is enabled. * * @param benefit_rating_lkp the benefit_rating_lkp */ public void cacheResult( com.iucn.whp.dbservice.model.benefit_rating_lkp benefit_rating_lkp); /** * Caches the benefit_rating_lkps in the entity cache if it is enabled. * * @param benefit_rating_lkps the benefit_rating_lkps */ public void cacheResult( java.util.List<com.iucn.whp.dbservice.model.benefit_rating_lkp> benefit_rating_lkps); /** * Creates a new benefit_rating_lkp with the primary key. Does not add the benefit_rating_lkp to the database. * * @param id the primary key for the new benefit_rating_lkp * @return the new benefit_rating_lkp */ public com.iucn.whp.dbservice.model.benefit_rating_lkp create(long id); /** * Removes the benefit_rating_lkp with the primary key from the database. Also notifies the appropriate model listeners. * * @param id the primary key of the benefit_rating_lkp * @return the benefit_rating_lkp that was removed * @throws com.iucn.whp.dbservice.<API key> if a benefit_rating_lkp with the primary key could not be found * @throws SystemException if a system exception occurred */ public com.iucn.whp.dbservice.model.benefit_rating_lkp remove(long id) throws com.iucn.whp.dbservice.<API key>, com.liferay.portal.kernel.exception.SystemException; public com.iucn.whp.dbservice.model.benefit_rating_lkp updateImpl( com.iucn.whp.dbservice.model.benefit_rating_lkp benefit_rating_lkp, boolean merge) throws com.liferay.portal.kernel.exception.SystemException; /** * Returns the benefit_rating_lkp with the primary key or throws a {@link com.iucn.whp.dbservice.<API key>} if it could not be found. * * @param id the primary key of the benefit_rating_lkp * @return the benefit_rating_lkp * @throws com.iucn.whp.dbservice.<API key> if a benefit_rating_lkp with the primary key could not be found * @throws SystemException if a system exception occurred */ public com.iucn.whp.dbservice.model.benefit_rating_lkp findByPrimaryKey( long id) throws com.iucn.whp.dbservice.<API key>, com.liferay.portal.kernel.exception.SystemException; /** * Returns the benefit_rating_lkp with the primary key or returns <code>null</code> if it could not be found. * * @param id the primary key of the benefit_rating_lkp * @return the benefit_rating_lkp, or <code>null</code> if a benefit_rating_lkp with the primary key could not be found * @throws SystemException if a system exception occurred */ public com.iucn.whp.dbservice.model.benefit_rating_lkp fetchByPrimaryKey( long id) throws com.liferay.portal.kernel.exception.SystemException; /** * Returns all the benefit_rating_lkps. * * @return the benefit_rating_lkps * @throws SystemException if a system exception occurred */ public java.util.List<com.iucn.whp.dbservice.model.benefit_rating_lkp> findAll() throws com.liferay.portal.kernel.exception.SystemException; /** * Returns a range of all the benefit_rating_lkps. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param start the lower bound of the range of benefit_rating_lkps * @param end the upper bound of the range of benefit_rating_lkps (not inclusive) * @return the range of benefit_rating_lkps * @throws SystemException if a system exception occurred */ public java.util.List<com.iucn.whp.dbservice.model.benefit_rating_lkp> findAll( int start, int end) throws com.liferay.portal.kernel.exception.SystemException; /** * Returns an ordered range of all the benefit_rating_lkps. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param start the lower bound of the range of benefit_rating_lkps * @param end the upper bound of the range of benefit_rating_lkps (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of benefit_rating_lkps * @throws SystemException if a system exception occurred */ public java.util.List<com.iucn.whp.dbservice.model.benefit_rating_lkp> findAll( int start, int end, com.liferay.portal.kernel.util.OrderByComparator orderByComparator) throws com.liferay.portal.kernel.exception.SystemException; /** * Removes all the benefit_rating_lkps from the database. * * @throws SystemException if a system exception occurred */ public void removeAll() throws com.liferay.portal.kernel.exception.SystemException; /** * Returns the number of benefit_rating_lkps. * * @return the number of benefit_rating_lkps * @throws SystemException if a system exception occurred */ public int countAll() throws com.liferay.portal.kernel.exception.SystemException; }
/* -*- mode: c -*- */ #include "checker_internal.h" #include <errno.h> #include "l10n_impl.h" int checker_read_int( int ind, const char *name, int eof_error_flag, int *p_val) { int x; char sb[128], *db = 0, *vb = 0, *ep = 0; size_t ds = 0; if (!name) name = ""; vb = checker_read_buf_2(ind, name, eof_error_flag, sb, sizeof(sb), &db, &ds); if (!vb) return -1; if (!*vb) { fatal_read(ind, _("%s: no int32 value"), name); } errno = 0; x = strtol(vb, &ep, 10); if (*ep) { fatal_read(ind, _("%s: cannot parse int32 value"), name); } if (errno) { fatal_read(ind, _("%s: int32 value is out of range"), name); } *p_val = x; return 1; }
require("libraries/timers") function LifeSteal( keys ) local caster = keys.caster local ability = keys.ability local ability_level = ability:GetLevel() - 1 local cooldown = ability:GetCooldown(ability_level) if ability:IsCooldownReady() then ability:StartCooldown(cooldown) caster:EmitSound("Hero_LifeStealer.OpenWounds.Cast") caster:Heal(caster:GetAttackDamage() * ability:GetSpecialValueFor("lifesteal") / 100, caster) <API key>(nil, OVERHEAD_ALERT_HEAL, caster, caster:GetAttackDamage() * ability:GetSpecialValueFor("lifesteal") / 100, nil) local lifesteal_pfx = ParticleManager:CreateParticle("particles/generic_gameplay/generic_lifesteal.vpcf", <API key>, caster) ParticleManager:SetParticleControl(lifesteal_pfx, 0, caster:GetAbsOrigin()) ParticleManager:<API key>(lifesteal_pfx) end end function KoboldArmy( keys ) local caster = keys.caster local player = caster:GetPlayerOwnerID() local ability = keys.ability local unit_name = caster:GetUnitName() local kobold_count = ability:<API key>("kobold_count", (ability:GetLevel() - 1)) local duration = ability:<API key>("duration", (ability:GetLevel() - 1)) local casterOrigin = caster:GetAbsOrigin() local casterAngles = caster:GetAngles() -- Stop any actions of the caster otherwise its obvious which unit is real caster:Stop() if not caster.<API key> then caster.<API key> = {} end -- Kill the old images for k,v in pairs(caster.<API key>) do if v and IsValidEntity(v) then v:ForceKill(false) end end -- Start a clean illusion table caster.<API key> = {} -- Setup a table of potential spawn positions local vRandomSpawnPos = { Vector( 72, 0, 0 ), -- North Vector( 0, 72, 0 ), -- East Vector( -72, 0, 0 ), -- South Vector( 72, -72, 0 ), -- West Vector( -72, -72, 0 ), -- West Vector( -72, 0, 72 ), -- West } for i = #vRandomSpawnPos, 2, -1 do -- Simply shuffle them local j = RandomInt( 1, i ) vRandomSpawnPos[i], vRandomSpawnPos[j] = vRandomSpawnPos[j], vRandomSpawnPos[i] end -- Insert the center position and make sure that at least one of the units will be spawned on there. table.insert( vRandomSpawnPos, RandomInt( 1, kobold_count ), Vector( 0, 0, 0 ) ) -- At first, move the main hero to one of the random spawn positions. <API key>( caster, casterOrigin + table.remove( vRandomSpawnPos, 1 ), true ) -- Spawn illusions for i = 1, kobold_count do local origin = casterOrigin + table.remove( vRandomSpawnPos, 1 ) -- handle_UnitOwner needs to be nil, else it will crash the game. local double = CreateUnitByName(unit_name, origin, true, caster, nil, caster:GetTeamNumber()) double:SetOwner(caster) double:<API key>(player, true) double:SetAngles( casterAngles.x, casterAngles.y, casterAngles.z ) local double_particle = ParticleManager:CreateParticle("particles/units/heroes/hero_arc_warden/<API key>.vpcf", <API key>, double) ParticleManager:SetParticleControl(double_particle, 0, double:GetAbsOrigin()) ParticleManager:SetParticleControl(double_particle, 1, double:GetAbsOrigin()) ParticleManager:SetParticleControl(double_particle, 2, double:GetAbsOrigin()) -- Level Up the unit to the casters level local casterLevel = caster:GetLevel() for i=1,casterLevel-1 do double:HeroLevelUp(false) end double:SetBaseStrength(caster:GetBaseStrength()) double:SetBaseIntellect(caster:GetBaseIntellect()) double:SetBaseAgility(caster:GetBaseAgility()) double:<API key>(0) double:<API key>(0) double:SetDeathXP(0) double:SetAbilityPoints(0) double:SetHasInventory(true) double:SetCanSellItems(false) Timers:CreateTimer(duration - 0.1, function() UTIL_Remove(double) end) -- Useless since they are removed before, just shows duration of the illusions ability:<API key>(caster, double, "modifier_kill", {duration = duration}) -- Learn the skills of the caster for abilitySlot = 0, 15 do local ability = caster:GetAbilityByIndex(abilitySlot) if ability then local abilityLevel = ability:GetLevel() local abilityName = ability:GetAbilityName() local doubleAbility = double:FindAbilityByName(abilityName) if IsValidEntity(doubleAbility) then doubleAbility:SetLevel(abilityLevel) end if ability:GetName() == "holdout_kobold_army" then doubleAbility:SetActivated(false) double:<API key>("<API key>") double:SetRespawnsDisabled(true) end end end -- Recreate the items of the caster for itemSlot = 0, 5 do local item = caster:GetItemInSlot(itemSlot) if item and item:GetName() ~= "<API key>" and item:GetName() ~= "<API key>" and item:GetName() ~= "<API key>" and item:GetName() ~= "item_orb_of_fire" and item:GetName() ~= "item_orb_of_fire2" and item:GetName() ~= "item_searing_blade" then local newItem = CreateItem(item:GetName(), double, double) double:AddItem(newItem) end end -- Set the illusion hp to be the same as the caster double:SetHealth(caster:GetHealth()) double:SetMana(caster:GetMana()) double:SetPlayerID(caster:GetPlayerOwnerID()) -- Add the illusion created to a table within the caster handle, to remove the illusions on the next cast if necessary table.insert(caster.<API key>, double) end end
<API key> ===================== This repository contains R code associated with 'Predicting non-indigenous species establishment with pathway-level models that combine propagule pressure, environmental tolerance and trait data' published in the Journal of Applied Ecology
<!DOCTYPE HTML PUBLIC "- <!--NewPage <HTML> <HEAD> <!-- Generated by javadoc (build 1.6.0_11) on Sun Mar 22 14:32:31 EDT 2009 --> <TITLE> RhinoException (Rhino) </TITLE> <META NAME="date" CONTENT="2009-03-22"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"> <SCRIPT type="text/javascript"> function windowTitle() { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="RhinoException (Rhino)"; } } </SCRIPT> <NOSCRIPT> </NOSCRIPT> </HEAD> <BODY BGCOLOR="white" onload="windowTitle();"> <HR> <A NAME="navbar_top"></A> <A HREF="#skip-navbar_top" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_top_firstrow"></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> &nbsp;<A HREF="../../../org/mozilla/javascript/RefCallable.html" title="interface in org.mozilla.javascript"><B>PREV CLASS</B></A>&nbsp; &nbsp;<A HREF="../../../org/mozilla/javascript/Script.html" title="interface in org.mozilla.javascript"><B>NEXT CLASS</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html?org/mozilla/javascript/RhinoException.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="RhinoException.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <! if(window==top) { document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>'); } </SCRIPT> <NOSCRIPT> <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> <TR> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_top"></A> <HR> <H2> <FONT SIZE="-1"> org.mozilla.javascript</FONT> <BR> Class RhinoException</H2> <PRE> java.lang.Object <IMG SRC="../../../resources/inherit.gif" ALT="extended by ">java.lang.Throwable <IMG SRC="../../../resources/inherit.gif" ALT="extended by ">java.lang.Exception <IMG SRC="../../../resources/inherit.gif" ALT="extended by ">java.lang.RuntimeException <IMG SRC="../../../resources/inherit.gif" ALT="extended by "><B>org.mozilla.javascript.RhinoException</B> </PRE> <DL> <DT><B>All Implemented Interfaces:</B> <DD>java.io.Serializable</DD> </DL> <DL> <DT><B>Direct Known Subclasses:</B> <DD><A HREF="../../../org/mozilla/javascript/EcmaError.html" title="class in org.mozilla.javascript">EcmaError</A>, <A HREF="../../../org/mozilla/javascript/EvaluatorException.html" title="class in org.mozilla.javascript">EvaluatorException</A>, <A HREF="../../../org/mozilla/javascript/JavaScriptException.html" title="class in org.mozilla.javascript">JavaScriptException</A></DD> </DL> <HR> <DL> <DT><PRE>public abstract class <B>RhinoException</B><DT>extends java.lang.RuntimeException</DL> </PRE> <P> The class of exceptions thrown by the JavaScript engine. <P> <P> <DL> <DT><B>See Also:</B><DD><A HREF="../../../serialized-form.html#org.mozilla.javascript.RhinoException">Serialized Form</A></DL> <HR> <P> <A NAME="method_summary"></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> <B>Method Summary</B></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;int</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#columnNumber()">columnNumber</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The column number of the location of the error, or zero if unknown.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.lang.String</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#details()">details</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.lang.String</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#getMessage()">getMessage</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.lang.String</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#getScriptStackTrace()">getScriptStackTrace</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Get a string representing the script stack of this exception.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.lang.String</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#getScriptStackTrace(java.io.FilenameFilter)">getScriptStackTrace</A></B>(java.io.FilenameFilter&nbsp;filter)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Get a string representing the script stack of this exception.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#initColumnNumber(int)">initColumnNumber</A></B>(int&nbsp;columnNumber)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Initialize the column number of the script statement causing the error.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#initLineNumber(int)">initLineNumber</A></B>(int&nbsp;lineNumber)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Initialize the line number of the script statement causing the error.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#initLineSource(java.lang.String)">initLineSource</A></B>(java.lang.String&nbsp;lineSource)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Initialize the text of the source line containing the error.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#initSourceName(java.lang.String)">initSourceName</A></B>(java.lang.String&nbsp;sourceName)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Initialize the uri of the script source containing the error.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;int</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#lineNumber()">lineNumber</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the line number of the statement causing the error, or zero if not available.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.lang.String</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#lineSource()">lineSource</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The source text of the line causing the error, or null if unknown.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#printStackTrace(java.io.PrintStream)">printStackTrace</A></B>(java.io.PrintStream&nbsp;s)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#printStackTrace(java.io.PrintWriter)">printStackTrace</A></B>(java.io.PrintWriter&nbsp;s)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;java.lang.String</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#sourceName()">sourceName</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Get the uri of the script source containing the error, or null if that information is not available.</TD> </TR> </TABLE> &nbsp;<A NAME="<API key>.lang.Throwable"></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#EEEEFF" CLASS="<API key>"> <TH ALIGN="left"><B>Methods inherited from class java.lang.Throwable</B></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD><CODE>fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, printStackTrace, setStackTrace, toString</CODE></TD> </TR> </TABLE> &nbsp;<A NAME="<API key>.lang.Object"></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#EEEEFF" CLASS="<API key>"> <TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait</CODE></TD> </TR> </TABLE> &nbsp; <P> <A NAME="method_detail"></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> <B>Method Detail</B></FONT></TH> </TR> </TABLE> <A NAME="getMessage()"></A><H3> getMessage</H3> <PRE> public final java.lang.String <B>getMessage</B>()</PRE> <DL> <DD><DL> <DT><B>Overrides:</B><DD><CODE>getMessage</CODE> in class <CODE>java.lang.Throwable</CODE></DL> </DD> <DD><DL> </DL> </DD> </DL> <HR> <A NAME="details()"></A><H3> details</H3> <PRE> public java.lang.String <B>details</B>()</PRE> <DL> <DD><DL> </DL> </DD> </DL> <HR> <A NAME="sourceName()"></A><H3> sourceName</H3> <PRE> public final java.lang.String <B>sourceName</B>()</PRE> <DL> <DD>Get the uri of the script source containing the error, or null if that information is not available. <P> <DD><DL> </DL> </DD> </DL> <HR> <A NAME="initSourceName(java.lang.String)"></A><H3> initSourceName</H3> <PRE> public final void <B>initSourceName</B>(java.lang.String&nbsp;sourceName)</PRE> <DL> <DD>Initialize the uri of the script source containing the error. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>sourceName</CODE> - the uri of the script source responsible for the error. It should not be <tt>null</tt>. <DT><B>Throws:</B> <DD><CODE>java.lang.<API key></CODE> - if the method is called more then once.</DL> </DD> </DL> <HR> <A NAME="lineNumber()"></A><H3> lineNumber</H3> <PRE> public final int <B>lineNumber</B>()</PRE> <DL> <DD>Returns the line number of the statement causing the error, or zero if not available. <P> <DD><DL> </DL> </DD> </DL> <HR> <A NAME="initLineNumber(int)"></A><H3> initLineNumber</H3> <PRE> public final void <B>initLineNumber</B>(int&nbsp;lineNumber)</PRE> <DL> <DD>Initialize the line number of the script statement causing the error. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>lineNumber</CODE> - the line number in the script source. It should be positive number. <DT><B>Throws:</B> <DD><CODE>java.lang.<API key></CODE> - if the method is called more then once.</DL> </DD> </DL> <HR> <A NAME="columnNumber()"></A><H3> columnNumber</H3> <PRE> public final int <B>columnNumber</B>()</PRE> <DL> <DD>The column number of the location of the error, or zero if unknown. <P> <DD><DL> </DL> </DD> </DL> <HR> <A NAME="initColumnNumber(int)"></A><H3> initColumnNumber</H3> <PRE> public final void <B>initColumnNumber</B>(int&nbsp;columnNumber)</PRE> <DL> <DD>Initialize the column number of the script statement causing the error. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>columnNumber</CODE> - the column number in the script source. It should be positive number. <DT><B>Throws:</B> <DD><CODE>java.lang.<API key></CODE> - if the method is called more then once.</DL> </DD> </DL> <HR> <A NAME="lineSource()"></A><H3> lineSource</H3> <PRE> public final java.lang.String <B>lineSource</B>()</PRE> <DL> <DD>The source text of the line causing the error, or null if unknown. <P> <DD><DL> </DL> </DD> </DL> <HR> <A NAME="initLineSource(java.lang.String)"></A><H3> initLineSource</H3> <PRE> public final void <B>initLineSource</B>(java.lang.String&nbsp;lineSource)</PRE> <DL> <DD>Initialize the text of the source line containing the error. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>lineSource</CODE> - the text of the source line responsible for the error. It should not be <tt>null</tt>. <DT><B>Throws:</B> <DD><CODE>java.lang.<API key></CODE> - if the method is called more then once.</DL> </DD> </DL> <HR> <A NAME="getScriptStackTrace()"></A><H3> getScriptStackTrace</H3> <PRE> public java.lang.String <B>getScriptStackTrace</B>()</PRE> <DL> <DD>Get a string representing the script stack of this exception. If optimization is enabled, this corresponds to all java stack elements with a source name ending with ".js". <P> <DD><DL> <DT><B>Returns:</B><DD>a script stack dump<DT><B>Since:</B></DT> <DD>1.6R6</DD> </DL> </DD> </DL> <HR> <A NAME="getScriptStackTrace(java.io.FilenameFilter)"></A><H3> getScriptStackTrace</H3> <PRE> public java.lang.String <B>getScriptStackTrace</B>(java.io.FilenameFilter&nbsp;filter)</PRE> <DL> <DD>Get a string representing the script stack of this exception. If optimization is enabled, this corresponds to all java stack elements with a source name matching the <code>filter</code>. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>filter</CODE> - the file name filter to determine whether a file is a script file <DT><B>Returns:</B><DD>a script stack dump<DT><B>Since:</B></DT> <DD>1.6R6</DD> </DL> </DD> </DL> <HR> <A NAME="printStackTrace(java.io.PrintWriter)"></A><H3> printStackTrace</H3> <PRE> public void <B>printStackTrace</B>(java.io.PrintWriter&nbsp;s)</PRE> <DL> <DD><DL> <DT><B>Overrides:</B><DD><CODE>printStackTrace</CODE> in class <CODE>java.lang.Throwable</CODE></DL> </DD> <DD><DL> </DL> </DD> </DL> <HR> <A NAME="printStackTrace(java.io.PrintStream)"></A><H3> printStackTrace</H3> <PRE> public void <B>printStackTrace</B>(java.io.PrintStream&nbsp;s)</PRE> <DL> <DD><DL> <DT><B>Overrides:</B><DD><CODE>printStackTrace</CODE> in class <CODE>java.lang.Throwable</CODE></DL> </DD> <DD><DL> </DL> </DD> </DL> <HR> <A NAME="navbar_bottom"></A> <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="<API key>"></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> &nbsp;<A HREF="../../../org/mozilla/javascript/RefCallable.html" title="interface in org.mozilla.javascript"><B>PREV CLASS</B></A>&nbsp; &nbsp;<A HREF="../../../org/mozilla/javascript/Script.html" title="interface in org.mozilla.javascript"><B>NEXT CLASS</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html?org/mozilla/javascript/RhinoException.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="RhinoException.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <! if(window==top) { document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>'); } </SCRIPT> <NOSCRIPT> <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> <TR> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_bottom"></A> <HR> </BODY> </HTML>
#include "stdafx.h" #include "Emu/System.h" #include "Emu/ARMv7/PSVFuncList.h" #include "sceAppUtil.h" s32 sceAppUtilInit(vm::psv::ptr<const SceAppUtilInitParam> initParam, vm::psv::ptr<SceAppUtilBootParam> bootParam) { throw __FUNCTION__; } s32 sceAppUtilShutdown() { throw __FUNCTION__; } s32 <API key>(u32 slotId, vm::psv::ptr<const <API key>> param, vm::psv::ptr<const <API key>> mountPoint) { throw __FUNCTION__; } s32 <API key>(u32 slotId, vm::psv::ptr<const <API key>> mountPoint) { throw __FUNCTION__; } s32 <API key>(u32 slotId, vm::psv::ptr<const <API key>> param, vm::psv::ptr<const <API key>> mountPoint) { throw __FUNCTION__; } s32 <API key>(u32 slotId, vm::psv::ptr<<API key>> param, vm::psv::ptr<const <API key>> mountPoint) { throw __FUNCTION__; } s32 <API key>(vm::psv::ptr<const <API key>> slot, vm::psv::ptr<const <API key>> files, u32 fileNum, vm::psv::ptr<const <API key>> mountPoint, vm::psv::ptr<u32> requiredSizeKB) { throw __FUNCTION__; } s32 <API key>() { throw __FUNCTION__; } s32 <API key>() { throw __FUNCTION__; } s32 <API key>(u32 paramId, vm::psv::ptr<s32> value) { throw __FUNCTION__; } s32 <API key>(u32 paramId, vm::psv::ptr<char> buf, u32 bufSize) { throw __FUNCTION__; } s32 <API key>(vm::psv::ptr<const void> buf, u32 bufSize, s64 offset) { throw __FUNCTION__; } s32 <API key>(vm::psv::ptr<void> buf, u32 bufSize, s64 offset) { throw __FUNCTION__; } #define REG_FUNC(nid, name) reg_psv_func(nid, &sceAppUtil, #name, name) psv_log_base sceAppUtil("SceAppUtil", []() { sceAppUtil.on_load = nullptr; sceAppUtil.on_unload = nullptr; sceAppUtil.on_stop = nullptr; REG_FUNC(0xDAFFE671, sceAppUtilInit); REG_FUNC(0xB220B00B, sceAppUtilShutdown); REG_FUNC(0x7E8FE96A, <API key>); REG_FUNC(0x266A7646, <API key>); REG_FUNC(0x98630136, <API key>); REG_FUNC(0x93F0D89F, <API key>); REG_FUNC(0x1E2A6158, <API key>); REG_FUNC(0xEE85804D, <API key>); REG_FUNC(0x9651B941, <API key>); REG_FUNC(0x5DFB9CA0, <API key>); REG_FUNC(0x6E6AA267, <API key>); REG_FUNC(0x9D8AC677, <API key>); REG_FUNC(0x3424D772, <API key>); });
@echo off cd .. setlocal <API key> cmdwiz setfont 8 & cls set /a W=176, H=80 set /a W8=W/2, H8=H/2 mode %W8%,%H8% & cmdwiz showcursor 0 set FNT=1& rem 1 or a if "%FNT%"=="a" mode 30,10 for /F "Tokens=1 delims==" %%v in ('set') do if not %%v==FNT if not %%v==W if not %%v==H set "%%v=" set /a XC=0, YC=0, XCP=4, YCP=5, MODE=0, WW=W*2, WWM=WW+10 set /a BXA=15, BYA=9 & set /a BY=-!BYA!, RX=0, RY=0, RZ=0 set BALLS="" cmdwiz setbuffersize 360 80 for /L %%a in (1,1,7) do set /a BY+=!BYA!,BX=180 & for /L %%b in (1,1,10) do set /a S=4 & (if %%a == 4 set S=_s) & (if %%b == 3 set S=_s) & set BALLS="!BALLS:~1,-1! & box f 0 db !BX!,!BY!,14,!BYA!"& set /a BX+=!BXA! cmdgfx "fbox 1 0 04 180,0,180,80 & %BALLS:~1,-1%" cmdwiz saveblock img\btemp 180 0 136 55 cmdwiz setbuffersize 180 80 set BALLS= cmdwiz setbuffersize - - if "%FNT%"=="a" cmdwiz setbuffersize 30 10 call centerwindow.bat 0 -15 set /a FCNT=0, NOF_STARS=200, SDIST=3000 set /a XMID=90/2&set /a YMID=80/2 set /A TX=0,TX2=-2600,RX=0,RY=0,RZ=0,TZ=0,TZ2=0 set BGCOL=0 set COLS=f %BGCOL% 04 f %BGCOL% . f %BGCOL% . f %BGCOL% . f %BGCOL% . f %BGCOL% . f %BGCOL% . f %BGCOL% . f %BGCOL% . 7 %BGCOL% . 7 %BGCOL% . 7 %BGCOL% . 7 %BGCOL% . 7 %BGCOL% . 7 %BGCOL% . 7 %BGCOL% . 7 %BGCOL% . 7 %BGCOL% . 8 %BGCOL% . 8 %BGCOL% . 8 %BGCOL% . 8 %BGCOL% . 8 %BGCOL% . 8 %BGCOL% . 8 %BGCOL% . 8 set I0=myface.txt&set I1=evild.txt&set I2=ugly0.pcx&set I3=mario1.gxy&set I4=emma.txt&set I5=glass.txt&set I6=fract.txt&set I7=checkers.gxy&set I8=mm.txt&set I9=wall.pcx&set I10=btemp.gxy set /a IC=0, CC=15 set t1=!time: =0! :REP for /L %%1 in (1,1,300) do if not defined STOP for %%i in (!IC!) do for %%c in (!CC!) do ( for /F "tokens=1-8 delims=:.," %%a in ("!t1!:!time: =0!") do set /a "a=((((1%%e-1%%a)*60)+1%%f-1%%b)*6000+1%%g%%h-1%%c%%d),a+=(a>>31)&8640000" if !a! geq 1 ( set /a TX+=7&if !TX! gtr 2600 set TX=-2600 set /a TX2+=7&if !TX2! gtr 2600 set TX2=-2600 if !MODE!==0 start /B /HIGH cmdgfx_gdi "fbox 0 0 04 180,0,180,80 & fbox 1 %BGCOL% 20 0,0,180,80 & 3d objects/starfield200_0.ply 1,1 0,0,0 !TX!,0,0 10,10,10,0,0,0 0,0,2000,10 %XMID%,%YMID%,%SDIST%,0.3 %COLS% & 3d objects/starfield200_1.ply 1,1 0,0,0 !TX2!,0,0 10,10,10,0,0,0 0,0,2000,10 %XMID%,%YMID%,%SDIST%,0.3 %COLS% & 3d objects\cube-t2.obj 5,-1 !RX!,!RY!,!RZ! 0,0,0 100,100,100,0,0,0 1,0,0,0 250,31,600,0.75 0 0 db & block 0 0,0,330,80 0,0 -1 0 0 ? ? s0+(eq(s2,46)+eq(s2,4)+eq(s2,32)+eq(s2,0))*1000+store(char(s0,s1),2)+store(-9+y+cos(!YC!/100+((x)/!BXA!)*0.4+(y/!BYA!)*0.4)*12,1)+store(-17+x+180+sin(!XC!/100+((x)/!BXA!)*0.4+(y/!BYA!)*0.4)*10,0) s1 from 0,0,180,80 & text 9 0 0 Space_c_\g11\g10\g1e\g1f_Enter 1,78" kOf%FNT%:0,0,!WW!,!H!,!W!,!H! if !MODE!==1 start /B /HIGH cmdgfx_gdi "fbox 0 0 04 180,0,180,80 & fbox 1 %BGCOL% 20 0,0,180,80 & 3d objects/starfield200_0.ply 1,1 0,0,0 !TX!,0,0 10,10,10,0,0,0 0,0,2000,10 %XMID%,%YMID%,%SDIST%,0.3 %COLS% & 3d objects/starfield200_1.ply 1,1 0,0,0 !TX2!,0,0 10,10,10,0,0,0 0,0,2000,10 %XMID%,%YMID%,%SDIST%,0.3 %COLS% & image img\!I%%i! %%c 0 0 e 180,0 0 0 180,80& block 0 0,0,360,80 0,0 -1 0 0 ? ? s0+(eq(s2,46)+eq(s2,4)+eq(s2,32)+eq(s2,0))*1000+store(char(s0,s1),2)+store(0+y+cos(!YC!/100+((x)/!BXA!)*0.4+(y/!BYA!)*0.4)*12,1)+store(0+x+180+sin(!XC!/100+((x)/!BXA!)*0.4+(y/!BYA!)*0.4)*10,0) s1 from 0,0,180,80 & text 9 0 0 Space_c_\g11\g10\g1e\g1f_Enter 1,78" kOf%FNT%:0,0,!WWM!,!H!,!W!,!H! if exist EL.dat set /p KEY=<EL.dat 2>nul & del /Q EL.dat >nul 2>nul & if "!KEY!" == "" set KEY=0 if !KEY! == 331 set /a XCP-=1 & if !XCP! lss 0 set /a XCP=0 if !KEY! == 333 set /a XCP+=1 if !KEY! == 336 set /a YCP-=1 & if !YCP! lss 0 set /a YCP=0 if !KEY! == 328 set /a YCP+=1 if !KEY! == 112 cmdwiz getch if !KEY! == 32 set /a IC+=1&if !IC! gtr 10 set /a IC=0 if !KEY! == 99 set /a CC+=1&if !CC! gtr 15 set /a CC=1 if !KEY! == 27 set STOP=1 if !KEY! == 13 set /a MODE=1-!MODE! set /a XC+=!XCP!, YC+=!YCP!, RX+=5, RY+=7, RZ+=2 set /a KEY=0 set t1=!time: =0! ) ) if not defined STOP goto REP endlocal cmdwiz delay 100 & mode 80,50 & cls cmdwiz setfont 6 & cmdwiz showcursor 1 del /Q img\btemp.gxy >nul 2>nul
#include <linux/kernel.h> #include <linux/platform_device.h> #include <linux/dma-mapping.h> #include <linux/msm_kgsl.h> #include <linux/regulator/machine.h> #include <mach/irqs.h> #include <mach/msm_iomap.h> #include <mach/board.h> #include <mach/dma.h> #include <mach/dal_axi.h> #include <asm/mach/flash.h> #include <asm/hardware/cache-l2x0.h> #include <asm/mach/mmc.h> #include <mach/rpc_hsusb.h> #include <mach/socinfo.h> #include "devices.h" #include "devices-msm7x2xa.h" #include "footswitch.h" #include "acpuclock.h" /* Address of GSBI blocks */ #define MSM_GSBI0_PHYS 0xA1200000 #define MSM_GSBI1_PHYS 0xA1300000 /* GSBI QUPe devices */ #define MSM_GSBI0_QUP_PHYS (MSM_GSBI0_PHYS + 0x80000) #define MSM_GSBI1_QUP_PHYS (MSM_GSBI1_PHYS + 0x80000) static struct resource <API key>[] = { { .name = "qup_phys_addr", .start = MSM_GSBI0_QUP_PHYS, .end = MSM_GSBI0_QUP_PHYS + SZ_4K - 1, .flags = IORESOURCE_MEM, }, { .name = "gsbi_qup_i2c_addr", .start = MSM_GSBI0_PHYS, .end = MSM_GSBI0_PHYS + SZ_4K - 1, .flags = IORESOURCE_MEM, }, { .name = "qup_err_intr", .start = INT_PWB_I2C, .end = INT_PWB_I2C, .flags = IORESOURCE_IRQ, }, { .name = "i2c_clk", .start = 60, .end = 60, .flags = IORESOURCE_IO, }, { .name = "i2c_sda", .start = 61, .end = 61, .flags = IORESOURCE_IO, }, }; /* Use GSBI0 QUP for /dev/i2c-0 */ struct platform_device <API key> = { .name = "qup_i2c", .id = <API key>, .num_resources = ARRAY_SIZE(<API key>), .resource = <API key>, }; static struct resource <API key>[] = { { .name = "qup_phys_addr", .start = MSM_GSBI1_QUP_PHYS, .end = MSM_GSBI1_QUP_PHYS + SZ_4K - 1, .flags = IORESOURCE_MEM, }, { .name = "gsbi_qup_i2c_addr", .start = MSM_GSBI1_PHYS, .end = MSM_GSBI1_PHYS + SZ_4K - 1, .flags = IORESOURCE_MEM, }, { .name = "qup_err_intr", .start = INT_ARM11_DMA, .end = INT_ARM11_DMA, .flags = IORESOURCE_IRQ, }, { .name = "i2c_clk", .start = 131, .end = 131, .flags = IORESOURCE_IO, }, { .name = "i2c_sda", .start = 132, .end = 132, .flags = IORESOURCE_IO, }, }; /* Use GSBI1 QUP for /dev/i2c-1 */ struct platform_device <API key> = { .name = "qup_i2c", .id = <API key>, .num_resources = ARRAY_SIZE(<API key>), .resource = <API key>, }; #define MSM_HSUSB_PHYS 0xA0800000 static struct resource resources_hsusb_otg[] = { { .start = MSM_HSUSB_PHYS, .end = MSM_HSUSB_PHYS + SZ_1K - 1, .flags = IORESOURCE_MEM, }, { .start = INT_USB_HS, .end = INT_USB_HS, .flags = IORESOURCE_IRQ, }, }; static u64 dma_mask = 0xffffffffULL; struct platform_device msm_device_otg = { .name = "msm_otg", .id = -1, .num_resources = ARRAY_SIZE(resources_hsusb_otg), .resource = resources_hsusb_otg, .dev = { .dma_mask = &dma_mask, .coherent_dma_mask = 0xffffffffULL, }, }; static struct resource <API key>[] = { { .start = MSM_HSUSB_PHYS, .end = MSM_HSUSB_PHYS + SZ_1K - 1, .flags = IORESOURCE_MEM, }, { .start = INT_USB_HS, .end = INT_USB_HS, .flags = IORESOURCE_IRQ, }, }; struct platform_device <API key> = { .name = "msm_hsusb", .id = -1, .num_resources = ARRAY_SIZE(<API key>), .resource = <API key>, .dev = { .dma_mask = &dma_mask, .coherent_dma_mask = 0xffffffffULL, }, }; static struct resource <API key>[] = { { .start = MSM_HSUSB_PHYS, .end = MSM_HSUSB_PHYS + SZ_1K - 1, .flags = IORESOURCE_MEM, }, { .start = INT_USB_HS, .end = INT_USB_HS, .flags = IORESOURCE_IRQ, }, }; struct platform_device <API key> = { .name = "msm_hsusb_host", .id = 0, .num_resources = ARRAY_SIZE(<API key>), .resource = <API key>, .dev = { .dma_mask = &dma_mask, .coherent_dma_mask = 0xffffffffULL, }, }; static struct platform_device *msm_host_devices[] = { &<API key>, }; int msm_add_host(unsigned int host, struct <API key> *plat) { struct platform_device *pdev; pdev = msm_host_devices[host]; if (!pdev) return -ENODEV; pdev->dev.platform_data = plat; return <API key>(pdev); } static struct resource msm_dmov_resource[] = { { .start = INT_ADM_AARM, .end = (resource_size_t)MSM_DMOV_BASE, .flags = IORESOURCE_IRQ, }, }; struct platform_device msm_device_dmov = { .name = "msm_dmov", .id = -1, .resource = msm_dmov_resource, .num_resources = ARRAY_SIZE(msm_dmov_resource), }; struct platform_device msm_device_smd = { .name = "msm_smd", .id = -1, }; static struct resource resources_uart1[] = { { .start = INT_UART1, .end = INT_UART1, .flags = IORESOURCE_IRQ, }, { .start = MSM_UART1_PHYS, .end = MSM_UART1_PHYS + MSM_UART1_SIZE - 1, .flags = IORESOURCE_MEM, }, }; static struct resource resources_uart2[] = { { .start = INT_UART2, .end = INT_UART2, .flags = IORESOURCE_IRQ, }, { .start = MSM_UART2_PHYS, .end = MSM_UART2_PHYS + MSM_UART2_SIZE - 1, .flags = IORESOURCE_MEM, }, }; static struct resource resources_uart3[] = { { .start = INT_UART3, .end = INT_UART3, .flags = IORESOURCE_IRQ, }, { .start = MSM_UART3_PHYS, .end = MSM_UART3_PHYS + MSM_UART3_SIZE - 1, .flags = IORESOURCE_MEM, }, }; struct platform_device msm_device_uart1 = { .name = "msm_serial", .id = 0, .num_resources = ARRAY_SIZE(resources_uart1), .resource = resources_uart1, }; struct platform_device msm_device_uart2 = { .name = "msm_serial", .id = 1, .num_resources = ARRAY_SIZE(resources_uart2), .resource = resources_uart2, }; struct platform_device msm_device_uart3 = { .name = "msm_serial", .id = 2, .num_resources = ARRAY_SIZE(resources_uart3), .resource = resources_uart3, }; #define MSM_UART1DM_PHYS 0xA0200000 static struct resource <API key>[] = { { .start = MSM_UART1DM_PHYS, .end = MSM_UART1DM_PHYS + PAGE_SIZE - 1, .flags = IORESOURCE_MEM, }, { .start = INT_UART1DM_IRQ, .end = INT_UART1DM_IRQ, .flags = IORESOURCE_IRQ, }, { .start = INT_UART1DM_RX, .end = INT_UART1DM_RX, .flags = IORESOURCE_IRQ, }, { .start = <API key>, .end = <API key>, .name = "uartdm_channels", .flags = IORESOURCE_DMA, }, { .start = <API key>, .end = <API key>, .name = "uartdm_crci", .flags = IORESOURCE_DMA, }, }; static u64 <API key> = DMA_BIT_MASK(32); struct platform_device msm_device_uart_dm1 = { .name = "msm_serial_hs", .id = 0, .num_resources = ARRAY_SIZE(<API key>), .resource = <API key>, .dev = { .dma_mask = &<API key>, .coherent_dma_mask = DMA_BIT_MASK(32), }, }; #define MSM_UART2DM_PHYS 0xA0300000 static struct resource <API key>[] = { { .start = MSM_UART2DM_PHYS, .end = MSM_UART2DM_PHYS + PAGE_SIZE - 1, .name = "uartdm_resource", .flags = IORESOURCE_MEM, }, { .start = INT_UART2DM_IRQ, .end = INT_UART2DM_IRQ, .flags = IORESOURCE_IRQ, }, }; struct platform_device msm_device_uart_dm2 = { .name = "msm_serial_hsl", .id = 0, .num_resources = ARRAY_SIZE(<API key>), .resource = <API key>, }; #define MSM_NAND_PHYS 0xA0A00000 #define MSM_NANDC01_PHYS 0xA0A40000 #define MSM_NANDC10_PHYS 0xA0A80000 #define MSM_NANDC11_PHYS 0xA0AC0000 #define EBI2_REG_BASE 0xA0D00000 static struct resource resources_nand[] = { [0] = { .name = "msm_nand_dmac", .start = DMOV_NAND_CHAN, .end = DMOV_NAND_CHAN, .flags = IORESOURCE_DMA, }, [1] = { .name = "msm_nand_phys", .start = MSM_NAND_PHYS, .end = MSM_NAND_PHYS + 0x7FF, .flags = IORESOURCE_MEM, }, [2] = { .name = "msm_nandc01_phys", .start = MSM_NANDC01_PHYS, .end = MSM_NANDC01_PHYS + 0x7FF, .flags = IORESOURCE_MEM, }, [3] = { .name = "msm_nandc10_phys", .start = MSM_NANDC10_PHYS, .end = MSM_NANDC10_PHYS + 0x7FF, .flags = IORESOURCE_MEM, }, [4] = { .name = "msm_nandc11_phys", .start = MSM_NANDC11_PHYS, .end = MSM_NANDC11_PHYS + 0x7FF, .flags = IORESOURCE_MEM, }, [5] = { .name = "ebi2_reg_base", .start = EBI2_REG_BASE, .end = EBI2_REG_BASE + 0x60, .flags = IORESOURCE_MEM, }, }; struct flash_platform_data msm_nand_data; struct platform_device msm_device_nand = { .name = "msm_nand", .id = -1, .num_resources = ARRAY_SIZE(resources_nand), .resource = resources_nand, .dev = { .platform_data = &msm_nand_data, }, }; #define MSM_SDC1_BASE 0xA0400000 #define MSM_SDC2_BASE 0xA0500000 #define MSM_SDC3_BASE 0xA0600000 #define MSM_SDC4_BASE 0xA0700000 static struct resource resources_sdc1[] = { { .start = MSM_SDC1_BASE, .end = MSM_SDC1_BASE + SZ_4K - 1, .flags = IORESOURCE_MEM, }, { .start = INT_SDC1_0, .end = INT_SDC1_1, .flags = IORESOURCE_IRQ, }, { .name = "sdcc_dma_chnl", .start = DMOV_SDC1_CHAN, .end = DMOV_SDC1_CHAN, .flags = IORESOURCE_DMA, }, { .name = "sdcc_dma_crci", .start = DMOV_SDC1_CRCI, .end = DMOV_SDC1_CRCI, .flags = IORESOURCE_DMA, } }; static struct resource resources_sdc2[] = { { .start = MSM_SDC2_BASE, .end = MSM_SDC2_BASE + SZ_4K - 1, .flags = IORESOURCE_MEM, }, { .start = INT_SDC2_0, .end = INT_SDC2_1, .flags = IORESOURCE_IRQ, }, { .name = "sdcc_dma_chnl", .start = DMOV_SDC2_CHAN, .end = DMOV_SDC2_CHAN, .flags = IORESOURCE_DMA, }, { .name = "sdcc_dma_crci", .start = DMOV_SDC2_CRCI, .end = DMOV_SDC2_CRCI, .flags = IORESOURCE_DMA, } }; #ifdef <API key> static struct resource resources_sdc3[] = { { .start = MSM_SDC3_BASE, .end = MSM_SDC3_BASE + SZ_4K - 1, .flags = IORESOURCE_MEM, }, { .start = INT_SDC3_0, .end = INT_SDC3_1, .flags = IORESOURCE_IRQ, }, { .name = "sdcc_dma_chnl", .start = DMOV_SDC3_CHAN, .end = DMOV_SDC3_CHAN, .flags = IORESOURCE_DMA, }, { .name = "sdcc_dma_crci", .start = DMOV_SDC3_CRCI, .end = DMOV_SDC3_CRCI, .flags = IORESOURCE_DMA, }, }; #else static struct resource resources_sdc3[] = { { .start = MSM_SDC3_BASE, .end = MSM_SDC3_BASE + SZ_4K - 1, .flags = IORESOURCE_MEM, }, { .start = INT_SDC3_0, .end = INT_SDC3_1, .flags = IORESOURCE_IRQ, }, { .name = "sdcc_dma_chnl", .start = DMOV_SDC4_CHAN, .end = DMOV_SDC4_CHAN, .flags = IORESOURCE_DMA, }, { .name = "sdcc_dma_crci", .start = DMOV_SDC4_CRCI, .end = DMOV_SDC4_CRCI, .flags = IORESOURCE_DMA, }, }; #endif static struct resource resources_sdc4[] = { { .start = MSM_SDC4_BASE, .end = MSM_SDC4_BASE + SZ_4K - 1, .flags = IORESOURCE_MEM, }, { .start = INT_SDC4_0, .end = INT_SDC4_1, .flags = IORESOURCE_IRQ, }, { .name = "sdcc_dma_chnl", .start = DMOV_SDC3_CHAN, .end = DMOV_SDC3_CHAN, .flags = IORESOURCE_DMA, }, { .name = "sdcc_dma_crci", .start = DMOV_SDC3_CRCI, .end = DMOV_SDC3_CRCI, .flags = IORESOURCE_DMA, }, }; struct platform_device msm_device_sdc1 = { .name = "msm_sdcc", .id = 1, .num_resources = ARRAY_SIZE(resources_sdc1), .resource = resources_sdc1, .dev = { .coherent_dma_mask = 0xffffffff, }, }; struct platform_device msm_device_sdc2 = { .name = "msm_sdcc", .id = 2, .num_resources = ARRAY_SIZE(resources_sdc2), .resource = resources_sdc2, .dev = { .coherent_dma_mask = 0xffffffff, }, }; struct platform_device msm_device_sdc3 = { .name = "msm_sdcc", .id = 3, .num_resources = ARRAY_SIZE(resources_sdc3), .resource = resources_sdc3, .dev = { .coherent_dma_mask = 0xffffffff, }, }; struct platform_device msm_device_sdc4 = { .name = "msm_sdcc", .id = 4, .num_resources = ARRAY_SIZE(resources_sdc4), .resource = resources_sdc4, .dev = { .coherent_dma_mask = 0xffffffff, }, }; static struct platform_device *msm_sdcc_devices[] __initdata = { &msm_device_sdc1, &msm_device_sdc2, &msm_device_sdc3, &msm_device_sdc4, }; int __init msm_add_sdcc(unsigned int controller, struct mmc_platform_data *plat) { struct platform_device *pdev; if (controller < 1 || controller > 4) return -EINVAL; pdev = msm_sdcc_devices[controller-1]; pdev->dev.platform_data = plat; return <API key>(pdev); } #define MDP_BASE 0xAA200000 #define MIPI_DSI_HW_BASE 0xA1100000 static struct resource <API key>[] = { { .name = "mipi_dsi", .start = MIPI_DSI_HW_BASE, .end = MIPI_DSI_HW_BASE + 0x000F0000 - 1, .flags = IORESOURCE_MEM, }, { .start = INT_DSI_IRQ, .end = INT_DSI_IRQ, .flags = IORESOURCE_IRQ, }, }; static struct platform_device msm_mipi_dsi_device = { .name = "mipi_dsi", .id = 1, .num_resources = ARRAY_SIZE(<API key>), .resource = <API key>, }; static struct resource msm_mdp_resources[] = { { .name = "mdp", .start = MDP_BASE, .end = MDP_BASE + 0x000F1008 - 1, .flags = IORESOURCE_MEM, }, { .start = INT_MDP, .end = INT_MDP, .flags = IORESOURCE_IRQ, }, }; static struct platform_device msm_mdp_device = { .name = "mdp", .id = 0, .num_resources = ARRAY_SIZE(msm_mdp_resources), .resource = msm_mdp_resources, }; static struct platform_device msm_lcdc_device = { .name = "lcdc", .id = 0, }; #ifdef <API key> static struct resource kgsl_3d0_resources[] = { { .name = KGSL_3D0_REG_MEMORY, .start = 0xA0000000, .end = 0xA001ffff, .flags = IORESOURCE_MEM, }, { .name = KGSL_3D0_IRQ, .start = INT_GRAPHICS, .end = INT_GRAPHICS, .flags = IORESOURCE_IRQ, }, }; static struct <API key> kgsl_3d0_pdata = { .pwrlevel = { { .gpu_freq = 245760000, .bus_freq = 200000000, }, { .gpu_freq = 192000000, .bus_freq = 160000000, }, { .gpu_freq = 133330000, .bus_freq = 0, }, }, .init_level = 0, .num_levels = 3, .set_grp_async = set_grp_xbar_async, .idle_timeout = HZ, .strtstp_sleepwake = true, .nap_allowed = false, .clk_map = KGSL_CLK_CORE | KGSL_CLK_IFACE | KGSL_CLK_MEM, }; struct platform_device msm_kgsl_3d0 = { .name = "kgsl-3d0", .id = 0, .num_resources = ARRAY_SIZE(kgsl_3d0_resources), .resource = kgsl_3d0_resources, .dev = { .platform_data = &kgsl_3d0_pdata, }, }; void __init <API key>(void) { if (cpu_is_msm7x25a() || cpu_is_msm7x25aa()) { kgsl_3d0_pdata.num_levels = 2; kgsl_3d0_pdata.pwrlevel[0].gpu_freq = 133330000; kgsl_3d0_pdata.pwrlevel[0].bus_freq = 160000000; kgsl_3d0_pdata.pwrlevel[1].gpu_freq = 96000000; kgsl_3d0_pdata.pwrlevel[1].bus_freq = 0; } } #endif static void __init msm_register_device(struct platform_device *pdev, void *data) { int ret; pdev->dev.platform_data = data; ret = <API key>(pdev); if (ret) dev_err(&pdev->dev, "%s: <API key>() failed = %d\n", __func__, ret); } void __init <API key>(char *name, void *data) { if (!strncmp(name, "mdp", 3)) msm_register_device(&msm_mdp_device, data); else if (!strncmp(name, "mipi_dsi", 8)) msm_register_device(&msm_mipi_dsi_device, data); else if (!strncmp(name, "lcdc", 4)) msm_register_device(&msm_lcdc_device, data); else printk(KERN_ERR "%s: unknown device! %s\n", __func__, name); } #define <API key> (0xA9D00040) #define PDM0_CTL_OFFSET (0x04) #define SIZE_8B (0x08) static struct resource resources_led[] = { { .start = <API key>, .end = <API key> + (SIZE_8B) - 1, .name = "led-gpio-pdm", .flags = IORESOURCE_MEM, }, }; static struct led_info <API key> = { .name = "keyboard-backlight", }; struct platform_device led_pdev = { .name = "leds-msm-pdm", /* use pdev id to represent pdm id */ .id = 0, .num_resources = ARRAY_SIZE(resources_led), .resource = resources_led, .dev = { .platform_data = &<API key>, }, }; struct platform_device asoc_msm_pcm = { .name = "msm-dsp-audio", .id = 0, }; struct platform_device asoc_msm_dai0 = { .name = "msm-codec-dai", .id = 0, }; struct platform_device asoc_msm_dai1 = { .name = "msm-cpu-dai", .id = 0, }; int __init msm7x2x_misc_init(void) { msm_clock_init(&<API key>); if (cpu_is_msm7x27aa()) acpuclk_init(&<API key>); else acpuclk_init(&<API key>); return 0; } #ifdef CONFIG_CACHE_L2X0 static int __init msm7x27x_cache_init(void) { int aux_ctrl = 0; /* Way Size 010(0x2) 32KB */ aux_ctrl = (0x1 << <API key>) | \ (0x2 << <API key>) | \ (0x1 << <API key>); l2x0_init(MSM_L2CC_BASE, aux_ctrl, L2X0_AUX_CTRL_MASK); return 0; } #else static int __init msm7x27x_cache_init(void){ return 0; } #endif void __init msm_common_io_init(void) { msm_map_common_io(); msm7x27x_cache_init(); if (socinfo_init() < 0) pr_err("%s: socinfo_init() failed!\n", __func__); } struct platform_device *<API key>[] = { FS_PCOM(FS_GFX3D, "fs_gfx3d"), }; unsigned <API key> = ARRAY_SIZE(<API key>);
using System; using System.Globalization; using System.IO; using System.Security.Permissions; using System.Security.Policy; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; public partial class UserProfile : Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Request["User"] == null) { Response.Redirect("MainPage.aspx"); return; } Guid userId; if (!Guid.TryParse(Request["User"], out userId)) { Response.Redirect("MainPage.aspx"); return; } var membershipUser = Membership.GetUser(userId); if (membershipUser == null) { Response.Redirect("MainPage.aspx"); return; } <API key>(userId); <API key>(membershipUser); <API key>(membershipUser); } } private void <API key>(Guid userId) { pnlEditProfile.Visible = false; pnlShowProfile.Visible = true; lvShowChecker.Visible = UserInteraction.<API key>(userId); lvEditChecker.Visible = lvShowChecker.Visible; } private void <API key>(MembershipUser membershipUser) { if (membershipUser == null) { return; } var userProfile = Profile.GetProfile(membershipUser.UserName); lblUsernameShow.Text = membershipUser.UserName; lblFirstNameShow.Text = userProfile.FirstName; lblLastNameShow.Text = userProfile.LastName; lblBirthDateShow.Text = userProfile.BirthDate.HasValue ? userProfile.BirthDate.Value.ToString("dd MMMMM yyyy", CultureInfo.<API key>("en-us")) : string.Empty; lblAgeShow.Text = userProfile.BirthDate.HasValue ? ((DateTime.Now - userProfile.BirthDate.Value).Days / 365).ToString() : string.Empty; hlEmailShow.Text = membershipUser.Email; hlEmailShow.NavigateUrl = string.Format("mailto:{0}", membershipUser.Email); lblRoleShow.Text = Roles.GetRolesForUser(membershipUser.UserName)[0]; if (membershipUser.ProviderUserKey != null) { <API key>.ImageUrl = UserInteraction.MakeProfileUrl((Guid)membershipUser.ProviderUserKey); } <API key>.ImageAlign = ImageAlign.Middle; } private void <API key>(MembershipUser membershipUser) { if (membershipUser == null) { return; } var userProfile = Profile.GetProfile(membershipUser.UserName); lblUsernameEdit.Text = membershipUser.UserName; tbFirstNameEdit.Text = userProfile.FirstName; tbLastNameEdit.Text = userProfile.LastName; tbBirthDateEdit.Text = userProfile.BirthDate.HasValue ? userProfile.BirthDate.Value.ToString("dd MMMMM yyyy", CultureInfo.<API key>("en-us")) : string.Empty; lblAgeEdit.Text = userProfile.BirthDate.HasValue ? ((DateTime.Now - userProfile.BirthDate.Value).Days / 365).ToString() : string.Empty; tbEmailEdit.Text = membershipUser.Email; lblRoleEdit.Text = Roles.GetRolesForUser(membershipUser.UserName)[0]; if (membershipUser.ProviderUserKey != null) { <API key>.ImageUrl = UserInteraction.MakeProfileUrl((Guid)membershipUser.ProviderUserKey); } <API key>.ImageAlign = ImageAlign.Middle; } protected void EditButtonClick(object sender, EventArgs e) { pnlEditProfile.Visible = true; pnlShowProfile.Visible = false; } protected void CancelButtonClick(object sender, EventArgs e) { if (Request["User"] == null) { return; } Guid userId; if (!Guid.TryParse(Request["User"], out userId)) { return; } var membershipUser = Membership.GetUser(userId); if (membershipUser == null) { return; } <API key>(membershipUser); pnlEditProfile.Visible = false; pnlShowProfile.Visible = true; } protected void UpdateButtonClick(object sender, EventArgs e) { if (Request["User"] == null) { return; } Guid userId; if (!Guid.TryParse(Request["User"], out userId)) { return; } var membershipUser = Membership.GetUser(userId); if (membershipUser == null) { return; } membershipUser.Email = tbEmailEdit.Text; var userProfile = Profile.GetProfile(membershipUser.UserName); userProfile.FirstName = tbFirstNameEdit.Text; userProfile.LastName = tbLastNameEdit.Text; if (!string.IsNullOrWhiteSpace(tbBirthDateEdit.Text)) { userProfile.BirthDate = DateTime.Parse(tbBirthDateEdit.Text); } if (fuUserProfileImage.HasFile) { var filePath = Server.MapPath("ProfileImages") + Path.<API key> + membershipUser.ProviderUserKey; fuUserProfileImage.SaveAs(filePath); userProfile.ProfilePicture = "/ForumWebsite" + "/" + "ProfileImages" + "/" + membershipUser.ProviderUserKey; } userProfile.Save(); <API key>(membershipUser); <API key>(membershipUser); pnlEditProfile.Visible = false; pnlShowProfile.Visible = true; } }
# pyraw python and raw sockets author: deadc0de6 A simple python script using raw sockets and epoll for fast processing packets Some example of implementations using scapy to forge the packets: - *ping.py* - a simple ping implementation - *syn-scanner.py* - a basic SYN scanner - *naive-traceroute.py* - a naive tracerouter with multiple protocols (tcp, udp, icmp)
#include <linux/module.h> #include <linux/init.h> #include <linux/firmware.h> #include <linux/slab.h> #include <linux/platform_device.h> #include <linux/device.h> #include <linux/printk.h> #include <linux/ratelimit.h> #include <linux/debugfs.h> #include <linux/wait.h> #include <linux/bitops.h> #include <linux/mfd/wcd9xxx/core.h> #include <linux/mfd/wcd9xxx/wcd9xxx_registers.h> #include <linux/mfd/wcd9xxx/wcd9306_registers.h> #include <linux/mfd/wcd9xxx/pdata.h> #include <linux/regulator/consumer.h> #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/soc.h> #include <sound/soc-dapm.h> #include <sound/tlv.h> #include <linux/bitops.h> #include <linux/delay.h> #include <linux/pm_runtime.h> #include <linux/kernel.h> #include <linux/gpio.h> #include "wcd9306.h" #include "wcd9xxx-resmgr.h" #include "wcd9xxx-common.h" #define <API key> 5000 #define <API key> 13000 #define <API key> "MIC BIAS2 External Standalone" #define <API key>(port) ((port >= 16) && (port <= 20)) #define <API key>(port) (port - 16) /* RX1 port ID = 0 */ #define <API key> 10000 #define <API key> 2000 /* RX_HPH_CNP_WG_TIME increases by 0.24ms */ #define <API key> 240 #define <API key> 0x40 #define <API key> 0x50 #define <API key> 0x800 #define <API key> 1 static struct regulator *<API key>( struct snd_soc_codec *codec, const char *name); static atomic_t kp_tapan_priv; static int <API key>(const char *val, const struct kernel_param *kp); static int spkr_drv_wrnd = 1; static struct kernel_param_ops <API key> = { .set = <API key>, .get = param_get_int, }; module_param_cb(spkr_drv_wrnd, &<API key>, &spkr_drv_wrnd, 0644); MODULE_PARM_DESC(spkr_drv_wrnd, "Run software workaround to avoid leakage on the speaker drive"); #define WCD9306_RATES (SNDRV_PCM_RATE_8000 | <API key> |\ <API key> | <API key> |\ <API key> | <API key>) #define WCD9302_RATES (SNDRV_PCM_RATE_8000 | <API key> |\ <API key> | <API key>) #define NUM_DECIMATORS 4 #define NUM_INTERPOLATORS 4 #define BITS_PER_REG 8 /* This actual number of TX ports supported in slimbus slave */ #define <API key> 16 #define <API key> 16 /* Nummer of TX ports actually connected from Slimbus slave to codec Digital */ #define <API key> 5 #define <API key> 0x08 #define <API key> 12288000 #define <API key> 9600000 #define <API key> 1000 #define <API key> (1 << 0) #define <API key> (1 << 1) #define <API key> (1 << 2) enum tapan_codec_type { WCD9306, WCD9302, }; static enum tapan_codec_type codec_ver; /* * Multiplication factor to compute impedance on Tapan * This is computed from (Vx / (m*Ical)) = (10mV/(180*30uA)) */ #define <API key> 1852 static struct <API key> audio_reg_cfg[] = { { <API key>, (<API key> + <API key>), <API key>, 0x1E, 8, 0x1 }, { <API key>, (<API key> + <API key>), <API key>, 0x1, 8, 0x1 }, { <API key>, (<API key> + <API key>), <API key>, 0x1E, 8, 0x1 }, { <API key>, (<API key> + <API key>), <API key>, 0x1, 8, 0x1 }, { <API key>, (<API key> + <API key>), <API key>, 0x4, 8, 0 }, { <API key>, (<API key> + <API key>), <API key>, 0x8, 8, 0 }, { <API key>, (<API key> + <API key>), AANC_GAIN_CONTROL, 0xFF, 8, 0 }, }; static struct <API key> tapan_audio_reg_cfg = { .num_registers = ARRAY_SIZE(audio_reg_cfg), .reg_data = audio_reg_cfg, }; static struct <API key> <API key> = { .<API key> = <API key>, .aanc_hw_version = <API key>, }; enum { AIF1_PB = 0, AIF1_CAP, AIF2_PB, AIF2_CAP, AIF3_PB, AIF3_CAP, NUM_CODEC_DAIS, }; enum { <API key> = 0, <API key>, <API key>, <API key>, <API key>, RX_MIX1_INP_SEL_RX1, RX_MIX1_INP_SEL_RX2, RX_MIX1_INP_SEL_RX3, RX_MIX1_INP_SEL_RX4, RX_MIX1_INP_SEL_RX5, <API key>, }; #define <API key> 3 static const <API key>(digital_gain, 0, 1, 0); static const <API key>(line_gain, 0, 7, 1); static const <API key>(analog_gain, 0, 25, 1); static struct snd_soc_dai_driver tapan_dai[]; static const <API key>(aux_pga_gain, 0, 2, 0); /* Codec supports 2 IIR filters */ enum { IIR1 = 0, IIR2, IIR_MAX, }; /* Codec supports 5 bands */ enum { BAND1 = 0, BAND2, BAND3, BAND4, BAND5, BAND_MAX, }; enum { COMPANDER_0, COMPANDER_1, COMPANDER_2, COMPANDER_MAX, }; enum { COMPANDER_FS_8KHZ = 0, COMPANDER_FS_16KHZ, COMPANDER_FS_32KHZ, COMPANDER_FS_48KHZ, COMPANDER_FS_96KHZ, COMPANDER_FS_192KHZ, COMPANDER_FS_MAX, }; struct <API key> { u32 peak_det_timeout; u32 rms_meter_div_fact; u32 <API key>; }; struct hpf_work { struct tapan_priv *tapan; u32 decimator; u8 tx_hpf_cut_of_freq; struct delayed_work dwork; }; static struct hpf_work tx_hpf_work[NUM_DECIMATORS]; static const struct wcd9xxx_ch tapan_rx_chs[TAPAN_RX_MAX] = { WCD9XXX_CH(<API key>, 0), WCD9XXX_CH(<API key> + 1, 1), WCD9XXX_CH(<API key> + 2, 2), WCD9XXX_CH(<API key> + 3, 3), WCD9XXX_CH(<API key> + 4, 4), }; static const struct wcd9xxx_ch tapan_tx_chs[TAPAN_TX_MAX] = { WCD9XXX_CH(0, 0), WCD9XXX_CH(1, 1), WCD9XXX_CH(2, 2), WCD9XXX_CH(3, 3), WCD9XXX_CH(4, 4), }; static const u32 vport_check_table[NUM_CODEC_DAIS] = { 0, /* AIF1_PB */ (1 << AIF2_CAP) | (1 << AIF3_CAP), /* AIF1_CAP */ 0, /* AIF2_PB */ (1 << AIF1_CAP) | (1 << AIF3_CAP), /* AIF2_CAP */ 0, /* AIF2_PB */ (1 << AIF1_CAP) | (1 << AIF2_CAP), /* AIF2_CAP */ }; static const u32 <API key>[NUM_CODEC_DAIS] = { 0, /* AIF1_PB */ 0, /* AIF1_CAP */ }; enum { CP_REG_BUCK = 0, CP_REG_BHELPER, CP_REG_MAX, }; struct tapan_priv { struct snd_soc_codec *codec; u32 adc_count; u32 rx_bias_count; s32 dmic_1_2_clk_cnt; s32 dmic_3_4_clk_cnt; s32 dmic_5_6_clk_cnt; s32 ldo_h_users; s32 micb_2_users; u32 anc_slot; bool anc_func; /*track adie loopback mode*/ bool lb_mode; /*track tapan interface type*/ u8 intf_type; /* num of slim ports required */ struct <API key> dai[NUM_CODEC_DAIS]; /*compander*/ int comp_enabled[COMPANDER_MAX]; u32 comp_fs[COMPANDER_MAX]; /* Maintain the status of AUX PGA */ int aux_pga_cnt; u8 aux_l_gain; u8 aux_r_gain; bool dec_active[NUM_DECIMATORS]; bool spkr_pa_widget_on; struct <API key> slimbus_slave_cfg; /* resmgr module */ struct wcd9xxx_resmgr resmgr; /* mbhc module */ struct wcd9xxx_mbhc mbhc; /* class h specific data */ struct <API key> clsh_d; /* pointers to regulators required for chargepump */ struct regulator *cp_regulators[CP_REG_MAX]; /* * list used to save/restore registers at start and * end of impedance measurement */ struct list_head reg_save_restore; int (*<API key>)(struct snd_soc_codec *codec, enum wcd9xxx_codec_event); }; static const u32 comp_shift[] = { 0, 1, 2, }; static const int comp_rx_path[] = { COMPANDER_1, COMPANDER_1, COMPANDER_2, COMPANDER_2, COMPANDER_MAX, }; static const struct <API key> comp_samp_params[] = { { /* 8 Khz */ .peak_det_timeout = 0x06, .rms_meter_div_fact = 0x09, .<API key> = 0x06, }, { /* 16 Khz */ .peak_det_timeout = 0x07, .rms_meter_div_fact = 0x0A, .<API key> = 0x0C, }, { /* 32 Khz */ .peak_det_timeout = 0x08, .rms_meter_div_fact = 0x0B, .<API key> = 0x1E, }, { /* 48 Khz */ .peak_det_timeout = 0x09, .rms_meter_div_fact = 0x0B, .<API key> = 0x28, }, { /* 96 Khz */ .peak_det_timeout = 0x0A, .rms_meter_div_fact = 0x0C, .<API key> = 0x50, }, { /* 192 Khz */ .peak_det_timeout = 0x0B, .rms_meter_div_fact = 0xC, .<API key> = 0xA0, }, }; static unsigned short rx_digital_gain_reg[] = { <API key>, <API key>, <API key>, <API key>, }; static unsigned short tx_digital_gain_reg[] = { <API key>, <API key>, <API key>, <API key>, }; static int <API key>(const char *val, const struct kernel_param *kp) { struct snd_soc_codec *codec; int ret, old; struct tapan_priv *priv; priv = (struct tapan_priv *)atomic_read(&kp_tapan_priv); if (!priv) { pr_debug("%s: codec isn't yet registered\n", __func__); return 0; } codec = priv->codec; mutex_lock(&codec->mutex); old = spkr_drv_wrnd; ret = param_set_int(val, kp); if (ret) { mutex_unlock(&codec->mutex); return ret; } dev_dbg(codec->dev, "%s: spkr_drv_wrnd %d -> %d\n", __func__, old, spkr_drv_wrnd); if ((old == -1 || old == 0) && spkr_drv_wrnd == 1) { WCD9XXX_BG_CLK_LOCK(&priv->resmgr); <API key>(&priv->resmgr, <API key>); <API key>(&priv->resmgr); snd_soc_update_bits(codec, TAPAN_A_SPKR_DRV_EN, 0x80, 0x80); } else if (old == 1 && spkr_drv_wrnd == 0) { WCD9XXX_BG_CLK_LOCK(&priv->resmgr); <API key>(&priv->resmgr, <API key>); <API key>(&priv->resmgr); if (!priv->spkr_pa_widget_on) snd_soc_update_bits(codec, TAPAN_A_SPKR_DRV_EN, 0x80, 0x00); } mutex_unlock(&codec->mutex); return 0; } static int tapan_get_anc_slot(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); struct tapan_priv *tapan = <API key>(codec); ucontrol->value.integer.value[0] = tapan->anc_slot; return 0; } static int tapan_put_anc_slot(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); struct tapan_priv *tapan = <API key>(codec); tapan->anc_slot = ucontrol->value.integer.value[0]; return 0; } static int tapan_get_anc_func(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); struct tapan_priv *tapan = <API key>(codec); ucontrol->value.integer.value[0] = (tapan->anc_func == true ? 1 : 0); return 0; } static int tapan_put_anc_func(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); struct tapan_priv *tapan = <API key>(codec); struct <API key> *dapm = &codec->dapm; mutex_lock(&dapm->codec->mutex); tapan->anc_func = (!ucontrol->value.integer.value[0] ? false : true); dev_err(codec->dev, "%s: anc_func %x", __func__, tapan->anc_func); if (tapan->anc_func == true) { pr_info("enable anc virtual widgets"); <API key>(dapm, "ANC HPHR"); <API key>(dapm, "ANC HPHL"); <API key>(dapm, "ANC HEADPHONE"); <API key>(dapm, "ANC EAR PA"); <API key>(dapm, "ANC EAR"); <API key>(dapm, "HPHR"); <API key>(dapm, "HPHL"); <API key>(dapm, "HEADPHONE"); <API key>(dapm, "EAR PA"); <API key>(dapm, "EAR"); } else { pr_info("disable anc virtual widgets"); <API key>(dapm, "ANC HPHR"); <API key>(dapm, "ANC HPHL"); <API key>(dapm, "ANC HEADPHONE"); <API key>(dapm, "ANC EAR PA"); <API key>(dapm, "ANC EAR"); <API key>(dapm, "HPHR"); <API key>(dapm, "HPHL"); <API key>(dapm, "HEADPHONE"); <API key>(dapm, "EAR PA"); <API key>(dapm, "EAR"); } snd_soc_dapm_sync(dapm); mutex_unlock(&dapm->codec->mutex); return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); struct tapan_priv *tapan = <API key>(codec); ucontrol->value.integer.value[0] = tapan->lb_mode; dev_dbg(codec->dev, "%s: lb_mode = %d\n", __func__, tapan->lb_mode); return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); struct tapan_priv *tapan = <API key>(codec); dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", __func__, ucontrol->value.integer.value[0]); switch (ucontrol->value.integer.value[0]) { case 0: tapan->lb_mode = false; break; case 1: tapan->lb_mode = true; break; default: return -EINVAL; } return 0; } static int tapan_pa_gain_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { u8 ear_pa_gain; int rc = 0; struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); ear_pa_gain = snd_soc_read(codec, TAPAN_A_RX_EAR_GAIN); ear_pa_gain = ear_pa_gain >> 5; switch (ear_pa_gain) { case 0: case 1: case 2: case 3: case 4: case 5: ucontrol->value.integer.value[0] = ear_pa_gain; break; case 7: ucontrol->value.integer.value[0] = (ear_pa_gain - 1); break; default: rc = -EINVAL; pr_err("%s: ERROR: Unsupported Ear Gain = 0x%x\n", __func__, ear_pa_gain); break; } dev_dbg(codec->dev, "%s: ear_pa_gain = 0x%x\n", __func__, ear_pa_gain); return rc; } static int tapan_pa_gain_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { u8 ear_pa_gain; int rc = 0; struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", __func__, ucontrol->value.integer.value[0]); switch (ucontrol->value.integer.value[0]) { case 0: case 1: case 2: case 3: case 4: case 5: ear_pa_gain = ucontrol->value.integer.value[0]; break; case 6: ear_pa_gain = 0x07; break; default: rc = -EINVAL; break; } if (!rc) snd_soc_update_bits(codec, TAPAN_A_RX_EAR_GAIN, 0xE0, ear_pa_gain << 5); return rc; } static int <API key>( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); int iir_idx = ((struct <API key> *) kcontrol->private_value)->reg; int band_idx = ((struct <API key> *) kcontrol->private_value)->shift; ucontrol->value.integer.value[0] = (snd_soc_read(codec, (<API key> + 16 * iir_idx)) & (1 << band_idx)) != 0; dev_dbg(codec->dev, "%s: IIR #%d band #%d enable %d\n", __func__, iir_idx, band_idx, (uint32_t)ucontrol->value.integer.value[0]); return 0; } static int <API key>( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); int iir_idx = ((struct <API key> *) kcontrol->private_value)->reg; int band_idx = ((struct <API key> *) kcontrol->private_value)->shift; int value = ucontrol->value.integer.value[0]; /* Mask first 5 bits, 6-8 are reserved */ snd_soc_update_bits(codec, (<API key> + 16 * iir_idx), (1 << band_idx), (value << band_idx)); pr_debug("%s: IIR #%d band #%d enable %d\n", __func__, iir_idx, band_idx, ((snd_soc_read(codec, (<API key> + 16 * iir_idx)) & (1 << band_idx)) != 0)); return 0; } static uint32_t get_iir_band_coeff(struct snd_soc_codec *codec, int iir_idx, int band_idx, int coeff_idx) { uint32_t value = 0; /* Address does not automatically update if reading */ snd_soc_write(codec, (<API key> + 16 * iir_idx), ((band_idx * BAND_MAX + coeff_idx) * sizeof(uint32_t)) & 0x7F); value |= snd_soc_read(codec, (<API key> + 16 * iir_idx)); snd_soc_write(codec, (<API key> + 16 * iir_idx), ((band_idx * BAND_MAX + coeff_idx) * sizeof(uint32_t) + 1) & 0x7F); value |= (snd_soc_read(codec, (<API key> + 16 * iir_idx)) << 8); snd_soc_write(codec, (<API key> + 16 * iir_idx), ((band_idx * BAND_MAX + coeff_idx) * sizeof(uint32_t) + 2) & 0x7F); value |= (snd_soc_read(codec, (<API key> + 16 * iir_idx)) << 16); snd_soc_write(codec, (<API key> + 16 * iir_idx), ((band_idx * BAND_MAX + coeff_idx) * sizeof(uint32_t) + 3) & 0x7F); /* Mask bits top 2 bits since they are reserved */ value |= ((snd_soc_read(codec, (<API key> + 16 * iir_idx)) & 0x3F) << 24); return value; } static int <API key>( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); int iir_idx = ((struct <API key> *) kcontrol->private_value)->reg; int band_idx = ((struct <API key> *) kcontrol->private_value)->shift; ucontrol->value.integer.value[0] = get_iir_band_coeff(codec, iir_idx, band_idx, 0); ucontrol->value.integer.value[1] = get_iir_band_coeff(codec, iir_idx, band_idx, 1); ucontrol->value.integer.value[2] = get_iir_band_coeff(codec, iir_idx, band_idx, 2); ucontrol->value.integer.value[3] = get_iir_band_coeff(codec, iir_idx, band_idx, 3); ucontrol->value.integer.value[4] = get_iir_band_coeff(codec, iir_idx, band_idx, 4); dev_dbg(codec->dev, "%s: IIR #%d band #%d b0 = 0x%x\n" "%s: IIR #%d band #%d b1 = 0x%x\n" "%s: IIR #%d band #%d b2 = 0x%x\n" "%s: IIR #%d band #%d a1 = 0x%x\n" "%s: IIR #%d band #%d a2 = 0x%x\n", __func__, iir_idx, band_idx, (uint32_t)ucontrol->value.integer.value[0], __func__, iir_idx, band_idx, (uint32_t)ucontrol->value.integer.value[1], __func__, iir_idx, band_idx, (uint32_t)ucontrol->value.integer.value[2], __func__, iir_idx, band_idx, (uint32_t)ucontrol->value.integer.value[3], __func__, iir_idx, band_idx, (uint32_t)ucontrol->value.integer.value[4]); return 0; } static void set_iir_band_coeff(struct snd_soc_codec *codec, int iir_idx, int band_idx, uint32_t value) { snd_soc_write(codec, (<API key> + 16 * iir_idx), (value & 0xFF)); snd_soc_write(codec, (<API key> + 16 * iir_idx), (value >> 8) & 0xFF); snd_soc_write(codec, (<API key> + 16 * iir_idx), (value >> 16) & 0xFF); /* Mask top 2 bits, 7-8 are reserved */ snd_soc_write(codec, (<API key> + 16 * iir_idx), (value >> 24) & 0x3F); } static int <API key>( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); int iir_idx = ((struct <API key> *) kcontrol->private_value)->reg; int band_idx = ((struct <API key> *) kcontrol->private_value)->shift; /* Mask top bit it is reserved */ /* Updates addr automatically for each B2 write */ snd_soc_write(codec, (<API key> + 16 * iir_idx), (band_idx * BAND_MAX * sizeof(uint32_t)) & 0x7F); set_iir_band_coeff(codec, iir_idx, band_idx, ucontrol->value.integer.value[0]); set_iir_band_coeff(codec, iir_idx, band_idx, ucontrol->value.integer.value[1]); set_iir_band_coeff(codec, iir_idx, band_idx, ucontrol->value.integer.value[2]); set_iir_band_coeff(codec, iir_idx, band_idx, ucontrol->value.integer.value[3]); set_iir_band_coeff(codec, iir_idx, band_idx, ucontrol->value.integer.value[4]); dev_dbg(codec->dev, "%s: IIR #%d band #%d b0 = 0x%x\n" "%s: IIR #%d band #%d b1 = 0x%x\n" "%s: IIR #%d band #%d b2 = 0x%x\n" "%s: IIR #%d band #%d a1 = 0x%x\n" "%s: IIR #%d band #%d a2 = 0x%x\n", __func__, iir_idx, band_idx, get_iir_band_coeff(codec, iir_idx, band_idx, 0), __func__, iir_idx, band_idx, get_iir_band_coeff(codec, iir_idx, band_idx, 1), __func__, iir_idx, band_idx, get_iir_band_coeff(codec, iir_idx, band_idx, 2), __func__, iir_idx, band_idx, get_iir_band_coeff(codec, iir_idx, band_idx, 3), __func__, iir_idx, band_idx, get_iir_band_coeff(codec, iir_idx, band_idx, 4)); return 0; } static int tapan_get_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); int comp = ((struct <API key> *) kcontrol->private_value)->shift; struct tapan_priv *tapan = <API key>(codec); ucontrol->value.integer.value[0] = tapan->comp_enabled[comp]; return 0; } static int tapan_set_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); struct tapan_priv *tapan = <API key>(codec); int comp = ((struct <API key> *) kcontrol->private_value)->shift; int value = ucontrol->value.integer.value[0]; dev_dbg(codec->dev, "%s: Compander %d enable current %d, new %d\n", __func__, comp, tapan->comp_enabled[comp], value); tapan->comp_enabled[comp] = value; if (comp == COMPANDER_1 && tapan->comp_enabled[comp] == 1) { /* Wavegen to 5 msec */ snd_soc_write(codec, <API key>, 0xDA); snd_soc_write(codec, <API key>, 0x15); snd_soc_write(codec, <API key>, 0x2A); /* Enable Chopper */ snd_soc_update_bits(codec, <API key>, 0x80, 0x80); snd_soc_write(codec, TAPAN_A_NCP_DTEST, 0x20); pr_debug("%s: Enabled Chopper and set wavegen to 5 msec\n", __func__); } else if (comp == COMPANDER_1 && tapan->comp_enabled[comp] == 0) { /* Wavegen to 20 msec */ snd_soc_write(codec, <API key>, 0xDB); snd_soc_write(codec, <API key>, 0x58); snd_soc_write(codec, <API key>, 0x1A); /* Disable CHOPPER block */ snd_soc_update_bits(codec, <API key>, 0x80, 0x00); snd_soc_write(codec, TAPAN_A_NCP_DTEST, 0x10); pr_debug("%s: Disabled Chopper and set wavegen to 20 msec\n", __func__); } return 0; } static int <API key>(struct snd_soc_codec *codec, int comp, bool enable) { int ret = 0; switch (comp) { case COMPANDER_0: snd_soc_update_bits(codec, <API key>, 1 << 2, !enable << 2); break; case COMPANDER_1: snd_soc_update_bits(codec, <API key>, 1 << 5, !enable << 5); snd_soc_update_bits(codec, <API key>, 1 << 5, !enable << 5); break; case COMPANDER_2: snd_soc_update_bits(codec, <API key>, 1 << 5, !enable << 5); snd_soc_update_bits(codec, <API key>, 1 << 5, !enable << 5); break; default: WARN_ON(1); ret = -EINVAL; } return ret; } static void <API key>(struct snd_soc_codec *codec, int comp) { /* Level meter DIV Factor to 5*/ snd_soc_update_bits(codec, <API key> + (comp * 8), 0xF0, 0x05 << 4); /* RMS meter Sampling to 0x01 */ snd_soc_write(codec, <API key> + (comp * 8), 0x01); /* Worst case timeout for compander CnP sleep timeout */ usleep_range(3000, 3000); } static enum wcd9xxx_buck_volt <API key>( struct snd_soc_codec *codec) { int buck_volt = <API key>; struct tapan_priv *tapan = <API key>(codec); struct wcd9xxx_pdata *pdata = tapan->resmgr.pdata; int i; bool found_regulator = false; for (i = 0; i < ARRAY_SIZE(pdata->regulator); i++) { if (pdata->regulator[i].name == NULL) continue; if (!strncmp(pdata->regulator[i].name, <API key>, sizeof(<API key>))) { found_regulator = true; if ((pdata->regulator[i].min_uV == <API key>) || (pdata->regulator[i].min_uV == <API key>)) buck_volt = pdata->regulator[i].min_uV; break; } } if (!found_regulator) dev_err(codec->dev, "%s: Failed to find regulator for %s\n", __func__, <API key>); else dev_dbg(codec->dev, "%s: S4 voltage requested is %d\n", __func__, buck_volt); return buck_volt; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { int mask, enable_mask; u8 rdac5_mux; struct snd_soc_codec *codec = w->codec; struct tapan_priv *tapan = <API key>(codec); const int comp = w->shift; const u32 rate = tapan->comp_fs[comp]; const struct <API key> *comp_params = &comp_samp_params[rate]; enum wcd9xxx_buck_volt buck_mv; dev_dbg(codec->dev, "%s: %s event %d compander %d, enabled %d", __func__, w->name, event, comp, tapan->comp_enabled[comp]); if (!tapan->comp_enabled[comp]) return 0; /* Compander 0 has single channel */ mask = (comp == COMPANDER_0 ? 0x01 : 0x03); buck_mv = <API key>(codec); rdac5_mux = snd_soc_read(codec, <API key>); rdac5_mux = (rdac5_mux & 0x04) >> 2; if (comp == COMPANDER_0) { /* SPK compander */ enable_mask = 0x02; } else if (comp == COMPANDER_1) { /* HPH compander */ enable_mask = 0x03; } else if (comp == COMPANDER_2) { /* LO compander */ if (rdac5_mux == 0) { /* DEM4 */ /* for LO Stereo SE, enable Compander 2 left * channel on RX3 interpolator Path and Compander 2 * rigt channel on RX4 interpolator Path. */ enable_mask = 0x03; } else if (rdac5_mux == 1) { /* DEM3_INV */ /* for LO mono differential only enable Compander 2 * left channel on RX3 interpolator Path. */ enable_mask = 0x02; } else { dev_err(codec->dev, "%s: invalid rdac5_mux val %d", __func__, rdac5_mux); return -EINVAL; } } else { dev_err(codec->dev, "%s: invalid compander %d", __func__, comp); return -EINVAL; } switch (event) { case <API key>: /* Set compander Sample rate */ snd_soc_update_bits(codec, <API key> + (comp * 8), 0x07, rate); /* Set the static gain offset for HPH Path */ if (comp == COMPANDER_1) { if (buck_mv == <API key>) snd_soc_update_bits(codec, <API key> + (comp * 8), 0x80, 0x00); else snd_soc_update_bits(codec, <API key> + (comp * 8), 0x80, 0x80); } /* Enable RX interpolation path compander clocks */ snd_soc_update_bits(codec, <API key>, 0x01 << comp_shift[comp], 0x01 << comp_shift[comp]); /* Toggle compander reset bits */ snd_soc_update_bits(codec, <API key>, 0x01 << comp_shift[comp], 0x01 << comp_shift[comp]); snd_soc_update_bits(codec, <API key>, 0x01 << comp_shift[comp], 0); /* Set gain source to compander */ <API key>(codec, comp, true); /* Compander enable */ snd_soc_update_bits(codec, <API key> + (comp * 8), enable_mask, enable_mask); <API key>(codec, comp); /* Set sample rate dependent paramater */ snd_soc_write(codec, <API key> + (comp * 8), comp_params-><API key>); snd_soc_update_bits(codec, <API key> + (comp * 8), 0xF0, comp_params->rms_meter_div_fact << 4); snd_soc_update_bits(codec, <API key> + (comp * 8), 0x0F, comp_params->peak_det_timeout); break; case <API key>: /* Disable compander */ snd_soc_update_bits(codec, <API key> + (comp * 8), enable_mask, 0x00); /* Toggle compander reset bits */ snd_soc_update_bits(codec, <API key>, mask << comp_shift[comp], mask << comp_shift[comp]); snd_soc_update_bits(codec, <API key>, mask << comp_shift[comp], 0); /* Turn off the clock for compander in pair */ snd_soc_update_bits(codec, <API key>, mask << comp_shift[comp], 0); /* Set gain source to register */ <API key>(codec, comp, false); break; } return 0; } static const char * const <API key>[] = { "DISABLE", "ENABLE"}; static const struct soc_enum <API key>[] = { SOC_ENUM_SINGLE_EXT(2, <API key>), }; static const char * const <API key>[] = {"POS_6_DB", "POS_4P5_DB", "POS_3_DB", "POS_1P5_DB", "POS_0_DB", "NEG_2P5_DB", "NEG_12_DB"}; static const struct soc_enum <API key>[] = { SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(<API key>), <API key>), }; static const char *const tapan_anc_func_text[] = {"OFF", "ON"}; static const struct soc_enum tapan_anc_func_enum = SOC_ENUM_SINGLE_EXT(2, tapan_anc_func_text); /*cut of frequency for high pass filter*/ static const char * const cf_text[] = { "MIN_3DB_4Hz", "MIN_3DB_75Hz", "MIN_3DB_150Hz" }; static const struct soc_enum cf_dec1_enum = SOC_ENUM_SINGLE(<API key>, 4, 3, cf_text); static const struct soc_enum cf_dec2_enum = SOC_ENUM_SINGLE(<API key>, 4, 3, cf_text); static const struct soc_enum cf_dec3_enum = SOC_ENUM_SINGLE(<API key>, 4, 3, cf_text); static const struct soc_enum cf_dec4_enum = SOC_ENUM_SINGLE(<API key>, 4, 3, cf_text); static const struct soc_enum cf_rxmix1_enum = SOC_ENUM_SINGLE(<API key>, 0, 3, cf_text); static const struct soc_enum cf_rxmix2_enum = SOC_ENUM_SINGLE(<API key>, 0, 3, cf_text); static const struct soc_enum cf_rxmix3_enum = SOC_ENUM_SINGLE(<API key>, 0, 3, cf_text); static const struct soc_enum cf_rxmix4_enum = SOC_ENUM_SINGLE(<API key>, 0, 3, cf_text); static const char * const class_h_dsm_text[] = { "ZERO", "RX_HPHL", "RX_SPKR" }; static const struct soc_enum class_h_dsm_enum = SOC_ENUM_SINGLE(<API key>, 2, 3, class_h_dsm_text); static const struct snd_kcontrol_new class_h_dsm_mux = SOC_DAPM_ENUM("CLASS_H_DSM MUX Mux", class_h_dsm_enum); static const char * const <API key>[] = { "ZERO", "RX1 MIX2" }; static const struct soc_enum <API key> = SOC_ENUM_SINGLE(0, 0, 2, <API key>); static const struct snd_kcontrol_new rx1_interpolator = SOC_DAPM_ENUM_VIRT("RX1 INTERPOLATOR Mux", <API key>); static const char * const <API key>[] = { "ZERO", "RX2 MIX2" }; static const struct soc_enum <API key> = SOC_ENUM_SINGLE(0, 1, 2, <API key>); static const struct snd_kcontrol_new rx2_interpolator = SOC_DAPM_ENUM_VIRT("RX2 INTERPOLATOR Mux", <API key>); static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { uint32_t zl, zr; bool hphr; struct <API key> *mc; struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); struct tapan_priv *priv = <API key>(codec); mc = (struct <API key> *)(kcontrol->private_value); hphr = mc->shift; <API key>(&priv->mbhc, &zl, &zr); pr_debug("%s: zl %u, zr %u\n", __func__, zl, zr); ucontrol->value.integer.value[0] = hphr ? zr : zl; return 0; } static const struct snd_kcontrol_new <API key>[] = { SOC_ENUM_EXT("EAR PA Gain", <API key>[0], tapan_pa_gain_get, tapan_pa_gain_put), SOC_ENUM_EXT("LOOPBACK Mode", <API key>[0], <API key>, <API key>), SOC_SINGLE_TLV("HPHL Volume", <API key>, 0, 20, 1, line_gain), SOC_SINGLE_TLV("HPHR Volume", <API key>, 0, 20, 1, line_gain), SOC_SINGLE_TLV("LINEOUT1 Volume", <API key>, 0, 20, 1, line_gain), SOC_SINGLE_TLV("LINEOUT2 Volume", <API key>, 0, 20, 1, line_gain), SOC_SINGLE_TLV("SPK DRV Volume", <API key>, 3, 8, 1, line_gain), SOC_SINGLE_TLV("ADC1 Volume", TAPAN_A_TX_1_EN, 2, 19, 0, analog_gain), SOC_SINGLE_TLV("ADC2 Volume", TAPAN_A_TX_2_EN, 2, 19, 0, analog_gain), SOC_SINGLE_TLV("ADC3 Volume", TAPAN_A_TX_3_EN, 2, 19, 0, analog_gain), SOC_SINGLE_TLV("ADC4 Volume", TAPAN_A_TX_4_EN, 2, 19, 0, analog_gain), SOC_SINGLE_S8_TLV("RX1 Digital Volume", <API key>, -84, 40, digital_gain), SOC_SINGLE_S8_TLV("RX2 Digital Volume", <API key>, -84, 40, digital_gain), SOC_SINGLE_S8_TLV("RX3 Digital Volume", <API key>, -84, 40, digital_gain), SOC_SINGLE_S8_TLV("DEC1 Volume", <API key>, -84, 40, digital_gain), SOC_SINGLE_S8_TLV("DEC2 Volume", <API key>, -84, 40, digital_gain), SOC_SINGLE_S8_TLV("IIR1 INP1 Volume", <API key>, -84, 40, digital_gain), SOC_SINGLE_S8_TLV("IIR1 INP2 Volume", <API key>, -84, 40, digital_gain), SOC_SINGLE_S8_TLV("IIR1 INP3 Volume", <API key>, -84, 40, digital_gain), SOC_SINGLE_S8_TLV("IIR1 INP4 Volume", <API key>, -84, 40, digital_gain), SOC_SINGLE_S8_TLV("IIR2 INP1 Volume", <API key>, -84, 40, digital_gain), SOC_SINGLE_S8_TLV("IIR2 INP2 Volume", <API key>, -84, 40, digital_gain), SOC_SINGLE_S8_TLV("IIR2 INP3 Volume", <API key>, -84, 40, digital_gain), SOC_SINGLE_S8_TLV("IIR2 INP4 Volume", <API key>, -84, 40, digital_gain), SOC_ENUM("TX1 HPF cut off", cf_dec1_enum), SOC_ENUM("TX2 HPF cut off", cf_dec2_enum), SOC_ENUM("TX3 HPF cut off", cf_dec3_enum), SOC_ENUM("TX4 HPF cut off", cf_dec4_enum), SOC_SINGLE("TX1 HPF Switch", <API key>, 3, 1, 0), SOC_SINGLE("TX2 HPF Switch", <API key>, 3, 1, 0), SOC_SINGLE("TX3 HPF Switch", <API key>, 3, 1, 0), SOC_SINGLE("TX4 HPF Switch", <API key>, 3, 1, 0), SOC_SINGLE("RX1 HPF Switch", <API key>, 2, 1, 0), SOC_SINGLE("RX2 HPF Switch", <API key>, 2, 1, 0), SOC_SINGLE("RX3 HPF Switch", <API key>, 2, 1, 0), SOC_ENUM("RX1 HPF cut off", cf_rxmix1_enum), SOC_ENUM("RX2 HPF cut off", cf_rxmix2_enum), SOC_ENUM("RX3 HPF cut off", cf_rxmix3_enum), SOC_SINGLE_EXT("IIR1 Enable Band1", IIR1, BAND1, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("IIR1 Enable Band2", IIR1, BAND2, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("IIR1 Enable Band3", IIR1, BAND3, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("IIR1 Enable Band4", IIR1, BAND4, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("IIR1 Enable Band5", IIR1, BAND5, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("IIR2 Enable Band1", IIR2, BAND1, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("IIR2 Enable Band2", IIR2, BAND2, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("IIR2 Enable Band3", IIR2, BAND3, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("IIR2 Enable Band4", IIR2, BAND4, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("IIR2 Enable Band5", IIR2, BAND5, 1, 0, <API key>, <API key>), <API key>("IIR1 Band1", IIR1, BAND1, 255, 0, 5, <API key>, <API key>), <API key>("IIR1 Band2", IIR1, BAND2, 255, 0, 5, <API key>, <API key>), <API key>("IIR1 Band3", IIR1, BAND3, 255, 0, 5, <API key>, <API key>), <API key>("IIR1 Band4", IIR1, BAND4, 255, 0, 5, <API key>, <API key>), <API key>("IIR1 Band5", IIR1, BAND5, 255, 0, 5, <API key>, <API key>), <API key>("IIR2 Band1", IIR2, BAND1, 255, 0, 5, <API key>, <API key>), <API key>("IIR2 Band2", IIR2, BAND2, 255, 0, 5, <API key>, <API key>), <API key>("IIR2 Band3", IIR2, BAND3, 255, 0, 5, <API key>, <API key>), <API key>("IIR2 Band4", IIR2, BAND4, 255, 0, 5, <API key>, <API key>), <API key>("IIR2 Band5", IIR2, BAND5, 255, 0, 5, <API key>, <API key>), SOC_SINGLE_EXT("HPHL Impedance", 0, 0, UINT_MAX, 0, <API key>, NULL), SOC_SINGLE_EXT("HPHR Impedance", 0, 1, UINT_MAX, 0, <API key>, NULL), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_TLV("ADC5 Volume", TAPAN_A_TX_5_EN, 2, 19, 0, analog_gain), SOC_SINGLE_S8_TLV("RX4 Digital Volume", <API key>, -84, 40, digital_gain), SOC_SINGLE_S8_TLV("DEC3 Volume", <API key>, -84, 40, digital_gain), SOC_SINGLE_S8_TLV("DEC4 Volume", <API key>, -84, 40, digital_gain), SOC_SINGLE_EXT("ANC Slot", SND_SOC_NOPM, 0, 100, 0, tapan_get_anc_slot, tapan_put_anc_slot), SOC_ENUM_EXT("ANC Function", tapan_anc_func_enum, tapan_get_anc_func, tapan_put_anc_func), SOC_SINGLE("RX4 HPF Switch", <API key>, 2, 1, 0), SOC_ENUM("RX4 HPF cut off", cf_rxmix4_enum), SOC_SINGLE_EXT("COMP0 Switch", SND_SOC_NOPM, COMPANDER_0, 1, 0, tapan_get_compander, tapan_set_compander), SOC_SINGLE_EXT("COMP1 Switch", SND_SOC_NOPM, COMPANDER_1, 1, 0, tapan_get_compander, tapan_set_compander), SOC_SINGLE_EXT("COMP2 Switch", SND_SOC_NOPM, COMPANDER_2, 1, 0, tapan_get_compander, tapan_set_compander), }; static const char * const rx_1_2_mix1_text[] = { "ZERO", "SRC1", "SRC2", "IIR1", "IIR2", "RX1", "RX2", "RX3", "RX4", "RX5", "AUXRX", "AUXTX1" }; static const char * const rx_3_4_mix1_text[] = { "ZERO", "SRC1", "SRC2", "IIR1", "IIR2", "RX1", "RX2", "RX3", "RX4", "RX5", "AUXRX", "AUXTX1", "AUXTX2" }; static const char * const rx_mix2_text[] = { "ZERO", "SRC1", "SRC2", "IIR1", "IIR2" }; static const char * const rx_rdac3_text[] = { "DEM1", "DEM2" }; static const char * const rx_rdac4_text[] = { "DEM3", "DEM2" }; static const char * const rx_rdac5_text[] = { "DEM4", "DEM3_INV" }; static const char * const sb_tx_1_2_mux_text[] = { "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RSVD", "RSVD", "RSVD", "DEC1", "DEC2", "DEC3", "DEC4" }; static const char * const sb_tx3_mux_text[] = { "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RSVD", "RSVD", "RSVD", "RSVD", "RSVD", "DEC3" }; static const char * const sb_tx4_mux_text[] = { "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RSVD", "RSVD", "RSVD", "RSVD", "RSVD", "RSVD", "DEC4" }; static const char * const sb_tx5_mux_text[] = { "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RSVD", "RSVD", "RSVD", "DEC1" }; static const char * const dec_1_2_mux_text[] = { "ZERO", "ADC1", "ADC2", "ADC3", "ADC4", "ADCMB", "DMIC1", "DMIC2", "DMIC3", "DMIC4" }; static const char * const dec3_mux_text[] = { "ZERO", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADCMB", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "ANCFBTUNE1" }; static const char * const dec4_mux_text[] = { "ZERO", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADCMB", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "ANCFBTUNE2" }; static const char * const anc_mux_text[] = { "ZERO", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "RSVD", "RSVD", "RSVD", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "RSVD", "RSVD" }; static const char * const anc1_fb_mux_text[] = { "ZERO", "EAR_HPH_L", "EAR_LINE_1", }; static const char * const iir_inp_text[] = { "ZERO", "DEC1", "DEC2", "DEC3", "DEC4", "RX1", "RX2", "RX3", "RX4", "RX5" }; static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 0, 12, rx_1_2_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 4, 12, rx_1_2_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 0, 12, rx_1_2_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 0, 12, rx_1_2_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 4, 12, rx_1_2_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 0, 13, rx_3_4_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 4, 13, rx_3_4_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 0, 13, rx_3_4_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 0, 13, rx_3_4_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 4, 13, rx_3_4_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 0, 13, rx_3_4_mix1_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 0, 5, rx_mix2_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 3, 5, rx_mix2_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 0, 5, rx_mix2_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 3, 5, rx_mix2_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 0, 5, rx_mix2_text); static const struct soc_enum <API key> = SOC_ENUM_SINGLE(<API key>, 3, 5, rx_mix2_text); static const struct soc_enum rx_rdac3_enum = SOC_ENUM_SINGLE(<API key>, 4, 2, rx_rdac3_text); static const struct soc_enum rx_rdac4_enum = SOC_ENUM_SINGLE(<API key>, 1, 2, rx_rdac4_text); static const struct soc_enum rx_rdac5_enum = SOC_ENUM_SINGLE(<API key>, 2, 2, rx_rdac5_text); static const struct soc_enum sb_tx1_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 12, sb_tx_1_2_mux_text); static const struct soc_enum sb_tx2_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 12, sb_tx_1_2_mux_text); static const struct soc_enum sb_tx3_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 11, sb_tx3_mux_text); static const struct soc_enum sb_tx4_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 12, sb_tx4_mux_text); static const struct soc_enum sb_tx5_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 9, sb_tx5_mux_text); static const struct soc_enum dec1_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 10, dec_1_2_mux_text); static const struct soc_enum dec2_mux_enum = SOC_ENUM_SINGLE(<API key>, 4, 10, dec_1_2_mux_text); static const struct soc_enum dec3_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 12, dec3_mux_text); static const struct soc_enum dec4_mux_enum = SOC_ENUM_SINGLE(<API key>, 4, 12, dec4_mux_text); static const struct soc_enum anc1_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 15, anc_mux_text); static const struct soc_enum anc2_mux_enum = SOC_ENUM_SINGLE(<API key>, 4, 15, anc_mux_text); static const struct soc_enum anc1_fb_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 3, anc1_fb_mux_text); static const struct soc_enum iir1_inp1_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 10, iir_inp_text); static const struct soc_enum iir1_inp2_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 10, iir_inp_text); static const struct soc_enum iir1_inp3_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 10, iir_inp_text); static const struct soc_enum iir1_inp4_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 10, iir_inp_text); static const struct soc_enum iir2_inp1_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 10, iir_inp_text); static const struct soc_enum iir2_inp2_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 10, iir_inp_text); static const struct soc_enum iir2_inp3_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 10, iir_inp_text); static const struct soc_enum iir2_inp4_mux_enum = SOC_ENUM_SINGLE(<API key>, 0, 10, iir_inp_text); static const struct snd_kcontrol_new rx_mix1_inp1_mux = SOC_DAPM_ENUM("RX1 MIX1 INP1 Mux", <API key>); static const struct snd_kcontrol_new rx_mix1_inp2_mux = SOC_DAPM_ENUM("RX1 MIX1 INP2 Mux", <API key>); static const struct snd_kcontrol_new rx_mix1_inp3_mux = SOC_DAPM_ENUM("RX1 MIX1 INP3 Mux", <API key>); static const struct snd_kcontrol_new rx2_mix1_inp1_mux = SOC_DAPM_ENUM("RX2 MIX1 INP1 Mux", <API key>); static const struct snd_kcontrol_new rx2_mix1_inp2_mux = SOC_DAPM_ENUM("RX2 MIX1 INP2 Mux", <API key>); static const struct snd_kcontrol_new rx3_mix1_inp1_mux = SOC_DAPM_ENUM("RX3 MIX1 INP1 Mux", <API key>); static const struct snd_kcontrol_new rx3_mix1_inp2_mux = SOC_DAPM_ENUM("RX3 MIX1 INP2 Mux", <API key>); static const struct snd_kcontrol_new rx3_mix1_inp3_mux = SOC_DAPM_ENUM("RX3 MIX1 INP3 Mux", <API key>); static const struct snd_kcontrol_new rx4_mix1_inp1_mux = SOC_DAPM_ENUM("RX4 MIX1 INP1 Mux", <API key>); static const struct snd_kcontrol_new rx4_mix1_inp2_mux = SOC_DAPM_ENUM("RX4 MIX1 INP2 Mux", <API key>); static const struct snd_kcontrol_new rx4_mix1_inp3_mux = SOC_DAPM_ENUM("RX4 MIX1 INP3 Mux", <API key>); static const struct snd_kcontrol_new rx1_mix2_inp1_mux = SOC_DAPM_ENUM("RX1 MIX2 INP1 Mux", <API key>); static const struct snd_kcontrol_new rx1_mix2_inp2_mux = SOC_DAPM_ENUM("RX1 MIX2 INP2 Mux", <API key>); static const struct snd_kcontrol_new rx2_mix2_inp1_mux = SOC_DAPM_ENUM("RX2 MIX2 INP1 Mux", <API key>); static const struct snd_kcontrol_new rx2_mix2_inp2_mux = SOC_DAPM_ENUM("RX2 MIX2 INP2 Mux", <API key>); static const struct snd_kcontrol_new rx4_mix2_inp1_mux = SOC_DAPM_ENUM("RX4 MIX2 INP1 Mux", <API key>); static const struct snd_kcontrol_new rx4_mix2_inp2_mux = SOC_DAPM_ENUM("RX4 MIX2 INP2 Mux", <API key>); static const struct snd_kcontrol_new rx_dac3_mux = SOC_DAPM_ENUM("RDAC3 MUX Mux", rx_rdac3_enum); static const struct snd_kcontrol_new rx_dac4_mux = SOC_DAPM_ENUM("RDAC4 MUX Mux", rx_rdac4_enum); static const struct snd_kcontrol_new rx_dac5_mux = SOC_DAPM_ENUM("RDAC5 MUX Mux", rx_rdac5_enum); static const struct snd_kcontrol_new sb_tx1_mux = SOC_DAPM_ENUM("SLIM TX1 MUX Mux", sb_tx1_mux_enum); static const struct snd_kcontrol_new sb_tx2_mux = SOC_DAPM_ENUM("SLIM TX2 MUX Mux", sb_tx2_mux_enum); static const struct snd_kcontrol_new sb_tx3_mux = SOC_DAPM_ENUM("SLIM TX3 MUX Mux", sb_tx3_mux_enum); static const struct snd_kcontrol_new sb_tx4_mux = SOC_DAPM_ENUM("SLIM TX4 MUX Mux", sb_tx4_mux_enum); static const struct snd_kcontrol_new sb_tx5_mux = SOC_DAPM_ENUM("SLIM TX5 MUX Mux", sb_tx5_mux_enum); static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct <API key> *wlist = snd_kcontrol_chip(kcontrol); struct snd_soc_dapm_widget *w = wlist->widgets[0]; struct snd_soc_codec *codec = w->codec; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int dec_mux, decimator; char *dec_name = NULL; char *widget_name = NULL; char *temp; u16 tx_mux_ctl_reg; u8 adc_dmic_sel = 0x0; int ret = 0; char *srch = NULL; if (ucontrol->value.enumerated.item[0] > e->max - 1) return -EINVAL; dec_mux = ucontrol->value.enumerated.item[0]; widget_name = kstrndup(w->name, 15, GFP_KERNEL); if (!widget_name) return -ENOMEM; temp = widget_name; dec_name = strsep(&widget_name, " "); widget_name = temp; if (!dec_name) { pr_err("%s: Invalid decimator = %s\n", __func__, w->name); ret = -EINVAL; goto out; } srch = strpbrk(dec_name, "1234"); if (srch == NULL) { pr_err("%s: Invalid decimator name %s\n", __func__, dec_name); return -EINVAL; } ret = kstrtouint(srch, 10, &decimator); if (ret < 0) { pr_err("%s: Invalid decimator = %s\n", __func__, dec_name); ret = -EINVAL; goto out; } dev_dbg(w->dapm->dev, "%s(): widget = %s decimator = %u dec_mux = %u\n" , __func__, w->name, decimator, dec_mux); switch (decimator) { case 1: case 2: if ((dec_mux >= 1) && (dec_mux <= 5)) adc_dmic_sel = 0x0; else if ((dec_mux >= 6) && (dec_mux <= 9)) adc_dmic_sel = 0x1; break; case 3: case 4: if ((dec_mux >= 1) && (dec_mux <= 6)) adc_dmic_sel = 0x0; else if ((dec_mux >= 7) && (dec_mux <= 10)) adc_dmic_sel = 0x1; break; default: pr_err("%s: Invalid Decimator = %u\n", __func__, decimator); ret = -EINVAL; goto out; } tx_mux_ctl_reg = <API key> + 8 * (decimator - 1); snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x1, adc_dmic_sel); ret = <API key>(kcontrol, ucontrol); out: kfree(widget_name); return ret; } #define WCD9306_DEC_ENUM(xname, xenum) \ { .iface = <API key>, .name = xname, \ .info = <API key>, \ .get = <API key>, \ .put = <API key>, \ .private_value = (unsigned long)&xenum } static const struct snd_kcontrol_new dec1_mux = WCD9306_DEC_ENUM("DEC1 MUX Mux", dec1_mux_enum); static const struct snd_kcontrol_new dec2_mux = WCD9306_DEC_ENUM("DEC2 MUX Mux", dec2_mux_enum); static const struct snd_kcontrol_new dec3_mux = WCD9306_DEC_ENUM("DEC3 MUX Mux", dec3_mux_enum); static const struct snd_kcontrol_new dec4_mux = WCD9306_DEC_ENUM("DEC4 MUX Mux", dec4_mux_enum); static const struct snd_kcontrol_new iir1_inp1_mux = SOC_DAPM_ENUM("IIR1 INP1 Mux", iir1_inp1_mux_enum); static const struct snd_kcontrol_new iir1_inp2_mux = SOC_DAPM_ENUM("IIR1 INP2 Mux", iir1_inp2_mux_enum); static const struct snd_kcontrol_new iir1_inp3_mux = SOC_DAPM_ENUM("IIR1 INP3 Mux", iir1_inp3_mux_enum); static const struct snd_kcontrol_new iir1_inp4_mux = SOC_DAPM_ENUM("IIR1 INP4 Mux", iir1_inp4_mux_enum); static const struct snd_kcontrol_new iir2_inp1_mux = SOC_DAPM_ENUM("IIR2 INP1 Mux", iir2_inp1_mux_enum); static const struct snd_kcontrol_new iir2_inp2_mux = SOC_DAPM_ENUM("IIR2 INP2 Mux", iir2_inp2_mux_enum); static const struct snd_kcontrol_new iir2_inp3_mux = SOC_DAPM_ENUM("IIR2 INP3 Mux", iir2_inp3_mux_enum); static const struct snd_kcontrol_new iir2_inp4_mux = SOC_DAPM_ENUM("IIR2 INP4 Mux", iir2_inp4_mux_enum); static const struct snd_kcontrol_new anc1_mux = SOC_DAPM_ENUM("ANC1 MUX Mux", anc1_mux_enum); static const struct snd_kcontrol_new anc2_mux = SOC_DAPM_ENUM("ANC2 MUX Mux", anc2_mux_enum); static const struct snd_kcontrol_new anc1_fb_mux = SOC_DAPM_ENUM("ANC1 FB MUX Mux", anc1_fb_mux_enum); static const struct snd_kcontrol_new dac1_switch[] = { SOC_DAPM_SINGLE("Switch", TAPAN_A_RX_EAR_EN, 5, 1, 0) }; static const struct snd_kcontrol_new hphl_switch[] = { SOC_DAPM_SINGLE("Switch", <API key>, 6, 1, 0) }; static const struct snd_kcontrol_new spk_dac_switch[] = { SOC_DAPM_SINGLE("Switch", <API key>, 2, 1, 0) }; static const struct snd_kcontrol_new hphl_pa_mix[] = { SOC_DAPM_SINGLE("AUX_PGA_L Switch", <API key>, 7, 1, 0), }; static const struct snd_kcontrol_new hphr_pa_mix[] = { SOC_DAPM_SINGLE("AUX_PGA_R Switch", <API key>, 6, 1, 0), }; static const struct snd_kcontrol_new ear_pa_mix[] = { SOC_DAPM_SINGLE("AUX_PGA_L Switch", <API key>, 5, 1, 0), }; static const struct snd_kcontrol_new lineout1_pa_mix[] = { SOC_DAPM_SINGLE("AUX_PGA_L Switch", <API key>, 4, 1, 0), }; static const struct snd_kcontrol_new lineout2_pa_mix[] = { SOC_DAPM_SINGLE("AUX_PGA_R Switch", <API key>, 3, 1, 0), }; /* virtual port entries */ static int slim_tx_mixer_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct <API key> *wlist = snd_kcontrol_chip(kcontrol); struct snd_soc_dapm_widget *widget = wlist->widgets[0]; ucontrol->value.integer.value[0] = widget->value; return 0; } static int slim_tx_mixer_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct <API key> *wlist = snd_kcontrol_chip(kcontrol); struct snd_soc_dapm_widget *widget = wlist->widgets[0]; struct snd_soc_codec *codec = widget->codec; struct tapan_priv *tapan_p = <API key>(codec); struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent); struct <API key> *mixer = ((struct <API key> *)kcontrol->private_value); u32 dai_id = widget->shift; u32 port_id = mixer->shift; u32 enable = ucontrol->value.integer.value[0]; u32 vtable = vport_check_table[dai_id]; dev_dbg(codec->dev, "%s: wname %s cname %s\n", __func__, widget->name, ucontrol->id.name); dev_dbg(codec->dev, "%s: value %u shift %d item %ld\n", __func__, widget->value, widget->shift, ucontrol->value.integer.value[0]); mutex_lock(&codec->mutex); if (tapan_p->intf_type != <API key>) { if (dai_id != AIF1_CAP) { dev_err(codec->dev, "%s: invalid AIF for I2C mode\n", __func__); mutex_unlock(&codec->mutex); return -EINVAL; } } switch (dai_id) { case AIF1_CAP: case AIF2_CAP: case AIF3_CAP: /* only add to the list if value not set */ if (enable && !(widget->value & 1 << port_id)) { if (tapan_p->intf_type == <API key>) vtable = vport_check_table[dai_id]; if (tapan_p->intf_type == <API key>) vtable = <API key>[dai_id]; if (<API key>( vtable, port_id, tapan_p->dai, NUM_CODEC_DAIS)) { dev_dbg(codec->dev, "%s: TX%u is used by other virtual port\n", __func__, port_id + 1); mutex_unlock(&codec->mutex); return 0; } widget->value |= 1 << port_id; list_add_tail(&core->tx_chs[port_id].list, &tapan_p->dai[dai_id].wcd9xxx_ch_list ); } else if (!enable && (widget->value & 1 << port_id)) { widget->value &= ~(1 << port_id); list_del_init(&core->tx_chs[port_id].list); } else { if (enable) dev_dbg(codec->dev, "%s: TX%u port is used by\n" "this virtual port\n", __func__, port_id + 1); else dev_dbg(codec->dev, "%s: TX%u port is not used by\n" "this virtual port\n", __func__, port_id + 1); /* avoid update power function */ mutex_unlock(&codec->mutex); return 0; } break; default: dev_err(codec->dev, "Unknown AIF %d\n", dai_id); mutex_unlock(&codec->mutex); return -EINVAL; } dev_dbg(codec->dev, "%s: name %s sname %s updated value %u shift %d\n", __func__, widget->name, widget->sname, widget->value, widget->shift); <API key>(widget, kcontrol, enable); mutex_unlock(&codec->mutex); return 0; } static int slim_rx_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct <API key> *wlist = snd_kcontrol_chip(kcontrol); struct snd_soc_dapm_widget *widget = wlist->widgets[0]; ucontrol->value.enumerated.item[0] = widget->value; return 0; } static const char *const slim_rx_mux_text[] = { "ZERO", "AIF1_PB", "AIF2_PB", "AIF3_PB" }; static int slim_rx_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct <API key> *wlist = snd_kcontrol_chip(kcontrol); struct snd_soc_dapm_widget *widget = wlist->widgets[0]; struct snd_soc_codec *codec = widget->codec; struct tapan_priv *tapan_p = <API key>(codec); struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; u32 port_id = widget->shift; dev_dbg(codec->dev, "%s: wname %s cname %s value %u shift %d item %ld\n", __func__, widget->name, ucontrol->id.name, widget->value, widget->shift, ucontrol->value.integer.value[0]); widget->value = ucontrol->value.enumerated.item[0]; mutex_lock(&codec->mutex); if (tapan_p->intf_type != <API key>) { if (widget->value > 1) { dev_err(codec->dev, "%s: invalid AIF for I2C mode\n", __func__); goto err; } } /* value need to match the Virtual port and AIF number */ switch (widget->value) { case 0: list_del_init(&core->rx_chs[port_id].list); break; case 1: if (<API key>(port_id + <API key>, &tapan_p->dai[AIF1_PB].wcd9xxx_ch_list)) { dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n", __func__, port_id + 1); goto rtn; } list_add_tail(&core->rx_chs[port_id].list, &tapan_p->dai[AIF1_PB].wcd9xxx_ch_list); break; case 2: if (<API key>(port_id + <API key>, &tapan_p->dai[AIF2_PB].wcd9xxx_ch_list)) { dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n", __func__, port_id + 1); goto rtn; } list_add_tail(&core->rx_chs[port_id].list, &tapan_p->dai[AIF2_PB].wcd9xxx_ch_list); break; case 3: if (<API key>(port_id + <API key>, &tapan_p->dai[AIF3_PB].wcd9xxx_ch_list)) { dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n", __func__, port_id + 1); goto rtn; } list_add_tail(&core->rx_chs[port_id].list, &tapan_p->dai[AIF3_PB].wcd9xxx_ch_list); break; default: pr_err("Unknown AIF %d\n", widget->value); goto err; } rtn: <API key>(widget, kcontrol, 1, widget->value, e); mutex_unlock(&codec->mutex); return 0; err: mutex_unlock(&codec->mutex); return -EINVAL; } static const struct soc_enum slim_rx_mux_enum = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(slim_rx_mux_text), slim_rx_mux_text); static const struct snd_kcontrol_new slim_rx_mux[TAPAN_RX_MAX] = { SOC_DAPM_ENUM_EXT("SLIM RX1 Mux", slim_rx_mux_enum, slim_rx_mux_get, slim_rx_mux_put), SOC_DAPM_ENUM_EXT("SLIM RX2 Mux", slim_rx_mux_enum, slim_rx_mux_get, slim_rx_mux_put), SOC_DAPM_ENUM_EXT("SLIM RX3 Mux", slim_rx_mux_enum, slim_rx_mux_get, slim_rx_mux_put), SOC_DAPM_ENUM_EXT("SLIM RX4 Mux", slim_rx_mux_enum, slim_rx_mux_get, slim_rx_mux_put), SOC_DAPM_ENUM_EXT("SLIM RX5 Mux", slim_rx_mux_enum, slim_rx_mux_get, slim_rx_mux_put), }; static const struct snd_kcontrol_new aif_cap_mixer[] = { SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, TAPAN_TX1, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, TAPAN_TX2, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, TAPAN_TX3, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, TAPAN_TX4, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, TAPAN_TX5, 1, 0, slim_tx_mixer_get, slim_tx_mixer_put), }; static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tapan_priv *tapan = <API key>(codec); u16 adc_reg; u8 init_bit_shift; dev_dbg(codec->dev, "%s(): %s %d\n", __func__, w->name, event); if (w->reg == TAPAN_A_TX_1_EN) { init_bit_shift = 7; adc_reg = <API key>; } else if (w->reg == TAPAN_A_TX_2_EN) { init_bit_shift = 6; adc_reg = <API key>; } else if (w->reg == TAPAN_A_TX_3_EN) { init_bit_shift = 6; adc_reg = <API key>; } else if (w->reg == TAPAN_A_TX_4_EN) { init_bit_shift = 7; adc_reg = <API key>; } else if (w->reg == TAPAN_A_TX_5_EN) { init_bit_shift = 6; adc_reg = <API key>; } else { pr_err("%s: Error, invalid adc register\n", __func__); return -EINVAL; } switch (event) { case <API key>: if (w->reg == TAPAN_A_TX_3_EN || w->reg == TAPAN_A_TX_1_EN) <API key>(&tapan->resmgr, <API key>); snd_soc_update_bits(codec, adc_reg, 1 << init_bit_shift, 1 << init_bit_shift); break; case <API key>: usleep_range(2000, 2010); snd_soc_update_bits(codec, adc_reg, 1 << init_bit_shift, 0x00); break; case <API key>: if (w->reg == TAPAN_A_TX_3_EN || w->reg == TAPAN_A_TX_1_EN) <API key>(&tapan->resmgr, <API key>); break; } return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tapan_priv *tapan = <API key>(codec); dev_dbg(codec->dev, "%s: %d\n", __func__, event); switch (event) { case <API key>: WCD9XXX_BG_CLK_LOCK(&tapan->resmgr); <API key>(&tapan->resmgr, <API key>); /* AUX PGA requires RCO or MCLK */ <API key>(&tapan->resmgr, WCD9XXX_CLK_RCO); <API key>(&tapan->resmgr); <API key>(&tapan->resmgr, 1); break; case <API key>: <API key>(&tapan->resmgr, 0); WCD9XXX_BG_CLK_LOCK(&tapan->resmgr); <API key>(&tapan->resmgr, <API key>); <API key>(&tapan->resmgr, WCD9XXX_CLK_RCO); <API key>(&tapan->resmgr); break; } return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tapan_priv *tapan = <API key>(codec); u16 lineout_gain_reg; dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name); switch (w->shift) { case 0: lineout_gain_reg = <API key>; break; case 1: lineout_gain_reg = <API key>; break; default: pr_err("%s: Error, incorrect lineout register value\n", __func__); return -EINVAL; } switch (event) { case <API key>: break; case <API key>: wcd9xxx_clsh_fsm(codec, &tapan->clsh_d, <API key>, <API key>, <API key>); dev_dbg(codec->dev, "%s: sleeping 5 ms after %s PA turn on\n", __func__, w->name); /* Wait for CnP time after PA enable */ usleep_range(5000, 5100); break; case <API key>: wcd9xxx_clsh_fsm(codec, &tapan->clsh_d, <API key>, <API key>, <API key>); dev_dbg(codec->dev, "%s: sleeping 5 ms after %s PA turn on\n", __func__, w->name); /* Wait for CnP time after PA disable */ usleep_range(5000, 5100); break; } return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tapan_priv *tapan = <API key>(codec); dev_dbg(codec->dev, "%s: %s %d\n", __func__, w->name, event); switch (event) { case <API key>: tapan->spkr_pa_widget_on = true; snd_soc_update_bits(codec, TAPAN_A_SPKR_DRV_EN, 0x80, 0x80); break; case <API key>: tapan->spkr_pa_widget_on = false; snd_soc_update_bits(codec, TAPAN_A_SPKR_DRV_EN, 0x80, 0x00); break; } return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tapan_priv *tapan = <API key>(codec); u8 dmic_clk_en; u16 dmic_clk_reg; s32 *dmic_clk_cnt; unsigned int dmic; int ret; char *srch = NULL; srch = strpbrk(w->name, "1234"); if (srch == NULL) { pr_err("%s: Invalid widget name %s\n", __func__, w->name); return -EINVAL; } ret = kstrtouint(srch, 10, &dmic); if (ret < 0) { pr_err("%s: Invalid DMIC line on the codec\n", __func__); return -EINVAL; } switch (dmic) { case 1: case 2: dmic_clk_en = 0x01; dmic_clk_cnt = &(tapan->dmic_1_2_clk_cnt); dmic_clk_reg = <API key>; dev_dbg(codec->dev, "%s() event %d DMIC%d dmic_1_2_clk_cnt %d\n", __func__, event, dmic, *dmic_clk_cnt); break; case 3: case 4: dmic_clk_en = 0x10; dmic_clk_cnt = &(tapan->dmic_3_4_clk_cnt); dmic_clk_reg = <API key>; dev_dbg(codec->dev, "%s() event %d DMIC%d dmic_3_4_clk_cnt %d\n", __func__, event, dmic, *dmic_clk_cnt); break; default: pr_err("%s: Invalid DMIC Selection\n", __func__); return -EINVAL; } switch (event) { case <API key>: (*dmic_clk_cnt)++; if (*dmic_clk_cnt == 1) snd_soc_update_bits(codec, dmic_clk_reg, dmic_clk_en, dmic_clk_en); break; case <API key>: (*dmic_clk_cnt) if (*dmic_clk_cnt == 0) snd_soc_update_bits(codec, dmic_clk_reg, dmic_clk_en, 0); break; } return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; const char *filename; const struct firmware *fw; int i; int ret; int num_anc_slots; struct wcd9xxx_anc_header *anc_head; struct tapan_priv *tapan = <API key>(codec); u32 anc_writes_size = 0; int anc_size_remaining; u32 *anc_ptr; u16 reg; u8 mask, val, old_val; dev_dbg(codec->dev, "%s %d\n", __func__, event); if (tapan->anc_func == 0) return 0; switch (event) { case <API key>: filename = "wcd9306/wcd9306_anc.bin"; ret = request_firmware(&fw, filename, codec->dev); if (ret != 0) { dev_err(codec->dev, "Failed to acquire ANC data: %d\n", ret); return -ENODEV; } if (fw->size < sizeof(struct wcd9xxx_anc_header)) { dev_err(codec->dev, "Not enough data\n"); release_firmware(fw); return -ENOMEM; } /* First number is the number of register writes */ anc_head = (struct wcd9xxx_anc_header *)(fw->data); anc_ptr = (u32 *)((u32)fw->data + sizeof(struct wcd9xxx_anc_header)); anc_size_remaining = fw->size - sizeof(struct wcd9xxx_anc_header); num_anc_slots = anc_head->num_anc_slots; if (tapan->anc_slot >= num_anc_slots) { dev_err(codec->dev, "Invalid ANC slot selected\n"); release_firmware(fw); return -EINVAL; } for (i = 0; i < num_anc_slots; i++) { if (anc_size_remaining < <API key>) { dev_err(codec->dev, "Invalid register format\n"); release_firmware(fw); return -EINVAL; } anc_writes_size = (u32)(*anc_ptr); anc_size_remaining -= sizeof(u32); anc_ptr += 1; if (anc_writes_size * <API key> > anc_size_remaining) { dev_err(codec->dev, "Invalid register format\n"); release_firmware(fw); return -ENOMEM; } if (tapan->anc_slot == i) break; anc_size_remaining -= (anc_writes_size * <API key>); anc_ptr += anc_writes_size; } if (i == num_anc_slots) { dev_err(codec->dev, "Selected ANC slot not present\n"); release_firmware(fw); return -ENOMEM; } for (i = 0; i < anc_writes_size; i++) { <API key>(anc_ptr[i], reg, mask, val); old_val = snd_soc_read(codec, reg); snd_soc_write(codec, reg, (old_val & ~mask) | (val & mask)); } release_firmware(fw); break; case <API key>: msleep(40); snd_soc_update_bits(codec, <API key>, 0x01, 0x00); snd_soc_update_bits(codec, <API key>, 0x02, 0x00); msleep(20); snd_soc_write(codec, <API key>, 0x0F); snd_soc_write(codec, <API key>, 0); snd_soc_write(codec, <API key>, 0xFF); break; } return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tapan_priv *tapan = <API key>(codec); u16 micb_int_reg = 0, micb_ctl_reg = 0; u8 cfilt_sel_val = 0; char *internal1_text = "Internal1"; char *internal2_text = "Internal2"; char *internal3_text = "Internal3"; enum <API key> e_post_off, e_pre_on, e_post_on; pr_debug("%s: w->name %s event %d\n", __func__, w->name, event); if (strnstr(w->name, "MIC BIAS1", sizeof("MIC BIAS1"))) { micb_ctl_reg = TAPAN_A_MICB_1_CTL; micb_int_reg = <API key>; cfilt_sel_val = tapan->resmgr.pdata->micbias.bias1_cfilt_sel; e_pre_on = <API key>; e_post_on = <API key>; e_post_off = <API key>; } else if (strnstr(w->name, "MIC BIAS2", sizeof("MIC BIAS2"))) { micb_ctl_reg = TAPAN_A_MICB_2_CTL; micb_int_reg = <API key>; cfilt_sel_val = tapan->resmgr.pdata->micbias.bias2_cfilt_sel; e_pre_on = <API key>; e_post_on = <API key>; e_post_off = <API key>; } else if (strnstr(w->name, "MIC BIAS3", sizeof("MIC BIAS3"))) { micb_ctl_reg = TAPAN_A_MICB_3_CTL; micb_int_reg = <API key>; cfilt_sel_val = tapan->resmgr.pdata->micbias.bias3_cfilt_sel; e_pre_on = <API key>; e_post_on = <API key>; e_post_off = <API key>; } else { pr_err("%s: Error, invalid micbias %s\n", __func__, w->name); return -EINVAL; } switch (event) { case <API key>: /* Let MBHC module know so micbias switch to be off */ <API key>(&tapan->resmgr, e_pre_on); /* Get cfilt */ <API key>(&tapan->resmgr, cfilt_sel_val); if (strnstr(w->name, internal1_text, 30)) snd_soc_update_bits(codec, micb_int_reg, 0xE0, 0xE0); else if (strnstr(w->name, internal2_text, 30)) snd_soc_update_bits(codec, micb_int_reg, 0x1C, 0x1C); else if (strnstr(w->name, internal3_text, 30)) snd_soc_update_bits(codec, micb_int_reg, 0x3, 0x3); if (micb_ctl_reg == TAPAN_A_MICB_2_CTL) { if (++tapan->micb_2_users == 1) <API key>( &tapan->resmgr, <API key>, micb_ctl_reg, w->shift, false); pr_debug("%s: micb_2_users %d\n", __func__, tapan->micb_2_users); } else snd_soc_update_bits(codec, micb_ctl_reg, 1 << w->shift, 1 << w->shift); break; case <API key>: usleep_range(20000, 20000); /* Let MBHC module know so micbias is on */ <API key>(&tapan->resmgr, e_post_on); break; case <API key>: if (micb_ctl_reg == TAPAN_A_MICB_2_CTL) { if (--tapan->micb_2_users == 0) <API key>( &tapan->resmgr, <API key>, micb_ctl_reg, 7, false); pr_debug("%s: micb_2_users %d\n", __func__, tapan->micb_2_users); WARN(tapan->micb_2_users < 0, "Unexpected micbias users %d\n", tapan->micb_2_users); } else snd_soc_update_bits(codec, micb_ctl_reg, 1 << w->shift, 0); /* Let MBHC module know so micbias switch to be off */ <API key>(&tapan->resmgr, e_post_off); if (strnstr(w->name, internal1_text, 30)) snd_soc_update_bits(codec, micb_int_reg, 0x80, 0x00); else if (strnstr(w->name, internal2_text, 30)) snd_soc_update_bits(codec, micb_int_reg, 0x10, 0x00); else if (strnstr(w->name, internal3_text, 30)) snd_soc_update_bits(codec, micb_int_reg, 0x2, 0x0); /* Put cfilt */ <API key>(&tapan->resmgr, cfilt_sel_val); break; } return 0; } /* called under codec_resource_lock acquisition */ static int <API key>(struct snd_soc_codec *codec, bool enable, enum wcd9xxx_micbias_num micb_num) { int rc; const char *micbias; if (micb_num == MBHC_MICBIAS2) micbias = <API key>; else return -EINVAL; if (enable) rc = <API key>(&codec->dapm, micbias); else rc = <API key>(&codec->dapm, micbias); if (!rc) snd_soc_dapm_sync(&codec->dapm); pr_debug("%s: leave ret %d\n", __func__, rc); return rc; } static void <API key>(struct work_struct *work) { struct delayed_work *hpf_delayed_work; struct hpf_work *hpf_work; struct tapan_priv *tapan; struct snd_soc_codec *codec; u16 tx_mux_ctl_reg; u8 hpf_cut_of_freq; hpf_delayed_work = to_delayed_work(work); hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork); tapan = hpf_work->tapan; codec = hpf_work->tapan->codec; hpf_cut_of_freq = hpf_work->tx_hpf_cut_of_freq; tx_mux_ctl_reg = <API key> + (hpf_work->decimator - 1) * 8; dev_dbg(codec->dev, "%s(): decimator %u hpf_cut_of_freq 0x%x\n", __func__, hpf_work->decimator, (unsigned int)hpf_cut_of_freq); snd_soc_update_bits(codec, <API key>, 0x55, 0x55); snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x30, hpf_cut_of_freq << 4); } #define <API key> 0x30 #define CF_MIN_3DB_4HZ 0x0 #define CF_MIN_3DB_75HZ 0x1 #define CF_MIN_3DB_150HZ 0x2 static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; unsigned int decimator; struct tapan_priv *tapan_p = <API key>(codec); char *dec_name = NULL; char *widget_name = NULL; char *temp; int ret = 0, i; u16 dec_reset_reg, tx_vol_ctl_reg, tx_mux_ctl_reg; u8 dec_hpf_cut_of_freq; int offset; char *srch = NULL; dev_dbg(codec->dev, "%s %d\n", __func__, event); widget_name = kstrndup(w->name, 15, GFP_KERNEL); if (!widget_name) return -ENOMEM; temp = widget_name; dec_name = strsep(&widget_name, " "); widget_name = temp; if (!dec_name) { pr_err("%s: Invalid decimator = %s\n", __func__, w->name); ret = -EINVAL; goto out; } srch = strpbrk(dec_name, "123456789"); if (srch == NULL) { pr_err("%s: Invalid decimator name %s\n", __func__, dec_name); return -EINVAL; } ret = kstrtouint(srch, 10, &decimator); if (ret < 0) { pr_err("%s: Invalid decimator = %s\n", __func__, dec_name); ret = -EINVAL; goto out; } dev_dbg(codec->dev, "%s(): widget = %s dec_name = %s decimator = %u\n", __func__, w->name, dec_name, decimator); if (w->reg == <API key>) { dec_reset_reg = <API key>; offset = 0; } else if (w->reg == <API key>) { dec_reset_reg = <API key>; offset = 8; } else { pr_err("%s: Error, incorrect dec\n", __func__); ret = -EINVAL; goto out; } tx_vol_ctl_reg = <API key> + 8 * (decimator - 1); tx_mux_ctl_reg = <API key> + 8 * (decimator - 1); switch (event) { case <API key>: for (i = 0; i < NUM_DECIMATORS; i++) { if (decimator == i + 1) tapan_p->dec_active[i] = true; } /* Enableable TX digital mute */ snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x01, 0x01); snd_soc_update_bits(codec, dec_reset_reg, 1 << w->shift, 1 << w->shift); snd_soc_update_bits(codec, dec_reset_reg, 1 << w->shift, 0x0); dec_hpf_cut_of_freq = snd_soc_read(codec, tx_mux_ctl_reg); dec_hpf_cut_of_freq = (dec_hpf_cut_of_freq & 0x30) >> 4; tx_hpf_work[decimator - 1].tx_hpf_cut_of_freq = dec_hpf_cut_of_freq; if ((dec_hpf_cut_of_freq != CF_MIN_3DB_150HZ)) { /* set cut of freq to CF_MIN_3DB_150HZ (0x1); */ snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x30, CF_MIN_3DB_150HZ << 4); } /* enable HPF */ snd_soc_update_bits(codec, tx_mux_ctl_reg , 0x08, 0x00); snd_soc_update_bits(codec, <API key>, 0x55, 0x44); break; case <API key>: if (tapan_p->lb_mode) { pr_debug("%s: loopback mode unmute the DEC\n", __func__); snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x01, 0x00); } if (tx_hpf_work[decimator - 1].tx_hpf_cut_of_freq != CF_MIN_3DB_150HZ) { <API key>(&tx_hpf_work[decimator - 1].dwork, msecs_to_jiffies(300)); } /* apply the digital gain after the decimator is enabled*/ if ((w->shift + offset) < ARRAY_SIZE(tx_digital_gain_reg)) snd_soc_write(codec, tx_digital_gain_reg[w->shift + offset], snd_soc_read(codec, tx_digital_gain_reg[w->shift + offset]) ); break; case <API key>: snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x01, 0x01); <API key>(&tx_hpf_work[decimator - 1].dwork); break; case <API key>: snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x08, 0x08); snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x30, (tx_hpf_work[decimator - 1].tx_hpf_cut_of_freq) << 4); for (i = 0; i < NUM_DECIMATORS; i++) { if (decimator == i + 1) tapan_p->dec_active[i] = false; } break; } out: kfree(widget_name); return ret; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent); dev_dbg(codec->dev, "%s: %s %d\n", __func__, w->name, event); switch (event) { case <API key>: if (spkr_drv_wrnd > 0) { WARN_ON(!(snd_soc_read(codec, TAPAN_A_SPKR_DRV_EN) & 0x80)); snd_soc_update_bits(codec, TAPAN_A_SPKR_DRV_EN, 0x80, 0x00); } if (TAPAN_IS_1_0(core->version)) snd_soc_update_bits(codec, <API key>, 0x24, 0x00); break; case <API key>: if (TAPAN_IS_1_0(core->version)) snd_soc_update_bits(codec, <API key>, 0x24, 0x24); if (spkr_drv_wrnd > 0) { WARN_ON(!!(snd_soc_read(codec, TAPAN_A_SPKR_DRV_EN) & 0x80)); snd_soc_update_bits(codec, TAPAN_A_SPKR_DRV_EN, 0x80, 0x80); } break; } return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; pr_debug("%s %d %s\n", __func__, event, w->name); switch (event) { case <API key>: if (codec_ver == WCD9306) snd_soc_update_bits(codec, <API key>, 1 << 5, 1 << 5); break; case <API key>: if (codec_ver == WCD9306) snd_soc_update_bits(codec, <API key>, 1 << 5, 0); break; } return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name); switch (event) { case <API key>: snd_soc_update_bits(codec, <API key>, 1 << w->shift, 1 << w->shift); snd_soc_update_bits(codec, <API key>, 1 << w->shift, 0x0); break; case <API key>: /* apply the digital gain after the interpolator is enabled*/ if ((w->shift) < ARRAY_SIZE(rx_digital_gain_reg)) snd_soc_write(codec, rx_digital_gain_reg[w->shift], snd_soc_read(codec, rx_digital_gain_reg[w->shift]) ); break; } return 0; } /* called under codec_resource_lock acquisition */ static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tapan_priv *priv = <API key>(codec); pr_debug("%s: enter\n", __func__); switch (event) { case <API key>: /* * ldo_h_users is protected by codec->mutex, don't need * additional mutex */ if (++priv->ldo_h_users == 1) { WCD9XXX_BG_CLK_LOCK(&priv->resmgr); <API key>(&priv->resmgr, <API key>); <API key>(&priv->resmgr, WCD9XXX_CLK_RCO); snd_soc_update_bits(codec, <API key>, 1 << 7, 1 << 7); <API key>(&priv->resmgr, WCD9XXX_CLK_RCO); <API key>(&priv->resmgr); pr_debug("%s: ldo_h_users %d\n", __func__, priv->ldo_h_users); /* LDO enable requires 1ms to settle down */ usleep_range(1000, 1010); } break; case <API key>: if (--priv->ldo_h_users == 0) { WCD9XXX_BG_CLK_LOCK(&priv->resmgr); <API key>(&priv->resmgr, WCD9XXX_CLK_RCO); snd_soc_update_bits(codec, <API key>, 1 << 7, 0); <API key>(&priv->resmgr, WCD9XXX_CLK_RCO); <API key>(&priv->resmgr, <API key>); <API key>(&priv->resmgr); pr_debug("%s: ldo_h_users %d\n", __func__, priv->ldo_h_users); } WARN(priv->ldo_h_users < 0, "Unexpected ldo_h users %d\n", priv->ldo_h_users); break; } pr_debug("%s: leave\n", __func__); return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { int rc; rc = <API key>(w, kcontrol, event); return rc; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tapan_priv *tapan = <API key>(codec); dev_dbg(codec->dev, "%s %d\n", __func__, event); switch (event) { case <API key>: <API key>(&tapan->resmgr, 1); break; case <API key>: <API key>(&tapan->resmgr, 0); break; } return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tapan_priv *tapan_p = <API key>(codec); dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); switch (event) { case <API key>: snd_soc_update_bits(codec, <API key>, 0x02, 0x02); wcd9xxx_clsh_fsm(codec, &tapan_p->clsh_d, <API key>, <API key>, <API key>); break; case <API key>: snd_soc_update_bits(codec, <API key>, 0x02, 0x00); } return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tapan_priv *tapan_p = <API key>(codec); dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); switch (event) { case <API key>: snd_soc_update_bits(codec, <API key>, 0x04, 0x04); snd_soc_update_bits(codec, w->reg, 0x40, 0x40); wcd9xxx_clsh_fsm(codec, &tapan_p->clsh_d, <API key>, <API key>, <API key>); break; case <API key>: snd_soc_update_bits(codec, <API key>, 0x04, 0x00); snd_soc_update_bits(codec, w->reg, 0x40, 0x00); break; } return 0; } static int tapan_hph_pa_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tapan_priv *tapan = <API key>(codec); enum <API key> e_pre_on, e_post_off; u8 req_clsh_state; u32 pa_settle_time = <API key>; dev_dbg(codec->dev, "%s: %s event = %d\n", __func__, w->name, event); if (w->shift == 5) { e_pre_on = <API key>; e_post_off = <API key>; req_clsh_state = <API key>; } else if (w->shift == 4) { e_pre_on = <API key>; e_post_off = <API key>; req_clsh_state = <API key>; } else { pr_err("%s: Invalid w->shift %d\n", __func__, w->shift); return -EINVAL; } if (tapan->comp_enabled[COMPANDER_1]) pa_settle_time = <API key>; switch (event) { case <API key>: /* Let MBHC module know PA is turning on */ <API key>(&tapan->resmgr, e_pre_on); break; case <API key>: dev_dbg(codec->dev, "%s: sleep %d ms after %s PA enable.\n", __func__, pa_settle_time / 1000, w->name); /* Time needed for PA to settle */ usleep_range(pa_settle_time, pa_settle_time + 1000); wcd9xxx_clsh_fsm(codec, &tapan->clsh_d, req_clsh_state, <API key>, <API key>); break; case <API key>: dev_dbg(codec->dev, "%s: sleep %d ms after %s PA disable.\n", __func__, pa_settle_time / 1000, w->name); /* Time needed for PA to settle */ usleep_range(pa_settle_time, pa_settle_time + 1000); /* Let MBHC module know PA turned off */ <API key>(&tapan->resmgr, e_post_off); wcd9xxx_clsh_fsm(codec, &tapan->clsh_d, req_clsh_state, <API key>, <API key>); break; } return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; int ret = 0; switch (event) { case <API key>: ret = tapan_hph_pa_event(w, kcontrol, event); if (w->shift == 4) { ret |= <API key>(w, kcontrol, event); msleep(50); } break; case <API key>: if (w->shift == 4) { snd_soc_update_bits(codec, <API key>, 0x30, 0x30); msleep(30); } ret = tapan_hph_pa_event(w, kcontrol, event); break; case <API key>: if (w->shift == 5) { snd_soc_update_bits(codec, <API key>, 0x30, 0x00); msleep(40); snd_soc_update_bits(codec, <API key>, 0x80, 00); ret |= <API key>(w, kcontrol, event); } break; case <API key>: ret = tapan_hph_pa_event(w, kcontrol, event); break; } return ret; } static const struct snd_soc_dapm_widget <API key>[] = { SND_SOC_DAPM_SUPPLY("I2S_CLK", <API key>, 4, 0, NULL, 0), }; static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tapan_priv *tapan = <API key>(codec); dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); switch (event) { case <API key>: wcd9xxx_clsh_fsm(codec, &tapan->clsh_d, <API key>, <API key>, <API key>); snd_soc_update_bits(codec, w->reg, 0x40, 0x40); break; case <API key>: snd_soc_update_bits(codec, w->reg, 0x40, 0x00); break; } return 0; } static int tapan_spk_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); return 0; } static const struct snd_soc_dapm_route audio_i2s_map[] = { {"I2S_CLK", NULL, "CDC_CONN"}, {"SLIM RX1", NULL, "I2S_CLK"}, {"SLIM RX2", NULL, "I2S_CLK"}, {"SLIM TX1 MUX", NULL, "I2S_CLK"}, {"SLIM TX2 MUX", NULL, "I2S_CLK"}, }; static const struct snd_soc_dapm_route wcd9306_map[] = { {"SLIM TX1 MUX", "RMIX4", "RX4 MIX1"}, {"SLIM TX2 MUX", "RMIX4", "RX4 MIX1"}, {"SLIM TX3 MUX", "RMIX4", "RX4 MIX1"}, {"SLIM TX4 MUX", "RMIX4", "RX4 MIX1"}, {"SLIM TX5 MUX", "RMIX4", "RX4 MIX1"}, {"SLIM TX1 MUX", "DEC3", "DEC3 MUX"}, {"SLIM TX1 MUX", "DEC4", "DEC4 MUX"}, {"SLIM TX2 MUX", "DEC3", "DEC3 MUX"}, {"SLIM TX2 MUX", "DEC4", "DEC4 MUX"}, {"SLIM TX3 MUX", "DEC3", "DEC3 MUX"}, {"SLIM TX4 MUX", "DEC4", "DEC4 MUX"}, {"ANC EAR", NULL, "ANC EAR PA"}, {"ANC EAR PA", NULL, "EAR_PA_MIXER"}, {"ANC1 FB MUX", "EAR_HPH_L", "RX1 MIX2"}, {"ANC1 FB MUX", "EAR_LINE_1", "RX2 MIX2"}, {"ANC HEADPHONE", NULL, "ANC HPHL"}, {"ANC HEADPHONE", NULL, "ANC HPHR"}, {"ANC HPHL", NULL, "HPHL_PA_MIXER"}, {"ANC HPHR", NULL, "HPHR_PA_MIXER"}, {"ANC1 MUX", "ADC1", "ADC1"}, {"ANC1 MUX", "ADC2", "ADC2"}, {"ANC1 MUX", "ADC3", "ADC3"}, {"ANC1 MUX", "ADC4", "ADC4"}, {"ANC1 MUX", "ADC5", "ADC5"}, {"ANC1 MUX", "DMIC1", "DMIC1"}, {"ANC1 MUX", "DMIC2", "DMIC2"}, {"ANC1 MUX", "DMIC3", "DMIC3"}, {"ANC1 MUX", "DMIC4", "DMIC4"}, {"ANC2 MUX", "ADC1", "ADC1"}, {"ANC2 MUX", "ADC2", "ADC2"}, {"ANC2 MUX", "ADC3", "ADC3"}, {"ANC2 MUX", "ADC4", "ADC4"}, {"ANC2 MUX", "ADC5", "ADC5"}, {"ANC2 MUX", "DMIC1", "DMIC1"}, {"ANC2 MUX", "DMIC2", "DMIC2"}, {"ANC2 MUX", "DMIC3", "DMIC3"}, {"ANC2 MUX", "DMIC4", "DMIC4"}, {"ANC HPHR", NULL, "CDC_CONN"}, {"RDAC5 MUX", "DEM4", "RX4 MIX2"}, {"SPK DAC", "Switch", "RX4 MIX2"}, {"RX1 MIX2", NULL, "ANC1 MUX"}, {"RX2 MIX2", NULL, "ANC2 MUX"}, {"RX1 MIX1", NULL, "COMP1_CLK"}, {"RX2 MIX1", NULL, "COMP1_CLK"}, {"RX3 MIX1", NULL, "COMP2_CLK"}, {"RX4 MIX1", NULL, "COMP0_CLK"}, {"RX4 MIX1", NULL, "RX4 MIX1 INP1"}, {"RX4 MIX1", NULL, "RX4 MIX1 INP2"}, {"RX4 MIX2", NULL, "RX4 MIX1"}, {"RX4 MIX2", NULL, "RX4 MIX2 INP1"}, {"RX4 MIX2", NULL, "RX4 MIX2 INP2"}, {"RX4 MIX1 INP1", "RX1", "SLIM RX1"}, {"RX4 MIX1 INP1", "RX2", "SLIM RX2"}, {"RX4 MIX1 INP1", "RX3", "SLIM RX3"}, {"RX4 MIX1 INP1", "RX4", "SLIM RX4"}, {"RX4 MIX1 INP1", "RX5", "SLIM RX5"}, {"RX4 MIX1 INP1", "IIR1", "IIR1"}, {"RX4 MIX1 INP2", "RX1", "SLIM RX1"}, {"RX4 MIX1 INP2", "RX2", "SLIM RX2"}, {"RX4 MIX1 INP2", "RX3", "SLIM RX3"}, {"RX4 MIX1 INP2", "RX5", "SLIM RX5"}, {"RX4 MIX1 INP2", "RX4", "SLIM RX4"}, {"RX4 MIX1 INP2", "IIR1", "IIR1"}, {"RX4 MIX2 INP1", "IIR1", "IIR1"}, {"RX4 MIX2 INP2", "IIR1", "IIR1"}, {"DEC1 MUX", "DMIC3", "DMIC3"}, {"DEC1 MUX", "DMIC4", "DMIC4"}, {"DEC2 MUX", "DMIC3", "DMIC3"}, {"DEC2 MUX", "DMIC4", "DMIC4"}, {"DEC3 MUX", "ADC1", "ADC1"}, {"DEC3 MUX", "ADC2", "ADC2"}, {"DEC3 MUX", "ADC3", "ADC3"}, {"DEC3 MUX", "ADC4", "ADC4"}, {"DEC3 MUX", "ADC5", "ADC5"}, {"DEC3 MUX", "DMIC1", "DMIC1"}, {"DEC3 MUX", "DMIC2", "DMIC2"}, {"DEC3 MUX", "DMIC3", "DMIC3"}, {"DEC3 MUX", "DMIC4", "DMIC4"}, {"DEC3 MUX", NULL, "CDC_CONN"}, {"DEC4 MUX", "ADC1", "ADC1"}, {"DEC4 MUX", "ADC2", "ADC2"}, {"DEC4 MUX", "ADC3", "ADC3"}, {"DEC4 MUX", "ADC4", "ADC4"}, {"DEC4 MUX", "ADC5", "ADC5"}, {"DEC4 MUX", "DMIC1", "DMIC1"}, {"DEC4 MUX", "DMIC2", "DMIC2"}, {"DEC4 MUX", "DMIC3", "DMIC3"}, {"DEC4 MUX", "DMIC4", "DMIC4"}, {"DEC4 MUX", NULL, "CDC_CONN"}, {"ADC5", NULL, "AMIC5"}, {"AUX_PGA_Left", NULL, "AMIC5"}, {"IIR1 INP1 MUX", "DEC3", "DEC3 MUX"}, {"IIR1 INP1 MUX", "DEC4", "DEC4 MUX"}, {"MIC BIAS3 Internal1", NULL, "LDO_H"}, {"MIC BIAS3 Internal2", NULL, "LDO_H"}, {"MIC BIAS3 External", NULL, "LDO_H"}, }; static const struct snd_soc_dapm_route audio_map[] = { /* SLIMBUS Connections */ {"AIF1 CAP", NULL, "AIF1_CAP Mixer"}, {"AIF2 CAP", NULL, "AIF2_CAP Mixer"}, {"AIF3 CAP", NULL, "AIF3_CAP Mixer"}, /* SLIM_MIXER("AIF1_CAP Mixer"),*/ {"AIF1_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"}, {"AIF1_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"}, {"AIF1_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"}, {"AIF1_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"}, {"AIF1_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"}, /* SLIM_MIXER("AIF2_CAP Mixer"),*/ {"AIF2_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"}, {"AIF2_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"}, {"AIF2_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"}, {"AIF2_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"}, {"AIF2_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"}, /* SLIM_MIXER("AIF3_CAP Mixer"),*/ {"AIF3_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"}, {"AIF3_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"}, {"AIF3_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"}, {"AIF3_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"}, {"AIF3_CAP Mixer", "SLIM TX5", "SLIM TX5 MUX"}, {"SLIM TX1 MUX", "DEC1", "DEC1 MUX"}, {"SLIM TX1 MUX", "DEC2", "DEC2 MUX"}, {"SLIM TX1 MUX", "RMIX1", "RX1 MIX1"}, {"SLIM TX1 MUX", "RMIX2", "RX2 MIX1"}, {"SLIM TX1 MUX", "RMIX3", "RX3 MIX1"}, {"SLIM TX2 MUX", "DEC1", "DEC1 MUX"}, {"SLIM TX2 MUX", "DEC2", "DEC2 MUX"}, {"SLIM TX2 MUX", "RMIX1", "RX1 MIX1"}, {"SLIM TX2 MUX", "RMIX2", "RX2 MIX1"}, {"SLIM TX2 MUX", "RMIX3", "RX3 MIX1"}, {"SLIM TX3 MUX", "RMIX1", "RX1 MIX1"}, {"SLIM TX3 MUX", "RMIX2", "RX2 MIX1"}, {"SLIM TX3 MUX", "RMIX3", "RX3 MIX1"}, {"SLIM TX4 MUX", "RMIX1", "RX1 MIX1"}, {"SLIM TX4 MUX", "RMIX2", "RX2 MIX1"}, {"SLIM TX4 MUX", "RMIX3", "RX3 MIX1"}, {"SLIM TX5 MUX", "DEC1", "DEC1 MUX"}, {"SLIM TX5 MUX", "RMIX1", "RX1 MIX1"}, {"SLIM TX5 MUX", "RMIX2", "RX2 MIX1"}, {"SLIM TX5 MUX", "RMIX3", "RX3 MIX1"}, /* Earpiece (RX MIX1) */ {"EAR", NULL, "EAR PA"}, {"EAR PA", NULL, "EAR_PA_MIXER"}, {"EAR_PA_MIXER", NULL, "DAC1"}, {"DAC1", NULL, "RX_BIAS"}, {"DAC1", NULL, "CDC_CP_VDD"}, /* Headset (RX MIX1 and RX MIX2) */ {"HEADPHONE", NULL, "HPHL"}, {"HEADPHONE", NULL, "HPHR"}, {"HPHL", NULL, "HPHL_PA_MIXER"}, {"HPHL_PA_MIXER", NULL, "HPHL DAC"}, {"HPHL DAC", NULL, "RX_BIAS"}, {"HPHL DAC", NULL, "CDC_CP_VDD"}, {"HPHR", NULL, "HPHR_PA_MIXER"}, {"HPHR_PA_MIXER", NULL, "HPHR DAC"}, {"HPHR DAC", NULL, "RX_BIAS"}, {"HPHR DAC", NULL, "CDC_CP_VDD"}, {"DAC1", "Switch", "CLASS_H_DSM MUX"}, {"HPHL DAC", "Switch", "CLASS_H_DSM MUX"}, {"HPHR DAC", NULL, "RDAC3 MUX"}, {"LINEOUT1", NULL, "LINEOUT1 PA"}, {"LINEOUT2", NULL, "LINEOUT2 PA"}, {"SPK_OUT", NULL, "SPK PA"}, {"LINEOUT1 PA", NULL, "LINEOUT1_PA_MIXER"}, {"LINEOUT1_PA_MIXER", NULL, "LINEOUT1 DAC"}, {"LINEOUT2 PA", NULL, "LINEOUT2_PA_MIXER"}, {"LINEOUT2_PA_MIXER", NULL, "LINEOUT2 DAC"}, {"RDAC5 MUX", "DEM3_INV", "RX3 MIX1"}, {"LINEOUT2 DAC", NULL, "RDAC5 MUX"}, {"RDAC4 MUX", "DEM3", "RX3 MIX1"}, {"RDAC4 MUX", "DEM2", "RX2 CHAIN"}, {"LINEOUT1 DAC", NULL, "RDAC4 MUX"}, {"SPK PA", NULL, "SPK DAC"}, {"SPK DAC", NULL, "VDD_SPKDRV"}, {"RX1 INTERPOLATOR", NULL, "RX1 MIX2"}, {"RX1 CHAIN", NULL, "RX1 INTERPOLATOR"}, {"RX2 INTERPOLATOR", NULL, "RX2 MIX2"}, {"RX2 CHAIN", NULL, "RX2 INTERPOLATOR"}, {"CLASS_H_DSM MUX", "RX_HPHL", "RX1 CHAIN"}, {"LINEOUT1 DAC", NULL, "RX_BIAS"}, {"LINEOUT2 DAC", NULL, "RX_BIAS"}, {"LINEOUT1 DAC", NULL, "CDC_CP_VDD"}, {"LINEOUT2 DAC", NULL, "CDC_CP_VDD"}, {"RDAC3 MUX", "DEM2", "RX2 CHAIN"}, {"RDAC3 MUX", "DEM1", "RX1 CHAIN"}, {"RX1 MIX1", NULL, "RX1 MIX1 INP1"}, {"RX1 MIX1", NULL, "RX1 MIX1 INP2"}, {"RX1 MIX1", NULL, "RX1 MIX1 INP3"}, {"RX2 MIX1", NULL, "RX2 MIX1 INP1"}, {"RX2 MIX1", NULL, "RX2 MIX1 INP2"}, {"RX3 MIX1", NULL, "RX3 MIX1 INP1"}, {"RX3 MIX1", NULL, "RX3 MIX1 INP2"}, {"RX1 MIX2", NULL, "RX1 MIX1"}, {"RX1 MIX2", NULL, "RX1 MIX2 INP1"}, {"RX1 MIX2", NULL, "RX1 MIX2 INP2"}, {"RX2 MIX2", NULL, "RX2 MIX1"}, {"RX2 MIX2", NULL, "RX2 MIX2 INP1"}, {"RX2 MIX2", NULL, "RX2 MIX2 INP2"}, /* SLIM_MUX("AIF1_PB", "AIF1 PB"),*/ {"SLIM RX1 MUX", "AIF1_PB", "AIF1 PB"}, {"SLIM RX2 MUX", "AIF1_PB", "AIF1 PB"}, {"SLIM RX3 MUX", "AIF1_PB", "AIF1 PB"}, {"SLIM RX4 MUX", "AIF1_PB", "AIF1 PB"}, {"SLIM RX5 MUX", "AIF1_PB", "AIF1 PB"}, /* SLIM_MUX("AIF2_PB", "AIF2 PB"),*/ {"SLIM RX1 MUX", "AIF2_PB", "AIF2 PB"}, {"SLIM RX2 MUX", "AIF2_PB", "AIF2 PB"}, {"SLIM RX3 MUX", "AIF2_PB", "AIF2 PB"}, {"SLIM RX4 MUX", "AIF2_PB", "AIF2 PB"}, {"SLIM RX5 MUX", "AIF2_PB", "AIF2 PB"}, /* SLIM_MUX("AIF3_PB", "AIF3 PB"),*/ {"SLIM RX1 MUX", "AIF3_PB", "AIF3 PB"}, {"SLIM RX2 MUX", "AIF3_PB", "AIF3 PB"}, {"SLIM RX3 MUX", "AIF3_PB", "AIF3 PB"}, {"SLIM RX4 MUX", "AIF3_PB", "AIF3 PB"}, {"SLIM RX5 MUX", "AIF3_PB", "AIF3 PB"}, {"SLIM RX1", NULL, "SLIM RX1 MUX"}, {"SLIM RX2", NULL, "SLIM RX2 MUX"}, {"SLIM RX3", NULL, "SLIM RX3 MUX"}, {"SLIM RX4", NULL, "SLIM RX4 MUX"}, {"SLIM RX5", NULL, "SLIM RX5 MUX"}, {"RX1 MIX1 INP1", "RX1", "SLIM RX1"}, {"RX1 MIX1 INP1", "RX2", "SLIM RX2"}, {"RX1 MIX1 INP1", "RX3", "SLIM RX3"}, {"RX1 MIX1 INP1", "RX4", "SLIM RX4"}, {"RX1 MIX1 INP1", "RX5", "SLIM RX5"}, {"RX1 MIX1 INP1", "IIR1", "IIR1"}, {"RX1 MIX1 INP1", "IIR2", "IIR2"}, {"RX1 MIX1 INP2", "RX1", "SLIM RX1"}, {"RX1 MIX1 INP2", "RX2", "SLIM RX2"}, {"RX1 MIX1 INP2", "RX3", "SLIM RX3"}, {"RX1 MIX1 INP2", "RX4", "SLIM RX4"}, {"RX1 MIX1 INP2", "RX5", "SLIM RX5"}, {"RX1 MIX1 INP2", "IIR1", "IIR1"}, {"RX1 MIX1 INP2", "IIR2", "IIR2"}, {"RX1 MIX1 INP3", "RX1", "SLIM RX1"}, {"RX1 MIX1 INP3", "RX2", "SLIM RX2"}, {"RX1 MIX1 INP3", "RX3", "SLIM RX3"}, {"RX1 MIX1 INP3", "RX4", "SLIM RX4"}, {"RX1 MIX1 INP3", "RX5", "SLIM RX5"}, {"RX2 MIX1 INP1", "RX1", "SLIM RX1"}, {"RX2 MIX1 INP1", "RX2", "SLIM RX2"}, {"RX2 MIX1 INP1", "RX3", "SLIM RX3"}, {"RX2 MIX1 INP1", "RX4", "SLIM RX4"}, {"RX2 MIX1 INP1", "RX5", "SLIM RX5"}, {"RX2 MIX1 INP1", "IIR1", "IIR1"}, {"RX2 MIX1 INP1", "IIR2", "IIR2"}, {"RX2 MIX1 INP2", "RX1", "SLIM RX1"}, {"RX2 MIX1 INP2", "RX2", "SLIM RX2"}, {"RX2 MIX1 INP2", "RX3", "SLIM RX3"}, {"RX2 MIX1 INP2", "RX4", "SLIM RX4"}, {"RX2 MIX1 INP2", "RX5", "SLIM RX5"}, {"RX2 MIX1 INP2", "IIR1", "IIR1"}, {"RX2 MIX1 INP2", "IIR2", "IIR2"}, {"RX3 MIX1 INP1", "RX1", "SLIM RX1"}, {"RX3 MIX1 INP1", "RX2", "SLIM RX2"}, {"RX3 MIX1 INP1", "RX3", "SLIM RX3"}, {"RX3 MIX1 INP1", "RX4", "SLIM RX4"}, {"RX3 MIX1 INP1", "RX5", "SLIM RX5"}, {"RX3 MIX1 INP1", "IIR1", "IIR1"}, {"RX3 MIX1 INP1", "IIR2", "IIR2"}, {"RX3 MIX1 INP2", "RX1", "SLIM RX1"}, {"RX3 MIX1 INP2", "RX2", "SLIM RX2"}, {"RX3 MIX1 INP2", "RX3", "SLIM RX3"}, {"RX3 MIX1 INP2", "RX4", "SLIM RX4"}, {"RX3 MIX1 INP2", "RX5", "SLIM RX5"}, {"RX3 MIX1 INP2", "IIR1", "IIR1"}, {"RX3 MIX1 INP2", "IIR2", "IIR2"}, {"RX1 MIX2 INP1", "IIR1", "IIR1"}, {"RX1 MIX2 INP2", "IIR1", "IIR1"}, {"RX2 MIX2 INP1", "IIR1", "IIR1"}, {"RX2 MIX2 INP2", "IIR1", "IIR1"}, {"RX1 MIX2 INP1", "IIR2", "IIR2"}, {"RX1 MIX2 INP2", "IIR2", "IIR2"}, {"RX2 MIX2 INP1", "IIR2", "IIR2"}, {"RX2 MIX2 INP2", "IIR2", "IIR2"}, /* Decimator Inputs */ {"DEC1 MUX", "ADC1", "ADC1"}, {"DEC1 MUX", "ADC2", "ADC2"}, {"DEC1 MUX", "ADC3", "ADC3"}, {"DEC1 MUX", "ADC4", "ADC4"}, {"DEC1 MUX", "DMIC1", "DMIC1"}, {"DEC1 MUX", "DMIC2", "DMIC2"}, {"DEC1 MUX", NULL, "CDC_CONN"}, {"DEC2 MUX", "ADC1", "ADC1"}, {"DEC2 MUX", "ADC2", "ADC2"}, {"DEC2 MUX", "ADC3", "ADC3"}, {"DEC2 MUX", "ADC4", "ADC4"}, {"DEC2 MUX", "DMIC1", "DMIC1"}, {"DEC2 MUX", "DMIC2", "DMIC2"}, {"DEC2 MUX", NULL, "CDC_CONN"}, /* ADC Connections */ {"ADC1", NULL, "AMIC1"}, {"ADC2", NULL, "AMIC2"}, {"ADC3", NULL, "AMIC3"}, {"ADC4", NULL, "AMIC4"}, /* AUX PGA Connections */ {"EAR_PA_MIXER", "AUX_PGA_L Switch", "AUX_PGA_Left"}, {"HPHL_PA_MIXER", "AUX_PGA_L Switch", "AUX_PGA_Left"}, {"HPHR_PA_MIXER", "AUX_PGA_R Switch", "AUX_PGA_Right"}, {"LINEOUT1_PA_MIXER", "AUX_PGA_L Switch", "AUX_PGA_Left"}, {"LINEOUT2_PA_MIXER", "AUX_PGA_R Switch", "AUX_PGA_Right"}, {"MIC BIAS1 Internal1", NULL, "LDO_H"}, {"MIC BIAS1 Internal2", NULL, "LDO_H"}, {"MIC BIAS1 External", NULL, "LDO_H"}, {"MIC BIAS2 Internal1", NULL, "LDO_H"}, {"MIC BIAS2 Internal2", NULL, "LDO_H"}, {"MIC BIAS2 Internal3", NULL, "LDO_H"}, {"MIC BIAS2 External", NULL, "LDO_H"}, {<API key>, NULL, "LDO_H Standalone"}, /*sidetone path enable*/ {"IIR1", NULL, "IIR1 INP1 MUX"}, {"IIR1 INP1 MUX", "DEC1", "DEC1 MUX"}, {"IIR1 INP1 MUX", "DEC2", "DEC2 MUX"}, {"IIR1 INP1 MUX", "DEC3", "DEC3 MUX"}, {"IIR1 INP1 MUX", "DEC4", "DEC4 MUX"}, {"IIR1 INP1 MUX", "RX1", "SLIM RX1"}, {"IIR1 INP1 MUX", "RX2", "SLIM RX2"}, {"IIR1 INP1 MUX", "RX3", "SLIM RX3"}, {"IIR1 INP1 MUX", "RX4", "SLIM RX4"}, {"IIR1 INP1 MUX", "RX5", "SLIM RX5"}, {"IIR1", NULL, "IIR1 INP2 MUX"}, {"IIR1 INP2 MUX", "DEC1", "DEC1 MUX"}, {"IIR1 INP2 MUX", "DEC2", "DEC2 MUX"}, {"IIR1 INP2 MUX", "DEC3", "DEC3 MUX"}, {"IIR1 INP2 MUX", "DEC4", "DEC4 MUX"}, {"IIR1 INP2 MUX", "RX1", "SLIM RX1"}, {"IIR1 INP2 MUX", "RX2", "SLIM RX2"}, {"IIR1 INP2 MUX", "RX3", "SLIM RX3"}, {"IIR1 INP2 MUX", "RX4", "SLIM RX4"}, {"IIR1 INP2 MUX", "RX5", "SLIM RX5"}, {"IIR1", NULL, "IIR1 INP3 MUX"}, {"IIR1 INP3 MUX", "DEC1", "DEC1 MUX"}, {"IIR1 INP3 MUX", "DEC2", "DEC2 MUX"}, {"IIR1 INP3 MUX", "DEC3", "DEC3 MUX"}, {"IIR1 INP3 MUX", "DEC4", "DEC4 MUX"}, {"IIR1 INP3 MUX", "RX1", "SLIM RX1"}, {"IIR1 INP3 MUX", "RX2", "SLIM RX2"}, {"IIR1 INP3 MUX", "RX3", "SLIM RX3"}, {"IIR1 INP3 MUX", "RX4", "SLIM RX4"}, {"IIR1 INP3 MUX", "RX5", "SLIM RX5"}, {"IIR1", NULL, "IIR1 INP4 MUX"}, {"IIR1 INP4 MUX", "DEC1", "DEC1 MUX"}, {"IIR1 INP4 MUX", "DEC2", "DEC2 MUX"}, {"IIR1 INP4 MUX", "DEC3", "DEC3 MUX"}, {"IIR1 INP4 MUX", "DEC4", "DEC4 MUX"}, {"IIR1 INP4 MUX", "RX1", "SLIM RX1"}, {"IIR1 INP4 MUX", "RX2", "SLIM RX2"}, {"IIR1 INP4 MUX", "RX3", "SLIM RX3"}, {"IIR1 INP4 MUX", "RX4", "SLIM RX4"}, {"IIR1 INP4 MUX", "RX5", "SLIM RX5"}, {"IIR2", NULL, "IIR2 INP1 MUX"}, {"IIR2 INP1 MUX", "DEC1", "DEC1 MUX"}, {"IIR2 INP1 MUX", "DEC2", "DEC2 MUX"}, {"IIR2 INP1 MUX", "DEC3", "DEC3 MUX"}, {"IIR2 INP1 MUX", "DEC4", "DEC4 MUX"}, {"IIR2 INP1 MUX", "RX1", "SLIM RX1"}, {"IIR2 INP1 MUX", "RX2", "SLIM RX2"}, {"IIR2 INP1 MUX", "RX3", "SLIM RX3"}, {"IIR2 INP1 MUX", "RX4", "SLIM RX4"}, {"IIR2 INP1 MUX", "RX5", "SLIM RX5"}, {"IIR2", NULL, "IIR2 INP2 MUX"}, {"IIR2 INP2 MUX", "DEC1", "DEC1 MUX"}, {"IIR2 INP2 MUX", "DEC2", "DEC2 MUX"}, {"IIR2 INP2 MUX", "DEC3", "DEC3 MUX"}, {"IIR2 INP2 MUX", "DEC4", "DEC4 MUX"}, {"IIR2 INP2 MUX", "RX1", "SLIM RX1"}, {"IIR2 INP2 MUX", "RX2", "SLIM RX2"}, {"IIR2 INP2 MUX", "RX3", "SLIM RX3"}, {"IIR2 INP2 MUX", "RX4", "SLIM RX4"}, {"IIR2 INP2 MUX", "RX5", "SLIM RX5"}, {"IIR2", NULL, "IIR2 INP3 MUX"}, {"IIR2 INP3 MUX", "DEC1", "DEC1 MUX"}, {"IIR2 INP3 MUX", "DEC2", "DEC2 MUX"}, {"IIR2 INP3 MUX", "DEC3", "DEC3 MUX"}, {"IIR2 INP3 MUX", "DEC4", "DEC4 MUX"}, {"IIR2 INP3 MUX", "RX1", "SLIM RX1"}, {"IIR2 INP3 MUX", "RX2", "SLIM RX2"}, {"IIR2 INP3 MUX", "RX3", "SLIM RX3"}, {"IIR2 INP3 MUX", "RX4", "SLIM RX4"}, {"IIR2 INP3 MUX", "RX5", "SLIM RX5"}, {"IIR2", NULL, "IIR2 INP4 MUX"}, {"IIR2 INP4 MUX", "DEC1", "DEC1 MUX"}, {"IIR2 INP4 MUX", "DEC2", "DEC2 MUX"}, {"IIR2 INP4 MUX", "DEC3", "DEC3 MUX"}, {"IIR2 INP4 MUX", "DEC4", "DEC4 MUX"}, {"IIR2 INP4 MUX", "RX1", "SLIM RX1"}, {"IIR2 INP4 MUX", "RX2", "SLIM RX2"}, {"IIR2 INP4 MUX", "RX3", "SLIM RX3"}, {"IIR2 INP4 MUX", "RX4", "SLIM RX4"}, {"IIR2 INP4 MUX", "RX5", "SLIM RX5"}, }; static const struct snd_soc_dapm_route wcd9302_map[] = { {"SPK DAC", "Switch", "RX3 MIX1"}, {"RDAC5 MUX", "DEM4", "RX3 MIX1"}, {"RDAC5 MUX", "DEM3_INV", "RDAC4 MUX"}, }; static int tapan_readable(struct snd_soc_codec *ssc, unsigned int reg) { return tapan_reg_readable[reg]; } static bool <API key>(unsigned int reg) { bool rtn = false; switch (reg) { case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: rtn = true; break; default: break; } return rtn; } static int tapan_volatile(struct snd_soc_codec *ssc, unsigned int reg) { int i = 0; /* Registers lower than 0x100 are top level registers which can be * written by the Tapan core driver. */ if ((reg >= <API key>) || (reg < 0x100)) return 1; /* IIR Coeff registers are not cacheable */ if ((reg >= <API key>) && (reg <= <API key>)) return 1; /* ANC filter registers are not cacheable */ if ((reg >= <API key>) && (reg <= <API key>)) return 1; if ((reg >= <API key>) && (reg <= <API key>)) return 1; /* Digital gain register is not cacheable so we have to write * the setting even it is the same */ if (<API key>(reg)) return 1; /* HPH status registers */ if (reg == <API key> || reg == <API key>) return 1; if (reg == <API key>) return 1; for (i = 0; i < ARRAY_SIZE(audio_reg_cfg); i++) if (audio_reg_cfg[i].reg_logical_addr - <API key> == reg) return 1; return 0; } #define TAPAN_FORMATS (<API key>) #define <API key> (<API key> | \ <API key>) static int tapan_write(struct snd_soc_codec *codec, unsigned int reg, unsigned int value) { int ret; struct wcd9xxx *wcd9xxx = codec->control_data; if (reg == SND_SOC_NOPM) return 0; BUG_ON(reg > TAPAN_MAX_REGISTER); if (!tapan_volatile(codec, reg)) { ret = snd_soc_cache_write(codec, reg, value); if (ret != 0) dev_err(codec->dev, "Cache write to %x failed: %d\n", reg, ret); } return wcd9xxx_reg_write(&wcd9xxx->core_res, reg, value); } static unsigned int tapan_read(struct snd_soc_codec *codec, unsigned int reg) { unsigned int val; int ret; struct wcd9xxx *wcd9xxx = codec->control_data; if (reg == SND_SOC_NOPM) return 0; BUG_ON(reg > TAPAN_MAX_REGISTER); if (!tapan_volatile(codec, reg) && tapan_readable(codec, reg) && reg < codec->driver->reg_cache_size) { ret = snd_soc_cache_read(codec, reg, &val); if (ret >= 0) { return val; } else dev_err(codec->dev, "Cache read from %x failed: %d\n", reg, ret); } val = wcd9xxx_reg_read(&wcd9xxx->core_res, reg); return val; } static int tapan_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct wcd9xxx *tapan_core = dev_get_drvdata(dai->codec->dev->parent); dev_dbg(dai->codec->dev, "%s(): substream = %s stream = %d\n", __func__, substream->name, substream->stream); if ((tapan_core != NULL) && (tapan_core->dev != NULL) && (tapan_core->dev->parent != NULL)) pm_runtime_get_sync(tapan_core->dev->parent); return 0; } static void tapan_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct wcd9xxx *tapan_core = dev_get_drvdata(dai->codec->dev->parent); struct tapan_priv *tapan = <API key>(dai->codec); u32 active = 0; dev_dbg(dai->codec->dev, "%s(): substream = %s stream = %d\n", __func__, substream->name, substream->stream); if (dai->id < NUM_CODEC_DAIS) { if (tapan->dai[dai->id].ch_mask) { active = 1; dev_dbg(dai->codec->dev, "%s(): Codec DAI: chmask[%d] = 0x%lx\n", __func__, dai->id, tapan->dai[dai->id].ch_mask); } } if ((tapan_core != NULL) && (tapan_core->dev != NULL) && (tapan_core->dev->parent != NULL) && (active == 0)) { <API key>(tapan_core->dev->parent); pm_runtime_put(tapan_core->dev->parent); dev_dbg(dai->codec->dev, "%s: unvote requested", __func__); } } static void <API key>(struct snd_soc_codec *codec, int current_uA) { struct regulator *cx_regulator; int ret; cx_regulator = <API key>(codec, "cdc-vdd-cx"); if (!cx_regulator) { dev_err(codec->dev, "%s: Regulator %s not defined\n", __func__, "cdc-vdd-cx-supply"); return; } ret = <API key>(cx_regulator, current_uA); if (ret < 0) dev_err(codec->dev, "%s: Failed to set vdd_cx current to %d\n", __func__, current_uA); } int tapan_mclk_enable(struct snd_soc_codec *codec, int mclk_enable, bool dapm) { struct tapan_priv *tapan = <API key>(codec); dev_dbg(codec->dev, "%s: mclk_enable = %u, dapm = %d\n", __func__, mclk_enable, dapm); WCD9XXX_BG_CLK_LOCK(&tapan->resmgr); if (mclk_enable) { <API key>(codec, <API key>); <API key>(&tapan->resmgr, <API key>); <API key>(&tapan->resmgr, WCD9XXX_CLK_MCLK); } else { /* Put clock and BG */ <API key>(&tapan->resmgr, WCD9XXX_CLK_MCLK); <API key>(&tapan->resmgr, <API key>); /* Set the vdd cx power rail sleep mode current */ <API key>(codec, <API key>); } <API key>(&tapan->resmgr); return 0; } static int <API key>(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { dev_dbg(dai->codec->dev, "%s\n", __func__); return 0; } static int tapan_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { u8 val = 0; struct snd_soc_codec *codec = dai->codec; struct tapan_priv *tapan = <API key>(codec); dev_dbg(codec->dev, "%s\n", __func__); switch (fmt & <API key>) { case <API key>: /* CPU is master */ if (tapan->intf_type == <API key>) { if (dai->id == AIF1_CAP) snd_soc_update_bits(codec, <API key>, <API key>, 0); else if (dai->id == AIF1_PB) snd_soc_update_bits(codec, <API key>, <API key>, 0); } break; case <API key>: /* CPU is slave */ if (tapan->intf_type == <API key>) { val = <API key>; if (dai->id == AIF1_CAP) snd_soc_update_bits(codec, <API key>, val, val); else if (dai->id == AIF1_PB) snd_soc_update_bits(codec, <API key>, val, val); } break; default: return -EINVAL; } return 0; } static int <API key>(struct snd_soc_dai *dai, unsigned int tx_num, unsigned int *tx_slot, unsigned int rx_num, unsigned int *rx_slot) { struct tapan_priv *tapan = <API key>(dai->codec); struct wcd9xxx *core = dev_get_drvdata(dai->codec->dev->parent); if (!tx_slot || !rx_slot) { pr_err("%s: Invalid\n", __func__); return -EINVAL; } dev_dbg(dai->codec->dev, "%s(): dai_name = %s DAI-ID %x\n", __func__, dai->name, dai->id); dev_dbg(dai->codec->dev, "%s(): tx_ch %d rx_ch %d\n intf_type %d\n", __func__, tx_num, rx_num, tapan->intf_type); if (tapan->intf_type == <API key>) <API key>(core, core->slim->laddr, tx_num, tx_slot, rx_num, rx_slot); return 0; } static int <API key>(struct snd_soc_dai *dai, unsigned int *tx_num, unsigned int *tx_slot, unsigned int *rx_num, unsigned int *rx_slot) { struct tapan_priv *tapan_p = <API key>(dai->codec); u32 i = 0; struct wcd9xxx_ch *ch; switch (dai->id) { case AIF1_PB: case AIF2_PB: case AIF3_PB: if (!rx_slot || !rx_num) { pr_err("%s: Invalid rx_slot %d or rx_num %d\n", __func__, (u32) rx_slot, (u32) rx_num); return -EINVAL; } list_for_each_entry(ch, &tapan_p->dai[dai->id].wcd9xxx_ch_list, list) { dev_dbg(dai->codec->dev, "%s: rx_slot[%d] %d, ch->ch_num %d\n", __func__, i, rx_slot[i], ch->ch_num); rx_slot[i++] = ch->ch_num; } dev_dbg(dai->codec->dev, "%s: rx_num %d\n", __func__, i); *rx_num = i; break; case AIF1_CAP: case AIF2_CAP: case AIF3_CAP: if (!tx_slot || !tx_num) { pr_err("%s: Invalid tx_slot %d or tx_num %d\n", __func__, (u32) tx_slot, (u32) tx_num); return -EINVAL; } list_for_each_entry(ch, &tapan_p->dai[dai->id].wcd9xxx_ch_list, list) { dev_dbg(dai->codec->dev, "%s: tx_slot[%d] %d, ch->ch_num %d\n", __func__, i, tx_slot[i], ch->ch_num); tx_slot[i++] = ch->ch_num; } dev_dbg(dai->codec->dev, "%s: tx_num %d\n", __func__, i); *tx_num = i; break; default: pr_err("%s: Invalid DAI ID %x\n", __func__, dai->id); break; } return 0; } static int <API key>(struct snd_soc_dai *dai, u8 rx_fs_rate_reg_val, u32 compander_fs, u32 sample_rate) { u32 j; u8 rx_mix1_inp; u16 rx_mix_1_reg_1, rx_mix_1_reg_2; u16 rx_fs_reg; u8 rx_mix_1_reg_1_val, rx_mix_1_reg_2_val; u8 rdac5_mux; struct snd_soc_codec *codec = dai->codec; struct wcd9xxx_ch *ch; struct tapan_priv *tapan = <API key>(codec); list_for_each_entry(ch, &tapan->dai[dai->id].wcd9xxx_ch_list, list) { /* for RX port starting from 16 instead of 10 like tabla */ rx_mix1_inp = ch->port + RX_MIX1_INP_SEL_RX1 - <API key>; if ((rx_mix1_inp < RX_MIX1_INP_SEL_RX1) || (rx_mix1_inp > RX_MIX1_INP_SEL_RX5)) { pr_err("%s: Invalid TAPAN_RX%u port. Dai ID is %d\n", __func__, rx_mix1_inp - 5 , dai->id); return -EINVAL; } rx_mix_1_reg_1 = <API key>; rdac5_mux = snd_soc_read(codec, <API key>); rdac5_mux = (rdac5_mux & 0x04) >> 2; for (j = 0; j < NUM_INTERPOLATORS; j++) { rx_mix_1_reg_2 = rx_mix_1_reg_1 + 1; rx_mix_1_reg_1_val = snd_soc_read(codec, rx_mix_1_reg_1); rx_mix_1_reg_2_val = snd_soc_read(codec, rx_mix_1_reg_2); if (((rx_mix_1_reg_1_val & 0x0F) == rx_mix1_inp) || (((rx_mix_1_reg_1_val >> 4) & 0x0F) == rx_mix1_inp) || ((rx_mix_1_reg_2_val & 0x0F) == rx_mix1_inp)) { rx_fs_reg = <API key> + 8 * j; dev_dbg(codec->dev, "%s: AIF_PB DAI(%d) connected to RX%u\n", __func__, dai->id, j + 1); dev_dbg(codec->dev, "%s: set RX%u sample rate to %u\n", __func__, j + 1, sample_rate); snd_soc_update_bits(codec, rx_fs_reg, 0xE0, rx_fs_rate_reg_val); if (comp_rx_path[j] < COMPANDER_MAX) { if ((j == 3) && (rdac5_mux == 1)) tapan->comp_fs[COMPANDER_0] = compander_fs; else tapan->comp_fs[comp_rx_path[j]] = compander_fs; } } if (j <= 1) rx_mix_1_reg_1 += 3; else rx_mix_1_reg_1 += 2; } } return 0; } static int <API key>(struct snd_soc_dai *dai, u8 tx_fs_rate_reg_val, u32 sample_rate) { struct snd_soc_codec *codec = dai->codec; struct wcd9xxx_ch *ch; struct tapan_priv *tapan = <API key>(codec); u32 tx_port; u16 tx_port_reg, tx_fs_reg; u8 tx_port_reg_val; s8 decimator; list_for_each_entry(ch, &tapan->dai[dai->id].wcd9xxx_ch_list, list) { tx_port = ch->port + 1; dev_dbg(codec->dev, "%s: dai->id = %d, tx_port = %d", __func__, dai->id, tx_port); if ((tx_port < 1) || (tx_port > <API key>)) { pr_err("%s: Invalid SLIM TX%u port. DAI ID is %d\n", __func__, tx_port, dai->id); return -EINVAL; } tx_port_reg = <API key> + (tx_port - 1); tx_port_reg_val = snd_soc_read(codec, tx_port_reg); decimator = 0; tx_port_reg_val = tx_port_reg_val & 0x0F; if ((tx_port_reg_val >= 0x8) && (tx_port_reg_val <= 0x11)) { decimator = (tx_port_reg_val - 0x8) + 1; } if (decimator) { /* SLIM_TX port has a DEC as input */ tx_fs_reg = <API key> + 8 * (decimator - 1); dev_dbg(codec->dev, "%s: set DEC%u (-> SLIM_TX%u) rate to %u\n", __func__, decimator, tx_port, sample_rate); snd_soc_update_bits(codec, tx_fs_reg, 0x07, tx_fs_rate_reg_val); } else { if ((tx_port_reg_val >= 0x1) && (tx_port_reg_val <= 0x4)) { dev_dbg(codec->dev, "%s: RMIX%u going to SLIM TX%u\n", __func__, tx_port_reg_val, tx_port); } else if ((tx_port_reg_val >= 0x8) && (tx_port_reg_val <= 0x11)) { pr_err("%s: ERROR: Should not be here\n", __func__); pr_err("%s: ERROR: DEC connected to SLIM TX%u\n", __func__, tx_port); return -EINVAL; } else if (tx_port_reg_val == 0) { dev_dbg(codec->dev, "%s: no signal to SLIM TX%u\n", __func__, tx_port); } else { pr_err("%s: ERROR: wrong signal to SLIM TX%u\n", __func__, tx_port); pr_err("%s: ERROR: wrong signal = %u\n", __func__, tx_port_reg_val); return -EINVAL; } } } return 0; } static void <API key>(struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { struct snd_soc_codec *codec = dai->codec; struct tapan_priv *tapan_p = <API key>(codec); struct <API key> *cdc_dai; struct wcd9xxx_ch *ch; int port; u8 bit_sel; u16 sb_ctl_reg, field_shift; switch (params_format(params)) { case <API key>: bit_sel = 0x2; tapan_p->dai[dai->id].bit_width = 16; break; case <API key>: bit_sel = 0x0; tapan_p->dai[dai->id].bit_width = 24; break; default: dev_err(codec->dev, "Invalid format %x\n", params_format(params)); return; } cdc_dai = &tapan_p->dai[dai->id]; list_for_each_entry(ch, &cdc_dai->wcd9xxx_ch_list, list) { port = <API key>(ch->ch_num); if (IS_ERR_VALUE(port) || !<API key>(port)) { dev_warn(codec->dev, "%s: invalid port ID %d returned for RX DAI\n", __func__, port); return; } port = <API key>(port); if (port <= 3) { sb_ctl_reg = <API key>; field_shift = port << 1; } else if (port <= 4) { sb_ctl_reg = <API key>; field_shift = (port - 4) << 1; } else { /* should not happen */ dev_warn(codec->dev, "%s: bad port ID %d\n", __func__, port); return; } dev_dbg(codec->dev, "%s: sb_ctl_reg %x field_shift %x\n" "bit_sel %x\n", __func__, sb_ctl_reg, field_shift, bit_sel); snd_soc_update_bits(codec, sb_ctl_reg, 0x3 << field_shift, bit_sel << field_shift); } } static int tapan_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { struct snd_soc_codec *codec = dai->codec; struct tapan_priv *tapan = <API key>(dai->codec); u8 tx_fs_rate, rx_fs_rate; u32 compander_fs; int ret; dev_dbg(dai->codec->dev, "%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n", __func__, dai->name, dai->id, params_rate(params), params_channels(params)); switch (params_rate(params)) { case 8000: tx_fs_rate = 0x00; rx_fs_rate = 0x00; compander_fs = COMPANDER_FS_8KHZ; break; case 16000: tx_fs_rate = 0x01; rx_fs_rate = 0x20; compander_fs = COMPANDER_FS_16KHZ; break; case 32000: tx_fs_rate = 0x02; rx_fs_rate = 0x40; compander_fs = COMPANDER_FS_32KHZ; break; case 48000: tx_fs_rate = 0x03; rx_fs_rate = 0x60; compander_fs = COMPANDER_FS_48KHZ; break; case 96000: tx_fs_rate = 0x04; rx_fs_rate = 0x80; compander_fs = COMPANDER_FS_96KHZ; break; case 192000: tx_fs_rate = 0x05; rx_fs_rate = 0xA0; compander_fs = COMPANDER_FS_192KHZ; break; default: pr_err("%s: Invalid sampling rate %d\n", __func__, params_rate(params)); return -EINVAL; } switch (substream->stream) { case <API key>: ret = <API key>(dai, tx_fs_rate, params_rate(params)); if (ret < 0) { pr_err("%s: set decimator rate failed %d\n", __func__, ret); return ret; } if (tapan->intf_type == <API key>) { switch (params_format(params)) { case <API key>: snd_soc_update_bits(codec, <API key>, 0x20, 0x20); break; case <API key>: snd_soc_update_bits(codec, <API key>, 0x20, 0x00); break; default: pr_err("invalid format\n"); break; } snd_soc_update_bits(codec, <API key>, 0x07, tx_fs_rate); } else { tapan->dai[dai->id].rate = params_rate(params); } break; case <API key>: ret = <API key>(dai, rx_fs_rate, compander_fs, params_rate(params)); if (ret < 0) { dev_err(codec->dev, "%s: set decimator rate failed %d\n", __func__, ret); return ret; } if (tapan->intf_type == <API key>) { switch (params_format(params)) { case <API key>: snd_soc_update_bits(codec, <API key>, 0x20, 0x20); break; case <API key>: snd_soc_update_bits(codec, <API key>, 0x20, 0x00); break; default: dev_err(codec->dev, "invalid format\n"); break; } snd_soc_update_bits(codec, <API key>, 0x03, (rx_fs_rate >> 0x05)); } else { <API key>(params, dai); tapan->dai[dai->id].rate = params_rate(params); } break; default: dev_err(codec->dev, "%s: Invalid stream type %d\n", __func__, substream->stream); return -EINVAL; } return 0; } int tapan_digital_mute(struct snd_soc_dai *dai, int mute) { struct snd_soc_codec *codec = NULL; u16 tx_vol_ctl_reg = 0; u8 decimator = 0, i; struct tapan_priv *tapan_p; pr_debug("%s: Digital Mute val = %d\n", __func__, mute); if (!dai || !dai->codec) { pr_err("%s: Invalid params\n", __func__); return -EINVAL; } codec = dai->codec; tapan_p = <API key>(codec); if (dai->id != AIF1_CAP) { dev_dbg(codec->dev, "%s: Not capture use case skip\n", __func__); return 0; } mute = (mute) ? 1 : 0; if (!mute) { /* * 5 ms is an emperical value for the mute time * that was arrived by checking the pop level * to be inaudible */ usleep_range(5000, 5010); } for (i = 0; i < NUM_DECIMATORS; i++) { if (tapan_p->dec_active[i]) decimator = i + 1; if (decimator && decimator <= NUM_DECIMATORS) { pr_debug("%s: Mute = %d Decimator = %d", __func__, mute, decimator); tx_vol_ctl_reg = <API key> + 8 * (decimator - 1); snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x01, mute); } decimator = 0; } return 0; } static struct snd_soc_dai_ops tapan_dai_ops = { .startup = tapan_startup, .shutdown = tapan_shutdown, .hw_params = tapan_hw_params, .set_sysclk = <API key>, .set_fmt = tapan_set_dai_fmt, .set_channel_map = <API key>, .get_channel_map = <API key>, .digital_mute = tapan_digital_mute, }; static struct snd_soc_dai_driver tapan9302_dai[] = { { .name = "tapan9302_rx1", .id = AIF1_PB, .playback = { .stream_name = "AIF1 Playback", .rates = WCD9302_RATES, .formats = TAPAN_FORMATS, .rate_max = 48000, .rate_min = 8000, .channels_min = 1, .channels_max = 2, }, .ops = &tapan_dai_ops, }, { .name = "tapan9302_tx1", .id = AIF1_CAP, .capture = { .stream_name = "AIF1 Capture", .rates = WCD9302_RATES, .formats = TAPAN_FORMATS, .rate_max = 48000, .rate_min = 8000, .channels_min = 1, .channels_max = 4, }, .ops = &tapan_dai_ops, }, { .name = "tapan9302_rx2", .id = AIF2_PB, .playback = { .stream_name = "AIF2 Playback", .rates = WCD9302_RATES, .formats = TAPAN_FORMATS, .rate_min = 8000, .rate_max = 48000, .channels_min = 1, .channels_max = 2, }, .ops = &tapan_dai_ops, }, { .name = "tapan9302_tx2", .id = AIF2_CAP, .capture = { .stream_name = "AIF2 Capture", .rates = WCD9302_RATES, .formats = TAPAN_FORMATS, .rate_max = 48000, .rate_min = 8000, .channels_min = 1, .channels_max = 4, }, .ops = &tapan_dai_ops, }, { .name = "tapan9302_tx3", .id = AIF3_CAP, .capture = { .stream_name = "AIF3 Capture", .rates = WCD9302_RATES, .formats = TAPAN_FORMATS, .rate_max = 48000, .rate_min = 8000, .channels_min = 1, .channels_max = 2, }, .ops = &tapan_dai_ops, }, { .name = "tapan9302_rx3", .id = AIF3_PB, .playback = { .stream_name = "AIF3 Playback", .rates = WCD9302_RATES, .formats = TAPAN_FORMATS, .rate_min = 8000, .rate_max = 48000, .channels_min = 1, .channels_max = 2, }, .ops = &tapan_dai_ops, }, }; static struct snd_soc_dai_driver tapan_dai[] = { { .name = "tapan_rx1", .id = AIF1_PB, .playback = { .stream_name = "AIF1 Playback", .rates = WCD9306_RATES, .formats = <API key>, .rate_max = 192000, .rate_min = 8000, .channels_min = 1, .channels_max = 2, }, .ops = &tapan_dai_ops, }, { .name = "tapan_tx1", .id = AIF1_CAP, .capture = { .stream_name = "AIF1 Capture", .rates = WCD9306_RATES, .formats = TAPAN_FORMATS, .rate_max = 192000, .rate_min = 8000, .channels_min = 1, .channels_max = 4, }, .ops = &tapan_dai_ops, }, { .name = "tapan_rx2", .id = AIF2_PB, .playback = { .stream_name = "AIF2 Playback", .rates = WCD9306_RATES, .formats = <API key>, .rate_min = 8000, .rate_max = 192000, .channels_min = 1, .channels_max = 2, }, .ops = &tapan_dai_ops, }, { .name = "tapan_tx2", .id = AIF2_CAP, .capture = { .stream_name = "AIF2 Capture", .rates = WCD9306_RATES, .formats = TAPAN_FORMATS, .rate_max = 192000, .rate_min = 8000, .channels_min = 1, .channels_max = 4, }, .ops = &tapan_dai_ops, }, { .name = "tapan_tx3", .id = AIF3_CAP, .capture = { .stream_name = "AIF3 Capture", .rates = WCD9306_RATES, .formats = TAPAN_FORMATS, .rate_max = 48000, .rate_min = 8000, .channels_min = 1, .channels_max = 2, }, .ops = &tapan_dai_ops, }, { .name = "tapan_rx3", .id = AIF3_PB, .playback = { .stream_name = "AIF3 Playback", .rates = WCD9306_RATES, .formats = <API key>, .rate_min = 8000, .rate_max = 192000, .channels_min = 1, .channels_max = 2, }, .ops = &tapan_dai_ops, }, }; static struct snd_soc_dai_driver tapan_i2s_dai[] = { { .name = "tapan_i2s_rx1", .id = AIF1_PB, .playback = { .stream_name = "AIF1 Playback", .rates = WCD9306_RATES, .formats = TAPAN_FORMATS, .rate_max = 192000, .rate_min = 8000, .channels_min = 1, .channels_max = 4, }, .ops = &tapan_dai_ops, }, { .name = "tapan_i2s_tx1", .id = AIF1_CAP, .capture = { .stream_name = "AIF1 Capture", .rates = WCD9306_RATES, .formats = TAPAN_FORMATS, .rate_max = 192000, .rate_min = 8000, .channels_min = 1, .channels_max = 4, }, .ops = &tapan_dai_ops, }, }; static int <API key>(struct <API key> *dai, bool up) { int ret = 0; struct wcd9xxx_ch *ch; if (up) { list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) { ret = <API key>(ch->ch_num); if (ret < 0) { pr_debug("%s: Invalid slave port ID: %d\n", __func__, ret); ret = -EINVAL; } else { set_bit(ret, &dai->ch_mask); } } } else { ret = wait_event_timeout(dai->dai_wait, (dai->ch_mask == 0), msecs_to_jiffies( <API key>)); if (!ret) { pr_debug("%s: Slim close tx/rx wait timeout\n", __func__); ret = -ETIMEDOUT; } else { ret = 0; } } return ret; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct wcd9xxx *core; struct snd_soc_codec *codec = w->codec; struct tapan_priv *tapan_p = <API key>(codec); int ret = 0; struct <API key> *dai; core = dev_get_drvdata(codec->dev->parent); if(core == NULL) { dev_err(codec->dev, "%s: core is null\n", __func__); return -EINVAL; } dev_dbg(codec->dev, "%s: event called! codec name %s\n", __func__, w->codec->name); dev_dbg(codec->dev, "%s: num_dai %d stream name %s event %d\n", __func__, w->codec->num_dai, w->sname, event); /* Execute the callback only if interface type is slimbus */ if (tapan_p->intf_type != <API key>) return 0; dai = &tapan_p->dai[w->shift]; dev_dbg(codec->dev, "%s: w->name %s w->shift %d event %d\n", __func__, w->name, w->shift, event); switch (event) { case <API key>: dai-><API key> = false; (void) <API key>(dai, true); ret = <API key>(core, &dai->wcd9xxx_ch_list, dai->rate, dai->bit_width, &dai->grph); break; case <API key>: ret = <API key>(core, &dai->wcd9xxx_ch_list, dai->grph); if (!dai-><API key>) ret = <API key>(dai, false); if (ret < 0) { ret = <API key>(core, &dai->wcd9xxx_ch_list, dai->grph); dev_dbg(codec->dev, "%s: Disconnect RX port, ret = %d\n", __func__, ret); } if ((core != NULL) && (core->dev != NULL) && (core->dev->parent != NULL)) { <API key>(core->dev->parent); pm_runtime_put(core->dev->parent); dev_dbg(codec->dev, "%s: unvote requested", __func__); } dai-><API key> = false; break; } return ret; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct wcd9xxx *core; struct snd_soc_codec *codec = w->codec; struct tapan_priv *tapan_p = <API key>(codec); u32 ret = 0; struct <API key> *dai; core = dev_get_drvdata(codec->dev->parent); dev_dbg(codec->dev, "%s: event called! codec name %s\n", __func__, w->codec->name); dev_dbg(codec->dev, "%s: num_dai %d stream name %s\n", __func__, w->codec->num_dai, w->sname); /* Execute the callback only if interface type is slimbus */ if (tapan_p->intf_type != <API key>) return 0; dev_dbg(codec->dev, "%s(): w->name %s event %d w->shift %d\n", __func__, w->name, event, w->shift); dai = &tapan_p->dai[w->shift]; switch (event) { case <API key>: dai-><API key> = false; (void) <API key>(dai, true); ret = <API key>(core, &dai->wcd9xxx_ch_list, dai->rate, dai->bit_width, &dai->grph); break; case <API key>: ret = <API key>(core, &dai->wcd9xxx_ch_list, dai->grph); if (!dai-><API key>) ret = <API key>(dai, false); if (ret < 0) { ret = <API key>(core, &dai->wcd9xxx_ch_list, dai->grph); dev_dbg(codec->dev, "%s: Disconnect RX port, ret = %d\n", __func__, ret); } if ((core != NULL) && (core->dev != NULL) && (core->dev->parent != NULL)) { <API key>(core->dev->parent); pm_runtime_put(core->dev->parent); dev_dbg(codec->dev, "%s: unvote requested", __func__); } dai-><API key> = false; break; } return ret; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tapan_priv *tapan_p = <API key>(codec); dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); switch (event) { case <API key>: wcd9xxx_clsh_fsm(codec, &tapan_p->clsh_d, <API key>, <API key>, <API key>); usleep_range(5000, 5010); break; case <API key>: usleep_range(5000, 5010); snd_soc_update_bits(codec, TAPAN_A_RX_EAR_EN, 0x40, 0x00); wcd9xxx_clsh_fsm(codec, &tapan_p->clsh_d, <API key>, <API key>, <API key>); } return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tapan_priv *tapan_p = <API key>(codec); dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); switch (event) { case <API key>: wcd9xxx_clsh_fsm(codec, &tapan_p->clsh_d, <API key>, <API key>, <API key>); break; } return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; pr_debug("%s: event = %d\n", __func__, event); switch (event) { case <API key>: snd_soc_write(codec, w->reg, snd_soc_read(codec, w->reg)); break; case <API key>: snd_soc_write(codec, w->reg, snd_soc_read(codec, w->reg)); break; } return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; u8 reg_val, zoh_mux_val = 0x00; dev_dbg(codec->dev, "%s: event = %d\n", __func__, event); switch (event) { case <API key>: reg_val = snd_soc_read(codec, <API key>); if ((reg_val & 0x30) == 0x10) zoh_mux_val = 0x04; else if ((reg_val & 0x30) == 0x20) zoh_mux_val = 0x08; if (zoh_mux_val != 0x00) snd_soc_update_bits(codec, <API key>, 0x0C, zoh_mux_val); break; case <API key>: snd_soc_update_bits(codec, <API key>, 0x0C, 0x00); break; } return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; int ret = 0; switch (event) { case <API key>: ret = <API key>(w, kcontrol, event); msleep(50); snd_soc_update_bits(codec, TAPAN_A_RX_EAR_EN, 0x10, 0x10); break; case <API key>: ret = <API key>(w, kcontrol, event); break; case <API key>: snd_soc_update_bits(codec, TAPAN_A_RX_EAR_EN, 0x10, 0x00); msleep(40); ret |= <API key>(w, kcontrol, event); break; case <API key>: ret = <API key>(w, kcontrol, event); break; } return ret; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct tapan_priv *priv = <API key>(codec); int ret = 0, i; pr_info("%s: event = %d\n", __func__, event); if (!priv->cp_regulators[CP_REG_BUCK] && !priv->cp_regulators[CP_REG_BHELPER]) { pr_err("%s: No power supply defined for ChargePump\n", __func__); return -EINVAL; } switch (event) { case <API key>: for (i = 0; i < CP_REG_MAX ; i++) { if (!priv->cp_regulators[i]) continue; ret = regulator_enable(priv->cp_regulators[i]); if (ret) { pr_err("%s: CP Regulator enable failed, index = %d\n", __func__, i); continue; } else { pr_debug("%s: Enabled CP regulator, index %d\n", __func__, i); } } break; case <API key>: for (i = 0; i < CP_REG_MAX; i++) { if (!priv->cp_regulators[i]) continue; ret = regulator_disable(priv->cp_regulators[i]); if (ret) { pr_err("%s: CP Regulator disable failed, index = %d\n", __func__, i); return ret; } else { pr_debug("%s: Disabled CP regulator %d\n", __func__, i); } } break; } return 0; } static int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; int value = 0; switch (event) { case <API key>: value = snd_soc_read(codec, <API key>); snd_soc_write(codec, <API key>, value); break; default: pr_err("%s: event = %d not expected\n", __func__, event); } return 0; } static const struct snd_soc_dapm_widget <API key>[] = { /* RX4 MIX1 mux inputs */ SND_SOC_DAPM_MUX("RX4 MIX1 INP1", SND_SOC_NOPM, 0, 0, &rx4_mix1_inp1_mux), SND_SOC_DAPM_MUX("RX4 MIX1 INP2", SND_SOC_NOPM, 0, 0, &rx4_mix1_inp2_mux), SND_SOC_DAPM_MUX("RX4 MIX1 INP3", SND_SOC_NOPM, 0, 0, &rx4_mix1_inp3_mux), /* RX4 MIX2 mux inputs */ SND_SOC_DAPM_MUX("RX4 MIX2 INP1", SND_SOC_NOPM, 0, 0, &rx4_mix2_inp1_mux), SND_SOC_DAPM_MUX("RX4 MIX2 INP2", SND_SOC_NOPM, 0, 0, &rx4_mix2_inp2_mux), SND_SOC_DAPM_MIXER("RX4 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0), <API key>("RX4 MIX2", <API key>, 3, 0, NULL, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_MUX_E("DEC3 MUX", <API key>, 2, 0, &dec3_mux, <API key>, <API key> | <API key> | <API key> | <API key>), SND_SOC_DAPM_MUX_E("DEC4 MUX", <API key>, 3, 0, &dec4_mux, <API key>, <API key> | <API key> | <API key> | <API key>), SND_SOC_DAPM_SUPPLY("COMP0_CLK", SND_SOC_NOPM, 0, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_SUPPLY("COMP1_CLK", SND_SOC_NOPM, 1, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_SUPPLY("COMP2_CLK", SND_SOC_NOPM, 2, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_INPUT("AMIC5"), SND_SOC_DAPM_ADC_E("ADC5", NULL, TAPAN_A_TX_5_EN, 7, 0, <API key>, <API key>), SND_SOC_DAPM_MUX("ANC1 MUX", SND_SOC_NOPM, 0, 0, &anc1_mux), SND_SOC_DAPM_MUX("ANC2 MUX", SND_SOC_NOPM, 0, 0, &anc2_mux), SND_SOC_DAPM_OUTPUT("ANC HEADPHONE"), SND_SOC_DAPM_PGA_E("ANC HPHL", SND_SOC_NOPM, 5, 0, NULL, 0, <API key>, <API key> | <API key> | <API key> | <API key>), SND_SOC_DAPM_PGA_E("ANC HPHR", SND_SOC_NOPM, 4, 0, NULL, 0, <API key>, <API key> | <API key> | <API key> | <API key>), SND_SOC_DAPM_OUTPUT("ANC EAR"), SND_SOC_DAPM_PGA_E("ANC EAR PA", SND_SOC_NOPM, 0, 0, NULL, 0, <API key>, <API key> | <API key> | <API key> | <API key>), SND_SOC_DAPM_MUX("ANC1 FB MUX", SND_SOC_NOPM, 0, 0, &anc1_fb_mux), <API key>("MIC BIAS3 External", SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key> | <API key>), <API key>("MIC BIAS3 Internal1", SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key> | <API key>), <API key>("MIC BIAS3 Internal2", SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key> | <API key>), SND_SOC_DAPM_ADC_E("DMIC3", NULL, SND_SOC_NOPM, 0, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_ADC_E("DMIC4", NULL, SND_SOC_NOPM, 0, 0, <API key>, <API key> | <API key>), }; /* Todo: Have seperate dapm widgets for I2S and Slimbus. * Might Need to have callbacks registered only for slimbus */ static const struct snd_soc_dapm_widget <API key>[] = { <API key>("AIF1 PB", "AIF1 Playback", 0, SND_SOC_NOPM, AIF1_PB, 0, <API key>, <API key> | <API key>), <API key>("AIF2 PB", "AIF2 Playback", 0, SND_SOC_NOPM, AIF2_PB, 0, <API key>, <API key> | <API key>), <API key>("AIF3 PB", "AIF3 Playback", 0, SND_SOC_NOPM, AIF3_PB, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_MUX("SLIM RX1 MUX", SND_SOC_NOPM, TAPAN_RX1, 0, &slim_rx_mux[TAPAN_RX1]), SND_SOC_DAPM_MUX("SLIM RX2 MUX", SND_SOC_NOPM, TAPAN_RX2, 0, &slim_rx_mux[TAPAN_RX2]), SND_SOC_DAPM_MUX("SLIM RX3 MUX", SND_SOC_NOPM, TAPAN_RX3, 0, &slim_rx_mux[TAPAN_RX3]), SND_SOC_DAPM_MUX("SLIM RX4 MUX", SND_SOC_NOPM, TAPAN_RX4, 0, &slim_rx_mux[TAPAN_RX4]), SND_SOC_DAPM_MUX("SLIM RX5 MUX", SND_SOC_NOPM, TAPAN_RX5, 0, &slim_rx_mux[TAPAN_RX5]), SND_SOC_DAPM_MIXER("SLIM RX1", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER("SLIM RX2", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER("SLIM RX3", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER("SLIM RX4", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER("SLIM RX5", SND_SOC_NOPM, 0, 0, NULL, 0), /* RX1 MIX1 mux inputs */ SND_SOC_DAPM_MUX("RX1 MIX1 INP1", SND_SOC_NOPM, 0, 0, &rx_mix1_inp1_mux), SND_SOC_DAPM_MUX("RX1 MIX1 INP2", SND_SOC_NOPM, 0, 0, &rx_mix1_inp2_mux), SND_SOC_DAPM_MUX("RX1 MIX1 INP3", SND_SOC_NOPM, 0, 0, &rx_mix1_inp3_mux), /* RX2 MIX1 mux inputs */ SND_SOC_DAPM_MUX("RX2 MIX1 INP1", SND_SOC_NOPM, 0, 0, &rx2_mix1_inp1_mux), SND_SOC_DAPM_MUX("RX2 MIX1 INP2", SND_SOC_NOPM, 0, 0, &rx2_mix1_inp2_mux), SND_SOC_DAPM_MUX("RX2 MIX1 INP3", SND_SOC_NOPM, 0, 0, &rx2_mix1_inp2_mux), /* RX3 MIX1 mux inputs */ SND_SOC_DAPM_MUX("RX3 MIX1 INP1", SND_SOC_NOPM, 0, 0, &rx3_mix1_inp1_mux), SND_SOC_DAPM_MUX("RX3 MIX1 INP2", SND_SOC_NOPM, 0, 0, &rx3_mix1_inp2_mux), SND_SOC_DAPM_MUX("RX3 MIX1 INP3", SND_SOC_NOPM, 0, 0, &rx3_mix1_inp3_mux), /* RX1 MIX2 mux inputs */ SND_SOC_DAPM_MUX("RX1 MIX2 INP1", SND_SOC_NOPM, 0, 0, &rx1_mix2_inp1_mux), SND_SOC_DAPM_MUX("RX1 MIX2 INP2", SND_SOC_NOPM, 0, 0, &rx1_mix2_inp2_mux), /* RX2 MIX2 mux inputs */ SND_SOC_DAPM_MUX("RX2 MIX2 INP1", SND_SOC_NOPM, 0, 0, &rx2_mix2_inp1_mux), SND_SOC_DAPM_MUX("RX2 MIX2 INP2", SND_SOC_NOPM, 0, 0, &rx2_mix2_inp2_mux), SND_SOC_DAPM_MIXER("RX1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER("RX2 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER("RX1 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER("RX2 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0), <API key>("RX3 MIX1", <API key>, 2, 0, NULL, 0, <API key>, <API key> | <API key>), <API key>("RX1 INTERPOLATOR", <API key>, 0, 0, &rx1_interpolator, <API key>, <API key> | <API key>), <API key>("RX2 INTERPOLATOR", <API key>, 1, 0, &rx2_interpolator, <API key>, <API key> | <API key>), SND_SOC_DAPM_MIXER("RX1 CHAIN", <API key>, 5, 0, NULL, 0), <API key>("RX2 CHAIN", SND_SOC_NOPM, 0, 0, NULL, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_MUX_E("CLASS_H_DSM MUX", SND_SOC_NOPM, 0, 0, &class_h_dsm_mux, <API key>, <API key> | <API key>), /* RX Bias */ SND_SOC_DAPM_SUPPLY("RX_BIAS", SND_SOC_NOPM, 0, 0, <API key>, <API key> | <API key>), /* CDC_CP_VDD */ SND_SOC_DAPM_SUPPLY("CDC_CP_VDD", SND_SOC_NOPM, 0, 0, <API key>, <API key> | <API key>), /*EAR */ SND_SOC_DAPM_PGA_E("EAR PA", TAPAN_A_RX_EAR_EN, 4, 0, NULL, 0, <API key>, <API key> | <API key>), <API key>("DAC1", TAPAN_A_RX_EAR_EN, 6, 0, dac1_switch, ARRAY_SIZE(dac1_switch), <API key>, <API key>), /* Headphone Left */ SND_SOC_DAPM_PGA_E("HPHL", <API key>, 5, 0, NULL, 0, tapan_hph_pa_event, <API key> | <API key> | <API key>), <API key>("HPHL DAC", <API key>, 7, 0, hphl_switch, ARRAY_SIZE(hphl_switch), <API key>, <API key> | <API key>), /* Headphone Right */ SND_SOC_DAPM_PGA_E("HPHR", <API key>, 4, 0, NULL, 0, tapan_hph_pa_event, <API key> | <API key> | <API key>), SND_SOC_DAPM_DAC_E("HPHR DAC", NULL, <API key>, 7, 0, <API key>, <API key> | <API key>), /* LINEOUT1*/ SND_SOC_DAPM_DAC_E("LINEOUT1 DAC", NULL, <API key>, 7, 0 , <API key>, <API key> | <API key>), SND_SOC_DAPM_PGA_E("LINEOUT1 PA", <API key>, 0, 0, NULL, 0, <API key>, <API key> | <API key> | <API key>), /* LINEOUT2*/ SND_SOC_DAPM_MUX("RDAC5 MUX", SND_SOC_NOPM, 0, 0, &rx_dac5_mux), /* LINEOUT1*/ SND_SOC_DAPM_MUX("RDAC4 MUX", SND_SOC_NOPM, 0, 0, &rx_dac4_mux), SND_SOC_DAPM_MUX("RDAC3 MUX", SND_SOC_NOPM, 0, 0, &rx_dac3_mux), SND_SOC_DAPM_DAC_E("LINEOUT2 DAC", NULL, <API key>, 7, 0 , <API key>, <API key> | <API key>), SND_SOC_DAPM_PGA_E("LINEOUT2 PA", <API key>, 1, 0, NULL, 0, <API key>, <API key> | <API key> | <API key>), /* CLASS-D SPK */ <API key>("SPK DAC", SND_SOC_NOPM, 0, 0, spk_dac_switch, ARRAY_SIZE(spk_dac_switch), tapan_spk_dac_event, <API key> | <API key>), SND_SOC_DAPM_PGA_E("SPK PA", SND_SOC_NOPM, 0, 0 , NULL, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_SUPPLY("VDD_SPKDRV", SND_SOC_NOPM, 0, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_OUTPUT("EAR"), SND_SOC_DAPM_OUTPUT("HEADPHONE"), SND_SOC_DAPM_OUTPUT("LINEOUT1"), SND_SOC_DAPM_OUTPUT("LINEOUT2"), SND_SOC_DAPM_OUTPUT("SPK_OUT"), /* TX Path*/ SND_SOC_DAPM_MIXER("AIF1_CAP Mixer", SND_SOC_NOPM, AIF1_CAP, 0, aif_cap_mixer, ARRAY_SIZE(aif_cap_mixer)), SND_SOC_DAPM_MIXER("AIF2_CAP Mixer", SND_SOC_NOPM, AIF2_CAP, 0, aif_cap_mixer, ARRAY_SIZE(aif_cap_mixer)), SND_SOC_DAPM_MIXER("AIF3_CAP Mixer", SND_SOC_NOPM, AIF3_CAP, 0, aif_cap_mixer, ARRAY_SIZE(aif_cap_mixer)), SND_SOC_DAPM_MUX("SLIM TX1 MUX", SND_SOC_NOPM, TAPAN_TX1, 0, &sb_tx1_mux), SND_SOC_DAPM_MUX("SLIM TX2 MUX", SND_SOC_NOPM, TAPAN_TX2, 0, &sb_tx2_mux), SND_SOC_DAPM_MUX("SLIM TX3 MUX", SND_SOC_NOPM, TAPAN_TX3, 0, &sb_tx3_mux), SND_SOC_DAPM_MUX("SLIM TX4 MUX", SND_SOC_NOPM, TAPAN_TX4, 0, &sb_tx4_mux), SND_SOC_DAPM_MUX("SLIM TX5 MUX", SND_SOC_NOPM, TAPAN_TX5, 0, &sb_tx5_mux), SND_SOC_DAPM_SUPPLY("CDC_CONN", <API key>, 2, 0, NULL, 0), /* Decimator MUX */ SND_SOC_DAPM_MUX_E("DEC1 MUX", <API key>, 0, 0, &dec1_mux, <API key>, <API key> | <API key> | <API key> | <API key>), SND_SOC_DAPM_MUX_E("DEC2 MUX", <API key>, 1, 0, &dec2_mux, <API key>, <API key> | <API key> | <API key> | <API key>), SND_SOC_DAPM_SUPPLY("LDO_H", SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key>), /* * DAPM 'LDO_H Standalone' is to be powered by mbhc driver after * acquring codec_resource lock. * So call <API key> instead and avoid deadlock. */ SND_SOC_DAPM_SUPPLY("LDO_H Standalone", SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_INPUT("AMIC1"), <API key>("MIC BIAS1 External", SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key> | <API key>), <API key>("MIC BIAS1 Internal1", SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key> | <API key>), <API key>("MIC BIAS1 Internal2", SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key> | <API key>), SND_SOC_DAPM_ADC_E("ADC1", NULL, TAPAN_A_TX_1_EN, 7, 0, <API key>, <API key> | <API key> | <API key>), SND_SOC_DAPM_ADC_E("ADC2", NULL, TAPAN_A_TX_2_EN, 7, 0, <API key>, <API key> | <API key> | <API key>), SND_SOC_DAPM_INPUT("AMIC3"), SND_SOC_DAPM_ADC_E("ADC3", NULL, TAPAN_A_TX_3_EN, 7, 0, <API key>, <API key> | <API key> | <API key>), SND_SOC_DAPM_INPUT("AMIC4"), SND_SOC_DAPM_ADC_E("ADC4", NULL, TAPAN_A_TX_4_EN, 7, 0, <API key>, <API key> | <API key> | <API key>), SND_SOC_DAPM_INPUT("AMIC2"), <API key>("MIC BIAS2 External", SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key> | <API key>), <API key>("MIC BIAS2 Internal1", SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key> | <API key>), <API key>("MIC BIAS2 Internal2", SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key> | <API key>), <API key>("MIC BIAS2 Internal3", SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key> | <API key>), <API key>(<API key>, SND_SOC_NOPM, 7, 0, <API key>, <API key> | <API key> | <API key>), <API key>("AIF1 CAP", "AIF1 Capture", 0, SND_SOC_NOPM, AIF1_CAP, 0, <API key>, <API key> | <API key>), <API key>("AIF2 CAP", "AIF2 Capture", 0, SND_SOC_NOPM, AIF2_CAP, 0, <API key>, <API key> | <API key>), <API key>("AIF3 CAP", "AIF3 Capture", 0, SND_SOC_NOPM, AIF3_CAP, 0, <API key>, <API key> | <API key>), /* Digital Mic Inputs */ SND_SOC_DAPM_ADC_E("DMIC1", NULL, SND_SOC_NOPM, 0, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_ADC_E("DMIC2", NULL, SND_SOC_NOPM, 0, 0, <API key>, <API key> | <API key>), /* Sidetone */ SND_SOC_DAPM_MUX_E("IIR1 INP1 MUX", <API key>, 0, 0, &iir1_inp1_mux, <API key>, <API key> | <API key>), SND_SOC_DAPM_PGA_E("IIR1", <API key>, 0, 0, NULL, 0, <API key>, <API key>), SND_SOC_DAPM_MUX_E("IIR1 INP2 MUX", <API key>, 0, 0, &iir1_inp2_mux, <API key>, <API key> | <API key>), SND_SOC_DAPM_MUX_E("IIR1 INP3 MUX", <API key>, 0, 0, &iir1_inp3_mux, <API key>, <API key> | <API key>), SND_SOC_DAPM_MUX_E("IIR1 INP4 MUX", <API key>, 0, 0, &iir1_inp4_mux, <API key>, <API key> | <API key>), SND_SOC_DAPM_MUX_E("IIR2 INP1 MUX", <API key>, 0, 0, &iir2_inp1_mux, <API key>, <API key> | <API key>), SND_SOC_DAPM_MUX_E("IIR2 INP2 MUX", <API key>, 0, 0, &iir2_inp2_mux, <API key>, <API key> | <API key>), SND_SOC_DAPM_MUX_E("IIR2 INP3 MUX", <API key>, 0, 0, &iir2_inp3_mux, <API key>, <API key> | <API key>), SND_SOC_DAPM_MUX_E("IIR2 INP4 MUX", <API key>, 0, 0, &iir2_inp4_mux, <API key>, <API key> | <API key>), SND_SOC_DAPM_PGA("IIR2", <API key>, 1, 0, NULL, 0), /* AUX PGA */ SND_SOC_DAPM_ADC_E("AUX_PGA_Left", NULL, <API key>, 7, 0, <API key>, <API key> | <API key>), SND_SOC_DAPM_ADC_E("AUX_PGA_Right", NULL, <API key>, 6, 0, <API key>, <API key> | <API key>), /* Lineout, ear and HPH PA Mixers */ SND_SOC_DAPM_MIXER("EAR_PA_MIXER", SND_SOC_NOPM, 0, 0, ear_pa_mix, ARRAY_SIZE(ear_pa_mix)), SND_SOC_DAPM_MIXER("HPHL_PA_MIXER", SND_SOC_NOPM, 0, 0, hphl_pa_mix, ARRAY_SIZE(hphl_pa_mix)), SND_SOC_DAPM_MIXER("HPHR_PA_MIXER", SND_SOC_NOPM, 0, 0, hphr_pa_mix, ARRAY_SIZE(hphr_pa_mix)), SND_SOC_DAPM_MIXER("LINEOUT1_PA_MIXER", SND_SOC_NOPM, 0, 0, lineout1_pa_mix, ARRAY_SIZE(lineout1_pa_mix)), SND_SOC_DAPM_MIXER("LINEOUT2_PA_MIXER", SND_SOC_NOPM, 0, 0, lineout2_pa_mix, ARRAY_SIZE(lineout2_pa_mix)), }; static irqreturn_t tapan_slimbus_irq(int irq, void *data) { struct tapan_priv *priv = data; struct snd_soc_codec *codec = priv->codec; unsigned long status = 0; int i, j, port_id, k; u32 bit; u8 val; bool tx, cleared; for (i = <API key>, j = 0; i <= <API key>; i++, j++) { val = <API key>(codec->control_data, i); status |= ((u32)val << (8 * j)); } for_each_set_bit(j, &status, 32) { tx = (j >= 16 ? true : false); port_id = (tx ? j - 16 : j); val = <API key>(codec->control_data, <API key> + j); if (val & <API key>) pr_err_ratelimited( "%s: overflow error on %s port %d, value %x\n", __func__, (tx ? "TX" : "RX"), port_id, val); if (val & <API key>) pr_err_ratelimited( "%s: underflow error on %s port %d, value %x\n", __func__, (tx ? "TX" : "RX"), port_id, val); if (val & <API key>) { /* * INT SOURCE register starts from RX to TX * but port number in the ch_mask is in opposite way */ bit = (tx ? j - 16 : j + 16); dev_dbg(codec->dev, "%s: %s port %d closed value %x, bit %u\n", __func__, (tx ? "TX" : "RX"), port_id, val, bit); for (k = 0, cleared = false; k < NUM_CODEC_DAIS; k++) { dev_dbg(codec->dev, "%s: priv->dai[%d].ch_mask = 0x%lx\n", __func__, k, priv->dai[k].ch_mask); if (test_and_clear_bit(bit, &priv->dai[k].ch_mask)) { cleared = true; if (!priv->dai[k].ch_mask) wake_up(&priv->dai[k].dai_wait); /* * There are cases when multiple DAIs * might be using the same slimbus * channel. Hence don't break here. */ } } WARN(!cleared, "Couldn't find slimbus %s port %d for closing\n", (tx ? "TX" : "RX"), port_id); } <API key>(codec->control_data, <API key> + (j / 8), 1 << (j % 8)); } return IRQ_HANDLED; } static int tapan_handle_pdata(struct tapan_priv *tapan) { struct snd_soc_codec *codec = tapan->codec; struct wcd9xxx_pdata *pdata = tapan->resmgr.pdata; int k1, k2, k3, rc = 0; u8 txfe_bypass; u8 txfe_buff; u8 flag; u8 i = 0, j = 0; u8 val_txfe = 0, value = 0; u8 <API key> = 0; u8 dmic_b1_ctl_value = 0; u8 anc_ctl_value = 0; if (!pdata) { dev_err(codec->dev, "%s: NULL pdata\n", __func__); rc = -ENODEV; goto done; } txfe_bypass = pdata->amic_settings.txfe_enable; txfe_buff = pdata->amic_settings.txfe_buff; flag = pdata->amic_settings.use_pdata; /* Make sure settings are correct */ if ((pdata->micbias.ldoh_v > WCD9XXX_LDOH_3P0_V) || (pdata->micbias.bias1_cfilt_sel > WCD9XXX_CFILT3_SEL) || (pdata->micbias.bias2_cfilt_sel > WCD9XXX_CFILT3_SEL) || (pdata->micbias.bias3_cfilt_sel > WCD9XXX_CFILT3_SEL)) { dev_err(codec->dev, "%s: Invalid ldoh voltage or bias cfilt\n", __func__); rc = -EINVAL; goto done; } /* figure out k value */ k1 = <API key>(&tapan->resmgr, pdata->micbias.cfilt1_mv); k2 = <API key>(&tapan->resmgr, pdata->micbias.cfilt2_mv); k3 = <API key>(&tapan->resmgr, pdata->micbias.cfilt3_mv); if (IS_ERR_VALUE(k1) || IS_ERR_VALUE(k2) || IS_ERR_VALUE(k3)) { dev_err(codec->dev, "%s: could not get K value. k1 = %d k2 = %d k3 = %d\n", __func__, k1, k2, k3); rc = -EINVAL; goto done; } /* Set voltage level and always use LDO */ snd_soc_update_bits(codec, <API key>, 0x0C, (pdata->micbias.ldoh_v << 2)); snd_soc_update_bits(codec, <API key>, 0xFC, (k1 << 2)); snd_soc_update_bits(codec, <API key>, 0xFC, (k2 << 2)); snd_soc_update_bits(codec, <API key>, 0xFC, (k3 << 2)); i = 0; while (i < 5) { if (flag & (0x01 << i)) { val_txfe = (txfe_bypass & (0x01 << i)) ? 0x20 : 0x00; val_txfe = val_txfe | ((txfe_buff & (0x01 << i)) ? 0x10 : 0x00); snd_soc_update_bits(codec, <API key> + j * 10, 0x30, val_txfe); } if (flag & (0x01 << (i + 1))) { val_txfe = (txfe_bypass & (0x01 << (i + 1))) ? 0x02 : 0x00; val_txfe |= (txfe_buff & (0x01 << (i + 1))) ? 0x01 : 0x00; snd_soc_update_bits(codec, <API key> + j * 10, 0x03, val_txfe); } /* Tapan only has <API key> and <API key> reg */ if (i == 0) { i = 3; continue; } else if (i == 3) { break; } } if (pdata->ocp.use_pdata) { /* not defined in CODEC specification */ if (pdata->ocp.hph_ocp_limit == 1 || pdata->ocp.hph_ocp_limit == 5) { rc = -EINVAL; goto done; } snd_soc_update_bits(codec, <API key>, 0x0F, pdata->ocp.num_attempts); snd_soc_write(codec, <API key>, ((pdata->ocp.run_time << 4) | pdata->ocp.wait_time)); snd_soc_update_bits(codec, <API key>, 0xE0, (pdata->ocp.hph_ocp_limit << 5)); } /* Set micbias capless mode with tail current */ value = (pdata->micbias.bias1_cap_mode == MICBIAS_EXT_BYP_CAP ? 0x00 : 0x10); snd_soc_update_bits(codec, TAPAN_A_MICB_1_CTL, 0x10, value); value = (pdata->micbias.bias2_cap_mode == MICBIAS_EXT_BYP_CAP ? 0x00 : 0x10); snd_soc_update_bits(codec, TAPAN_A_MICB_2_CTL, 0x10, value); value = (pdata->micbias.bias3_cap_mode == MICBIAS_EXT_BYP_CAP ? 0x00 : 0x10); snd_soc_update_bits(codec, TAPAN_A_MICB_3_CTL, 0x10, value); /* Set the DMIC sample rate */ if (pdata->mclk_rate == <API key>) { switch (pdata->dmic_sample_rate) { case <API key>: <API key> = <API key>; dmic_b1_ctl_value = <API key>; anc_ctl_value = <API key>; break; case <API key>: <API key> = <API key>; dmic_b1_ctl_value = <API key>; anc_ctl_value = <API key>; break; case <API key>: case <API key>: <API key> = <API key>; dmic_b1_ctl_value = <API key>; anc_ctl_value = <API key>; break; default: dev_err(codec->dev, "%s Invalid sample rate %d for mclk %d\n", __func__, pdata->dmic_sample_rate, pdata->mclk_rate); rc = -EINVAL; goto done; } } else if (pdata->mclk_rate == <API key>) { switch (pdata->dmic_sample_rate) { case <API key>: <API key> = <API key>; dmic_b1_ctl_value = <API key>; anc_ctl_value = <API key>; break; case <API key>: <API key> = <API key>; dmic_b1_ctl_value = <API key>; anc_ctl_value = <API key>; break; case <API key>: case <API key>: <API key> = <API key>; dmic_b1_ctl_value = <API key>; anc_ctl_value = <API key>; break; default: dev_err(codec->dev, "%s Invalid sample rate %d for mclk %d\n", __func__, pdata->dmic_sample_rate, pdata->mclk_rate); rc = -EINVAL; goto done; } } else { dev_err(codec->dev, "%s MCLK is not set!\n", __func__); rc = -EINVAL; goto done; } snd_soc_update_bits(codec, <API key>, 0x7, <API key>); snd_soc_update_bits(codec, <API key>, 0x7, <API key>); snd_soc_update_bits(codec, <API key>, 0x7, <API key>); snd_soc_update_bits(codec, <API key>, 0x7, <API key>); snd_soc_update_bits(codec, <API key>, 0xEE, dmic_b1_ctl_value); snd_soc_update_bits(codec, <API key>, 0x1, anc_ctl_value); done: return rc; } static const struct tapan_reg_mask_val tapan_reg_defaults[] = { /* enable QFUSE for wcd9306 */ TAPAN_REG_VAL(TAPAN_A_QFUSE_CTL, 0x03), /* <API key> = V_0P858V */ TAPAN_REG_VAL(<API key>, 0x04), TAPAN_REG_VAL(<API key>, 0x03), /* EAR PA deafults */ TAPAN_REG_VAL(<API key>, 0x05), /* RX1 and RX2 defaults */ TAPAN_REG_VAL(<API key>, 0xA0), TAPAN_REG_VAL(<API key>, 0x80), /* Heaset set Right from RX2 */ TAPAN_REG_VAL(<API key>, 0x10), /* * The following only need to be written for Tapan 1.0 parts. * Tapan 2.0 will have appropriate defaults for these registers. */ /* Required defaults for class H operation */ /* borrowed from Taiko class-h */ TAPAN_REG_VAL(<API key>, 0xF4), TAPAN_REG_VAL(<API key>, 0x08), TAPAN_REG_VAL(<API key>, 0x5B), TAPAN_REG_VAL(<API key>, 0x6F), /* TODO: Check below reg writes conflict with above */ /* <API key> = V_0P858V */ TAPAN_REG_VAL(<API key>, 0x04), TAPAN_REG_VAL(<API key>, 0x74), TAPAN_REG_VAL(<API key>, 0x62), /* Choose max non-overlap time for NCP */ TAPAN_REG_VAL(TAPAN_A_NCP_CLK, 0xFC), /* Use 25mV/50mV for deltap/m to reduce ripple */ TAPAN_REG_VAL(<API key>, 0x08), /* * Set DISABLE_MODE_SEL<1:0> to 0b10 (disable PWM in auto mode). * Note that the other bits of this register will be changed during * Rx PA bring up. */ TAPAN_REG_VAL(<API key>, 0xCE), /* Reduce HPH DAC bias to 70% */ TAPAN_REG_VAL(<API key>, 0x7A), /*Reduce EAR DAC bias to 70% */ TAPAN_REG_VAL(<API key>, 0x76), /* Reduce LINE DAC bias to 70% */ TAPAN_REG_VAL(<API key>, 0x78), /* * There is a diode to pull down the micbias while doing * insertion detection. This diode can cause leakage. * Set bit 0 to 1 to prevent leakage. * Setting this bit of micbias 2 prevents leakage for all other micbias. */ TAPAN_REG_VAL(TAPAN_A_MICB_2_MBHC, 0x41), /* * Default register settings to support dynamic change of * vdd_buck between 1.8 volts and 2.15 volts. */ TAPAN_REG_VAL(TAPAN_A_BUCK_MODE_2, 0xAA), }; static const struct tapan_reg_mask_val <API key>[] = { TAPAN_REG_VAL(<API key>, 0x6C), TAPAN_REG_VAL(<API key>, 0x51), TAPAN_REG_VAL(<API key>, 0xDA), TAPAN_REG_VAL(TAPAN_A_RX_EAR_CNP, 0xC0), TAPAN_REG_VAL(<API key>, 0x02), TAPAN_REG_VAL(<API key>, 0x02), TAPAN_REG_VAL(<API key>, 0x97), TAPAN_REG_VAL(<API key>, 0x01), TAPAN_REG_VAL(<API key>, 0x00), TAPAN_REG_VAL(<API key>, 0xE4), TAPAN_REG_VAL(<API key>, 0x00), TAPAN_REG_VAL(<API key>, 0x00), TAPAN_REG_VAL(<API key>, 0x00), TAPAN_REG_VAL(<API key>, 0x00), TAPAN_REG_VAL(<API key>, 0x00), TAPAN_REG_VAL(<API key>, 0x00), TAPAN_REG_VAL(<API key>, 0x00), }; static const struct tapan_reg_mask_val <API key>[] = { /* Close leakage on the spkdrv */ TAPAN_REG_VAL(<API key>, 0x24), TAPAN_REG_VAL(<API key>, 0xE5), }; static void <API key>(struct snd_soc_codec *codec) { u32 i; struct wcd9xxx *tapan_core = dev_get_drvdata(codec->dev->parent); if (!TAPAN_IS_1_0(tapan_core->version)) { for (i = 0; i < ARRAY_SIZE(<API key>); i++) snd_soc_write(codec, <API key>[i].reg, <API key>[i].val); } for (i = 0; i < ARRAY_SIZE(tapan_reg_defaults); i++) snd_soc_write(codec, tapan_reg_defaults[i].reg, tapan_reg_defaults[i].val); if (TAPAN_IS_1_0(tapan_core->version)) { for (i = 0; i < ARRAY_SIZE(<API key>); i++) snd_soc_write(codec, <API key>[i].reg, <API key>[i].val); } if (!TAPAN_IS_1_0(tapan_core->version)) spkr_drv_wrnd = -1; else if (spkr_drv_wrnd == 1) snd_soc_write(codec, TAPAN_A_SPKR_DRV_EN, 0xEF); } static void <API key>(struct wcd9xxx *wcd9xxx) { struct snd_soc_codec *codec; codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv); dev_dbg(codec->dev, "%s: MCLK Rate = %x\n", __func__, wcd9xxx->mclk_rate); if (wcd9xxx->mclk_rate == <API key>) { snd_soc_update_bits(codec, TAPAN_A_CHIP_CTL, 0x06, 0x0); snd_soc_update_bits(codec, <API key>, 0x01, 0x01); } else if (wcd9xxx->mclk_rate == <API key>) { snd_soc_update_bits(codec, TAPAN_A_CHIP_CTL, 0x06, 0x2); } } static const struct tapan_reg_mask_val <API key>[] = { /* Initialize current threshold to 365MA * number of wait and run cycles to 4096 */ {<API key>, 0xE9, 0x69}, {<API key>, 0xFF, 0xFF}, {<API key>, 0x01, 0x01}, {<API key>, 0x01, 0x01}, /* Initialize gain registers to use register gain */ {<API key>, 0x20, 0x20}, {<API key>, 0x20, 0x20}, {<API key>, 0x20, 0x20}, {<API key>, 0x20, 0x20}, {<API key>, 0x04, 0x04}, /* Set RDAC5 MUX to take input from DEM3_INV. * This sets LO2 DAC to get input from DEM3_INV * for LO1 and LO2 to work as differential outputs. */ {<API key>, 0x04, 0x04}, /* CLASS H config */ {<API key>, 0x3C, 0x14}, /* Use 16 bit sample size for TX1 to TX5 */ {<API key>, 0x30, 0x20}, {<API key>, 0x30, 0x20}, {<API key>, 0x30, 0x20}, {<API key>, 0x30, 0x20}, {<API key>, 0x30, 0x20}, /* Disable SPK SWITCH */ {<API key>, 0x04, 0x00}, /* Use 16 bit sample size for RX */ {<API key>, 0xFF, 0xAA}, {<API key>, 0xFF, 0x2A}, /*enable HPF filter for TX paths */ {<API key>, 0x8, 0x0}, {<API key>, 0x8, 0x0}, {<API key>, 0x8, 0x0}, {<API key>, 0x8, 0x0}, /* Compander zone selection */ {<API key>, 0x3F, 0x37}, {<API key>, 0x3F, 0x37}, {<API key>, 0x3F, 0x37}, {<API key>, 0x7F, 0x7F}, {<API key>, 0x7F, 0x7F}, {<API key>, 0x7F, 0x7F}, /* * Setup wavegen timer to 20msec and disable chopper * as default. This corresponds to Compander OFF */ {<API key>, 0xFF, 0xDB}, {<API key>, 0xFF, 0x58}, {<API key>, 0xFF, 0x1A}, {<API key>, 0xFF, 0x24}, }; void *<API key>(struct snd_soc_codec *codec, enum afe_config_type config_type) { struct tapan_priv *priv = <API key>(codec); switch (config_type) { case <API key>: return &priv->slimbus_slave_cfg; case <API key>: return &tapan_audio_reg_cfg; case AFE_AANC_VERSION: return &<API key>; default: pr_err("%s: Unknown config_type 0x%x\n", __func__, config_type); return NULL; } } static void <API key>(struct snd_soc_codec *codec) { struct tapan_priv *priv = <API key>(codec); struct <API key> *cfg; struct wcd9xxx *wcd9xxx = codec->control_data; uint64_t eaddr = 0; pr_debug("%s\n", __func__); cfg = &priv->slimbus_slave_cfg; cfg->minor_version = 1; cfg-><API key> = 0; cfg-><API key> = 16; memcpy(&eaddr, &wcd9xxx->slim->e_addr, sizeof(wcd9xxx->slim->e_addr)); /* e-addr is 6-byte elemental address of the device */ WARN_ON(sizeof(wcd9xxx->slim->e_addr) != 6); cfg-><API key> = eaddr & 0xFFFFFFFF; cfg-><API key> = eaddr >> 32; pr_debug("%s: slimbus logical address 0x%llx\n", __func__, eaddr); } static void <API key>(struct snd_soc_codec *codec) { u32 i; for (i = 0; i < ARRAY_SIZE(<API key>); i++) snd_soc_update_bits(codec, <API key>[i].reg, <API key>[i].mask, <API key>[i].val); } static void <API key>(struct snd_soc_codec *codec) { int i; for (i = 0; i < <API key>; i++) <API key>(codec->control_data, <API key> + i, 0xFF); } static int tapan_setup_irqs(struct tapan_priv *tapan) { int ret = 0; struct snd_soc_codec *codec = tapan->codec; struct wcd9xxx *wcd9xxx = codec->control_data; struct <API key> *core_res = &wcd9xxx->core_res; ret = wcd9xxx_request_irq(core_res, WCD9XXX_IRQ_SLIMBUS, tapan_slimbus_irq, "SLIMBUS Slave", tapan); if (ret) pr_err("%s: Failed to request irq %d\n", __func__, WCD9XXX_IRQ_SLIMBUS); else <API key>(codec); return ret; } static void tapan_cleanup_irqs(struct tapan_priv *tapan) { struct snd_soc_codec *codec = tapan->codec; struct wcd9xxx *wcd9xxx = codec->control_data; struct <API key> *core_res = &wcd9xxx->core_res; wcd9xxx_free_irq(core_res, WCD9XXX_IRQ_SLIMBUS, tapan); } static void <API key>(struct snd_soc_codec *codec) { snd_soc_update_bits(codec, <API key>, 0x80, 0x00); } static void <API key>(struct snd_soc_codec *codec, struct wcd9xxx_mbhc *mbhc) { snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.cfilt_ctl, 0x30, 0x30); } static void <API key>(struct snd_soc_codec *codec, struct wcd9xxx_mbhc *mbhc) { snd_soc_update_bits(codec, <API key>, 0x04, 0x04); snd_soc_update_bits(codec, <API key>, 0xE0, 0xE0); } static struct wcd9xxx_cfilt_mode <API key>( struct wcd9xxx_mbhc *mbhc, bool fast) { struct snd_soc_codec *codec = mbhc->codec; struct wcd9xxx_cfilt_mode cfilt_mode; if (fast) cfilt_mode.reg_mode_val = <API key>; else cfilt_mode.reg_mode_val = <API key>; cfilt_mode.cur_mode_val = snd_soc_read(codec, mbhc->mbhc_bias_regs.cfilt_ctl) & 0x30; cfilt_mode.reg_mask = 0x30; return cfilt_mode; } static void tapan_select_cfilt(struct snd_soc_codec *codec, struct wcd9xxx_mbhc *mbhc) { snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.ctl_reg, 0x60, 0x00); } enum wcd9xxx_cdc_type tapan_get_cdc_type(void) { return <API key>; } static void <API key>(struct wcd9xxx_mbhc *mbhc, struct list_head *lh) { int i; struct snd_soc_codec *codec = mbhc->codec; u32 delay; const struct <API key> reg_set_paon[] = { {<API key>, 0x0F, 0x00}, {<API key>, 0xFF, 0xA4}, {<API key>, 0xFF, 0x67}, {<API key>, 0x1, 0x0}, {<API key>, 0x1, 0x0}, {<API key>, 0xFF, 0x1A}, {<API key>, 0xFF, 0xDB}, {<API key>, 0xFF, 0x2A}, {<API key>, 0xFF, 0x10}, {<API key>, 0xFF, 0x05}, {<API key>, 0xFF, 0x81}, {<API key>, 0x03, 0x03}, {<API key>, 0xFF, 0x2C}, {<API key>, 0xFF, 0x81}, {<API key>, 0xFF, 0x2C}, {<API key>, 0xFF, 0x50}, {<API key>, 0xFF, 0x08}, {<API key>, 0xFF, 0x5B}, {WCD9XXX_A_NCP_CLK, 0xFF, 0x9C}, {WCD9XXX_A_NCP_CLK, 0xFF, 0xFC}, {<API key>, 0xFF, 0xCE}, {<API key>, 0xFF, 0x6B}, {<API key>, 0xFF, 0x6F}, {<API key>, 0xFF, 0x62}, {<API key>, 0xFF, 0x7A}, {<API key>, 0xFF, 0x02}, {<API key>, 0xFF, 0x06}, {<API key>, 0xFF, 0x80}, {<API key>, 0xFF, 0xC6}, {<API key>, 0xFF, 0xE6}, {<API key>, 0xFF, 0x02}, {<API key>, 0xFF, 0xA1}, /* Delay 1ms */ {WCD9XXX_A_NCP_EN, 0xFF, 0xFF}, /* Delay 1ms */ {<API key>, 0xFF, 0x03}, {<API key>, 0xFF, 0x7B}, {<API key>, 0xFF, 0xE6}, {<API key>, 0xFF, 0x40}, {<API key>, 0xFF, 0xC0}, {<API key>, 0xFF, 0x40}, {<API key>, 0xFF, 0xC0}, {<API key>, 0xFF, 0x08}, {<API key>, 0x03, 0x01}, {<API key>, 0x03, 0x01}, }; /* * Configure PA in class-AB, -18dB gain, * companding off, OCP off, Chopping ON */ for (i = 0; i < ARRAY_SIZE(reg_set_paon); i++) { /* * Some of the codec registers like BUCK_MODE_1 * and NCP_EN requires 1ms wait time for them * to take effect. Other register writes for * PA configuration do not require any wait time. */ if (reg_set_paon[i].reg == <API key> || reg_set_paon[i].reg == WCD9XXX_A_NCP_EN) delay = 1000; else delay = 0; <API key>(codec, lh, reg_set_paon[i].reg, reg_set_paon[i].mask, reg_set_paon[i].val, delay); } pr_debug("%s: PAs are prepared\n", __func__); return; } static int <API key>(struct wcd9xxx_mbhc *mbhc, bool enable) { struct snd_soc_codec *codec = mbhc->codec; int wg_time = snd_soc_read(codec, <API key>) * <API key>; /* * Tapan requires additional time to enable PA. * It is observed during experiments that we need * an additional wait time about 0.35 times of * the WG_TIME */ wg_time += (int) (wg_time * 35) / 100; snd_soc_update_bits(codec, <API key>, 0x30, enable ? 0x30 : 0x0); /* Wait for wave gen time to avoid pop noise */ usleep_range(wg_time, wg_time + <API key>); pr_debug("%s: PAs are %s as static mode (wg_time %d)\n", __func__, enable ? "enabled" : "disabled", wg_time); return 0; } static int tapan_setup_zdet(struct wcd9xxx_mbhc *mbhc, enum <API key> stage) { int ret = 0; struct snd_soc_codec *codec = mbhc->codec; struct tapan_priv *tapan = <API key>(codec); const int mux_wait_us = 25; switch (stage) { case <API key>: INIT_LIST_HEAD(&tapan->reg_save_restore); /* Configure PA */ <API key>(mbhc, &tapan->reg_save_restore); #define __wr(reg, mask, value) \ do { \ ret = <API key>(codec, \ &tapan->reg_save_restore, \ reg, mask, value, 0); \ if (ret < 0) \ return ret; \ } while (0) /* Setup MBHC */ __wr(<API key>, 0x7F, 0x40); __wr(<API key>, 0xFF, 0xF0); __wr(<API key>, 0xFF, 0x78); __wr(<API key>, 0xFF, 0xEC); __wr(<API key>, 0xFF, 0x45); __wr(<API key>, 0xFF, 0x80); __wr(<API key>, 0xFF, 0x0A); snd_soc_write(codec, <API key>, 0x2); __wr(<API key>, 0xFF, 0x02); /* Enable Impedance Detection */ __wr(WCD9XXX_A_MBHC_HPH, 0xFF, 0xC8); /* * CnP setup for 0mV * Route static data as input to noise shaper */ __wr(<API key>, 0xFF, 0x02); __wr(<API key>, 0xFF, 0x02); snd_soc_update_bits(codec, <API key>, 0x02, 0x00); snd_soc_update_bits(codec, <API key>, 0x02, 0x00); /* Reset the HPHL static data pointer */ __wr(<API key>, 0xFF, 0x00); /* Four consecutive writes to set 0V as static data input */ snd_soc_write(codec, <API key>, 0x00); snd_soc_write(codec, <API key>, 0x00); snd_soc_write(codec, <API key>, 0x00); snd_soc_write(codec, <API key>, 0x00); /* Reset the HPHR static data pointer */ __wr(<API key>, 0xFF, 0x00); /* Four consecutive writes to set 0V as static data input */ snd_soc_write(codec, <API key>, 0x00); snd_soc_write(codec, <API key>, 0x00); snd_soc_write(codec, <API key>, 0x00); snd_soc_write(codec, <API key>, 0x00); /* Enable the HPHL and HPHR PA */ <API key>(mbhc, true); break; case <API key>: /* Turn off ICAL */ snd_soc_write(codec, <API key>, 0xF0); <API key>(mbhc, false); /* * Setup CnP wavegen to ramp to the desired * output using a 40ms ramp */ /* CnP wavegen current to 0.5uA */ snd_soc_write(codec, <API key>, 0x1A); /* Set the current division ratio to 2000 */ snd_soc_write(codec, <API key>, 0xDF); /* Set the wavegen timer to max (60msec) */ snd_soc_write(codec, <API key>, 0xA0); /* Set the CnP reference current to sc_bias */ snd_soc_write(codec, <API key>, 0x6D); snd_soc_write(codec, <API key>, 0x00); /* Four consecutive writes to set -10mV as static data input */ snd_soc_write(codec, <API key>, 0x00); snd_soc_write(codec, <API key>, 0x1F); snd_soc_write(codec, <API key>, 0x19); snd_soc_write(codec, <API key>, 0xAA); snd_soc_write(codec, <API key>, 0x00); /* Four consecutive writes to set -10mV as static data input */ snd_soc_write(codec, <API key>, 0x00); snd_soc_write(codec, <API key>, 0x1F); snd_soc_write(codec, <API key>, 0x19); snd_soc_write(codec, <API key>, 0xAA); snd_soc_update_bits(codec, <API key>, 0x02, 0x02); snd_soc_update_bits(codec, <API key>, 0x02, 0x02); /* Enable the HPHL and HPHR PA and wait for 60mS */ <API key>(mbhc, true); snd_soc_update_bits(codec, <API key>, 0x7F, 0x40); usleep_range(mux_wait_us, mux_wait_us + <API key>); break; case <API key>: if (!mbhc->hph_pa_dac_state) <API key>(mbhc, false); <API key>(codec, &tapan->reg_save_restore); break; default: dev_dbg(codec->dev, "%s: Case %d not supported\n", __func__, stage); break; } #undef __wr return ret; } static void <API key>(struct wcd9xxx_mbhc *mbhc, s16 *l, s16 *r, uint32_t *zl, uint32_t *zr) { int zln, zld; int zrn, zrd; int rl = 0, rr = 0; if (!mbhc) { pr_err("%s: NULL pointer for MBHC", __func__); return; } zln = (l[1] - l[0]) * <API key>; zld = (l[2] - l[0]); if (zld) rl = zln / zld; zrn = (r[1] - r[0]) * <API key>; zrd = (r[2] - r[0]); if (zrd) rr = zrn / zrd; *zl = rl; *zr = rr; } static const struct wcd9xxx_mbhc_cb mbhc_cb = { .<API key> = <API key>, .cfilt_fast_mode = <API key>, .codec_specific_cal = <API key>, .switch_cfilt_mode = <API key>, .select_cfilt = tapan_select_cfilt, .get_cdc_type = tapan_get_cdc_type, .setup_zdet = tapan_setup_zdet, .compute_impedance = <API key>, }; int tapan_hs_detect(struct snd_soc_codec *codec, struct wcd9xxx_mbhc_config *mbhc_cfg) { struct tapan_priv *tapan = <API key>(codec); return wcd9xxx_mbhc_start(&tapan->mbhc, mbhc_cfg); } EXPORT_SYMBOL(tapan_hs_detect); void <API key>(struct snd_soc_codec *codec) { struct tapan_priv *tapan = <API key>(codec); wcd9xxx_mbhc_stop(&tapan->mbhc); } EXPORT_SYMBOL(<API key>); void <API key>( int (*machine_event_cb)(struct snd_soc_codec *codec, enum wcd9xxx_codec_event), struct snd_soc_codec *codec) { struct tapan_priv *tapan = <API key>(codec); tapan-><API key> = machine_event_cb; } EXPORT_SYMBOL(<API key>); static int tapan_device_down(struct wcd9xxx *wcd9xxx) { struct snd_soc_codec *codec; codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv); <API key>(codec->card, 0); return 0; } static const struct wcd9xxx_mbhc_intr cdc_intr_ids = { .poll_plug_rem = <API key>, .shortavg_complete = <API key>, .<API key> = <API key>, .button_release = <API key>, .dce_est_complete = <API key>, .insertion = <API key>, .hph_left_ocp = <API key>, .hph_right_ocp = <API key>, .hs_jack_switch = <API key>, }; static int tapan_post_reset_cb(struct wcd9xxx *wcd9xxx) { int ret = 0; int rco_clk_rate; struct snd_soc_codec *codec; struct tapan_priv *tapan; int count; codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv); tapan = <API key>(codec); <API key>(codec->card, 1); mutex_lock(&codec->mutex); if (codec->reg_def_copy) { pr_debug("%s: Update ASOC cache", __func__); kfree(codec->reg_cache); codec->reg_cache = kmemdup(codec->reg_def_copy, codec->reg_size, GFP_KERNEL); if (!codec->reg_cache) { pr_err("%s: Cache update failed!\n", __func__); mutex_unlock(&codec->mutex); return -ENOMEM; } } if (spkr_drv_wrnd == 1) snd_soc_update_bits(codec, TAPAN_A_SPKR_DRV_EN, 0x80, 0x80); <API key>(codec); <API key>(wcd9xxx); <API key>(codec); ret = tapan_handle_pdata(tapan); if (IS_ERR_VALUE(ret)) pr_err("%s: bad pdata\n", __func__); <API key>(codec); <API key>(&tapan->resmgr); wcd9xxx_mbhc_deinit(&tapan->mbhc); if (TAPAN_IS_1_0(wcd9xxx->version)) rco_clk_rate = <API key>; else rco_clk_rate = <API key>; ret = wcd9xxx_mbhc_init(&tapan->mbhc, &tapan->resmgr, codec, <API key>, &mbhc_cb, &cdc_intr_ids, rco_clk_rate, <API key>); if (ret) pr_err("%s: mbhc init failed %d\n", __func__, ret); else wcd9xxx_mbhc_start(&tapan->mbhc, tapan->mbhc.mbhc_cfg); tapan_cleanup_irqs(tapan); ret = tapan_setup_irqs(tapan); if (ret) pr_err("%s: Failed to setup irq: %d\n", __func__, ret); tapan-><API key>(codec, <API key>); for (count = 0; count < NUM_CODEC_DAIS; count++) tapan->dai[count].<API key> = true; mutex_unlock(&codec->mutex); return ret; } static struct wcd9xxx_reg_address tapan_reg_address = { }; static int <API key>(struct wcd9xxx *control, int (*device_down_cb)(struct wcd9xxx *wcd9xxx), int (*device_up_cb)(struct wcd9xxx *wcd9xxx), void *priv) { control->dev_down = device_down_cb; control->post_reset = device_up_cb; control->ssr_priv = priv; return 0; } static struct regulator *<API key>( struct snd_soc_codec *codec, const char *name) { int i; struct wcd9xxx *core = NULL; if (codec == NULL) { dev_err(codec->dev, "%s: codec not initialized\n", __func__); return NULL; } core = dev_get_drvdata(codec->dev->parent); if (core == NULL) { dev_err(codec->dev, "%s: core not initialized\n", __func__); return NULL; } for (i = 0; i < core->num_of_supplies; i++) { if (core->supplies[i].supply && !strcmp(core->supplies[i].supply, name)) return core->supplies[i].consumer; } return NULL; } static void <API key>(struct wcd9xxx *core, bool enable) { struct <API key> *core_res = &core->core_res; if (enable) { wcd9xxx_reg_update(core, <API key>, 0x80, 0x80); wcd9xxx_reg_update(core, <API key>, 0x04, 0x04); wcd9xxx_reg_update(core, <API key>, 0x01, 0x01); usleep_range(1000, 1000); wcd9xxx_reg_update(core, <API key>, 0x80, 0x00); /* Enable RC Oscillator */ wcd9xxx_reg_update(core, <API key>, 0x10, 0x00); wcd9xxx_reg_write(core_res, <API key>, 0x17); usleep_range(5, 5); wcd9xxx_reg_update(core, <API key>, 0x80, 0x80); wcd9xxx_reg_update(core, <API key>, 0x80, 0x80); usleep_range(10, 10); wcd9xxx_reg_update(core, <API key>, 0x80, 0x00); usleep_range(20, 20); wcd9xxx_reg_update(core, <API key>, 0x08, 0x08); /* Enable MCLK and wait 1ms till it gets enabled */ wcd9xxx_reg_write(core_res, <API key>, 0x02); usleep_range(1000, 1000); /* Enable CLK BUFF and wait for 1.2ms */ wcd9xxx_reg_update(core, <API key>, 0x01, 0x01); usleep_range(1000, 1200); wcd9xxx_reg_update(core, <API key>, 0x02, 0x00); wcd9xxx_reg_update(core, <API key>, 0x04, 0x04); wcd9xxx_reg_update(core, <API key>, 0x01, 0x01); usleep_range(50, 50); } else { wcd9xxx_reg_update(core, <API key>, 0x04, 0x00); usleep_range(50, 50); wcd9xxx_reg_update(core, <API key>, 0x02, 0x02); wcd9xxx_reg_update(core, <API key>, 0x05, 0x00); usleep_range(50, 50); wcd9xxx_reg_update(core, <API key>, 0x80, 0x00); usleep_range(10, 10); wcd9xxx_reg_write(core_res, <API key>, 0x16); wcd9xxx_reg_update(core, <API key>, 0x03, 0x00); usleep_range(100, 100); } } static bool tapan_check_wcd9306(struct device *cdc_dev, bool sensed) { struct wcd9xxx *core = dev_get_drvdata(cdc_dev->parent); u8 reg_val; bool ret = true; unsigned long timeout; bool timedout; struct <API key> *core_res = &core->core_res; if (!core) { dev_err(cdc_dev, "%s: core not initialized\n", __func__); return -EINVAL; } <API key>(core, 1); if (sensed == false) { reg_val = wcd9xxx_reg_read(core_res, TAPAN_A_QFUSE_CTL); wcd9xxx_reg_write(core_res, TAPAN_A_QFUSE_CTL, (reg_val | 0x03)); } timeout = jiffies + HZ; do { if ((wcd9xxx_reg_read(core_res, <API key>))) break; } while (!(timedout = time_after(jiffies, timeout))); if (wcd9xxx_reg_read(core_res, <API key>) || wcd9xxx_reg_read(core_res, <API key>)) { dev_info(cdc_dev, "%s: wcd9302 detected\n", __func__); ret = false; } else dev_info(cdc_dev, "%s: wcd9306 detected\n", __func__); <API key>(core, 0); return ret; }; static int tapan_codec_probe(struct snd_soc_codec *codec) { struct wcd9xxx *control; struct tapan_priv *tapan; struct wcd9xxx_pdata *pdata; struct wcd9xxx *wcd9xxx; struct <API key> *dapm = &codec->dapm; int ret = 0; int i, rco_clk_rate; void *ptr = NULL; struct <API key> *core_res; codec->control_data = dev_get_drvdata(codec->dev->parent); control = codec->control_data; <API key>(control, tapan_device_down, tapan_post_reset_cb, (void *)codec); dev_info(codec->dev, "%s()\n", __func__); tapan = kzalloc(sizeof(struct tapan_priv), GFP_KERNEL); if (!tapan) { dev_err(codec->dev, "Failed to allocate private data\n"); return -ENOMEM; } for (i = 0 ; i < NUM_DECIMATORS; i++) { tx_hpf_work[i].tapan = tapan; tx_hpf_work[i].decimator = i + 1; INIT_DELAYED_WORK(&tx_hpf_work[i].dwork, <API key>); } <API key>(codec, tapan); /* codec resmgr module init */ wcd9xxx = codec->control_data; core_res = &wcd9xxx->core_res; pdata = dev_get_platdata(codec->dev->parent); ret = wcd9xxx_resmgr_init(&tapan->resmgr, codec, core_res, pdata, &pdata->micbias, &tapan_reg_address, <API key>); if (ret) { pr_err("%s: wcd9xxx init failed %d\n", __func__, ret); return ret; } tapan->cp_regulators[CP_REG_BUCK] = <API key>(codec, <API key>); tapan->cp_regulators[CP_REG_BHELPER] = <API key>(codec, "cdc-vdd-buckhelper"); tapan->clsh_d.buck_mv = <API key>(codec); /* * If 1.8 volts is requested on the vdd_cp line, then * assume that S4 is in a dynamically switchable state * and can switch between 1.8 volts and 2.15 volts */ if (tapan->clsh_d.buck_mv == <API key>) tapan->clsh_d.is_dynamic_vdd_cp = true; wcd9xxx_clsh_init(&tapan->clsh_d, &tapan->resmgr); if (TAPAN_IS_1_0(control->version)) rco_clk_rate = <API key>; else rco_clk_rate = <API key>; ret = wcd9xxx_mbhc_init(&tapan->mbhc, &tapan->resmgr, codec, <API key>, &mbhc_cb, &cdc_intr_ids, rco_clk_rate, <API key>); if (ret) { pr_err("%s: mbhc init failed %d\n", __func__, ret); return ret; } tapan->codec = codec; for (i = 0; i < COMPANDER_MAX; i++) { tapan->comp_enabled[i] = 0; tapan->comp_fs[i] = COMPANDER_FS_48KHZ; } tapan->intf_type = <API key>(); tapan->aux_pga_cnt = 0; tapan->aux_l_gain = 0x1F; tapan->aux_r_gain = 0x1F; tapan->ldo_h_users = 0; tapan->micb_2_users = 0; tapan->lb_mode = false; <API key>(codec); <API key>(wcd9xxx); <API key>(codec); ret = tapan_handle_pdata(tapan); if (IS_ERR_VALUE(ret)) { dev_err(codec->dev, "%s: bad pdata\n", __func__); goto err_pdata; } if (spkr_drv_wrnd > 0) { WCD9XXX_BG_CLK_LOCK(&tapan->resmgr); <API key>(&tapan->resmgr, <API key>); <API key>(&tapan->resmgr); } ptr = kmalloc((sizeof(tapan_rx_chs) + sizeof(tapan_tx_chs)), GFP_KERNEL); if (!ptr) { pr_err("%s: no mem for slim chan ctl data\n", __func__); ret = -ENOMEM; goto err_nomem_slimch; } if (tapan->intf_type == <API key>) { <API key>(dapm, <API key>, ARRAY_SIZE(<API key>)); <API key>(dapm, audio_i2s_map, ARRAY_SIZE(audio_i2s_map)); for (i = 0; i < ARRAY_SIZE(tapan_i2s_dai); i++) INIT_LIST_HEAD(&tapan->dai[i].wcd9xxx_ch_list); } else if (tapan->intf_type == <API key>) { for (i = 0; i < NUM_CODEC_DAIS; i++) { INIT_LIST_HEAD(&tapan->dai[i].wcd9xxx_ch_list); init_waitqueue_head(&tapan->dai[i].dai_wait); } <API key>(codec); } if (codec_ver == WCD9306) { <API key>(codec, <API key>, ARRAY_SIZE(<API key>)); <API key>(dapm, <API key>, ARRAY_SIZE(<API key>)); <API key>(dapm, wcd9306_map, ARRAY_SIZE(wcd9306_map)); } else { <API key>(dapm, wcd9302_map, ARRAY_SIZE(wcd9302_map)); } control->num_rx_port = TAPAN_RX_MAX; control->rx_chs = ptr; memcpy(control->rx_chs, tapan_rx_chs, sizeof(tapan_rx_chs)); control->num_tx_port = TAPAN_TX_MAX; control->tx_chs = ptr + sizeof(tapan_rx_chs); memcpy(control->tx_chs, tapan_tx_chs, sizeof(tapan_tx_chs)); snd_soc_dapm_sync(dapm); (void) tapan_setup_irqs(tapan); atomic_set(&kp_tapan_priv, (unsigned long)tapan); mutex_lock(&dapm->codec->mutex); if (codec_ver == WCD9306) { <API key>(dapm, "ANC HPHL"); <API key>(dapm, "ANC HPHR"); <API key>(dapm, "ANC HEADPHONE"); <API key>(dapm, "ANC EAR PA"); <API key>(dapm, "ANC EAR"); } snd_soc_dapm_sync(dapm); mutex_unlock(&dapm->codec->mutex); codec->ignore_pmdown_time = 1; if (ret) tapan_cleanup_irqs(tapan); return ret; err_pdata: kfree(ptr); err_nomem_slimch: kfree(tapan); return ret; } static int tapan_codec_remove(struct snd_soc_codec *codec) { struct tapan_priv *tapan = <API key>(codec); int index = 0; WCD9XXX_BG_CLK_LOCK(&tapan->resmgr); atomic_set(&kp_tapan_priv, 0); if (spkr_drv_wrnd > 0) <API key>(&tapan->resmgr, <API key>); <API key>(&tapan->resmgr); tapan_cleanup_irqs(tapan); /* cleanup MBHC */ wcd9xxx_mbhc_deinit(&tapan->mbhc); /* cleanup resmgr */ <API key>(&tapan->resmgr); for (index = 0; index < CP_REG_MAX; index++) tapan->cp_regulators[index] = NULL; kfree(tapan); return 0; } static struct <API key> soc_codec_dev_tapan = { .probe = tapan_codec_probe, .remove = tapan_codec_remove, .read = tapan_read, .write = tapan_write, .readable_register = tapan_readable, .volatile_register = tapan_volatile, .reg_cache_size = TAPAN_CACHE_SIZE, .reg_cache_default = <API key>, .reg_word_size = 1, .controls = <API key>, .num_controls = ARRAY_SIZE(<API key>), .dapm_widgets = <API key>, .num_dapm_widgets = ARRAY_SIZE(<API key>), .dapm_routes = audio_map, .num_dapm_routes = ARRAY_SIZE(audio_map), }; #ifdef CONFIG_PM static int tapan_suspend(struct device *dev) { dev_dbg(dev, "%s: system suspend\n", __func__); return 0; } static int tapan_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct tapan_priv *tapan = <API key>(pdev); dev_dbg(dev, "%s: system resume\n", __func__); /* Notify */ <API key>(&tapan->resmgr, <API key>); return 0; } static const struct dev_pm_ops tapan_pm_ops = { .suspend = tapan_suspend, .resume = tapan_resume, }; #endif static int __devinit tapan_probe(struct platform_device *pdev) { int ret = 0; bool is_wcd9306; is_wcd9306 = tapan_check_wcd9306(&pdev->dev, false); if (is_wcd9306 < 0) { dev_info(&pdev->dev, "%s: cannot find codec type, default to 9306\n", __func__); is_wcd9306 = true; } codec_ver = is_wcd9306 ? WCD9306 : WCD9302; if (!is_wcd9306) { if (<API key>() == <API key>) ret = <API key>(&pdev->dev, &soc_codec_dev_tapan, tapan9302_dai, ARRAY_SIZE(tapan9302_dai)); else if (<API key>() == <API key>) ret = <API key>(&pdev->dev, &soc_codec_dev_tapan, tapan_i2s_dai, ARRAY_SIZE(tapan_i2s_dai)); } else { if (<API key>() == <API key>) ret = <API key>(&pdev->dev, &soc_codec_dev_tapan, tapan_dai, ARRAY_SIZE(tapan_dai)); else if (<API key>() == <API key>) ret = <API key>(&pdev->dev, &soc_codec_dev_tapan, tapan_i2s_dai, ARRAY_SIZE(tapan_i2s_dai)); } return ret; } static int __devexit tapan_remove(struct platform_device *pdev) { <API key>(&pdev->dev); return 0; } static struct platform_driver tapan_codec_driver = { .probe = tapan_probe, .remove = tapan_remove, .driver = { .name = "tapan_codec", .owner = THIS_MODULE, #ifdef CONFIG_PM .pm = &tapan_pm_ops, #endif }, }; static int __init tapan_codec_init(void) { return <API key>(&tapan_codec_driver); } static void __exit tapan_codec_exit(void) { <API key>(&tapan_codec_driver); } module_init(tapan_codec_init); module_exit(tapan_codec_exit); MODULE_DESCRIPTION("Tapan codec driver"); MODULE_LICENSE("GPL v2");
#ifndef MANAGER_RENDER_H #define MANAGER_RENDER_H #include "manager_space.h" #include <vector> #include <string> #include <glm/gtc/matrix_transform.hpp> #include <glm/glm.hpp> using namespace std; class render_obj { public: render_obj(); render_obj(GLuint _vao, GLuint _vbo); render_obj(GLuint _vao, GLuint _vbo, GLuint _tbo); render_obj(GLuint _vao, GLuint _vbo, GLuint _tbo, GLuint _nbo); void basicPlane(); void end(); bool hasV, hasT, hasN; GLuint vao, vbo, tbo, nbo; }; class camera{ public: camera(); camera(int dim); glm::mat4 proj, model, view, mvp; void setMat(int dim); void calcMat(); }; class render_manager { public: render_manager(); virtual ~render_manager(); void loadShader(const char *vertexpath, const char *fragmentpath); void end(); void init(); void useProg(int index); GLuint getProg(int index); GLuint getUniform(const char *s); void putTex(GLuint t_id, int where, const char *var_name); void loadPNG(const char *name); void deletePNG(int ind); void drawImg(int w,int h); int in_use; camera c; render_obj r; vector<GLuint> prog; vector<tex> texture; }; #endif // MANAGER_RENDER_H
<?php /** * CSS typography * * @package Elgg.Core * @subpackage UI */ ?> body { font-size: 80%; line-height: 1.4em; font-family: "Lucida Grande", Arial, Tahoma, Verdana, sans-serif; } a { color: #446; } a:hover, a.selected { <?php //@todo remove .selected ?> color: #555555; text-decoration: underline; } p { margin-bottom: 15px; } p:last-child { margin-bottom: 0; } pre, code { font-family: Monaco, "Courier New", Courier, monospace; font-size: 12px; background:#EBF5FF; color:#000000; overflow:auto; overflow-x: auto; /* Use horizontal scroller if needed; for Firefox 2, not needed in Firefox 3 */ white-space: pre-wrap; word-wrap: break-word; /* IE 5.5-7 */ } pre { padding:3px 15px; margin:0px 0 15px 0; line-height:1.3em; } code { padding:2px 3px; } .elgg-monospace { font-family: Monaco, "Courier New", Courier, monospace; } blockquote { line-height: 1.3em; padding:3px 15px; margin:0px 0 15px 0; background:#EBF5FF; border:none; -<API key>: 4px; -moz-border-radius: 4px; border-radius: 4px; } h1, h2, h3, h4, h5, h6 { font-weight: bold; color: #566; } h1 { font-size: 1.8em; } h2 { font-size: 1.5em; line-height: 1.1em; padding-bottom:5px} h3 { font-size: 1.2em; } h4 { font-size: 1.0em; } h5 { font-size: 0.9em; } h6 { font-size: 0.8em; } .elgg-heading-site, .elgg-heading-site:hover { font-size: 2em; line-height: 1.4em; color: white; font-style: italic; font-family: Georgia, times, serif; text-shadow: 1px 2px 4px #333333; text-decoration: none; } .elgg-heading-main { float: left; max-width: 530px; margin-right: 10px; } .elgg-heading-basic { color: #455; font-size: 1.2em; font-weight: bold; } .elgg-subtext { color: #666666; font-size: 85%; line-height: 1.2em; font-style: italic; } .elgg-text-help { display: block; font-size: 85%; font-style: italic; } .elgg-quiet { color: #666; } .elgg-loud { color: #0054A7; } .elgg-output { margin-top: 10px; } .elgg-output dt { font-weight: bold } .elgg-output dd { margin: 0 0 1em 1em } .elgg-output ul, .elgg-output ol { margin: 0 1.5em 1.5em 0; padding-left: 1.5em; } .elgg-output ul { list-style-type: disc; } .elgg-output ol { list-style-type: decimal; } .elgg-output table { border: 1px solid #ccc; } .elgg-output table td { border: 1px solid #ccc; padding: 3px 5px; } .elgg-output img { max-width: 100%; }
INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10095, -2973.16, -21.0658, 190.085, 3.63401, 1, 'montmulgore'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10094, 9450.69, 65.4357, 18.6532, 3.75495, 1, 'retrievalally'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10092, -1859.96, -4139.58, 10.7204, 4.52634, 0, 'merinterdite'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10091, -4828.17, -982.03, 464.709, 3.9015, 0, 'EldestIronforge'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10090, -11372.9, -4729.71, 5.04762, 3.44946, 1, 'iledelunah'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10087, 9463.68, 66.9378, 19.3721, 2.76772, 1, 'evangeline'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10086, -1833.26, -4198.24, 3.81099, 1.62944, 0, 'cedrix'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10085, -3991.53, -1306.78, 147.66, 3.42565, 0, 'bulle'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10084, 16303.8, 16317.3, 69.4447, 3.95691, 451, 'programmer'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10083, 16303.5, -16173.5, 40.4365, 4.48784, 451, 'designer'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10082, 2212.57, -5110.05, 235.914, 4.37593, 571, 'loveyou'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10081, 2212.57, -5110.05, 235.914, 0.056245, 571, 'tuesunemauvaise'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10080, -5513.16, 930.636, 396.782, 3.28808, 0, 'EventMograine'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10079, 5440.62, -2791.63, 1474.01, 0.994314, 1, 'hyjalarena'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10078, 4418.91, -2522.02, 1123.48, 0.165595, 1, 'hyjalarene'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10077, 4426.23, -2511.4, 1125.03, 0.117803, 1, 'Hyjal tournois'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10076, -13258.7, 279.552, 33.2427, 5.97963, 0, 'Allypxp'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10075, -5086.68, -1702.21, 497.885, 4.13885, 0, 'KTK'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10074, -9826.97, 2567.91, 22.2774, 5.93439, 1, 'sadnessel'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10073, -10772.1, 2183.32, 3.33876, 0.029769, 1, 'Chaussette'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10072, 238.79, 869.559, 121.7, 4.87649, 0, 'retrieval'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10071, 5129.85, -3800.41, 1971.05, 1.68194, 1, 'Sommethyjal'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10070, 2383.68, -5645.17, 421.806, 0.779895, 0, 'acherus'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10069, 1497.92, -24.0304, 421.368, 0.014686, 603, 'vousetesmauvais'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10068, 1497.92, -24.0304, 421.368, 0.014686, 603, 'dansulduar'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10067, 7526.79, 1834.83, 685.055, 4.72038, 571, 'testmog'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10066, -108.961, 25.2245, -63.3502, 0.005686, 13, 'test1'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10065, 3009.27, -5086.37, 732.537, 6.00983, 571, 'noel'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10064, -10738.7, 2437.38, 7.05442, 3.31185, 1, 'Agmagor'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10063, 2166.08, -4706.11, 74.8039, 3.82289, 0, 'Event Maz'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10062, -8621.1, 742.933, 96.7918, 3.11445, 0, 'orphelinally'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10061, -11820.1, -4744.13, 6.74256, 3.52564, 1, 'iledemograine'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10060, 16232.3, 16403.5, -64.3789, 3.07557, 1, 'tribunal'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10059, -9713.21, -4642.26, 19.9119, 2.68797, 1, 'bateau3'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10058, -9712.6, -4641.17, 19.6332, 3.73647, 1, 'bateau4'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10057, -10049.2, -4546.71, 42.0294, 6.07974, 1, 'bns1'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10056, -9464.41, -4706.54, 54.9513, 0.999026, 1, 'BNS'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10055, 16053.3, 16198.8, 5.92209, 3.72675, 1, 'bateau0'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10054, -9638.28, -4686.16, 17.9324, 3.75439, 1, 'bateau2'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10053, 16224.2, 16173, 10.164, 5.82628, 1, 'bateau1'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10052, 5745.47, 3097.24, 316.595, 4.90944, 571, 'faible'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10051, -11350.6, -4728.47, 6.18444, 3.08188, 1, 'Ile tanaris'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10050, -4765.19, -1665.34, 503.324, 0.32606, 0, 'aeroport'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10049, 5706.63, 3427.42, 300.842, 1.67478, 571, 'zonetelemaillon2'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10048, 5710.54, 3389.96, 300.842, 4.82737, 571, 'zonetelemaillon'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10047, -4732.56, -1546.22, 98.3497, 0.52324, 1, 'Cocabox'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10046, 1023.59, 288.158, 332.004, 3.54831, 37, 'agmaevent'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10045, -4819.33, -974.58, 464.709, 0.691372, 0, 'QGdworkin'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10044, 323.337, 169.505, 234.944, 5.14283, 37, 'eventunnutz'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10043, -4816.21, -971.918, 464.709, 3.87829, 0, 'QG2'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10042, 5062.36, -5572.05, 0.000176, 5.09297, 530, 'dworkin11'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10041, 5058.07, -5561.33, 0.000176, 5.09689, 530, 'zonetest'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10040, 4130.36, -3669.49, 45.5482, 1.08652, 0, 'dworkin10'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10039, -2923.34, -3609.87, 178.876, 3.82757, 0, 'dworkin9'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10038, -4244.13, -4503.6, 131.407, 0.238299, 0, 'dworkin8'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10037, -6991.95, 1114.32, 131.396, 3.17022, 0, 'dworkin7*'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10036, -7637.5, -105.542, 59.4568, 0.990743, 0, 'dworkin6'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10035, -7545.66, -1254.35, 481.528, 0.623149, 0, 'dworkin5'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10034, 10374.1, -6408.33, 163.458, 0.226115, 530, 'maisonmograine'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10033, -8680.03, -1167.88, 8.87751, 3.32598, 1, 'enormezone'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10032, -5444.08, -4319.32, 325.784, 2.77644, 1, 'dworkinmj'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10031, 376.233, 866.837, 178.872, 6.21471, 1, 'dworkin4'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10030, 495.349, -737.974, 68.7487, 1.44735, 1, 'dworkin3'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10029, 1736.44, 1934.12, 131.406, 0.371381, 1, 'dworkin2'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10028, -5468.38, -4316.08, 86.1112, 3.89956, 1, 'Dworkin'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10027, -4541.9, -1481.95, 88.0295, 2.87846, 1, 'Cocatrone'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10026, -4547.5, -1462.23, 87.4237, 2.7405, 1, 'Cocahorde'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10025, -4561.49, -1502.51, 92.3065, 0.803512, 1, 'Cocaally'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10024, -4556.61, -1484.48, 87.9318, 1.11472, 1, 'Coca'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10023, 1056.12, -4739.21, 131.171, 2.38611, 0, 'Test2'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10021, 1877.52, 1392.34, 142.147, 1.68047, 1, 'eventpvp1'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10020, -1035.66, 1587.06, 54.0382, 2.58963, 0, 'testgob2'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10019, -1064.93, 1582.08, 66.5807, 3.25722, 0, 'testgob'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10018, 6135.09, 5676.97, 5.15026, 3.86762, 571, 'zonetelebanquet1'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10017, 6171.31, 5709.33, 5.15026, 0.721311, 571, 'zonetelebanquet'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10016, -410.464, -12.5369, 308.466, 2.79667, 37, 'zonetelemariage'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10015, 6235.77, 5764.88, -6.33749, 0.869625, 571, 'banquet'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10014, -5232.07, 1041.33, 393.854, 5.33832, 0, 'event1'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10013, -306.878, -306.384, 295.928, 4.68613, 37, 'mariage!'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10012, -229.042, 501.283, 189.958, 4.87649, 0, 'recup'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10011, -9043.14, 375.864, 137.484, 0.795174, 0, 'toursw'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10010, -5534.36, -1355.33, 398.664, 5.13288, 0, 'freya'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10009, 6471.82, 2379.13, 462.567, 3.69145, 571, 'campargent'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10008, 8510.31, 1031.64, 547.301, 5.33137, 571, 'tournoi'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10001, 16197, 16199.6, 10203.5, 0.881942, 1, 'chute'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (10000, 16228, 16403.4, -63.8851, 3.59132, 1, 'Gmbox'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (9999, 240.101, 870.046, 121.701, 3.0978, 0, 'hordezone'); INSERT INTO `game_tele` (`id`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `name`) VALUES (9998, -229.382, 509.039, 189.958, 2.16503, 0, 'allyzone');
<?php /** List with all available otw sitebars * * */ global $_wp_column_headers; $_wp_column_headers['<API key>'] = array( 'id' => __( 'Sidebar ID' ), 'title' => __( 'Title' ), 'description' => __( 'Description' ) ); $otw_sidebar_list = get_option( 'otw_sidebars' ); $message = ''; $massages = array(); $messages[1] = 'Sidebar saved.'; $messages[2] = 'Sidebar deleted.'; $messages[3] = 'Sidebar activated.'; $messages[4] = 'Sidebar deactivated.'; if( isset( $_GET['message'] ) && isset( $messages[ $_GET['message'] ] ) ){ $message .= $messages[ $_GET['message'] ]; } $<API key> = array(); if( is_array( $otw_sidebar_list ) && count( $otw_sidebar_list ) ){ foreach( $otw_sidebar_list as $sidebar_key => $sidebar_item ){ if( $sidebar_item['replace'] == '' ){ $<API key>[ $sidebar_key ] = $sidebar_item; } } } ?> <div class="updated"><p>Check out the <a href="http: <a href="http://otwthemes.com/<API key>?utm_source=wp.org&utm_medium=admin&utm_content=site&utm_campaign=wpl">Create responsive layouts in minutes, drag & drop interface, feature rich.</a></p></div> <?php if ( $message ) : ?> <div id="message" class="updated"><p><?php echo $message; ?></p></div> <?php endif; ?> <div class="wrap"> <div id="icon-edit" class="icon32"><br/></div> <h2> <?php _e('Available Custom Sidebars') ?> <a class="button add-new-h2" href="<?php echo admin_url( 'admin.php?page=otw-wpl-add'); ?>">Add New</a> </h2> <form class="search-form" action="" method="get"> </form> <br class="clear" /> <?php if( is_array( $<API key> ) && count( $<API key> ) ){?> <table class="widefat fixed" cellspacing="0"> <thead> <tr> <?php foreach( $_wp_column_headers['<API key>'] as $key => $name ){?> <th><?php echo $name?></th> <?php }?> </tr> </thead> <tfoot> <tr> <?php foreach( $_wp_column_headers['<API key>'] as $key => $name ){?> <th><?php echo $name?></th> <?php }?> </tr> </tfoot> <tbody> <?php foreach( $<API key> as $sidebar_item ){?> <tr> <?php foreach( $_wp_column_headers['<API key>'] as $column_name => $column_title ){ $edit_link = admin_url( 'admin.php?page=otw-wpl&amp;action=edit&amp;sidebar='.$sidebar_item['id'] ); $delete_link = admin_url( 'admin.php?page=otw-wpl-action&amp;sidebar='.$sidebar_item['id'].'&amp;action=delete' ); switch($column_name) { case 'cb': echo '<th scope="row" class="check-column"><input type="checkbox" name="itemcheck[]" value="'. esc_attr($sidebar_item['id']) .'" /></th>'; break; case 'id': echo '<td><strong><a href="'.$edit_link.'" title="'.esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $sidebar_item['id'])).'">'.$sidebar_item['id'].'</a></strong><br />'; echo '<div class="row-actions">'; echo '<a href="'.$edit_link.'">' . __('Edit') . '</a>'; echo ' | <a href="'.$delete_link.'">' . __('Delete'). '</a>'; echo '</div>'; echo '</td>'; break; case 'title': echo '<td>'.$sidebar_item['title'].'</td>'; break; case 'description': echo '<td>'.$sidebar_item['description'].'</td>'; break; } }?> </tr> <?php }?> </tbody> </table> <div class="updated einfo"><p><?php _e( 'Create as many sidebars as you need. Then add them in your pages/posts/template files. Here is how you can add sidebars:<br /><br />&nbsp;- page/post bellow content using the Grid Manager metabox when you edit your page<br />&nbsp;- page/post content - select the sidebar you want to insert from the Insert Sidebar ShortCode button in your page/post editor.<br />&nbsp;- page/post content - copy the shortcode and paste it in the editor of a page/post.<br />&nbsp;- any page template using the do_shortcode WP function.<br /><br />Use the Sidebar ID to build your shortcodes.<br />Example: [otw_is sidebar=otw-sidebar-1] ' );?></p></div> <?php }else{ ?> <p><?php _e('No custom sidebars found.')?></p> <?php } ?> </div>
from splinter import Browser from time import sleep from selenium.common.exceptions import <API key> from settings import settings from lib import db from lib import assets_helper import unittest from datetime import datetime, timedelta asset_x = { 'mimetype': u'web', 'asset_id': u'<API key>', 'name': u'WireLoad', 'uri': u'http: 'start_date': datetime.now() - timedelta(days=1), 'end_date': datetime.now() + timedelta(days=1), 'duration': u'5', 'is_enabled': 0, 'nocache': 0, 'play_order': 1, } asset_y = { 'mimetype': u'image', 'asset_id': u'<API key>', 'name': u'Google', 'uri': u'https: 'start_date': datetime.now() - timedelta(days=1), 'end_date': datetime.now() + timedelta(days=1), 'duration': u'6', 'is_enabled': 1, 'nocache': 0, 'play_order': 0, } main_page_url = 'http://foo:bar@localhost:8080' settings_url = 'http://foo:bar@localhost:8080/settings' system_info_url = 'http://foo:bar@localhost:8080/system_info' def wait_for_and_do(browser, query, callback): not_filled = True n = 0 while not_filled: try: callback(browser.find_by_css(query).first) not_filled = False except <API key>, e: if n > 20: raise e n += 1 class WebTest(unittest.TestCase): def setUp(self): with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) for asset in assets: assets_helper.delete(conn, asset['asset_id']) def tearDown(self): pass def test_add_asset_url(self): with Browser() as browser: browser.visit(main_page_url) wait_for_and_do(browser, '#add-asset-button', lambda btn: btn.click()) sleep(1) wait_for_and_do(browser, 'input[name="uri"]', lambda field: field.fill('http://example.com')) sleep(1) wait_for_and_do(browser, '#add-form', lambda form: form.click()) sleep(1) wait_for_and_do(browser, '#save-asset', lambda btn: btn.click()) sleep(3) # backend need time to process request with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) self.assertEqual(len(assets), 1) asset = assets[0] self.assertEqual(asset['name'], u'http://example.com') self.assertEqual(asset['uri'], u'http://example.com') self.assertEqual(asset['mimetype'], u'webpage') self.assertEqual(asset['duration'], settings['default_duration']) def test_edit_asset(self): with db.conn(settings['database']) as conn: assets_helper.create(conn, asset_x) with Browser() as browser: browser.visit(main_page_url) wait_for_and_do(browser, '.edit-asset-button', lambda btn: btn.click()) sleep(1) wait_for_and_do(browser, 'input[name="duration"]', lambda field: field.fill('333')) sleep(1) # wait for new-asset panel animation wait_for_and_do(browser, '#add-form', lambda form: form.click()) sleep(1) wait_for_and_do(browser, '#save-asset', lambda btn: btn.click()) sleep(3) # backend need time to process request with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) self.assertEqual(len(assets), 1) asset = assets[0] self.assertEqual(asset['duration'], u'333') def <API key>(self): image_file = '/tmp/image.png' with Browser() as browser: browser.visit(main_page_url) browser.find_by_id('add-asset-button').click() sleep(1) wait_for_and_do(browser, 'a[href="#tab-file_upload"]', lambda tab: tab.click()) wait_for_and_do(browser, 'input[name="file_upload"]', lambda input: input.fill(image_file)) sleep(1) # wait for new-asset panel animation sleep(3) # backend need time to process request with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) self.assertEqual(len(assets), 1) asset = assets[0] self.assertEqual(asset['name'], u'image.png') self.assertEqual(asset['mimetype'], u'image') self.assertEqual(asset['duration'], settings['default_duration']) def <API key>(self): video_file = '/tmp/video.flv' with Browser() as browser: browser.visit(main_page_url) browser.find_by_id('add-asset-button').click() sleep(1) wait_for_and_do(browser, 'a[href="#tab-file_upload"]', lambda tab: tab.click()) wait_for_and_do(browser, 'input[name="file_upload"]', lambda input: input.fill(video_file)) sleep(1) # wait for new-asset panel animation sleep(3) # backend need time to process request with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) self.assertEqual(len(assets), 1) asset = assets[0] self.assertEqual(asset['name'], u'video.flv') self.assertEqual(asset['mimetype'], u'video') self.assertEqual(asset['duration'], u'54') def <API key>(self): video_file = '/tmp/video.flv' image_file = '/tmp/image.png' with Browser() as browser: browser.visit(main_page_url) browser.find_by_id('add-asset-button').click() sleep(1) wait_for_and_do(browser, 'a[href="#tab-file_upload"]', lambda tab: tab.click()) wait_for_and_do(browser, 'input[name="file_upload"]', lambda input: input.fill(image_file)) wait_for_and_do(browser, 'input[name="file_upload"]', lambda input: input.fill(video_file)) sleep(3) # backend need time to process request with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) self.assertEqual(len(assets), 2) self.assertEqual(assets[0]['name'], u'image.png') self.assertEqual(assets[0]['mimetype'], u'image') self.assertEqual(assets[0]['duration'], settings['default_duration']) self.assertEqual(assets[1]['name'], u'video.flv') self.assertEqual(assets[1]['mimetype'], u'video') self.assertEqual(assets[1]['duration'], u'54') def <API key>(self): with Browser() as browser: browser.visit(main_page_url) wait_for_and_do(browser, '#add-asset-button', lambda btn: btn.click()) sleep(1) wait_for_and_do(browser, 'input[name="uri"]', lambda field: field.fill('rtmp://localhost:1935/app/video.flv')) sleep(1) wait_for_and_do(browser, '#add-form', lambda form: form.click()) sleep(1) wait_for_and_do(browser, '#save-asset', lambda btn: btn.click()) sleep(10) # backend need time to process request with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) self.assertEqual(len(assets), 1) asset = assets[0] self.assertEqual(asset['name'], u'rtmp://localhost:1935/app/video.flv') self.assertEqual(asset['uri'], u'rtmp://localhost:1935/app/video.flv') self.assertEqual(asset['mimetype'], u'streaming') self.assertEqual(asset['duration'], settings['<API key>']) def test_rm_asset(self): with db.conn(settings['database']) as conn: assets_helper.create(conn, asset_x) with Browser() as browser: browser.visit(main_page_url) wait_for_and_do(browser, '.delete-asset-button', lambda btn: btn.click()) wait_for_and_do(browser, '.confirm-delete', lambda btn: btn.click()) sleep(3) # backend need time to process request with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) self.assertEqual(len(assets), 0) def test_enable_asset(self): with db.conn(settings['database']) as conn: assets_helper.create(conn, asset_x) with Browser() as browser: browser.visit(main_page_url) wait_for_and_do(browser, 'span[class="on"]', lambda btn: btn.click()) sleep(3) # backend need time to process request with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) self.assertEqual(len(assets), 1) asset = assets[0] self.assertEqual(asset['is_enabled'], 1) def test_disable_asset(self): with db.conn(settings['database']) as conn: _asset_x = asset_x.copy() _asset_x['is_enabled'] = 1 assets_helper.create(conn, _asset_x) with Browser() as browser: browser.visit(main_page_url) wait_for_and_do(browser, 'span[class="off"]', lambda btn: btn.click()) sleep(3) # backend need time to process request with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) self.assertEqual(len(assets), 1) asset = assets[0] self.assertEqual(asset['is_enabled'], 0) def test_reorder_asset(self): with db.conn(settings['database']) as conn: _asset_x = asset_x.copy() _asset_x['is_enabled'] = 1 assets_helper.create(conn, _asset_x) assets_helper.create(conn, asset_y) with Browser() as browser: browser.visit(main_page_url) asset_x_for_drag = browser.find_by_id(asset_x['asset_id']) sleep(1) asset_y_to_reorder = browser.find_by_id(asset_y['asset_id']) asset_x_for_drag.drag_and_drop(asset_y_to_reorder) sleep(3) # backend need time to process request with db.conn(settings['database']) as conn: x = assets_helper.read(conn, asset_x['asset_id']) y = assets_helper.read(conn, asset_y['asset_id']) self.assertEqual(x['play_order'], 0) self.assertEqual(y['play_order'], 1) def <API key>(self): with Browser() as browser: browser.visit(settings_url) self.assertEqual(browser.is_text_present('Error: 500 Internal Server Error'), False, '500: internal server error not expected') def <API key>(self): with Browser() as browser: browser.visit(system_info_url) self.assertEqual(browser.is_text_present('Error: 500 Internal Server Error'), False, '500: internal server error not expected')
#ifndef <API key> #define <API key> #include "generate/decorator.h" #include "generate/decorator/<API key>.h" #include "block/builtin/cobblestone.h" #include "util/<API key>.h" namespace programmerjake { namespace voxels { namespace Decorators { namespace builtin { class <API key> : public DecoratorDescriptor { friend class <API key><<API key>>; private: <API key>() : DecoratorDescriptor(L"builtin.cobblestone_spike", 1, 1000) { } public: static const <API key> *pointer() { return <API key><<API key>>::getInstance(); } static <API key> descriptor() { return pointer(); } /** @brief create a DecoratorInstance for this decorator in a chunk * * @param chunkBasePosition the base position of the chunk to generate in * @param columnBasePosition the base position of the column to generate in * @param surfacePosition the surface position of the column to generate in * @param lock_manager the WorldLockManager * @param chunkBaseIterator a BlockIterator to chunkBasePosition * @param blocks the blocks for this chunk * @param randomSource the RandomSource * @param generateNumber a number that is different for each decorator in a chunk (use for *picking a different position each time) * @return the new DecoratorInstance or nullptr * */ virtual std::shared_ptr<const DecoratorInstance> createInstance( PositionI chunkBasePosition, PositionI columnBasePosition, PositionI surfacePosition, WorldLockManager &lock_manager, BlockIterator chunkBaseIterator, const BlocksGenerateArray &blocks, RandomSource &randomSource, std::uint32_t generateNumber) const override { std::shared_ptr<<API key>> retval = std::make_shared<<API key>>( surfacePosition, this, VectorI(-5, 0, -5), VectorI(11, 10, 11)); for(int i = 0; i < 5; i++) { retval->setBlock(VectorI(0, i, 0), Block(Blocks::builtin::Cobblestone::descriptor())); } for(int i = 5; i < 10; i++) { retval->setBlock(VectorI(5 - i, i, 0), Block(Blocks::builtin::Cobblestone::descriptor())); retval->setBlock(VectorI(i - 5, i, 0), Block(Blocks::builtin::Cobblestone::descriptor())); retval->setBlock(VectorI(0, i, 5 - i), Block(Blocks::builtin::Cobblestone::descriptor())); retval->setBlock(VectorI(0, i, i - 5), Block(Blocks::builtin::Cobblestone::descriptor())); } return retval; } }; } } } } #endif // <API key>
package speiger.src.api.common.recipes.squezingCompressor.parts; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; import speiger.src.api.common.recipes.squezingCompressor.EnumRecipeType; import speiger.src.api.common.recipes.util.RecipeHardness; import speiger.src.api.common.recipes.util.Result; public class SqueezerRecipe implements INormalRecipe { ItemStack recipeInput; Result[] result; public SqueezerRecipe(ItemStack par1, Result...par2) { recipeInput = par1; result = par2; } @Override public ItemStack getItemInput() { return recipeInput; } @Override public FluidStack[] getFluidInput() { return null; } @Override public Result[] getResults() { return result; } @Override public boolean matches(ItemStack input, FluidTank first, FluidTank second, World world) { if(recipeInput.isItemEqual(input) && input.stackSize >= recipeInput.stackSize) { return true; } return false; } @Override public EnumRecipeType getRecipeType() { return EnumRecipeType.Sqeezing; } @Override public void runResult(ItemStack input, FluidTank first, FluidTank second, World world) { input.stackSize -= recipeInput.stackSize; } @Override public RecipeHardness getComplexity() { return RecipeHardness.Extrem_Easy; } }
<?php namespace Joomla\Component\Newsfeeds\Administrator\View\Newsfeeds; \defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Helper\ContentHelper; use Joomla\CMS\Language\Multilanguage; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\View\<API key>; use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Toolbar\ToolbarHelper; /** * View class for a list of newsfeeds. * * @since 1.6 */ class HtmlView extends BaseHtmlView { /** * The list of newsfeeds * * @var \JObject * @since 1.6 */ protected $items; /** * The pagination object * * @var \Joomla\CMS\Pagination\Pagination * @since 1.6 */ protected $pagination; /** * The model state * * @var \JObject * @since 1.6 */ protected $state; /** * Execute and display a template script. * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return mixed A string if successful, otherwise an Error object. * * @since 1.6 */ public function display($tpl = null) { $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); $this->filterForm = $this->get('FilterForm'); $this->activeFilters = $this->get('ActiveFilters'); // Check for errors. if (count($errors = $this->get('Errors'))) { throw new <API key>(implode("\n", $errors), 500); } // We don't need toolbar in the modal layout. if ($this->getLayout() !== 'modal') { $this->addToolbar(); // We do not need to filter by language when multilingual is disabled if (!Multilanguage::isEnabled()) { unset($this->activeFilters['language']); $this->filterForm->removeField('language', 'filter'); } } else { // In article associations modal we need to remove language filter if forcing a language. // We also need to change the category filter to show show categories with All or the forced language. if ($forcedLanguage = Factory::getApplication()->input->get('forcedLanguage', '', 'CMD')) { // If the language is forced we can't allow to select the language, so transform the language selector filter into a hidden field. $languageXml = new \SimpleXMLElement('<field name="language" type="hidden" default="' . $forcedLanguage . '" />'); $this->filterForm->setField($languageXml, 'filter', true); // Also, unset the active language filter so the search tools is not open by default with this filter. unset($this->activeFilters['language']); // One last changes needed is to change the category filter to just show categories with All language or with the forced language. $this->filterForm->setFieldAttribute('category_id', 'language', '*,' . $forcedLanguage, 'filter'); } } parent::display($tpl); } /** * Add the page title and toolbar. * * @return void * * @since 1.6 */ protected function addToolbar() { $state = $this->get('State'); $canDo = ContentHelper::getActions('com_newsfeeds', 'category', $state->get('filter.category_id')); $user = Factory::getUser(); // Get the toolbar object instance $toolbar = Toolbar::getInstance('toolbar'); ToolbarHelper::title(Text::_('<API key>'), 'rss newsfeeds'); if (count($user->get<API key>('com_newsfeeds', 'core.create')) > 0) { $toolbar->addNew('newsfeed.add'); } if ($canDo->get('core.edit.state') || $user->authorise('core.admin')) { $dropdown = $toolbar->dropdownButton('status-group') ->text('<API key>') ->toggleSplit(false) ->icon('fas fa-ellipsis-h') ->buttonClass('btn btn-action') ->listCheck(true); $childBar = $dropdown->getChildToolbar(); $childBar->publish('newsfeeds.publish')->listCheck(true); $childBar->unpublish('newsfeeds.unpublish')->listCheck(true); $childBar->archive('newsfeeds.archive')->listCheck(true); if ($user->authorise('core.admin')) { $childBar->checkin('newsfeeds.checkin')->listCheck(true); } if (!$this->state->get('filter.published') == -2) { $childBar->trash('newsfeeds.trash')->listCheck(true); } // Add a batch button if ($user->authorise('core.create', 'com_newsfeeds') && $user->authorise('core.edit', 'com_newsfeeds') && $user->authorise('core.edit.state', 'com_newsfeeds')) { $childBar->popupButton('batch') ->text('JTOOLBAR_BATCH') ->selector('collapseModal') ->listCheck(true); } if ($state->get('filter.published') == -2 && $canDo->get('core.delete')) { $childBar->delete('newsfeeds.delete') ->text('<API key>') ->message('<API key>') ->listCheck(true); } } if ($user->authorise('core.admin', 'com_newsfeeds') || $user->authorise('core.options', 'com_newsfeeds')) { $toolbar->preferences('com_newsfeeds'); } $toolbar->help('<API key>'); } }
<!DOCTYPE HTML PUBLIC "- <!-- NewPage --> <html lang="de"> <head> <!-- Generated by javadoc (1.8.0_25) on Sat Jan 02 14:50:50 CET 2016 --> <title>ra.woGibtEsWas Class Hierarchy</title> <meta name="date" content="2016-01-02"> <link rel="stylesheet" type="text/css" href="../../stylesheet.css" title="Style"> <script type="text/javascript" src="../../script.js"></script> </head> <body> <script type="text/javascript"><! try { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="ra.woGibtEsWas Class Hierarchy"; } } catch(err) { } </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <div class="topNav"><a name="navbar.top"> </a> <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> <a name="navbar.top.firstrow"> </a> <ul class="navList" title="Navigation"> <li><a href="../../overview-summary.html">Overview</a></li> <li><a href="package-summary.html">Package</a></li> <li>Class</li> <li class="navBarCell1Rev">Tree</li> <li><a href="../../index-files/index-1.html">Index</a></li> <li><a href="../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../ra/servlets/package-tree.html">Prev</a></li> <li>Next</li> </ul> <ul class="navList"> <li><a href="../../index.html?ra/woGibtEsWas/package-tree.html" target="_top">Frames</a></li> <li><a href="package-tree.html" target="_top">No&nbsp;Frames</a></li> </ul> <ul class="navList" id="<API key>"> <li><a href="../../allclasses-noframe.html">All&nbsp;Classes</a></li> </ul> <div> <script type="text/javascript"><! allClassesLink = document.getElementById("<API key>"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } </script> </div> <a name="skip.navbar.top"> </a></div> <div class="header"> <h1 class="title">Hierarchy For Package ra.woGibtEsWas</h1> <span class="<API key>">Package Hierarchies:</span> <ul class="horizontal"> <li><a href="../../overview-tree.html">All Packages</a></li> </ul> </div> <div class="contentContainer"> <h2 title="Class Hierarchy">Class Hierarchy</h2> <ul> <li type="circle">java.lang.Object <ul> <li type="circle">ra.woGibtEsWas.<a href="../../ra/woGibtEsWas/Abfragen.html" title="class in ra.woGibtEsWas"><span class="typeNameLink">Abfragen</span></a></li> </ul> </li> </ul> </div> <div class="bottomNav"><a name="navbar.bottom"> </a> <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> <a name="navbar.bottom.firstrow"> </a> <ul class="navList" title="Navigation"> <li><a href="../../overview-summary.html">Overview</a></li> <li><a href="package-summary.html">Package</a></li> <li>Class</li> <li class="navBarCell1Rev">Tree</li> <li><a href="../../index-files/index-1.html">Index</a></li> <li><a href="../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../ra/servlets/package-tree.html">Prev</a></li> <li>Next</li> </ul> <ul class="navList"> <li><a href="../../index.html?ra/woGibtEsWas/package-tree.html" target="_top">Frames</a></li> <li><a href="package-tree.html" target="_top">No&nbsp;Frames</a></li> </ul> <ul class="navList" id="<API key>"> <li><a href="../../allclasses-noframe.html">All&nbsp;Classes</a></li> </ul> <div> <script type="text/javascript"><! allClassesLink = document.getElementById("<API key>"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } </script> </div> <a name="skip.navbar.bottom"> </a></div> </body> </html>
#include <cxxtools/http/request.h> #include <cxxtools/http/reply.h> #include <cxxtools/http/responder.h> #include <cxxtools/arg.h> #include <cxxtools/jsonserializer.h> #include <cxxtools/serializationinfo.h> #include <cxxtools/utf8codec.h> #include <vdr/epg.h> #include <vdr/plugin.h> #include "tools.h" #include "epgsearch/services.h" #include "epgsearch.h" #include "events.h" #ifndef <API key> #define <API key> class <API key> : public cxxtools::http::Responder { public: explicit <API key>(cxxtools::http::Service& service) : cxxtools::http::Responder(service) { } virtual void reply(std::ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply); virtual void replyShow(std::ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply); virtual void replyCreate(std::ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply); virtual void replyDelete(std::ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply); virtual void replySearch(std::ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply); }; typedef cxxtools::http::CachedService<<API key>> SearchTimersService; class SearchTimerList : public BaseList { protected: StreamExtension *s; int total; public: SearchTimerList(std::ostream* _out); ~SearchTimerList(); virtual void init() { }; virtual void addSearchTimer(<API key> searchTimer) { }; virtual void finish() { }; virtual void setTotal(int _total) { total = _total; }; }; class HtmlSearchTimerList : public SearchTimerList { public: HtmlSearchTimerList(std::ostream* _out) : SearchTimerList(_out) { }; ~HtmlSearchTimerList() { }; virtual void init(); virtual void addSearchTimer(<API key> searchTimer); virtual void finish(); }; class JsonSearchTimerList : public SearchTimerList { private: std::vector< <API key> > _items; public: JsonSearchTimerList(std::ostream* _out) : SearchTimerList(_out) { }; ~JsonSearchTimerList() { }; virtual void init() { }; virtual void addSearchTimer(<API key> searchTimer); virtual void finish(); }; class XmlSearchTimerList : public SearchTimerList { public: XmlSearchTimerList(std::ostream* _out) : SearchTimerList(_out) { }; ~XmlSearchTimerList() { }; virtual void init(); virtual void addSearchTimer(<API key> searchTimer); virtual void finish(); }; #endif
<?php namespace Components\Members\Admin; if (!\User::authorise('core.manage', 'com_members')) { return \App::abort(403, \Lang::txt('<API key>')); } // Include scripts require_once dirname(__DIR__) . DS . 'models' . DS . 'member.php'; require_once dirname(__DIR__) . DS . 'helpers' . DS . 'admin.php'; $controllerName = \Request::getCmd('controller', 'members'); if (!file_exists(__DIR__ . DS . 'controllers' . DS . $controllerName . '.php')) { $controllerName = 'members'; } // Build sub-menu require_once __DIR__ . DS . 'helpers' . DS . 'members.php'; \MembersHelper::addSubmenu($controllerName); // Instantiate controller require_once __DIR__ . DS . 'controllers' . DS . $controllerName . '.php'; $controllerName = __NAMESPACE__ . '\\Controllers\\' . ucfirst($controllerName); $controller = new $controllerName(); $controller->execute();
<?php namespace Cachan\Bbst\Context; use Behat\Behat\Tester\Exception\PendingException; use Cachan\Bbst\TestType\HttpTestType; use Behat\Behat\Context\Context; use Behat\Behat\Context\<API key>; /** * Defines application Context from the specific context. */ class HttpContext implements Context, <API key> { /** @var HttpTestType */ private $httpType; public function __construct() { } /** * @Given I am in a web browser */ public function iAmInAWebBrowser() { $this->httpType = new HttpTestType(); $this->httpType->initialize(); } /** * @When I make an HTTP GET request to :arg1 */ public function <API key>($arg1) { $this->httpType->makeRequest('GET', $arg1); } /** * @Then I should be redirected to :arg1 */ public function <API key>($arg1) { if (!$this->httpType->isRedirectMatch($arg1)) { throw new \Exception("Expected $arg1 does not match " . $this->httpType->getResponse()->getEffectiveUrl()); } } /** * @Given I have an :type referer */ public function <API key>($type) { if ('internal' === $type) { $this->httpType->setInternalReferer(); } else if ('external' === $type) { $this->httpType->setExternalReferer(); } else { throw new \Exception("Unknown referer type $type."); } } /** * @Then I should see the text :text */ public function iShouldSeeTheText($text) { if (false === $this->httpType-><API key>($text)) { throw new \Exception("Expected text '$text' does not appear in the response'"); } } /** * @Then I should receive response code :statusCode */ public function <API key>($statusCode) { $actualCode = (int)$this->httpType->getStatusCode(); if ((int)$statusCode !== $actualCode) { throw new \Exception("Expected status code $statusCode does not match $actualCode."); } } /** * @Then I should receive a file with MIME type :contentType */ public function <API key>($contentType) { $actualType = $this->httpType->getContentType(); if ($contentType !== $actualType) { throw new \Exception("Expected Content-Type $contentType does not match $actualType"); } } }
PUMP_SELECTOR.CoordSlicer = function( parameters ) { var image = parameters.image; var coord = parameters.coord; var name = parameters.name; var obj = {}; if( image === undefined) { //PUMPER.debug("PUMPER::CoordSlicer() - Cannot slice image, image missing."); return undefined; }else if (coord === undefined) { //PUMPER.debug("PUMPER::CoordSlicer() - Warn: No coordinate data given. Returning image."); return obj[name] = obj; }else{ var coords = coord.split("\n"); coords.clean(""); for(var i=0;i<coords.length;i++) { var coordinate = coords[i].split(" "); obj[coordinate[0]] = PUMP_SELECTOR.CropImage(image,coordinate[1],coordinate[2],coordinate[3],coordinate[4]); } return obj; } };
package gof.structure.proxy; public class ProxySubject extends Subject { private RealSubject realSubject; public ProxySubject(){ } /* (non-Javadoc) * @see gof.structure.proxy.Subject#request() * * Subject subject = new ProxySubject(); * subject.request(); */ @Override public void request() { preRequest(); if(realSubject == null){ realSubject = new RealSubject(); } realSubject.request(); postRequest(); } private void preRequest(){ } private void postRequest(){ } }
#include <linux/module.h> #include <linux/kernel.h> #include <linux/delay.h> #include <linux/device.h> #include <linux/wait.h> #include <linux/interrupt.h> #include <linux/workqueue.h> #include <linux/delay.h> #include <linux/i2c.h> #include <linux/irq.h> #include <linux/io.h> #include <plat/gpio-cfg.h> #include <mach/regs-gpio.h> #include <mach/gpio.h> #include <plat/regs-hdmi.h> #include "../ddc.h" #include "tv_out_s5pv210.h" /* for Operation check */ #ifdef <API key> #define S5P_HDCP_DEBUG 1 #define S5P_HDCP_AUTH_DEBUG 1 #endif #ifdef S5P_HDCP_DEBUG #define HDCPPRINTK(fmt, args...) \ printk(KERN_INFO "\t\t[HDCP] %s: " fmt, __func__ , ## args) #else #define HDCPPRINTK(fmt, args...) #endif /* for authentication key check */ #ifdef S5P_HDCP_AUTH_DEBUG #define AUTHPRINTK(fmt, args...) \ printk("\t\t\t[AUTHKEY] %s: " fmt, __func__ , ## args) #else #define AUTHPRINTK(fmt, args...) #endif enum hdmi_run_mode { DVI_MODE = 0, HDMI_MODE }; enum hdmi_resolution { SD480P = 0, SD480I, WWSD480P, HD720P, SD576P, WWSD576P, HD1080I }; enum hdmi_color_bar_type { HORIZONTAL = 0, VERTICAL }; enum hdcp_event { /* Stop HDCP */ HDCP_EVENT_STOP = 0, /* Start HDCP*/ HDCP_EVENT_START, /* Start to read Bksv, Bcaps */ <API key>, /* Start to write Aksv, An */ <API key>, /* Start to check if Ri is equal to Rj */ <API key>, /* Start 2nd authentication process */ <API key> }; enum hdcp_state { NOT_AUTHENTICATED = 0, RECEIVER_READ_READY, BCAPS_READ_DONE, BKSV_READ_DONE, AN_WRITE_DONE, AKSV_WRITE_DONE, <API key>, <API key>, <API key>, <API key>, }; /* * Below CSC_TYPE is temporary. CSC_TYPE enum. * may be included in SetSD480pVars_60Hz etc. * * LR : Limited Range (16~235) * FR : Full Range (0~255) */ enum hdmi_intr_src { WAIT_FOR_ACTIVE_RX = 0, WDT_FOR_REPEATER, EXCHANGE_KSV, UPDATE_P_VAL, UPDATE_R_VAL, AUDIO_OVERFLOW, AUTHEN_ACK, UNKNOWN_INT }; struct s5p_hdcp_info { bool is_repeater; bool hpd_status; u32 time_out; u32 hdcp_enable; spinlock_t lock; spinlock_t reset_lock; struct i2c_client *client; wait_queue_head_t waitq; enum hdcp_event event; enum hdcp_state auth_status; struct work_struct work; }; static struct s5p_hdcp_info hdcp_info = { .is_repeater = false, .time_out = 0, .hdcp_enable = false, .client = NULL, .event = HDCP_EVENT_STOP, .auth_status = NOT_AUTHENTICATED, }; #define HDCP_RI_OFFSET 0x08 #define INFINITE 0xffffffff #define HDMI_SYS_ENABLE (1 << 0) #define HDMI_ASP_ENABLE (1 << 2) #define HDMI_ASP_DISABLE (~HDMI_ASP_ENABLE) #define MAX_DEVS_EXCEEDED (0x1 << 7) #define <API key> (0x1 << 3) #define <API key> (-1) #define <API key> (-2) #define <API key> (-3) #define <API key> (-4) #define AINFO_SIZE 1 #define BCAPS_SIZE 1 #define BSTATUS_SIZE 2 #define SHA_1_HASH_SIZE 20 #define KSV_FIFO_READY (0x1 << 5) /* spmoon for test : it's not in manual */ #define <API key> (0x1 << 3) #define <API key> (~<API key>) #define <API key> (0x1 << 2) #define <API key> (~<API key>) #define SET_HDCP_KSV_END (0x1 << 1) #define CLEAR_HDCP_KSV_END (~SET_HDCP_KSV_END) #define SET_HDCP_KSV_READ (0x1 << 0) #define CLEAR_HDCP_KSV_READ (~SET_HDCP_KSV_READ) #define <API key> (0x1 << 1) #define <API key> (~<API key>) #define SET_HDCP_SHA_VALID (0x1 << 0) #define <API key> (~SET_HDCP_SHA_VALID) #define <API key> (0x1 << 1) /* must be checked */ static bool g_sw_reset; static bool g_is_dvi; static bool g_av_mute; static bool g_audio_en; /* * 1st Authentication step func. * Write the Ainfo data to Rx */ static bool write_ainfo(void) { int ret = 0; u8 ainfo[2]; ainfo[0] = HDCP_Ainfo; ainfo[1] = 0; ret = ddc_write(ainfo, 2); if (ret < 0) { pr_err("%s::Can't write ainfo data through i2c bus\n", __func__); } return (ret < 0) ? false : true; } /* * Write the An data to Rx */ static bool write_an(void) { int ret = 0; u8 an[AN_SIZE+1]; an[0] = HDCP_An; an[1] = readb(g_hdmi_base + S5P_HDCP_An_0_0); an[2] = readb(g_hdmi_base + S5P_HDCP_An_0_1); an[3] = readb(g_hdmi_base + S5P_HDCP_An_0_2); an[4] = readb(g_hdmi_base + S5P_HDCP_An_0_3); an[5] = readb(g_hdmi_base + S5P_HDCP_An_1_0); an[6] = readb(g_hdmi_base + S5P_HDCP_An_1_1); an[7] = readb(g_hdmi_base + S5P_HDCP_An_1_2); an[8] = readb(g_hdmi_base + S5P_HDCP_An_1_3); ret = ddc_write(an, AN_SIZE + 1); if (ret < 0) { pr_err("%s::Can't write an data through i2c bus\n", __func__); } #ifdef S5P_HDCP_AUTH_DEBUG { u16 i = 0; for (i = 1; i < AN_SIZE + 1; i++) AUTHPRINTK("HDCPAn[%d]: 0x%x\n", i, an[i]); } #endif return (ret < 0) ? false : true; } /* * Write the Aksv data to Rx */ static bool write_aksv(void) { int ret = 0; u8 aksv[AKSV_SIZE+1]; aksv[0] = HDCP_Aksv; aksv[1] = readb(g_hdmi_base + S5P_HDCP_AKSV_0_0); aksv[2] = readb(g_hdmi_base + S5P_HDCP_AKSV_0_1); aksv[3] = readb(g_hdmi_base + S5P_HDCP_AKSV_0_2); aksv[4] = readb(g_hdmi_base + S5P_HDCP_AKSV_0_3); aksv[5] = readb(g_hdmi_base + S5P_HDCP_AKSV_1); if (aksv[1] == 0 && aksv[2] == 0 && aksv[3] == 0 && aksv[4] == 0 && aksv[5] == 0) return false; ret = ddc_write(aksv, AKSV_SIZE + 1); if (ret < 0) { pr_err("%s::Can't write aksv data through i2c bus\n", __func__); } #ifdef S5P_HDCP_AUTH_DEBUG { u16 i = 0; for (i = 1; i < AKSV_SIZE + 1; i++) AUTHPRINTK("HDCPAksv[%d]: 0x%x\n", i, aksv[i]); } #endif return (ret < 0) ? false : true; } static bool read_bcaps(void) { int ret = 0; u8 bcaps[BCAPS_SIZE] = {0}; ret = ddc_read(HDCP_Bcaps, bcaps, BCAPS_SIZE); if (ret < 0) { pr_err("%s::Can't read bcaps data from i2c bus\n", __func__); return false; } writel(bcaps[0], g_hdmi_base + S5P_HDCP_BCAPS); HDCPPRINTK("BCAPS(from i2c) : 0x%08x\n", bcaps[0]); if (bcaps[0] & REPEATER_SET) hdcp_info.is_repeater = true; else hdcp_info.is_repeater = false; HDCPPRINTK("attached device type : %s !!\n", hdcp_info.is_repeater ? "REPEATER" : "SINK"); HDCPPRINTK("BCAPS(from sfr) = 0x%08x\n", readl(g_hdmi_base + S5P_HDCP_BCAPS)); return true; } static bool read_again_bksv(void) { u8 bk_sv[BKSV_SIZE] = {0, 0, 0, 0, 0}; u8 i = 0; u8 j = 0; u32 no_one = 0; u32 no_zero = 0; u32 result = 0; int ret = 0; ret = ddc_read(HDCP_Bksv, bk_sv, BKSV_SIZE); if (ret < 0) { pr_err("%s::Can't read bk_sv data from i2c bus\n", __func__); return false; } #ifdef S5P_HDCP_AUTH_DEBUG for (i = 0; i < BKSV_SIZE; i++) AUTHPRINTK("i2c read : Bksv[%d]: 0x%x\n", i, bk_sv[i]); #endif for (i = 0; i < BKSV_SIZE; i++) { for (j = 0; j < 8; j++) { result = bk_sv[i] & (0x1 << j); if (result == 0) no_zero += 1; else no_one += 1; } } if ((no_zero == 20) && (no_one == 20)) { HDCPPRINTK("Suucess: no_zero, and no_one is 20\n"); writel(bk_sv[0], g_hdmi_base + S5P_HDCP_BKSV_0_0); writel(bk_sv[1], g_hdmi_base + S5P_HDCP_BKSV_0_1); writel(bk_sv[2], g_hdmi_base + S5P_HDCP_BKSV_0_2); writel(bk_sv[3], g_hdmi_base + S5P_HDCP_BKSV_0_3); writel(bk_sv[4], g_hdmi_base + S5P_HDCP_BKSV_1); #ifdef S5P_HDCP_AUTH_DEBUG for (i = 0; i < BKSV_SIZE; i++) AUTHPRINTK("set reg : Bksv[%d]: 0x%x\n", i, bk_sv[i]); /* writel(HDCP_ENC_ENABLE, g_hdmi_base + S5P_ENC_EN); */ #endif return true; } else { pr_err("%s::no_zero or no_one is NOT 20\n", __func__); return false; } } static bool read_bksv(void) { u8 bk_sv[BKSV_SIZE] = {0, 0, 0, 0, 0}; int i = 0; int j = 0; u32 no_one = 0; u32 no_zero = 0; u32 result = 0; u32 count = 0; int ret = 0; ret = ddc_read(HDCP_Bksv, bk_sv, BKSV_SIZE); if (ret < 0) { pr_err("%s::Can't read bk_sv data from i2c bus\n", __func__); return false; } #ifdef S5P_HDCP_AUTH_DEBUG for (i = 0; i < BKSV_SIZE; i++) AUTHPRINTK("i2c read : Bksv[%d]: 0x%x\n", i, bk_sv[i]); #endif for (i = 0; i < BKSV_SIZE; i++) { for (j = 0; j < 8; j++) { result = bk_sv[i] & (0x1 << j); if (result == 0) no_zero++; else no_one++; } } if ((no_zero == 20) && (no_one == 20)) { writel(bk_sv[0], g_hdmi_base + S5P_HDCP_BKSV_0_0); writel(bk_sv[1], g_hdmi_base + S5P_HDCP_BKSV_0_1); writel(bk_sv[2], g_hdmi_base + S5P_HDCP_BKSV_0_2); writel(bk_sv[3], g_hdmi_base + S5P_HDCP_BKSV_0_3); writel(bk_sv[4], g_hdmi_base + S5P_HDCP_BKSV_1); #ifdef S5P_HDCP_AUTH_DEBUG for (i = 0; i < BKSV_SIZE; i++) AUTHPRINTK("set reg : Bksv[%d]: 0x%x\n", i, bk_sv[i]); #endif HDCPPRINTK("Success: no_zero, and no_one is 20\n"); } else { HDCPPRINTK("Failed: no_zero or no_one is NOT 20\n"); while (!read_again_bksv()) { count++; mdelay(200); if (count == 14) return false; } } return true; } /* * Compare the R value of Tx with that of Rx */ static bool compare_r_val(void) { int ret = 0; u8 ri[2] = {0, 0}; u8 rj[2] = {0, 0}; u16 i; for (i = 0; i < R_VAL_RETRY_CNT; i++) { if (hdcp_info.auth_status < AKSV_WRITE_DONE) { ret = false; break; } /* Read R value from Tx */ ri[0] = readl(g_hdmi_base + S5P_HDCP_Ri_0); ri[1] = readl(g_hdmi_base + S5P_HDCP_Ri_1); /* Read R value from Rx */ ret = ddc_read(HDCP_Ri, rj, 2); if (ret < 0) { pr_err("%s::Can't read r data from i2c bus\n", __func__); return false; } #ifdef S5P_HDCP_AUTH_DEBUG AUTHPRINTK("retries :: %d\n", i); printk("\t\t\t Rx(ddc)\t ->"); printk("rj[0]: 0x%02x, rj[1]: 0x%02x\n", rj[0], rj[1]); printk("\t\t\t Tx(register)\t ->"); printk("ri[0]: 0x%02x, ri[1]: 0x%02x\n", ri[0], ri[1]); #endif /* Compare R value */ if ((ri[0] == rj[0]) && (ri[1] == rj[1]) && (ri[0] | ri[1])) { writel(<API key>, g_hdmi_base + <API key>); HDCPPRINTK("R0, R0' is matched!!\n"); /* for simplay test */ mdelay(1); ret = true; break; } else { writel(Ri_MATCH_RESULT__NO, g_hdmi_base + <API key>); HDCPPRINTK("R0, R0' is not matched!!\n"); ret = false; } ri[0] = 0; ri[1] = 0; rj[0] = 0; rj[1] = 0; } if (!ret) { hdcp_info.event = HDCP_EVENT_STOP; hdcp_info.auth_status = NOT_AUTHENTICATED; } return ret ? true : false; } /* * Enable/Disable Software HPD control */ static void sw_hpd_enable(bool enable) { u8 reg; reg = readb(g_hdmi_base + S5P_HPD); reg &= ~HPD_SW_ENABLE; if (enable) writeb(reg | HPD_SW_ENABLE, g_hdmi_base + S5P_HPD); else writeb(reg, g_hdmi_base + S5P_HPD); } /* * Set Software HPD level * * @param level [in] if 0 - low;othewise, high */ static void set_sw_hpd(bool level) { u8 reg; reg = readb(g_hdmi_base + S5P_HPD); reg &= ~HPD_ON; if (level) writeb(reg | HPD_ON, g_hdmi_base + S5P_HPD); else writeb(reg, g_hdmi_base + S5P_HPD); } /* * Reset Authentication */ static void <API key>(void) { u8 reg; spin_lock_irq(&hdcp_info.reset_lock); hdcp_info.time_out = INFINITE; hdcp_info.event = HDCP_EVENT_STOP; hdcp_info.auth_status = NOT_AUTHENTICATED; /* Disable hdcp */ writeb(0x0, g_hdmi_base + S5P_HDCP_CTRL1); writeb(0x0, g_hdmi_base + S5P_HDCP_CTRL2); s5p_hdmi_mute_en(true); /* Disable encryption */ HDCPPRINTK("Stop Encryption by reset!!\n"); writeb(HDCP_ENC_DIS, g_hdmi_base + S5P_ENC_EN); HDCPPRINTK("Now reset authentication\n"); /* disable hdmi status enable reg. */ reg = readb(g_hdmi_base + S5P_STATUS_EN); reg &= HDCP_STATUS_DIS_ALL; writeb(reg, g_hdmi_base + S5P_STATUS_EN); /* clear all result */ writeb(CLEAR_ALL_RESULTS, g_hdmi_base + <API key>); /* * 1. Mask HPD plug and unplug interrupt * disable HPD INT */ g_sw_reset = true; reg = <API key>(); <API key>(HDMI_IRQ_HPD_PLUG); <API key>(HDMI_IRQ_HPD_UNPLUG); /* for simplay test */ mdelay(50); /* 2. Enable software HPD */ sw_hpd_enable(true); /* 3. Make software HPD logical 0 */ set_sw_hpd(false); /* 4. Make software HPD logical 1 */ set_sw_hpd(true); /* 5. Disable software HPD */ sw_hpd_enable(false); /* 6. Unmask HPD plug and unplug interrupt */ if (reg & 1<<HDMI_IRQ_HPD_PLUG) <API key>(HDMI_IRQ_HPD_PLUG); if (reg & 1<<HDMI_IRQ_HPD_UNPLUG) <API key>(HDMI_IRQ_HPD_UNPLUG); g_sw_reset = false; /* clear result */ #if 0 writel(Ri_MATCH_RESULT__NO, g_hdmi_base + <API key>); writel(readl(g_hdmi_base + S5P_HDMI_CON_0) & HDMI_DIS, g_hdmi_base + S5P_HDMI_CON_0); writel(readl(g_hdmi_base + S5P_HDMI_CON_0) | HDMI_EN, g_hdmi_base + S5P_HDMI_CON_0); #endif writel(CLEAR_ALL_RESULTS, g_hdmi_base + <API key>); /* set hdcp_int enable */ reg = readb(g_hdmi_base + S5P_STATUS_EN); reg |= <API key> | <API key> | <API key> | <API key>; writeb(reg, g_hdmi_base + S5P_STATUS_EN); /* HDCP Enable */ writeb(CP_DESIRED_EN, g_hdmi_base + S5P_HDCP_CTRL1); spin_unlock_irq(&hdcp_info.reset_lock); } /* * Set the timing parameter for load e-fuse key. */ /* TODO: must use clk_get for pclk rate */ #define <API key> 166000000 static u32 efuse_ceil(u32 val, u32 time) { u32 res; res = val / time; if (val % time) res += 1; return res; } #if 0 static void hdcp_efuse_timing(void) { u32 time, val; /* TODO: must use clk_get for pclk rate */ time = 1000000000/<API key>; val = efuse_ceil(EFUSE_ADDR_WIDTH, time); writeb(val, g_hdmi_base + <API key>); val = efuse_ceil(EFUSE_SIGDEV_ASSERT, time); writeb(val, g_hdmi_base + <API key>); val = efuse_ceil(<API key>, time); writeb(val, g_hdmi_base + <API key>); val = efuse_ceil(EFUSE_PRCHG_ASSERT, time); writeb(val, g_hdmi_base + <API key>); val = efuse_ceil(<API key>, time); writeb(val, g_hdmi_base + <API key>); val = efuse_ceil(EFUSE_FSET_ASSERT, time); writeb(val, g_hdmi_base + <API key>); val = efuse_ceil(EFUSE_FSET_DEASSERT, time); writeb(val, g_hdmi_base + <API key>); val = efuse_ceil(EFUSE_SENSING, time); writeb(val, g_hdmi_base + S5P_EFUSE_SENSING); val = efuse_ceil(EFUSE_SCK_ASSERT, time); writeb(val, g_hdmi_base + <API key>); val = efuse_ceil(EFUSE_SCK_DEASSERT, time); writeb(val, g_hdmi_base + <API key>); val = efuse_ceil(EFUSE_SDOUT_OFFSET, time); writeb(val, g_hdmi_base + <API key>); val = efuse_ceil(EFUSE_READ_OFFSET, time); writeb(val, g_hdmi_base + <API key>); } #endif /* * load hdcp key from e-fuse mem. */ static int hdcp_loadkey(void) { u8 status; int time_out = HDMI_TIME_OUT; #if 0 hdcp_efuse_timing(); #endif /* read HDCP key from E-Fuse */ writeb(EFUSE_CTRL_ACTIVATE, g_hdmi_base + S5P_EFUSE_CTRL); do { status = readb(g_hdmi_base + S5P_EFUSE_STATUS); time_out } while (!(status & EFUSE_ECC_DONE) && time_out); if (readb(g_hdmi_base + S5P_EFUSE_STATUS) & EFUSE_ECC_FAIL) { pr_err("%s::Can't load key from fuse ctrl.\n", __func__); return -EINVAL; } else { HDCPPRINTK("%s::readb S5P_EFUSE_STATUS for EFUSE_ECC_FAIL: 0\n", __func__); } return 0; } /* * Start encryption */ static void start_encryption(void) { int time_out = HDMI_TIME_OUT; if (readl(g_hdmi_base + <API key>) == <API key>) { do { if (readl(g_hdmi_base + S5P_STATUS) & AUTHENTICATED) { writel(HDCP_ENC_ENABLE, g_hdmi_base + S5P_ENC_EN); HDCPPRINTK("Encryption start!!\n"); s5p_hdmi_mute_en(false); break; } else { time_out mdelay(1); } } while (time_out); if (time_out <= 0) pr_err("%s::readl S5P_STATUS for AUTHENTICATED fail!!\n", __func__); } else { writel(HDCP_ENC_DISABLE, g_hdmi_base + S5P_ENC_EN); s5p_hdmi_mute_en(true); HDCPPRINTK("Encryption stop!!\n"); } } /* * Check whether Rx is repeater or not */ static int check_repeater(void) { int ret = 0; u8 i = 0; u16 j = 0; u8 bcaps[BCAPS_SIZE] = {0}; u8 status[BSTATUS_SIZE] = {0, 0}; u8 rx_v[SHA_1_HASH_SIZE] = {0}; u8 ksv_list[HDCP_MAX_DEVS*HDCP_KSV_SIZE] = {0}; u32 dev_cnt; u32 stat; bool ksv_fifo_ready = false; memset(rx_v, 0x0, SHA_1_HASH_SIZE); memset(ksv_list, 0x0, HDCP_MAX_DEVS * HDCP_KSV_SIZE); while (j <= 50) { ret = ddc_read(HDCP_Bcaps, bcaps, BCAPS_SIZE); if (ret < 0) { pr_err("%s::Can't read bcaps data from i2c bus\n", __func__); return false; } if (bcaps[0] & KSV_FIFO_READY) { HDCPPRINTK("ksv fifo is ready\n"); ksv_fifo_ready = true; writel(bcaps[0], g_hdmi_base + S5P_HDCP_BCAPS); break; } else { HDCPPRINTK("ksv fifo is not ready\n"); ksv_fifo_ready = false; mdelay(100); j++; } bcaps[0] = 0; } if (!ksv_fifo_ready) return <API key>; /* * Check <API key> * or MAX_DEVS_EXCEEDED indicator */ ret = ddc_read(HDCP_BStatus, status, BSTATUS_SIZE); if (ret < 0) { pr_err("%s::Can't read status data from i2c bus\n", __func__); return false; } /* <API key> || MAX_DEVS_EXCEEDED */ if (status[1] & <API key>) { HDCPPRINTK("<API key>\n"); return <API key>; } else if (status[0] & MAX_DEVS_EXCEEDED) { HDCPPRINTK("<API key>\n"); return <API key>; } writel(status[0], g_hdmi_base + S5P_HDCP_BSTATUS_0); writel(status[1], g_hdmi_base + S5P_HDCP_BSTATUS_1); /* Read KSV list */ dev_cnt = status[0] & 0x7f; HDCPPRINTK("status[0] :0x%08x, status[1] :0x%08x!!\n", status[0], status[1]); if (dev_cnt) { u32 val = 0; /* read ksv */ ret = ddc_read(HDCP_KSVFIFO, ksv_list, dev_cnt * HDCP_KSV_SIZE); if (ret < 0) { pr_err("%s::Can't read ksv fifo!!\n", __func__); return false; } /* write ksv */ for (i = 0; i < dev_cnt - 1; i++) { writel(ksv_list[(i*5) + 0], g_hdmi_base + S5P_HDCP_RX_KSV_0_0); writel(ksv_list[(i*5) + 1], g_hdmi_base + S5P_HDCP_RX_KSV_0_1); writel(ksv_list[(i*5) + 2], g_hdmi_base + S5P_HDCP_RX_KSV_0_2); writel(ksv_list[(i*5) + 3], g_hdmi_base + S5P_HDCP_RX_KSV_0_3); writel(ksv_list[(i*5) + 4], g_hdmi_base + S5P_HDCP_RX_KSV_0_4); mdelay(1); writel(<API key>, g_hdmi_base + <API key>); mdelay(1); stat = readl(g_hdmi_base + <API key>); if (!(stat & SET_HDCP_KSV_READ)) return false; HDCPPRINTK("HDCP_RX_KSV_1 = 0x%x\n", readl(g_hdmi_base + <API key>)); HDCPPRINTK("i : %d, dev_cnt : %d, val = 0x%08x\n", i, dev_cnt, val); } writel(ksv_list[(i*5) + 0], g_hdmi_base + S5P_HDCP_RX_KSV_0_0); writel(ksv_list[(i*5) + 1], g_hdmi_base + S5P_HDCP_RX_KSV_0_1); writel(ksv_list[(i*5) + 2], g_hdmi_base + S5P_HDCP_RX_KSV_0_2); writel(ksv_list[(i*5) + 3], g_hdmi_base + S5P_HDCP_RX_KSV_0_3); writel(ksv_list[(i*5) + 4], g_hdmi_base + S5P_HDCP_RX_KSV_0_4); mdelay(1); /* end of ksv */ val = SET_HDCP_KSV_END|<API key>; writel(val, g_hdmi_base + <API key>); HDCPPRINTK("HDCP_RX_KSV_1 = 0x%x\n", readl(g_hdmi_base + <API key>)); HDCPPRINTK("i : %d, dev_cnt : %d, val = 0x%08x\n", i, dev_cnt, val); } else { /* mdelay(200); */ writel(<API key>, g_hdmi_base + <API key>); } /* Read SHA-1 from receiver */ ret = ddc_read(HDCP_SHA1, rx_v, SHA_1_HASH_SIZE); if (ret < 0) { pr_err("%s::Can't read sha_1_hash data from i2c bus\n", __func__); return false; } #ifdef S5P_HDCP_DEBUG for (i = 0; i < SHA_1_HASH_SIZE; i++) HDCPPRINTK("SHA_1 rx :: %x\n", rx_v[i]); #endif /* write SHA-1 to register */ writeb(rx_v[0], g_hdmi_base + <API key>); writeb(rx_v[1], g_hdmi_base + <API key>); writeb(rx_v[2], g_hdmi_base + <API key>); writeb(rx_v[3], g_hdmi_base + <API key>); writeb(rx_v[4], g_hdmi_base + <API key>); writeb(rx_v[5], g_hdmi_base + <API key>); writeb(rx_v[6], g_hdmi_base + <API key>); writeb(rx_v[7], g_hdmi_base + <API key>); writeb(rx_v[8], g_hdmi_base + <API key>); writeb(rx_v[9], g_hdmi_base + <API key>); writeb(rx_v[10], g_hdmi_base + <API key>); writeb(rx_v[11], g_hdmi_base + <API key>); writeb(rx_v[12], g_hdmi_base + <API key>); writeb(rx_v[13], g_hdmi_base + <API key>); writeb(rx_v[14], g_hdmi_base + <API key>); writeb(rx_v[15], g_hdmi_base + <API key>); writeb(rx_v[16], g_hdmi_base + <API key>); writeb(rx_v[17], g_hdmi_base + <API key>); writeb(rx_v[18], g_hdmi_base + <API key>); writeb(rx_v[19], g_hdmi_base + <API key>); /* SHA write done, and wait for SHA computation being done */ mdelay(1); /* check authentication success or not */ stat = readb(g_hdmi_base + <API key>); HDCPPRINTK("auth status %d\n", stat); if (stat & <API key>) { stat = readb(g_hdmi_base + <API key>); if (stat & SET_HDCP_SHA_VALID) ret = true; else ret = false; } else { pr_err("%s::SHA not ready 0x%x\n", __func__, stat); ret = false; } /* clear all validate bit */ writeb(0x0, g_hdmi_base + <API key>); return ret; } static bool try_read_receiver(void) { u16 i = 0; bool ret = false; s5p_hdmi_mute_en(true); for (i = 0; i < 400; i++) { msleep(250); if (hdcp_info.auth_status != RECEIVER_READ_READY) { pr_err("%s::hdcp stat. changed!!\ failed attempt no = %d\n", __func__, i); return false; } ret = read_bcaps(); if (ret) { HDCPPRINTK("succeeded at attempt no= %d\n", i); return true; } else pr_err("%s::can't read bcaps!! \ failed attempt no=%d\n", __func__, i); } return false; } static void s5p_hdcp_reset(void) { s5p_stop_hdcp(); <API key> = 2; HDCPPRINTK("HDCP ftn. reset!!\n"); } static void bksv_start_bh(void) { bool ret = false; HDCPPRINTK("<API key> bh\n"); hdcp_info.auth_status = RECEIVER_READ_READY; ret = read_bcaps(); if (!ret) { ret = try_read_receiver(); if (!ret) { pr_err("%s::Can't read bcaps!! retry failed!!\ hdcp ftn. will be stopped\n", __func__); <API key>(); return; } } hdcp_info.auth_status = BCAPS_READ_DONE; ret = read_bksv(); if (!ret) { pr_err("%s::Can't read bksv!!\ hdcp ftn. will be reset\n", __func__); <API key>(); return; } hdcp_info.auth_status = BKSV_READ_DONE; HDCPPRINTK("authentication status : bksv is done (0x%08x)\n", hdcp_info.auth_status); } static void <API key>(void) { u8 count = 0; int reg; bool ret = false; int ret_err; u32 bcaps; HDCPPRINTK("<API key> bh\n"); ret = read_bcaps(); if (!ret) { ret = try_read_receiver(); if (!ret) { pr_err("%s::Can't read bcaps!! retry failed!!\ hdcp ftn. will be stopped\n", __func__); <API key>(); return; } } bcaps = readl(g_hdmi_base + S5P_HDCP_BCAPS); bcaps &= (KSV_FIFO_READY); if (!bcaps) { HDCPPRINTK("ksv fifo is not ready\n"); do { count++; ret = read_bcaps(); if (!ret) { ret = try_read_receiver(); if (!ret) <API key>(); return; } bcaps = readl(g_hdmi_base + S5P_HDCP_BCAPS); bcaps &= (KSV_FIFO_READY); if (bcaps) { HDCPPRINTK("bcaps retries : %d\n", count); break; } mdelay(100); if (!hdcp_info.hdcp_enable) { <API key>(); return; } } while (count <= 50); /* wait times exceeded 5 seconds */ if (count > 50) { hdcp_info.time_out = INFINITE; /* * time-out (This bit is only available in a REPEATER) */ writel(readl(g_hdmi_base + S5P_HDCP_CTRL1) | 0x1 << 2, g_hdmi_base + S5P_HDCP_CTRL1); <API key>(); return; } } HDCPPRINTK("ksv fifo ready\n"); ret_err = check_repeater(); if (ret_err == true) { u32 flag; hdcp_info.auth_status = <API key>; HDCPPRINTK("second authentication done!!\n"); flag = readb(g_hdmi_base + S5P_STATUS); HDCPPRINTK("hdcp state : %s authenticated!!\n", flag & AUTHENTICATED ? "" : "not not"); start_encryption(); } else if (ret_err == false) { /* i2c error */ pr_err("%s::repeater check error!!\n", __func__); <API key>(); } else { if (ret_err == <API key>) { /* * No need to start the HDCP * in case of invalid KSV (revocation case) */ pr_err("%s::illegal dev. error!!\n", __func__); reg = readl(g_hdmi_base + S5P_HDCP_CTRL2); reg = 0x1; writel(reg, g_hdmi_base + S5P_HDCP_CTRL2); reg = 0x0; writel(reg, g_hdmi_base + S5P_HDCP_CTRL2); hdcp_info.auth_status = NOT_AUTHENTICATED; } else if (ret_err == <API key>) { reg = readl(g_hdmi_base + S5P_HDCP_CTRL1); reg |= <API key>; writel(reg, g_hdmi_base + S5P_HDCP_CTRL1); reg &= ~<API key>; writel(reg, g_hdmi_base + S5P_HDCP_CTRL1); hdcp_info.auth_status = NOT_AUTHENTICATED; } else { /* * <API key> * <API key> */ pr_err("%s::repeater check error(MAX_EXCEEDED)!!\n", __func__); <API key>(); } } } static bool write_aksv_start_bh(void) { bool ret = false; HDCPPRINTK("<API key> bh\n"); if (hdcp_info.auth_status != BKSV_READ_DONE) { pr_err("%s::bksv is not ready!!\n", __func__); return false; } ret = write_an(); if (!ret) return false; hdcp_info.auth_status = AN_WRITE_DONE; HDCPPRINTK("an write done!!\n"); ret = write_aksv(); if (!ret) return false; /* * Wait for 100ms. Transmitter must not read * Ro' value sooner than 100ms after writing * Aksv */ mdelay(100); hdcp_info.auth_status = AKSV_WRITE_DONE; HDCPPRINTK("aksv write done!!\n"); return ret; } static bool check_ri_start_bh(void) { bool ret = false; HDCPPRINTK("<API key> bh\n"); if (hdcp_info.auth_status == AKSV_WRITE_DONE || hdcp_info.auth_status == <API key> || hdcp_info.auth_status == <API key>) { ret = compare_r_val(); if (ret) { if (hdcp_info.auth_status == AKSV_WRITE_DONE) { /* * Check whether HDMI receiver is * repeater or not */ if (hdcp_info.is_repeater) hdcp_info.auth_status = <API key>; else { hdcp_info.auth_status = <API key>; start_encryption(); } } } else { HDCPPRINTK("authentication reset\n"); <API key>(); } HDCPPRINTK("auth_status = 0x%08x\n", hdcp_info.auth_status); return true; } else <API key>(); HDCPPRINTK("aksv_write or first/second" " authentication is not done\n"); return false; } /* * bottom half for hdmi interrupt * */ static void hdcp_work(void *arg) { /* HDCPPRINTK("event : 0x%08x\n", hdcp_info.event); */ /* * I2C int. was occurred * for reading Bksv and Bcaps */ if (hdcp_info.event & (1 << <API key>)) { bksv_start_bh(); /* clear event */ /* spin_lock_bh(&hdcp_info.lock); */ hdcp_info.event &= ~(1 << <API key>); /* spin_unlock_bh(&hdcp_info.lock); */ } /* * Watchdog timer int. was occurred * for checking repeater */ if (hdcp_info.event & (1 << <API key>)) { <API key>(); /* clear event */ /* spin_lock_bh(&hdcp_info.lock); */ hdcp_info.event &= ~(1 << <API key>); /* spin_unlock_bh(&hdcp_info.lock); */ } /* * An_Write int. was occurred * for writing Ainfo, An and Aksv */ if (hdcp_info.event & (1 << <API key>)) { write_aksv_start_bh(); /* clear event */ /* spin_lock_bh(&hdcp_info.lock); */ hdcp_info.event &= ~(1 << <API key>); /* spin_unlock_bh(&hdcp_info.lock); */ } /* * Ri int. was occurred * for comparing Ri and Ri'(from HDMI sink) */ if (hdcp_info.event & (1 << <API key>)) { check_ri_start_bh(); /* clear event */ /* spin_lock_bh(&hdcp_info.lock); */ hdcp_info.event &= ~(1 << <API key>); /* spin_unlock_bh(&hdcp_info.lock); */ } } irqreturn_t <API key>(int irq, void *dev_id) { u32 event = 0; u8 flag; unsigned long spin_flags; event = 0; /* check HDCP Status */ flag = readb(g_hdmi_base + S5P_STATUS); HDCPPRINTK("irq_status : 0x%08x\n", readb(g_hdmi_base + S5P_STATUS)); HDCPPRINTK("hdcp state : %s authenticated!!\n", flag & AUTHENTICATED ? "" : "not"); spin_lock_irqsave(&hdcp_info.lock, spin_flags); /* * processing interrupt * interrupt processing seq. is firstly set event for workqueue, * and interrupt pending clear. 'flag|' was used for preventing * to clear AUTHEN_ACK.- it caused many problem. be careful. */ /* I2C INT */ if (flag & <API key>) { event |= (1 << <API key>); writeb(flag | <API key>, g_hdmi_base + S5P_STATUS); writeb(0x0, g_hdmi_base + S5P_HDCP_I2C_INT); } /* AN INT */ if (flag & <API key>) { event |= (1 << <API key>); writeb(flag | <API key>, g_hdmi_base + S5P_STATUS); writeb(0x0, g_hdmi_base + S5P_HDCP_AN_INT); } /* RI INT */ if (flag & <API key>) { event |= (1 << <API key>); writeb(flag | <API key>, g_hdmi_base + S5P_STATUS); writeb(0x0, g_hdmi_base + S5P_HDCP_RI_INT); } /* WATCHDOG INT */ if (flag & <API key>) { event |= (1 << <API key>); writeb(flag | <API key>, g_hdmi_base + S5P_STATUS); writeb(0x0, g_hdmi_base + S5P_HDCP_WDT_INT); } if (!event) { pr_err("%s::unknown irq.\n", __func__); <API key>(&hdcp_info.lock, spin_flags); return IRQ_HANDLED; } hdcp_info.event |= event; schedule_work(&hdcp_info.work); <API key>(&hdcp_info.lock, spin_flags); return IRQ_HANDLED; } static int s5p_hdcp_is_reset(void) { int ret = 0; if (spin_is_locked(&hdcp_info.reset_lock)) return 1; return ret; } static bool <API key>(bool detection, bool hdcp_enabled, struct i2c_client *client) { u32 hpd_reg_val = 0; if (detection) hpd_reg_val = CABLE_PLUGGED; else hpd_reg_val = CABLE_UNPLUGGED; writel(hpd_reg_val, g_hdmi_base + S5P_HPD); HDCPPRINTK("HPD status :: 0x%08x\n", readl(g_hdmi_base + S5P_HPD)); return true; } int s5p_hdcp_init(void) { HDCPPRINTK("HDCP ftn. Init!!\n"); g_is_dvi = false; g_av_mute = false; g_audio_en = true; /* for bh */ INIT_WORK(&hdcp_info.work, (work_func_t)hdcp_work); init_waitqueue_head(&hdcp_info.waitq); /* for dev_dbg err. */ spin_lock_init(&hdcp_info.lock); spin_lock_init(&hdcp_info.reset_lock); <API key>((hdmi_isr)<API key>, (u8)HDMI_IRQ_HDCP); return 0; } /* * start - start functions are only called under stopping HDCP */ bool s5p_start_hdcp(void) { u8 reg; u32 sfr_val; hdcp_info.event = HDCP_EVENT_STOP; hdcp_info.time_out = INFINITE; hdcp_info.auth_status = NOT_AUTHENTICATED; HDCPPRINTK("HDCP ftn. Start!!\n"); g_sw_reset = true; reg = <API key>(); <API key>(HDMI_IRQ_HPD_PLUG); <API key>(HDMI_IRQ_HPD_UNPLUG); /* 2. Enable software HPD */ sw_hpd_enable(true); /* 3. Make software HPD logical */ set_sw_hpd(false); /* 4. Make software HPD logical */ set_sw_hpd(true); /* 5. Disable software HPD */ sw_hpd_enable(false); set_sw_hpd(false); /* 6. Unmask HPD plug and unplug interrupt */ if (reg & 1<<HDMI_IRQ_HPD_PLUG) <API key>(HDMI_IRQ_HPD_PLUG); if (reg & 1<<HDMI_IRQ_HPD_UNPLUG) <API key>(HDMI_IRQ_HPD_UNPLUG); g_sw_reset = false; HDCPPRINTK("Stop Encryption by Start!!\n"); writel(HDCP_ENC_DISABLE, g_hdmi_base + S5P_ENC_EN); s5p_hdmi_mute_en(true); <API key> = 1; if (hdcp_loadkey() < 0) return false; /* for av mute */ writel(DO_NOT_TRANSMIT, g_hdmi_base + S5P_GCP_CON); /* * 1-1. set hdmi status enable reg. * Update_Ri_int_en should be enabled after * s/w gets ExchangeKSV_int. */ writel(HDCP_STATUS_EN_ALL, g_hdmi_base + S5P_STATUS_EN); /* * 3. set hdcp control reg. * Disable advance cipher option, Enable CP(Content Protection), * Disable time-out (This bit is only available in a REPEATER) * Disable XOR shift, Disable Pj port update, Use external key */ sfr_val = 0; sfr_val |= CP_DESIRED_EN; writel(sfr_val, g_hdmi_base + S5P_HDCP_CTRL1); <API key>(HDMI_IRQ_HDCP); if (!read_bcaps()) { pr_err("%s::can't read ddc port!\n", __func__); <API key>(); } hdcp_info.hdcp_enable = true; HDCPPRINTK("\tSTATUS \t0x%08x\n", readl(g_hdmi_base + S5P_STATUS)); HDCPPRINTK("\tSTATUS_EN \t0x%08x\n", readl(g_hdmi_base + S5P_STATUS_EN)); HDCPPRINTK("\tHPD \t0x%08x\n", readl(g_hdmi_base + S5P_HPD)); HDCPPRINTK("\tHDCP_CTRL \t0x%08x\n", readl(g_hdmi_base + S5P_HDCP_CTRL1)); HDCPPRINTK("\tMODE_SEL \t0x%08x\n", readl(g_hdmi_base + S5P_MODE_SEL)); HDCPPRINTK("\tENC_EN \t0x%08x\n", readl(g_hdmi_base + S5P_ENC_EN)); HDCPPRINTK("\tHDMI_CON_0 \t0x%08x\n", readl(g_hdmi_base + S5P_HDMI_CON_0)); return true; } /* * stop - stop functions are only called under running HDCP */ bool s5p_stop_hdcp(void) { u32 sfr_val = 0; HDCPPRINTK("HDCP ftn. Stop!!\n"); /* <API key>(HDMI_IRQ_HPD_PLUG); <API key>(HDMI_IRQ_HPD_UNPLUG); */ <API key>(HDMI_IRQ_HDCP); <API key> = 0; hdcp_info.time_out = INFINITE; hdcp_info.event = HDCP_EVENT_STOP; hdcp_info.auth_status = NOT_AUTHENTICATED; hdcp_info.hdcp_enable = false; /* hdcp_info.client = NULL; */ /* 3. disable hdcp control reg. */ sfr_val = readl(g_hdmi_base + S5P_HDCP_CTRL1); sfr_val &= (<API key> & <API key> & EN_PJ_DIS & CP_DESIRED_DIS); writel(sfr_val, g_hdmi_base + S5P_HDCP_CTRL1); /* 1-3. disable hdmi hpd reg. */ sw_hpd_enable(false); /* 1-2. disable hdmi status enable reg. */ sfr_val = readl(g_hdmi_base + S5P_STATUS_EN); sfr_val &= HDCP_STATUS_DIS_ALL; writel(sfr_val, g_hdmi_base + S5P_STATUS_EN); /* 1-1. clear all status pending */ sfr_val = readl(g_hdmi_base + S5P_STATUS); sfr_val |= HDCP_STATUS_EN_ALL; writel(sfr_val, g_hdmi_base + S5P_STATUS); /* disable encryption */ HDCPPRINTK("Stop Encryption by Stop!!\n"); writel(HDCP_ENC_DISABLE, g_hdmi_base + S5P_ENC_EN); s5p_hdmi_mute_en(true); /* clear result */ writel(Ri_MATCH_RESULT__NO, g_hdmi_base + <API key>); writel(CLEAR_ALL_RESULTS, g_hdmi_base + <API key>); #if 0 /* hdmi disable */ sfr_val = readl(g_hdmi_base + S5P_HDMI_CON_0); sfr_val &= ~(PWDN_ENB_NORMAL | HDMI_EN | ASP_EN); writel(sfr_val, g_hdmi_base + S5P_HDMI_CON_0); */ HDCPPRINTK("\tSTATUS \t0x%08x\n", readl(g_hdmi_base + S5P_STATUS)); HDCPPRINTK("\tSTATUS_EN \t0x%08x\n", readl(g_hdmi_base + S5P_STATUS_EN)); HDCPPRINTK("\tHPD \t0x%08x\n", readl(g_hdmi_base + S5P_HPD)); HDCPPRINTK("\tHDCP_CTRL \t0x%08x\n", readl(g_hdmi_base + S5P_HDCP_CTRL1)); HDCPPRINTK("\tMODE_SEL \t0x%08x\n", readl(g_hdmi_base + S5P_MODE_SEL)); HDCPPRINTK("\tENC_EN \t0x%08x\n", readl(g_hdmi_base + S5P_ENC_EN)); HDCPPRINTK("\tHDMI_CON_0 \t0x%08x\n", readl(g_hdmi_base + S5P_HDMI_CON_0)); writel(sfr_val, g_hdmi_base + S5P_HDMI_CON_0); #endif return true; } /* called by hpd */ int <API key>(bool on) { u32 reg; if (hdcp_info.hdcp_enable) { /* clear interrupt pending all */ writeb(0x0, g_hdmi_base + S5P_HDCP_I2C_INT); writeb(0x0, g_hdmi_base + S5P_HDCP_AN_INT); writeb(0x0, g_hdmi_base + S5P_HDCP_RI_INT); writeb(0x0, g_hdmi_base + S5P_HDCP_WDT_INT); writel(HDCP_ENC_DISABLE, g_hdmi_base + S5P_ENC_EN); s5p_hdmi_mute_en(true); if (!g_sw_reset) { reg = readl(g_hdmi_base + S5P_HDCP_CTRL1); if (on) { writel(reg | CP_DESIRED_EN, g_hdmi_base + S5P_HDCP_CTRL1); <API key>(HDMI_IRQ_HDCP); } else { hdcp_info.event = HDCP_EVENT_STOP; hdcp_info.auth_status = NOT_AUTHENTICATED; writel(reg & ~CP_DESIRED_EN, g_hdmi_base + S5P_HDCP_CTRL1); <API key>(HDMI_IRQ_HDCP); } } HDCPPRINTK("Stop Encryption by HPD Event!!\n"); } return 0; } int s5p_hdmi_set_dvi(bool en) { if (en) g_is_dvi = true; else g_is_dvi = false; return 0; } void s5p_hdmi_set_audio(bool en) { if (en) g_audio_en = true; else g_audio_en = false; } int <API key>(bool en) { u8 reg; if (!g_is_dvi) { reg = readl(g_hdmi_base + S5P_HDMI_CON_0); if (en) { reg |= ASP_EN; writel(<API key> , g_hdmi_base + S5P_AUI_CON); } else { reg &= ~ASP_EN; writel(HDMI_DO_NOT_TANS , g_hdmi_base + S5P_AUI_CON); } writel(reg, g_hdmi_base + S5P_HDMI_CON_0); } return 0; } int s5p_hdmi_set_mute(bool en) { if (en) g_av_mute = true; else g_av_mute = false; return 0; } int s5p_hdmi_get_mute(void) { return g_av_mute ? true : false; } void s5p_hdmi_mute_en(bool en) { if (!g_av_mute) { if (en) { <API key>(true, 128, 0, 128); <API key>(false); } else { <API key>(false, 128, 0, 128); if (g_audio_en) <API key>(true); } } }