2019-07-04 18:47:56 endkillerym 阅读数 336

linux工作环境配置

linux工作环境下常用的配置包括**.cshrc**, .vimrc, .dir_colors.

-.cshrc配置terminal显示
-.vimrc配置vi显示
-.dir_colors配置文件夹显示


.cshrc配置

source ~/yum.cfg

  • yum.cfg
    alias project 'cd ~/projects/pro1'

.vimrc配置

set nu
colorscheme murphy

.dir_colors配置

## DIR 01;34
DIR 01;37;44

2018-05-02 15:57:07 ywcpig 阅读数 874

1. 查看Linux操作系统信息:

uname -a

cat /proc/version

lsb_release -a

 

2. 设置ls显示的文件夹的颜色(将下面这条目录加在 .bashrc 文件最后):

LS_COLORS=$LS_COLORS:'di=0;35:' ; export LS_COLORS

(All possible colors:
31  = red
32  = green
33  = orange
34  = blue
35  = purple
36  = cyan
37  = grey
90  = dark grey
91  = light red
92  = light green
93  = yellow
94  = light blue
95  = light purple
96  = turquoise

97  = white)

 

3. 在远程服务器X Server上显示图形界面

ssh -x uname@ip

 

4. 强制转换图像大小

convert -resize 1056x640! 000456.jpg 000456_640_1056.jpg

 

5. 查看图像信息

file 000456_640_1056.jpg

identify 000456_640_1056.jpg

 

6. 查看物理CPU的个数

cat /proc/cpuinfo |grep "physical id"|sort |uniq|wc -l 

 

7. 查看逻辑CPU的个数

cat /proc/cpuinfo |grep "processor"|wc -l 

 

8. 查看一个物理CPU是几核

cat /proc/cpuinfo |grep "cores"|uniq

 

9. 查看当前目录大小

du -h --max-depth=1 ./

2013-08-17 14:23:34 u011698971 阅读数 449

localhost~# cat /etc/DIR_COLORS
# Configuration file for the color ls utility
#
# This file goes in the /etc directory, and must be world readable.
# You can copy this file to .dir_colors in your $HOME directory to override
# the system defaults.

# COLOR needs one of these arguments: 'tty' colorizes output to ttys, but not
# pipes. 'all' adds color characters to all output. 'none' shuts colorization
# off.
COLOR tty

# Extra command line options for ls go here.
# Basically these ones are:
#  -F = show '/' for dirs, '*' for executables, etc.
#  -T 0 = don't trust tab spacing when formatting ls output.
OPTIONS -F -T 0

# Below, there should be one TERM entry for each termtype that is colorizable
TERM linux
TERM linux-c
TERM console
TERM con132x25
TERM con132x30
TERM con132x43
TERM con132x60
TERM con80x25
TERM con80x28
TERM con80x30
TERM con80x43
TERM con80x50
TERM con80x60
TERM gnome
TERM mach-color
TERM rxvt
TERM rxvt-unicode
TERM screen
TERM screen-w
TERM screen-256color
TERM vt100
TERM vt102
TERM xterm
TERM xterm-debian
TERM xterm-256color
TERM iterm

# EIGHTBIT, followed by '1' for on, '0' for off. (8-bit output)
EIGHTBIT 1

# Below are the color init strings for the basic file types. A color init
# string consists of one or more of the following numeric codes:
#
# Attribute codes:
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white

NORMAL 00       # global default, although everything should be something.
FILE   00       # normal file
DIR    01;34    # directory
LINK   00;36    # symbolic link
FIFO   40;33    # pipe
SOCK   01;35    # socket
DOOR   01;35    # door
BLK    40;33;01 # block device driver
CHR    40;33;01 # character device driver
ORPHAN 41;33;01 # symlink to nonexistent file

# This is for files with execute permission:
EXEC 00;32

# List any file extensions like '.gz' or '.tar' that you would like ls
# to colorize below. Put the extension, a space, and the color init string.
# (and any comments you want to add after a '#')

# executables (bright green)
.cmd  00;32
.exe  01;32
.com  01;32
.bat  01;32
.btm  01;32
.dll  01;32

# archives or compressed
.tar  00;31
.tbz  00;31
.tgz  00;31
.rpm  00;31
.deb  00;31
.arj  00;31
.taz  00;31
.lzh  00;31
.lzma 00;31
.zip  00;31
.zoo  00;31
.z    00;31
.Z    00;31
.gz   00;31
.bz2  00;31
.tb2  00;31
.tz2  00;31
.tbz2 00;31

