当前位置:  编程技术>移动开发
本页文章导读:
    ▪【玩转VLC】- ubuntu上编译vlc        【玩转VLC】--- ubuntu下编译vlc1.安装vlc依赖的库 sudo apt-get build-dep vlc 下列【新】软件包将被安装: autoconf automake autopoint autotools-dev build-essential debhelper dh-apparmor dh-autoreconf dh-buildinfo dpkg-dev g++.........
    ▪ Phone 通话界面银幕长亮        Phone 通话界面屏幕长亮 packages\apps\Phone\src\com\android\phone\InCallScreen.java 1.添加全局声明  private PowerManager.WakeLock mWakeLock;//soten cwb 2012/11/21 2.initInCallScreen方法的最后加上 //soten cwb 2012/11/21     .........
    ▪ MINI2440开发板PWM驱动与测试程序简明分析       MINI2440开发板PWM驱动与测试程序简要分析先看下电路原理图 #include <linux/module.h> #include <linux/kernel.h> #include <linux/fs.h> #include <linux/init.h> #include <linux/delay.h> #include <linu.........

[1]【玩转VLC】- ubuntu上编译vlc
    来源: 互联网  发布时间: 2014-02-18
【玩转VLC】--- ubuntu下编译vlc
1.安装vlc依赖的库
sudo apt-get build-dep vlc
下列【新】软件包将被安装:
  autoconf automake autopoint autotools-dev build-essential debhelper
  dh-apparmor dh-autoreconf dh-buildinfo dpkg-dev g++ gettext gir1.2-rsvg-2.0
  git git-man html2text intltool-debian liba52-0.7.4 liba52-0.7.4-dev
  libaa1-dev libasound2-dev libass-dev libass4 libatk1.0-dev
  libavahi-client-dev libavahi-common-dev libavc1394-dev libbluray-dev
  libbluray1 libcaca-dev libcairo-script-interpreter2 libcairo2-dev libcddb2
  libcddb2-dev libcdio-dev libcrystalhd-dev libcrystalhd3 libdbus-1-dev
  libdc1394-22-dev libdca-dev libdca0 libdirac-decoder0 libdirac-dev
  libdirac-encoder0 libdirectfb-1.2-9 libdirectfb-dev libdirectfb-extra
  libdpkg-perl libdrm-dev libdvbpsi-dev libdvbpsi7 libdvdnav-dev libdvdnav4
  libdvdread-dev libdvdread4 libebml-dev libebml3 libenca-dev libenca0
  liberror-perl libexpat1-dev libfaad-dev libfaad2 libflac-dev
  libfluidsynth-dev libfluidsynth1 libfontconfig1-dev libfreetype6-dev
  libfribidi-dev libgcrypt11-dev libgdk-pixbuf2.0-dev libgettextpo0
  libgl1-mesa-dev libglib2.0-dev libglu1-mesa-dev libgnutls-dev
  libgnutls-openssl27 libgnutlsxx27 libgpg-error-dev libgtk2.0-dev libice-dev
  libiso9660-8 libiso9660-dev libjack-dev libjack0 libjpeg-dev
  libjpeg-turbo8-dev libjpeg8-dev libkate-dev libkate1 libkms1
  liblircclient-dev liblivemedia-dev liblua5.1-0-dev libmad0 libmad0-dev
  libmatroska-dev libmatroska5 libmodplug-dev libmodplug1 libmpcdec-dev
  libmpcdec6 libmpeg2-4 libmpeg2-4-dev libmtp-dev libncurses5-dev
  libncursesw5-dev libnotify-dev libogg-dev libomxil-bellagio-bin
  libomxil-bellagio-dev libomxil-bellagio0 liborc-0.4-dev libp11-kit-dev
  libpango1.0-dev libpcre3-dev libpcrecpp0 libpixman-1-dev libpng12-dev
  libpostproc-dev libproxy-dev libpthread-stubs0 libpthread-stubs0-dev
  libpulse-dev libqt4-designer libqt4-dev libqt4-help libqt4-qt3support
  libqt4-scripttools libqt4-test libraw1394-dev libreadline-dev
  libreadline6-dev libresid-builder-dev libresid-builder0c2a librsvg2-bin
  librsvg2-dev libsamplerate0-dev libschroedinger-dev libsdl-image1.2
  libsdl-image1.2-dev libsdl1.2-dev libshout3-dev libsidplay2 libsidplay2-dev
  libslang2-dev libsm-dev libsmbclient-dev libsndfile1-dev libspeex-dev
  libspeexdsp-dev libsvga1 libsvga1-dev libswscale-dev libsysfs-dev
  libtag1-dev libtar-dev libtar0 libtasn1-3-dev libtheora-dev libtiff4-dev
  libtiffxx0c2 libtimedate-perl libtinfo-dev libtool libts-0.0-0
  libtwolame-dev libtwolame0 libudev-dev libunistring0 libupnp-dev libupnp3
  libupnp3-dev libusb-1.0-0-dev libv4l-dev libva-dev libva-egl1 libva-glx1
  libva-tpi1 libva-x11-1 libvcdinfo-dev libvcdinfo0 libvorbis-dev libx11-dev
  libx11-xcb-dev libx264-120 libx264-dev libxau-dev libxcb-composite0
  libxcb-composite0-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-randr0
  libxcb-randr0-dev libxcb-render0-dev libxcb-shape0-dev libxcb-shm0-dev
  libxcb-xfixes0 libxcb-xfixes0-dev libxcb-xv0 libxcb-xv0-dev libxcb1-dev
  libxcomposite-dev libxcursor-dev libxdamage-dev libxdmcp-dev libxext-dev
  libxfixes-dev libxft-dev libxi-dev libxinerama-dev libxml2-dev libxml2-utils
  libxpm-dev libxrandr-dev libxrender-dev libxt-dev libzvbi-common libzvbi-dev
  libzvbi0 lua5.1 m4 mesa-common-dev po-debconf qt4-linguist-tools qt4-qmake
  tsconf x11proto-composite-dev x11proto-core-dev x11proto-damage-dev
  x11proto-fixes-dev x11proto-input-dev x11proto-kb-dev x11proto-randr-dev
  x11proto-render-dev x11proto-xext-dev x11proto-xinerama-dev
  xorg-sgml-doctools xtrans-dev zlib1g-dev
