2012年7月25日 星期三
android: how to see LOGV message
In your code add
#define LOG_NDEBUG 0
The reason is log.h at system/core/include/cutils/log.h
Ex:
In you want to see LOGV in audio_hw.c
You must add
#define LOG_TAG "audio_hw_primary"
#define LOG_NDEBUG 0
#define LOG_NDEBUG_FUNCTION
#ifndef LOG_NDEBUG_FUNCTION
#define LOGFUNC(...) ((void)0)
#else
#define LOGFUNC(...) (LOGV(__VA_ARGS__))
#endif
android: Filter logcat to get only you want message
adb -d logcat your_package_name:log_level *:S
ex: adb -d logcat com.example.example:I *:S
reference:
http://stackoverflow.com/questions/6854127/filter-logcat-to-get-only-the-messages-from-my-application-in-android
2012年7月24日 星期二
audio: concept
@Fetures Overview
The features supported by ALSA SoC Audio driver are:
-Supports audio codec in ALSA SoC framework.
-Multiple sample rates support (8 KHz, 16 KHz, 22.05 KHz, 32 KHz, 44.1 KHz, 48 KHz etc) for both capture and playback.
-Supports audio in stereo mode.
-Supports simultaneous playback and record (full-duplex mode).
-Start, stop, pause and resume feature.
-Supports mixer interface for audio codecs.
@Tool:
tinyalsa are used for audio playback, capture and configuration.
@ALSA HAL:
mydroid/device/xx/common-open/audio/audio_hw.c
The compiled HAL is named audio.primary.xxxx.so at /system/lib/hw
@ALSA Soc Architecture
- ASOC (ALSA System On Chip)
ASoC) layer is to provide better ALSA support for embedded system on chip processors and portable audio codecs
- Desgin:
1.Codec independence:
Allows reuse of codec drivers on other platforms and machines.
2.Easy I2S/PCM audio interface setup between codec and SoC.
Each SoC interface and codec registers it's audio interface capabilities with the
core and are subsequently matched and configured when the application hw params are known.
3.Dynamic Audio Power Management (DAPM):
DAPM automatically sets the codec to it's minimum power state at all times.
This includes powering up/down internal power blocks depending on the internal codec audio routing
and any active streams.
4.Pop and click reduction:
Pops and clicks can be reduced by powering the codec up/down in the correct sequence
(including using digital mute). ASoC signals the codec when to change power states.
-SoC basically splits an embedded audio system into three components:
1.Codec driver:
The codec driver is platform independent and contains audio controls,
audio interface capabilities, codec dapm definition and codec IO functions.
2.Platform driver:
The platform driver contains the audio dma engine and audio interface drivers (e.g. I2S, AC97, PCM)
for that platform.
3.Machine driver:
The machine driver handles any machine specific controls and audio events
i.e. turning on an amp at start of playback
@ Device Interface : /dev/snd/
- PCM devices for recording and play
- CTL devices that allow manipulating the internal mixer and routing of the card
1./dev/snd/controlC0: Control devices (i.e. mixer, etc)
2./dev/snd/pcmC0D0c : PCM Card 0 Device 0 Capture device
3./dev/snd/pcmC0D0p : PCM Card 0 Device 0 Playback device
@ Proc FS Interface: /proc/asound
The /proc/asound kernel interface is used as a status and configuration interface.
A lot of useful information about the sound system can be found in the
/proc/asound subdirectory.
1.cards : List of registered cards
2.version : Version and date the driver was built on
3.devices : List of registered ALSA devices
4.pcm : The list of allocated PCM streams
5.cardX : (X = 0-7) The card specific directory
6.cardX/pcm0p : The directory of the given PCM playback stream
7.cardX/pcm0c : The directory of the given PCM capture stream
@ Sys FS Interface:
- /sys/devices/platform/soc-audio/ : Information on the codec device
- /sys/devices/platform/xxx-pcm-audio : Interface for platfrom pcm (ALSA) device
- /sys/devices/platfrom/xxx-mcbsp-dai.x : Interface for McBSP device
@ Commonly Used API for ALSA:
snd_pcm_open:
Opens a PCM stream
snd_pcm_close:
Closes a previously opened PCM stream
snd_pcm_hw_params_any:
Fill params with a full configuration space for a PCM
snd_pcm_hw_params_test_ <
Test the availability of important parameters like number of channels,
sample rate etc.
For e.g. snd_pcm_hw_params_test_format, snd_pcm_hw_params_test_rate etc.
snd_pcm_hw_params_set_ <
For e.g. snd_pcm_hw_params_set_format, snd_pcm_hw_params_set_rate etc.
snd_pcm_hw_params:
Install one PCM hardware configuration chosen from a configuration space
snd_pcm_writei:
Write interleaved frames to a PCM
snd_pcm_readi:
Read interleaved frames from a PCM
snd_pcm_prepare:
Prepare PCM for use
snd_pcm_drop:
Stop a PCM dropping pending frames
snd_pcm_drain:
Stop a PCM preserving pending frames
reference:
http://processors.wiki.ti.com/index.php/UserGuideAudioDriver_PSP_04.02.00.07
2012年7月19日 星期四
Enabling dev_dbg in the kernel
Enabling dev_dbg in the kernel
To enable dev_dbg messages in a specific kernel file:
Reference: https://lkml.org/lkml/2007/6/29/323
To enable dev_dbg messages in a specific kernel file:
#define DEBUG
before including
Reference: https://lkml.org/lkml/2007/6/29/323
2012年7月11日 星期三
android: lcd backlight
1. packages/apps/Settings/src/com/Android/settings/BrightnessPreference.java
2.frameworks/base/core/java/Android/os/IPowerManager.aidl.java
--> // sets the brightness of the backlights (screen, keyboard, button) 0-255
void setBacklightBrightness(int brightness)
3.frameworks/base/core/java/Android/os/PowerManager.java
public void setBacklightBrightness(int brightness)
{
try {
mService.setBacklightBrightness(brightness);
} catch (RemoteException e) {
}
}
4.frameworks/base/services/java/com/Android/server/PowerManagerService.java
-- >public void setBacklightBrightness(int brightness) {
5.frameworks/base/services/java/com/android/server/LightsService.java
public void setBrightness(int brightness) {
setBrightness(brightness, BRIGHTNESS_MODE_USER);
}
public void setBrightness(int brightness, int brightnessMode) {
synchronized (this) {
int color = brightness & 0x000000ff;
color = 0xff000000 | (color << 16) | (color << 8) | color;
setLightLocked(color, LIGHT_FLASH_NONE, 0, 0, brightnessMode);
}
}
6./frameworks/base/services/jni/com_android_server_LightsService.cpp
static void setLight_native(JNIEnv *env, jobject clazz, int ptr,
int light, int colorARGB, int flashMode, int onMS, int offMS, int brightnessMode)
{
Devices* devices = (Devices*)ptr;
light_state_t state;
if (light < 0 || light >= LIGHT_COUNT || devices->lights[light] == NULL) {
return ;
}
memset(&state, 0, sizeof(light_state_t));
state.color = colorARGB;
state.flashMode = flashMode;
state.flashOnMS = onMS;
state.flashOffMS = offMS;
state.brightnessMode = brightnessMode;
devices->lights[light]->set_light(devices->lights[light], &state);
}
7. devices/vendor/board/liblights.c
set_light_backlight(struct light_device_t* dev,
struct light_state_t const* state)
{
int err = 0;
int brightness = rgb_to_brightness(state);
int fd;
char buf[1]={0};
pthread_mutex_lock(&g_lock);
fd = open(LCD_FILE, O_RDONLY);
err=read(fd, &buf, 1);
close(fd);
if(buf[0] == '0' && brightness)
usleep(200000);
err = write_int(LCD_FILE, brightness);
pthread_mutex_unlock(&g_lock);
return err;
}
char const*const LCD_FILE
= "/sys/class/leds/lcd-backlight/brightness";
8. kernel/driver/leds
ex: kernel/driver/leds/xxxx-pwm.c
2012年7月2日 星期一
vim: marked word
- 使用 vim 來註解一整段文字 -----------------------------------------------
‧執行 apt-get install vim-addon-manager vim-scripts
‧執行 vim-addons install enhanced-commentify
‧執行 vim 某個 文字檔,進入vim:
1. 先按 Esc 離開 insert mode
2. 再按 ctrl+v 將要註解的這幾行選取(使用上下左右鍵 or + shift )
3. 再按大寫的 I (指的是進入Insert mode)
4. 再輸入 #
5. 最後按 Esc 就會看到選取的這幾行都被 # 註解掉了
‧執行 apt-get install vim-addon-manager vim-scripts
‧執行 vim-addons install enhanced-commentify
‧執行 vim 某個 文字檔,進入vim:
1. 先按 Esc 離開 insert mode
2. 再按 ctrl+v 將要註解的這幾行選取(使用上下左右鍵 or + shift )
3. 再按大寫的 I (指的是進入Insert mode)
4. 再輸入 #
5. 最後按 Esc 就會看到選取的這幾行都被 # 註解掉了
linux screen: command list
Key | Action | Notes |
---|---|---|
Ctrl+a c | new window | |
Ctrl+a n | next window | |
Ctrl+a p | previous window | |
Ctrl+a “ | select window from list | |
Ctrl+a Ctrl+a | previous window viewed | |
Ctrl+a S | split terminal horizontally into regions | Ctrl+a c to create new window there |
Ctrl+a | | split terminal vertically into regions | Requires debian/ubuntu patched screen 4.0 |
Ctrl+a :resize | resize region | |
Ctrl+a :fit | fit screen size to new terminal size | Ctrl+a F is the same. Do after resizing xterm |
Ctrl+a :remove | remove region | Ctrl+a X is the same |
Ctrl+a tab | Move to next region | |
Ctrl+a d | detach screen from terminal | Start screen with -r option to reattach |
Ctrl+a A | set window title | |
Ctrl+a x | lock session | Enter user password to unlock |
Ctrl+a [ | enter scrollback/copy mode | Enter to start and end copy region. Ctrl+a ] to leave this mod |
Ctrl+a ] | paste buffer | Supports pasting between windows |
Ctrl+a > | write paste buffer to file | useful for copying between screens |
Ctrl+a < | read paste buffer from file | useful for pasting between screens |
Ctrl+a ? | show key bindings/command names | Note unbound commands only in man page |
Ctrl+a : | goto screen command prompt | up shows last command entered |
refer: http://deep.tw/others/screen/split-vertical.html
git & vimdiff setting
ref:http://stackoverflow.com/questions/3713765/viewing-all-git-diffs-with-vimdiff
#git config --global diff.tool vimdiff
#git config --global difftool.prompt false
#git config --global alias.d difftool
You type #git d
exit #wq:
2012年7月1日 星期日
git log
http://gitready.com/advanced/2009/01/20/bend-logs-to-your-will.html
#git log -n
show all content
#git log -p
show one line
#git log -pretty=oneline
show graph
#git log --graph
訂閱:
文章 (Atom)