# image formats
.avi  01;35
.bmp  01;35
.fli  01;35
.gif  01;35
.jpg  01;35
.jpeg 01;35
.mng  01;35
.mov  01;35
.mpg  01;35
.pcx  01;35
.pbm  01;35
.pgm  01;35
.png  01;35
.ppm  01;35
.tga  01;35
.tif  01;35
.xbm  01;35
.xpm  01;35
.dl   01;35
.gl   01;35
.wmv  01;35

# sound formats
.aiff 00;32
.au   00;32
.mid  00;32
.mp3  00;32
.ogg  00;32
.voc  00;32
.wav  00;32

 

2012-05-08 21:03:55 yyplc 阅读数 3511

====本文系本站原创,欢迎转载! 转载请注明出处:http://blog.csdn.net/yyplc====
内核版本:linux-2.6.30.4

Linux源码包中/document/fb/framebuffer.txt有如下介绍:

The frame buffer device provides an abstraction for the graphics hardware. It represents the frame buffer of some video hardware and allows application software to access the graphics hardware through a well-defined interface, so the software doesn't need to know anything about the low-level (hardware register) stuff.

Frame buffer机制为图形显示卡提供了一个抽象层。可以使得应用程序不用考虑底层硬件的实现细节而通过一些API接口即可访问到显示设备。  但Framebuffer本身不具备任何运算数据的能力,就只好比是一个暂时存放水的水池。水池里的水就是显示的东西。CPU将运算后的结果放到这个水池,水池再将结果流到显示器(通常通过DMA传输). 所以应用程序通过读写这个水池,即可相当于操作了显示卡。系统中可以在/dev/fb*看到framebuffer设备。下面这幅图很好的描述了framebuffer运行机制:


framebuffer子系统的层次结构:



上图主要在下面文件中:

drivers/vedio/fbmem.c   该文件是framebuffer实现的核心,与硬件无关

drivers/vedio/xxxfb.c     该文件主要是framebuffer 设备驱动的实现,如s3c2410fb.c实现了framebuffer设备驱动

fbmem.c是实现framebuffer的核心,与硬件无关。它使用了以下这些数据结构:

struct fb_info   *fb_info    该数据结构描述了一个framebuffer device相关一系列信息
struct fb_ops   *fb_ops      该数据结构描述了一个framebuffer device的操作函数集合,类似file_operations,但只供内核使用
static const struct file_operations fb_fops   该数据结构为文件操作函数集合,当应用程序打开设备时,用户可以read,write,ioctl等
struct fb_var_screeninfo var      该数据结构描述了framebuffer device显示特性,是可以更改的
struct fb_fix_screeninfo fix        该数据结构用于保存framebuffer device显示特性,是固定不变的,不可以更改

具体数据结构:

struct fb_var_screeninfo {
	__u32 xres;			/* visible resolution		*/
	__u32 yres;
	__u32 xres_virtual;		/* virtual resolution		*/
	__u32 yres_virtual;
	__u32 xoffset;			/* offset from virtual to visible */
	__u32 yoffset;			/* resolution			*/

	__u32 bits_per_pixel;		/* guess what			*/
	__u32 grayscale;		/* != 0 Graylevels instead of colors */

	struct fb_bitfield red;		/* bitfield in fb mem if true color, */
	struct fb_bitfield green;	/* else only length is significant */
	struct fb_bitfield blue;
	struct fb_bitfield transp;	/* transparency			*/	

	__u32 nonstd;			/* != 0 Non standard pixel format */

	__u32 activate;			/* see FB_ACTIVATE_*		*/

	__u32 height;			/* height of picture in mm    */
	__u32 width;			/* width of picture in mm     */

	__u32 accel_flags;		/* (OBSOLETE) see fb_info.flags */

	/* Timing: All values in pixclocks, except pixclock (of course) */
	__u32 pixclock;			/* pixel clock in ps (pico seconds) */
	__u32 left_margin;		/* time from sync to picture	*/
	__u32 right_margin;		/* time from picture to sync	*/
	__u32 upper_margin;		/* time from sync to picture	*/
	__u32 lower_margin;
	__u32 hsync_len;		/* length of horizontal sync	*/
	__u32 vsync_len;		/* length of vertical sync	*/
	__u32 sync;			/* see FB_SYNC_*		*/
	__u32 vmode;			/* see FB_VMODE_*		*/
	__u32 rotate;			/* angle we rotate counter clockwise */
	__u32 reserved[5];		/* Reserved for future compatibility */
};