下列软件包将被升级:
  libfreetype6 libpulse-mainloop-glib0 libpulse0

2.下载vlc最新代码并解压
tar xvf vlc-2.0.5.tar.xz
3.配置所需参数
可输入  查看配置帮助
./configure --help
直接运行 
./configure 
然后等待有没有错误了。
libvlc configuration
--------------------
version               : 2.0.5
system                : linux
architecture          : i686 mmx sse sse2
optimizations         : yes
vlc aliases           : cvlc rvlc svlc qvlc nvlc

To build vlc and its plugins, type `make', or `./compile' if you like nice colors.
ok了,这样就生成了makefile了。
4.编译
上一步生成的makefile,可直接编译了。
make
漫长的等待吧!
ok了,检查一下劳动成果:
ls ./lib/.libs/ -al
在lib目录下的.libs下,隐藏着编译好的库文件
 libvlc.so -> libvlc.so.5.3.1
 libvlc.so.5 -> libvlc.so.5.3.1
 libvlc.so.5.3.1
5.安装
sudo make install 
通过上面命令把编译好的vlc,安装到系统上。












    
[2] Phone 通话界面银幕长亮
    来源: 互联网  发布时间: 2014-02-18
Phone 通话界面屏幕长亮
packages\apps\Phone\src\com\android\phone\InCallScreen.java
1.添加全局声明
 private PowerManager.WakeLock mWakeLock;//soten cwb 2012/11/21

2.initInCallScreen方法的最后加上
//soten cwb 2012/11/21    
       mWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag");

3.在onResume方法的最后添加
     //soten cwb 2012/11/21
     mWakeLock.acquire();

4.在onPause方法的最后添加

     //soten cwb 2012/11/21
     mWakeLock.release();

    
