目前分類:Android (26)

瀏覽方式: 標題列表 簡短摘要
Android 6.0.1 修改按下 power button 三秒後才出現關機選單

power button按下時的code流程位於
\frameworks\base\services\core\java\com\android\server\policy\PhoneWindowManager.java
在以下code中
==
        // If the power key has still not yet been handled, then detect short
        // press, long press, or multi press and decide what to do.
        mPowerKeyHandled = hungUp || mScreenshotChordVolumeDownKeyTriggered
                || mScreenshotChordVolumeUpKeyTriggered || gesturedServiceIntercepted;
        if (!mPowerKeyHandled) {
            if (interactive) {
                // When interactive, we're already awake.
                // Wait for a long press or for the button to be released to decide what to do.
                if (hasLongPressOnPowerBehavior()) {
                    Message msg = mHandler.obtainMessage(MSG_POWER_LONG_PRESS);
                    msg.setAsynchronous(true);
                    mHandler.sendMessageDelayed(msg,
                            ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout());  //mark trace
==         

會呼叫 sendMessageDelayed 在 getDeviceGlobalActionKeyTimeout 時間之後送出  MSG_POWER_LONG_PRESS message
mHandler.sendMessageDelayed(msg,
                            ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout());  //mark trace                 
                           
而getDeviceGlobalActionKeyTimeout 相關code位於
\frameworks\base\core\java\android\view\ViewConfiguration.java
==
    public long getDeviceGlobalActionKeyTimeout() {
        return mGlobalActionsKeyTimeout;
    }
==
搜尋mGlobalActionsKeyTimeout,找到

mGlobalActionsKeyTimeout = GLOBAL_ACTIONS_KEY_TIMEOUT;

往上找 GLOBAL_ACTIONS_KEY_TIMEOUT,找到定義處
--
    /**
     * Defines the duration in milliseconds a user needs to hold down the
     * appropriate button to bring up the global actions dialog (power off,
     * lock screen, etc).
     */
    private static final int GLOBAL_ACTIONS_KEY_TIMEOUT = 500;  
--
這只是預設值 500 ms,往後找 mGlobalActionsKeyTimeout 還會有

        mGlobalActionsKeyTimeout = res.getInteger(
                com.android.internal.R.integer.config_globalActionsKeyTimeout);

在 frameworks\base\core\res\res\values\config.xml 檔案內,搜尋 config_globalActionsKeyTimeout
找到
    <!-- Amount of time in ms the user needs to press the relevant key to bring up the global actions dialog -->
    <integer name="config_globalActionsKeyTimeout">3000</integer>
所以就是修改  config.xml 檔案


    <!-- Amount of time in ms the user needs to press the relevant key to bring up the global actions dialog -->
    <integer name="config_globalActionsKeyTimeout">500</integer>
改成
  <integer name="config_globalActionsKeyTimeout">3000</integer>

  
                               
build method:
  mmm ./frameworks/base/core/res
  mmm ./frameworks/base/services
 
  make snod
  用 fastboot 去更新 system.img,就可以生效了
  fastboot flash system system.img
              
這樣就可以讓 power button 按下三秒後才出現 關機選單了  
文章標籤

CuteParrot 發表在 痞客邦 PIXNET 留言(0) 人氣()

== for msm8996 LK panel header file===


#ifndef _PANEL_SHARP_1440P_DUALDSI_VIDEO_H_
#define _PANEL_SHARP_1440P_DUALDSI_VIDEO_H_
/*---------------------------------------------------------------------------*/
/* HEADER files */
/*---------------------------------------------------------------------------*/
#include "panel.h"

/*---------------------------------------------------------------------------*/
/* Panel configuration
struct panel_config{

char *panel_node_id;
char *panel_controller;
char *panel_compatible;
uint16_t panel_interface; //
uint16_t panel_type;
char *panel_destination;
uint32_t panel_orientation;
// panel_clockrate is deprecated in favor of panel_bitclock_freq
uint32_t panel_clockrate;
uint16_t panel_framerate;
uint16_t panel_channelid;
uint16_t dsi_virtualchannel_id;
uint16_t panel_broadcast_mode;
uint16_t panel_lp11_init;
uint16_t panel_init_delay;
uint16_t dsi_stream;
uint8_t interleave_mode;
uint32_t panel_bitclock_freq;
uint32_t panel_operating_mode;
uint32_t panel_with_enable_gpio;
uint8_t mode_gpio_state;
char *slave_panel_node_id;
}; */
/*---------------------------------------------------------------------------*/
static struct panel_config sharp_1440p_dualdsi_video_panel_data = {
"qcom,mdss_dsi_sharp_1440p_video", "dsi:0:", "qcom,mdss-dsi-panel",
10, 0, "DISPLAY_1", 0, 0, 60, 0, 0, 1, 0, 0, 0, 0, 0, 11, 0, 0, //
sharp 1440x2560 panel_operating_mode is 11(0x0b)
"qcom,mdss_dsi_sharp_1440p_video"
};

/*---------------------------------------------------------------------------*/
/* Panel resolution
struct panel_resolution{

uint16_t panel_width; // 1440
uint16_t panel_height; // 2560
uint16_t hfront_porch; //100
uint16_t hback_porch; // 28
uint16_t hpulse_width; //16
uint16_t hsync_skew;
uint16_t vfront_porch; //4
uint16_t vback_porch; // 3
uint16_t vpulse_width; //1
uint16_t hleft_border;
uint16_t hright_border;
uint16_t vtop_border;
uint16_t vbottom_border;
uint16_t hactive_res;
uint16_t vactive_res;
uint16_t invert_data_polarity;
uint16_t invert_vsync_polarity;
uint16_t invert_hsync_polarity;
};
*/
/*---------------------------------------------------------------------------*/
static struct panel_resolution sharp_1440p_dualdsi_video_panel_res = {
1440, 2560, 100, 28, 16, 0, 4, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
};

/*---------------------------------------------------------------------------*/
/* Panel color information

struct color_info{
uint8_t color_format;
uint8_t color_order;
uint8_t underflow_color;
uint8_t border_color;
uint8_t pixel_packing;
uint8_t pixel_alignment;
};
*/
/*---------------------------------------------------------------------------*/
static struct color_info sharp_1440p_dualdsi_video_color = {
24, 0, 0xff, 0, 0, 0
};

/*---------------------------------------------------------------------------*/
/* Panel on/off command
information */
/*---------------------------------------------------------------------------*/
static char sharp_1440p_dualdsi_video_on_cmd0[] = {
0x02, 0x00, 0x29, 0xC0,
0xb0, 0x00, 0xFF, 0xFF,
};

static char sharp_1440p_dualdsi_video_on_cmd1[] = {
0x02, 0x00, 0x29, 0xC0,
0xd6, 0x01, 0xFF, 0xFF,
};

static char sharp_1440p_dualdsi_video_on_cmd2[] = {
0x02, 0x00, 0x29, 0xC0,
0xb3, 0x18, 0xFF, 0xFF,
};


static char sharp_1440p_dualdsi_video_on_cmd3[] = {
0x02, 0x00, 0x29, 0xC0,
0xb0, 0x03, 0xFF, 0xFF,
};

static char sharp_1440p_dualdsi_video_on_cmd4[] = {
0x29, 0x00, 0x05, 0x80
};

static char sharp_1440p_dualdsi_video_on_cmd5[] = {
0x11, 0x00, 0x05, 0x80
};

static struct mipi_dsi_cmd sharp_1440p_dualdsi_video_on_command[] = {
{0x8, sharp_1440p_dualdsi_video_on_cmd0, 0x10},
{0x8, sharp_1440p_dualdsi_video_on_cmd1, 0x10},
{0x8, sharp_1440p_dualdsi_video_on_cmd2, 0x10},
{0x8, sharp_1440p_dualdsi_video_on_cmd3, 0x10},
{0x4, sharp_1440p_dualdsi_video_on_cmd4, 0xa0},
{0x4, sharp_1440p_dualdsi_video_on_cmd5, 0xa0}
};

#define SHARP_1440P_DUALDSI_VIDEO_ON_COMMAND 6


static char sharp_1440p_dualdsi_videooff_cmd0[] = {
0x28, 0x00, 0x05, 0x80
};

static char sharp_1440p_dualdsi_videooff_cmd1[] = {
0x10, 0x00, 0x05, 0x80
};

static struct mipi_dsi_cmd sharp_1440p_dualdsi_video_off_command[] = {
{0x4, sharp_1440p_dualdsi_videooff_cmd0, 0x78}, //0x32
{0x4, sharp_1440p_dualdsi_videooff_cmd1, 0x78}
};

#define SHARP_1440P_DUALDSI_VIDEO_OFF_COMMAND 2

static struct command_state sharp_1440p_dualdsi_video_state = {
0, 1
};

/*---------------------------------------------------------------------------*/
/* Command mode panel
information */
/*---------------------------------------------------------------------------*/
static struct commandpanel_info sharp_1440p_dualdsi_video_command_panel = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};

/*---------------------------------------------------------------------------*/
/* Video mode panel information
struct videopanel_info {
uint8_t hsync_pulse; //0
uint8_t hfp_power_mode; //0
uint8_t hbp_power_mode; //0
uint8_t hsa_power_mode; //0
uint8_t bllp_eof_power_mode; //1
uint8_t bllp_power_mode; //1
uint8_t traffic_mode; //1
uint8_t dma_delayafter_vsync; //0
uint32_t bllp_eof_power; //0x09 ????
};

*/
/*---------------------------------------------------------------------------*/
static struct videopanel_info sharp_1440p_dualdsi_video_video_panel = {
0, 0, 0, 0, 1, 1, 1, 0, 0x9
};

/*---------------------------------------------------------------------------*/
/* Lane configuration


struct lane_configuration {
uint8_t dsi_lanes;
uint8_t dsi_lanemap;
uint8_t lane0_state;
uint8_t lane1_state;
uint8_t lane2_state;
uint8_t lane3_state;
uint8_t force_clk_lane_hs;
};
*/
/*---------------------------------------------------------------------------*/
static struct lane_configuration sharp_1440p_dualdsi_video_lane_config = {
4, 0, 1, 1, 1, 1, 0
};

/*---------------------------------------------------------------------------*/
/* Panel timing
d5 32 22 00 60 64 26 34 29 03 04 00
*/
/*---------------------------------------------------------------------------*/
static const uint32_t sharp_1440p_dualdsi_video_timings[] = {
0xd5, 0x32, 0x22, 0x00, 0x60, 0x64, 0x26, 0x34, 0x29, 0x03, 0x04, 0x00
};

/*
22 1e 07 08 04 03 04 a0 // DLN timimg-ctrl-4-8
22 1e 07 08 04 03 04 a0
22 1e 07 08 04 03 04 a0
22 1e 07 08 04 03 04 a0
22 18 07 08 04 03 04 a0
*/

static const uint32_t sharp_1440p_dualdsi_thulium_video_timings[] = {
0x22, 0x1e, 0x07, 0x08, 0x04, 0x03, 0x04, 0xa0,
0x22, 0x1e, 0x07, 0x08, 0x04, 0x03, 0x04, 0xa0,
0x22, 0x1e, 0x07, 0x08, 0x04, 0x03, 0x04, 0xa0,
0x22, 0x1e, 0x07, 0x08, 0x04, 0x03, 0x04, 0xa0,
0x22, 0x18, 0x07, 0x08, 0x04, 0x03, 0x04, 0xa0
};

/*
struct panel_timing {
uint8_t dsi_mdp_trigger;
uint8_t dsi_dma_trigger;
uint8_t tclk_post;
uint8_t tclk_pre;
};
*/

static struct panel_timing sharp_1440p_dualdsi_video_timing_info = {
0x0, 0x04, 0x0d, 0x2c
};

/*---------------------------------------------------------------------------*/
/* Panel reset sequence

struct panel_reset_sequence {
uint8_t pin_state[TOTAL_RESET_GPIO_CTRL];
uint32_t sleep[TOTAL_RESET_GPIO_CTRL];
uint8_t pin_direction;
};

*/
/*---------------------------------------------------------------------------*/
static struct panel_reset_sequence sharp_1440p_dualdsi_video_reset_seq = {
{0, 1, 1, }, {5, 20, 1, }, 2 // must 3 items
};

/*---------------------------------------------------------------------------*/
/* Backlight setting

struct backlight {
uint16_t bl_interface_type;
uint16_t bl_min_level;
uint16_t bl_max_level;
uint16_t bl_step;
uint16_t bl_pmic_controltype;
char *bl_pmic_model;
};

*/
/*---------------------------------------------------------------------------*/
static struct backlight sharp_1440p_dualdsi_video_backlight = {
1, 1, 4095, 100, 1, "PMIC_8941" /* BL_WLED */
};

/*
struct labibb_desc {
char amoled_panel; // lcd = 0, amoled = 1
char force_config; // 0 to use default value
uint32_t ibb_min_volt;
uint32_t ibb_max_volt;
uint32_t lab_min_volt;
uint32_t lab_max_volt;
char pwr_up_delay; // ndx to => 1250, 2500, 5000 and 10000 us
char pwr_down_delay; // ndx to => 1250, 2500, 5000 and 10000 us
char ibb_discharge_en;
bool swire_control;
};
*/
static struct labibb_desc sharp_1440p_dualdsi_video_labibb = {
0, 1, 5800000, 5800000, 5800000, 5800000, 3, 3, 1, 0 // lab ibb
set 5.8v to meet data sheet
};

/*
struct dfps_info {
struct dfps_panel_info panel_dfps;
struct dfps_codes_info codes_dfps[DFPS_MAX_FRAME_RATE];
void *dfps_fb_base;
};
*/
/*---------------------------------------------------------------------------*/
/* Dynamic fps supported frequencies by
panel */
/*---------------------------------------------------------------------------*/
static const struct dfps_panel_info sharp_1440p_dualdsi_video_dfps = {
1, 8, {53, 54, 55, 56, 57, 58, 59, 60}
};

/*
struct topology_config {
char *config_name; // matches with kernel cmdline
//
// lm_split: -ve value means that lm_split is not used.
// If lm_split is used then DUAL_PIPE flag will be added.
//
int lm_split[2];
int num_dsc_enc; // how many encoder to use
struct dsc_parameters *dsc;
int use_pingpong_split;
};
*/
/* 2LM + 2CTL */
struct topology_config sharp_1440p_dualdsi_video_config0 = {
"config0", {720, 720}, 0, NULL, false
};

/* 1LM + 1CTL + PP_SPLIT */
struct topology_config sharp_1440p_dualdsi_video_config1 = {
"config1", {-1, -1}, 0, NULL, true // sharp 1440x2560 use
config 1,use_pingpong_split set true
};

#define SHARP_1440P_DUALDSI_VIDEO_SIGNATURE 0x210000

#endif /*_PANEL_SHARP_1440P_DUALDSI_VIDEO_H_*/


===for msm8996 kernel dtsi file ====

&mdss_mdp {
dsi_dual_sharp_1440p_video: qcom,mdss_dsi_sharp_1440p_video {
qcom,mdss-dsi-panel-name = "Dual SHARP 1440p video mode dsi panel";
qcom,mdss-dsi-panel-type = "dsi_video_mode";
qcom,mdss-dsi-panel-framerate = <60>;
qcom,mdss-dsi-virtual-channel-id = <0>;
qcom,mdss-dsi-stream = <0>;


qcom,mdss-dsi-panel-width = <720>; //1440x2560 , 720
qcom,mdss-dsi-panel-height = <2560>;
qcom,mdss-dsi-h-front-porch =<100>; // <76>;
qcom,mdss-dsi-h-back-porch = <28>; //<32>;
qcom,mdss-dsi-h-pulse-width =<16>; //<16>;
qcom,mdss-dsi-h-sync-skew = <0>;
qcom,mdss-dsi-v-back-porch = <3>; // ??
qcom,mdss-dsi-v-front-porch = <4>; // ??
qcom,mdss-dsi-v-pulse-width = <1>; //??

qcom,mdss-dsi-bpp = <24>;
qcom,mdss-dsi-underflow-color = <0xff>;
qcom,mdss-dsi-border-color = <0>;
qcom,mdss-dsi-on-command = // check
[
29 01 00 00 01 00 02 b0 00 // unlock command write // byte
0 must use 29
29 01 00 00 01 00 02 d6 01 // byte 0 must use 29
29 01 00 00 01 00 02 b3 18 // byte 0 must use 29, not use 15

29 01 00 00 01 00 02 b0 03 // lock command write // byte 0
must use 29
05 01 00 00 a0 00 02 29 00
05 01 00 00 a0 00 02 11 00 // a0 =160 ms

];
qcom,mdss-dsi-off-command = // check
[
05 01 00 00 78 00 02 28 00
05 01 00 00 78 00 02 10 00
];

qcom,mdss-dsi-on-command-state = "dsi_lp_mode"; // must lp mode
qcom,mdss-dsi-off-command-state = "dsi_hs_mode";
qcom,mdss-dsi-h-sync-pulse = <0>; // <1>;
qcom,mdss-dsi-traffic-mode = "non_burst_sync_event"; //1 //
"burst_mode"; //2
qcom,mdss-dsi-lane-map = "lane_map_0123";
qcom,mdss-dsi-bllp-eof-power-mode;
qcom,mdss-dsi-bllp-power-mode;
qcom,mdss-dsi-lane-0-state;
qcom,mdss-dsi-lane-1-state;
qcom,mdss-dsi-lane-2-state;
qcom,mdss-dsi-lane-3-state;
qcom,cmd-sync-wait-broadcast; // checked
//new
qcom,mdss-dsi-panel-timings =
[
d5 32 22 00 60 64 26 34 29 03 04 00

];
qcom,mdss-dsi-t-clk-post = <13>; //<0x02>;
qcom,mdss-dsi-t-clk-pre = <44>; ////<0x2a>;

qcom,mdss-dsi-bl-min-level = <1>;
qcom,mdss-dsi-bl-max-level = <4095>;
qcom,mdss-dsi-dma-trigger = "trigger_sw";
qcom,mdss-dsi-mdp-trigger = "none";
qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_pwm";

qcom,mdss-dsi-bl-pmic-pwm-frequency = <100>;
qcom,mdss-dsi-bl-pmic-bank-select = <0>;

qcom,mdss-dsi-reset-sequence = <0 5>, <1 20>;

qcom,mdss-pan-physical-width-dimension = <71>;
qcom,mdss-pan-physical-height-dimension = <128>;
qcom,mdss-dsi-min-refresh-rate = <53>;
qcom,mdss-dsi-max-refresh-rate = <60>;
qcom,mdss-dsi-pan-enable-dynamic-fps;

qcom,mdss-dsi-pan-fps-update = "dfps_immediate_porch_mode_vfp";
qcom,mdss-dsi-panel-status-check-mode = "bta_check";
qcom,mdss-dsi-tx-eot-append;
qcom,esd-check-enabled;

qcom,config-select = <&dsi_dual_sharp_1440p_video_config1>;

dsi_dual_sharp_1440p_video_config0: config0 {
qcom,split-mode = "dualctl-split";
};

dsi_dual_sharp_1440p_video_config1: config1 {
qcom,split-mode = "pingpong-split";
};

};
};

文章標籤

CuteParrot 發表在 痞客邦 PIXNET 留言(2) 人氣()


最近常常接觸 Android 4.4 之後才開始採用的 SEAndroid(SELinux),上網查了一下如何將之取消的方法
找到了以下網站


4 Effective Methods to Disable SELinux Temporarily or Permanently
http://www.thegeekstuff.com/2009/06/how-to-disable-selinux-redhat-fedora-debian-unix/

這篇雖然是針對 linux 撰寫,但是在Android上,只是路徑從 /selinux 變為 /sys/fs/selinux ,方法皆適用。

在此作紀錄!


文章標籤

CuteParrot 發表在 痞客邦 PIXNET 留言(2) 人氣()

裝置無法用fastboot update image,出現錯誤訊息 FAILED (remote: Partition flashing is not allowed) 解決方法


開發專案時,發生用 fastboot 無法 flash image,並出現錯誤訊息如下
--
D:\8909img>fastboot flash boot boot.img
< waiting for any device >
target reported max download size of 262144000 bytes
sending 'boot' (8253 KB)...
OKAY [  0.266s]
writing 'boot'...
FAILED (remote: Partition flashing is not allowed)
finished. total time: 0.281s
--

解決方法如下:

1.開機進入android,開啟developer options,開啟 oem unlock 選項
2.reboot 到 bootloader,輸入指令 fastboot oem unlock-go ,用來 wipe userdata
  之後再進入 bootloader 模式,輸入 fastboot flashing unlock
  就可以看到unlock成功
  ---
  D:\8909img>fastboot flashing unlock
  ...
  (bootloader)    Device already : unlocked!
  OKAY [  0.000s]
  finished. total time: 0.000s
  --
3.之後就可以正常用  fastboot flash boot boot.img 指令了

備註:
在bootloader下可用指令 fastboot flashing get_unlock_ability 查看是否能 unlock (也就是oem unlock 選項 是否有開啟)
返回值 1 表示有開啟,0表示沒有開啟。
C:\Windows\system32>fastboot flashing get_unlock_ability
...
(bootloader)    get_unlock_ability: 1
OKAY [  0.000s]
finished. total time: 0.000s

CuteParrot 發表在 痞客邦 PIXNET 留言(1) 人氣()

Media Controller API淺嚐

最近有機會研究了一下Media Controller API在這邊做一下紀錄
Media Controller API主要是針對 /dev/mediaX device file 做存取

官方Medial Controller API文件的說明為:
https://www.linuxtv.org/downloads/v4l-dvb-apis/media_common.html

根據我對其在簡介部分解讀精簡如下
Media Controller API主要是要解決以下問題
1.近年來越來越多多媒體裝置都會有多重的功能,這些功能以前只能從 sysfs得知其關係
2.查出裝置內的拓樸關係,並可在運作期間組態它

以下只先針對三大部分來做實作,其餘留有興趣的人去研究
.media open()
.media close()
.media ioctl()
    -ioctl MEDIA_IOC_DEVICE_INFO — Query device information
    -ioctl MEDIA_IOC_ENUM_ENTITIES — Enumerate entities and their properties
    
我的裝置為msm8992,Android 6.0,開完機後用adb shell去看系統檔案,發現在/dev下有三個media裝置,分別為
/dev/media0
/dev/media1
/dev/media2

所以我們可以,建立兩個檔案 mediatest.c 與 Android.mk,這邊我是放在AOSP內 device\qcom\msm8992\mediatest\ 目錄下
build的方式,你必須已經有 make -j6過一次image,將目錄切換到 device\qcom\msm8992\mediatest\下,鍵入 mm 指令,就可以build
如果成功 build出的,檔案會產生在 out\target\product\msm8992\system\bin\mediatest

.media open()
 要開啟 /dev/mediaX,要 #include <fcntl.h>,呼叫 open函式,成功的話會得到傳回的 file descriptor
 函式原型為:
 int open(    const char *device_name,int flags);
 
.media close()
 要關閉 /dev/mediaX,要 #include <unistd.h>,呼叫 close 函式,成功的話會得到傳回 0
 函式原型為:
 int close(    int fd);
 
.media ioctl() - ioctl MEDIA_IOC_DEVICE_INFO — Query device information
 利用ioctl MEDIA_IOC_DEVICE_INFO 來得知裝置的資訊,第三個參數為struct media_device_info *argp 指標
 執行成功,會將資料填入 struct media_device_info *argp 指標內
 函式原型為:
 int ioctl(    int fd,    int request,    struct media_device_info *argp);
 media_device 結構如下: (include/media/media-device.h)
 ---
 struct media_device {
    /* dev->driver_data points to this struct. */
    struct device *dev;
    struct media_devnode devnode;

    char model[32];
    char serial[40];
    char bus_info[32];
    u32 hw_revision;
    u32 driver_version;

    u32 entity_id;
    struct list_head entities;

    /* Protects the entities list */
    spinlock_t lock;
    /* Serializes graph operations. */
    struct mutex graph_mutex;

    int (*link_notify)(struct media_pad *source,
               struct media_pad *sink, u32 flags);
  };
  --
 
 mediatest運行後,針對/dev/media0 下MEDIA_IOC_DEVICE_INFO ioctl command得到以下media_device_info資訊
 --------------------------
 mdev_info.driver=msm,
 mdev_info.model=msm_config,
 mdev_info.serial=,
 mdev_info.bus_info=,
 mdev_info.media_version=256,
 mdev_info.hw_revision=0,
 mdev_info.driver_version=0,
 --------------------------
 在kernel driver,這部分的code是位於 AOSP /driver/media/platform/msm/camera_v2/msm.c 中 msm_probe function
 可以看到以下的 code
 --
 #if defined(CONFIG_MEDIA_CONTROLLER)
   ...
     strlcpy(msm_v4l2_dev->mdev->model, MSM_CONFIGURATION_NAME,
            sizeof(msm_v4l2_dev->mdev->model));
    msm_v4l2_dev->mdev->dev = &(pdev->dev);

    rc = media_device_register(msm_v4l2_dev->mdev);            
  --
  其中 /dev/mediaX是呼叫 media_device_register 去註冊的
  呼叫 media_device_unregister(msm_v4l2_dev->mdev); 去 unregister
 
 
.media ioctl() -ioctl MEDIA_IOC_ENUM_ENTITIES — Enumerate entities and their properties
 利用ioctl MEDIA_IOC_ENUM_ENTITIES 來列舉實體裝置與性能,第三個參數為struct media_entity_desc *argp 指標
 執行成功,會將資料填入 struct media_entity_desc *argp 指標內
 函式原型為:
 int ioctl(    int fd,    int request,    struct media_entity_desc *argp);  
 media_entity 結構如下: (include/media/media-entity.h)
 --
 struct media_entity {
    struct list_head list;
    struct media_device *parent;    /* Media device this entity belongs to*/
    u32 id;                /* Entity ID, unique in the parent media
                     * device context */
    const char *name;        /* Entity name */
    u32 type;            /* Entity type (MEDIA_ENT_T_*) */
    u32 revision;            /* Entity revision, driver specific */
    unsigned long flags;        /* Entity flags (MEDIA_ENT_FL_*) */
    u32 group_id;            /* Entity group ID */

    u16 num_pads;            /* Number of sink and source pads */
    u16 num_links;            /* Number of existing links, both
                     * enabled and disabled */
    u16 num_backlinks;        /* Number of backlinks */
    u16 max_links;            /* Maximum number of links */

    struct media_pad *pads;        /* Pads array (num_pads elements) */
    struct media_link *links;    /* Links array (max_links elements)*/

    const struct media_entity_operations *ops;    /* Entity operations */

    /* Reference counts must never be negative, but are signed integers on
     * purpose: a simple WARN_ON(<0) check can be used to detect reference
     * count bugs that would make them negative.
     */
    int stream_count;        /* Stream count for the entity. */
    int use_count;            /* Use count for the entity. */

    struct media_pipeline *pipe;    /* Pipeline this entity belongs to. */

    union {
        /* Node specifications */
        struct {
            u32 major;
            u32 minor;
        } v4l;
        struct {
            u32 major;
            u32 minor;
        } fb;
        struct {
            u32 card;
            u32 device;
            u32 subdevice;
        } alsa;
        int dvb;

        /* Sub-device specifications */
        /* Nothing needed yet */
    } info;
  };
  --
  mediatest運行後,針對/dev/media0 下 MEDIA_IOC_ENUM_ENTITIES ioctl command得到以下 media_entity 資訊
  總共得到了19個 media_entity
  --------------------------
  main 97,ioctl success,id=1,name=video0
  --------------------------
  entity.id=1,
  entity.name=video0,
  entity.type=65537,
  entity.revision=0,
  entity.flags=0,
  entity.group_id=2,
  entity.pads=0,
  entity,links=0,
  --------------------------
  main 97,ioctl success,id=2,name=msm_cci
  --------------------------
  entity.id=2,
  entity.name=msm_cci,
  entity.type=131072,
  entity.revision=0,
  entity.flags=0,
  entity.group_id=0,
  entity.pads=0,
  entity,links=0,
  --------------------------
  main 97,ioctl success,id=3,name=v4l-subdev0
  --------------------------
  entity.id=3,
  entity.name=v4l-subdev0,
  entity.type=131072,
  entity.revision=0,
  entity.flags=0,
  entity.group_id=0,
  entity.pads=0,
  entity,links=0,
  --------------------------
  main 97,ioctl success,id=4,name=v4l-subdev1
  --------------------------
  entity.id=4,
  entity.name=v4l-subdev1,
  entity.type=131072,
  entity.revision=0,
  entity.flags=0,
  entity.group_id=0,
  entity.pads=0,
  entity,links=0,
  --------------------------
  main 97,ioctl success,id=5,name=v4l-subdev2
  --------------------------
  entity.id=5,
  entity.name=v4l-subdev2,
  entity.type=131072,
  entity.revision=0,
  entity.flags=0,
  entity.group_id=0,
  entity.pads=0,
  entity,links=0,
  --------------------------
  main 97,ioctl success,id=6,name=v4l-subdev3
  --------------------------
  entity.id=6,
  entity.name=v4l-subdev3,
  entity.type=131072,
  entity.revision=0,
  entity.flags=0,
  entity.group_id=1,
  entity.pads=0,
  entity,links=0,
  --------------------------
  main 97,ioctl success,id=7,name=v4l-subdev4
  --------------------------
  entity.id=7,
  entity.name=v4l-subdev4,
  entity.type=131072,
  entity.revision=0,
  entity.flags=0,
  entity.group_id=1,
  entity.pads=0,
  entity,links=0,
  --------------------------
  main 97,ioctl success,id=8,name=v4l-subdev5
  --------------------------
  entity.id=8,
  entity.name=v4l-subdev5,
  entity.type=131072,
  entity.revision=0,
  entity.flags=0,
  entity.group_id=1,
  entity.pads=0,
  entity,links=0,
  --------------------------
  main 97,ioctl success,id=9,name=v4l-subdev6
  --------------------------
  entity.id=9,
  entity.name=v4l-subdev6,
  entity.type=131072,
  entity.revision=0,
  entity.flags=0,
  entity.group_id=1,
  entity.pads=0,
  entity,links=0,
  --------------------------
  main 97,ioctl success,id=10,name=v4l-subdev7
  --------------------------
  entity.id=10,
  entity.name=v4l-subdev7,
  entity.type=131072,
  entity.revision=0,
  entity.flags=0,
  entity.group_id=7,
  entity.pads=0,
  entity,links=0,
  --------------------------
  main 97,ioctl success,id=11,name=v4l-subdev8
  --------------------------
  entity.id=11,
  entity.name=v4l-subdev8,
  entity.type=131072,
  entity.revision=0,
  entity.flags=0,
  entity.group_id=16,
  entity.pads=0,
  entity,links=0,
  --------------------------
  main 97,ioctl success,id=12,name=v4l-subdev9
  --------------------------
  entity.id=12,
  entity.name=v4l-subdev9,
  entity.type=131072,
  entity.revision=0,
  entity.flags=0,
  entity.group_id=14,
  entity.pads=0,
  entity,links=0,
  --------------------------
  main 97,ioctl success,id=13,name=v4l-subdev10
  --------------------------
  entity.id=13,
  entity.name=v4l-subdev10,
  entity.type=131072,
  entity.revision=10,
  entity.flags=0,
  entity.group_id=9,
  entity.pads=0,
  entity,links=0,
  --------------------------
  main 97,ioctl success,id=14,name=v4l-subdev11
  --------------------------
  entity.id=14,
  entity.name=v4l-subdev11,
  entity.type=131072,
  entity.revision=0,
  entity.flags=0,
  entity.group_id=3,
  entity.pads=0,
  entity,links=0,
  --------------------------
  main 97,ioctl success,id=15,name=v4l-subdev12
  --------------------------
  entity.id=15,
  entity.name=v4l-subdev12,
  entity.type=131072,
  entity.revision=0,
  entity.flags=0,
  entity.group_id=3,
  entity.pads=0,
  entity,links=0,
  --------------------------
  main 97,ioctl success,id=16,name=v4l-subdev13
  --------------------------
  entity.id=16,
  entity.name=v4l-subdev13,
  entity.type=131072,
  entity.revision=0,
  entity.flags=0,
  entity.group_id=2,
  entity.pads=0,
  entity,links=0,
  --------------------------
  main 97,ioctl success,id=17,name=v4l-subdev14
  --------------------------
  entity.id=17,
  entity.name=v4l-subdev14,
  entity.type=131072,
  entity.revision=0,
  entity.flags=0,
  entity.group_id=13,
  entity.pads=0,
  entity,links=0,
  --------------------------
  main 97,ioctl success,id=18,name=v4l-subdev15
  --------------------------
  entity.id=18,
  entity.name=v4l-subdev15,
  entity.type=131072,
  entity.revision=0,
  entity.flags=769,
  entity.group_id=6,
  entity.pads=0,
  entity,links=0,
  --------------------------
  main 103,id=18,name=v4l-subdev15
  main 112,open /dev/v4l-subdev15 success
  main 122,ioctl success
  main 124,ioctl success,sensor_name=ov8865
  main 127, sensor_info.subdev_id[0] = 1
  main 127, sensor_info.subdev_id[1] = -1
  main 127, sensor_info.subdev_id[2] = 0
  main 127, sensor_info.subdev_id[3] = -1
  main 127, sensor_info.subdev_id[4] = 0
  main 127, sensor_info.subdev_id[5] = -1
  main 127, sensor_info.subdev_id[6] = 0
  main 127, sensor_info.subdev_id[7] = -1
  main 127, sensor_info.subdev_id[8] = 0
  main 127, sensor_info.subdev_id[9] = -1
  main 127, sensor_info.subdev_id[10] = -1
  main 97,ioctl success,id=19,name=v4l-subdev16
  --------------------------
  entity.id=19,
  entity.name=v4l-subdev16,
  entity.type=131072,
  entity.revision=0,
  entity.flags=65793,
  entity.group_id=6,
  entity.pads=0,
  entity,links=0,
  --------------------------
  main 103,id=19,name=v4l-subdev16
  main 112,open /dev/v4l-subdev16 success
  main 122,ioctl success
  main 124,ioctl success,sensor_name=de2011
  main 127, sensor_info.subdev_id[0] = 2
  main 127, sensor_info.subdev_id[1] = -1
  main 127, sensor_info.subdev_id[2] = -1
  main 127, sensor_info.subdev_id[3] = -1
  main 127, sensor_info.subdev_id[4] = -1
  main 127, sensor_info.subdev_id[5] = -1
  main 127, sensor_info.subdev_id[6] = 2
  main 127, sensor_info.subdev_id[7] = -1
  main 127, sensor_info.subdev_id[8] = 2
  main 127, sensor_info.subdev_id[9] = -1
  main 127, sensor_info.subdev_id[10] = -1
  main 93, ioctl failed  
 ---
 針對第1個entity
 --------------------------
 entity.id=1,
 entity.name=video0,
 entity.type=65537,
 entity.revision=0,
 entity.flags=0,
 entity.group_id=2,
 entity.pads=0,
 entity,links=0,
 --------------------------
 code 落在 /driver/media/platform/msm/camera_v2/msm.c
 中 msm_probe 函式
#if defined(CONFIG_MEDIA_CONTROLLER)
  ..
    pvdev->vdev->entity.type = MEDIA_ENT_T_DEVNODE_V4L;  //65537
    pvdev->vdev->entity.group_id = QCAMERA_VNODE_GROUP_ID;  // 2
#endif
 
  針對第 18,19 個 entity
 --------------------------
 entity.id=18,
 entity.name=v4l-subdev15,
 entity.type=131072,
 entity.revision=0,
 entity.flags=769,
 entity.group_id=6,
 entity.pads=0,
 entity,links=0,
 --------------------------
 entity.id=19,
 entity.name=v4l-subdev16,
 entity.type=131072,
 entity.revision=0,
 entity.flags=65793,
 entity.group_id=6,
 entity.pads=0,
 entity,links=0,
 --------------------------
 kernel code 落在 /driver/media/platform/msm/camera_v2/sensor/msm_sensor_driver.c
 中 msm_sensor_driver_create_v4l_subdev 函式
 entity.type 的值為 MEDIA_ENT_T_V4L2_SUBDEV (131072)
 entity.group_id 的值為 MSM_CAMERA_SUBDEV_SENSOR (6)
 
 mediatest程式會判斷當 (entity.type == MEDIA_ENT_T_V4L2_SUBDEV(131072) && entity.group_id == MSM_CAMERA_SUBDEV_SENSOR(6))
 去開啟 /dev/entity.name ,並下達
 cfg.cfgtype = CFG_GET_SENSOR_INFO;
 ioctl(sd_fd, VIDIOC_MSM_SENSOR_CFG, &cfg);
 去得到 sensor information 結構 struct sensorb_cfg_data cfg;
 

 kernel code 落在 /driver/media/platform/msm/camera_v2/sensor/msm_sensor.c  msm_sensor_config32 函式
 ---
    case CFG_GET_SENSOR_INFO:
        memcpy(cdata->cfg.sensor_info.sensor_name,
            s_ctrl->sensordata->sensor_name,
            sizeof(cdata->cfg.sensor_info.sensor_name));
        cdata->cfg.sensor_info.session_id =
            s_ctrl->sensordata->sensor_info->session_id;
        for (i = 0; i < SUB_MODULE_MAX; i++) {
            cdata->cfg.sensor_info.subdev_id[i] =
                s_ctrl->sensordata->sensor_info->subdev_id[i];
            cdata->cfg.sensor_info.subdev_intf[i] =
                s_ctrl->sensordata->sensor_info->subdev_intf[i];
        }
        cdata->cfg.sensor_info.is_mount_angle_valid =
            s_ctrl->sensordata->sensor_info->is_mount_angle_valid;
        cdata->cfg.sensor_info.sensor_mount_angle =
            s_ctrl->sensordata->sensor_info->sensor_mount_angle;
        cdata->cfg.sensor_info.position =
            s_ctrl->sensordata->sensor_info->position;
        cdata->cfg.sensor_info.modes_supported =
            s_ctrl->sensordata->sensor_info->modes_supported;
        CDBG("%s:%d sensor name %s\n", __func__, __LINE__,
            cdata->cfg.sensor_info.sensor_name);
        CDBG("%s:%d session id %d\n", __func__, __LINE__,
            cdata->cfg.sensor_info.session_id);
        for (i = 0; i < SUB_MODULE_MAX; i++) {
            CDBG("%s:%d subdev_id[%d] %d\n", __func__, __LINE__, i,
                cdata->cfg.sensor_info.subdev_id[i]);
            CDBG("%s:%d subdev_intf[%d] %d\n", __func__, __LINE__,
                i, cdata->cfg.sensor_info.subdev_intf[i]);
        }
        CDBG("%s:%d mount angle valid %d value %d\n", __func__,
            __LINE__, cdata->cfg.sensor_info.is_mount_angle_valid,
            cdata->cfg.sensor_info.sensor_mount_angle);

        break;
  ---

 有了以上的實作,相信各位應該可以更清楚瞭解到 media controller API與 kernel dirver的對應關係了
 希望對各位有所幫助。
 
 最後附上 mediatest.c 與 Android.mk 完整 source code 給各位參考
 Android.mk

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := eng
LOCAL_SRC_FILES:=mediatest.c
LOCAL_MODULE:=mediatest
LOCAL_CPPFLAGS += -DANDROID
LOCAL_SHARED_LIBRARIES:=libc
$(info "=========================================>>>>>>>>$(LOCAL_PATH)/$(KERNEL_DIR)")

LOCAL_C_INCLUDES+= $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include/media
LOCAL_C_INCLUDES+= $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
LOCAL_C_INCLUDES+= hardware/qcom/camera/QCamera2/stack/common
LOCAL_C_INCLUDES += \
           $(LOCAL_PATH) \
           $(LOCAL_PATH)/$(KERNEL_DIR)/include \
           
include $(BUILD_EXECUTABLE)
 mediatest.c
#include <fcntl.h>  // for open
#include <unistd.h>  // for close
#include <stdio.h>
#include <sys/ioctl.h> 
#include <linux/media.h>
#include <media/msm_cam_sensor.h>
#include <media/msmb_camera.h>
#include <string.h>  // for memset

struct media_device_info mdev_info;
struct media_entity_desc entity;
struct sensorb_cfg_data cfg;

int32_t num_media_devices = 0;

  
  
void showm_entity()
{
        printf("--------------------------\n"); 
        printf("entity.id=%d,\n",entity.id);   
        printf("entity.name=%s,\n",entity.name);   
        printf("entity.type=%d,\n",entity.type);   //MEDIA_ENT_T_V4L2_SUBDEV
        printf("entity.revision=%d,\n",entity.revision);   
        printf("entity.flags=%d,\n",entity.flags);   
        printf("entity.group_id=%d,\n",entity.group_id);   //MSM_CAMERA_SUBDEV_SENSOR
        printf("entity.pads=%d,\n",entity.pads);   
        printf("entity,links=%d,\n",entity.links);   
  printf("--------------------------\n"); 

  return ;      
}

  
void showm_mdev_info()
{
        printf("--------------------------\n");   
        printf("mdev_info.driver=%s,\n",mdev_info.driver);   
        printf("mdev_info.model=%s,\n",mdev_info.model);   
        printf("mdev_info.serial=%s,\n",mdev_info.serial);   
        printf("mdev_info.bus_info=%s,\n",mdev_info.bus_info); 
        printf("mdev_info.media_version=%d,\n",mdev_info.media_version);   
        printf("mdev_info.hw_revision=%d,\n",mdev_info.hw_revision);            
        printf("mdev_info.driver_version=%d,\n",mdev_info.driver_version);   
        printf("--------------------------\n");   
        return;
}  
  
int main()
{

  int dev_fd=0;
  int sd_fd=0;
  int rc=-1;
  char dev_name[32];
  char subdev_name[32];
  int i;
  int32_t num_media_devices = 0;  //media file count 
  
  printf("%s+ %d,\n",__func__,__LINE__);
  
  
  while (1) {
          int num_entities = 1;   
          snprintf(dev_name, sizeof(dev_name), "/dev/media%d", num_media_devices);
          //dev_fd=open("/dev/media0", O_RDWR );
          dev_fd=open(dev_name, O_RDWR);
          if(dev_fd<0){
                printf("%s %d, open %s failed\n",__func__,__LINE__,dev_name);   
                return rc;
          }else{
                printf("%s %d,open %s success\n",__func__,__LINE__,dev_name);   
          }
          
          num_media_devices++;
          
          memset(&mdev_info, 0, sizeof(mdev_info));
          rc=ioctl(dev_fd,MEDIA_IOC_DEVICE_INFO,&mdev_info);  
          if(rc < 0){
                printf("%s %d, ioctl failed\n",__func__,__LINE__);   
                goto close_media;
          }else{
                printf("%s %d,ioctl success,model=%s\n",__func__,__LINE__,mdev_info.model);  
                showm_mdev_info();
          }  
          
          while (1) {
          //ioctl MEDIA_IOC_ENUM_ENTITIES
                  memset(&entity, 0, sizeof(entity));
                  entity.id=num_entities++;  //??
                  rc=ioctl(dev_fd,MEDIA_IOC_ENUM_ENTITIES,&entity);  
                  if(rc < 0){
                        printf("%s %d, ioctl failed\n",__func__,__LINE__);   
                        //goto close_media;
                        break;
                  }else{
                        printf("%s %d,ioctl success,id=%d,name=%s\n",__func__,__LINE__,entity.id,entity.name);  
                        showm_entity();
                  }    
                  
                  //MEDIA_ENT_T_V4L2_SUBDEV= 131072 ,MSM_CAMERA_SUBDEV_SENSOR =6
            if (entity.type == MEDIA_ENT_T_V4L2_SUBDEV && entity.group_id == MSM_CAMERA_SUBDEV_SENSOR) {
                printf("%s %d,id=%d,name=%s\n",__func__,__LINE__,entity.id,entity.name); 
                snprintf(subdev_name, sizeof(subdev_name), "/dev/%s", entity.name);
                
                sd_fd=open(subdev_name, O_RDWR);
                                  if(sd_fd<0){
                                        printf("%s %d, open %s failed\n",__func__,__LINE__,subdev_name);   
                                        //goto close_media;
                                        continue;
                                  }else{
                                        printf("%s %d,open %s success\n",__func__,__LINE__,subdev_name);   
                                  }        
                memset(&cfg, 0, sizeof(cfg));
                cfg.cfgtype = CFG_GET_SENSOR_INFO;
                rc=ioctl(sd_fd, VIDIOC_MSM_SENSOR_CFG, &cfg);
                                  if(rc < 0){
                                        printf("%s %d, ioctl failed\n",__func__,__LINE__);   
                                        close(sd_fd);  
                                        continue;
                                  }else{
                                        printf("%s %d,ioctl success\n",__func__,__LINE__);                              
                                  }       
                                        printf("%s %d,ioctl success,sensor_name=%s\n",__func__,__LINE__,cfg.cfg.sensor_info.sensor_name);                               
                                     
                for (i = 0; i < SUB_MODULE_MAX; i++) {
                  printf("%s %d, sensor_info.subdev_id[%d] = %d\n",__func__,__LINE__, i, cfg.cfg.sensor_info.subdev_id[i]);
                }                         
                
            }
                  
          }
  }
  printf("%s %d,\n",__func__,__LINE__);    

close_sd: 
        close(sd_fd);  
        
close_media:    
  
  close(dev_fd);
  printf("%s %d, close \n",__func__,__LINE__);
        return rc;
}
 
 
 
 

文章標籤

CuteParrot 發表在 痞客邦 PIXNET 留言(0) 人氣()

conventional (OPEN LOOP)AF 與 CLOSED LOOP AF差異

OPEN LOOP AF :必須常保持一個電力來維持AF的位置
CLOSED LOOP AF: 只有當要移動時才需要電力,AF不動時不用電力來維持位置。


CuteParrot 發表在 痞客邦 PIXNET 留言(0) 人氣()

android APP 無法開啟 device file 解決方式(Qualcomm MSM8992 Android 5.1.1)

狀況:
---
寫了一隻APK呼叫JNI library要開啟/dev/v4l-subdev16,但卻失敗
debug message出現以下錯誤訊息
--
[  207.905424] type=1400 audit(2013.599:10): avc: denied { read write } for pid=6248 comm=".yps.cameratest" name="v4l-subdev16" dev="tmpfs" ino=11488 scontext=u:r:platform_app:s0 tcontext=u:object_r:camera_device:s0 tclass=chr_file permissive=0
--

解決方法:
---
1.因為android 5.0之後有啟動 SEAndroid機制,這是是一種安全性存取機制,詳細了解可以看以下網址
  http://blog.csdn.net/Luoshengyang/article/details/...
  錯誤訊息
  type=1400 audit(2013.599:10): avc: denied { read write } for pid=6248 comm=".yps.cameratest" name="v4l-subdev16" dev="tmpfs" ino=11488 scontext=u:r:platform_app:s0 tcontext=u:object_r:camera_device:s0 tclass=chr_file permissive=0
  就是因為SEAndroid不允許 APK 去存取 /dev/v4l-subdev16所產生的錯誤訊息
  所以要 allow APK去存取 /dev/v4l-subdev16
 
  首先先了解一下debug message- [scontext=u:r:platform_app:s0]
  scontext 四個欄位分別表示:[ SElinux用戶、角色、類型、安全級別],用戶固定為u,角色固定為r,級別固定為s0,會變動的為 [類型],在這邊是 [platform_app]
  [platform_app]表示的是 在AOSP source code下編譯並使用平台簽名的APP,所以獲得的seinfo為"platform",如果是第三方簽名的APP獲得的seinfo簽名為 "default"
  (check \external\sepolicy\mac_permissions.xml)
    
  再來了解一下devug message-[tcontext=u:object_r:camera_device:s0 tclass=chr_file]
  從檔案
  \device\qcom\sepolicy\common\file_contexts
  可以看到這一行
  /dev/v4l-subdev.*                               u:object_r:camera_device:s0
  表示"/dev/v4l-subdev*" 他的 [類型]名稱為 [camera_device]
 
  所以我們加入 allow APK去存取 /dev/v4l-subdev* 的規則
  修改檔案
  \device\qcom\sepolicy\common\platform_app.te
  加上
  allow platform_app camera_device:chr_file {write read open ioctl};
  重新編譯發現會有錯誤訊息
  所以還要修改檔案  \external\sepolicy\app.te
 
  將camera_device 的 neverallow 拿掉
      --
      # Access to any of the following character devices.
      neverallow appdomain {
          audio_device
          dm_device
          radio_device
          gps_device
          rpmsg_device
      }:chr_file { read write };
      ---
  重新編譯更新到裝置上
  這樣就可以允許APK 去存取 /dev/v4l-subdev*   
  就不會出現以下錯誤訊息
  --
  [  207.905424] type=1400 audit(2013.599:10): avc: denied { read write } for pid=6248 comm=".yps.cameratest" name="v4l-subdev16" dev="tmpfs" ino=11488 scontext=u:r:platform_app:s0 tcontext=u:object_r:camera_device:s0 tclass=chr_file permissive=0
  --
 
2.解決了 andorid 5.0 的 SEAndroid存取設定問題後,你會發現 APK仍是無法開啟  /dev/v4l-subdev16
  我們先用 adb shell切換成 su看一下 /dev/v4l-subdev16 檔案權限,發現為 /dev/v4l-subdev16 檔案權限0660如下:
  crw-rw---- system   camera    81,  21 1970-01-01 00:13 v4l-subdev16
  這樣是無法讓 APK去存取,所以  我們必須將/dev/v4l-subdev16 更改為 0666才可以讓 APK 存取    
  修改
  \device\qcom\common\rootdir\etc\ueventd.qcom.rc
  將
  /dev/v4l-subdev*          0660   system     camera
  改為
  /dev/v4l-subdev*          0666   system     camera
  重新編譯更新到裝置上
  這樣一來APK就可以順利存取/dev/v4l-subdev16。
 
 
  以上給大家參考!
 
 
文章標籤

CuteParrot 發表在 痞客邦 PIXNET 留言(1) 人氣()

將 APK ,so 等文件打包進 system.img 的方法

假設我有 CameraTest.apk 與 linscanhwl.so 要包進 system.img

作法區分為兩種狀況:

1.單獨為編譯好的 APK 與 so 檔案
.將 CameraTest.apk 檔案複製到 AOSP
device/qcom/msm8992/app/CameraTest/app 下
.將 linscanhwl.so 檔案複製到 AOSP
device/qcom/msm8992/app/CameraTest/lib 下
.修改 device\qcom\msm8992\msm8992.mk 檔案,加入以下內容
----
PRODUCT_COPY_FILES += \
device/qcom/msm8992/app/CameraTest/app/CameraTest.apk:system/app/CameraTest/CameraTest.apk
device/qcom/msm8992/app/CameraTest/lib/linscanhwl.so:system/lib/linscanhwl.so
----
之後 make -j6 ,就可以在 out 路徑下 system/app/CameraTest/ 與
system/lib/ 看到這兩個檔案
表示已經成功包進 system.img中

2.為APK、so的source code
.將所有 source code放置到 AOSP device\qcom\msm8992\scanner_hil\ 路徑
下,並確定都可以成功 mm 出檔案
.修改 device\qcom\msm8992\msm8992.mk 檔案,加入以下內容
---
PRODUCT_PACKAGES += \
libscanhwl \
CameraTest
---
.在APP部分,修改 device\qcom\msm8992\scanner_hil\app\Android.mk 檔案
要確定 LOCAL_MODULE_TAGS 是設定為 optional,這樣才會在 system/app/ 產出
---
LOCAL_MODULE_TAGS := optional
---
完整 device\qcom\msm8992\scanner_hil\app\Android.mk 內容如下:
--
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional # must set optional
LOCAL_CERTIFICATE := platform
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SDK_VERSION := current
LOCAL_PACKAGE_NAME := CameraTest
LOCAL_REQUIRED_MODULES := libscanhwl libscanapi
include $(BUILD_PACKAGE)
include $(call all-makefiles-under,$(LOCAL_PATH))
--
之後 make -j6 ,就可以在 out 路徑下 system/app/CameraTest/ 與
system/lib(64)/ 看到這兩個檔案
表示已經成功包進 system.img中

CuteParrot 發表在 痞客邦 PIXNET 留言(0) 人氣()

debug Android NDK JNI code


可在 JNI source code加入以下code
--
#include <android/log.h>

#define APPNAME "imager_preview"

__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "Java_com_usi_imagerpreview_MainActivity_setAimer");
--

且在 android.mk 中加入 logging libary link
--
LOCAL_LDLIBS := -llog
--

重新 build之後,就可在 logcat 中看到訊息
--
01-01 00:35:57.562 6320-6320/? V/imager_preview: Java_com_usi_imagerpreview_MainActivity_setAimer
--

CuteParrot 發表在 痞客邦 PIXNET 留言(0) 人氣()


Android JNI practice use Android Studio 1.5
=================



1.creata an [empty activiry] android project.
2.set textview id to TextView1.
3.add below code in MainActivity.java, before onCreate()
  --
  static {
System.loadLibrary("JniDemo");
}
public native String getStringFromNative();
--

4.use Terminal, switch path to app/src/main/java
  submit command to create com_usi_testjni_MainActivity.h
  javah -jni com.usi.testjni.MainActivity
 
5.create JNI folder under main.
  Project-> Testjni > app > main, right click >new > folder > JNIfolder
  move main\com_usi_testjni_MainActivity.h
  to
  jni\com_usi_testjni_MainActivity.h

6.create HelloNDK.c undr jni folder
  jni > right click > new > file > file name HelloNDK.c
  add below code in HelloNDK.c
  -- 
#include <com_usi_testjni_MainActivity.h>
JNIEXPORT jstring JNICALL Java_com_usi_testjni_MainActivity_getStringFromNative
        (JNIEnv * evn, jobject obj)
{
    return (*evn)->NewStringUTF(evn,"Hello NKD demo!!!!!!!!!!!!");
}
  --

7.add ndk.dir,sdk.dir in local.properties
  open Testjni > local.properties, add
  ndk.dir=C\:\\Users\\mark\\AppData\\Local\\Android\\sdk\\ndk-bundle
  sdk.dir=C\:\\Users\\mark\\AppData\\Local\\Android\\sdk

8.add android.useDeprecatedNdk=true under Testjni >gradle.properties 
 open Testjni > gradle.properties, add
 android.useDeprecatedNdk=true
 
9.add ndk module name in app > build.gradle
  open Testjni > app > build.gradle, add
  --
          ndk{
            moduleName "JniDemo"
        }
  --
  after         versionName "1.0"

10.add code to show ndk message in MainActivity.java
   open MainActivity.java, add below code in onCreate function.
   --
        TextView tmpview = (TextView)findViewById(R.id.TextView1);
        tmpview.setText(getStringFromNative());
   -- 
  
11.now android app can call c/c++ function via JNI.
     On device, result show as below:
   

Note:  
.if javah can not find ,please check your java path and add to PATH fow windows platform.
  my java is locate
  c:\Program Files\Java\jdk1.7.0_75\bin\
.if [Error: Cannot determine signature for Bitmap message] show , try below to solve it
solve method:
javah -classpath C:\Users\mark\AppData\Local\Android\sdk\platforms\android-22\android.jar;. com.usi.imagerpreview.MainActivity

.default SDK path
C:\Users\mark\AppData\Local\Android\sdk

.default NDK path
C:\Users\mark\AppData\Local\Android\sdk\ndk-bundle 

CuteParrot 發表在 痞客邦 PIXNET 留言(0) 人氣()

幾經折騰,終於搞定 MSM8992 mipi bridge tc358746 參數

以下提供各位參考:


Reference clk :VAD8992 is 24 Mhz.

.後端parallel camera’s data sheet: DE2011 , MT9V024_DS data sheet

.mipi TX輸出的data lane數量: VAD8992 is 1 lane.

.輸出格式:  RAW8.


tc358746 參數為

  {0x0002,0x0001,0x01},   // reset , delay 1ms
  {0x0002,0x0000,0x00},  //
  {0x0016,0x205B,0x00},   //pll setting
  {0x0018,0x0603,0x01},   // pll ctl        delay 1ms

  {0x0018,0x0613,0x01},  //pll ctrl    delay 1ms

    
  {0x0006,0x0064,0x00},   //FIFO CTRL 0x4b0 =1200  //{0x0006,0x01F4,2,0},    
  {0x0008,0x0000,0x00},   //data format , RAW8 is 0x0000 , check
  {0x0022,0x02f0,0x00},    // word cnt  , 0x2f0= 752 ,check
                       
  {0x0140,0x0000,0x00},   // mipi lane setup start  ,check
  {0x0142,0x0000,0x00},   // clock lane             ,check
  {0x0144,0x0000,0x00},   // check
  {0x0146,0x0000,0x00},   // only 1 lane               
  {0x0148,0x0001,0x00},  // check
  {0x014A,0x0000,0x00},  // check               
  {0x014C,0x0001,0x00},  // check
  {0x014E,0x0000,0x00},  // check             
  {0x0150,0x0001,0x00},  // check
  {0x0152,0x0000,0x00},   // mipi lane setup end
 
  {0x0210,0x0960,0x00}, //{0x0210,0x0960,2,0},   // PPI control setting start
  {0x0212,0x0000,0x00},
                 
  {0x0214,0x0002,0x00},
  {0x0216,0x0000,0x00},
                 
  {0x0218,0x0c01,0x00},
  {0x021A,0x0000,0x00},
                 
  {0x0220,0x0003,0x00},   //
  {0x0222,0x0000,0x00},
                 
  {0x0224,0x4a38,0x00},
  {0x0226,0x0000,0x00},
                 
  {0x022C,0x0000,0x00},
  {0x022E,0x0000,0x00},
                 
  {0x0230,0x0005,0x00},
  {0x0232,0x0000,0x00},
                 
  {0x0234,0x0003,0x00},
  {0x0236,0x0000,0x00},
                 
  {0x0238,0x0001,0x00},
  {0x023A,0x0000,0x00},
                 
  {0x0204,0x0001,0x00},
  {0x0206,0x0000,0x00},
                 
  {0x0518,0x0001,0x00},  
  {0x051A,0x0000,0x00},                       // PPI control setting end
              
  {0x0500,0x8081,0x00},  // check   // HS mode  
  {0x0502,0xA300,0x00},              // HS mode                    
  {0x0004,0x8044,0x00},         //start

文章標籤

CuteParrot 發表在 痞客邦 PIXNET 留言(0) 人氣()

當我們在 Android 的 AOSP 內,想要編譯一個放置在 tools/external 內的 c 應用程式時

我們必須為這個 c檔案撰寫一個 Android.mk 才能將之編譯成執行檔

而Android.mk 內容參考如下:


--Android.mk---

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := eng
LOCAL_SRC_FILES:=vidtest.c
LOCAL_MODULE:=vidtest1
LOCAL_CPPFLAGS += -DANDROID
LOCAL_SHARED_LIBRARIES:=libc
LOCAL_C_INCLUDES += $(LOCAL_PATH) $(LOCAL_PATH)/$(KERNEL_DIR)/include
include $(BUILD_EXECUTABLE)

-----


將Android.mk 與 c 放置在同一目錄後,先設定環境

.source /build/envsetup.sh

.lunch (選擇專案)

使用 mm 就可以編譯 ,產生的 執行檔會放置在 \out\target\product\msm8992\system\bin\ 內。




文章標籤

CuteParrot 發表在 痞客邦 PIXNET 留言(0) 人氣()


error = gpio_request(pdata->gpio_reset,"maxtouch_gpio_reset");

gpio_request 第三個參數 "maxtouch_gpio_reset"
會秀在/sys/kernel/debug/gpio ,使用下列命令就可看到以下結果

# cat /sys/kernel/debug/gpio
root@msm8992:/sys/class/gpio/gpio974 # cat /sys/kernel/debug/gpio
cat /sys/kernel/debug/gpio
GPIOs 545-576, platform/qcom,smp2pgpio-ssr-smp2p-1-out.16, master-kernel:

GPIOs 577-608, platform/qcom,smp2pgpio-ssr-smp2p-1-in.15, slave-kernel:

GPIOs 609-640, platform/qcom,smp2pgpio-ssr-smp2p-2-out.14, master-kernel:

GPIOs 641-672, platform/qcom,smp2pgpio-ssr-smp2p-2-in.13, slave-kernel:

GPIOs 673-704, platform/qcom,smp2pgpio-smp2p-2-out.11, smp2p:

GPIOs 705-736, platform/qcom,smp2pgpio-smp2p-2-in.9, smp2p:

GPIOs 737-768, platform/qcom,smp2pgpio-smp2p-1-out.7, smp2p:

GPIOs 769-800, platform/qcom,smp2pgpio-smp2p-1-in.5, smp2p:

GPIOs 801-832, platform/qcom,smp2pgpio-smp2p-7-out.3, smp2p:

GPIOs 833-864, platform/qcom,smp2pgpio-smp2p-7-in.1, smp2p:

GPIOs 865-865, spmi/qpnp-pin-ffffffc06344e880, pmi8994-mpp:

GPIOs 866-866, spmi/qpnp-pin-ffffffc063449080, pmi8994-gpio:
gpio-866 (usb_otg_vreg ) out lo

GPIOs 867-877, spmi/qpnp-pin-ffffffc06340d280, pm8994-gpio:
gpio-868 (volume_up ) in hi
gpio-871 (pwrreq_gpio ) in lo
gpio-873 (bt_vreg ) out lo
gpio-874 (nfc_clkreq_gpio ) in lo
gpio-875 (TOMTOM_CODEC_PMIC_MC) in lo

GPIOs 878-1023, platform/fd510000.pinctrl, msm_tlmm_gpio:
gpio-907 (nfc_irq_gpio ) in lo
gpio-908 (nfc_reset_gpio ) out lo
gpio-913 (perst-gpio ) out lo
gpio-915 (wake-gpio ) in hi
gpio-935 (maxtouch_gpio_irq ) in hi
gpio-937 (maxtouch_gpio_reset ) out hi
gpio-939 (display-3v3 ) in hi
gpio-946 (CDC_RESET ) out hi
gpio-967 (display-1v8 ) in hi
gpio-974 (sysfs ) out hi
gpio-983 (sysfs ) out hi
gpio-991 (wlan-en-gpio ) out lo

CuteParrot 發表在 痞客邦 PIXNET 留言(0) 人氣()

 

platfrom: MSM8909

Android version: lolillop 5.1.1, user-debug build


GT970 driver在init時會建立 debug fs
我們可以利用adb shell去讀取 GT970 register的值
以下為方法:

.adb root
.adb remount
.adb shell
#cd d/ts_debug
#echo 0x8053 > addr // 讀取 0x8053的設定值
#cat data
20 // 讀取出來為0x20

目前此debug fs不支援 write的操作

文章標籤

CuteParrot 發表在 痞客邦 PIXNET 留言(0) 人氣()


atmel touch tools to set atmel object value


首先說明一下我的環境:
---
CPU: MSM8992
Touch panel: ATMEL MXT_224s
OS:Android  5.1.1 (lollipop)
---
目前有一個平台是用 atmel mxt 224s touch panel,有時候會有修改此touch panel object的需要
在網路上找了一下,發現有一個工具 mxt-app 可以用來修改touch panel內部object的設定
網址如下:
https://github.com/atmel-maxtouch/mxt-app

於是在 ubuntu環境下利用下面指定下載source code,目錄為 mxt-app
git clone https://github.com/atmel-maxtouch/mxt-app.git
並執行
git submodule init
git submodule update
來download libusbdroid submodule

根據https://github.com/atmel-maxtouch/mxt-app 網站的說明,要compile需要下載NDK
所以我就在我 windows 平台上,至以下網址下載 Android NDK
https://developer.android.com/ndk/downloads/index.html#download
因我是 64 bit 平台,下載後得到檔案為 android-ndk-r10e-windows-x86_64.exe 410MB,並解壓縮

注意此 android-ndk-r10e 不能放在有空白字元目錄下,所以我就放在 D:\android-ndk-r10e
並將此路徑加到windows的環境變數PATH中

將在 ubuntu 系統下載的 mxt-app source code複製到 windows 系統中,並切換目錄到windows mxt-app放置處
根據https://github.com/atmel-maxtouch/mxt-app 網站的說明,因我的系統為Android  5.1.1 (lollipop)
必須enable PIE support,不然執行時會出現 "error: only position independent executables (PIE) are supported." 錯誤訊息

執行以下命令:
ndk-build APP_PLATFORM=android-16

binary執行檔會產生再 mxt-app/libs目錄下,分別有 arm64-v8a, armeabi,armeabi-7a,mips,mips64,x86,x86_64
因我的系統是屬於 arm64_v8a,所以我將 mxt-app/libs/arm64-v8a/mxt-app 複製到 android 裝置上

先將裝置 root, remount,複製mxt-app到裝置上,給於執行權限
.adb root
.adb remount
.adb push mxt-app /data/local/tmp
.adb shell chmod 777 /data/local/tmp/mxt-app
.adb shell

之後在裝置上切換目錄到 /data/local/tmp,執行 mxt-app
./mxt-app

出現以下畫面,下面範例示範 Enter I:   Read (I)nfo block , Enter W:   (W)rite individual object 將T9, 第14個 NUMTOUCH設定為 0x09

root@msm8992:/data/local/tmp # ./mxt-app
./mxt-app
Version:
Registered sysfs path:/sys/bus/i2c/drivers/atmel_maxtouch_ts/2-004b
Command line tool for Atmel maXTouch chips version:

Select one of the options:

Enter L:   (L)oad config file
Enter S:   (S)ave config file
Enter I:   Read (I)nfo block
Enter D:   Rea(D) individual object config
Enter W:   (W)rite individual object
Enter T:   Run sel(T)-test
Enter F:   (F)lash firmware to chip
Enter B:   (B)ackup the config data to NVM
Enter R:   (R)eset the maxtouch device
Enter C:   (C)alibrate the maxtouch device
Enter M:   Display raw (M)essages
Enter U:   D(U)mp Diagnostic data
Enter Q:   (Q)uit the application
I
I
Reading info block.....

Family: 130 Variant: 36 Firmware V3.0.AB Objects: 21
Matrix size: X24Y14
Information Block CRC: 0xF0808B

Type Start Size Instances ReportIds Name
-----------------------------------------------------------------
T37   136   130     1        0-0    DEBUG_DIAGNOSTIC_T37
T5    266     9     1        0-0    GEN_MESSAGEPROCESSOR_T5
T6    275     6     1        1-1    GEN_COMMANDPROCESSOR_T6
T38   281     8     1        0-0    SPT_USERDATA_T38
T71   289   112     1        0-0    SPT_DYNAMICCONFIGURATIONCONTAINER_T71
T7    401     4     1        0-0    GEN_POWERCONFIG_T7
T8    405    14     1        0-0    GEN_ACQUISITIONCONFIG_T8
T9    419    46     1        2-9    TOUCH_MULTITOUCHSCREEN_T9
T18   465     2     1        0-0    SPT_COMMSCONFIG_T18
T25   467     9     1       10-10   SPT_SELFTEST_T25
T42   476    10     1       11-11   PROCI_TOUCHSUPPRESSION_T42
T46   486    10     1       12-12   SPT_CTECONFIG_T46
T47   496    26     1        0-0    PROCI_STYLUS_T47
T56   522    30     1       13-13   PROCI_SHIELDLESS_T56
T57   552     3     1       14-14   PROCI_EXTRATOUCHSCREENDATA_T57
T61   555     5     2       15-16   SPT_TIMER_T61
T65   565    11     1        0-0    PROCI_LENSBENDING_T65
T66   576     3     1       17-17   SPT_GOLDENREFERENCES_T66
T70   579    10     8       18-25   SPT_DYNAMICCONFIGURATIONCONTROLLER_T70
T72   659    80     1       26-26   PROCG_NOISESUPPRESSION_T72
T80   739     4     1        0-0    PROCI_RETRANSMISSIONCOMPENSATION_T80

Select one of the options:

Enter L:   (L)oad config file
Enter S:   (S)ave config file
Enter I:   Read (I)nfo block
Enter D:   Rea(D) individual object config
Enter W:   (W)rite individual object
Enter T:   Run sel(T)-test
Enter F:   (F)lash firmware to chip
Enter B:   (B)ackup the config data to NVM
Enter R:   (R)eset the maxtouch device
Enter C:   (C)alibrate the maxtouch device
Enter M:   Display raw (M)essages
Enter U:   D(U)mp Diagnostic data
Enter Q:   (Q)uit the application
W
W
Enter the object number to write or 0 to finish
9
9
TOUCH_MULTITOUCHSCREEN_T9:
Object element 0 =       139
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 1 =       0
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 2 =       0
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 3 =       19
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 4 =       11
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 5 =       0
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 6 =       112
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 7 =       70
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 8 =       2
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 9 =       7
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 10 =      5
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 11 =      5
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 12 =      2
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 13 =      224
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 14 =      1
Do you want to change this value? (1 for yes/2 for no)1
1
Enter the value to be written to object element 14       :9
9
Wrote 9
Object element 15 =      10
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 16 =      10
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 17 =      10
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 18 =      32
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 19 =      3
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 20 =      224
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 21 =      1
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 22 =      45
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 23 =      44
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 24 =      32
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 25 =      3
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 26 =      0
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 27 =      0
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 28 =      0
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 29 =      0
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 30 =      10
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 31 =      10
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 32 =      0
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 33 =      0
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 34 =      0
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 35 =      0
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 36 =      0
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 37 =      0
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 38 =      0
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 39 =      0
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 40 =      0
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 41 =      0
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 42 =      0
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 43 =      0
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 44 =      0
Do you want to change this value? (1 for yes/2 for no)2
2
Object element 45 =      0
Do you want to change this value? (1 for yes/2 for no)2
2
Enter the object number to write or 0 to finish
0
0
Select one of the options:

Enter L:   (L)oad config file
Enter S:   (S)ave config file
Enter I:   Read (I)nfo block
Enter D:   Rea(D) individual object config
Enter W:   (W)rite individual object
Enter T:   Run sel(T)-test
Enter F:   (F)lash firmware to chip
Enter B:   (B)ackup the config data to NVM
Enter R:   (R)eset the maxtouch device
Enter C:   (C)alibrate the maxtouch device
Enter M:   Display raw (M)essages
Enter U:   D(U)mp Diagnostic data
Enter Q:   (Q)uit the application
q
q
Quit
root@msm8992:/data/local/tmp #


以上提供給有需要的朋友參考!

CuteParrot 發表在 痞客邦 PIXNET 留言(0) 人氣()

先切換成root
.adb root
remount 裝置
.adb remount

進入 adb shell
.adb shell

切換目錄到
.cd /sys/class/leds

如果要控制 led燈,請在進入 touch-light 目錄
root@msm8909:/sys/class/leds/torch-light0 #
利用以下指令點亮led燈
#echo 255 > brightness
如要更換其他亮度必須先設定 0後再重新設定亮度
#echo 0 > brightness
#echo 10 > brightness

如果要控制 led燈,請在進入 button-backlight 目錄

如果要控制 led燈,請在進入 lcd-backlight 目錄

一樣也是利用以下指令切換亮度
#echo 255 > brightness

如要更換其他亮度必須先設定 0後再重新設定亮度
#echo 0 > brightness
#echo 10 > brightness

文章標籤

CuteParrot 發表在 痞客邦 PIXNET 留言(0) 人氣()

以下就MSM8992 Ortus COM40H4M66ULC 的dtsi設定檔案一一做說明:


&mdss_mdp {
dsi_ortus_wvga_vid: qcom,mdss_dsi_ortus_wvga_video {
//dsi_ortus_wvga_vid 這名稱會被用在msm8992-mtp.dtsi,主要用來
指定主要panel是哪一塊
//mdss_dsi_ortus_wvga_video 這名稱可以自己訂

qcom,mdss-dsi-panel-name = "ORTUS wvga video mode dsi panel";
//"ORTUS wvga video mode dsi panel" 這名稱可以自己訂

qcom,mdss-dsi-panel-controller = <&mdss_dsi0>;
//因為這個 ortus在硬體上是接再 DSI0當主螢幕,所以設為 <&mdss_dsi0>

qcom,mdss-dsi-panel-type = "dsi_video_mode";
//此panel是 video mode,所以設為 "dsi_video_mode"

qcom,mdss-dsi-panel-destination = "display_1";
//因為只有一個螢幕,且當主螢幕用,所以設定為"display_1"
qcom,mdss-dsi-panel-framerate = <60>;
//通常都設定為 <60>
qcom,mdss-dsi-virtual-channel-id = <0>;
//因為只有一個螢幕,且當主螢幕用,所以設定為 <0>
qcom,mdss-dsi-stream = <0>;
//因為只有一個螢幕,且當主螢幕用,所以設定為 <0>
qcom,mdss-dsi-panel-width = <480>;
//螢幕的寬度,根據datasheet設定為480
qcom,mdss-dsi-panel-height = <800>;
////螢幕的寬度,根據datasheet設定為 800
qcom,mdss-dsi-h-front-porch = <16>; //check data sheet
//根據data sheet的 input timing haracteristics (page 17)頁
//將HFP設定為 16
qcom,mdss-dsi-h-back-porch = <16>; //check data sheet
//根據data sheet的 input timing haracteristics (page 17)頁
//將 HBP 設定為 16
qcom,mdss-dsi-h-pulse-width = <16>; //check data sheet
//根據data sheet的 input timing haracteristics (page 17)頁
//將 HPW 設定為 16
qcom,mdss-dsi-h-sync-skew = <0>;
//mdss-dsi-h-sync-skew 通常設定為 0
qcom,mdss-dsi-v-back-porch = <8>; //check data sheet
//根據data sheet的 input timing haracteristics (page 17)頁
//將 VBP 設定為 8
qcom,mdss-dsi-v-front-porch = <8>; //check data sheet
//根據data sheet的 input timing haracteristics (page 17)頁
//將 VFP 設定為 16
qcom,mdss-dsi-v-pulse-width = <8>; //check data sheet
//根據data sheet的 input timing haracteristics (page 17)頁
//將 VPW 設定為 16
qcom,mdss-dsi-h-left-border = <0>;
//通常mdss-dsi-h-left-border 都設定為0
qcom,mdss-dsi-h-right-border = <0>;
//通常mdss-dsi-h-right-border 都設定為0
qcom,mdss-dsi-v-top-border = <0>;
//通常mdss-dsi-h-top-border 都設定為0
qcom,mdss-dsi-v-bottom-border = <0>;
//通常mdss-dsi-h-bottom-border 都設定為0
qcom,mdss-dsi-bpp = <24>;
//此panel為 24 bit RGB,所以設定為 24
qcom,mdss-dsi-underflow-color = <0xff>;
//通常mdss-dsi-underflow-color 都設定為 ff
qcom,mdss-dsi-border-color = <0>;
//通常 mdss-dsi-border-color 都設定為 0
qcom,mdss-dsi-on-command = [
05 01 00 00 C8 00 02 11 00
39 01 00 00 00 00 04 B9 FF 83 63
39 01 00 00 00 00 0E BA 80 00 10 08 08 10 7C 6E 6D 0A 01 80 43
15 01 00 00 00 00 02 36 00
15 01 00 00 05 00 02 3A 70
39 01 00 00 00 00 0D B1 78 24 04 02 02 03 10 10 34 3C 3F 3F
39 01 00 00 00 00 0A B4 00 08 6E 07 01 01 62 01 57
15 01 00 00 00 00 02 CC 0B
39 01 00 00 05 00 1F E0 01 48 4D 4E 58 F6 0B 4E 12 D5 15 95
55 8E 11 01 48 4D 55 5F FD 0A 4E 51 D3 17 95 96 4E 11
05 01 00 00 32 00 02 29 00
]; //follow spec
// mdss-dsi-on-command 要根據 panel data sheet page 30
(power-on sequence)
//來做設定
qcom,mdss-dsi-off-command = [05 01 00 00 05 00 02 28 00
05 01 00 00 78 00 02 10 00]; //follow spec
// mdss-dsi-off-command 要根據 panel data sheet page 33
(power-off sequence)
//來做設定
qcom,mdss-dsi-on-command-state = "dsi_lp_mode";
//mdss-dsi-on-command 通常都是在 lp mode傳送
qcom,mdss-dsi-off-command-state = "dsi_lp_mode";
//mdss-dsi-off-command 通常都是在 lp mode傳送

qcom,mdss-dsi-h-sync-pulse = <1>;
//可以設定的值有,這個設定要跟供應商確定,此panel是設定為 1
// 0 = Don't send hsa/he following vs/ve packet(default)
// 1 = Send hsa/he following vs/ve packet
//
qcom,mdss-dsi-traffic-mode = "non_burst_sync_pulse";
//此panel設定為 sync pulses mode
//所以 mdss-dsi-on-command中有一行,要設定為
//39 01 00 00 00 00 0E BA 80 00 10 08 08 10 7C 6E 6D 0A 01 80 43

qcom,mdss-dsi-lane-map = "lane_map_0123";
//lane的順序,跟HW連接有關,通常設定為 "lane_map_0123"

qcom,mdss-dsi-bllp-eof-power-mode;
//Boolean to determine DSI lane state during
//blanking low power period (BLLP) EOF mode.
//通常都會加設此設定

qcom,mdss-dsi-bllp-power-mode;
//通常都會加設此設定

qcom,mdss-dsi-lane-0-state; // 2 data lanes use only
qcom,mdss-dsi-lane-1-state;
//因此panel data lane只用到 2 lanes所以設定 0 與 1
qcom,mdss-dsi-panel-timings = [66 12 0C 00 34 34 0F 16 0E 03 04
00];
//mdss-dsi-panel-timings根據 Qualcomm (ortus) -80-NH713-1 DSI
TIMING PARAMETERS USER INTERACTIVE SPREADSHEET.xlsm
//去計算出來的

qcom,mdss-dsi-t-clk-post = <0x04>;
//根據 panel data sheet T clk_post去做設定,此panel設定為 0x04

qcom,mdss-dsi-t-clk-pre = <0x1b>;
////根據 panel data sheet T clk_pre 去做設定,此panel設定為 0x1b

qcom,mdss-dsi-bl-min-level = <1>;
qcom,mdss-dsi-bl-max-level = <4095>;
//設定背光亮度最大與最小值

qcom,mdss-dsi-dma-trigger = "trigger_sw";
//Specifies the trigger mechanism to be used for DMA path.
// "none" = no trigger
// "trigger_te" = Tear check signal line used for
trigger
// "trigger_sw" = Triggered by software (default)
// "trigger_sw_seof" = Software trigger and
start/end of frame trigger.
// "trigger_sw_te" = Software trigger and TE
//通常設定為 "trigger_sw"

qcom,mdss-dsi-mdp-trigger = "none";
//指定 mdp trigger方式,可設定的值有
// "none" = no trigger
// "trigger_te" = Tear check signal line used for
trigger
// "trigger_sw" = Triggered by software (default)
// "trigger_sw_te" = Software trigger and TE
//通常設定為 "none"

qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
//在硬體設計是採用 mipi command控制背光,所以設定為 bl_ctrl_wled
qcom,mdss-dsi-reset-sequence = <1 20>, <0 2>, <1 20>;
//設定 reset pin的行為

qcom,mdss-dsi-min-refresh-rate = <53>;
//Minimum refresh rate supported by the panel, check panel vendor

qcom,mdss-dsi-max-refresh-rate = <60>;
//Maximum refresh rate supported by the panel,check panel vendor

};
};

CuteParrot 發表在 痞客邦 PIXNET 留言(0) 人氣()

1.取消 automatic date&time
開啟
\frameworks\base\packages\SettingsProvider\res\values\defaults.xml
改為
<bool name="def_auto_time">false</bool>

2.取消 use 24-hour format
開啟
\frameworks\base\packages\SettingsProvider\res\values\customize.xml
改為
<!-- Time format,default vlaue is 24 : 24 format,other value is 12
format -->
<string name="def_time_format" translatable="false"></string>

重新 make os image後,就會uncheck這兩個設定了

CuteParrot 發表在 痞客邦 PIXNET 留言(0) 人氣()


可以設定或取得的資訊有
http://developer.android.com/reference/android/provider/Settings.System.html

範例:

.取得目前 screen_off_timeout
shell@msm8909:/ $ settings get system screen_off_timeout
604800000

.設定 screen_off_timeout
shell@msm8909:/ $ settings put system screen_off_timeout 4800000

.取消 screen_brightness_mode , 設定背光 screen_brightness
shell@msm8909:/ $ settings put system screen_brightness_mode 0
shell@msm8909:/ $ settings put system screen_brightness 50

CuteParrot 發表在 痞客邦 PIXNET 留言(0) 人氣()



有時候在測試CTS時,在一些測項裡會有類似以下code
if (VERBOSE) Log.v(TAG, "Video snapshot is " +
  bmpOptions.outWidth + " x " + bmpOptions.outHeight +
  ", video size is " + videoWidth + " x " + videoHeight);
但是因為VERBOSE不是TRUE所以不會output logcat log
查CODE後發現有以下的code
---
public class CameraTest extends ActivityInstrumentationTestCase2<CameraCtsActivity> {
    private static String TAG = "CameraTest";
    private static final boolean VERBOSE = Log.isLoggable(TAG, Log.VERBOSE);
---                   
尤其是這一段
VERBOSE = Log.isLoggable(TAG, Log.VERBOSE);
決定VERBOSE是TRUE 或是 FALSE

而這一個屬性質可以透過 setprop來做開啟或是關閉
開啟方式為
adb shell setprop log.tag.CameraTest VERBOSE
關閉方式為
adb shell setprop log.tag.CameraTest
注意上方的CameraTest是從private static String TAG = "CameraTest";得知的

所以當開啟後,logcat終究會秀出以下的log 了
CameraTest: Video snapshot is 864 x 480, video size is 720 x 480                       



Sample:

cameratest.java
--
public class CameraTest extends ActivityInstrumentationTestCase2<CameraCtsActivity> {
    private static String TAG = "CameraTest";
    private static final String PACKAGE = "com.android.cts.hardware";
    private static final boolean VERBOSE = Log.isLoggable(TAG, Log.VERBOSE);

--
            if (VERBOSE) Log.v(TAG, "Video snapshot is " +
                    bmpOptions.outWidth + " x " + bmpOptions.outHeight +
                    ", video size is " + videoWidth + " x " + videoHeight);
--


device:
  mark@R3600:/dev/bus/usb/001$ adb shell setprop log.tag.CameraTest VERBOSE
  mark@R3600:/dev/bus/usb/001$ adb shell getprop log.tag.CameraTest
  VERBOSE
  
logcat show:
  01-01 00:53:54.446  6997  6997 V CameraTest: Video snapshot is 864 x 480, video size is 720 x 480                       

CuteParrot 發表在 痞客邦 PIXNET 留言(0) 人氣()

1 2