struct fb_fix_screeninfo {
	char id[16];			/* identification string eg "TT Builtin" */
	unsigned long smem_start;	/* Start of frame buffer mem */
					/* (physical address) */
	__u32 smem_len;			/* Length of frame buffer mem */
	__u32 type;			/* see FB_TYPE_*		*/
	__u32 type_aux;			/* Interleave for interleaved Planes */
	__u32 visual;			/* see FB_VISUAL_*		*/ 
	__u16 xpanstep;			/* zero if no hardware panning  */
	__u16 ypanstep;			/* zero if no hardware panning  */
	__u16 ywrapstep;		/* zero if no hardware ywrap    */
	__u32 line_length;		/* length of a line in bytes    */
	unsigned long mmio_start;	/* Start of Memory Mapped I/O   */
					/* (physical address) */
	__u32 mmio_len;			/* Length of Memory Mapped I/O  */
	__u32 accel;			/* Indicate to driver which	*/
					/*  specific chip/card we have	*/
	__u16 reserved[3];		/* Reserved for future compatibility */
};

struct fb_info {
	int node;
	int flags;
	struct mutex lock;		/* Lock for open/release/ioctl funcs */
	struct fb_var_screeninfo var;	/* Current var */
	struct fb_fix_screeninfo fix;	/* Current fix */
	struct fb_monspecs monspecs;	/* Current Monitor specs */
	struct work_struct queue;	/* Framebuffer event queue */
	struct fb_pixmap pixmap;	/* Image hardware mapper */
	struct fb_pixmap sprite;	/* Cursor hardware mapper */
	struct fb_cmap cmap;		/* Current cmap */
	struct list_head modelist;      /* mode list */
	struct fb_videomode *mode;	/* current mode */
        ...
	struct fb_ops *fbops;
	struct device *device;		/* This is the parent */
	struct device *dev;		/* This is this fb device */
	int class_flag;                    /* private sysfs flags */
#ifdef CONFIG_FB_TILEBLITTING
	struct fb_tile_ops *tileops;    /* Tile Blitting */
#endif
	char __iomem *screen_base;	/* Virtual address */
	unsigned long screen_size;	/* Amount of ioremapped VRAM or 0 */ 
	void *pseudo_palette;		/* Fake palette of 16 colors */ 
        ...
};
struct fb_ops {
	/* open/release and usage marking */
	struct module *owner;
	int (*fb_open)(struct fb_info *info, int user);
	int (*fb_release)(struct fb_info *info, int user);

	/* For framebuffers with strange non linear layouts or that do not
	 * work with normal memory mapped access
	 */
	ssize_t (*fb_read)(struct fb_info *info, char __user *buf,
			   size_t count, loff_t *ppos);
	ssize_t (*fb_write)(struct fb_info *info, const char __user *buf,
			    size_t count, loff_t *ppos);

	/* checks var and eventually tweaks it to something supported,
	 * DO NOT MODIFY PAR */
	int (*fb_check_var)(struct fb_var_screeninfo *var, struct fb_info *info);

	/* set the video mode according to info->var */
	int (*fb_set_par)(struct fb_info *info);

	/* set color register */
	int (*fb_setcolreg)(unsigned regno, unsigned red, unsigned green,
			    unsigned blue, unsigned transp, struct fb_info *info);

	/* set color registers in batch */
	int (*fb_setcmap)(struct fb_cmap *cmap, struct fb_info *info);

	/* blank display */
	int (*fb_blank)(int blank, struct fb_info *info);

	/* pan display */
	int (*fb_pan_display)(struct fb_var_screeninfo *var, struct fb_info *info);

	/* Draws a rectangle */
	void (*fb_fillrect) (struct fb_info *info, const struct fb_fillrect *rect);
	/* Copy data from area to another */
	void (*fb_copyarea) (struct fb_info *info, const struct fb_copyarea *region);
	/* Draws a image to the display */
	void (*fb_imageblit) (struct fb_info *info, const struct fb_image *image);

	/* Draws cursor */
	int (*fb_cursor) (struct fb_info *info, struct fb_cursor *cursor);

	/* Rotates the display */
	void (*fb_rotate)(struct fb_info *info, int angle);

	/* wait for blit idle, optional */
	int (*fb_sync)(struct fb_info *info);

	/* perform fb specific ioctl (optional) */
	int (*fb_ioctl)(struct fb_info *info, unsigned int cmd,
			unsigned long arg);

	/* Handle 32bit compat ioctl (optional) */
	int (*fb_compat_ioctl)(struct fb_info *info, unsigned cmd,
			unsigned long arg);

	/* perform fb specific mmap */
	int (*fb_mmap)(struct fb_info *info, struct vm_area_struct *vma);

	/* save current hardware state */
	void (*fb_save_state)(struct fb_info *info);

	/* restore saved state */
	void (*fb_restore_state)(struct fb_info *info);