[3] MINI2440开发板PWM驱动与测试程序简明分析
    来源: 互联网  发布时间: 2014-02-18
MINI2440开发板PWM驱动与测试程序简要分析

先看下电路原理图

#include <linux/module.h>

#include <linux/kernel.h>

#include <linux/fs.h>

#include <linux/init.h>

#include <linux/delay.h>

#include <linux/poll.h>

#include <linux/interrupt.h>

#include <linux/gpio.h>

 

#include <asm/irq.h>

#include <asm/io.h>

#include <asm/uaccess.h>

#include <mach/regs-gpio.h>

#include <mach/hardware.h>

#include <plat/regs-timer.h>

#include <mach/regs-irq.h>

#include <asm/mach/time.h>

#include <linux/clk.h>

#include <linux/cdev.h>

#include <linux/device.h>

#include <linux/miscdevice.h>

 

#define DEVICE_NAME     "pwm"

 

#define PWM_IOCTL_SET_FREQ              1    //设置pwm的频率

#define PWM_IOCTL_STOP                        0    //停止pwm

 

static struct semaphore lock;            

//定义信号量,此处的信号量是一个互斥信号量,用于PWM设备之多只能被一个进程打开

 

/* freq:  pclk/50/16/65536 ~ pclk/50/16

  * if pclk = 50MHz, freq is 1Hz to 62500Hz

  * human ear : 20Hz~ 20000Hz

  */

static void PWM_Set_Freq( unsigned long freq )

{

         unsigned long tcon;

         unsigned long tcnt;

         unsigned long tcfg1;

         unsigned long tcfg0;

 

         struct clk *clk_p;

         unsigned long pclk;

 

         //set GPB0 as tout0, pwm output

         s3c2410_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPB0_TOUT0);//功能配置

 

         tcon = __raw_readl(S3C2410_TCON);    //获得定时器控制寄存器的数值

         tcfg1 = __raw_readl(S3C2410_TCFG1);   //获得定时器配置寄存器0的值

         tcfg0 = __raw_readl(S3C2410_TCFG0);   //获得定时器配置寄存器1的值

 

         //prescaler = 50

         tcfg0 &= ~S3C2410_TCFG_PRESCALER0_MASK;

         tcfg0 |= (50 - 1);

 

         //mux = 1/16

         tcfg1 &= ~S3C2410_TCFG1_MUX0_MASK;

         tcfg1 |= S3C2410_TCFG1_MUX0_DIV16;

 

         __raw_writel(tcfg1, S3C2410_TCFG1);

         __raw_writel(tcfg0, S3C2410_TCFG0);

 

         clk_p = clk_get(NULL, "pclk");

         pclk  = clk_get_rate(clk_p);

         tcnt  = (pclk/50/16)/freq;

        

         __raw_writel(tcnt, S3C2410_TCNTB(0));

         __raw_writel(tcnt/2, S3C2410_TCMPB(0));

                                    

         tcon &= ~0x1f;

         tcon |= 0xb;               //disable deadzone, auto-reload, inv-off, update TCNTB0&TCMPB0, start timer 0

         __raw_writel(tcon, S3C2410_TCON);

        

         tcon &= ~2;                         //clear manual update bit

         __raw_writel(tcon, S3C2410_TCON);

}

 

static void PWM_Stop(void)

{

         s3c2410_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPIO_OUTPUT);

         s3c2410_gpio_setpin(S3C2410_GPB(0), 0);

}

 

static int s3c24xx_pwm_open(struct inode *inode, struct file *file)

{

         if (!down_trylock(&lock))//判断是否设备已经打开,已打开返回EBUSY

                   return 0;

         else

                   return -EBUSY;

}

 

 

static int s3c24xx_pwm_close(struct inode *inode, struct file *file)

{

         PWM_Stop();//停止PWM

         up(&lock);//释放信号量

    return 0;

}

 

 

static int s3c24xx_pwm_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)

