answer
stringlengths
15
1.25M
require 'rails_helper' RSpec.describe User, type: :model do let(:user){ create(:user) } let(:unfinished_project){ create(:project, state: 'online') } let(:successful_project){ create(:project, state: 'online') } let(:failed_project){ create(:project, state: 'online') } let(:facebook_provider){ create :oauth_provider, name: 'facebook' } describe "associations" do it{ is_expected.to have_many(:payments).through(:contributions) } it{ is_expected.to have_many :contributions } it{ is_expected.to have_many :<API key> } it{ is_expected.to have_many :projects } it{ is_expected.to have_many :published_projects } it{ is_expected.to have_many :notifications } it{ is_expected.to have_many :project_posts } it{ is_expected.to have_many :unsubscribes } it{ is_expected.to have_many :authorizations } it{ is_expected.to have_one :user_total } it{ is_expected.to have_one :bank_account } it{ is_expected.to belong_to :country } end describe "validations" do before{ user } it{ is_expected.to allow_value('foo@bar.com').for(:email) } it{ is_expected.not_to allow_value('foo').for(:email) } it{ is_expected.not_to allow_value('foo@bar').for(:email) } it{ is_expected.to <API key>(:email) } end describe ".<API key>" do let(:category) { create(:category) } let(:user_1) { create(:user) } let(:user_2) { create(:user) } before do create(:project, category: category, user: user) category.users << user_1 category.users << user_2 category.<API key> category.users << user end subject { User.<API key>(category.id) } it { is_expected.to eq([user]) } end describe "#<API key>" do let(:user) { create(:user) } let(:failed_project) { create(:project, state: 'online') } let(:invalid_payment) do c = create(:<API key>, project: failed_project, user: user) c.payments.update_all({ gateway: 'Pagarme', payment_method: 'BoletoBancario'}) c.payments.first end let(:valid_payment) do c = create(:<API key>, project: failed_project, user: user) c.payments.update_all(gateway: 'Pagarme') c.payments.first end subject { user.<API key> } before do invalid_payment valid_payment failed_project.update_column(:state, 'failed') end it { is_expected.to eq([failed_project]) } end describe "#<API key>" do let(:user) { create(:user) } let(:failed_project) { create(:project, state: 'online') } let(:invalid_payment) do c = create(:<API key>, project: failed_project, user: user) c.payments.update_all({ gateway: 'Pagarme', payment_method: 'BoletoBancario'}) c.payments.first end let(:in_queue_payment) do c = create(:<API key>, project: failed_project, user: user) c.payments.update_all({ gateway: 'Pagarme', payment_method: 'BoletoBancario'}) c.payments.first end let(:valid_payment) do c = create(:<API key>, project: failed_project, user: user) c.payments.update_all(gateway: 'Pagarme') c.payments.first end subject { user.<API key> } before do invalid_payment valid_payment in_queue_payment.direct_refund failed_project.update_column(:state, 'failed') end it { is_expected.to eq([invalid_payment]) } it { expect(in_queue_payment.<API key>?).to eq(true) } end describe ".find_active!" do it "should raise error when user is inactive" do @inactive_user = create(:user, deactivated_at: Time.now) expect(->{ User.find_active!(@inactive_user.id) }).to raise_error(ActiveRecord::RecordNotFound) end it "should return user when active" do expect(User.find_active!(user.id)).to eq user end end describe ".active" do subject{ User.active } before do user create(:user, deactivated_at: Time.now) end it{ is_expected.to eq [user] } end describe ".has_credits" do subject{ User.has_credits } context "when he has credits in the user_total" do before do @user_with_credits = create(:<API key>, project: failed_project).user failed_project.update_attributes state: 'failed' create(:<API key>, project: successful_project) UserTotal.refresh_view end it{ is_expected.to eq([@user_with_credits]) } end context "when he has credits in the user_total but is checked with zero credits" do before do b = create(:<API key>, value: 100, project: failed_project) failed_project.update_attributes state: 'failed' @u = b.user b = create(:<API key>, value: 100, project: successful_project) @u.update_attributes(zero_credits: true) UserTotal.refresh_view end it{ is_expected.to eq([]) } end end describe ".<API key>" do subject{ User.<API key> } context "when he has used credits in the last month" do before do create(:<API key>) end it{ is_expected.to eq([]) } end context "when he has not used credits in the last month" do before do @user_with_credits = create(:<API key>, project: failed_project).user failed_project.update_attributes state: 'failed' UserTotal.refresh_view end it{ is_expected.to eq([@user_with_credits]) } end end describe ".by_payer_email" do before do p = create(:<API key>) contribution = p.contribution @u = contribution.user p.extra_data = {'payer_email' => 'foo@bar.com'} p.save! p = create(:<API key>, contribution: contribution) p.extra_data = {'payer_email' => 'another_email@bar.com'} p.save! p = create(:<API key>) p.extra_data = {'payer_email' => 'another_email@bar.com'} p.save! end subject{ User.by_payer_email 'foo@bar.com' } it{ is_expected.to eq([@u]) } end describe ".by_key" do before do @payment = create(:payment) @contribution = create(:contribution, payments: [@payment]) @user = @contribution.user create(:contribution) end subject{ User.by_key @payment.key } it{ is_expected.to eq([@user]) } end describe ".by_id" do before do @u = create(:user) create(:user) end subject{ User.by_id @u.id } it{ is_expected.to eq([@u]) } end describe ".by_name" do before do @u = create(:user, name: 'Foo Bar') create(:user, name: 'Baz Qux') end subject{ User.by_name 'Bar' } it{ is_expected.to eq([@u]) } end describe ".by_email" do before do @u = create(:user, email: 'foo@bar.com') create(:user, email: 'another_email@bar.com') end subject{ User.by_email 'foo@bar' } it{ is_expected.to eq([@u]) } end describe ".<API key>" do subject{ User.<API key>(successful_project.id) } before do @contribution = create(:<API key>, project: successful_project) create(:<API key>, project: successful_project, user: @contribution.user) create(:<API key>, project: successful_project) end it{ is_expected.to eq([@contribution.user]) } end describe ".create" do subject do User.create! do |u| u.email = 'diogob@gmail.com' u.password = '123456' u.twitter = '@dbiazus' u.facebook_link = 'facebook.com/test' end end its(:twitter){ should == 'dbiazus' } its(:facebook_link){ should == 'http://facebook.com/test' } end describe "#fix_twitter_user" do context "when twitter is full link" do let(:user) { build(:user, twitter: "https://twitter.com/username") } before { user.fix_twitter_user } it { expect(user.twitter).to eq("username") } end context "when twitter is null" do let(:user) { build(:user, twitter: nil) } before { user.fix_twitter_user } it { expect(user.twitter).to eq(nil) } end context "when twitter is @username" do let(:user) { build(:user, twitter: "@username") } before { user.fix_twitter_user } it { expect(user.twitter).to eq("username") } end context "when twitter is username" do let(:user) { build(:user, twitter: "username") } before { user.fix_twitter_user } it { expect(user.twitter).to eq("username") } end end describe "#change_locale" do let(:user) { create(:user, locale: 'pt') } context "when user already has a locale" do before do expect(user).not_to receive(:update_attributes).with(locale: 'pt') end it { user.change_locale('pt') } end context "when locale is diff from the user locale" do before do expect(user).to receive(:update_attributes).with(locale: 'en') end it { user.change_locale('en') } end end describe "#notify" do before do user.notify(:heartbleed) end it "should create notification" do notification = UserNotification.last expect(notification.user).to eq user expect(notification.template_name).to eq 'heartbleed' end end describe "#reactivate" do before do user.deactivate user.reactivate end it "should set reatiactivate_token to nil" do expect(user.reactivate_token).to be_nil end it "should set deactivated_at to nil" do expect(user.deactivated_at).to be_nil end end describe "#deactivate" do before do @contribution = create(:contribution, user: user, anonymous: false) user.deactivate end it "should send user_deactivate notification" do expect(UserNotification.last.template_name).to eq 'user_deactivate' end it "should set all contributions as anonymous" do expect(@contribution.reload.anonymous).to eq(true) end it "should set reatiactivate_token" do expect(user.reactivate_token).to be_present end it "should set deactivated_at" do expect(user.deactivated_at).to be_present end end describe "#<API key>" do let(:user) { create(:user) } let(:project) { create(:project) } subject { user.<API key> } before do create(:<API key>, user: user, project: project) create(:<API key>, user: user, project: project) create(:<API key>, user: user, project: project) create(:<API key>, user: user) user.reload UserTotal.refresh_view end it { is_expected.to eq(2)} end describe "#created_today?" do subject { user.created_today? } context "when user is created today and not sign in yet" do before do allow(user).to receive(:created_at).and_return(Time.zone.today) allow(user).to receive(:sign_in_count).and_return(0) end it { is_expected.to eq(true) } end context "when user is created today and already signed in more that once time" do before do allow(user).to receive(:created_at).and_return(Time.zone.today) allow(user).to receive(:sign_in_count).and_return(2) end it { is_expected.to eq(false) } end context "when user is created yesterday and not sign in yet" do before do allow(user).to receive(:created_at).and_return(Time.zone.yesterday) allow(user).to receive(:sign_in_count).and_return(1) end it { is_expected.to eq(false) } end end describe "#to_analytics_json" do subject{ user.to_analytics_json } it do is_expected.to eq({ user_id: user.id, email: user.email, name: user.name, contributions: user.<API key>, projects: user.projects.count, published_projects: user.published_projects.count, created: user.created_at, has_online_project: user.has_online_project?, <API key>: user.<API key>?, last_login: user.last_sign_in_at, created_today: user.created_today? }.to_json) end end describe "#credits" do def <API key> user, project, value, credits, payment_state = 'paid' c = create(:<API key>, user_id: user.id, project: project) c.payments.first.update_attributes gateway: (credits ? 'Credits' : 'AnyButCredits'), value: value, state: payment_state end before do @u = create(:user) <API key> @u, successful_project, 100, false <API key> @u, unfinished_project, 100, false <API key> @u, failed_project, 200, false <API key> @u, successful_project, 100, true <API key> @u, unfinished_project, 50, true <API key> @u, failed_project, 100, true <API key> @u, failed_project, 200, false, 'pending_refund' <API key> @u, failed_project, 200, false, 'refunded' failed_project.update_attributes state: 'failed' successful_project.update_attributes state: 'successful' UserTotal.refresh_view end subject{ @u.credits } it{ is_expected.to eq(50.0) } end describe "#update_attributes" do context "when I try to update moip_login" do before do user.update_attributes moip_login: 'test' end it("should perform the update"){ expect(user.moip_login).to eq('test') } end end describe "#recommended_project" do subject{ user.<API key> } before do other_contribution = create(:<API key>) create(:<API key>, user: other_contribution.user, project: unfinished_project) create(:<API key>, user: user, project: other_contribution.project) end it{ is_expected.to eq([unfinished_project])} end describe "#<API key>" do subject{user.<API key>} before do @p1 = create(:project) create(:<API key>, user: user, project: @p1) @u1 = create(:unsubscribe, project_id: @p1.id, user_id: user.id ) end it{ is_expected.to eq([@u1])} end describe "#<API key>" do subject{user.<API key>} before do @p1 = create(:project) create(:<API key>, user: user, project: @p1) create(:<API key>, user: user, project: @p1) end it{is_expected.to eq([@p1])} end describe "#<API key>" do subject{user.<API key>} before do @failed_project = create(:project, state: 'online') @online_project = create(:project, state: 'online') create(:<API key>, user: user, project: @failed_project) create(:<API key>, user: user, project: @online_project) @failed_project.update_columns state: 'failed' end it{is_expected.to eq([@failed_project])} end describe "#fix_facebook_link" do subject{ user.facebook_link } context "when user provides invalid url" do let(:user){ create(:user, facebook_link: 'facebook.com/foo') } it{ is_expected.to eq('http://facebook.com/foo') } end context "when user provides valid url" do let(:user){ create(:user, facebook_link: 'http://facebook.com/foo') } it{ is_expected.to eq('http://facebook.com/foo') } end end describe "#<API key>??" do let(:project) { create(:project) } subject { user.<API key>?(project.id) } context "when user has valid contributions for the project" do before do create(:<API key>, project: project, user: user) end it { is_expected.to eq(true) } end context "when user don't have valid contributions for the project" do before do create(:<API key>, project: project, user: user) end it { is_expected.to eq(false) } end context "when user don't have contributions for the project" do it { is_expected.to eq(false) } end end describe "#nullify_permalink" do subject{ user.permalink } context "when user provides blank permalink" do let(:user){ create(:user, permalink: '') } it{ is_expected.to eq(nil) } end context "when user provides permalink" do let(:user){ create(:user, permalink: 'foo') } it{ is_expected.to eq('foo') } end end describe "#<API key>?" do let(:project) { create(:project) } subject { user.<API key>?(project.id) } context "when user have contributions for the project" do before do create(:<API key>, project: project, user: user) end it { is_expected.to eq(true) } end context "when user don't have contributions for the project" do it { is_expected.to eq(false) } end end describe "#<API key>?" do subject{ user.<API key>? } let(:user) { create(:user) } context "when user has sent notifications" do let(:project) { create(:project, user: user, state: 'online') } before do create(:project_post, user: user, project: project ) end it{ is_expected.to eq(true) } end context "when user has not sent notifications" do before do create(:project, user: user, state: 'online') end it{ is_expected.to eq(false) } end context "when user has no project" do it{ is_expected.to eq(false) } end end describe "#has_online_project?" do subject{ user.has_online_project? } let(:user) { create(:user) } context "when user has project online" do before do create(:project, user: user, state: 'online') end it{ is_expected.to eq(true) } end context "when user has project not online" do before do create(:project, user: user, state: 'draft') end it{ is_expected.to eq(false) } end context "when user has no project" do it{ is_expected.to eq(false) } end end describe "#<API key>?" do let(:category) { create(:category) } let(:category_extra) { create(:category) } let(:user) { create(:user) } subject { user.<API key>?(category.id)} context "when is following the category" do before do user.categories << category end it { is_expected.to eq(true) } end context "when not following the category" do before do user.categories << category_extra end it { is_expected.to eq(false) } end context "when not following any category" do it { is_expected.to eq(false) } end end describe "PostgREST users synchronization" do it "should delete api user on user destroy" do user = create(:user) user.bank_account.destroy! User.connection.select_all("DELETE FROM public.users WHERE email = '#{user.email}'") expect(User.connection.select_all("SELECT * FROM postgrest.auth WHERE id = '#{user.email}'").count).to eq 0 end it "should update api user on user update" do user = create(:user) user.email = 'foo@bar.com' user.admin = true user.save! api_user = User.connection.select_all("SELECT * FROM postgrest.auth WHERE id = '#{user.id}'")[0] expect(api_user["id"]).to eq user.id.to_s expect(api_user["rolname"]).to eq 'admin' expect(api_user["pass"].size).to eq 60 end it "should create api user on user creation" do user = create(:user) api_user = User.connection.select_all("SELECT * FROM postgrest.auth WHERE id = '#{user.id}'")[0] expect(api_user["id"]).to eq user.id.to_s expect(api_user["rolname"]).to eq 'web_user' expect(api_user["pass"].size).to eq 60 end end end
<a href="http://github.com/angular/angular.js/tree/v1.2.0-rc.2/src/ngSanitize/filter/linky.js <div><span class="hint">filter in module <code ng:non-bindable="">ngSanitize</code> </span> </div> </h1> <div><h2 id="Description">Description</h2> <div class="description"><div class="<API key> <API key>"><p>Finds links in text input and turns them into html links. Supports http/https/ftp/mailto and plain email address links.</p> <p>Requires the <a href="api/ngSanitize"><code>ngSanitize</code></a> module to be installed.</p> </div></div> <h2 id="Usage">Usage</h2> <div class="usage"><h3 id="In.HTML.Template.Binding">In HTML Template Binding</h3> <div class="<API key>"><code ng:non-bindable="">&lt;span ng-bind-html="linky_expression | linky"&gt;&lt;/span&gt;</code> </div> <h3 id="In.JavaScript">In JavaScript</h3> <div class="in-javascript"><code ng:non-bindable="">$filter('linky')(text, target)</code> </div> <h4 id="parameters">Parameters</h4><table class="variables-matrix table table-bordered table-striped"><thead><tr><th>Param</th><th>Type</th><th>Details</th></tr></thead><tbody><tr><td>text</td><td><a href="" class="label type-hint type-hint-string">string</a></td><td><div class="<API key> <API key>"><p>Input text.</p> </div></td></tr><tr><td>target</td><td><a href="" class="label type-hint type-hint-string">string</a></td><td><div class="<API key> <API key>"><p>Window (_blank|_self|_parent|_top) or named frame to open links in.</p> </div></td></tr></tbody></table><h4 id="returns">Returns</h4><table class="variables-matrix"><tr><td><a href="" class="label type-hint type-hint-string">string</a></td><td><div class="<API key> <API key>"><p>Html-linkified text.</p> </div></td></tr></table></div> <h2 id="Example">Example</h2> <div class="example"><div class="<API key> <API key>"><h4>Source</h2> <div source-edit="ngSanitize" source-edit-deps="angular.js script.js" source-edit-html="index.html-165" source-edit-css="" source-edit-js="script.js-164" source-edit-json="" source-edit-unit="" <API key>="scenario.js-166"></div> <div class="tabbable"><div class="tab-pane" title="index.html"> <pre class="prettyprint linenums" ng-set-text="index.html-165" ng-html-wrap="ngSanitize angular.js script.js"></pre> <script type="text/ng-template" id="index.html-165"> <div ng-controller="Ctrl"> Snippet: <textarea ng-model="snippet" cols="60" rows="3"></textarea> <table> <tr> <td>Filter</td> <td>Source</td> <td>Rendered</td> </tr> <tr id="linky-filter"> <td>linky filter</td> <td> <pre>&lt;div ng-bind-html="snippet | linky"&gt;<br>&lt;/div&gt;</pre> </td> <td> <div ng-bind-html="snippet | linky"></div> </td> </tr> <tr id="linky-target"> <td>linky target</td> <td> <pre>&lt;div ng-bind-html="snippetWithTarget | linky:'_blank'"&gt;<br>&lt;/div&gt;</pre> </td> <td> <div ng-bind-html="snippetWithTarget | linky:'_blank'"></div> </td> </tr> <tr id="escaped-html"> <td>no filter</td> <td><pre>&lt;div ng-bind="snippet"&gt;<br>&lt;/div&gt;</pre></td> <td><div ng-bind="snippet"></div></td> </tr> </table> </script> </div> <div class="tab-pane" title="script.js"> <pre class="prettyprint linenums" ng-set-text="script.js-164"></pre> <script type="text/ng-template" id="script.js-164"> function Ctrl($scope) { $scope.snippet = 'Pretty text with some links:\n'+ 'http://angularjs.org/,\n'+ 'mailto:us@somewhere.org,\n'+ 'another@somewhere.org,\n'+ 'and one more: ftp://127.0.0.1/.'; $scope.snippetWithTarget = 'http://angularjs.org/'; } </script> </div> <div class="tab-pane" title="End to end test"> <pre class="prettyprint linenums" ng-set-text="scenario.js-166"></pre> <script type="text/ng-template" id="scenario.js-166"> it('should linkify the snippet with urls', function() { expect(using('#linky-filter').binding('snippet | linky')). toBe('Pretty text with some links:& '<a href="http://angularjs.org/">http://angularjs.org/</a>,& '<a href="mailto:us@somewhere.org">us@somewhere.org</a>,& '<a href="mailto:another@somewhere.org">another@somewhere.org</a>,& 'and one more: <a href="ftp: }); it ('should not linkify snippet without the linky filter', function() { expect(using('#escaped-html').binding('snippet')). toBe("Pretty text with some links:\n" + "http://angularjs.org/,\n" + "mailto:us@somewhere.org,\n" + "another@somewhere.org,\n" + "and one more: ftp://127.0.0.1/."); }); it('should update', function() { input('snippet').enter('new http://link.'); expect(using('#linky-filter').binding('snippet | linky')). toBe('new <a href="http: expect(using(' }); it('should work with the target property', function() { expect(using('#linky-target').binding("snippetWithTarget | linky:'_blank'")). toBe('<a target="_blank" href="http: }); </script> </div> </div><h2>Demo</h4> <div class="well doc-example-live animate-container" ng-embed-app="ngSanitize" ng-set-html="index.html-165" ng-eval-javascript="script.js-164"></div> </div></div> </div>
package com.youtube.vitess.client; import com.google.common.util.concurrent.ListenableFuture; import com.youtube.vitess.proto.Query.QueryResult; import com.youtube.vitess.proto.Vtgate.BeginRequest; import com.youtube.vitess.proto.Vtgate.BeginResponse; import com.youtube.vitess.proto.Vtgate.CommitRequest; import com.youtube.vitess.proto.Vtgate.CommitResponse; import com.youtube.vitess.proto.Vtgate.<API key>; import com.youtube.vitess.proto.Vtgate.<API key>; import com.youtube.vitess.proto.Vtgate.<API key>; import com.youtube.vitess.proto.Vtgate.<API key>; import com.youtube.vitess.proto.Vtgate.<API key>; import com.youtube.vitess.proto.Vtgate.<API key>; import com.youtube.vitess.proto.Vtgate.<API key>; import com.youtube.vitess.proto.Vtgate.<API key>; import com.youtube.vitess.proto.Vtgate.<API key>; import com.youtube.vitess.proto.Vtgate.<API key>; import com.youtube.vitess.proto.Vtgate.ExecuteRequest; import com.youtube.vitess.proto.Vtgate.ExecuteResponse; import com.youtube.vitess.proto.Vtgate.<API key>; import com.youtube.vitess.proto.Vtgate.<API key>; import com.youtube.vitess.proto.Vtgate.<API key>; import com.youtube.vitess.proto.Vtgate.<API key>; import com.youtube.vitess.proto.Vtgate.RollbackRequest; import com.youtube.vitess.proto.Vtgate.RollbackResponse; import com.youtube.vitess.proto.Vtgate.SplitQueryRequest; import com.youtube.vitess.proto.Vtgate.SplitQueryResponse; import com.youtube.vitess.proto.Vtgate.<API key>; import com.youtube.vitess.proto.Vtgate.<API key>; import com.youtube.vitess.proto.Vtgate.<API key>; import com.youtube.vitess.proto.Vtgate.<API key>; import java.io.Closeable; import java.sql.SQLException; /** * RpcClient defines a set of methods to communicate with VTGates. */ public interface RpcClient extends Closeable { ListenableFuture<ExecuteResponse> execute(Context ctx, ExecuteRequest request) throws SQLException; ListenableFuture<<API key>> executeShards(Context ctx, <API key> request) throws SQLException; ListenableFuture<<API key>> executeKeyspaceIds( Context ctx, <API key> request) throws SQLException; ListenableFuture<<API key>> executeKeyRanges( Context ctx, <API key> request) throws SQLException; ListenableFuture<<API key>> executeEntityIds( Context ctx, <API key> request) throws SQLException; ListenableFuture<<API key>> executeBatchShards( Context ctx, <API key> request) throws SQLException; ListenableFuture<<API key>> <API key>( Context ctx, <API key> request) throws SQLException; StreamIterator<QueryResult> streamExecute(Context ctx, <API key> request) throws SQLException; StreamIterator<QueryResult> streamExecuteShards(Context ctx, <API key> request) throws SQLException; StreamIterator<QueryResult> <API key>( Context ctx, <API key> request) throws SQLException; StreamIterator<QueryResult> <API key>( Context ctx, <API key> request) throws SQLException; ListenableFuture<BeginResponse> begin(Context ctx, BeginRequest request) throws SQLException; ListenableFuture<CommitResponse> commit(Context ctx, CommitRequest request) throws SQLException; ListenableFuture<RollbackResponse> rollback(Context ctx, RollbackRequest request) throws SQLException; ListenableFuture<SplitQueryResponse> splitQuery(Context ctx, SplitQueryRequest request) throws SQLException; ListenableFuture<<API key>> getSrvKeyspace( Context ctx, <API key> request) throws SQLException; }
<div class="ccm-ui"> <div class="row"> <div class="ccm-pane"> <?php echo Loader::helper('concrete/dashboard')-><API key>(t('File Manager'), array(t('Add, search, replace and modify the files for your website.'), 'http: <?php $c = Page::getCurrentPage(); $ocID = $c->getCollectionID(); $fp = FilePermissions::getGlobal(); if ($fp->canSearchFiles()) { ?> <div class="ccm-pane-options" id="ccm-<?php echo $searchInstance?>-pane-options"> <div class="<API key>"><?php Loader::element('files/<API key>', array('searchInstance' => $searchInstance, 'searchRequest' => $searchRequest, 'searchType' => 'DASHBOARD')); ?></div> </div> <?php Loader::element('files/search_results', array('searchInstance' => $searchInstance, 'searchRequest' => $searchRequest, 'columns' => $columns, 'searchType' => 'DASHBOARD', 'files' => $files, 'fileList' => $fileList)); ?> <?php } else { ?> <div class="ccm-pane-body"> <p><?php echo t("You do not have access to the file manager.");?></p> </div> <div class="ccm-pane-footer"></div> </div> <?php } ?> </div> </div>
<b>Creating AOT Friendly Dynamic Components with Angular 2</b> <div class="row"> <div class="col-lg-12"> <div class="panel panel-default"> <div class="panel-heading">Application Code</div> <div class="panel-body"> <div class="input-group"> <select class="form-control" [(ngModel)]="<API key>"> <option *ngFor="let cellComponentType of componentTypes" [ngValue]="cellComponentType">{{cellComponentType.name}}</option> </select> <span class="input-group-btn"> <button type="button" class="btn btn-primary" (click)="grid.<API key>(<API key>)">Add Dynamic Grid component</button> </span> </div> </div> </div> </div> </div> <div class="row"> <div class="col-lg-12"> <div class="panel panel-default"> <div class="panel-heading">Library Code</div> <div class="panel-body"> <appc-grid-component #grid></appc-grid-component> </div> </div> </div> </div>
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.<API key>(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; import { Optional } from '@angular/core'; /** The points of the origin element and the overlay element to connect. */ export var <API key> = (function () { function <API key>(origin, overlay) { this.originX = origin.originX; this.originY = origin.originY; this.overlayX = overlay.overlayX; this.overlayY = overlay.overlayY; } return <API key>; }()); export var <API key> = (function () { function <API key>() { } return <API key>; }()); /** The change event emitted by the strategy when a fallback position is used. */ export var <API key> = (function () { function <API key>(connectionPair, <API key>) { this.connectionPair = connectionPair; this.<API key> = <API key>; } <API key> = __decorate([ __param(1, Optional()), __metadata('design:paramtypes', [<API key>, <API key>]) ], <API key>); return <API key>; }()); //# sourceMappingURL=connected-position.js.map
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <meta name="renderer" content="webkit|ie-comp|ie-stand"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" /> <meta http-equiv="Cache-Control" content="no-siteapp" /> <!--[if lt IE 9]> <script type="text/javascript" src="lib/html5.js"></script> <script type="text/javascript" src="lib/respond.min.js"></script> <script type="text/javascript" src="lib/PIE_IE678.js"></script> <![endif] <link href="css/H-ui.min.css" rel="stylesheet" type="text/css" /> <link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" /> <link href="css/style.css" rel="stylesheet" type="text/css" /> <link href="lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" /> <!--[if IE 6]> <script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script> <script>DD_belatedPNG.fix('*');</script> <![endif] <title></title> </head> <body> <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> <span class="c-gray en">&gt;</span> <span class="c-gray en">&gt;</span> <a class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="" ><i class="Hui-iconfont">&#xe68f;</i></a></nav> <div class="pd-20"> <div class="text-c"> <form class="Huiform" method="post" action="" target="_self"> <input type="text" class="input-text" style="width:250px" placeholder="" id="" name=""> <button type="submit" class="btn btn-success" id="" name=""><i class="Hui-iconfont">&#xe665;</i> </button> </form> </div> <div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"><a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> </a> <a href="javascript:;" onclick="<API key>('','<API key>.html','','310')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> </a></span> <span class="r"><strong>54</strong> </span> </div> <table class="table table-border table-bordered table-bg"> <thead> <tr> <th scope="col" colspan="7"></th> </tr> <tr class="text-c"> <th width="25"><input type="checkbox" name="" value=""></th> <th width="40">ID</th> <th width="200"></th> <th></th> <th width="100"></th> </tr> </thead> <tbody> <tr class="text-c"> <td><input type="checkbox" value="1" name=""></td> <td>1</td> <td></td> <td></td> <td><a title="" href="javascript:;" onclick="<API key>('','<API key>.html','1','','310')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a> <a title="" href="javascript:;" onclick="<API key>(this,'1')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a></td> </tr> </tbody> </table> </div> <script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> <script type="text/javascript" src="lib/layer/1.9.3/layer.js"></script> <script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script> <script type="text/javascript" src="lib/My97DatePicker/WdatePicker.js"></script> <script type="text/javascript" src="js/H-ui.js"></script> <script type="text/javascript" src="js/H-ui.admin.js"></script> <script type="text/javascript"> /* title url url id id w h */ function <API key>(title,url,w,h){ layer_show(title,url,w,h); } function <API key>(title,url,id,w,h){ layer_show(title,url,w,h); } function <API key>(obj,id){ layer.confirm('',function(index){ $(obj).parents("tr").remove(); layer.msg('!',{icon:1,time:1000}); }); } </script> </body> </html>
// flow-typed signature: <API key> declare module 'babel-preset-react' { declare module.exports: any; } /** * We include stubs for each file inside this npm package in case you need to * require those files directly. Feel free to delete any files that aren't * needed. */ declare module 'babel-preset-react/lib/index' { declare module.exports: any; } // Filename aliases declare module 'babel-preset-react/lib/index.js' { declare module.exports: $Exports<'babel-preset-react/lib/index'>; }
#ifndef <API key> #define <API key> #include <vector> #include "base/macros.h" #include "sync/engine/commit_queue.h" #include "sync/internal_api/public/<API key>.h" namespace syncer_v2 { // Receives and records commit requests sent through the CommitQueue. // This class also includes features intended to help mock out server behavior. // It has some basic functionality to keep track of server state and generate // plausible UpdateResponseData and CommitResponseData messages. class MockCommitQueue : public CommitQueue { public: MockCommitQueue(); ~MockCommitQueue() override; // Implementation of CommitQueue. void EnqueueForCommit(const <API key>& list) override; // Getters to inspect the requests sent to this object. size_t <API key>() const; <API key> <API key>(size_t n) const; bool <API key>(const std::string& tag_hash) const; CommitRequestData <API key>( const std::string& tag_hash) const; // Functions to produce state as though it came from a real server and had // been filtered through a real CommitQueue. // Returns an UpdateResponseData representing an update received from // the server. Updates server state accordingly. // The |version_offset| field can be used to emulate stale data (ie. versions // going backwards), reflections and redeliveries (ie. several instances of // the same version) or new updates. UpdateResponseData UpdateFromServer( int64 version_offset, const std::string& tag_hash, const sync_pb::EntitySpecifics& specifics); // Returns an UpdateResponseData representing a tombstone update from the // server. Updates server state accordingly. UpdateResponseData TombstoneFromServer(int64 version_offset, const std::string& tag_hash); // Returns a commit response that indicates a successful commit of the // given |request_data|. Updates server state accordingly. CommitResponseData <API key>( const CommitRequestData& request_data); // Sets the encryption key name used for updates from the server. // (ie. the key other clients are using to encrypt their commits.) // The default value is an empty string, which indicates no encryption. void <API key>(const std::string& key_name); private: // Generate an ID string. static std::string GenerateId(const std::string& tag_hash); // Retrieve or set the server version. int64 GetServerVersion(const std::string& tag_hash); void SetServerVersion(const std::string& tag_hash, int64 version); // A record of past commits requests. std::vector<<API key>> <API key>; // Map of versions by client tag. // This is an essential part of the mocked server state. std::map<const std::string, int64> server_versions_; // Name of the encryption key in use on other clients. std::string <API key>; <API key>(MockCommitQueue); }; } // namespace syncer #endif // <API key>
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); $user=User_helper::get_user(); $CI = & get_instance(); ?> <div class="row widget"> <?php if($user->user_group==0) { ?> <div class="col-sm-12 text-center"> <h3 class="alert alert-warning"><?php echo $CI->lang->line('<API key>');?></h3> </div> <?php } ?> <?php if($CI->is_site_offline()) { ?> <div class="col-sm-12 text-center"> <h3 class="alert alert-warning"><?php echo $CI->lang->line('MSG_SITE_OFFLINE');?></h3> </div> <?php } ?> <div class="col-sm-12 text-center"> <h1><?php echo $user->name;?></h1> <img style="max-width: 250px;" src="<?php echo $user->picture_profile; ?>"> </div> </div> <div class="clearfix"></div>
#! /bin/bash set -euxo pipefail # provide a default environment if none exists if [ ! -f ".env" ]; then echo "Using .env.oss" cp .env.oss .env fi # prepare a production build yarn assets yarn build:server # start server in the background in production mode NODE_ENV=production yarn start & # wait for it to accept connections ./node_modules/.bin/wait-on http://localhost:5000
#include "buffer.h" #include "posix.h" #include <stdarg.h> #include <ctype.h> /* Used as default value for git_buf->ptr so that people can always * assume ptr is non-NULL and zero terminated even for new git_bufs. */ char git_buf__initbuf[1]; char git_buf__oom[1]; #define ENSURE_SIZE(b, d) \ if ((d) > buf->asize && git_buf_grow(b, (d)) < 0)\ return -1; void git_buf_init(git_buf *buf, size_t initial_size) { buf->asize = 0; buf->size = 0; buf->ptr = git_buf__initbuf; if (initial_size) git_buf_grow(buf, initial_size); } int git_buf_try_grow(git_buf *buf, size_t target_size, bool mark_oom) { char *new_ptr; size_t new_size; if (buf->ptr == git_buf__oom) return -1; if (target_size <= buf->asize) return 0; if (buf->asize == 0) { new_size = target_size; new_ptr = NULL; } else { new_size = buf->asize; new_ptr = buf->ptr; } /* grow the buffer size by 1.5, until it's big enough * to fit our target size */ while (new_size < target_size) new_size = (new_size << 1) - (new_size >> 1); /* round allocation up to multiple of 8 */ new_size = (new_size + 7) & ~7; new_ptr = git__realloc(new_ptr, new_size); if (!new_ptr) { if (mark_oom) buf->ptr = git_buf__oom; return -1; } buf->asize = new_size; buf->ptr = new_ptr; /* truncate the existing buffer size if necessary */ if (buf->size >= buf->asize) buf->size = buf->asize - 1; buf->ptr[buf->size] = '\0'; return 0; } void git_buf_free(git_buf *buf) { if (!buf) return; if (buf->ptr != git_buf__initbuf && buf->ptr != git_buf__oom) git__free(buf->ptr); git_buf_init(buf, 0); } void git_buf_clear(git_buf *buf) { buf->size = 0; if (buf->asize > 0) buf->ptr[0] = '\0'; } int git_buf_set(git_buf *buf, const char *data, size_t len) { if (len == 0 || data == NULL) { git_buf_clear(buf); } else { if (data != buf->ptr) { ENSURE_SIZE(buf, len + 1); memmove(buf->ptr, data, len); } buf->size = len; buf->ptr[buf->size] = '\0'; } return 0; } int git_buf_sets(git_buf *buf, const char *string) { return git_buf_set(buf, string, string ? strlen(string) : 0); } int git_buf_putc(git_buf *buf, char c) { ENSURE_SIZE(buf, buf->size + 2); buf->ptr[buf->size++] = c; buf->ptr[buf->size] = '\0'; return 0; } int git_buf_put(git_buf *buf, const char *data, size_t len) { ENSURE_SIZE(buf, buf->size + len + 1); memmove(buf->ptr + buf->size, data, len); buf->size += len; buf->ptr[buf->size] = '\0'; return 0; } int git_buf_puts(git_buf *buf, const char *string) { assert(string); return git_buf_put(buf, string, strlen(string)); } static const char b64str[64] = "<API key>+/"; int git_buf_put_base64(git_buf *buf, const char *data, size_t len) { size_t extra = len % 3; uint8_t *write, a, b, c; const uint8_t *read = (const uint8_t *)data; ENSURE_SIZE(buf, buf->size + 4 * ((len / 3) + !!extra) + 1); write = (uint8_t *)&buf->ptr[buf->size]; /* convert each run of 3 bytes into 4 output bytes */ for (len -= extra; len > 0; len -= 3) { a = *read++; b = *read++; c = *read++; *write++ = b64str[a >> 2]; *write++ = b64str[(a & 0x03) << 4 | b >> 4]; *write++ = b64str[(b & 0x0f) << 2 | c >> 6]; *write++ = b64str[c & 0x3f]; } if (extra > 0) { a = *read++; b = (extra > 1) ? *read++ : 0; *write++ = b64str[a >> 2]; *write++ = b64str[(a & 0x03) << 4 | b >> 4]; *write++ = (extra > 1) ? b64str[(b & 0x0f) << 2] : '='; *write++ = '='; } buf->size = ((char *)write) - buf->ptr; buf->ptr[buf->size] = '\0'; return 0; } int git_buf_vprintf(git_buf *buf, const char *format, va_list ap) { int len; const size_t expected_size = buf->size + (strlen(format) * 2); ENSURE_SIZE(buf, expected_size); while (1) { va_list args; va_copy(args, ap); len = p_vsnprintf( buf->ptr + buf->size, buf->asize - buf->size, format, args ); if (len < 0) { git__free(buf->ptr); buf->ptr = git_buf__oom; return -1; } if ((size_t)len + 1 <= buf->asize - buf->size) { buf->size += len; break; } ENSURE_SIZE(buf, buf->size + len + 1); } return 0; } int git_buf_printf(git_buf *buf, const char *format, ...) { int r; va_list ap; va_start(ap, format); r = git_buf_vprintf(buf, format, ap); va_end(ap); return r; } void git_buf_copy_cstr(char *data, size_t datasize, const git_buf *buf) { size_t copylen; assert(data && datasize && buf); data[0] = '\0'; if (buf->size == 0 || buf->asize <= 0) return; copylen = buf->size; if (copylen > datasize - 1) copylen = datasize - 1; memmove(data, buf->ptr, copylen); data[copylen] = '\0'; } void git_buf_consume(git_buf *buf, const char *end) { if (end > buf->ptr && end <= buf->ptr + buf->size) { size_t consumed = end - buf->ptr; memmove(buf->ptr, end, buf->size - consumed); buf->size -= consumed; buf->ptr[buf->size] = '\0'; } } void git_buf_truncate(git_buf *buf, size_t len) { if (len < buf->size) { buf->size = len; buf->ptr[buf->size] = '\0'; } } void <API key>(git_buf *buf, char separator) { ssize_t idx = git_buf_rfind_next(buf, separator); git_buf_truncate(buf, idx < 0 ? 0 : (size_t)idx); } void git_buf_swap(git_buf *buf_a, git_buf *buf_b) { git_buf t = *buf_a; *buf_a = *buf_b; *buf_b = t; } char *git_buf_detach(git_buf *buf) { char *data = buf->ptr; if (buf->asize == 0 || buf->ptr == git_buf__oom) return NULL; git_buf_init(buf, 0); return data; } void git_buf_attach(git_buf *buf, char *ptr, size_t asize) { git_buf_free(buf); if (ptr) { buf->ptr = ptr; buf->size = strlen(ptr); if (asize) buf->asize = (asize < buf->size) ? buf->size + 1 : asize; else /* pass 0 to fall back on strlen + 1 */ buf->asize = buf->size + 1; } else { git_buf_grow(buf, asize); } } int git_buf_join_n(git_buf *buf, char separator, int nbuf, ...) { va_list ap; int i; size_t total_size = 0, original_size = buf->size; char *out, *original = buf->ptr; if (buf->size > 0 && buf->ptr[buf->size - 1] != separator) ++total_size; /* space for initial separator */ /* Make two passes to avoid multiple reallocation */ va_start(ap, nbuf); for (i = 0; i < nbuf; ++i) { const char* segment; size_t segment_len; segment = va_arg(ap, const char *); if (!segment) continue; segment_len = strlen(segment); total_size += segment_len; if (segment_len == 0 || segment[segment_len - 1] != separator) ++total_size; /* space for separator */ } va_end(ap); /* expand buffer if needed */ if (total_size == 0) return 0; if (git_buf_grow(buf, buf->size + total_size + 1) < 0) return -1; out = buf->ptr + buf->size; /* append separator to existing buf if needed */ if (buf->size > 0 && out[-1] != separator) *out++ = separator; va_start(ap, nbuf); for (i = 0; i < nbuf; ++i) { const char* segment; size_t segment_len; segment = va_arg(ap, const char *); if (!segment) continue; /* deal with join that references buffer's original content */ if (segment >= original && segment < original + original_size) { size_t offset = (segment - original); segment = buf->ptr + offset; segment_len = original_size - offset; } else { segment_len = strlen(segment); } /* skip leading separators */ if (out > buf->ptr && out[-1] == separator) while (segment_len > 0 && *segment == separator) { segment++; segment_len } /* copy over next buffer */ if (segment_len > 0) { memmove(out, segment, segment_len); out += segment_len; } /* append trailing separator (except for last item) */ if (i < nbuf - 1 && out > buf->ptr && out[-1] != separator) *out++ = separator; } va_end(ap); /* set size based on num characters actually written */ buf->size = out - buf->ptr; buf->ptr[buf->size] = '\0'; return 0; } int git_buf_join( git_buf *buf, char separator, const char *str_a, const char *str_b) { size_t strlen_a = str_a ? strlen(str_a) : 0; size_t strlen_b = strlen(str_b); int need_sep = 0; ssize_t offset_a = -1; /* not safe to have str_b point internally to the buffer */ assert(str_b < buf->ptr || str_b > buf->ptr + buf->size); /* figure out if we need to insert a separator */ if (separator && strlen_a) { while (*str_b == separator) { str_b++; strlen_b if (str_a[strlen_a - 1] != separator) need_sep = 1; } /* str_a could be part of the buffer */ if (str_a >= buf->ptr && str_a < buf->ptr + buf->size) offset_a = str_a - buf->ptr; if (git_buf_grow(buf, strlen_a + strlen_b + need_sep + 1) < 0) return -1; /* fix up internal pointers */ if (offset_a >= 0) str_a = buf->ptr + offset_a; /* do the actual copying */ if (offset_a != 0) memmove(buf->ptr, str_a, strlen_a); if (need_sep) buf->ptr[strlen_a] = separator; memcpy(buf->ptr + strlen_a + need_sep, str_b, strlen_b); buf->size = strlen_a + strlen_b + need_sep; buf->ptr[buf->size] = '\0'; return 0; } void git_buf_rtrim(git_buf *buf) { while (buf->size > 0) { if (!git__isspace(buf->ptr[buf->size - 1])) break; buf->size } buf->ptr[buf->size] = '\0'; } int git_buf_cmp(const git_buf *a, const git_buf *b) { int result = memcmp(a->ptr, b->ptr, min(a->size, b->size)); return (result != 0) ? result : (a->size < b->size) ? -1 : (a->size > b->size) ? 1 : 0; } int git_buf_splice( git_buf *buf, size_t where, size_t nb_to_remove, const char *data, size_t nb_to_insert) { assert(buf && where <= git_buf_len(buf) && where + nb_to_remove <= git_buf_len(buf)); if (git_buf_grow(buf, git_buf_len(buf) + nb_to_insert - nb_to_remove) < 0) return -1; memmove(buf->ptr + where + nb_to_insert, buf->ptr + where + nb_to_remove, buf->size - where - nb_to_remove); memcpy(buf->ptr + where, data, nb_to_insert); buf->size = buf->size + nb_to_insert - nb_to_remove; buf->ptr[buf->size] = '\0'; return 0; }
from direct.distributed import DistributedObject class <API key>(DistributedObject.DistributedObject): def setRequiredField(self, r): self.requiredField = r def setB(self, B): self.B = B def setBA(self, BA): self.BA = BA def setBO(self, BO): self.BO = BO def setBR(self, BR): self.BR = BR def setBRA(self, BRA): self.BRA = BRA def setBRO(self, BRO): self.BRO = BRO def setBROA(self, BROA): self.BROA = BROA def <API key>(self): for field in ('B', 'BA', 'BO', 'BR', 'BRA', 'BRO', 'BROA'): if hasattr(self, field): return True return False
/* Generated automatically. DO NOT EDIT! */ #define SIMD_HEADER "simd-support/simd-sse2.h" #include "../common/t1fuv_9.c"
# List.automap ( field ) > *@param* **field** _{Object}_ - valid field object > _@api_ **private** Checks to see if a field path matches a currently unmapped path, and if so, adds a mapping for it. <div class="code-header addGitHubLink" data-file="lib/list/automap.js"><a href="#" class="loadCode"> code</a></div><pre class=" language-javascript hideCode api"></pre>
namespace Microsoft.Zelig.Runtime.TypeSystem { using System; [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum )] public class <API key> : Attribute { } }
#include "../../../main/vsccameraadd.h" #include <QtCore/qbytearray.h> #include <QtCore/qmetatype.h> #if !defined(<API key>) #error "The header file 'vsccameraadd.h' doesn't include <QObject>." #elif <API key> != 67 #error "This file was generated using the moc from 5.4.0. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif <API key> struct <API key> { QByteArrayData data[6]; char stringdata[77]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ <API key>(len, \ qptrdiff(offsetof(<API key>, stringdata) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const <API key> <API key> = { { QT_MOC_LITERAL(0, 0, 12), // "VSCCameraAdd" QT_MOC_LITERAL(1, 13, 14), // "floatingAction" QT_MOC_LITERAL(2, 28, 0), QT_MOC_LITERAL(3, 29, 16), // "unFloatingAction" QT_MOC_LITERAL(4, 46, 18), // "radioButtonClicked" QT_MOC_LITERAL(5, 65, 11) // "applyConfig" }, "VSCCameraAdd\0floatingAction\0\0" "unFloatingAction\0radioButtonClicked\0" "applyConfig" }; #undef QT_MOC_LITERAL static const uint <API key>[] = { // content: 7, // revision 0, // classname 0, 0, // classinfo 4, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount // slots: name, argc, parameters, tag, flags 1, 0, 34, 2, 0x08 /* Private */, 3, 0, 35, 2, 0x08 /* Private */, 4, 0, 36, 2, 0x08 /* Private */, 5, 0, 37, 2, 0x08 /* Private */, // slots: parameters QMetaType::Void, QMetaType::Void, QMetaType::Void, QMetaType::Void, 0 // eod }; void VSCCameraAdd::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { VSCCameraAdd *_t = static_cast<VSCCameraAdd *>(_o); switch (_id) { case 0: _t->floatingAction(); break; case 1: _t->unFloatingAction(); break; case 2: _t->radioButtonClicked(); break; case 3: _t->applyConfig(); break; default: ; } } Q_UNUSED(_a); } const QMetaObject VSCCameraAdd::staticMetaObject = { { &QWidget::staticMetaObject, <API key>.data, <API key>, qt_static_metacall, Q_NULLPTR, Q_NULLPTR} }; const QMetaObject *VSCCameraAdd::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *VSCCameraAdd::qt_metacast(const char *_clname) { if (!_clname) return Q_NULLPTR; if (!strcmp(_clname, <API key>.stringdata)) return static_cast<void*>(const_cast< VSCCameraAdd*>(this)); return QWidget::qt_metacast(_clname); } int VSCCameraAdd::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 4) qt_static_metacall(this, _c, _id, _a); _id -= 4; } else if (_c == QMetaObject::<API key>) { if (_id < 4) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 4; } return _id; } <API key>
<?php defined('C5_EXECUTE') or die("Access Denied."); global $c;?> <?php if ($b->getBlockTypeHandle() == <API key>) { $bi = $b->getInstance(); $bx = Block::getByID($bi->getOriginalBlockID()); $bt = BlockType::getByID($bx->getBlockTypeID()); } else { $bt = BlockType::getByID($b->getBlockTypeID()); } $templates = $bt-><API key>(); $txt = Loader::helper('text'); ?> <div class="ccm-ui" style="padding-top:10px;"> <form method="post" id="<API key>" action="<?php echo $b-><API key>()?>&amp;rcID=<?php echo intval($rcID) ?>" class="form-stacked clearfix"> <?php if (count($templates) == 0) { ?> <?php echo t('There are no custom templates available.')?> <?php } else { ?> <div class="clearfix"> <label for="bFilename"><?php echo t('Custom Template')?></label> <div class="input"> <select id="bFilename" name="bFilename" class="xlarge"> <option value="">(<?php echo t('None selected')?>)</option> <?php foreach($templates as $tpl) { ?> <option value="<?php echo $tpl?>" <?php if ($b->getBlockFilename() == $tpl) { ?> selected <?php } ?>><?php if (strpos($tpl, '.') !== false) { print substr($txt->unhandle($tpl), 0, strrpos($tpl, '.')); } else { print $txt->unhandle($tpl); } ?></option> <?php } ?> </select> </div> </div> <?php } ?> <div class="clearfix" style="padding-top:10px"> <label for="bName"><?php echo t('Block Name')?></label> <div class="input"> <input type="text" id="bName" name="bName" class="bName" value="<?php echo $b->getBlockName() ?>" /> </div> </div> <div class="ccm-buttons dialog-buttons"> <a href="#" class="btn ccm-dialog-close ccm-button-left cancel"><?php echo t('Cancel')?></a> <a href="javascript:void(0)" onclick="$('#<API key>').submit()" class="ccm-button-right accept primary btn"><span><?php echo t('Save')?></span></a> </div> <?php $valt = Loader::helper('validation/token'); $valt->output(); ?> </form> </div> <script type="text/javascript"> $(function() { $('#<API key>').each(function() { ccm_setupBlockForm($(this), '<?php echo $b->getBlockID()?>', 'edit'); }); }); </script>
<?php namespace Bolt\Tests\Nut; use Bolt\Nut\TestRunner; use Bolt\Tests\BoltUnitTest; use Symfony\Component\Console\Tester\CommandTester; /** * Class to test src/Nut/TestRunner. * * @author Ross Riley <riley.ross@gmail.com> */ class TestRunnerTest extends BoltUnitTest { public function testRun() { $app = $this->getApp(); $command = new TestRunner($app); $tester = new CommandTester($command); $tester->execute([]); $result = $tester->getDisplay(); $this->assertRegExp('/Running PHPUnit/', $result); } } namespace Bolt\Nut; function system($command) { return $command; }
<?php namespace Sylius\Bundle\RbacBundle\Doctrine\ORM; use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository; use Sylius\Component\Rbac\Model\RoleInterface; use Sylius\Component\Rbac\Repository\<API key>; class RoleRepository extends EntityRepository implements <API key> { /** * {@inheritdoc} */ public function getChildRoles(RoleInterface $role) { $queryBuilder = $this->createQueryBuilder('o'); return $queryBuilder ->where($queryBuilder->expr()->lt('o.left', $role->getRight())) ->andWhere($queryBuilder->expr()->gt('o.left', $role->getLeft())) ->getQuery() ->execute() ; } }
'use strict'; angular.module("ngLocale", [], ["$provide", function($provide) { var PLURAL_CATEGORY = {ZERO: "zero", ONE: "one", TWO: "two", FEW: "few", MANY: "many", OTHER: "other"}; function getDecimals(n) { n = n + ''; var i = n.indexOf('.'); return (i == -1) ? 0 : n.length - i - 1; } function getVF(n, opt_precision) { var v = opt_precision; if (undefined === v) { v = Math.min(getDecimals(n), 3); } var base = Math.pow(10, v); var f = ((n * base) | 0) % base; return {v: v, f: f}; } $provide.value("$locale", { "DATETIME_FORMATS": { "AMPMS": [ "fm", "em" ], "DAY": [ "s\u00f6ndag", "m\u00e5ndag", "tisdag", "onsdag", "torsdag", "fredag", "l\u00f6rdag" ], "MONTH": [ "januari", "februari", "mars", "april", "maj", "juni", "juli", "augusti", "september", "oktober", "november", "december" ], "SHORTDAY": [ "s\u00f6n", "m\u00e5n", "tis", "ons", "tors", "fre", "l\u00f6r" ], "SHORTMONTH": [ "jan", "feb", "mar", "apr", "maj", "jun", "jul", "aug", "sep", "okt", "nov", "dec" ], "fullDate": "EEEE'en' 'den' d:'e' MMMM y", "longDate": "d MMMM y", "medium": "d MMM y HH:mm:ss", "mediumDate": "d MMM y", "mediumTime": "HH:mm:ss", "short": "dd-MM-y HH:mm", "shortDate": "dd-MM-y", "shortTime": "HH:mm" }, "NUMBER_FORMATS": { "CURRENCY_SYM": "\u20ac", "DECIMAL_SEP": ",", "GROUP_SEP": "\u00a0", "PATTERNS": [ { "gSize": 3, "lgSize": 3, "maxFrac": 3, "minFrac": 0, "minInt": 1, "negPre": "-", "negSuf": "", "posPre": "", "posSuf": "" }, { "gSize": 3, "lgSize": 3, "maxFrac": 2, "minFrac": 2, "minInt": 1, "negPre": "-", "negSuf": "\u00a0\u00a4", "posPre": "", "posSuf": "\u00a0\u00a4" } ] }, "id": "sv-fi", "pluralCat": function(n, opt_precision) { var i = n | 0; var vf = getVF(n, opt_precision); if (i == 1 && vf.v == 0) { return PLURAL_CATEGORY.ONE; } return PLURAL_CATEGORY.OTHER;} }); }]);
module OmniAuth module Strategies # The Developer strategy is a very simple strategy that can be used as a # placeholder in your application until a different authentication strategy # is swapped in. It has zero security and should *never* be used in a # production setting. # ## Usage # To use the Developer strategy, all you need to do is put it in like any # other strategy: # @example Basic Usage # use OmniAuth::Builder do # provider :developer # end # @example Custom Fields # use OmniAuth::Builder do # provider :developer, # :fields => [:first_name, :last_name], # :uid_field => :last_name # end # This will create a strategy that, when the user visits `/auth/developer` # they will be presented a form that prompts for (by default) their name # and email address. The auth hash will be populated with these fields and # the `uid` will simply be set to the provided email. class Developer include OmniAuth::Strategy option :fields, %i[name email] option :uid_field, :email def request_phase form = OmniAuth::Form.new(:title => 'User Info', :url => callback_path) options.fields.each do |field| form.text_field field.to_s.capitalize.tr('_', ' '), field.to_s end form.button 'Sign In' form.to_response end uid do request.params[options.uid_field.to_s] end info do options.fields.inject({}) do |hash, field| hash[field] = request.params[field.to_s] hash end end end end end
/*++ Module Name: path.c Abstract: Implementation of all functions related to path support Revision History: --*/ #include "pal/thread.hpp" #include "pal/palinternal.h" #include "pal/dbgmsg.h" #include "pal/file.h" #include "pal/malloc.hpp" #include "pal/stackstring.hpp" #include <errno.h> #include <unistd.h> #include <stdlib.h> <API key>(FILE); // In safemath.h, Template SafeInt uses macro _ASSERTE, which need to use variable // defdbgchan defined by <API key>. Therefore, the include statement // should be placed after the <API key>(FILE) #include <safemath.h> int <API key> = 3; /*++ Function: GetFullPathNameA See MSDN doc. --*/ DWORD PALAPI GetFullPathNameA( IN LPCSTR lpFileName, IN DWORD nBufferLength, OUT LPSTR lpBuffer, OUT LPSTR *lpFilePart) { DWORD nReqPathLen, nRet = 0; LPSTR lpUnixPath = NULL; BOOL fullPath = FALSE; PERF_ENTRY(GetFullPathNameA); ENTRY("GetFullPathNameA(lpFileName=%p (%s), nBufferLength=%u, lpBuffer=%p, " "lpFilePart=%p)\n", lpFileName?lpFileName:"NULL", lpFileName?lpFileName:"NULL", nBufferLength, lpBuffer, lpFilePart); if(NULL == lpFileName) { WARN("lpFileName is NULL\n"); SetLastError(<API key>); goto done; } /* find out if lpFileName is a partial or full path */ if ('\\' == *lpFileName || '/' == *lpFileName) { fullPath = TRUE; } if(fullPath) { lpUnixPath = PAL__strdup( lpFileName ); if(NULL == lpUnixPath) { ERROR("strdup() failed; error is %d (%s)\n", errno, strerror(errno)); SetLastError(<API key>); goto done; } } else { size_t max_len; /* allocate memory for full non-canonical path */ max_len = strlen(lpFileName)+1; /* 1 for the slash to append */ max_len += MAX_LONGPATH + 1; lpUnixPath = (LPSTR)PAL_malloc(max_len); if(NULL == lpUnixPath) { ERROR("PAL_malloc() failed; error is %d (%s)\n", errno, strerror(errno)); SetLastError(<API key>); goto done; } /* build full path */ if(!<API key>(MAX_LONGPATH + 1, lpUnixPath)) { /* no reason for this to fail now... */ ASSERT("<API key>() failed! lasterror is %#xd\n", GetLastError()); SetLastError(<API key>); goto done; } if (strcat_s(lpUnixPath, max_len, "/") != SAFECRT_SUCCESS) { ERROR("strcat_s failed!\n"); SetLastError(<API key>); goto done; } if (strcat_s(lpUnixPath, max_len, lpFileName) != SAFECRT_SUCCESS) { ERROR("strcat_s failed!\n"); SetLastError(<API key>); goto done; } } /* do conversion to Unix path */ FILEDosToUnixPathA( lpUnixPath ); /* now we can canonicalize this */ <API key>(lpUnixPath); /* at last, we can figure out how long this path is */ nReqPathLen = strlen(lpUnixPath)+1; if(nBufferLength < nReqPathLen) { TRACE("reporting insufficient buffer : minimum is %d, caller " "provided %d\n", nReqPathLen, nBufferLength); nRet = nReqPathLen; goto done; } nRet = nReqPathLen-1; strcpy_s(lpBuffer, nBufferLength, lpUnixPath); /* locate the filename component if caller cares */ if(lpFilePart) { *lpFilePart = strrchr(lpBuffer, '/'); if (*lpFilePart == NULL) { ASSERT("Not able to find '/' in the full path.\n"); SetLastError( <API key> ); nRet = 0; goto done; } else { (*lpFilePart)++; } } done: PAL_free (lpUnixPath); LOGEXIT("GetFullPathNameA returns DWORD %u\n", nRet); PERF_EXIT(GetFullPathNameA); return nRet; } /*++ Function: GetFullPathNameW See MSDN doc. --*/ DWORD PALAPI GetFullPathNameW( IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart) { LPSTR fileNameA; /* bufferA needs to be able to hold a path that's potentially as large as MAX_LONGPATH WCHARs. */ CHAR * bufferA; size_t bufferASize = 0; PathCharString bufferAPS; LPSTR lpFilePartA; int fileNameLength; int srcSize; DWORD length; DWORD nRet = 0; PERF_ENTRY(GetFullPathNameW); ENTRY("GetFullPathNameW(lpFileName=%p (%S), nBufferLength=%u, lpBuffer=%p" ", lpFilePart=%p)\n", lpFileName?lpFileName:W16_NULLSTRING, lpFileName?lpFileName:W16_NULLSTRING, nBufferLength, lpBuffer, lpFilePart); /* Find the number of bytes required to convert lpFileName to ANSI. This may be more than MAX_LONGPATH. We try to handle that case, since it may be less than MAX_LONGPATH WCHARs. */ fileNameLength = WideCharToMultiByte(CP_ACP, 0, lpFileName, -1, NULL, 0, NULL, NULL); if (fileNameLength == 0) { /* Couldn't convert to ANSI. That's odd. */ SetLastError(<API key>); goto done; } else { fileNameA = static_cast<LPSTR>(alloca(fileNameLength)); } /* Now convert lpFileName to ANSI. */ srcSize = WideCharToMultiByte (CP_ACP, 0, lpFileName, -1, fileNameA, fileNameLength, NULL, NULL ); if( srcSize == 0 ) { DWORD dwLastError = GetLastError(); if( dwLastError == <API key> ) { ERROR("lpFileName is larger than MAX_LONGPATH (%d)!\n", MAX_LONGPATH); } else { ASSERT("WideCharToMultiByte failure! error is %d\n", dwLastError); } SetLastError(<API key>); goto done; } bufferASize = MAX_LONGPATH * <API key>; bufferA = bufferAPS.OpenStringBuffer(bufferASize); if (NULL == bufferA) { SetLastError(<API key>); goto done; } length = GetFullPathNameA(fileNameA, bufferASize, bufferA, &lpFilePartA); bufferAPS.CloseBuffer(length); if (length == 0 || length > bufferASize) { /* Last error is set by GetFullPathNameA */ nRet = length; goto done; } /* Convert back to Unicode the result */ nRet = MultiByteToWideChar( CP_ACP, 0, bufferA, -1, lpBuffer, nBufferLength ); if (nRet == 0) { if ( GetLastError() == <API key> ) { /* get the required length */ nRet = MultiByteToWideChar( CP_ACP, 0, bufferA, -1, NULL, 0 ); SetLastError(<API key>); } goto done; } /* MultiByteToWideChar counts the trailing NULL, but GetFullPathName does not. */ nRet /* now set lpFilePart */ if (lpFilePart != NULL) { *lpFilePart = lpBuffer; *lpFilePart += MultiByteToWideChar( CP_ACP, 0, bufferA, lpFilePartA - bufferA, NULL, 0); } done: LOGEXIT("GetFullPathNameW returns DWORD %u\n", nRet); PERF_EXIT(GetFullPathNameW); return nRet; } /*++ Function: GetLongPathNameW See MSDN doc. Note: Since short path names are not implemented (nor supported) in the PAL, this function simply copies the given path into the new buffer. --*/ DWORD PALAPI GetLongPathNameW( IN LPCWSTR lpszShortPath, OUT LPWSTR lpszLongPath, IN DWORD cchBuffer) { DWORD dwPathLen = 0; PERF_ENTRY(GetLongPathNameW); ENTRY("GetLongPathNameW(lpszShortPath=%p (%S), lpszLongPath=%p (%S), " "cchBuffer=%d\n", lpszShortPath, lpszShortPath, lpszLongPath, lpszLongPath, cchBuffer); if ( !lpszShortPath ) { ERROR( "lpszShortPath was not a valid pointer.\n" ) SetLastError( <API key> ); LOGEXIT("GetLongPathNameW returns DWORD 0\n"); PERF_EXIT(GetLongPathNameW); return 0; } else if (<API key> == GetFileAttributesW( lpszShortPath )) { // last error has been set by GetFileAttributes ERROR( "lpszShortPath does not exist.\n" ) LOGEXIT("GetLongPathNameW returns DWORD 0\n"); PERF_EXIT(GetLongPathNameW); return 0; } /* all lengths are # of TCHAR characters */ /* "required size" includes space for the terminating null character */ dwPathLen = PAL_wcslen(lpszShortPath)+1; /* lpszLongPath == 0 means caller is asking only for size */ if ( lpszLongPath ) { if ( dwPathLen > cchBuffer ) { ERROR("Buffer is too small, need %d characters\n", dwPathLen); SetLastError( <API key> ); } else { if ( lpszShortPath != lpszLongPath ) { // Note: MSDN doesn't specify the behavior of GetLongPathName API // if the buffers are overlap. PAL_wcsncpy( lpszLongPath, lpszShortPath, cchBuffer ); } /* actual size not including terminating null is returned */ dwPathLen } } LOGEXIT("GetLongPathNameW returns DWORD %u\n", dwPathLen); PERF_EXIT(GetLongPathNameW); return dwPathLen; } /*++ Function: GetShortPathNameW See MSDN doc. Note: Since short path names are not implemented (nor supported) in the PAL, this function simply copies the given path into the new buffer. --*/ DWORD PALAPI GetShortPathNameW( IN LPCWSTR lpszLongPath, OUT LPWSTR lpszShortPath, IN DWORD cchBuffer) { DWORD dwPathLen = 0; PERF_ENTRY(GetShortPathNameW); ENTRY("GetShortPathNameW(lpszLongPath=%p (%S), lpszShortPath=%p (%S), " "cchBuffer=%d\n", lpszLongPath, lpszLongPath, lpszShortPath, lpszShortPath, cchBuffer); if ( !lpszLongPath ) { ERROR( "lpszLongPath was not a valid pointer.\n" ) SetLastError( <API key> ); LOGEXIT("GetShortPathNameW returns DWORD 0\n"); PERF_EXIT(GetShortPathNameW); return 0; } else if (<API key> == GetFileAttributesW( lpszLongPath )) { // last error has been set by GetFileAttributes ERROR( "lpszLongPath does not exist.\n" ) LOGEXIT("GetShortPathNameW returns DWORD 0\n"); PERF_EXIT(GetShortPathNameW); return 0; } /* all lengths are # of TCHAR characters */ /* "required size" includes space for the terminating null character */ dwPathLen = PAL_wcslen(lpszLongPath)+1; /* lpszShortPath == 0 means caller is asking only for size */ if ( lpszShortPath ) { if ( dwPathLen > cchBuffer ) { ERROR("Buffer is too small, need %d characters\n", dwPathLen); SetLastError( <API key> ); } else { if ( lpszLongPath != lpszShortPath ) { // Note: MSDN doesn't specify the behavior of GetShortPathName API // if the buffers are overlap. PAL_wcsncpy( lpszShortPath, lpszLongPath, cchBuffer ); } /* actual size not including terminating null is returned */ dwPathLen } } LOGEXIT("GetShortPathNameW returns DWORD %u\n", dwPathLen); PERF_EXIT(GetShortPathNameW); return dwPathLen; } /*++ Function: GetTempPathA See MSDN. Notes: On Windows, the temp path is determined by the following steps: 1. The value of the "TMP" environment variable, or if it doesn't exist, 2. The value of the "TEMP" environment variable, or if it doesn't exist, 3. The Windows directory. On Unix, we follow in spirit: 1. The value of the "TMPDIR" environment variable, or if it doesn't exist, 2. The /tmp directory. This is the same approach employed by mktemp. --*/ DWORD PALAPI GetTempPathA( IN DWORD nBufferLength, OUT LPSTR lpBuffer) { DWORD dwPathLen = 0; PERF_ENTRY(GetTempPathA); ENTRY("GetTempPathA(nBufferLength=%u, lpBuffer=%p)\n", nBufferLength, lpBuffer); if ( !lpBuffer ) { ERROR( "lpBuffer was not a valid pointer.\n" ) SetLastError( <API key> ); LOGEXIT("GetTempPathA returns DWORD %u\n", dwPathLen); PERF_EXIT(GetTempPathA); return 0; } /* Try the TMPDIR environment variable. This is the same env var checked by mktemp. */ dwPathLen = <API key>("TMPDIR", lpBuffer, nBufferLength); if (dwPathLen > 0) { /* The env var existed. dwPathLen will be the length without null termination * if the entire value was successfully retrieved, or it'll be the length * required to store the value with null termination. */ if (dwPathLen < nBufferLength) { /* The environment variable fit in the buffer. Make sure it ends with '/'. */ if (lpBuffer[dwPathLen - 1] != '/') { /* If adding the slash would still fit in our provided buffer, do it. Otherwise, * let the caller know how much space would be needed. */ if (dwPathLen + 2 <= nBufferLength) { lpBuffer[dwPathLen++] = '/'; lpBuffer[dwPathLen] = '\0'; } else { dwPathLen += 2; } } } else /* dwPathLen >= nBufferLength */ { /* The value is too long for the supplied buffer. dwPathLen will now be the * length required to hold the value, but we don't know whether that value * is going to be '/' terminated. Since we'll need enough space for the '/', and since * a caller would assume that the dwPathLen we return will be sufficient, * we make sure to account for it in dwPathLen even if that means we end up saying * one more byte of space is needed than actually is. */ dwPathLen++; } } else /* env var not found or was empty */ { /* no luck, use /tmp/ */ const char *defaultDir = "/tmp/"; int defaultDirLen = strlen(defaultDir); if (defaultDirLen < nBufferLength) { dwPathLen = defaultDirLen; strcpy_s(lpBuffer, nBufferLength, defaultDir); } else { /* get the required length */ dwPathLen = defaultDirLen + 1; } } if ( dwPathLen >= nBufferLength ) { ERROR("Buffer is too small, need space for %d characters including null termination\n", dwPathLen); SetLastError( <API key> ); } LOGEXIT("GetTempPathA returns DWORD %u\n", dwPathLen); PERF_EXIT(GetTempPathA); return dwPathLen; } /*++ Function: GetTempPathW See MSDN. See also the comment for GetTempPathA. --*/ DWORD PALAPI GetTempPathW( IN DWORD nBufferLength, OUT LPWSTR lpBuffer) { PERF_ENTRY(GetTempPathW); ENTRY("GetTempPathW(nBufferLength=%u, lpBuffer=%p)\n", nBufferLength, lpBuffer); if (!lpBuffer) { ERROR("lpBuffer was not a valid pointer.\n") SetLastError(<API key>); LOGEXIT("GetTempPathW returns DWORD 0\n"); PERF_EXIT(GetTempPathW); return 0; } char TempBuffer[nBufferLength > 0 ? nBufferLength : 1]; DWORD dwRetVal = GetTempPathA( nBufferLength, TempBuffer ); if ( dwRetVal >= nBufferLength ) { ERROR( "lpBuffer was not large enough.\n" ) SetLastError( <API key> ); *lpBuffer = '\0'; } else if ( dwRetVal != 0 ) { /* Convert to wide. */ if ( 0 == MultiByteToWideChar( CP_ACP, 0, TempBuffer, -1, lpBuffer, dwRetVal + 1 ) ) { ASSERT( "An error occurred while converting the string to wide.\n" ); SetLastError( <API key> ); dwRetVal = 0; } } else { ERROR( "The function failed.\n" ); *lpBuffer = '\0'; } LOGEXIT("GetTempPathW returns DWORD %u\n", dwRetVal ); PERF_EXIT(GetTempPathW); return dwRetVal; } /*++ Function: FileDosToUnixPathA Abstract: Change a DOS path to a Unix path. Replaces '\' by '/', removes any trailing dots on directory/filenames, and changes '*.*' to be equal to '*' Parameter: IN/OUT lpPath: path to be modified --*/ void FILEDosToUnixPathA( LPSTR lpPath) { LPSTR p; LPSTR pPointAtDot=NULL; char charBeforeFirstDot='\0'; TRACE("Original DOS path = [%s]\n", lpPath); if (!lpPath) { return; } for (p = lpPath; *p; p++) { /* Make the \\ to / switch first */ if (*p == '\\') { /* Replace \ with / */ *p = '/'; } if (pPointAtDot) { /* If pPointAtDot is not NULL, it is pointing at the first encountered dot. If we encountered a \, that means it could be a trailing dot */ if (*p == '/') { /* If char before the first dot is a '\' or '.' (special case if the dot is the first char in the path) , then we leave it alone, because it is either . or .., otherwise it is a trailing dot pattern and will be truncated */ if (charBeforeFirstDot != '.' && charBeforeFirstDot != '/') { memmove(pPointAtDot,p,(strlen(p)*sizeof(char))+1); p = pPointAtDot; } pPointAtDot = NULL; /* Need to reset this */ } else if (*p == '*') { /* Check our size before doing anything with our pointers */ if ((p - lpPath) >= 3) { /* At this point, we know that there is 1 or more dots and then a star. AND we know the size of our string at this point is at least 3 (so we can go backwards from our pointer safely AND there could possilby be two characters back) So lets check if there is a '*' and a '.' before, if there is, replace just a '*'. Otherwise, reset pPointAtDot to NULL and do nothing */ if (p[-2] == '*' && p[-1] == '.' && p[0] == '*') { memmove(&(p[-2]),p,(strlen(p)*sizeof(char))+1); } pPointAtDot = NULL; } } else if (*p != '.') { /* If we are here, that means that this is NOT a trailing dot, some other character is here, so forget our pointer */ pPointAtDot = NULL; } } else { if (*p == '.') { /* If pPointAtDot is NULL, and we encounter a dot, save the pointer */ pPointAtDot = p; if (pPointAtDot != lpPath) { charBeforeFirstDot = p[-1]; } else { charBeforeFirstDot = lpPath[0]; } } } } /* If pPointAtDot still points at anything, then we still have trailing dots. Truncate at pPointAtDot, unless the dots are path specifiers (. or ..) */ if (pPointAtDot) { /* make sure the trailing dots don't follow a '/', and that they aren't the only thing in the name */ if(pPointAtDot != lpPath && *(pPointAtDot-1) != '/') { *pPointAtDot = '\0'; } } TRACE("Resulting Unix path = [%s]\n", lpPath); } /*++ Function: FileDosToUnixPathW Abstract: Change a DOS path to a Unix path. Replaces '\' by '/', removes any trailing dots on directory/filenames, and changes '*.*' to be equal to '*' Parameter: IN/OUT lpPath: path to be modified --*/ void FILEDosToUnixPathW( LPWSTR lpPath) { LPWSTR p; LPWSTR pPointAtDot=NULL; WCHAR charBeforeFirstDot='\0'; TRACE("Original DOS path = [%S]\n", lpPath); if (!lpPath) { return; } for (p = lpPath; *p; p++) { /* Make the \\ to / switch first */ if (*p == '\\') { /* Replace \ with / */ *p = '/'; } if (pPointAtDot) { /* If pPointAtDot is not NULL, it is pointing at the first encountered dot. If we encountered a \, that means it could be a trailing dot */ if (*p == '/') { /* If char before the first dot is a '\' or '.' (special case if the dot is the first char in the path) , then we leave it alone, because it is either . or .., otherwise it is a trailing dot pattern and will be truncated */ if (charBeforeFirstDot != '.' && charBeforeFirstDot != '/') { memmove(pPointAtDot,p,((PAL_wcslen(p)+1)*sizeof(WCHAR))); p = pPointAtDot; } pPointAtDot = NULL; /* Need to reset this */ } else if (*p == '*') { /* Check our size before doing anything with our pointers */ if ((p - lpPath) >= 3) { /* At this point, we know that there is 1 or more dots and then a star. AND we know the size of our string at this point is at least 3 (so we can go backwards from our pointer safely AND there could possilby be two characters back) So lets check if there is a '*' and a '.' before, if there is, replace just a '*'. Otherwise, reset pPointAtDot to NULL and do nothing */ if (p[-2] == '*' && p[-1] == '.' && p[0] == '*') { memmove(&(p[-2]),p,(PAL_wcslen(p)*sizeof(WCHAR))); } pPointAtDot = NULL; } } else if (*p != '.') { /* If we are here, that means that this is NOT a trailing dot, some other character is here, so forget our pointer */ pPointAtDot = NULL; } } else { if (*p == '.') { /* If pPointAtDot is NULL, and we encounter a dot, save the pointer */ pPointAtDot = p; if (pPointAtDot != lpPath) { charBeforeFirstDot = p[-1]; } else { charBeforeFirstDot = lpPath[0]; } } } } /* If pPointAtDot still points at anything, then we still have trailing dots. Truncate at pPointAtDot, unless the dots are path specifiers (. or ..) */ if (pPointAtDot) { /* make sure the trailing dots don't follow a '/', and that they aren't the only thing in the name */ if(pPointAtDot != lpPath && *(pPointAtDot-1) != '/') { *pPointAtDot = '\0'; } } TRACE("Resulting Unix path = [%S]\n", lpPath); } /*++ Function: FileUnixToDosPathA Abstract: Change a Unix path to a DOS path. Replace '/' by '\'. Parameter: IN/OUT lpPath: path to be modified --*/ void FILEUnixToDosPathA( LPSTR lpPath) { LPSTR p; TRACE("Original Unix path = [%s]\n", lpPath); if (!lpPath) return; for (p = lpPath; *p; p++) { if (*p == '/') *p = '\\'; } TRACE("Resulting DOS path = [%s]\n", lpPath); } /*++ Function: <API key> Parse the given path. If it contains a directory part and a file part, put the directory part into the supplied buffer, and return the number of characters written to the buffer. If the buffer is not large enough, return the required size of the buffer including the NULL character. If there is no directory part in the path, return 0. --*/ DWORD <API key>( LPCSTR lpFullPath, DWORD nBufferLength, LPSTR lpBuffer ) { int full_len, dir_len, i; LPCSTR lpDirEnd; DWORD dwRetLength; full_len = lstrlenA( lpFullPath ); /* look for the first path separator backwards */ lpDirEnd = lpFullPath + full_len - 1; while( lpDirEnd >= lpFullPath && *lpDirEnd != '/' && *lpDirEnd != '\\') --lpDirEnd; dir_len = lpDirEnd - lpFullPath + 1; /* +1 for fencepost */ if ( dir_len <= 0 ) { dwRetLength = 0; } else if (static_cast<DWORD>(dir_len) >= nBufferLength) { dwRetLength = dir_len + 1; /* +1 for NULL char */ } else { /* put the directory into the buffer, including 1 or more trailing path separators */ for( i = 0; i < dir_len; ++i ) *(lpBuffer + i) = *(lpFullPath + i); *(lpBuffer + i) = '\0'; dwRetLength = dir_len; } return( dwRetLength ); } /*++ Function: <API key> Given a full path, return a pointer to the first char of the filename part. --*/ LPCSTR <API key>( LPCSTR lpFullPath ) { int DirLen = <API key>( lpFullPath, 0, NULL ); if ( DirLen > 0 ) { return lpFullPath + DirLen - 1; } else { return lpFullPath; } } /*++ <API key> Removes all instances of '/./', '/../' and '//' from an absolute path. Parameters: LPSTR lpUnixPath : absolute path to modify, in Unix format (no return value) Notes : -behavior is undefined if path is not absolute -the order of steps *is* important: /one/./../two would give /one/two instead of /two if step 3 was done before step 2 -reason for this function is that GetFullPathName can't use realpath(), since realpath() requires the given path to be valid and GetFullPathName does not. --*/ void <API key>(LPSTR lpUnixPath) { LPSTR slashslashptr; LPSTR dotdotptr; LPSTR slashdotptr; LPSTR slashptr; /* step 1 : replace '//' sequences by a single '/' */ slashslashptr = lpUnixPath; while(1) { slashslashptr = strstr(slashslashptr," if(NULL == slashslashptr) { break; } /* remove extra '/' */ TRACE("stripping '//' from %s\n", lpUnixPath); memmove(slashslashptr,slashslashptr+1,strlen(slashslashptr+1)+1); } /* step 2 : replace '/./' sequences by a single '/' */ slashdotptr = lpUnixPath; while(1) { slashdotptr = strstr(slashdotptr,"/./"); if(NULL == slashdotptr) { break; } /* strip the extra '/.' */ TRACE("removing '/./' sequence from %s\n", lpUnixPath); memmove(slashdotptr,slashdotptr+2,strlen(slashdotptr+2)+1); } /* step 3 : replace '/<name>/../' sequences by a single '/' */ while(1) { dotdotptr = strstr(lpUnixPath,"/../"); if(NULL == dotdotptr) { break; } if(dotdotptr == lpUnixPath) { /* special case : '/../' at the beginning of the path are replaced by a single '/' */ TRACE("stripping leading '/../' from %s\n", lpUnixPath); memmove(lpUnixPath, lpUnixPath+3,strlen(lpUnixPath+3)+1); continue; } /* null-terminate the string before the '/../', so that strrchr will start looking right before it */ *dotdotptr = '\0'; slashptr = strrchr(lpUnixPath,'/'); if(NULL == slashptr) { /* this happens if this function was called with a relative path. don't do that. */ ASSERT("can't find leading '/' before '/../ sequence\n"); break; } TRACE("removing '/<dir>/../' sequence from %s\n", lpUnixPath); memmove(slashptr,dotdotptr+3,strlen(dotdotptr+3)+1); } /* step 4 : remove a trailing '/..' */ dotdotptr = strstr(lpUnixPath,"/.."); if(dotdotptr == lpUnixPath) { /* if the full path is simply '/..', replace it by '/' */ lpUnixPath[1] = '\0'; } else if(NULL != dotdotptr && '\0' == dotdotptr[3]) { *dotdotptr = '\0'; slashptr = strrchr(lpUnixPath,'/'); if(NULL != slashptr) { /* make sure the last slash isn't the root */ if (slashptr == lpUnixPath) { lpUnixPath[1] = '\0'; } else { *slashptr = '\0'; } } } /* step 5 : remove a traling '/.' */ slashdotptr = strstr(lpUnixPath,"/."); if (slashdotptr != NULL && slashdotptr[2] == '\0') { if(slashdotptr == lpUnixPath) { // if the full path is simply '/.', replace it by '/' */ lpUnixPath[1] = '\0'; } else { *slashdotptr = '\0'; } } } /*++ Function: SearchPathA See MSDN doc. PAL-specific notes : -lpPath must be non-NULL; path delimiters are platform-dependent (':' for Unix) -lpFileName must be non-NULL, may be an absolute path -lpExtension must be NULL -lpFilePart (if non-NULL) doesn't need to be used (but we do) --*/ DWORD PALAPI SearchPathA( IN LPCSTR lpPath, IN LPCSTR lpFileName, IN LPCSTR lpExtension, IN DWORD nBufferLength, OUT LPSTR lpBuffer, OUT LPSTR *lpFilePart ) { DWORD nRet = 0; CHAR * FullPath; size_t FullPathLength = 0; PathCharString FullPathPS; PathCharString CanonicalFullPathPS; CHAR * CanonicalFullPath; LPCSTR pPathStart; LPCSTR pPathEnd; size_t PathLength; size_t FileNameLength; DWORD length; DWORD dw; PERF_ENTRY(SearchPathA); ENTRY("SearchPathA(lpPath=%p (%s), lpFileName=%p (%s), lpExtension=%p, " "nBufferLength=%u, lpBuffer=%p, lpFilePart=%p)\n", lpPath, lpPath, lpFileName, lpFileName, lpExtension, nBufferLength, lpBuffer, lpFilePart); /* validate parameters */ if(NULL == lpPath) { ASSERT("lpPath may not be NULL\n"); SetLastError(<API key>); goto done; } if(NULL == lpFileName) { ASSERT("lpFileName may not be NULL\n"); SetLastError(<API key>); goto done; } if(NULL != lpExtension) { ASSERT("lpExtension must be NULL, is %p instead\n", lpExtension); SetLastError(<API key>); goto done; } FileNameLength = strlen(lpFileName); /* special case : if file name contains absolute path, don't search the provided path */ if('\\' == lpFileName[0] || '/' == lpFileName[0]) { if(FileNameLength >= MAX_LONGPATH) { WARN("absolute file name <%s> is too long\n", lpFileName); SetLastError(<API key>); goto done; } /* Canonicalize the path to deal with back-to-back '/', etc. */ length = MAX_LONGPATH; CanonicalFullPath = CanonicalFullPathPS.OpenStringBuffer(length); if (NULL == CanonicalFullPath) { SetLastError(<API key>); goto done; } dw = GetFullPathNameA(lpFileName, length+1, CanonicalFullPath, NULL); CanonicalFullPathPS.CloseBuffer(dw); if (length+1 < dw) { CanonicalFullPath = CanonicalFullPathPS.OpenStringBuffer(dw-1); if (NULL == CanonicalFullPath) { SetLastError(<API key>); goto done; } dw = GetFullPathNameA(lpFileName, dw, CanonicalFullPath, NULL); CanonicalFullPathPS.CloseBuffer(dw); } if (dw == 0) { WARN("couldn't canonicalize path <%s>, error is %#x. failing.\n", lpFileName, GetLastError()); SetLastError(<API key>); goto done; } /* see if the file exists */ if(0 == access(CanonicalFullPath, F_OK)) { /* found it */ nRet = dw; } } else { LPCSTR pNextPath; pNextPath = lpPath; while (*pNextPath) { pPathStart = pNextPath; /* get a pointer to the end of the first path in pPathStart */ pPathEnd = strchr(pPathStart, ':'); if (!pPathEnd) { pPathEnd = pPathStart + strlen(pPathStart); /* we want to break out of the loop after this pass, so let *pNextPath be '\0' */ pNextPath = pPathEnd; } else { /* point to the next component in the path string */ pNextPath = pPathEnd+1; } PathLength = pPathEnd-pPathStart; if (PathLength+FileNameLength+1 >= MAX_LONGPATH) { /* The path+'/'+file length is too long. Skip it. */ WARN("path component %.*s is too long, skipping it\n", (int)PathLength, pPathStart); continue; } else if(0 == PathLength) { /* empty component : there were 2 consecutive ':' */ continue; } /* Construct a pathname by concatenating one path from lpPath, '/' and lpFileName */ FullPathLength = PathLength + FileNameLength; FullPath = FullPathPS.OpenStringBuffer(FullPathLength+1); if (NULL == FullPath) { SetLastError(<API key>); goto done; } memcpy(FullPath, pPathStart, PathLength); FullPath[PathLength] = '/'; if (strcpy_s(&FullPath[PathLength+1], FullPathLength+1-PathLength, lpFileName) != SAFECRT_SUCCESS) { ERROR("strcpy_s failed!\n"); SetLastError( <API key> ); nRet = 0; goto done; } FullPathPS.CloseBuffer(FullPathLength+1); /* Canonicalize the path to deal with back-to-back '/', etc. */ length = MAX_LONGPATH; CanonicalFullPath = CanonicalFullPathPS.OpenStringBuffer(length); if (NULL == CanonicalFullPath) { SetLastError(<API key>); goto done; } dw = GetFullPathNameA(FullPath, length+1, CanonicalFullPath, NULL); CanonicalFullPathPS.CloseBuffer(dw); if (length+1 < dw) { CanonicalFullPath = CanonicalFullPathPS.OpenStringBuffer(dw-1); dw = GetFullPathNameA(FullPath, dw, CanonicalFullPath, NULL); CanonicalFullPathPS.CloseBuffer(dw); } if (dw == 0) { /* Call failed - possibly low memory. Skip the path */ WARN("couldn't canonicalize path <%s>, error is % "skipping it\n", FullPath, GetLastError()); continue; } /* see if the file exists */ if(0 == access(CanonicalFullPath, F_OK)) { /* found it */ nRet = dw; break; } } } if (nRet == 0) { /* file not found anywhere; say so. in Windows, this always seems to say FILE_NOT_FOUND, even if path doesn't exist */ SetLastError(<API key>); } else { if (nRet < nBufferLength) { if(NULL == lpBuffer) { /* Windows merily crashes here, but let's not */ ERROR("caller told us buffer size was %d, but buffer is NULL\n", nBufferLength); SetLastError(<API key>); nRet = 0; goto done; } if (strcpy_s(lpBuffer, nBufferLength, CanonicalFullPath) != SAFECRT_SUCCESS) { ERROR("strcpy_s failed!\n"); SetLastError( <API key> ); nRet = 0; goto done; } if(NULL != lpFilePart) { *lpFilePart = strrchr(lpBuffer,'/'); if(NULL == *lpFilePart) { ASSERT("no '/' in full path!\n"); } else { /* point to character after last '/' */ (*lpFilePart)++; } } } else { /* if buffer is too small, report required length, including terminating null */ nRet++; } } done: LOGEXIT("SearchPathA returns DWORD %u\n", nRet); PERF_EXIT(SearchPathA); return nRet; } /*++ Function: SearchPathW See MSDN doc. PAL-specific notes : -lpPath must be non-NULL; path delimiters are platform-dependent (':' for Unix) -lpFileName must be non-NULL, may be an absolute path -lpExtension must be NULL -lpFilePart (if non-NULL) doesn't need to be used (but we do) --*/ DWORD PALAPI SearchPathW( IN LPCWSTR lpPath, IN LPCWSTR lpFileName, IN LPCWSTR lpExtension, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart ) { DWORD nRet = 0; WCHAR * FullPath; size_t FullPathLength = 0; PathWCharString FullPathPS; LPCWSTR pPathStart; LPCWSTR pPathEnd; size_t PathLength; size_t FileNameLength; DWORD dw; DWORD length; char * AnsiPath; PathCharString AnsiPathPS; size_t CanonicalPathLength; int canonical_size; WCHAR * CanonicalPath; PathWCharString CanonicalPathPS; PERF_ENTRY(SearchPathW); ENTRY("SearchPathW(lpPath=%p (%S), lpFileName=%p (%S), lpExtension=%p, " "nBufferLength=%u, lpBuffer=%p, lpFilePart=%p)\n", lpPath, lpPath, lpFileName, lpFileName, lpExtension, nBufferLength, lpBuffer, lpFilePart); /* validate parameters */ if(NULL == lpPath) { ASSERT("lpPath may not be NULL\n"); SetLastError(<API key>); goto done; } if(NULL == lpFileName) { ASSERT("lpFileName may not be NULL\n"); SetLastError(<API key>); goto done; } if(NULL != lpExtension) { ASSERT("lpExtension must be NULL, is %p instead\n", lpExtension); SetLastError(<API key>); goto done; } /* special case : if file name contains absolute path, don't search the provided path */ if('\\' == lpFileName[0] || '/' == lpFileName[0]) { /* Canonicalize the path to deal with back-to-back '/', etc. */ length = MAX_LONGPATH; CanonicalPath = CanonicalPathPS.OpenStringBuffer(length); if (NULL == CanonicalPath) { SetLastError(<API key>); goto done; } dw = GetFullPathNameW(lpFileName, length+1, CanonicalPath, NULL); CanonicalPathPS.CloseBuffer(dw); if (length+1 < dw) { CanonicalPath = CanonicalPathPS.OpenStringBuffer(dw-1); if (NULL == CanonicalPath) { SetLastError(<API key>); goto done; } dw = GetFullPathNameW(lpFileName, dw, CanonicalPath, NULL); CanonicalPathPS.CloseBuffer(dw); } if (dw == 0) { WARN("couldn't canonicalize path <%S>, error is %#x. failing.\n", lpPath, GetLastError()); SetLastError(<API key>); goto done; } /* see if the file exists */ CanonicalPathLength = (PAL_wcslen(CanonicalPath)+1) * <API key>; AnsiPath = AnsiPathPS.OpenStringBuffer(CanonicalPathLength); if (NULL == AnsiPath) { SetLastError(<API key>); goto done; } canonical_size = WideCharToMultiByte(CP_ACP, 0, CanonicalPath, -1, AnsiPath, CanonicalPathLength, NULL, NULL); AnsiPathPS.CloseBuffer(canonical_size); if(0 == access(AnsiPath, F_OK)) { /* found it */ nRet = dw; } } else { LPCWSTR pNextPath; pNextPath = lpPath; FileNameLength = PAL_wcslen(lpFileName); while (*pNextPath) { pPathStart = pNextPath; /* get a pointer to the end of the first path in pPathStart */ pPathEnd = PAL_wcschr(pPathStart, ':'); if (!pPathEnd) { pPathEnd = pPathStart + PAL_wcslen(pPathStart); /* we want to break out of the loop after this pass, so let *pNextPath be '\0' */ pNextPath = pPathEnd; } else { /* point to the next component in the path string */ pNextPath = pPathEnd+1; } PathLength = pPathEnd-pPathStart; if (PathLength+FileNameLength+1 >= MAX_LONGPATH) { /* The path+'/'+file length is too long. Skip it. */ WARN("path component %.*S is too long, skipping it\n", (int)PathLength, pPathStart); continue; } else if(0 == PathLength) { /* empty component : there were 2 consecutive ':' */ continue; } /* Construct a pathname by concatenating one path from lpPath, '/' and lpFileName */ FullPathLength = PathLength + FileNameLength; FullPath = FullPathPS.OpenStringBuffer(FullPathLength+1); if (NULL == FullPath) { SetLastError(<API key>); goto done; } memcpy(FullPath, pPathStart, PathLength*sizeof(WCHAR)); FullPath[PathLength] = '/'; PAL_wcscpy(&FullPath[PathLength+1], lpFileName); FullPathPS.CloseBuffer(FullPathLength+1); /* Canonicalize the path to deal with back-to-back '/', etc. */ length = MAX_LONGPATH; CanonicalPath = CanonicalPathPS.OpenStringBuffer(length); if (NULL == CanonicalPath) { SetLastError(<API key>); goto done; } dw = GetFullPathNameW(FullPath, length+1, CanonicalPath, NULL); CanonicalPathPS.CloseBuffer(dw); if (length+1 < dw) { CanonicalPath = CanonicalPathPS.OpenStringBuffer(dw-1); if (NULL == CanonicalPath) { SetLastError(<API key>); goto done; } dw = GetFullPathNameW(FullPath, dw, CanonicalPath, NULL); CanonicalPathPS.CloseBuffer(dw); } if (dw == 0) { /* Call failed - possibly low memory. Skip the path */ WARN("couldn't canonicalize path <%S>, error is % "skipping it\n", FullPath, GetLastError()); continue; } /* see if the file exists */ CanonicalPathLength = (PAL_wcslen(CanonicalPath)+1) * <API key>; AnsiPath = AnsiPathPS.OpenStringBuffer(CanonicalPathLength); if (NULL == AnsiPath) { SetLastError(<API key>); goto done; } canonical_size = WideCharToMultiByte(CP_ACP, 0, CanonicalPath, -1, AnsiPath, CanonicalPathLength, NULL, NULL); AnsiPathPS.CloseBuffer(canonical_size); if(0 == access(AnsiPath, F_OK)) { /* found it */ nRet = dw; break; } } } if (nRet == 0) { /* file not found anywhere; say so. in Windows, this always seems to say FILE_NOT_FOUND, even if path doesn't exist */ SetLastError(<API key>); } else { /* find out the required buffer size, copy path to buffer if it's large enough */ nRet = PAL_wcslen(CanonicalPath)+1; if(nRet <= nBufferLength) { if(NULL == lpBuffer) { /* Windows merily crashes here, but let's not */ ERROR("caller told us buffer size was %d, but buffer is NULL\n", nBufferLength); SetLastError(<API key>); nRet = 0; goto done; } PAL_wcscpy(lpBuffer, CanonicalPath); /* don't include the null-terminator in the count if buffer was large enough */ nRet if(NULL != lpFilePart) { *lpFilePart = PAL_wcsrchr(lpBuffer, '/'); if(NULL == *lpFilePart) { ASSERT("no '/' in full path!\n"); } else { /* point to character after last '/' */ (*lpFilePart)++; } } } } done: LOGEXIT("SearchPathW returns DWORD %u\n", nRet); PERF_EXIT(SearchPathW); return nRet; } /*++ Function: PathFindFileNameW See MSDN doc. --*/ LPWSTR PALAPI PathFindFileNameW( IN LPCWSTR pPath ) { PERF_ENTRY(PathFindFileNameW); ENTRY("PathFindFileNameW(pPath=%p (%S))\n", pPath?pPath:W16_NULLSTRING, pPath?pPath:W16_NULLSTRING); LPWSTR ret = (LPWSTR)pPath; if (ret != NULL && *ret != W('\0')) { ret = PAL_wcschr(ret, W('\0')) - 1; if (ret > pPath && *ret == W('/')) { ret } while (ret > pPath && *ret != W('/')) { ret } if (*ret == W('/') && *(ret + 1) != W('\0')) { ret++; } } LOGEXIT("PathFindFileNameW returns %S\n", ret); PERF_EXIT(PathFindFileNameW); return ret; }
Shindo.tests("Fog::Compute[:iam] | managed_policies", ['aws','iam']) do iam = Fog::AWS[:iam] tests('#all').succeeds do iam.managed_policies.size == 100 end tests('#each').succeeds do policies = [] iam.managed_policies.each { |policy| policies << policy } policies.size > 100 end policy = iam.managed_policies.get("arn:aws:iam::aws:policy/IAMReadOnlyAccess") tests("#document").succeeds do policy.document == { "Version" => "2012-10-17", "Statement" => [ { "Effect" => "Allow", "Action" => [ "iam:<API key>", "iam:<API key>", "iam:Get*", "iam:List*" ], "Resource" => "*" } ] } end tests("users") do user = iam.users.create(:id => uniq_id("fog-test-user")) tests("#attach").succeeds do user.attach(policy) user.attached_policies.map(&:identity) == [policy.identity] end returns(1) { policy.reload.attachments} tests("#detach").succeeds do user.detach(policy) user.attached_policies.map(&:identity) == [] end user.destroy end tests("groups") do group = iam.groups.create(:name => uniq_id("fog-test-group")) tests("#attach").succeeds do group.attach(policy) group.attached_policies.map(&:identity) == [policy.identity] end returns(1) { policy.reload.attachments} tests("#detach").succeeds do group.detach(policy) group.attached_policies.map(&:identity) == [] end group.destroy end tests("roles") do role = iam.roles.create(:rolename => uniq_id("fog-test-role")) tests("#attach").succeeds do role.attach(policy) role.attached_policies.map(&:identity) == [policy.identity] end returns(1) { policy.reload.attachments} tests("#detach").succeeds do role.detach(policy) role.attached_policies.map(&:identity) == [] end role.destroy end end
// Product Name: DotSpatial.Projection // Description: The basic module for MapWindow version 6.0 // The Original Code is from MapWindow.dll version 6.0 // The Initial Developer of this Original Code is Ted Dunsford. Created 7/23/2009 3:58:48 PM // Contributor(s): (Open source contributors should list themselves and their modifications here). // Name | Date | Comment using System; namespace DotSpatial.Projections.Transforms { <summary> ITransform </summary> public interface ITransform : ICloneable { #region Methods <summary> Initializes the parameters from the projection info </summary> <param name="proj">The projection information used to control this transform</param> void Init(ProjectionInfo proj); <summary> Transforms all the coordinates by cycling through them in a loop, transforming each one. Only the 0 and 1 values of each coordinate will be transformed, higher dimensional values will be copied. </summary> void Forward(double[] xy, int startIndex, int numPoints); <summary> Transforms all the coordinates by cycling through them in a loop, transforming each one. Only the 0 and 1 values of each coordinate will be transformed, higher dimensional values will be copied. </summary> void Inverse(double[] xy, int startIndex, int numPoints); <summary> Special factor calculations for a factors calculation </summary> <param name="lp"></param> <param name="p"></param> <param name="fac"></param> void Special(double[] lp, ProjectionInfo p, Factors fac); #endregion #region Properties <summary> Gets or sets the string name of this projection. This should uniquely define the projection, and controls what appears in the .prj files. This name is required. </summary> string Name { get; set; } <summary> Gets or sets the string name of this projection as it is known to proj4, or should appear in a proj4 string. This name is required to read and write to proj4 strings. </summary> string Proj4Name { get; } <summary> This is the list of alternate names to check besides the Proj4Name. This will not be used for writing Proj4 strings, but may be helpful for reading them. </summary> string[] Proj4Aliases { get; } #endregion } }
var fs = require('fs'); var http = require('http'); var d = require('dtrace-provider'); var filed = require('filed'); var Logger = require('bunyan'); var test = require('tap').test; var uuid = require('node-uuid'); var HttpError = require('../lib/errors').HttpError; var RestError = require('../lib/errors').RestError; var Request = require('../lib/request'); var Response = require('../lib/response'); var Server = require('../lib/server'); var restify = require('../lib'); --- Globals var DTRACE = d.<API key>('restifyUnitTest'); var LOGGER = new Logger({name: 'restify/test/server'}); var PORT = process.env.UNIT_TEST_PORT || 12345; --- Tests test('throws on missing options', function (t) { t.throws(function () { return new Server(); }, new TypeError('options (Object) required')); t.end(); }); test('throws on missing dtrace', function (t) { t.throws(function () { return new Server({}); }, new TypeError('options.dtrace (Object) required')); t.end(); }); test('throws on missing bunyan', function (t) { t.throws(function () { return new Server({ dtrace: {} }); }, new TypeError('options.log (Object) required')); t.end(); }); test('ok', function (t) { t.ok(new Server({ dtrace: DTRACE, log: LOGGER })); t.end(); }); test('ok (ssl)', function (t) { // Lame, just make sure we go down the https path try { t.ok(new Server({ dtrace: DTRACE, log: LOGGER, certificate: 'hello', key: 'world' })); t.fail('HTTPS server not created'); } catch (e) { // noop } t.end(); }); test('listen and close (port only)', function (t) { var server = new Server({ dtrace: DTRACE, log: LOGGER }); server.on('listening', function () { server.close(function () { t.end(); }); }); server.listen(PORT); }); test('listen and close (port only) w/ port number as string', function (t) { var server = new Server({ dtrace: DTRACE, log: LOGGER }); server.listen(String(PORT), function () { server.close(function () { t.end(); }); }); }); test('listen and close (port and hostname)', function (t) { var server = new Server({ dtrace: DTRACE, log: LOGGER }); server.listen(PORT, '127.0.0.1', function () { server.close(function () { t.end(); }); }); }); test('listen and close (socketPath)', function (t) { var server = new Server({ dtrace: DTRACE, log: LOGGER }); server.listen('/tmp/.' + uuid(), function () { server.close(function () { t.end(); }); }); }); test('get (path only)', function (t) { var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); server.get('/foo/:id', function tester(req, res, next) { t.ok(req.params); t.equal(req.params.id, 'bar'); res.send(); return next(); }); var done = 0; server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/foo/bar', agent: false }; http.get(opts, function (res) { t.equal(res.statusCode, 200); if (++done == 2) { server.close(function () { t.end(); }); } }); }); server.on('after', function (req, res) { t.ok(req); t.ok(res); if (++done == 2) { server.close(function () { t.end(); }); } }); }); test('get (path and version ok)', function (t) { var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); server.get({ url: '/foo/:id', version: '1.2.3' }, function tester(req, res, next) { t.ok(req.params); t.equal(req.params.id, 'bar'); res.send(); return next(); }); var done = 0; server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/foo/bar', agent: false, headers: { 'accept-version': '~1.2' } }; http.get(opts, function (res) { t.equal(res.statusCode, 200); if (++done == 2) { server.close(function () { t.end(); }); } }); }); server.on('after', function (req, res) { t.ok(req); t.ok(res); if (++done == 2) { server.close(function () { t.end(); }); } }); }); test('get (path and version not ok)', function (t) { var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); server.get({ url: '/foo/:id', version: '1.2.3' }, function (req, res, next) { t.ok(req.params); t.equal(req.params.id, 'bar'); res.send(); return next(); }); server.get({ url: '/foo/:id', version: '1.2.4' }, function (req, res, next) { t.ok(req.params); t.equal(req.params.id, 'bar'); res.send(); return next(); }); server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/foo/bar', agent: false, headers: { 'accept': 'text/plain', 'accept-version': '~2.1' } }; http.get(opts, function (res) { t.equal(res.statusCode, 400); res.setEncoding('utf8'); res.body = ''; res.on('data', function (chunk) { res.body += chunk; }); res.on('end', function () { t.equal(res.body, 'GET /foo/bar supports versions: 1.2.3, 1.2.4'); server.close(function () { t.end(); }); }); }); }); }); test('use - throws TypeError on non function as argument', function (t) { var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); var err = new TypeError('handlers must be Functions'); t.throws(function () { server.use('/nonfn'); }, err); t.throws(function () { server.use({an:'object'}); }, err); t.throws(function () { server.use( function good() { return next() }, '/bad', {really:'bad'} ); }, err); t.end(); }); test('use + get (path only)', function (t) { var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); var handler = 0; server.use(function (req, res, next) { handler++; return next(); }); server.get('/foo/:id', function tester(req, res, next) { t.ok(req.params); t.equal(req.params.id, 'bar'); handler++; res.send(); return next(); }); server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/foo/bar', agent: false }; http.get(opts, function (res) { t.equal(res.statusCode, 200); t.equal(handler, 2); server.close(function () { t.end(); }); }); }); }); test('rm', function (t) { var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); server.get('/foo/:id', function (req, res, next) { return next(); }); server.get('/bar/:id', function (req, res, next) { t.ok(req.params); t.equal(req.params.id, 'foo'); res.send(); return next(); }); t.ok(server.rm('GET /foo/:id')); server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/foo/bar', agent: false }; http.get(opts, function (res) { t.equal(res.statusCode, 404); opts.path = '/bar/foo'; http.get(opts, function (res2) { t.equal(res2.statusCode, 200); server.close(function () { t.end(); }); }); }); }); }); test('405', function (t) { var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); server.post('/foo/:id', function tester(req, res, next) { t.ok(req.params); t.equal(req.params.id, 'bar'); res.send(); return next(); }); server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/foo/bar', agent: false }; http.get(opts, function (res) { t.equal(res.statusCode, 405); t.equal(res.headers.allow, 'POST'); server.close(function () { t.end(); }); }); }); }); test('PUT ok', function (t) { var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); server.put('/foo/:id', function tester(req, res, next) { t.ok(req.params); t.equal(req.params.id, 'bar'); res.send(); return next(); }); server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/foo/bar', method: 'PUT', agent: false }; http.request(opts, function (res) { t.equal(res.statusCode, 200); server.close(function () { t.end(); }); }).end(); }); }); test('PATCH ok', function (t) { var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); server.patch('/foo/:id', function tester(req, res, next) { t.ok(req.params); t.equal(req.params.id, 'bar'); res.send(); return next(); }); server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/foo/bar', method: 'PATCH', agent: false }; http.request(opts, function (res) { t.equal(res.statusCode, 200); server.close(function () { t.end(); }); }).end(); }); }); test('HEAD ok', function (t) { var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); server.head('/foo/:id', function tester(req, res, next) { t.ok(req.params); t.equal(req.params.id, 'bar'); res.send('hi there'); return next(); }); server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/foo/bar', method: 'HEAD', agent: false }; http.request(opts, function (res) { t.equal(res.statusCode, 200); res.on('data', function (chunk) { t.fail('Data was sent on HEAD'); }); server.close(function () { t.end(); }); }).end(); }); }); test('DELETE ok', function (t) { var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); server.del('/foo/:id', function tester(req, res, next) { t.ok(req.params); t.equal(req.params.id, 'bar'); res.send(204, 'hi there'); return next(); }); server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/foo/bar', method: 'DELETE', agent: false }; http.request(opts, function (res) { t.equal(res.statusCode, 204); res.on('data', function (chunk) { t.fail('Data was sent on 204'); }); server.close(function () { t.end(); }); }).end(); }); }); test('OPTIONS', function (t) { var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); ['get', 'post', 'put', 'del'].forEach(function (method) { server[method]('/foo/:id', function tester(req, res, next) { t.ok(req.params); t.equal(req.params.id, 'bar'); res.send(); return next(); }); }); server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/foo/bar', method: 'OPTIONS', agent: false }; http.request(opts, function (res) { t.equal(res.statusCode, 200); t.ok(res.headers.allow); t.equal(res.headers['<API key>'], 'GET, POST, PUT, DELETE'); server.close(function () { t.end(); }); }).end(); }); }); test('RegExp ok', function (t) { var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); server.get(/\/foo/, function tester(req, res, next) { res.send('hi there'); return next(); }); server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/foo', method: 'GET', agent: false }; http.request(opts, function (res) { t.equal(res.statusCode, 200); server.close(function () { t.end(); }); }).end(); }); }); test('path+flags ok', function (t) { var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); server.get({path: '/foo', flags: 'i'}, function tester(req, res, next) { res.send('hi there'); return next(); }); server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/FOO', method: 'GET', agent: false }; http.request(opts, function (res) { t.equal(res.statusCode, 200); server.close(function () { t.end(); }); }).end(); }); }); test('GH-56 streaming with filed (download)', function (t) { var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); server.get('/foo.txt', function tester(req, res, next) { filed(__filename).pipe(res); }); server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/foo.txt', method: 'GET', agent: false }; http.request(opts, function (res) { t.equal(res.statusCode, 200); var body = ''; res.setEncoding('utf8'); res.on('data', function (chunk) { body += chunk; }); res.on('end', function () { t.ok(body.length > 0); server.close(function () { t.end(); }); }); }).end(); }); }); test('GH-59 Query params with / result in a 404', function (t) { var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); server.get('/', function tester(req, res, next) { res.send('hello'); return next(); }); server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/?foo=bar/foo', method: 'GET', agent: false, headers: { accept: 'text/plain' } }; http.request(opts, function (res) { t.equal(res.statusCode, 200); var body = ''; res.setEncoding('utf8'); res.on('data', function (chunk) { body += chunk; }); res.on('end', function () { t.equal(body, 'hello'); server.close(function () { t.end(); }); }); }).end(); }); }); test('GH-63 res.send 204 is sending a body', function (t) { var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); server.del('/hello/:name', function tester(req, res, next) { res.send(204); return next(); }); server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/hello/mark', method: 'DELETE', agent: false, headers: { accept: 'text/plain' } }; http.request(opts, function (res) { t.equal(res.statusCode, 204); var body = ''; res.setEncoding('utf8'); res.on('data', function (chunk) { body += chunk; }); res.on('end', function () { t.notOk(body); server.close(function () { t.end(); }); }); }).end(); }); }); test('GH-64 prerouting chain', function (t) { var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); server.pre(function (req, res, next) { req.log.info('prerouting chain'); req.headers.accept = 'application/json'; return next(); }); server.get('/hello/:name', function tester(req, res, next) { res.send(req.params.name); return next(); }); server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/hello/mark', method: 'GET', agent: false, headers: { accept: 'text/plain' } }; http.request(opts, function (res) { t.equal(res.statusCode, 200); var body = ''; res.setEncoding('utf8'); res.on('data', function (chunk) { body += chunk; }); res.on('end', function () { t.equal(body, '\"mark\"'); server.close(function () { t.end(); }); }); }).end(); }); }); test('GH-64 prerouting chain with error', function (t) { var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); server.pre(function (req, res, next) { return next(new RestError(400, 'BadRequest', 'screw you client')); }); server.get('/hello/:name', function tester(req, res, next) { res.send(req.params.name); return next(); }); server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/hello/mark', method: 'GET', agent: false, headers: { accept: 'text/plain' } }; http.request(opts, function (res) { t.equal(res.statusCode, 400); var body = ''; res.setEncoding('utf8'); res.on('data', function (chunk) { body += chunk; }); res.on('end', function () { t.equal(body, 'screw you client'); server.close(function () { t.end(); }); }); }).end(); }); }); test('GH-67 extend access-control headers', function (t) { var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); server.get('/hello/:name', function tester(req, res, next) { res.header('<API key>', (res.header('<API key>') + ', If-Match, If-None-Match')); res.send(req.params.name); return next(); }); server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/hello/mark', method: 'GET', agent: false, headers: { accept: 'text/plain' } }; http.request(opts, function (res) { t.equal(res.statusCode, 200); var body = ''; res.setEncoding('utf8'); res.on('data', function (chunk) { body += chunk; }); res.on('end', function () { t.equal(body, 'mark'); server.close(function () { t.ok(res.headers['<API key>'].indexOf('If-Match')); t.end(); }); }); }).end(); }); }); test('GH-77 uncaughtException (default behavior)', function (t) { var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); server.get('/', function (req, res, next) { throw new Error('Catch me!'); }); server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/', method: 'GET', agent: false, headers: { accept: 'text/plain' } }; http.request(opts, function (res) { t.equal(res.statusCode, 500); var body = ''; res.setEncoding('utf8'); res.on('data', function (chunk) { body += chunk; }); res.on('end', function () { t.equal(body, 'Catch me!'); server.close(function () { t.end(); }); }); }).end(); }); }); test('GH-77 uncaughtException (with custom handler)', function (t) { var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); server.on('uncaughtException', function (req, res, route, err) { res.send(204); }); server.get('/', function (req, res, next) { throw new Error('Catch me!'); }); server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/', method: 'GET', agent: false, headers: { accept: 'text/plain' } }; http.request(opts, function (res) { t.equal(res.statusCode, 204); var body = ''; res.setEncoding('utf8'); res.on('data', function (chunk) { body += chunk; }); res.on('end', function () { t.equal(body, ''); server.close(function () { t.end(); }); }); }).end(); }); }); test('GH-77 uncaughtException (with custom handler)', function (t) { var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); server.on('uncaughtException', function (req, res, route, err) { res.send(204); }); server.get('/', function (req, res, next) { throw new Error('Catch me!'); }); server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/', method: 'GET', agent: false, headers: { accept: 'text/plain' } }; http.request(opts, function (res) { t.equal(res.statusCode, 204); var body = ''; res.setEncoding('utf8'); res.on('data', function (chunk) { body += chunk; }); res.on('end', function () { t.equal(body, ''); server.close(function () { t.end(); }); }); }).end(); }); }); test('GH-97 malformed URI breaks server', function (t) { var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); server.get('/echo/:name', function (req, res, next) { res.send(200); return next(); }); server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/echo/mark%', method: 'GET', agent: false, headers: { accept: 'text/plain' } }; http.request(opts, function (res) { t.equal(res.statusCode, 400); var body = ''; res.setEncoding('utf8'); res.on('data', function (chunk) { body += chunk; }); res.on('end', function () { t.ok(body); server.close(function () { t.end(); }); }); }).end(); }); }); test('GH-109 RegExp flags not honored', function (t) { var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); server.get(/\/echo\/(\w+)/i, function (req, res, next) { res.send(200, req.params[0]); return next(); }); server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/ECHO/mark', method: 'GET', agent: false, headers: { accept: 'text/plain' } }; http.request(opts, function (res) { t.equal(res.statusCode, 200); var body = ''; res.setEncoding('utf8'); res.on('data', function (chunk) { body += chunk; }); res.on('end', function () { t.equal(body, 'mark'); server.close(function () { t.end(); }); }); }).end(); }); }); test('GH-141 return next(err) not working', function (t) { var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); server.use(restify.authorizationParser()); server.use(function authenticate(req, res, next) { if (req.username !== 'admin' || !req.authorization.basic || req.authorization.basic.password !== 'admin') { return next(new restify.NotAuthorizedError('invalid credentials')); } return next(); }); server.get('/', function (req, res, next) { res.send(200, req.username); return next(); }); server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/', method: 'GET', agent: false, headers: { accept: 'text/plain', authorization: 'Basic ' + new Buffer('admin:foo').toString('base64') } }; http.request(opts, function (res) { t.equal(res.statusCode, 403); var body = ''; res.setEncoding('utf8'); res.on('data', function (chunk) { body += chunk; }); res.on('end', function () { t.equal(body, 'invalid credentials'); server.close(function () { t.end(); }); }); }).end(); }); }); // Disabled, as Heroku (travis) doesn't allow us to write to /tmp // test('GH-56 streaming with filed (upload)', function (t) { // var server = restify.createServer({ dtrace: DTRACE, log: LOGGER }); // var file = '/tmp/.' + uuid(); // server.put('/foo', function tester(req, res, next) { // req.pipe(filed(file)).pipe(res); // server.listen(PORT, function () { // var opts = { // hostname: 'localhost', // port: PORT, // path: '/foo', // method: 'PUT', // agent: false // var req = http.request(opts, function (res) { // t.equal(res.statusCode, 201); // res.on('end', function () { // fs.readFile(file, 'utf8', function (err, data) { // t.ifError(err); // t.equal(data, 'hello world'); // server.close(function () { // fs.unlink(file, function () { // t.end(); // req.write('hello world'); // req.end(); test('GH-149 limit request body size (form)', function (t) { var server = restify.createServer(); server.use(restify.bodyParser({maxBodySize: 1024})); server.post('/', function (req, res, next) { res.send(200, {length: req.body.length}); return next(); }); server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/', method: 'POST', agent: false, headers: { 'accept': 'application/json', 'content-type': 'application/<API key>', 'transfer-encoding': 'chunked' } }; var req = http.request(opts, function (res) { t.equal(res.statusCode, 413); res.on('end', function () { server.close(function () { t.end(); }); }); }); req.write(new Array(1026).join('x')); req.end(); }); }); test('GH-149 limit request body size (json)', function (t) { var server = restify.createServer(); server.use(restify.bodyParser({maxBodySize: 1024})); server.post('/', function (req, res, next) { res.send(200, {length: req.body.length}); return next(); }); server.listen(PORT, function () { var opts = { hostname: 'localhost', port: PORT, path: '/', method: 'POST', agent: false, headers: { 'accept': 'application/json', 'content-type': 'application/json', 'transfer-encoding': 'chunked' } }; var req = http.request(opts, function (res) { t.equal(res.statusCode, 413); res.on('end', function () { server.close(function () { t.end(); }); }); }); req.write('{"a":[' + new Array(512).join('1,') + '0]}'); req.end(); }); });
#ifndef ASF_H #define ASF_H /* * This file includes all API header files for the selected drivers from ASF. * Note: There might be duplicate includes required by more than one driver. * * The file is automatically generated and will be re-written when * running the ASF driver selector tool. Any changes will be discarded. */ // From module: Common SAM compiler driver #include <compiler.h> #include <status_codes.h> // From module: GPIO - General purpose Input/Output #include <gpio.h> // From module: Generic board support #include <board.h> // From module: IOPORT - General purpose I/O service #include <ioport.h> // From module: Interrupt management - SAM implementation #include <interrupt.h> // From module: PDC - Peripheral DMA Controller Example #include <pdc.h> // From module: PIO - Parallel Input/Output Controller #include <pio.h> // From module: PMC - Power Management Controller #include <pmc.h> #include <sleep.h> // From module: Part identification macros #include <parts.h> // From module: SAM4S EK LED support enabled #include <led.h> // From module: Standard serial I/O (stdio) - SAM implementation #include <stdio_serial.h> // From module: System Clock Control - SAM4S implementation #include <sysclk.h> // From module: UART - Univ. Async Rec/Trans #include <uart.h> // From module: USART - Serial interface - SAM implementation for devices with both UART and USART #include <serial.h> // From module: USART - Univ. Syn Async Rec/Trans #include <usart.h> // From module: pio_handler support enabled #include <pio_handler.h> #endif // ASF_H
{-# LANGUAGE PackageImports #-} import "devel-example" DevelExample (develMain) main :: IO () main = develMain
var dom = require("../../../../lib/jsdom/level1/core").dom.level1.core; exports.hc_staff = function() { var doc = new dom.Document("html"); var implementation = new dom.DOMImplementation(doc, { "XML" : "1.0" }); var notations = new dom.NotationNodeMap( doc, doc.createNotationNode("notation1","notation1File", null), doc.createNotationNode("notation2",null, "notation2File") ); // TODO: consider importing the master list of entities var entities = new dom.EntityNodeMap( doc, doc.createEntityNode("alpha", "α"), doc.createEntityNode("beta", "&#946;"), doc.createEntityNode("gamma", "&#947;"), doc.createEntityNode("delta", "&#948;"), doc.createEntityNode("epsilon", "&#949;") ); // <!ATTLIST acronym dir CDATA "ltr"> var defaultAttributes = new dom.NamedNodeMap(doc); var acronym = doc.createElement("acronym"); acronym.setAttribute("dir", "ltr"); defaultAttributes.setNamedItem(acronym); var doctype = new dom.DocumentType(doc, "svg", entities, notations, defaultAttributes); doc.doctype = doctype; doc.implementation = implementation; doc.appendChild(doc.createComment(" This is comment number 1.")); var html = doc.createElement("svg"); var html = doc.appendChild(html); //<rect x="0" y="0" width="100" height="100"/><script type="text/ecmascript">&svgtest;&svgunit;</script> var rect = doc.createElement("rect"); rect.setAttribute("x", "0"); rect.setAttribute("y", "0"); rect.setAttribute("width", "100"); rect.setAttribute("height", "100"); html.appendChild(rect); var script = doc.createElement("script"); script.setAttribute("type", "text/ecmascript"); script.nodeValue = "&svgtest;&svgunit;"; html.appendChild(script); var head = doc.createElement("head"); var head = html.appendChild(head); var meta = doc.createElement("meta"); meta.setAttribute("http-equiv", "Content-Type"); meta.setAttribute("content", "text/html; charset=UTF-8"); head.appendChild(meta); var title = doc.createElement("title") title.appendChild(doc.createTextNode("hc_staff")); var title = head.appendChild(title); var body = doc.createElement("body"); var staff = html.appendChild(body); var employees = []; var addresses = []; var names = []; var positions = []; var genders = []; var ids = []; var salaries = []; // create 5 employees for (var i=0; i<5; i++) { var employee = doc.createElement("p"); var address = doc.createElement("acronym"); var name = doc.createElement("strong"); var position = doc.createElement("code"); var gender = doc.createElement("var"); var id = doc.createElement("em"); var salary = doc.createElement("sup"); employee.appendChild(doc.createTextNode("\r\n")); employee.appendChild(id); employee.appendChild(doc.createTextNode("\r\n")); employee.appendChild(name); employee.appendChild(doc.createTextNode("\r\n")); employee.appendChild(position); employee.appendChild(doc.createTextNode("\r\n")); employee.appendChild(salary); employee.appendChild(doc.createTextNode("\r\n")); employee.appendChild(gender); employee.appendChild(doc.createTextNode("\r\n")); if (i===1) { employee.appendChild(doc.createTextNode("\r\n")); } employee.appendChild(address); employee.appendChild(doc.createTextNode("\r\n")); staff.appendChild(employee); names.push(name); employees.push(employee); addresses.push(address); genders.push(gender); positions.push(position); ids.push(id); salaries.push(salary); } ids[0].appendChild(doc.createTextNode("EMP0001")); salaries[0].appendChild(doc.createTextNode("56,000")); addresses[0].setAttribute("title", "Yes"); addresses[0].appendChild(doc.createTextNode('1230 North Ave. Dallas, Texas 98551')); names[0].appendChild(doc.createTextNode("Margaret Martin")); genders[0].appendChild(doc.createTextNode("Female")); positions[0].appendChild(doc.createTextNode("Accountant")); ids[1].appendChild(doc.createTextNode("EMP0002")); salaries[1].appendChild(doc.createTextNode("35,000")); addresses[1].setAttribute("title", "Yes"); addresses[1].setAttribute("class", "Yes"); addresses[1].appendChild(doc.createTextNode("β Dallas, γ\n 98554")); names[1].appendChild(doc.createTextNode("Martha Raynolds")); names[1].appendChild(doc.createCDATASection("This is a CDATASection with EntityReference number 2 &amp;ent2;")); names[1].appendChild(doc.createCDATASection("This is an adjacent CDATASection with a reference to a tab &amp;tab;")); genders[1].appendChild(doc.createTextNode("Female")); positions[1].appendChild(doc.createTextNode("Secretary")); ids[2].appendChild(doc.createTextNode("EMP0003")); salaries[2].appendChild(doc.createTextNode("100,000")); addresses[2].setAttribute("title", "Yes"); addresses[2].setAttribute("class", "No"); addresses[2].appendChild(doc.createTextNode("PO Box 27 Irving, texas 98553")); names[2].appendChild(doc.createTextNode("Roger\n Jones")) ; genders[2].appendChild(doc.<API key>("&delta;"));//Text("&delta;")); positions[2].appendChild(doc.createTextNode("Department Manager")); ids[3].appendChild(doc.createTextNode("EMP0004")); salaries[3].appendChild(doc.createTextNode("95,000")); addresses[3].setAttribute("title", "Yes"); addresses[3].setAttribute("class", "Yα"); addresses[3].appendChild(doc.createTextNode("27 South Road. Dallas, Texas 98556")); names[3].appendChild(doc.createTextNode("Jeny Oconnor")); genders[3].appendChild(doc.createTextNode("Female")); positions[3].appendChild(doc.createTextNode("Personal Director")); ids[4].appendChild(doc.createTextNode("EMP0005")); salaries[4].appendChild(doc.createTextNode("90,000")); addresses[4].setAttribute("title", "Yes"); addresses[4].appendChild(doc.createTextNode("1821 Nordic. Road, Irving Texas 98558")); names[4].appendChild(doc.createTextNode("Robert Myers")); genders[4].appendChild(doc.createTextNode("male")); positions[4].appendChild(doc.createTextNode("Computer Specialist")); doc.appendChild(doc.<API key>("TEST-STYLE", "PIDATA")); doc.normalize(); return doc; };
var searchData= [ ['tagbitmapfileheader',['tagBITMAPFILEHEADER',['../<API key>.html',1,'']]], ['tagbitmapinfoheader',['tagBITMAPINFOHEADER',['../<API key>.html',1,'']]], ['texture',['Texture',['../class_texture.html',1,'']]] ];
<?php namespace Magento\Backend\Test\Constraint; use Magento\Backend\Test\Fixture\GlobalSearch; use Magento\Backend\Test\Page\Adminhtml\Dashboard; use Magento\Sales\Test\Fixture\OrderInjectable; use Magento\Mtf\Constraint\AbstractConstraint; /** * Class <API key> * Assert that product name is present in search results */ class <API key> extends AbstractConstraint { /** * Assert that product name is present in search results * * @param Dashboard $dashboard * @param GlobalSearch $search * @return void */ public function processAssert(Dashboard $dashboard, GlobalSearch $search) { $entity = $search->getDataFieldConfig('query')['source']->getEntity(); $product = $entity instanceof OrderInjectable ? $entity->getEntityId()['products'][0] : $entity; $productName = $product->getName(); $isVisibleInResult = $dashboard->getAdminPanelHeader()-><API key>($productName); \<API key>::assertTrue( $isVisibleInResult, 'Product name ' . $productName . ' is absent in search results' ); } /** * Returns a string representation of the object. * * @return string */ public function toString() { return 'Product name is present in search results'; } }
#include "<API key>.h" #include <bond/core/bond.h> #include <bond/stream/output_buffer.h> #include <bond/protocol/simple_json_writer.h> using namespace examples::string_ref; int main() { Example obj, obj2; const char* text = "Alice was beginning to get very tired of sitting by her sister on the " "bank and of having nothing to do: once or twice she had peeped into the " "book her sister was reading but it had no pictures or conversations in " "it 'and what is the use of a book' thought Alice 'without pictures or " "conversation?'"; using examples::string_ref::string_ref; // Create a vector of string_refs, each pointing to a word in the source // text. Using boost::string_ref instead of std::string avoid allocating // and coping memory. // Note that string_ref can be only used as a read-only string, so we could // not deserialize into a string_ref. for (const char *begin = text, *end = text;; ++end) { if (*end == ' ' || *end == '\x0') { obj.words.push_back(string_ref(begin, end - begin)); begin = end + 1; if (*end == '\x0') break; } } // Serialize the object to Json bond::OutputBuffer output; bond::SimpleJsonWriter<bond::OutputBuffer> writer(output); Serialize(obj, writer); return 0; }
// CoverArtdisplay.cs // Gabriel Burt <gburt@novell.com> // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // included in all copies or substantial portions of the Software. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. using System; using System.Collections.Generic; using Mono.Unix; using Gtk; using Cairo; using Hyena; using Hyena.Gui; using Hyena.Gui.Theatrics; using Banshee.Base; using Banshee.Collection; using Banshee.Collection.Gui; using Banshee.ServiceStack; using Banshee.MediaEngine; namespace Banshee.Gui.Widgets { public class CoverArtDisplay : TrackInfoDisplay { private ImageSurface idle_album; public CoverArtDisplay () { } public override void Dispose () { var disposable = idle_album as IDisposable; if (disposable != null) { disposable.Dispose (); } base.Dispose (); } protected override int ArtworkSizeRequest { get { return Allocation.Width; } } protected override void RenderTrackInfo (Cairo.Context cr, TrackInfo track, bool renderTrack, bool renderArtistAlbum) { } protected override bool CanRenderIdle { get { return true; } } protected override void RenderIdle (Cairo.Context cr) { idle_album = idle_album ?? PixbufImageSurface.Create (Banshee.Gui.IconThemeUtils.LoadIcon ( ArtworkSizeRequest, <API key>), true); ArtworkRenderer.RenderThumbnail (cr, idle_album, false, Allocation.X, Allocation.Y, ArtworkSizeRequest, ArtworkSizeRequest, false, 0, true, BackgroundColor); } } }
namespace UnitTest.Convert { using System; using System.Collections.Generic; using System.Text; using System.Threading; using Bond; using Bond.IO.Safe; using Bond.Protocols; using NUnit.Framework; [global::Bond.Schema] public class Dates { [global::Bond.Id(0), global::Bond.Type(typeof(long))] public System.DateTime _date { get; set; } [global::Bond.Id(1), global::Bond.Type(typeof(List<long>))] public List<System.DateTime> _dateVector { get; set; } [global::Bond.Id(2), global::Bond.Type(typeof(LinkedList<long>))] public LinkedList<System.DateTime> _dateList { get; set; } [global::Bond.Id(3), global::Bond.Type(typeof(Dictionary<int,long>))] public Dictionary<int, System.DateTime> _dateMap { get; set; } [global::Bond.Id(4), global::Bond.Type(typeof(global::Bond.Tag.nullable<long>))] public System.DateTime? _dateNullable { get; set; } [global::Bond.Id(5), global::Bond.Type(typeof(long)), global::Bond.Required] public System.DateTime _dateRequired { get; set; } [global::Bond.Id(6), global::Bond.Type(typeof(long)), global::Bond.RequiredOptional] public System.DateTime <API key> { get; set; } public Dates() : this("UnitTest.Convert.Dates", "Dates") { } protected Dates(string fullName, string name) { _date = new System.DateTime(); _dateVector = new List<System.DateTime>(); _dateList = new LinkedList<System.DateTime>(); _dateMap = new Dictionary<int, System.DateTime>(); _dateNullable = null; _dateRequired = new System.DateTime(); <API key> = new System.DateTime(); } internal int CountInstances() { return 3 + _dateVector.Count + _dateList.Count + _dateMap.Count + (_dateNullable.HasValue ? 1 : 0); } } [global::Bond.Schema] public class Decimals { [global::Bond.Id(0), global::Bond.Type(typeof(global::Bond.Tag.blob))] public decimal _dec { get; set; } [global::Bond.Id(1), global::Bond.Type(typeof(List<global::Bond.Tag.blob>))] public List<decimal> _decVector { get; set; } [global::Bond.Id(2), global::Bond.Type(typeof(LinkedList<global::Bond.Tag.blob>))] public LinkedList<decimal> _decList { get; set; } [global::Bond.Id(3), global::Bond.Type(typeof(Dictionary<int, global::Bond.Tag.blob>))] public Dictionary<int, decimal> _decMap { get; set; } [global::Bond.Id(4), global::Bond.Type(typeof(global::Bond.Tag.nullable<global::Bond.Tag.blob>))] public decimal? _decNullable { get; set; } [global::Bond.Id(5), global::Bond.Type(typeof(global::Bond.Tag.blob)), global::Bond.Required] public decimal _decRequired { get; set; } [global::Bond.Id(6), global::Bond.Type(typeof(global::Bond.Tag.blob)), global::Bond.RequiredOptional] public decimal <API key> { get; set; } public Decimals() : this("UnitTest.Convert.Decimals", "Decimals") { } protected Decimals(string fullName, string name) { _dec = new decimal(); _decVector = new List<decimal>(); _decList = new LinkedList<decimal>(); _decMap = new Dictionary<int, decimal>(); _decNullable = null; _decRequired = new decimal(); <API key> = new decimal(); } internal int CountInstances() { return 3 + _decVector.Count + _decList.Count + _decMap.Count + (_decNullable.HasValue ? 1 : 0); } } public class RefObject : IEquatable<RefObject> { public RefObject() : this("") { } public RefObject(string value) { Value = value; } public string Value { get; } public bool Equals(RefObject other) { if (ReferenceEquals(other, null)) return false; if (ReferenceEquals(other, this)) return true; return this.Value == other.Value; } public override int GetHashCode() { return Value.GetHashCode(); } public override bool Equals(object obj) { return Equals(obj as RefObject); } public static bool operator ==(RefObject left, RefObject right) { return Equals(left, right); } public static bool operator !=(RefObject left, RefObject right) { return !(left == right); } } [global::Bond.Schema] public class RefObjects { [global::Bond.Id(0), global::Bond.Type(typeof(global::Bond.Tag.blob))] public RefObject _ref { get; set; } [global::Bond.Id(1), global::Bond.Type(typeof(List<global::Bond.Tag.blob>))] public List<RefObject> _refVector { get; set; } [global::Bond.Id(2), global::Bond.Type(typeof(LinkedList<global::Bond.Tag.blob>))] public LinkedList<RefObject> _refList { get; set; } [global::Bond.Id(3), global::Bond.Type(typeof(Dictionary<int, global::Bond.Tag.blob>))] public Dictionary<int, RefObject> _refMap { get; set; } [global::Bond.Id(4), global::Bond.Type(typeof(global::Bond.Tag.nullable<global::Bond.Tag.blob>))] public RefObject _refNullable { get; set; } [global::Bond.Id(5), global::Bond.Type(typeof(global::Bond.Tag.blob)), global::Bond.Required] public RefObject _refRequired { get; set; } [global::Bond.Id(6), global::Bond.Type(typeof(global::Bond.Tag.blob)), global::Bond.RequiredOptional] public RefObject <API key> { get; set; } public RefObjects() : this("UnitTest.Convert.RefObjects", "RefObjects") { } protected RefObjects(string fullName, string name) { _ref = new RefObject(); _refVector = new List<RefObject>(); _refList = new LinkedList<RefObject>(); _refMap = new Dictionary<int, RefObject>(); _refNullable = null; _refRequired = new RefObject(); <API key> = new RefObject(); } internal int CountInstances() { return 3 + _refVector.Count + _refList.Count + _refMap.Count + (_refNullable != null ? 1 : 0); } } public static class <API key> { public static int <API key> = 0; public static int <API key> = 0; public static int <API key> = 0; public static int <API key> = 0; public static int <API key> = 0; public static int <API key> = 0; public static DateTime Convert(long value, DateTime unused) { Interlocked.Increment(ref <API key>); return new DateTime(value, DateTimeKind.Utc); } public static long Convert(DateTime value, long unused) { Interlocked.Increment(ref <API key>); return value.ToUniversalTime().Ticks; } public static decimal Convert(ArraySegment<byte> value, decimal unused) { var bits = new int[value.Count / sizeof(int)]; Buffer.BlockCopy(value.Array, value.Offset, bits, 0, bits.Length * sizeof(int)); Interlocked.Increment(ref <API key>); return new decimal(bits); } public static ArraySegment<byte> Convert(decimal value, ArraySegment<byte> unused) { var bits = decimal.GetBits(value); var data = new byte[bits.Length * sizeof(int)]; Buffer.BlockCopy(bits, 0, data, 0, data.Length); Interlocked.Increment(ref <API key>); return new ArraySegment<byte>(data); } public static RefObject Convert(ArraySegment<byte> value, RefObject unused) { Interlocked.Increment(ref <API key>); return new RefObject(Encoding.ASCII.GetString(value.Array, value.Offset, value.Count)); } public static ArraySegment<byte> Convert(RefObject value, ArraySegment<byte> unused) { Interlocked.Increment(ref <API key>); return new ArraySegment<byte>(Encoding.ASCII.GetBytes(value.Value)); } public static void ResetCounts() { <API key> = 0; <API key> = 0; <API key> = 0; <API key> = 0; <API key> = 0; <API key> = 0; } } [TestFixture] public class ConvertTests { [SetUp] public void Setup() { <API key>.ResetCounts(); } [Test] public void <API key>() { var foo = new Dates(); foo._date = MakeUtcDateTime(2015,1,8); foo._dateVector.Add(MakeUtcDateTime(2015,1,9)); foo._dateVector.Add(MakeUtcDateTime(2015,1,10)); foo._dateList.AddLast(MakeUtcDateTime(2015, 1, 11)); foo._dateList.AddLast(MakeUtcDateTime(2015, 1, 12)); foo._dateList.AddLast(MakeUtcDateTime(2015, 1, 13)); foo._dateMap.Add(1, MakeUtcDateTime(2015, 1, 14)); foo._dateMap.Add(2, MakeUtcDateTime(2015, 1, 15)); foo._dateMap.Add(3, MakeUtcDateTime(2015, 1, 16)); foo._dateNullable = MakeUtcDateTime(2015, 1, 17); foo._dateRequired = MakeUtcDateTime(2015, 1, 18); foo.<API key> = MakeUtcDateTime(2015, 1, 19); var output = new OutputBuffer(); var writer = new CompactBinaryWriter<OutputBuffer>(output); var serializer = new Serializer<CompactBinaryWriter<OutputBuffer>>(typeof(Dates)); serializer.Serialize(foo, writer); Assert.AreEqual(foo.CountInstances(), <API key>.<API key>); Assert.AreEqual(0, <API key>.<API key>); } [Test] public void <API key>() { var foo = new Dates(); foo._date = MakeUtcDateTime(2015,1,8); foo._dateVector.Add(MakeUtcDateTime(2015,1,9)); foo._dateVector.Add(MakeUtcDateTime(2015,1,10)); foo._dateList.AddLast(MakeUtcDateTime(2015, 1, 11)); foo._dateList.AddLast(MakeUtcDateTime(2015, 1, 12)); foo._dateList.AddLast(MakeUtcDateTime(2015, 1, 13)); foo._dateMap.Add(1, MakeUtcDateTime(2015, 1, 14)); foo._dateMap.Add(2, MakeUtcDateTime(2015, 1, 15)); foo._dateMap.Add(3, MakeUtcDateTime(2015, 1, 16)); foo._dateNullable = MakeUtcDateTime(2015, 1, 17); foo._dateRequired = MakeUtcDateTime(2015, 1, 18); foo.<API key> = MakeUtcDateTime(2015, 1, 19); var output = new OutputBuffer(); var writer = new CompactBinaryWriter<OutputBuffer>(output); var serializer = new Serializer<CompactBinaryWriter<OutputBuffer>>(typeof(Dates)); serializer.Serialize(foo, writer); var input = new InputBuffer(output.Data); var reader = new CompactBinaryReader<InputBuffer>(input); var deserializer = new Deserializer<CompactBinaryReader<InputBuffer>>(typeof(Dates)); var foo2 = deserializer.Deserialize<Dates>(reader); Assert.AreEqual(foo.CountInstances(), <API key>.<API key>); Assert.AreEqual(foo2.CountInstances(), <API key>.<API key>); Assert.AreEqual(foo.CountInstances(), foo2.CountInstances()); Assert.IsTrue(Bond.Comparer.Equal(foo, foo2)); } [Test] public void <API key>() { var foo = new Decimals(); foo._dec = new decimal(19.91); foo._decVector.Add(new decimal(10.10)); foo._decVector.Add(new decimal(11.11)); foo._decList.AddLast(new decimal(12.12)); foo._decList.AddLast(new decimal(13.13)); foo._decList.AddLast(new decimal(14.14)); foo._decMap.Add(1, new decimal(15.15)); foo._decMap.Add(2, new decimal(16.16)); foo._decMap.Add(3, new decimal(17.17)); foo._decNullable = new decimal(20.20); foo._decRequired = new decimal(21.21); foo.<API key> = new decimal(22.22); var output = new OutputBuffer(); var writer = new CompactBinaryWriter<OutputBuffer>(output); var serializer = new Serializer<CompactBinaryWriter<OutputBuffer>>(typeof(Decimals)); serializer.Serialize(foo, writer); Assert.AreEqual(foo.CountInstances(), <API key>.<API key>); Assert.AreEqual(0, <API key>.<API key>); } [Test] public void <API key>() { var foo = new Decimals(); foo._dec = new decimal(19.91); foo._decVector.Add(new decimal(10.10)); foo._decVector.Add(new decimal(11.11)); foo._decList.AddLast(new decimal(12.12)); foo._decList.AddLast(new decimal(13.13)); foo._decList.AddLast(new decimal(14.14)); foo._decMap.Add(1, new decimal(15.15)); foo._decMap.Add(2, new decimal(16.16)); foo._decMap.Add(3, new decimal(17.17)); foo._decNullable = new decimal(20.20); foo._decRequired = new decimal(21.21); foo.<API key> = new decimal(22.22); var output = new OutputBuffer(); var writer = new CompactBinaryWriter<OutputBuffer>(output); var serializer = new Serializer<CompactBinaryWriter<OutputBuffer>>(typeof(Decimals)); serializer.Serialize(foo, writer); var input = new InputBuffer(output.Data); var reader = new CompactBinaryReader<InputBuffer>(input); var deserializer = new Deserializer<CompactBinaryReader<InputBuffer>>(typeof(Decimals)); var foo2 = deserializer.Deserialize<Decimals>(reader); Assert.AreEqual(foo.CountInstances(), <API key>.<API key>); Assert.AreEqual(foo2.CountInstances(), <API key>.<API key>); Assert.AreEqual(foo.CountInstances(), foo2.CountInstances()); Assert.IsTrue(Bond.Comparer.Equal(foo, foo2)); } [Test] public void <API key>() { var foo = new RefObjects(); foo._ref = new RefObject("1111"); foo._refVector.Add(new RefObject("2222")); foo._refVector.Add(new RefObject("3333")); foo._refList.AddLast(new RefObject("4444")); foo._refList.AddLast(new RefObject("5555")); foo._refList.AddLast(new RefObject("6666")); foo._refMap.Add(1, new RefObject("7777")); foo._refMap.Add(2, new RefObject("8888")); foo._refMap.Add(3, new RefObject("9999")); foo._refNullable = new RefObject("10010"); foo._refRequired = new RefObject("11011"); foo.<API key> = new RefObject("12012"); var output = new OutputBuffer(); var writer = new CompactBinaryWriter<OutputBuffer>(output); var serializer = new Serializer<CompactBinaryWriter<OutputBuffer>>(typeof(RefObjects)); serializer.Serialize(foo, writer); Assert.AreEqual(foo.CountInstances(), <API key>.<API key>); Assert.AreEqual(0, <API key>.<API key>); } [Test] public void <API key>() { var foo = new RefObjects(); foo._ref = new RefObject("1111"); foo._refVector.Add(new RefObject("2222")); foo._refVector.Add(new RefObject("3333")); foo._refList.AddLast(new RefObject("4444")); foo._refList.AddLast(new RefObject("5555")); foo._refList.AddLast(new RefObject("6666")); foo._refMap.Add(1, new RefObject("7777")); foo._refMap.Add(2, new RefObject("8888")); foo._refMap.Add(3, new RefObject("9999")); foo._refNullable = new RefObject("10010"); foo._refRequired = new RefObject("11011"); foo.<API key> = new RefObject("12012"); var output = new OutputBuffer(); var writer = new CompactBinaryWriter<OutputBuffer>(output); var serializer = new Serializer<CompactBinaryWriter<OutputBuffer>>(typeof(RefObjects)); serializer.Serialize(foo, writer); var input = new InputBuffer(output.Data); var reader = new CompactBinaryReader<InputBuffer>(input); var deserializer = new Deserializer<CompactBinaryReader<InputBuffer>>(typeof(RefObjects)); var foo2 = deserializer.Deserialize<RefObjects>(reader); Assert.AreEqual(foo.CountInstances(), <API key>.<API key>); Assert.AreEqual(foo2.CountInstances(), <API key>.<API key>); Assert.AreEqual(foo.CountInstances(), foo2.CountInstances()); Assert.IsTrue(Bond.Comparer.Equal(foo, foo2)); } private static DateTime MakeUtcDateTime(int year, int month, int day) { return new DateTime(year, month, day, 0, 0, 0, DateTimeKind.Utc); } } }
#import <Foundation/Foundation.h> #import "ESTDefinitions.h" @class <API key>; <API key> /** * ESTStorageManager class is responsible for managing Location Beacon's non-volatile storage. */ @interface ESTStorageManager : NSObject /** * Dictionary of data stored in Estimote Storage. */ @property (nonatomic, strong, readonly) NSDictionary *storageDictionary; /** * Designated initializer. * * @param deviceIdentifier Identifier of device * @param peripheral <API key> object of device * * @return Initilized ESTStorageManager object with empty storageDictionary property. */ - (instancetype)<API key>:(NSString *)deviceIdentifier peripheral:(<API key> *)peripheral; /** * Method for reading storageDictionary from Estimote Storage. Authorized conenction is optional. * * @param completion Completion block with Estimote Storage current dictionary content. */ - (void)<API key>:(<API key>)completion; /** * Method for overwriting storageDictionary. Authorized connection required. * * @param dictionary NSDictionary object that will overwrite storageDictionary. * @param completion Completion block returning NSError if saving to Estimote Storage would fail. */ - (void)<API key>:(NSDictionary *)dictionary withCompletion:(ESTCompletionBlock)completion; @end <API key>
<html xmlns="http: <head> <title>OpenLayers: Single Tile</title> <link rel="stylesheet" href="../theme/default/style.css" type="text/css" /> <link rel="stylesheet" href="style.css" type="text/css" /> <script src="../lib/OpenLayers.js"></script> <script type="text/javascript"> var map; function init(){ map = new OpenLayers.Map('mapDiv', {maxResolution: 'auto'}); var old_ol_wms = new OpenLayers.Layer.WMS.Untiled( "WMS.Untiled", "http://vmap0.tiles.osgeo.org/wms/vmap0?", {layers: 'basic'} ); old_ol_wms.addOptions({isBaseLayer: true}); var new_ol_wms = new OpenLayers.Layer.WMS( "WMS w/singleTile", "http://vmap0.tiles.osgeo.org/wms/vmap0?", {layers: 'basic'}, { singleTile: true, ratio: 1 } ); new_ol_wms.addOptions({isBaseLayer: true}); map.addLayers([old_ol_wms, new_ol_wms]); map.addControl(new OpenLayers.Control.LayerSwitcher()); map.setCenter(new OpenLayers.LonLat(6.5, 40.5), 4); } </script> </head> <body onload="init()"> <h1 id="title">Untiled Example</h1> <p id="shortdesc"> Create an untiled WMS layer using the singleTile: true, option or the deprecated WMS.Untiled layer. </p> <div id="mapDiv" class="smallmap"></div> <p> The first layer is an old OpenLayers.Layer.WMS.Untiled layer, using a default ratio value of 1.5. <p> The second layer is an OpenLayers.Layer.WMS layer with singleTile set to true, and with a ratio of 1. </body> </html>
import ca_ES from '../../date-picker/locale/ca_ES'; export default ca_ES;
div.sort-container { cursor: pointer; } ul.sort { list-style: none; margin: 0px; padding: 0px; float: right; } li.sort-ascending { border-color: transparent transparent #eee transparent; border-style: solid; border-width: 8px; width: 0px; height: 0px; padding-top: 0px; margin-top: -8px; margin-bottom: 3px; } li.<API key> { border-color: transparent transparent #aaa transparent; } li.sort-descending { border-color: #eee transparent transparent transparent; border-style: solid; border-width: 8px; width: 0px; height: 0px; margin-bottom: -8px; padding: 0px; } li.<API key> { border-color: #aaa transparent transparent transparent; } div.loading { position: absolute; height: 100%; width: 100%; z-index: 999; border: 5px; background-color: white; background-image: url('load.gif'); background-repeat: no-repeat; background-position: center; }
<html lang="en"> <head> <title>nan - Untitled</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="Untitled"> <meta name="generator" content="makeinfo 4.11"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Math.html#Math" title="Math"> <link rel="prev" href="modf.html#modf" title="modf"> <link rel="next" href="nearbyint.html#nearbyint" title="nearbyint"> <link href="http: <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><! pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <p> <a name="nan"></a> Next:&nbsp;<a rel="next" accesskey="n" href="nearbyint.html#nearbyint">nearbyint</a>, Previous:&nbsp;<a rel="previous" accesskey="p" href="modf.html#modf">modf</a>, Up:&nbsp;<a rel="up" accesskey="u" href="Math.html#Math">Math</a> <hr> </div> <h3 class="section">1.42 <code>nan</code>, <code>nanf</code>&mdash;representation of &ldquo;Not a Number&rdquo;</h3> <p><a name="index-nan-119"></a><a name="index-nanf-120"></a><strong>Synopsis</strong> <pre class="example"> #include &lt;math.h&gt; double nan(const char *); float nanf(const char *); </pre> <p><strong>Description</strong><br> <code>nan</code> and <code>nanf</code> return an IEEE NaN (Not a Number) in double- and single-precision arithmetic respectively. The argument is currently disregarded. <p><br> </body></html>
<!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="refresh" content="0;URL=../../../../libc/constant.<API key>.html"> </head> <body> <p>Redirecting to <a href="../../../../libc/constant.<API key>.html">../../../../libc/constant.<API key>.html</a>...</p> <script>location.replace("../../../../libc/constant.<API key>.html" + location.search + location.hash);</script> </body> </html>
#include "../../SDL_internal.h" #if <API key> extern "C" { #include "SDL_messagebox.h" #include "../../core/windows/SDL_windows.h" } #include "SDL_winrtevents_c.h" #include <windows.ui.popups.h> using namespace Platform; using namespace Windows::Foundation; using namespace Windows::UI::Popups; static String ^ <API key>(const char * str) { wchar_t * wstr = WIN_UTF8ToString(str); String ^ rtstr = ref new String(wstr); SDL_free(wstr); return rtstr; } extern "C" int <API key>(const SDL_MessageBoxData *messageboxdata, int *buttonid) { #if (WINAPI_FAMILY == <API key>) && (NTDDI_VERSION == NTDDI_WIN8) /* Sadly, Windows Phone 8 doesn't include the MessageDialog class that * Windows 8.x/RT does, even though MSDN's reference documentation for * Windows Phone 8 mentions it. * * The .NET runtime on Windows Phone 8 does, however, include a * MessageBox class. Perhaps this could be called, somehow? */ return SDL_SetError("SDL_messagebox support is not available for Windows Phone 8.0"); #else SDL_VideoDevice *_this = SDL_GetVideoDevice(); #if WINAPI_FAMILY == <API key> const int maxbuttons = 2; const char * platform = "Windows Phone 8.1+"; #else const int maxbuttons = 3; const char * platform = "Windows 8.x"; #endif if (messageboxdata->numbuttons > maxbuttons) { return SDL_SetError("WinRT's MessageDialog only supports %d buttons, at most, on %s. %d were requested.", maxbuttons, platform, messageboxdata->numbuttons); } /* Build a MessageDialog object and its buttons */ MessageDialog ^ dialog = ref new MessageDialog(<API key>(messageboxdata->message)); dialog->Title = <API key>(messageboxdata->title); for (int i = 0; i < messageboxdata->numbuttons; ++i) { UICommand ^ button = ref new UICommand(<API key>(messageboxdata->buttons[i].text)); button->Id = safe_cast<IntPtr>(i); dialog->Commands->Append(button); if (messageboxdata->buttons[i].flags & <API key>) { dialog->CancelCommandIndex = i; } if (messageboxdata->buttons[i].flags & <API key>) { dialog->DefaultCommandIndex = i; } } /* Display the MessageDialog, then wait for it to be closed */ /* TODO, WinRT: Find a way to redraw MessageDialog instances if a GPU device-reset occurs during the following event-loop */ auto operation = dialog->ShowAsync(); while (operation->Status == Windows::Foundation::AsyncStatus::Started) { WINRT_PumpEvents(_this); } /* Retrieve results from the MessageDialog and process them accordingly */ if (operation->Status != Windows::Foundation::AsyncStatus::Completed) { return SDL_SetError("An unknown error occurred in displaying the WinRT MessageDialog"); } if (buttonid) { IntPtr results = safe_cast<IntPtr>(operation->GetResults()->Id); int clicked_index = results.ToInt32(); *buttonid = messageboxdata->buttons[clicked_index].buttonid; } return 0; #endif /* if WINAPI_FAMILY == <API key> / else */ } #endif /* <API key> */ /* vi: set ts=4 sw=4 expandtab: */
package org.jboss.windup.config.parser; import org.jboss.windup.config.exception.<API key>; import org.w3c.dom.Element; /** * Parses the given {@link Element} and returns a result, that will depend upon the underlying implementation. */ public interface ElementHandler<T> { /** * Parses the provided {@link Element} with the given {@link ParserContext}. * * See also {@link <API key>}. */ T processElement(ParserContext handlerManager, Element element) throws <API key>; }
package org.eclipse.persistence.internal.sessions.coordination.rmi; import org.eclipse.persistence.exceptions.<API key>; import org.eclipse.persistence.sessions.coordination.Command; import org.eclipse.persistence.internal.sessions.coordination.RemoteConnection; import java.rmi.RemoteException; /** * <p> * <b>Purpose</b>: Define an RMI implementation class for the remote object that * can execute a remote command. * <p> * <b>Description</b>: This implementation class is the RMI transport version of * the connection that is used by the remote command manager to send remote * commands. This object just wraps the <API key> remote object * * @since OracleAS TopLink 10<i>g</i> (9.0.4) */ public class RMIRemoteConnection extends RemoteConnection { <API key> connection; public RMIRemoteConnection(<API key> connection) { this.connection = connection; } /** * INTERNAL: * This method invokes the remote object with the Command argument, and causes * it to execute the command in the remote VM. The result is currently assumed * to be either null if successful, or an exception string if an exception was * thrown during execution. * * If a RemoteException occurred then a communication problem occurred. In this * case the exception will be wrapped in a <API key> and re-thrown. */ public Object executeCommand(Command command) throws <API key> { try { return this.connection.executeCommand(command); } catch (RemoteException exception) { throw <API key>.errorInInvocation(exception); } } /** * INTERNAL: * This method invokes the remote object with the Command argument, and causes * it to execute the command in the remote VM. The result is currently assumed * to be either null if successful, or an exception string if an exception was * thrown during execution. * * If a RemoteException occurred then a communication problem occurred. In this * case the exception will be wrapped in a <API key> and re-thrown. */ public Object executeCommand(byte[] command) throws <API key> { try { return this.connection.executeCommand(command); } catch (RemoteException exception) { throw <API key>.errorInInvocation(exception); } } /** * INTERNAL * Return the <API key> associated with this RemoteConnection * @return <API key> connection */ public <API key> getConnection() { return this.connection; } }
package org.eclipse.persistence.jpa.tests.jpql; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * This annotation can be added to a unit-test class when it is executed more than once and the * signature of its methods remain identical. This will allow Eclipse to differentiate between them * and to properly update the test's status in the JUnit view. * * @version 2.4 * @since 2.4 * @author Pascal Filion */ @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface UniqueSignature { }
package org.eclipse.persistence.testing.tests.queries; import java.util.*; import org.eclipse.persistence.testing.framework.*; import org.eclipse.persistence.testing.models.insurance.*; import org.eclipse.persistence.sessions.*; import org.eclipse.persistence.internal.helper.Helper; /** * For simple single table objects that have a primary key set to 0, it is to be expected that * there will be 1 insert statement per object. * <p> * An extra existence check read would be encountered if a PK is set to 0 where the object is * set to check for existence. * <p> * The Helper.<API key> value is enabled/disabled and tested * @author dminsky */ public class <API key> extends <API key> { protected boolean <API key>; protected boolean <API key>; protected List objectsToBeWritten; protected QuerySQLTracker sqlTracker; public <API key>(boolean <API key>) { super(); this.<API key> = <API key>; setDescription("Test for checking 0 is valid primary key"); } @SuppressWarnings("deprecation") public void setup() { super.setup(); getSession().<API key>().<API key>(); // zero valid primary key <API key> = Helper.<API key>; Helper.<API key> = this.<API key>; // create tracker object for query SQL sqlTracker = new QuerySQLTracker(getSession()); } public void test() { PolicyHolder holder = new PolicyHolder(); holder.setFirstName("David"); holder.setLastName("Minkoff"); holder.setMale(); holder.setSsn(0l); // 0 PK holder.setBirthDate(Helper.dateFromString("1979/03/25")); holder.setOccupation("Electrician"); HealthPolicy healthPolicy = new HealthPolicy(); healthPolicy.setPolicyNumber(0); // 0 PK healthPolicy.setDescription("Not bad body"); healthPolicy.setCoverageRate((float)1.5); healthPolicy.setMaxCoverage(50000); HealthClaim healthClaim1 = new HealthClaim(); healthClaim1.setId(0); // 0 PK healthClaim1.setDisease("Flu"); healthClaim1.setAmount(1000); healthPolicy.addClaim(healthClaim1); holder.addPolicy(healthPolicy); objectsToBeWritten = new ArrayList(); objectsToBeWritten.add(holder); objectsToBeWritten.add(healthPolicy); objectsToBeWritten.add(healthClaim1); UnitOfWork uow = getSession().acquireUnitOfWork(); uow.registerObject(holder); uow.commit(); } public void verify() { int <API key> = 0; if (<API key>) { <API key> = objectsToBeWritten.size() + 2; // 2 x existence checks: policy and claim } else { <API key> = (objectsToBeWritten.size()); // no existence checks } int <API key> = sqlTracker.getSqlStatements().size(); if (<API key> != <API key>) { throw new TestErrorException("Expected " + <API key> + " SQL statements - got " + <API key>); } } @SuppressWarnings("deprecation") public void reset() { super.reset(); // reset global values changed Helper.<API key> = <API key>; sqlTracker.remove(); if (objectsToBeWritten != null) { objectsToBeWritten.clear(); } } public String toString() { return super.toString() + " (<API key>: " + <API key> + ")"; } }
package org.eclipse.persistence.testing.jaxb.<API key>.xmlanyelement; import org.eclipse.persistence.platform.xml.XMLComparer; import org.w3c.dom.Node; @javax.xml.bind.annotation.XmlRootElement public class EmployeeWithList { public int a; public String b; //@javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter(value=org.eclipse.persistence.testing.jaxb.<API key>.xmlanyelement.MyDomAdapter.class) //@javax.xml.bind.annotation.XmlAnyElement(lax=false, value=org.eclipse.persistence.testing.jaxb.<API key>.xmlanyelement.MyDomHandler.class) public java.util.List<Object> stuff; public EmployeeWithList() {} public boolean equals(Object obj) { EmployeeWithList empObj; try { empObj = (EmployeeWithList) obj; } catch (ClassCastException e) { return false; } if (empObj.stuff.size() != this.stuff.size()) { return false; } // assumes size of list is 2, and order is not relevant XMLComparer comparer = new XMLComparer(); for (int i=0; i<2; i++) { Object stuffStr = empObj.stuff.get(i); if(stuff.get(i) instanceof Node){ if(!(stuffStr instanceof Node)){ return false; } if(!comparer.isNodeEqual((Node)stuff.get(i), (Node)stuffStr)){ return false; } }else if (!(stuff.get(0).equals(stuffStr) || stuff.get(1).equals(stuffStr))) { return false; } } return empObj.a == this.a && empObj.b.equals(this.b); } }
package org.eclipse.persistence.oxm.mappings; import javax.activation.DataHandler; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.eclipse.persistence.descriptors.ClassDescriptor; import org.eclipse.persistence.exceptions.XMLMarshalException; import org.eclipse.persistence.internal.helper.ClassConstants; import org.eclipse.persistence.internal.helper.DatabaseField; import org.eclipse.persistence.internal.identitymaps.CacheKey; import org.eclipse.persistence.internal.oxm.XMLBinaryDataHelper; import org.eclipse.persistence.internal.oxm.<API key>; import org.eclipse.persistence.internal.oxm.mappings.BinaryDataMapping; import org.eclipse.persistence.internal.oxm.mappings.Field; import org.eclipse.persistence.internal.queries.ContainerPolicy; import org.eclipse.persistence.internal.queries.<API key>; import org.eclipse.persistence.internal.sessions.AbstractRecord; import org.eclipse.persistence.internal.sessions.AbstractSession; import org.eclipse.persistence.mappings.AttributeAccessor; import org.eclipse.persistence.mappings.converters.Converter; import org.eclipse.persistence.oxm.NamespaceResolver; import org.eclipse.persistence.oxm.XMLConstants; import org.eclipse.persistence.oxm.XMLDescriptor; import org.eclipse.persistence.oxm.XMLField; import org.eclipse.persistence.oxm.XMLMarshaller; import org.eclipse.persistence.oxm.XMLUnmarshaller; import org.eclipse.persistence.oxm.record.DOMRecord; import org.eclipse.persistence.oxm.record.XMLRecord; import org.eclipse.persistence.queries.ObjectBuildingQuery; import org.eclipse.persistence.sessions.Session; /** * <p><b>Purpose:</b>Provide a mapping for binary data that can be treated as either inline or as * an attachment. * <p><b>Responsibilities:</b><ul> * <li>Handle converting binary types (byte[], Image etc) to base64</li> * <li>Make callbacks to <API key>/<API key></li> * <li>Write out approriate attachment information (xop:include) </li> * </ul> * <p><API key> represents a mapping of binary data in the object model * to XML. This can either be written directly as inline binary data (base64) or * passed through as an MTOM or SWAREF attachment. * <p>The following typed are allowable to be mapped using an <API key>:<ul> * <li>java.awt.Image</li> * <li>byte[]</li> * <li>javax.activation.DataHandler</li> * <li>javax.xml.transform.Source</li> * <li>javax.mail.internet.MimeMultipart</li> * </ul> * <p><b>Setting the XPath</b>: TopLink XML mappings make use of XPath statements to find the relevant * data in an XML document. The XPath statement is relative to the context node specified in the descriptor. * The XPath may contain path and positional information; the last node in the XPath forms the local * node for the binary mapping. The XPath is specified on the mapping using the <code>setXPath</code> * method. * * <p><b>Inline Binary Data</b>: Set this flag if you want to always inline binary data for this mapping. * This will disable consideration for attachment handling for this mapping. * * <p><b>SwaRef</b>: Set this flag in order to specify that the target node of this mapping is of type * xs:swaref * * @see org.eclipse.persistence.oxm.attachment.<API key> * @see org.eclipse.persistence.oxm.attachment.<API key> * @see org.eclipse.persistence.oxm.mappings.MimeTypePolicy * @since TopLink 11.1.1.0.0g */ public class <API key> extends XMLDirectMapping implements BinaryDataMapping<AbstractSession, AttributeAccessor, ContainerPolicy, Converter, ClassDescriptor, DatabaseField, XMLMarshaller, MimeTypePolicy, Session, XMLUnmarshaller, XMLRecord> { private boolean <API key>; private MimeTypePolicy mimeTypePolicy; private boolean isSwaRef; private static final String include = ":Include/@href"; public <API key>() { } public boolean <API key>() { return <API key>; } public void <API key>(boolean b) { <API key> = b; } /** * INTERNAL */ public String getMimeType(Object anObject) { if (mimeTypePolicy == null) { return null; } else { return mimeTypePolicy.getMimeType(anObject); } } /** * INTERNAL */ public String getMimeType() { if(mimeTypePolicy == null) { return null; } return mimeTypePolicy.getMimeType(null); } public MimeTypePolicy getMimeTypePolicy() { return mimeTypePolicy; } /** * Allow implementer to set the MimeTypePolicy class FixedMimeTypePolicy or <API key> (dynamic) * @param aPolicy MimeTypePolicy */ public void setMimeTypePolicy(MimeTypePolicy aPolicy) { mimeTypePolicy = aPolicy; } /** * Force mapping to set default FixedMimeTypePolicy using the MimeType string as argument * @param mimeTypeString */ public void setMimeType(String mimeTypeString) { // use the following to set dynamically - mapping.setMimeTypePolicy(new FixedMimeTypePolicy(property.getMimeType())); mimeTypePolicy = new FixedMimeTypePolicy(mimeTypeString); } public boolean isSwaRef() { return isSwaRef; } public void setSwaRef(boolean swaRef) { isSwaRef = swaRef; } /** * Set the Mapping field name attribute to the given XPath String * @param xpathString String */ public void setXPath(String xpathString) { setField(new XMLField(xpathString)); } @Override public void <API key>(Object object, AbstractRecord row, AbstractSession session, WriteType writeType) { Object attributeValue = <API key>(object); if (attributeValue == null) { XMLField field = (XMLField) getField(); if(getNullPolicy() != null && !field.getXPathFragment().isSelfFragment()) { getNullPolicy().directMarshal((Field) this.getField(), (XMLRecord) row, object); } return; } writeSingleValue(attributeValue, object, (XMLRecord) row, session); } public void writeSingleValue(Object attributeValue, Object parent, XMLRecord record, AbstractSession session) { XMLMarshaller marshaller = record.getMarshaller(); attributeValue = <API key>(attributeValue, session, record.getMarshaller()); XMLField field = (XMLField) getField(); if (field.<API key>().isAttribute()) { if (isSwaRef() && (marshaller.<API key>() != null)) { //should be a DataHandler here try { String value = null; if (<API key>() == XMLBinaryDataHelper.<API key>().DATA_HANDLER) { value = marshaller.<API key>().addSwaRefAttachment((DataHandler) attributeValue); } else { XMLBinaryDataHelper.EncodedData data = XMLBinaryDataHelper.<API key>().<API key>( attributeValue, marshaller, getMimeType(parent)); byte[] bytes = data.getData(); value = marshaller.<API key>().addSwaRefAttachment(bytes, 0, bytes.length); } record.put(field, value); } catch (ClassCastException cce) { throw XMLMarshalException.<API key>(<API key>().getName()); } } else { //inline case XMLBinaryDataHelper.EncodedData data = XMLBinaryDataHelper.<API key>().<API key>(attributeValue, record.getMarshaller(), getMimeType(parent)); String base64Value = ((<API key>) session.<API key>().<API key>()).<API key>(data.getData()); record.put(field, base64Value); } return; } if (record.isXOPPackage() && !isSwaRef() && !<API key>()) { //write as attachment String c_id = XMLConstants.EMPTY_STRING; byte[] bytes = null; String elementName = field.<API key>().getLocalName(); String namespaceUri = field.<API key>().getNamespaceURI(); if(field.<API key>().isSelfFragment()) { //If it's a self mapping, get the element from the DOM record DOMRecord domRecord = (DOMRecord)record; if(domRecord.getDOM().getNodeType() == Node.ELEMENT_NODE) { elementName = domRecord.getDOM().getLocalName(); namespaceUri = domRecord.getDOM().getNamespaceURI(); } } if ((<API key>() == ClassConstants.ABYTE) || (<API key>() == ClassConstants.APBYTE)) { if (<API key>() == ClassConstants.ABYTE) { attributeValue = ((<API key>) session.<API key>().<API key>()).convertObject(attributeValue, ClassConstants.APBYTE); } bytes = (byte[])attributeValue; c_id = marshaller.<API key>().addMtomAttachment( bytes, 0, bytes.length, this.getMimeType(parent), elementName, namespaceUri); } else if (<API key>() == XMLBinaryDataHelper.<API key>().DATA_HANDLER) { c_id = marshaller.<API key>().addMtomAttachment( (DataHandler) attributeValue, elementName, namespaceUri); if(c_id == null) { //get the bytes so we can write it out inline XMLBinaryDataHelper.EncodedData data = XMLBinaryDataHelper.<API key>().<API key>( attributeValue, marshaller, getMimeType(parent)); bytes = data.getData(); } } else { XMLBinaryDataHelper.EncodedData data = XMLBinaryDataHelper.<API key>().<API key>( attributeValue, marshaller, getMimeType(parent)); bytes = data.getData(); c_id = marshaller.<API key>().addMtomAttachment(bytes, 0, bytes.length, data.getMimeType(), elementName, namespaceUri); } if(c_id == null) { XMLField textField = null; if(field.isSelfField()){ textField = new XMLField(XMLConstants.TEXT); }else{ textField = new XMLField(field.getXPath() + '/' + XMLConstants.TEXT); } textField.<API key>(field.<API key>()); textField.setSchemaType(field.getSchemaType()); record.put(textField, bytes); //write out bytes inline } else { String xpath = this.getXPath(); String prefix = null; boolean <API key> = false; // If the field's resolver is non-null and has an entry for XOP, // use it - otherwise, create a new resolver, set the XOP entry, // on it, and use it instead. // We do this to avoid setting the XOP namespace declaration on // a given field or descriptor's resolver, as it is only required // on the current element NamespaceResolver resolver = field.<API key>(); if (resolver != null) { prefix = resolver.resolveNamespaceURI(XMLConstants.XOP_URL); } if (prefix == null) { prefix = XMLConstants.XOP_PREFIX; resolver = new NamespaceResolver(); resolver.put(prefix, XMLConstants.XOP_URL); } else { <API key> = true; } String incxpath = null; if(field.isSelfField()){ incxpath = prefix + ":Include"; xpath = (prefix + include); }else{ incxpath = xpath + '/' + prefix + ":Include"; xpath += ('/' + prefix + include); } XMLField xpathField = new XMLField(xpath); xpathField.<API key>(resolver); record.put(xpathField, c_id); // Need to call setAttributeNS on the record, unless the xop prefix // is defined on the descriptor's resolver already XMLField incField = new XMLField(incxpath); incField.<API key>(resolver); Object obj = record.<API key>(incField); if (!<API key> && obj != null && obj instanceof DOMRecord) { if (((DOMRecord) obj).getDOM().getNodeType() == Node.ELEMENT_NODE) { ((Element) ((DOMRecord) obj).getDOM()).setAttributeNS(javax.xml.XMLConstants.<API key>, javax.xml.XMLConstants.XMLNS_ATTRIBUTE + XMLConstants.COLON + prefix, XMLConstants.XOP_URL); } } } } else if (isSwaRef() && (marshaller.<API key>() != null)) { //AttributeValue should be a data-handler try { String c_id = null; if (<API key>() == XMLBinaryDataHelper.<API key>().DATA_HANDLER) { c_id = marshaller.<API key>().addSwaRefAttachment((DataHandler) attributeValue); } else { XMLBinaryDataHelper.EncodedData data = XMLBinaryDataHelper.<API key>().<API key>( attributeValue, marshaller, getMimeType(parent)); byte[] bytes = data.getData(); c_id = marshaller.<API key>().addSwaRefAttachment(bytes, 0, bytes.length); } XMLField textField = new XMLField(field.getXPath() + '/' + XMLConstants.TEXT); textField.<API key>(field.<API key>()); textField.setSchemaType(field.getSchemaType()); record.put(textField, c_id); } catch (Exception ex) { } } else { //inline XMLField textField = null; if(field.isSelfField()){ textField = new XMLField(XMLConstants.TEXT); }else{ textField = new XMLField(field.getXPath() + '/' + XMLConstants.TEXT); } textField.<API key>(field.<API key>()); textField.setSchemaType(field.getSchemaType()); if ((<API key>() == ClassConstants.ABYTE) || (<API key>() == ClassConstants.APBYTE)) { record.put(textField, attributeValue); } else { byte[] bytes = XMLBinaryDataHelper.<API key>().<API key>( attributeValue, marshaller, getMimeType(parent)).getData(); record.put(textField, bytes); } } } public Object valueFromRow(AbstractRecord row, <API key> joinManager, ObjectBuildingQuery query, CacheKey cacheKey, AbstractSession executionSession, boolean isTargetProtected, Boolean[] wasCacheUsed) { // PERF: Direct variable access. Object value = row.get(this.field); if (value == null) { return value; } Object fieldValue = null; XMLUnmarshaller unmarshaller = ((XMLRecord) row).getUnmarshaller(); if (value instanceof String) { if (this.isSwaRef() && (unmarshaller.<API key>() != null)) { if (<API key>() == XMLBinaryDataHelper.<API key>().DATA_HANDLER) { fieldValue = unmarshaller.<API key>().<API key>((String) value); } else { fieldValue = unmarshaller.<API key>().<API key>((String) value); } } else if (!this.isSwaRef()) { //should be base64 byte[] bytes = ((<API key>) executionSession.<API key>().<API key>()).<API key>(value); fieldValue = bytes; } } else if(value instanceof byte[] || value instanceof Byte[]){ fieldValue = value; } else { //this was an element, so do the XOP/SWAREF/Inline binary cases for an element XMLRecord record = (XMLRecord) value; if (getNullPolicy().valueIsNull((Element) record.getDOM())) { return null; } record.setSession(executionSession); if ((unmarshaller.<API key>() != null) && unmarshaller.<API key>().isXOPPackage() && !this.isSwaRef() && !this.<API key>()) { //look for the include element: String xpath = XMLConstants.EMPTY_STRING; // need a prefix for XOP String prefix = null; NamespaceResolver descriptorResolver = ((XMLDescriptor) getDescriptor()).<API key>(); // 20061023: handle NPE on null NSR if (descriptorResolver != null) { prefix = descriptorResolver.resolveNamespaceURI(XMLConstants.XOP_URL); } if (prefix == null) { prefix = XMLConstants.XOP_PREFIX; } NamespaceResolver tempResolver = new NamespaceResolver(); tempResolver.put(prefix, XMLConstants.XOP_URL); xpath = prefix + include; XMLField field = new XMLField(xpath); field.<API key>(tempResolver); String includeValue = (String) record.get(field); if (includeValue != null) { if ((<API key>() == ClassConstants.ABYTE) || (<API key>() == ClassConstants.APBYTE)) { fieldValue = unmarshaller.<API key>().<API key>(includeValue); } else { fieldValue = unmarshaller.<API key>().<API key>(includeValue); } } else { //If we didn't find the Include element, check for inline fieldValue = record.get(XMLConstants.TEXT); //should be a base64 string fieldValue = ((<API key>) executionSession.<API key>().<API key>()).<API key>(fieldValue); } } else if ((unmarshaller.<API key>() != null) && isSwaRef()) { String refValue = (String) record.get(XMLConstants.TEXT); if (refValue != null) { fieldValue = unmarshaller.<API key>().<API key>(refValue); } } else { fieldValue = record.get(XMLConstants.TEXT); //should be a base64 string if (fieldValue != null) { fieldValue = ((<API key>) executionSession.<API key>().<API key>()).<API key>(fieldValue); } else { fieldValue = new byte[0]; } } } Object attributeValue = <API key>(fieldValue, executionSession, unmarshaller); attributeValue = XMLBinaryDataHelper.<API key>().convertObject(attributeValue, <API key>(), executionSession, null); return attributeValue; } public boolean <API key>() { return false; } @Override public boolean <API key>() { return false; } }
package org.openhab.persistence.jdbc.db; import java.util.ArrayList; import java.util.List; import org.joda.time.DateTime; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; import org.knowm.yank.Yank; import org.openhab.core.items.Item; import org.openhab.core.persistence.FilterCriteria; import org.openhab.core.persistence.FilterCriteria.Ordering; import org.openhab.core.persistence.HistoricItem; import org.openhab.persistence.jdbc.model.ItemVO; import org.openhab.persistence.jdbc.model.ItemsVO; import org.openhab.persistence.jdbc.model.JdbcItem; import org.openhab.persistence.jdbc.utils.StringUtilsExt; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Extended Database Configuration class. Class represents * the extended database-specific configuration. Overrides and supplements the * default settings from JdbcBaseDAO. Enter only the differences to JdbcBaseDAO here. * * @author Helmut Lehmeyer * @since 1.8.0 */ public class JdbcDerbyDAO extends JdbcBaseDAO { private static final Logger logger = LoggerFactory.getLogger(JdbcDerbyDAO.class); public JdbcDerbyDAO() { super(); initSqlTypes(); initDbProps(); initSqlQueries(); } private void initSqlQueries() { logger.debug("JDBC::initSqlQueries: '{}'", this.getClass().getSimpleName()); SQL_PING_DB = "values 1"; SQL_IF_TABLE_EXISTS = "SELECT * FROM SYS.SYSTABLES WHERE TABLENAME='#searchTable#'"; <API key> = "CREATE TABLE #itemsManageTable# ( ItemId INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), #colname# #coltype# NOT NULL)"; <API key> = "CREATE TABLE #tableName# (time TIMESTAMP NOT NULL, value #dbType#, PRIMARY KEY(time))"; // Prevent error against duplicate time value (seldom): No powerful Merge found: <API key> = "INSERT INTO #tableName# (TIME, VALUE) VALUES( CURRENT_TIMESTAMP, CAST( ? as #dbType#) )"; } private void initSqlTypes() { sqlTypes.put("DATETIMEITEM", "DATE"); sqlTypes.put("DIMMERITEM", "SMALLINT"); sqlTypes.put("ROLLERSHUTTERITEM", "SMALLINT"); sqlTypes.put("STRINGITEM", "VARCHAR(32000)"); logger.debug("JDBC::initEtendedSqlTypes: Initialize the type array sqlTypes={}", sqlTypes.values()); } private void initDbProps() { // Properties for HikariCP // Use driverClassName databaseProps.setProperty("driverClassName", "org.apache.derby.jdbc.EmbeddedDriver"); // OR dataSourceClassName // databaseProps.setProperty("dataSourceClassName", "org.apache.derby.jdbc.EmbeddedDataSource"); databaseProps.setProperty("maximumPoolSize", "1"); databaseProps.setProperty("minimumIdle", "1"); } @Override public Integer doPingDB() { return Yank.queryScalar(SQL_PING_DB, Integer.class, null); } @Override public boolean doIfTableExists(ItemsVO vo) { String sql = StringUtilsExt.replaceArrayMerge(SQL_IF_TABLE_EXISTS, new String[] { "#searchTable#" }, new String[] { vo.getItemsManageTable().toUpperCase() }); logger.debug("JDBC::doIfTableExists sql={}", sql); return Yank.queryScalar(sql, String.class, null) != null; } @Override public Long <API key>(ItemsVO vo) { String sql = StringUtilsExt.replaceArrayMerge(<API key>, new String[] { "#itemsManageTable#", "#itemname#" }, new String[] { vo.getItemsManageTable().toUpperCase(), vo.getItemname() }); logger.debug("JDBC::<API key> sql={}", sql); return Yank.insert(sql, null); } @Override public ItemsVO <API key>(ItemsVO vo) { // boolean tableExists = Yank.queryScalar(SQL_IF_TABLE_EXISTS.replace("#searchTable#", // vo.getItemsManageTable().toUpperCase()), String.class, null) == null; boolean tableExists = doIfTableExists(vo); if (!tableExists) { String sql = StringUtilsExt.replaceArrayMerge(<API key>, new String[] { "#itemsManageTable#", "#colname#", "#coltype#" }, new String[] { vo.getItemsManageTable().toUpperCase(), vo.getColname(), vo.getColtype() }); logger.debug("JDBC::<API key> tableExists={} therefore sql={}", tableExists, sql); Yank.execute(sql, null); } else { logger.debug("JDBC::<API key> tableExists={}, did no CREATE TABLE", tableExists); } return vo; } @Override public void doCreateItemTable(ItemVO vo) { String sql = StringUtilsExt.replaceArrayMerge(<API key>, new String[] { "#tableName#", "#dbType#" }, new String[] { vo.getTableName(), vo.getDbType() }); Yank.execute(sql, null); } @Override public void doStoreItemValue(Item item, ItemVO vo) { vo = <API key>(item, vo); String sql = StringUtilsExt.replaceArrayMerge(<API key>, new String[] { "#tableName#", "#dbType#" }, new String[] { vo.getTableName().toUpperCase(), vo.getDbType() }); Object[] params = new Object[] { vo.getValue() }; logger.debug("JDBC::doStoreItemValue sql={} value='{}'", sql, vo.getValue()); Yank.execute(sql, params); } @Override public List<HistoricItem> <API key>(Item item, FilterCriteria filter, int numberDecimalcount, String table, String name) { String sql = <API key>(filter, numberDecimalcount, table, name); List<Object[]> m = Yank.queryObjectArrays(sql, null); logger.debug("JDBC::<API key> gor Array length={}", m.size()); List<HistoricItem> items = new ArrayList<HistoricItem>(); for (int i = 0; i < m.size(); i++) { logger.debug("JDBC::<API key> 0='{}' 1='{}'", m.get(i)[0], m.get(i)[1]); items.add(new JdbcItem(item.getName(), getState(item, m.get(i)[1]), objectAsDate(m.get(i)[0]))); } return items; } static final DateTimeFormatter jdbcDateFormat = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); /** * @param filter * @param numberDecimalcount * @param table * @return */ private String <API key>(FilterCriteria filter, int numberDecimalcount, String table, String simpleName) { logger.debug( "JDBC::<API key> filter = {}, numberDecimalcount = {}, table = {}, simpleName = {}", StringUtilsExt.filterToString(filter), numberDecimalcount, table, simpleName); String filterString = ""; if (filter.getBeginDate() != null) { filterString += filterString.isEmpty() ? " WHERE" : " AND"; filterString += " TIME>'" + jdbcDateFormat.print(new DateTime(filter.getBeginDate().getTime())) + "'"; } if (filter.getEndDate() != null) { filterString += filterString.isEmpty() ? " WHERE" : " AND"; filterString += " TIME<'" + jdbcDateFormat.print(new DateTime(filter.getEndDate().getTime())) + "'"; } filterString += (filter.getOrdering() == Ordering.ASCENDING) ? " ORDER BY time ASC" : " ORDER BY time DESC"; if (filter.getPageSize() != 0x7fffffff) { // TODO: TESTING!!! // filterString += " LIMIT " + filter.getPageNumber() * // filter.getPageSize() + "," + filter.getPageSize(); // SELECT time, value FROM <API key> ORDER BY // time DESC OFFSET 1 ROWS FETCH NEXT 0 ROWS ONLY // filterString += " OFFSET " + filter.getPageSize() +" ROWS FETCH // FIRST||NEXT " + filter.getPageNumber() * filter.getPageSize() + " // ROWS ONLY"; filterString += " OFFSET " + filter.getPageSize() + " ROWS FETCH FIRST " + (filter.getPageNumber() * filter.getPageSize() + 1) + " ROWS ONLY"; } // simulated round function in Derby: CAST(value 0.0005 AS DECIMAL(15,3)) // simulated round function in Derby: "CAST(value 0.0005 AS DECIMAL(15,"+numberDecimalcount+"))" String queryString = "SELECT time,"; if ("NUMBERITEM".equalsIgnoreCase(simpleName) && numberDecimalcount > -1) { // rounding HALF UP queryString += "CAST(value 0."; for (int i = 0; i < numberDecimalcount; i++) { queryString += "0"; } queryString += "5 AS DECIMAL(31," + numberDecimalcount + "))"; // 31 is DECIMAL max precision } else { queryString += " value FROM " + table.toUpperCase(); } if (!filterString.isEmpty()) { queryString += filterString; } logger.debug("JDBC::query queryString = {}", queryString); return queryString; } }
<?php /** * @file * Contains \Drupal\image\Annotation\ImageEffectBase. */ namespace Drupal\image; use Drupal\Core\Plugin\PluginBase; /** * Provides a base class for image effects. */ abstract class ImageEffectBase extends PluginBase implements <API key> { /** * The image effect ID. * * @var string */ protected $uuid; /** * The weight of the image effect. * * @var int|string */ protected $weight = ''; /** * {@inheritdoc} */ public function __construct(array $configuration, $plugin_id, array $plugin_definition) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->setConfiguration($configuration); } /** * {@inheritdoc} */ public function transformDimensions(array &$dimensions) { $dimensions['width'] = $dimensions['height'] = NULL; } /** * {@inheritdoc} */ public function getSummary() { return array( '#markup' => '', ); } /** * {@inheritdoc} */ public function label() { return $this->pluginDefinition['label']; } /** * {@inheritdoc} */ public function getUuid() { return $this->uuid; } /** * {@inheritdoc} */ public function setWeight($weight) { $this->weight = $weight; return $this; } /** * {@inheritdoc} */ public function getWeight() { return $this->weight; } /** * {@inheritdoc} */ public function getConfiguration() { return array( 'uuid' => $this->getUuid(), 'id' => $this->getPluginId(), 'weight' => $this->getWeight(), 'data' => $this->configuration, ); } /** * {@inheritdoc} */ public function setConfiguration(array $configuration) { $configuration += array( 'data' => array(), 'uuid' => '', 'weight' => '', ); $this->configuration = $configuration['data'] + $this-><API key>(); $this->uuid = $configuration['uuid']; $this->weight = $configuration['weight']; return $this; } /** * {@inheritdoc} */ public function <API key>() { return array(); } }
#ifndef __VARIANT_H__ #define __VARIANT_H__ #include <stdint.h> #include <unistd.h> #include <AnalogIO.h> #include <wiring_digital.h> #include "pins_arduino.h" #ifdef __cplusplus extern "C" { #endif #ifdef __cplusplus #include "TTYUART.h" extern TTYUARTClass Serial; extern TTYUARTClass Serial1; extern TTYUARTClass Serial2; #endif #define <API key> "/dev/ttyGS0" #define LINUX_SERIAL1_TTY "/dev/ttyS0" #define LINUX_SERIAL2_TTY "/dev/ttyS1" #define LINUX_SPIDEV "/dev/spidev1.0" #define LINUX_EEPROM "/sys/bus/i2c/devices/0-0050/eeprom" #define LINUX_ADC_FMT "/sys/bus/iio/devices/iio:device0/in_voltage%d_raw" #define LINUX_GPIO_ROOT "/sys/class/gpio/" #define LINUX_GPIO_EXPORT LINUX_GPIO_ROOT "export" #define <API key> LINUX_GPIO_ROOT "gpio%u/value" #define <API key> LINUX_GPIO_ROOT "gpio%u/direction" #define <API key> LINUX_GPIO_ROOT "gpio%u/drive" #define LINUX_GPIO_EDGE_FMT LINUX_GPIO_ROOT "gpio%u/edge" #define <API key> LINUX_GPIO_ROOT "gpio%u/level" #define LINUX_PWM_ROOT "/sys/class/pwm/pwmchip0/" #define LINUX_PWM_EXPORT LINUX_PWM_ROOT "export" #define <API key> LINUX_PWM_ROOT "pwm%u/period" #define LINUX_PWM_DUTY_FMT LINUX_PWM_ROOT "pwm%u/duty_cycle" #define <API key> LINUX_PWM_ROOT "pwm%u/enable" #define PLATFORM_NAME "Galileo" // In /sys/devices/platform #define PLATFORM_ID 0x06 // Fab D platform id #define ADC_RESOLUTION 12 #define PWM_RESOLUTION 8 /* * Define period such that the PWM frequency is as close as possible to Arduino * Uno's one (~490Hz). * The following value gives a frequency of 489Hz (scope capture). Do not * touch unless you know what you're doing. */ #define SYSFS_PWM_PERIOD_NS 1900000 #define <API key> 1000 //#define VARIANT_TRACE_LEVEL TRACE_LEVEL_DEBUG // default trace level #define VARIANT_TRACE_LEVEL TRACE_LEVEL_INFO // default trace level /* Mux selector definition */ struct mux_sel { uint32_t sel_id; // GPIOLib ID uint32_t sel_val; }; /* Mux selects (Arduino Pin ID). */ #define MUX_SEL_NONE -1 #define MUX_SEL_UART0_RXD 0 #define MUX_SEL_UART0_TXD 1 #define MUX_SEL_SPI1_SS_B 10 #define MUX_SEL_SPI1_MOSI 11 #define MUX_SEL_SPI1_MISO 12 #define MUX_SEL_SPI1_SCK 13 #define MUX_SEL_AD7298_VIN0 14 #define MUX_SEL_AD7298_VIN1 15 #define MUX_SEL_AD7298_VIN2 16 #define MUX_SEL_AD7298_VIN3 17 #define MUX_SEL_AD7298_VIN4 18 #define MUX_SEL_AD7298_VIN5 19 #define MUX_SEL_I2C 18 // Uses pin 19 as well but this should do /* Pins table to be instanciated into variant.cpp */ #define MUX_DEPTH_DIGITAL 0x02 #define MUX_DEPTH_ANALOG 0x01 #define MUX_DEPTH_UART 0x02 #define MUX_DEPTH_SPI 0x03 #define MUX_DEPTH_I2C 0x01 #define GPIO_TOTAL 56 #define GPIO_FAST_IO2 <API key>(0x40) #define GPIO_FAST_IO3 <API key>(0x80) /* APIs for fast GPIO access */ #define <API key>(id, val) \ <API key>(<API key>, \ GPIO_FAST_ID_MASK(id), val) #define fastGpioDigitalRead(id) \ <API key>(<API key>, \ GPIO_FAST_ID_MASK(id)) #define <API key>(id) \ <API key>(<API key>) #define <API key>(id, mask) \ <API key>(<API key>, mask) /* DEPRECATED API FUNCTION * - USE <API key>() INSTEAD */ #define <API key>() <API key>(<API key>) /* DEPRECATED API FUNCTION * - USE <API key>() INSTEAD */ #define <API key>(mask) \ <API key>(<API key>, mask) extern PinDescription g_APinDescription[] ; extern uint32_t <API key>; extern PwmDescription g_APwmDescription[] ; extern uint32_t <API key>; extern AdcDescription g_AdcDescription[] ; extern uint32_t <API key>; extern uint32_t ardPin2DescIdx[GPIO_TOTAL]; extern PinState g_APinState[] ; extern uint32_t sizeof_g_APinState; extern const int mux_sel_analog[NUM_ANALOG_INPUTS]; extern const int mux_sel_uart[NUM_UARTS][MUX_DEPTH_UART]; extern const int mux_sel_spi[NUM_SPI][MUX_DEPTH_SPI]; extern const int mux_sel_i2c[NUM_I2C][MUX_DEPTH_I2C]; int muxSelectAnalogPin(uint8_t pin); int muxSelectUart(uint8_t interface); int muxSelectSpi(uint8_t interface); int muxSelectI2c(uint8_t interface); const unsigned mapUnoPinToSoC(uint8_t pin); int variantPinMode(uint8_t pin, uint8_t mode); int variantPinModeIRQ(uint8_t pin, uint8_t mode); void turnOffPWM(uint8_t pin); void turnOnPWM(uint8_t pin); void <API key>(int pin); #ifdef __cplusplus } #endif #endif /* __VARIANT_H__ */
#include "avcodec.h" #include "fmtconvert.h" #include "libavutil/common.h" static void <API key>(float *dst, const int *src, float mul, int len){ int i; for(i=0; i<len; i++) dst[i] = src[i] * mul; } static void <API key>(FmtConvertContext *c, float *dst, const int32_t *src, const float *mul, int len) { int i; for (i = 0; i < len; i += 8) c-><API key>(&dst[i], &src[i], *mul++, 8); } static av_always_inline int float_to_int16_one(const float *src){ return av_clip_int16(lrintf(*src)); } static void float_to_int16_c(int16_t *dst, const float *src, long len) { int i; for(i=0; i<len; i++) dst[i] = float_to_int16_one(src+i); } static void <API key>(int16_t *dst, const float **src, long len, int channels) { int i,j,c; if(channels==2){ for(i=0; i<len; i++){ dst[2*i] = float_to_int16_one(src[0]+i); dst[2*i+1] = float_to_int16_one(src[1]+i); } }else{ for(c=0; c<channels; c++) for(i=0, j=c; i<len; i++, j+=channels) dst[j] = float_to_int16_one(src[c]+i); } } void <API key>(float *dst, const float **src, unsigned int len, int channels) { int j, c; unsigned int i; if (channels == 2) { for (i = 0; i < len; i++) { dst[2*i] = src[0][i]; dst[2*i+1] = src[1][i]; } } else if (channels == 1 && len < INT_MAX / sizeof(float)) { memcpy(dst, src[0], len * sizeof(float)); } else { for (c = 0; c < channels; c++) for (i = 0, j = c; i < len; i++, j += channels) dst[j] = src[c][i]; } } av_cold void ff_fmt_convert_init(FmtConvertContext *c, AVCodecContext *avctx) { c-><API key> = <API key>; c-><API key> = <API key>; c->float_to_int16 = float_to_int16_c; c-><API key> = <API key>; c->float_interleave = <API key>; if (ARCH_ARM) <API key>(c, avctx); if (HAVE_ALTIVEC) <API key>(c, avctx); if (ARCH_X86) <API key>(c, avctx); if (HAVE_MIPSFPU) <API key>(c); } /* ffdshow custom code */ void float_interleave(float *dst, const float **src, long len, int channels) { int i,j,c; if(channels==2){ for(i=0; i<len; i++){ dst[2*i] = src[0][i] / 32768.0f; dst[2*i+1] = src[1][i] / 32768.0f; } }else{ for(c=0; c<channels; c++) for(i=0, j=c; i<len; i++, j+=channels) dst[j] = src[c][i] / 32768.0f; } } void <API key>(float *dst, const float **src, long len, int channels) { int i,j,c; if(channels==2){ for(i=0; i<len; i++){ dst[2*i] = src[0][i]; dst[2*i+1] = src[1][i]; } }else{ for(c=0; c<channels; c++) for(i=0, j=c; i<len; i++, j+=channels) dst[j] = src[c][i]; } }
_S(CAP_CHOWN, "chown" ) _S(CAP_DAC_OVERRIDE, "dac_override" ) _S(CAP_DAC_READ_SEARCH, "dac_read_search" ) _S(CAP_FOWNER, "fowner" ) _S(CAP_FSETID, "fsetid" ) _S(CAP_KILL, "kill" ) _S(CAP_SETGID, "setgid" ) _S(CAP_SETUID, "setuid" ) _S(CAP_SETPCAP, "setpcap" ) _S(CAP_LINUX_IMMUTABLE, "linux_immutable" ) _S(<API key>, "net_bind_service" ) _S(CAP_NET_BROADCAST, "net_broadcast" ) _S(CAP_NET_ADMIN, "net_admin" ) _S(CAP_NET_RAW, "net_raw" ) _S(CAP_IPC_LOCK, "ipc_lock" ) _S(CAP_IPC_OWNER, "ipc_owner" ) _S(CAP_SYS_MODULE, "sys_module" ) _S(CAP_SYS_RAWIO, "sys_rawio" ) _S(CAP_SYS_CHROOT, "sys_chroot" ) _S(CAP_SYS_PTRACE, "sys_ptrace" ) _S(CAP_SYS_PACCT, "sys_psacct" ) _S(CAP_SYS_ADMIN, "sys_admin" ) _S(CAP_SYS_BOOT, "sys_boot" ) _S(CAP_SYS_NICE, "sys_nice" ) _S(CAP_SYS_RESOURCE, "sys_resource" ) _S(CAP_SYS_TIME, "sys_time" ) _S(CAP_SYS_TTY_CONFIG, "sys_tty_config" ) _S(CAP_MKNOD, "mknod" ) _S(CAP_LEASE, "lease" ) _S(CAP_AUDIT_WRITE, "audit_write" ) _S(CAP_AUDIT_CONTROL, "audit_control" ) #ifdef CAP_SETFCAP _S(CAP_SETFCAP, "setfcap" ) #endif #ifdef CAP_MAC_OVERRIDE _S(CAP_MAC_OVERRIDE, "mac_override" ) #endif #ifdef CAP_MAC_ADMIN _S(CAP_MAC_ADMIN, "mac_admin" ) #endif #ifdef CAP_SYSLOG _S(CAP_SYSLOG, "syslog" ) #endif #ifdef CAP_WAKE_ALARM _S(CAP_WAKE_ALARM, "wake_alarm" ) #endif #if defined(CAP_EPOLLWAKEUP) && defined(CAP_BLOCK_SUSPEND) #error "Both CAP_EPOLLWAKEUP and CAP_BLOCK_SUSPEND are defined" #endif #ifdef CAP_EPOLLWAKEUP _S(CAP_EPOLLWAKEUP, "epollwakeup" ) #endif #ifdef CAP_BLOCK_SUSPEND _S(CAP_BLOCK_SUSPEND, "block_suspend" ) #endif
#include "msm_fb.h" #include "mipi_dsi.h" #include "<API key>.h" /* Initial Sequence */ static char mcap[] = { 0xB0, 0x00 }; static char auto_cmd_refresh[] = { 0xB2, 0x00 }; static char panel_driving[] = { 0xC0, 0x41, 0x02, 0x7F, 0xC9, 0x07 }; static char mcap_lock[] = { 0xB0, 0x03 }; /* Display ON Sequence */ static char exit_sleep[] = { 0x11 }; static char display_on[] = { 0x29 }; /* Display OFF Sequence */ static char display_off[] = { 0x28 }; static char enter_sleep[] = { 0x10 }; /* Reading DDB Sequence */ static char read_ddb_start[] = { 0xA1, 0x00 }; /* LTPS Interface mode */ static char ltps_if_ctrl[] = { 0xC4, 0xC3, 0x29 }; /* Gamma */ static char gamma_ctrl[] = { 0xC8, 0x00, 0x0A, 0x1F, 0x06 }; static char <API key>[] = { 0xC9, 0x14, 0x0E, 0x12, 0x1D, 0x20, 0x18, 0x20, 0x23, 0x15, 0x11, 0x19, 0x0C, 0x2C }; static char <API key>[] = { 0xCA, 0x3E, 0x3C, 0x51, 0x40, 0x3E, 0x43, 0x3C, 0x36, 0x40, 0x46, 0x3F, 0x2F, 0x15 }; static char <API key>[] = { 0xCB, 0x27, 0x21, 0x24, 0x2A, 0x29, 0x1E, 0x25, 0x26, 0x18, 0x13, 0x1B, 0x10, 0x38 }; static char <API key>[] = { 0xCC, 0x21, 0x23, 0x3C, 0x34, 0x34, 0x3C, 0x37, 0x31, 0x3D, 0x43, 0x39, 0x25, 0x0B }; static char <API key>[] = { 0xCD, 0x35, 0x33, 0x38, 0x38, 0x36, 0x29, 0x2B, 0x2A, 0x1B, 0x15, 0x19, 0x09, 0x02 }; static char <API key>[] = { 0xCE, 0x18, 0x1A, 0x34, 0x2C, 0x2B, 0x35, 0x30, 0x2C, 0x38, 0x3D, 0x39, 0x2D, 0x34 }; /* rsp area */ static char nvm_rsp1[1 + NVRW_NUM_E7_PARAM] = { 0xE7, 0x00, 0x00, 0x00, 0x00 }; static char dev_code[] = { 0xBF, 0x01, 0x22, 0x33, 0x06, 0xA4 }; /* nvm command */ static char <API key>[] = { 0xE0 }; static char <API key>[] = { 0xE0, 0x00 }; static char nvm_status[] = { 0xE1 }; static char test_mode1[] = { 0xE4, 0x00, 0x00, 0x00, 0xF0, 0xFF }; static char test_mode2[] = { 0xE4, 0x39, 0x87 }; static char test_mode3[] = { 0xE4, 0x00, 0x00, 0x00, 0x00, 0x00 }; static char test_mode4[] = { 0xE4, 0xB9, 0x47 }; static char test_mode5[] = { 0xE4, 0xBD }; static char test_mode6[] = { 0xE4 }; /* user area*/ static char ddb_wri_ctl[1 + NVRW_NUM_E6_PARAM] = { 0xE6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static char vcomdc_set[1 + NVRW_NUM_DE_PARAM] = { 0xDE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static char test_mode7[] = { 0xFD, 0x04, 0x55, 0x53, 0x00, 0x70, 0xFF, 0x10, 0x33, 0x22, 0x22, 0x22, 0x37, 0x00 }; static char pix_fmt[] = { 0xB4, 0x02 }; static char dsi_ctl[] = { 0xB6, 0x51, 0xE3 }; static char dsp_h_timming[] = { 0xC1, 0x00, 0xB4, 0x00, 0x00, 0xA1, 0x00, 0x00, 0xA1, 0x09, 0x21, 0x09, 0x00, 0x00, 0x00, 0x01 }; static char src_output[] = { 0xC2, 0x00, 0x09, 0x09, 0x00, 0x00 }; static char gate_drv_if_ctl[] = { 0xC3, 0x04 }; static char pbctrl_ctl[] = { 0xC5, 0x00, 0x02 }; static char dsp_rgb_sw_odr[] = { 0xC6, 0x11, 0x20, 0x20, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static char ltps_if_ctl[] = { 0xC7, 0x00 }; static char pow_set1[] = { 0xD0, 0x6B, 0x66, 0x09, 0x18, 0x58, 0x00, 0x14, 0x00 }; static char pow_set2[] = { 0xD1, 0x77, 0xD4 }; static char pow_internal[] = { 0xD3, 0x33 }; static char vol_set[] = { 0xD5, 0x09, 0x09 }; static char nvm_ld_ctl[] = { 0xE2, 0x03 }; static char reg_wri_ctl[] = { 0xE5, 0x01 }; static struct dsi_cmd_desc <API key>[] = { {DTYPE_DCS_WRITE, 1, 0, 0, 10, sizeof(exit_sleep), exit_sleep}, {DTYPE_GEN_WRITE2, 1, 0, 0, 0, sizeof(mcap), mcap}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(auto_cmd_refresh), auto_cmd_refresh}, {DTYPE_GEN_LWRITE, 1, 0, 0, 120, sizeof(panel_driving), panel_driving}, {DTYPE_GEN_WRITE2, 1, 0, 0, 0, sizeof(mcap_lock), mcap_lock}, }; static struct dsi_cmd_desc display_on_cmd_seq[] = { {DTYPE_DCS_WRITE, 1, 0, 0, 0, sizeof(display_on), display_on}, }; static struct dsi_cmd_desc display_off_cmd_seq[] = { {DTYPE_DCS_WRITE, 1, 0, 0, 0, sizeof(display_off), display_off}, {DTYPE_DCS_WRITE, 1, 0, 0, 120, sizeof(enter_sleep), enter_sleep} }; static struct dsi_cmd_desc read_ddb_cmd_seq[] = { {DTYPE_DCS_READ, 1, 0, 1, 5, sizeof(read_ddb_start), read_ddb_start}, }; static struct dsi_cmd_desc <API key>[] = { {DTYPE_DCS_WRITE, 1, 0, 0, 0, sizeof(display_off), display_off}, {DTYPE_DCS_WRITE, 1, 0, 0, 120, sizeof(enter_sleep), enter_sleep} }; static struct dsi_cmd_desc nvm_mcap_cmd_seq[] = { {DTYPE_GEN_WRITE2, 1, 0, 0, 0, sizeof(mcap), mcap}, }; static struct dsi_cmd_desc <API key>[] = { {DTYPE_GEN_WRITE2, 1, 0, 0, 0, sizeof(mcap_lock), mcap_lock}, }; static struct dsi_cmd_desc <API key>[] = { {DTYPE_GEN_READ, 1, 0, 0, 0, 1, nvm_rsp1}, }; static struct dsi_cmd_desc <API key>[] = { {DTYPE_GEN_READ, 1, 0, 0, 0, 1, vcomdc_set}, }; static struct dsi_cmd_desc <API key>[] = { {DTYPE_GEN_READ, 1, 0, 0, 0, 1, ddb_wri_ctl}, }; static struct dsi_cmd_desc nvm_open_cmd_seq[] = { {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(test_mode1), test_mode1}, }; static struct dsi_cmd_desc nvm_close_cmd_seq[] = { {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(test_mode3), test_mode3}, }; static struct dsi_cmd_desc nvm_status_cmd_seq[] = { {DTYPE_GEN_READ, 1, 0, 0, 0, sizeof(nvm_status), nvm_status}, }; static struct dsi_cmd_desc nvm_erase_cmd_seq[] = { {DTYPE_DCS_WRITE, 1, 0, 0, 200, sizeof(exit_sleep), exit_sleep}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(test_mode4), test_mode4}, {DTYPE_GEN_LWRITE, 1, 0, 0, 1300, sizeof(test_mode5), test_mode5}, }; static struct dsi_cmd_desc <API key>[] = { {DTYPE_GEN_READ, 1, 0, 0, 0, sizeof(test_mode6), test_mode6}, }; static struct dsi_cmd_desc <API key>[] = { {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(nvm_rsp1), nvm_rsp1}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(dev_code), dev_code}, }; static struct dsi_cmd_desc <API key>[] = { {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(test_mode2), test_mode2}, {DTYPE_GEN_LWRITE, 1, 0, 0, 1300, sizeof(<API key>), <API key>}, }; static struct dsi_cmd_desc <API key>[] = { {DTYPE_GEN_WRITE2, 1, 0, 0, 0, sizeof(auto_cmd_refresh), auto_cmd_refresh}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(pix_fmt), pix_fmt}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(dsi_ctl), dsi_ctl}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(panel_driving), panel_driving}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(dsp_h_timming), dsp_h_timming}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(src_output), src_output}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(gate_drv_if_ctl), gate_drv_if_ctl}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(ltps_if_ctrl), ltps_if_ctrl}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(pbctrl_ctl), pbctrl_ctl}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(dsp_rgb_sw_odr), dsp_rgb_sw_odr}, {DTYPE_GEN_WRITE2, 1, 0, 0, 0, sizeof(ltps_if_ctl), ltps_if_ctl}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(pow_set1), pow_set1}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(pow_set2), pow_set2}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(pow_internal), pow_internal}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(vol_set), vol_set}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(vcomdc_set), vcomdc_set}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(nvm_ld_ctl), nvm_ld_ctl}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(reg_wri_ctl), reg_wri_ctl}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(ddb_wri_ctl), ddb_wri_ctl}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(gamma_ctrl), gamma_ctrl}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(<API key>), <API key>}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(<API key>), <API key>}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(<API key>), <API key>}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(<API key>), <API key>}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(<API key>), <API key>}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(<API key>), <API key>}, {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(test_mode7), test_mode7}, }; static struct dsi_cmd_desc <API key>[] = { {DTYPE_GEN_LWRITE, 1, 0, 0, 2500, sizeof(<API key>), <API key>}, }; static const struct panel_cmd display_init_cmds[] = { {CMD_DSI, {.dsi_payload = {<API key>, ARRAY_SIZE(<API key>)} } }, {CMD_END, {} }, }; static const struct panel_cmd display_on_cmds[] = { {CMD_DSI, {.dsi_payload = {display_on_cmd_seq, ARRAY_SIZE(display_on_cmd_seq)} } }, {CMD_END, {} }, }; static const struct panel_cmd display_off_cmds[] = { {CMD_DSI, {.dsi_payload = {display_off_cmd_seq, ARRAY_SIZE(display_off_cmd_seq)} } }, {CMD_END, {} }, }; static const struct panel_cmd read_ddb_cmds[] = { {CMD_DSI, {.dsi_payload = {read_ddb_cmd_seq, ARRAY_SIZE(read_ddb_cmd_seq)} } }, {CMD_END, {} }, }; static const struct panel_cmd nvm_disp_off_cmds[] = { {CMD_DSI, {.dsi_payload = {<API key>, ARRAY_SIZE(<API key>)} } }, {CMD_END, {} }, }; static const struct panel_cmd nvm_mcap_cmds[] = { {CMD_DSI, {.dsi_payload = {nvm_mcap_cmd_seq, ARRAY_SIZE(nvm_mcap_cmd_seq)} } }, {CMD_END, {} }, }; static const struct panel_cmd nvm_mcap_lock_cmds[] = { {CMD_DSI, {.dsi_payload = {<API key>, ARRAY_SIZE(<API key>)} } }, {CMD_END, {} }, }; static const struct panel_cmd nvm_open_cmds[] = { {CMD_DSI, {.dsi_payload = {nvm_open_cmd_seq, ARRAY_SIZE(nvm_open_cmd_seq)} } }, {CMD_END, {} }, }; static const struct panel_cmd nvm_close_cmds[] = { {CMD_DSI, {.dsi_payload = {nvm_close_cmd_seq, ARRAY_SIZE(nvm_close_cmd_seq)} } }, {CMD_END, {} }, }; static const struct panel_cmd nvm_status_cmds[] = { {CMD_DSI, {.dsi_payload = {nvm_status_cmd_seq, ARRAY_SIZE(nvm_status_cmd_seq)} } }, {CMD_END, {} }, }; static const struct panel_cmd nvm_erase_cmds[] = { {CMD_DSI, {.dsi_payload = {nvm_erase_cmd_seq, ARRAY_SIZE(nvm_erase_cmd_seq)} } }, {CMD_END, {} }, }; static const struct panel_cmd nvm_erase_res_cmds[] = { {CMD_DSI, {.dsi_payload = {<API key>, ARRAY_SIZE(<API key>)} } }, {CMD_END, {} }, }; static const struct panel_cmd nvm_read_rsp1_cmds[] = { {CMD_DSI, {.dsi_payload = {<API key>, ARRAY_SIZE(<API key>)} } }, {CMD_END, {} }, }; static const struct panel_cmd <API key>[] = { {CMD_DSI, {.dsi_payload = {<API key>, ARRAY_SIZE(<API key>)} } }, {CMD_END, {} }, }; static const struct panel_cmd <API key>[] = { {CMD_DSI, {.dsi_payload = {<API key>, ARRAY_SIZE(<API key>)} } }, {CMD_END, {} }, }; static struct panel_cmd nvm_write_rsp_cmds[] = { {CMD_DSI, {.dsi_payload = {<API key>, ARRAY_SIZE(<API key>)} } }, {CMD_END, {} }, }; static struct panel_cmd nvm_flash_rsp_cmds[] = { {CMD_DSI, {.dsi_payload = {<API key>, ARRAY_SIZE(<API key>)} } }, {CMD_END, {} }, }; static struct panel_cmd nvm_write_user_cmds[] = { {CMD_DSI, {.dsi_payload = {<API key>, ARRAY_SIZE(<API key>)} } }, {CMD_END, {} }, }; static struct panel_cmd nvm_flash_user_cmds[] = { {CMD_DSI, {.dsi_payload = {<API key>, ARRAY_SIZE(<API key>)} } }, {CMD_END, {} }, }; static const struct mipi_dsi_phy_ctrl <API key>[] = { /* 720*1280, RGB888, 4 Lane 60 fps video mode */ { /* regulator */ {0x03, 0x0a, 0x04, 0x00, 0x20}, /* timing */ {0x87, 0x1e, 0x14, 0x00, 0x44, 0x4b, 0x19, 0x21, 0x22, 0x03, 0x04, 0xa0}, /* phy ctrl */ {0x5f, 0x00, 0x00, 0x10}, /* strength */ {0xff, 0x00, 0x06, 0x00}, /* pll control */ {0x00, 0xce, 0x31, 0xd9, 0x00, 0x50, 0x48, 0x63, 0x41, 0x0f, 0x03, 0x00, 0x14, 0x03, 0x00, 0x02, 0x00, 0x20, 0x00, 0x01 }, }, }; static struct msm_panel_info pinfo; /* TODO: why a get function? */ static struct msm_panel_info *get_panel_info(void) { pinfo.xres = 720; pinfo.yres = 1280; pinfo.type = MIPI_VIDEO_PANEL; pinfo.pdest = DISPLAY_1; pinfo.wait_cycle = 0; pinfo.bpp = 24; pinfo.lcdc.h_back_porch = 40; pinfo.lcdc.h_front_porch = 252; pinfo.lcdc.h_pulse_width = 20; pinfo.lcdc.v_back_porch = 6; pinfo.lcdc.v_front_porch = 8; pinfo.lcdc.v_pulse_width = 2; pinfo.lcdc.border_clr = 0; /* blk */ pinfo.lcdc.underflow_clr = 0; /* black */ pinfo.lcdc.hsync_skew = 0; pinfo.bl_max = 15; pinfo.bl_min = 1; pinfo.fb_num = 2; pinfo.clk_rate = 481000000; pinfo.mipi.mode = DSI_VIDEO_MODE; pinfo.mipi.pulse_mode_hsa_he = TRUE; pinfo.mipi.hfp_power_stop = FALSE; pinfo.mipi.hbp_power_stop = FALSE; pinfo.mipi.hsa_power_stop = FALSE; pinfo.mipi.eof_bllp_power_stop = TRUE; pinfo.mipi.bllp_power_stop = TRUE; pinfo.mipi.traffic_mode = <API key>; pinfo.mipi.dst_format = <API key>; pinfo.mipi.vc = 0; pinfo.mipi.rgb_swap = DSI_RGB_SWAP_BGR; pinfo.mipi.r_sel = 0; pinfo.mipi.g_sel = 0; pinfo.mipi.b_sel = 0; pinfo.mipi.data_lane0 = TRUE; pinfo.mipi.data_lane1 = TRUE; pinfo.mipi.data_lane2 = TRUE; pinfo.mipi.data_lane3 = TRUE; pinfo.mipi.tx_eot_append = TRUE; pinfo.mipi.t_clk_post = 0x04; pinfo.mipi.t_clk_pre = 0x1B; pinfo.mipi.esc_byte_ratio = 4; pinfo.mipi.stream = 0; /* dma_p */ pinfo.mipi.mdp_trigger = DSI_CMD_TRIGGER_SW; pinfo.mipi.dma_trigger = DSI_CMD_TRIGGER_SW; pinfo.mipi.frame_rate = 60; pinfo.mipi.dsi_phy_db = (struct mipi_dsi_phy_ctrl *)<API key>; return &pinfo; } static struct dsi_controller <API key> = { .get_panel_info = get_panel_info, .display_init = display_init_cmds, .display_on = display_on_cmds, .display_off = display_off_cmds, .read_id = read_ddb_cmds, }; static struct dsi_nvm_rewrite_ctl dsi_nvrw_ctl = { .nvm_disp_off = nvm_disp_off_cmds, .nvm_mcap = nvm_mcap_cmds, .nvm_mcap_lock = nvm_mcap_lock_cmds, .nvm_open = nvm_open_cmds, .nvm_close = nvm_close_cmds, .nvm_read_rsp = nvm_read_rsp1_cmds, .nvm_read_vcomdc = <API key>, .nvm_read_ddb_write = <API key>, .nvm_status = nvm_status_cmds, .nvm_erase = nvm_erase_cmds, .nvm_erase_res = nvm_erase_res_cmds, .nvm_write_rsp = nvm_write_rsp_cmds, .nvm_flash_rsp = nvm_flash_rsp_cmds, .nvm_write_user = nvm_write_user_cmds, .nvm_flash_user = nvm_flash_user_cmds, }; static char ddb_val_tov[] = { PANEL_SKIP_ID, PANEL_SKIP_ID, 0x22, 0x14, PANEL_SKIP_ID, 0x01, 0x00, PANEL_SKIP_ID }; static char ddb_val_1a[] = { 0x12, 0x69, 0x22, 0x13, 0x1a, 0x01, 0x00, PANEL_SKIP_ID }; static char ddb_val[] = { PANEL_SKIP_ID, PANEL_SKIP_ID, 0x22, 0x13, PANEL_SKIP_ID, 0x01, 0x00, PANEL_SKIP_ID }; const struct panel <API key> = { .name = "<API key>", .pctrl = &<API key>, .pnvrw_ctl = &dsi_nvrw_ctl, .id = ddb_val_tov, .id_num = ARRAY_SIZE(ddb_val_tov), .width = 53, .height = 95, .panel_id = "ls046k3sx01", .panel_rev = "tov", }; const struct panel <API key> = { .name = "<API key>", .pctrl = &<API key>, .pnvrw_ctl = &dsi_nvrw_ctl, .id = ddb_val_1a, .id_num = ARRAY_SIZE(ddb_val_1a), .width = 53, .height = 95, .panel_id = "ls046k3sx01", .panel_rev = "1a", }; const struct panel <API key> = { .name = "<API key>", .pctrl = &<API key>, .pnvrw_ctl = &dsi_nvrw_ctl, .id = ddb_val, .id_num = ARRAY_SIZE(ddb_val), .width = 53, .height = 95, .panel_id = "ls046k3sx01", .panel_rev = "generic", };
window.share = function() { // List of all of the URL element attributes var URLElements = { "a": "href", "applet": ["archive", "code", "codebase"], "area": "href", "audio": "src", "base": "href", "blockquote": ["cite"], "body": "background", "button": "formaction", "command": "icon", "del": ["cite"], "embed": "src", "form": "action", "frame": ["longdesc", "src"], "iframe": ["longdesc", "src"], "img": ["longdesc", "src"], "input": ["formaction", "src"], "ins": ["cite"], "link": "href", "object": ["archive", "codebase", "data"], "q": ["cite"], "script": "src", "source": "src", }; // Expands URL element attributes function expandAttribute(node, attrName, baseURL, pageURL) { var attrValue = node.getAttribute(attrName); if (!attrValue) return; try { var url = node.getAttribute(attrName) // Resolve protocol absolute, domain absolute and relative URLs if (url && url.length > 1 && url[0] == '/' && url[1] == '/') { url = 'http:' + url; } else if (url && url.length > 0 && url[0] == '/') { url = baseURL + url; } else if (url.indexOf(': url = pageURL + url; } node.setAttribute(attrName, url); } catch (e) { } } // Expands all URLs recursively from parent n function expandURLs(n, baseURL, pageURL) { for (var i = 0; i < n.children.length; i++) { var child = n.children[i]; var childTagName = child.tagName.toLowerCase(); for (var tagName in URLElements) { if (tagName === childTagName) { if (URLElements[tagName] instanceof Array) { URLElements[tagName].forEach(function (attrName) { expandAttribute(child, attrName, baseURL, pageURL); }, this); } else { expandAttribute(child, URLElements[tagName], baseURL, pageURL); } } } expandURLs(child, baseURL, pageURL); } } return { expandURLs: expandURLs }; }();
require 'fileutils' # Create important directories that are needed at runtime sub_dirs = %w(log tmp tmp/cache tmp/pids tmp/sessions tmp/sockets) sub_dirs.each do |subdir| FileUtils.mkdir_p("#{Rails.root}/#{subdir}") unless File.exist?(subdir) end
<?php /** * Override of ezcMvcRegexpRoute. * Necessary to be able to be mixed with rails-like routes */ class ezpMvcRegexpRoute extends ezcMvcRegexpRoute { /** * Array containing the map between the protocol and corresponding action * * @var array */ protected $protocolActionMap = array(); /** * Constructs a new ezpMvcRegexpRoute with $pattern for protocols used as * keys in $protocolActionMap * * Examples: * <code> * $route = new ezpMvcRegexpRoute( * REGEXP, * '<API key>' * array( * 'http-get' => 'viewContent', * 'http-delete' => 'deleteContent' * ) * ); * </code> * * will define the route with the REGEXP and a different method in * the controller will be called depending on the used HTTP verb. If * $protocolActionMap is a string, we assume the mapping is done for * http-get (kept to not introduce a BC break) * * @param string $pattern * @param string $controllerClassName * @param array|string $protocolActionMap * @param array $defaultValues */ public function __construct( $pattern, $controllerClassName, $protocolActionMap, array $defaultValues = array() ) { if ( is_string( $protocolActionMap ) ) { $protocolActionMap = array( 'http-get' => $protocolActionMap ); } if ( !isset( $protocolActionMap['http-options'] ) ) { $protocolActionMap['http-options'] = 'httpOptions'; } $this->protocolActionMap = $protocolActionMap; parent::__construct( $pattern, $controllerClassName, '', $defaultValues ); } /** * Little fix to allow mixed regexp and rails routes in the router * @see lib/ezc/MvcTools/src/routes/ezcMvcRegexpRoute::prefix() */ public function prefix( $prefix ) { // Detect the Regexp delimiter $patternDelim = $this->pattern[0]; // Add the Regexp delimiter to the prefix $prefix = $patternDelim . $prefix . $patternDelim; parent::prefix( $prefix ); } /** * Evaluates the URI against this route and allowed protocols * * The method first runs the match. If the regular expression matches, it * cleans up the variables to only include named parameters. it then * creates an object containing routing information and returns it. If the * route's pattern did not match it returns null. * * @param ezcMvcRequest $request * @return null|<API key> */ public function matches( ezcMvcRequest $request ) { if ( $this->pregMatch( $request, $matches ) ) { foreach ( $matches as $key => $match ) { if ( is_numeric( $key ) ) { unset( $matches[$key] ); } } if ( !isset( $this->protocolActionMap[$request->protocol] ) ) { throw new <API key>( $this-><API key>() ); } $request->variables = array_merge( $this->defaultValues, $request->variables, $matches ); if ( $request->protocol === 'http-options' ) { $request->variables['<API key>'] = $this-><API key>(); } return new <API key>( $this->pattern, $this->controllerClassName, $this->protocolActionMap[$request->protocol] ); } return null; } /** * Returns an array containing the HTTP methods supported by the route * based on $this->protocolActionMap * * @return array(string) */ protected function <API key>() { $methods = array_keys( $this->protocolActionMap ); foreach ( $methods as &$method ) { $method = strtoupper( str_replace( 'http-', '', $method ) ); } return $methods; } } ?>
<?php get_header() ?> <div id="container"> <div id="content"> <?php the_post() ?> <h2 class="page-title"><a href="<?php echo get_permalink($post->post_parent) ?>" title="<?php printf( __( 'Return to %s', 'sandbox' ), wp_specialchars( get_the_title($post->post_parent), 1 ) ) ?>" rev="attachment"><?php echo get_the_title($post->post_parent) ?></a></h2> <div id="post-<?php the_ID() ?>" class="<?php sandbox_post_class() ?>"> <h3 class="entry-title"><?php the_title() ?></h3> <div class="entry-content"> <div class="entry-attachment"><a href="<?php echo <API key>($post->ID) ?>" title="<?php echo wp_specialchars( get_the_title($post->ID), 1 ) ?>" rel="attachment"><?php echo basename($post->guid) ?></a></div> <div class="entry-caption"><?php if ( !empty($post->post_excerpt) ) the_excerpt() ?></div> <?php the_content() ?> </div> <div class="entry-meta"> <?php printf( __( 'Posted by %1$s on <abbr class="published" title="%2$sT%3$s">%4$s at %5$s</abbr>. Bookmark the <a href="%6$s" title="Permalink to %7$s" rel="bookmark">permalink</a>. Follow any comments here with the <a href="%8$s" title="Comments RSS to %7$s" rel="alternate" type="application/rss+xml">RSS feed for this post</a>.', 'sandbox' ), '<span class="author vcard"><a class="url fn n" href="' . get_author_link( false, $authordata->ID, $authordata->user_nicename ) . '" title="' . sprintf( __( 'View all posts by %s', 'sandbox' ), $authordata->display_name ) . '">' . get_the_author() . '</a></span>', get_the_time('Y-m-d'), get_the_time('H:i:sO'), the_date( '', '', '', false ), get_the_time(), get_permalink(), the_title_attribute('echo=0'), comments_rss() ) ?> <?php if ( ('open' == $post->comment_status) && ('open' == $post->ping_status) ) : // Comments and trackbacks open ?> <?php printf( __( '<a class="comment-link" href="#respond" title="Post a comment">Post a comment</a> or leave a trackback: <a class="trackback-link" href="%s" title="Trackback URL for your post" rel="trackback">Trackback URL</a>.', 'sandbox' ), get_trackback_url() ) ?> <?php elseif ( !('open' == $post->comment_status) && ('open' == $post->ping_status) ) : // Only trackbacks open ?> <?php printf( __( 'Comments are closed, but you can leave a trackback: <a class="trackback-link" href="%s" title="Trackback URL for your post" rel="trackback">Trackback URL</a>.', 'sandbox' ), get_trackback_url() ) ?> <?php elseif ( ('open' == $post->comment_status) && !('open' == $post->ping_status) ) : // Only comments open ?> <?php _e( 'Trackbacks are closed, but you can <a class="comment-link" href="#respond" title="Post a comment">post a comment</a>.', 'sandbox' ) ?> <?php elseif ( !('open' == $post->comment_status) && !('open' == $post->ping_status) ) : // Comments and trackbacks closed ?> <?php _e( 'Both comments and trackbacks are currently closed.', 'sandbox' ) ?> <?php endif; ?> <?php edit_post_link( __( 'Edit', 'sandbox' ), "\n\t\t\t\t\t<span class=\"edit-link\">", "</span>" ) ?> </div> </div><!-- .post --> <?php comments_template() ?> </div><!-- #content --> </div><!-- #container --> <?php get_sidebar() ?> <?php get_footer() ?>
/* TMS1000 family - TMS1000, TMS1070, TMS1040, TMS1200 */ #ifndef _TMS1000_H_ #define _TMS1000_H_ #include "tms1k_base.h" class tms1000_cpu_device : public tms1k_base_device { public: tms1000_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); tms1000_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT8 o_pins, UINT8 r_pins, UINT8 pc_bits, UINT8 byte_bits, UINT8 x_bits, int prgwidth, <API key> program, int datawidth, <API key> data, const char *shortname, const char *source); protected: // overrides virtual void device_reset() override; virtual <API key> <API key>() const override; virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) override; }; class tms1070_cpu_device : public tms1000_cpu_device { public: tms1070_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); }; class tms1040_cpu_device : public tms1000_cpu_device { public: tms1040_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); }; class tms1200_cpu_device : public tms1000_cpu_device { public: tms1200_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); }; class tms1700_cpu_device : public tms1000_cpu_device { public: tms1700_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); }; class tms1730_cpu_device : public tms1000_cpu_device { public: tms1730_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); }; extern const device_type TMS1000; extern const device_type TMS1070; extern const device_type TMS1040; extern const device_type TMS1200; extern const device_type TMS1700; extern const device_type TMS1730; #endif /* _TMS1000_H_ */
#include <inttypes.h> #include <rte_ethdev.h> #include <rte_common.h> #include "fm10k.h" #include "base/fm10k_type.h" #ifdef <API key> #define rte_packet_prefetch(p) rte_prefetch1(p) #else #define rte_packet_prefetch(p) do {} while (0) #endif #ifdef <API key> static inline void dump_rxd(union fm10k_rx_desc *rxd) { PMD_RX_LOG(DEBUG, "+ PMD_RX_LOG(DEBUG, "| GLORT | PKT HDR & TYPE |"); PMD_RX_LOG(DEBUG, "| 0x%08x | 0x%08x |", rxd->d.glort, rxd->d.data); PMD_RX_LOG(DEBUG, "+ PMD_RX_LOG(DEBUG, "| VLAN & LEN | STATUS |"); PMD_RX_LOG(DEBUG, "| 0x%08x | 0x%08x |", rxd->d.vlan_len, rxd->d.staterr); PMD_RX_LOG(DEBUG, "+ PMD_RX_LOG(DEBUG, "| RESERVED | RSS_HASH |"); PMD_RX_LOG(DEBUG, "| 0x%08x | 0x%08x |", 0, rxd->d.rss); PMD_RX_LOG(DEBUG, "+ PMD_RX_LOG(DEBUG, "| TIME TAG |"); PMD_RX_LOG(DEBUG, "| 0x%016"PRIx64" |", rxd->q.timestamp); PMD_RX_LOG(DEBUG, "+ } #endif static inline void rx_desc_to_ol_flags(struct rte_mbuf *m, const union fm10k_rx_desc *d) { static const uint32_t ptype_table[<API key> >> <API key>] __rte_cache_aligned = { [FM10K_PKTTYPE_OTHER] = RTE_PTYPE_L2_ETHER, [FM10K_PKTTYPE_IPV4] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4, [<API key>] = RTE_PTYPE_L2_ETHER | <API key>, [FM10K_PKTTYPE_IPV6] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6, [<API key>] = RTE_PTYPE_L2_ETHER | <API key>, [FM10K_PKTTYPE_IPV4 | FM10K_PKTTYPE_TCP] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_TCP, [FM10K_PKTTYPE_IPV6 | FM10K_PKTTYPE_TCP] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_TCP, [FM10K_PKTTYPE_IPV4 | FM10K_PKTTYPE_UDP] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP, [FM10K_PKTTYPE_IPV6 | FM10K_PKTTYPE_UDP] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_UDP, }; m->packet_type = ptype_table[(d->w.pkt_info & <API key>) >> <API key>]; if (d->w.pkt_info & <API key>) m->ol_flags |= PKT_RX_RSS_HASH; if (unlikely((d->d.staterr & (<API key> | <API key>)) == (<API key> | <API key>))) m->ol_flags |= PKT_RX_IP_CKSUM_BAD; if (unlikely((d->d.staterr & (<API key> | <API key>)) == (<API key> | <API key>))) m->ol_flags |= PKT_RX_L4_CKSUM_BAD; if (unlikely(d->d.staterr & <API key>)) m->ol_flags |= <API key>; if (unlikely(d->d.staterr & <API key>)) m->ol_flags |= PKT_RX_RECIP_ERR; } uint16_t fm10k_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) { struct rte_mbuf *mbuf; union fm10k_rx_desc desc; struct fm10k_rx_queue *q = rx_queue; uint16_t count = 0; int alloc = 0; uint16_t next_dd; int ret; next_dd = q->next_dd; nb_pkts = RTE_MIN(nb_pkts, q->alloc_thresh); for (count = 0; count < nb_pkts; ++count) { mbuf = q->sw_ring[next_dd]; desc = q->hw_ring[next_dd]; if (!(desc.d.staterr & FM10K_RXD_STATUS_DD)) break; #ifdef <API key> dump_rxd(&desc); #endif rte_pktmbuf_pkt_len(mbuf) = desc.w.length; <API key>(mbuf) = desc.w.length; mbuf->ol_flags = 0; #ifdef <API key> rx_desc_to_ol_flags(mbuf, &desc); #endif mbuf->hash.rss = desc.d.rss; /** * Packets in fm10k device always carry at least one VLAN tag. * For those packets coming in without VLAN tag, * the port default VLAN tag will be used. * So, always PKT_RX_VLAN_PKT flag is set and vlan_tci * is valid for each RX packet's mbuf. */ mbuf->ol_flags |= PKT_RX_VLAN_PKT; mbuf->vlan_tci = desc.w.vlan; rx_pkts[count] = mbuf; if (++next_dd == q->nb_desc) { next_dd = 0; alloc = 1; } /* Prefetch next mbuf while processing current one. */ rte_prefetch0(q->sw_ring[next_dd]); /* * When next RX descriptor is on a cache-line boundary, * prefetch the next 4 RX descriptors and the next 8 pointers * to mbufs. */ if ((next_dd & 0x3) == 0) { rte_prefetch0(&q->hw_ring[next_dd]); rte_prefetch0(&q->sw_ring[next_dd]); } } q->next_dd = next_dd; if ((q->next_dd > q->next_trigger) || (alloc == 1)) { ret = <API key>(q->mp, (void **)&q->sw_ring[q->next_alloc], q->alloc_thresh); if (unlikely(ret != 0)) { uint8_t port = q->port_id; PMD_RX_LOG(ERR, "Failed to alloc mbuf"); /* * Need to restore next_dd if we cannot allocate new * buffers to replenish the old ones. */ q->next_dd = (q->next_dd + q->nb_desc - count) % q->nb_desc; rte_eth_devices[port].data-><API key>++; return 0; } for (; q->next_alloc <= q->next_trigger; ++q->next_alloc) { mbuf = q->sw_ring[q->next_alloc]; /* setup static mbuf fields */ fm10k_pktmbuf_reset(mbuf, q->port_id); /* write descriptor */ desc.q.pkt_addr = <API key>(mbuf); desc.q.hdr_addr = <API key>(mbuf); q->hw_ring[q->next_alloc] = desc; } FM10K_PCI_REG_WRITE(q->tail_ptr, q->next_trigger); q->next_trigger += q->alloc_thresh; if (q->next_trigger >= q->nb_desc) { q->next_trigger = q->alloc_thresh - 1; q->next_alloc = 0; } } return count; } uint16_t <API key>(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) { struct rte_mbuf *mbuf; union fm10k_rx_desc desc; struct fm10k_rx_queue *q = rx_queue; uint16_t count = 0; uint16_t nb_rcv, nb_seg; int alloc = 0; uint16_t next_dd; struct rte_mbuf *first_seg = q->pkt_first_seg; struct rte_mbuf *last_seg = q->pkt_last_seg; int ret; next_dd = q->next_dd; nb_rcv = 0; nb_seg = RTE_MIN(nb_pkts, q->alloc_thresh); for (count = 0; count < nb_seg; count++) { mbuf = q->sw_ring[next_dd]; desc = q->hw_ring[next_dd]; if (!(desc.d.staterr & FM10K_RXD_STATUS_DD)) break; #ifdef <API key> dump_rxd(&desc); #endif if (++next_dd == q->nb_desc) { next_dd = 0; alloc = 1; } /* Prefetch next mbuf while processing current one. */ rte_prefetch0(q->sw_ring[next_dd]); /* * When next RX descriptor is on a cache-line boundary, * prefetch the next 4 RX descriptors and the next 8 pointers * to mbufs. */ if ((next_dd & 0x3) == 0) { rte_prefetch0(&q->hw_ring[next_dd]); rte_prefetch0(&q->sw_ring[next_dd]); } /* Fill data length */ <API key>(mbuf) = desc.w.length; /* * If this is the first buffer of the received packet, * set the pointer to the first mbuf of the packet and * initialize its context. * Otherwise, update the total length and the number of segments * of the current scattered packet, and update the pointer to * the last mbuf of the current packet. */ if (!first_seg) { first_seg = mbuf; first_seg->pkt_len = desc.w.length; } else { first_seg->pkt_len = (uint16_t)(first_seg->pkt_len + <API key>(mbuf)); first_seg->nb_segs++; last_seg->next = mbuf; } /* * If this is not the last buffer of the received packet, * update the pointer to the last mbuf of the current scattered * packet and continue to parse the RX ring. */ if (!(desc.d.staterr & <API key>)) { last_seg = mbuf; continue; } first_seg->ol_flags = 0; #ifdef <API key> rx_desc_to_ol_flags(first_seg, &desc); #endif first_seg->hash.rss = desc.d.rss; /** * Packets in fm10k device always carry at least one VLAN tag. * For those packets coming in without VLAN tag, * the port default VLAN tag will be used. * So, always PKT_RX_VLAN_PKT flag is set and vlan_tci * is valid for each RX packet's mbuf. */ mbuf->ol_flags |= PKT_RX_VLAN_PKT; first_seg->vlan_tci = desc.w.vlan; /* Prefetch data of first segment, if configured to do so. */ rte_packet_prefetch((char *)first_seg->buf_addr + first_seg->data_off); /* * Store the mbuf address into the next entry of the array * of returned packets. */ rx_pkts[nb_rcv++] = first_seg; /* * Setup receipt context for a new packet. */ first_seg = NULL; } q->next_dd = next_dd; if ((q->next_dd > q->next_trigger) || (alloc == 1)) { ret = <API key>(q->mp, (void **)&q->sw_ring[q->next_alloc], q->alloc_thresh); if (unlikely(ret != 0)) { uint8_t port = q->port_id; PMD_RX_LOG(ERR, "Failed to alloc mbuf"); /* * Need to restore next_dd if we cannot allocate new * buffers to replenish the old ones. */ q->next_dd = (q->next_dd + q->nb_desc - count) % q->nb_desc; rte_eth_devices[port].data-><API key>++; return 0; } for (; q->next_alloc <= q->next_trigger; ++q->next_alloc) { mbuf = q->sw_ring[q->next_alloc]; /* setup static mbuf fields */ fm10k_pktmbuf_reset(mbuf, q->port_id); /* write descriptor */ desc.q.pkt_addr = <API key>(mbuf); desc.q.hdr_addr = <API key>(mbuf); q->hw_ring[q->next_alloc] = desc; } FM10K_PCI_REG_WRITE(q->tail_ptr, q->next_trigger); q->next_trigger += q->alloc_thresh; if (q->next_trigger >= q->nb_desc) { q->next_trigger = q->alloc_thresh - 1; q->next_alloc = 0; } } q->pkt_first_seg = first_seg; q->pkt_last_seg = last_seg; return nb_rcv; } static inline void tx_free_descriptors(struct fm10k_tx_queue *q) { uint16_t next_rs, count = 0; next_rs = fifo_peek(&q->rs_tracker); if (!(q->hw_ring[next_rs].flags & FM10K_TXD_FLAG_DONE)) return; /* the DONE flag is set on this descriptor so remove the ID * from the RS bit tracker and free the buffers */ fifo_remove(&q->rs_tracker); /* wrap around? if so, free buffers from last_free up to but NOT * including nb_desc */ if (q->last_free > next_rs) { count = q->nb_desc - q->last_free; while (q->last_free < q->nb_desc) { <API key>(q->sw_ring[q->last_free]); q->sw_ring[q->last_free] = NULL; ++q->last_free; } q->last_free = 0; } /* adjust free descriptor count before the next loop */ q->nb_free += count + (next_rs + 1 - q->last_free); /* free buffers from last_free, up to and including next_rs */ while (q->last_free <= next_rs) { <API key>(q->sw_ring[q->last_free]); q->sw_ring[q->last_free] = NULL; ++q->last_free; } if (q->last_free == q->nb_desc) q->last_free = 0; } static inline void tx_xmit_pkt(struct fm10k_tx_queue *q, struct rte_mbuf *mb) { uint16_t last_id; uint8_t flags, hdrlen; /* always set the LAST flag on the last descriptor used to * transmit the packet */ flags = FM10K_TXD_FLAG_LAST; last_id = q->next_free + mb->nb_segs - 1; if (last_id >= q->nb_desc) last_id = last_id - q->nb_desc; /* but only set the RS flag on the last descriptor if rs_thresh * descriptors will be used since the RS flag was last set */ if ((q->nb_used + mb->nb_segs) >= q->rs_thresh) { flags |= FM10K_TXD_FLAG_RS; fifo_insert(&q->rs_tracker, last_id); q->nb_used = 0; } else { q->nb_used = q->nb_used + mb->nb_segs; } q->nb_free -= mb->nb_segs; q->hw_ring[q->next_free].flags = 0; /* set checksum flags on first descriptor of packet. SCTP checksum * offload is not supported, but we do not explicitly check for this * case in favor of greatly simplified processing. */ if (mb->ol_flags & (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK | PKT_TX_TCP_SEG)) q->hw_ring[q->next_free].flags |= FM10K_TXD_FLAG_CSUM; /* set vlan if requested */ if (mb->ol_flags & PKT_TX_VLAN_PKT) q->hw_ring[q->next_free].vlan = mb->vlan_tci; q->sw_ring[q->next_free] = mb; q->hw_ring[q->next_free].buffer_addr = rte_cpu_to_le_64(MBUF_DMA_ADDR(mb)); q->hw_ring[q->next_free].buflen = rte_cpu_to_le_16(<API key>(mb)); if (mb->ol_flags & PKT_TX_TCP_SEG) { hdrlen = mb->outer_l2_len + mb->outer_l3_len + mb->l2_len + mb->l3_len + mb->l4_len; if (q->hw_ring[q->next_free].flags & FM10K_TXD_FLAG_FTAG) hdrlen += sizeof(struct fm10k_ftag); if (likely((hdrlen >= <API key>) && (hdrlen <= <API key>) && (mb->tso_segsz >= FM10K_TSO_MINMSS))) { q->hw_ring[q->next_free].mss = mb->tso_segsz; q->hw_ring[q->next_free].hdrlen = hdrlen; } } if (++q->next_free == q->nb_desc) q->next_free = 0; /* fill up the rings */ for (mb = mb->next; mb != NULL; mb = mb->next) { q->sw_ring[q->next_free] = mb; q->hw_ring[q->next_free].buffer_addr = rte_cpu_to_le_64(MBUF_DMA_ADDR(mb)); q->hw_ring[q->next_free].buflen = rte_cpu_to_le_16(<API key>(mb)); q->hw_ring[q->next_free].flags = 0; if (++q->next_free == q->nb_desc) q->next_free = 0; } q->hw_ring[last_id].flags |= flags; } uint16_t fm10k_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) { struct fm10k_tx_queue *q = tx_queue; struct rte_mbuf *mb; uint16_t count; for (count = 0; count < nb_pkts; ++count) { mb = tx_pkts[count]; /* running low on descriptors? try to free some... */ if (q->nb_free < q->free_thresh) tx_free_descriptors(q); /* make sure there are enough free descriptors to transmit the * entire packet before doing anything */ if (q->nb_free < mb->nb_segs) break; /* sanity check to make sure the mbuf is valid */ if ((mb->nb_segs == 0) || ((mb->nb_segs > 1) && (mb->next == NULL))) break; /* process the packet */ tx_xmit_pkt(q, mb); } /* update the tail pointer if any packets were processed */ if (likely(count > 0)) FM10K_PCI_REG_WRITE(q->tail_ptr, q->next_free); return count; }
#pragma once #include "core/hle/service/service.h" // Namespace AM_NET namespace AM_NET { class Interface : public Service::Interface { public: Interface(); std::string GetPortName() const override { return "am:net"; } }; } // namespace
package javafx.scene; import com.sun.javafx.test.TestHelper; import javafx.geometry.BoundingBox; import javafx.scene.transform.Rotate; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import javafx.geometry.Bounds; import javafx.geometry.Point2D; import javafx.scene.shape.Rectangle; import javafx.scene.shape.Circle; import javafx.scene.transform.Translate; import org.junit.Test; public class <API key> { private static final Rectangle r1 = new Rectangle(100, 100, 100, 100); private static final Rectangle r2 = new Rectangle(250, 250, 50, 50); private static final Rectangle r3 = new Rectangle(50, 50, 10, 10); @Test public void <API key>() { final Group g = new Group(); Bounds b; b = g.getBoundsInParent(); assertTrue(b.isEmpty()); g.getChildren().add(r1); b = g.getBoundsInParent(); assertEquals(100, b.getMinX(), 0.0001); assertEquals(100, b.getMinY(), 0.0001); assertEquals(100, b.getWidth(), 0.0001); assertEquals(100, b.getHeight(), 0.0001); g.getChildren().add(r2); b = g.getBoundsInParent(); assertEquals(100, b.getMinX(), 0.0001); assertEquals(100, b.getMinY(), 0.0001); assertEquals(200, b.getWidth(), 0.0001); assertEquals(200, b.getHeight(), 0.0001); g.getChildren().add(r3); b = g.getBoundsInParent(); assertEquals(50, b.getMinX(), 0.0001); assertEquals(50, b.getMinY(), 0.0001); assertEquals(250, b.getWidth(), 0.0001); assertEquals(250, b.getHeight(), 0.0001); } @Test public void <API key>() { final Group g = new Group(); g.getChildren().add(r1); g.getChildren().add(r2); g.getChildren().add(r3); Bounds b; b = g.getBoundsInParent(); assertEquals(50, b.getMinX(), 0.0001); assertEquals(50, b.getMinY(), 0.0001); assertEquals(250, b.getWidth(), 0.0001); assertEquals(250, b.getHeight(), 0.0001); g.getChildren().remove(r3); b = g.getBoundsInParent(); assertEquals(100, b.getMinX(), 0.0001); assertEquals(100, b.getMinY(), 0.0001); assertEquals(200, b.getWidth(), 0.0001); assertEquals(200, b.getHeight(), 0.0001); g.getChildren().remove(r2); b = g.getBoundsInParent(); assertEquals(100, b.getMinX(), 0.0001); assertEquals(100, b.getMinY(), 0.0001); assertEquals(100, b.getWidth(), 0.0001); assertEquals(100, b.getHeight(), 0.0001); g.getChildren().remove(r1); b = g.getBoundsInParent(); assertTrue(b.isEmpty()); } @Test public void <API key>() { final Group g = new Group(); g.getChildren().add(r1); g.getChildren().add(r2); g.getChildren().add(r3); Bounds b; b = g.getBoundsInParent(); assertEquals(50, b.getMinX(), 0.0001); assertEquals(50, b.getMinY(), 0.0001); assertEquals(250, b.getWidth(), 0.0001); assertEquals(250, b.getHeight(), 0.0001); r3.setVisible(false); b = g.getBoundsInParent(); assertEquals(100, b.getMinX(), 0.0001); assertEquals(100, b.getMinY(), 0.0001); assertEquals(200, b.getWidth(), 0.0001); assertEquals(200, b.getHeight(), 0.0001); r3.setVisible(true); b = g.getBoundsInParent(); assertEquals(50, b.getMinX(), 0.0001); assertEquals(50, b.getMinY(), 0.0001); assertEquals(250, b.getWidth(), 0.0001); assertEquals(250, b.getHeight(), 0.0001); } @Test public void <API key>() { final Group g = new Group(); final Rectangle r = new Rectangle(200,200,1,1); g.getChildren().add(r2); g.getChildren().add(r); g.getChildren().add(r3); Bounds b; r.setVisible(false); b = g.getBoundsInParent(); assertEquals(50, b.getMinX(), 0.0001); assertEquals(50, b.getMinY(), 0.0001); assertEquals(250, b.getWidth(), 0.0001); assertEquals(250, b.getHeight(), 0.0001); r.setX(10); b = g.getBoundsInParent(); assertEquals(50, b.getMinX(), 0.0001); assertEquals(50, b.getMinY(), 0.0001); assertEquals(250, b.getWidth(), 0.0001); assertEquals(250, b.getHeight(), 0.0001); r.setWidth(500); b = g.getBoundsInParent(); assertEquals(50, b.getMinX(), 0.0001); assertEquals(50, b.getMinY(), 0.0001); assertEquals(250, b.getWidth(), 0.0001); assertEquals(250, b.getHeight(), 0.0001); } @Test public void <API key>() { final Group g = new Group(); final Rectangle r = new Rectangle(200,200,1,1); g.getChildren().add(r2); g.getChildren().add(r); g.getChildren().add(r3); Bounds b; b = g.getBoundsInParent(); assertEquals(50, b.getMinX(), 0.0001); assertEquals(50, b.getMinY(), 0.0001); assertEquals(250, b.getWidth(), 0.0001); assertEquals(250, b.getHeight(), 0.0001); r.setX(190); r.setY(190); r.setWidth(48); r.setHeight(48); b = g.getBoundsInParent(); assertEquals(50, b.getMinX(), 0.0001); assertEquals(50, b.getMinY(), 0.0001); assertEquals(250, b.getWidth(), 0.0001); assertEquals(250, b.getHeight(), 0.0001); } @Test public void <API key>() { final Group g = new Group(); final Rectangle r = new Rectangle(200,200,50,50); g.getChildren().add(r); g.getChildren().add(r3); Bounds b; b = g.getBoundsInParent(); assertEquals(50, b.getMinX(), 0.0001); assertEquals(50, b.getMinY(), 0.0001); assertEquals(200, b.getWidth(), 0.0001); assertEquals(200, b.getHeight(), 0.0001); r.setX(100); r.setY(100); r.setWidth(150); r.setHeight(150); b = g.getBoundsInParent(); assertEquals(50, b.getMinX(), 0.0001); assertEquals(50, b.getMinY(), 0.0001); assertEquals(200, b.getWidth(), 0.0001); assertEquals(200, b.getHeight(), 0.0001); } @Test public void <API key>() { final Group g = new Group(); final Rectangle r = new Rectangle(200,200,1,1); g.getChildren().add(r2); g.getChildren().add(r); g.getChildren().add(r3); Bounds b; b = g.getBoundsInParent(); assertEquals(50, b.getMinX(), 0.0001); assertEquals(50, b.getMinY(), 0.0001); assertEquals(250, b.getWidth(), 0.0001); assertEquals(250, b.getHeight(), 0.0001); r.setX(40); b = g.getBoundsInParent(); assertEquals(40, b.getMinX(), 0.0001); assertEquals(50, b.getMinY(), 0.0001); assertEquals(260, b.getWidth(), 0.0001); assertEquals(250, b.getHeight(), 0.0001); r.setX(200); b = g.getBoundsInParent(); assertEquals(50, b.getMinX(), 0.0001); assertEquals(50, b.getMinY(), 0.0001); assertEquals(250, b.getWidth(), 0.0001); assertEquals(250, b.getHeight(), 0.0001); } @Test public void <API key>() { final Group g = new Group(); final Rectangle r = new Rectangle(200,200,1,1); g.getChildren().add(r2); g.getChildren().add(r); g.getChildren().add(r3); Bounds b; b = g.getBoundsInParent(); assertEquals(50, b.getMinX(), 0.0001); assertEquals(50, b.getMinY(), 0.0001); assertEquals(250, b.getWidth(), 0.0001); assertEquals(250, b.getHeight(), 0.0001); r.setWidth(200); b = g.getBoundsInParent(); assertEquals(50, b.getMinX(), 0.0001); assertEquals(50, b.getMinY(), 0.0001); assertEquals(350, b.getWidth(), 0.0001); assertEquals(250, b.getHeight(), 0.0001); r.setWidth(5); b = g.getBoundsInParent(); assertEquals(50, b.getMinX(), 0.0001); assertEquals(50, b.getMinY(), 0.0001); assertEquals(250, b.getWidth(), 0.0001); assertEquals(250, b.getHeight(), 0.0001); } @Test public void <API key>() { final Group g = new Group(); final Rectangle lt = new Rectangle(100, 100, 100, 100); final Rectangle rt = new Rectangle(200, 100, 100, 100); final Rectangle lb = new Rectangle(100, 200, 100, 100); final Rectangle rb = new Rectangle(200, 200, 100, 100); final Rectangle rm1 = new Rectangle(150, 150, 50, 50); final Rectangle rm2 = new Rectangle(150, 150, 50, 50); Bounds b; g.getChildren().add(lt); g.getChildren().add(rt); g.getChildren().add(lb); g.getChildren().add(rb); g.getChildren().add(rm1); g.getChildren().add(rm2); for (int i = 0; i < 20; i++) { g.getChildren().add(new Rectangle(150 + i, 150 + i, 50 + i, 50 + i)); } b = g.getBoundsInParent(); assertEquals(100, b.getMinX(), 0.0001); assertEquals(100, b.getMinY(), 0.0001); assertEquals(200, b.getWidth(), 0.0001); assertEquals(200, b.getHeight(), 0.0001); lt.setX(50); rt.setX(250); lb.setY(250); rb.setX(220); rm1.setY(50); rm2.setX(151); rm2.setY(151); b = g.getBoundsInParent(); assertEquals(50, b.getMinX(), 0.0001); assertEquals(50, b.getMinY(), 0.0001); assertEquals(300, b.getWidth(), 0.0001); assertEquals(300, b.getHeight(), 0.0001); } @Test public void <API key>() { final Group g = new Group(); final Rectangle lt = new Rectangle(100, 100, 100, 100); final Rectangle rt = new Rectangle(200, 100, 100, 100); final Rectangle lb = new Rectangle(100, 200, 100, 100); final Rectangle rb = new Rectangle(200, 200, 100, 100); final Rectangle rm1 = new Rectangle(150, 150, 50, 50); final Rectangle rm2 = new Rectangle(150, 150, 50, 50); Bounds b; g.getChildren().addAll(lt, rt, lb, rb, rm1, rm2); for (int i = 0; i < 20; i++) { g.getChildren().add(new Rectangle(150 + i, 150 + i, 50 + i, 50 + i)); } b = g.getBoundsInLocal(); assertEquals(100, b.getMinX(), 0.0001); assertEquals(100, b.getMinY(), 0.0001); assertEquals(200, b.getWidth(), 0.0001); assertEquals(200, b.getHeight(), 0.0001); g.getTransforms().add(new Rotate(45)); lt.setX(50); rt.setX(250); lb.setY(250); rb.setX(220); rm1.setY(50); rm2.setX(151); rm2.setY(151); // this call gets transformed Parent bounds and shouldn't clear the // Parent's dirty children list g.getBoundsInParent(); b = g.getBoundsInLocal(); assertEquals(50, b.getMinX(), 0.0001); assertEquals(50, b.getMinY(), 0.0001); assertEquals(300, b.getWidth(), 0.0001); assertEquals(300, b.getHeight(), 0.0001); } @Test public void <API key>() { final Group g = new Group(); final Rectangle lt = new Rectangle(50, 50, 50, 50); final Rectangle rb = new Rectangle(100, 100, 50, 50); Bounds b; g.getChildren().addAll(lt, rb); b = g.getBoundsInLocal(); assertEquals(50, b.getMinX(), 0.0001); assertEquals(50, b.getMinY(), 0.0001); assertEquals(100, b.getWidth(), 0.0001); assertEquals(100, b.getHeight(), 0.0001); // invalidate (empty) bounds rb.setVisible(false); // add new rectangle, bounds should not be recalculated by using // empty bounds g.getChildren().add(new Rectangle(150, 150, 50, 50)); b = g.getBoundsInLocal(); assertEquals(50, b.getMinX(), 0.0001); assertEquals(50, b.getMinY(), 0.0001); assertEquals(150, b.getWidth(), 0.0001); assertEquals(150, b.getHeight(), 0.0001); } @Test public void <API key>() { final Group g = new Group(); final Rectangle lt = new Rectangle(100, 100, 100, 100); final Rectangle mt = new Rectangle(200, 100, 100, 100); final Rectangle rt = new Rectangle(300, 100, 100, 100); final Rectangle rb = new Rectangle(300, 200, 100, 100); Bounds b; g.getChildren().addAll(lt, mt); b = g.getBoundsInLocal(); assertEquals(100, b.getMinX(), 0.0001); assertEquals(100, b.getMinY(), 0.0001); assertEquals(200, b.getWidth(), 0.0001); assertEquals(100, b.getHeight(), 0.0001); ((Node) rb).boundsChanged = false; // rt, rb should be either incorporated into parent bounds directly // or marked as dirty for parent bounds calculation g.getChildren().addAll(rt, rb); b = g.getBoundsInLocal(); assertEquals(100, b.getMinX(), 0.0001); assertEquals(100, b.getMinY(), 0.0001); assertEquals(300, b.getWidth(), 0.0001); assertEquals(200, b.getHeight(), 0.0001); } @Test public void <API key>() { final Group g = new Group(); final Rectangle lt = new Rectangle(100, 100, 100, 100); final Rectangle rt = new Rectangle(200, 100, 100, 100); final Rectangle lb = new Rectangle(100, 200, 100, 100); final Rectangle rb = new Rectangle(200, 200, 100, 100); Bounds b; g.getChildren().addAll(lt, rt, lb, rb); final int toAdd = Parent.<API key> - 4; for (int i = 0; i < toAdd; ++i) { g.getChildren().add( new Rectangle(150 + i * 80 / (toAdd - 1), 190, 20, 20)); } b = g.getBoundsInLocal(); assertEquals(100, b.getMinX(), 0.0001); assertEquals(100, b.getMinY(), 0.0001); assertEquals(200, b.getWidth(), 0.0001); assertEquals(200, b.getHeight(), 0.0001); lt.setX(50); // this should create a dirty children list on Parent, even though // the added node doesn't change the group gemetry, the created // dirty children list should still contain the previously modified // corner node (lt) g.getChildren().add(new Rectangle(150, 150, 100, 100)); b = g.getBoundsInLocal(); assertEquals(50, b.getMinX(), 0.0001); assertEquals(100, b.getMinY(), 0.0001); assertEquals(250, b.getWidth(), 0.0001); assertEquals(200, b.getHeight(), 0.0001); } @Test public void <API key>() { final Group g = new Group(new Circle(0, -100, 0.001), new Circle(0, 100, 0.001), new Circle(-100, 0, 0.001), new Circle(100, 0, 0.001)); g.getTransforms().add(new Rotate(-45)); Bounds b; b = g.getBoundsInParent(); assertEquals(-100 * Math.sqrt(2) / 2, b.getMinX(), 0.1); assertEquals(-100 * Math.sqrt(2) / 2, b.getMinY(), 0.1); assertEquals(100 * Math.sqrt(2), b.getWidth(), 0.1); assertEquals(100 * Math.sqrt(2), b.getHeight(), 0.1); g.getChildren().add(new Circle(95, -95, 0.001)); b = g.getBoundsInParent(); assertEquals(-100 * Math.sqrt(2) / 2, b.getMinX(), 0.1); assertEquals(-95 * Math.sqrt(2), b.getMinY(), 0.1); assertEquals(100 * Math.sqrt(2), b.getWidth(), 0.1); assertEquals((50 + 95) * Math.sqrt(2), b.getHeight(), 0.1); } @Test public void <API key>() { final Circle toRemove = new Circle(95, -95, 0.001); final Group g = new Group(toRemove, new Circle(0, -100, 0.001), new Circle(0, 100, 0.001), new Circle(-100, 0, 0.001), new Circle(100, 0, 0.001)); g.getTransforms().add(new Rotate(-45)); Bounds b; b = g.getBoundsInParent(); assertEquals(-100 * Math.sqrt(2) / 2, b.getMinX(), 0.1); assertEquals(-95 * Math.sqrt(2), b.getMinY(), 0.1); assertEquals(100 * Math.sqrt(2), b.getWidth(), 0.1); assertEquals((50 + 95) * Math.sqrt(2), b.getHeight(), 0.1); g.getChildren().remove(toRemove); b = g.getBoundsInParent(); assertEquals(-100 * Math.sqrt(2) / 2, b.getMinX(), 0.1); assertEquals(-100 * Math.sqrt(2) / 2, b.getMinY(), 0.1); assertEquals(100 * Math.sqrt(2), b.getWidth(), 0.1); assertEquals(100 * Math.sqrt(2), b.getHeight(), 0.1); } @Test public void <API key>() { final Rectangle child = new Rectangle(0, 0, 100, 100); final Group parent = new Group(child); // ensures that child's <API key> will be called with // a non-identity transform argument during parent's bounds calculations parent.getTransforms().add(new Rotate(-45)); // make the cached child's transformed bounds dirty child.getTransforms().add(new Translate(50, 0)); // the cached child's transformed bounds will remain dirty because // of a non-trivial parent transformation TestHelper.assertSimilar( boundsOfRotatedRect(50, 0, 100, 100, -45), parent.getBoundsInParent()); // during the following call the child bounds changed notification // should still be generated even though the child's cached transformed // bounds are already dirty child.getTransforms().add(new Translate(50, 0)); TestHelper.assertSimilar( boundsOfRotatedRect(100, 0, 100, 100, -45), parent.getBoundsInParent()); } private static Bounds boundsOfRotatedRect( final double x, final double y, final double width, final double height, final double angle) { final Point2D p1 = rotatePoint(x, y, angle); final Point2D p2 = rotatePoint(x + width, y, angle); final Point2D p3 = rotatePoint(x, y + height, angle); final Point2D p4 = rotatePoint(x + width, y + height, angle); final double minx = min(p1.getX(), p2.getX(), p3.getX(), p4.getX()); final double miny = min(p1.getY(), p2.getY(), p3.getY(), p4.getY()); final double maxx = max(p1.getX(), p2.getX(), p3.getX(), p4.getX()); final double maxy = max(p1.getY(), p2.getY(), p3.getY(), p4.getY()); return new BoundingBox(minx, miny, maxx - minx, maxy - miny); } private static Point2D rotatePoint(final double x, final double y, final double angle) { final double rada = Math.toRadians(angle); final double sina = Math.sin(rada); final double cosa = Math.cos(rada); return new Point2D(x * cosa - y * sina, x * sina + y * cosa); } private static double min(final double... values) { double result = values[0]; for (int i = 1; i < values.length; ++i) { if (result > values[i]) { result = values[i]; } } return result; } private static double max(final double... values) { double result = values[0]; for (int i = 1; i < values.length; ++i) { if (result < values[i]) { result = values[i]; } } return result; } }
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ #include "ns3/log.h" #include "ns3/inet-socket-address.h" #include "ns3/packet.h" #include "ns3/node.h" #include "ns3/epc-gtpu-header.h" #include "ns3/epc-x2-header.h" #include "ns3/epc-x2.h" namespace ns3 { <API key> ("EpcX2"); X2IfaceInfo::X2IfaceInfo (Ipv4Address remoteIpAddr, Ptr<Socket> <API key>, Ptr<Socket> <API key>) { m_remoteIpAddr = remoteIpAddr; <API key> = <API key>; <API key> = <API key>; } X2IfaceInfo::~X2IfaceInfo (void) { <API key> = 0; <API key> = 0; } X2IfaceInfo& X2IfaceInfo::operator= (const X2IfaceInfo& value) { NS_LOG_FUNCTION (this); m_remoteIpAddr = value.m_remoteIpAddr; <API key> = value.<API key>; <API key> = value.<API key>; return *this; } X2CellInfo::X2CellInfo (uint16_t localCellId, uint16_t remoteCellId) { m_localCellId = localCellId; m_remoteCellId = remoteCellId; } X2CellInfo::~X2CellInfo (void) { m_localCellId = 0; m_remoteCellId = 0; } X2CellInfo& X2CellInfo::operator= (const X2CellInfo& value) { NS_LOG_FUNCTION (this); m_localCellId = value.m_localCellId; m_remoteCellId = value.m_remoteCellId; return *this; } <API key> (EpcX2); EpcX2::EpcX2 () : m_x2cUdpPort (4444), m_x2uUdpPort (2152) { NS_LOG_FUNCTION (this); m_x2SapProvider = new <API key><EpcX2> (this); } EpcX2::~EpcX2 () { NS_LOG_FUNCTION (this); } void EpcX2::DoDispose (void) { NS_LOG_FUNCTION (this); <API key>.clear (); <API key>.clear (); delete m_x2SapProvider; } TypeId EpcX2::GetTypeId (void) { static TypeId tid = TypeId ("ns3::EpcX2") .SetParent<Object> (); return tid; } void EpcX2::SetEpcX2SapUser (EpcX2SapUser * s) { NS_LOG_FUNCTION (this << s); m_x2SapUser = s; } EpcX2SapProvider* EpcX2::GetEpcX2SapProvider () { NS_LOG_FUNCTION (this); return m_x2SapProvider; } void EpcX2::AddX2Interface (uint16_t localCellId, Ipv4Address localX2Address, uint16_t remoteCellId, Ipv4Address remoteX2Address) { NS_LOG_FUNCTION (this << localCellId << localX2Address << remoteCellId << remoteX2Address); int retval; // Get local eNB where this X2 entity belongs to Ptr<Node> localEnb = GetObject<Node> (); // Create X2-C socket for the local eNB Ptr<Socket> localX2cSocket = Socket::CreateSocket (localEnb, TypeId::LookupByName ("ns3::UdpSocketFactory")); retval = localX2cSocket->Bind (InetSocketAddress (localX2Address, m_x2cUdpPort)); NS_ASSERT (retval == 0); localX2cSocket->SetRecvCallback (MakeCallback (&EpcX2::RecvFromX2cSocket, this)); // Create X2-U socket for the local eNB Ptr<Socket> localX2uSocket = Socket::CreateSocket (localEnb, TypeId::LookupByName ("ns3::UdpSocketFactory")); retval = localX2uSocket->Bind (InetSocketAddress (localX2Address, m_x2uUdpPort)); NS_ASSERT (retval == 0); localX2uSocket->SetRecvCallback (MakeCallback (&EpcX2::RecvFromX2uSocket, this)); NS_ASSERT_MSG (<API key>.find (remoteCellId) == <API key>.end (), "Mapping for remoteCellId = " << remoteCellId << " is already known"); <API key> [remoteCellId] = Create<X2IfaceInfo> (remoteX2Address, localX2cSocket, localX2uSocket); NS_ASSERT_MSG (<API key>.find (localX2cSocket) == <API key>.end (), "Mapping for control plane localSocket = " << localX2cSocket << " is already known"); <API key> [localX2cSocket] = Create<X2CellInfo> (localCellId, remoteCellId); NS_ASSERT_MSG (<API key>.find (localX2uSocket) == <API key>.end (), "Mapping for data plane localSocket = " << localX2uSocket << " is already known"); <API key> [localX2uSocket] = Create<X2CellInfo> (localCellId, remoteCellId); } void EpcX2::RecvFromX2cSocket (Ptr<Socket> socket) { NS_LOG_FUNCTION (this << socket); NS_LOG_LOGIC ("Recv X2 message: from Socket"); Ptr<Packet> packet = socket->Recv (); NS_LOG_LOGIC ("packetLen = " << packet->GetSize ()); NS_ASSERT_MSG (<API key>.find (socket) != <API key>.end (), "Missing infos of local and remote CellId"); Ptr<X2CellInfo> cellsInfo = <API key> [socket]; EpcX2Header x2Header; packet->RemoveHeader (x2Header); NS_LOG_LOGIC ("X2 header: " << x2Header); uint8_t messageType = x2Header.GetMessageType (); uint8_t procedureCode = x2Header.GetProcedureCode (); if (procedureCode == EpcX2Header::HandoverPreparation) { if (messageType == EpcX2Header::InitiatingMessage) { NS_LOG_LOGIC ("Recv X2 message: HANDOVER REQUEST"); <API key> x2HoReqHeader; packet->RemoveHeader (x2HoReqHeader); NS_LOG_INFO ("X2 HandoverRequest header: " << x2HoReqHeader); EpcX2SapUser::<API key> params; params.oldEnbUeX2apId = x2HoReqHeader.GetOldEnbUeX2apId (); params.cause = x2HoReqHeader.GetCause (); params.sourceCellId = cellsInfo->m_remoteCellId; params.targetCellId = x2HoReqHeader.GetTargetCellId (); params.mmeUeS1apId = x2HoReqHeader.GetMmeUeS1apId (); params.<API key> = x2HoReqHeader.<API key> (); params.<API key> = x2HoReqHeader.<API key> (); params.bearers = x2HoReqHeader.GetBearers (); params.rrcContext = packet; NS_LOG_LOGIC ("oldEnbUeX2apId = " << params.oldEnbUeX2apId); NS_LOG_LOGIC ("sourceCellId = " << params.sourceCellId); NS_LOG_LOGIC ("targetCellId = " << params.targetCellId); NS_LOG_LOGIC ("mmeUeS1apId = " << params.mmeUeS1apId); NS_LOG_LOGIC ("cellsInfo->m_localCellId = " << cellsInfo->m_localCellId); NS_ASSERT_MSG (params.targetCellId == cellsInfo->m_localCellId, "TargetCellId mismatches with localCellId"); m_x2SapUser->RecvHandoverRequest (params); } else if (messageType == EpcX2Header::SuccessfulOutcome) { NS_LOG_LOGIC ("Recv X2 message: HANDOVER REQUEST ACK"); <API key> x2HoReqAckHeader; packet->RemoveHeader (x2HoReqAckHeader); NS_LOG_INFO ("X2 HandoverRequestAck header: " << x2HoReqAckHeader); EpcX2SapUser::<API key> params; params.oldEnbUeX2apId = x2HoReqAckHeader.GetOldEnbUeX2apId (); params.newEnbUeX2apId = x2HoReqAckHeader.GetNewEnbUeX2apId (); params.sourceCellId = cellsInfo->m_localCellId; params.targetCellId = cellsInfo->m_remoteCellId; params.admittedBearers = x2HoReqAckHeader.GetAdmittedBearers (); params.notAdmittedBearers = x2HoReqAckHeader.<API key> (); params.rrcContext = packet; NS_LOG_LOGIC ("oldEnbUeX2apId = " << params.oldEnbUeX2apId); NS_LOG_LOGIC ("newEnbUeX2apId = " << params.newEnbUeX2apId); NS_LOG_LOGIC ("sourceCellId = " << params.sourceCellId); NS_LOG_LOGIC ("targetCellId = " << params.targetCellId); m_x2SapUser-><API key> (params); } else // messageType == EpcX2Header::UnsuccessfulOutcome { NS_LOG_LOGIC ("Recv X2 message: HANDOVER PREPARATION FAILURE"); <API key> x2HoPrepFailHeader; packet->RemoveHeader (x2HoPrepFailHeader); NS_LOG_INFO ("X2 <API key> header: " << x2HoPrepFailHeader); EpcX2SapUser::<API key> params; params.oldEnbUeX2apId = x2HoPrepFailHeader.GetOldEnbUeX2apId (); params.sourceCellId = cellsInfo->m_localCellId; params.targetCellId = cellsInfo->m_remoteCellId; params.cause = x2HoPrepFailHeader.GetCause (); params.<API key> = x2HoPrepFailHeader.<API key> (); NS_LOG_LOGIC ("oldEnbUeX2apId = " << params.oldEnbUeX2apId); NS_LOG_LOGIC ("sourceCellId = " << params.sourceCellId); NS_LOG_LOGIC ("targetCellId = " << params.targetCellId); NS_LOG_LOGIC ("cause = " << params.cause); NS_LOG_LOGIC ("<API key> = " << params.<API key>); m_x2SapUser-><API key> (params); } } else if (procedureCode == EpcX2Header::LoadIndication) { if (messageType == EpcX2Header::InitiatingMessage) { NS_LOG_LOGIC ("Recv X2 message: LOAD INFORMATION"); <API key> x2LoadInfoHeader; packet->RemoveHeader (x2LoadInfoHeader); NS_LOG_INFO ("X2 LoadInformation header: " << x2LoadInfoHeader); EpcX2SapUser::<API key> params; params.cellInformationList = x2LoadInfoHeader.<API key> (); NS_LOG_LOGIC ("cellInformationList size = " << params.cellInformationList.size ()); m_x2SapUser->RecvLoadInformation (params); } } else if (procedureCode == EpcX2Header::SnStatusTransfer) { if (messageType == EpcX2Header::InitiatingMessage) { NS_LOG_LOGIC ("Recv X2 message: SN STATUS TRANSFER"); <API key> <API key>; packet->RemoveHeader (<API key>); NS_LOG_INFO ("X2 SnStatusTransfer header: " << <API key>); EpcX2SapUser::<API key> params; params.oldEnbUeX2apId = <API key>.GetOldEnbUeX2apId (); params.newEnbUeX2apId = <API key>.GetNewEnbUeX2apId (); params.sourceCellId = cellsInfo->m_remoteCellId; params.targetCellId = cellsInfo->m_localCellId; params.<API key> = <API key>.<API key> (); NS_LOG_LOGIC ("oldEnbUeX2apId = " << params.oldEnbUeX2apId); NS_LOG_LOGIC ("newEnbUeX2apId = " << params.newEnbUeX2apId); NS_LOG_LOGIC ("sourceCellId = " << params.sourceCellId); NS_LOG_LOGIC ("targetCellId = " << params.targetCellId); NS_LOG_LOGIC ("erabsList size = " << params.<API key>.size ()); m_x2SapUser-><API key> (params); } } else if (procedureCode == EpcX2Header::UeContextRelease) { if (messageType == EpcX2Header::InitiatingMessage) { NS_LOG_LOGIC ("Recv X2 message: UE CONTEXT RELEASE"); <API key> <API key>; packet->RemoveHeader (<API key>); NS_LOG_INFO ("X2 UeContextRelease header: " << <API key>); EpcX2SapUser::<API key> params; params.oldEnbUeX2apId = <API key>.GetOldEnbUeX2apId (); params.newEnbUeX2apId = <API key>.GetNewEnbUeX2apId (); NS_LOG_LOGIC ("oldEnbUeX2apId = " << params.oldEnbUeX2apId); NS_LOG_LOGIC ("newEnbUeX2apId = " << params.newEnbUeX2apId); m_x2SapUser-><API key> (params); } } else if (procedureCode == EpcX2Header::<API key>) { if (messageType == EpcX2Header::InitiatingMessage) { NS_LOG_LOGIC ("Recv X2 message: RESOURCE STATUS UPDATE"); <API key> x2ResStatUpdHeader; packet->RemoveHeader (x2ResStatUpdHeader); NS_LOG_INFO ("X2 <API key> header: " << x2ResStatUpdHeader); EpcX2SapUser::<API key> params; params.enb1MeasurementId = x2ResStatUpdHeader.<API key> (); params.enb2MeasurementId = x2ResStatUpdHeader.<API key> (); params.<API key> = x2ResStatUpdHeader.<API key> (); NS_LOG_LOGIC ("enb1MeasurementId = " << params.enb1MeasurementId); NS_LOG_LOGIC ("enb2MeasurementId = " << params.enb2MeasurementId); NS_LOG_LOGIC ("<API key> size = " << params.<API key>.size ()); m_x2SapUser-><API key> (params); } } else { NS_ASSERT_MSG (false, "ProcedureCode NOT SUPPORTED!!!"); } } void EpcX2::RecvFromX2uSocket (Ptr<Socket> socket) { NS_LOG_FUNCTION (this << socket); NS_LOG_LOGIC ("Recv UE DATA through X2-U interface from Socket"); Ptr<Packet> packet = socket->Recv (); NS_LOG_LOGIC ("packetLen = " << packet->GetSize ()); NS_ASSERT_MSG (<API key>.find (socket) != <API key>.end (), "Missing infos of local and remote CellId"); Ptr<X2CellInfo> cellsInfo = <API key> [socket]; GtpuHeader gtpu; packet->RemoveHeader (gtpu); NS_LOG_LOGIC ("GTP-U header: " << gtpu); EpcX2SapUser::UeDataParams params; params.sourceCellId = cellsInfo->m_remoteCellId; params.targetCellId = cellsInfo->m_localCellId; params.gtpTeid = gtpu.GetTeid (); params.ueData = packet; m_x2SapUser->RecvUeData (params); } // Implementation of the X2 SAP Provider void EpcX2::<API key> (EpcX2SapProvider::<API key> params) { NS_LOG_FUNCTION (this); NS_LOG_LOGIC ("oldEnbUeX2apId = " << params.oldEnbUeX2apId); NS_LOG_LOGIC ("sourceCellId = " << params.sourceCellId); NS_LOG_LOGIC ("targetCellId = " << params.targetCellId); NS_LOG_LOGIC ("mmeUeS1apId = " << params.mmeUeS1apId); NS_ASSERT_MSG (<API key>.find (params.targetCellId) != <API key>.end (), "Missing infos for targetCellId = " << params.targetCellId); Ptr<X2IfaceInfo> socketInfo = <API key> [params.targetCellId]; Ptr<Socket> sourceSocket = socketInfo-><API key>; Ipv4Address targetIpAddr = socketInfo->m_remoteIpAddr; NS_LOG_LOGIC ("sourceSocket = " << sourceSocket); NS_LOG_LOGIC ("targetIpAddr = " << targetIpAddr); NS_LOG_INFO ("Send X2 message: HANDOVER REQUEST"); // Build the X2 message <API key> x2HoReqHeader; x2HoReqHeader.SetOldEnbUeX2apId (params.oldEnbUeX2apId); x2HoReqHeader.SetCause (params.cause); x2HoReqHeader.SetTargetCellId (params.targetCellId); x2HoReqHeader.SetMmeUeS1apId (params.mmeUeS1apId); x2HoReqHeader.<API key> (params.<API key>); x2HoReqHeader.<API key> (params.<API key>); x2HoReqHeader.SetBearers (params.bearers); EpcX2Header x2Header; x2Header.SetMessageType (EpcX2Header::InitiatingMessage); x2Header.SetProcedureCode (EpcX2Header::HandoverPreparation); x2Header.SetLengthOfIes (x2HoReqHeader.GetLengthOfIes ()); x2Header.SetNumberOfIes (x2HoReqHeader.GetNumberOfIes ()); NS_LOG_INFO ("X2 header: " << x2Header); NS_LOG_INFO ("X2 HandoverRequest header: " << x2HoReqHeader); // Build the X2 packet Ptr<Packet> packet = (params.rrcContext != 0) ? (params.rrcContext) : (Create <Packet> ()); packet->AddHeader (x2HoReqHeader); packet->AddHeader (x2Header); NS_LOG_INFO ("packetLen = " << packet->GetSize ()); // Send the X2 message through the socket sourceSocket->SendTo (packet, 0, InetSocketAddress (targetIpAddr, m_x2cUdpPort)); } void EpcX2::<API key> (EpcX2SapProvider::<API key> params) { NS_LOG_FUNCTION (this); NS_LOG_LOGIC ("oldEnbUeX2apId = " << params.oldEnbUeX2apId); NS_LOG_LOGIC ("newEnbUeX2apId = " << params.newEnbUeX2apId); NS_LOG_LOGIC ("sourceCellId = " << params.sourceCellId); NS_LOG_LOGIC ("targetCellId = " << params.targetCellId); NS_ASSERT_MSG (<API key>.find (params.sourceCellId) != <API key>.end (), "Socket infos not defined for sourceCellId = " << params.sourceCellId); Ptr<Socket> localSocket = <API key> [params.sourceCellId]-><API key>; Ipv4Address remoteIpAddr = <API key> [params.sourceCellId]->m_remoteIpAddr; NS_LOG_LOGIC ("localSocket = " << localSocket); NS_LOG_LOGIC ("remoteIpAddr = " << remoteIpAddr); NS_LOG_INFO ("Send X2 message: HANDOVER REQUEST ACK"); // Build the X2 message <API key> x2HoAckHeader; x2HoAckHeader.SetOldEnbUeX2apId (params.oldEnbUeX2apId); x2HoAckHeader.SetNewEnbUeX2apId (params.newEnbUeX2apId); x2HoAckHeader.SetAdmittedBearers (params.admittedBearers); x2HoAckHeader.<API key> (params.notAdmittedBearers); EpcX2Header x2Header; x2Header.SetMessageType (EpcX2Header::SuccessfulOutcome); x2Header.SetProcedureCode (EpcX2Header::HandoverPreparation); x2Header.SetLengthOfIes (x2HoAckHeader.GetLengthOfIes ()); x2Header.SetNumberOfIes (x2HoAckHeader.GetNumberOfIes ()); NS_LOG_INFO ("X2 header: " << x2Header); NS_LOG_INFO ("X2 HandoverAck header: " << x2HoAckHeader); NS_LOG_INFO ("RRC context: " << params.rrcContext); // Build the X2 packet Ptr<Packet> packet = (params.rrcContext != 0) ? (params.rrcContext) : (Create <Packet> ()); packet->AddHeader (x2HoAckHeader); packet->AddHeader (x2Header); NS_LOG_INFO ("packetLen = " << packet->GetSize ()); // Send the X2 message through the socket localSocket->SendTo (packet, 0, InetSocketAddress (remoteIpAddr, m_x2cUdpPort)); } void EpcX2::<API key> (EpcX2SapProvider::<API key> params) { NS_LOG_FUNCTION (this); NS_LOG_LOGIC ("oldEnbUeX2apId = " << params.oldEnbUeX2apId); NS_LOG_LOGIC ("sourceCellId = " << params.sourceCellId); NS_LOG_LOGIC ("targetCellId = " << params.targetCellId); NS_LOG_LOGIC ("cause = " << params.cause); NS_LOG_LOGIC ("<API key> = " << params.<API key>); NS_ASSERT_MSG (<API key>.find (params.sourceCellId) != <API key>.end (), "Socket infos not defined for sourceCellId = " << params.sourceCellId); Ptr<Socket> localSocket = <API key> [params.sourceCellId]-><API key>; Ipv4Address remoteIpAddr = <API key> [params.sourceCellId]->m_remoteIpAddr; NS_LOG_LOGIC ("localSocket = " << localSocket); NS_LOG_LOGIC ("remoteIpAddr = " << remoteIpAddr); NS_LOG_INFO ("Send X2 message: HANDOVER PREPARATION FAILURE"); // Build the X2 message <API key> x2HoPrepFailHeader; x2HoPrepFailHeader.SetOldEnbUeX2apId (params.oldEnbUeX2apId); x2HoPrepFailHeader.SetCause (params.cause); x2HoPrepFailHeader.<API key> (params.<API key>); EpcX2Header x2Header; x2Header.SetMessageType (EpcX2Header::UnsuccessfulOutcome); x2Header.SetProcedureCode (EpcX2Header::HandoverPreparation); x2Header.SetLengthOfIes (x2HoPrepFailHeader.GetLengthOfIes ()); x2Header.SetNumberOfIes (x2HoPrepFailHeader.GetNumberOfIes ()); NS_LOG_INFO ("X2 header: " << x2Header); NS_LOG_INFO ("X2 HandoverPrepFail header: " << x2HoPrepFailHeader); // Build the X2 packet Ptr<Packet> packet = Create <Packet> (); packet->AddHeader (x2HoPrepFailHeader); packet->AddHeader (x2Header); NS_LOG_INFO ("packetLen = " << packet->GetSize ()); // Send the X2 message through the socket localSocket->SendTo (packet, 0, InetSocketAddress (remoteIpAddr, m_x2cUdpPort)); } void EpcX2::<API key> (EpcX2SapProvider::<API key> params) { NS_LOG_FUNCTION (this); NS_LOG_LOGIC ("oldEnbUeX2apId = " << params.oldEnbUeX2apId); NS_LOG_LOGIC ("newEnbUeX2apId = " << params.newEnbUeX2apId); NS_LOG_LOGIC ("sourceCellId = " << params.sourceCellId); NS_LOG_LOGIC ("targetCellId = " << params.targetCellId); NS_LOG_LOGIC ("erabsList size = " << params.<API key>.size ()); NS_ASSERT_MSG (<API key>.find (params.targetCellId) != <API key>.end (), "Socket infos not defined for targetCellId = " << params.targetCellId); Ptr<Socket> localSocket = <API key> [params.targetCellId]-><API key>; Ipv4Address remoteIpAddr = <API key> [params.targetCellId]->m_remoteIpAddr; NS_LOG_LOGIC ("localSocket = " << localSocket); NS_LOG_LOGIC ("remoteIpAddr = " << remoteIpAddr); NS_LOG_INFO ("Send X2 message: SN STATUS TRANSFER"); // Build the X2 message <API key> <API key>; <API key>.SetOldEnbUeX2apId (params.oldEnbUeX2apId); <API key>.SetNewEnbUeX2apId (params.newEnbUeX2apId); <API key>.<API key> (params.<API key>); EpcX2Header x2Header; x2Header.SetMessageType (EpcX2Header::InitiatingMessage); x2Header.SetProcedureCode (EpcX2Header::SnStatusTransfer); x2Header.SetLengthOfIes (<API key>.GetLengthOfIes ()); x2Header.SetNumberOfIes (<API key>.GetNumberOfIes ()); NS_LOG_INFO ("X2 header: " << x2Header); NS_LOG_INFO ("X2 SnStatusTransfer header: " << <API key>); // Build the X2 packet Ptr<Packet> packet = Create <Packet> (); packet->AddHeader (<API key>); packet->AddHeader (x2Header); NS_LOG_INFO ("packetLen = " << packet->GetSize ()); // Send the X2 message through the socket localSocket->SendTo (packet, 0, InetSocketAddress (remoteIpAddr, m_x2cUdpPort)); } void EpcX2::<API key> (EpcX2SapProvider::<API key> params) { NS_LOG_FUNCTION (this); NS_LOG_LOGIC ("oldEnbUeX2apId = " << params.oldEnbUeX2apId); NS_LOG_LOGIC ("newEnbUeX2apId = " << params.newEnbUeX2apId); NS_LOG_LOGIC ("sourceCellId = " << params.sourceCellId); NS_ASSERT_MSG (<API key>.find (params.sourceCellId) != <API key>.end (), "Socket infos not defined for sourceCellId = " << params.sourceCellId); Ptr<Socket> localSocket = <API key> [params.sourceCellId]-><API key>; Ipv4Address remoteIpAddr = <API key> [params.sourceCellId]->m_remoteIpAddr; NS_LOG_LOGIC ("localSocket = " << localSocket); NS_LOG_LOGIC ("remoteIpAddr = " << remoteIpAddr); NS_LOG_INFO ("Send X2 message: UE CONTEXT RELEASE"); // Build the X2 message <API key> <API key>; <API key>.SetOldEnbUeX2apId (params.oldEnbUeX2apId); <API key>.SetNewEnbUeX2apId (params.newEnbUeX2apId); EpcX2Header x2Header; x2Header.SetMessageType (EpcX2Header::InitiatingMessage); x2Header.SetProcedureCode (EpcX2Header::UeContextRelease); x2Header.SetLengthOfIes (<API key>.GetLengthOfIes ()); x2Header.SetNumberOfIes (<API key>.GetNumberOfIes ()); NS_LOG_INFO ("X2 header: " << x2Header); NS_LOG_INFO ("X2 UeContextRelease header: " << <API key>); // Build the X2 packet Ptr<Packet> packet = Create <Packet> (); packet->AddHeader (<API key>); packet->AddHeader (x2Header); NS_LOG_INFO ("packetLen = " << packet->GetSize ()); // Send the X2 message through the socket localSocket->SendTo (packet, 0, InetSocketAddress (remoteIpAddr, m_x2cUdpPort)); } void EpcX2::<API key> (EpcX2SapProvider::<API key> params) { NS_LOG_FUNCTION (this); NS_LOG_LOGIC ("targetCellId = " << params.targetCellId); NS_LOG_LOGIC ("cellInformationList size = " << params.cellInformationList.size ()); NS_ASSERT_MSG (<API key>.find (params.targetCellId) != <API key>.end (), "Missing infos for targetCellId = " << params.targetCellId); Ptr<X2IfaceInfo> socketInfo = <API key> [params.targetCellId]; Ptr<Socket> sourceSocket = socketInfo-><API key>; Ipv4Address targetIpAddr = socketInfo->m_remoteIpAddr; NS_LOG_LOGIC ("sourceSocket = " << sourceSocket); NS_LOG_LOGIC ("targetIpAddr = " << targetIpAddr); NS_LOG_INFO ("Send X2 message: LOAD INFORMATION"); // Build the X2 message <API key> x2LoadInfoHeader; x2LoadInfoHeader.<API key> (params.cellInformationList); EpcX2Header x2Header; x2Header.SetMessageType (EpcX2Header::InitiatingMessage); x2Header.SetProcedureCode (EpcX2Header::LoadIndication); x2Header.SetLengthOfIes (x2LoadInfoHeader.GetLengthOfIes ()); x2Header.SetNumberOfIes (x2LoadInfoHeader.GetNumberOfIes ()); NS_LOG_INFO ("X2 header: " << x2Header); NS_LOG_INFO ("X2 LoadInformation header: " << x2LoadInfoHeader); // Build the X2 packet Ptr<Packet> packet = Create <Packet> (); packet->AddHeader (x2LoadInfoHeader); packet->AddHeader (x2Header); NS_LOG_INFO ("packetLen = " << packet->GetSize ()); // Send the X2 message through the socket sourceSocket->SendTo (packet, 0, InetSocketAddress (targetIpAddr, m_x2cUdpPort)); } void EpcX2::<API key> (EpcX2SapProvider::<API key> params) { NS_LOG_FUNCTION (this); NS_LOG_LOGIC ("targetCellId = " << params.targetCellId); NS_LOG_LOGIC ("enb1MeasurementId = " << params.enb1MeasurementId); NS_LOG_LOGIC ("enb2MeasurementId = " << params.enb2MeasurementId); NS_LOG_LOGIC ("<API key> size = " << params.<API key>.size ()); NS_ASSERT_MSG (<API key>.find (params.targetCellId) != <API key>.end (), "Missing infos for targetCellId = " << params.targetCellId); Ptr<X2IfaceInfo> socketInfo = <API key> [params.targetCellId]; Ptr<Socket> sourceSocket = socketInfo-><API key>; Ipv4Address targetIpAddr = socketInfo->m_remoteIpAddr; NS_LOG_LOGIC ("sourceSocket = " << sourceSocket); NS_LOG_LOGIC ("targetIpAddr = " << targetIpAddr); NS_LOG_INFO ("Send X2 message: RESOURCE STATUS UPDATE"); // Build the X2 message <API key> <API key>; <API key>.<API key> (params.enb1MeasurementId); <API key>.<API key> (params.enb2MeasurementId); <API key>.<API key> (params.<API key>); EpcX2Header x2Header; x2Header.SetMessageType (EpcX2Header::InitiatingMessage); x2Header.SetProcedureCode (EpcX2Header::<API key>); x2Header.SetLengthOfIes (<API key>.GetLengthOfIes ()); x2Header.SetNumberOfIes (<API key>.GetNumberOfIes ()); NS_LOG_INFO ("X2 header: " << x2Header); NS_LOG_INFO ("X2 <API key> header: " << <API key>); // Build the X2 packet Ptr<Packet> packet = Create <Packet> (); packet->AddHeader (<API key>); packet->AddHeader (x2Header); NS_LOG_INFO ("packetLen = " << packet->GetSize ()); // Send the X2 message through the socket sourceSocket->SendTo (packet, 0, InetSocketAddress (targetIpAddr, m_x2cUdpPort)); } void EpcX2::DoSendUeData (EpcX2SapProvider::UeDataParams params) { NS_LOG_FUNCTION (this); NS_LOG_LOGIC ("sourceCellId = " << params.sourceCellId); NS_LOG_LOGIC ("targetCellId = " << params.targetCellId); NS_LOG_LOGIC ("gtpTeid = " << params.gtpTeid); NS_ASSERT_MSG (<API key>.find (params.targetCellId) != <API key>.end (), "Missing infos for targetCellId = " << params.targetCellId); Ptr<X2IfaceInfo> socketInfo = <API key> [params.targetCellId]; Ptr<Socket> sourceSocket = socketInfo-><API key>; Ipv4Address targetIpAddr = socketInfo->m_remoteIpAddr; NS_LOG_LOGIC ("sourceSocket = " << sourceSocket); NS_LOG_LOGIC ("targetIpAddr = " << targetIpAddr); GtpuHeader gtpu; gtpu.SetTeid (params.gtpTeid); gtpu.SetLength (params.ueData->GetSize () + gtpu.GetSerializedSize () - 8); /// \todo This should be done in GtpuHeader NS_LOG_INFO ("GTP-U header: " << gtpu); Ptr<Packet> packet = params.ueData; packet->AddHeader (gtpu); NS_LOG_INFO ("Forward UE DATA through X2 interface"); sourceSocket->SendTo (packet, 0, InetSocketAddress (targetIpAddr, m_x2uUdpPort)); } } // namespace ns3
#include "hsi_driver.h" #define NOT_SET (-1) /* Manage HSR divisor update * A special divisor value allows switching to auto-divisor mode in Rx * (but with error counters deactivated). This function implements the * the transitions to/from this mode. */ int hsi_set_rx_divisor(struct hsi_port *sport, struct hsr_ctx *cfg) { struct hsi_dev *hsi_ctrl = sport->hsi_controller; void __iomem *base = hsi_ctrl->base; int port = sport->port_number; struct platform_device *pdev = to_platform_device(hsi_ctrl->dev); if (cfg->divisor == NOT_SET) return 0; if (<API key>(pdev)) { if (cfg->divisor == <API key> && sport->counters_on) { /* auto mode: deactivate counters + set divisor = 0 */ sport->reg_counters = hsi_inl(base, <API key> (port)); sport->counters_on = 0; hsi_outl(0, base, <API key>(port)); hsi_outl(0, base, HSI_HSR_DIVISOR_REG(port)); dev_dbg(hsi_ctrl->dev, "Switched to HSR auto mode\n"); } else if (cfg->divisor != <API key>) { /* Divisor set mode: use counters */ /* Leave auto mode: use new counters values */ sport->reg_counters = cfg->counters; sport->counters_on = 1; hsi_outl(cfg->counters, base, <API key>(port)); hsi_outl(cfg->divisor, base, HSI_HSR_DIVISOR_REG(port)); dev_dbg(hsi_ctrl->dev, "Left HSR auto mode. " "Counters=0x%08x, Divisor=0x%08x\n", cfg->counters, cfg->divisor); } } else { if (cfg->divisor == <API key> && sport->counters_on) { /* auto mode: deactivate timeout */ sport->reg_counters = hsi_inl(base, SSI_TIMEOUT_REG(port)); sport->counters_on = 0; hsi_outl(0, base, SSI_TIMEOUT_REG(port)); dev_dbg(hsi_ctrl->dev, "Deactivated SSR timeout\n"); } else if (cfg->divisor == <API key>) { /* Leave auto mode: use new counters values */ sport->reg_counters = cfg->counters; sport->counters_on = 1; hsi_outl(cfg->counters, base, SSI_TIMEOUT_REG(port)); dev_dbg(hsi_ctrl->dev, "Left SSR auto mode. " "Timeout=0x%08x\n", cfg->counters); } } return 0; } int hsi_set_rx(struct hsi_port *sport, struct hsr_ctx *cfg) { struct hsi_dev *hsi_ctrl = sport->hsi_controller; void __iomem *base = hsi_ctrl->base; int port = sport->port_number; struct platform_device *pdev = to_platform_device(hsi_ctrl->dev); if (((cfg->mode & HSI_MODE_VAL_MASK) != HSI_MODE_STREAM) && ((cfg->mode & HSI_MODE_VAL_MASK) != HSI_MODE_FRAME) && ((cfg->mode & HSI_MODE_VAL_MASK) != HSI_MODE_SLEEP) && (cfg->mode != NOT_SET)) return -EINVAL; if (<API key>(pdev)) { if (((cfg->flow & HSI_FLOW_VAL_MASK) != <API key>) && ((cfg->flow & HSI_FLOW_VAL_MASK) != HSI_FLOW_PIPELINED) && (cfg->flow != NOT_SET)) return -EINVAL; /* HSI only supports payload size of 32bits */ if ((cfg->frame_size != HSI_FRAMESIZE_MAX) && (cfg->frame_size != NOT_SET)) return -EINVAL; } else { if (((cfg->flow & HSI_FLOW_VAL_MASK) != <API key>) && (cfg->flow != NOT_SET)) return -EINVAL; /* HSI only supports payload size of 32bits */ if ((cfg->frame_size != HSI_FRAMESIZE_MAX) && (cfg->frame_size != NOT_SET)) return -EINVAL; } if ((cfg->channels == 0) || ((cfg->channels > sport->max_ch) && (cfg->channels != NOT_SET))) return -EINVAL; if (<API key>(pdev)) { if ((cfg->divisor > HSI_MAX_RX_DIVISOR) && (cfg->divisor != <API key>) && (cfg->divisor != NOT_SET)) return -EINVAL; } if ((cfg->mode != NOT_SET) && (cfg->flow != NOT_SET)) hsi_outl(cfg->mode | ((cfg->flow & HSI_FLOW_VAL_MASK) << HSI_FLOW_OFFSET), base, HSI_HSR_MODE_REG(port)); if (cfg->frame_size != NOT_SET) hsi_outl(cfg->frame_size, base, <API key>(port)); if (cfg->channels != NOT_SET) { if ((cfg->channels & (-cfg->channels)) ^ cfg->channels) return -EINVAL; else hsi_outl(cfg->channels, base, <API key>(port)); } return hsi_set_rx_divisor(sport, cfg); } void hsi_get_rx(struct hsi_port *sport, struct hsr_ctx *cfg) { struct hsi_dev *hsi_ctrl = sport->hsi_controller; void __iomem *base = hsi_ctrl->base; int port = sport->port_number; struct platform_device *pdev = to_platform_device(hsi_ctrl->dev); cfg->mode = hsi_inl(base, HSI_HSR_MODE_REG(port)) & HSI_MODE_VAL_MASK; cfg->flow = (hsi_inl(base, HSI_HSR_MODE_REG(port)) & HSI_FLOW_VAL_MASK) >> HSI_FLOW_OFFSET; cfg->frame_size = hsi_inl(base, <API key>(port)); cfg->channels = hsi_inl(base, <API key>(port)); if (<API key>(pdev)) { cfg->divisor = hsi_inl(base, HSI_HSR_DIVISOR_REG(port)); cfg->counters = hsi_inl(base, <API key>(port)); } else { cfg->counters = hsi_inl(base, SSI_TIMEOUT_REG(port)); } } int hsi_set_tx(struct hsi_port *sport, struct hst_ctx *cfg) { struct hsi_dev *hsi_ctrl = sport->hsi_controller; void __iomem *base = hsi_ctrl->base; int port = sport->port_number; struct platform_device *pdev = to_platform_device(hsi_ctrl->dev); unsigned int max_divisor = <API key>(pdev) ? HSI_MAX_TX_DIVISOR : <API key>; if (((cfg->mode & HSI_MODE_VAL_MASK) != HSI_MODE_STREAM) && ((cfg->mode & HSI_MODE_VAL_MASK) != HSI_MODE_FRAME) && (cfg->mode != NOT_SET)) return -EINVAL; if (<API key>(pdev)) { if (((cfg->flow & HSI_FLOW_VAL_MASK) != <API key>) && ((cfg->flow & HSI_FLOW_VAL_MASK) != HSI_FLOW_PIPELINED) && (cfg->flow != NOT_SET)) return -EINVAL; /* HSI only supports payload size of 32bits */ if ((cfg->frame_size != HSI_FRAMESIZE_MAX) && (cfg->frame_size != NOT_SET)) return -EINVAL; } else { if (((cfg->flow & HSI_FLOW_VAL_MASK) != <API key>) && (cfg->flow != NOT_SET)) return -EINVAL; if ((cfg->frame_size > HSI_FRAMESIZE_MAX) && (cfg->frame_size != NOT_SET)) return -EINVAL; } if ((cfg->channels == 0) || ((cfg->channels > sport->max_ch) && (cfg->channels != NOT_SET))) return -EINVAL; if ((cfg->divisor > max_divisor) && (cfg->divisor != NOT_SET)) return -EINVAL; if ((cfg->arb_mode != <API key>) && (cfg->arb_mode != <API key>) && (cfg->mode != NOT_SET)) return -EINVAL; if ((cfg->mode != NOT_SET) && (cfg->flow != NOT_SET)) hsi_outl(cfg->mode | ((cfg->flow & HSI_FLOW_VAL_MASK) << HSI_FLOW_OFFSET) | <API key>, base, HSI_HST_MODE_REG(port)); if (cfg->frame_size != NOT_SET) hsi_outl(cfg->frame_size, base, <API key>(port)); if (cfg->channels != NOT_SET) { if ((cfg->channels & (-cfg->channels)) ^ cfg->channels) return -EINVAL; else hsi_outl(cfg->channels, base, <API key>(port)); } if (cfg->divisor != NOT_SET) hsi_outl(cfg->divisor, base, HSI_HST_DIVISOR_REG(port)); if (cfg->arb_mode != NOT_SET) hsi_outl(cfg->arb_mode, base, HSI_HST_ARBMODE_REG(port)); return 0; } void hsi_get_tx(struct hsi_port *sport, struct hst_ctx *cfg) { struct hsi_dev *hsi_ctrl = sport->hsi_controller; void __iomem *base = hsi_ctrl->base; int port = sport->port_number; cfg->mode = hsi_inl(base, HSI_HST_MODE_REG(port)) & HSI_MODE_VAL_MASK; cfg->flow = (hsi_inl(base, HSI_HST_MODE_REG(port)) & HSI_FLOW_VAL_MASK) >> HSI_FLOW_OFFSET; cfg->frame_size = hsi_inl(base, <API key>(port)); cfg->channels = hsi_inl(base, <API key>(port)); cfg->divisor = hsi_inl(base, HSI_HST_DIVISOR_REG(port)); cfg->arb_mode = hsi_inl(base, HSI_HST_ARBMODE_REG(port)); } /** * hsi_open - open a hsi device channel. * @dev - Reference to the hsi device channel to be openned. * * Returns 0 on success, -EINVAL on bad parameters, -EBUSY if is already opened. */ int hsi_open(struct hsi_device *dev) { struct hsi_channel *ch; struct hsi_port *port; struct hsi_dev *hsi_ctrl; int err; if (!dev || !dev->ch) { pr_err(LOG_NAME "Wrong HSI device %p\n", dev); return -EINVAL; } dev_dbg(dev->device.parent, "%s ch %d\n", __func__, dev->n_ch); ch = dev->ch; if (!ch->read_done || !ch->write_done) { dev_err(dev->device.parent, "Trying to open with no (read/write) callbacks " "registered\n"); return -EINVAL; } if (ch->flags & HSI_CH_OPEN) { dev_err(dev->device.parent, "Port %d Channel %d already OPENED\n", dev->n_p, dev->n_ch); return -EBUSY; } port = ch->hsi_port; hsi_ctrl = port->hsi_controller; if (!hsi_ctrl) { dev_err(dev->device.parent, "%s: Port %d Channel %d has no hsi controller?\n", __func__, dev->n_p, dev->n_ch); return -EINVAL; } if (hsi_ctrl->clock_rate == 0) { struct hsi_platform_data *pdata; pdata = dev_get_platdata(hsi_ctrl->dev); if (!pdata) { dev_err(dev->device.parent, "%s: Port %d Channel %d has no pdata\n", __func__, dev->n_p, dev->n_ch); return -EINVAL; } if (!pdata->device_scale) { dev_err(dev->device.parent, "%s: Undefined platform device_scale function\n", __func__); return -ENXIO; } /* Retry to set the HSI FCLK to default. */ err = pdata->device_scale(hsi_ctrl->dev, hsi_ctrl->dev, pdata->default_hsi_fclk); if (err) { dev_err(dev->device.parent, "%s: Error %d setting HSI FClk to %ld. " "Will retry on next open\n", __func__, err, pdata->default_hsi_fclk); return err; } else { dev_info(dev->device.parent, "HSI clock is now %ld\n", pdata->default_hsi_fclk); hsi_ctrl->clock_rate = pdata->default_hsi_fclk; } } spin_lock_bh(&hsi_ctrl->lock); <API key>(dev->device.parent, ch->channel_number, __func__); /* Restart with flags cleaned up */ ch->flags = HSI_CH_OPEN; <API key>(port, HSI_CAWAKEDETECTED | HSI_ERROROCCURED | HSI_BREAKDETECTED); /* NOTE: error and break are port events and do not need to be * enabled for HSI extended enable register */ <API key>(dev->device.parent, ch->channel_number, __func__); spin_unlock_bh(&hsi_ctrl->lock); return 0; } EXPORT_SYMBOL(hsi_open); /** * hsi_write - write data into the hsi device channel * @dev - reference to the hsi device channel to write into. * @addr - pointer to a 32-bit word data to be written. * @size - number of 32-bit word to be written. * * Return 0 on success, a negative value on failure. * A success value only indicates that the request has been accepted. * Transfer is only completed when the write_done callback is called. * */ int hsi_write(struct hsi_device *dev, u32 *addr, unsigned int size) { struct hsi_channel *ch; int err; if (unlikely(!dev)) { pr_err(LOG_NAME "Null dev pointer in hsi_write\n"); return -EINVAL; } if (unlikely(!dev->ch || !addr || (size <= 0))) { dev_err(dev->device.parent, "Wrong parameters hsi_device %p data %p count %d", dev, addr, size); return -EINVAL; } dev_dbg(dev->device.parent, "%s ch %d, @%x, size %d u32\n", __func__, dev->n_ch, (u32) addr, size); if (unlikely(!(dev->ch->flags & HSI_CH_OPEN))) { dev_err(dev->device.parent, "HSI device NOT open\n"); return -EINVAL; } ch = dev->ch; if (ch->write_data.addr != NULL) { dev_err(dev->device.parent, "# Invalid request - Write " "operation pending port %d channel %d\n", ch->hsi_port->port_number, ch->channel_number); return -EINVAL; } spin_lock_bh(&ch->hsi_port->hsi_controller->lock); if (<API key>(dev->device.parent) || !ch->hsi_port->hsi_controller->clock_enabled) dev_dbg(dev->device.parent, "hsi_write with HSI clocks OFF, clock_enabled = %d\n", ch->hsi_port->hsi_controller->clock_enabled); <API key>(dev->device.parent, ch->channel_number, __func__); ch->write_data.addr = addr; ch->write_data.size = size; ch->write_data.lch = -1; if (size == 1) err = <API key>(ch, addr); else err = <API key>(ch, addr, size); if (unlikely(err < 0)) { ch->write_data.addr = NULL; ch->write_data.size = 0; dev_err(dev->device.parent, "Failed to program write\n"); } spin_unlock_bh(&ch->hsi_port->hsi_controller->lock); /* Leave clocks enabled until transfer is complete (write callback */ /* is called */ return err; } EXPORT_SYMBOL(hsi_write); /** * hsi_read - read data from the hsi device channel * @dev - hsi device channel reference to read data from. * @addr - pointer to a 32-bit word data to store the data. * @size - number of 32-bit word to be stored. * * Return 0 on sucess, a negative value on failure. * A success value only indicates that the request has been accepted. * Data is only available in the buffer when the read_done callback is called. * */ int hsi_read(struct hsi_device *dev, u32 *addr, unsigned int size) { struct hsi_channel *ch; int err; if (unlikely(!dev)) { pr_err(LOG_NAME "Null dev pointer in hsi_read\n"); return -EINVAL; } if (unlikely(!dev->ch || !addr || (size <= 0))) { dev_err(dev->device.parent, "Wrong parameters " "hsi_device %p data %p count %d", dev, addr, size); return -EINVAL; } #if 0 if (dev->n_ch == 0) dev_info(dev->device.parent, "%s ch %d, @%x, size %d u32\n", __func__, dev->n_ch, (u32) addr, size); #endif if (unlikely(!(dev->ch->flags & HSI_CH_OPEN))) { dev_err(dev->device.parent, "HSI device NOT open\n"); return -EINVAL; } ch = dev->ch; spin_lock_bh(&ch->hsi_port->hsi_controller->lock); if (<API key>(dev->device.parent) || !ch->hsi_port->hsi_controller->clock_enabled) dev_dbg(dev->device.parent, "hsi_read with HSI clocks OFF, clock_enabled = %d\n", ch->hsi_port->hsi_controller->clock_enabled); <API key>(dev->device.parent, ch->channel_number, __func__); if (ch->read_data.addr != NULL) { dev_err(dev->device.parent, "# Invalid request - Read " "operation pending port %d channel %d\n", ch->hsi_port->port_number, ch->channel_number); err = -EINVAL; goto done; } ch->read_data.addr = addr; ch->read_data.size = size; ch->read_data.lch = -1; if (size == 1) err = <API key>(ch, addr); else err = hsi_driver_read_dma(ch, addr, size); if (unlikely(err < 0)) { ch->read_data.addr = NULL; ch->read_data.size = 0; dev_err(dev->device.parent, "Failed to program read\n"); } done: <API key>(dev->device.parent, ch->channel_number, __func__); spin_unlock_bh(&ch->hsi_port->hsi_controller->lock); return err; } EXPORT_SYMBOL(hsi_read); int __hsi_write_cancel(struct hsi_channel *ch) { int err = -ENODATA; if (ch->write_data.size == 1) err = <API key>(ch); else if (ch->write_data.size > 1) err = <API key>(ch); else dev_dbg(ch->dev->device.parent, "%s : Nothing to cancel %d\n", __func__, ch->write_data.size); dev_err(ch->dev->device.parent, "%s : %d\n", __func__, err); return err; } /** * hsi_write_cancel - Cancel pending write request. * @dev - hsi device channel where to cancel the pending write. * * write_done() callback will not be called after success of this function. * * Return: -ENXIO : No DMA channel found for specified HSI channel * -ECANCELED : write cancel success, data not transfered to TX FIFO * 0 : transfer is already over, data already transfered to TX FIFO * * Note: whatever returned value, write callback will not be called after * write cancel. */ int hsi_write_cancel(struct hsi_device *dev) { int err; if (unlikely(!dev || !dev->ch)) { pr_err(LOG_NAME "Wrong HSI device %p\n", dev); return -ENODEV; } dev_err(dev->device.parent, "%s ch %d\n", __func__, dev->n_ch); if (unlikely(!(dev->ch->flags & HSI_CH_OPEN))) { dev_err(dev->device.parent, "HSI device NOT open\n"); return -ENODEV; } spin_lock_bh(&dev->ch->hsi_port->hsi_controller->lock); <API key>(dev->device.parent, dev->ch->channel_number, __func__); err = __hsi_write_cancel(dev->ch); <API key>(dev->device.parent, dev->ch->channel_number, __func__); spin_unlock_bh(&dev->ch->hsi_port->hsi_controller->lock); return err; } EXPORT_SYMBOL(hsi_write_cancel); int __hsi_read_cancel(struct hsi_channel *ch) { int err = -ENODATA; if (ch->read_data.size == 1) err = <API key>(ch); else if (ch->read_data.size > 1) err = <API key>(ch); else dev_dbg(ch->dev->device.parent, "%s : Nothing to cancel %d\n", __func__, ch->read_data.size); dev_err(ch->dev->device.parent, "%s : %d\n", __func__, err); return err; } /** * hsi_read_cancel - Cancel pending read request. * @dev - hsi device channel where to cancel the pending read. * * read_done() callback will not be called after success of this function. * * Return: -ENXIO : No DMA channel found for specified HSI channel * -ECANCELED : read cancel success, data not available at expected * address. * 0 : transfer is already over, data already available at expected * address. * * Note: whatever returned value, read callback will not be called after cancel. */ int hsi_read_cancel(struct hsi_device *dev) { int err; if (unlikely(!dev || !dev->ch)) { pr_err(LOG_NAME "Wrong HSI device %p\n", dev); return -ENODEV; } dev_err(dev->device.parent, "%s ch %d\n", __func__, dev->n_ch); if (unlikely(!(dev->ch->flags & HSI_CH_OPEN))) { dev_err(dev->device.parent, "HSI device NOT open\n"); return -ENODEV; } spin_lock_bh(&dev->ch->hsi_port->hsi_controller->lock); <API key>(dev->device.parent, dev->ch->channel_number, __func__); err = __hsi_read_cancel(dev->ch); <API key>(dev->device.parent, dev->ch->channel_number, __func__); spin_unlock_bh(&dev->ch->hsi_port->hsi_controller->lock); return err; } EXPORT_SYMBOL(hsi_read_cancel); /** * hsi_poll - HSI poll feature, enables data interrupt on frame reception * @dev - hsi device channel reference to apply the I/O control * (or port associated to it) * * Return 0 on success, a negative value on failure. * */ int hsi_poll(struct hsi_device *dev) { struct hsi_channel *ch; struct hsi_dev *hsi_ctrl; int err; if (unlikely(!dev || !dev->ch)) return -EINVAL; dev_dbg(dev->device.parent, "%s ch %d\n", __func__, dev->n_ch); if (unlikely(!(dev->ch->flags & HSI_CH_OPEN))) { dev_err(dev->device.parent, "HSI device NOT open\n"); return -EINVAL; } ch = dev->ch; hsi_ctrl = ch->hsi_port->hsi_controller; spin_lock_bh(&hsi_ctrl->lock); <API key>(dev->device.parent, dev->ch->channel_number, __func__); ch->flags |= HSI_CH_RX_POLL; err = <API key>(ch, NULL); <API key>(dev->device.parent, dev->ch->channel_number, __func__); spin_unlock_bh(&hsi_ctrl->lock); return err; } EXPORT_SYMBOL(hsi_poll); /** * hsi_unpoll - HSI poll feature, disables data interrupt on frame reception * @dev - hsi device channel reference to apply the I/O control * (or port associated to it) * * Return 0 on success, a negative value on failure. * */ int hsi_unpoll(struct hsi_device *dev) { struct hsi_channel *ch; struct hsi_dev *hsi_ctrl; if (unlikely(!dev || !dev->ch)) return -EINVAL; dev_dbg(dev->device.parent, "%s ch %d\n", __func__, dev->n_ch); if (unlikely(!(dev->ch->flags & HSI_CH_OPEN))) { dev_err(dev->device.parent, "HSI device NOT open\n"); return -EINVAL; } ch = dev->ch; hsi_ctrl = ch->hsi_port->hsi_controller; spin_lock_bh(&hsi_ctrl->lock); <API key>(dev->device.parent, dev->ch->channel_number, __func__); ch->flags &= ~HSI_CH_RX_POLL; <API key>(ch); <API key>(dev->device.parent, dev->ch->channel_number, __func__); spin_unlock_bh(&hsi_ctrl->lock); return 0; } EXPORT_SYMBOL(hsi_unpoll); /** * hsi_ioctl - HSI I/O control * @dev - hsi device channel reference to apply the I/O control * (or port associated to it) * @command - HSI I/O control command * @arg - parameter associated to the control command. NULL, if no parameter. * * Return 0 on success, a negative value on failure. * */ int hsi_ioctl(struct hsi_device *dev, unsigned int command, void *arg) { struct hsi_channel *ch; struct hsi_dev *hsi_ctrl; struct hsi_port *pport; void __iomem *base; unsigned int port, channel; u32 acwake; int err = 0; int fifo = 0; if (unlikely((!dev) || (!dev->ch) || (!dev->ch->hsi_port) || (!dev->ch->hsi_port->hsi_controller)) || (!(dev->ch->flags & HSI_CH_OPEN))) { pr_err(LOG_NAME "HSI IOCTL Invalid parameter\n"); return -EINVAL; } ch = dev->ch; pport = ch->hsi_port; hsi_ctrl = ch->hsi_port->hsi_controller; port = ch->hsi_port->port_number; channel = ch->channel_number; base = hsi_ctrl->base; dev_dbg(dev->device.parent, "IOCTL: ch %d, command %d\n", channel, command); spin_lock_bh(&hsi_ctrl->lock); <API key>(dev->device.parent, channel, __func__); switch (command) { case HSI_IOCTL_ACWAKE_UP: /* Wake up request to Modem (typically OMAP initiated) */ /* Symetrical disable will be done in <API key> */ if (ch->flags & HSI_CH_ACWAKE) { dev_dbg(dev->device.parent, "Duplicate ACWAKE UP\n"); err = -EPERM; goto out; } ch->flags |= HSI_CH_ACWAKE; pport->acwake_status |= BIT(channel); /* We only claim once the wake line per channel */ acwake = hsi_inl(base, HSI_SYS_WAKE_REG(port)); if (!(acwake & HSI_WAKE(channel))) { hsi_outl(HSI_SET_WAKE(channel), base, <API key>(port)); } goto out; break; case <API key>: /* Low power request initiation (OMAP initiated, typically */ /* following inactivity timeout) */ /* ACPU HSI block shall still be capable of receiving */ if (!(ch->flags & HSI_CH_ACWAKE)) { dev_dbg(dev->device.parent, "Duplicate ACWAKE DOWN\n"); err = -EPERM; goto out; } acwake = hsi_inl(base, HSI_SYS_WAKE_REG(port)); if (unlikely(pport->acwake_status != (acwake & HSI_WAKE_MASK))) { dev_warn(dev->device.parent, "ACWAKE shadow register mismatch" " acwake_status: 0x%x, HSI_SYS_WAKE_REG: 0x%x", pport->acwake_status, acwake); pport->acwake_status = acwake & HSI_WAKE_MASK; } /* SSI_TODO: add safety check for SSI also */ ch->flags &= ~HSI_CH_ACWAKE; pport->acwake_status &= ~BIT(channel); /* Release the wake line per channel */ if ((acwake & HSI_WAKE(channel))) { hsi_outl(HSI_CLEAR_WAKE(channel), base, <API key>(port)); } goto out; break; case <API key>: hsi_outl(1, base, HSI_HST_BREAK_REG(port)); /*HSI_TODO : need to deactivate clock after BREAK frames sent*/ /*Use interrupt ? (if TX BREAK INT exists)*/ break; case <API key>: if (!arg) { err = -EINVAL; goto out; } *(u32 *)arg = hsi_inl(base, HSI_SYS_WAKE_REG(port)); break; case HSI_IOCTL_FLUSH_RX: hsi_outl(0, base, HSI_HSR_RXSTATE_REG(port)); break; case HSI_IOCTL_FLUSH_TX: hsi_outl(0, base, HSI_HST_TXSTATE_REG(port)); break; case <API key>: if (!arg) { err = -EINVAL; goto out; } err = hsi_get_cawake(dev->ch->hsi_port); if (err < 0) { err = -ENODEV; goto out; } *(u32 *)arg = err; break; case HSI_IOCTL_SET_RX: if (!arg) { err = -EINVAL; goto out; } err = hsi_set_rx(dev->ch->hsi_port, (struct hsr_ctx *)arg); break; case HSI_IOCTL_GET_RX: if (!arg) { err = -EINVAL; goto out; } hsi_get_rx(dev->ch->hsi_port, (struct hsr_ctx *)arg); break; case HSI_IOCTL_SET_TX: if (!arg) { err = -EINVAL; goto out; } err = hsi_set_tx(dev->ch->hsi_port, (struct hst_ctx *)arg); break; case HSI_IOCTL_GET_TX: if (!arg) { err = -EINVAL; goto out; } hsi_get_tx(dev->ch->hsi_port, (struct hst_ctx *)arg); break; case HSI_IOCTL_SW_RESET: dev_info(dev->device.parent, "SW Reset\n"); err = hsi_softreset(hsi_ctrl); /* Reset HSI config to default */ <API key>(hsi_ctrl); break; case <API key>: if (!arg) { err = -EINVAL; goto out; } fifo = hsi_fifo_get_id(hsi_ctrl, channel, port); if (unlikely(fifo < 0)) { dev_err(hsi_ctrl->dev, "No valid FIFO id found for " "channel %d.\n", channel); err = -EFAULT; goto out; } *(size_t *)arg = <API key>(hsi_ctrl, fifo); break; case <API key>: dev_info(dev->device.parent, "Entering RX wakeup in 3 wires mode (no CAWAKE)\n"); pport-><API key> = 1; /* HW errata HSI-C1BUG00085, HSI wakeup issue in 3 wires mode : * HSI will NOT generate the Swakeup for 2nd frame if it entered * IDLE after 1st received frame */ if (<API key>(to_platform_device(hsi_ctrl->dev))) <API key>(hsi_ctrl); /* When WAKE is not available, ACREADY must be set to 1 at * reset else remote will never have a chance to transmit. */ hsi_outl_or(<API key> | <API key>, base, <API key>(port)); <API key>(pport, HSI_CAWAKEDETECTED); break; case <API key>: dev_info(dev->device.parent, "Entering RX wakeup in 4 wires mode\n"); pport-><API key> = 0; /* HW errata HSI-C1BUG00085 : go back to normal IDLE mode */ if (<API key>(to_platform_device(hsi_ctrl->dev))) hsi_set_pm_default(hsi_ctrl); <API key>(pport, HSI_CAWAKEDETECTED); hsi_outl_and(<API key>, base, <API key>(port)); break; default: err = -ENOIOCTLCMD; break; } out: /* All IOCTL end by disabling the clocks, except ACWAKE high. */ <API key>(dev->device.parent, channel, __func__); spin_unlock_bh(&hsi_ctrl->lock); return err; } EXPORT_SYMBOL(hsi_ioctl); /** * hsi_close - close given hsi device channel * @dev - reference to hsi device channel. */ void hsi_close(struct hsi_device *dev) { struct hsi_dev *hsi_ctrl; if (!dev || !dev->ch) { pr_err(LOG_NAME "Trying to close wrong HSI device %p\n", dev); return; } dev_dbg(dev->device.parent, "%s ch %d\n", __func__, dev->n_ch); hsi_ctrl = dev->ch->hsi_port->hsi_controller; spin_lock_bh(&hsi_ctrl->lock); <API key>(dev->device.parent, dev->ch->channel_number, __func__); if (dev->ch->flags & HSI_CH_OPEN) { dev->ch->flags &= ~HSI_CH_OPEN; __hsi_write_cancel(dev->ch); __hsi_read_cancel(dev->ch); } <API key>(dev->device.parent, dev->ch->channel_number, __func__); spin_unlock_bh(&hsi_ctrl->lock); } EXPORT_SYMBOL(hsi_close); /** * hsi_set_read_cb - register read_done() callback. * @dev - reference to hsi device channel where the callback is associated to. * @read_cb - callback to signal read transfer completed. * size is expressed in number of 32-bit words. * * NOTE: Write callback must be only set when channel is not open ! */ void hsi_set_read_cb(struct hsi_device *dev, void (*read_cb) (struct hsi_device *dev, unsigned int size)) { dev_dbg(dev->device.parent, "%s ch %d\n", __func__, dev->n_ch); dev->ch->read_done = read_cb; } EXPORT_SYMBOL(hsi_set_read_cb); /** * hsi_set_read_cb - register write_done() callback. * @dev - reference to hsi device channel where the callback is associated to. * @write_cb - callback to signal read transfer completed. * size is expressed in number of 32-bit words. * * NOTE: Read callback must be only set when channel is not open ! */ void hsi_set_write_cb(struct hsi_device *dev, void (*write_cb) (struct hsi_device *dev, unsigned int size)) { dev_dbg(dev->device.parent, "%s ch %d\n", __func__, dev->n_ch); dev->ch->write_done = write_cb; } EXPORT_SYMBOL(hsi_set_write_cb); /** * <API key> - register port_event callback. * @dev - reference to hsi device channel where the callback is associated to. * @port_event_cb - callback to signal events from the channel port. */ void <API key>(struct hsi_device *dev, void (*port_event_cb) (struct hsi_device *dev, unsigned int event, void *arg)) { struct hsi_port *port = dev->ch->hsi_port; struct hsi_dev *hsi_ctrl = port->hsi_controller; dev_dbg(dev->device.parent, "%s ch %d\n", __func__, dev->n_ch); write_lock_bh(&dev->ch->rw_lock); dev->ch->port_event = port_event_cb; write_unlock_bh(&dev->ch->rw_lock); /* Since we now have a callback registered for events, we can now */ /* enable the CAWAKE, ERROR and BREAK interrupts */ spin_lock_bh(&hsi_ctrl->lock); <API key>(dev->device.parent, dev->ch->channel_number, __func__); <API key>(port, HSI_CAWAKEDETECTED | HSI_ERROROCCURED | HSI_BREAKDETECTED); <API key>(dev->device.parent, dev->ch->channel_number, __func__); spin_unlock_bh(&hsi_ctrl->lock); } EXPORT_SYMBOL(<API key>);
#include "hw.h" #include "pci.h" #include "apb_pci.h" #include "pc.h" #include "nvram.h" #include "fdc.h" #include "net.h" #include "qemu-timer.h" #include "sysemu.h" #include "boards.h" #include "firmware_abi.h" #include "fw_cfg.h" #include "sysbus.h" #include "ide.h" #include "loader.h" #include "elf.h" //#define DEBUG_IRQ #ifdef DEBUG_IRQ #define DPRINTF(fmt, ...) \ do { printf("CPUIRQ: " fmt , ## __VA_ARGS__); } while (0) #else #define DPRINTF(fmt, ...) #endif #define KERNEL_LOAD_ADDR 0x00404000 #define CMDLINE_ADDR 0x003ff000 #define INITRD_LOAD_ADDR 0x00300000 #define PROM_SIZE_MAX (4 * 1024 * 1024) #define PROM_VADDR 0x000ffd00000ULL #define APB_SPECIAL_BASE 0x1fe00000000ULL #define APB_MEM_BASE 0x1ff00000000ULL #define VGA_BASE (APB_MEM_BASE + 0x400000ULL) #define PROM_FILENAME "openbios-sparc64" #define NVRAM_SIZE 0x2000 #define MAX_IDE_BUS 2 #define BIOS_CFG_IOPORT 0x510 #define <API key> (FW_CFG_ARCH_LOCAL + 0x00) #define <API key> (FW_CFG_ARCH_LOCAL + 0x01) #define <API key> (FW_CFG_ARCH_LOCAL + 0x02) #define MAX_PILS 16 #define TICK_INT_DIS <API key> #define TICK_MAX <API key> struct hwdef { const char * const default_cpu_model; uint16_t machine_id; uint64_t prom_addr; uint64_t console_serial_base; }; int <API key> (int nchan) { return 0; } int DMA_read_memory (int nchan, void *buf, int pos, int size) { return 0; } int DMA_write_memory (int nchan, void *buf, int pos, int size) { return 0; } void DMA_hold_DREQ (int nchan) {} void DMA_release_DREQ (int nchan) {} void DMA_schedule(int nchan) {} void DMA_init (int high_page_enable) {} void <API key> (int nchan, <API key> transfer_handler, void *opaque) { } static int fw_cfg_boot_set(void *opaque, const char *boot_device) { fw_cfg_add_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]); return 0; } static int <API key> (m48t59_t *nvram, uint16_t NVRAM_size, const char *arch, ram_addr_t RAM_size, const char *boot_devices, uint32_t kernel_image, uint32_t kernel_size, const char *cmdline, uint32_t initrd_image, uint32_t initrd_size, uint32_t NVRAM_image, int width, int height, int depth, const uint8_t *macaddr) { unsigned int i; uint32_t start, end; uint8_t image[0x1ff0]; struct OpenBIOS_nvpart_v1 *part_header; memset(image, '\0', sizeof(image)); start = 0; // OpenBIOS nvram variables // Variable partition part_header = (struct OpenBIOS_nvpart_v1 *)&image[start]; part_header->signature = <API key>; pstrcpy(part_header->name, sizeof(part_header->name), "system"); end = start + sizeof(struct OpenBIOS_nvpart_v1); for (i = 0; i < nb_prom_envs; i++) end = OpenBIOS_set_var(image, end, prom_envs[i]); // End marker image[end++] = '\0'; end = start + ((end - start + 15) & ~15); <API key>(part_header, end - start); // free partition start = end; part_header = (struct OpenBIOS_nvpart_v1 *)&image[start]; part_header->signature = OPENBIOS_PART_FREE; pstrcpy(part_header->name, sizeof(part_header->name), "free"); end = 0x1fd0; <API key>(part_header, end - start); Sun_init_header((struct Sun_nvram *)&image[0x1fd8], macaddr, 0x80); for (i = 0; i < sizeof(image); i++) m48t59_write(nvram, i, image[i]); return 0; } static unsigned long sun4u_load_kernel(const char *kernel_filename, const char *initrd_filename, ram_addr_t RAM_size, long *initrd_size) { int linux_boot; unsigned int i; long kernel_size; linux_boot = (kernel_filename != NULL); kernel_size = 0; if (linux_boot) { int bswap_needed; #ifdef BSWAP_NEEDED bswap_needed = 1; #else bswap_needed = 0; #endif kernel_size = load_elf(kernel_filename, 0, NULL, NULL, NULL, 1, ELF_MACHINE, 0); if (kernel_size < 0) kernel_size = load_aout(kernel_filename, KERNEL_LOAD_ADDR, RAM_size - KERNEL_LOAD_ADDR, bswap_needed, TARGET_PAGE_SIZE); if (kernel_size < 0) kernel_size = load_image_targphys(kernel_filename, KERNEL_LOAD_ADDR, RAM_size - KERNEL_LOAD_ADDR); if (kernel_size < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } /* load initrd */ *initrd_size = 0; if (initrd_filename) { *initrd_size = load_image_targphys(initrd_filename, INITRD_LOAD_ADDR, RAM_size - INITRD_LOAD_ADDR); if (*initrd_size < 0) { fprintf(stderr, "qemu: could not load initial ram disk '%s'\n", initrd_filename); exit(1); } } if (*initrd_size > 0) { for (i = 0; i < 64 * TARGET_PAGE_SIZE; i += TARGET_PAGE_SIZE) { if (ldl_phys(KERNEL_LOAD_ADDR + i) == 0x48647253) { // HdrS stl_phys(KERNEL_LOAD_ADDR + i + 16, INITRD_LOAD_ADDR); stl_phys(KERNEL_LOAD_ADDR + i + 20, *initrd_size); break; } } } } return kernel_size; } void pic_info(Monitor *mon) { } void irq_info(Monitor *mon) { } void cpu_check_irqs(CPUState *env) { uint32_t pil = env->pil_in | (env->softint & ~SOFTINT_TIMER) | ((env->softint & SOFTINT_TIMER) << 14); if (pil && (env->interrupt_index == 0 || (env->interrupt_index & ~15) == TT_EXTINT)) { unsigned int i; for (i = 15; i > 0; i if (pil & (1 << i)) { int old_interrupt = env->interrupt_index; env->interrupt_index = TT_EXTINT | i; if (old_interrupt != env->interrupt_index) { DPRINTF("Set CPU IRQ %d\n", i); cpu_interrupt(env, CPU_INTERRUPT_HARD); } break; } } } else if (!pil && (env->interrupt_index & ~15) == TT_EXTINT) { DPRINTF("Reset CPU IRQ %d\n", env->interrupt_index & 15); env->interrupt_index = 0; cpu_reset_interrupt(env, CPU_INTERRUPT_HARD); } } static void cpu_set_irq(void *opaque, int irq, int level) { CPUState *env = opaque; if (level) { DPRINTF("Raise CPU IRQ %d\n", irq); env->halted = 0; env->pil_in |= 1 << irq; cpu_check_irqs(env); } else { DPRINTF("Lower CPU IRQ %d\n", irq); env->pil_in &= ~(1 << irq); cpu_check_irqs(env); } } typedef struct ResetData { CPUState *env; uint64_t prom_addr; } ResetData; static void main_cpu_reset(void *opaque) { ResetData *s = (ResetData *)opaque; CPUState *env = s->env; static unsigned int nr_resets; cpu_reset(env); env->tick_cmpr = TICK_INT_DIS | 0; ptimer_set_limit(env->tick, TICK_MAX, 1); ptimer_run(env->tick, 1); env->stick_cmpr = TICK_INT_DIS | 0; ptimer_set_limit(env->stick, TICK_MAX, 1); ptimer_run(env->stick, 1); env->hstick_cmpr = TICK_INT_DIS | 0; ptimer_set_limit(env->hstick, TICK_MAX, 1); ptimer_run(env->hstick, 1); env->gregs[1] = 0; // Memory start env->gregs[2] = ram_size; // Memory size env->gregs[3] = 0; // Machine description XXX if (nr_resets++ == 0) { /* Power on reset */ env->pc = s->prom_addr + 0x20ULL; } else { env->pc = s->prom_addr + 0x40ULL; } env->npc = env->pc + 4; } static void tick_irq(void *opaque) { CPUState *env = opaque; if (!(env->tick_cmpr & TICK_INT_DIS)) { env->softint |= SOFTINT_TIMER; cpu_interrupt(env, CPU_INTERRUPT_TIMER); } } static void stick_irq(void *opaque) { CPUState *env = opaque; if (!(env->stick_cmpr & TICK_INT_DIS)) { env->softint |= SOFTINT_STIMER; cpu_interrupt(env, CPU_INTERRUPT_TIMER); } } static void hstick_irq(void *opaque) { CPUState *env = opaque; if (!(env->hstick_cmpr & TICK_INT_DIS)) { cpu_interrupt(env, CPU_INTERRUPT_TIMER); } } void cpu_tick_set_count(void *opaque, uint64_t count) { ptimer_set_count(opaque, -count); } uint64_t cpu_tick_get_count(void *opaque) { return -ptimer_get_count(opaque); } void cpu_tick_set_limit(void *opaque, uint64_t limit) { ptimer_set_limit(opaque, -limit, 0); } static void ebus_mmio_mapfunc(PCIDevice *pci_dev, int region_num, pcibus_t addr, pcibus_t size, int type) { DPRINTF("Mapping region %d registers at %08x\n", region_num, addr); switch (region_num) { case 0: isa_mmio_init(addr, 0x1000000); break; case 1: isa_mmio_init(addr, 0x800000); break; } } static void <API key>(void *opaque, int n, int level) { } /* EBUS (Eight bit bus) bridge */ static void pci_ebus_init(PCIBus *bus, int devfn) { qemu_irq *isa_irq; pci_create_simple(bus, devfn, "ebus"); isa_irq = qemu_allocate_irqs(<API key>, NULL, 16); isa_bus_irqs(isa_irq); } static int pci_ebus_init1(PCIDevice *s) { isa_bus_new(&s->qdev); <API key>(s->config, PCI_VENDOR_ID_SUN); <API key>(s->config, <API key>); s->config[0x04] = 0x06; // command = bus master, pci mem s->config[0x05] = 0x00; s->config[0x06] = 0xa0; // status = fast back-to-back, 66MHz, no error s->config[0x07] = 0x03; // status = medium devsel s->config[0x08] = 0x01; // revision s->config[0x09] = 0x00; // programming i/f <API key>(s->config, <API key>); s->config[0x0D] = 0x0a; // latency_timer s->config[PCI_HEADER_TYPE] = <API key>; // header_type pci_register_bar(s, 0, 0x1000000, <API key>, ebus_mmio_mapfunc); pci_register_bar(s, 1, 0x800000, <API key>, ebus_mmio_mapfunc); return 0; } static PCIDeviceInfo ebus_info = { .qdev.name = "ebus", .qdev.size = sizeof(PCIDevice), .init = pci_ebus_init1, }; static void pci_ebus_register(void) { pci_qdev_register(&ebus_info); } device_init(pci_ebus_register); /* Boot PROM (OpenBIOS) */ static void prom_init(target_phys_addr_t addr, const char *bios_name) { DeviceState *dev; SysBusDevice *s; char *filename; int ret; dev = qdev_create(NULL, "openprom"); qdev_init_nofail(dev); s = sysbus_from_qdev(dev); sysbus_mmio_map(s, 0, addr); /* load boot prom */ if (bios_name == NULL) { bios_name = PROM_FILENAME; } filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (filename) { ret = load_elf(filename, addr - PROM_VADDR, NULL, NULL, NULL, 1, ELF_MACHINE, 0); if (ret < 0 || ret > PROM_SIZE_MAX) { ret = load_image_targphys(filename, addr, PROM_SIZE_MAX); } qemu_free(filename); } else { ret = -1; } if (ret < 0 || ret > PROM_SIZE_MAX) { fprintf(stderr, "qemu: could not load prom '%s'\n", bios_name); exit(1); } } static int prom_init1(SysBusDevice *dev) { ram_addr_t prom_offset; prom_offset = qemu_ram_alloc(PROM_SIZE_MAX); sysbus_init_mmio(dev, PROM_SIZE_MAX, prom_offset | IO_MEM_ROM); return 0; } static SysBusDeviceInfo prom_info = { .init = prom_init1, .qdev.name = "openprom", .qdev.size = sizeof(SysBusDevice), .qdev.props = (Property[]) { {/* end of property list */} } }; static void <API key>(void) { <API key>(&prom_info); } device_init(<API key>); typedef struct RamDevice { SysBusDevice busdev; uint64_t size; } RamDevice; /* System RAM */ static int ram_init1(SysBusDevice *dev) { ram_addr_t RAM_size, ram_offset; RamDevice *d = FROM_SYSBUS(RamDevice, dev); RAM_size = d->size; ram_offset = qemu_ram_alloc(RAM_size); sysbus_init_mmio(dev, RAM_size, ram_offset); return 0; } static void ram_init(target_phys_addr_t addr, ram_addr_t RAM_size) { DeviceState *dev; SysBusDevice *s; RamDevice *d; /* allocate RAM */ dev = qdev_create(NULL, "memory"); s = sysbus_from_qdev(dev); d = FROM_SYSBUS(RamDevice, s); d->size = RAM_size; qdev_init_nofail(dev); sysbus_mmio_map(s, 0, addr); } static SysBusDeviceInfo ram_info = { .init = ram_init1, .qdev.name = "memory", .qdev.size = sizeof(RamDevice), .qdev.props = (Property[]) { DEFINE_PROP_UINT64("size", RamDevice, size, 0), <API key>(), } }; static void <API key>(void) { <API key>(&ram_info); } device_init(<API key>); static CPUState *cpu_devinit(const char *cpu_model, const struct hwdef *hwdef) { CPUState *env; QEMUBH *bh; ResetData *reset_info; if (!cpu_model) cpu_model = hwdef->default_cpu_model; env = cpu_init(cpu_model); if (!env) { fprintf(stderr, "Unable to find Sparc CPU definition\n"); exit(1); } bh = qemu_bh_new(tick_irq, env); env->tick = ptimer_init(bh); ptimer_set_period(env->tick, 1ULL); bh = qemu_bh_new(stick_irq, env); env->stick = ptimer_init(bh); ptimer_set_period(env->stick, 1ULL); bh = qemu_bh_new(hstick_irq, env); env->hstick = ptimer_init(bh); ptimer_set_period(env->hstick, 1ULL); reset_info = qemu_mallocz(sizeof(ResetData)); reset_info->env = env; reset_info->prom_addr = hwdef->prom_addr; qemu_register_reset(main_cpu_reset, reset_info); return env; } static void sun4uv_init(ram_addr_t RAM_size, const char *boot_devices, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model, const struct hwdef *hwdef) { CPUState *env; m48t59_t *nvram; unsigned int i; long initrd_size, kernel_size; PCIBus *pci_bus, *pci_bus2, *pci_bus3; qemu_irq *irq; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; DriveInfo *fd[MAX_FD]; void *fw_cfg; /* init CPUs */ env = cpu_devinit(cpu_model, hwdef); /* set up devices */ ram_init(0, RAM_size); prom_init(hwdef->prom_addr, bios_name); irq = qemu_allocate_irqs(cpu_set_irq, env, MAX_PILS); pci_bus = pci_apb_init(APB_SPECIAL_BASE, APB_MEM_BASE, irq, &pci_bus2, &pci_bus3); isa_mem_base = VGA_BASE; pci_vga_init(pci_bus, 0, 0); // XXX Should be pci_bus3 pci_ebus_init(pci_bus, -1); i = 0; if (hwdef->console_serial_base) { serial_mm_init(hwdef->console_serial_base, 0, NULL, 115200, serial_hds[i], 1); i++; } for(; i < MAX_SERIAL_PORTS; i++) { if (serial_hds[i]) { serial_isa_init(i, serial_hds[i]); } } for(i = 0; i < MAX_PARALLEL_PORTS; i++) { if (parallel_hds[i]) { parallel_init(i, parallel_hds[i]); } } for(i = 0; i < nb_nics; i++) pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL); if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) { fprintf(stderr, "qemu: too many IDE bus\n"); exit(1); } for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) { hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); } pci_cmd646_ide_init(pci_bus, hd, 1); isa_create_simple("i8042"); for(i = 0; i < MAX_FD; i++) { fd[i] = drive_get(IF_FLOPPY, 0, i); } fdctrl_init_isa(fd); nvram = m48t59_init_isa(0x0074, NVRAM_SIZE, 59); initrd_size = 0; kernel_size = sun4u_load_kernel(kernel_filename, initrd_filename, ram_size, &initrd_size); <API key>(nvram, NVRAM_SIZE, "Sun4u", RAM_size, boot_devices, KERNEL_LOAD_ADDR, kernel_size, kernel_cmdline, INITRD_LOAD_ADDR, initrd_size, /* XXX: need an option to load a NVRAM image */ 0, graphic_width, graphic_height, graphic_depth, (uint8_t *)&nd_table[0].macaddr); fw_cfg = fw_cfg_init(BIOS_CFG_IOPORT, BIOS_CFG_IOPORT + 1, 0, 0); fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1); fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id); fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, KERNEL_LOAD_ADDR); fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); if (kernel_cmdline) { fw_cfg_add_i32(fw_cfg, <API key>, CMDLINE_ADDR); pstrcpy_targphys("cmdline", CMDLINE_ADDR, TARGET_PAGE_SIZE, kernel_cmdline); } else { fw_cfg_add_i32(fw_cfg, <API key>, 0); } fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, INITRD_LOAD_ADDR); fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, boot_devices[0]); fw_cfg_add_i16(fw_cfg, <API key>, graphic_width); fw_cfg_add_i16(fw_cfg, <API key>, graphic_height); fw_cfg_add_i16(fw_cfg, <API key>, graphic_depth); <API key>(fw_cfg_boot_set, fw_cfg); } enum { sun4u_id = 0, sun4v_id = 64, niagara_id, }; static const struct hwdef hwdefs[] = { /* Sun4u generic PC-like machine */ { .default_cpu_model = "TI UltraSparc II", .machine_id = sun4u_id, .prom_addr = 0x1fff0000000ULL, .console_serial_base = 0, }, /* Sun4v generic PC-like machine */ { .default_cpu_model = "Sun UltraSparc T1", .machine_id = sun4v_id, .prom_addr = 0x1fff0000000ULL, .console_serial_base = 0, }, /* Sun4v generic Niagara machine */ { .default_cpu_model = "Sun UltraSparc T1", .machine_id = niagara_id, .prom_addr = 0xfff0000000ULL, .console_serial_base = 0xfff0c2c000ULL, }, }; /* Sun4u hardware initialisation */ static void sun4u_init(ram_addr_t RAM_size, const char *boot_devices, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { sun4uv_init(RAM_size, boot_devices, kernel_filename, kernel_cmdline, initrd_filename, cpu_model, &hwdefs[0]); } /* Sun4v hardware initialisation */ static void sun4v_init(ram_addr_t RAM_size, const char *boot_devices, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { sun4uv_init(RAM_size, boot_devices, kernel_filename, kernel_cmdline, initrd_filename, cpu_model, &hwdefs[1]); } /* Niagara hardware initialisation */ static void niagara_init(ram_addr_t RAM_size, const char *boot_devices, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { sun4uv_init(RAM_size, boot_devices, kernel_filename, kernel_cmdline, initrd_filename, cpu_model, &hwdefs[2]); } static QEMUMachine sun4u_machine = { .name = "sun4u", .desc = "Sun4u platform", .init = sun4u_init, .max_cpus = 1, // XXX for now .is_default = 1, }; static QEMUMachine sun4v_machine = { .name = "sun4v", .desc = "Sun4v platform", .init = sun4v_init, .max_cpus = 1, // XXX for now }; static QEMUMachine niagara_machine = { .name = "Niagara", .desc = "Sun4v platform, Niagara", .init = niagara_init, .max_cpus = 1, // XXX for now }; static void sun4u_machine_init(void) { <API key>(&sun4u_machine); <API key>(&sun4v_machine); <API key>(&niagara_machine); } machine_init(sun4u_machine_init);
<label><?php echo $LDMonth; ?> <select name="month" size="1"> <option <?php if ($ARR_SELECT_MONTH[1]) echo "selected";?> value="1"><?php echo $LDMonthShortName[1]; ?></option> <option <?php if ($ARR_SELECT_MONTH[2]) echo "selected";?> value="2"><?php echo $LDMonthShortName[2]; ?></option> <option <?php if ($ARR_SELECT_MONTH[3]) echo "selected";?> value="3"><?php echo $LDMonthShortName[3]; ?></option> <option <?php if ($ARR_SELECT_MONTH[4]) echo "selected";?> value="4"><?php echo $LDMonthShortName[4]; ?></option> <option <?php if ($ARR_SELECT_MONTH[5]) echo "selected";?> value="5"><?php echo $LDMonthShortName[5]; ?></option> <option <?php if ($ARR_SELECT_MONTH[6]) echo "selected";?> value="6"><?php echo $LDMonthShortName[6]; ?></option> <option <?php if ($ARR_SELECT_MONTH[7]) echo "selected";?> value="7"><?php echo $LDMonthShortName[7]; ?></option> <option <?php if ($ARR_SELECT_MONTH[8]) echo "selected";?> value="8"><?php echo $LDMonthShortName[8]; ?></option> <option <?php if ($ARR_SELECT_MONTH[9]) echo "selected";?> value="9"><?php echo $LDMonthShortName[9]; ?></option> <option <?php if ($ARR_SELECT_MONTH[10]) echo "selected";?> value="10"><?php echo $LDMonthShortName[10]; ?></option> <option <?php if ($ARR_SELECT_MONTH[11]) echo "selected";?> value="11"><?php echo $LDMonthShortName[11]; ?></option> <option <?php if ($ARR_SELECT_MONTH[12]) echo "selected";?> value="12"><?php echo $LDMonthShortName[12]; ?></option> </select> </label> <label><?php echo $LDYear; ?> <select name="year"> <option <?php if ($ARR_SELECT_YEAR[$curr_year]) echo "selected";?> value="<?php echo $ARR_YEAR[$curr_year];?>"> <?php echo $ARR_YEAR[$curr_year];?></option> <option <?php if ($ARR_SELECT_YEAR[$curr_year-1]) echo "selected";?> value="<?php echo $ARR_YEAR[$curr_year-1];?>"> <?php echo $ARR_YEAR[$curr_year-1];?></option> <option <?php if ($ARR_SELECT_YEAR[$curr_year-2]) echo "selected";?> value="<?php echo $ARR_YEAR[$curr_year-2];?>"> <?php echo $ARR_YEAR[$curr_year-2];?></option> </select> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </label> <label><?php echo 'Transaction'; ?> <select name="transaction"> <?php if($_REQUEST[transaction] == 'saleInvoice'){ echo'<option value="saleInvoice" selected> Sale Invoice </option><option value="debtor">Debtor</option>'; }else if($_REQUEST[transaction] == 'debtor') { echo'<option value="saleInvoice"> Sale Invoice </option><option value="debtor" selected>Debtor</option>'; } else { echo'<option value="saleInvoice" > Sale Invoice </option><option value="debtor">Debtor</option>'; } ?> </select> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </label> <label> <input type="submit" name="show" value="<?php echo $LDShow; ?>"> </label>
# $Id: Makefile,v 1.1.10.1 2005/03/01 10:44:21 dcm Exp $ # example module makefile # WARNING: do not run this directly, it should be run by the master Makefile include ../../Makefile.defs auto_gen= NAME=xlog.so LIBS= include ../../Makefile.modules
package OpenILS::WWW::AddedContent::Syndetic; use strict; use warnings; use OpenSRF::Utils::Logger qw/$logger/; use OpenSRF::Utils::SettingsParser; use OpenSRF::Utils::JSON; use OpenSRF::EX qw/:try/; use OpenILS::WWW::AddedContent; use XML::LibXML; use MIME::Base64; my $AC = 'OpenILS::WWW::AddedContent'; sub new { my( $class, $args ) = @_; $class = ref $class || $class; return bless($args, $class); } sub base_url { my $self = shift; return $self->{base_url}; } sub userid { my $self = shift; return $self->{userid}; } sub expects_keyhash { # we expect a keyhash as opposed to a simple scalar containing an ISBN return 1; } sub jacket_small { my( $self, $keys ) = @_; return $self->send_img( $self->fetch_response('sc.gif', $keys, 1)); } sub jacket_medium { my( $self, $keys ) = @_; return $self->send_img( $self->fetch_response('mc.gif', $keys, 1)); } sub jacket_large { my( $self, $keys ) = @_; return $self->send_img( $self->fetch_response('lc.gif', $keys, 1)); } sub toc_html { my( $self, $key ) = @_; return $self->send_html( $self->fetch_content('toc.html', $key)); } sub toc_xml { my( $self, $key ) = @_; return $self->send_xml( $self->fetch_content('toc.xml', $key)); } sub toc_json { my( $self, $key ) = @_; return $self->send_json( $self->fetch_content('toc.xml', $key)); } sub anotes_html { my( $self, $key ) = @_; return $self->send_html( $self->fetch_content('anotes.html', $key)); } sub anotes_xml { my( $self, $key ) = @_; return $self->send_xml( $self->fetch_content('anotes.xml', $key)); } sub anotes_json { my( $self, $key ) = @_; return $self->send_json( $self->fetch_content('anotes.xml', $key)); } sub excerpt_html { my( $self, $key ) = @_; return $self->send_html( $self->fetch_content('dbchapter.html', $key)); } sub excerpt_xml { my( $self, $key ) = @_; return $self->send_xml( $self->fetch_content('dbchapter.xml', $key)); } sub excerpt_json { my( $self, $key ) = @_; return $self->send_json( $self->fetch_content('dbchapter.xml', $key)); } sub reviews_html { my( $self, $key ) = @_; my %reviews; $reviews{ljreview} = $self->fetch_content('ljreview.html', $key); # Library Journal $reviews{pwreview} = $self->fetch_content('pwreview.html', $key); # Publishers Weekly $reviews{sljreview} = $self->fetch_content('sljreview.html', $key); # School Library Journal $reviews{chreview} = $self->fetch_content('chreview.html', $key); # CHOICE Review $reviews{blreview} = $self->fetch_content('blreview.html', $key); # Booklist Review $reviews{hbreview} = $self->fetch_content('hbreview.html', $key); # Horn Book Review $reviews{kireview} = $self->fetch_content('kireview.html', $key); # Kirkus Reviews #$reviews{abreview} = $self->fetch_content('abreview.html', $key); # Bookseller+Publisher #$reviews{criticasreview} = $self->fetch_content('criticasreview.html', $key); # Criticas $reviews{nyreview} = $self->fetch_content('nyreview.html', $key); # New York Times #$reviews{gdnreview} = $self->fetch_content('gdnreview.html', $key); # Guardian Review #$reviews{doodysreview} = $self->fetch_content('doodysreview.html', $key); # Doody's Reviews for(keys %reviews) { if( ! $self->data_exists($reviews{$_}) ) { delete $reviews{$_}; next; } $reviews{$_} =~ s/<!.*?>//og; # Strip any doctype declarations } return 0 if scalar(keys %reviews) == 0; #my $html = "<div>"; my $html; $html .= $reviews{$_} for keys %reviews; #$html .= "</div>"; return $self->send_html($html); } # we have to aggregate the reviews sub reviews_xml { my( $self, $key ) = @_; my %reviews; $reviews{ljreview} = $self->fetch_content('ljreview.xml', $key); $reviews{pwreview} = $self->fetch_content('pwreview.xml', $key); $reviews{sljreview} = $self->fetch_content('sljreview.xml', $key); $reviews{chreview} = $self->fetch_content('chreview.xml', $key); $reviews{blreview} = $self->fetch_content('blreview.xml', $key); $reviews{hbreview} = $self->fetch_content('hbreview.xml', $key); $reviews{kireview} = $self->fetch_content('kireview.xml', $key); #$reviews{abreview} = $self->fetch_content('abreview.xml', $key); #$reviews{criticasreview} = $self->fetch_content('criticasreview.xml', $key); $reviews{nyreview} = $self->fetch_content('nyreview.xml', $key); #$reviews{gdnreview} = $self->fetch_content('gdnreview.xml', $key); #$reviews{doodysreview} = $self->fetch_content('doodysreview.xml', $key); for(keys %reviews) { if( ! $self->data_exists($reviews{$_}) ) { delete $reviews{$_}; next; } # Strip the xml and doctype declarations $reviews{$_} =~ s/<\?xml.*?> $reviews{$_} =~ s/<!.*?> } return 0 if scalar(keys %reviews) == 0; my $xml = "<reviews>"; $xml .= $reviews{$_} for keys %reviews; $xml .= "</reviews>"; return $self->send_xml($xml); } sub reviews_json { my( $self, $key ) = @_; return $self->send_json( $self->fetch_content('dbchapter.xml', $key)); } sub summary_html { my( $self, $key ) = @_; return $self->send_html( $self->fetch_content('summary.html', $key)); } sub summary_xml { my( $self, $key ) = @_; return $self->send_xml( $self->fetch_content('summary.xml', $key)); } sub summary_json { my( $self, $key ) = @_; return $self->send_json( $self->fetch_content('summary.xml', $key)); } sub data_exists { my( $self, $data ) = @_; return 0 if $data =~ m/<title>No Data Available<\/title>/iog; return 0 if $data =~ m/<title>error<\/title>/iog; return 1; } sub send_json { my( $self, $xml ) = @_; return 0 unless $self->data_exists($xml); my $doc; try { $doc = XML::LibXML->new->parse_string($xml); } catch Error with { my $err = shift; $logger->error("added content XML parser error: $err\n\n$xml"); $doc = undef; }; return 0 unless $doc; my $perl = OpenSRF::Utils::SettingsParser::XML2perl($doc->documentElement); my $json = OpenSRF::Utils::JSON->perl2JSON($perl); return { content_type => 'text/plain', content => $json }; } sub send_xml { my( $self, $xml ) = @_; return 0 unless $self->data_exists($xml); return { content_type => 'application/xml', content => $xml }; } sub send_html { my( $self, $content ) = @_; return 0 unless $self->data_exists($content); # Hide anything that might contain a link since it will be broken my $HTML = <<" HTML"; <div> <style type='text/css'> div.ac input, div.ac a[href],div.ac img, div.ac button { display: none; visibility: hidden } </style> <div class='ac'> $content </div> </div> HTML return { content_type => 'text/html', content => $HTML }; } sub send_img { my($self, $response) = @_; return { content_type => $response->header('Content-type'), content => $response->content, binary => 1 }; } # returns the raw content returned from the URL fetch sub fetch_content { my( $self, $page, $key ) = @_; return $self->fetch_response($page, $key)->content; } # returns the HTTP response object from the URL fetch sub fetch_response { my( $self, $page, $keys, $notype ) = @_; my $uname = $self->userid; # Fetch single isbn, upc, and issn my $isbn = $keys->{isbn}[0]; my $upc = $keys->{upc}[0]; my $issn = $keys->{issn}[0]; $isbn = '' if !defined($isbn); $upc = '' if !defined($upc); $issn = '' if !defined($issn); my $url = $self->base_url . "?isbn=$isbn/$page&upc=$upc&issn=$issn&client=$uname" . (($notype) ? '' : "&type=rw12"); return $AC->get_url($url); } 1;
package com.sun.midp.crypto; import org.bouncycastle.crypto.digests.SHA256Digest; import gnu.testlet.TestHarness; import gnu.testlet.Testlet; public class <API key> implements Testlet { public int getExpectedPass() { return 7; } public int getExpectedFail() { return 0; } public int <API key>() { return 0; } private static final String[] messages = { "", "a", "abc", "<API key>", "message digest", "secure hash algorithm" }; private static final String[] digests = { "<SHA256-like>", "<SHA256-like>", "<SHA256-like>", "<SHA256-like>", "<SHA256-like>", "<SHA256-like>" }; private static final String MILLION_A_DIGEST = "<SHA256-like>"; public void test(TestHarness th) { SHA256Digest md = new SHA256Digest(); byte[] retValue = new byte[md.getDigestSize()]; for (int i = 0; i < messages.length; i++) { byte[] bytes = messages[i].getBytes(); md.update(bytes, 0, bytes.length); md.doFinal(retValue, 0); th.check(Util.hexEncode(retValue).toLowerCase(), digests[i]); } for (int i = 0; i < 1000000; i++) { md.update((byte)'a'); } md.doFinal(retValue, 0); th.check(Util.hexEncode(retValue).toLowerCase(), MILLION_A_DIGEST); } }
// modification, are permitted provided that the following conditions // are met: // and/or other materials provided with the distribution. // * Neither the name of Jaroslaw Kowalski nor the names of its // contributors may be used to endorse or promote products derived from this // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // 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. using System; using System.Text; using System.Collections; using System.Globalization; using NLog.Conditions; namespace NLog.Conditions { <summary> Condition parser. Turns a string representation of condition expression into an expression tree. </summary> public class ConditionParser { private ConditionTokenizer tokenizer = new ConditionTokenizer(); private ConditionParser(string query) { tokenizer.InitTokenizer(query); } private <API key> ParsePredicate(string functionName) { <API key> par = new <API key>(); while (!tokenizer.IsEOF() && tokenizer.TokenType != ConditionTokenType.RightParen) { par.Add(ParseExpression()); if (tokenizer.TokenType != ConditionTokenType.Comma) break; tokenizer.GetNextToken(); } tokenizer.Expect(ConditionTokenType.RightParen); return new <API key>(functionName, par); } private ConditionExpression <API key>() { if (tokenizer.IsToken(ConditionTokenType.LeftParen)) { tokenizer.GetNextToken(); ConditionExpression e = ParseExpression(); tokenizer.Expect(ConditionTokenType.RightParen); return e; }; if (tokenizer.IsNumber()) { string numberString = (string)tokenizer.TokenValue; tokenizer.GetNextToken(); if (numberString.IndexOf('.') >= 0) { return new <API key>(Double.Parse(numberString, CultureInfo.InvariantCulture)); } else { return new <API key>(Int32.Parse(numberString, CultureInfo.InvariantCulture)); } } if (tokenizer.TokenType == ConditionTokenType.String) { ConditionExpression e = new <API key>(tokenizer.StringTokenValue); tokenizer.GetNextToken(); return e; } if (tokenizer.TokenType == ConditionTokenType.Keyword) { string keyword = tokenizer.EatKeyword(); if (0 == String.Compare(keyword, "level", true)) return new <API key>(); if (0 == String.Compare(keyword, "logger", true)) return new <API key>(); if (0 == String.Compare(keyword, "message", true)) return new <API key>(); if (0 == String.Compare(keyword, "loglevel", true)) { tokenizer.Expect(ConditionTokenType.Dot); return new <API key>(LogLevel.FromString(tokenizer.EatKeyword())); } if (0 == String.Compare(keyword, "true", true)) return new <API key>(true); if (0 == String.Compare(keyword, "false", true)) return new <API key>(false); if (tokenizer.TokenType == ConditionTokenType.LeftParen) { tokenizer.GetNextToken(); <API key> predicateExpression = ParsePredicate(keyword); return predicateExpression; } } throw new <API key>("Unexpected token: " + tokenizer.TokenValue); } private ConditionExpression <API key>() { ConditionExpression e = <API key>(); if (tokenizer.IsToken(ConditionTokenType.EQ)) { tokenizer.GetNextToken(); return new <API key>(e, <API key>(), <API key>.Equal); }; if (tokenizer.IsToken(ConditionTokenType.NE)) { tokenizer.GetNextToken(); return new <API key>(e, <API key>(), <API key>.NotEqual); }; if (tokenizer.IsToken(ConditionTokenType.LT)) { tokenizer.GetNextToken(); return new <API key>(e, <API key>(), <API key>.Less); }; if (tokenizer.IsToken(ConditionTokenType.GT)) { tokenizer.GetNextToken(); return new <API key>(e, <API key>(), <API key>.Greater); }; if (tokenizer.IsToken(ConditionTokenType.LE)) { tokenizer.GetNextToken(); return new <API key>(e, <API key>(), <API key>.LessOrEqual); }; if (tokenizer.IsToken(ConditionTokenType.GE)) { tokenizer.GetNextToken(); return new <API key>(e, <API key>(), <API key>.GreaterOrEqual); }; return e; } private ConditionExpression <API key>() { if (tokenizer.IsKeyword("not") || tokenizer.IsToken(ConditionTokenType.Not)) { tokenizer.GetNextToken(); return new <API key>((ConditionExpression)<API key>()); } return <API key>(); } private ConditionExpression ParseBooleanAnd() { ConditionExpression e = <API key>(); while (tokenizer.IsKeyword("and") || tokenizer.IsToken(ConditionTokenType.And)) { tokenizer.GetNextToken(); e = new <API key>((ConditionExpression)e, (ConditionExpression)<API key>()); } return e; } private ConditionExpression ParseBooleanOr() { ConditionExpression e = ParseBooleanAnd(); while (tokenizer.IsKeyword("or") || tokenizer.IsToken(ConditionTokenType.Or)) { tokenizer.GetNextToken(); e = new <API key>((ConditionExpression)e, (ConditionExpression)ParseBooleanAnd()); } return e; } private ConditionExpression <API key>() { return ParseBooleanOr(); } private ConditionExpression ParseExpression() { return <API key>(); } <summary> Parses the specified condition string and turns it into <see cref="ConditionExpression"/> tree. </summary> <param name="expr">The expression to be parsed.</param> <returns>The root of the expression syntax tree which can be used to get the value of the condition in a specified context</returns> public static ConditionExpression ParseExpression(string expr) { ConditionParser parser = new ConditionParser(expr); ConditionExpression e = parser.ParseExpression(); if (!parser.tokenizer.IsEOF()) throw new <API key>("Unexpected token: " + parser.tokenizer.TokenValue); return e; } } }
Ext.define('KitchenSink.view.ColorPatterns', { singleton: true, requires: ['Ext.draw.Color'], colors: ["#115fa6", "#94ae0a", "#a61120", "#ff8809", "#ffd13e", "#a61187", "#24ad9a", "#7c7474", "#a66111"], getBaseColors: function (index) { if (index == null) { return this.colors.slice(); } else { return this.colors[index]; } }, <API key>: function (deltaHSL) { deltaHSL = Ext.applyIf(deltaHSL || {}, {h: 0, s: 0, l: 0}); var deltaH = deltaHSL.h, deltaS = deltaHSL.s, deltaL = deltaHSL.l, colors = [], i, hsl; for (i = 0; i < this.colors.length; i++) { hsl = Ext.draw.Color.create(this.colors[i]).getHSL(); colors.push(Ext.draw.Color.fromHSL(hsl[0] + deltaH, hsl[1] + deltaS, hsl[2] + deltaL)); } return colors; }, <API key>: function (baseColor, from, to, number) { baseColor = Ext.draw.Color.create(baseColor); var hsl = baseColor.getHSL(), fromH = 'h' in from ? from.h : hsl[0], fromS = 's' in from ? from.s : hsl[1], fromL = 'l' in from ? from.l : hsl[2], toH = 'h' in to ? to.h : hsl[0], toS = 's' in to ? to.s : hsl[1], toL = 'l' in to ? to.l : hsl[2], i, colors = [], deltaH = (toH - fromH) / number, deltaS = (toS - fromS) / number, deltaL = (toL - fromL) / number; for (i = 0; i <= number; i++) { colors.push(Ext.draw.Color.fromHSL( fromH + deltaH * i, fromS + deltaS * i, fromL + deltaL * i ).toString()); } return colors; }, getGradientColors: function (fromColor, toColor, number) { var colors = [], temp = new Ext.draw.Color(), i; fromColor = Ext.draw.Color.create(fromColor); toColor = Ext.draw.Color.create(toColor); for (i = 0; i <= number; i++) { temp.r = fromColor.r * (1 - i / number) + toColor.r * i / number; temp.g = fromColor.g * (1 - i / number) + toColor.g * i / number; temp.b = fromColor.b * (1 - i / number) + toColor.b * i / number; temp.a = fromColor.a * (1 - i / number) + toColor.a * i / number; colors.push(temp.toString()); } return colors; }, <API key>: function (baseColor, fromBrightness, toBrightness, number) { baseColor = Ext.draw.Color.create(baseColor); var hsl = baseColor.getHSL(), colors = [], i; for (i = 0; i <= number; i++) { colors.push(Ext.draw.Color.fromHSL(hsl[0], hsl[1], fromBrightness * (1 - i / number) + toBrightness * i / number).toString()); } return colors; } });
/* ANSI-C code produced by gperf version 2.7.2 */ /* Command-line: gperf -acCgopt -k'1,2,5,9,$' -L ANSI-C -N locfile_hash programs/locfile-kw.gperf */ #include <string.h> #include "locfile-token.h" struct keyword_t ; #define TOTAL_KEYWORDS 175 #define MIN_WORD_LENGTH 3 #define MAX_WORD_LENGTH 22 #define MIN_HASH_VALUE 3 #define MAX_HASH_VALUE 687 /* maximum key range = 685, duplicates = 0 */ #ifdef __GNUC__ __inline #else #ifdef __cplusplus inline #endif #endif static unsigned int hash (register const char *str, register unsigned int len) { static const unsigned short asso_values[] = { 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 5, 0, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 15, 688, 0, 0, 0, 5, 0, 0, 0, 688, 688, 0, 688, 0, 5, 688, 688, 15, 0, 5, 15, 688, 688, 688, 0, 688, 688, 688, 688, 688, 75, 688, 0, 0, 65, 5, 0, 85, 40, 5, 155, 688, 10, 105, 120, 125, 35, 5, 20, 5, 190, 0, 125, 35, 10, 30, 35, 0, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688 }; register int hval = len; switch (hval) { default: case 9: hval += asso_values[(unsigned char)str[8]]; case 8: case 7: case 6: case 5: hval += asso_values[(unsigned char)str[4]]; case 4: case 3: case 2: hval += asso_values[(unsigned char)str[1]]; case 1: hval += asso_values[(unsigned char)str[0]]; break; } return hval + asso_values[(unsigned char)str[len - 1]]; } #ifdef __GNUC__ __inline #endif const struct keyword_t * locfile_hash (register const char *str, register unsigned int len) { static const struct keyword_t wordlist[] = { {""}, {""}, {""}, {"END", tok_end, 0}, {""}, {""}, {""}, {"LC_TIME", tok_lc_time, 0}, {"era", tok_era, 0}, {"date", tok_date, 0}, {"LC_ADDRESS", tok_lc_address, 0}, {"LC_MESSAGES", tok_lc_messages, 0}, {"LC_TELEPHONE", tok_lc_telephone, 0}, {"LC_CTYPE", tok_lc_ctype, 0}, {"era_t_fmt", tok_era_t_fmt, 0}, {"print", tok_print, 0}, {"height", tok_height, 0}, {"LC_IDENTIFICATION", <API key>, 0}, {""}, {"era_d_fmt", tok_era_d_fmt, 0}, {"LC_COLLATE", tok_lc_collate, 0}, {"IGNORE", tok_ignore, 0}, {"LC_NAME", tok_lc_name, 0}, {"backward", tok_backward, 0}, {"week", tok_week, 0}, {"LC_NUMERIC", tok_lc_numeric, 0}, {"reorder-end", tok_reorder_end, 0}, {""}, {"reorder-after", tok_reorder_after, 0}, {"UNDEFINED", tok_undefined, 0}, {""}, {"LC_MONETARY", tok_lc_monetary, 0}, {""}, {"repertoiremap", tok_repertoiremap, 0}, {"LC_MEASUREMENT", tok_lc_measurement, 0}, {""}, {""}, {""}, {"LC_PAPER", tok_lc_paper, 0}, {""}, {""}, {""}, {""}, {"day", tok_day, 0}, {""}, {""}, {"yesstr", tok_yesstr, 0}, {""}, {""}, {""}, {""}, {""}, {"toupper", tok_toupper, 0}, {"era_year", tok_era_year, 0}, {""}, {""}, {"order_start", tok_order_start, 0}, {"tolower", tok_tolower, 0}, {""}, {""}, {"graph", tok_graph, 0}, {""}, {""}, {""}, {"order_end", tok_order_end, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {"abday", tok_abday, 0}, {""}, {"yesexpr", tok_yesexpr, 0}, {""}, {""}, {"t_fmt", tok_t_fmt, 0}, {""}, {""}, {""}, {""}, {"d_fmt", tok_d_fmt, 0}, {""}, {""}, {"date_fmt", tok_date_fmt, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {"grouping", tok_grouping, 0}, {""}, {""}, {"tel_dom_fmt", tok_tel_dom_fmt, 0}, {""}, {""}, {""}, {""}, {"era_d_t_fmt", tok_era_d_t_fmt, 0}, {"contact", tok_contact, 0}, {"tel", tok_tel, 0}, {"else", tok_else, 0}, {"alpha", tok_alpha, 0}, {"country_ab3", tok_country_ab3, 0}, {""}, {""}, {""}, {""}, {"country_ab2", tok_country_ab2, 0}, {"country_post", tok_country_post, 0}, {"fax", tok_fax, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {"map", tok_map, 0}, {""}, {"blank", tok_blank, 0}, {""}, {"forward", tok_forward, 0}, {"audience", tok_audience, 0}, {""}, {"punct", tok_punct, 0}, {"define", tok_define, 0}, {"abbreviation", tok_abbreviation, 0}, {""}, {"copy", tok_copy, 0}, {""}, {""}, {""}, {"decimal_point", tok_decimal_point, 0}, {""}, {"upper", tok_upper, 0}, {""}, {""}, {"category", tok_category, 0}, {""}, {"conversion_rate", tok_conversion_rate, 0}, {""}, {""}, {""}, {""}, {"lower", tok_lower, 0}, {""}, {"collating-element", <API key>, 0}, {"duo_p_sep_by_space", <API key>, 0}, {""}, {"title", tok_title, 0}, {""}, {""}, {"timezone", tok_timezone, 0}, {""}, {"digit", tok_digit, 0}, {""}, {""}, {""}, {""}, {"postal_fmt", tok_postal_fmt, 0}, {""}, {"d_t_fmt", tok_d_t_fmt, 0}, {"position", tok_position, 0}, {"p_sep_by_space", tok_p_sep_by_space, 0}, {"nostr", tok_nostr, 0}, {"noexpr", tok_noexpr, 0}, {""}, {"charconv", tok_charconv, 0}, {""}, {"width", tok_width, 0}, {"country_car", tok_country_car, 0}, {"comment_char", tok_comment_char, 0}, {""}, {""}, {""}, {""}, {"lang_ab", tok_lang_ab, 0}, {"lang_lib", tok_lang_lib, 0}, {"lang_name", tok_lang_name, 0}, {""}, {""}, {""}, {""}, {"elif", tok_elif, 0}, {""}, {"xdigit", tok_xdigit, 0}, {""}, {""}, {""}, {"space", tok_space, 0}, {""}, {"address", tok_address, 0}, {""}, {""}, {""}, {""}, {""}, {"name_fmt", tok_name_fmt, 0}, {""}, {"t_fmt_ampm", tok_t_fmt_ampm, 0}, {""}, {"name_mr", tok_name_mr, 0}, {""}, {"from", tok_from, 0}, {""}, {"escape_char", tok_escape_char, 0}, {"duo_valid_to", tok_duo_valid_to, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {"<API key>", <API key>, 0}, {""}, {"<API key>", <API key>, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {"territory", tok_territory, 0}, {""}, {""}, {"country_name", tok_country_name, 0}, {"language", tok_language, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {"tel_int_fmt", tok_tel_int_fmt, 0}, {"mon_grouping", tok_mon_grouping, 0}, {"positive_sign", tok_positive_sign, 0}, {""}, {"abmon", tok_abmon, 0}, {"measurement", tok_measurement, 0}, {""}, {""}, {""}, {"coll_weight_max", tok_coll_weight_max, 0}, {"collating-symbol", <API key>, 0}, {""}, {""}, {""}, {""}, {"script", tok_script, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {"cal_direction", tok_cal_direction, 0}, {""}, {""}, {""}, {""}, {"duo_n_sep_by_space", <API key>, 0}, {""}, {""}, {""}, {""}, {"mon", tok_mon, 0}, {"translit_start", tok_translit_start, 0}, {"translit_ignore", tok_translit_ignore, 0}, {""}, {"translit_end", tok_translit_end, 0}, {"first_weekday", tok_first_weekday, 0}, {""}, {""}, {"p_sign_posn", tok_p_sign_posn, 0}, {""}, {"first_workday", tok_first_workday, 0}, {"n_sep_by_space", tok_n_sep_by_space, 0}, {""}, {"source", tok_source, 0}, {"mon_decimal_point", <API key>, 0}, {"symbol-equivalence", <API key>, 0}, {""}, {"endif", tok_endif, 0}, {""}, {""}, {""}, {"duo_valid_from", tok_duo_valid_from, 0}, {"default_missing", tok_default_missing, 0}, {""}, {""}, {"int_p_sep_by_space", <API key>, 0}, {""}, {"alt_digits", tok_alt_digits, 0}, {""}, {"<API key>", <API key>, 0}, {""}, {""}, {"duo_p_sign_posn", tok_duo_p_sign_posn, 0}, {""}, {""}, {""}, {"duo_currency_symbol", <API key>, 0}, {""}, {""}, {""}, {"outdigit", tok_outdigit, 0}, {""}, {""}, {""}, {""}, {"revision", tok_revision, 0}, {""}, {""}, {""}, {""}, {"name_gen", tok_name_gen, 0}, {""}, {"email", tok_email, 0}, {""}, {"uno_valid_to", tok_uno_valid_to, 0}, {"negative_sign", tok_negative_sign, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {"alnum", tok_alnum, 0}, {""}, {""}, {""}, {""}, {""}, {"country_num", tok_country_num, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {"am_pm", tok_am_pm, 0}, {""}, {"mon_thousands_sep", <API key>, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {"currency_symbol", tok_currency_symbol, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {"country_isbn", tok_country_isbn, 0}, {""}, {""}, {""}, {""}, {"name_ms", tok_name_ms, 0}, {"name_mrs", tok_name_mrs, 0}, {""}, {""}, {""}, {""}, {"thousands_sep", tok_thousands_sep, 0}, {""}, {"cntrl", tok_cntrl, 0}, {""}, {""}, {""}, {""}, {""}, {"n_sign_posn", tok_n_sign_posn, 0}, {"include", tok_include, 0}, {""}, {""}, {"ifdef", tok_ifdef, 0}, {""}, {"duo_p_cs_precedes", <API key>, 0}, {""}, {""}, {""}, {""}, {""}, {"p_cs_precedes", tok_p_cs_precedes, 0}, {"uno_valid_from", tok_uno_valid_from, 0}, {"undef", tok_undef, 0}, {""}, {""}, {"int_n_sep_by_space", <API key>, 0}, {"lang_term", tok_lang_term, 0}, {""}, {""}, {"<API key>", <API key>, 0}, {""}, {"duo_int_p_sign_posn", <API key>, 0}, {"duo_n_sign_posn", tok_duo_n_sign_posn, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {"application", tok_application, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {"int_p_sign_posn", tok_int_p_sign_posn, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {"duo_int_curr_symbol", <API key>, 0}, {""}, {""}, {""}, {""}, {""}, {"int_prefix", tok_int_prefix, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {"duo_frac_digits", tok_duo_frac_digits, 0}, {""}, {""}, {""}, {""}, {""}, {"<API key>", <API key>, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {"frac_digits", tok_frac_digits, 0}, {""}, {""}, {"charclass", tok_charclass, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {"duo_n_cs_precedes", <API key>, 0}, {""}, {""}, {"int_curr_symbol", tok_int_curr_symbol, 0}, {""}, {""}, {"n_cs_precedes", tok_n_cs_precedes, 0}, {""}, {"int_select", tok_int_select, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {"duo_int_n_sign_posn", <API key>, 0}, {"class", tok_class, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {"int_p_cs_precedes", <API key>, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {"duo_int_frac_digits", <API key>, 0}, {""}, {""}, {""}, {""}, {""}, {"int_n_sign_posn", tok_int_n_sign_posn, 0}, {""}, {""}, {""}, {"name_miss", tok_name_miss, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {"<API key>", <API key>, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {"int_frac_digits", tok_int_frac_digits, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {"section-symbol", tok_section_symbol, 0}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {"int_n_cs_precedes", <API key>, 0} }; if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) { register int key = hash (str, len); if (key <= MAX_HASH_VALUE && key >= 0) { register const char *s = wordlist[key].name; if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0') return &wordlist[key]; } } return 0; }
# -*- coding: utf-8 -*- # <API key>.py # This file is part of NEST. # NEST is free software: you can redistribute it and/or modify # (at your option) any later version. # NEST is distributed in the hope that it will be useful, # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the """ Weights given as lists with the different connection rules """ import unittest import nest @nest.ll_api.check_stack class <API key>(unittest.TestCase): """Test weights given as lists""" def setUp(self): nest.ResetKernel() def test_OneToOneWeight(self): """Weight given as list, when connection rule is one_to_one""" src = nest.Create('iaf_psc_alpha', 3) tgt = nest.Create('iaf_psc_delta', 3) # weight has to be a list with dimension (n_sources x 1) when one_to_one is used ref_weights = [1.2, -3.5, 0.4] conn_dict = {'rule': 'one_to_one'} syn_dict = {'weight': ref_weights} nest.Connect(src, tgt, conn_dict, syn_dict) conns = nest.GetConnections() weights = conns.weight self.assertEqual(weights, ref_weights) def test_AllToAllWeight(self): """Weight given as list of lists, when connection rule is all_to_all""" src = nest.Create('iaf_psc_alpha', 3) tgt = nest.Create('iaf_psc_delta', 2) # weight has to be a list of lists with dimension (n_target x n_sources) when all_to_all is used ref_weights = [[1.2, -3.5, 2.5], [0.4, -0.2, 0.7]] conn_dict = {'rule': 'all_to_all'} syn_dict = {'weight': ref_weights} nest.Connect(src, tgt, conn_dict, syn_dict) conns = nest.GetConnections() weights = conns.weight # Need to flatten ref_weights in order to compare with the weights given by the SynapseCollection. ref_weights = [w for sub_weights in ref_weights for w in sub_weights] self.assertEqual(weights.sort(), ref_weights.sort()) def <API key>(self): """Weight given as list of list, when connection rule is fixed_indegree""" src = nest.Create('iaf_psc_alpha', 5) tgt = nest.Create('iaf_psc_delta', 3) # weight has to be a list of lists with dimension (n_target x indegree) when fixed_indegree is used ref_weights = [[1.2, -3.5], [0.4, -0.2], [0.6, 2.2]] conn_dict = {'rule': 'fixed_indegree', 'indegree': 2} syn_dict = {'weight': ref_weights} nest.Connect(src, tgt, conn_dict, syn_dict) conns = nest.GetConnections() weights = conns.weight # Need to flatten ref_weights in order to compare with the weights given by the SynapseCollection. ref_weights = [w for sub_weights in ref_weights for w in sub_weights] self.assertEqual(weights.sort(), ref_weights.sort()) def <API key>(self): """Weight given as list of lists, when connection rule is fixed_outdegree""" src = nest.Create('iaf_psc_alpha', 2) tgt = nest.Create('iaf_psc_delta', 5) # weight has to be a list of lists with dimension (n_source x outegree) when fixed_outdegree is used ref_weights = [[1.2, -3.5, 0.4], [-0.2, 0.6, 2.2]] conn_dict = {'rule': 'fixed_outdegree', 'outdegree': 3} syn_dict = {'weight': ref_weights} nest.Connect(src, tgt, conn_dict, syn_dict) conns = nest.GetConnections() weights = conns.weight # Need to flatten ref_weights in order to compare with the weights given by the SynapseCollection. ref_weights = [w for sub_weights in ref_weights for w in sub_weights] self.assertEqual(weights.sort(), ref_weights.sort()) def <API key>(self): """Weight given as list, when connection rule is fixed_total_number""" src = nest.Create('iaf_psc_alpha', 3) tgt = nest.Create('iaf_psc_delta', 4) conn_dict = {'rule': 'fixed_total_number', 'N': 4} # weight has to be a list with dimension (n_conns x 1) when fixed_total_number is used ref_weights = [1.2, -3.5, 0.4, -0.2] syn_dict = {'weight': ref_weights} nest.Connect(src, tgt, conn_dict, syn_dict) conns = nest.GetConnections() weights = conns.weight self.assertEqual(weights, ref_weights) def suite(): suite = unittest.makeSuite(<API key>, 'test') return suite def run(): runner = unittest.TextTestRunner(verbosity=2) runner.run(suite()) if __name__ == "__main__": run()
#include <linux/module.h> #include <linux/fs.h> #include <linux/types.h> #include <linux/highmem.h> #include <linux/init.h> #include <linux/sysctl.h> #include <linux/random.h> #include <linux/blkdev.h> #include <linux/socket.h> #include <linux/inet.h> #include <linux/timer.h> #include <linux/kthread.h> #include <linux/delay.h> #include "cluster/heartbeat.h" #include "cluster/nodemanager.h" #include "cluster/tcp.h" #include "dlmapi.h" #include "dlmcommon.h" #include "dlmdomain.h" #define MLOG_MASK_PREFIX (ML_DLM|ML_DLM_THREAD) #include "cluster/masklog.h" static int dlm_thread(void *data); static void dlm_flush_asts(struct dlm_ctxt *dlm); #define dlm_lock_is_remote(dlm, lock) ((lock)->ml.node != (dlm)->node_num) /* will exit holding res->spinlock, but may drop in function */ /* waits until flags are cleared on res->state */ void <API key>(struct dlm_lock_resource *res, int flags) { DECLARE_WAITQUEUE(wait, current); assert_spin_locked(&res->spinlock); add_wait_queue(&res->wq, &wait); repeat: set_current_state(<API key>); if (res->state & flags) { spin_unlock(&res->spinlock); schedule(); spin_lock(&res->spinlock); goto repeat; } remove_wait_queue(&res->wq, &wait); __set_current_state(TASK_RUNNING); } int <API key>(struct dlm_lock_resource *res) { if (list_empty(&res->granted) && list_empty(&res->converting) && list_empty(&res->blocked)) return 0; return 1; } /* "unused": the lockres has no locks, is not on the dirty list, * has no inflight locks (in the gap between mastery and acquiring * the first lock), and has no bits in its refmap. * truly ready to be freed. */ int <API key>(struct dlm_lock_resource *res) { int bit; assert_spin_locked(&res->spinlock); if (<API key>(res)) return 0; /* Locks are in the process of being created */ if (res->inflight_locks) return 0; if (!list_empty(&res->dirty) || res->state & DLM_LOCK_RES_DIRTY) return 0; if (res->state & <API key>) return 0; /* Another node has this resource with this node as the master */ bit = find_next_bit(res->refmap, O2NM_MAX_NODES, 0); if (bit < O2NM_MAX_NODES) return 0; return 1; } /* Call whenever you may have added or deleted something from one of * the lockres queue's. This will figure out whether it belongs on the * unused list or not and does the appropriate thing. */ void <API key>(struct dlm_ctxt *dlm, struct dlm_lock_resource *res) { assert_spin_locked(&dlm->spinlock); assert_spin_locked(&res->spinlock); if (<API key>(res)){ if (list_empty(&res->purge)) { mlog(0, "%s: Adding res %.*s to purge list\n", dlm->name, res->lockname.len, res->lockname.name); res->last_used = jiffies; dlm_lockres_get(res); list_add_tail(&res->purge, &dlm->purge_list); dlm->purge_count++; } } else if (!list_empty(&res->purge)) { mlog(0, "%s: Removing res %.*s from purge list\n", dlm->name, res->lockname.len, res->lockname.name); list_del_init(&res->purge); dlm_lockres_put(res); dlm->purge_count } } void <API key>(struct dlm_ctxt *dlm, struct dlm_lock_resource *res) { spin_lock(&dlm->spinlock); spin_lock(&res->spinlock); <API key>(dlm, res); spin_unlock(&res->spinlock); spin_unlock(&dlm->spinlock); } static void dlm_purge_lockres(struct dlm_ctxt *dlm, struct dlm_lock_resource *res) { int master; int ret = 0; assert_spin_locked(&dlm->spinlock); assert_spin_locked(&res->spinlock); master = (res->owner == dlm->node_num); mlog(0, "%s: Purging res %.*s, master %d\n", dlm->name, res->lockname.len, res->lockname.name, master); if (!master) { res->state |= <API key>; /* drop spinlock... retake below */ spin_unlock(&res->spinlock); spin_unlock(&dlm->spinlock); spin_lock(&res->spinlock); /* This ensures that clear refmap is sent after the set */ <API key>(res, <API key>); spin_unlock(&res->spinlock); /* clear our bit from the master's refmap, ignore errors */ ret = <API key>(dlm, res); if (ret < 0) { if (!dlm_is_host_down(ret)) BUG(); } spin_lock(&dlm->spinlock); spin_lock(&res->spinlock); } if (!list_empty(&res->purge)) { mlog(0, "%s: Removing res %.*s from purgelist, master %d\n", dlm->name, res->lockname.len, res->lockname.name, master); list_del_init(&res->purge); dlm_lockres_put(res); dlm->purge_count } if (!<API key>(res)) { mlog(ML_ERROR, "%s: res %.*s in use after deref\n", dlm->name, res->lockname.len, res->lockname.name); <API key>(res); BUG(); } <API key>(dlm, res); /* lockres is not in the hash now. drop the flag and wake up * any processes waiting in <API key>. */ if (!master) { res->state &= ~<API key>; spin_unlock(&res->spinlock); wake_up(&res->wq); } else spin_unlock(&res->spinlock); } static void dlm_run_purge_list(struct dlm_ctxt *dlm, int purge_now) { unsigned int run_max, unused; unsigned long purge_jiffies; struct dlm_lock_resource *lockres; spin_lock(&dlm->spinlock); run_max = dlm->purge_count; while(run_max && !list_empty(&dlm->purge_list)) { run_max lockres = list_entry(dlm->purge_list.next, struct dlm_lock_resource, purge); spin_lock(&lockres->spinlock); purge_jiffies = lockres->last_used + msecs_to_jiffies(<API key>); /* Make sure that we want to be processing this guy at * this time. */ if (!purge_now && time_after(purge_jiffies, jiffies)) { /* Since resources are added to the purge list * in tail order, we can stop at the first * unpurgable resource -- anyone added after * him will have a greater last_used value */ spin_unlock(&lockres->spinlock); break; } /* Status of the lockres *might* change so double * check. If the lockres is unused, holding the dlm * spinlock will prevent people from getting and more * refs on it. */ unused = <API key>(lockres); if (!unused || (lockres->state & <API key>)) { mlog(0, "%s: res %.*s is in use or being remastered, " "used %d, state %d\n", dlm->name, lockres->lockname.len, lockres->lockname.name, !unused, lockres->state); list_move_tail(&dlm->purge_list, &lockres->purge); spin_unlock(&lockres->spinlock); continue; } dlm_lockres_get(lockres); dlm_purge_lockres(dlm, lockres); dlm_lockres_put(lockres); /* Avoid adding any scheduling latencies */ cond_resched_lock(&dlm->spinlock); } spin_unlock(&dlm->spinlock); } static void dlm_shuffle_lists(struct dlm_ctxt *dlm, struct dlm_lock_resource *res) { struct dlm_lock *lock, *target; struct list_head *iter; struct list_head *head; int can_grant = 1; /* * Because this function is called with the lockres * spinlock, and because we know that it is not migrating/ * recovering/in-progress, it is fine to reserve asts and * basts right before queueing them all throughout */ assert_spin_locked(&dlm->ast_lock); assert_spin_locked(&res->spinlock); BUG_ON((res->state & (<API key>| <API key>| <API key>))); converting: if (list_empty(&res->converting)) goto blocked; mlog(0, "%s: res %.*s has locks on the convert queue\n", dlm->name, res->lockname.len, res->lockname.name); target = list_entry(res->converting.next, struct dlm_lock, list); if (target->ml.convert_type == LKM_IVMODE) { mlog(ML_ERROR, "%s: res %.*s converting lock to invalid mode\n", dlm->name, res->lockname.len, res->lockname.name); BUG(); } head = &res->granted; list_for_each(iter, head) { lock = list_entry(iter, struct dlm_lock, list); if (lock==target) continue; if (!dlm_lock_compatible(lock->ml.type, target->ml.convert_type)) { can_grant = 0; /* queue the BAST if not already */ if (lock->ml.highest_blocked == LKM_IVMODE) { <API key>(res); __dlm_queue_bast(dlm, lock); } /* update the highest_blocked if needed */ if (lock->ml.highest_blocked < target->ml.convert_type) lock->ml.highest_blocked = target->ml.convert_type; } } head = &res->converting; list_for_each(iter, head) { lock = list_entry(iter, struct dlm_lock, list); if (lock==target) continue; if (!dlm_lock_compatible(lock->ml.type, target->ml.convert_type)) { can_grant = 0; if (lock->ml.highest_blocked == LKM_IVMODE) { <API key>(res); __dlm_queue_bast(dlm, lock); } if (lock->ml.highest_blocked < target->ml.convert_type) lock->ml.highest_blocked = target->ml.convert_type; } } /* we can convert the lock */ if (can_grant) { spin_lock(&target->spinlock); BUG_ON(target->ml.highest_blocked != LKM_IVMODE); mlog(0, "%s: res %.*s, AST for Converting lock %u:%llu, type " "%d => %d, node %u\n", dlm->name, res->lockname.len, res->lockname.name, <API key>(be64_to_cpu(target->ml.cookie)), <API key>(be64_to_cpu(target->ml.cookie)), target->ml.type, target->ml.convert_type, target->ml.node); target->ml.type = target->ml.convert_type; target->ml.convert_type = LKM_IVMODE; list_move_tail(&target->list, &res->granted); BUG_ON(!target->lksb); target->lksb->status = DLM_NORMAL; spin_unlock(&target->spinlock); <API key>(res); __dlm_queue_ast(dlm, target); /* go back and check for more */ goto converting; } blocked: if (list_empty(&res->blocked)) goto leave; target = list_entry(res->blocked.next, struct dlm_lock, list); head = &res->granted; list_for_each(iter, head) { lock = list_entry(iter, struct dlm_lock, list); if (lock==target) continue; if (!dlm_lock_compatible(lock->ml.type, target->ml.type)) { can_grant = 0; if (lock->ml.highest_blocked == LKM_IVMODE) { <API key>(res); __dlm_queue_bast(dlm, lock); } if (lock->ml.highest_blocked < target->ml.type) lock->ml.highest_blocked = target->ml.type; } } head = &res->converting; list_for_each(iter, head) { lock = list_entry(iter, struct dlm_lock, list); if (lock==target) continue; if (!dlm_lock_compatible(lock->ml.type, target->ml.type)) { can_grant = 0; if (lock->ml.highest_blocked == LKM_IVMODE) { <API key>(res); __dlm_queue_bast(dlm, lock); } if (lock->ml.highest_blocked < target->ml.type) lock->ml.highest_blocked = target->ml.type; } } /* we can grant the blocked lock (only * possible if converting list empty) */ if (can_grant) { spin_lock(&target->spinlock); BUG_ON(target->ml.highest_blocked != LKM_IVMODE); mlog(0, "%s: res %.*s, AST for Blocked lock %u:%llu, type %d, " "node %u\n", dlm->name, res->lockname.len, res->lockname.name, <API key>(be64_to_cpu(target->ml.cookie)), <API key>(be64_to_cpu(target->ml.cookie)), target->ml.type, target->ml.node); /* target->ml.type is already correct */ list_move_tail(&target->list, &res->granted); BUG_ON(!target->lksb); target->lksb->status = DLM_NORMAL; spin_unlock(&target->spinlock); <API key>(res); __dlm_queue_ast(dlm, target); /* go back and check for more */ goto converting; } leave: return; } /* must have NO locks when calling this with res !=NULL * */ void dlm_kick_thread(struct dlm_ctxt *dlm, struct dlm_lock_resource *res) { if (res) { spin_lock(&dlm->spinlock); spin_lock(&res->spinlock); __dlm_dirty_lockres(dlm, res); spin_unlock(&res->spinlock); spin_unlock(&dlm->spinlock); } wake_up(&dlm->dlm_thread_wq); } void __dlm_dirty_lockres(struct dlm_ctxt *dlm, struct dlm_lock_resource *res) { assert_spin_locked(&dlm->spinlock); assert_spin_locked(&res->spinlock); /* don't shuffle secondary queues */ if ((res->owner == dlm->node_num)) { if (res->state & (<API key> | <API key>)) return; if (list_empty(&res->dirty)) { /* ref for dirty_list */ dlm_lockres_get(res); list_add_tail(&res->dirty, &dlm->dirty_list); res->state |= DLM_LOCK_RES_DIRTY; } } mlog(0, "%s: res %.*s\n", dlm->name, res->lockname.len, res->lockname.name); } /* Launch the NM thread for the mounted volume */ int dlm_launch_thread(struct dlm_ctxt *dlm) { mlog(0, "Starting dlm_thread...\n"); dlm->dlm_thread_task = kthread_run(dlm_thread, dlm, "dlm_thread"); if (IS_ERR(dlm->dlm_thread_task)) { mlog_errno(PTR_ERR(dlm->dlm_thread_task)); dlm->dlm_thread_task = NULL; return -EINVAL; } return 0; } void dlm_complete_thread(struct dlm_ctxt *dlm) { if (dlm->dlm_thread_task) { mlog(ML_KTHREAD, "Waiting for dlm thread to exit\n"); kthread_stop(dlm->dlm_thread_task); dlm->dlm_thread_task = NULL; } } static int <API key>(struct dlm_ctxt *dlm) { int empty; spin_lock(&dlm->spinlock); empty = list_empty(&dlm->dirty_list); spin_unlock(&dlm->spinlock); return empty; } static void dlm_flush_asts(struct dlm_ctxt *dlm) { int ret; struct dlm_lock *lock; struct dlm_lock_resource *res; u8 hi; spin_lock(&dlm->ast_lock); while (!list_empty(&dlm->pending_asts)) { lock = list_entry(dlm->pending_asts.next, struct dlm_lock, ast_list); /* get an extra ref on lock */ dlm_lock_get(lock); res = lock->lockres; mlog(0, "%s: res %.*s, Flush AST for lock %u:%llu, type %d, " "node %u\n", dlm->name, res->lockname.len, res->lockname.name, <API key>(be64_to_cpu(lock->ml.cookie)), <API key>(be64_to_cpu(lock->ml.cookie)), lock->ml.type, lock->ml.node); BUG_ON(!lock->ast_pending); /* remove from list (including ref) */ list_del_init(&lock->ast_list); dlm_lock_put(lock); spin_unlock(&dlm->ast_lock); if (lock->ml.node != dlm->node_num) { ret = dlm_do_remote_ast(dlm, res, lock); if (ret < 0) mlog_errno(ret); } else dlm_do_local_ast(dlm, res, lock); spin_lock(&dlm->ast_lock); /* possible that another ast was queued while * we were delivering the last one */ if (!list_empty(&lock->ast_list)) { mlog(0, "%s: res %.*s, AST queued while flushing last " "one\n", dlm->name, res->lockname.len, res->lockname.name); } else lock->ast_pending = 0; /* drop the extra ref. * this may drop it completely. */ dlm_lock_put(lock); <API key>(dlm, res); } while (!list_empty(&dlm->pending_basts)) { lock = list_entry(dlm->pending_basts.next, struct dlm_lock, bast_list); /* get an extra ref on lock */ dlm_lock_get(lock); res = lock->lockres; BUG_ON(!lock->bast_pending); /* get the highest blocked lock, and reset */ spin_lock(&lock->spinlock); BUG_ON(lock->ml.highest_blocked <= LKM_IVMODE); hi = lock->ml.highest_blocked; lock->ml.highest_blocked = LKM_IVMODE; spin_unlock(&lock->spinlock); /* remove from list (including ref) */ list_del_init(&lock->bast_list); dlm_lock_put(lock); spin_unlock(&dlm->ast_lock); mlog(0, "%s: res %.*s, Flush BAST for lock %u:%llu, " "blocked %d, node %u\n", dlm->name, res->lockname.len, res->lockname.name, <API key>(be64_to_cpu(lock->ml.cookie)), <API key>(be64_to_cpu(lock->ml.cookie)), hi, lock->ml.node); if (lock->ml.node != dlm->node_num) { ret = dlm_send_proxy_bast(dlm, res, lock, hi); if (ret < 0) mlog_errno(ret); } else dlm_do_local_bast(dlm, res, lock, hi); spin_lock(&dlm->ast_lock); /* possible that another bast was queued while * we were delivering the last one */ if (!list_empty(&lock->bast_list)) { mlog(0, "%s: res %.*s, BAST queued while flushing last " "one\n", dlm->name, res->lockname.len, res->lockname.name); } else lock->bast_pending = 0; /* drop the extra ref. * this may drop it completely. */ dlm_lock_put(lock); <API key>(dlm, res); } wake_up(&dlm->ast_wq); spin_unlock(&dlm->ast_lock); } #define <API key> (4 * 1000) #define <API key> 100 #define DLM_THREAD_MAX_ASTS 10 static int dlm_thread(void *data) { struct dlm_lock_resource *res; struct dlm_ctxt *dlm = data; unsigned long timeout = msecs_to_jiffies(<API key>); mlog(0, "dlm thread running for %s...\n", dlm->name); while (!kthread_should_stop()) { int n = <API key>; /* dlm_shutting_down is very point-in-time, but that * doesn't matter as we'll just loop back around if we * get false on the leading edge of a state * transition. */ dlm_run_purge_list(dlm, dlm_shutting_down(dlm)); /* We really don't want to hold dlm->spinlock while * calling dlm_shuffle_lists on each lockres that * needs to have its queues adjusted and AST/BASTs * run. So let's pull each entry off the dirty_list * and drop dlm->spinlock ASAP. Once off the list, * res->spinlock needs to be taken again to protect * the queues while calling dlm_shuffle_lists. */ spin_lock(&dlm->spinlock); while (!list_empty(&dlm->dirty_list)) { int delay = 0; res = list_entry(dlm->dirty_list.next, struct dlm_lock_resource, dirty); /* peel a lockres off, remove it from the list, * unset the dirty flag and drop the dlm lock */ BUG_ON(!res); dlm_lockres_get(res); spin_lock(&res->spinlock); /* We clear the DLM_LOCK_RES_DIRTY state once we shuffle lists below */ list_del_init(&res->dirty); spin_unlock(&res->spinlock); spin_unlock(&dlm->spinlock); /* Drop dirty_list ref */ dlm_lockres_put(res); /* lockres can be re-dirtied/re-added to the * dirty_list in this gap, but that is ok */ spin_lock(&dlm->ast_lock); spin_lock(&res->spinlock); if (res->owner != dlm->node_num) { <API key>(res); mlog(ML_ERROR, "%s: inprog %d, mig %d, reco %d," " dirty %d\n", dlm->name, !!(res->state & <API key>), !!(res->state & <API key>), !!(res->state & <API key>), !!(res->state & DLM_LOCK_RES_DIRTY)); } BUG_ON(res->owner != dlm->node_num); /* it is now ok to move lockreses in these states * to the dirty list, assuming that they will only be * dirty for a short while. */ BUG_ON(res->state & <API key>); if (res->state & (<API key> | <API key>)) { /* move it to the tail and keep going */ res->state &= ~DLM_LOCK_RES_DIRTY; spin_unlock(&res->spinlock); spin_unlock(&dlm->ast_lock); mlog(0, "%s: res %.*s, inprogress, delay list " "shuffle, state %d\n", dlm->name, res->lockname.len, res->lockname.name, res->state); delay = 1; goto in_progress; } /* at this point the lockres is not migrating/ * recovering/in-progress. we have the lockres * spinlock and do NOT have the dlm lock. * safe to reserve/queue asts and run the lists. */ /* called while holding lockres lock */ dlm_shuffle_lists(dlm, res); res->state &= ~DLM_LOCK_RES_DIRTY; spin_unlock(&res->spinlock); spin_unlock(&dlm->ast_lock); <API key>(dlm, res); in_progress: spin_lock(&dlm->spinlock); /* if the lock was in-progress, stick * it on the back of the list */ if (delay) { spin_lock(&res->spinlock); __dlm_dirty_lockres(dlm, res); spin_unlock(&res->spinlock); } dlm_lockres_put(res); /* unlikely, but we may need to give time to * other tasks */ if (!--n) { mlog(0, "%s: Throttling dlm thread\n", dlm->name); break; } } spin_unlock(&dlm->spinlock); dlm_flush_asts(dlm); /* yield and continue right away if there is more work to do */ if (!n) { cond_resched(); continue; } <API key>(dlm->dlm_thread_wq, !<API key>(dlm) || kthread_should_stop(), timeout); } mlog(0, "quitting DLM thread\n"); return 0; }
//>>built define("dijit/form/nls/pl/Textarea",({iframeEditTitle:"edycja obszaru",iframeFocusTitle:"edycja ramki obszaru"}));
<?php if ( !defined( 'MEDIAWIKI' ) ) die; class ThreadWatchView extends ThreadPermalinkView { }
#include <linux/kernel.h> #include <linux/errno.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/completion.h> #include <linux/sched.h> #include <linux/list.h> #include <linux/slab.h> #include <linux/ioctl.h> #include <linux/usb.h> #include <linux/usbdevice_fs.h> #include <linux/usb/hcd.h> #include <linux/usb/quirks.h> #include <linux/kthread.h> #include <linux/mutex.h> #include <linux/freezer.h> #include <linux/usb/otg.h> #include <linux/random.h> #include <asm/uaccess.h> #include <asm/byteorder.h> #include "usb.h" #if defined(<API key>) || defined(<API key>) #include <linux/usb/hcd.h> #include <linux/usb/ch11.h> int portno; int No_Data_Phase; EXPORT_SYMBOL(No_Data_Phase); int No_Status_Phase; EXPORT_SYMBOL(No_Status_Phase); unsigned char hub_tier; #define PDC_HOST_NOTIFY 0x8001 /*completion from core */ #define UNSUPPORTED_DEVICE 0x8099 #define UNWANTED_SUSPEND 0x8098 #define PDC_POWERMANAGEMENT 0x8097 int <API key>; EXPORT_SYMBOL(<API key>); int HostComplianceTest; EXPORT_SYMBOL(HostComplianceTest); int HostTest; EXPORT_SYMBOL(HostTest); #endif /* if we are in debug mode, always announce new devices */ #ifdef DEBUG #ifndef <API key> #define <API key> #endif #endif struct usb_hub { struct device *intfdev; /* the "interface" device */ struct usb_device *hdev; struct kref kref; struct urb *urb; /* for interrupt polling pipe */ /* buffer for urb ... with extra space in case of babble */ char (*buffer)[8]; union { struct usb_hub_status hub; struct usb_port_status port; } *status; /* buffer for status reports */ struct mutex status_mutex; /* for the status buffer */ int error; /* last reported error */ int nerrors; /* track consecutive errors */ struct list_head event_list; /* hubs w/data or errs ready */ unsigned long event_bits[1]; /* status change bitmask */ unsigned long change_bits[1]; /* ports with logical connect status change */ unsigned long busy_bits[1]; /* ports being reset or resumed */ unsigned long removed_bits[1]; /* ports with a "removed" device present */ unsigned long wakeup_bits[1]; /* ports that have signaled remote wakeup */ #if USB_MAXCHILDREN > 31 /* 8*sizeof(unsigned long) - 1 */ #error event_bits[] is too short! #endif struct usb_hub_descriptor *descriptor; /* class descriptor */ struct usb_tt tt; /* Transaction Translator */ unsigned mA_per_port; /* current for each child */ unsigned limited_power:1; unsigned quiescing:1; unsigned disconnected:1; unsigned has_indicators:1; u8 indicator[USB_MAXCHILDREN]; struct delayed_work leds; struct delayed_work init_work; void **port_owners; }; static inline int hub_is_superspeed(struct usb_device *hdev) { return (hdev->descriptor.bDeviceProtocol == USB_HUB_PR_SS); } /* Protect struct usb_device->state and ->children members * Note: Both are also protected by ->dev.sem, except that ->state can * change to <API key> even when the semaphore isn't held. */ static DEFINE_SPINLOCK(device_state_lock); /* khubd's worklist and its lock */ static DEFINE_SPINLOCK(hub_event_lock); static LIST_HEAD(hub_event_list); /* List of hubs needing servicing */ /* Wakes up khubd */ static <API key>(khubd_wait); static struct task_struct *khubd_task; /* cycle leds on hubs that aren't blinking for attention */ static bool blinkenlights = 0; module_param (blinkenlights, bool, S_IRUGO); MODULE_PARM_DESC (blinkenlights, "true to cycle leds on hubs"); /* * Device SATA8000 FW1.0 from DATAST0R Technology Corp requires about * 10 seconds to send reply for the initial 64-byte descriptor request. */ /* define initial 64-byte descriptor request timeout in milliseconds */ static int <API key> = <API key>; module_param(<API key>, int, S_IRUGO|S_IWUSR); MODULE_PARM_DESC(<API key>, "initial 64-byte descriptor request timeout in milliseconds " "(default 5000 - 5.0 seconds)"); /* * As of 2.6.10 we introduce a new USB device initialization scheme which * closely resembles the way Windows works. Hopefully it will be compatible * with a wider range of devices than the old scheme. However some previously * working devices may start giving rise to "device not accepting address" * errors; if that happens the user can try the old scheme by adjusting the * following module parameters. * * For maximum flexibility there are two boolean parameters to control the * hub driver's behavior. On the first initialization attempt, if the * "old_scheme_first" parameter is set then the old scheme will be used, * otherwise the new scheme is used. If that fails and "use_both_schemes" * is set, then the driver will make another attempt, using the other scheme. */ static bool old_scheme_first = 0; module_param(old_scheme_first, bool, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(old_scheme_first, "start with the old device initialization scheme"); static bool use_both_schemes = 1; module_param(use_both_schemes, bool, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(use_both_schemes, "try the other device initialization scheme if the " "first one fails"); /* Mutual exclusion for EHCI CF initialization. This interferes with * port reset on some companion controllers. */ DECLARE_RWSEM(<API key>); EXPORT_SYMBOL_GPL(<API key>); #define <API key> 1500 #define HUB_DEBOUNCE_STEP 25 #define HUB_DEBOUNCE_STABLE 100 static int <API key>(struct usb_device *udev); static inline char *portspeed(struct usb_hub *hub, int portstatus) { if (hub_is_superspeed(hub->hdev)) return "5.0 Gb/s"; if (portstatus & <API key>) return "480 Mb/s"; else if (portstatus & <API key>) return "1.5 Mb/s"; else return "12 Mb/s"; } /* Note that hdev or one of its children must be locked! */ static struct usb_hub *hdev_to_hub(struct usb_device *hdev) { if (!hdev || !hdev->actconfig) return NULL; return usb_get_intfdata(hdev->actconfig->interface[0]); } /* USB 2.0 spec Section 11.24.4.5 */ static int get_hub_descriptor(struct usb_device *hdev, void *data) { int i, ret, size; unsigned dtype; if (hub_is_superspeed(hdev)) { dtype = USB_DT_SS_HUB; size = USB_DT_SS_HUB_SIZE; } else { dtype = USB_DT_HUB; size = sizeof(struct usb_hub_descriptor); } for (i = 0; i < 3; i++) { ret = usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0), <API key>, USB_DIR_IN | USB_RT_HUB, dtype << 8, 0, data, size, <API key>); if (ret >= (<API key> + 2)) return ret; } return -EINVAL; } /* * USB 2.0 spec Section 11.24.2.1 */ static int clear_hub_feature(struct usb_device *hdev, int feature) { return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), <API key>, USB_RT_HUB, feature, 0, NULL, 0, 1000); } /* * USB 2.0 spec Section 11.24.2.2 */ static int clear_port_feature(struct usb_device *hdev, int port1, int feature) { return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), <API key>, USB_RT_PORT, feature, port1, NULL, 0, 1000); } /* * USB 2.0 spec Section 11.24.2.13 */ static int set_port_feature(struct usb_device *hdev, int port1, int feature) { return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), USB_REQ_SET_FEATURE, USB_RT_PORT, feature, port1, NULL, 0, 1000); } /* * USB 2.0 spec Section 11.24.2.7.1.10 and table 11-7 * for info about using port indicators */ static void set_port_led( struct usb_hub *hub, int port1, int selector ) { int status = set_port_feature(hub->hdev, (selector << 8) | port1, <API key>); if (status < 0) dev_dbg (hub->intfdev, "port %d indicator %s status %d\n", port1, ({ char *s; switch (selector) { case HUB_LED_AMBER: s = "amber"; break; case HUB_LED_GREEN: s = "green"; break; case HUB_LED_OFF: s = "off"; break; case HUB_LED_AUTO: s = "auto"; break; default: s = "??"; break; }; s; }), status); } #define LED_CYCLE_PERIOD ((2*HZ)/3) static void led_work (struct work_struct *work) { struct usb_hub *hub = container_of(work, struct usb_hub, leds.work); struct usb_device *hdev = hub->hdev; unsigned i; unsigned changed = 0; int cursor = -1; if (hdev->state != <API key> || hub->quiescing) return; for (i = 0; i < hub->descriptor->bNbrPorts; i++) { unsigned selector, mode; /* 30%-50% duty cycle */ switch (hub->indicator[i]) { /* cycle marker */ case INDICATOR_CYCLE: cursor = i; selector = HUB_LED_AUTO; mode = INDICATOR_AUTO; break; /* blinking green = sw attention */ case <API key>: selector = HUB_LED_GREEN; mode = <API key>; break; case <API key>: selector = HUB_LED_OFF; mode = <API key>; break; /* blinking amber = hw attention */ case <API key>: selector = HUB_LED_AMBER; mode = <API key>; break; case <API key>: selector = HUB_LED_OFF; mode = <API key>; break; /* blink green/amber = reserved */ case INDICATOR_ALT_BLINK: selector = HUB_LED_GREEN; mode = <API key>; break; case <API key>: selector = HUB_LED_AMBER; mode = INDICATOR_ALT_BLINK; break; default: continue; } if (selector != HUB_LED_AUTO) changed = 1; set_port_led(hub, i + 1, selector); hub->indicator[i] = mode; } if (!changed && blinkenlights) { cursor++; cursor %= hub->descriptor->bNbrPorts; set_port_led(hub, cursor + 1, HUB_LED_GREEN); hub->indicator[cursor] = INDICATOR_CYCLE; changed++; } if (changed) <API key>(&hub->leds, LED_CYCLE_PERIOD); } /* use a short timeout for hub/port status fetches */ #define USB_STS_TIMEOUT 1000 #define USB_STS_RETRIES 5 /* * USB 2.0 spec Section 11.24.2.6 */ static int get_hub_status(struct usb_device *hdev, struct usb_hub_status *data) { int i, status = -ETIMEDOUT; for (i = 0; i < USB_STS_RETRIES && (status == -ETIMEDOUT || status == -EPIPE); i++) { status = usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0), USB_REQ_GET_STATUS, USB_DIR_IN | USB_RT_HUB, 0, 0, data, sizeof(*data), USB_STS_TIMEOUT); } return status; } /* * USB 2.0 spec Section 11.24.2.7 */ static int get_port_status(struct usb_device *hdev, int port1, struct usb_port_status *data) { int i, status = -ETIMEDOUT; /* ISP1763A HUB sometimes returns 2 bytes instead of 4 bytes, retry * if this happens */ for (i = 0; i < USB_STS_RETRIES && (status == -ETIMEDOUT || status == -EPIPE || status == 2); i++) { status = usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0), USB_REQ_GET_STATUS, USB_DIR_IN | USB_RT_PORT, 0, port1, data, sizeof(*data), USB_STS_TIMEOUT); } return status; } static int hub_port_status(struct usb_hub *hub, int port1, u16 *status, u16 *change) { int ret; mutex_lock(&hub->status_mutex); ret = get_port_status(hub->hdev, port1, &hub->status->port); if (ret < 4) { dev_err(hub->intfdev, "%s failed (err = %d)\n", __func__, ret); if (ret >= 0) ret = -EIO; } else { *status = le16_to_cpu(hub->status->port.wPortStatus); *change = le16_to_cpu(hub->status->port.wPortChange); ret = 0; } mutex_unlock(&hub->status_mutex); return ret; } static void kick_khubd(struct usb_hub *hub) { unsigned long flags; spin_lock_irqsave(&hub_event_lock, flags); if (!hub->disconnected && list_empty(&hub->event_list)) { list_add_tail(&hub->event_list, &hub_event_list); /* Suppress autosuspend until khubd runs */ <API key>( to_usb_interface(hub->intfdev)); wake_up(&khubd_wait); } <API key>(&hub_event_lock, flags); } void usb_kick_khubd(struct usb_device *hdev) { struct usb_hub *hub = hdev_to_hub(hdev); if (hub) kick_khubd(hub); } /* * Let the USB core know that a USB 3.0 device has sent a Function Wake Device * Notification, which indicates it had initiated remote wakeup. * * USB 3.0 hubs do not report the port link state change from U3 to U0 when the * device initiates resume, so the USB core will not receive notice of the * resume through the normal hub interrupt URB. */ void <API key>(struct usb_device *hdev, unsigned int portnum) { struct usb_hub *hub; if (!hdev) return; hub = hdev_to_hub(hdev); if (hub) { set_bit(portnum, hub->wakeup_bits); kick_khubd(hub); } } EXPORT_SYMBOL_GPL(<API key>); /* completion function, fires on port status changes and various faults */ static void hub_irq(struct urb *urb) { struct usb_hub *hub = urb->context; int status = urb->status; unsigned i; unsigned long bits; switch (status) { case -ENOENT: /* synchronous unlink */ case -ECONNRESET: /* async unlink */ case -ESHUTDOWN: /* hardware going away */ return; default: /* presumably an error */ /* Cause a hub reset after 10 consecutive errors */ dev_dbg (hub->intfdev, "transfer --> %d\n", status); if ((++hub->nerrors < 10) || hub->error) goto resubmit; hub->error = status; /* FALL THROUGH */ /* let khubd handle things */ case 0: /* we got data: port status changed */ bits = 0; for (i = 0; i < urb->actual_length; ++i) bits |= ((unsigned long) ((*hub->buffer)[i])) << (i*8); hub->event_bits[0] = bits; break; } hub->nerrors = 0; /* Something happened, let khubd figure it out */ kick_khubd(hub); resubmit: if (hub->quiescing) return; if ((status = usb_submit_urb (hub->urb, GFP_ATOMIC)) != 0 && status != -ENODEV && status != -EPERM) dev_err (hub->intfdev, "resubmit --> %d\n", status); } /* USB 2.0 spec Section 11.24.2.3 */ static inline int hub_clear_tt_buffer (struct usb_device *hdev, u16 devinfo, u16 tt) { /* Need to clear both directions for control ep */ if (((devinfo >> 11) & <API key>) == <API key>) { int status = usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), HUB_CLEAR_TT_BUFFER, USB_RT_PORT, devinfo ^ 0x8000, tt, NULL, 0, 1000); if (status) return status; } return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), HUB_CLEAR_TT_BUFFER, USB_RT_PORT, devinfo, tt, NULL, 0, 1000); } /* * enumeration blocks khubd for a long time. we use keventd instead, since * long blocking there is the exception, not the rule. accordingly, HCDs * talking to TTs must queue control transfers (not just bulk and iso), so * both can talk to the same hub concurrently. */ static void hub_tt_work(struct work_struct *work) { struct usb_hub *hub = container_of(work, struct usb_hub, tt.clear_work); unsigned long flags; int limit = 100; spin_lock_irqsave (&hub->tt.lock, flags); while (!list_empty(&hub->tt.clear_list)) { struct list_head *next; struct usb_tt_clear *clear; struct usb_device *hdev = hub->hdev; const struct hc_driver *drv; int status; if (!hub->quiescing && --limit < 0) break; next = hub->tt.clear_list.next; clear = list_entry (next, struct usb_tt_clear, clear_list); list_del (&clear->clear_list); /* drop lock so HCD can concurrently report other TT errors */ <API key> (&hub->tt.lock, flags); status = hub_clear_tt_buffer (hdev, clear->devinfo, clear->tt); if (status) dev_err (&hdev->dev, "clear tt %d (%04x) error %d\n", clear->tt, clear->devinfo, status); /* Tell the HCD, even if the operation failed */ drv = clear->hcd->driver; if (drv-><API key>) (drv-><API key>)(clear->hcd, clear->ep); kfree(clear); spin_lock_irqsave(&hub->tt.lock, flags); } <API key> (&hub->tt.lock, flags); } /** * <API key> - clear control/bulk TT state in high speed hub * @urb: an URB associated with the failed or incomplete split transaction * * High speed HCDs use this to tell the hub driver that some split control or * bulk transaction failed in a way that requires clearing internal state of * a transaction translator. This is normally detected (and reported) from * interrupt context. * * It may not be possible for that hub to handle additional full (or low) * speed transactions until that state is fully cleared out. */ int <API key>(struct urb *urb) { struct usb_device *udev = urb->dev; int pipe = urb->pipe; struct usb_tt *tt = udev->tt; unsigned long flags; struct usb_tt_clear *clear; /* we've got to cope with an arbitrary number of pending TT clears, * since each TT has "at least two" buffers that can need it (and * there can be many TTs per hub). even if they're uncommon. */ if ((clear = kmalloc (sizeof *clear, GFP_ATOMIC)) == NULL) { dev_err (&udev->dev, "can't save CLEAR_TT_BUFFER state\n"); /* FIXME recover somehow ... RESET_TT? */ return -ENOMEM; } /* info that CLEAR_TT_BUFFER needs */ clear->tt = tt->multi ? udev->ttport : 1; clear->devinfo = usb_pipeendpoint (pipe); clear->devinfo |= udev->devnum << 4; clear->devinfo |= usb_pipecontrol (pipe) ? (<API key> << 11) : (<API key> << 11); if (usb_pipein (pipe)) clear->devinfo |= 1 << 15; /* info for completion callback */ clear->hcd = bus_to_hcd(udev->bus); clear->ep = urb->ep; /* tell keventd to clear state for this TT */ spin_lock_irqsave (&tt->lock, flags); list_add_tail (&clear->clear_list, &tt->clear_list); schedule_work(&tt->clear_work); <API key> (&tt->lock, flags); return 0; } EXPORT_SYMBOL_GPL(<API key>); /* If do_delay is false, return the number of milliseconds the caller * needs to delay. */ static unsigned hub_power_on(struct usb_hub *hub, bool do_delay) { int port1; unsigned pgood_delay = hub->descriptor->bPwrOn2PwrGood * 2; unsigned delay; u16 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); /* Enable power on each port. Some hubs have reserved values * of LPSM (> 2) in their descriptors, even though they are * USB 2.0 hubs. Some hubs do not implement port-power switching * but only emulate it. In all cases, the ports won't work * unless we send these messages to the hub. */ if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2) dev_dbg(hub->intfdev, "enabling power on all ports\n"); else dev_dbg(hub->intfdev, "trying to enable port power on " "non-switchable hub\n"); for (port1 = 1; port1 <= hub->descriptor->bNbrPorts; port1++) set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER); /* Wait at least 100 msec for power to become stable */ delay = max(pgood_delay, (unsigned) 100); if (do_delay) msleep(delay); return delay; } static int hub_hub_status(struct usb_hub *hub, u16 *status, u16 *change) { int ret; mutex_lock(&hub->status_mutex); ret = get_hub_status(hub->hdev, &hub->status->hub); if (ret < 0) dev_err (hub->intfdev, "%s failed (err = %d)\n", __func__, ret); else { *status = le16_to_cpu(hub->status->hub.wHubStatus); *change = le16_to_cpu(hub->status->hub.wHubChange); ret = 0; } mutex_unlock(&hub->status_mutex); return ret; } static int <API key>(struct usb_hub *hub, int port1, unsigned int link_status) { return set_port_feature(hub->hdev, port1 | (link_status << 3), <API key>); } /* * If USB 3.0 ports are placed into the Disabled state, they will no longer * detect any device connects or disconnects. This is generally not what the * USB core wants, since it expects a disabled port to produce a port status * change event when a new device connects. * * Instead, set the link state to Disabled, wait for the link to settle into * that state, clear any change bits, and then put the port into the RxDetect * state. */ static int <API key>(struct usb_hub *hub, int port1) { int ret; int total_time; u16 portchange, portstatus; if (!hub_is_superspeed(hub->hdev)) return -EINVAL; ret = <API key>(hub, port1, <API key>); if (ret) { dev_err(hub->intfdev, "cannot disable port %d (err = %d)\n", port1, ret); return ret; } /* Wait for the link to enter the disabled state. */ for (total_time = 0; ; total_time += HUB_DEBOUNCE_STEP) { ret = hub_port_status(hub, port1, &portstatus, &portchange); if (ret < 0) return ret; if ((portstatus & <API key>) == <API key>) break; if (total_time >= <API key>) break; msleep(HUB_DEBOUNCE_STEP); } if (total_time >= <API key>) dev_warn(hub->intfdev, "Could not disable port %d after %d ms\n", port1, total_time); return <API key>(hub, port1, <API key>); } static int hub_port_disable(struct usb_hub *hub, int port1, int set_state) { struct usb_device *hdev = hub->hdev; int ret = 0; if (hdev->children[port1-1] && set_state) <API key>(hdev->children[port1-1], <API key>); if (!hub->error) { if (hub_is_superspeed(hub->hdev)) ret = <API key>(hub, port1); else ret = clear_port_feature(hdev, port1, <API key>); } if (ret) dev_err(hub->intfdev, "cannot disable port %d (err = %d)\n", port1, ret); return ret; } /* * Disable a port and mark a logical connect-change event, so that some * time later khubd will disconnect() any existing usb_device on the port * and will re-enumerate if there actually is a device attached. */ static void <API key>(struct usb_hub *hub, int port1) { dev_dbg(hub->intfdev, "logical disconnect on port %d\n", port1); hub_port_disable(hub, port1, 1); /* FIXME let caller ask to power down the port: * - some devices won't enumerate without a VBUS power cycle * - SRP saves power that way * - ... new call, TBD ... * That's easy if this hub can switch power per-port, and * khubd reactivates the port later (timer, SRP, etc). * Powerdown must be optional, because of reset/DFU. */ set_bit(port1, hub->change_bits); kick_khubd(hub); } /** * usb_remove_device - disable a device's port on its parent hub * @udev: device to be disabled and removed * Context: @udev locked, must be able to sleep. * * After @udev's port has been disabled, khubd is notified and it will * see that the device has been disconnected. When the device is * physically unplugged and something is plugged in, the events will * be received and processed normally. */ int usb_remove_device(struct usb_device *udev) { struct usb_hub *hub; struct usb_interface *intf; if (!udev->parent) /* Can't remove a root hub */ return -EINVAL; hub = hdev_to_hub(udev->parent); intf = to_usb_interface(hub->intfdev); <API key>(intf); set_bit(udev->portnum, hub->removed_bits); <API key>(hub, udev->portnum); <API key>(intf); return 0; } enum hub_activation_type { HUB_INIT, HUB_INIT2, HUB_INIT3, /* INITs must come first */ HUB_POST_RESET, HUB_RESUME, HUB_RESET_RESUME, }; static void hub_init_func2(struct work_struct *ws); static void hub_init_func3(struct work_struct *ws); static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) { struct usb_device *hdev = hub->hdev; struct usb_hcd *hcd; int ret; int port1; int status; bool need_debounce_delay = false; unsigned delay; /* Continue a partial initialization */ if (type == HUB_INIT2) goto init2; if (type == HUB_INIT3) goto init3; /* The superspeed hub except for root hub has to use Hub Depth * value as an offset into the route string to locate the bits * it uses to determine the downstream port number. So hub driver * should send a set hub depth request to superspeed hub after * the superspeed hub is set configuration in initialization or * reset procedure. * * After a resume, port power should still be on. * For any other type of activation, turn it on. */ if (type != HUB_RESUME) { if (hdev->parent && hub_is_superspeed(hdev)) { ret = usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), HUB_SET_DEPTH, USB_RT_HUB, hdev->level - 1, 0, NULL, 0, <API key>); if (ret < 0) dev_err(hub->intfdev, "set hub depth failed\n"); } /* Speed up system boot by using a delayed_work for the * hub's initial power-up delays. This is pretty awkward * and the implementation looks like a home-brewed sort of * setjmp/longjmp, but it saves at least 100 ms for each * root hub (assuming usbcore is compiled into the kernel * rather than as a module). It adds up. * * This can't be done for HUB_RESUME or HUB_RESET_RESUME * because for those activation types the ports have to be * operational when we return. In theory this could be done * for HUB_POST_RESET, but it's easier not to. */ if (type == HUB_INIT) { delay = hub_power_on(hub, false); #ifdef CONFIG_USB_OTG if (hdev->bus->is_b_host) goto init2; #endif <API key>(&hub->init_work, hub_init_func2); <API key>(&hub->init_work, msecs_to_jiffies(delay)); /* Suppress autosuspend until init is done */ <API key>( to_usb_interface(hub->intfdev)); return; /* Continues at init2: below */ } else if (type == HUB_RESET_RESUME) { /* The internal host controller state for the hub device * may be gone after a host power loss on system resume. * Update the device's info so the HW knows it's a hub. */ hcd = bus_to_hcd(hdev->bus); if (hcd->driver->update_hub_device) { ret = hcd->driver->update_hub_device(hcd, hdev, &hub->tt, GFP_NOIO); if (ret < 0) { dev_err(hub->intfdev, "Host not " "accepting hub info " "update.\n"); dev_err(hub->intfdev, "LS/FS devices " "and hubs may not work " "under this hub\n."); } } hub_power_on(hub, true); } else { hub_power_on(hub, true); } } init2: /* Check each port and set hub->change_bits to let khubd know * which ports need attention. */ for (port1 = 1; port1 <= hdev->maxchild; ++port1) { struct usb_device *udev = hdev->children[port1-1]; u16 portstatus, portchange; portstatus = portchange = 0; status = hub_port_status(hub, port1, &portstatus, &portchange); if (udev || (portstatus & <API key>)) dev_dbg(hub->intfdev, "port %d: status %04x change %04x\n", port1, portstatus, portchange); /* After anything other than HUB_RESUME (i.e., initialization * or any sort of reset), every port should be disabled. * Unconnected ports should likewise be disabled (paranoia), * and so should ports for which we have no usb_device. */ if ((portstatus & <API key>) && ( type != HUB_RESUME || !(portstatus & <API key>) || !udev || udev->state == <API key>)) { /* * USB3 protocol ports will automatically transition * to Enabled state when detect an USB3.0 device attach. * Do not disable USB3 protocol ports. */ if (!hub_is_superspeed(hdev)) { clear_port_feature(hdev, port1, <API key>); portstatus &= ~<API key>; } else { /* Pretend that power was lost for USB3 devs */ portstatus &= ~<API key>; } } /* Clear status-change flags; we'll debounce later */ if (portchange & <API key>) { need_debounce_delay = true; clear_port_feature(hub->hdev, port1, <API key>); } if (portchange & <API key>) { need_debounce_delay = true; clear_port_feature(hub->hdev, port1, <API key>); } if (portchange & <API key>) { need_debounce_delay = true; clear_port_feature(hub->hdev, port1, <API key>); } if ((portchange & <API key>) && hub_is_superspeed(hub->hdev)) { need_debounce_delay = true; clear_port_feature(hub->hdev, port1, <API key>); } /* We can forget about a "removed" device when there's a * physical disconnect or the connect status changes. */ if (!(portstatus & <API key>) || (portchange & <API key>)) clear_bit(port1, hub->removed_bits); if (!udev || udev->state == <API key>) { /* Tell khubd to disconnect the device or * check for a new connection */ if (udev || (portstatus & <API key>)) set_bit(port1, hub->change_bits); } else if (portstatus & <API key>) { bool port_resumed = (portstatus & <API key>) == USB_SS_PORT_LS_U0; /* The power session apparently survived the resume. * If there was an overcurrent or suspend change * (i.e., remote wakeup request), have khubd * take care of it. Look at the port link state * for USB 3.0 hubs, since they don't have a suspend * change bit, and they don't set the port link change * bit on device-initiated resume. */ if (portchange || (hub_is_superspeed(hub->hdev) && port_resumed)) set_bit(port1, hub->change_bits); } else if (udev->persist_enabled) { #ifdef CONFIG_PM udev->reset_resume = 1; #endif set_bit(port1, hub->change_bits); } else { /* The power session is gone; tell khubd */ <API key>(udev, <API key>); set_bit(port1, hub->change_bits); } } /* If no port-status-change flags were set, we don't need any * debouncing. If flags were set we can try to debounce the * ports all at once right now, instead of letting khubd do them * one at a time later on. * * If any port-status changes do occur during this delay, khubd * will see them later and handle them normally. */ if (need_debounce_delay) { #ifdef CONFIG_USB_OTG if (hdev->bus->is_b_host && type == HUB_INIT) goto init3; #endif delay = HUB_DEBOUNCE_STABLE; /* Don't do a long sleep inside a workqueue routine */ if (type == HUB_INIT2) { <API key>(&hub->init_work, hub_init_func3); <API key>(&hub->init_work, msecs_to_jiffies(delay)); return; /* Continues at init3: below */ } else { msleep(delay); } } init3: hub->quiescing = 0; status = usb_submit_urb(hub->urb, GFP_NOIO); if (status < 0) dev_err(hub->intfdev, "activate --> %d\n", status); if (hub->has_indicators && blinkenlights) <API key>(&hub->leds, LED_CYCLE_PERIOD); /* Scan all ports that need attention */ kick_khubd(hub); /* Allow autosuspend if it was suppressed */ if (type <= HUB_INIT3) <API key>(to_usb_interface(hub->intfdev)); } /* Implement the continuations for the delays above */ static void hub_init_func2(struct work_struct *ws) { struct usb_hub *hub = container_of(ws, struct usb_hub, init_work.work); hub_activate(hub, HUB_INIT2); } static void hub_init_func3(struct work_struct *ws) { struct usb_hub *hub = container_of(ws, struct usb_hub, init_work.work); hub_activate(hub, HUB_INIT3); } enum hub_quiescing_type { HUB_DISCONNECT, HUB_PRE_RESET, HUB_SUSPEND }; static void hub_quiesce(struct usb_hub *hub, enum hub_quiescing_type type) { struct usb_device *hdev = hub->hdev; int i; <API key>(&hub->init_work); /* khubd and related activity won't re-trigger */ hub->quiescing = 1; if (type != HUB_SUSPEND) { /* Disconnect all the children */ for (i = 0; i < hdev->maxchild; ++i) { if (hdev->children[i]) usb_disconnect(&hdev->children[i]); } } /* Stop khubd and related activity */ usb_kill_urb(hub->urb); if (hub->has_indicators) <API key>(&hub->leds); if (hub->tt.hub) flush_work_sync(&hub->tt.clear_work); } /* caller has locked the hub device */ static int hub_pre_reset(struct usb_interface *intf) { struct usb_hub *hub = usb_get_intfdata(intf); hub_quiesce(hub, HUB_PRE_RESET); return 0; } /* caller has locked the hub device */ static int hub_post_reset(struct usb_interface *intf) { struct usb_hub *hub = usb_get_intfdata(intf); hub_activate(hub, HUB_POST_RESET); return 0; } static int hub_configure(struct usb_hub *hub, struct <API key> *endpoint) { struct usb_hcd *hcd; struct usb_device *hdev = hub->hdev; struct device *hub_dev = hub->intfdev; u16 hubstatus, hubchange; u16 wHubCharacteristics; unsigned int pipe; int maxp, ret; char *message = "out of memory"; hub->buffer = kmalloc(sizeof(*hub->buffer), GFP_KERNEL); if (!hub->buffer) { ret = -ENOMEM; goto fail; } hub->status = kmalloc(sizeof(*hub->status), GFP_KERNEL); if (!hub->status) { ret = -ENOMEM; goto fail; } mutex_init(&hub->status_mutex); hub->descriptor = kmalloc(sizeof(*hub->descriptor), GFP_KERNEL); if (!hub->descriptor) { ret = -ENOMEM; goto fail; } /* Request the entire hub descriptor. * hub->descriptor can handle USB_MAXCHILDREN ports, * but the hub can/will return fewer bytes here. */ ret = get_hub_descriptor(hdev, hub->descriptor); if (ret < 0) { message = "can't read hub descriptor"; goto fail; } else if (hub->descriptor->bNbrPorts > USB_MAXCHILDREN) { message = "hub has too many ports!"; ret = -ENODEV; goto fail; } hdev->maxchild = hub->descriptor->bNbrPorts; dev_info (hub_dev, "%d port%s detected\n", hdev->maxchild, (hdev->maxchild == 1) ? "" : "s"); hdev->children = kzalloc(hdev->maxchild * sizeof(struct usb_device *), GFP_KERNEL); hub->port_owners = kzalloc(hdev->maxchild * sizeof(void *), GFP_KERNEL); if (!hdev->children || !hub->port_owners) { ret = -ENOMEM; goto fail; } wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); /* FIXME for USB 3.0, skip for now */ if ((wHubCharacteristics & HUB_CHAR_COMPOUND) && !(hub_is_superspeed(hdev))) { int i; char portstr [USB_MAXCHILDREN + 1]; for (i = 0; i < hdev->maxchild; i++) portstr[i] = hub->descriptor->u.hs.DeviceRemovable [((i + 1) / 8)] & (1 << ((i + 1) % 8)) ? 'F' : 'R'; portstr[hdev->maxchild] = 0; dev_dbg(hub_dev, "compound device; port removable status: %s\n", portstr); } else dev_dbg(hub_dev, "standalone hub\n"); switch (wHubCharacteristics & HUB_CHAR_LPSM) { case <API key>: dev_dbg(hub_dev, "ganged power switching\n"); break; case <API key>: dev_dbg(hub_dev, "individual port power switching\n"); break; case HUB_CHAR_NO_LPSM: case HUB_CHAR_LPSM: dev_dbg(hub_dev, "no power switching (usb 1.0)\n"); break; } switch (wHubCharacteristics & HUB_CHAR_OCPM) { case <API key>: dev_dbg(hub_dev, "global over-current protection\n"); break; case <API key>: dev_dbg(hub_dev, "individual port over-current protection\n"); break; case HUB_CHAR_NO_OCPM: case HUB_CHAR_OCPM: dev_dbg(hub_dev, "no over-current protection\n"); break; } spin_lock_init (&hub->tt.lock); INIT_LIST_HEAD (&hub->tt.clear_list); INIT_WORK(&hub->tt.clear_work, hub_tt_work); switch (hdev->descriptor.bDeviceProtocol) { case USB_HUB_PR_FS: break; case <API key>: dev_dbg(hub_dev, "Single TT\n"); hub->tt.hub = hdev; break; case <API key>: ret = usb_set_interface(hdev, 0, 1); if (ret == 0) { dev_dbg(hub_dev, "TT per port\n"); hub->tt.multi = 1; } else dev_err(hub_dev, "Using single TT (err %d)\n", ret); hub->tt.hub = hdev; break; case USB_HUB_PR_SS: /* USB 3.0 hubs don't have a TT */ break; default: dev_dbg(hub_dev, "Unrecognized hub protocol %d\n", hdev->descriptor.bDeviceProtocol); break; } /* Note 8 FS bit times == (8 bits / 12000000 bps) ~= 666ns */ switch (wHubCharacteristics & HUB_CHAR_TTTT) { case HUB_TTTT_8_BITS: if (hdev->descriptor.bDeviceProtocol != 0) { hub->tt.think_time = 666; dev_dbg(hub_dev, "TT requires at most %d " "FS bit times (%d ns)\n", 8, hub->tt.think_time); } break; case HUB_TTTT_16_BITS: hub->tt.think_time = 666 * 2; dev_dbg(hub_dev, "TT requires at most %d " "FS bit times (%d ns)\n", 16, hub->tt.think_time); break; case HUB_TTTT_24_BITS: hub->tt.think_time = 666 * 3; dev_dbg(hub_dev, "TT requires at most %d " "FS bit times (%d ns)\n", 24, hub->tt.think_time); break; case HUB_TTTT_32_BITS: hub->tt.think_time = 666 * 4; dev_dbg(hub_dev, "TT requires at most %d " "FS bit times (%d ns)\n", 32, hub->tt.think_time); break; } /* probe() zeroes hub->indicator[] */ if (wHubCharacteristics & HUB_CHAR_PORTIND) { hub->has_indicators = 1; dev_dbg(hub_dev, "Port indicators are supported\n"); } dev_dbg(hub_dev, "power on to power good time: %dms\n", hub->descriptor->bPwrOn2PwrGood * 2); /* power budgeting mostly matters with bus-powered hubs, * and battery-powered root hubs (may provide just 8 mA). */ ret = usb_get_status(hdev, USB_RECIP_DEVICE, 0, &hubstatus); if (ret < 2) { message = "can't get hub status"; goto fail; } le16_to_cpus(&hubstatus); if (hdev == hdev->bus->root_hub) { if (hdev->bus_mA == 0 || hdev->bus_mA >= 500) hub->mA_per_port = 500; else { hub->mA_per_port = hdev->bus_mA; hub->limited_power = 1; } } else if ((hubstatus & (1 << <API key>)) == 0) { dev_dbg(hub_dev, "hub controller current requirement: %dmA\n", hub->descriptor->bHubContrCurrent); hub->limited_power = 1; if (hdev->maxchild > 0) { int remaining = hdev->bus_mA - hub->descriptor->bHubContrCurrent; if (remaining < hdev->maxchild * 100) dev_warn(hub_dev, "insufficient power available " "to use all downstream ports\n"); hub->mA_per_port = 100; /* 7.2.1.1 */ } } else { /* Self-powered external hub */ /* FIXME: What about battery-powered external hubs that * provide less current per port? */ hub->mA_per_port = 500; } if (hub->mA_per_port < 500) dev_dbg(hub_dev, "%umA bus power budget for each child\n", hub->mA_per_port); /* Update the HCD's internal representation of this hub before khubd * starts getting port status changes for devices under the hub. */ hcd = bus_to_hcd(hdev->bus); if (hcd->driver->update_hub_device) { ret = hcd->driver->update_hub_device(hcd, hdev, &hub->tt, GFP_KERNEL); if (ret < 0) { message = "can't update HCD hub info"; goto fail; } } ret = hub_hub_status(hub, &hubstatus, &hubchange); if (ret < 0) { message = "can't get hub status"; goto fail; } /* local power status reports aren't always correct */ if (hdev->actconfig->desc.bmAttributes & <API key>) dev_dbg(hub_dev, "local power source is %s\n", (hubstatus & <API key>) ? "lost (inactive)" : "good"); if ((wHubCharacteristics & HUB_CHAR_OCPM) == 0) dev_dbg(hub_dev, "%sover-current condition exists\n", (hubstatus & <API key>) ? "" : "no "); /* set up the interrupt endpoint * We use the EP's maxpacket size instead of (PORTS+1+7)/8 * bytes as USB2.0[11.12.3] says because some hubs are known * to send more data (and thus cause overflow). For root hubs, * maxpktsize is defined in hcd.c's fake endpoint descriptors * to be big enough for at least USB_MAXCHILDREN ports. */ pipe = usb_rcvintpipe(hdev, endpoint->bEndpointAddress); maxp = usb_maxpacket(hdev, pipe, usb_pipeout(pipe)); if (maxp > sizeof(*hub->buffer)) maxp = sizeof(*hub->buffer); hub->urb = usb_alloc_urb(0, GFP_KERNEL); if (!hub->urb) { ret = -ENOMEM; goto fail; } usb_fill_int_urb(hub->urb, hdev, pipe, *hub->buffer, maxp, hub_irq, hub, endpoint->bInterval); /* maybe cycle the hub leds */ if (hub->has_indicators && blinkenlights) hub->indicator [0] = INDICATOR_CYCLE; hub_activate(hub, HUB_INIT); return 0; fail: hdev->maxchild = 0; dev_err (hub_dev, "config failed, %s (err %d)\n", message, ret); /* hub_disconnect() frees urb and descriptor */ return ret; } static void hub_release(struct kref *kref) { struct usb_hub *hub = container_of(kref, struct usb_hub, kref); usb_put_intf(to_usb_interface(hub->intfdev)); kfree(hub); } static unsigned highspeed_hubs; static void hub_disconnect(struct usb_interface *intf) { struct usb_hub *hub = usb_get_intfdata(intf); struct usb_device *hdev = interface_to_usbdev(intf); /* Take the hub off the event list and don't let it be added again */ spin_lock_irq(&hub_event_lock); if (!list_empty(&hub->event_list)) { list_del_init(&hub->event_list); <API key>(intf); } hub->disconnected = 1; spin_unlock_irq(&hub_event_lock); /* Disconnect all children and quiesce the hub */ hub->error = 0; hub_quiesce(hub, HUB_DISCONNECT); usb_set_intfdata (intf, NULL); hub->hdev->maxchild = 0; if (hub->hdev->speed == USB_SPEED_HIGH) highspeed_hubs usb_free_urb(hub->urb); kfree(hdev->children); kfree(hub->port_owners); kfree(hub->descriptor); kfree(hub->status); kfree(hub->buffer); kref_put(&hub->kref, hub_release); } static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct usb_host_interface *desc; struct <API key> *endpoint; struct usb_device *hdev; struct usb_hub *hub; desc = intf->cur_altsetting; hdev = interface_to_usbdev(intf); /* * Hubs have proper suspend/resume support, except for root hubs * where the controller driver doesn't have bus_suspend and * bus_resume methods. */ if (hdev->parent) { /* normal device */ <API key>(hdev); } else { /* root hub */ const struct hc_driver *drv = bus_to_hcd(hdev->bus)->driver; if (drv->bus_suspend && drv->bus_resume) <API key>(hdev); } if (hdev->level == MAX_TOPO_LEVEL) { dev_err(&intf->dev, "Unsupported bus topology: hub nested too deep\n"); return -E2BIG; } #ifdef <API key> if (hdev->parent) { dev_warn(&intf->dev, "ignoring external hub\n"); otg_send_event(<API key>); return -ENODEV; } #endif /* Some hubs have a subclass of 1, which AFAICT according to the */ /* specs is not defined, but it works */ if ((desc->desc.bInterfaceSubClass != 0) && (desc->desc.bInterfaceSubClass != 1)) { descriptor_error: dev_err (&intf->dev, "bad descriptor, ignoring hub\n"); return -EIO; } /* Multiple endpoints? What kind of mutant ninja-hub is this? */ if (desc->desc.bNumEndpoints != 1) goto descriptor_error; endpoint = &desc->endpoint[0].desc; /* If it's not an interrupt in endpoint, we'd better punt! */ if (!<API key>(endpoint)) goto descriptor_error; /* We found a hub */ dev_info (&intf->dev, "USB hub found\n"); hub = kzalloc(sizeof(*hub), GFP_KERNEL); if (!hub) { dev_dbg (&intf->dev, "couldn't kmalloc hub struct\n"); return -ENOMEM; } kref_init(&hub->kref); INIT_LIST_HEAD(&hub->event_list); hub->intfdev = &intf->dev; hub->hdev = hdev; INIT_DELAYED_WORK(&hub->leds, led_work); INIT_DELAYED_WORK(&hub->init_work, NULL); usb_get_intf(intf); usb_set_intfdata (intf, hub); intf->needs_remote_wakeup = 1; if (hdev->speed == USB_SPEED_HIGH) highspeed_hubs++; if (hub_configure(hub, endpoint) >= 0) return 0; hub_disconnect (intf); return -ENODEV; } static int hub_ioctl(struct usb_interface *intf, unsigned int code, void *user_data) { struct usb_device *hdev = interface_to_usbdev (intf); /* assert ifno == 0 (part of hub spec) */ switch (code) { case <API key>: { struct <API key> *info = user_data; int i; spin_lock_irq(&device_state_lock); if (hdev->devnum <= 0) info->nports = 0; else { info->nports = hdev->maxchild; for (i = 0; i < info->nports; i++) { if (hdev->children[i] == NULL) info->port[i] = 0; else info->port[i] = hdev->children[i]->devnum; } } spin_unlock_irq(&device_state_lock); return info->nports + 1; } default: return -ENOSYS; } } /* * Allow user programs to claim ports on a hub. When a device is attached * to one of these "claimed" ports, the program will "own" the device. */ static int find_port_owner(struct usb_device *hdev, unsigned port1, void ***ppowner) { if (hdev->state == <API key>) return -ENODEV; if (port1 == 0 || port1 > hdev->maxchild) return -EINVAL; /* This assumes that devices not managed by the hub driver * will always have maxchild equal to 0. */ *ppowner = &(hdev_to_hub(hdev)->port_owners[port1 - 1]); return 0; } /* In the following three functions, the caller must hold hdev's lock */ int usb_hub_claim_port(struct usb_device *hdev, unsigned port1, void *owner) { int rc; void **powner; rc = find_port_owner(hdev, port1, &powner); if (rc) return rc; if (*powner) return -EBUSY; *powner = owner; return rc; } int <API key>(struct usb_device *hdev, unsigned port1, void *owner) { int rc; void **powner; rc = find_port_owner(hdev, port1, &powner); if (rc) return rc; if (*powner != owner) return -ENOENT; *powner = NULL; return rc; } void <API key>(struct usb_device *hdev, void *owner) { int n; void **powner; n = find_port_owner(hdev, 1, &powner); if (n == 0) { for (; n < hdev->maxchild; (++n, ++powner)) { if (*powner == owner) *powner = NULL; } } } /* The caller must hold udev's lock */ bool usb_device_is_owned(struct usb_device *udev) { struct usb_hub *hub; if (udev->state == <API key> || !udev->parent) return false; hub = hdev_to_hub(udev->parent); return !!hub->port_owners[udev->portnum - 1]; } static void <API key>(struct usb_device *udev) { int i; for (i = 0; i < udev->maxchild; ++i) { if (udev->children[i]) <API key>(udev->children[i]); } if (udev->state == USB_STATE_SUSPENDED) udev->active_duration -= jiffies; udev->state = <API key>; } /** * <API key> - change a device's current state (usbcore, hcds) * @udev: pointer to device whose state should be changed * @new_state: new state value to be stored * * udev->state is _not_ fully protected by the device lock. Although * most transitions are made only while holding the lock, the state can * can change to <API key> at almost any time. This * is so that devices can be marked as disconnected as soon as possible, * without having to wait for any semaphores to be released. As a result, * all changes to any device's state must be protected by the * device_state_lock spinlock. * * Once a device has been added to the device tree, all changes to its state * should be made using this routine. The state should _not_ be set directly. * * If udev->state is already <API key> then no change is made. * Otherwise udev->state is set to new_state, and if new_state is * <API key> then all of udev's descendants' states are also set * to <API key>. */ void <API key>(struct usb_device *udev, enum usb_device_state new_state) { unsigned long flags; int wakeup = -1; spin_lock_irqsave(&device_state_lock, flags); if (udev->state == <API key>) ; /* do nothing */ else if (new_state != <API key>) { /* root hub wakeup capabilities are managed out-of-band * and may involve silicon errata ... ignore them here. */ if (udev->parent) { if (udev->state == USB_STATE_SUSPENDED || new_state == USB_STATE_SUSPENDED) ; /* No change to wakeup settings */ else if (new_state == <API key>) wakeup = udev->actconfig->desc.bmAttributes & <API key>; else wakeup = 0; } if (udev->state == USB_STATE_SUSPENDED && new_state != USB_STATE_SUSPENDED) udev->active_duration -= jiffies; else if (new_state == USB_STATE_SUSPENDED && udev->state != USB_STATE_SUSPENDED) udev->active_duration += jiffies; udev->state = new_state; } else <API key>(udev); <API key>(&device_state_lock, flags); if (wakeup >= 0) <API key>(&udev->dev, wakeup); } EXPORT_SYMBOL_GPL(<API key>); /* * Choose a device number. * * Device numbers are used as filenames in usbfs. On USB-1.1 and * USB-2.0 buses they are also used as device addresses, however on * USB-3.0 buses the address is assigned by the controller hardware * and it usually is not the same as the device number. * * WUSB devices are simple: they have no hubs behind, so the mapping * device <-> virtual port number becomes 1:1. Why? to simplify the * life of the device connection logic in * drivers/usb/wusbcore/devconnect.c. When we do the initial secret * handshake we need to assign a temporary address in the unauthorized * space. For simplicity we use the first virtual port number found to * be free [drivers/usb/wusbcore/devconnect.c:<API key>()] * and that becomes it's address [X < 128] or its unauthorized address * [X | 0x80]. * * We add 1 as an offset to the one-based USB-stack port number * (zero-based wusb virtual port index) for two reasons: (a) dev addr * 0 is reserved by USB for default address; (b) Linux's USB stack * uses always #1 for the root hub of the controller. So USB stack's * port #1, which is wusb virtual-port #0 has address #2. * * Devices connected under xHCI are not as simple. The host controller * supports virtualization, so the hardware assigns device addresses and * the HCD must setup data structures before issuing a set address * command to the hardware. */ static void choose_devnum(struct usb_device *udev) { int devnum; struct usb_bus *bus = udev->bus; /* If khubd ever becomes multithreaded, this will need a lock */ if (udev->wusb) { devnum = udev->portnum + 1; BUG_ON(test_bit(devnum, bus->devmap.devicemap)); } else { /* Try to allocate the next devnum beginning at * bus->devnum_next. */ devnum = find_next_zero_bit(bus->devmap.devicemap, 128, bus->devnum_next); if (devnum >= 128) devnum = find_next_zero_bit(bus->devmap.devicemap, 128, 1); bus->devnum_next = ( devnum >= 127 ? 1 : devnum + 1); } if (devnum < 128) { set_bit(devnum, bus->devmap.devicemap); udev->devnum = devnum; } } static void release_devnum(struct usb_device *udev) { if (udev->devnum > 0) { clear_bit(udev->devnum, udev->bus->devmap.devicemap); udev->devnum = -1; } } static void update_devnum(struct usb_device *udev, int devnum) { /* The address for a WUSB device is managed by wusbcore. */ if (!udev->wusb) udev->devnum = devnum; } static void hub_free_dev(struct usb_device *udev) { struct usb_hcd *hcd = bus_to_hcd(udev->bus); /* Root hubs aren't real devices, so don't free HCD resources */ if (hcd->driver->free_dev && udev->parent) hcd->driver->free_dev(hcd, udev); } /** * usb_disconnect - disconnect a device (usbcore-internal) * @pdev: pointer to device being disconnected * Context: !in_interrupt () * * Something got disconnected. Get rid of it and all of its children. * * If *pdev is a normal device then the parent hub must already be locked. * If *pdev is a root hub then this routine will acquire the * usb_bus_list_lock on behalf of the caller. * * Only hub drivers (including virtual root hub drivers for host * controllers) should ever call this. * * This call is synchronous, and may not be used in an interrupt context. */ void usb_disconnect(struct usb_device **pdev) { struct usb_device *udev = *pdev; int i; /* mark the device as inactive, so any further urb submissions for * this device (and any of its children) will fail immediately. * this quiesces everything except pending urbs. */ <API key>(udev, <API key>); dev_info(&udev->dev, "USB disconnect, device number %d\n", udev->devnum); #ifdef CONFIG_USB_OTG if (udev->bus->hnp_support && udev->portnum == udev->bus->otg_port) { <API key>(&udev->bus->hnp_polling); udev->bus->hnp_support = 0; } #endif usb_lock_device(udev); /* Free up all the children before we remove this device */ for (i = 0; i < udev->maxchild; i++) { if (udev->children[i]) usb_disconnect(&udev->children[i]); } /* deallocate hcd/hardware state ... nuking all pending urbs and * cleaning up all state associated with the current configuration * so that the hardware is now fully quiesced. */ dev_dbg (&udev->dev, "unregistering device\n"); usb_disable_device(udev, 0); <API key>(udev); usb_remove_ep_devs(&udev->ep0); usb_unlock_device(udev); /* Unregister the device. The device driver is responsible * for de-configuring the device and invoking the remove-device * notifier chain (used by usbfs and possibly others). */ device_del(&udev->dev); /* Free the device number and delete the parent's children[] * (or root_hub) pointer. */ release_devnum(udev); /* Avoid races with <API key>() */ spin_lock_irq(&device_state_lock); *pdev = NULL; spin_unlock_irq(&device_state_lock); hub_free_dev(udev); put_device(&udev->dev); } #ifdef <API key> static void show_string(struct usb_device *udev, char *id, char *string) { if (!string) return; dev_printk(KERN_INFO, &udev->dev, "%s: %s\n", id, string); } static void announce_device(struct usb_device *udev) { dev_info(&udev->dev, "New USB device found, idVendor=%04x, idProduct=%04x\n", le16_to_cpu(udev->descriptor.idVendor), le16_to_cpu(udev->descriptor.idProduct)); dev_info(&udev->dev, "New USB device strings: Mfr=%d, Product=%d, SerialNumber=%d\n", udev->descriptor.iManufacturer, udev->descriptor.iProduct, udev->descriptor.iSerialNumber); show_string(udev, "Product", udev->product); show_string(udev, "Manufacturer", udev->manufacturer); show_string(udev, "SerialNumber", udev->serial); } #else static inline void announce_device(struct usb_device *udev) { } #endif #ifdef CONFIG_USB_OTG #include "otg_whitelist.h" #endif /** * <API key> - FIXME (usbcore-internal) * @udev: newly addressed device (in ADDRESS state) * * Finish enumeration for On-The-Go devices */ static int <API key>(struct usb_device *udev) { int err = 0; #ifdef CONFIG_USB_OTG bool old_otg = false; /* * OTG-aware devices on OTG-capable root hubs may be able to use SRP, * to wake us after we've powered off VBUS; and HNP, switching roles * "host" to "peripheral". The OTG descriptor helps figure this out. */ if (!udev->bus->is_b_host && udev->config && udev->parent == udev->bus->root_hub) { struct usb_otg_descriptor *desc = NULL; struct usb_bus *bus = udev->bus; /* descriptor may appear anywhere in config */ if (<API key> (udev->rawdescriptors[0], le16_to_cpu(udev->config[0].desc.wTotalLength), USB_DT_OTG, (void **) &desc) == 0) { if (desc->bmAttributes & USB_OTG_HNP) { unsigned port1 = udev->portnum; dev_info(&udev->dev, "Dual-Role OTG device on %sHNP port\n", (port1 == bus->otg_port) ? "" : "non-"); /* a_alt_hnp_support is obsoleted */ if (port1 != bus->otg_port) goto out; bus->hnp_support = 1; /* a_hnp_support is not required for devices * compliant to revision 2.0 or subsequent * versions. */ if ((le16_to_cpu(desc->bLength) == USB_DT_OTG_SIZE) && le16_to_cpu(desc->bcdOTG) >= 0x0200) goto out; /* Legacy B-device i.e compliant to spec * revision 1.3 expect A-device to set * a_hnp_support or b_hnp_enable before * selecting configuration. */ old_otg = true; /* enable HNP before suspend, it's simpler */ err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), USB_REQ_SET_FEATURE, 0, <API key>, 0, NULL, 0, <API key>); if (err < 0) { /* OTG MESSAGE: report errors here, * customize to match your product. */ dev_info(&udev->dev, "can't set HNP mode: %d\n", err); bus->hnp_support = 0; } } } } out: if ((udev->quirks & USB_QUIRK_OTG_PET)) { if (le16_to_cpu(udev->descriptor.bcdDevice) & OTG_TTST_VBUS_OFF) udev->bus->otg_vbus_off = 1; if (udev->bus->is_b_host || old_otg) udev->bus->quick_hnp = 1; } if (!is_targeted(udev)) { otg_send_event(<API key>); /* Maybe it can talk to us, though we can't talk to it. * (Includes HNP test device.) */ if (udev->bus->hnp_support) { err = usb_port_suspend(udev, PMSG_SUSPEND); if (err < 0) dev_dbg(&udev->dev, "HNP fail, %d\n", err); } err = -ENOTSUPP; } else if (udev->bus->hnp_support && udev->portnum == udev->bus->otg_port) { /* HNP polling is introduced in OTG supplement Rev 2.0 * and older devices may not support. Work is not * re-armed if device returns STALL. B-Host also perform * HNP polling. */ if (udev->bus->quick_hnp) <API key>(&udev->bus->hnp_polling, msecs_to_jiffies(OTG_TTST_SUSP)); else <API key>(&udev->bus->hnp_polling, msecs_to_jiffies(THOST_REQ_POLL)); } #endif return err; } /** * <API key> - Read device configs/intfs/otg (usbcore-internal) * @udev: newly addressed device (in ADDRESS state) * * This is only called by usb_new_device() and <API key>() * and FIXME -- all comments that apply to them apply here wrt to * environment. * * If the device is WUSB and not authorized, we don't attempt to read * the string descriptors, as they will be errored out by the device * until it has been authorized. */ static int <API key>(struct usb_device *udev) { int err; if (udev->config == NULL) { err = <API key>(udev); if (err < 0) { dev_err(&udev->dev, "can't read configurations, error %d\n", err); return err; } } /* read the standard strings and cache them if present */ udev->product = usb_cache_string(udev, udev->descriptor.iProduct); udev->manufacturer = usb_cache_string(udev, udev->descriptor.iManufacturer); udev->serial = usb_cache_string(udev, udev->descriptor.iSerialNumber); err = <API key>(udev); if (err < 0) return err; <API key>(udev); return 0; } static void <API key>(struct usb_device *udev) { struct usb_device *hdev = udev->parent; struct usb_hub *hub; u8 port = udev->portnum; u16 wHubCharacteristics; bool removable = true; if (!hdev) return; hub = hdev_to_hub(udev->parent); wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); if (!(wHubCharacteristics & HUB_CHAR_COMPOUND)) return; if (hub_is_superspeed(hdev)) { if (hub->descriptor->u.ss.DeviceRemovable & (1 << port)) removable = false; } else { if (hub->descriptor->u.hs.DeviceRemovable[port / 8] & (1 << (port % 8))) removable = false; } if (removable) udev->removable = <API key>; else udev->removable = USB_DEVICE_FIXED; } /** * usb_new_device - perform initial device setup (usbcore-internal) * @udev: newly addressed device (in ADDRESS state) * * This is called with devices which have been detected but not fully * enumerated. The device descriptor is available, but not descriptors * for any device configuration. The caller must have locked either * the parent hub (if udev is a normal device) or else the * usb_bus_list_lock (if udev is a root hub). The parent's pointer to * udev has already been installed, but udev is not yet visible through * sysfs or other filesystem code. * * It will return if the device is configured properly or not. Zero if * the interface was registered with the driver core; else a negative * errno value. * * This call is synchronous, and may not be used in an interrupt context. * * Only the hub driver or root-hub registrar should ever call this. */ int usb_new_device(struct usb_device *udev) { int err; if (udev->parent) { /* Initialize non-root-hub device wakeup to disabled; * device (un)configuration controls wakeup capable * sysfs power/wakeup controls wakeup enabled/disabled */ device_init_wakeup(&udev->dev, 0); } /* Tell the runtime-PM framework the device is active */ <API key>(&udev->dev); <API key>(&udev->dev); <API key>(&udev->dev); pm_runtime_enable(&udev->dev); /* By default, forbid autosuspend for all devices. It will be * allowed for hubs during binding. */ <API key>(udev); err = <API key>(udev); /* Read descriptors */ if (err < 0) goto fail; dev_dbg(&udev->dev, "udev %d, busnum %d, minor = %d\n", udev->devnum, udev->bus->busnum, (((udev->bus->busnum-1) * 128) + (udev->devnum-1))); /* export the usbdev device-node for libusb */ udev->dev.devt = MKDEV(USB_DEVICE_MAJOR, (((udev->bus->busnum-1) * 128) + (udev->devnum-1))); /* Tell the world! */ announce_device(udev); if (udev->serial) <API key>(udev->serial, strlen(udev->serial)); if (udev->product) <API key>(udev->product, strlen(udev->product)); if (udev->manufacturer) <API key>(udev->manufacturer, strlen(udev->manufacturer)); <API key>(&udev->dev); /* * check whether the hub marks this port as non-removable. Do it * now so that platform-specific data can override it in * device_add() */ if (udev->parent) <API key>(udev); /* Register the device. The device driver is responsible * for configuring the device and invoking the add-device * notifier chain (used by usbfs and possibly others). */ err = device_add(&udev->dev); if (err) { dev_err(&udev->dev, "can't device_add, error %d\n", err); goto fail; } (void) usb_create_ep_devs(&udev->dev, &udev->ep0, udev); usb_mark_last_busy(udev); <API key>(&udev->dev); return err; fail: <API key>(udev, <API key>); pm_runtime_disable(&udev->dev); <API key>(&udev->dev); return err; } /** * <API key> - deauthorize a device (usbcore-internal) * @usb_dev: USB device * * Move the USB device to a very basic state where interfaces are disabled * and the device is in fact unconfigured and unusable. * * We share a lock (that we have) with device_del(), so we need to * defer its call. */ int <API key>(struct usb_device *usb_dev) { usb_lock_device(usb_dev); if (usb_dev->authorized == 0) goto out_unauthorized; usb_dev->authorized = 0; <API key>(usb_dev, -1); out_unauthorized: usb_unlock_device(usb_dev); return 0; } int <API key>(struct usb_device *usb_dev) { int result = 0, c; usb_lock_device(usb_dev); if (usb_dev->authorized == 1) goto out_authorized; result = <API key>(usb_dev); if (result < 0) { dev_err(&usb_dev->dev, "can't autoresume for authorization: %d\n", result); goto error_autoresume; } result = <API key>(usb_dev, sizeof(usb_dev->descriptor)); if (result < 0) { dev_err(&usb_dev->dev, "can't re-read device descriptor for " "authorization: %d\n", result); goto <API key>; } usb_dev->authorized = 1; /* Choose and set the configuration. This registers the interfaces * with the driver core and lets interface drivers bind to them. */ c = <API key>(usb_dev); if (c >= 0) { result = <API key>(usb_dev, c); if (result) { dev_err(&usb_dev->dev, "can't set config #%d, error %d\n", c, result); /* This need not be fatal. The user can try to * set other configurations. */ } } dev_info(&usb_dev->dev, "authorized to connect\n"); <API key>: <API key>(usb_dev); error_autoresume: out_authorized: usb_unlock_device(usb_dev); // complements locktree return result; } /* Returns 1 if @hub is a WUSB root hub, 0 otherwise */ static unsigned hub_is_wusb(struct usb_hub *hub) { struct usb_hcd *hcd; if (hub->hdev->parent != NULL) /* not a root hub? */ return 0; hcd = container_of(hub->hdev->bus, struct usb_hcd, self); return hcd->wireless; } #define PORT_RESET_TRIES 5 #define SET_ADDRESS_TRIES 2 #define <API key> 2 #define SET_CONFIG_TRIES (2 * (use_both_schemes + 1)) #define USE_NEW_SCHEME(i) ((i) / 2 == (int)old_scheme_first) #define HUB_ROOT_RESET_TIME 50 /* times are in msec */ #define <API key> 10 #define HUB_BH_RESET_TIME 50 #define HUB_LONG_RESET_TIME 200 #define HUB_RESET_TIMEOUT 800 static int hub_port_reset(struct usb_hub *hub, int port1, struct usb_device *udev, unsigned int delay, bool warm); /* Is a USB 3.0 port in the Inactive or Complinance Mode state? * Port worm reset is required to recover */ static bool <API key>(struct usb_hub *hub, u16 portstatus) { return hub_is_superspeed(hub->hdev) && (((portstatus & <API key>) == <API key>) || ((portstatus & <API key>) == <API key>)) ; } static int hub_port_wait_reset(struct usb_hub *hub, int port1, struct usb_device *udev, unsigned int delay, bool warm) { int delay_time, ret; u16 portstatus; u16 portchange; for (delay_time = 0; delay_time < HUB_RESET_TIMEOUT; delay_time += delay) { /* wait to give the device a chance to reset */ msleep(delay); /* read and decode port status */ ret = hub_port_status(hub, port1, &portstatus, &portchange); if (ret < 0) return ret; /* The port state is unknown until the reset completes. */ if ((portstatus & USB_PORT_STAT_RESET)) goto delay; if (<API key>(hub, portstatus)) return -ENOTCONN; /* Device went away? */ if (!(portstatus & <API key>)) return -ENOTCONN; /* bomb out completely if the connection bounced. A USB 3.0 * connection may bounce if multiple warm resets were issued, * but the device may have successfully re-connected. Ignore it. */ if (!hub_is_superspeed(hub->hdev) && (portchange & <API key>)) return -ENOTCONN; if ((portstatus & <API key>)) { if (!udev) return 0; if (hub_is_wusb(hub)) udev->speed = USB_SPEED_WIRELESS; else if (hub_is_superspeed(hub->hdev)) udev->speed = USB_SPEED_SUPER; else if (portstatus & <API key>) udev->speed = USB_SPEED_HIGH; else if (portstatus & <API key>) udev->speed = USB_SPEED_LOW; else udev->speed = USB_SPEED_FULL; return 0; } delay: /* switch to the long delay after two short delay failures */ if (delay_time >= 2 * <API key>) delay = HUB_LONG_RESET_TIME; dev_dbg (hub->intfdev, "port %d not %sreset yet, waiting %dms\n", port1, warm ? "warm " : "", delay); } return -EBUSY; } static void <API key>(struct usb_hub *hub, int port1, struct usb_device *udev, int *status) { switch (*status) { case 0: /* TRSTRCY = 10 ms; plus some extra */ msleep(10 + 40); if (udev) { struct usb_hcd *hcd = bus_to_hcd(udev->bus); update_devnum(udev, 0); /* The xHC may think the device is already reset, * so ignore the status. */ if (hcd->driver->reset_device) hcd->driver->reset_device(hcd, udev); } /* FALL THROUGH */ case -ENOTCONN: case -ENODEV: clear_port_feature(hub->hdev, port1, <API key>); if (hub_is_superspeed(hub->hdev)) { clear_port_feature(hub->hdev, port1, <API key>); clear_port_feature(hub->hdev, port1, <API key>); clear_port_feature(hub->hdev, port1, <API key>); } if (udev) <API key>(udev, *status ? <API key> : USB_STATE_DEFAULT); break; } } /* Handle port reset and port warm(BH) reset (for USB3 protocol ports) */ static int hub_port_reset(struct usb_hub *hub, int port1, struct usb_device *udev, unsigned int delay, bool warm) { int i, status; u16 portchange, portstatus; if (!hub_is_superspeed(hub->hdev)) { if (warm) { dev_err(hub->intfdev, "only USB3 hub support " "warm reset\n"); return -EINVAL; } /* Block EHCI CF initialization during the port reset. * Some companion controllers don't like it when they mix. */ down_read(&<API key>); } else if (!warm) { /* * If the caller hasn't explicitly requested a warm reset, * double check and see if one is needed. */ status = hub_port_status(hub, port1, &portstatus, &portchange); if (status < 0) goto done; if (<API key>(hub, portstatus)) warm = true; } /* Reset the port */ for (i = 0; i < PORT_RESET_TRIES; i++) { status = set_port_feature(hub->hdev, port1, (warm ? <API key> : USB_PORT_FEAT_RESET)); if (status) { dev_err(hub->intfdev, "cannot %sreset port %d (err = %d)\n", warm ? "warm " : "", port1, status); } else { status = hub_port_wait_reset(hub, port1, udev, delay, warm); if (status && status != -ENOTCONN) dev_dbg(hub->intfdev, "port_wait_reset: err = %d\n", status); } /* Check for disconnect or reset */ if (status == 0 || status == -ENOTCONN || status == -ENODEV) { <API key>(hub, port1, udev, &status); if (!hub_is_superspeed(hub->hdev)) goto done; /* * If a USB 3.0 device migrates from reset to an error * state, re-issue the warm reset. */ if (hub_port_status(hub, port1, &portstatus, &portchange) < 0) goto done; if (!<API key>(hub, portstatus)) goto done; /* * If the port is in SS.Inactive or Compliance Mode, the * hot or warm reset failed. Try another warm reset. */ if (!warm) { dev_dbg(hub->intfdev, "hot reset failed, warm reset port %d\n", port1); warm = true; } } dev_dbg (hub->intfdev, "port %d not enabled, trying %sreset again...\n", port1, warm ? "warm " : ""); delay = HUB_LONG_RESET_TIME; } dev_err (hub->intfdev, "Cannot enable port %i. Maybe the USB cable is bad?\n", port1); done: if (!hub_is_superspeed(hub->hdev)) up_read(&<API key>); return status; } /* Check if a port is power on */ static int port_is_power_on(struct usb_hub *hub, unsigned portstatus) { int ret = 0; if (hub_is_superspeed(hub->hdev)) { if (portstatus & <API key>) ret = 1; } else { if (portstatus & USB_PORT_STAT_POWER) ret = 1; } return ret; } #ifdef CONFIG_PM /* Check if a port is suspended(USB2.0 port) or in U3 state(USB3.0 port) */ static int port_is_suspended(struct usb_hub *hub, unsigned portstatus) { int ret = 0; if (hub_is_superspeed(hub->hdev)) { if ((portstatus & <API key>) == USB_SS_PORT_LS_U3) ret = 1; } else { if (portstatus & <API key>) ret = 1; } return ret; } /* Determine whether the device on a port is ready for a normal resume, * is ready for a reset-resume, or should be disconnected. */ static int <API key>(struct usb_device *udev, struct usb_hub *hub, int port1, int status, unsigned portchange, unsigned portstatus) { /* Is the device still present? */ if (status || port_is_suspended(hub, portstatus) || !port_is_power_on(hub, portstatus) || !(portstatus & <API key>)) { if (status >= 0) status = -ENODEV; } /* Can't do a normal resume if the port isn't enabled, * so try a reset-resume instead. */ else if (!(portstatus & <API key>) && !udev->reset_resume) { if (udev->persist_enabled) udev->reset_resume = 1; else status = -ENODEV; } if (status) { dev_dbg(hub->intfdev, "port %d status %04x.%04x after resume, %d\n", port1, portchange, portstatus, status); } else if (udev->reset_resume) { /* Late port handoff can set status-change bits */ if (portchange & <API key>) clear_port_feature(hub->hdev, port1, <API key>); if (portchange & <API key>) clear_port_feature(hub->hdev, port1, <API key>); } return status; } #ifdef CONFIG_USB_SUSPEND /* * <API key> - disable usb3.0 * device's function remote wakeup * @udev: target device * * Assume there's only one function on the USB 3.0 * device and disable remote wake for the first * interface. FIXME if the interface association * descriptor shows there's more than one function. */ static int <API key>(struct usb_device *udev) { return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), <API key>, USB_RECIP_INTERFACE, <API key>, 0, NULL, 0, <API key>); } /* * usb_port_suspend - suspend a usb device's upstream port * @udev: device that's no longer in active use, not a root hub * Context: must be able to sleep; device not locked; pm locks held * * Suspends a USB device that isn't in active use, conserving power. * Devices may wake out of a suspend, if anything important happens, * using the remote wakeup mechanism. They may also be taken out of * suspend by the host, using usb_port_resume(). It's also routine * to disconnect devices while they are suspended. * * This only affects the USB hardware for a device; its interfaces * (and, for hubs, child devices) must already have been suspended. * * Selective port suspend reduces power; most suspended devices draw * less than 500 uA. It's also used in OTG, along with remote wakeup. * All devices below the suspended port are also suspended. * * Devices leave suspend state when the host wakes them up. Some devices * also support "remote wakeup", where the device can activate the USB * tree above them to deliver data, such as a keypress or packet. In * some cases, this wakes the USB host. * * Suspending OTG devices may trigger HNP, if that's been enabled * between a pair of dual-role devices. That will change roles, such * as from A-Host to A-Peripheral or from B-Host back to B-Peripheral. * * Devices on USB hub ports have only one "suspend" state, corresponding * to ACPI D2, "may cause the device to lose some context". * State transitions include: * * - suspend, resume ... when the VBUS power link stays live * - suspend, disconnect ... VBUS lost * * Once VBUS drop breaks the circuit, the port it's using has to go through * normal re-enumeration procedures, starting with enabling VBUS power. * Other than re-initializing the hub (plug/unplug, except for root hubs), * Linux (2.6) currently has NO mechanisms to initiate that: no khubd * timer, no SRP, no requests through sysfs. * * If CONFIG_USB_SUSPEND isn't enabled, devices only really suspend when * the root hub for their bus goes into global suspend ... so we don't * (falsely) update the device power state to say it suspended. * * Returns 0 on success, else negative errno. */ int usb_port_suspend(struct usb_device *udev, pm_message_t msg) { struct usb_hub *hub = hdev_to_hub(udev->parent); int port1 = udev->portnum; int status; /* enable remote wakeup when appropriate; this lets the device * wake up the upstream hub (including maybe the root hub). * * NOTE: OTG devices may issue remote wakeup (or SRP) even when * we don't explicitly enable it here. */ if (udev->do_remote_wakeup) { if (!hub_is_superspeed(hub->hdev)) { status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, <API key>, 0, NULL, 0, <API key>); } else { /* Assume there's only one function on the USB 3.0 * device and enable remote wake for the first * interface. FIXME if the interface association * descriptor shows there's more than one function. */ status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), USB_REQ_SET_FEATURE, USB_RECIP_INTERFACE, <API key>, <API key> | <API key>, NULL, 0, <API key>); } if (status) { dev_dbg(&udev->dev, "won't remote wakeup, status %d\n", status); /* bail if autosuspend is requested */ if (PMSG_IS_AUTO(msg)) return status; } } #ifdef CONFIG_USB_OTG if (!udev->bus->is_b_host && udev->bus->hnp_support && udev->portnum == udev->bus->otg_port) { status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), USB_REQ_SET_FEATURE, 0, <API key>, 0, NULL, 0, <API key>); if (status < 0) { otg_send_event(<API key>); dev_dbg(&udev->dev, "can't enable HNP on port %d, " "status %d\n", port1, status); } else { udev->bus->b_hnp_enable = 1; } } #endif /* disable USB2 hardware LPM */ if (udev->usb2_hw_lpm_enabled == 1) <API key>(udev, 0); /* see 7.1.7.6 */ if (hub_is_superspeed(hub->hdev)) status = set_port_feature(hub->hdev, port1 | (USB_SS_PORT_LS_U3 << 3), <API key>); else status = set_port_feature(hub->hdev, port1, <API key>); if (status) { dev_dbg(hub->intfdev, "can't suspend port %d, status %d\n", port1, status); /* paranoia: "should not happen" */ if (udev->do_remote_wakeup) { if (!hub_is_superspeed(hub->hdev)) { (void) usb_control_msg(udev, usb_sndctrlpipe(udev, 0), <API key>, USB_RECIP_DEVICE, <API key>, 0, NULL, 0, <API key>); } else (void) <API key>(udev); } /* Try to enable USB2 hardware LPM again */ if (udev->usb2_hw_lpm_capable == 1) <API key>(udev, 1); /* System sleep transitions should never fail */ if (!PMSG_IS_AUTO(msg)) status = 0; } else { /* device has up to 10 msec to fully suspend */ dev_dbg(&udev->dev, "usb %ssuspend, wakeup %d\n", (PMSG_IS_AUTO(msg) ? "auto-" : ""), udev->do_remote_wakeup); <API key>(udev, USB_STATE_SUSPENDED); msleep(10); } usb_mark_last_busy(hub->hdev); return status; } /* * If the USB "suspend" state is in use (rather than "global suspend"), * many devices will be individually taken out of suspend state using * special "resume" signaling. This routine kicks in shortly after * hardware resume signaling is finished, either because of selective * resume (by host) or remote wakeup (by device) ... now see what changed * in the tree that's rooted at this device. * * If @udev->reset_resume is set then the device is reset before the * status check is done. */ static int finish_port_resume(struct usb_device *udev) { int status = 0; u16 devstatus = 0; /* caller owns the udev device lock */ dev_dbg(&udev->dev, "%s\n", udev->reset_resume ? "finish reset-resume" : "finish resume"); /* usb ch9 identifies four variants of SUSPENDED, based on what * state the device resumes to. Linux currently won't see the * first two on the host side; they'd be inside hub_port_init() * during many timeouts, but khubd can't suspend until later. */ <API key>(udev, udev->actconfig ? <API key> : USB_STATE_ADDRESS); /* 10.5.4.5 says not to reset a suspended port if the attached * device is enabled for remote wakeup. Hence the reset * operation is carried out here, after the port has been * resumed. */ if (udev->reset_resume) retry_reset_resume: status = <API key>(udev); /* 10.5.4.5 says be sure devices in the tree are still there. * For now let's assume the device didn't go crazy on resume, * and device drivers will know about any resume quirks. */ if (status == 0) { devstatus = 0; status = usb_get_status(udev, USB_RECIP_DEVICE, 0, &devstatus); if (status >= 0) status = (status > 0 ? 0 : -ENODEV); /* If a normal resume failed, try doing a reset-resume */ if (status && !udev->reset_resume && udev->persist_enabled) { dev_dbg(&udev->dev, "retry with reset-resume\n"); udev->reset_resume = 1; goto retry_reset_resume; } } if (status) { dev_dbg(&udev->dev, "gone after usb resume? status %d\n", status); /* * There are a few quirky devices which violate the standard * by claiming to have remote wakeup enabled after a reset, * which crash if the feature is cleared, hence check for * udev->reset_resume */ } else if (udev->actconfig && !udev->reset_resume) { if (!hub_is_superspeed(udev->parent)) { le16_to_cpus(&devstatus); if (devstatus & (1 << <API key>)) status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), <API key>, USB_RECIP_DEVICE, <API key>, 0, NULL, 0, <API key>); } else { status = usb_get_status(udev, USB_RECIP_INTERFACE, 0, &devstatus); le16_to_cpus(&devstatus); if (!status && devstatus & (<API key> | <API key>)) status = <API key>(udev); } if (status) dev_dbg(&udev->dev, "disable remote wakeup, status %d\n", status); status = 0; } return status; } /* * usb_port_resume - re-activate a suspended usb device's upstream port * @udev: device to re-activate, not a root hub * Context: must be able to sleep; device not locked; pm locks held * * This will re-activate the suspended device, increasing power usage * while letting drivers communicate again with its endpoints. * USB resume explicitly guarantees that the power session between * the host and the device is the same as it was when the device * suspended. * * If @udev->reset_resume is set then this routine won't check that the * port is still enabled. Furthermore, finish_port_resume() above will * reset @udev. The end result is that a broken power session can be * recovered and @udev will appear to persist across a loss of VBUS power. * * For example, if a host controller doesn't maintain VBUS suspend current * during a system sleep or is reset when the system wakes up, all the USB * power sessions below it will be broken. This is especially troublesome * for mass-storage devices containing mounted filesystems, since the * device will appear to have disconnected and all the memory mappings * to it will be lost. Using the USB_PERSIST facility, the device can be * made to appear as if it had not disconnected. * * This facility can be dangerous. Although <API key>() makes * every effort to insure that the same device is present after the * reset as before, it cannot provide a 100% guarantee. Furthermore it's * quite possible for a device to remain unaltered but its media to be * changed. If the user replaces a flash memory card while the system is * asleep, he will have only himself to blame when the filesystem on the * new card is corrupted and the system crashes. * * Returns 0 on success, else negative errno. */ int usb_port_resume(struct usb_device *udev, pm_message_t msg) { struct usb_hub *hub = hdev_to_hub(udev->parent); int port1 = udev->portnum; int status; u16 portchange, portstatus; /* Skip the initial Clear-Suspend step for a remote wakeup */ status = hub_port_status(hub, port1, &portstatus, &portchange); if (status == 0 && !port_is_suspended(hub, portstatus)) goto SuspendCleared; // dev_dbg(hub->intfdev, "resume port %d\n", port1); set_bit(port1, hub->busy_bits); /* see 7.1.7.7; affects power usage, but not budgeting */ if (hub_is_superspeed(hub->hdev)) status = set_port_feature(hub->hdev, port1 | (USB_SS_PORT_LS_U0 << 3), <API key>); else status = clear_port_feature(hub->hdev, port1, <API key>); if (status) { dev_dbg(hub->intfdev, "can't resume port %d, status %d\n", port1, status); } else { /* drive resume for at least 20 msec */ dev_dbg(&udev->dev, "usb %sresume\n", (PMSG_IS_AUTO(msg) ? "auto-" : "")); msleep(25); /* Virtual root hubs can trigger on GET_PORT_STATUS to * stop resume signaling. Then finish the resume * sequence. */ status = hub_port_status(hub, port1, &portstatus, &portchange); /* TRSMRCY = 10 msec */ msleep(10); } SuspendCleared: if (status == 0) { if (hub_is_superspeed(hub->hdev)) { if (portchange & <API key>) clear_port_feature(hub->hdev, port1, <API key>); } else { if (portchange & <API key>) clear_port_feature(hub->hdev, port1, <API key>); } } clear_bit(port1, hub->busy_bits); status = <API key>(udev, hub, port1, status, portchange, portstatus); if (status == 0) status = finish_port_resume(udev); if (status < 0) { dev_dbg(&udev->dev, "can't resume, status %d\n", status); <API key>(hub, port1); } else { /* Try to enable USB2 hardware LPM */ if (udev->usb2_hw_lpm_capable == 1) <API key>(udev, 1); } return status; } /* caller has locked udev */ int usb_remote_wakeup(struct usb_device *udev) { int status = 0; struct usb_hcd *hcd = bus_to_hcd(udev->bus); if (udev->state == USB_STATE_SUSPENDED) { dev_dbg(&udev->dev, "usb %sresume\n", "wakeup-"); status = <API key>(udev); if (status == 0) { /* Let the drivers do their thing, then... */ <API key>(udev); } } else { dev_dbg(&udev->dev, "usb not suspended\n"); clear_bit(<API key>, &hcd->flags); } return status; } #else /* CONFIG_USB_SUSPEND */ /* When CONFIG_USB_SUSPEND isn't set, we never suspend or resume any ports. */ int usb_port_suspend(struct usb_device *udev, pm_message_t msg) { return 0; } /* However we may need to do a reset-resume */ int usb_port_resume(struct usb_device *udev, pm_message_t msg) { struct usb_hub *hub = hdev_to_hub(udev->parent); int port1 = udev->portnum; int status; u16 portchange, portstatus; status = hub_port_status(hub, port1, &portstatus, &portchange); status = <API key>(udev, hub, port1, status, portchange, portstatus); if (status) { dev_dbg(&udev->dev, "can't resume, status %d\n", status); <API key>(hub, port1); } else if (udev->reset_resume) { dev_dbg(&udev->dev, "reset-resume\n"); status = <API key>(udev); } return status; } #endif static int hub_suspend(struct usb_interface *intf, pm_message_t msg) { struct usb_hub *hub = usb_get_intfdata (intf); struct usb_device *hdev = hub->hdev; unsigned port1; int status; /* Warn if children aren't already suspended */ for (port1 = 1; port1 <= hdev->maxchild; port1++) { struct usb_device *udev; udev = hdev->children [port1-1]; if (udev && udev->can_submit) { dev_warn(&intf->dev, "port %d nyet suspended\n", port1); if (PMSG_IS_AUTO(msg)) return -EBUSY; } } if (hub_is_superspeed(hdev) && hdev->do_remote_wakeup) { /* Enable hub to send remote wakeup for all ports. */ for (port1 = 1; port1 <= hdev->maxchild; port1++) { status = set_port_feature(hdev, port1 | <API key> | <API key> | <API key>, <API key>); } } dev_dbg(&intf->dev, "%s\n", __func__); /* stop khubd and related activity */ hub_quiesce(hub, HUB_SUSPEND); return 0; } static int hub_resume(struct usb_interface *intf) { struct usb_hub *hub = usb_get_intfdata(intf); dev_dbg(&intf->dev, "%s\n", __func__); hub_activate(hub, HUB_RESUME); return 0; } static int hub_reset_resume(struct usb_interface *intf) { struct usb_hub *hub = usb_get_intfdata(intf); dev_dbg(&intf->dev, "%s\n", __func__); hub_activate(hub, HUB_RESET_RESUME); return 0; } /** * <API key> - called by HCD if the root hub lost Vbus power * @rhdev: struct usb_device for the root hub * * The USB host controller driver calls this function when its root hub * is resumed and Vbus power has been interrupted or the controller * has been reset. The routine marks @rhdev as having lost power. * When the hub driver is resumed it will take notice and carry out * power-session recovery for all the "USB-PERSIST"-enabled child devices; * the others will be disconnected. */ void <API key>(struct usb_device *rhdev) { dev_warn(&rhdev->dev, "root hub lost power or was reset\n"); rhdev->reset_resume = 1; } EXPORT_SYMBOL_GPL(<API key>); #else /* CONFIG_PM */ #define hub_suspend NULL #define hub_resume NULL #define hub_reset_resume NULL #endif /* USB 2.0 spec, 7.1.7.3 / fig 7-29: * * Between connect detection and reset signaling there must be a delay * of 100ms at least for debounce and power-settling. The corresponding * timer shall restart whenever the downstream port detects a disconnect. * * Apparently there are some bluetooth and irda-dongles and a number of * low-speed devices for which this debounce period may last over a second. * Not covered by the spec - but easy to deal with. * * This implementation uses a 1500ms total debounce timeout; if the * connection isn't stable by then it returns -ETIMEDOUT. It checks * every 25ms for transient disconnects. When the port status has been * unchanged for 100ms it returns the port status. */ static int hub_port_debounce(struct usb_hub *hub, int port1) { int ret; int total_time, stable_time = 0; u16 portchange, portstatus; unsigned connection = 0xffff; for (total_time = 0; ; total_time += HUB_DEBOUNCE_STEP) { ret = hub_port_status(hub, port1, &portstatus, &portchange); if (ret < 0) return ret; if (!(portchange & <API key>) && (portstatus & <API key>) == connection) { stable_time += HUB_DEBOUNCE_STEP; if (stable_time >= HUB_DEBOUNCE_STABLE) break; } else { stable_time = 0; connection = portstatus & <API key>; } if (portchange & <API key>) { clear_port_feature(hub->hdev, port1, <API key>); } if (total_time >= <API key>) break; msleep(HUB_DEBOUNCE_STEP); } dev_dbg (hub->intfdev, "debounce: port %d: total %dms stable %dms status 0x%x\n", port1, total_time, stable_time, portstatus); if (stable_time < HUB_DEBOUNCE_STABLE) return -ETIMEDOUT; return portstatus; } void usb_ep0_reinit(struct usb_device *udev) { <API key>(udev, 0 + USB_DIR_IN, true); <API key>(udev, 0 + USB_DIR_OUT, true); usb_enable_endpoint(udev, &udev->ep0, true); } EXPORT_SYMBOL_GPL(usb_ep0_reinit); #define usb_sndaddr0pipe() (PIPE_CONTROL << 30) #define usb_rcvaddr0pipe() ((PIPE_CONTROL << 30) | USB_DIR_IN) static int hub_set_address(struct usb_device *udev, int devnum) { int retval; struct usb_hcd *hcd = bus_to_hcd(udev->bus); /* * The host controller will choose the device address, * instead of the core having chosen it earlier */ if (!hcd->driver->address_device && devnum <= 1) return -EINVAL; if (udev->state == USB_STATE_ADDRESS) return 0; if (udev->state != USB_STATE_DEFAULT) return -EINVAL; if (hcd->driver->address_device) retval = hcd->driver->address_device(hcd, udev); else retval = usb_control_msg(udev, usb_sndaddr0pipe(), USB_REQ_SET_ADDRESS, 0, devnum, 0, NULL, 0, <API key>); if (retval == 0) { update_devnum(udev, devnum); /* Device now using proper address. */ <API key>(udev, USB_STATE_ADDRESS); usb_ep0_reinit(udev); } return retval; } /* Reset device, (re)assign address, get device descriptor. * Device connection must be stable, no more debouncing needed. * Returns device in USB_STATE_ADDRESS, except on error. * * If this is called for an already-existing device (as part of * <API key>), the caller must own the device lock. For a * newly detected device that is not accessible through any global * pointers, it's not necessary to lock the device. */ static int hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, int retry_counter) { static DEFINE_MUTEX(usb_address0_mutex); struct usb_device *hdev = hub->hdev; struct usb_hcd *hcd = bus_to_hcd(hdev->bus); int i, j, retval; unsigned delay = <API key>; enum usb_device_speed oldspeed = udev->speed; const char *speed; int devnum = udev->devnum; /* root hub ports have a slightly longer reset period * (from USB 2.0 spec, section 7.1.7.5) */ if (!hdev->parent) { delay = HUB_ROOT_RESET_TIME; if (port1 == hdev->bus->otg_port) hdev->bus->b_hnp_enable = 0; } /* Some low speed devices have problems with the quick delay, so */ /* be a bit pessimistic with those devices. RHbug #23670 */ if (oldspeed == USB_SPEED_LOW) delay = HUB_LONG_RESET_TIME; mutex_lock(&usb_address0_mutex); /* Reset the device; full speed may morph to high speed */ /* FIXME a USB 2.0 device may morph into SuperSpeed on reset. */ retval = hub_port_reset(hub, port1, udev, delay, false); if (retval < 0) /* error or disconnect */ goto fail; /* success, speed is known */ retval = -ENODEV; if (oldspeed != USB_SPEED_UNKNOWN && oldspeed != udev->speed) { dev_dbg(&udev->dev, "device reset changed speed!\n"); goto fail; } oldspeed = udev->speed; /* USB 2.0 section 5.5.3 talks about ep0 maxpacket ... * it's fixed size except for full speed devices. * For Wireless USB devices, ep0 max packet is always 512 (tho * reported as 0xff in the device descriptor). WUSB1.0[4.8.1]. */ switch (udev->speed) { case USB_SPEED_SUPER: case USB_SPEED_WIRELESS: /* fixed at 512 */ udev->ep0.desc.wMaxPacketSize = cpu_to_le16(512); break; case USB_SPEED_HIGH: /* fixed at 64 */ udev->ep0.desc.wMaxPacketSize = cpu_to_le16(64); break; case USB_SPEED_FULL: /* 8, 16, 32, or 64 */ /* to determine the ep0 maxpacket size, try to read * the device descriptor to get bMaxPacketSize0 and * then correct our initial guess. */ udev->ep0.desc.wMaxPacketSize = cpu_to_le16(64); break; case USB_SPEED_LOW: /* fixed at 8 */ udev->ep0.desc.wMaxPacketSize = cpu_to_le16(8); break; default: goto fail; } if (udev->speed == USB_SPEED_WIRELESS) speed = "variable speed Wireless"; else speed = usb_speed_string(udev->speed); if (udev->speed != USB_SPEED_SUPER) dev_info(&udev->dev, "%s %s USB device number %d using %s\n", (udev->config) ? "reset" : "new", speed, devnum, udev->bus->controller->driver->name); /* Set up TT records, if needed */ if (hdev->tt) { udev->tt = hdev->tt; udev->ttport = hdev->ttport; } else if (udev->speed != USB_SPEED_HIGH && hdev->speed == USB_SPEED_HIGH) { if (!hub->tt.hub) { dev_err(&udev->dev, "parent hub has no TT\n"); retval = -EINVAL; goto fail; } udev->tt = &hub->tt; udev->ttport = port1; } /* Why interleave GET_DESCRIPTOR and SET_ADDRESS this way? * Because device hardware and firmware is sometimes buggy in * this area, and this is how Linux has done it for ages. * Change it cautiously. * * NOTE: If USE_NEW_SCHEME() is true we will start by issuing * a 64-byte GET_DESCRIPTOR request. This is what Windows does, * so it may help with some <API key> devices. * Otherwise we start with SET_ADDRESS and then try to read the * first 8 bytes of the device descriptor to get the ep0 maxpacket * value. */ for (i = 0; i < <API key>; (++i, msleep(100))) { if (USE_NEW_SCHEME(retry_counter) && !(hcd->driver->flags & HCD_USB3) && !((hcd->driver->flags & HCD_RT_OLD_ENUM) && !hdev->parent)) { struct <API key> *buf; int r = 0; #define <API key> 64 buf = kmalloc(<API key>, GFP_NOIO); if (!buf) { retval = -ENOMEM; continue; } /* Retry on all errors; some devices are flakey. * 255 is for WUSB devices, we actually need to use * 512 (WUSB1.0[4.8.1]). */ for (j = 0; j < 3; ++j) { buf->bMaxPacketSize0 = 0; r = usb_control_msg(udev, usb_rcvaddr0pipe(), <API key>, USB_DIR_IN, USB_DT_DEVICE << 8, 0, buf, <API key>, <API key>); switch (buf->bMaxPacketSize0) { case 8: case 16: case 32: case 64: case 255: if (buf->bDescriptorType == USB_DT_DEVICE) { r = 0; break; } /* FALL THROUGH */ default: if (r == 0) r = -EPROTO; break; } if (r == 0) break; } udev->descriptor.bMaxPacketSize0 = buf->bMaxPacketSize0; kfree(buf); /* * If it is a HSET Test device, we don't issue a * second reset which results in failure due to * speed change. */ if (le16_to_cpu(buf->idVendor) != 0x1a0a) { retval = hub_port_reset(hub, port1, udev, delay, false); if (retval < 0) /* error or disconnect */ goto fail; if (oldspeed != udev->speed) { dev_dbg(&udev->dev, "device reset changed speed!\n"); retval = -ENODEV; goto fail; } } if (r) { dev_err(&udev->dev, "device descriptor read/64, error %d\n", r); retval = -EMSGSIZE; continue; } #undef <API key> } /* * If device is WUSB, we already assigned an * unauthorized address in the Connect Ack sequence; * authorization will assign the final address. */ if (udev->wusb == 0) { for (j = 0; j < SET_ADDRESS_TRIES; ++j) { retval = hub_set_address(udev, devnum); if (retval >= 0) break; msleep(200); } if (retval < 0) { dev_err(&udev->dev, "device not accepting address %d, error %d\n", devnum, retval); goto fail; } if (udev->speed == USB_SPEED_SUPER) { devnum = udev->devnum; dev_info(&udev->dev, "%s SuperSpeed USB device number %d using %s\n", (udev->config) ? "reset" : "new", devnum, udev->bus->controller->driver->name); } /* cope with hardware quirkiness: * - let SET_ADDRESS settle, some device hardware wants it * - read ep0 maxpacket even for high and low speed, */ msleep(10); if (USE_NEW_SCHEME(retry_counter) && !(hcd->driver->flags & HCD_USB3) && !((hcd->driver->flags & HCD_RT_OLD_ENUM) && !hdev->parent)) break; } retval = <API key>(udev, 8); if (retval < 8) { dev_err(&udev->dev, "device descriptor read/8, error %d\n", retval); if (retval >= 0) retval = -EMSGSIZE; } else { retval = 0; break; } } if (retval) goto fail; /* * Some superspeed devices have finished the link training process * and attached to a superspeed hub port, but the device descriptor * got from those devices show they aren't superspeed devices. Warm * reset the port attached by the devices can fix them. */ if ((udev->speed == USB_SPEED_SUPER) && (le16_to_cpu(udev->descriptor.bcdUSB) < 0x0300)) { dev_err(&udev->dev, "got a wrong device descriptor, " "warm reset device\n"); hub_port_reset(hub, port1, udev, HUB_BH_RESET_TIME, true); retval = -EINVAL; goto fail; } if (udev->descriptor.bMaxPacketSize0 == 0xff || udev->speed == USB_SPEED_SUPER) i = 512; else i = udev->descriptor.bMaxPacketSize0; if (usb_endpoint_maxp(&udev->ep0.desc) != i) { if (udev->speed == USB_SPEED_LOW || !(i == 8 || i == 16 || i == 32 || i == 64)) { dev_err(&udev->dev, "Invalid ep0 maxpacket: %d\n", i); retval = -EMSGSIZE; goto fail; } if (udev->speed == USB_SPEED_FULL) dev_dbg(&udev->dev, "ep0 maxpacket = %d\n", i); else dev_warn(&udev->dev, "Using ep0 maxpacket: %d\n", i); udev->ep0.desc.wMaxPacketSize = cpu_to_le16(i); usb_ep0_reinit(udev); } retval = <API key>(udev, USB_DT_DEVICE_SIZE); if (retval < (signed)sizeof(udev->descriptor)) { dev_err(&udev->dev, "device descriptor read/all, error %d\n", retval); if (retval >= 0) retval = -ENOMSG; goto fail; } if (udev->wusb == 0 && le16_to_cpu(udev->descriptor.bcdUSB) >= 0x0201) { retval = <API key>(udev); if (!retval) { if (udev->bos->ext_cap && (USB_LPM_SUPPORT & le32_to_cpu(udev->bos->ext_cap->bmAttributes))) udev->lpm_capable = 1; } } retval = 0; /* notify HCD that we have a device connected and addressed */ if (hcd->driver->update_device) hcd->driver->update_device(hcd, udev); fail: if (retval) { hub_port_disable(hub, port1, 0); update_devnum(udev, devnum); /* for disconnect processing */ } mutex_unlock(&usb_address0_mutex); return retval; } static void check_highspeed (struct usb_hub *hub, struct usb_device *udev, int port1) { struct <API key> *qual; int status; qual = kmalloc (sizeof *qual, GFP_KERNEL); if (qual == NULL) return; status = usb_get_descriptor (udev, <API key>, 0, qual, sizeof *qual); if (status == sizeof *qual) { dev_info(&udev->dev, "not running at top speed; " "connect to a high speed hub\n"); /* hub LEDs are probably harder to miss than syslog */ if (hub->has_indicators) { hub->indicator[port1-1] = <API key>; <API key> (&hub->leds, 0); } } kfree(qual); } static unsigned hub_power_remaining (struct usb_hub *hub) { struct usb_device *hdev = hub->hdev; int remaining; int port1; if (!hub->limited_power) return 0; remaining = hdev->bus_mA - hub->descriptor->bHubContrCurrent; for (port1 = 1; port1 <= hdev->maxchild; ++port1) { struct usb_device *udev = hdev->children[port1 - 1]; int delta; if (!udev) continue; /* Unconfigured devices may not use more than 100mA, * or 8mA for OTG ports */ if (udev->actconfig) delta = udev->actconfig->desc.bMaxPower * 2; else if (port1 != udev->bus->otg_port || hdev->parent) delta = 100; else delta = 8; if (delta > hub->mA_per_port) dev_warn(&udev->dev, "%dmA is over %umA budget for port %d!\n", delta, hub->mA_per_port, port1); remaining -= delta; } if (remaining < 0) { dev_warn(hub->intfdev, "%dmA over power budget!\n", - remaining); remaining = 0; } return remaining; } /* Handle physical or logical connection change events. * This routine is called when: * a port connection-change occurs; * a port enable-change occurs (often caused by EMI); * <API key>() encounters changed descriptors (as from * a firmware download) * caller already locked the hub */ static void <API key>(struct usb_hub *hub, int port1, u16 portstatus, u16 portchange) { struct usb_device *hdev = hub->hdev; struct device *hub_dev = hub->intfdev; struct usb_hcd *hcd = bus_to_hcd(hdev->bus); unsigned wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); struct usb_device *udev; int status, i; dev_dbg (hub_dev, "port %d, status %04x, change %04x, %s\n", port1, portstatus, portchange, portspeed(hub, portstatus)); if (hub->has_indicators) { set_port_led(hub, port1, HUB_LED_AUTO); hub->indicator[port1-1] = INDICATOR_AUTO; } #ifdef CONFIG_USB_OTG /* during HNP, don't repeat the debounce */ if (hdev->bus->is_b_host) portchange &= ~(<API key> | <API key>); #endif /* Try to resuscitate an existing device */ udev = hdev->children[port1-1]; if ((portstatus & <API key>) && udev && udev->state != <API key>) { usb_lock_device(udev); if (portstatus & <API key>) { status = 0; /* Nothing to do */ #ifdef CONFIG_USB_SUSPEND } else if (udev->state == USB_STATE_SUSPENDED && udev->persist_enabled) { /* For a suspended device, treat this as a * remote wakeup event. */ status = usb_remote_wakeup(udev); #endif } else { status = -ENODEV; /* Don't resuscitate */ } usb_unlock_device(udev); if (status == 0) { clear_bit(port1, hub->change_bits); return; } } /* Disconnect any existing devices under this port */ if (udev) usb_disconnect(&hdev->children[port1-1]); clear_bit(port1, hub->change_bits); /* We can forget about a "removed" device when there's a physical * disconnect or the connect status changes. */ if (!(portstatus & <API key>) || (portchange & <API key>)) clear_bit(port1, hub->removed_bits); #if defined(<API key>) || defined(<API key>) if (<API key> == 0) /*stericsson*/ #endif if (portchange & (<API key> | <API key>)) { status = hub_port_debounce(hub, port1); if (status < 0) { if (printk_ratelimit()) dev_err(hub_dev, "connect-debounce failed, " "port %d disabled\n", port1); portstatus &= ~<API key>; } else { portstatus = status; } } /* Return now if debouncing failed or nothing is connected or * the device was "removed". */ if (!(portstatus & <API key>) || test_bit(port1, hub->removed_bits)) { /* maybe switch power back on (e.g. root hub was reset) */ if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2 && !port_is_power_on(hub, portstatus)) set_port_feature(hdev, port1, USB_PORT_FEAT_POWER); if (portstatus & <API key>) goto done; return; } for (i = 0; i < SET_CONFIG_TRIES; i++) { /* reallocate for each attempt, since references * to the previous one can escape in various ways */ udev = usb_alloc_dev(hdev, hdev->bus, port1); if (!udev) { dev_err (hub_dev, "couldn't allocate port %d usb_device\n", port1); goto done; } <API key>(udev, USB_STATE_POWERED); udev->bus_mA = hub->mA_per_port; udev->level = hdev->level + 1; udev->wusb = hub_is_wusb(hub); /* Only USB 3.0 devices are connected to SuperSpeed hubs. */ if (hub_is_superspeed(hub->hdev)) udev->speed = USB_SPEED_SUPER; else udev->speed = USB_SPEED_UNKNOWN; choose_devnum(udev); if (udev->devnum <= 0) { status = -ENOTCONN; /* Don't retry */ goto loop; } /* reset (non-USB 3.0 devices) and get descriptor */ status = hub_port_init(hub, udev, port1, i); if (status < 0) goto loop; usb_detect_quirks(udev); if (udev->quirks & <API key>) msleep(1000); /* consecutive bus-powered hubs aren't reliable; they can * violate the voltage drop budget. if the new child has * a "powered" LED, users should notice we didn't enable it * (without reading syslog), even without per-port LEDs * on the parent. */ if (udev->descriptor.bDeviceClass == USB_CLASS_HUB && udev->bus_mA <= 100) { u16 devstat; status = usb_get_status(udev, USB_RECIP_DEVICE, 0, &devstat); if (status < 2) { dev_dbg(&udev->dev, "get status %d ?\n", status); goto loop_disable; } le16_to_cpus(&devstat); if ((devstat & (1 << <API key>)) == 0) { dev_err(&udev->dev, "can't connect bus-powered hub " "to this port\n"); if (hub->has_indicators) { hub->indicator[port1-1] = <API key>; <API key> (&hub->leds, 0); } status = -ENOTCONN; /* Don't retry */ goto loop_disable; } } /* check for devices running slower than they could */ if (le16_to_cpu(udev->descriptor.bcdUSB) >= 0x0200 && udev->speed == USB_SPEED_FULL && highspeed_hubs != 0) check_highspeed (hub, udev, port1); /* Store the parent's children[] pointer. At this point * udev becomes globally accessible, although presumably * no one will look at it until hdev is unlocked. */ status = 0; /* We mustn't add new devices if the parent hub has * been disconnected; we would race with the * <API key>() routine. */ spin_lock_irq(&device_state_lock); if (hdev->state == <API key>) status = -ENOTCONN; else hdev->children[port1-1] = udev; spin_unlock_irq(&device_state_lock); /* Run it through the hoops (find a driver, etc) */ if (!status) { status = usb_new_device(udev); if (status) { spin_lock_irq(&device_state_lock); hdev->children[port1-1] = NULL; spin_unlock_irq(&device_state_lock); } } if (status) goto loop_disable; status = hub_power_remaining(hub); if (status) dev_dbg(hub_dev, "%dmA power budget left\n", status); #if defined(<API key>) || defined(<API key>) if (HostComplianceTest == 1 && udev->devnum > 1) { if (HostTest == 7) { /*<API key> */ dev_info(hub_dev, "Testing " "<API key>\n"); /* Test the Single Step Get Device Descriptor , * take care it should not get status phase */ No_Data_Phase = 1; No_Status_Phase = 1; <API key>(udev, 8); No_Data_Phase = 0; No_Status_Phase = 0; } if (HostTest == 8) { dev_info(hub_dev, "Testing " "<API key>\n"); /* Test Single Step Set Feature */ No_Status_Phase = 1; <API key>(udev, 8); No_Status_Phase = 0; } } #endif return; loop_disable: hub_port_disable(hub, port1, 1); loop: usb_ep0_reinit(udev); release_devnum(udev); hub_free_dev(udev); usb_put_dev(udev); if ((status == -ENOTCONN) || (status == -ENOTSUPP)) break; } if (hub->hdev->parent || !hcd->driver->port_handed_over || !(hcd->driver->port_handed_over)(hcd, port1)) dev_err(hub_dev, "unable to enumerate USB device on port %d\n", port1); done: hub_port_disable(hub, port1, 1); if (hcd->driver->relinquish_port && !hub->hdev->parent) hcd->driver->relinquish_port(hcd, port1); } /* Returns 1 if there was a remote wakeup and a connect status change. */ static int <API key>(struct usb_hub *hub, unsigned int port, u16 portstatus, u16 portchange) { struct usb_device *hdev; struct usb_device *udev; int connect_change = 0; int ret; hdev = hub->hdev; udev = hdev->children[port-1]; if (!hub_is_superspeed(hdev)) { if (!(portchange & <API key>)) return 0; clear_port_feature(hdev, port, <API key>); } else { if (!udev || udev->state != USB_STATE_SUSPENDED || (portstatus & <API key>) != USB_SS_PORT_LS_U0) return 0; } if (udev) { /* TRSMRCY = 10 msec */ msleep(10); usb_lock_device(udev); ret = usb_remote_wakeup(udev); usb_unlock_device(udev); if (ret < 0) connect_change = 1; } else { ret = -ENODEV; hub_port_disable(hub, port, 1); } dev_dbg(hub->intfdev, "resume on port %d, status %d\n", port, ret); return connect_change; } static void hub_events(void) { struct list_head *tmp; struct usb_device *hdev; struct usb_interface *intf; struct usb_hub *hub; struct device *hub_dev; u16 hubstatus; u16 hubchange; u16 portstatus; u16 portchange; int i, ret; #if defined(<API key>) || defined(<API key>) int j; int otgport = 0; struct usb_port_status port_status; #endif int connect_change, wakeup_change; /* * We restart the list every time to avoid a deadlock with * deleting hubs downstream from this one. This should be * safe since we delete the hub from the event list. * Not the most efficient, but avoids deadlocks. */ while (1) { /* Grab the first entry at the beginning of the list */ spin_lock_irq(&hub_event_lock); if (list_empty(&hub_event_list)) { spin_unlock_irq(&hub_event_lock); break; } tmp = hub_event_list.next; list_del_init(tmp); hub = list_entry(tmp, struct usb_hub, event_list); kref_get(&hub->kref); spin_unlock_irq(&hub_event_lock); hdev = hub->hdev; hub_dev = hub->intfdev; intf = to_usb_interface(hub_dev); dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x\n", hdev->state, hub->descriptor ? hub->descriptor->bNbrPorts : 0, /* NOTE: expects max 15 ports... */ (u16) hub->change_bits[0], (u16) hub->event_bits[0]); /* Lock the device, then check to see if we were * disconnected while waiting for the lock to succeed. */ usb_lock_device(hdev); if (unlikely(hub->disconnected)) goto loop_disconnected; /* If the hub has died, clean up after it */ if (hdev->state == <API key>) { hub->error = -ENODEV; hub_quiesce(hub, HUB_DISCONNECT); goto loop; } /* Autoresume */ ret = <API key>(intf); if (ret) { dev_dbg(hub_dev, "Can't autoresume: %d\n", ret); goto loop; } /* If this is an inactive hub, do nothing */ if (hub->quiescing) goto loop_autopm; if (hub->error) { dev_dbg (hub_dev, "resetting for error %d\n", hub->error); ret = usb_reset_device(hdev); if (ret) { dev_dbg (hub_dev, "error resetting hub: %d\n", ret); goto loop_autopm; } hub->nerrors = 0; hub->error = 0; } /* deal with port status changes */ for (i = 1; i <= hub->descriptor->bNbrPorts; i++) { #if defined(<API key>) || defined(<API key>) struct usb_port_status portsts; /*if we have something to do on * otg port * */ if ((hdev->otgstate & USB_OTG_SUSPEND) || (hdev->otgstate & USB_OTG_ENUMERATE) || (hdev->otgstate & USB_OTG_DISCONNECT) || (hdev->otgstate & USB_OTG_RESUME)) { otgport = 1; } if (hdev->otgstate & USB_OTG_RESUME) { ret = clear_port_feature(hdev, i, <API key>); if (ret < 0) { dev_err(hub_dev, "usb otg port Resume" " fails, %d\n", ret); } hdev->otgstate &= ~USB_OTG_RESUME; } if ((hdev->otgstate & USB_OTG_SUSPEND) && (hdev->children[0])) { hdev->otgstate &= ~USB_OTG_SUSPEND; ret = set_port_feature(hdev, 1, <API key>); if (ret < 0) { dev_err(hub_dev, "usb otg port suspend" " fails, %d\n", ret); break; } msleep(1); ret = get_port_status(hdev, i, &portsts); if (ret < 0) { dev_err(hub_dev, "usb otg get port" " status fails, %d\n", ret); break; } portchange = le16_to_cpu(portsts.wPortChange); if (portchange & <API key>) { clear_port_feature(hdev, i, <API key>); } break; } if (hdev->otgstate & <API key>) { for (j = 1; j <= hub->descriptor->bNbrPorts; j++) { if (hdev->children[j - 1]) { dev_dbg(hub_dev, "child" " found at port %d\n", j); ret = usb_control_msg(hdev-> children[j - 1], usb_sndctrlpipe(hdev-> children[j - 1], 0), USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, <API key>, 0, NULL, 0, <API key>); if (ret < 0) { dev_err(hub_dev, "Port" " %d doesn't support" "remote wakeup\n", j); } else { dev_dbg(hub_dev, "Port" " %d supports" "remote wakeup\n", j); } ret = set_port_feature(hdev, j, <API key>); if (ret < 0) { dev_err(hub_dev, "Port" " %d NOT ABLE TO" " SUSPEND\n", j); } else { dev_dbg(hub_dev, "Port" " %d is ABLE TO" " SUSPEND\n", j); } } } ret = usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, <API key>, 0, NULL, 0, <API key>); if (ret < 0) { dev_err(hub_dev, "HUB doesn't support" " REMOTE WAKEUP\n"); } else { dev_dbg(hub_dev, "HUB supports" " REMOTE WAKEUP\n"); } ret = 0; msleep(10); if (hdev->parent == hdev->bus->root_hub) { if (hdev->hcd_suspend && hdev->hcd_priv) { dev_dbg(hub_dev, "calling" " suspend after remote wakeup" " command is issued\n"); hdev->hcd_suspend(hdev-> hcd_priv); } if (hdev->otg_notif) hdev->otg_notif(hdev->otgpriv, PDC_POWERMANAGEMENT, 10); } } if (hdev->otgstate & USB_OTG_WAKEUP_ALL) { (void) usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), <API key>, USB_RECIP_DEVICE, <API key>, 0, NULL, 0, <API key>); dev_dbg(hub_dev, "Hub CLEARED REMOTE WAKEUP\n"); for (j = 1; j <= hub->descriptor->bNbrPorts; j++) { if (hdev->children[j - 1]) { dev_dbg(hub_dev, "PORT %d" " SUSPEND IS CLEARD\n", j); clear_port_feature(hdev, j, <API key>); msleep(50); (void) usb_control_msg(hdev-> children[j - 1], usb_sndctrlpipe( hdev->children[j - 1], 0), <API key>, USB_RECIP_DEVICE, <API key>, 0, NULL, 0, <API key>); dev_dbg(hub_dev, "PORT %d " "REMOTE WAKEUP IS " "CLEARD\n", j); msleep(10); } } } /* * reset the state of otg device, * regardless of otg device */ hdev->otgstate = 0; #endif if (test_bit(i, hub->busy_bits)) continue; connect_change = test_bit(i, hub->change_bits); wakeup_change = test_and_clear_bit(i, hub->wakeup_bits); if (!test_and_clear_bit(i, hub->event_bits) && !connect_change && !wakeup_change) continue; ret = hub_port_status(hub, i, &portstatus, &portchange); if (ret < 0) continue; if (portchange & <API key>) { clear_port_feature(hdev, i, <API key>); connect_change = 1; } if (portchange & <API key>) { if (!connect_change) dev_dbg (hub_dev, "port %d enable change, " "status %08x\n", i, portstatus); clear_port_feature(hdev, i, <API key>); /* * EM interference sometimes causes badly * shielded USB devices to be shutdown by * the hub, this hack enables them again. * Works at least with mouse driver. */ if (!(portstatus & <API key>) && !connect_change && hdev->children[i-1]) { dev_err (hub_dev, "port %i " "disabled by hub (EMI?), " "re-enabling...\n", i); connect_change = 1; } } if (<API key>(hub, i, portstatus, portchange)) connect_change = 1; if (portchange & <API key>) { u16 status = 0; u16 unused; dev_dbg(hub_dev, "over-current change on port " "%d\n", i); clear_port_feature(hdev, i, <API key>); msleep(100); /* Cool down */ hub_power_on(hub, true); hub_port_status(hub, i, &status, &unused); if (status & <API key>) dev_err(hub_dev, "over-current " "condition on port %d\n", i); } if (portchange & <API key>) { dev_dbg (hub_dev, "reset change on port %d\n", i); clear_port_feature(hdev, i, <API key>); } if ((portchange & <API key>) && hub_is_superspeed(hub->hdev)) { dev_dbg(hub_dev, "warm reset change on port %d\n", i); clear_port_feature(hdev, i, <API key>); } if (portchange & <API key>) { clear_port_feature(hub->hdev, i, <API key>); } if (portchange & <API key>) { dev_warn(hub_dev, "config error on port %d\n", i); clear_port_feature(hub->hdev, i, <API key>); } /* Warm reset a USB3 protocol port if it's in * SS.Inactive state. */ if (<API key>(hub, portstatus)) { int status; struct usb_device *udev = hub->hdev->children[i - 1]; dev_dbg(hub_dev, "warm reset port %d\n", i); if (!udev || !(portstatus & <API key>) || udev->state == <API key>) { status = hub_port_reset(hub, i, NULL, HUB_BH_RESET_TIME, true); if (status < 0) hub_port_disable(hub, i, 1); } else { usb_lock_device(udev); status = usb_reset_device(udev); usb_unlock_device(udev); connect_change = 0; } } if (connect_change) { #if defined(<API key>) || defined(<API key>) if (hdev->parent == hdev->bus->root_hub) if (hdev->otg_notif && (HostComplianceTest == 0)) hdev->otg_notif(hdev->otgpriv, PDC_HOST_NOTIFY, 5); portno = i; #endif <API key>(hub, i, portstatus, portchange); } } /* end for i */ /* deal with hub status changes */ if (test_and_clear_bit(0, hub->event_bits) == 0) ; /* do nothing */ else if (hub_hub_status(hub, &hubstatus, &hubchange) < 0) dev_err (hub_dev, "get_hub_status failed\n"); else { if (hubchange & <API key>) { dev_dbg (hub_dev, "power change\n"); clear_hub_feature(hdev, C_HUB_LOCAL_POWER); if (hubstatus & <API key>) /* FIXME: Is this always true? */ hub->limited_power = 1; else hub->limited_power = 0; } if (hubchange & <API key>) { u16 status = 0; u16 unused; dev_dbg(hub_dev, "over-current change\n"); clear_hub_feature(hdev, C_HUB_OVER_CURRENT); msleep(500); /* Cool down */ hub_power_on(hub, true); hub_hub_status(hub, &status, &unused); if (status & <API key>) dev_err(hub_dev, "over-current " "condition\n"); } } #if defined(<API key>) || defined(<API key>) /* if we have something on otg */ if (otgport) { otgport = 0; /* notify otg controller about it */ if (hdev->parent == hdev->bus->root_hub) if (hdev->otg_notif) hdev->otg_notif(hdev->otgpriv, PDC_HOST_NOTIFY, 0); } if (HostComplianceTest && hdev->devnum > 1) { /* TEST_SE0_NAK */ if (HostTest == 1) { dev_info(hub_dev, "Testing for TEST_SE0_NAK\n"); ret = clear_port_feature(hdev, portno, <API key>); ret = set_port_feature(hdev, portno, <API key>); ret = set_port_feature(hdev, portno | 0x300, USB_PORT_FEAT_TEST); ret = get_port_status(hdev, portno, &port_status); } /*TEST_J*/ if (HostTest == 2) { dev_info(hub_dev, "Testing TEST_J\n"); ret = clear_port_feature(hdev, portno, <API key>); ret = set_port_feature(hdev, portno, <API key>); ret = set_port_feature(hdev, portno | 0x100, USB_PORT_FEAT_TEST); ret = get_port_status(hdev, portno, &port_status); } if (HostTest == 3) { dev_info(hub_dev, "Testing TEST_K\n"); ret = clear_port_feature(hdev, portno, <API key>); ret = set_port_feature(hdev, portno, <API key>); ret = set_port_feature(hdev, portno | 0x200, USB_PORT_FEAT_TEST); ret = get_port_status(hdev, portno, &port_status); } if (HostTest == 4) { dev_info(hub_dev, "Testing TEST_PACKET at Port" " %d\n", portno); ret = clear_port_feature(hdev, portno, <API key>); if (ret < 0) dev_err(hub_dev, "Clear port feature" " C_CONNECTION failed\n"); ret = set_port_feature(hdev, portno, <API key>); if (ret < 0) dev_err(hub_dev, "Clear port feature" " SUSPEND failed\n"); ret = set_port_feature(hdev, portno | 0x400, USB_PORT_FEAT_TEST); if (ret < 0) dev_err(hub_dev, "Clear port feature" " TEST failed\n"); ret = get_port_status(hdev, portno, &port_status); if (ret < 0) dev_err(hub_dev, "Get port status" " failed\n"); } if (HostTest == 5) { dev_info(hub_dev, "Testing TEST_FORCE_ENBLE\n"); ret = clear_port_feature(hdev, portno, <API key>); ret = set_port_feature(hdev, portno, <API key>); ret = set_port_feature(hdev, portno | 0x500, USB_PORT_FEAT_TEST); ret = get_port_status(hdev, portno, &port_status); } if (HostTest == 6) { dev_info(hub_dev, "Testing " "<API key>\n"); ret = clear_port_feature(hdev, portno, <API key>); ret = set_port_feature(hdev, portno, <API key>); msleep(3000); ret = clear_port_feature(hdev, portno, <API key>); HostTest = 0; } } #endif loop_autopm: /* Balance the <API key>() above */ <API key>(intf); loop: /* Balance the <API key>() in * kick_khubd() and allow autosuspend. */ <API key>(intf); loop_disconnected: usb_unlock_device(hdev); kref_put(&hub->kref, hub_release); } /* end while (1) */ } static int hub_thread(void *__unused) { /* khubd needs to be freezable to avoid intefering with USB-PERSIST * port handover. Otherwise it might see that a full-speed device * was gone before the EHCI controller had handed its port over to * the companion full-speed controller. */ set_freezable(); do { hub_events(); <API key>(khubd_wait, !list_empty(&hub_event_list) || kthread_should_stop()); } while (!kthread_should_stop() || !list_empty(&hub_event_list)); pr_debug("%s: khubd exiting\n", usbcore_name); return 0; } static const struct usb_device_id hub_id_table[] = { { .match_flags = <API key>, .bDeviceClass = USB_CLASS_HUB}, { .match_flags = <API key>, .bInterfaceClass = USB_CLASS_HUB}, { } /* Terminating entry */ }; MODULE_DEVICE_TABLE (usb, hub_id_table); static struct usb_driver hub_driver = { .name = "hub", .probe = hub_probe, .disconnect = hub_disconnect, .suspend = hub_suspend, .resume = hub_resume, .reset_resume = hub_reset_resume, .pre_reset = hub_pre_reset, .post_reset = hub_post_reset, .unlocked_ioctl = hub_ioctl, .id_table = hub_id_table, .<API key> = 1, }; int usb_hub_init(void) { if (usb_register(&hub_driver) < 0) { printk(KERN_ERR "%s: can't register hub driver\n", usbcore_name); return -1; } khubd_task = kthread_run(hub_thread, NULL, "khubd"); if (!IS_ERR(khubd_task)) return 0; /* Fall through if kernel_thread failed */ usb_deregister(&hub_driver); printk(KERN_ERR "%s: can't start khubd\n", usbcore_name); return -1; } void usb_hub_cleanup(void) { kthread_stop(khubd_task); /* * Hub resources are freed for us by usb_deregister. It calls * usb_driver_purge on every device which in turn calls that * devices disconnect function if it is using this driver. * The hub_disconnect function takes care of releasing the * individual hub resources. -greg */ usb_deregister(&hub_driver); } /* usb_hub_cleanup() */ static int descriptors_changed(struct usb_device *udev, struct <API key> *<API key>) { int changed = 0; unsigned index; unsigned serial_len = 0; unsigned len; unsigned old_length; int length; char *buf; if (memcmp(&udev->descriptor, <API key>, sizeof(*<API key>)) != 0) return 1; /* Since the idVendor, idProduct, and bcdDevice values in the * device descriptor haven't changed, we will assume the * Manufacturer and Product strings haven't changed either. * But the SerialNumber string could be different (e.g., a * different flash card of the same brand). */ if (udev->serial) serial_len = strlen(udev->serial) + 1; len = serial_len; for (index = 0; index < udev->descriptor.bNumConfigurations; index++) { old_length = le16_to_cpu(udev->config[index].desc.wTotalLength); len = max(len, old_length); } buf = kmalloc(len, GFP_NOIO); if (buf == NULL) { dev_err(&udev->dev, "no mem to re-read configs after reset\n"); /* assume the worst */ return 1; } for (index = 0; index < udev->descriptor.bNumConfigurations; index++) { old_length = le16_to_cpu(udev->config[index].desc.wTotalLength); length = usb_get_descriptor(udev, USB_DT_CONFIG, index, buf, old_length); if (length != old_length) { dev_dbg(&udev->dev, "config index %d, error %d\n", index, length); changed = 1; break; } if (memcmp (buf, udev->rawdescriptors[index], old_length) != 0) { dev_dbg(&udev->dev, "config index %d changed ( index, ((struct <API key> *) buf)-> bConfigurationValue); changed = 1; break; } } if (!changed && serial_len) { length = usb_string(udev, udev->descriptor.iSerialNumber, buf, serial_len); if (length + 1 != serial_len) { dev_dbg(&udev->dev, "serial string error %d\n", length); changed = 1; } else if (memcmp(buf, udev->serial, length) != 0) { dev_dbg(&udev->dev, "serial string changed\n"); changed = 1; } } kfree(buf); return changed; } /** * <API key> - perform a USB port reset to reinitialize a device * @udev: device to reset (not in SUSPENDED or NOTATTACHED state) * * WARNING - don't use this routine to reset a composite device * (one with multiple interfaces owned by separate drivers)! * Use usb_reset_device() instead. * * Do a port reset, reassign the device's address, and establish its * former operating configuration. If the reset fails, or the device's * descriptors change from their values before the reset, or the original * configuration and altsettings cannot be restored, a flag will be set * telling khubd to pretend the device has been disconnected and then * re-connected. All drivers will be unbound, and the device will be * re-enumerated and probed all over again. * * Returns 0 if the reset succeeded, -ENODEV if the device has been * flagged for logical disconnection, or some other negative error code * if the reset wasn't even attempted. * * The caller must own the device lock. For example, it's safe to use * this from a driver probe() routine after downloading new firmware. * For calls that might not occur during probe(), drivers should lock * the device using <API key>(). * * Locking exception: This routine may also be called from within an * autoresume handler. Such usage won't conflict with other tasks * holding the device lock because these tasks should always call * <API key>(), thereby preventing any unwanted autoresume. */ static int <API key>(struct usb_device *udev) { struct usb_device *parent_hdev = udev->parent; struct usb_hub *parent_hub; struct usb_hcd *hcd = bus_to_hcd(udev->bus); struct <API key> descriptor = udev->descriptor; int i, ret = 0; int port1 = udev->portnum; if (udev->state == <API key> || udev->state == USB_STATE_SUSPENDED) { dev_dbg(&udev->dev, "device reset not allowed in state %d\n", udev->state); return -EINVAL; } if (!parent_hdev) { /* this requires hcd-specific logic; see ohci_restart() */ dev_dbg(&udev->dev, "%s for root hub!\n", __func__); return -EISDIR; } parent_hub = hdev_to_hub(parent_hdev); /* Disable USB2 hardware LPM. * It will be re-enabled by the enumeration process. */ if (udev->usb2_hw_lpm_enabled == 1) <API key>(udev, 0); set_bit(port1, parent_hub->busy_bits); for (i = 0; i < SET_CONFIG_TRIES; ++i) { /* ep0 maxpacket size may change; let the HCD know about it. * Other endpoints will be handled by re-enumeration. */ usb_ep0_reinit(udev); ret = hub_port_init(parent_hub, udev, port1, i); if (ret >= 0 || ret == -ENOTCONN || ret == -ENODEV) break; } clear_bit(port1, parent_hub->busy_bits); if (ret < 0) goto re_enumerate; /* Device might have changed firmware (DFU or similar) */ if (descriptors_changed(udev, &descriptor)) { dev_info(&udev->dev, "device firmware changed\n"); udev->descriptor = descriptor; /* for disconnect() calls */ goto re_enumerate; } /* Restore the device's previous configuration */ if (!udev->actconfig) goto done; mutex_lock(hcd->bandwidth_mutex); ret = <API key>(udev, udev->actconfig, NULL, NULL); if (ret < 0) { dev_warn(&udev->dev, "Busted HC? Not enough HCD resources for " "old configuration.\n"); mutex_unlock(hcd->bandwidth_mutex); goto re_enumerate; } ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), <API key>, 0, udev->actconfig->desc.bConfigurationValue, 0, NULL, 0, <API key>); if (ret < 0) { dev_err(&udev->dev, "can't restore configuration #%d (error=%d)\n", udev->actconfig->desc.bConfigurationValue, ret); mutex_unlock(hcd->bandwidth_mutex); goto re_enumerate; } mutex_unlock(hcd->bandwidth_mutex); <API key>(udev, <API key>); /* Put interfaces back into the same altsettings as before. * Don't bother to send the Set-Interface request for interfaces * that were already in altsetting 0; besides being unnecessary, * many devices can't handle it. Instead just reset the host-side * endpoint state. */ for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) { struct usb_host_config *config = udev->actconfig; struct usb_interface *intf = config->interface[i]; struct <API key> *desc; desc = &intf->cur_altsetting->desc; if (desc->bAlternateSetting == 0) { <API key>(udev, intf, true); <API key>(udev, intf, true); ret = 0; } else { /* Let the bandwidth allocation function know that this * device has been reset, and it will have to use * alternate setting 0 as the current alternate setting. */ intf->resetting_device = 1; ret = usb_set_interface(udev, desc->bInterfaceNumber, desc->bAlternateSetting); intf->resetting_device = 0; } if (ret < 0) { dev_err(&udev->dev, "failed to restore interface %d " "altsetting %d (error=%d)\n", desc->bInterfaceNumber, desc->bAlternateSetting, ret); goto re_enumerate; } } done: return 0; re_enumerate: <API key>(parent_hub, port1); return -ENODEV; } /** * usb_reset_device - warn interface drivers and perform a USB port reset * @udev: device to reset (not in SUSPENDED or NOTATTACHED state) * * Warns all drivers bound to registered interfaces (using their pre_reset * method), performs the port reset, and then lets the drivers know that * the reset is over (using their post_reset method). * * Return value is the same as for <API key>(). * * The caller must own the device lock. For example, it's safe to use * this from a driver probe() routine after downloading new firmware. * For calls that might not occur during probe(), drivers should lock * the device using <API key>(). * * If an interface is currently being probed or disconnected, we assume * its driver knows how to handle resets. For all other interfaces, * if the driver doesn't have pre_reset and post_reset methods then * we attempt to unbind it and rebind afterward. */ int usb_reset_device(struct usb_device *udev) { int ret; int i; struct usb_host_config *config = udev->actconfig; if (udev->state == <API key> || udev->state == USB_STATE_SUSPENDED) { dev_dbg(&udev->dev, "device reset not allowed in state %d\n", udev->state); return -EINVAL; } /* Prevent autosuspend during the reset */ <API key>(udev); if (config) { for (i = 0; i < config->desc.bNumInterfaces; ++i) { struct usb_interface *cintf = config->interface[i]; struct usb_driver *drv; int unbind = 0; if (cintf->dev.driver) { drv = to_usb_driver(cintf->dev.driver); if (drv->pre_reset && drv->post_reset) unbind = (drv->pre_reset)(cintf); else if (cintf->condition == USB_INTERFACE_BOUND) unbind = 1; if (unbind) <API key>(cintf); } } } ret = <API key>(udev); if (config) { for (i = config->desc.bNumInterfaces - 1; i >= 0; --i) { struct usb_interface *cintf = config->interface[i]; struct usb_driver *drv; int rebind = cintf->needs_binding; if (!rebind && cintf->dev.driver) { drv = to_usb_driver(cintf->dev.driver); if (drv->post_reset) rebind = (drv->post_reset)(cintf); else if (cintf->condition == USB_INTERFACE_BOUND) rebind = 1; if (rebind) cintf->needs_binding = 1; } } <API key>(udev); } <API key>(udev); return ret; } EXPORT_SYMBOL_GPL(usb_reset_device); /** * <API key> - Reset a USB device from an atomic context * @iface: USB interface belonging to the device to reset * * This function can be used to reset a USB device from an atomic * context, where usb_reset_device() won't work (as it blocks). * * Doing a reset via this method is functionally equivalent to calling * usb_reset_device(), except for the fact that it is delayed to a * workqueue. This means that any drivers bound to other interfaces * might be unbound, as well as users from usbfs in user space. * * Corner cases: * * - Scheduling two resets at the same time from two different drivers * attached to two different interfaces of the same device is * possible; depending on how the driver attached to each interface * handles ->pre_reset(), the second reset might happen or not. * * - If a driver is unbound and it had a pending reset, the reset will * be cancelled. * * - This function can be called during .probe() or .disconnect() * times. On return from .disconnect(), any pending resets will be * cancelled. * * There is no no need to lock/unlock the @reset_ws as schedule_work() * does its own. * * NOTE: We don't do any reference count tracking because it is not * needed. The lifecycle of the work_struct is tied to the * usb_interface. Before destroying the interface we cancel the * work_struct, so the fact that work_struct is queued and or * running means the interface (and thus, the device) exist and * are referenced. */ void <API key>(struct usb_interface *iface) { schedule_work(&iface->reset_ws); } EXPORT_SYMBOL_GPL(<API key>);
#ifdef HAVE_CONFIG_H #include "config.h" #endif #include <stdbool.h> #include <stdio.h> #include <string.h> #include "pcep_utils_logging.h" #include "pcep_utils_memory.h" #include "pcep_utils_queue.h" queue_handle *queue_initialize() { /* Set the max_entries to 0 to disable it */ return <API key>(0); } queue_handle *<API key>(unsigned int max_entries) { queue_handle *handle = pceplib_malloc(PCEPLIB_INFRA, sizeof(queue_handle)); memset(handle, 0, sizeof(queue_handle)); handle->max_entries = max_entries; return handle; } void queue_destroy(queue_handle *handle) { if (handle == NULL) { pcep_log( LOG_DEBUG, "%s: queue_destroy, the queue has not been initialized", __func__); return; } while (queue_dequeue(handle) != NULL) { } pceplib_free(PCEPLIB_INFRA, handle); } void <API key>(queue_handle *handle) { if (handle == NULL) { pcep_log( LOG_DEBUG, "%s: <API key>, the queue has not been initialized", __func__); return; } void *data = queue_dequeue(handle); while (data != NULL) { pceplib_free(PCEPLIB_INFRA, data); data = queue_dequeue(handle); } pceplib_free(PCEPLIB_INFRA, handle); } queue_node *queue_enqueue(queue_handle *handle, void *data) { if (handle == NULL) { pcep_log( LOG_DEBUG, "%s: queue_enqueue, the queue has not been initialized", __func__); return NULL; } if (handle->max_entries > 0 && handle->num_entries >= handle->max_entries) { pcep_log( LOG_DEBUG, "%s: queue_enqueue, cannot enqueue: max entries hit [%u]", handle->num_entries); return NULL; } queue_node *new_node = pceplib_malloc(PCEPLIB_INFRA, sizeof(queue_node)); memset(new_node, 0, sizeof(queue_node)); new_node->data = data; new_node->next_node = NULL; (handle->num_entries)++; if (handle->head == NULL) { /* its the first entry in the queue */ handle->head = handle->tail = new_node; } else { handle->tail->next_node = new_node; handle->tail = new_node; } return new_node; } void *queue_dequeue(queue_handle *handle) { if (handle == NULL) { pcep_log( LOG_DEBUG, "%s: queue_dequeue, the queue has not been initialized", __func__); return NULL; } if (handle->head == NULL) { return NULL; } void *node_data = handle->head->data; queue_node *node = handle->head; (handle->num_entries) if (handle->head == handle->tail) { /* its the last entry in the queue */ handle->head = handle->tail = NULL; } else { handle->head = node->next_node; } pceplib_free(PCEPLIB_INFRA, node); return node_data; }
//returns first gram point >t template <class ttype> Double L_function <ttype>:: initialize_gram(Double t) { Double N1=Nmain(t)/2,N2; Double t2=t; Long n1,n2; Double incr=1.01/(Nmain(t+1)/2-N1); Double x,tmp; Double y; Long u; if (incr<0)incr=.1; n1=(Long)(floor(lcalc_to_double(N1))+.1); //Nmain(T) behaves funny near the origin. So, if we are //asking for a small gram point, start at 20, and scan backwards if(N1<=2.){ t2=12; do{ t2=t2-.2; tmp=Nmain(t2)/2; }while(t2>t&&tmp>0); if(t2<t) { t2=t; //if zeta, dirichlet, cusp form for SL2(Z), or maass L-function, //we can return 0 as a gram point if(t==0&&what_type_L<4&&what_type_L!=0) return 0; } else {n1=-1;incr=.2;} } //fudge with the increment until we're sure to capture the next gram point N2=Nmain(t2+incr)/2; n2=(Long)(floor(lcalc_to_double(N2))+.1); if(N2<0)n2 do{ if((n2-n1)<1){incr=incr*1.4; N2=Nmain(t2+incr)/2;n2=(Long)(floor(lcalc_to_double(N2))+.1);if(N2<0)n2 if((n2-n1)>=2){incr=incr*.9; N2=Nmain(t2+incr)/2;n2=(Long)(floor(lcalc_to_double(N2))+.1);if(N2<0)n2 //cout << t2 << " " << t2+incr << " " << n1 << " " << n2 << endl; }while((n2-n1)<1||(n2-n1)>=2); y=t2+incr; //divide and conquer to compute the next gram point for(int i=1;i<=20;i++){ x=(t2+y)/2; tmp=Nmain(x)/2; u=(Long) (floor(lcalc_to_double(tmp))+.1); if(tmp<0) u if(u==n1){ t2=x;} else{ y=x;} //cout << t2 << " " << y << endl; } return x; } //computes the gram point above the current gram point t, i.e. //assumes that t is itself a gram point. //I don't want to use initialize_gram(current_gram) because //the numeric current gram might be slightly smaller than actual current //gram and we might just get the same point template <class ttype> Double L_function <ttype>:: next_gram(Double t) { Double N1=(Nmain(t))/2,N2; Double t2=t; Long n1,n2; Double incr=1.01/((Nmain(t+1))/2-N1); if (incr<0)incr=.1; n1=(Long)(rint(lcalc_to_double(N1))+.1); //n1 is the closest integer to Nmain(t)/2 //fudge with the increment until we're sure to capture the next gram point N2=(Nmain(t2+incr))/2; n2=(Long)(floor(lcalc_to_double(N2))+.1); do{ if((n2-n1)<1){incr=incr*1.4; N2=Nmain(t2+incr)/2;n2=(Long)(floor(lcalc_to_double((N2)))+.1);} if((n2-n1)>=2){incr=incr*.9; N2=Nmain(t2+incr)/2;n2=(Long)(floor(lcalc_to_double((N2)))+.1);} //cout << N1 << " " << N2 << " " << n1 << " " << n2 << endl; }while((n2-n1)<1||(n2-n1)>=2); Double x; Double y=t2+incr; //divide and conquer to compute the next gram point for(int i=1;i<=20;i++){ x=(t2+y)/2; if(((Long)(floor(lcalc_to_double(Nmain(x)/2))+.1))==n1){ t2=x;} else{ y=x;} //cout << t2 << " " << y << endl; } //cout << x << " " << Nmain(x)/2 << endl; return x; } //find the nth gram point t such that Nmain(t)/2=n template <class ttype> Double L_function <ttype>:: nth_gram(Long n) { if(n==0) return 0.; Double t=1000.,r,x,b=Double(n)*Double(n)*tolerance_sqrd; do{ x=(n-.5*Nmain(t)); r=.5*(Nmain(t-.05)-Nmain(t+.05))*10; //this is essentially Newton's method, but with a crude approximation //for the derivative. Works reasonably well. Reason for approx: in case //n, hence t, is large, we won't have much precision left over for the derivative. t-=x/r; if(my_verbose>3) cout << "nth_gram("<< n << "): N(" << t << " )/2=" << Nmain(t)/2 << " , difference:" << x << endl; }while(x*x>b); return t; }
#ifndef _NIOS_SEMAPHORE_H #define _NIOS_SEMAPHORE_H /* Dinky, good for nothing, just barely irq safe, Nios semaphores. */ #ifdef __KERNEL__ #include <asm/atomic.h> #include <linux/wait.h> #include <linux/rwsem.h> struct semaphore { atomic_t count; int sleepers; wait_queue_head_t wait; #if WAITQUEUE_DEBUG long __magic; #endif }; #if WAITQUEUE_DEBUG # define __SEM_DEBUG_INIT(name) \ , (long)&(name).__magic #else # define __SEM_DEBUG_INIT(name) #endif #define <API key>(name,count) \ { ATOMIC_INIT(count), 0, <API key>((name).wait) \ __SEM_DEBUG_INIT(name) } #define __MUTEX_INITIALIZER(name) \ <API key>(name,1) #define <API key>(name,count) \ struct semaphore name = <API key>(name,count) #define DECLARE_MUTEX(name) <API key>(name,1) #define <API key>(name) <API key>(name,0) static inline void sema_init (struct semaphore *sem, int val) { atomic_set(&sem->count, val); sem->sleepers = 0; init_waitqueue_head(&sem->wait); #if WAITQUEUE_DEBUG sem->__magic = (long)&sem->__magic; #endif } static inline void init_MUTEX (struct semaphore *sem) { sema_init(sem, 1); } static inline void init_MUTEX_LOCKED (struct semaphore *sem) { sema_init(sem, 0); } extern void __down(struct semaphore * sem); extern int <API key>(struct semaphore * sem); extern int __down_trylock (struct semaphore * sem); extern void __up(struct semaphore * sem); /* * This isn't quite as clever as the x86 side, but the gp register * makes things a bit more complicated on the alpha.. */ extern inline void down(struct semaphore * sem) { if (atomic_dec_return(&sem->count) < 0) __down(sem); } extern inline int down_interruptible(struct semaphore * sem) { int ret = 0; if(atomic_dec_return(&sem->count) < 0) ret = <API key>(sem); return ret; } extern inline int down_trylock (struct semaphore *sem) { int ret = 0; if (atomic_dec_return (&sem->count) < 0) ret = __down_trylock(sem); return ret; } extern inline void up(struct semaphore * sem) { if (atomic_inc_return(&sem->count) <= 0) __up(sem); } #endif /* __KERNEL__ */ #endif /* !(_NIOS_SEMAPHORE_H) */
Ext.define('Pandora.view.Viewport', { extend: 'Ext.container.Viewport', layout: 'fit', requires: [ 'Pandora.view.NewStation', 'Pandora.view.SongControls', 'Pandora.view.StationsList', 'Pandora.view.<API key>', 'Pandora.view.SongInfo' ], initComponent: function() { this.items = { dockedItems: [{ dock: 'top', xtype: 'toolbar', height: 80, items: [{ xtype: 'newstation', width: 150 }, { xtype: 'songcontrols', flex: 1 }, { xtype: 'component', html: 'Pandora<br>Internet Radio' }] }], layout: { type: 'hbox', align: 'stretch' }, items: [{ width: 250, xtype: 'panel', layout: { type: 'vbox', align: 'stretch' }, items: [{ xtype: 'stationslist', flex: 1 }, { html: 'Ad', height: 250, xtype: 'panel' }] }, { xtype: 'container', flex: 1, border: false, layout: { type: 'vbox', align: 'stretch' }, items: [{ xtype: '<API key>', height: 250 }, { xtype: 'songinfo', flex: 1 }] }] }; this.callParent(); } });
#ifdef P4_TO_P8 #include <p8est_bits.h> #include <p8est_points.h> #include <p8est_vtk.h> #else #include <p4est_bits.h> #include <p4est_points.h> #include <p4est_vtk.h> #endif /* !P4_TO_P8 */ #include <sc_io.h> /* * Usage: p4est_points <configuration> <level> <prefix> * possible configurations: * o unit Refinement on the unit square. * o three Refinement on a forest with three trees. * o moebius Refinement on a 5-tree Moebius band. * o star Refinement on a 6-tree star shaped domain. * o periodic Refinement on the unit square with periodic b.c. */ static p4est_quadrant_t * read_points (const char *filename, p4est_topidx_t num_trees, p4est_locidx_t * num_points) { int retval; int qshift; unsigned ucount, u, ignored; double x, y, z; double qlen; double *point_buffer; p4est_quadrant_t *points, *q; FILE *file; file = fopen (filename, "rb"); SC_CHECK_ABORTF (file != NULL, "Open file %s", filename); sc_fread (&ucount, sizeof (unsigned int), 1, file, "Read point count"); point_buffer = P4EST_ALLOC (double, 3 * ucount); sc_fread (point_buffer, sizeof (double), (size_t) (3 * ucount), file, "Read points"); retval = fclose (file); SC_CHECK_ABORTF (retval == 0, "Close file %s", filename); q = points = P4EST_ALLOC_ZERO (p4est_quadrant_t, ucount); qlen = (double) (1 << P4EST_QMAXLEVEL); qshift = P4EST_MAXLEVEL - P4EST_QMAXLEVEL; for (ignored = u = 0; u < ucount; ++u) { x = point_buffer[3 * u + 0]; y = point_buffer[3 * u + 1]; z = point_buffer[3 * u + 2]; if (x < 0. || x > 1. || y < 0. || y > 1. || z < 0. || z > 1.) { ++ignored; continue; } q->x = (p4est_qcoord_t) (x * qlen) << qshift; q->x = SC_MIN (q->x, P4EST_ROOT_LEN - 1); q->y = (p4est_qcoord_t) (y * qlen) << qshift; q->y = SC_MIN (q->y, P4EST_ROOT_LEN - 1); #ifdef P4_TO_P8 q->z = (p4est_qcoord_t) (z * qlen) << qshift; q->z = SC_MIN (q->z, P4EST_ROOT_LEN - 1); #endif q->level = P4EST_MAXLEVEL; q->p.which_tree = (p4est_topidx_t) ((double) num_trees * rand () / (RAND_MAX + 1.0)); P4EST_ASSERT (<API key> (q, 1)); ++q; } P4EST_FREE (point_buffer); if (num_points != NULL) { *num_points = (p4est_locidx_t) (ucount - ignored); } return points; } int main (int argc, char **argv) { int mpiret; int num_procs, rank; int maxlevel; int wrongusage; char buffer[BUFSIZ]; p4est_locidx_t num_points, max_points; <API key> *conn; p4est_quadrant_t *points; p4est_t *p4est; sc_MPI_Comm mpicomm; const char *usage; /* initialize MPI and p4est internals */ mpiret = sc_MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); mpicomm = sc_MPI_COMM_WORLD; mpiret = sc_MPI_Comm_size (mpicomm, &num_procs); SC_CHECK_MPI (mpiret); mpiret = sc_MPI_Comm_rank (mpicomm, &rank); SC_CHECK_MPI (mpiret); sc_init (mpicomm, 1, 1, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); /* process command line arguments */ usage = "Arguments: <configuration> <level> <maxpoints> <prefix>\n" " Configuration can be any of\n" #ifndef P4_TO_P8 " unit|three|moebius|star|periodic\n" #else " unit|periodic|rotwrap|twocubes|rotcubes\n" #endif " Level controls the maximum depth of refinement\n" " Maxpoints is the maximum number of points per quadrant\n" " which applies to all quadrants above maxlevel\n" " A value of 0 refines recursively to maxlevel\n" " A value of -1 does no refinement at all\n" " Prefix is for loading a point data file\n"; wrongusage = 0; if (!wrongusage && argc != 5) { wrongusage = 1; } conn = NULL; if (!wrongusage) { #ifndef P4_TO_P8 if (!strcmp (argv[1], "unit")) { conn = <API key> (); } else if (!strcmp (argv[1], "three")) { conn = <API key> (); } else if (!strcmp (argv[1], "moebius")) { conn = <API key> (); } else if (!strcmp (argv[1], "star")) { conn = <API key> (); } else if (!strcmp (argv[1], "periodic")) { conn = <API key> (); } #else if (!strcmp (argv[1], "unit")) { conn = <API key> (); } else if (!strcmp (argv[1], "periodic")) { conn = <API key> (); } else if (!strcmp (argv[1], "rotwrap")) { conn = <API key> (); } else if (!strcmp (argv[1], "twocubes")) { conn = <API key> (); } else if (!strcmp (argv[1], "rotcubes")) { conn = <API key> (); } #endif else { wrongusage = 1; } } if (!wrongusage) { maxlevel = atoi (argv[2]); if (maxlevel < 0 || maxlevel > P4EST_QMAXLEVEL) { wrongusage = 1; } } if (!wrongusage) { max_points = (p4est_locidx_t) atoi (argv[3]); if (max_points < -1) { wrongusage = 1; } } if (wrongusage) { P4EST_GLOBAL_LERROR (usage); sc_abort_collective ("Usage error"); } snprintf (buffer, BUFSIZ, "%s%d_%d.pts", argv[4], rank, num_procs); points = read_points (buffer, conn->num_trees, &num_points); SC_LDEBUGF ("Read %lld points\n", (long long) num_points); p4est = p4est_new_points (mpicomm, conn, maxlevel, points, num_points, max_points, 5, NULL, NULL); P4EST_FREE (points); <API key> (p4est, NULL, P4EST_STRING "_points_created"); p4est_partition (p4est, 0, NULL); <API key> (p4est, NULL, P4EST_STRING "_points_partition"); p4est_balance (p4est, P4EST_CONNECT_FULL, NULL); <API key> (p4est, NULL, P4EST_STRING "_points_balance"); p4est_destroy (p4est); <API key> (conn); /* clean up and exit */ sc_finalize (); mpiret = sc_MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }
#include <linux/earlysuspend.h> #include <linux/init.h> #include <linux/module.h> #include <linux/cpufreq.h> #include <linux/workqueue.h> #include <linux/completion.h> #include <linux/cpu.h> #include <linux/cpumask.h> #include <linux/sched.h> #include <linux/suspend.h> #include <mach/socinfo.h> #include <mach/cpufreq.h> #include "acpuclock.h" struct cpufreq_work_struct { struct work_struct work; struct cpufreq_policy *policy; struct completion complete; int frequency; int status; }; static DEFINE_PER_CPU(struct cpufreq_work_struct, cpufreq_work); static struct workqueue_struct *msm_cpufreq_wq; struct cpufreq_suspend_t { struct mutex suspend_mutex; int device_suspended; }; static DEFINE_PER_CPU(struct cpufreq_suspend_t, cpufreq_suspend); struct cpu_freq { uint32_t max; uint32_t min; uint32_t allowed_max; uint32_t allowed_min; uint32_t limits_init; }; static DEFINE_PER_CPU(struct cpu_freq, cpu_freq_info); #ifdef CONFIG_SEC_DVFS static unsigned int upper_limit_freq; static unsigned int lower_limit_freq; static unsigned int cpuinfo_max_freq; static unsigned int cpuinfo_min_freq; unsigned int get_min_lock(void) { return lower_limit_freq; } unsigned int get_max_lock(void) { return upper_limit_freq; } void set_min_lock(int freq) { if (freq <= MIN_FREQ_LIMIT) lower_limit_freq = 0; else if (freq > MAX_FREQ_LIMIT) lower_limit_freq = 0; else lower_limit_freq = freq; } void set_max_lock(int freq) { if (freq < MIN_FREQ_LIMIT) upper_limit_freq = 0; else if (freq >= MAX_FREQ_LIMIT) upper_limit_freq = 0; else upper_limit_freq = freq; } int get_max_freq(void) { return cpuinfo_max_freq; } int get_min_freq(void) { return cpuinfo_min_freq; } #endif static int set_cpu_freq(struct cpufreq_policy *policy, unsigned int new_freq) { int ret = 0; int saved_sched_policy = -EINVAL; int saved_sched_rt_prio = -EINVAL; struct cpufreq_freqs freqs; struct cpu_freq *limit = &per_cpu(cpu_freq_info, policy->cpu); struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 }; if (limit->limits_init) { if (new_freq > limit->allowed_max) { new_freq = limit->allowed_max; pr_debug("max: limiting freq to %d\n", new_freq); } if (new_freq < limit->allowed_min) { new_freq = limit->allowed_min; pr_debug("min: limiting freq to %d\n", new_freq); } } #ifdef CONFIG_SEC_DVFS if (lower_limit_freq || upper_limit_freq) { unsigned int t_freq = new_freq; if (lower_limit_freq && new_freq < lower_limit_freq) t_freq = lower_limit_freq; if (upper_limit_freq && new_freq > upper_limit_freq) t_freq = upper_limit_freq; new_freq = t_freq; if (new_freq < policy->min) new_freq = policy->min; if (new_freq > policy->max) new_freq = policy->max; if (new_freq == policy->cur) return 0; } #endif freqs.old = policy->cur; freqs.new = new_freq; freqs.cpu = policy->cpu; /* * Put the caller into SCHED_FIFO priority to avoid cpu starvation * in the acpuclk_set_rate path while increasing frequencies */ if (freqs.new > freqs.old && current->policy != SCHED_FIFO) { saved_sched_policy = current->policy; saved_sched_rt_prio = current->rt_priority; <API key>(current, SCHED_FIFO, &param); } <API key>(&freqs, CPUFREQ_PRECHANGE); ret = acpuclk_set_rate(policy->cpu, new_freq, SETRATE_CPUFREQ); if (!ret) <API key>(&freqs, CPUFREQ_POSTCHANGE); /* Restore priority after clock ramp-up */ if (freqs.new > freqs.old && saved_sched_policy >= 0) { param.sched_priority = saved_sched_rt_prio; <API key>(current, saved_sched_policy, &param); } return ret; } static void set_cpu_work(struct work_struct *work) { struct cpufreq_work_struct *cpu_work = container_of(work, struct cpufreq_work_struct, work); cpu_work->status = set_cpu_freq(cpu_work->policy, cpu_work->frequency); complete(&cpu_work->complete); } static int msm_cpufreq_target(struct cpufreq_policy *policy, unsigned int target_freq, unsigned int relation) { int ret = -EFAULT; int index; struct <API key> *table; struct cpufreq_work_struct *cpu_work = NULL; cpumask_var_t mask; if (!cpu_active(policy->cpu)) { pr_info("cpufreq: cpu %d is not active.\n", policy->cpu); return -ENODEV; } if (!alloc_cpumask_var(&mask, GFP_KERNEL)) return -ENOMEM; mutex_lock(&per_cpu(cpufreq_suspend, policy->cpu).suspend_mutex); if (per_cpu(cpufreq_suspend, policy->cpu).device_suspended) { pr_debug("cpufreq: cpu%d scheduling frequency change " "in suspend.\n", policy->cpu); ret = -EFAULT; goto done; } table = <API key>(policy->cpu); if (<API key>(policy, table, target_freq, relation, &index)) { pr_err("cpufreq: invalid target_freq: %d\n", target_freq); ret = -EINVAL; goto done; } pr_debug("CPU[%d] target %d relation %d (%d-%d) selected %d\n", policy->cpu, target_freq, relation, policy->min, policy->max, table[index].frequency); cpu_work = &per_cpu(cpufreq_work, policy->cpu); cpu_work->policy = policy; cpu_work->frequency = table[index].frequency; cpu_work->status = -ENODEV; cpumask_clear(mask); cpumask_set_cpu(policy->cpu, mask); if (cpumask_equal(mask, &current->cpus_allowed)) { ret = set_cpu_freq(cpu_work->policy, cpu_work->frequency); goto done; } else { cancel_work_sync(&cpu_work->work); INIT_COMPLETION(cpu_work->complete); queue_work_on(policy->cpu, msm_cpufreq_wq, &cpu_work->work); wait_for_completion(&cpu_work->complete); } ret = cpu_work->status; done: free_cpumask_var(mask); mutex_unlock(&per_cpu(cpufreq_suspend, policy->cpu).suspend_mutex); return ret; } static int msm_cpufreq_verify(struct cpufreq_policy *policy) { <API key>(policy, policy->cpuinfo.min_freq, policy->cpuinfo.max_freq); return 0; } static unsigned int <API key>(unsigned int cpu) { return acpuclk_get_rate(cpu); } static inline int <API key>(void) { int cpu = 0; int i = 0; struct <API key> *table = NULL; uint32_t min = (uint32_t) -1; uint32_t max = 0; struct cpu_freq *limit = NULL; <API key>(cpu) { limit = &per_cpu(cpu_freq_info, cpu); table = <API key>(cpu); if (table == NULL) { pr_err("%s: error reading cpufreq table for cpu %d\n", __func__, cpu); continue; } for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { if (table[i].frequency > max) max = table[i].frequency; if (table[i].frequency < min) min = table[i].frequency; } limit->allowed_min = min; limit->allowed_max = max; limit->min = min; limit->max = max; limit->limits_init = 1; } return 0; } int <API key>(uint32_t cpu, uint32_t min, uint32_t max) { struct cpu_freq *limit = &per_cpu(cpu_freq_info, cpu); if (!limit->limits_init) <API key>(); if ((min != <API key>) && min >= limit->min && min <= limit->max) limit->allowed_min = min; else limit->allowed_min = limit->min; if ((max != <API key>) && max <= limit->max && max >= limit->min) limit->allowed_max = max; else limit->allowed_max = limit->max; pr_debug("%s: Limiting cpu %d min = %d, max = %d\n", __func__, cpu, limit->allowed_min, limit->allowed_max); return 0; } EXPORT_SYMBOL(<API key>); static int __cpuinit msm_cpufreq_init(struct cpufreq_policy *policy) { int cur_freq; int index; struct <API key> *table; struct cpufreq_work_struct *cpu_work = NULL; table = <API key>(policy->cpu); if (table == NULL) return -ENODEV; /* * In 8625 both cpu core's frequency can not * be changed independently. Each cpu is bound to * same frequency. Hence set the cpumask to all cpu. */ if (cpu_is_msm8625()) cpumask_setall(policy->cpus); if (<API key>(policy, table)) { #ifdef <API key> policy->cpuinfo.min_freq = <API key>; policy->cpuinfo.max_freq = <API key>; #endif } #ifdef <API key> policy->min = <API key>; policy->max = <API key>; #endif #ifdef CONFIG_SEC_DVFS cpuinfo_max_freq = policy->cpuinfo.max_freq; cpuinfo_min_freq = policy->cpuinfo.min_freq; #endif cur_freq = acpuclk_get_rate(policy->cpu); if (<API key>(policy, table, cur_freq, CPUFREQ_RELATION_H, &index) && <API key>(policy, table, cur_freq, CPUFREQ_RELATION_L, &index)) { pr_info("cpufreq: cpu%d at invalid freq: %d\n", policy->cpu, cur_freq); return -EINVAL; } if (cur_freq != table[index].frequency) { int ret = 0; ret = acpuclk_set_rate(policy->cpu, table[index].frequency, SETRATE_CPUFREQ); if (ret) return ret; pr_info("cpufreq: cpu%d init at %d switching to %d\n", policy->cpu, cur_freq, table[index].frequency); cur_freq = table[index].frequency; } policy->cur = cur_freq; policy->cpuinfo.transition_latency = <API key>() * NSEC_PER_USEC; cpu_work = &per_cpu(cpufreq_work, policy->cpu); INIT_WORK(&cpu_work->work, set_cpu_work); init_completion(&cpu_work->complete); return 0; } #ifdef <API key> extern bool lmf_screen_state; #endif static void <API key>(struct early_suspend *h) { #ifdef <API key> int cpu = 0; <API key>(cpu) { mutex_lock(&per_cpu(cpufreq_suspend, cpu).suspend_mutex); lmf_screen_state = false; mutex_unlock(&per_cpu(cpufreq_suspend, cpu).suspend_mutex); } #endif } static void msm_cpu_late_resume(struct early_suspend *h) { #ifdef <API key> int cpu = 0; <API key>(cpu) { mutex_lock(&per_cpu(cpufreq_suspend, cpu).suspend_mutex); lmf_screen_state = true; mutex_unlock(&per_cpu(cpufreq_suspend, cpu).suspend_mutex); } #endif } static struct early_suspend <API key> = { .level = <API key>, .suspend = <API key>, .resume = msm_cpu_late_resume, }; static int __cpuinit <API key>(struct notifier_block *nfb, unsigned long action, void *hcpu) { unsigned int cpu = (unsigned long)hcpu; switch (action) { case CPU_ONLINE: case CPU_ONLINE_FROZEN: per_cpu(cpufreq_suspend, cpu).device_suspended = 0; break; case CPU_DOWN_PREPARE: case <API key>: mutex_lock(&per_cpu(cpufreq_suspend, cpu).suspend_mutex); per_cpu(cpufreq_suspend, cpu).device_suspended = 1; mutex_unlock(&per_cpu(cpufreq_suspend, cpu).suspend_mutex); break; case CPU_DOWN_FAILED: case <API key>: per_cpu(cpufreq_suspend, cpu).device_suspended = 0; break; } return NOTIFY_OK; } static struct notifier_block __refdata <API key> = { .notifier_call = <API key>, }; /* * Define suspend/resume for cpufreq_driver. Kernel will call * these during suspend/resume with interrupts disabled. This * helps the suspend/resume variable get's updated before cpufreq * governor tries to change the frequency after coming out of suspend. */ static int msm_cpufreq_suspend(struct cpufreq_policy *policy) { int cpu; <API key>(cpu) { per_cpu(cpufreq_suspend, cpu).device_suspended = 1; } return 0; } static int msm_cpufreq_resume(struct cpufreq_policy *policy) { int cpu; <API key>(cpu) { per_cpu(cpufreq_suspend, cpu).device_suspended = 0; } return 0; } static struct freq_attr *msm_freq_attr[] = { &<API key>, NULL, }; static struct cpufreq_driver msm_cpufreq_driver = { /* lps calculations are handled here. */ .flags = CPUFREQ_STICKY | CPUFREQ_CONST_LOOPS, .init = msm_cpufreq_init, .verify = msm_cpufreq_verify, .target = msm_cpufreq_target, .get = <API key>, .suspend = msm_cpufreq_suspend, .resume = msm_cpufreq_resume, .name = "msm", .attr = msm_freq_attr, }; static int __init <API key>(void) { int cpu; <API key>(cpu) { mutex_init(&(per_cpu(cpufreq_suspend, cpu).suspend_mutex)); per_cpu(cpufreq_suspend, cpu).device_suspended = 0; } msm_cpufreq_wq = create_workqueue("msm-cpufreq"); <API key>(&<API key>); return <API key>(&msm_cpufreq_driver); } late_initcall(<API key>);
(function($){ $(document).ready(function() { // var tooltips = $( "[data-description]" ).tooltip( { items: '[data-description]' } ); var tooltips = $( ".description" ).tooltip({ content: function () { return $(this).prop('title'); }, position: { my: "center bottom-20", at: "center top", }, hide: { delay: 2000 } }); }); })(jQuery);
package com.achep.acdisplay.plugins.xposed; import android.util.Log; import com.achep.base.Device; import de.robv.android.xposed.<API key>; import de.robv.android.xposed.XC_MethodHook; import static de.robv.android.xposed.XposedHelpers.findAndHookMethod; /** * Android shows you an help message when you first start an app in Immersive Mode. * When you press the 'OK' button, Android sets a flag to remember you saw * this message, and stops showing it in the future for this app. * <p/> * However, Android resets this flag when a panicking user is detected. * This is a safeguard measure to help people who don't know what's happening * (if they dismissed the message without reading it.) Panicking is detected when * the user turns the screen on and off more than once within 5 seconds. * <p/> * This module makes the method responsible for this check do nothing, thus removing this annoyance. */ public class <API key> implements <API key> { private static final String TAG = "xposed:ImmersivePanic"; @Override public void initZygote(StartupParam startupParam) throws Throwable { if (Device.hasLollipopApi()) { // Unfortunately this removes all immersive panic reports, // not only about AcDisplay. XC_MethodHook hook = new XC_MethodHook() { @Override protected void beforeHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable { param.setResult(null); } }; findAndHookMethod( "com.android.internal.policy.impl.<API key>", null, "handlePanic", hook); } else { XC_MethodHook hook = new XC_MethodHook() { @Override protected void beforeHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable { String pkg = (String) param.args[0]; if (pkg != null && pkg.startsWith("com.achep.acdisplay")) { param.setResult(null); Log.i(TAG, "An unconfirmation of AcDisplay\'s immersive mode passed to hell."); } } }; findAndHookMethod( "com.android.internal.policy.impl.<API key>", null, "unconfirmPackage", String.class, hook); } } }
#ifndef <API key> #define <API key> #include <linux/types.h> #include <sound/control.h> struct device; /* widget has no PM register bit */ #define SND_SOC_NOPM -1 /* * SoC dynamic audio power management * * We can have up to 4 power domains * 1. Codec domain - VREF, VMID * Usually controlled at codec probe/remove, although can be set * at stream time if power is not needed for sidetone, etc. * 2. Platform/Machine domain - physically connected inputs and outputs * Is platform/machine and user action specific, is set in the machine * driver and by userspace e.g when HP are inserted * 3. Path domain - Internal codec path mixers * Are automatically set when mixer and mux settings are * changed by the user. * 4. Stream domain - DAC's and ADC's. * Enabled when stream playback/capture is started. */ /* codec domain */ #define SND_SOC_DAPM_VMID(wname) \ { .id = snd_soc_dapm_vmid, .name = wname, .kcontrol_news = NULL, \ .num_kcontrols = 0} /* platform domain */ #define SND_SOC_DAPM_SIGGEN(wname) \ { .id = snd_soc_dapm_siggen, .name = wname, .kcontrol_news = NULL, \ .num_kcontrols = 0, .reg = SND_SOC_NOPM } #define SND_SOC_DAPM_INPUT(wname) \ { .id = snd_soc_dapm_input, .name = wname, .kcontrol_news = NULL, \ .num_kcontrols = 0, .reg = SND_SOC_NOPM } #define SND_SOC_DAPM_OUTPUT(wname) \ { .id = snd_soc_dapm_output, .name = wname, .kcontrol_news = NULL, \ .num_kcontrols = 0, .reg = SND_SOC_NOPM } #define SND_SOC_DAPM_MIC(wname, wevent) \ { .id = snd_soc_dapm_mic, .name = wname, .kcontrol_news = NULL, \ .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \ .event_flags = <API key> | <API key>} #define SND_SOC_DAPM_HP(wname, wevent) \ { .id = snd_soc_dapm_hp, .name = wname, .kcontrol_news = NULL, \ .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \ .event_flags = <API key> | <API key>} #define SND_SOC_DAPM_SPK(wname, wevent) \ { .id = snd_soc_dapm_spk, .name = wname, .kcontrol_news = NULL, \ .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \ .event_flags = <API key> | <API key>} #define SND_SOC_DAPM_LINE(wname, wevent) \ { .id = snd_soc_dapm_line, .name = wname, .kcontrol_news = NULL, \ .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \ .event_flags = <API key> | <API key>} #define <API key>(wreg, wshift, winvert) \ .reg = wreg, .mask = 1, .shift = wshift, \ .on_val = winvert ? 0 : 1, .off_val = winvert ? 1 : 0 #define SND_SOC_DAPM_DEMUX(wname, wreg, wshift, winvert, wcontrols) \ { .id = snd_soc_dapm_demux, .name = wname, \ <API key>(wreg, wshift, winvert), \ .kcontrol_news = wcontrols, .num_kcontrols = 1} /* path domain */ #define SND_SOC_DAPM_PGA(wname, wreg, wshift, winvert,\ wcontrols, wncontrols) \ { .id = snd_soc_dapm_pga, .name = wname, \ <API key>(wreg, wshift, winvert), \ .kcontrol_news = wcontrols, .num_kcontrols = wncontrols} #define <API key>(wname, wreg, wshift, winvert,\ wcontrols, wncontrols) \ { .id = <API key>, .name = wname, \ <API key>(wreg, wshift, winvert), \ .kcontrol_news = wcontrols, .num_kcontrols = wncontrols} #define SND_SOC_DAPM_MIXER(wname, wreg, wshift, winvert, \ wcontrols, wncontrols)\ { .id = snd_soc_dapm_mixer, .name = wname, \ <API key>(wreg, wshift, winvert), \ .kcontrol_news = wcontrols, .num_kcontrols = wncontrols} #define <API key>(wname, wreg, wshift, winvert, \ wcontrols, wncontrols)\ { .id = <API key>, .name = wname, \ <API key>(wreg, wshift, winvert), \ .kcontrol_news = wcontrols, .num_kcontrols = wncontrols} #define <API key>(wname, wreg, wshift, winvert) \ { .id = <API key>, .name = wname, \ <API key>(wreg, wshift, winvert), \ .kcontrol_news = NULL, .num_kcontrols = 0} #define SND_SOC_DAPM_SWITCH(wname, wreg, wshift, winvert, wcontrols) \ { .id = snd_soc_dapm_switch, .name = wname, \ <API key>(wreg, wshift, winvert), \ .kcontrol_news = wcontrols, .num_kcontrols = 1} #define SND_SOC_DAPM_MUX(wname, wreg, wshift, winvert, wcontrols) \ { .id = snd_soc_dapm_mux, .name = wname, \ <API key>(wreg, wshift, winvert), \ .kcontrol_news = wcontrols, .num_kcontrols = 1} /* Simplified versions of above macros, assuming wncontrols = ARRAY_SIZE(wcontrols) */ #define SOC_PGA_ARRAY(wname, wreg, wshift, winvert,\ wcontrols) \ { .id = snd_soc_dapm_pga, .name = wname, \ <API key>(wreg, wshift, winvert), \ .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols)} #define SOC_MIXER_ARRAY(wname, wreg, wshift, winvert, \ wcontrols)\ { .id = snd_soc_dapm_mixer, .name = wname, \ <API key>(wreg, wshift, winvert), \ .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols)} #define <API key>(wname, wreg, wshift, winvert, \ wcontrols)\ { .id = <API key>, .name = wname, \ <API key>(wreg, wshift, winvert), \ .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols)} /* path domain with event - event handler must return 0 for success */ #define SND_SOC_DAPM_PGA_E(wname, wreg, wshift, winvert, wcontrols, \ wncontrols, wevent, wflags) \ { .id = snd_soc_dapm_pga, .name = wname, \ <API key>(wreg, wshift, winvert), \ .kcontrol_news = wcontrols, .num_kcontrols = wncontrols, \ .event = wevent, .event_flags = wflags} #define <API key>(wname, wreg, wshift, winvert, wcontrols, \ wncontrols, wevent, wflags) \ { .id = <API key>, .name = wname, \ <API key>(wreg, wshift, winvert), \ .kcontrol_news = wcontrols, .num_kcontrols = wncontrols, \ .event = wevent, .event_flags = wflags} #define <API key>(wname, wreg, wshift, winvert, wcontrols, \ wncontrols, wevent, wflags) \ { .id = snd_soc_dapm_mixer, .name = wname, \ <API key>(wreg, wshift, winvert), \ .kcontrol_news = wcontrols, .num_kcontrols = wncontrols, \ .event = wevent, .event_flags = wflags} #define <API key>(wname, wreg, wshift, winvert, \ wcontrols, wncontrols, wevent, wflags) \ { .id = snd_soc_dapm_mixer, .name = wname, \ <API key>(wreg, wshift, winvert), \ .kcontrol_news = wcontrols, \ .num_kcontrols = wncontrols, .event = wevent, .event_flags = wflags} #define <API key>(wname, wreg, wshift, winvert, wcontrols, \ wevent, wflags) \ { .id = snd_soc_dapm_switch, .name = wname, \ <API key>(wreg, wshift, winvert), \ .kcontrol_news = wcontrols, .num_kcontrols = 1, \ .event = wevent, .event_flags = wflags} #define SND_SOC_DAPM_MUX_E(wname, wreg, wshift, winvert, wcontrols, \ wevent, wflags) \ { .id = snd_soc_dapm_mux, .name = wname, \ <API key>(wreg, wshift, winvert), \ .kcontrol_news = wcontrols, .num_kcontrols = 1, \ .event = wevent, .event_flags = wflags} /* additional sequencing control within an event type */ #define SND_SOC_DAPM_PGA_S(wname, wsubseq, wreg, wshift, winvert, \ wevent, wflags) \ { .id = snd_soc_dapm_pga, .name = wname, \ <API key>(wreg, wshift, winvert), \ .event = wevent, .event_flags = wflags, \ .subseq = wsubseq} #define <API key>(wname, wsubseq, wreg, wshift, winvert, wevent, \ wflags) \ { .id = snd_soc_dapm_supply, .name = wname, \ <API key>(wreg, wshift, winvert), \ .event = wevent, .event_flags = wflags, .subseq = wsubseq} /* Simplified versions of above macros, assuming wncontrols = ARRAY_SIZE(wcontrols) */ #define SOC_PGA_E_ARRAY(wname, wreg, wshift, winvert, wcontrols, \ wevent, wflags) \ { .id = snd_soc_dapm_pga, .name = wname, \ <API key>(wreg, wshift, winvert), \ .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols), \ .event = wevent, .event_flags = wflags} #define SOC_MIXER_E_ARRAY(wname, wreg, wshift, winvert, wcontrols, \ wevent, wflags) \ { .id = snd_soc_dapm_mixer, .name = wname, \ <API key>(wreg, wshift, winvert), \ .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols), \ .event = wevent, .event_flags = wflags} #define <API key>(wname, wreg, wshift, winvert, \ wcontrols, wevent, wflags) \ { .id = snd_soc_dapm_mixer, .name = wname, \ <API key>(wreg, wshift, winvert), \ .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols), \ .event = wevent, .event_flags = wflags} /* events that are pre and post DAPM */ #define SND_SOC_DAPM_PRE(wname, wevent) \ { .id = snd_soc_dapm_pre, .name = wname, .kcontrol_news = NULL, \ .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \ .event_flags = <API key> | <API key>} #define SND_SOC_DAPM_POST(wname, wevent) \ { .id = snd_soc_dapm_post, .name = wname, .kcontrol_news = NULL, \ .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \ .event_flags = <API key> | <API key>} /* stream domain */ #define SND_SOC_DAPM_AIF_IN(wname, stname, wslot, wreg, wshift, winvert) \ { .id = snd_soc_dapm_aif_in, .name = wname, .sname = stname, \ <API key>(wreg, wshift, winvert), } #define <API key>(wname, stname, wslot, wreg, wshift, winvert, \ wevent, wflags) \ { .id = snd_soc_dapm_aif_in, .name = wname, .sname = stname, \ <API key>(wreg, wshift, winvert), \ .event = wevent, .event_flags = wflags } #define <API key>(wname, stname, wslot, wreg, wshift, winvert) \ { .id = <API key>, .name = wname, .sname = stname, \ <API key>(wreg, wshift, winvert), } #define <API key>(wname, stname, wslot, wreg, wshift, winvert, \ wevent, wflags) \ { .id = <API key>, .name = wname, .sname = stname, \ <API key>(wreg, wshift, winvert), \ .event = wevent, .event_flags = wflags } #define SND_SOC_DAPM_DAC(wname, stname, wreg, wshift, winvert) \ { .id = snd_soc_dapm_dac, .name = wname, .sname = stname, \ <API key>(wreg, wshift, winvert) } #define SND_SOC_DAPM_DAC_E(wname, stname, wreg, wshift, winvert, \ wevent, wflags) \ { .id = snd_soc_dapm_dac, .name = wname, .sname = stname, \ <API key>(wreg, wshift, winvert), \ .event = wevent, .event_flags = wflags} #define SND_SOC_DAPM_ADC(wname, stname, wreg, wshift, winvert) \ { .id = snd_soc_dapm_adc, .name = wname, .sname = stname, \ <API key>(wreg, wshift, winvert), } #define SND_SOC_DAPM_ADC_E(wname, stname, wreg, wshift, winvert, \ wevent, wflags) \ { .id = snd_soc_dapm_adc, .name = wname, .sname = stname, \ <API key>(wreg, wshift, winvert), \ .event = wevent, .event_flags = wflags} #define <API key>(wname) \ { .id = <API key>, .name = wname, \ .reg = SND_SOC_NOPM, .event = dapm_clock_event, \ .event_flags = <API key> | <API key> } /* generic widgets */ #define SND_SOC_DAPM_REG(wid, wname, wreg, wshift, wmask, won_val, woff_val) \ { .id = wid, .name = wname, .kcontrol_news = NULL, .num_kcontrols = 0, \ .reg = wreg, .shift = wshift, .mask = wmask, \ .on_val = won_val, .off_val = woff_val, } #define SND_SOC_DAPM_SUPPLY(wname, wreg, wshift, winvert, wevent, wflags) \ { .id = snd_soc_dapm_supply, .name = wname, \ <API key>(wreg, wshift, winvert), \ .event = wevent, .event_flags = wflags} #define <API key>(wname, wdelay, wflags) \ { .id = <API key>, .name = wname, \ .reg = SND_SOC_NOPM, .shift = wdelay, .event = <API key>, \ .event_flags = <API key> | <API key>, \ .on_val = wflags} /* dapm kcontrol types */ #define SOC_DAPM_SINGLE(xname, reg, shift, max, invert) \ { .iface = <API key>, .name = xname, \ .info = snd_soc_info_volsw, \ .get = <API key>, .put = <API key>, \ .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) } #define <API key>(xname, reg, shift, max, invert) \ { .iface = <API key>, .name = xname, \ .info = snd_soc_info_volsw, \ .get = <API key>, .put = <API key>, \ .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 1) } #define <API key>(xname, max) \ SOC_DAPM_SINGLE(xname, SND_SOC_NOPM, 0, max, 0) #define SOC_DAPM_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \ { .iface = <API key>, .name = xname, \ .info = snd_soc_info_volsw, \ .access = <API key> | <API key>,\ .tlv.p = (tlv_array), \ .get = <API key>, .put = <API key>, \ .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) } #define <API key>(xname, reg, shift, max, invert, tlv_array) \ { .iface = <API key>, .name = xname, \ .info = snd_soc_info_volsw, \ .access = <API key> | <API key>,\ .tlv.p = (tlv_array), \ .get = <API key>, .put = <API key>, \ .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 1) } #define <API key>(xname, max, tlv_array) \ SOC_DAPM_SINGLE(xname, SND_SOC_NOPM, 0, max, 0, tlv_array) #define SOC_DAPM_ENUM(xname, xenum) \ { .iface = <API key>, .name = xname, \ .info = <API key>, \ .get = <API key>, \ .put = <API key>, \ .private_value = (unsigned long)&xenum } #define SOC_DAPM_ENUM_EXT(xname, xenum, xget, xput) \ { .iface = <API key>, .name = xname, \ .info = <API key>, \ .get = xget, \ .put = xput, \ .private_value = (unsigned long)&xenum } #define SOC_DAPM_PIN_SWITCH(xname) \ { .iface = <API key>, .name = xname " Switch", \ .info = <API key>, \ .get = <API key>, \ .put = <API key>, \ .private_value = (unsigned long)xname } #define <API key>(wname, wreg, wshift, winvert, wevent, wflags) \ { .id = <API key>, .name = wname, \ <API key>(wreg, wshift, winvert), \ .kcontrol_news = NULL, .num_kcontrols = 0, \ .event = wevent, .event_flags = wflags} /* dapm stream operations */ #define <API key> 0x0 #define <API key> 0x1 #define <API key> 0x2 #define <API key> 0x4 #define <API key> 0x8 #define <API key> 0x10 #define <API key> 0x20 /* dapm event types */ #define <API key> 0x1 /* before widget power up */ #define <API key> 0x2 /* after widget power up */ #define <API key> 0x4 /* before widget power down */ #define <API key> 0x8 /* after widget power down */ #define <API key> 0x10 /* before audio path setup */ #define <API key> 0x20 /* after audio path setup */ #define <API key> 0x40 /* called at start of sequence */ #define <API key> 0x80 /* called at start of sequence */ #define <API key> \ (<API key> | <API key>) /* convenience event type detection */ #define <API key>(e) \ (e & (<API key> | <API key>)) #define <API key>(e) \ (e & (<API key> | <API key>)) /* regulator widget flags */ #define <API key> 0x1 /* bypass when disabled */ struct snd_soc_dapm_widget; enum snd_soc_dapm_type; struct snd_soc_dapm_path; struct snd_soc_dapm_pin; struct snd_soc_dapm_route; struct <API key>; struct regulator; struct <API key>; struct snd_soc_dapm_update; int <API key>(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event); int dapm_clock_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event); /* dapm controls */ int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo); int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *uncontrol); int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *uncontrol); int <API key>(struct <API key> *dapm, const struct snd_soc_dapm_widget *widget, int num); int <API key>(struct <API key> *dapm, struct snd_soc_dai *dai); int <API key>(struct snd_soc_card *card); void <API key>(struct snd_soc_card *card); int <API key>(struct snd_soc_card *card, const struct snd_soc_pcm_stream *params, struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink); /* dapm path setup */ int <API key>(struct snd_soc_card *card); void snd_soc_dapm_free(struct <API key> *dapm); int <API key>(struct <API key> *dapm, const struct snd_soc_dapm_route *route, int num); int <API key>(struct <API key> *dapm, const struct snd_soc_dapm_route *route, int num); int <API key>(struct <API key> *dapm, const struct snd_soc_dapm_route *route, int num); /* dapm events */ void <API key>(struct snd_soc_pcm_runtime *rtd, int stream, int event); void <API key>(struct snd_soc_card *card); /* external DAPM widget events */ int <API key>(struct <API key> *dapm, struct snd_kcontrol *kcontrol, int connect, struct snd_soc_dapm_update *update); int <API key>(struct <API key> *dapm, struct snd_kcontrol *kcontrol, int mux, struct soc_enum *e, struct snd_soc_dapm_update *update); /* dapm sys fs - used by the core */ int <API key>(struct device *dev); void <API key>(struct <API key> *dapm, struct dentry *parent); /* dapm audio pin control and status */ int <API key>(struct <API key> *dapm, const char *pin); int <API key>(struct <API key> *dapm, const char *pin); int <API key>(struct <API key> *dapm, const char *pin); int <API key>(struct <API key> *dapm, const char *pin); int snd_soc_dapm_nc_pin(struct <API key> *dapm, const char *pin); int <API key>(struct <API key> *dapm, const char *pin); int <API key>(struct <API key> *dapm, const char *pin); int snd_soc_dapm_sync(struct <API key> *dapm); int <API key>(struct <API key> *dapm); int <API key>(struct <API key> *dapm, const char *pin); int <API key>(struct <API key> *dapm, const char *pin); int <API key>(struct <API key> *dapm, const char *pin); void <API key>(struct snd_soc_card *card); unsigned int <API key>(const struct snd_kcontrol *kcontrol); /* Mostly internal - should not normally be used */ void dapm_mark_io_dirty(struct <API key> *dapm); /* dapm path query */ int <API key>(struct snd_soc_dai *dai, int stream, struct <API key> **list); struct snd_soc_codec *<API key>(struct snd_kcontrol *kcontrol); struct <API key> *<API key>( struct snd_kcontrol *kcontrol); struct <API key> *<API key>( const struct snd_kcontrol *kcontrol); struct <API key> *<API key>( struct snd_kcontrol *kcontrol); /* dapm widget types */ enum snd_soc_dapm_type { snd_soc_dapm_input = 0, /* input pin */ snd_soc_dapm_output, /* output pin */ snd_soc_dapm_mux, /* selects 1 analog signal from many inputs */ snd_soc_dapm_demux, /* connects the input of one multiple outputs */ snd_soc_dapm_mixer, /* mixes several analog signals together */ <API key>, /* mixer with named controls */ snd_soc_dapm_pga, /* programmable gain/attenuation (volume) */ <API key>, /* output driver */ snd_soc_dapm_adc, /* analog to digital converter */ snd_soc_dapm_dac, /* digital to analog converter */ <API key>, /* microphone bias (power) */ snd_soc_dapm_mic, /* microphone */ snd_soc_dapm_hp, /* headphones */ snd_soc_dapm_spk, /* speaker */ snd_soc_dapm_line, /* line input/output */ snd_soc_dapm_switch, /* analog switch */ snd_soc_dapm_vmid, /* codec bias/vmid - to minimise pops */ snd_soc_dapm_pre, /* machine specific pre widget - exec first */ snd_soc_dapm_post, /* machine specific post widget - exec last */ snd_soc_dapm_supply, /* power/clock supply */ <API key>, /* external regulator */ <API key>, /* external clock */ snd_soc_dapm_aif_in, /* audio interface input */ <API key>, /* audio interface output */ snd_soc_dapm_siggen, /* signal generator */ snd_soc_dapm_dai_in, /* link to DAI structure */ <API key>, <API key>, /* link between two DAI structures */ <API key>, /* Auto-disabled kcontrol */ }; enum <API key> { <API key> = 0, <API key> = 1, }; /* * DAPM audio route definition. * * Defines an audio route originating at source via control and finishing * at sink. */ struct snd_soc_dapm_route { const char *sink; const char *control; const char *source; /* Note: currently only supported for links where source is a supply */ int (*connected)(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink); }; /* dapm audio path between two widgets */ struct snd_soc_dapm_path { const char *name; /* source (input) and sink (output) widgets */ struct snd_soc_dapm_widget *source; struct snd_soc_dapm_widget *sink; /* status */ u32 connect:1; /* source and sink widgets are connected */ u32 walked:1; /* path has been walked */ u32 walking:1; /* path is in the process of being walked */ u32 weak:1; /* path ignored for power management */ int (*connected)(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink); struct list_head list_source; struct list_head list_sink; struct list_head list_kcontrol; struct list_head list; }; /* dapm widget */ struct snd_soc_dapm_widget { enum snd_soc_dapm_type id; const char *name; /* widget name */ const char *sname; /* stream name */ struct snd_soc_codec *codec; struct list_head list; struct <API key> *dapm; void *priv; /* widget specific data */ struct regulator *regulator; /* attached regulator */ const struct snd_soc_pcm_stream *params; /* params for dai links */ /* dapm control */ int reg; /* negative reg = no direct dapm */ unsigned char shift; /* bits to shift */ unsigned int mask; /* non-shifted mask */ unsigned int on_val; /* on state value */ unsigned int off_val; /* off state value */ unsigned char power:1; /* block power status */ unsigned char active:1; /* active stream on DAC, ADC's */ unsigned char connected:1; /* connected codec pin */ unsigned char new:1; /* cnew complete */ unsigned char ext:1; /* has external widgets */ unsigned char force:1; /* force state */ unsigned char ignore_suspend:1; /* kept enabled over suspend */ unsigned char new_power:1; /* power from this run */ unsigned char power_checked:1; /* power checked this run */ int subseq; /* sort within widget type */ int (*power_check)(struct snd_soc_dapm_widget *w); /* external events */ unsigned short event_flags; /* flags to specify event types */ int (*event)(struct snd_soc_dapm_widget*, struct snd_kcontrol *, int); /* kcontrols that relate to this widget */ int num_kcontrols; const struct snd_kcontrol_new *kcontrol_news; struct snd_kcontrol **kcontrols; /* widget input and outputs */ struct list_head sources; struct list_head sinks; /* used during DAPM updates */ struct list_head power_list; struct list_head dirty; int inputs; int outputs; struct clk *clk; }; struct snd_soc_dapm_update { struct snd_kcontrol *kcontrol; int reg; int mask; int val; }; /* DAPM context */ struct <API key> { enum snd_soc_bias_level bias_level; enum snd_soc_bias_level suspend_bias_level; struct delayed_work delayed_work; unsigned int idle_bias_off:1; /* Use BIAS_OFF instead of STANDBY */ /* Go to BIAS_OFF in suspend if the DAPM context is idle */ unsigned int suspend_bias_off:1; void (*seq_notifier)(struct <API key> *, enum snd_soc_dapm_type, int); struct device *dev; /* from parent - for debug */ struct snd_soc_component *component; /* parent component */ struct snd_soc_card *card; /* parent card */ /* used during DAPM updates */ enum snd_soc_bias_level target_bias_level; struct list_head list; int (*stream_event)(struct <API key> *dapm, int event); int (*set_bias_level)(struct <API key> *dapm, enum snd_soc_bias_level level); #ifdef CONFIG_DEBUG_FS struct dentry *debugfs_dapm; #endif }; /* A list of widgets associated with an object, typically a snd_kcontrol */ struct <API key> { int num_widgets; struct snd_soc_dapm_widget *widgets[0]; }; struct snd_soc_dapm_stats { int power_checks; int path_checks; int neighbour_checks; }; #endif
<div class="page-header"> <h1 class="entry-title" itemprop="name"> <?php echo apply_filters('kadence_page_title', kadence_title() ); ?> </h1> <?php global $post; if(is_page()) { $bsub = get_post_meta( $post->ID, '_kad_subtitle', true ); if(!empty($bsub)){ echo '<p class="subtitle"> '.__($bsub).' </p>'; } } else if(is_category()) { echo '<p class="subtitle">'.__(<API key>()).' </p>'; } ?> </div>
#include <linux/kernel.h> #include <linux/gpio.h> #include <linux/platform_device.h> #include <asm/mach-types.h> #include <mach/board.h> #include <mach/board_lge.h> #include <mach/qdsp5v2/msm_lpa.h> #include <linux/mfd/marimba.h> #include <mach/qdsp5v2/aux_pcm.h> #include <mach/qdsp5v2/mi2s.h> #include <mach/qdsp5v2/audio_dev_ctl.h> #include <mach/rpc_server_handset.h> #include "mach/qdsp5v2/lge_tpa2055-amp.h" #include <mach/pmic.h> #include <mach/rpc_pmapp.h> #if defined(<API key>) #define PMIC_VIBRATOR_LEVEL (3000) static struct <API key> m3s_vibrator_data = { .max_timeout_ms = 30000, /* max time for vibrator enable 30 sec. */ .level_mV = PMIC_VIBRATOR_LEVEL, }; static struct platform_device m3s_vibrator_device = { .name = "msm7x30_pm8058-vib", .id = -1, .dev = { .platform_data = &m3s_vibrator_data, }, }; #endif /*<API key>*/ // matthew.choi@lge.com 111003 for M3S Rev.B #if (<API key> == LGE_REV_A) #define GPIO_AMP_I2C_SDA 89 #define GPIO_AMP_I2C_SCL 88 #else #define GPIO_AMP_I2C_SDA 92 #define GPIO_AMP_I2C_SCL 93 #endif static struct gpio_i2c_pin lge_amp_i2c_pin[] = { [0] = { .sda_pin = GPIO_AMP_I2C_SDA, .scl_pin = GPIO_AMP_I2C_SCL, }, }; static struct <API key> lge_amp_i2c_pdata = { .sda_pin = GPIO_AMP_I2C_SDA, .scl_pin = GPIO_AMP_I2C_SCL, .sda_is_open_drain = 0, .scl_is_open_drain = 0, .udelay = 2, }; struct platform_device lge_amp_i2c_device = { .name = "i2c-gpio", .dev.platform_data = &lge_amp_i2c_pdata, }; #if defined(<API key>) && (<API key> < LGE_REV_B) #define GPIO_EAR_SPK_SEL 80 static void <API key>(void) { int err; err = gpio_request(GPIO_EAR_SPK_SEL, "rcv_spk"); if(!err){ <API key>(GPIO_EAR_SPK_SEL, 1); printk(KERN_INFO "gpio_spk_rcv to low\n"); } } static void amp_bypass_switch(bool on) { <API key>(GPIO_EAR_SPK_SEL,on?1: 0); } #endif /*<API key>*/ static struct amp_platform_data lge_amp_data = { .bypass_mode = 1, #if (<API key> == LGE_REV_0) .line_out = false, #else .line_out = true, #endif #if defined(<API key>) && (<API key> < LGE_REV_B) .<API key> = <API key>, .external_bypass = amp_bypass_switch, #endif }; static struct i2c_board_info lge_amp_i2c_bdinfo[] = { [0] = { I2C_BOARD_INFO("lge_tpa2055", 0xE0 >> 1), .platform_data = &lge_amp_data, }, }; /* LGE init function for sound*/ static void __init <API key>(int bus_num, bool platform) { lge_amp_i2c_device.id = bus_num; pr_info("[LGE] Audio subsystem gpio i2c init for (bus num: %d) \n", bus_num); init_gpio_i2c_pin(&lge_amp_i2c_pdata, lge_amp_i2c_pin[0], &lge_amp_i2c_bdinfo[0]); <API key>(bus_num, lge_amp_i2c_bdinfo, ARRAY_SIZE(lge_amp_i2c_bdinfo)); if(platform) <API key>(&lge_amp_i2c_device); } #if defined(<API key>) void <API key>(int on) { if(on){ pmic_hsed_enable(<API key>, <API key>); } else{ pmic_hsed_enable(<API key>, PM_HSED_ENABLE_OFF); } } static struct <API key> m3s_h2w_data = { .gpio_detect = 26, #if (<API key> == LGE_REV_0) .gpio_button_detect = 101, #else .gpio_button_detect = 40, #endif .gpio_jpole = 102, .gpio_mic_bias_en = 103, .mic_bias_power = <API key>, }; static struct platform_device m3s_h2w_device = { .name = "gpio-h2w", .id = -1, .dev = { .platform_data = &m3s_h2w_data, }, }; #endif /*<API key>*/ static struct platform_device *m3s_audio_devices[] __initdata = { #ifdef <API key> &m3s_h2w_device, #endif #if defined(<API key>) &m3s_vibrator_device, #endif }; /* common function */ void __init lge_m3s_audio_init(void) { <API key>(m3s_audio_devices, ARRAY_SIZE(m3s_audio_devices)); <API key>(<API key>,&lge_amp_i2c_pin[0]); }
from gourmet.plugin import ShoppingListPlugin import gtk import gourmet.recipeManager, gourmet.<API key> from gourmet.prefs import get_prefs from nutritionLabel import NutritionLabel import os.path from gettext import gettext as _ class <API key> (ShoppingListPlugin): ui_string = '''<ui> <menubar name="ShoppingListMenuBar"> <menu name="Tools" action="Tools"> <menuitem action="<API key>"/> </menu> </menubar> <toolbar name="<API key>"> <separator/> <toolitem action="<API key>"/> </toolbar> </ui> ''' name = '<API key>' def setup_action_groups (self): self.<API key> = gtk.ActionGroup('<API key>') self.<API key>.add_actions([ ('Tools',None,_('Tools')), ('<API key>', # name 'nutritional-info', # stock _('Nutritional Information'), # label '<Ctrl><Shift>N', #key-command _('Get nutritional information for current list'), self.show_nutinfo # callback ) ]) self.action_groups.append(self.<API key>) def show_nutinfo (self, *args): sg = self.pluggable rr = sg.recs rd = gourmet.recipeManager.get_recipe_manager() rg = gourmet.<API key>.get_application() if not hasattr(self,'nutrition_window'): self.<API key>() nutinfo = None # Add recipes... for rec in rr: ings = rd.get_ings(rec) ni = rd.nd.<API key>(rd.get_ings(rec), rd) if nutinfo: nutinfo = nutinfo + ni else: nutinfo = ni # Add extras... for amt,unit,item in sg.extras: ni = rd.nd.<API key>(item,amt,unit) if nutinfo: nutinfo = nutinfo + ni else: nutinfo = ni self.nl.set_nutinfo(nutinfo) self.nutrition_window.present() def <API key> (self): self.nutrition_window = gtk.Dialog(_('Nutritional Information'), self.pluggable.w, buttons=(gtk.STOCK_CLOSE,gtk.RESPONSE_CLOSE) ) self.nutrition_window.set_default_size(400,550) self.nutrition_window.set_icon( self.nutrition_window.render_icon('nutritional-info', gtk.ICON_SIZE_MENU) ) self.nl = NutritionLabel(get_prefs()) self.sw = gtk.ScrolledWindow(); self.sw.set_policy(gtk.POLICY_NEVER,gtk.POLICY_AUTOMATIC) self.sw.add_with_viewport(self.nl); self.sw.show() self.nutrition_window.vbox.pack_start(self.sw) self.nutrition_window.connect('response',self.response_cb) self.nutrition_window.connect('close',self.response_cb) self.nl.yieldLabel.set_markup('<b>'+_('Amount for Shopping List')+'</b>') self.nl.show() def response_cb (self, *args): # We only allow one response -- closing the window! self.nutrition_window.hide()
TARGET=pkgdetails all: $(TARGET) $(TARGET): $(TARGET).o $(CC) -o $@ $^ $(LDFLAGS) $(TARGET).o: $(TARGET).c $(CC) -c -o $@ $^ $(CFLAGS) clean: $(RM) $(TARGET) $(TARGET).o
#ifdef <API key> #ifndef <API key> #define <API key> #include <linux/dsm_pub.h> /* define a 1024 size of array as buffer */ #define <API key> 1024 #define MSG_MAX_SIZE 200 /* Error code, decimal[5]: 0 is input, 1 is output, 2 I&O * decimal[4:3]: 10 is for eMMC, * decimal[2:1]: for different error code. */ enum DSM_EMMC_ERR { DSM_SYSTEM_W_ERR = 21001, DSM_EMMC_ERASE_ERR, DSM_EMMC_VDET_ERR, <API key>, DSM_EMMC_READ_ERR, DSM_EMMC_WRITE_ERR, }; struct emmc_dsm_log { char emmc_dsm_log[<API key>]; spinlock_t lock; /* mutex */ }; extern struct dsm_client *emmc_dclient; /*buffer for transffering to device radar*/ extern struct emmc_dsm_log g_emmc_dsm_log; extern int dsm_emmc_get_log(void *card, int code, char * err_msg); /*Transfer the msg to device radar*/ #define DSM_EMMC_LOG(card, no, fmt, a...) \ do { \ char msg[MSG_MAX_SIZE]; \ snprintf(msg, MSG_MAX_SIZE-1, fmt, spin_lock(&g_emmc_dsm_log.lock); \ if(dsm_emmc_get_log((card), (no), (msg))){ \ if(!dsm_client_ocuppy(emmc_dclient)) { \ dsm_client_copy(emmc_dclient,g_emmc_dsm_log.emmc_dsm_log, strlen(g_emmc_dsm_log.emmc_dsm_log) + 1); \ dsm_client_notify(emmc_dclient, no); } \ } \ spin_unlock(&g_emmc_dsm_log.lock); \ }while(0) #endif /* <API key> */ #endif /* <API key> */
/** * (not used) */ package simulator.networking;
#include <glib.h> #include <errno.h> #include <unistd.h> #include <sys/syscall.h> #include "sysfuzz.h" #include "typelib.h" #include "iknowthis.h" // Start/stop swapping to file/device. // int swapoff(const char *path); SYSFUZZ(swapoff, SYS_swapoff, SYS_FAIL | SYS_BORING, CLONE_DEFAULT, 0) { glong retcode; gchar *path; retcode = syscall_fast(SYS_swapoff, <API key>(&path)); // const char *path g_free(path); return retcode; }
#include <linux/init.h> #include <linux/err.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/platform_device.h> #include <linux/bitops.h> #include <linux/mutex.h> #include <linux/of_device.h> #include <sound/core.h> #include <sound/soc.h> #include <sound/soc-dapm.h> #include <sound/pcm.h> #include <sound/initval.h> #include <sound/control.h> #include <sound/q6adm-v2.h> #include <sound/q6asm-v2.h> #include <sound/q6afe-v2.h> #include <sound/tlv.h> #include <sound/asound.h> #include <sound/pcm_params.h> #include <sound/q6core.h> #include <linux/slab.h> #include "msm-pcm-routing-v2.h" #include "<API key>.h" #include "q6voice.h" extern u32 score; struct <API key> { u16 port_id; /* AFE port ID */ u8 active; /* track if this backend is enabled */ unsigned long fe_sessions; /* Front-end sessions */ u64 port_sessions; /* track Tx BE ports -> Rx BE * number of BE should not exceed * the size of this field */ unsigned int sample_rate; unsigned int channel; unsigned int format; }; struct <API key> { u16 be_srate; /* track prior backend sample rate for flushing purpose */ int strm_id; /* ASM stream ID */ struct msm_pcm_routing_evt event_info; }; #define INVALID_SESSION -1 #define SESSION_TYPE_RX 0 #define SESSION_TYPE_TX 1 #define MAX_LSM_SESSIONS 8 #define <API key> 1 #define <API key> 2 #define <API key> 3 #define <API key> 4 static struct mutex routing_lock; static int fm_switch_enable; static int <API key>; static int <API key>; static int lsm_mux_slim_port; static int <API key>; static int msm_route_ec_ref_rx = 7; /* NONE */ static uint32_t voc_session_id = ALL_SESSION_VSID; static int <API key> = AFE_PORT_INVALID; enum { MADNONE, MADAUDIO, MADBEACON, MADULTRASOUND, MADSWAUDIO, }; #define SLIMBUS_0_TX_TEXT "SLIMBUS_0_TX" #define SLIMBUS_1_TX_TEXT "SLIMBUS_1_TX" #define SLIMBUS_2_TX_TEXT "SLIMBUS_2_TX" #define SLIMBUS_3_TX_TEXT "SLIMBUS_3_TX" #define SLIMBUS_4_TX_TEXT "SLIMBUS_4_TX" #define SLIMBUS_5_TX_TEXT "SLIMBUS_5_TX" #define LSM_FUNCTION_TEXT "LSM Function" static const char * const mad_audio_mux_text[] = { "None", SLIMBUS_0_TX_TEXT, SLIMBUS_1_TX_TEXT, SLIMBUS_2_TX_TEXT, SLIMBUS_3_TX_TEXT, SLIMBUS_4_TX_TEXT, SLIMBUS_5_TX_TEXT }; #define <API key> 0x2000 #define INT_RX_VOL_GAIN 0x2000 static int <API key>; static const <API key>(fm_rx_vol_gain, 0, <API key>); static int <API key>; static const <API key>(hfp_rx_vol_gain, 0, <API key>); static int <API key>; static const <API key>(<API key>, 0, <API key>); static int <API key>; static const <API key>(<API key>, 0, <API key>); /* Equal to Frontend after last of the MULTIMEDIA SESSIONS */ #define MAX_EQ_SESSIONS <API key> enum { EQ_BAND1 = 0, EQ_BAND2, EQ_BAND3, EQ_BAND4, EQ_BAND5, EQ_BAND6, EQ_BAND7, EQ_BAND8, EQ_BAND9, EQ_BAND10, EQ_BAND11, EQ_BAND12, EQ_BAND_MAX, }; struct msm_audio_eq_band { uint16_t band_idx; /* The band index, 0 .. 11 */ uint32_t filter_type; /* Filter band type */ uint32_t center_freq_hz; /* Filter band center frequency */ uint32_t filter_gain; /* Filter band initial gain (dB) */ /* Range is +12 dB to -12 dB with 1dB increments. */ uint32_t q_factor; } __packed; struct <API key> { uint32_t enable; /* Number of consequtive bands specified */ uint32_t num_bands; struct msm_audio_eq_band eq_bands[EQ_BAND_MAX]; } __packed; struct <API key> eq_data[MAX_EQ_SESSIONS]; static void msm_send_eq_values(int eq_idx); /* This array is indexed by back-end DAI ID defined in msm-pcm-routing.h * If new back-end is defined, add new back-end DAI ID at the end of enum */ #define SRS_TRUMEDIA_INDEX 2 union <API key> { struct srs_trumedia_params srs_params; unsigned short int raw_params[1]; }; static union <API key> <API key>[SRS_TRUMEDIA_INDEX]; static int srs_port_id = -1; static void srs_send_params(int port_id, unsigned int techs, int param_block_idx) { /* only send commands to dsp if srs alsa ctrl was used at least one time */ if (!<API key>) return; pr_debug("SRS %s: called, port_id = %d, techs flags = %u, paramblockidx %d", __func__, port_id, techs, param_block_idx); /* force all if techs is set to 1 */ if (techs == 1) techs = 0xFFFFFFFF; if (techs & (1 << SRS_ID_WOWHD)) srs_trumedia_open(port_id, SRS_ID_WOWHD, (void *)&<API key>[param_block_idx].srs_params.wowhd); if (techs & (1 << SRS_ID_CSHP)) srs_trumedia_open(port_id, SRS_ID_CSHP, (void *)&<API key>[param_block_idx].srs_params.cshp); if (techs & (1 << SRS_ID_HPF)) srs_trumedia_open(port_id, SRS_ID_HPF, (void *)&<API key>[param_block_idx].srs_params.hpf); if (techs & (1 << SRS_ID_PEQ)) srs_trumedia_open(port_id, SRS_ID_PEQ, (void *)&<API key>[param_block_idx].srs_params.peq); if (techs & (1 << SRS_ID_HL)) srs_trumedia_open(port_id, SRS_ID_HL, (void *)&<API key>[param_block_idx].srs_params.hl); if (techs & (1 << SRS_ID_GLOBAL)) srs_trumedia_open(port_id, SRS_ID_GLOBAL, (void *)&<API key>[param_block_idx].srs_params.global); } int get_topology(int path_type) { int topology_id = 0; if (path_type == ADM_PATH_PLAYBACK) topology_id = get_adm_rx_topology(); else topology_id = get_adm_tx_topology(); #ifdef <API key> if((path_type!=ADM_PATH_PLAYBACK) && (topology_id ==0 || 0x00010315/*AUDIO_TX_MONO_COPP*/)) { topology_id = <API key>; } #endif if (topology_id == 0) topology_id = NULL_COPP_TOPOLOGY; return topology_id; } #define SLIMBUS_EXTPROC_RX AFE_PORT_INVALID static struct <API key> msm_bedais[MSM_BACKEND_DAI_MAX] = { { PRIMARY_I2S_RX, 0, 0, 0, 0, 0}, { PRIMARY_I2S_TX, 0, 0, 0, 0, 0}, { SLIMBUS_0_RX, 0, 0, 0, 0, 0}, { SLIMBUS_0_TX, 0, 0, 0, 0, 0}, { HDMI_RX, 0, 0, 0, 0, 0}, { INT_BT_SCO_RX, 0, 0, 0, 0, 0}, { INT_BT_SCO_TX, 0, 0, 0, 0, 0}, { INT_FM_RX, 0, 0, 0, 0, 0}, { INT_FM_TX, 0, 0, 0, 0, 0}, { <API key>, 0, 0, 0, 0, 0}, { <API key>, 0, 0, 0, 0, 0}, { <API key>, 0, 0, 0, 0, 0}, { <API key>, 0, 0, 0, 0, 0}, { VOICE_PLAYBACK_TX, 0, 0, 0, 0, 0}, { VOICE2_PLAYBACK_TX, 0, 0, 0, 0, 0}, { VOICE_RECORD_RX, 0, 0, 0, 0, 0}, { VOICE_RECORD_TX, 0, 0, 0, 0, 0}, { MI2S_RX, 0, 0, 0, 0, 0}, { MI2S_TX, 0, 0, 0, 0}, { SECONDARY_I2S_RX, 0, 0, 0, 0, 0}, { SLIMBUS_1_RX, 0, 0, 0, 0, 0}, { SLIMBUS_1_TX, 0, 0, 0, 0, 0}, { SLIMBUS_4_RX, 0, 0, 0, 0, 0}, { SLIMBUS_4_TX, 0, 0, 0, 0, 0}, { SLIMBUS_3_RX, 0, 0, 0, 0, 0}, { SLIMBUS_3_TX, 0, 0, 0, 0, 0}, { SLIMBUS_5_TX, 0, 0, 0, 0, 0 }, { SLIMBUS_EXTPROC_RX, 0, 0, 0, 0, 0}, { SLIMBUS_EXTPROC_RX, 0, 0, 0, 0, 0}, { SLIMBUS_EXTPROC_RX, 0, 0, 0, 0, 0}, { <API key>, 0, 0, 0, 0, 0}, { <API key>, 0, 0, 0, 0, 0}, { <API key>, 0, 0, 0, 0, 0}, { <API key>, 0, 0, 0, 0, 0}, { <API key>, 0, 0, 0, 0, 0}, { <API key>, 0, 0, 0, 0, 0}, { <API key>, 0, 0, 0, 0, 0}, { <API key>, 0, 0, 0, 0, 0}, { <API key>, 0, 0, 0, 0, 0}, { <API key>, 0, 0, 0, 0, 0}, { <API key>, 0, 0, 0, 0, 0}, }; /* Track ASM playback & capture sessions of DAI */ static struct <API key> fe_dai_map[<API key>][2] = { /* MULTIMEDIA1 */ {{0, INVALID_SESSION, {NULL, NULL} }, {0, INVALID_SESSION, {NULL, NULL} } }, /* MULTIMEDIA2 */ {{0, INVALID_SESSION, {NULL, NULL} }, {0, INVALID_SESSION, {NULL, NULL} } }, /* MULTIMEDIA3 */ {{0, INVALID_SESSION, {NULL, NULL} }, {0, INVALID_SESSION, {NULL, NULL} } }, /* MULTIMEDIA4 */ {{0, INVALID_SESSION, {NULL, NULL} }, {0, INVALID_SESSION, {NULL, NULL} } }, /* MULTIMEDIA5 */ {{0, INVALID_SESSION, {NULL, NULL} }, {0, INVALID_SESSION, {NULL, NULL} } }, /* MULTIMEDIA6 */ {{0, INVALID_SESSION, {NULL, NULL} }, {0, INVALID_SESSION, {NULL, NULL} } }, /* MULTIMEDIA7*/ {{0, INVALID_SESSION, {NULL, NULL} }, {0, INVALID_SESSION, {NULL, NULL} } }, /* MULTIMEDIA8 */ {{0, INVALID_SESSION, {NULL, NULL} }, {0, INVALID_SESSION, {NULL, NULL} } }, /* MULTIMEDIA9 */ {{0, INVALID_SESSION, {NULL, NULL} }, {0, INVALID_SESSION, {NULL, NULL} } }, #ifdef CONFIG_JACK_AUDIO /* MULTIMEDIA10 */ {{0, INVALID_SESSION, {NULL, NULL} }, {0, INVALID_SESSION, {NULL, NULL} } }, #endif }; /* Track performance mode of all front-end multimedia sessions. * Performance mode is only valid when session is valid. */ static int fe_dai_perf_mode[<API key>][2]; static uint8_t is_be_dai_extproc(int be_dai) { if (be_dai == <API key> || be_dai == <API key> || be_dai == <API key>) return 1; else return 0; } static void <API key>(int fedai_id, int dspst_id, int path_type, int perf_mode) { int i, port_type; struct route_payload payload; payload.num_copps = 0; port_type = (path_type == ADM_PATH_PLAYBACK ? <API key> : <API key>); for (i = 0; i < MSM_BACKEND_DAI_MAX; i++) { if (!is_be_dai_extproc(i) && (afe_get_port_type(msm_bedais[i].port_id) == port_type) && (msm_bedais[i].active) && (test_bit(fedai_id, &msm_bedais[i].fe_sessions))) payload.copp_ids[payload.num_copps++] = msm_bedais[i].port_id; } if (payload.num_copps) adm_matrix_map(dspst_id, path_type, payload.num_copps, payload.copp_ids, 0, perf_mode); } void <API key>(int fedai_id, int dspst_id, int stream_type) { int i, session_type, path_type, port_type; u32 mode = 0; if (fedai_id > <API key>) { /* bad ID assigned in machine driver */ pr_err("%s: bad MM ID\n", __func__); return; } if (stream_type == <API key>) { session_type = SESSION_TYPE_RX; path_type = ADM_PATH_PLAYBACK; port_type = <API key>; } else { session_type = SESSION_TYPE_TX; path_type = ADM_PATH_LIVE_REC; port_type = <API key>; } mutex_lock(&routing_lock); fe_dai_map[fedai_id][session_type].strm_id = dspst_id; for (i = 0; i < MSM_BACKEND_DAI_MAX; i++) { if (!is_be_dai_extproc(i) && (afe_get_port_type(msm_bedais[i].port_id) == port_type) && (msm_bedais[i].active) && (test_bit(fedai_id, &msm_bedais[i].fe_sessions))) { mode = afe_get_port_type(msm_bedais[i].port_id); <API key>(mode, dspst_id, msm_bedais[i].port_id); break; } } mutex_unlock(&routing_lock); } void <API key>(int fedai_id, int perf_mode, int dspst_id, int stream_type) { int i, session_type, path_type, port_type, port_id, topology; struct route_payload payload; u32 channels; uint16_t bits_per_sample = 16; if (fedai_id > <API key>) { /* bad ID assigned in machine driver */ pr_err("%s: bad MM ID %d\n", __func__, fedai_id); return; } if (stream_type == <API key>) { session_type = SESSION_TYPE_RX; path_type = ADM_PATH_PLAYBACK; port_type = <API key>; } else { session_type = SESSION_TYPE_TX; path_type = ADM_PATH_LIVE_REC; port_type = <API key>; } mutex_lock(&routing_lock); payload.num_copps = 0; /* only RX needs to use payload */ fe_dai_map[fedai_id][session_type].strm_id = dspst_id; fe_dai_perf_mode[fedai_id][session_type] = perf_mode; /* re-enable EQ if active */ if (eq_data[fedai_id].enable) msm_send_eq_values(fedai_id); topology = get_topology(path_type); for (i = 0; i < MSM_BACKEND_DAI_MAX; i++) { if (!is_be_dai_extproc(i) && (afe_get_port_type(msm_bedais[i].port_id) == port_type) && (msm_bedais[i].active) && (test_bit(fedai_id, &msm_bedais[i].fe_sessions))) { channels = msm_bedais[i].channel; if (msm_bedais[i].format == <API key>) bits_per_sample = 16; else if (msm_bedais[i].format == <API key>) bits_per_sample = 24; if (msm_bedais[i].port_id == VOICE_RECORD_RX || msm_bedais[i].port_id == VOICE_RECORD_TX) topology = <API key>; if ((stream_type == <API key>) && (channels > 0)) <API key>(msm_bedais[i].port_id, path_type, msm_bedais[i].sample_rate, msm_bedais[i].channel, topology, perf_mode, bits_per_sample); else adm_open(msm_bedais[i].port_id, path_type, msm_bedais[i].sample_rate, msm_bedais[i].channel, topology, perf_mode, bits_per_sample); payload.copp_ids[payload.num_copps++] = msm_bedais[i].port_id; port_id = srs_port_id = msm_bedais[i].port_id; srs_send_params(srs_port_id, 1, 0); if ((<API key> == topology) && (perf_mode == LEGACY_PCM_MODE)) if (dolby_dap_init(port_id, msm_bedais[i].channel) < 0) pr_err("%s: Err init dolby dap\n", __func__); } } if (payload.num_copps) adm_matrix_map(dspst_id, path_type, payload.num_copps, payload.copp_ids, 0, perf_mode); mutex_unlock(&routing_lock); } void <API key>(int fedai_id, bool perf_mode, int dspst_id, int stream_type, struct msm_pcm_routing_evt event_info) { <API key>(fedai_id, perf_mode, dspst_id, stream_type); if (stream_type == <API key>) fe_dai_map[fedai_id][SESSION_TYPE_RX].event_info = event_info; else fe_dai_map[fedai_id][SESSION_TYPE_TX].event_info = event_info; } void <API key>(int fedai_id, int stream_type) { int i, port_type, session_type, path_type, topology; if (fedai_id > <API key>) { /* bad ID assigned in machine driver */ pr_err("%s: bad MM ID\n", __func__); return; } if (stream_type == <API key>) { port_type = <API key>; session_type = SESSION_TYPE_RX; path_type = ADM_PATH_PLAYBACK; } else { port_type = <API key>; session_type = SESSION_TYPE_TX; path_type = ADM_PATH_LIVE_REC; } mutex_lock(&routing_lock); topology = get_topology(path_type); for (i = 0; i < MSM_BACKEND_DAI_MAX; i++) { if (!is_be_dai_extproc(i) && (afe_get_port_type(msm_bedais[i].port_id) == port_type) && (msm_bedais[i].active) && (test_bit(fedai_id, &msm_bedais[i].fe_sessions))) { adm_close(msm_bedais[i].port_id, fe_dai_perf_mode[fedai_id][session_type]); if ((<API key> == topology) && (fe_dai_perf_mode[fedai_id][session_type] == LEGACY_PCM_MODE)) dolby_dap_deinit(msm_bedais[i].port_id); } } fe_dai_map[fedai_id][session_type].strm_id = INVALID_SESSION; fe_dai_map[fedai_id][session_type].be_srate = 0; mutex_unlock(&routing_lock); } /* Check if FE/BE route is set */ static bool <API key>(u16 be_id, u16 fe_id) { bool rc = false; if (fe_id > <API key>) { /* recheck FE ID in the mixer control defined in this file */ pr_err("%s: bad MM ID\n", __func__); return rc; } if (test_bit(fe_id, &msm_bedais[be_id].fe_sessions)) rc = true; return rc; } static void <API key>(u16 reg, u16 val, int set) { int session_type, path_type, port_id, topology; u32 channels; uint16_t bits_per_sample = 16; struct <API key> *fdai; pr_debug("%s: reg %x val %x set %x\n", __func__, reg, val, set); if (val > <API key>) { /* recheck FE ID in the mixer control defined in this file */ pr_err("%s: bad MM ID\n", __func__); return; } if (afe_get_port_type(msm_bedais[reg].port_id) == <API key>) { session_type = SESSION_TYPE_RX; path_type = ADM_PATH_PLAYBACK; } else { session_type = SESSION_TYPE_TX; path_type = ADM_PATH_LIVE_REC; } mutex_lock(&routing_lock); topology = get_topology(path_type); if (set) { if (!test_bit(val, &msm_bedais[reg].fe_sessions) && ((msm_bedais[reg].port_id == VOICE_PLAYBACK_TX) || (msm_bedais[reg].port_id == VOICE2_PLAYBACK_TX))) voc_start_playback(set, msm_bedais[reg].port_id); set_bit(val, &msm_bedais[reg].fe_sessions); fdai = &fe_dai_map[val][session_type]; if (msm_bedais[reg].active && fdai->strm_id != INVALID_SESSION) { channels = msm_bedais[reg].channel; if (session_type == SESSION_TYPE_TX && fdai->be_srate && (fdai->be_srate != msm_bedais[reg].sample_rate)) { pr_debug("%s: flush strm %d diff BE rates\n", __func__, fdai->strm_id); if (fdai->event_info.event_func) fdai->event_info.event_func( <API key>, fdai->event_info.priv_data); fdai->be_srate = 0; /* might not need it */ } if (msm_bedais[reg].format == <API key>) bits_per_sample = 24; if (msm_bedais[reg].port_id == VOICE_RECORD_RX || msm_bedais[reg].port_id == VOICE_RECORD_TX) topology = <API key>; if ((session_type == SESSION_TYPE_RX) && (channels > 0)) { <API key>(msm_bedais[reg].port_id, path_type, msm_bedais[reg].sample_rate, channels, topology, fe_dai_perf_mode[val][session_type], bits_per_sample); } else adm_open(msm_bedais[reg].port_id, path_type, msm_bedais[reg].sample_rate, channels, topology, false, bits_per_sample); if (session_type == SESSION_TYPE_RX && fdai->event_info.event_func) fdai->event_info.event_func( <API key>, fdai->event_info.priv_data); <API key>(val, fdai->strm_id, path_type, fe_dai_perf_mode[val][session_type]); port_id = srs_port_id = msm_bedais[reg].port_id; srs_send_params(srs_port_id, 1, 0); if ((<API key> == topology) && (fe_dai_perf_mode[val][session_type] == LEGACY_PCM_MODE)) if (dolby_dap_init(port_id, channels) < 0) pr_err("%s: Err init dolby dap\n", __func__); } } else { if (test_bit(val, &msm_bedais[reg].fe_sessions) && ((msm_bedais[reg].port_id == VOICE_PLAYBACK_TX) || (msm_bedais[reg].port_id == VOICE2_PLAYBACK_TX))) voc_start_playback(set, msm_bedais[reg].port_id); clear_bit(val, &msm_bedais[reg].fe_sessions); fdai = &fe_dai_map[val][session_type]; if (msm_bedais[reg].active && fdai->strm_id != INVALID_SESSION) { adm_close(msm_bedais[reg].port_id, fe_dai_perf_mode[val][session_type]); if ((<API key> == topology) && (fe_dai_perf_mode[val][session_type] == LEGACY_PCM_MODE)) dolby_dap_deinit(msm_bedais[reg].port_id); <API key>(val, fdai->strm_id, path_type, fe_dai_perf_mode[val][session_type]); } } if ((msm_bedais[reg].port_id == VOICE_RECORD_RX) || (msm_bedais[reg].port_id == VOICE_RECORD_TX)) voc_start_record(msm_bedais[reg].port_id, set, voc_session_id); mutex_unlock(&routing_lock); } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; if (test_bit(mc->shift, &msm_bedais[mc->reg].fe_sessions)) ucontrol->value.integer.value[0] = 1; else ucontrol->value.integer.value[0] = 0; pr_debug("%s: reg %x shift %x val %ld\n", __func__, mc->reg, mc->shift, ucontrol->value.integer.value[0]); return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct <API key> *wlist = snd_kcontrol_chip(kcontrol); struct snd_soc_dapm_widget *widget = wlist->widgets[0]; struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; if (ucontrol->value.integer.value[0] && <API key>(mc->reg, mc->shift) == false) { <API key>(mc->reg, mc->shift, 1); <API key>(widget, kcontrol, 1); } else if (!ucontrol->value.integer.value[0] && <API key>(mc->reg, mc->shift) == true) { <API key>(mc->reg, mc->shift, 0); <API key>(widget, kcontrol, 0); } return 1; } static void <API key>(u16 reg, u16 val, int set) { u32 session_id = 0; pr_debug("%s: reg %x val %x set %x\n", __func__, reg, val, set); if (val == <API key>) session_id = voc_get_session_id(VOICE_SESSION_NAME); else if (val == <API key>) session_id = voc_get_session_id(VOLTE_SESSION_NAME); else if (val == <API key>) session_id = voc_get_session_id(VOWLAN_SESSION_NAME); else if (val == <API key>) session_id = voc_get_session_id(VOICE2_SESSION_NAME); else if (val == <API key>) session_id = voc_get_session_id(QCHAT_SESSION_NAME); else session_id = voc_get_session_id(VOIP_SESSION_NAME); pr_debug("%s: FE DAI 0x%x session_id 0x%x\n", __func__, val, session_id); mutex_lock(&routing_lock); if (set) set_bit(val, &msm_bedais[reg].fe_sessions); else clear_bit(val, &msm_bedais[reg].fe_sessions); if (val == <API key> && afe_get_port_type(msm_bedais[reg].port_id) == <API key>) { pr_debug("%s(): set=%d port id=0x%x for dtmf generation\n", __func__, set, msm_bedais[reg].port_id); <API key>(msm_bedais[reg].port_id, set); } mutex_unlock(&routing_lock); if (afe_get_port_type(msm_bedais[reg].port_id) == <API key>) { voc_set_route_flag(session_id, RX_PATH, set); if (set) { voc_set_rxtx_port(session_id, msm_bedais[reg].port_id, DEV_RX); if (voc_get_route_flag(session_id, RX_PATH) && voc_get_route_flag(session_id, TX_PATH)) voc_enable_device(session_id); } else { voc_disable_device(session_id); } } else { voc_set_route_flag(session_id, TX_PATH, set); if (set) { voc_set_rxtx_port(session_id, msm_bedais[reg].port_id, DEV_TX); if (voc_get_route_flag(session_id, RX_PATH) && voc_get_route_flag(session_id, TX_PATH)) voc_enable_device(session_id); } else { voc_disable_device(session_id); } } } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; mutex_lock(&routing_lock); if (test_bit(mc->shift, &msm_bedais[mc->reg].fe_sessions)) ucontrol->value.integer.value[0] = 1; else ucontrol->value.integer.value[0] = 0; mutex_unlock(&routing_lock); pr_debug("%s: reg %x shift %x val %ld\n", __func__, mc->reg, mc->shift, ucontrol->value.integer.value[0]); return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct <API key> *wlist = snd_kcontrol_chip(kcontrol); struct snd_soc_dapm_widget *widget = wlist->widgets[0]; struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; if (ucontrol->value.integer.value[0]) { <API key>(mc->reg, mc->shift, 1); <API key>(widget, kcontrol, 1); } else { <API key>(mc->reg, mc->shift, 0); <API key>(widget, kcontrol, 0); } return 1; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; mutex_lock(&routing_lock); if (test_bit(mc->shift, &msm_bedais[mc->reg].fe_sessions)) ucontrol->value.integer.value[0] = 1; else ucontrol->value.integer.value[0] = 0; mutex_unlock(&routing_lock); pr_debug("%s: reg %x shift %x val %ld\n", __func__, mc->reg, mc->shift, ucontrol->value.integer.value[0]); return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct <API key> *wlist = snd_kcontrol_chip(kcontrol); struct snd_soc_dapm_widget *widget = wlist->widgets[0]; struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; if (ucontrol->value.integer.value[0]) { mutex_lock(&routing_lock); set_bit(mc->shift, &msm_bedais[mc->reg].fe_sessions); mutex_unlock(&routing_lock); <API key>(widget, kcontrol, 1); } else { mutex_lock(&routing_lock); clear_bit(mc->shift, &msm_bedais[mc->reg].fe_sessions); mutex_unlock(&routing_lock); <API key>(widget, kcontrol, 0); } pr_debug("%s: reg %x shift %x val %ld\n", __func__, mc->reg, mc->shift, ucontrol->value.integer.value[0]); return 1; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { ucontrol->value.integer.value[0] = fm_switch_enable; pr_debug("%s: FM Switch enable %ld\n", __func__, ucontrol->value.integer.value[0]); return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct <API key> *wlist = snd_kcontrol_chip(kcontrol); struct snd_soc_dapm_widget *widget = wlist->widgets[0]; pr_debug("%s: FM Switch enable %ld\n", __func__, ucontrol->value.integer.value[0]); if (ucontrol->value.integer.value[0]) <API key>(widget, kcontrol, 1); else <API key>(widget, kcontrol, 0); fm_switch_enable = ucontrol->value.integer.value[0]; return 1; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { ucontrol->value.integer.value[0] = <API key>; pr_debug("%s: FM Switch enable %ld\n", __func__, ucontrol->value.integer.value[0]); return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct <API key> *wlist = snd_kcontrol_chip(kcontrol); struct snd_soc_dapm_widget *widget = wlist->widgets[0]; pr_debug("%s: FM Switch enable %ld\n", __func__, ucontrol->value.integer.value[0]); if (ucontrol->value.integer.value[0]) <API key>(widget, kcontrol, 1); else <API key>(widget, kcontrol, 0); <API key> = ucontrol->value.integer.value[0]; return 1; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { ucontrol->value.integer.value[0] = lsm_mux_slim_port; return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct <API key> *wlist = snd_kcontrol_chip(kcontrol); struct snd_soc_dapm_widget *widget = wlist->widgets[0]; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; int mux = ucontrol->value.enumerated.item[0]; pr_debug("%s: LSM enable %ld\n", __func__, ucontrol->value.integer.value[0]); if (ucontrol->value.integer.value[0]) { lsm_mux_slim_port = ucontrol->value.integer.value[0]; <API key>(widget, kcontrol, 1, mux, e); } else { <API key>(widget, kcontrol, 1, mux, e); lsm_mux_slim_port = ucontrol->value.integer.value[0]; } return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int i; u16 port_id; enum afe_mad_type mad_type; pr_debug("%s: enter\n", __func__); for (i = 0; i < ARRAY_SIZE(mad_audio_mux_text); i++) if (!strncmp(kcontrol->id.name, mad_audio_mux_text[i], strlen(mad_audio_mux_text[i]))) break; if (i-- == ARRAY_SIZE(mad_audio_mux_text)) { WARN(1, "Invalid id name %s\n", kcontrol->id.name); return -EINVAL; } port_id = i * 2 + 1 + SLIMBUS_0_RX; mad_type = <API key>(port_id); pr_debug("%s: port_id 0x%x, mad_type %d\n", __func__, port_id, mad_type); switch (mad_type) { case MAD_HW_NONE: ucontrol->value.integer.value[0] = MADNONE; break; case MAD_HW_AUDIO: ucontrol->value.integer.value[0] = MADAUDIO; break; case MAD_HW_BEACON: ucontrol->value.integer.value[0] = MADBEACON; break; case MAD_HW_ULTRASOUND: ucontrol->value.integer.value[0] = MADULTRASOUND; break; case MAD_SW_AUDIO: ucontrol->value.integer.value[0] = MADSWAUDIO; break; default: WARN(1, "Unknown\n"); return -EINVAL; } return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int i; u16 port_id; enum afe_mad_type mad_type; pr_debug("%s: enter\n", __func__); for (i = 0; i < ARRAY_SIZE(mad_audio_mux_text); i++) if (!strncmp(kcontrol->id.name, mad_audio_mux_text[i], strlen(mad_audio_mux_text[i]))) break; if (i-- == ARRAY_SIZE(mad_audio_mux_text)) { WARN(1, "Invalid id name %s\n", kcontrol->id.name); return -EINVAL; } port_id = i * 2 + 1 + SLIMBUS_0_RX; switch (ucontrol->value.integer.value[0]) { case MADNONE: mad_type = MAD_HW_NONE; break; case MADAUDIO: mad_type = MAD_HW_AUDIO; break; case MADBEACON: mad_type = MAD_HW_BEACON; break; case MADULTRASOUND: mad_type = MAD_HW_ULTRASOUND; break; case MADSWAUDIO: mad_type = MAD_SW_AUDIO; break; default: WARN(1, "Unknown\n"); return -EINVAL; } pr_debug("%s: port_id 0x%x, mad_type %d\n", __func__, port_id, mad_type); return <API key>(port_id, mad_type); } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { mutex_lock(&routing_lock); ucontrol->value.integer.value[0] = <API key>; mutex_unlock(&routing_lock); pr_debug("%s: AANC Mux Port %ld\n", __func__, ucontrol->value.integer.value[0]); return 0; }; static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct aanc_data aanc_info; mutex_lock(&routing_lock); memset(&aanc_info, 0x00, sizeof(aanc_info)); pr_debug("%s: AANC Mux Port %ld\n", __func__, ucontrol->value.integer.value[0]); <API key> = ucontrol->value.integer.value[0]; if (ucontrol->value.integer.value[0] == 0) { aanc_info.aanc_active = false; aanc_info.aanc_tx_port = 0; aanc_info.aanc_rx_port = 0; } else { aanc_info.aanc_active = true; aanc_info.aanc_rx_port = SLIMBUS_0_RX; aanc_info.aanc_tx_port = (SLIMBUS_0_RX - 1 + (<API key> * 2)); } afe_set_aanc_info(&aanc_info); mutex_unlock(&routing_lock); return 0; }; static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; if (test_bit(mc->shift, (unsigned long *)&msm_bedais[mc->reg].port_sessions)) ucontrol->value.integer.value[0] = 1; else ucontrol->value.integer.value[0] = 0; pr_debug("%s: reg %x shift %x val %ld\n", __func__, mc->reg, mc->shift, ucontrol->value.integer.value[0]); return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; pr_debug("%s: reg 0x%x shift 0x%x val %ld\n", __func__, mc->reg, mc->shift, ucontrol->value.integer.value[0]); if (ucontrol->value.integer.value[0]) { afe_loopback(1, msm_bedais[mc->reg].port_id, msm_bedais[mc->shift].port_id); set_bit(mc->shift, (unsigned long *)&msm_bedais[mc->reg].port_sessions); } else { afe_loopback(0, msm_bedais[mc->reg].port_id, msm_bedais[mc->shift].port_id); clear_bit(mc->shift, (unsigned long *)&msm_bedais[mc->reg].port_sessions); } return 1; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { ucontrol->value.integer.value[0] = <API key>; return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { afe_loopback_gain(INT_FM_TX , ucontrol->value.integer.value[0]); <API key> = ucontrol->value.integer.value[0]; return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { ucontrol->value.integer.value[0] = <API key>; return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { afe_loopback_gain(INT_BT_SCO_TX , ucontrol->value.integer.value[0]); <API key> = ucontrol->value.integer.value[0]; return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { ucontrol->value.integer.value[0] = <API key>; return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { ucontrol->value.integer.value[0] = <API key>; return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { if (!<API key>(ucontrol->value.integer.value[0])) <API key> = ucontrol->value.integer.value[0]; return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { if (!<API key>(ucontrol->value.integer.value[0])) <API key> = ucontrol->value.integer.value[0]; return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { char channel_map[<API key>] = {0}; int i; <API key>(channel_map); for (i = 0; i < <API key>; i++) ucontrol->value.integer.value[i] = (unsigned) channel_map[i]; return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { char channel_map[<API key>]; int i; for (i = 0; i < <API key>; i++) channel_map[i] = (char)(ucontrol->value.integer.value[i]); <API key>(channel_map); return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { ucontrol->value.integer.value[0] = 0; return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { unsigned int techs = 0; unsigned short offset, value, max, index; <API key> = 1; max = sizeof(<API key>) >> 1; index = (unsigned short)((ucontrol->value.integer.value[0] & <API key>) >> 31); if (SRS_CMD_UPLOAD == (ucontrol->value.integer.value[0] & SRS_CMD_UPLOAD)) { techs = ucontrol->value.integer.value[0] & 0xFF; pr_debug("SRS %s: send params request, flags = %u", __func__, techs); if (srs_port_id >= 0 && techs) srs_send_params(srs_port_id, techs, index); return 0; } offset = (unsigned short)((ucontrol->value.integer.value[0] & <API key>) >> 16); value = (unsigned short)(ucontrol->value.integer.value[0] & <API key>); if ((offset < max) && (index < SRS_TRUMEDIA_INDEX)) { <API key>[index].raw_params[offset] = value; pr_debug("SRS %s: index set... (max %d, requested %d, val %d, paramblockidx %d)", __func__, max, offset, value, index); } else { pr_err("SRS %s: index out of bounds! (max %d, requested %d)", __func__, max, offset); } if (offset == 4) { int i; for (i = 0; i < max; i++) { if (i == 0) { pr_debug("SRS %s: global block start", __func__); } if (i == (sizeof(struct <API key>) >> 1)) { pr_debug("SRS %s: wowhd block start at offset %d word offset %d", __func__, i, i>>1); break; } pr_debug("SRS %s: param_index %d index %d val %d", __func__, index, i, <API key>[index].raw_params[i]); } } return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int ret; pr_debug("SRS control normal called"); mutex_lock(&routing_lock); srs_port_id = SLIMBUS_0_RX; ret = <API key>(kcontrol, ucontrol); mutex_unlock(&routing_lock); return ret; } static int <API key>( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int ret; pr_debug("SRS control I2S called"); mutex_lock(&routing_lock); srs_port_id = PRIMARY_I2S_RX; ret = <API key>(kcontrol, ucontrol); mutex_unlock(&routing_lock); return ret; } static int <API key>( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int ret; pr_debug("SRS control HDMI called"); mutex_lock(&routing_lock); srs_port_id = HDMI_RX; ret = <API key>(kcontrol, ucontrol); mutex_unlock(&routing_lock); return ret; } static void msm_send_eq_values(int eq_idx) { int result; struct audio_client *ac = <API key>( fe_dai_map[eq_idx][SESSION_TYPE_RX].strm_id); if (ac == NULL) { pr_err("%s: Could not get audio client for session: %d\n", __func__, fe_dai_map[eq_idx][SESSION_TYPE_RX].strm_id); goto done; } result = q6asm_equalizer(ac, &eq_data[eq_idx]); if (result < 0) pr_err("%s: Call to ASM equalizer failed, returned = %d\n", __func__, result); done: return; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int eq_idx = ((struct <API key> *) kcontrol->private_value)->reg; ucontrol->value.integer.value[0] = eq_data[eq_idx].enable; pr_debug("%s: EQ #%d enable %d\n", __func__, eq_idx, eq_data[eq_idx].enable); return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int eq_idx = ((struct <API key> *) kcontrol->private_value)->reg; int value = ucontrol->value.integer.value[0]; pr_debug("%s: EQ #%d enable %d\n", __func__, eq_idx, value); eq_data[eq_idx].enable = value; msm_send_eq_values(eq_idx); return 0; } static int <API key>( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int eq_idx = ((struct <API key> *) kcontrol->private_value)->reg; ucontrol->value.integer.value[0] = eq_data[eq_idx].num_bands; pr_debug("%s: EQ #%d bands %d\n", __func__, eq_idx, eq_data[eq_idx].num_bands); return eq_data[eq_idx].num_bands; } static int <API key>( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int eq_idx = ((struct <API key> *) kcontrol->private_value)->reg; int value = ucontrol->value.integer.value[0]; pr_debug("%s: EQ #%d bands %d\n", __func__, eq_idx, value); eq_data[eq_idx].num_bands = value; return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int eq_idx = ((struct <API key> *) kcontrol->private_value)->reg; int band_idx = ((struct <API key> *) kcontrol->private_value)->shift; ucontrol->value.integer.value[0] = eq_data[eq_idx].eq_bands[band_idx].band_idx; ucontrol->value.integer.value[1] = eq_data[eq_idx].eq_bands[band_idx].filter_type; ucontrol->value.integer.value[2] = eq_data[eq_idx].eq_bands[band_idx].center_freq_hz; ucontrol->value.integer.value[3] = eq_data[eq_idx].eq_bands[band_idx].filter_gain; ucontrol->value.integer.value[4] = eq_data[eq_idx].eq_bands[band_idx].q_factor; pr_debug("%s: band_idx = %d\n", __func__, eq_data[eq_idx].eq_bands[band_idx].band_idx); pr_debug("%s: filter_type = %d\n", __func__, eq_data[eq_idx].eq_bands[band_idx].filter_type); pr_debug("%s: center_freq_hz = %d\n", __func__, eq_data[eq_idx].eq_bands[band_idx].center_freq_hz); pr_debug("%s: filter_gain = %d\n", __func__, eq_data[eq_idx].eq_bands[band_idx].filter_gain); pr_debug("%s: q_factor = %d\n", __func__, eq_data[eq_idx].eq_bands[band_idx].q_factor); return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int eq_idx = ((struct <API key> *) kcontrol->private_value)->reg; int band_idx = ((struct <API key> *) kcontrol->private_value)->shift; eq_data[eq_idx].eq_bands[band_idx].band_idx = ucontrol->value.integer.value[0]; eq_data[eq_idx].eq_bands[band_idx].filter_type = ucontrol->value.integer.value[1]; eq_data[eq_idx].eq_bands[band_idx].center_freq_hz = ucontrol->value.integer.value[2]; eq_data[eq_idx].eq_bands[band_idx].filter_gain = ucontrol->value.integer.value[3]; eq_data[eq_idx].eq_bands[band_idx].q_factor = ucontrol->value.integer.value[4]; return 0; } static int msm_sec_sa_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { return 0; } static int msm_sec_vsp_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { return 0; } static int msm_sec_dha_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { return 0; } static int msm_sec_sa_ep_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct audio_client *ac; mutex_lock(&routing_lock); ac = <API key>(fe_dai_map[3][SESSION_TYPE_RX].strm_id); pr_info("%s: sa_ep ret=%d score=%d", __func__, q6asm_get_sa_ep(ac), score); ucontrol->value.integer.value[0] = score; mutex_unlock(&routing_lock); return 0; } static int msm_sec_lrsm_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { return 0; } static int msm_sec_msp_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { return 0; } static int msm_sec_sa_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int ret = 0; struct audio_client *ac; mutex_lock(&routing_lock); ac = <API key>(fe_dai_map[3][SESSION_TYPE_RX].strm_id); ret = q6asm_set_sa(ac,(int*)ucontrol->value.integer.value); mutex_unlock(&routing_lock); return ret; } static int msm_sec_vsp_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int ret = 0; struct audio_client *ac; mutex_lock(&routing_lock); ac = <API key>(fe_dai_map[3][SESSION_TYPE_RX].strm_id); ret = q6asm_set_vsp(ac,(int*)ucontrol->value.integer.value); mutex_unlock(&routing_lock); return ret; } static int msm_sec_dha_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int ret = 0; struct audio_client *ac; mutex_lock(&routing_lock); ac = <API key>(fe_dai_map[3][SESSION_TYPE_RX].strm_id); ret = q6asm_set_dha(ac,(int*)ucontrol->value.integer.value); mutex_unlock(&routing_lock); return ret; } static int msm_sec_lrsm_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int ret = 0; struct audio_client *ac; mutex_lock(&routing_lock); ac = <API key>(fe_dai_map[3][SESSION_TYPE_RX].strm_id); ret = q6asm_set_lrsm(ac,(int*)ucontrol->value.integer.value); mutex_unlock(&routing_lock); return ret; } static int msm_sec_sa_ep_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int ret = 0; struct audio_client *ac; mutex_lock(&routing_lock); ac = <API key>(fe_dai_map[3][SESSION_TYPE_RX].strm_id); ret = q6asm_set_sa_ep(ac,(int*)ucontrol->value.integer.value); mutex_unlock(&routing_lock); return ret; } static int msm_sec_msp_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int ret = 0; struct audio_client *ac; mutex_lock(&routing_lock); ac = <API key>(fe_dai_map[3][SESSION_TYPE_RX].strm_id); ret = q6asm_set_msp(ac, (long*)ucontrol->value.integer.value); mutex_unlock(&routing_lock); return ret; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { pr_debug("%s: ec_ref_rx = %d", __func__, msm_route_ec_ref_rx); ucontrol->value.integer.value[0] = msm_route_ec_ref_rx; return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int ec_ref_port_id; struct <API key> *wlist = snd_kcontrol_chip(kcontrol); struct snd_soc_dapm_widget *widget = wlist->widgets[0]; int mux = ucontrol->value.enumerated.item[0]; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; if (mux >= e->max) { pr_err("%s: Invalid mux value %d\n", __func__, mux); return -EINVAL; } mutex_lock(&routing_lock); switch (ucontrol->value.integer.value[0]) { case 0: msm_route_ec_ref_rx = 0; ec_ref_port_id = AFE_PORT_INVALID; break; case 1: msm_route_ec_ref_rx = 1; ec_ref_port_id = SLIMBUS_0_RX; break; case 2: msm_route_ec_ref_rx = 2; ec_ref_port_id = <API key>; break; case 3: msm_route_ec_ref_rx = 3; ec_ref_port_id = <API key>; break; case 4: msm_route_ec_ref_rx = 4; ec_ref_port_id = <API key>; break; case 5: msm_route_ec_ref_rx = 5; ec_ref_port_id = <API key>; break; case 6: msm_route_ec_ref_rx = 6; ec_ref_port_id = <API key>; break; default: msm_route_ec_ref_rx = 0; /* NONE */ pr_err("%s EC ref rx %ld not valid\n", __func__, ucontrol->value.integer.value[0]); ec_ref_port_id = AFE_PORT_INVALID; break; } adm_ec_ref_rx_id(ec_ref_port_id); pr_debug("%s: msm_route_ec_ref_rx = %d\n", __func__, msm_route_ec_ref_rx); mutex_unlock(&routing_lock); <API key>(widget, kcontrol, 1, mux, e); return 0; } static const char *const ec_ref_rx[] = { "None", "SLIM_RX", "I2S_RX", "PRI_MI2S_TX", "SEC_MI2S_TX", "TERT_MI2S_TX", "QUAT_MI2S_TX", "PROXY_RX"}; static const struct soc_enum <API key>[] = { SOC_ENUM_SINGLE_EXT(8, ec_ref_rx), }; static const struct snd_kcontrol_new ext_ec_ref_mux_ul1 = SOC_DAPM_ENUM_EXT("AUDIO_REF_EC_UL1 MUX Mux", <API key>[0], <API key>, <API key>); static const struct snd_kcontrol_new ext_ec_ref_mux_ul2 = SOC_DAPM_ENUM_EXT("AUDIO_REF_EC_UL2 MUX Mux", <API key>[0], <API key>, <API key>); static const struct snd_kcontrol_new ext_ec_ref_mux_ul4 = SOC_DAPM_ENUM_EXT("AUDIO_REF_EC_UL4 MUX Mux", <API key>[0], <API key>, <API key>); static const struct snd_kcontrol_new ext_ec_ref_mux_ul5 = SOC_DAPM_ENUM_EXT("AUDIO_REF_EC_UL5 MUX Mux", <API key>[0], <API key>, <API key>); static const struct snd_kcontrol_new ext_ec_ref_mux_ul6 = SOC_DAPM_ENUM_EXT("AUDIO_REF_EC_UL6 MUX Mux", <API key>[0], <API key>, <API key>); static const struct snd_kcontrol_new ext_ec_ref_mux_ul8 = SOC_DAPM_ENUM_EXT("AUDIO_REF_EC_UL8 MUX Mux", <API key>[0], <API key>, <API key>); static const struct snd_kcontrol_new ext_ec_ref_mux_ul9 = SOC_DAPM_ENUM_EXT("AUDIO_REF_EC_UL9 MUX Mux", <API key>[0], <API key>, <API key>); static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { pr_debug("%s: ext_ec_ref_rx = %x\n", __func__, <API key>); mutex_lock(&routing_lock); ucontrol->value.integer.value[0] = <API key>; mutex_unlock(&routing_lock); return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct <API key> *wlist = snd_kcontrol_chip(kcontrol); struct snd_soc_dapm_widget *widget = wlist->widgets[0]; int mux = ucontrol->value.enumerated.item[0]; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; int ret = 0; bool state = false; pr_debug("%s: msm_route_ec_ref_rx = %d value = %ld\n", __func__, <API key>, ucontrol->value.integer.value[0]); if (mux >= e->max) { pr_err("%s: Invalid mux value %d\n", __func__, mux); return -EINVAL; } mutex_lock(&routing_lock); switch (ucontrol->value.integer.value[0]) { case <API key>: <API key> = <API key>; state = true; break; case <API key>: <API key> = <API key>; state = true; break; case <API key>: <API key> = <API key>; state = true; break; case <API key>: <API key> = <API key>; state = true; break; default: <API key> = AFE_PORT_INVALID; break; } if (!voc_set_ext_ec_ref(<API key>, state)) { mutex_unlock(&routing_lock); <API key>(widget, kcontrol, 1, mux, e); } else { ret = -EINVAL; mutex_unlock(&routing_lock); } return ret; } static const char * const ext_ec_ref_rx[] = {"NONE", "PRI_MI2S_TX", "SEC_MI2S_TX", "TERT_MI2S_TX", "QUAT_MI2S_TX"}; static const struct soc_enum <API key>[] = { SOC_ENUM_SINGLE_EXT(5, ext_ec_ref_rx), }; static const struct snd_kcontrol_new voc_ext_ec_mux = SOC_DAPM_ENUM_EXT("VOC_EXT_EC MUX Mux", <API key>[0], <API key>, <API key>); static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("MultiMedia1", <API key> , <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia3", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia4", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia5", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia6", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia7", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia8", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia9", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("MultiMedia1", <API key> , <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia3", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia4", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia5", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia6", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia7", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia8", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia9", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("MultiMedia1", <API key> , <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia3", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia4", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia5", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia6", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia7", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia8", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia9", <API key>, <API key>, 1, 0, <API key>, <API key>), #ifdef CONFIG_JACK_AUDIO SOC_SINGLE_EXT("MultiMedia10", <API key>, <API key>, 1, 0, <API key>, <API key>), #endif }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("MultiMedia1", <API key> , <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia3", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia4", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia5", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia6", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia7", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia8", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia9", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("MultiMedia1", <API key> , <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia3", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia4", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia5", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia6", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia7", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia8", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia9", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("MultiMedia1", <API key> , <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia3", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia4", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia5", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia10", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("MultiMedia1", <API key> , <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia3", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia4", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia5", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia6", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia7", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia8", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia9", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("PRI_MI2S_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("INTERNAL_FM_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("MultiMedia1", <API key> , <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia3", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia4", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia5", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia6", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia7", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia8", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia9", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new hdmi_mixer_controls[] = { SOC_SINGLE_EXT("MultiMedia1", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia3", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia4", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia5", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia6", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia7", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia8", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia9", <API key>, <API key>, 1, 0, <API key>, <API key>), }; /* incall music delivery mixer */ static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("MultiMedia1", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia5", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia9", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("MultiMedia1", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia5", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia9", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("MultiMedia1", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia2", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("MultiMedia1", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia3", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia4", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia5", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia6", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia7", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia8", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia9", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("MultiMedia1", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia3", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia4", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia5", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia6", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia7", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia8", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia9", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("MultiMedia1", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia3", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia4", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia5", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia6", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia7", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia8", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia9", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("MultiMedia1", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia3", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia4", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia5", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia6", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia7", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia8", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia9", <API key>, <API key>, 1, 0, <API key>, <API key>), #ifdef CONFIG_JACK_AUDIO SOC_SINGLE_EXT("MultiMedia10", <API key>, <API key>, 1, 0, <API key>, <API key>), #endif }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("MultiMedia1", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia3", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia4", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia5", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia6", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia7", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia8", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia9", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("PRI_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MI2S_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("PRI_MI2S_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("QUAT_MI2S_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("TERT_MI2S_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("SEC_MI2S_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("SLIM_0_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("AUX_PCM_UL_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("INTERNAL_FM_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("AFE_PCM_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("VOC_REC_DL", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("VOC_REC_UL", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("SLIM_4_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("INTERNAL_FM_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MI2S_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), #ifdef <API key> SOC_SINGLE_EXT("TERT_MI2S_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), #elif defined(<API key>) || defined(<API key>) SOC_SINGLE_EXT("SEC_MI2S_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), #endif SOC_SINGLE_EXT("SLIM_0_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("SLIM_0_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("PRI_MI2S_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("INTERNAL_FM_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("AFE_PCM_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("VOC_REC_DL", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("VOC_REC_UL", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("SLIM_0_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("INTERNAL_FM_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MI2S_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("AFE_PCM_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("AUX_PCM_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("SEC_AUX_PCM_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("PRI_MI2S_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), }; #ifdef CONFIG_JACK_AUDIO static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("SLIM_0_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("AUX_PCM_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), }; #endif static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("SLIM_0_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("PRI_MI2S_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("INTERNAL_FM_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("AFE_PCM_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("VOC_REC_DL", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("VOC_REC_UL", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("INTERNAL_FM_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("SLIM_0_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("CSVoice", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("Voice2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("Voip", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("VoLTE", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("VoWLAN", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("DTMF", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("QCHAT", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("CSVoice", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("Voice2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("Voip", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("VoLTE", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("VoWLAN", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("DTMF", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("QCHAT", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("CSVoice", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("Voice2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("Voip", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("VoLTE", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("VoWLAN", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("DTMF", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("QCHAT", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("CSVoice", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("Voice2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("Voip", <API key> , <API key>, 1, 0, <API key>, <API key>), #if defined( <API key> ) || defined(<API key>) SOC_SINGLE_EXT("Voice Stub", <API key>, <API key>, 1, 0, <API key>, <API key>), #endif /* <API key> || <API key> */ SOC_SINGLE_EXT("VoLTE", <API key> , <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("VoWLAN", <API key> , <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("DTMF", <API key> , <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("QCHAT", <API key> , <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("CSVoice", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("Voice2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("Voip", <API key> , <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("Voice Stub", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("VoLTE", <API key> , <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("VoWLAN", <API key> , <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("DTMF", <API key> , <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("QCHAT", <API key> , <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("CSVoice", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("Voice2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("Voip", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("Voice Stub", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("VoLTE", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("VoWLAN", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("DTMF", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("QCHAT", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("CSVoice", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("Voice2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("Voip", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("Voice Stub", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("VoLTE", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("VoWLAN", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("DTMF", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("QCHAT", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("CSVoice", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("Voice2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("Voip", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("Voice Stub", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("VoLTE", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("VoWLAN", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("DTMF", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("QCHAT", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("CSVoice", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("Voip", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("Voice Stub", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("VoLTE", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("VoWLAN", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("DTMF", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("QCHAT", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("CSVoice", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("Voice2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("Voip", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("VoLTE", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("VoWLAN", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("Voice Stub", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("DTMF", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("QCHAT", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("Voice Stub", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("Voice Stub", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("Voice Stub", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("PRI_TX_Voice", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MI2S_TX_Voice", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("SLIM_0_TX_Voice", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("<API key>", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("AFE_PCM_TX_Voice", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("AUX_PCM_TX_Voice", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("<API key>", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("PRI_MI2S_TX_Voice", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("PRI_TX_Voice2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MI2S_TX_Voice2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("SLIM_0_TX_Voice2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("<API key>", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("AFE_PCM_TX_Voice2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("AUX_PCM_TX_Voice2", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("PRI_MI2S_TX_Voice2", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("PRI_TX_VoLTE", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("SLIM_0_TX_VoLTE", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("<API key>", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("AFE_PCM_TX_VoLTE", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("AUX_PCM_TX_VoLTE", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("<API key>", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MI2S_TX_VoLTE", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("PRI_TX_VoWLAN", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("SLIM_0_TX_VoWLAN", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("<API key>", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("AFE_PCM_TX_VoWLAN", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("AUX_PCM_TX_VoWLAN", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("<API key>", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MI2S_TX_VoWLAN", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("PRI_MI2S_TX_VoWLAN", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("PRI_TX_Voip", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MI2S_TX_Voip", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("SLIM_0_TX_Voip", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("<API key>", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("AFE_PCM_TX_Voip", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("AUX_PCM_TX_Voip", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("SEC_AUX_PCM_TX_Voip", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("PRI_MI2S_TX_Voip", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("STUB_TX_HL", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("SLIM_1_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("STUB_1_TX_HL", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MI2S_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), #if defined( <API key> ) || defined(<API key>) SOC_SINGLE_EXT("AUX_PCM_UL_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("SLIM_0_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), #endif /* <API key> || <API key> */ }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("PRI_TX_QCHAT", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("SLIM_0_TX_QCHAT", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("<API key>", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("AFE_PCM_TX_QCHAT", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("AUX_PCM_TX_QCHAT", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("<API key>", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MI2S_TX_QCHAT", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("PRI_MI2S_TX_QCHAT", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("INTERNAL_FM_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("SLIM_0_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("AUX_PCM_UL_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MI2S_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), #if defined( <API key> ) || defined(<API key>) SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), #endif /* <API key> || <API key> */ }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("AUX_PCM_UL_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("SLIM_0_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), #if defined( <API key> ) || defined(<API key>) SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), #endif /* <API key> || <API key> */ }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("SLIM_0_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), #if defined( <API key> ) || defined(<API key>) SOC_SINGLE_EXT("AUX_PCM_UL_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), #endif /* <API key> || <API key> */ }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("INTERNAL_BT_SCO_RX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MI2S_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("SLIM_1_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), #if defined( <API key> ) || defined(<API key>) SOC_SINGLE_EXT("SLIM_0_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), #endif /* <API key> || <API key> */ }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("INTERNAL_FM_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("MI2S_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("MI2S_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("SLIM_1_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MI2S_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("SEC_MI2S_TX", <API key>, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key> = SOC_SINGLE_EXT("Switch", SND_SOC_NOPM, 0, 1, 0, <API key>, <API key>); static const struct snd_kcontrol_new <API key> = SOC_SINGLE_EXT("Switch", SND_SOC_NOPM, 0, 1, 0, <API key>, <API key>); static const struct snd_kcontrol_new <API key> = SOC_SINGLE_EXT("Switch", SND_SOC_NOPM, 0, 1, 0, <API key>, <API key>); static const struct soc_enum lsm_mux_enum = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(mad_audio_mux_text), mad_audio_mux_text); static const struct snd_kcontrol_new lsm1_mux = SOC_DAPM_ENUM_EXT("LSM1 MUX", lsm_mux_enum, <API key>, <API key>); static const struct snd_kcontrol_new lsm2_mux = SOC_DAPM_ENUM_EXT("LSM2 MUX", lsm_mux_enum, <API key>, <API key>); static const struct snd_kcontrol_new lsm3_mux = SOC_DAPM_ENUM_EXT("LSM3 MUX", lsm_mux_enum, <API key>, <API key>); static const struct snd_kcontrol_new lsm4_mux = SOC_DAPM_ENUM_EXT("LSM4 MUX", lsm_mux_enum, <API key>, <API key>); static const struct snd_kcontrol_new lsm5_mux = SOC_DAPM_ENUM_EXT("LSM5 MUX", lsm_mux_enum, <API key>, <API key>); static const struct snd_kcontrol_new lsm6_mux = SOC_DAPM_ENUM_EXT("LSM6 MUX", lsm_mux_enum, <API key>, <API key>); static const struct snd_kcontrol_new lsm7_mux = SOC_DAPM_ENUM_EXT("LSM7 MUX", lsm_mux_enum, <API key>, <API key>); static const struct snd_kcontrol_new lsm8_mux = SOC_DAPM_ENUM_EXT("LSM8 MUX", lsm_mux_enum, <API key>, <API key>); static const char * const lsm_func_text[] = { "None", "AUDIO", "BEACON", "ULTRASOUND", "SWAUDIO", }; static const struct soc_enum lsm_func_enum = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(lsm_func_text), lsm_func_text); static const struct snd_kcontrol_new lsm_function[] = { SOC_ENUM_EXT(SLIMBUS_0_TX_TEXT" "LSM_FUNCTION_TEXT, lsm_func_enum, <API key>, <API key>), SOC_ENUM_EXT(SLIMBUS_1_TX_TEXT" "LSM_FUNCTION_TEXT, lsm_func_enum, <API key>, <API key>), SOC_ENUM_EXT(SLIMBUS_2_TX_TEXT" "LSM_FUNCTION_TEXT, lsm_func_enum, <API key>, <API key>), SOC_ENUM_EXT(SLIMBUS_3_TX_TEXT" "LSM_FUNCTION_TEXT, lsm_func_enum, <API key>, <API key>), SOC_ENUM_EXT(SLIMBUS_4_TX_TEXT" "LSM_FUNCTION_TEXT, lsm_func_enum, <API key>, <API key>), SOC_ENUM_EXT(SLIMBUS_5_TX_TEXT" "LSM_FUNCTION_TEXT, lsm_func_enum, <API key>, <API key>), }; static const char * const aanc_slim_0_rx_text[] = { "ZERO", "SLIMBUS_0_TX", "SLIMBUS_1_TX", "SLIMBUS_2_TX", "SLIMBUS_3_TX", "SLIMBUS_4_TX", "SLIMBUS_5_TX", "SLIMBUS_6_TX" }; static const struct soc_enum aanc_slim_0_rx_enum = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(aanc_slim_0_rx_text), aanc_slim_0_rx_text); static const struct snd_kcontrol_new aanc_slim_0_rx_mux[] = { SOC_DAPM_ENUM_EXT("AANC_SLIM_0_RX MUX", aanc_slim_0_rx_enum, <API key>, <API key>) }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT_TLV("Internal FM RX Volume", SND_SOC_NOPM, 0, INT_RX_VOL_GAIN, 0, <API key>, <API key>, fm_rx_vol_gain), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT_TLV("Internal HFP RX Volume", SND_SOC_NOPM, 0, INT_RX_VOL_GAIN, 0, <API key>, <API key>, hfp_rx_vol_gain), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT_TLV("HIFI2 RX Volume", SND_SOC_NOPM, 0, INT_RX_VOL_GAIN, 0, <API key>, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT_TLV("HIFI3 RX Volume", SND_SOC_NOPM, 0, INT_RX_VOL_GAIN, 0, <API key>, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { <API key>("Playback Channel Map", SND_SOC_NOPM, 0, 16, 0, 8, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { {.iface = <API key>, .name = "SRS TruMedia", .access = <API key> | <API key>, .info = snd_soc_info_volsw, \ .get = <API key>, .put = <API key>, .private_value = ((unsigned long)&(struct soc_mixer_control) {.reg = SND_SOC_NOPM, .rreg = SND_SOC_NOPM, .shift = 0, .rshift = 0, .max = 0xFFFFFFFF, .platform_max = 0xFFFFFFFF, .invert = 0 }) } }; static const struct snd_kcontrol_new <API key>[] = { {.iface = <API key>, .name = "SRS TruMedia HDMI", .access = <API key> | <API key>, .info = snd_soc_info_volsw, \ .get = <API key>, .put = <API key>, .private_value = ((unsigned long)&(struct soc_mixer_control) {.reg = SND_SOC_NOPM, .rreg = SND_SOC_NOPM, .shift = 0, .rshift = 0, .max = 0xFFFFFFFF, .platform_max = 0xFFFFFFFF, .invert = 0 }) } }; static const struct snd_kcontrol_new <API key>[] = { {.iface = <API key>, .name = "SRS TruMedia I2S", .access = <API key> | <API key>, .info = snd_soc_info_volsw, \ .get = <API key>, .put = <API key>, .private_value = ((unsigned long)&(struct soc_mixer_control) {.reg = SND_SOC_NOPM, .rreg = SND_SOC_NOPM, .shift = 0, .rshift = 0, .max = 0xFFFFFFFF, .platform_max = 0xFFFFFFFF, .invert = 0 }) } }; int <API key>( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { /* not used while setting the manfr id*/ return 0; } int <API key>( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int manufacturer_id = ucontrol->value.integer.value[0]; <API key>(manufacturer_id); return 0; } static const struct snd_kcontrol_new <API key>[] = { <API key>("DS1 Security", SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 1, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { <API key>("DS1 DAP Set Param", SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 128, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { <API key>("DS1 DAP Get Param", SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 128, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { <API key>("DS1 DAP Get Visualizer", SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 41, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { <API key>("DS1 DAP Endpoint", SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 1, <API key>, <API key>), }; int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int rc = 0; int be_idx = 0; char *param_value; int *update_param_value; uint32_t param_length = sizeof(uint32_t); uint32_t param_payload_len = RMS_PAYLOAD_LEN * sizeof(uint32_t); param_value = kzalloc(param_length, GFP_KERNEL); if (!param_value) { pr_err("%s, param memory alloc failed\n", __func__); return -ENOMEM; } for (be_idx = 0; be_idx < MSM_BACKEND_DAI_MAX; be_idx++) if (msm_bedais[be_idx].port_id == SLIMBUS_0_TX) break; if ((be_idx < MSM_BACKEND_DAI_MAX) && msm_bedais[be_idx].active) { rc = adm_get_params(SLIMBUS_0_TX, <API key>, <API key>, param_length + param_payload_len, param_value); if (rc) { pr_err("%s: get parameters failed\n", __func__); kfree(param_value); return -EINVAL; } update_param_value = (int *)param_value; ucontrol->value.integer.value[0] = update_param_value[0]; pr_debug("%s: FROM DSP value[0] 0x%x\n", __func__, update_param_value[0]); } kfree(param_value); return 0; } int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { /* not used */ return 0; } static const struct snd_kcontrol_new get_rms_controls[] = { SOC_SINGLE_EXT("Get RMS", SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, <API key>, <API key>), }; static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { voc_session_id = ucontrol->value.integer.value[0]; pr_debug("%s: voc_session_id=%u\n", __func__, voc_session_id); return 0; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { ucontrol->value.integer.value[0] = voc_session_id; return 0; } static struct snd_kcontrol_new <API key>[] = { <API key>("Voc VSID", SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 1, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("MultiMedia1 EQ Enable", SND_SOC_NOPM, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia2 EQ Enable", SND_SOC_NOPM, <API key>, 1, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia3 EQ Enable", SND_SOC_NOPM, <API key>, 1, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { SOC_SINGLE_EXT("MultiMedia1 EQ Band Count", SND_SOC_NOPM, <API key>, 11, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia2 EQ Band Count", SND_SOC_NOPM, <API key>, 11, 0, <API key>, <API key>), SOC_SINGLE_EXT("MultiMedia3 EQ Band Count", SND_SOC_NOPM, <API key>, 11, 0, <API key>, <API key>), }; static const struct snd_kcontrol_new <API key>[] = { <API key>("MultiMedia1 EQ Band1", EQ_BAND1, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia1 EQ Band2", EQ_BAND2, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia1 EQ Band3", EQ_BAND3, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia1 EQ Band4", EQ_BAND4, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia1 EQ Band5", EQ_BAND5, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia1 EQ Band6", EQ_BAND6, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia1 EQ Band7", EQ_BAND7, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia1 EQ Band8", EQ_BAND8, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia1 EQ Band9", EQ_BAND9, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia1 EQ Band10", EQ_BAND10, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia1 EQ Band11", EQ_BAND11, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia1 EQ Band12", EQ_BAND12, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia2 EQ Band1", EQ_BAND1, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia2 EQ Band2", EQ_BAND2, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia2 EQ Band3", EQ_BAND3, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia2 EQ Band4", EQ_BAND4, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia2 EQ Band5", EQ_BAND5, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia2 EQ Band6", EQ_BAND6, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia2 EQ Band7", EQ_BAND7, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia2 EQ Band8", EQ_BAND8, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia2 EQ Band9", EQ_BAND9, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia2 EQ Band10", EQ_BAND10, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia2 EQ Band11", EQ_BAND11, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia2 EQ Band12", EQ_BAND12, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia3 EQ Band1", EQ_BAND1, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia3 EQ Band2", EQ_BAND2, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia3 EQ Band3", EQ_BAND3, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia3 EQ Band4", EQ_BAND4, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia3 EQ Band5", EQ_BAND5, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia3 EQ Band6", EQ_BAND6, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia3 EQ Band7", EQ_BAND7, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia3 EQ Band8", EQ_BAND8, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia3 EQ Band9", EQ_BAND9, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia3 EQ Band10", EQ_BAND10, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia3 EQ Band11", EQ_BAND11, <API key>, 255, 0, 5, <API key>, <API key>), <API key>("MultiMedia3 EQ Band12", EQ_BAND12, <API key>, 255, 0, 5, <API key>, <API key>), }; static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int ret = 0; int item; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; pr_debug("%s item is %d\n", __func__, ucontrol->value.enumerated.item[0]); mutex_lock(&routing_lock); item = ucontrol->value.enumerated.item[0]; if (item < e->max) { pr_debug("%s RX DAI ID %d TX DAI id %d\n", __func__, e->shift_l , e->values[item]); if (e->shift_l < MSM_BACKEND_DAI_MAX && e->values[item] < MSM_BACKEND_DAI_MAX) /* Enable feedback TX path */ ret = <API key>( msm_bedais[e->values[item]].port_id, msm_bedais[e->shift_l].port_id, 1, 0, 1); else { pr_debug("%s values are out of range item %d\n", __func__, e->values[item]); /* Disable feedback TX path */ if (e->values[item] == MSM_BACKEND_DAI_MAX) ret = <API key>(0, 0, 0, 0, 0); else ret = -EINVAL; } } else { pr_err("%s item value is out of range item\n", __func__); ret = -EINVAL; } mutex_unlock(&routing_lock); return ret; } static int <API key>(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { pr_debug("%s\n", __func__); return 0; } static const char * const <API key>[] = { "ZERO", "SLIM4_TX" }; static const int const <API key>[] = { MSM_BACKEND_DAI_MAX, <API key> }; static const struct soc_enum <API key> = <API key>(0, <API key>, 0, 0, ARRAY_SIZE(<API key>), <API key>, <API key>); static const struct snd_kcontrol_new <API key> = SOC_DAPM_ENUM_EXT("<API key>", <API key>, <API key>, <API key>); static const struct snd_kcontrol_new <API key>[] = { <API key>("SA data", SND_SOC_NOPM, 0, 65535, 0, 19, msm_sec_sa_get, msm_sec_sa_put), <API key>("VSP data", SND_SOC_NOPM, 0, 65535, 0, 1, msm_sec_vsp_get, msm_sec_vsp_put), <API key>("Audio DHA data", SND_SOC_NOPM, 0, 65535, 0, 13, msm_sec_dha_get, msm_sec_dha_put), <API key>("LRSM data", SND_SOC_NOPM, 0, 65535, 0, 2, msm_sec_lrsm_get, msm_sec_lrsm_put), <API key>("SA_EP data", SND_SOC_NOPM, 0, 65535, 0, 2, msm_sec_sa_ep_get, msm_sec_sa_ep_put), <API key>("MSP data", SND_SOC_NOPM, 0, 65535, 0, 1, msm_sec_msp_get, msm_sec_msp_put), }; static const struct snd_soc_dapm_widget msm_qdsp6_widgets[] = { /* Frontend AIF */ /* Widget name equals to Front-End DAI name<Need confirmation>, * Stream name must contains substring of front-end dai name */ SND_SOC_DAPM_AIF_IN("MM_DL1", "MultiMedia1 Playback", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("MM_DL2", "MultiMedia2 Playback", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("MM_DL3", "MultiMedia3 Playback", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("MM_DL4", "MultiMedia4 Playback", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("MM_DL5", "MultiMedia5 Playback", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("MM_DL6", "MultiMedia6 Playback", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("MM_DL7", "MultiMedia7 Playback", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("MM_DL8", "MultiMedia8 Playback", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("MM_DL9", "MultiMedia9 Playback", 0, 0, 0, 0), #ifdef CONFIG_JACK_AUDIO SND_SOC_DAPM_AIF_IN("MM_DL10", "MultiMedia10 Playback", 0, 0, 0, 0), #endif SND_SOC_DAPM_AIF_IN("VOIP_DL", "VoIP Playback", 0, 0, 0, 0), <API key>("MM_UL1", "MultiMedia1 Capture", 0, 0, 0, 0), <API key>("MM_UL2", "MultiMedia2 Capture", 0, 0, 0, 0), <API key>("MM_UL4", "MultiMedia4 Capture", 0, 0, 0, 0), <API key>("MM_UL5", "MultiMedia5 Capture", 0, 0, 0, 0), <API key>("MM_UL8", "MultiMedia8 Capture", 0, 0, 0, 0), <API key>("MM_UL6", "MultiMedia6 Capture", 0, 0, 0, 0), <API key>("MM_UL9", "MultiMedia9 Capture", 0, 0, 0, 0), #ifdef CONFIG_JACK_AUDIO <API key>("MM_UL10", "MultiMedia10 Capture", 0, 0, 0, 0), #endif SND_SOC_DAPM_AIF_IN("CS-VOICE_DL1", "CS-VOICE Playback", 0, 0, 0, 0), <API key>("CS-VOICE_UL1", "CS-VOICE Capture", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("VOICE2_DL", "Voice2 Playback", 0, 0, 0, 0), <API key>("VOICE2_UL", "Voice2 Capture", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("VoLTE_DL", "VoLTE Playback", 0, 0, 0, 0), <API key>("VoLTE_UL", "VoLTE Capture", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("VoWLAN_DL", "VoWLAN Playback", 0, 0, 0, 0), <API key>("VoWLAN_UL", "VoWLAN Capture", 0, 0, 0, 0), <API key>("VOIP_UL", "VoIP Capture", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("SLIM0_DL_HL", "SLIMBUS0_HOSTLESS Playback", 0, 0, 0, 0), <API key>("SLIM0_UL_HL", "SLIMBUS0_HOSTLESS Capture", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("SLIM1_DL_HL", "SLIMBUS1_HOSTLESS Playback", 0, 0, 0, 0), <API key>("SLIM1_UL_HL", "SLIMBUS1_HOSTLESS Capture", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("SLIM3_DL_HL", "SLIMBUS3_HOSTLESS Playback", 0, 0, 0, 0), <API key>("SLIM3_UL_HL", "SLIMBUS3_HOSTLESS Capture", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("SLIM4_DL_HL", "SLIMBUS4_HOSTLESS Playback", 0, 0, 0, 0), <API key>("SLIM4_UL_HL", "SLIMBUS4_HOSTLESS Capture", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("INTFM_DL_HL", "INT_FM_HOSTLESS Playback", 0, 0, 0, 0), <API key>("INTFM_UL_HL", "INT_FM_HOSTLESS Capture", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("INTHFP_DL_HL", "INT_HFP_BT_HOSTLESS Playback", 0, 0, 0, 0), <API key>("INTHFP_UL_HL", "INT_HFP_BT_HOSTLESS Capture", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("HDMI_DL_HL", "HDMI_HOSTLESS Playback", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("SEC_I2S_DL_HL", "SEC_I2S_RX_HOSTLESS Playback", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("SEC_MI2S_DL_HL", "Secondary MI2S_RX Hostless Playback", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("AUXPCM_DL_HL", "AUXPCM_HOSTLESS Playback", 0, 0, 0, 0), <API key>("AUXPCM_UL_HL", "AUXPCM_HOSTLESS Capture", 0, 0, 0, 0), <API key>("MI2S_UL_HL", "MI2S_TX_HOSTLESS Capture", 0, 0, 0, 0), <API key>("PRI_MI2S_UL_HL", "Primary MI2S_TX Hostless Capture", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("PRI_MI2S_DL_HL", "Primary MI2S_RX Hostless Playback", 0, 0, 0, 0), <API key>("MI2S_DL_HL", "MI2S_RX_HOSTLESS Playback", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("DTMF_DL_HL", "DTMF_RX_HOSTLESS Playback", 0, 0, 0, 0), /* LSM */ <API key>("LSM1_UL_HL", "Listen 1 Audio Service Capture", 0, 0, 0, 0), <API key>("LSM2_UL_HL", "Listen 2 Audio Service Capture", 0, 0, 0, 0), <API key>("LSM3_UL_HL", "Listen 3 Audio Service Capture", 0, 0, 0, 0), <API key>("LSM4_UL_HL", "Listen 4 Audio Service Capture", 0, 0, 0, 0), <API key>("LSM5_UL_HL", "Listen 5 Audio Service Capture", 0, 0, 0, 0), <API key>("LSM6_UL_HL", "Listen 6 Audio Service Capture", 0, 0, 0, 0), <API key>("LSM7_UL_HL", "Listen 7 Audio Service Capture", 0, 0, 0, 0), <API key>("LSM8_UL_HL", "Listen 8 Audio Service Capture", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("QCHAT_DL", "QCHAT Playback", 0, 0, 0, 0), <API key>("QCHAT_UL", "QCHAT Capture", 0, 0, 0, 0), /* Backend AIF */ /* Stream name equals to backend dai link stream name */ <API key>("PRI_I2S_RX", "Primary I2S Playback", 0, 0, 0, 0), <API key>("SEC_I2S_RX", "Secondary I2S Playback", 0, 0, 0 , 0), <API key>("SLIMBUS_0_RX", "Slimbus Playback", 0, 0, 0, 0), <API key>("HDMI", "HDMI Playback", 0, 0, 0 , 0), <API key>("MI2S_RX", "MI2S Playback", 0, 0, 0, 0), <API key>("QUAT_MI2S_RX", "Quaternary MI2S Playback", 0, 0, 0, 0), <API key>("TERT_MI2S_RX", "Tertiary MI2S Playback", 0, 0, 0, 0), <API key>("SEC_MI2S_RX", "Secondary MI2S Playback", 0, 0, 0, 0), <API key>("PRI_MI2S_RX", "Primary MI2S Playback", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("PRI_I2S_TX", "Primary I2S Capture", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("MI2S_TX", "MI2S Capture", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("QUAT_MI2S_TX", "Quaternary MI2S Capture", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("PRI_MI2S_TX", "Primary MI2S Capture", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("TERT_MI2S_TX", "Tertiary MI2S Capture", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("SEC_MI2S_TX", "Secondary MI2S Capture", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("SLIMBUS_0_TX", "Slimbus Capture", 0, 0, 0, 0), <API key>("INT_BT_SCO_RX", "Internal BT-SCO Playback", 0, 0, 0 , 0), SND_SOC_DAPM_AIF_IN("INT_BT_SCO_TX", "Internal BT-SCO Capture", 0, 0, 0, 0), <API key>("INT_FM_RX", "Internal FM Playback", 0, 0, 0 , 0), SND_SOC_DAPM_AIF_IN("INT_FM_TX", "Internal FM Capture", 0, 0, 0, 0), <API key>("PCM_RX", "AFE Playback", 0, 0, 0 , 0), SND_SOC_DAPM_AIF_IN("PCM_TX", "AFE Capture", 0, 0, 0 , 0), /* incall */ <API key>("VOICE_PLAYBACK_TX", "Voice Farend Playback", 0, 0, 0 , 0), <API key>("VOICE2_PLAYBACK_TX", "Voice2 Farend Playback", 0, 0, 0 , 0), <API key>("SLIMBUS_4_RX", "Slimbus4 Playback", 0, 0, 0 , 0), SND_SOC_DAPM_AIF_IN("INCALL_RECORD_TX", "Voice Uplink Capture", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("INCALL_RECORD_RX", "Voice Downlink Capture", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("SLIMBUS_4_TX", "Slimbus4 Capture", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("SLIMBUS_5_TX", "Slimbus5 Capture", 0, 0, 0, 0), <API key>("AUX_PCM_RX", "AUX PCM Playback", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("AUX_PCM_TX", "AUX PCM Capture", 0, 0, 0, 0), <API key>("SEC_AUX_PCM_RX", "Sec AUX PCM Playback", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("SEC_AUX_PCM_TX", "Sec AUX PCM Capture", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("VOICE_STUB_DL", "VOICE_STUB Playback", 0, 0, 0, 0), <API key>("VOICE_STUB_UL", "VOICE_STUB Capture", 0, 0, 0, 0), <API key>("STUB_RX", "Stub Playback", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("STUB_TX", "Stub Capture", 0, 0, 0, 0), <API key>("SLIMBUS_1_RX", "Slimbus1 Playback", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("SLIMBUS_1_TX", "Slimbus1 Capture", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("STUB_1_TX", "Stub1 Capture", 0, 0, 0, 0), <API key>("SLIMBUS_3_RX", "Slimbus3 Playback", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("SLIMBUS_3_TX", "Slimbus3 Capture", 0, 0, 0, 0), /* Switch Definitions */ SND_SOC_DAPM_SWITCH("SLIMBUS_DL_HL", SND_SOC_NOPM, 0, 0, &<API key>), SND_SOC_DAPM_SWITCH("SLIMBUS1_DL_HL", SND_SOC_NOPM, 0, 0, &<API key>), SND_SOC_DAPM_SWITCH("SLIMBUS3_DL_HL", SND_SOC_NOPM, 0, 0, &<API key>), SND_SOC_DAPM_SWITCH("SLIMBUS4_DL_HL", SND_SOC_NOPM, 0, 0, &<API key>), SND_SOC_DAPM_SWITCH("PCM_RX_DL_HL", SND_SOC_NOPM, 0, 0, &<API key>), SND_SOC_DAPM_SWITCH("PRI_MI2S_RX_DL_HL", SND_SOC_NOPM, 0, 0, &<API key>), /* Mux Definitions */ SND_SOC_DAPM_MUX("LSM1 MUX", SND_SOC_NOPM, 0, 0, &lsm1_mux), SND_SOC_DAPM_MUX("LSM2 MUX", SND_SOC_NOPM, 0, 0, &lsm2_mux), SND_SOC_DAPM_MUX("LSM3 MUX", SND_SOC_NOPM, 0, 0, &lsm3_mux), SND_SOC_DAPM_MUX("LSM4 MUX", SND_SOC_NOPM, 0, 0, &lsm4_mux), SND_SOC_DAPM_MUX("LSM5 MUX", SND_SOC_NOPM, 0, 0, &lsm5_mux), SND_SOC_DAPM_MUX("LSM6 MUX", SND_SOC_NOPM, 0, 0, &lsm6_mux), SND_SOC_DAPM_MUX("LSM7 MUX", SND_SOC_NOPM, 0, 0, &lsm7_mux), SND_SOC_DAPM_MUX("LSM8 MUX", SND_SOC_NOPM, 0, 0, &lsm8_mux), SND_SOC_DAPM_MUX("SLIM_0_RX AANC MUX", SND_SOC_NOPM, 0, 0, aanc_slim_0_rx_mux), /* Mixer definitions */ SND_SOC_DAPM_MIXER("PRI_RX Audio Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("SEC_RX Audio Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("SLIMBUS_0_RX Audio Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("HDMI Mixer", SND_SOC_NOPM, 0, 0, hdmi_mixer_controls, ARRAY_SIZE(hdmi_mixer_controls)), SND_SOC_DAPM_MIXER("MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("QUAT_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("TERT_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("SEC_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("SEC_MI2S_RX Port Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("PRI_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("MultiMedia1 Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("MultiMedia2 Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("MultiMedia4 Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("MultiMedia5 Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("MultiMedia8 Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("MultiMedia6 Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), #ifdef CONFIG_JACK_AUDIO SND_SOC_DAPM_MIXER("MultiMedia10 Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), #endif SND_SOC_DAPM_MIXER("AUX_PCM_RX Audio Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("SEC_AUX_PCM_RX Audio Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), /* incall */ SND_SOC_DAPM_MIXER("Incall_Music Audio Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("Incall_Music_2 Audio Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("SLIMBUS_4_RX Audio Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), /* Voice Mixer */ SND_SOC_DAPM_MIXER("PRI_RX_Voice Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("SEC_RX_Voice Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("SEC_MI2S_RX_Voice Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("SLIM_0_RX_Voice Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("<API key> Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("AFE_PCM_RX_Voice Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("AUX_PCM_RX_Voice Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("<API key> Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("HDMI_RX_Voice Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("MI2S_RX_Voice Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("Voice_Tx Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("Voice2_Tx Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("Voip_Tx Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("VoLTE_Tx Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("VoWLAN_Tx Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("INTERNAL_BT_SCO_RX Audio Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("INTERNAL_FM_RX Audio Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("AFE_PCM_RX Audio Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("Voice Stub Tx Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("STUB_RX Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("SLIMBUS_1_RX Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("SLIMBUS_3_RX_Voice Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("SLIMBUS_0_RX Port Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("AUXPCM_RX Port Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("SEC_AUXPCM_RX Port Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("SLIMBUS_1_RX Port Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("INTERNAL_BT_SCO_RX Port Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("AFE_PCM_RX Port Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("HDMI_RX Port Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("SEC_I2S_RX Port Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("SLIMBUS_3_RX Port Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("MI2S_RX Port Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("PRI_MI2S_RX Port Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), SND_SOC_DAPM_MIXER("QCHAT_Tx Mixer", SND_SOC_NOPM, 0, 0, <API key>, ARRAY_SIZE(<API key>)), /* Virtual Pins to force backends ON atm */ SND_SOC_DAPM_OUTPUT("BE_OUT"), SND_SOC_DAPM_INPUT("BE_IN"), SND_SOC_DAPM_MUX("<API key>", SND_SOC_NOPM, 0, 0, &<API key>), SND_SOC_DAPM_MUX("VOC_EXT_EC MUX", SND_SOC_NOPM, 0, 0, &voc_ext_ec_mux), SND_SOC_DAPM_MUX("AUDIO_REF_EC_UL1 MUX", SND_SOC_NOPM, 0, 0, &ext_ec_ref_mux_ul1), SND_SOC_DAPM_MUX("AUDIO_REF_EC_UL2 MUX", SND_SOC_NOPM, 0, 0, &ext_ec_ref_mux_ul2), SND_SOC_DAPM_MUX("AUDIO_REF_EC_UL4 MUX", SND_SOC_NOPM, 0, 0, &ext_ec_ref_mux_ul4), SND_SOC_DAPM_MUX("AUDIO_REF_EC_UL5 MUX", SND_SOC_NOPM, 0, 0, &ext_ec_ref_mux_ul5), SND_SOC_DAPM_MUX("AUDIO_REF_EC_UL6 MUX", SND_SOC_NOPM, 0, 0, &ext_ec_ref_mux_ul6), SND_SOC_DAPM_MUX("AUDIO_REF_EC_UL8 MUX", SND_SOC_NOPM, 0, 0, &ext_ec_ref_mux_ul8), SND_SOC_DAPM_MUX("AUDIO_REF_EC_UL9 MUX", SND_SOC_NOPM, 0, 0, &ext_ec_ref_mux_ul9), }; static const struct snd_soc_dapm_route intercon[] = { {"PRI_RX Audio Mixer", "MultiMedia1", "MM_DL1"}, {"PRI_RX Audio Mixer", "MultiMedia2", "MM_DL2"}, {"PRI_RX Audio Mixer", "MultiMedia3", "MM_DL3"}, {"PRI_RX Audio Mixer", "MultiMedia4", "MM_DL4"}, {"PRI_RX Audio Mixer", "MultiMedia5", "MM_DL5"}, {"PRI_RX Audio Mixer", "MultiMedia6", "MM_DL6"}, {"PRI_RX Audio Mixer", "MultiMedia7", "MM_DL7"}, {"PRI_RX Audio Mixer", "MultiMedia8", "MM_DL8"}, {"PRI_RX Audio Mixer", "MultiMedia9", "MM_DL9"}, {"PRI_I2S_RX", NULL, "PRI_RX Audio Mixer"}, {"SEC_RX Audio Mixer", "MultiMedia1", "MM_DL1"}, {"SEC_RX Audio Mixer", "MultiMedia2", "MM_DL2"}, {"SEC_RX Audio Mixer", "MultiMedia3", "MM_DL3"}, {"SEC_RX Audio Mixer", "MultiMedia4", "MM_DL4"}, {"SEC_RX Audio Mixer", "MultiMedia5", "MM_DL5"}, {"SEC_RX Audio Mixer", "MultiMedia6", "MM_DL6"}, {"SEC_RX Audio Mixer", "MultiMedia7", "MM_DL7"}, {"SEC_RX Audio Mixer", "MultiMedia8", "MM_DL8"}, {"SEC_RX Audio Mixer", "MultiMedia9", "MM_DL9"}, {"SEC_I2S_RX", NULL, "SEC_RX Audio Mixer"}, {"SLIMBUS_0_RX Audio Mixer", "MultiMedia1", "MM_DL1"}, {"SLIMBUS_0_RX Audio Mixer", "MultiMedia2", "MM_DL2"}, {"SLIMBUS_0_RX Audio Mixer", "MultiMedia3", "MM_DL3"}, {"SLIMBUS_0_RX Audio Mixer", "MultiMedia4", "MM_DL4"}, {"SLIMBUS_0_RX Audio Mixer", "MultiMedia5", "MM_DL5"}, {"SLIMBUS_0_RX Audio Mixer", "MultiMedia6", "MM_DL6"}, {"SLIMBUS_0_RX Audio Mixer", "MultiMedia7", "MM_DL7"}, {"SLIMBUS_0_RX Audio Mixer", "MultiMedia8", "MM_DL8"}, {"SLIMBUS_0_RX Audio Mixer", "MultiMedia9", "MM_DL9"}, #ifdef CONFIG_JACK_AUDIO {"SLIMBUS_0_RX Audio Mixer", "MultiMedia10", "MM_DL10"}, #endif {"SLIMBUS_0_RX", NULL, "SLIMBUS_0_RX Audio Mixer"}, {"HDMI Mixer", "MultiMedia1", "MM_DL1"}, {"HDMI Mixer", "MultiMedia2", "MM_DL2"}, {"HDMI Mixer", "MultiMedia3", "MM_DL3"}, {"HDMI Mixer", "MultiMedia4", "MM_DL4"}, {"HDMI Mixer", "MultiMedia5", "MM_DL5"}, {"HDMI Mixer", "MultiMedia6", "MM_DL6"}, {"HDMI Mixer", "MultiMedia7", "MM_DL7"}, {"HDMI Mixer", "MultiMedia8", "MM_DL8"}, {"HDMI Mixer", "MultiMedia9", "MM_DL9"}, {"HDMI", NULL, "HDMI Mixer"}, /* incall */ {"Incall_Music Audio Mixer", "MultiMedia1", "MM_DL1"}, {"Incall_Music Audio Mixer", "MultiMedia2", "MM_DL2"}, {"Incall_Music Audio Mixer", "MultiMedia5", "MM_DL5"}, {"Incall_Music Audio Mixer", "MultiMedia9", "MM_DL9"}, {"VOICE_PLAYBACK_TX", NULL, "Incall_Music Audio Mixer"}, {"Incall_Music_2 Audio Mixer", "MultiMedia1", "MM_DL1"}, {"Incall_Music_2 Audio Mixer", "MultiMedia2", "MM_DL2"}, {"Incall_Music_2 Audio Mixer", "MultiMedia5", "MM_DL5"}, {"Incall_Music_2 Audio Mixer", "MultiMedia9", "MM_DL9"}, {"VOICE2_PLAYBACK_TX", NULL, "Incall_Music_2 Audio Mixer"}, {"SLIMBUS_4_RX Audio Mixer", "MultiMedia1", "MM_DL1"}, {"SLIMBUS_4_RX Audio Mixer", "MultiMedia2", "MM_DL2"}, {"SLIMBUS_4_RX", NULL, "SLIMBUS_4_RX Audio Mixer"}, {"MultiMedia1 Mixer", "VOC_REC_UL", "INCALL_RECORD_TX"}, {"MultiMedia4 Mixer", "VOC_REC_UL", "INCALL_RECORD_TX"}, {"MultiMedia8 Mixer", "VOC_REC_UL", "INCALL_RECORD_TX"}, {"MultiMedia1 Mixer", "VOC_REC_DL", "INCALL_RECORD_RX"}, {"MultiMedia4 Mixer", "VOC_REC_DL", "INCALL_RECORD_RX"}, {"MultiMedia8 Mixer", "VOC_REC_DL", "INCALL_RECORD_RX"}, {"MultiMedia1 Mixer", "SLIM_4_TX", "SLIMBUS_4_TX"}, {"MultiMedia4 Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"}, {"MultiMedia8 Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"}, {"MultiMedia4 Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"}, {"MultiMedia8 Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"}, {"MultiMedia5 Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"}, #ifdef CONFIG_JACK_AUDIO {"MultiMedia10 Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"}, #endif {"MI2S_RX Audio Mixer", "MultiMedia1", "MM_DL1"}, {"MI2S_RX Audio Mixer", "MultiMedia2", "MM_DL2"}, {"MI2S_RX Audio Mixer", "MultiMedia3", "MM_DL3"}, {"MI2S_RX Audio Mixer", "MultiMedia4", "MM_DL4"}, {"MI2S_RX Audio Mixer", "MultiMedia5", "MM_DL5"}, {"MI2S_RX Audio Mixer", "MultiMedia6", "MM_DL6"}, {"MI2S_RX Audio Mixer", "MultiMedia7", "MM_DL7"}, {"MI2S_RX Audio Mixer", "MultiMedia8", "MM_DL8"}, {"MI2S_RX Audio Mixer", "MultiMedia9", "MM_DL9"}, {"MI2S_RX", NULL, "MI2S_RX Audio Mixer"}, {"QUAT_MI2S_RX Audio Mixer", "MultiMedia1", "MM_DL1"}, {"QUAT_MI2S_RX Audio Mixer", "MultiMedia2", "MM_DL2"}, {"QUAT_MI2S_RX Audio Mixer", "MultiMedia3", "MM_DL3"}, {"QUAT_MI2S_RX Audio Mixer", "MultiMedia4", "MM_DL4"}, {"QUAT_MI2S_RX Audio Mixer", "MultiMedia5", "MM_DL5"}, {"QUAT_MI2S_RX Audio Mixer", "MultiMedia6", "MM_DL6"}, {"QUAT_MI2S_RX Audio Mixer", "MultiMedia7", "MM_DL7"}, {"QUAT_MI2S_RX Audio Mixer", "MultiMedia8", "MM_DL8"}, {"QUAT_MI2S_RX", NULL, "QUAT_MI2S_RX Audio Mixer"}, {"TERT_MI2S_RX Audio Mixer", "MultiMedia1", "MM_DL1"}, {"TERT_MI2S_RX Audio Mixer", "MultiMedia2", "MM_DL2"}, {"TERT_MI2S_RX Audio Mixer", "MultiMedia3", "MM_DL3"}, {"TERT_MI2S_RX Audio Mixer", "MultiMedia4", "MM_DL4"}, {"TERT_MI2S_RX Audio Mixer", "MultiMedia5", "MM_DL5"}, {"TERT_MI2S_RX", NULL, "TERT_MI2S_RX Audio Mixer"}, {"SEC_MI2S_RX Audio Mixer", "MultiMedia1", "MM_DL1"}, {"SEC_MI2S_RX Audio Mixer", "MultiMedia2", "MM_DL2"}, {"SEC_MI2S_RX Audio Mixer", "MultiMedia3", "MM_DL3"}, {"SEC_MI2S_RX Audio Mixer", "MultiMedia4", "MM_DL4"}, {"SEC_MI2S_RX Audio Mixer", "MultiMedia5", "MM_DL5"}, {"SEC_MI2S_RX", NULL, "SEC_MI2S_RX Audio Mixer"}, {"SEC_MI2S_RX Port Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"}, {"SEC_MI2S_RX Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"}, {"PRI_MI2S_RX Audio Mixer", "MultiMedia1", "MM_DL1"}, {"PRI_MI2S_RX Audio Mixer", "MultiMedia2", "MM_DL2"}, {"PRI_MI2S_RX Audio Mixer", "MultiMedia3", "MM_DL3"}, {"PRI_MI2S_RX Audio Mixer", "MultiMedia4", "MM_DL4"}, {"PRI_MI2S_RX Audio Mixer", "MultiMedia5", "MM_DL5"}, {"PRI_MI2S_RX", NULL, "PRI_MI2S_RX Audio Mixer"}, {"MultiMedia1 Mixer", "PRI_TX", "PRI_I2S_TX"}, {"MultiMedia1 Mixer", "MI2S_TX", "MI2S_TX"}, {"MultiMedia2 Mixer", "MI2S_TX", "MI2S_TX"}, {"MultiMedia5 Mixer", "MI2S_TX", "MI2S_TX"}, {"MultiMedia1 Mixer", "QUAT_MI2S_TX", "QUAT_MI2S_TX"}, {"MultiMedia1 Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"}, {"MultiMedia1 Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"}, {"MultiMedia1 Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"}, {"MultiMedia5 Mixer", "AUX_PCM_TX", "AUX_PCM_TX"}, #ifdef CONFIG_JACK_AUDIO {"MultiMedia10 Mixer", "AUX_PCM_TX", "AUX_PCM_TX"}, #endif {"MultiMedia1 Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"}, {"MultiMedia5 Mixer", "SEC_AUX_PCM_TX", "SEC_AUX_PCM_TX"}, {"MultiMedia2 Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"}, {"MultiMedia1 Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"}, {"MultiMedia1 Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"}, {"MultiMedia6 Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"}, #ifdef <API key> {"MultiMedia2 Mixer", "TERT_MI2S_TX", "TERT_MI2S_TX"}, #elif defined(<API key>) || defined(<API key>) {"MultiMedia2 Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"}, #endif {"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia1", "MM_DL1"}, {"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia2", "MM_DL2"}, {"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia3", "MM_DL3"}, {"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia4", "MM_DL4"}, {"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia5", "MM_DL5"}, {"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia6", "MM_DL6"}, {"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia7", "MM_DL7"}, {"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia8", "MM_DL8"}, {"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia9", "MM_DL9"}, {"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia6", "MM_UL6"}, {"INT_BT_SCO_RX", NULL, "INTERNAL_BT_SCO_RX Audio Mixer"}, {"INTERNAL_FM_RX Audio Mixer", "MultiMedia1", "MM_DL1"}, {"INTERNAL_FM_RX Audio Mixer", "MultiMedia2", "MM_DL2"}, {"INTERNAL_FM_RX Audio Mixer", "MultiMedia3", "MM_DL3"}, {"INTERNAL_FM_RX Audio Mixer", "MultiMedia4", "MM_DL4"}, {"INTERNAL_FM_RX Audio Mixer", "MultiMedia5", "MM_DL5"}, {"INTERNAL_FM_RX Audio Mixer", "MultiMedia6", "MM_DL6"}, {"INTERNAL_FM_RX Audio Mixer", "MultiMedia7", "MM_DL7"}, {"INTERNAL_FM_RX Audio Mixer", "MultiMedia8", "MM_DL8"}, {"INTERNAL_FM_RX Audio Mixer", "MultiMedia9", "MM_DL9"}, {"INT_FM_RX", NULL, "INTERNAL_FM_RX Audio Mixer"}, {"AFE_PCM_RX Audio Mixer", "MultiMedia1", "MM_DL1"}, {"AFE_PCM_RX Audio Mixer", "MultiMedia2", "MM_DL2"}, {"AFE_PCM_RX Audio Mixer", "MultiMedia3", "MM_DL3"}, {"AFE_PCM_RX Audio Mixer", "MultiMedia4", "MM_DL4"}, {"AFE_PCM_RX Audio Mixer", "MultiMedia5", "MM_DL5"}, {"AFE_PCM_RX Audio Mixer", "MultiMedia6", "MM_DL6"}, {"AFE_PCM_RX Audio Mixer", "MultiMedia7", "MM_DL7"}, {"AFE_PCM_RX Audio Mixer", "MultiMedia8", "MM_DL8"}, {"AFE_PCM_RX Audio Mixer", "MultiMedia9", "MM_DL9"}, {"PCM_RX", NULL, "AFE_PCM_RX Audio Mixer"}, {"MultiMedia1 Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"}, {"MultiMedia4 Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"}, {"MultiMedia5 Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"}, {"MultiMedia8 Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"}, {"MultiMedia1 Mixer", "INTERNAL_FM_TX", "INT_FM_TX"}, {"MultiMedia4 Mixer", "INTERNAL_FM_TX", "INT_FM_TX"}, {"MultiMedia5 Mixer", "INTERNAL_FM_TX", "INT_FM_TX"}, {"MultiMedia8 Mixer", "INTERNAL_FM_TX", "INT_FM_TX"}, {"MultiMedia6 Mixer", "INTERNAL_FM_TX", "INT_FM_TX"}, {"MultiMedia1 Mixer", "AFE_PCM_TX", "PCM_TX"}, {"MultiMedia4 Mixer", "AFE_PCM_TX", "PCM_TX"}, {"MultiMedia5 Mixer", "AFE_PCM_TX", "PCM_TX"}, {"MultiMedia8 Mixer", "AFE_PCM_TX", "PCM_TX"}, {"MM_UL1", NULL, "MultiMedia1 Mixer"}, {"MultiMedia2 Mixer", "INTERNAL_FM_TX", "INT_FM_TX"}, {"MM_UL2", NULL, "MultiMedia2 Mixer"}, {"MM_UL4", NULL, "MultiMedia4 Mixer"}, {"MM_UL5", NULL, "MultiMedia5 Mixer"}, {"MM_UL8", NULL, "MultiMedia8 Mixer"}, {"MM_UL6", NULL, "MultiMedia6 Mixer"}, #ifdef CONFIG_JACK_AUDIO {"MM_UL10", NULL, "MultiMedia10 Mixer"}, #endif {"AUX_PCM_RX Audio Mixer", "MultiMedia1", "MM_DL1"}, {"AUX_PCM_RX Audio Mixer", "MultiMedia2", "MM_DL2"}, {"AUX_PCM_RX Audio Mixer", "MultiMedia3", "MM_DL3"}, {"AUX_PCM_RX Audio Mixer", "MultiMedia4", "MM_DL4"}, {"AUX_PCM_RX Audio Mixer", "MultiMedia5", "MM_DL5"}, {"AUX_PCM_RX Audio Mixer", "MultiMedia6", "MM_DL6"}, {"AUX_PCM_RX Audio Mixer", "MultiMedia7", "MM_DL7"}, {"AUX_PCM_RX Audio Mixer", "MultiMedia8", "MM_DL8"}, {"AUX_PCM_RX Audio Mixer", "MultiMedia9", "MM_DL9"}, #ifdef CONFIG_JACK_AUDIO {"AUX_PCM_RX Audio Mixer", "MultiMedia10", "MM_DL10"}, #endif {"AUX_PCM_RX", NULL, "AUX_PCM_RX Audio Mixer"}, {"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia1", "MM_DL1"}, {"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia2", "MM_DL2"}, {"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia3", "MM_DL3"}, {"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia4", "MM_DL4"}, {"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia5", "MM_DL5"}, {"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia6", "MM_DL6"}, {"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia7", "MM_DL7"}, {"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia8", "MM_DL8"}, {"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia9", "MM_DL9"}, {"SEC_AUX_PCM_RX", NULL, "SEC_AUX_PCM_RX Audio Mixer"}, {"MI2S_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"}, {"MI2S_RX_Voice Mixer", "Voice2", "VOICE2_DL"}, {"MI2S_RX_Voice Mixer", "Voip", "VOIP_DL"}, {"MI2S_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"}, {"MI2S_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"}, {"MI2S_RX_Voice Mixer", "QCHAT", "QCHAT_DL"}, {"MI2S_RX", NULL, "MI2S_RX_Voice Mixer"}, {"PRI_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"}, {"PRI_RX_Voice Mixer", "Voice2", "VOICE2_DL"}, {"PRI_RX_Voice Mixer", "VoLTE", "VoLTE_DL"}, {"PRI_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"}, {"PRI_RX_Voice Mixer", "Voip", "VOIP_DL"}, {"PRI_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"}, {"PRI_RX_Voice Mixer", "QCHAT", "QCHAT_DL"}, {"PRI_I2S_RX", NULL, "PRI_RX_Voice Mixer"}, {"SEC_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"}, {"SEC_RX_Voice Mixer", "Voice2", "VOICE2_DL"}, {"SEC_RX_Voice Mixer", "VoLTE", "VoLTE_DL"}, {"SEC_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"}, {"SEC_RX_Voice Mixer", "Voip", "VOIP_DL"}, {"SEC_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"}, {"SEC_RX_Voice Mixer", "QCHAT", "QCHAT_DL"}, {"SEC_I2S_RX", NULL, "SEC_RX_Voice Mixer"}, {"SEC_MI2S_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"}, {"SEC_MI2S_RX_Voice Mixer", "Voice2", "VOICE2_DL"}, {"SEC_MI2S_RX_Voice Mixer", "VoLTE", "VoLTE_DL"}, {"SEC_MI2S_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"}, {"SEC_MI2S_RX_Voice Mixer", "Voip", "VOIP_DL"}, {"SEC_MI2S_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"}, {"SEC_MI2S_RX_Voice Mixer", "QCHAT", "QCHAT_DL"}, {"SEC_MI2S_RX", NULL, "SEC_MI2S_RX_Voice Mixer"}, {"SLIM_0_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"}, {"SLIM_0_RX_Voice Mixer", "Voice2", "VOICE2_DL"}, {"SLIM_0_RX_Voice Mixer", "VoLTE", "VoLTE_DL"}, {"SLIM_0_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"}, {"SLIM_0_RX_Voice Mixer", "Voip", "VOIP_DL"}, {"SLIM_0_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"}, #if defined( <API key> ) || defined(<API key>) {"SLIM_0_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"}, #endif /* <API key> || <API key> */ {"SLIM_0_RX_Voice Mixer", "QCHAT", "QCHAT_DL"}, {"SLIMBUS_0_RX", NULL, "SLIM_0_RX_Voice Mixer"}, {"<API key> Mixer", "CSVoice", "CS-VOICE_DL1"}, {"<API key> Mixer", "Voice2", "VOICE2_DL"}, {"<API key> Mixer", "VoLTE", "VoLTE_DL"}, {"<API key> Mixer", "VoWLAN", "VoWLAN_DL"}, {"<API key> Mixer", "Voip", "VOIP_DL"}, {"<API key> Mixer", "DTMF", "DTMF_DL_HL"}, {"<API key> Mixer", "QCHAT", "QCHAT_DL"}, {"INT_BT_SCO_RX", NULL, "<API key> Mixer"}, {"AFE_PCM_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"}, {"AFE_PCM_RX_Voice Mixer", "Voice2", "VOICE2_DL"}, {"AFE_PCM_RX_Voice Mixer", "VoLTE", "VoLTE_DL"}, {"AFE_PCM_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"}, {"AFE_PCM_RX_Voice Mixer", "Voip", "VOIP_DL"}, {"AFE_PCM_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"}, {"AFE_PCM_RX_Voice Mixer", "QCHAT", "QCHAT_DL"}, {"PCM_RX", NULL, "AFE_PCM_RX_Voice Mixer"}, {"AUX_PCM_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"}, {"AUX_PCM_RX_Voice Mixer", "Voice2", "VOICE2_DL"}, {"AUX_PCM_RX_Voice Mixer", "VoLTE", "VoLTE_DL"}, {"AUX_PCM_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"}, {"AUX_PCM_RX_Voice Mixer", "Voip", "VOIP_DL"}, {"AUX_PCM_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"}, #if defined( <API key> ) || defined(<API key>) {"AUX_PCM_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"}, #endif /* <API key> || <API key>*/ {"AUX_PCM_RX_Voice Mixer", "QCHAT", "QCHAT_DL"}, {"AUX_PCM_RX", NULL, "AUX_PCM_RX_Voice Mixer"}, {"<API key> Mixer", "CSVoice", "CS-VOICE_DL1"}, {"<API key> Mixer", "VoLTE", "VoLTE_DL"}, {"<API key> Mixer", "VoWLAN", "VoWLAN_DL"}, {"<API key> Mixer", "Voip", "VOIP_DL"}, {"<API key> Mixer", "DTMF", "DTMF_DL_HL"}, #if defined( <API key> ) || defined(<API key>) {"<API key> Mixer", "Voice Stub", "VOICE_STUB_DL"}, #endif /* <API key> || <API key>*/ {"<API key> Mixer", "QCHAT", "QCHAT_DL"}, {"SEC_AUX_PCM_RX", NULL, "<API key> Mixer"}, {"HDMI_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"}, {"HDMI_RX_Voice Mixer", "Voice2", "VOICE2_DL"}, {"HDMI_RX_Voice Mixer", "VoLTE", "VoLTE_DL"}, {"HDMI_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"}, {"HDMI_RX_Voice Mixer", "Voip", "VOIP_DL"}, {"HDMI_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"}, {"HDMI_RX_Voice Mixer", "QCHAT", "QCHAT_DL"}, {"HDMI", NULL, "HDMI_RX_Voice Mixer"}, {"HDMI", NULL, "HDMI_DL_HL"}, {"MI2S_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"}, {"MI2S_RX_Voice Mixer", "Voice2", "VOICE2_DL"}, {"MI2S_RX_Voice Mixer", "Voip", "VOIP_DL"}, {"MI2S_RX_Voice Mixer", "VoLTE", "VoLTE_DL"}, {"MI2S_RX_Voice Mixer", "VoWLAN", "VoWLAN_DL"}, {"MI2S_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"}, {"MI2S_RX_Voice Mixer", "QCHAT", "QCHAT_DL"}, {"MI2S_RX", NULL, "MI2S_RX_Voice Mixer"}, {"VOC_EXT_EC MUX", "PRI_MI2S_TX" , "PRI_MI2S_TX"}, {"VOC_EXT_EC MUX", "SEC_MI2S_TX" , "SEC_MI2S_TX"}, {"VOC_EXT_EC MUX", "TERT_MI2S_TX" , "TERT_MI2S_TX"}, {"VOC_EXT_EC MUX", "QUAT_MI2S_TX" , "QUAT_MI2S_TX"}, {"CS-VOICE_UL1", NULL, "VOC_EXT_EC MUX"}, {"VOIP_UL", NULL, "VOC_EXT_EC MUX"}, {"VoLTE_UL", NULL, "VOC_EXT_EC MUX"}, {"VOICE2_UL", NULL, "VOC_EXT_EC MUX"}, {"AUDIO_REF_EC_UL1 MUX", "PRI_MI2S_TX" , "PRI_MI2S_TX"}, {"AUDIO_REF_EC_UL1 MUX", "SEC_MI2S_TX" , "SEC_MI2S_TX"}, {"AUDIO_REF_EC_UL1 MUX", "TERT_MI2S_TX" , "TERT_MI2S_TX"}, {"AUDIO_REF_EC_UL1 MUX", "QUAT_MI2S_TX" , "QUAT_MI2S_TX"}, {"AUDIO_REF_EC_UL2 MUX", "PRI_MI2S_TX" , "PRI_MI2S_TX"}, {"AUDIO_REF_EC_UL2 MUX", "SEC_MI2S_TX" , "SEC_MI2S_TX"}, {"AUDIO_REF_EC_UL2 MUX", "TERT_MI2S_TX" , "TERT_MI2S_TX"}, {"AUDIO_REF_EC_UL2 MUX", "QUAT_MI2S_TX" , "QUAT_MI2S_TX"}, {"AUDIO_REF_EC_UL4 MUX", "PRI_MI2S_TX" , "PRI_MI2S_TX"}, {"AUDIO_REF_EC_UL4 MUX", "SEC_MI2S_TX" , "SEC_MI2S_TX"}, {"AUDIO_REF_EC_UL4 MUX", "TERT_MI2S_TX" , "TERT_MI2S_TX"}, {"AUDIO_REF_EC_UL4 MUX", "QUAT_MI2S_TX" , "QUAT_MI2S_TX"}, {"AUDIO_REF_EC_UL5 MUX", "PRI_MI2S_TX" , "PRI_MI2S_TX"}, {"AUDIO_REF_EC_UL5 MUX", "SEC_MI2S_TX" , "SEC_MI2S_TX"}, {"AUDIO_REF_EC_UL5 MUX", "TERT_MI2S_TX" , "TERT_MI2S_TX"}, {"AUDIO_REF_EC_UL5 MUX", "QUAT_MI2S_TX" , "QUAT_MI2S_TX"}, {"AUDIO_REF_EC_UL6 MUX", "PRI_MI2S_TX" , "PRI_MI2S_TX"}, {"AUDIO_REF_EC_UL6 MUX", "SEC_MI2S_TX" , "SEC_MI2S_TX"}, {"AUDIO_REF_EC_UL6 MUX", "TERT_MI2S_TX" , "TERT_MI2S_TX"}, {"AUDIO_REF_EC_UL6 MUX", "QUAT_MI2S_TX" , "QUAT_MI2S_TX"}, {"AUDIO_REF_EC_UL8 MUX", "PRI_MI2S_TX" , "PRI_MI2S_TX"}, {"AUDIO_REF_EC_UL8 MUX", "SEC_MI2S_TX" , "SEC_MI2S_TX"}, {"AUDIO_REF_EC_UL8 MUX", "TERT_MI2S_TX" , "TERT_MI2S_TX"}, {"AUDIO_REF_EC_UL8 MUX", "QUAT_MI2S_TX" , "QUAT_MI2S_TX"}, {"AUDIO_REF_EC_UL9 MUX", "PRI_MI2S_TX" , "PRI_MI2S_TX"}, {"AUDIO_REF_EC_UL9 MUX", "SEC_MI2S_TX" , "SEC_MI2S_TX"}, {"AUDIO_REF_EC_UL9 MUX", "TERT_MI2S_TX" , "TERT_MI2S_TX"}, {"AUDIO_REF_EC_UL9 MUX", "QUAT_MI2S_TX" , "QUAT_MI2S_TX"}, {"MM_UL1", NULL, "AUDIO_REF_EC_UL1 MUX"}, {"MM_UL2", NULL, "AUDIO_REF_EC_UL2 MUX"}, {"MM_UL4", NULL, "AUDIO_REF_EC_UL4 MUX"}, {"MM_UL5", NULL, "AUDIO_REF_EC_UL5 MUX"}, {"MM_UL6", NULL, "AUDIO_REF_EC_UL6 MUX"}, {"MM_UL8", NULL, "AUDIO_REF_EC_UL8 MUX"}, {"MM_UL9", NULL, "AUDIO_REF_EC_UL9 MUX"}, {"Voice_Tx Mixer", "PRI_TX_Voice", "PRI_I2S_TX"}, {"Voice_Tx Mixer", "PRI_MI2S_TX_Voice", "PRI_MI2S_TX"}, {"Voice_Tx Mixer", "MI2S_TX_Voice", "MI2S_TX"}, {"Voice_Tx Mixer", "SLIM_0_TX_Voice", "SLIMBUS_0_TX"}, {"Voice_Tx Mixer", "<API key>", "INT_BT_SCO_TX"}, {"Voice_Tx Mixer", "AFE_PCM_TX_Voice", "PCM_TX"}, {"Voice_Tx Mixer", "AUX_PCM_TX_Voice", "AUX_PCM_TX"}, {"Voice_Tx Mixer", "<API key>", "SEC_AUX_PCM_TX"}, {"CS-VOICE_UL1", NULL, "Voice_Tx Mixer"}, {"Voice2_Tx Mixer", "PRI_TX_Voice2", "PRI_I2S_TX"}, {"Voice2_Tx Mixer", "PRI_MI2S_TX_Voice2", "PRI_MI2S_TX"}, {"Voice2_Tx Mixer", "MI2S_TX_Voice2", "MI2S_TX"}, {"Voice2_Tx Mixer", "SLIM_0_TX_Voice2", "SLIMBUS_0_TX"}, {"Voice2_Tx Mixer", "<API key>", "INT_BT_SCO_TX"}, {"Voice2_Tx Mixer", "AFE_PCM_TX_Voice2", "PCM_TX"}, {"Voice2_Tx Mixer", "AUX_PCM_TX_Voice2", "AUX_PCM_TX"}, {"VOICE2_UL", NULL, "Voice2_Tx Mixer"}, {"VoLTE_Tx Mixer", "PRI_TX_VoLTE", "PRI_I2S_TX"}, {"VoLTE_Tx Mixer", "SLIM_0_TX_VoLTE", "SLIMBUS_0_TX"}, {"VoLTE_Tx Mixer", "<API key>", "INT_BT_SCO_TX"}, {"VoLTE_Tx Mixer", "AFE_PCM_TX_VoLTE", "PCM_TX"}, {"VoLTE_Tx Mixer", "AUX_PCM_TX_VoLTE", "AUX_PCM_TX"}, {"VoLTE_Tx Mixer", "<API key>", "SEC_AUX_PCM_TX"}, {"VoLTE_Tx Mixer", "MI2S_TX_VoLTE", "MI2S_TX"}, {"VoLTE_UL", NULL, "VoLTE_Tx Mixer"}, {"VoWLAN_Tx Mixer", "PRI_TX_VoWLAN", "PRI_I2S_TX"}, {"VoWLAN_Tx Mixer", "SLIM_0_TX_VoWLAN", "SLIMBUS_0_TX"}, {"VoWLAN_Tx Mixer", "<API key>", "INT_BT_SCO_TX"}, {"VoWLAN_Tx Mixer", "AFE_PCM_TX_VoWLAN", "PCM_TX"}, {"VoWLAN_Tx Mixer", "AUX_PCM_TX_VoWLAN", "AUX_PCM_TX"}, {"VoWLAN_Tx Mixer", "<API key>", "SEC_AUX_PCM_TX"}, {"VoWLAN_Tx Mixer", "MI2S_TX_VoWLAN", "MI2S_TX"}, {"VoWLAN_UL", NULL, "VoWLAN_Tx Mixer"}, {"Voip_Tx Mixer", "PRI_TX_Voip", "PRI_I2S_TX"}, {"Voip_Tx Mixer", "MI2S_TX_Voip", "MI2S_TX"}, {"Voip_Tx Mixer", "SLIM_0_TX_Voip", "SLIMBUS_0_TX"}, {"Voip_Tx Mixer", "<API key>", "INT_BT_SCO_TX"}, {"Voip_Tx Mixer", "AFE_PCM_TX_Voip", "PCM_TX"}, {"Voip_Tx Mixer", "AUX_PCM_TX_Voip", "AUX_PCM_TX"}, {"Voip_Tx Mixer", "SEC_AUX_PCM_TX_Voip", "SEC_AUX_PCM_TX"}, {"Voip_Tx Mixer", "PRI_MI2S_TX_Voip", "PRI_MI2S_TX"}, {"VOIP_UL", NULL, "Voip_Tx Mixer"}, {"SLIMBUS_DL_HL", "Switch", "SLIM0_DL_HL"}, {"SLIMBUS_0_RX", NULL, "SLIMBUS_DL_HL"}, {"SLIMBUS1_DL_HL", "Switch", "SLIM1_DL_HL"}, {"SLIMBUS_1_RX", NULL, "SLIMBUS1_DL_HL"}, {"SLIMBUS3_DL_HL", "Switch", "SLIM3_DL_HL"}, {"SLIMBUS_3_RX", NULL, "SLIMBUS3_DL_HL"}, {"SLIMBUS4_DL_HL", "Switch", "SLIM4_DL_HL"}, {"SLIMBUS_4_RX", NULL, "SLIMBUS4_DL_HL"}, {"SLIM0_UL_HL", NULL, "SLIMBUS_0_TX"}, {"SLIM1_UL_HL", NULL, "SLIMBUS_1_TX"}, {"SLIM3_UL_HL", NULL, "SLIMBUS_3_TX"}, {"SLIM4_UL_HL", NULL, "SLIMBUS_4_TX"}, {"LSM1 MUX", "SLIMBUS_0_TX", "SLIMBUS_0_TX"}, {"LSM1 MUX", "SLIMBUS_1_TX", "SLIMBUS_1_TX"}, {"LSM1 MUX", "SLIMBUS_3_TX", "SLIMBUS_3_TX"}, {"LSM1 MUX", "SLIMBUS_4_TX", "SLIMBUS_4_TX"}, {"LSM1 MUX", "SLIMBUS_5_TX", "SLIMBUS_5_TX"}, {"LSM1_UL_HL", NULL, "LSM1 MUX"}, {"LSM2 MUX", "SLIMBUS_0_TX", "SLIMBUS_0_TX"}, {"LSM2 MUX", "SLIMBUS_1_TX", "SLIMBUS_1_TX"}, {"LSM2 MUX", "SLIMBUS_3_TX", "SLIMBUS_3_TX"}, {"LSM2 MUX", "SLIMBUS_4_TX", "SLIMBUS_4_TX"}, {"LSM2 MUX", "SLIMBUS_5_TX", "SLIMBUS_5_TX"}, {"LSM2_UL_HL", NULL, "LSM2 MUX"}, {"LSM3 MUX", "SLIMBUS_0_TX", "SLIMBUS_0_TX"}, {"LSM3 MUX", "SLIMBUS_1_TX", "SLIMBUS_1_TX"}, {"LSM3 MUX", "SLIMBUS_3_TX", "SLIMBUS_3_TX"}, {"LSM3 MUX", "SLIMBUS_4_TX", "SLIMBUS_4_TX"}, {"LSM3 MUX", "SLIMBUS_5_TX", "SLIMBUS_5_TX"}, {"LSM3_UL_HL", NULL, "LSM3 MUX"}, {"LSM4 MUX", "SLIMBUS_0_TX", "SLIMBUS_0_TX"}, {"LSM4 MUX", "SLIMBUS_1_TX", "SLIMBUS_1_TX"}, {"LSM4 MUX", "SLIMBUS_3_TX", "SLIMBUS_3_TX"}, {"LSM4 MUX", "SLIMBUS_4_TX", "SLIMBUS_4_TX"}, {"LSM4 MUX", "SLIMBUS_5_TX", "SLIMBUS_5_TX"}, {"LSM4_UL_HL", NULL, "LSM4 MUX"}, {"LSM5 MUX", "SLIMBUS_0_TX", "SLIMBUS_0_TX"}, {"LSM5 MUX", "SLIMBUS_1_TX", "SLIMBUS_1_TX"}, {"LSM5 MUX", "SLIMBUS_3_TX", "SLIMBUS_3_TX"}, {"LSM5 MUX", "SLIMBUS_4_TX", "SLIMBUS_4_TX"}, {"LSM5 MUX", "SLIMBUS_5_TX", "SLIMBUS_5_TX"}, {"LSM5_UL_HL", NULL, "LSM5 MUX"}, {"LSM6 MUX", "SLIMBUS_0_TX", "SLIMBUS_0_TX"}, {"LSM6 MUX", "SLIMBUS_1_TX", "SLIMBUS_1_TX"}, {"LSM6 MUX", "SLIMBUS_3_TX", "SLIMBUS_3_TX"}, {"LSM6 MUX", "SLIMBUS_4_TX", "SLIMBUS_4_TX"}, {"LSM6 MUX", "SLIMBUS_5_TX", "SLIMBUS_5_TX"}, {"LSM6_UL_HL", NULL, "LSM6 MUX"}, {"LSM7 MUX", "SLIMBUS_0_TX", "SLIMBUS_0_TX"}, {"LSM7 MUX", "SLIMBUS_1_TX", "SLIMBUS_1_TX"}, {"LSM7 MUX", "SLIMBUS_3_TX", "SLIMBUS_3_TX"}, {"LSM7 MUX", "SLIMBUS_4_TX", "SLIMBUS_4_TX"}, {"LSM7 MUX", "SLIMBUS_5_TX", "SLIMBUS_5_TX"}, {"LSM7_UL_HL", NULL, "LSM7 MUX"}, {"LSM8 MUX", "SLIMBUS_0_TX", "SLIMBUS_0_TX"}, {"LSM8 MUX", "SLIMBUS_1_TX", "SLIMBUS_1_TX"}, {"LSM8 MUX", "SLIMBUS_3_TX", "SLIMBUS_3_TX"}, {"LSM8 MUX", "SLIMBUS_4_TX", "SLIMBUS_4_TX"}, {"LSM8 MUX", "SLIMBUS_5_TX", "SLIMBUS_5_TX"}, {"LSM8_UL_HL", NULL, "LSM8 MUX"}, {"QCHAT_Tx Mixer", "PRI_TX_QCHAT", "PRI_I2S_TX"}, {"QCHAT_Tx Mixer", "SLIM_0_TX_QCHAT", "SLIMBUS_0_TX"}, {"QCHAT_Tx Mixer", "<API key>", "INT_BT_SCO_TX"}, {"QCHAT_Tx Mixer", "AFE_PCM_TX_QCHAT", "PCM_TX"}, {"QCHAT_Tx Mixer", "AUX_PCM_TX_QCHAT", "AUX_PCM_TX"}, {"QCHAT_Tx Mixer", "<API key>", "SEC_AUX_PCM_TX"}, {"QCHAT_Tx Mixer", "MI2S_TX_QCHAT", "MI2S_TX"}, {"QCHAT_Tx Mixer", "PRI_MI2S_TX_QCHAT", "PRI_MI2S_TX"}, {"QCHAT_UL", NULL, "QCHAT_Tx Mixer"}, {"INT_FM_RX", NULL, "INTFM_DL_HL"}, {"INTFM_UL_HL", NULL, "INT_FM_TX"}, {"INTHFP_UL_HL", NULL, "INT_BT_SCO_TX"}, {"INT_BT_SCO_RX", NULL, "MM_DL6"}, {"AUX_PCM_RX", NULL, "AUXPCM_DL_HL"}, {"AUXPCM_UL_HL", NULL, "AUX_PCM_TX"}, {"MI2S_RX", NULL, "MI2S_DL_HL"}, {"MI2S_UL_HL", NULL, "MI2S_TX"}, {"PCM_RX_DL_HL", "Switch", "SLIM0_DL_HL"}, {"PCM_RX", NULL, "PCM_RX_DL_HL"}, {"PRI_MI2S_RX_DL_HL", "Switch", "PRI_MI2S_DL_HL"}, {"PRI_MI2S_RX", NULL, "PRI_MI2S_RX_DL_HL"}, {"MI2S_UL_HL", NULL, "TERT_MI2S_TX"}, {"SEC_I2S_RX", NULL, "SEC_I2S_DL_HL"}, {"PRI_MI2S_UL_HL", NULL, "PRI_MI2S_TX"}, {"SEC_MI2S_RX", NULL, "SEC_MI2S_DL_HL"}, {"SLIMBUS_0_RX Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"}, {"SLIMBUS_0_RX Port Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"}, {"SLIMBUS_0_RX Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"}, {"SLIMBUS_0_RX Port Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"}, {"SLIMBUS_0_RX Port Mixer", "MI2S_TX", "MI2S_TX"}, #if defined( <API key> ) || defined(<API key>) {"SLIMBUS_0_RX Port Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"}, #endif /* <API key> || <API key> */ {"SLIMBUS_0_RX", NULL, "SLIMBUS_0_RX Port Mixer"}, {"AFE_PCM_RX Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"}, {"PCM_RX", NULL, "AFE_PCM_RX Port Mixer"}, {"AUXPCM_RX Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"}, {"AUXPCM_RX Port Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"}, #if defined( <API key> ) || defined(<API key>) {"AUXPCM_RX Port Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"}, #endif /* <API key> || <API key> */ {"AUX_PCM_RX", NULL, "AUXPCM_RX Port Mixer"}, #if defined( <API key> ) || defined(<API key>) {"SEC_AUXPCM_RX Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"}, #endif /* <API key> || <API key> */ {"SEC_AUXPCM_RX Port Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"}, {"SEC_AUXPCM_RX Port Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"}, {"SEC_AUX_PCM_RX", NULL, "SEC_AUXPCM_RX Port Mixer"}, {"Voice Stub Tx Mixer", "STUB_TX_HL", "STUB_TX"}, {"Voice Stub Tx Mixer", "SLIM_1_TX", "SLIMBUS_1_TX"}, {"Voice Stub Tx Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"}, {"Voice Stub Tx Mixer", "STUB_1_TX_HL", "STUB_1_TX"}, #if defined( <API key> ) || defined(<API key>) {"Voice Stub Tx Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"}, {"Voice Stub Tx Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"}, #endif /* <API key> || <API key> */ {"Voice Stub Tx Mixer", "MI2S_TX", "MI2S_TX"}, #if defined( <API key> ) || defined(<API key>) {"Voice Stub Tx Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"}, #endif /* <API key> || <API key> */ {"VOICE_STUB_UL", NULL, "Voice Stub Tx Mixer"}, {"STUB_RX Mixer", "Voice Stub", "VOICE_STUB_DL"}, {"STUB_RX", NULL, "STUB_RX Mixer"}, {"SLIMBUS_1_RX Mixer", "Voice Stub", "VOICE_STUB_DL"}, {"SLIMBUS_1_RX", NULL, "SLIMBUS_1_RX Mixer"}, {"<API key> Mixer", "Voice Stub", "VOICE_STUB_DL"}, {"SLIMBUS_3_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"}, {"SLIMBUS_3_RX", NULL, "SLIMBUS_3_RX_Voice Mixer"}, {"SLIMBUS_1_RX Port Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"}, {"SLIMBUS_1_RX", NULL, "SLIMBUS_1_RX Port Mixer"}, {"INTERNAL_BT_SCO_RX Port Mixer", "SLIM_1_TX", "SLIMBUS_1_TX"}, #if defined( <API key> ) || defined(<API key>) {"INTERNAL_BT_SCO_RX Port Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"}, #endif /* <API key> || <API key> */ {"INT_BT_SCO_RX", NULL, "INTERNAL_BT_SCO_RX Port Mixer"}, {"SLIMBUS_3_RX Port Mixer", "INTERNAL_BT_SCO_RX", "INT_BT_SCO_RX"}, {"SLIMBUS_3_RX Port Mixer", "MI2S_TX", "MI2S_TX"}, {"SLIMBUS_3_RX", NULL, "SLIMBUS_3_RX Port Mixer"}, {"HDMI_RX Port Mixer", "MI2S_TX", "MI2S_TX"}, {"HDMI", NULL, "HDMI_RX Port Mixer"}, {"SEC_I2S_RX Port Mixer", "MI2S_TX", "MI2S_TX"}, {"SEC_I2S_RX", NULL, "SEC_I2S_RX Port Mixer"}, {"MI2S_RX Port Mixer", "SLIM_1_TX", "SLIMBUS_1_TX"}, {"MI2S_RX Port Mixer", "MI2S_TX", "MI2S_TX"}, {"MI2S_RX", NULL, "MI2S_RX Port Mixer"}, {"PRI_MI2S_RX Port Mixer", "SEC_MI2S_TX", "SEC_MI2S_TX"}, {"PRI_MI2S_RX", NULL, "PRI_MI2S_RX Port Mixer"}, /* Backend Enablement */ {"BE_OUT", NULL, "PRI_I2S_RX"}, {"BE_OUT", NULL, "SEC_I2S_RX"}, {"BE_OUT", NULL, "SLIMBUS_0_RX"}, {"BE_OUT", NULL, "SLIMBUS_1_RX"}, {"BE_OUT", NULL, "SLIMBUS_3_RX"}, {"BE_OUT", NULL, "SLIMBUS_4_RX"}, {"BE_OUT", NULL, "HDMI"}, {"BE_OUT", NULL, "MI2S_RX"}, {"BE_OUT", NULL, "QUAT_MI2S_RX"}, {"BE_OUT", NULL, "TERT_MI2S_RX"}, {"BE_OUT", NULL, "SEC_MI2S_RX"}, {"BE_OUT", NULL, "PRI_MI2S_RX"}, {"BE_OUT", NULL, "INT_BT_SCO_RX"}, {"BE_OUT", NULL, "INT_FM_RX"}, {"BE_OUT", NULL, "PCM_RX"}, {"BE_OUT", NULL, "SLIMBUS_3_RX"}, {"BE_OUT", NULL, "AUX_PCM_RX"}, {"BE_OUT", NULL, "SEC_AUX_PCM_RX"}, {"BE_OUT", NULL, "INT_BT_SCO_RX"}, {"BE_OUT", NULL, "INT_FM_RX"}, {"BE_OUT", NULL, "PCM_RX"}, {"BE_OUT", NULL, "SLIMBUS_3_RX"}, {"BE_OUT", NULL, "AUX_PCM_RX"}, {"BE_OUT", NULL, "SEC_AUX_PCM_RX"}, {"BE_OUT", NULL, "VOICE_PLAYBACK_TX"}, {"BE_OUT", NULL, "VOICE2_PLAYBACK_TX"}, {"PRI_I2S_TX", NULL, "BE_IN"}, {"MI2S_TX", NULL, "BE_IN"}, {"QUAT_MI2S_TX", NULL, "BE_IN"}, {"PRI_MI2S_TX", NULL, "BE_IN"}, {"TERT_MI2S_TX", NULL, "BE_IN"}, {"SEC_MI2S_TX", NULL, "BE_IN"}, {"SLIMBUS_0_TX", NULL, "BE_IN" }, {"SLIMBUS_1_TX", NULL, "BE_IN" }, {"SLIMBUS_3_TX", NULL, "BE_IN" }, {"SLIMBUS_4_TX", NULL, "BE_IN" }, {"SLIMBUS_5_TX", NULL, "BE_IN" }, {"INT_BT_SCO_TX", NULL, "BE_IN"}, {"INT_FM_TX", NULL, "BE_IN"}, {"PCM_TX", NULL, "BE_IN"}, {"AUX_PCM_TX", NULL, "BE_IN"}, {"SEC_AUX_PCM_TX", NULL, "BE_IN"}, {"INCALL_RECORD_TX", NULL, "BE_IN"}, {"INCALL_RECORD_RX", NULL, "BE_IN"}, {"<API key>", "SLIM4_TX", "SLIMBUS_4_TX"}, {"SLIMBUS_0_RX", NULL, "<API key>"}, }; static int <API key>(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; unsigned int be_id = rtd->dai_link->be_id; if (be_id >= MSM_BACKEND_DAI_MAX) { pr_err("%s: unexpected be_id %d\n", __func__, be_id); return -EINVAL; } mutex_lock(&routing_lock); msm_bedais[be_id].sample_rate = params_rate(params); msm_bedais[be_id].channel = params_channels(params); msm_bedais[be_id].format = params_format(params); mutex_unlock(&routing_lock); return 0; } static int <API key>(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; unsigned int be_id = rtd->dai_link->be_id; int i, session_type, path_type, topology; struct <API key> *bedai; if (be_id >= MSM_BACKEND_DAI_MAX) { pr_err("%s: unexpected be_id %d\n", __func__, be_id); return -EINVAL; } bedai = &msm_bedais[be_id]; session_type = (substream->stream == <API key> ? 0 : 1); if (substream->stream == <API key>) path_type = ADM_PATH_PLAYBACK; else path_type = ADM_PATH_LIVE_REC; mutex_lock(&routing_lock); topology = get_topology(path_type); for_each_set_bit(i, &bedai->fe_sessions, <API key>) { if (fe_dai_map[i][session_type].strm_id != INVALID_SESSION) { fe_dai_map[i][session_type].be_srate = bedai->sample_rate; adm_close(bedai->port_id, fe_dai_perf_mode[i][session_type]); srs_port_id = -1; if ((<API key> == topology) && (fe_dai_perf_mode[i][session_type] == LEGACY_PCM_MODE)) dolby_dap_deinit(bedai->port_id); } } bedai->active = 0; bedai->sample_rate = 0; bedai->channel = 0; mutex_unlock(&routing_lock); return 0; } static int <API key>(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; unsigned int be_id = rtd->dai_link->be_id; int i, path_type, session_type, port_id, topology; struct <API key> *bedai; u32 channels; bool playback, capture; uint16_t bits_per_sample = 16; struct <API key> *fdai; if (be_id >= MSM_BACKEND_DAI_MAX) { pr_err("%s: unexpected be_id %d\n", __func__, be_id); return -EINVAL; } bedai = &msm_bedais[be_id]; if (substream->stream == <API key>) { path_type = ADM_PATH_PLAYBACK; session_type = SESSION_TYPE_RX; } else { path_type = ADM_PATH_LIVE_REC; session_type = SESSION_TYPE_TX; } mutex_lock(&routing_lock); topology = get_topology(path_type); if (bedai->active == 1) goto done; /* Ignore prepare if back-end already active */ /* AFE port is not active at this point. However, still * go ahead setting active flag under the notion that * QDSP6 is able to handle ADM starting before AFE port * is started. */ bedai->active = 1; playback = substream->stream == <API key>; capture = substream->stream == <API key>; for_each_set_bit(i, &bedai->fe_sessions, <API key>) { fdai = &fe_dai_map[i][session_type]; if (fdai->strm_id != INVALID_SESSION) { if (session_type == SESSION_TYPE_TX && fdai->be_srate && (fdai->be_srate != bedai->sample_rate)) { pr_debug("%s: flush strm %d diff BE rates\n", __func__, fdai->strm_id); if (fdai->event_info.event_func) fdai->event_info.event_func( <API key>, fdai->event_info.priv_data); fdai->be_srate = 0; /* might not need it */ } channels = bedai->channel; if (bedai->format == <API key>) bits_per_sample = 24; if (bedai->port_id == VOICE_RECORD_RX || bedai->port_id == VOICE_RECORD_TX) topology = <API key>; if ((playback) && (channels > 0)) { <API key>(bedai->port_id, path_type, bedai->sample_rate, channels, topology, fe_dai_perf_mode[i][session_type], bits_per_sample); } else if (capture) { adm_open(bedai->port_id, path_type, bedai->sample_rate, channels, topology, fe_dai_perf_mode[i][session_type], bits_per_sample); } <API key>(i, fdai->strm_id, path_type, fe_dai_perf_mode[i][session_type]); port_id = srs_port_id = bedai->port_id; srs_send_params(srs_port_id, 1, 0); if ((<API key> == topology) && (fe_dai_perf_mode[i][session_type] == LEGACY_PCM_MODE)) if (dolby_dap_init(port_id, channels) < 0) pr_err("%s: Err init dolby dap\n", __func__); } } done: mutex_unlock(&routing_lock); return 0; } static struct snd_pcm_ops msm_routing_pcm_ops = { .hw_params = <API key>, .close = <API key>, .prepare = <API key>, }; static unsigned int msm_routing_read(struct snd_soc_platform *platform, unsigned int reg) { dev_dbg(platform->dev, "reg %x\n", reg); return 0; } /* Not used but frame seems to require it */ static int msm_routing_write(struct snd_soc_platform *platform, unsigned int reg, unsigned int val) { dev_dbg(platform->dev, "reg %x val %x\n", reg, val); return 0; } /* Not used but frame seems to require it */ static int msm_routing_probe(struct snd_soc_platform *platform) { <API key>(&platform->dapm, msm_qdsp6_widgets, ARRAY_SIZE(msm_qdsp6_widgets)); <API key>(&platform->dapm, intercon, ARRAY_SIZE(intercon)); <API key>(&platform->dapm); <API key>(platform, <API key>, ARRAY_SIZE(<API key>)); <API key>(platform, <API key>, ARRAY_SIZE(<API key>)); <API key>(platform, <API key>, ARRAY_SIZE(<API key>)); <API key>(platform, <API key>, ARRAY_SIZE(<API key>)); <API key>(platform, <API key>, ARRAY_SIZE(<API key>)); <API key>(platform, <API key>, ARRAY_SIZE(<API key>)); <API key>(platform, <API key>, ARRAY_SIZE(<API key>)); <API key>(platform, <API key>, ARRAY_SIZE(<API key>)); <API key>(platform, <API key>, ARRAY_SIZE(<API key>)); <API key>(platform, <API key>, ARRAY_SIZE(<API key>)); <API key>(platform, <API key>, ARRAY_SIZE(<API key>)); <API key>(platform, lsm_function, ARRAY_SIZE(lsm_function)); <API key>(platform, <API key>, ARRAY_SIZE(<API key>)); <API key>(platform, aanc_slim_0_rx_mux, ARRAY_SIZE(aanc_slim_0_rx_mux)); <API key>(platform, <API key>, ARRAY_SIZE(<API key>)); <API key>(platform, <API key>, ARRAY_SIZE(<API key>)); <API key>(platform, <API key>, ARRAY_SIZE(<API key>)); <API key>(platform, <API key>, ARRAY_SIZE(<API key>)); <API key>(platform, <API key>, ARRAY_SIZE(<API key>)); <API key>(platform, get_rms_controls, ARRAY_SIZE(get_rms_controls)); <API key>(platform, <API key>, ARRAY_SIZE(<API key>)); return 0; } static struct <API key> <API key> = { .ops = &msm_routing_pcm_ops, .probe = msm_routing_probe, .read = msm_routing_read, .write = msm_routing_write, }; static __devinit int <API key>(struct platform_device *pdev) { if (pdev->dev.of_node) dev_set_name(&pdev->dev, "%s", "msm-pcm-routing"); dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev)); return <API key>(&pdev->dev, &<API key>); } static int <API key>(struct platform_device *pdev) { <API key>(&pdev->dev); return 0; } static const struct of_device_id <API key>[] = { {.compatible = "qcom,msm-pcm-routing"}, {} }; MODULE_DEVICE_TABLE(of, <API key>); static struct platform_driver <API key> = { .driver = { .name = "msm-pcm-routing", .owner = THIS_MODULE, .of_match_table = <API key>, }, .probe = <API key>, .remove = __devexit_p(<API key>), }; int <API key>(int fedai_id) { int i; if (fedai_id >= <API key>) { /* bad ID assigned in machine driver */ pr_err("%s: bad MM ID\n", __func__); return 0; } for (i = 0; i < MSM_BACKEND_DAI_MAX; i++) { if (test_bit(fedai_id, &msm_bedais[i].fe_sessions)) return msm_bedais[i].active; } return 0; } static int __init <API key>(void) { mutex_init(&routing_lock); return <API key>(&<API key>); } module_init(<API key>); static void __exit <API key>(void) { <API key>(&<API key>); } module_exit(<API key>); MODULE_DESCRIPTION("MSM routing platform driver"); MODULE_LICENSE("GPL v2");
<?php defined('_JEXEC') or die('Direct Access to ' . basename(__FILE__) . 'is not allowed.'); class <API key> extends amazonHelper { public function __construct (<API key> $<API key>, $method) { parent::__construct($<API key>, $method); } public function <API key> () { $response = $this->amazonData; $amazonInternalData = new stdClass(); if ($response-><API key>()) { $<API key> = $response-><API key>(); if ($<API key>-><API key>()) { $<API key> = $<API key>-><API key>(); if ($<API key>-><API key>()) { $amazonInternalData-><API key> = $<API key>-><API key>(); } if ($<API key>-><API key>()) { $<API key> = $<API key>-><API key>(); if ($<API key>->isSetState()) { $amazonInternalData-><API key> = $<API key>->getReasonCode(); } if ($<API key>->isSetReasonCode()) { $amazonInternalData-><API key> = $<API key>->getReasonCode(); } if ($<API key>-><API key>()) { $amazonInternalData-><API key> = $<API key>-><API key>(); } } } } return $amazonInternalData; } /** * @return string */ function getContents () { $contents = ""; $contents .= "Service Response" . "<br />"; $contents .= "=============================" . "<br />"; $contents .= "<API key>" . "<br />"; if ($this->amazonData-><API key>()) { $contents .= "<API key>" . "<br />"; $<API key> = $this->amazonData-><API key>(); if ($<API key>-><API key>()) { $contents .= " <API key>" . "<br />"; $<API key> = $<API key>-><API key>(); if ($<API key>-><API key>()) { $contents .= "<API key>: " . $<API key>-><API key>() . "<br />"; } if ($<API key>->isSetBuyer()) { $contents .= "Buyer" . "<br />"; $buyer = $<API key>->getBuyer(); if ($buyer->isSetName()) { $contents .= "Name: " . $buyer->getName() . "<br />"; } if ($buyer->isSetEmail()) { $contents .= "Email: " . $buyer->getEmail() . "<br />"; } if ($buyer->isSetPhone()) { $contents .= "Phone: " . $buyer->getPhone() . "<br />"; } } if ($<API key>->isSetOrderTotal()) { $contents .= "OrderTotal" . "<br />"; $orderTotal = $<API key>->getOrderTotal(); if ($orderTotal->isSetCurrencyCode()) { $contents .= "CurrencyCode: " . $orderTotal->getCurrencyCode() . "<br />"; } if ($orderTotal->isSetAmount()) { $contents .= "Amount: " . $orderTotal->getAmount() . "<br />"; } } if ($<API key>->isSetSellerNote()) { $contents .= "SellerNote: " . $<API key>->getSellerNote() . "<br />"; } if ($<API key>->isSetDestination()) { $contents .= "Destination" . "<br />"; $destination = $<API key>->getDestination(); if ($destination-><API key>()) { $contents .= "DestinationType: " . $destination->getDestinationType() . "<br />"; } if ($destination-><API key>()) { $contents .= "PhysicalDestination" . "<br />"; $physicalDestination = $destination-><API key>(); if ($physicalDestination->isSetName()) { $contents .= " Name: " . $physicalDestination->getName() . "<br />"; } if ($physicalDestination->isSetAddressLine1()) { $contents .= " AddressLine1: " . $physicalDestination->getAddressLine1() . "<br />"; } if ($physicalDestination->isSetAddressLine2()) { $contents .= " AddressLine2: " . $physicalDestination->getAddressLine2() . "<br />"; } if ($physicalDestination->isSetAddressLine3()) { $contents .= " AddressLine3: " . $physicalDestination->getAddressLine3() . "<br />"; } if ($physicalDestination->isSetCity()) { $contents .= " City: " . $physicalDestination->getCity() . "<br />"; } if ($physicalDestination->isSetCounty()) { $contents .= " County: " . $physicalDestination->getCounty() . "<br />"; } if ($physicalDestination->isSetDistrict()) { $contents .= " District: " . $physicalDestination->getDistrict() . "<br />"; } if ($physicalDestination->isSetStateOrRegion()) { $contents .= " StateOrRegion: " . $physicalDestination->getStateOrRegion() . "<br />"; } if ($physicalDestination->isSetPostalCode()) { $contents .= " PostalCode: " . $physicalDestination->getPostalCode() . "<br />"; } if ($physicalDestination->isSetCountryCode()) { $contents .= " CountryCode: " . $physicalDestination->getCountryCode() . "<br />"; } if ($physicalDestination->isSetPhone()) { $contents .= " Phone: " . $physicalDestination->getPhone() . "<br />"; } } } if ($<API key>-><API key>()) { $contents .= "ReleaseEnvironment" . "<br />"; $contents .= "" . $<API key>-><API key>() . "<br />"; } if ($<API key>->isSetIdList()) { $contents .= "IdList" . "<br />"; $idList = $<API key>->getIdList(); $memberList = $idList->getmember(); foreach ($memberList as $member) { $contents .= "member: " . $member . "<br />";; } } if ($<API key>-><API key>()) { $contents .= "<API key>" . "<br />"; $<API key> = $<API key>-><API key>(); if ($<API key>->isSetSellerOrderId()) { $contents .= "SellerOrderId: " . $<API key>->getSellerOrderId() . "<br />"; } if ($<API key>->isSetStoreName()) { $contents .= "StoreName: " . $<API key>->getStoreName() . "<br />"; } if ($<API key>-><API key>()) { $contents .= "OrderItemCategories" . "<br />"; $orderItemCategories = $<API key>-><API key>(); $<API key> = $orderItemCategories-><API key>(); foreach ($<API key> as $orderItemCategory) { $contents .= " OrderItemCategory: " . $orderItemCategory; } } if ($<API key>-><API key>()) { $contents .= "CustomInformation: " . $<API key>-><API key>() . "<br />"; } } if ($<API key>-><API key>()) { $contents .= "<API key>" . "<br />"; $<API key> = $<API key>-><API key>(); if ($<API key>->isSetState()) { $contents .= "State: " . $<API key>->getState() . "<br />"; } if ($<API key>-><API key>()) { $contents .= "LastUpdateTimestamp: " . $<API key>-><API key>() . "<br />"; } if ($<API key>->isSetReasonCode()) { $contents .= "ReasonCode: " . $<API key>->getReasonCode() . "<br />"; } if ($<API key>-><API key>()) { $contents .= "ReasonDescription: " . $<API key>-><API key>() . "<br />"; } } if ($<API key>->isSetConstraints()) { $contents .= "Constraints" . "<br />"; $constraints = $<API key>->getConstraints(); $constraintList = $constraints->getConstraint(); foreach ($constraintList as $constraint) { $contents .= "Constraint" . "<br />"; if ($constraint->isSetConstraintID()) { $contents .= " ConstraintID: " . $constraint->getConstraintID() . "<br />"; } if ($constraint->isSetDescription()) { $contents .= " Description: " . $constraint->getDescription() . "<br />"; } } } if ($<API key>-><API key>()) { $contents .= "CreationTimestamp: " . $<API key>-><API key>() . "<br />"; } if ($<API key>-><API key>()) { $contents .= "ExpirationTimestamp: " . $<API key>-><API key>() . "<br />"; } if ($<API key>->isSetParentDetails()) { $contents .= "ParentDetails" . "<br />"; $parentDetails = $<API key>->getParentDetails(); if ($parentDetails->isSetId()) { $contents .= "Id: " . $parentDetails->getId() . "<br />"; } if ($parentDetails->isSetType()) { $contents .= "Type: " . $parentDetails->getType() . "<br />"; } } } } /* if ($this->amazonData-><API key>()) { $contents .= "ResponseMetadata" . "<br />"; $responseMetadata = $this->amazonData->getResponseMetadata(); if ($responseMetadata->isSetRequestId()) { $contents .= " RequestId: " . $responseMetadata->getRequestId() . "<br />"; } } $contents .= "<API key>: " . $this->amazonData-><API key>() . "<br />"; */ $contents .= $this->tableEnd(); return $contents; } }
/*global tinymce:true */ tinymce.PluginManager.add('fullscreen', function(editor) { var fullscreenState = false, DOM = tinymce.DOM, iframeWidth, iframeHeight, resizeHandler; var containerWidth, containerHeight; if (editor.settings.inline) { return; } function getWindowSize() { var w, h, win = window, doc = document; var body = doc.body; // Old IE if (body.offsetWidth) { w = body.offsetWidth; h = body.offsetHeight; } // Modern browsers if (win.innerWidth && win.innerHeight) { w = win.innerWidth; h = win.innerHeight; } return {w: w, h: h}; } function toggleFullscreen() { var body = document.body, documentElement = document.documentElement, <API key>; var editorContainer, iframe, iframeStyle; function resize() { DOM.setStyle(iframe, 'height', getWindowSize().h - (editorContainer.clientHeight - iframe.clientHeight)); } fullscreenState = !fullscreenState; editorContainer = editor.getContainer(); <API key> = editorContainer.style; iframe = editor.<API key>().firstChild; iframeStyle = iframe.style; if (fullscreenState) { iframeWidth = iframeStyle.width; iframeHeight = iframeStyle.height; iframeStyle.width = iframeStyle.height = '100%'; containerWidth = <API key>.width; containerHeight = <API key>.height; <API key>.width = <API key>.height = ''; DOM.addClass(body, 'mce-fullscreen'); DOM.addClass(documentElement, 'mce-fullscreen'); DOM.addClass(editorContainer, 'mce-fullscreen'); DOM.bind(window, 'resize', resize); resize(); resizeHandler = resize; } else { iframeStyle.width = iframeWidth; iframeStyle.height = iframeHeight; if (containerWidth) { <API key>.width = containerWidth; } if (containerHeight) { <API key>.height = containerHeight; } DOM.removeClass(body, 'mce-fullscreen'); DOM.removeClass(documentElement, 'mce-fullscreen'); DOM.removeClass(editorContainer, 'mce-fullscreen'); DOM.unbind(window, 'resize', resizeHandler); } editor.fire('<API key>', {state: fullscreenState}); } editor.on('init', function() { editor.addShortcut('Meta+Alt+F', '', toggleFullscreen); }); editor.on('remove', function() { if (resizeHandler) { DOM.unbind(window, 'resize', resizeHandler); } }); editor.addCommand('mceFullScreen', toggleFullscreen); editor.addMenuItem('fullscreen', { text: 'Fullscreen', shortcut: 'Meta+Alt+F', selectable: true, onClick: toggleFullscreen, onPostRender: function() { var self = this; editor.on('<API key>', function(e) { self.active(e.state); }); }, context: 'view' }); editor.addButton('fullscreen', { tooltip: 'Fullscreen', shortcut: 'Meta+Alt+F', onClick: toggleFullscreen, onPostRender: function() { var self = this; editor.on('<API key>', function(e) { self.active(e.state); }); } }); return { isFullscreen: function() { return fullscreenState; } }; });
#ifndef <API key> #define <API key> #define GSENSOR_NAME "bma250" #define GPIO_GS_INT 70 #define LEVEL0 0 #define LEVEL1 1 #define LEVEL2 2 #define LEVEL3 3 //#define GSENSOR_DBG #ifdef GSENSOR_DBG static int gsensor_debug_level = 0; #define GSENSOR_DEBUG(level, fmt, ...) \ do { \ if (level <= gsensor_debug_level) \ printk("[GSENSOR] %s(%d): " fmt "\n", __FUNCTION__, __LINE__, ## __VA_ARGS__); \ } while(0) #else #define GSENSOR_DEBUG(level, fmt, ...) #endif struct <API key> { int (*gpio_init)(void); int layout; }; #endif /* <API key> */
/* misc.h */ #ifndef <API key> #define <API key> #if HAVE_CONFIG_H # include "config.h" #endif void die(const char *format, ...) PRINTF_STYLE (1, 2) NORETURN; void werror(const char *format, ...) PRINTF_STYLE (1, 2); void * xalloc(size_t size); enum sexp_mode { SEXP_CANONICAL = 0, SEXP_ADVANCED = 1, SEXP_TRANSPORT = 2, }; enum sexp_token { SEXP_STRING, SEXP_DISPLAY, /* Constructed by sexp_parse */ SEXP_COMMENT, SEXP_LIST_START, SEXP_LIST_END, SEXP_EOF, /* The below types are internal to the input parsing. sexp_parse * should never return a token of this type. */ SEXP_DISPLAY_START, SEXP_DISPLAY_END, <API key>, SEXP_CODING_END, }; extern const char sexp_token_chars[0x80]; #define TOKEN_CHAR(c) ((c) < 0x80 && sexp_token_chars[(c)]) #endif /* <API key> */
#include <linux/io.h> #include <media/v4l2-subdev.h> #include <asm/div64.h> #include "msm_isp_util.h" #include "msm_isp_axi_util.h" #include <linux/time.h> #define SENSOR_ISP_MAX 2 int g_subcam_SOF = 0; extern int g_subcam_vfe_intf; extern int g_subcam_no_ack; #define SRC_TO_INTF(src) \ ((src < RDI_INTF_0 || src == VFE_AXI_SRC_MAX) ? VFE_PIX_0 : \ (VFE_RAW_0 + src - RDI_INTF_0)) #define HANDLE_TO_IDX(handle) (handle & 0xFF) int <API key>( struct <API key> *axi_data, struct <API key> *stream_cfg_cmd) { int i, rc = -1; for (i = 0; i < MAX_NUM_STREAM; i++) { if (axi_data->stream_info[i].state == AVALIABLE) break; } if (i == MAX_NUM_STREAM) { pr_err("%s: No free stream\n", __func__); return rc; } if ((axi_data->stream_handle_cnt << 8) == 0) axi_data->stream_handle_cnt++; stream_cfg_cmd->axi_stream_handle = (++axi_data->stream_handle_cnt) << 8 | i; memset(&axi_data->stream_info[i], 0, sizeof(struct msm_vfe_axi_stream)); spin_lock_init(&axi_data->stream_info[i].lock); axi_data->stream_info[i].session_id = stream_cfg_cmd->session_id; axi_data->stream_info[i].stream_id = stream_cfg_cmd->stream_id; axi_data->stream_info[i].buf_divert = stream_cfg_cmd->buf_divert; axi_data->stream_info[i].state = INACTIVE; axi_data->stream_info[i].stream_handle = stream_cfg_cmd->axi_stream_handle; axi_data->stream_info[i].controllable_output = stream_cfg_cmd->controllable_output; if (stream_cfg_cmd->controllable_output) stream_cfg_cmd->frame_skip_pattern = SKIP_ALL; INIT_LIST_HEAD(&axi_data->stream_info[i].request_q); return 0; } void <API key>( struct <API key> *axi_data, int stream_idx) { if (axi_data->stream_info[stream_idx].state != AVALIABLE) { axi_data->stream_info[stream_idx].state = AVALIABLE; axi_data->stream_info[stream_idx].stream_handle = 0; } else { pr_err("%s: stream does not exist\n", __func__); } } int <API key>(struct <API key> *axi_data, struct <API key> *stream_cfg_cmd) { int rc = -1, i; struct msm_vfe_axi_stream *stream_info = NULL; if (HANDLE_TO_IDX(stream_cfg_cmd->axi_stream_handle) < MAX_NUM_STREAM) { stream_info = &axi_data->stream_info[ HANDLE_TO_IDX(stream_cfg_cmd->axi_stream_handle)]; } else { pr_err("%s: Invalid axi_stream_handle\n", __func__); return rc; } if (!stream_info) { pr_err("%s: Stream info is NULL\n", __func__); return -EINVAL; } switch (stream_cfg_cmd->output_format) { case V4L2_PIX_FMT_YUYV: case V4L2_PIX_FMT_YVYU: case V4L2_PIX_FMT_UYVY: case V4L2_PIX_FMT_VYUY: case V4L2_PIX_FMT_SBGGR8: case V4L2_PIX_FMT_SGBRG8: case V4L2_PIX_FMT_SGRBG8: case V4L2_PIX_FMT_SRGGB8: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case V4L2_PIX_FMT_QBGGR8: case V4L2_PIX_FMT_QGBRG8: case V4L2_PIX_FMT_QGRBG8: case V4L2_PIX_FMT_QRGGB8: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case V4L2_PIX_FMT_JPEG: case V4L2_PIX_FMT_META: stream_info->num_planes = 1; stream_info->format_factor = ISP_Q2; break; case V4L2_PIX_FMT_NV12: case V4L2_PIX_FMT_NV21: case V4L2_PIX_FMT_NV14: case V4L2_PIX_FMT_NV41: case V4L2_PIX_FMT_NV16: case V4L2_PIX_FMT_NV61: stream_info->num_planes = 2; stream_info->format_factor = 1.5 * ISP_Q2; break; default: <API key>(__func__, stream_cfg_cmd->output_format); return rc; } if (axi_data->hw_info->num_wm - axi_data->num_used_wm < stream_info->num_planes) { pr_err("%s: No free write masters\n", __func__); return rc; } if ((stream_info->num_planes > 1) && (axi_data->hw_info->num_comp_mask - axi_data-><API key> < 1)) { pr_err("%s: No free composite mask\n", __func__); return rc; } if (stream_cfg_cmd->init_frame_drop >= MAX_INIT_FRAME_DROP) { pr_err("%s: Invalid skip pattern\n", __func__); return rc; } if (stream_cfg_cmd->frame_skip_pattern >= MAX_SKIP) { pr_err("%s: Invalid skip pattern\n", __func__); return rc; } for (i = 0; i < stream_info->num_planes; i++) { stream_info->plane_cfg[i] = stream_cfg_cmd->plane_cfg[i]; stream_info->max_width = max(stream_info->max_width, stream_cfg_cmd->plane_cfg[i].output_width); } stream_info->output_format = stream_cfg_cmd->output_format; stream_info-><API key> = stream_info->output_format; stream_info->stream_src = stream_cfg_cmd->stream_src; stream_info->frame_based = stream_cfg_cmd->frame_base; return 0; } static uint32_t <API key>( struct msm_vfe_axi_stream *stream_info, int plane_idx) { uint32_t size = 0; struct <API key> *plane_cfg = stream_info->plane_cfg; switch (stream_info->output_format) { case V4L2_PIX_FMT_YUYV: case V4L2_PIX_FMT_YVYU: case V4L2_PIX_FMT_UYVY: case V4L2_PIX_FMT_VYUY: case V4L2_PIX_FMT_SBGGR8: case V4L2_PIX_FMT_SGBRG8: case V4L2_PIX_FMT_SGRBG8: case V4L2_PIX_FMT_SRGGB8: case V4L2_PIX_FMT_QBGGR8: case V4L2_PIX_FMT_QGBRG8: case V4L2_PIX_FMT_QGRBG8: case V4L2_PIX_FMT_QRGGB8: case V4L2_PIX_FMT_JPEG: case V4L2_PIX_FMT_META: size = plane_cfg[plane_idx].output_height * plane_cfg[plane_idx].output_width; break; case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: size = plane_cfg[plane_idx].output_height * plane_cfg[plane_idx].output_width; break; case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: size = plane_cfg[plane_idx].output_height * plane_cfg[plane_idx].output_width; break; case <API key>: case <API key>: case <API key>: case <API key>: size = plane_cfg[plane_idx].output_height * plane_cfg[plane_idx].output_width; break; case V4L2_PIX_FMT_NV12: case V4L2_PIX_FMT_NV21: if (plane_cfg[plane_idx].output_plane_format == Y_PLANE) size = plane_cfg[plane_idx].output_height * plane_cfg[plane_idx].output_width; else size = plane_cfg[plane_idx].output_height * plane_cfg[plane_idx].output_width; break; case V4L2_PIX_FMT_NV14: case V4L2_PIX_FMT_NV41: if (plane_cfg[plane_idx].output_plane_format == Y_PLANE) size = plane_cfg[plane_idx].output_height * plane_cfg[plane_idx].output_width; else size = plane_cfg[plane_idx].output_height * plane_cfg[plane_idx].output_width; break; case V4L2_PIX_FMT_NV16: case V4L2_PIX_FMT_NV61: size = plane_cfg[plane_idx].output_height * plane_cfg[plane_idx].output_width; break; default: <API key>(__func__, stream_info->output_format); break; } return size; } void <API key>(struct <API key> *axi_data, struct msm_vfe_axi_stream *stream_info) { int i, j; for (i = 0; i < stream_info->num_planes; i++) { for (j = 0; j < axi_data->hw_info->num_wm; j++) { if (!axi_data->free_wm[j]) { axi_data->free_wm[j] = stream_info->stream_handle; axi_data->wm_image_size[j] = <API key>( stream_info, i); axi_data->num_used_wm++; break; } } stream_info->wm[i] = j; } } void msm_isp_axi_free_wm(struct <API key> *axi_data, struct msm_vfe_axi_stream *stream_info) { int i; for (i = 0; i < stream_info->num_planes; i++) { axi_data->free_wm[stream_info->wm[i]] = 0; axi_data->num_used_wm } if (stream_info->stream_src <= IDEAL_RAW) { axi_data->num_pix_stream++; } else if (stream_info->stream_src < VFE_AXI_SRC_MAX) { axi_data->num_rdi_stream++; } } void <API key>( struct <API key> *axi_data, struct msm_vfe_axi_stream *stream_info) { int i; uint8_t comp_mask = 0; for (i = 0; i < stream_info->num_planes; i++) comp_mask |= 1 << stream_info->wm[i]; for (i = 0; i < axi_data->hw_info->num_comp_mask; i++) { if (!axi_data->composite_info[i].stream_handle) { axi_data->composite_info[i].stream_handle = stream_info->stream_handle; axi_data->composite_info[i]. <API key> = comp_mask; axi_data-><API key>++; break; } } stream_info->comp_mask_index = i; return; } void <API key>(struct <API key> *axi_data, struct msm_vfe_axi_stream *stream_info) { axi_data->composite_info[stream_info->comp_mask_index]. <API key> = 0; axi_data->composite_info[stream_info->comp_mask_index]. stream_handle = 0; axi_data-><API key> } int <API key>( struct vfe_device *vfe_dev, struct <API key> *stream_cfg_cmd) { int rc = 0, i; unsigned long flags; struct <API key> *axi_data = &vfe_dev->axi_data; struct msm_vfe_axi_stream *stream_info; enum msm_vfe_axi_state valid_state = (stream_cfg_cmd->cmd == START_STREAM) ? INACTIVE : ACTIVE; if (stream_cfg_cmd->num_streams > MAX_NUM_STREAM) return -EINVAL; for (i = 0; i < stream_cfg_cmd->num_streams; i++) { if (HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i]) > MAX_NUM_STREAM) { return -EINVAL; } stream_info = &axi_data->stream_info[ HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i])]; spin_lock_irqsave(&stream_info->lock, flags); if (stream_info->state != valid_state) { if ((stream_info->state == PAUSING || stream_info->state == PAUSED || stream_info->state == RESUME_PENDING || stream_info->state == RESUMING) && (stream_cfg_cmd->cmd == STOP_STREAM || stream_cfg_cmd->cmd == STOP_IMMEDIATELY)) { stream_info->state = ACTIVE; } else { pr_err("%s: Invalid stream state: %d\n", __func__, stream_info->state); <API key>( &stream_info->lock, flags); rc = -EINVAL; break; } } <API key>(&stream_info->lock, flags); } return rc; } void <API key>(struct vfe_device *vfe_dev, struct msm_vfe_axi_stream *stream_info) { uint32_t framedrop_pattern = 0, framedrop_period = 0; if (stream_info-><API key> == 0) { framedrop_pattern = stream_info->framedrop_pattern; framedrop_period = stream_info->framedrop_period; } if (stream_info->stream_type == BURST_STREAM && stream_info-><API key> == 0) { framedrop_pattern = 0; framedrop_period = 0; } ISP_DBG("%s: stream %x framedrop pattern %x period %u\n", __func__, stream_info->stream_id, framedrop_pattern, framedrop_period); vfe_dev->hw_info->vfe_ops.axi_ops.cfg_framedrop(vfe_dev, stream_info, framedrop_pattern, framedrop_period); } void <API key>(struct vfe_device *vfe_dev, enum msm_vfe_input_src frame_src) { int i; struct <API key> *axi_data = &vfe_dev->axi_data; struct msm_vfe_axi_stream *stream_info; for (i = 0; i < MAX_NUM_STREAM; i++) { if (SRC_TO_INTF(axi_data->stream_info[i].stream_src) != frame_src) { continue; } stream_info = &axi_data->stream_info[i]; if (stream_info->state != ACTIVE) continue; if (stream_info-><API key> && vfe_dev->axi_data.src_info[frame_src].frame_id > 0) { stream_info-><API key> if (stream_info-><API key> == 0) { stream_info-><API key> = 0; <API key>(vfe_dev, stream_info); } } if (stream_info->stream_type == BURST_STREAM && (SRC_TO_INTF(stream_info->stream_src) == frame_src)) { if (stream_info-><API key>) { stream_info-><API key> = 0; stream_info-><API key> = stream_info-><API key> + (stream_info-><API key> - 1) * (stream_info->framedrop_period + 1) + 1; <API key>(vfe_dev, stream_info); } else { stream_info-><API key> if (stream_info-><API key> == 0) <API key>(vfe_dev, stream_info); } } } } void <API key>(struct vfe_device *vfe_dev, struct msm_vfe_axi_stream *stream_info) { stream_info-><API key> = stream_info->init_frame_drop; stream_info-><API key> = stream_info->burst_frame_count; stream_info-><API key> = stream_info->num_burst_capture; stream_info-><API key> = stream_info->framedrop_update; <API key>(vfe_dev, stream_info); ISP_DBG("%s: init frame drop: %d\n", __func__, stream_info-><API key>); ISP_DBG("%s: burst_frame_count: %d\n", __func__, stream_info-><API key>); ISP_DBG("%s: num_burst_capture: %d\n", __func__, stream_info-><API key>); } void msm_isp_notify(struct vfe_device *vfe_dev, uint32_t event_type, enum msm_vfe_input_src frame_src, struct msm_isp_timestamp *ts) { struct msm_isp_event_data event_data; static struct timeval m_last[SENSOR_ISP_MAX]; struct timeval m_curr; static uint32_t last_frame_id[SENSOR_ISP_MAX]; uint32_t time_diff = 0; switch (event_type) { case ISP_EVENT_SOF: if (frame_src == VFE_PIX_0) { if ((vfe_dev->axi_data.src_info[VFE_PIX_0].frame_id < 3)|| (vfe_dev->axi_data.src_info[VFE_PIX_0].frame_id == 10)) { pr_info("[CAM]%s:(%d)PIX0 frame id: %u\n", __func__, vfe_dev->pdev->id, vfe_dev->axi_data.src_info[VFE_PIX_0].frame_id); } if(vfe_dev->axi_data.src_info[VFE_PIX_0].frame_id == 0) { do_gettimeofday(&m_last[vfe_dev->pdev->id]); last_frame_id[vfe_dev->pdev->id] = 0; } else { do_gettimeofday(&m_curr); time_diff = (m_curr.tv_sec-m_last[vfe_dev->pdev->id].tv_sec)*1000000 + (m_curr.tv_usec-m_last[vfe_dev->pdev->id].tv_usec); if(time_diff >= 1000000) { pr_info("[CAM]%s:(%d)PIX0 frame id: %u, fps: %d\n", __func__, vfe_dev->pdev->id, vfe_dev->axi_data.src_info[VFE_PIX_0].frame_id, (vfe_dev->axi_data.src_info[VFE_PIX_0].<API key>[vfe_dev->pdev->id])); m_last[vfe_dev->pdev->id] = m_curr; last_frame_id[vfe_dev->pdev->id] = vfe_dev->axi_data.src_info[VFE_PIX_0].frame_id; } } } if(vfe_dev->pdev->id == g_subcam_vfe_intf && g_subcam_SOF < 100) g_subcam_SOF ++; vfe_dev->axi_data.src_info[frame_src].frame_id++; if (vfe_dev->axi_data.src_info[frame_src].frame_id == 0) vfe_dev->axi_data.src_info[frame_src].frame_id = 1; ISP_DBG("%s: frame_src %d frame id: %u\n", __func__, frame_src, vfe_dev->axi_data.src_info[frame_src].frame_id); break; default: break; } event_data.input_intf = frame_src; event_data.frame_id = vfe_dev->axi_data.src_info[frame_src].frame_id; event_data.timestamp = ts->event_time; event_data.mono_timestamp = ts->buf_time; msm_isp_send_event(vfe_dev, event_type | frame_src, &event_data); } void <API key>( struct <API key> *axi_data, struct <API key> *stream_cfg_cmd) { uint32_t framedrop_period = 0; struct msm_vfe_axi_stream *stream_info = NULL; if (HANDLE_TO_IDX(stream_cfg_cmd->axi_stream_handle) < MAX_NUM_STREAM) { stream_info = &axi_data->stream_info[ HANDLE_TO_IDX(stream_cfg_cmd->axi_stream_handle)]; } else { pr_err("%s: Invalid stream handle", __func__); return; } if (!stream_info) { pr_err("%s: Stream info is NULL\n", __func__); return; } framedrop_period = <API key>( stream_cfg_cmd->frame_skip_pattern); stream_info->frame_skip_pattern = stream_cfg_cmd->frame_skip_pattern; if (stream_cfg_cmd->frame_skip_pattern == SKIP_ALL) stream_info->framedrop_pattern = 0x0; else stream_info->framedrop_pattern = 0x1; stream_info->framedrop_period = framedrop_period - 1; if (stream_cfg_cmd->init_frame_drop < framedrop_period) { stream_info->framedrop_pattern <<= stream_cfg_cmd->init_frame_drop; stream_info->init_frame_drop = 0; stream_info->framedrop_update = 0; } else { stream_info->init_frame_drop = stream_cfg_cmd->init_frame_drop; stream_info->framedrop_update = 1; } if (stream_cfg_cmd->burst_count > 0) { stream_info->stream_type = BURST_STREAM; stream_info->num_burst_capture = stream_cfg_cmd->burst_count; stream_info->burst_frame_count = stream_cfg_cmd->init_frame_drop + (stream_cfg_cmd->burst_count - 1) * framedrop_period + 1; } else { stream_info->stream_type = CONTINUOUS_STREAM; stream_info->burst_frame_count = 0; stream_info->num_burst_capture = 0; } } void <API key>( struct <API key> *axi_data, struct msm_vfe_axi_stream *stream_info) { if (stream_info->stream_src < RDI_INTF_0) { stream_info->bandwidth = (axi_data->src_info[VFE_PIX_0].pixel_clock / axi_data->src_info[VFE_PIX_0].width) * stream_info->max_width; stream_info->bandwidth = (unsigned long)stream_info->bandwidth * stream_info->format_factor / ISP_Q2; } else { int rdi = SRC_TO_INTF(stream_info->stream_src); if (rdi < VFE_SRC_MAX) stream_info->bandwidth = axi_data->src_info[rdi].pixel_clock; else pr_err("%s: Invalid rdi interface\n", __func__); } } #ifdef CONFIG_MSM_AVTIMER void <API key>(void) { avcs_core_open(); <API key>(1); } static inline void <API key>( struct msm_isp_timestamp *time_stamp) { int rc = 0; uint32_t avtimer_usec = 0; uint64_t avtimer_tick = 0; rc = <API key>(&avtimer_tick); if (rc < 0) { pr_err("%s: Error: Invalid AVTimer Tick, rc=%d\n", __func__, rc); time_stamp->vt_time.tv_sec = 0; time_stamp->vt_time.tv_usec = 0; } else { avtimer_usec = do_div(avtimer_tick, USEC_PER_SEC); time_stamp->vt_time.tv_sec = (uint32_t)(avtimer_tick); time_stamp->vt_time.tv_usec = avtimer_usec; pr_debug("%s: AVTimer TS = %u:%u\n", __func__, (uint32_t)(avtimer_tick), avtimer_usec); } } #else void <API key>(void) { pr_err("AV Timer is not supported\n"); } static inline void <API key>( struct msm_isp_timestamp *time_stamp) { pr_err_ratelimited("%s: Error: AVTimer driver not available\n", __func__); time_stamp->vt_time.tv_sec = 0; time_stamp->vt_time.tv_usec = 0; } #endif int <API key>(struct vfe_device *vfe_dev, void *arg) { int rc = 0, i; uint32_t io_format = 0; struct <API key> *stream_cfg_cmd = arg; struct msm_vfe_axi_stream *stream_info; rc = <API key>( &vfe_dev->axi_data, stream_cfg_cmd); if (rc) { pr_err("%s: create stream failed\n", __func__); return rc; } rc = <API key>( &vfe_dev->axi_data, stream_cfg_cmd); if (rc) { pr_err("%s: Request validation failed\n", __func__); <API key>(&vfe_dev->axi_data, HANDLE_TO_IDX(stream_cfg_cmd->axi_stream_handle)); return rc; } stream_info = &vfe_dev->axi_data. stream_info[HANDLE_TO_IDX(stream_cfg_cmd->axi_stream_handle)]; if (!stream_info) { pr_err("%s: can not find stream handle %x\n", __func__, stream_cfg_cmd->axi_stream_handle); return -EINVAL; } stream_info->memory_input = stream_cfg_cmd->memory_input; <API key>(&vfe_dev->axi_data, stream_info); if (stream_info->stream_src < RDI_INTF_0) { io_format = vfe_dev->axi_data.src_info[VFE_PIX_0].input_format; if (stream_info->stream_src == CAMIF_RAW || stream_info->stream_src == IDEAL_RAW) { if (stream_info->stream_src == CAMIF_RAW && io_format != stream_info->output_format) pr_debug("%s: Overriding input format\n", __func__); io_format = stream_info->output_format; } rc = vfe_dev->hw_info->vfe_ops.axi_ops.cfg_io_format( vfe_dev, stream_info->stream_src, io_format); if (rc) { pr_err("%s: cfg io format failed\n", __func__); msm_isp_axi_free_wm(&vfe_dev->axi_data, stream_info); <API key>(&vfe_dev->axi_data, HANDLE_TO_IDX( stream_cfg_cmd->axi_stream_handle)); return rc; } } <API key>(&vfe_dev->axi_data, stream_cfg_cmd); if (stream_cfg_cmd->vt_enable && !vfe_dev->vt_enable) { vfe_dev->vt_enable = stream_cfg_cmd->vt_enable; <API key>(); } if (stream_info->num_planes > 1) { <API key>( &vfe_dev->axi_data, stream_info); vfe_dev->hw_info->vfe_ops.axi_ops. cfg_comp_mask(vfe_dev, stream_info); } else { vfe_dev->hw_info->vfe_ops.axi_ops. cfg_wm_irq_mask(vfe_dev, stream_info); } for (i = 0; i < stream_info->num_planes; i++) { vfe_dev->hw_info->vfe_ops.axi_ops. cfg_wm_reg(vfe_dev, stream_info, i); vfe_dev->hw_info->vfe_ops.axi_ops. cfg_wm_xbar_reg(vfe_dev, stream_info, i); } return rc; } int <API key>(struct vfe_device *vfe_dev, void *arg) { int rc = 0, i; struct <API key> *stream_release_cmd = arg; struct <API key> *axi_data = &vfe_dev->axi_data; struct msm_vfe_axi_stream *stream_info = &axi_data->stream_info[ HANDLE_TO_IDX(stream_release_cmd->stream_handle)]; struct <API key> stream_cfg; if (stream_info->state == AVALIABLE) { pr_err("%s: Stream already released\n", __func__); return -EINVAL; } else if (stream_info->state != INACTIVE) { stream_cfg.cmd = STOP_STREAM; stream_cfg.num_streams = 1; stream_cfg.stream_handle[0] = stream_release_cmd->stream_handle; <API key>(vfe_dev, (void *) &stream_cfg); } for (i = 0; i < stream_info->num_planes; i++) { vfe_dev->hw_info->vfe_ops.axi_ops. clear_wm_reg(vfe_dev, stream_info, i); vfe_dev->hw_info->vfe_ops.axi_ops. clear_wm_xbar_reg(vfe_dev, stream_info, i); } if (stream_info->num_planes > 1) { vfe_dev->hw_info->vfe_ops.axi_ops. clear_comp_mask(vfe_dev, stream_info); <API key>(&vfe_dev->axi_data, stream_info); } else { vfe_dev->hw_info->vfe_ops.axi_ops. clear_wm_irq_mask(vfe_dev, stream_info); } vfe_dev->hw_info->vfe_ops.axi_ops.clear_framedrop(vfe_dev, stream_info); msm_isp_axi_free_wm(axi_data, stream_info); <API key>(&vfe_dev->axi_data, HANDLE_TO_IDX(stream_release_cmd->stream_handle)); return rc; } static void <API key>( struct vfe_device *vfe_dev, struct msm_vfe_axi_stream *stream_info) { int i; struct <API key> *axi_data = &vfe_dev->axi_data; if (stream_info->state == INACTIVE) return; for (i = 0; i < stream_info->num_planes; i++) { if (stream_info->state == START_PENDING || stream_info->state == RESUME_PENDING) { vfe_dev->hw_info->vfe_ops.axi_ops. enable_wm(vfe_dev, stream_info->wm[i], 1); } else { vfe_dev->hw_info->vfe_ops.axi_ops. enable_wm(vfe_dev, stream_info->wm[i], 0); if (vfe_dev->axi_data.src_info[VFE_PIX_0]. raw_stream_count > 0 && vfe_dev->axi_data.src_info[VFE_PIX_0]. pix_stream_count == 0) { if (stream_info->stream_src == CAMIF_RAW || stream_info->stream_src == IDEAL_RAW) { vfe_dev->hw_info->vfe_ops.core_ops. reg_update(vfe_dev, VFE_PIX_0); } } } } if (stream_info->state == START_PENDING) axi_data->num_active_stream++; else if (stream_info->state == STOP_PENDING) axi_data->num_active_stream } void <API key>(struct vfe_device *vfe_dev, enum msm_vfe_input_src frame_src) { int i; unsigned long flags; struct <API key> *axi_data = &vfe_dev->axi_data; spin_lock_irqsave(&vfe_dev->shared_data_lock, flags); for (i = 0; i < MAX_NUM_STREAM; i++) { if (SRC_TO_INTF(axi_data->stream_info[i].stream_src) != frame_src) { ISP_DBG("%s stream_src %d frame_src %d\n", __func__, SRC_TO_INTF( axi_data->stream_info[i].stream_src), frame_src); continue; } if (axi_data->stream_info[i].state == UPDATING) axi_data->stream_info[i].state = ACTIVE; else if (axi_data->stream_info[i].state == START_PENDING || axi_data->stream_info[i].state == STOP_PENDING) { <API key>( vfe_dev, &axi_data->stream_info[i]); axi_data->stream_info[i].state = axi_data->stream_info[i].state == START_PENDING ? STARTING : STOPPING; } else if (axi_data->stream_info[i].state == STARTING || axi_data->stream_info[i].state == STOPPING) { axi_data->stream_info[i].state = axi_data->stream_info[i].state == STARTING ? ACTIVE : INACTIVE; } } if (vfe_dev->axi_data.stream_update[frame_src]) { vfe_dev->axi_data.stream_update[frame_src] } if (vfe_dev->axi_data.pipeline_update == DISABLE_CAMIF || (vfe_dev->axi_data.pipeline_update == <API key>)) { vfe_dev->hw_info->vfe_ops.stats_ops. enable_module(vfe_dev, 0xFF, 0); vfe_dev->axi_data.pipeline_update = NO_UPDATE; } if (vfe_dev->axi_data.stream_update[frame_src] == 0) complete(&vfe_dev-><API key>); <API key>(&vfe_dev->shared_data_lock, flags); } static void <API key>(struct vfe_device *vfe_dev, struct msm_vfe_axi_stream *stream_info) { int i, j; uint32_t flag; struct msm_isp_buffer *buf; for (i = 0; i < 2; i++) { buf = stream_info->buf[i]; if (!buf) continue; flag = i ? VFE_PONG_FLAG : VFE_PING_FLAG; for (j = 0; j < stream_info->num_planes; j++) { vfe_dev->hw_info->vfe_ops.axi_ops.<API key>( vfe_dev, stream_info->wm[j], flag, buf->mapped_info[j].paddr + stream_info->plane_cfg[j].plane_addr_offset); } } } void <API key>(struct vfe_device *vfe_dev, enum msm_vfe_input_src frame_src) { int i, j; uint32_t update_state; unsigned long flags; struct <API key> *axi_data = &vfe_dev->axi_data; struct msm_vfe_axi_stream *stream_info; int num_stream = 0; for (i = 0; i < MAX_NUM_STREAM; i++) { if (SRC_TO_INTF(axi_data->stream_info[i].stream_src) != frame_src) { continue; } num_stream++; stream_info = &axi_data->stream_info[i]; if (stream_info->stream_type == BURST_STREAM || stream_info->state == AVALIABLE) continue; spin_lock_irqsave(&stream_info->lock, flags); if (stream_info->state == PAUSING) { stream_info->state = PAUSED; <API key>(vfe_dev, stream_info); for (j = 0; j < stream_info->num_planes; j++) vfe_dev->hw_info->vfe_ops.axi_ops. cfg_wm_reg(vfe_dev, stream_info, j); stream_info->state = RESUME_PENDING; <API key>( vfe_dev, &axi_data->stream_info[i]); stream_info->state = RESUMING; } else if (stream_info->state == RESUMING) { stream_info-><API key> = stream_info->output_format; stream_info->state = ACTIVE; } <API key>(&stream_info->lock, flags); } if (num_stream) update_state = atomic_dec_return( &axi_data->axi_cfg_update[frame_src]); } static int <API key>(struct vfe_device *vfe_dev, struct msm_vfe_axi_stream *stream_info) { int i, rc = -1; struct msm_isp_buffer *buf = stream_info->buf[0]; if (!buf) return rc; for (i = 0; i < stream_info->num_planes; i++) vfe_dev->hw_info->vfe_ops.axi_ops.<API key>( vfe_dev, stream_info->wm[i], VFE_PONG_FLAG, buf->mapped_info[i].paddr + stream_info->plane_cfg[i].plane_addr_offset); stream_info->buf[1] = buf; return 0; } static void <API key>(struct vfe_device *vfe_dev, struct msm_vfe_axi_stream *stream_info, uint32_t pingpong_status, struct msm_isp_buffer **done_buf) { uint32_t pingpong_bit = 0, i; pingpong_bit = (~(pingpong_status >> stream_info->wm[0]) & 0x1); for (i = 0; i < stream_info->num_planes; i++) { if (pingpong_bit != (~(pingpong_status >> stream_info->wm[i]) & 0x1)) { pr_debug("%s: Write master ping pong mismatch. Status: 0x%x\n", __func__, pingpong_status); } } *done_buf = stream_info->buf[pingpong_bit]; if (stream_info->controllable_output) { stream_info->buf[pingpong_bit] = NULL; if (!stream_info-><API key>) { pr_err("%s:%d error <API key> 0\n", __func__, __LINE__); } else { stream_info-><API key> } } } static int <API key>(struct vfe_device *vfe_dev, struct msm_vfe_axi_stream *stream_info, uint32_t pingpong_status) { int i, rc = -1; struct msm_isp_buffer *buf = NULL; uint32_t bufq_handle = 0; struct <API key> *queue_req; uint32_t pingpong_bit; uint32_t stream_idx = HANDLE_TO_IDX(stream_info->stream_handle); if (stream_idx >= MAX_NUM_STREAM) { pr_err("%s: Invalid stream_idx", __func__); return rc; } if (!stream_info->controllable_output) { bufq_handle = stream_info->bufq_handle[<API key>]; } else { queue_req = <API key>(&stream_info->request_q, struct <API key>, list); if (!queue_req) return 0; queue_req->cmd_used = 0; bufq_handle = stream_info-> bufq_handle[queue_req->buff_queue_id]; list_del(&queue_req->list); stream_info->request_q_cnt if (!bufq_handle) { pr_err("%s: Drop request. Shared stream is stopped.\n", __func__); return -EINVAL; } } rc = vfe_dev->buf_mgr->ops->get_buf(vfe_dev->buf_mgr, vfe_dev->pdev->id, bufq_handle, &buf); if (rc < 0) { vfe_dev->error_info.<API key>[stream_idx]++; return rc; } if (buf->num_planes != stream_info->num_planes) { pr_err("%s: Invalid buffer\n", __func__); rc = -EINVAL; goto buf_error; } for (i = 0; i < stream_info->num_planes; i++) vfe_dev->hw_info->vfe_ops.axi_ops.<API key>( vfe_dev, stream_info->wm[i], pingpong_status, buf->mapped_info[i].paddr + stream_info->plane_cfg[i].plane_addr_offset); pingpong_bit = (~(pingpong_status >> stream_info->wm[0]) & 0x1); stream_info->buf[pingpong_bit] = buf; return 0; buf_error: vfe_dev->buf_mgr->ops->put_buf(vfe_dev->buf_mgr, buf->bufq_handle, buf->buf_idx); return rc; } static void <API key>(struct vfe_device *vfe_dev, struct msm_vfe_axi_stream *stream_info, struct msm_isp_buffer *buf, struct msm_isp_timestamp *ts) { int rc; struct msm_isp_event_data buf_event; struct timeval *time_stamp; uint32_t stream_idx = HANDLE_TO_IDX(stream_info->stream_handle); uint32_t frame_id; uint32_t buf_src; memset(&buf_event, 0, sizeof(buf_event)); if (SRC_TO_INTF(stream_info->stream_src) >= VFE_SRC_MAX) { pr_err("%s: Invalid stream index, put buf back to vb2 queue\n", __func__); vfe_dev->buf_mgr->ops->put_buf(vfe_dev->buf_mgr, buf->bufq_handle, buf->buf_idx); return; } if (!buf || !ts) return; frame_id = vfe_dev->axi_data. src_info[SRC_TO_INTF(stream_info->stream_src)].frame_id; if (vfe_dev->vt_enable) { <API key>(ts); time_stamp = &ts->vt_time; } else { time_stamp = &ts->buf_time; } rc = vfe_dev->buf_mgr->ops->get_buf_src(vfe_dev->buf_mgr, buf->bufq_handle, &buf_src); if (stream_info->buf_divert && rc == 0 && buf_src != <API key>) { rc = vfe_dev->buf_mgr->ops->buf_divert(vfe_dev->buf_mgr, buf->bufq_handle, buf->buf_idx, time_stamp, frame_id); if (rc) return; buf_event.input_intf = SRC_TO_INTF(stream_info->stream_src); buf_event.frame_id = frame_id; buf_event.timestamp = *time_stamp; buf_event.u.buf_done.session_id = stream_info->session_id; buf_event.u.buf_done.stream_id = stream_info->stream_id; buf_event.u.buf_done.handle = buf->bufq_handle; buf_event.u.buf_done.buf_idx = buf->buf_idx; buf_event.u.buf_done.output_format = stream_info-><API key>; msm_isp_send_event(vfe_dev, <API key> + stream_idx, &buf_event); } else { buf_event.input_intf = SRC_TO_INTF(stream_info->stream_src); buf_event.frame_id = frame_id; buf_event.timestamp = ts->buf_time; buf_event.u.buf_done.session_id = stream_info->session_id; buf_event.u.buf_done.stream_id = stream_info->stream_id; buf_event.u.buf_done.output_format = stream_info-><API key>; msm_isp_send_event(vfe_dev, ISP_EVENT_BUF_DONE, &buf_event); vfe_dev->buf_mgr->ops->buf_done(vfe_dev->buf_mgr, buf->bufq_handle, buf->buf_idx, time_stamp, frame_id, stream_info-><API key>); } } static enum <API key> <API key>(struct vfe_device *vfe_dev, struct <API key> *stream_cfg_cmd) { int i; struct msm_vfe_axi_stream *stream_info; struct <API key> *axi_data = &vfe_dev->axi_data; uint8_t pix_stream_cnt = 0, cur_pix_stream_cnt; cur_pix_stream_cnt = axi_data->src_info[VFE_PIX_0].pix_stream_count + axi_data->src_info[VFE_PIX_0].raw_stream_count; for (i = 0; i < stream_cfg_cmd->num_streams; i++) { stream_info = &axi_data->stream_info[ HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i])]; if (stream_info->stream_src < RDI_INTF_0) pix_stream_cnt++; } if ((pix_stream_cnt) && (axi_data->src_info[VFE_PIX_0].input_mux != EXTERNAL_READ)) { if (cur_pix_stream_cnt == 0 && pix_stream_cnt && stream_cfg_cmd->cmd == START_STREAM) return ENABLE_CAMIF; else if (cur_pix_stream_cnt && (cur_pix_stream_cnt - pix_stream_cnt) == 0 && stream_cfg_cmd->cmd == STOP_STREAM) return DISABLE_CAMIF; else if (cur_pix_stream_cnt && (cur_pix_stream_cnt - pix_stream_cnt) == 0 && stream_cfg_cmd->cmd == STOP_IMMEDIATELY) return <API key>; } return NO_UPDATE; } static void <API key>( struct vfe_device *vfe_dev, struct <API key> *stream_cfg_cmd) { int i; struct msm_vfe_axi_stream *stream_info; struct <API key> *axi_data = &vfe_dev->axi_data; if (stream_cfg_cmd->num_streams > MAX_NUM_STREAM) return; for (i = 0; i < stream_cfg_cmd->num_streams; i++) { if (HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i]) > MAX_NUM_STREAM) { return; } stream_info = &axi_data->stream_info[ HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i])]; if (stream_info->stream_src >= RDI_INTF_0) continue; if (stream_info->stream_src == PIX_ENCODER || stream_info->stream_src == PIX_VIEWFINDER || stream_info->stream_src == PIX_VIDEO || stream_info->stream_src == IDEAL_RAW) { if (stream_cfg_cmd->cmd == START_STREAM) vfe_dev->axi_data.src_info[VFE_PIX_0]. pix_stream_count++; else vfe_dev->axi_data.src_info[VFE_PIX_0]. pix_stream_count } else if (stream_info->stream_src == CAMIF_RAW) { if (stream_cfg_cmd->cmd == START_STREAM) vfe_dev->axi_data.src_info[VFE_PIX_0]. raw_stream_count++; else vfe_dev->axi_data.src_info[VFE_PIX_0]. raw_stream_count } } } #define <API key> 6 #define <API key> 6 static int <API key>(struct vfe_device *vfe_dev) { int i, rc = 0; struct msm_vfe_axi_stream *stream_info; struct <API key> *axi_data = &vfe_dev->axi_data; uint64_t total_pix_bandwidth = 0, total_rdi_bandwidth = 0; uint32_t num_pix_streams = 0; uint64_t total_bandwidth = 0; for (i = 0; i < MAX_NUM_STREAM; i++) { stream_info = &axi_data->stream_info[i]; if (stream_info->state == ACTIVE || stream_info->state == START_PENDING) { if (stream_info->stream_src < RDI_INTF_0) { total_pix_bandwidth += stream_info->bandwidth; num_pix_streams++; } else { total_rdi_bandwidth += stream_info->bandwidth; } } } total_bandwidth = total_pix_bandwidth + total_rdi_bandwidth; rc = <API key>(ISP_VFE0 + vfe_dev->pdev->id, total_bandwidth, total_bandwidth * <API key> / ISP_Q2); if (rc < 0) pr_err("%s: update failed\n", __func__); return rc; } static int <API key>(struct vfe_device *vfe_dev, enum <API key> camif_update, uint32_t src_mask) { int rc; unsigned long flags; enum msm_vfe_input_src i = 0; spin_lock_irqsave(&vfe_dev->shared_data_lock, flags); for (i = 0; i < VFE_SRC_MAX; i++) { if (src_mask & (1 << i)) vfe_dev->axi_data.stream_update[i] = 2; } if (src_mask) { init_completion(&vfe_dev-><API key>); vfe_dev->axi_data.pipeline_update = camif_update; } <API key>(&vfe_dev->shared_data_lock, flags); if(g_subcam_no_ack == 1 && vfe_dev->pdev->id == g_subcam_vfe_intf) { rc = <API key>( &vfe_dev-><API key>, msecs_to_jiffies(100)); } else rc = <API key>( &vfe_dev-><API key>, msecs_to_jiffies(VFE_MAX_CFG_TIMEOUT)); if (rc == 0) { for (i = 0; i < VFE_SRC_MAX; i++) { if (src_mask & (1 << i)) vfe_dev->axi_data.stream_update[i] = 0; } pr_err("%s: wait timeout\n", __func__); rc = -EBUSY; } else { rc = 0; } return rc; } static int <API key>( struct vfe_device *vfe_dev, struct msm_vfe_axi_stream *stream_info) { int rc = 0; rc = <API key>(vfe_dev, stream_info, VFE_PING_FLAG); if (rc < 0) { pr_err("%s: No free buffer for ping\n", __func__); return rc; } if (stream_info->stream_type == BURST_STREAM && stream_info-><API key> <= 1) { rc = <API key>(vfe_dev, stream_info); if (rc < 0) { pr_err("%s: No free buffer for pong\n", __func__); return rc; } } else { rc = <API key>(vfe_dev, stream_info, VFE_PONG_FLAG); if (rc < 0) { pr_err("%s: No free buffer for pong\n", __func__); return rc; } } return rc; } static void <API key>( struct vfe_device *vfe_dev, struct msm_vfe_axi_stream *stream_info) { int i; for (i = 0; i < 2; i++) { struct msm_isp_buffer *buf; buf = stream_info->buf[i]; if (buf) { vfe_dev->buf_mgr->ops->put_buf(vfe_dev->buf_mgr, buf->bufq_handle, buf->buf_idx); } } } static void <API key>( struct msm_vfe_axi_stream *stream_info, uint32_t *wm_reload_mask) { int i; for (i = 0; i < stream_info->num_planes; i++) *wm_reload_mask |= (1 << stream_info->wm[i]); } int msm_isp_axi_halt(struct vfe_device *vfe_dev, struct <API key> *halt_cmd) { int rc = 0; if (halt_cmd->overflow_detected) { if (vfe_dev->error_info.<API key> == 0) { vfe_dev->hw_info->vfe_ops.core_ops.get_irq_mask(vfe_dev, &vfe_dev->error_info.<API key>, &vfe_dev->error_info.<API key>); } atomic_set(&vfe_dev->error_info.overflow_state, OVERFLOW_DETECTED); } rc = vfe_dev->hw_info->vfe_ops.axi_ops.halt(vfe_dev, 1); if (halt_cmd->stop_camif) { vfe_dev->hw_info->vfe_ops.core_ops. update_camif_state(vfe_dev, <API key>); } return rc; } int msm_isp_axi_reset(struct vfe_device *vfe_dev, struct <API key> *reset_cmd) { int rc = 0, i, j; struct msm_vfe_axi_stream *stream_info; struct <API key> *axi_data = &vfe_dev->axi_data; struct msm_isp_bufq *bufq = NULL; uint32_t bufq_handle = 0, bufq_id = 0; if (!reset_cmd) { pr_err("%s: NULL pointer reset cmd %p\n", __func__, reset_cmd); rc = -1; return rc; } rc = vfe_dev->hw_info->vfe_ops.core_ops.reset_hw(vfe_dev, 0, reset_cmd->blocking); for (i = 0, j = 0; j < axi_data->num_active_stream && i < MAX_NUM_STREAM; i++, j++) { stream_info = &axi_data->stream_info[i]; if (stream_info->stream_src >= VFE_AXI_SRC_MAX) { rc = -1; pr_err("%s invalid stream src = %d\n", __func__, stream_info->stream_src); break; } if (stream_info->state != ACTIVE) { j continue; } for (bufq_id = 0; bufq_id < VFE_BUF_QUEUE_MAX; bufq_id++) { bufq_handle = stream_info->bufq_handle[bufq_id]; if (!bufq_handle) continue; bufq = vfe_dev->buf_mgr->ops->get_bufq(vfe_dev->buf_mgr, bufq_handle); if (!bufq) { pr_err("%s: bufq null %p by handle %x\n", __func__, bufq, bufq_handle); continue; } if (bufq->buf_type != ISP_SHARE_BUF) { <API key>(vfe_dev, stream_info); } else { vfe_dev->buf_mgr->ops->flush_buf( vfe_dev->buf_mgr, bufq_handle, <API key>); } axi_data->src_info[SRC_TO_INTF(stream_info-> stream_src)]. frame_id = reset_cmd->frame_id; <API key>(vfe_dev, stream_info); } } if (rc < 0) pr_err("%s Error! reset hw Timed out\n", __func__); return rc; } int msm_isp_axi_restart(struct vfe_device *vfe_dev, struct <API key> *restart_cmd) { int rc = 0, i, j; struct msm_vfe_axi_stream *stream_info; struct <API key> *axi_data = &vfe_dev->axi_data; uint32_t wm_reload_mask = 0x0; for (i = 0, j = 0; j < axi_data->num_active_stream && i < MAX_NUM_STREAM; i++, j++) { stream_info = &axi_data->stream_info[i]; if (stream_info->state != ACTIVE) { j continue; } <API key>(stream_info, &wm_reload_mask); <API key>(vfe_dev, stream_info); } vfe_dev->hw_info->vfe_ops.axi_ops.reload_wm(vfe_dev, wm_reload_mask); rc = vfe_dev->hw_info->vfe_ops.axi_ops.restart(vfe_dev, 0, restart_cmd->enable_camif); if (rc < 0) pr_err("%s Error restarting HW\n", __func__); return rc; } static int <API key>(struct vfe_device *vfe_dev, struct <API key> *stream_cfg_cmd, uint8_t cgc_override) { int i = 0, j = 0; struct msm_vfe_axi_stream *stream_info; struct <API key> *axi_data = &vfe_dev->axi_data; if (stream_cfg_cmd->num_streams > MAX_NUM_STREAM) return -EINVAL; for (i = 0; i < stream_cfg_cmd->num_streams; i++) { if (HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i]) > MAX_NUM_STREAM) { return -EINVAL; } stream_info = &axi_data->stream_info[ HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i])]; for (j = 0; j < stream_info->num_planes; j++) { if (vfe_dev->hw_info->vfe_ops.axi_ops. update_cgc_override) vfe_dev->hw_info->vfe_ops.axi_ops. update_cgc_override(vfe_dev, stream_info->wm[j], cgc_override); } } return 0; } static int <API key>(struct vfe_device *vfe_dev, struct <API key> *stream_cfg_cmd, enum <API key> camif_update) { int i, rc = 0; uint8_t src_state, wait_for_complete = 0; uint32_t wm_reload_mask = 0x0; struct msm_vfe_axi_stream *stream_info; struct <API key> *axi_data = &vfe_dev->axi_data; uint32_t src_mask = 0; if (stream_cfg_cmd->num_streams > MAX_NUM_STREAM) return -EINVAL; for (i = 0; i < stream_cfg_cmd->num_streams; i++) { if (HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i]) > MAX_NUM_STREAM) { return -EINVAL; } stream_info = &axi_data->stream_info[ HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i])]; if (SRC_TO_INTF(stream_info->stream_src) < VFE_SRC_MAX) src_state = axi_data->src_info[ SRC_TO_INTF(stream_info->stream_src)].active; else { ISP_DBG("%s: invalid src info index\n", __func__); return -EINVAL; } <API key>(axi_data, stream_info); <API key>(vfe_dev, stream_info); <API key>(stream_info, &wm_reload_mask); rc = <API key>(vfe_dev, stream_info); if (rc < 0) { pr_err("%s: No buffer for stream%d\n", __func__, HANDLE_TO_IDX( stream_cfg_cmd->stream_handle[i])); return rc; } stream_info->state = START_PENDING; if (src_state) { src_mask |= (1 << SRC_TO_INTF(stream_info->stream_src)); wait_for_complete = 1; } else { if (vfe_dev->dump_reg) <API key>(vfe_dev->vfe_base, 0x900); <API key>(vfe_dev, stream_info); stream_info->state = ACTIVE; vfe_dev->hw_info->vfe_ops.core_ops.reg_update(vfe_dev, SRC_TO_INTF(stream_info->stream_src)); } if (SRC_TO_INTF(stream_info->stream_src) >= VFE_RAW_0 && SRC_TO_INTF(stream_info->stream_src) < VFE_SRC_MAX) { vfe_dev->axi_data.src_info[SRC_TO_INTF( stream_info->stream_src)].frame_id = 0; } } <API key>(vfe_dev); vfe_dev->hw_info->vfe_ops.axi_ops.reload_wm(vfe_dev, wm_reload_mask); <API key>(vfe_dev, stream_cfg_cmd); if (camif_update == ENABLE_CAMIF) { atomic_set(&vfe_dev->error_info.overflow_state, NO_OVERFLOW); vfe_dev->axi_data.src_info[VFE_PIX_0].frame_id = 0; vfe_dev->hw_info->vfe_ops.core_ops. update_camif_state(vfe_dev, camif_update); } if (wait_for_complete) { rc = <API key>(vfe_dev, camif_update, src_mask); if (rc < 0) pr_err("%s: wait for config done failed\n", __func__); } return rc; } static int <API key>(struct vfe_device *vfe_dev, struct <API key> *stream_cfg_cmd, enum <API key> camif_update) { int i, rc = 0; uint8_t <API key> = 0; struct msm_vfe_axi_stream *stream_info = NULL; struct <API key> *axi_data = &vfe_dev->axi_data; int ext_read = (axi_data->src_info[VFE_PIX_0].input_mux == EXTERNAL_READ); uint32_t src_mask = 0; if (stream_cfg_cmd->num_streams > MAX_NUM_STREAM || stream_cfg_cmd->num_streams == 0) return -EINVAL; for (i = 0; i < stream_cfg_cmd->num_streams; i++) { if (HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i]) > MAX_NUM_STREAM) { return -EINVAL; } stream_info = &axi_data->stream_info[ HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i])]; <API key> = 0; stream_info->state = STOP_PENDING; if (stream_info->stream_src == CAMIF_RAW || stream_info->stream_src == IDEAL_RAW) { if ((camif_update != <API key>) && (!ext_read)) <API key> = 1; } else if (stream_info->stream_type == BURST_STREAM && stream_info-><API key> == 0) { if (stream_info->stream_src == RDI_INTF_0 || stream_info->stream_src == RDI_INTF_1 || stream_info->stream_src == RDI_INTF_2) <API key> = 1; } else { if ((camif_update != <API key>) && (!ext_read)) <API key> = 1; } if (!<API key>) { <API key>(vfe_dev, stream_info); stream_info->state = INACTIVE; vfe_dev->hw_info->vfe_ops.core_ops.reg_update(vfe_dev, SRC_TO_INTF(stream_info->stream_src)); } else src_mask |= (1 << SRC_TO_INTF(stream_info->stream_src)); } if (src_mask) { rc = <API key>(vfe_dev, camif_update, src_mask); if (rc < 0) { pr_err("%s: wait for config done failed\n", __func__); for (i = 0; i < stream_cfg_cmd->num_streams; i++) { stream_info = &axi_data->stream_info[ HANDLE_TO_IDX( stream_cfg_cmd->stream_handle[i])]; stream_info->state = STOP_PENDING; <API key>( vfe_dev, stream_info); vfe_dev->hw_info->vfe_ops.core_ops.reg_update( vfe_dev, SRC_TO_INTF(stream_info->stream_src)); stream_info->state = INACTIVE; } } } if (camif_update == DISABLE_CAMIF) { vfe_dev->hw_info->vfe_ops.core_ops. update_camif_state(vfe_dev, DISABLE_CAMIF); } else if ((camif_update == <API key>) || (ext_read)) { vfe_dev->ignore_error = 1; vfe_dev->hw_info->vfe_ops.axi_ops.halt(vfe_dev, 1); if (!ext_read) vfe_dev->hw_info->vfe_ops.core_ops. update_camif_state(vfe_dev, <API key>); vfe_dev->hw_info->vfe_ops.core_ops.reset_hw(vfe_dev, 0, 1); vfe_dev->hw_info->vfe_ops.core_ops.init_hw_reg(vfe_dev); vfe_dev->ignore_error = 0; } <API key>(vfe_dev, stream_cfg_cmd); <API key>(vfe_dev); for (i = 0; i < stream_cfg_cmd->num_streams; i++) { stream_info = &axi_data->stream_info[ HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i])]; <API key>(vfe_dev, stream_info); } return rc; } int <API key>(struct vfe_device *vfe_dev, void *arg) { int rc = 0; struct <API key> *stream_cfg_cmd = arg; struct <API key> *axi_data = &vfe_dev->axi_data; enum <API key> camif_update; rc = <API key>(vfe_dev, stream_cfg_cmd); if (rc < 0) { pr_err("%s: Invalid stream state\n", __func__); return rc; } if (axi_data->num_active_stream == 0) { vfe_dev->hw_info->vfe_ops.axi_ops.cfg_ub(vfe_dev); } camif_update = <API key>(vfe_dev, stream_cfg_cmd); if (stream_cfg_cmd->cmd == START_STREAM) { <API key>(vfe_dev, stream_cfg_cmd, 1); rc = <API key>( vfe_dev, stream_cfg_cmd, camif_update); } else { rc = <API key>( vfe_dev, stream_cfg_cmd, camif_update); <API key>(vfe_dev, stream_cfg_cmd, 0); } if (rc < 0) pr_err("%s: start/stop stream failed\n", __func__); return rc; } static int <API key>(struct vfe_device *vfe_dev, struct msm_vfe_axi_stream *stream_info, uint32_t user_stream_id) { struct <API key> stream_cfg_cmd; struct <API key> *queue_req; uint32_t pingpong_status, wm_reload_mask = 0x0; unsigned long flags; int rc = 0; if (!stream_info->controllable_output) return 0; spin_lock_irqsave(&stream_info->lock, flags); queue_req = &stream_info->request_queue_cmd[stream_info->request_q_idx]; if (queue_req->cmd_used) { <API key>(&stream_info->lock, flags); pr_err_ratelimited("%s: Request queue overflow.\n", __func__); return -EINVAL; } if (user_stream_id == stream_info->stream_id) queue_req->buff_queue_id = <API key>; else queue_req->buff_queue_id = <API key>; if (!stream_info->bufq_handle[queue_req->buff_queue_id]) { <API key>(&stream_info->lock, flags); pr_err("%s:%d stream is stoped\n", __func__, __LINE__); return 0; } queue_req->cmd_used = 1; stream_info->request_q_idx = (stream_info->request_q_idx + 1) % <API key>; list_add_tail(&queue_req->list, &stream_info->request_q); stream_info->request_q_cnt++; stream_info-><API key>++; stream_cfg_cmd.axi_stream_handle = stream_info->stream_handle; stream_cfg_cmd.frame_skip_pattern = NO_SKIP; stream_cfg_cmd.init_frame_drop = 0; stream_cfg_cmd.burst_count = stream_info->request_q_cnt; <API key>(&vfe_dev->axi_data, &stream_cfg_cmd); <API key>(vfe_dev, stream_info); if (stream_info-><API key> == 1) { rc = <API key>(vfe_dev, stream_info, VFE_PING_FLAG); if (rc) { <API key>(&stream_info->lock, flags); pr_err("%s:%d fail to set ping pong address\n", __func__, __LINE__); return rc; } <API key>(stream_info, &wm_reload_mask); vfe_dev->hw_info->vfe_ops.axi_ops.reload_wm(vfe_dev, wm_reload_mask); } else if (stream_info-><API key> == 2) { pingpong_status = vfe_dev->hw_info->vfe_ops.axi_ops.get_pingpong_status( vfe_dev); rc = <API key>(vfe_dev, stream_info, pingpong_status); if (rc) { <API key>(&stream_info->lock, flags); pr_err("%s:%d fail to set ping pong address\n", __func__, __LINE__); return rc; } } <API key>(&stream_info->lock, flags); return rc; } static int <API key>(struct vfe_device *vfe_dev, struct msm_vfe_axi_stream *stream_info, uint32_t stream_id) { int rc = 0; uint32_t bufq_id = 0; if (stream_id == stream_info->stream_id) bufq_id = <API key>; else bufq_id = <API key>; stream_info->bufq_handle[bufq_id] = vfe_dev->buf_mgr->ops->get_bufq_handle(vfe_dev->buf_mgr, stream_info->session_id, stream_id); if (stream_info->bufq_handle[bufq_id] == 0) { pr_err("%s: failed: No valid buffer queue for stream: 0x%x\n", __func__, stream_id); rc = -EINVAL; } return rc; } static void <API key>(struct vfe_device *vfe_dev, struct msm_vfe_axi_stream *stream_info, uint32_t stream_id) { uint32_t bufq_id = 0; unsigned long flags; if (stream_id == stream_info->stream_id) bufq_id = <API key>; else bufq_id = <API key>; spin_lock_irqsave(&stream_info->lock, flags); stream_info->bufq_handle[bufq_id] = 0; <API key>(&stream_info->lock, flags); } int <API key>(struct vfe_device *vfe_dev, void *arg) { int rc = 0, i, j; struct msm_vfe_axi_stream *stream_info; struct <API key> *axi_data = &vfe_dev->axi_data; struct <API key> *update_cmd = arg; struct <API key> *update_info; if (update_cmd->num_streams > MAX_NUM_STREAM) return -EINVAL; for (i = 0; i < update_cmd->num_streams; i++) { update_info = &update_cmd->update_info[i]; if (HANDLE_TO_IDX(update_info->stream_handle) > MAX_NUM_STREAM) { return -EINVAL; } stream_info = &axi_data->stream_info[ HANDLE_TO_IDX(update_info->stream_handle)]; if (SRC_TO_INTF(stream_info->stream_src) >= VFE_SRC_MAX) continue; if (stream_info->state != ACTIVE && stream_info->state != INACTIVE) { pr_err("%s: Invalid stream state\n", __func__); return -EINVAL; } if (update_cmd->update_type == <API key> && atomic_read(&axi_data->axi_cfg_update[ SRC_TO_INTF(stream_info->stream_src)])) { pr_err("%s: AXI stream config updating\n", __func__); return -EBUSY; } } for (i = 0; i < update_cmd->num_streams; i++) { update_info = &update_cmd->update_info[i]; stream_info = &axi_data->stream_info[ HANDLE_TO_IDX(update_info->stream_handle)]; switch (update_cmd->update_type) { case <API key>: stream_info->buf_divert = 1; break; case <API key>: stream_info->buf_divert = 0; vfe_dev->buf_mgr->ops->flush_buf(vfe_dev->buf_mgr, stream_info->bufq_handle[<API key>], <API key>); break; case <API key>: { uint32_t framedrop_period = <API key>( update_info->skip_pattern); if (stream_info->controllable_output) { pr_err("Controllable output streams does not support custom frame skip pattern\n"); return -EINVAL; } if (update_info->skip_pattern == SKIP_ALL) stream_info->framedrop_pattern = 0x0; else stream_info->framedrop_pattern = 0x1; stream_info->framedrop_period = framedrop_period - 1; if (stream_info->stream_type == BURST_STREAM) { stream_info-><API key> = 1; } else { stream_info-><API key> = 0; <API key>(vfe_dev, stream_info); } break; } case <API key>: { for (j = 0; j < stream_info->num_planes; j++) { stream_info->plane_cfg[j] = update_info->plane_cfg[j]; } stream_info->output_format = update_info->output_format; if (stream_info->state == ACTIVE) { stream_info->state = PAUSE_PENDING; <API key>( vfe_dev, stream_info); stream_info->state = PAUSING; atomic_set(&axi_data-> axi_cfg_update[SRC_TO_INTF( stream_info->stream_src)], UPDATE_REQUESTED); } else { for (j = 0; j < stream_info->num_planes; j++) vfe_dev->hw_info->vfe_ops.axi_ops. cfg_wm_reg(vfe_dev, stream_info, j); stream_info-><API key> = stream_info->output_format; } break; } case <API key>: { rc = <API key>(vfe_dev, stream_info, update_info->user_stream_id); if (rc) pr_err("%s failed to request frame!\n", __func__); break; } case <API key>: { rc = <API key>(vfe_dev, stream_info, update_info->user_stream_id); if (rc) pr_err("%s failed to add bufq!\n", __func__); break; } case <API key>: { <API key>(vfe_dev, stream_info, update_info->user_stream_id); if (stream_info->state == ACTIVE) { stream_info->state = UPDATING; rc = <API key>(vfe_dev, NO_UPDATE, (1 << SRC_TO_INTF( stream_info->stream_src))); if (rc < 0) pr_err("%s: wait for update failed\n", __func__); } break; } default: pr_err("%s: Invalid update type\n", __func__); return -EINVAL; } } return rc; } void <API key>(struct vfe_device *vfe_dev, uint32_t irq_status0, uint32_t irq_status1, struct msm_isp_timestamp *ts) { int i, rc = 0; struct msm_isp_buffer *done_buf = NULL; uint32_t comp_mask = 0, wm_mask = 0; uint32_t pingpong_status, stream_idx; struct msm_vfe_axi_stream *stream_info; struct <API key> *comp_info; struct <API key> *axi_data = &vfe_dev->axi_data; unsigned long flags; comp_mask = vfe_dev->hw_info->vfe_ops.axi_ops. get_comp_mask(irq_status0, irq_status1); wm_mask = vfe_dev->hw_info->vfe_ops.axi_ops. get_wm_mask(irq_status0, irq_status1); if (!(comp_mask || wm_mask)) return; ISP_DBG("%s: status: 0x%x\n", __func__, irq_status0); pingpong_status = vfe_dev->hw_info->vfe_ops.axi_ops.get_pingpong_status(vfe_dev); for (i = 0; i < axi_data->hw_info->num_comp_mask; i++) { rc = 0; comp_info = &axi_data->composite_info[i]; wm_mask &= ~(comp_info-><API key>); if (comp_mask & (1 << i)) { if (!comp_info->stream_handle) { pr_err("%s: Invalid handle for composite irq\n", __func__); continue; } stream_idx = HANDLE_TO_IDX(comp_info->stream_handle); stream_info = &axi_data->stream_info[stream_idx]; ISP_DBG("%s: stream id %x frame id: 0x%x\n", __func__, stream_info->stream_id, stream_info->frame_id); stream_info->frame_id++; if (stream_info->stream_type == BURST_STREAM) { ISP_DBG("%s: burst_frame_count: %d\n", __func__, stream_info-><API key>); stream_info-><API key> } spin_lock_irqsave(&stream_info->lock, flags); <API key>(vfe_dev, stream_info, pingpong_status, &done_buf); if (stream_info->stream_type == CONTINUOUS_STREAM || stream_info-><API key> > 1) { rc = <API key>(vfe_dev, stream_info, pingpong_status); } <API key>(&stream_info->lock, flags); if (done_buf && !rc) <API key>(vfe_dev, stream_info, done_buf, ts); } } for (i = 0; i < axi_data->hw_info->num_wm; i++) { if (wm_mask & (1 << i)) { if (!axi_data->free_wm[i]) { pr_err("%s: Invalid handle for wm irq\n", __func__); continue; } stream_idx = HANDLE_TO_IDX(axi_data->free_wm[i]); stream_info = &axi_data->stream_info[stream_idx]; ISP_DBG("%s: stream id %x frame id: 0x%x\n", __func__, stream_info->stream_id, stream_info->frame_id); stream_info->frame_id++; if (stream_info->stream_type == BURST_STREAM) { ISP_DBG("%s: burst_frame_count: %d\n", __func__, stream_info-><API key>); stream_info-><API key> } spin_lock_irqsave(&stream_info->lock, flags); <API key>(vfe_dev, stream_info, pingpong_status, &done_buf); if (stream_info->stream_type == CONTINUOUS_STREAM || stream_info-><API key> > 1) { rc = <API key>(vfe_dev, stream_info, pingpong_status); } <API key>(&stream_info->lock, flags); if (done_buf && !rc) <API key>(vfe_dev, stream_info, done_buf, ts); } } return; }
local iceFlower = Action() function iceFlower.onUse(player, item, fromPosition, target, toPosition, isHotkey) if math.random(5) == 1 then player:addItem(15271, 1) -- ice flower seeds player:<API key>("Ice Harvester", 10) end item:transform(15270) -- harvested ice flower item:decay() return true end iceFlower:id(15269) iceFlower:register()
#include <linux/init.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/spinlock.h> #include <linux/interrupt.h> #include <linux/dma-mapping.h> #include <linux/etherdevice.h> #include <linux/delay.h> #include <linux/platform_device.h> #include <linux/mdio-bitbang.h> #include <linux/netdevice.h> #include <linux/phy.h> #include <linux/cache.h> #include <linux/io.h> #include <linux/pm_runtime.h> #include <linux/slab.h> #include <linux/ethtool.h> #include <linux/if_vlan.h> #include <linux/clk.h> #include <linux/sh_eth.h> #include "sh_eth.h" #define <API key> \ (NETIF_MSG_LINK | \ NETIF_MSG_TIMER | \ NETIF_MSG_RX_ERR| \ NETIF_MSG_TX_ERR) /* There is CPU dependent code */ #if defined(<API key>) #define <API key> 1 static void sh_eth_set_duplex(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); if (mdp->duplex) /* Full */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) | ECMR_DM, ECMR); else /* Half */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) & ~ECMR_DM, ECMR); } static void sh_eth_set_rate(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); switch (mdp->speed) { case 10: /* 10BASE */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) & ~ECMR_RTM, ECMR); break; case 100:/* 100BASE */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) | ECMR_RTM, ECMR); break; default: break; } } /* SH7724 */ static struct sh_eth_cpu_data sh_eth_my_cpu_data = { .set_duplex = sh_eth_set_duplex, .set_rate = sh_eth_set_rate, .ecsr_value = ECSR_PSRTO | ECSR_LCHNG | ECSR_ICD, .ecsipr_value = ECSIPR_PSRTOIP | ECSIPR_LCHNGIP | ECSIPR_ICDIP, .eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x01ff009f, .tx_check = EESR_FTC | EESR_CND | EESR_DLC | EESR_CD | EESR_RTO, .eesr_err_check = EESR_TWB | EESR_TABT | EESR_RABT | EESR_RDE | EESR_RFRMER | EESR_TFE | EESR_TDE | EESR_ECI, .tx_error_check = EESR_TWB | EESR_TABT | EESR_TDE | EESR_TFE, .apr = 1, .mpr = 1, .tpauser = 1, .hw_swap = 1, .rpadir = 1, .rpadir_value = 0x00020000, /* NET_IP_ALIGN assumed to be 2 */ }; #elif defined(<API key>) #define <API key> 1 #define SH_ETH_HAS_TSU 1 static void sh_eth_set_duplex(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); if (mdp->duplex) /* Full */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) | ECMR_DM, ECMR); else /* Half */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) & ~ECMR_DM, ECMR); } static void sh_eth_set_rate(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); switch (mdp->speed) { case 10: /* 10BASE */ sh_eth_write(ndev, 0, RTRATE); break; case 100:/* 100BASE */ sh_eth_write(ndev, 1, RTRATE); break; default: break; } } /* SH7757 */ static struct sh_eth_cpu_data sh_eth_my_cpu_data = { .set_duplex = sh_eth_set_duplex, .set_rate = sh_eth_set_rate, .eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff, .rmcr_value = 0x00000001, .tx_check = EESR_FTC | EESR_CND | EESR_DLC | EESR_CD | EESR_RTO, .eesr_err_check = EESR_TWB | EESR_TABT | EESR_RABT | EESR_RDE | EESR_RFRMER | EESR_TFE | EESR_TDE | EESR_ECI, .tx_error_check = EESR_TWB | EESR_TABT | EESR_TDE | EESR_TFE, .apr = 1, .mpr = 1, .tpauser = 1, .hw_swap = 1, .no_ade = 1, .rpadir = 1, .rpadir_value = 2 << 16, }; #define SH_GIGA_ETH_BASE 0xfee00000 #define GIGA_MALR(port) (SH_GIGA_ETH_BASE + 0x800 * (port) + 0x05c8) #define GIGA_MAHR(port) (SH_GIGA_ETH_BASE + 0x800 * (port) + 0x05c0) static void <API key>(struct net_device *ndev) { int i; unsigned long mahr[2], malr[2]; /* save MAHR and MALR */ for (i = 0; i < 2; i++) { malr[i] = ioread32((void *)GIGA_MALR(i)); mahr[i] = ioread32((void *)GIGA_MAHR(i)); } /* reset device */ iowrite32(ARSTR_ARSTR, (void *)(SH_GIGA_ETH_BASE + 0x1800)); mdelay(1); /* restore MAHR and MALR */ for (i = 0; i < 2; i++) { iowrite32(malr[i], (void *)GIGA_MALR(i)); iowrite32(mahr[i], (void *)GIGA_MAHR(i)); } } static int sh_eth_is_gether(struct sh_eth_private *mdp); static void sh_eth_reset(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); int cnt = 100; if (sh_eth_is_gether(mdp)) { sh_eth_write(ndev, 0x03, EDSR); sh_eth_write(ndev, sh_eth_read(ndev, EDMR) | EDMR_SRST_GETHER, EDMR); while (cnt > 0) { if (!(sh_eth_read(ndev, EDMR) & 0x3)) break; mdelay(1); cnt } if (cnt < 0) printk(KERN_ERR "Device reset fail\n"); /* Table Init */ sh_eth_write(ndev, 0x0, TDLAR); sh_eth_write(ndev, 0x0, TDFAR); sh_eth_write(ndev, 0x0, TDFXR); sh_eth_write(ndev, 0x0, TDFFR); sh_eth_write(ndev, 0x0, RDLAR); sh_eth_write(ndev, 0x0, RDFAR); sh_eth_write(ndev, 0x0, RDFXR); sh_eth_write(ndev, 0x0, RDFFR); } else { sh_eth_write(ndev, sh_eth_read(ndev, EDMR) | EDMR_SRST_ETHER, EDMR); mdelay(3); sh_eth_write(ndev, sh_eth_read(ndev, EDMR) & ~EDMR_SRST_ETHER, EDMR); } } static void <API key>(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); if (mdp->duplex) /* Full */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) | ECMR_DM, ECMR); else /* Half */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) & ~ECMR_DM, ECMR); } static void <API key>(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); switch (mdp->speed) { case 10: /* 10BASE */ sh_eth_write(ndev, 0x00000000, GECMR); break; case 100:/* 100BASE */ sh_eth_write(ndev, 0x00000010, GECMR); break; case 1000: /* 1000BASE */ sh_eth_write(ndev, 0x00000020, GECMR); break; default: break; } } /* SH7757(GETHERC) */ static struct sh_eth_cpu_data <API key> = { .chip_reset = <API key>, .set_duplex = <API key>, .set_rate = <API key>, .ecsr_value = ECSR_ICD | ECSR_MPD, .ecsipr_value = ECSIPR_LCHNGIP | ECSIPR_ICDIP | ECSIPR_MPDIP, .eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff, .tx_check = EESR_TC1 | EESR_FTC, .eesr_err_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_RABT | \ EESR_RDE | EESR_RFRMER | EESR_TFE | EESR_TDE | \ EESR_ECI, .tx_error_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_TDE | \ EESR_TFE, .fdr_value = 0x0000072f, .rmcr_value = 0x00000001, .apr = 1, .mpr = 1, .tpauser = 1, .bculr = 1, .hw_swap = 1, .rpadir = 1, .rpadir_value = 2 << 16, .no_trimd = 1, .no_ade = 1, .tsu = 1, }; static struct sh_eth_cpu_data *sh_eth_get_cpu_data(struct sh_eth_private *mdp) { if (sh_eth_is_gether(mdp)) return &<API key>; else return &sh_eth_my_cpu_data; } #elif defined(<API key>) || defined(<API key>) #define SH_ETH_HAS_TSU 1 static void sh_eth_reset_hw_crc(struct net_device *ndev); static void sh_eth_chip_reset(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); /* reset device */ sh_eth_tsu_write(mdp, ARSTR_ARSTR, ARSTR); mdelay(1); } static void sh_eth_reset(struct net_device *ndev) { int cnt = 100; sh_eth_write(ndev, EDSR_ENALL, EDSR); sh_eth_write(ndev, sh_eth_read(ndev, EDMR) | EDMR_SRST_GETHER, EDMR); while (cnt > 0) { if (!(sh_eth_read(ndev, EDMR) & 0x3)) break; mdelay(1); cnt } if (cnt == 0) printk(KERN_ERR "Device reset fail\n"); /* Table Init */ sh_eth_write(ndev, 0x0, TDLAR); sh_eth_write(ndev, 0x0, TDFAR); sh_eth_write(ndev, 0x0, TDFXR); sh_eth_write(ndev, 0x0, TDFFR); sh_eth_write(ndev, 0x0, RDLAR); sh_eth_write(ndev, 0x0, RDFAR); sh_eth_write(ndev, 0x0, RDFXR); sh_eth_write(ndev, 0x0, RDFFR); /* Reset HW CRC register */ sh_eth_reset_hw_crc(ndev); } static void sh_eth_set_duplex(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); if (mdp->duplex) /* Full */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) | ECMR_DM, ECMR); else /* Half */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) & ~ECMR_DM, ECMR); } static void sh_eth_set_rate(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); switch (mdp->speed) { case 10: /* 10BASE */ sh_eth_write(ndev, GECMR_10, GECMR); break; case 100:/* 100BASE */ sh_eth_write(ndev, GECMR_100, GECMR); break; case 1000: /* 1000BASE */ sh_eth_write(ndev, GECMR_1000, GECMR); break; default: break; } } /* sh7763 */ static struct sh_eth_cpu_data sh_eth_my_cpu_data = { .chip_reset = sh_eth_chip_reset, .set_duplex = sh_eth_set_duplex, .set_rate = sh_eth_set_rate, .ecsr_value = ECSR_ICD | ECSR_MPD, .ecsipr_value = ECSIPR_LCHNGIP | ECSIPR_ICDIP | ECSIPR_MPDIP, .eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff, .tx_check = EESR_TC1 | EESR_FTC, .eesr_err_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_RABT | \ EESR_RDE | EESR_RFRMER | EESR_TFE | EESR_TDE | \ EESR_ECI, .tx_error_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_TDE | \ EESR_TFE, .apr = 1, .mpr = 1, .tpauser = 1, .bculr = 1, .hw_swap = 1, .no_trimd = 1, .no_ade = 1, .tsu = 1, #if defined(<API key>) .hw_crc = 1, #endif }; static void sh_eth_reset_hw_crc(struct net_device *ndev) { if (sh_eth_my_cpu_data.hw_crc) sh_eth_write(ndev, 0x0, CSMR); } #elif defined(CONFIG_ARCH_R8A7740) #define SH_ETH_HAS_TSU 1 static void sh_eth_chip_reset(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); unsigned long mii; /* reset device */ sh_eth_tsu_write(mdp, ARSTR_ARSTR, ARSTR); mdelay(1); switch (mdp->phy_interface) { case <API key>: mii = 2; break; case <API key>: mii = 1; break; case <API key>: default: mii = 0; break; } sh_eth_write(ndev, mii, RMII_MII); } static void sh_eth_reset(struct net_device *ndev) { int cnt = 100; sh_eth_write(ndev, EDSR_ENALL, EDSR); sh_eth_write(ndev, sh_eth_read(ndev, EDMR) | EDMR_SRST_GETHER, EDMR); while (cnt > 0) { if (!(sh_eth_read(ndev, EDMR) & 0x3)) break; mdelay(1); cnt } if (cnt == 0) printk(KERN_ERR "Device reset fail\n"); /* Table Init */ sh_eth_write(ndev, 0x0, TDLAR); sh_eth_write(ndev, 0x0, TDFAR); sh_eth_write(ndev, 0x0, TDFXR); sh_eth_write(ndev, 0x0, TDFFR); sh_eth_write(ndev, 0x0, RDLAR); sh_eth_write(ndev, 0x0, RDFAR); sh_eth_write(ndev, 0x0, RDFXR); sh_eth_write(ndev, 0x0, RDFFR); } static void sh_eth_set_duplex(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); if (mdp->duplex) /* Full */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) | ECMR_DM, ECMR); else /* Half */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) & ~ECMR_DM, ECMR); } static void sh_eth_set_rate(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); switch (mdp->speed) { case 10: /* 10BASE */ sh_eth_write(ndev, GECMR_10, GECMR); break; case 100:/* 100BASE */ sh_eth_write(ndev, GECMR_100, GECMR); break; case 1000: /* 1000BASE */ sh_eth_write(ndev, GECMR_1000, GECMR); break; default: break; } } /* R8A7740 */ static struct sh_eth_cpu_data sh_eth_my_cpu_data = { .chip_reset = sh_eth_chip_reset, .set_duplex = sh_eth_set_duplex, .set_rate = sh_eth_set_rate, .ecsr_value = ECSR_ICD | ECSR_MPD, .ecsipr_value = ECSIPR_LCHNGIP | ECSIPR_ICDIP | ECSIPR_MPDIP, .eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff, .tx_check = EESR_TC1 | EESR_FTC, .eesr_err_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_RABT | \ EESR_RDE | EESR_RFRMER | EESR_TFE | EESR_TDE | \ EESR_ECI, .tx_error_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_TDE | \ EESR_TFE, .apr = 1, .mpr = 1, .tpauser = 1, .bculr = 1, .hw_swap = 1, .no_trimd = 1, .no_ade = 1, .tsu = 1, }; #elif defined(<API key>) #define <API key> 1 static struct sh_eth_cpu_data sh_eth_my_cpu_data = { .eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff, .apr = 1, .mpr = 1, .tpauser = 1, .hw_swap = 1, }; #elif defined(<API key>) || defined(<API key>) #define <API key> 1 #define SH_ETH_HAS_TSU 1 static struct sh_eth_cpu_data sh_eth_my_cpu_data = { .eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff, .tsu = 1, }; #endif static void <API key>(struct sh_eth_cpu_data *cd) { if (!cd->ecsr_value) cd->ecsr_value = DEFAULT_ECSR_INIT; if (!cd->ecsipr_value) cd->ecsipr_value = DEFAULT_ECSIPR_INIT; if (!cd->fcftr_value) cd->fcftr_value = <API key> | \ <API key>; if (!cd->fdr_value) cd->fdr_value = DEFAULT_FDR_INIT; if (!cd->rmcr_value) cd->rmcr_value = DEFAULT_RMCR_VALUE; if (!cd->tx_check) cd->tx_check = DEFAULT_TX_CHECK; if (!cd->eesr_err_check) cd->eesr_err_check = <API key>; if (!cd->tx_error_check) cd->tx_error_check = <API key>; } #if defined(<API key>) /* Chip Reset */ static void sh_eth_reset(struct net_device *ndev) { sh_eth_write(ndev, sh_eth_read(ndev, EDMR) | EDMR_SRST_ETHER, EDMR); mdelay(3); sh_eth_write(ndev, sh_eth_read(ndev, EDMR) & ~EDMR_SRST_ETHER, EDMR); } #endif #if defined(CONFIG_CPU_SH4) || defined(<API key>) static void <API key>(struct sk_buff *skb) { int reserve; reserve = SH4_SKB_RX_ALIGN - ((u32)skb->data & (SH4_SKB_RX_ALIGN - 1)); if (reserve) skb_reserve(skb, reserve); } #else static void <API key>(struct sk_buff *skb) { skb_reserve(skb, <API key>); } #endif /* CPU <-> EDMAC endian convert */ static inline __u32 cpu_to_edmac(struct sh_eth_private *mdp, u32 x) { switch (mdp->edmac_endian) { case EDMAC_LITTLE_ENDIAN: return cpu_to_le32(x); case EDMAC_BIG_ENDIAN: return cpu_to_be32(x); } return x; } static inline __u32 edmac_to_cpu(struct sh_eth_private *mdp, u32 x) { switch (mdp->edmac_endian) { case EDMAC_LITTLE_ENDIAN: return le32_to_cpu(x); case EDMAC_BIG_ENDIAN: return be32_to_cpu(x); } return x; } /* * Program the hardware MAC address from dev->dev_addr. */ static void update_mac_address(struct net_device *ndev) { sh_eth_write(ndev, (ndev->dev_addr[0] << 24) | (ndev->dev_addr[1] << 16) | (ndev->dev_addr[2] << 8) | (ndev->dev_addr[3]), MAHR); sh_eth_write(ndev, (ndev->dev_addr[4] << 8) | (ndev->dev_addr[5]), MALR); } /* * Get MAC address from SuperH MAC address register * * SuperH's Ethernet device doesn't have 'ROM' to MAC address. * This driver get MAC address that use by bootloader(U-boot or sh-ipl+g). * When you want use this device, you must set MAC address in bootloader. * */ static void read_mac_address(struct net_device *ndev, unsigned char *mac) { if (mac[0] || mac[1] || mac[2] || mac[3] || mac[4] || mac[5]) { memcpy(ndev->dev_addr, mac, 6); } else { ndev->dev_addr[0] = (sh_eth_read(ndev, MAHR) >> 24); ndev->dev_addr[1] = (sh_eth_read(ndev, MAHR) >> 16) & 0xFF; ndev->dev_addr[2] = (sh_eth_read(ndev, MAHR) >> 8) & 0xFF; ndev->dev_addr[3] = (sh_eth_read(ndev, MAHR) & 0xFF); ndev->dev_addr[4] = (sh_eth_read(ndev, MALR) >> 8) & 0xFF; ndev->dev_addr[5] = (sh_eth_read(ndev, MALR) & 0xFF); } } static int sh_eth_is_gether(struct sh_eth_private *mdp) { if (mdp->reg_offset == <API key>) return 1; else return 0; } static unsigned long <API key>(struct sh_eth_private *mdp) { if (sh_eth_is_gether(mdp)) return EDTRR_TRNS_GETHER; else return EDTRR_TRNS_ETHER; } struct bb_info { void (*set_gate)(void *addr); struct mdiobb_ctrl ctrl; void *addr; u32 mmd_msk;/* MMD */ u32 mdo_msk; u32 mdi_msk; u32 mdc_msk; }; /* PHY bit set */ static void bb_set(void *addr, u32 msk) { iowrite32(ioread32(addr) | msk, addr); } /* PHY bit clear */ static void bb_clr(void *addr, u32 msk) { iowrite32((ioread32(addr) & ~msk), addr); } /* PHY bit read */ static int bb_read(void *addr, u32 msk) { return (ioread32(addr) & msk) != 0; } /* Data I/O pin control */ static void sh_mmd_ctrl(struct mdiobb_ctrl *ctrl, int bit) { struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl); if (bitbang->set_gate) bitbang->set_gate(bitbang->addr); if (bit) bb_set(bitbang->addr, bitbang->mmd_msk); else bb_clr(bitbang->addr, bitbang->mmd_msk); } /* Set bit data*/ static void sh_set_mdio(struct mdiobb_ctrl *ctrl, int bit) { struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl); if (bitbang->set_gate) bitbang->set_gate(bitbang->addr); if (bit) bb_set(bitbang->addr, bitbang->mdo_msk); else bb_clr(bitbang->addr, bitbang->mdo_msk); } /* Get bit data*/ static int sh_get_mdio(struct mdiobb_ctrl *ctrl) { struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl); if (bitbang->set_gate) bitbang->set_gate(bitbang->addr); return bb_read(bitbang->addr, bitbang->mdi_msk); } /* MDC pin control */ static void sh_mdc_ctrl(struct mdiobb_ctrl *ctrl, int bit) { struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl); if (bitbang->set_gate) bitbang->set_gate(bitbang->addr); if (bit) bb_set(bitbang->addr, bitbang->mdc_msk); else bb_clr(bitbang->addr, bitbang->mdc_msk); } /* mdio bus control struct */ static struct mdiobb_ops bb_ops = { .owner = THIS_MODULE, .set_mdc = sh_mdc_ctrl, .set_mdio_dir = sh_mmd_ctrl, .set_mdio_data = sh_set_mdio, .get_mdio_data = sh_get_mdio, }; /* free skb and descriptor buffer */ static void sh_eth_ring_free(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); int i; /* Free Rx skb ringbuffer */ if (mdp->rx_skbuff) { for (i = 0; i < RX_RING_SIZE; i++) { if (mdp->rx_skbuff[i]) dev_kfree_skb(mdp->rx_skbuff[i]); } } kfree(mdp->rx_skbuff); /* Free Tx skb ringbuffer */ if (mdp->tx_skbuff) { for (i = 0; i < TX_RING_SIZE; i++) { if (mdp->tx_skbuff[i]) dev_kfree_skb(mdp->tx_skbuff[i]); } } kfree(mdp->tx_skbuff); } /* format skb and descriptor buffer */ static void sh_eth_ring_format(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); int i; struct sk_buff *skb; struct sh_eth_rxdesc *rxdesc = NULL; struct sh_eth_txdesc *txdesc = NULL; int rx_ringsize = sizeof(*rxdesc) * RX_RING_SIZE; int tx_ringsize = sizeof(*txdesc) * TX_RING_SIZE; mdp->cur_rx = mdp->cur_tx = 0; mdp->dirty_rx = mdp->dirty_tx = 0; memset(mdp->rx_ring, 0, rx_ringsize); /* build Rx ring buffer */ for (i = 0; i < RX_RING_SIZE; i++) { /* skb */ mdp->rx_skbuff[i] = NULL; skb = netdev_alloc_skb(ndev, mdp->rx_buf_sz); mdp->rx_skbuff[i] = skb; if (skb == NULL) break; dma_map_single(&ndev->dev, skb->data, mdp->rx_buf_sz, DMA_FROM_DEVICE); <API key>(skb); /* RX descriptor */ rxdesc = &mdp->rx_ring[i]; rxdesc->addr = virt_to_phys(PTR_ALIGN(skb->data, 4)); rxdesc->status = cpu_to_edmac(mdp, RD_RACT | RD_RFP); /* The size of the buffer is 16 byte boundary. */ rxdesc->buffer_length = ALIGN(mdp->rx_buf_sz, 16); /* Rx descriptor address set */ if (i == 0) { sh_eth_write(ndev, mdp->rx_desc_dma, RDLAR); if (sh_eth_is_gether(mdp)) sh_eth_write(ndev, mdp->rx_desc_dma, RDFAR); } } mdp->dirty_rx = (u32) (i - RX_RING_SIZE); /* Mark the last entry as wrapping the ring. */ rxdesc->status |= cpu_to_edmac(mdp, RD_RDEL); memset(mdp->tx_ring, 0, tx_ringsize); /* build Tx ring buffer */ for (i = 0; i < TX_RING_SIZE; i++) { mdp->tx_skbuff[i] = NULL; txdesc = &mdp->tx_ring[i]; txdesc->status = cpu_to_edmac(mdp, TD_TFP); txdesc->buffer_length = 0; if (i == 0) { /* Tx descriptor address set */ sh_eth_write(ndev, mdp->tx_desc_dma, TDLAR); if (sh_eth_is_gether(mdp)) sh_eth_write(ndev, mdp->tx_desc_dma, TDFAR); } } txdesc->status |= cpu_to_edmac(mdp, TD_TDLE); } /* Get skb and descriptor buffer */ static int sh_eth_ring_init(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); int rx_ringsize, tx_ringsize, ret = 0; /* * +26 gets the maximum ethernet encapsulation, +7 & ~7 because the * card needs room to do 8 byte alignment, +2 so we can reserve * the first 2 bytes, and +16 gets room for the status word from the * card. */ mdp->rx_buf_sz = (ndev->mtu <= 1492 ? PKT_BUF_SZ : (((ndev->mtu + 26 + 7) & ~7) + 2 + 16)); if (mdp->cd->rpadir) mdp->rx_buf_sz += NET_IP_ALIGN; /* Allocate RX and TX skb rings */ mdp->rx_skbuff = kmalloc(sizeof(*mdp->rx_skbuff) * RX_RING_SIZE, GFP_KERNEL); if (!mdp->rx_skbuff) { dev_err(&ndev->dev, "Cannot allocate Rx skb\n"); ret = -ENOMEM; return ret; } mdp->tx_skbuff = kmalloc(sizeof(*mdp->tx_skbuff) * TX_RING_SIZE, GFP_KERNEL); if (!mdp->tx_skbuff) { dev_err(&ndev->dev, "Cannot allocate Tx skb\n"); ret = -ENOMEM; goto skb_ring_free; } /* Allocate all Rx descriptors. */ rx_ringsize = sizeof(struct sh_eth_rxdesc) * RX_RING_SIZE; mdp->rx_ring = dma_alloc_coherent(NULL, rx_ringsize, &mdp->rx_desc_dma, GFP_KERNEL); if (!mdp->rx_ring) { dev_err(&ndev->dev, "Cannot allocate Rx Ring (size %d bytes)\n", rx_ringsize); ret = -ENOMEM; goto desc_ring_free; } mdp->dirty_rx = 0; /* Allocate all Tx descriptors. */ tx_ringsize = sizeof(struct sh_eth_txdesc) * TX_RING_SIZE; mdp->tx_ring = dma_alloc_coherent(NULL, tx_ringsize, &mdp->tx_desc_dma, GFP_KERNEL); if (!mdp->tx_ring) { dev_err(&ndev->dev, "Cannot allocate Tx Ring (size %d bytes)\n", tx_ringsize); ret = -ENOMEM; goto desc_ring_free; } return ret; desc_ring_free: /* free DMA buffer */ dma_free_coherent(NULL, rx_ringsize, mdp->rx_ring, mdp->rx_desc_dma); skb_ring_free: /* Free Rx and Tx skb ring buffer */ sh_eth_ring_free(ndev); return ret; } static int sh_eth_dev_init(struct net_device *ndev) { int ret = 0; struct sh_eth_private *mdp = netdev_priv(ndev); u_int32_t rx_int_var, tx_int_var; u32 val; /* Soft Reset */ sh_eth_reset(ndev); /* Descriptor format */ sh_eth_ring_format(ndev); if (mdp->cd->rpadir) sh_eth_write(ndev, mdp->cd->rpadir_value, RPADIR); /* all sh_eth int mask */ sh_eth_write(ndev, 0, EESIPR); #if defined(__LITTLE_ENDIAN) if (mdp->cd->hw_swap) sh_eth_write(ndev, EDMR_EL, EDMR); else #endif sh_eth_write(ndev, 0, EDMR); /* FIFO size set */ sh_eth_write(ndev, mdp->cd->fdr_value, FDR); sh_eth_write(ndev, 0, TFTR); /* Frame recv control */ sh_eth_write(ndev, mdp->cd->rmcr_value, RMCR); rx_int_var = mdp->rx_int_var = DESC_I_RINT8 | DESC_I_RINT5; tx_int_var = mdp->tx_int_var = DESC_I_TINT2; sh_eth_write(ndev, rx_int_var | tx_int_var, TRSCER); if (mdp->cd->bculr) sh_eth_write(ndev, 0x800, BCULR); /* Burst sycle set */ sh_eth_write(ndev, mdp->cd->fcftr_value, FCFTR); if (!mdp->cd->no_trimd) sh_eth_write(ndev, 0, TRIMD); /* Recv frame limit set register */ sh_eth_write(ndev, ndev->mtu + ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN, RFLR); sh_eth_write(ndev, sh_eth_read(ndev, EESR), EESR); sh_eth_write(ndev, mdp->cd->eesipr_value, EESIPR); /* PAUSE Prohibition */ val = (sh_eth_read(ndev, ECMR) & ECMR_DM) | ECMR_ZPF | (mdp->duplex ? ECMR_DM : 0) | ECMR_TE | ECMR_RE; sh_eth_write(ndev, val, ECMR); if (mdp->cd->set_rate) mdp->cd->set_rate(ndev); /* E-MAC Status Register clear */ sh_eth_write(ndev, mdp->cd->ecsr_value, ECSR); /* E-MAC Interrupt Enable register */ sh_eth_write(ndev, mdp->cd->ecsipr_value, ECSIPR); /* Set MAC address */ update_mac_address(ndev); /* mask reset */ if (mdp->cd->apr) sh_eth_write(ndev, APR_AP, APR); if (mdp->cd->mpr) sh_eth_write(ndev, MPR_MP, MPR); if (mdp->cd->tpauser) sh_eth_write(ndev, TPAUSER_UNLIMITED, TPAUSER); /* Setting the Rx mode will start the Rx process. */ sh_eth_write(ndev, EDRRR_R, EDRRR); netif_start_queue(ndev); return ret; } /* free Tx skb function */ static int sh_eth_txfree(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); struct sh_eth_txdesc *txdesc; int freeNum = 0; int entry = 0; for (; mdp->cur_tx - mdp->dirty_tx > 0; mdp->dirty_tx++) { entry = mdp->dirty_tx % TX_RING_SIZE; txdesc = &mdp->tx_ring[entry]; if (txdesc->status & cpu_to_edmac(mdp, TD_TACT)) break; /* Free the original skb. */ if (mdp->tx_skbuff[entry]) { dma_unmap_single(&ndev->dev, txdesc->addr, txdesc->buffer_length, DMA_TO_DEVICE); dev_kfree_skb_irq(mdp->tx_skbuff[entry]); mdp->tx_skbuff[entry] = NULL; freeNum++; } txdesc->status = cpu_to_edmac(mdp, TD_TFP); if (entry >= TX_RING_SIZE - 1) txdesc->status |= cpu_to_edmac(mdp, TD_TDLE); ndev->stats.tx_packets++; ndev->stats.tx_bytes += txdesc->buffer_length; } return freeNum; } /* Packet receive function */ static int sh_eth_rx(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); struct sh_eth_rxdesc *rxdesc; int entry = mdp->cur_rx % RX_RING_SIZE; int boguscnt = (mdp->dirty_rx + RX_RING_SIZE) - mdp->cur_rx; struct sk_buff *skb; u16 pkt_len = 0; u32 desc_status; rxdesc = &mdp->rx_ring[entry]; while (!(rxdesc->status & cpu_to_edmac(mdp, RD_RACT))) { desc_status = edmac_to_cpu(mdp, rxdesc->status); pkt_len = rxdesc->frame_length; #if defined(CONFIG_ARCH_R8A7740) desc_status >>= 16; #endif if (--boguscnt < 0) break; if (!(desc_status & RDFEND)) ndev->stats.rx_length_errors++; if (desc_status & (RD_RFS1 | RD_RFS2 | RD_RFS3 | RD_RFS4 | RD_RFS5 | RD_RFS6 | RD_RFS10)) { ndev->stats.rx_errors++; if (desc_status & RD_RFS1) ndev->stats.rx_crc_errors++; if (desc_status & RD_RFS2) ndev->stats.rx_frame_errors++; if (desc_status & RD_RFS3) ndev->stats.rx_length_errors++; if (desc_status & RD_RFS4) ndev->stats.rx_length_errors++; if (desc_status & RD_RFS6) ndev->stats.rx_missed_errors++; if (desc_status & RD_RFS10) ndev->stats.rx_over_errors++; } else { if (!mdp->cd->hw_swap) sh_eth_soft_swap( phys_to_virt(ALIGN(rxdesc->addr, 4)), pkt_len + 2); skb = mdp->rx_skbuff[entry]; mdp->rx_skbuff[entry] = NULL; if (mdp->cd->rpadir) skb_reserve(skb, NET_IP_ALIGN); skb_put(skb, pkt_len); skb->protocol = eth_type_trans(skb, ndev); netif_rx(skb); ndev->stats.rx_packets++; ndev->stats.rx_bytes += pkt_len; } rxdesc->status |= cpu_to_edmac(mdp, RD_RACT); entry = (++mdp->cur_rx) % RX_RING_SIZE; rxdesc = &mdp->rx_ring[entry]; } /* Refill the Rx ring buffers. */ for (; mdp->cur_rx - mdp->dirty_rx > 0; mdp->dirty_rx++) { entry = mdp->dirty_rx % RX_RING_SIZE; rxdesc = &mdp->rx_ring[entry]; /* The size of the buffer is 16 byte boundary. */ rxdesc->buffer_length = ALIGN(mdp->rx_buf_sz, 16); if (mdp->rx_skbuff[entry] == NULL) { skb = netdev_alloc_skb(ndev, mdp->rx_buf_sz); mdp->rx_skbuff[entry] = skb; if (skb == NULL) break; /* Better luck next round. */ dma_map_single(&ndev->dev, skb->data, mdp->rx_buf_sz, DMA_FROM_DEVICE); <API key>(skb); <API key>(skb); rxdesc->addr = virt_to_phys(PTR_ALIGN(skb->data, 4)); } if (entry >= RX_RING_SIZE - 1) rxdesc->status |= cpu_to_edmac(mdp, RD_RACT | RD_RFP | RD_RDEL); else rxdesc->status |= cpu_to_edmac(mdp, RD_RACT | RD_RFP); } /* Restart Rx engine if stopped. */ /* If we don't need to check status, don't. -KDU */ if (!(sh_eth_read(ndev, EDRRR) & EDRRR_R)) { /* fix the values for the next receiving */ mdp->cur_rx = mdp->dirty_rx = (sh_eth_read(ndev, RDFAR) - sh_eth_read(ndev, RDLAR)) >> 4; sh_eth_write(ndev, EDRRR_R, EDRRR); } return 0; } static void <API key>(struct net_device *ndev) { /* disable tx and rx */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) & ~(ECMR_RE | ECMR_TE), ECMR); } static void <API key>(struct net_device *ndev) { /* enable tx and rx */ sh_eth_write(ndev, sh_eth_read(ndev, ECMR) | (ECMR_RE | ECMR_TE), ECMR); } /* error control function */ static void sh_eth_error(struct net_device *ndev, int intr_status) { struct sh_eth_private *mdp = netdev_priv(ndev); u32 felic_stat; u32 link_stat; u32 mask; if (intr_status & EESR_ECI) { felic_stat = sh_eth_read(ndev, ECSR); sh_eth_write(ndev, felic_stat, ECSR); /* clear int */ if (felic_stat & ECSR_ICD) ndev->stats.tx_carrier_errors++; if (felic_stat & ECSR_LCHNG) { /* Link Changed */ if (mdp->cd->no_psr || mdp->no_ether_link) { if (mdp->link == PHY_DOWN) link_stat = 0; else link_stat = PHY_ST_LINK; } else { link_stat = (sh_eth_read(ndev, PSR)); if (mdp-><API key>) link_stat = ~link_stat; } if (!(link_stat & PHY_ST_LINK)) <API key>(ndev); else { /* Link Up */ sh_eth_write(ndev, sh_eth_read(ndev, EESIPR) & ~DMAC_M_ECI, EESIPR); /*clear int */ sh_eth_write(ndev, sh_eth_read(ndev, ECSR), ECSR); sh_eth_write(ndev, sh_eth_read(ndev, EESIPR) | DMAC_M_ECI, EESIPR); /* enable tx and rx */ <API key>(ndev); } } } if (intr_status & EESR_TWB) { /* Write buck end. unused write back interrupt */ if (intr_status & EESR_TABT) /* Transmit Abort int */ ndev->stats.tx_aborted_errors++; if (netif_msg_tx_err(mdp)) dev_err(&ndev->dev, "Transmit Abort\n"); } if (intr_status & EESR_RABT) { /* Receive Abort int */ if (intr_status & EESR_RFRMER) { /* Receive Frame Overflow int */ ndev->stats.rx_frame_errors++; if (netif_msg_rx_err(mdp)) dev_err(&ndev->dev, "Receive Abort\n"); } } if (intr_status & EESR_TDE) { /* Transmit Descriptor Empty int */ ndev->stats.tx_fifo_errors++; if (netif_msg_tx_err(mdp)) dev_err(&ndev->dev, "Transmit Descriptor Empty\n"); } if (intr_status & EESR_TFE) { /* FIFO under flow */ ndev->stats.tx_fifo_errors++; if (netif_msg_tx_err(mdp)) dev_err(&ndev->dev, "Transmit FIFO Under flow\n"); } if (intr_status & EESR_RDE) { /* Receive Descriptor Empty int */ ndev->stats.rx_over_errors++; if (netif_msg_rx_err(mdp)) dev_err(&ndev->dev, "Receive Descriptor Empty\n"); } if (intr_status & EESR_RFE) { /* Receive FIFO Overflow int */ ndev->stats.rx_fifo_errors++; if (netif_msg_rx_err(mdp)) dev_err(&ndev->dev, "Receive FIFO Overflow\n"); } if (!mdp->cd->no_ade && (intr_status & EESR_ADE)) { /* Address Error */ ndev->stats.tx_fifo_errors++; if (netif_msg_tx_err(mdp)) dev_err(&ndev->dev, "Address Error\n"); } mask = EESR_TWB | EESR_TABT | EESR_ADE | EESR_TDE | EESR_TFE; if (mdp->cd->no_ade) mask &= ~EESR_ADE; if (intr_status & mask) { /* Tx error */ u32 edtrr = sh_eth_read(ndev, EDTRR); /* dmesg */ dev_err(&ndev->dev, "TX error. status=%8.8x cur_tx=%8.8x ", intr_status, mdp->cur_tx); dev_err(&ndev->dev, "dirty_tx=%8.8x state=%8.8x EDTRR=%8.8x.\n", mdp->dirty_tx, (u32) ndev->state, edtrr); /* dirty buffer free */ sh_eth_txfree(ndev); /* SH7712 BUG */ if (edtrr ^ <API key>(mdp)) { /* tx dma start */ sh_eth_write(ndev, <API key>(mdp), EDTRR); } /* wakeup */ netif_wake_queue(ndev); } } static irqreturn_t sh_eth_interrupt(int irq, void *netdev) { struct net_device *ndev = netdev; struct sh_eth_private *mdp = netdev_priv(ndev); struct sh_eth_cpu_data *cd = mdp->cd; irqreturn_t ret = IRQ_NONE; u32 intr_status = 0; spin_lock(&mdp->lock); /* Get interrpt stat */ intr_status = sh_eth_read(ndev, EESR); /* Clear interrupt */ if (intr_status & (EESR_FRC | EESR_RMAF | EESR_RRF | EESR_RTLF | EESR_RTSF | EESR_PRE | EESR_CERF | cd->tx_check | cd->eesr_err_check)) { sh_eth_write(ndev, intr_status, EESR); ret = IRQ_HANDLED; } else goto other_irq; if (intr_status & (EESR_FRC | /* Frame recv*/ EESR_RMAF | /* Multi cast address recv*/ EESR_RRF | /* Bit frame recv */ EESR_RTLF | /* Long frame recv*/ EESR_RTSF | /* short frame recv */ EESR_PRE | /* PHY-LSI recv error */ EESR_CERF)){ /* recv frame CRC error */ sh_eth_rx(ndev); } /* Tx Check */ if (intr_status & cd->tx_check) { sh_eth_txfree(ndev); netif_wake_queue(ndev); } if (intr_status & cd->eesr_err_check) sh_eth_error(ndev, intr_status); other_irq: spin_unlock(&mdp->lock); return ret; } static void sh_eth_timer(unsigned long data) { struct net_device *ndev = (struct net_device *)data; struct sh_eth_private *mdp = netdev_priv(ndev); mod_timer(&mdp->timer, jiffies + (10 * HZ)); } /* PHY state control function */ static void sh_eth_adjust_link(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); struct phy_device *phydev = mdp->phydev; int new_state = 0; if (phydev->link != PHY_DOWN) { if (phydev->duplex != mdp->duplex) { new_state = 1; mdp->duplex = phydev->duplex; if (mdp->cd->set_duplex) mdp->cd->set_duplex(ndev); } if (phydev->speed != mdp->speed) { new_state = 1; mdp->speed = phydev->speed; if (mdp->cd->set_rate) mdp->cd->set_rate(ndev); } if (mdp->link == PHY_DOWN) { sh_eth_write(ndev, (sh_eth_read(ndev, ECMR) & ~ECMR_TXF), ECMR); new_state = 1; mdp->link = phydev->link; } } else if (mdp->link) { new_state = 1; mdp->link = PHY_DOWN; mdp->speed = 0; mdp->duplex = -1; } if (new_state && netif_msg_link(mdp)) phy_print_status(phydev); } /* PHY init function */ static int sh_eth_phy_init(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); char phy_id[MII_BUS_ID_SIZE + 3]; struct phy_device *phydev = NULL; snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT, mdp->mii_bus->id , mdp->phy_id); mdp->link = PHY_DOWN; mdp->speed = 0; mdp->duplex = -1; /* Try connect to PHY */ phydev = phy_connect(ndev, phy_id, sh_eth_adjust_link, 0, mdp->phy_interface); if (IS_ERR(phydev)) { dev_err(&ndev->dev, "phy_connect failed\n"); return PTR_ERR(phydev); } dev_info(&ndev->dev, "attached phy %i to driver %s\n", phydev->addr, phydev->drv->name); mdp->phydev = phydev; return 0; } /* PHY control start function */ static int sh_eth_phy_start(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); int ret; ret = sh_eth_phy_init(ndev); if (ret) return ret; /* reset phy - this also wakes it from PDOWN */ phy_write(mdp->phydev, MII_BMCR, BMCR_RESET); phy_start(mdp->phydev); return 0; } static int sh_eth_get_settings(struct net_device *ndev, struct ethtool_cmd *ecmd) { struct sh_eth_private *mdp = netdev_priv(ndev); unsigned long flags; int ret; spin_lock_irqsave(&mdp->lock, flags); ret = phy_ethtool_gset(mdp->phydev, ecmd); <API key>(&mdp->lock, flags); return ret; } static int sh_eth_set_settings(struct net_device *ndev, struct ethtool_cmd *ecmd) { struct sh_eth_private *mdp = netdev_priv(ndev); unsigned long flags; int ret; spin_lock_irqsave(&mdp->lock, flags); /* disable tx and rx */ <API key>(ndev); ret = phy_ethtool_sset(mdp->phydev, ecmd); if (ret) goto error_exit; if (ecmd->duplex == DUPLEX_FULL) mdp->duplex = 1; else mdp->duplex = 0; if (mdp->cd->set_duplex) mdp->cd->set_duplex(ndev); error_exit: mdelay(1); /* enable tx and rx */ <API key>(ndev); <API key>(&mdp->lock, flags); return ret; } static int sh_eth_nway_reset(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); unsigned long flags; int ret; spin_lock_irqsave(&mdp->lock, flags); ret = phy_start_aneg(mdp->phydev); <API key>(&mdp->lock, flags); return ret; } static u32 sh_eth_get_msglevel(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); return mdp->msg_enable; } static void sh_eth_set_msglevel(struct net_device *ndev, u32 value) { struct sh_eth_private *mdp = netdev_priv(ndev); mdp->msg_enable = value; } static const char <API key>[][ETH_GSTRING_LEN] = { "rx_current", "tx_current", "rx_dirty", "tx_dirty", }; #define SH_ETH_STATS_LEN ARRAY_SIZE(<API key>) static int <API key>(struct net_device *netdev, int sset) { switch (sset) { case ETH_SS_STATS: return SH_ETH_STATS_LEN; default: return -EOPNOTSUPP; } } static void <API key>(struct net_device *ndev, struct ethtool_stats *stats, u64 *data) { struct sh_eth_private *mdp = netdev_priv(ndev); int i = 0; /* device-specific stats */ data[i++] = mdp->cur_rx; data[i++] = mdp->cur_tx; data[i++] = mdp->dirty_rx; data[i++] = mdp->dirty_tx; } static void sh_eth_get_strings(struct net_device *ndev, u32 stringset, u8 *data) { switch (stringset) { case ETH_SS_STATS: memcpy(data, *<API key>, sizeof(<API key>)); break; } } static const struct ethtool_ops sh_eth_ethtool_ops = { .get_settings = sh_eth_get_settings, .set_settings = sh_eth_set_settings, .nway_reset = sh_eth_nway_reset, .get_msglevel = sh_eth_get_msglevel, .set_msglevel = sh_eth_set_msglevel, .get_link = ethtool_op_get_link, .get_strings = sh_eth_get_strings, .get_ethtool_stats = <API key>, .get_sset_count = <API key>, }; /* network device open function */ static int sh_eth_open(struct net_device *ndev) { int ret = 0; struct sh_eth_private *mdp = netdev_priv(ndev); pm_runtime_get_sync(&mdp->pdev->dev); ret = request_irq(ndev->irq, sh_eth_interrupt, #if defined(<API key>) || \ defined(<API key>) || \ defined(<API key>) IRQF_SHARED, #else 0, #endif ndev->name, ndev); if (ret) { dev_err(&ndev->dev, "Can not assign IRQ number\n"); return ret; } /* Descriptor set */ ret = sh_eth_ring_init(ndev); if (ret) goto out_free_irq; /* device init */ ret = sh_eth_dev_init(ndev); if (ret) goto out_free_irq; /* PHY control start*/ ret = sh_eth_phy_start(ndev); if (ret) goto out_free_irq; /* Set the timer to check for link beat. */ init_timer(&mdp->timer); mdp->timer.expires = (jiffies + (24 * HZ)) / 10;/* 2.4 sec. */ setup_timer(&mdp->timer, sh_eth_timer, (unsigned long)ndev); return ret; out_free_irq: free_irq(ndev->irq, ndev); pm_runtime_put_sync(&mdp->pdev->dev); return ret; } /* Timeout function */ static void sh_eth_tx_timeout(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); struct sh_eth_rxdesc *rxdesc; int i; netif_stop_queue(ndev); if (netif_msg_timer(mdp)) dev_err(&ndev->dev, "%s: transmit timed out, status %8.8x," " resetting...\n", ndev->name, (int)sh_eth_read(ndev, EESR)); /* tx_errors count up */ ndev->stats.tx_errors++; /* timer off */ del_timer_sync(&mdp->timer); /* Free all the skbuffs in the Rx queue. */ for (i = 0; i < RX_RING_SIZE; i++) { rxdesc = &mdp->rx_ring[i]; rxdesc->status = 0; rxdesc->addr = 0xBADF00D0; if (mdp->rx_skbuff[i]) dev_kfree_skb(mdp->rx_skbuff[i]); mdp->rx_skbuff[i] = NULL; } for (i = 0; i < TX_RING_SIZE; i++) { if (mdp->tx_skbuff[i]) dev_kfree_skb(mdp->tx_skbuff[i]); mdp->tx_skbuff[i] = NULL; } /* device init */ sh_eth_dev_init(ndev); /* timer on */ mdp->timer.expires = (jiffies + (24 * HZ)) / 10;/* 2.4 sec. */ add_timer(&mdp->timer); } /* Packet transmit function */ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); struct sh_eth_txdesc *txdesc; u32 entry; unsigned long flags; spin_lock_irqsave(&mdp->lock, flags); if ((mdp->cur_tx - mdp->dirty_tx) >= (TX_RING_SIZE - 4)) { if (!sh_eth_txfree(ndev)) { if (netif_msg_tx_queued(mdp)) dev_warn(&ndev->dev, "TxFD exhausted.\n"); netif_stop_queue(ndev); <API key>(&mdp->lock, flags); return NETDEV_TX_BUSY; } } <API key>(&mdp->lock, flags); entry = mdp->cur_tx % TX_RING_SIZE; mdp->tx_skbuff[entry] = skb; txdesc = &mdp->tx_ring[entry]; /* soft swap. */ if (!mdp->cd->hw_swap) sh_eth_soft_swap(phys_to_virt(ALIGN(txdesc->addr, 4)), skb->len + 2); txdesc->addr = dma_map_single(&ndev->dev, skb->data, skb->len, DMA_TO_DEVICE); if (skb->len < ETHERSMALL) txdesc->buffer_length = ETHERSMALL; else txdesc->buffer_length = skb->len; if (entry >= TX_RING_SIZE - 1) txdesc->status |= cpu_to_edmac(mdp, TD_TACT | TD_TDLE); else txdesc->status |= cpu_to_edmac(mdp, TD_TACT); mdp->cur_tx++; if (!(sh_eth_read(ndev, EDTRR) & <API key>(mdp))) sh_eth_write(ndev, <API key>(mdp), EDTRR); return NETDEV_TX_OK; } /* device close function */ static int sh_eth_close(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); int ringsize; netif_stop_queue(ndev); /* Disable interrupts by clearing the interrupt mask. */ sh_eth_write(ndev, 0x0000, EESIPR); /* Stop the chip's Tx and Rx processes. */ sh_eth_write(ndev, 0, EDTRR); sh_eth_write(ndev, 0, EDRRR); /* PHY Disconnect */ if (mdp->phydev) { phy_stop(mdp->phydev); phy_disconnect(mdp->phydev); } free_irq(ndev->irq, ndev); del_timer_sync(&mdp->timer); /* Free all the skbuffs in the Rx queue. */ sh_eth_ring_free(ndev); /* free DMA buffer */ ringsize = sizeof(struct sh_eth_rxdesc) * RX_RING_SIZE; dma_free_coherent(NULL, ringsize, mdp->rx_ring, mdp->rx_desc_dma); /* free DMA buffer */ ringsize = sizeof(struct sh_eth_txdesc) * TX_RING_SIZE; dma_free_coherent(NULL, ringsize, mdp->tx_ring, mdp->tx_desc_dma); pm_runtime_put_sync(&mdp->pdev->dev); return 0; } static struct net_device_stats *sh_eth_get_stats(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); pm_runtime_get_sync(&mdp->pdev->dev); ndev->stats.tx_dropped += sh_eth_read(ndev, TROCR); sh_eth_write(ndev, 0, TROCR); /* (write clear) */ ndev->stats.collisions += sh_eth_read(ndev, CDCR); sh_eth_write(ndev, 0, CDCR); /* (write clear) */ ndev->stats.tx_carrier_errors += sh_eth_read(ndev, LCCR); sh_eth_write(ndev, 0, LCCR); /* (write clear) */ if (sh_eth_is_gether(mdp)) { ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CERCR); sh_eth_write(ndev, 0, CERCR); /* (write clear) */ ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CEECR); sh_eth_write(ndev, 0, CEECR); /* (write clear) */ } else { ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CNDCR); sh_eth_write(ndev, 0, CNDCR); /* (write clear) */ } pm_runtime_put_sync(&mdp->pdev->dev); return &ndev->stats; } /* ioctl to device function */ static int sh_eth_do_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd) { struct sh_eth_private *mdp = netdev_priv(ndev); struct phy_device *phydev = mdp->phydev; if (!netif_running(ndev)) return -EINVAL; if (!phydev) return -ENODEV; return phy_mii_ioctl(phydev, rq, cmd); } #if defined(SH_ETH_HAS_TSU) /* For TSU_POSTn. Please refer to the manual about this (strange) bitfields */ static void *<API key>(struct sh_eth_private *mdp, int entry) { return <API key>(mdp, TSU_POST1) + (entry / 8 * 4); } static u32 <API key>(int entry) { return 0x0f << (28 - ((entry % 8) * 4)); } static u32 <API key>(struct sh_eth_private *mdp, int entry) { return (0x08 >> (mdp->port << 1)) << (28 - ((entry % 8) * 4)); } static void <API key>(struct net_device *ndev, int entry) { struct sh_eth_private *mdp = netdev_priv(ndev); u32 tmp; void *reg_offset; reg_offset = <API key>(mdp, entry); tmp = ioread32(reg_offset); iowrite32(tmp | <API key>(mdp, entry), reg_offset); } static bool <API key>(struct net_device *ndev, int entry) { struct sh_eth_private *mdp = netdev_priv(ndev); u32 post_mask, ref_mask, tmp; void *reg_offset; reg_offset = <API key>(mdp, entry); post_mask = <API key>(entry); ref_mask = <API key>(mdp, entry) & ~post_mask; tmp = ioread32(reg_offset); iowrite32(tmp & ~post_mask, reg_offset); /* If other port enables, the function returns "true" */ return tmp & ref_mask; } static int sh_eth_tsu_busy(struct net_device *ndev) { int timeout = <API key> * 100; struct sh_eth_private *mdp = netdev_priv(ndev); while ((sh_eth_tsu_read(mdp, TSU_ADSBSY) & TSU_ADSBSY_0)) { udelay(10); timeout if (timeout <= 0) { dev_err(&ndev->dev, "%s: timeout\n", __func__); return -ETIMEDOUT; } } return 0; } static int <API key>(struct net_device *ndev, void *reg, const u8 *addr) { u32 val; val = addr[0] << 24 | addr[1] << 16 | addr[2] << 8 | addr[3]; iowrite32(val, reg); if (sh_eth_tsu_busy(ndev) < 0) return -EBUSY; val = addr[4] << 8 | addr[5]; iowrite32(val, reg + 4); if (sh_eth_tsu_busy(ndev) < 0) return -EBUSY; return 0; } static void <API key>(void *reg, u8 *addr) { u32 val; val = ioread32(reg); addr[0] = (val >> 24) & 0xff; addr[1] = (val >> 16) & 0xff; addr[2] = (val >> 8) & 0xff; addr[3] = val & 0xff; val = ioread32(reg + 4); addr[4] = (val >> 8) & 0xff; addr[5] = val & 0xff; } static int <API key>(struct net_device *ndev, const u8 *addr) { struct sh_eth_private *mdp = netdev_priv(ndev); void *reg_offset = <API key>(mdp, TSU_ADRH0); int i; u8 c_addr[ETH_ALEN]; for (i = 0; i < <API key>; i++, reg_offset += 8) { <API key>(reg_offset, c_addr); if (memcmp(addr, c_addr, ETH_ALEN) == 0) return i; } return -ENOENT; } static int <API key>(struct net_device *ndev) { u8 blank[ETH_ALEN]; int entry; memset(blank, 0, sizeof(blank)); entry = <API key>(ndev, blank); return (entry < 0) ? -ENOMEM : entry; } static int <API key>(struct net_device *ndev, int entry) { struct sh_eth_private *mdp = netdev_priv(ndev); void *reg_offset = <API key>(mdp, TSU_ADRH0); int ret; u8 blank[ETH_ALEN]; sh_eth_tsu_write(mdp, sh_eth_tsu_read(mdp, TSU_TEN) & ~(1 << (31 - entry)), TSU_TEN); memset(blank, 0, sizeof(blank)); ret = <API key>(ndev, reg_offset + entry * 8, blank); if (ret < 0) return ret; return 0; } static int <API key>(struct net_device *ndev, const u8 *addr) { struct sh_eth_private *mdp = netdev_priv(ndev); void *reg_offset = <API key>(mdp, TSU_ADRH0); int i, ret; if (!mdp->cd->tsu) return 0; i = <API key>(ndev, addr); if (i < 0) { /* No entry found, create one */ i = <API key>(ndev); if (i < 0) return -ENOMEM; ret = <API key>(ndev, reg_offset + i * 8, addr); if (ret < 0) return ret; /* Enable the entry */ sh_eth_tsu_write(mdp, sh_eth_tsu_read(mdp, TSU_TEN) | (1 << (31 - i)), TSU_TEN); } /* Entry found or created, enable POST */ <API key>(ndev, i); return 0; } static int <API key>(struct net_device *ndev, const u8 *addr) { struct sh_eth_private *mdp = netdev_priv(ndev); int i, ret; if (!mdp->cd->tsu) return 0; i = <API key>(ndev, addr); if (i) { /* Entry found */ if (<API key>(ndev, i)) goto done; /* Disable the entry if both ports was disabled */ ret = <API key>(ndev, i); if (ret < 0) return ret; } done: return 0; } static int <API key>(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); int i, ret; if (unlikely(!mdp->cd->tsu)) return 0; for (i = 0; i < <API key>; i++) { if (<API key>(ndev, i)) continue; /* Disable the entry if both ports was disabled */ ret = <API key>(ndev, i); if (ret < 0) return ret; } return 0; } static void <API key>(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); u8 addr[ETH_ALEN]; void *reg_offset = <API key>(mdp, TSU_ADRH0); int i; if (unlikely(!mdp->cd->tsu)) return; for (i = 0; i < <API key>; i++, reg_offset += 8) { <API key>(reg_offset, addr); if (<API key>(addr)) <API key>(ndev, addr); } } /* Multicast reception directions set */ static void <API key>(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); u32 ecmr_bits; int mcast_all = 0; unsigned long flags; spin_lock_irqsave(&mdp->lock, flags); /* * Initial condition is MCT = 1, PRM = 0. * Depending on ndev->flags, set PRM or clear MCT */ ecmr_bits = (sh_eth_read(ndev, ECMR) & ~ECMR_PRM) | ECMR_MCT; if (!(ndev->flags & IFF_MULTICAST)) { <API key>(ndev); mcast_all = 1; } if (ndev->flags & IFF_ALLMULTI) { <API key>(ndev); ecmr_bits &= ~ECMR_MCT; mcast_all = 1; } if (ndev->flags & IFF_PROMISC) { <API key>(ndev); ecmr_bits = (ecmr_bits & ~ECMR_MCT) | ECMR_PRM; } else if (mdp->cd->tsu) { struct netdev_hw_addr *ha; <API key>(ha, ndev) { if (mcast_all && <API key>(ha->addr)) continue; if (<API key>(ndev, ha->addr) < 0) { if (!mcast_all) { <API key>(ndev); ecmr_bits &= ~ECMR_MCT; mcast_all = 1; } } } } else { /* Normal, unicast/broadcast-only mode. */ ecmr_bits = (ecmr_bits & ~ECMR_PRM) | ECMR_MCT; } /* update the ethernet mode */ sh_eth_write(ndev, ecmr_bits, ECMR); <API key>(&mdp->lock, flags); } static int <API key>(struct sh_eth_private *mdp) { if (!mdp->port) return TSU_VTAG0; else return TSU_VTAG1; } static int <API key>(struct net_device *ndev, u16 vid) { struct sh_eth_private *mdp = netdev_priv(ndev); int vtag_reg_index = <API key>(mdp); if (unlikely(!mdp->cd->tsu)) return -EPERM; /* No filtering if vid = 0 */ if (!vid) return 0; mdp->vlan_num_ids++; /* * The controller has one VLAN tag HW filter. So, if the filter is * already enabled, the driver disables it and the filte */ if (mdp->vlan_num_ids > 1) { /* disable VLAN filter */ sh_eth_tsu_write(mdp, 0, vtag_reg_index); return 0; } sh_eth_tsu_write(mdp, TSU_VTAG_ENABLE | (vid & TSU_VTAG_VID_MASK), vtag_reg_index); return 0; } static int <API key>(struct net_device *ndev, u16 vid) { struct sh_eth_private *mdp = netdev_priv(ndev); int vtag_reg_index = <API key>(mdp); if (unlikely(!mdp->cd->tsu)) return -EPERM; /* No filtering if vid = 0 */ if (!vid) return 0; mdp->vlan_num_ids sh_eth_tsu_write(mdp, 0, vtag_reg_index); return 0; } #endif /* SH_ETH_HAS_TSU */ /* SuperH's TSU register init function */ static void sh_eth_tsu_init(struct sh_eth_private *mdp) { sh_eth_tsu_write(mdp, 0, TSU_FWEN0); /* Disable forward(0->1) */ sh_eth_tsu_write(mdp, 0, TSU_FWEN1); /* Disable forward(1->0) */ sh_eth_tsu_write(mdp, 0, TSU_FCM); /* forward fifo 3k-3k */ sh_eth_tsu_write(mdp, 0xc, TSU_BSYSL0); sh_eth_tsu_write(mdp, 0xc, TSU_BSYSL1); sh_eth_tsu_write(mdp, 0, TSU_PRISL0); sh_eth_tsu_write(mdp, 0, TSU_PRISL1); sh_eth_tsu_write(mdp, 0, TSU_FWSL0); sh_eth_tsu_write(mdp, 0, TSU_FWSL1); sh_eth_tsu_write(mdp, TSU_FWSLC_POSTENU | TSU_FWSLC_POSTENL, TSU_FWSLC); if (sh_eth_is_gether(mdp)) { sh_eth_tsu_write(mdp, 0, TSU_QTAG0); /* Disable QTAG(0->1) */ sh_eth_tsu_write(mdp, 0, TSU_QTAG1); /* Disable QTAG(1->0) */ } else { sh_eth_tsu_write(mdp, 0, TSU_QTAGM0); /* Disable QTAG(0->1) */ sh_eth_tsu_write(mdp, 0, TSU_QTAGM1); /* Disable QTAG(1->0) */ } sh_eth_tsu_write(mdp, 0, TSU_FWSR); /* all interrupt status clear */ sh_eth_tsu_write(mdp, 0, TSU_FWINMK); /* Disable all interrupt */ sh_eth_tsu_write(mdp, 0, TSU_TEN); /* Disable all CAM entry */ sh_eth_tsu_write(mdp, 0, TSU_POST1); /* Disable CAM entry [ 0- 7] */ sh_eth_tsu_write(mdp, 0, TSU_POST2); /* Disable CAM entry [ 8-15] */ sh_eth_tsu_write(mdp, 0, TSU_POST3); /* Disable CAM entry [16-23] */ sh_eth_tsu_write(mdp, 0, TSU_POST4); /* Disable CAM entry [24-31] */ } /* MDIO bus release function */ static int sh_mdio_release(struct net_device *ndev) { struct mii_bus *bus = dev_get_drvdata(&ndev->dev); /* unregister mdio bus */ mdiobus_unregister(bus); /* remove mdio bus info from net_device */ dev_set_drvdata(&ndev->dev, NULL); /* free interrupts memory */ kfree(bus->irq); /* free bitbang info */ free_mdio_bitbang(bus); return 0; } /* MDIO bus init function */ static int sh_mdio_init(struct net_device *ndev, int id, struct sh_eth_plat_data *pd) { int ret, i; struct bb_info *bitbang; struct sh_eth_private *mdp = netdev_priv(ndev); /* create bit control struct for PHY */ bitbang = kzalloc(sizeof(struct bb_info), GFP_KERNEL); if (!bitbang) { ret = -ENOMEM; goto out; } /* bitbang init */ bitbang->addr = mdp->addr + mdp->reg_offset[PIR]; bitbang->set_gate = pd->set_mdio_gate; bitbang->mdi_msk = 0x08; bitbang->mdo_msk = 0x04; bitbang->mmd_msk = 0x02;/* MMD */ bitbang->mdc_msk = 0x01; bitbang->ctrl.ops = &bb_ops; /* MII controller setting */ mdp->mii_bus = alloc_mdio_bitbang(&bitbang->ctrl); if (!mdp->mii_bus) { ret = -ENOMEM; goto out_free_bitbang; } /* Hook up MII support for ethtool */ mdp->mii_bus->name = "sh_mii"; mdp->mii_bus->parent = &ndev->dev; snprintf(mdp->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x", mdp->pdev->name, id); /* PHY IRQ */ mdp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); if (!mdp->mii_bus->irq) { ret = -ENOMEM; goto out_free_bus; } for (i = 0; i < PHY_MAX_ADDR; i++) mdp->mii_bus->irq[i] = PHY_POLL; /* regist mdio bus */ ret = mdiobus_register(mdp->mii_bus); if (ret) goto out_free_irq; dev_set_drvdata(&ndev->dev, mdp->mii_bus); return 0; out_free_irq: kfree(mdp->mii_bus->irq); out_free_bus: free_mdio_bitbang(mdp->mii_bus); out_free_bitbang: kfree(bitbang); out: return ret; } static const u16 *<API key>(int register_type) { const u16 *reg_offset = NULL; switch (register_type) { case SH_ETH_REG_GIGABIT: reg_offset = <API key>; break; case SH_ETH_REG_FAST_SH4: reg_offset = <API key>; break; case <API key>: reg_offset = <API key>; break; default: printk(KERN_ERR "Unknown register type (%d)\n", register_type); break; } return reg_offset; } static const struct net_device_ops sh_eth_netdev_ops = { .ndo_open = sh_eth_open, .ndo_stop = sh_eth_close, .ndo_start_xmit = sh_eth_start_xmit, .ndo_get_stats = sh_eth_get_stats, #if defined(SH_ETH_HAS_TSU) .ndo_set_rx_mode = <API key>, .ndo_vlan_rx_add_vid = <API key>, .<API key> = <API key>, #endif .ndo_tx_timeout = sh_eth_tx_timeout, .ndo_do_ioctl = sh_eth_do_ioctl, .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = eth_mac_addr, .ndo_change_mtu = eth_change_mtu, }; static int sh_eth_drv_probe(struct platform_device *pdev) { int ret, devno = 0; struct resource *res; struct net_device *ndev = NULL; struct sh_eth_private *mdp = NULL; struct sh_eth_plat_data *pd; /* get base addr */ res = <API key>(pdev, IORESOURCE_MEM, 0); if (unlikely(res == NULL)) { dev_err(&pdev->dev, "invalid resource\n"); ret = -EINVAL; goto out; } ndev = alloc_etherdev(sizeof(struct sh_eth_private)); if (!ndev) { ret = -ENOMEM; goto out; } /* The sh Ether-specific entries in the device structure. */ ndev->base_addr = res->start; devno = pdev->id; if (devno < 0) devno = 0; ndev->dma = -1; ret = platform_get_irq(pdev, 0); if (ret < 0) { ret = -ENODEV; goto out_release; } ndev->irq = ret; SET_NETDEV_DEV(ndev, &pdev->dev); /* Fill in the fields of the device structure with ethernet values. */ ether_setup(ndev); mdp = netdev_priv(ndev); mdp->addr = ioremap(res->start, resource_size(res)); if (mdp->addr == NULL) { ret = -ENOMEM; dev_err(&pdev->dev, "ioremap failed.\n"); goto out_release; } spin_lock_init(&mdp->lock); mdp->pdev = pdev; pm_runtime_enable(&pdev->dev); pm_runtime_resume(&pdev->dev); pd = (struct sh_eth_plat_data *)(pdev->dev.platform_data); /* get PHY ID */ mdp->phy_id = pd->phy; mdp->phy_interface = pd->phy_interface; /* EDMAC endian */ mdp->edmac_endian = pd->edmac_endian; mdp->no_ether_link = pd->no_ether_link; mdp-><API key> = pd-><API key>; mdp->reg_offset = <API key>(pd->register_type); /* set cpu data */ #if defined(<API key>) mdp->cd = sh_eth_get_cpu_data(mdp); #else mdp->cd = &sh_eth_my_cpu_data; #endif <API key>(mdp->cd); /* set function */ ndev->netdev_ops = &sh_eth_netdev_ops; SET_ETHTOOL_OPS(ndev, &sh_eth_ethtool_ops); ndev->watchdog_timeo = TX_TIMEOUT; /* debug message level */ mdp->msg_enable = <API key>; mdp->post_rx = POST_RX >> (devno << 1); mdp->post_fw = POST_FW >> (devno << 1); /* read and set MAC address */ read_mac_address(ndev, pd->mac_addr); /* ioremap the TSU registers */ if (mdp->cd->tsu) { struct resource *rtsu; rtsu = <API key>(pdev, IORESOURCE_MEM, 1); if (!rtsu) { dev_err(&pdev->dev, "Not found TSU resource\n"); goto out_release; } mdp->tsu_addr = ioremap(rtsu->start, resource_size(rtsu)); mdp->port = devno % 2; ndev->features = <API key>; } /* initialize first or needed device */ if (!devno || pd->needs_init) { if (mdp->cd->chip_reset) mdp->cd->chip_reset(ndev); if (mdp->cd->tsu) { /* TSU init (Init only)*/ sh_eth_tsu_init(mdp); } } /* network device register */ ret = register_netdev(ndev); if (ret) goto out_release; /* mdio bus init */ ret = sh_mdio_init(ndev, pdev->id, pd); if (ret) goto out_unregister; /* print device information */ pr_info("Base address at 0x%x, %pM, IRQ %d.\n", (u32)ndev->base_addr, ndev->dev_addr, ndev->irq); <API key>(pdev, ndev); return ret; out_unregister: unregister_netdev(ndev); out_release: /* net_dev free */ if (mdp && mdp->addr) iounmap(mdp->addr); if (mdp && mdp->tsu_addr) iounmap(mdp->tsu_addr); if (ndev) free_netdev(ndev); out: return ret; } static int sh_eth_drv_remove(struct platform_device *pdev) { struct net_device *ndev = <API key>(pdev); struct sh_eth_private *mdp = netdev_priv(ndev); if (mdp->cd->tsu) iounmap(mdp->tsu_addr); sh_mdio_release(ndev); unregister_netdev(ndev); pm_runtime_disable(&pdev->dev); iounmap(mdp->addr); free_netdev(ndev); <API key>(pdev, NULL); return 0; } static int sh_eth_runtime_nop(struct device *dev) { /* * Runtime PM callback shared between ->runtime_suspend() * and ->runtime_resume(). Simply returns success. * * This driver re-initializes all registers after * pm_runtime_get_sync() anyway so there is no need * to save and restore registers here. */ return 0; } static struct dev_pm_ops sh_eth_dev_pm_ops = { .runtime_suspend = sh_eth_runtime_nop, .runtime_resume = sh_eth_runtime_nop, }; static struct platform_driver sh_eth_driver = { .probe = sh_eth_drv_probe, .remove = sh_eth_drv_remove, .driver = { .name = CARDNAME, .pm = &sh_eth_dev_pm_ops, }, }; <API key>(sh_eth_driver); MODULE_AUTHOR("Nobuhiro Iwamatsu, Yoshihiro Shimoda"); MODULE_DESCRIPTION("Renesas SuperH Ethernet driver"); MODULE_LICENSE("GPL v2");