From b271803ae2451c951344655ffe43ff74b42fa2ab Mon Sep 17 00:00:00 2001 From: codeworkx Date: Sat, 23 Feb 2013 05:03:10 +0000 Subject: p51xx: fix dock audio, add device specific settings Change-Id: Icaa5e6f7dc2a924ededbe9f5be4a768bcb3ecf6e --- DeviceSettings/Android.mk | 15 +++ DeviceSettings/AndroidManifest.xml | 31 +++++ .../res/drawable/ic_launcher_cmdevicesettings.png | Bin 0 -> 8207 bytes DeviceSettings/res/layout/top.xml | 5 + DeviceSettings/res/values-de/arrays.xml | 19 +++ DeviceSettings/res/values-de/strings.xml | 24 ++++ DeviceSettings/res/values/arrays.xml | 19 +++ DeviceSettings/res/values/strings.xml | 24 ++++ DeviceSettings/res/xml/dock_preferences.xml | 26 ++++ .../settings/device/DeviceSettings.java | 142 ++++++++++++++++++++ .../settings/device/DockFragmentActivity.java | 75 +++++++++++ .../com/cyanogenmod/settings/device/Startup.java | 29 +++++ .../src/com/cyanogenmod/settings/device/Utils.java | 143 +++++++++++++++++++++ audio/audio_hw.c | 28 +++- .../packages/apps/Settings/res/values/config.xml | 3 + configs/audio_policy.conf | 9 +- p51xx-common.mk | 1 + 17 files changed, 582 insertions(+), 11 deletions(-) create mode 100644 DeviceSettings/Android.mk create mode 100644 DeviceSettings/AndroidManifest.xml create mode 100755 DeviceSettings/res/drawable/ic_launcher_cmdevicesettings.png create mode 100755 DeviceSettings/res/layout/top.xml create mode 100644 DeviceSettings/res/values-de/arrays.xml create mode 100644 DeviceSettings/res/values-de/strings.xml create mode 100644 DeviceSettings/res/values/arrays.xml create mode 100644 DeviceSettings/res/values/strings.xml create mode 100644 DeviceSettings/res/xml/dock_preferences.xml create mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java create mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/DockFragmentActivity.java create mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java create mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java diff --git a/DeviceSettings/Android.mk b/DeviceSettings/Android.mk new file mode 100644 index 0000000..67ee3a6 --- /dev/null +++ b/DeviceSettings/Android.mk @@ -0,0 +1,15 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := optional + +LOCAL_STATIC_JAVA_LIBRARIES := android-support-v13 + +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_PACKAGE_NAME := GalaxyTab2Settings +LOCAL_CERTIFICATE := platform + +include $(BUILD_PACKAGE) + +include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/DeviceSettings/AndroidManifest.xml b/DeviceSettings/AndroidManifest.xml new file mode 100644 index 0000000..a581d10 --- /dev/null +++ b/DeviceSettings/AndroidManifest.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DeviceSettings/res/drawable/ic_launcher_cmdevicesettings.png b/DeviceSettings/res/drawable/ic_launcher_cmdevicesettings.png new file mode 100755 index 0000000..66de9c3 Binary files /dev/null and b/DeviceSettings/res/drawable/ic_launcher_cmdevicesettings.png differ diff --git a/DeviceSettings/res/layout/top.xml b/DeviceSettings/res/layout/top.xml new file mode 100755 index 0000000..744b568 --- /dev/null +++ b/DeviceSettings/res/layout/top.xml @@ -0,0 +1,5 @@ + + diff --git a/DeviceSettings/res/values-de/arrays.xml b/DeviceSettings/res/values-de/arrays.xml new file mode 100644 index 0000000..4cf4e23 --- /dev/null +++ b/DeviceSettings/res/values-de/arrays.xml @@ -0,0 +1,19 @@ + + + + + diff --git a/DeviceSettings/res/values-de/strings.xml b/DeviceSettings/res/values-de/strings.xml new file mode 100644 index 0000000..fb16ff2 --- /dev/null +++ b/DeviceSettings/res/values-de/strings.xml @@ -0,0 +1,24 @@ + + + + Galaxy Tab 2 Einstellungen + + Dock + Audio + USB-Dock Audio + Passive Audio-Ausgabe des USB-Docks verwenden + diff --git a/DeviceSettings/res/values/arrays.xml b/DeviceSettings/res/values/arrays.xml new file mode 100644 index 0000000..4cf4e23 --- /dev/null +++ b/DeviceSettings/res/values/arrays.xml @@ -0,0 +1,19 @@ + + + + + diff --git a/DeviceSettings/res/values/strings.xml b/DeviceSettings/res/values/strings.xml new file mode 100644 index 0000000..53ddcb0 --- /dev/null +++ b/DeviceSettings/res/values/strings.xml @@ -0,0 +1,24 @@ + + + + Galaxy Tab 2 Settings + + Dock + DOCK AUDIO + Use Dock USB Audio + Use the passive audio out on the dock + diff --git a/DeviceSettings/res/xml/dock_preferences.xml b/DeviceSettings/res/xml/dock_preferences.xml new file mode 100644 index 0000000..62c962c --- /dev/null +++ b/DeviceSettings/res/xml/dock_preferences.xml @@ -0,0 +1,26 @@ + + + + + + + + diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java new file mode 100644 index 0000000..ffa3054 --- /dev/null +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2012 The CyanogenMod Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.cyanogenmod.settings.device; + +import android.app.ActionBar; +import android.app.ActionBar.Tab; +import android.app.Activity; +import android.app.Fragment; +import android.app.FragmentTransaction; +import android.content.Context; +import android.os.Bundle; +import android.support.v4.app.FragmentActivity; +import android.support.v13.app.FragmentPagerAdapter; +import android.support.v4.view.ViewPager; + +import com.cyanogenmod.settings.device.R; + +import java.util.ArrayList; + +public class DeviceSettings extends FragmentActivity { + + public static final String SHARED_PREFERENCES_BASENAME = "com.cyanogenmod.settings.device"; + public static final String ACTION_UPDATE_PREFERENCES = "com.cyanogenmod.settings.device.UPDATE"; + public static final String KEY_USE_DOCK_AUDIO = "dock_audio"; + + ViewPager mViewPager; + TabsAdapter mTabsAdapter; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + mViewPager = new ViewPager(this); + mViewPager.setId(R.id.viewPager); + setContentView(mViewPager); + + final ActionBar bar = getActionBar(); + bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); + bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE); + bar.setTitle(R.string.app_name); + + mTabsAdapter = new TabsAdapter(this, mViewPager); + mTabsAdapter.addTab(bar.newTab().setText(R.string.category_dock_title), + DockFragmentActivity.class, null); + + if (savedInstanceState != null) { + bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0)); + } + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putInt("tab", getActionBar().getSelectedNavigationIndex()); + } + + public static class TabsAdapter extends FragmentPagerAdapter + implements ActionBar.TabListener, ViewPager.OnPageChangeListener { + private final Context mContext; + private final ActionBar mActionBar; + private final ViewPager mViewPager; + private final ArrayList mTabs = new ArrayList(); + + static final class TabInfo { + private final Class clss; + private final Bundle args; + + TabInfo(Class _class, Bundle _args) { + clss = _class; + args = _args; + } + } + + public TabsAdapter(Activity activity, ViewPager pager) { + super(activity.getFragmentManager()); + mContext = activity; + mActionBar = activity.getActionBar(); + mViewPager = pager; + mViewPager.setAdapter(this); + mViewPager.setOnPageChangeListener(this); + } + + public void addTab(ActionBar.Tab tab, Class clss, Bundle args) { + TabInfo info = new TabInfo(clss, args); + tab.setTag(info); + tab.setTabListener(this); + mTabs.add(info); + mActionBar.addTab(tab); + notifyDataSetChanged(); + } + + @Override + public int getCount() { + return mTabs.size(); + } + + @Override + public Fragment getItem(int position) { + TabInfo info = mTabs.get(position); + return Fragment.instantiate(mContext, info.clss.getName(), info.args); + } + + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + } + + public void onPageSelected(int position) { + mActionBar.setSelectedNavigationItem(position); + } + + public void onPageScrollStateChanged(int state) { + } + + public void onTabSelected(Tab tab, FragmentTransaction ft) { + Object tag = tab.getTag(); + for (int i=0; isup_channel_masks[0] = AUDIO_CHANNEL_OUT_STEREO; out->channel_mask = AUDIO_CHANNEL_OUT_STEREO; if (ladev->outputs[OUTPUT_DEEP_BUF] != NULL) { ret = -ENOSYS; + ALOGW("%s: output not available!", __func__); goto err_open; } output_type = OUTPUT_DEEP_BUF; @@ -2450,8 +2464,10 @@ static int adev_open_output_stream(struct audio_hw_device *dev, RESAMPLER_QUALITY_DEFAULT, NULL, &out->resampler); - if (ret != 0) + if (ret != 0) { + ALOGE("%s: error on resampler create!", __func__); goto err_open; + } out->stream.common.set_sample_rate = out_set_sample_rate; out->stream.common.get_channels = out_get_channels; @@ -2486,6 +2502,7 @@ static int adev_open_output_stream(struct audio_hw_device *dev, return 0; err_open: + ALOGE("%s: error opening output stream", __func__); free(out); return ret; } @@ -2781,6 +2798,7 @@ static const struct { { AUDIO_DEVICE_OUT_WIRED_HEADSET | AUDIO_DEVICE_OUT_WIRED_HEADPHONE, "headphone" }, { AUDIO_DEVICE_OUT_EARPIECE, "earpiece" }, { AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET, "analog-dock" }, + { AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET, "analog-dock" }, { AUDIO_DEVICE_OUT_ALL_SCO, "sco-out" }, { AUDIO_DEVICE_IN_BUILTIN_MIC, "builtin-mic" }, @@ -2990,7 +3008,7 @@ static int adev_open(const hw_module_t* module, const char* name, hw_device_t** device) { struct espresso_audio_device *adev; - int ret; + int i, ret; if (strcmp(name, AUDIO_HARDWARE_INTERFACE) != 0) return -EINVAL; @@ -3037,6 +3055,10 @@ static int adev_open(const hw_module_t* module, const char* name, adev->in_device = AUDIO_DEVICE_IN_BUILTIN_MIC & ~AUDIO_DEVICE_BIT_IN; select_devices(adev); + for (i = 0; i < OUTPUT_TOTAL; i++) { + adev->outputs[i] = NULL; + } + adev->pcm_modem_dl = NULL; adev->pcm_modem_ul = NULL; adev->pcm_bt_dl = NULL; diff --git a/common-overlay/packages/apps/Settings/res/values/config.xml b/common-overlay/packages/apps/Settings/res/values/config.xml index 165b0d1..6c9dc5f 100644 --- a/common-overlay/packages/apps/Settings/res/values/config.xml +++ b/common-overlay/packages/apps/Settings/res/values/config.xml @@ -20,4 +20,7 @@ true + + true + diff --git a/configs/audio_policy.conf b/configs/audio_policy.conf index 924811f..c83707b 100644 --- a/configs/audio_policy.conf +++ b/configs/audio_policy.conf @@ -26,7 +26,7 @@ audio_hw_modules { sampling_rates 44100 channel_masks AUDIO_CHANNEL_OUT_STEREO formats AUDIO_FORMAT_PCM_16_BIT - devices AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_HEADPHONE|AUDIO_DEVICE_OUT_ALL_SCO|AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET + devices AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_HEADPHONE|AUDIO_DEVICE_OUT_ALL_SCO|AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET|AUDIO_DEVICE_OUT_AUX_DIGITAL|AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET flags AUDIO_OUTPUT_FLAG_PRIMARY } deep_buffer { @@ -36,13 +36,6 @@ audio_hw_modules { devices AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_HEADPHONE flags AUDIO_OUTPUT_FLAG_DEEP_BUFFER } - hdmi { - sampling_rates 44100|48000 - channel_masks dynamic - formats AUDIO_FORMAT_PCM_16_BIT - devices AUDIO_DEVICE_OUT_AUX_DIGITAL - flags AUDIO_OUTPUT_FLAG_DIRECT - } } inputs { primary { diff --git a/p51xx-common.mk b/p51xx-common.mk index ab2ddcd..d90896d 100755 --- a/p51xx-common.mk +++ b/p51xx-common.mk @@ -74,6 +74,7 @@ PRODUCT_COPY_FILES += \ PRODUCT_PACKAGES += \ audio.primary.piranha \ camera.piranha \ + GalaxyTab2Settings \ hwcomposer.piranha \ lights.piranha \ libinvensense_mpl \ -- cgit v1.1