{

         //printk("ioctl pwm: %x %lx\n", cmd, arg);

         switch (cmd) {

         case PWM_IOCTL_SET_FREQ:

                   if (arg == 0)

                            return -EINVAL;

                   PWM_Set_Freq(arg);

                   break;

 

         case PWM_IOCTL_STOP:

                   PWM_Stop();

                   break;

         }

 

         return 0;

}

 

 

static struct file_operations dev_fops = {

    .owner   =   THIS_MODULE,

    .open    =   s3c24xx_pwm_open,

    .release =   s3c24xx_pwm_close,

    .ioctl   =   s3c24xx_pwm_ioctl,

};

 

static struct miscdevice misc = {

         .minor = MISC_DYNAMIC_MINOR,

         .name = DEVICE_NAME,

         .fops = &dev_fops,

};

 

static int __init dev_init(void)

{

         int ret;

 

         init_MUTEX(&lock);

         ret = misc_register(&misc);

 

         printk (DEVICE_NAME"\tinitialized\n");

             return ret;

}

 

static void __exit dev_exit(void)

{

         misc_deregister(&misc);

}

 

module_init(dev_init);

module_exit(dev_exit);

MODULE_LICENSE("GPL");

MODULE_AUTHOR("FriendlyARM Inc.");

MODULE_DESCRIPTION("S3C2410/S3C2440 PWM Driver");

 

分析,这个程序的结构比较简单,只实现了open(),ioctl(),close()功能,其中最主要的就是ioctl()功能,在ioctl()中最重要的核心函数为static void PWM_Set_Freq( unsigned long freq );所以说只要分析懂了这个函数,这个驱动也都全懂了。要是做过这个裸机程序的就更简单了。里面出现的一些没分析的,在本博客另一篇LED驱动分析中基本都说过了,不清楚的可以去看那个。

首先分析static void PWM_Set_Freq( unsigned long freq );

static void PWM_Set_Freq( unsigned long freq )

{

         unsigned long tcon;

         unsigned long tcnt;

         unsigned long tcfg1;

         unsigned long tcfg0;

 

         struct clk *clk_p;

         unsigned long pclk;

 

         //set GPB0 as tout0, pwm output

         s3c2410_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPB0_TOUT0);//功能配置

 

         tcon = __raw_readl(S3C2410_TCON);    //获得定时器控制寄存器的数值

         tcfg1 = __raw_readl(S3C2410_TCFG1);   //获得定时器配置寄存器0的值

         tcfg0 = __raw_readl(S3C2410_TCFG0);   //获得定时器配置寄存器1的值

 

         //prescaler = 50

         tcfg0 &= ~S3C2410_TCFG_PRESCALER0_MASK;

         tcfg0 |= (50 - 1);

    //上面的两句是设置预分频器

         //mux = 1/16

         tcfg1 &= ~S3C2410_TCFG1_MUX0_MASK;

         tcfg1 |= S3C2410_TCFG1_MUX0_DIV16;

    //上面两句设置MUX0

         __raw_writel(tcfg1, S3C2410_TCFG1);

         __raw_writel(tcfg0, S3C2410_TCFG0);

    //上面两句将配置好的数值写入到配置寄存器

         clk_p = clk_get(NULL, "pclk");

         pclk  = clk_get_rate(clk_p);

    //上面两句用于获取PCLK

         tcnt  = (pclk/50/16)/freq;

         //上面这个数值决定了频率,

         __raw_writel(tcnt, S3C2410_TCNTB(0));

         __raw_writel(tcnt/2, S3C2410_TCMPB(0));

         //上面两句将tcnt寄存器写入到TCNTB0,同时设置S3C2410_TCMPB0,也就是说占空比为50%                       

         tcon &= ~0x1f;    //低五位清零

         tcon |= 0xb;               //disable deadzone, auto-reload, inv-off, update TCNTB0&TCMPB0, start timer 0

         __raw_writel(tcon, S3C2410_TCON);

        

         tcon &= ~2;                         //clear manual update bit

         __raw_writel(tcon, S3C2410_TCON);

}

看几个宏定义:

#define S3C2410_TCFG_PRESCALER0_MASK (255<<0)    //0xff<<0