	/* get capability given var */
	void (*fb_get_caps)(struct fb_info *info, struct fb_blit_caps *caps,
			    struct fb_var_screeninfo *var);
};

static const struct file_operations fb_fops = {
	.owner =	THIS_MODULE,
	.read =		fb_read,
	.write =	fb_write,
	.check_flags = my_check,
	.unlocked_ioctl = fb_ioctl,
#ifdef CONFIG_COMPAT
	.compat_ioctl = fb_compat_ioctl,
#endif
	.mmap =		fb_mmap,
	.open =		fb_open,
	.release =	fb_release,
#ifdef HAVE_ARCH_FB_UNMAPPED_AREA
	.get_unmapped_area = get_fb_unmapped_area,
#endif
#ifdef CONFIG_FB_DEFERRED_IO
	.fsync =	fb_deferred_io_fsync,
#endif
};

framebuffer设备的注册与注销:

register_framebuffer(struct fb_info *fb_info);

unregister_framebuffer(struct fb_info *fb_info);

根据文件操作的static const struct file_operations fb_fops,应用程序在打开一个framebuffer设备时,可以使用read,write,ioctl来直接操作设备。

应用例程:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <fcntl.h>        
#include <linux/fb.h>
#include <sys/mman.h>

struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;

static void fb_var_printf(struct fb_var_screeninfo tmp)
{


	printf("fb_var_screeninfo:\n");
	printf("xres =%d, yres =%d, bits_per_pixel = %d\n",tmp.xres,tmp.yres,tmp.bits_per_pixel);
	printf("height=%d,width = %d\n",tmp.height,tmp.width);
	printf("xres_virtual =%d, yres_virtual =%d, xoffset=%d,yoffset=%d\n",tmp.xres_virtual,tmp.yres_virtual,tmp.xoffset,tmp.yoffset);
	return ;
}
int main(void)
{
	int fbfd;
	int fbsize;
	unsigned char *fbbuf;
   	char buf[100];
	int i,res,adc_data;
	for (i=0; i<100; i++) buf[i] = 0xaa;
	if ((fbfd = open("/dev/fb0", O_RDWR)) < 0) {
            printf("open fb0 failed\n");
	     return 1;
	}
	printf("fbfd = %d\n", fbfd);
	if ((res =ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo))) { //获取设备显示特性信息
		printf("bad vscreeninfo ioctl.error = %d\n",res);
	}

	fb_var_printf(vinfo);
	fbsize = vinfo.xres * vinfo.yres * (vinfo.bits_per_pixel/8); //计算显卡(LCD控制器)显存大小,也就是一整屏共占多少个字节
	printf("fbisze: %d\n",fbsize);
	if ((fbbuf = mmap(0, fbsize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0)) == (void*) -1)  //映射显卡设备的内存到用户控件,使得用户直接访问设备内存(显存)
	{
		printf("map video error.\n");
	}
	
	for (i = 0; i< fbsize; i++) {  //填充farmebuffer缓冲区
		*(fbbuf+i) = 0xaa;  //颜色信息
	}
	munmap(fbbuf, fbsize);       
	close(fbfd);
	return 0;
}

2012-03-14 13:23:45 fjb2080 阅读数 1697
第一种方法:
首先需要制作一张*.png的图片,该格式的图片可以用PS进行另存为即可。然后在Linux系统下执行以下命令
$ pngtopnm linux_logo.png > linux_logo.pnm
$ pnmquant 224 linux_logo.pnm > linux_logo_224.pnm
  ppmquant:making histogram...
  ppmquant:24431 colors found
  ppmquant:choosing 224 colors...
  ppmquant:mapping image to new colors...
$ pnmtoplainpnm linux_logo_224.pnm > linux_logo.ppm

第二种方法:
首先需要制作一张*.bmp的图片
 $bmptoppm linux_logo.bmp > linux_logo.ppm
  bmptoppm:Windows BMP, 320*240*24
 $ppmquant 224 linux_logo.ppm > linux_logo_224.ppm
  ppmquant:making histogram...
  ppmquant:24431 colors found
  ppmquant:choosing 224 colors...
  ppmquant:mapping image to new colors...
 $pnmnoraw linux_logo_224.ppm > linux_logo.ppm


这样logo就已经制作成功了,将linux_logo.ppm拷贝到/drivers/video/logo文件夹中即可,记得要替换相关的ppm文件


2.

在内核目录中 make menuconfig

        Device Drivers ---->   Graphics support ---->

        选中 Bootup logo ----> Standard 224-color Linux logo


linux的环境变量

阅读数 1693

没有更多推荐了,返回首页