#define S3C2410_TCFG1_MUX0_MASK   (15<<0)       //0xf<<0

#define S3C2410_TCFG1_MUX0_DIV16  (3<<0)       

 

分析:static void PWM_Stop(void)

static void PWM_Stop(void)

{

         s3c2410_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPIO_OUTPUT);//配置管脚为输出状态

         s3c2410_gpio_setpin(S3C2410_GPB(0), 0);                  //设置管脚为低电平输出

}

 

以下是测试程序

#include <stdio.h>

#include <termios.h>

#include <unistd.h>

#include <stdlib.h>

 

#define PWM_IOCTL_SET_FREQ              1

#define PWM_IOCTL_STOP                        0

 

#define     ESC_KEY            0x1b

 

static int getch(void)

{

         struct termios oldt,newt;

         int ch;

 

         if (!isatty(STDIN_FILENO)) {

                   fprintf(stderr, "this problem should be run at a terminal\n");

                   exit(1);

         }

         // save terminal setting

         if(tcgetattr(STDIN_FILENO, &oldt) < 0) {

                   perror("save the terminal setting");

                   exit(1);

         }

 

         // set terminal as need

         newt = oldt;

         newt.c_lflag &= ~( ICANON | ECHO );

         if(tcsetattr(STDIN_FILENO,TCSANOW, &newt) < 0) {

                   perror("set terminal");

                   exit(1);

         }

 

         ch = getchar();

 

         // restore termial setting

         if(tcsetattr(STDIN_FILENO,TCSANOW,&oldt) < 0) {

                   perror("restore the termial setting");

                   exit(1);

         }

         return ch;

}

 

static int fd = -1;

static void close_buzzer(void);

static void open_buzzer(void)

{

         fd = open("/dev/pwm", 0);

         if (fd < 0) {

                   perror("open pwm_buzzer device");

                   exit(1);

         }

 

         // any function exit call will stop the buzzer

         atexit(close_buzzer);

}

 

static void close_buzzer(void)

{

         if (fd >= 0) {

                   ioctl(fd, PWM_IOCTL_STOP);

                   close(fd);

                   fd = -1;

         }

}

 

static void set_buzzer_freq(int freq)

{

         // this IOCTL command is the key to set frequency

         int ret = ioctl(fd, PWM_IOCTL_SET_FREQ, freq);

         if(ret < 0) {

                   perror("set the frequency of the buzzer");

                   exit(1);

         }

}

static void stop_buzzer(void)

{

         int ret = ioctl(fd, PWM_IOCTL_STOP);

         if(ret < 0) {

                   perror("stop the buzzer");

                  exit(1);

         }

}

 

int main(int argc, char **argv)

{

         int freq = 1000 ;

        

         open_buzzer();

 

         printf( "\nBUZZER TEST ( PWM Control )\n" );

         printf( "Press +/- to increase/reduce the frequency of the BUZZER\n" ) ;

         printf( "Press 'ESC' key to Exit this program\n\n" );

        

        

         while( 1 )

         {

                   int key;

 

                   set_buzzer_freq(freq);

                   printf( "\tFreq = %d\n", freq );

 

                   key = getch();

 

                   switch(key) {

                   case '+':

                            if( freq < 20000 )

                                     freq += 10;

                            break;

 

                   case '-':

                            if( freq > 11 )

                                     freq -= 10 ;

                            break;

 

                   case ESC_KEY:

                   case EOF:

                            stop_buzzer();

                            exit(0);

 

                   default:

                            break;

                   }

         }

}

通过调用ioctl函数实现控制PWM的频率以及关闭PWM.

1楼hshhduuduj4天前 22:05这里面好像没有实现占空比的改变,我现在想实现占空比改变,怎么搞?请教Re: ssdsafsdsd4天前 22:11回复hshhduudujn __raw_writel(tcnt/2, S3C2410_TCMPB(0));n这个是控制占空比的,根据你的需要仿照上面的设置频率的函数写个调整占空比的函数,不难。。。

    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3