xf86-video-intel源码分析4 —— intel_options.c和intel_options.h(1)
admin
2024-02-14 10:35:22
0

intel_options.h

intel_options.h位于src目录下,内容为:

#define INTEL_OPTIONS_H#include 
#include 
#include /** Note: "ColorKey" is provided for compatibility with the i810 driver.* However, the correct option name is "VideoKey".  "ColorKey" usually* refers to the tranparency key for 8+24 overlays, not for video overlays.*/enum intel_options {OPTION_ACCEL_ENABLE,OPTION_ACCEL_METHOD,OPTION_BACKLIGHT,OPTION_EDID,OPTION_DRI,OPTION_PRESENT,OPTION_VIDEO_KEY,OPTION_COLOR_KEY,OPTION_TILING_2D,OPTION_TILING_FB,OPTION_ROTATION,OPTION_VSYNC,OPTION_PAGEFLIP,OPTION_SWAPBUFFERS_WAIT,OPTION_TRIPLE_BUFFER,OPTION_PREFER_OVERLAY,OPTION_HOTPLUG,OPTION_REPROBE,
#if defined(XvMCExtension) && defined(ENABLE_XVMC)OPTION_XVMC,
#define INTEL_XVMC 1
#endif
#ifdef USE_SNAOPTION_ZAPHOD,OPTION_VIRTUAL,OPTION_TEAR_FREE,OPTION_CRTC_PIXMAPS,
#endif
#ifdef USE_UXAOPTION_FALLBACKDEBUG,OPTION_DEBUG_FLUSH_BATCHES,OPTION_DEBUG_FLUSH_CACHES,OPTION_DEBUG_WAIT,OPTION_BUFFER_CACHE,
#endifNUM_OPTIONS,
};extern const OptionInfoRec intel_options[];
OptionInfoPtr intel_options_get(ScrnInfoPtr scrn);
unsigned intel_option_cast_to_unsigned(OptionInfoPtr, int id, unsigned val);
Bool intel_option_cast_to_bool(OptionInfoPtr, int id, Bool val);#endif /* INTEL_OPTIONS_H */

intel_options.h中包括了一些枚举值以及函数声明,下边分析intel_options.c时再做详细说明。

同时,根据它包含的头文件(#include )可以看到,它是与xorg-server强相关的。

intel_options.c

intel_options.c同样位于src目录下,内容如下:

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif#include 
#include 
#include #include "intel_options.h"const OptionInfoRec intel_options[] = {{OPTION_ACCEL_ENABLE,	"Accel",	OPTV_BOOLEAN,	{0},	0},{OPTION_ACCEL_METHOD,	"AccelMethod",	OPTV_STRING,	{0},	0},{OPTION_BACKLIGHT,	"Backlight",	OPTV_STRING,	{0},	0},{OPTION_EDID,		"CustomEDID",	OPTV_STRING,	{0},	0},{OPTION_DRI,		"DRI",		OPTV_STRING,	{0},	0},{OPTION_PRESENT,	"Present",	OPTV_BOOLEAN,	{0},	1},{OPTION_COLOR_KEY,	"ColorKey",	OPTV_INTEGER,	{0},	0},{OPTION_VIDEO_KEY,	"VideoKey",	OPTV_INTEGER,	{0},	0},{OPTION_TILING_2D,	"Tiling",	OPTV_BOOLEAN,	{0},	1},{OPTION_TILING_FB,	"LinearFramebuffer",	OPTV_BOOLEAN,	{0},	0},{OPTION_ROTATION,	"HWRotation",	OPTV_BOOLEAN,	{0},	1},{OPTION_VSYNC,		"VSync",	OPTV_BOOLEAN,	{0},	1},{OPTION_PAGEFLIP,	"PageFlip",	OPTV_BOOLEAN,	{0},	1},{OPTION_SWAPBUFFERS_WAIT, "SwapbuffersWait", OPTV_BOOLEAN,	{0},	1},{OPTION_TRIPLE_BUFFER,	"TripleBuffer", OPTV_BOOLEAN,	{0},	1},{OPTION_PREFER_OVERLAY, "XvPreferOverlay", OPTV_BOOLEAN, {0}, 0},{OPTION_HOTPLUG,	"HotPlug",	OPTV_BOOLEAN,	{0},	1},{OPTION_REPROBE,	"ReprobeOutputs", OPTV_BOOLEAN,	{0},	0},
#ifdef INTEL_XVMC{OPTION_XVMC,		"XvMC",		OPTV_BOOLEAN,	{0},	1},
#endif
#ifdef USE_SNA{OPTION_ZAPHOD,		"ZaphodHeads",	OPTV_STRING,	{0},	0},{OPTION_VIRTUAL,	"VirtualHeads",	OPTV_INTEGER,	{0},	0},{OPTION_TEAR_FREE,	"TearFree",	OPTV_BOOLEAN,	{0},	0},{OPTION_CRTC_PIXMAPS,	"PerCrtcPixmaps", OPTV_BOOLEAN,	{0},	0},
#endif
#ifdef USE_UXA{OPTION_FALLBACKDEBUG,	"FallbackDebug",OPTV_BOOLEAN,	{0},	0},{OPTION_DEBUG_FLUSH_BATCHES, "DebugFlushBatches", OPTV_BOOLEAN, {0}, 0},{OPTION_DEBUG_FLUSH_CACHES, "DebugFlushCaches", OPTV_BOOLEAN, {0}, 0},{OPTION_DEBUG_WAIT, "DebugWait", OPTV_BOOLEAN, {0}, 0},{OPTION_BUFFER_CACHE,	"BufferCache",	OPTV_BOOLEAN,   {0},    1},
#endif{-1,			NULL,		OPTV_NONE,	{0},	0}
};OptionInfoPtr intel_options_get(ScrnInfoPtr scrn)
{OptionInfoPtr options;xf86CollectOptions(scrn, NULL);if (!(options = malloc(sizeof(intel_options))))return NULL;memcpy(options, intel_options, sizeof(intel_options));xf86ProcessOptions(scrn->scrnIndex, scrn->options, options);return options;
}Bool intel_option_cast_to_bool(OptionInfoPtr options, int id, Bool val)
{
#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,7,99,901,0)xf86getBoolValue(&val, xf86GetOptValString(options, id));
#endifreturn val;
}static int
namecmp(const char *s1, const char *s2)
{char c1, c2;if (!s1 || *s1 == 0) {if (!s2 || *s2 == 0)return 0;elsereturn 1;}while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')s1++;while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')s2++;c1 = isupper(*s1) ? tolower(*s1) : *s1;c2 = isupper(*s2) ? tolower(*s2) : *s2;while (c1 == c2) {if (c1 == '\0')return 0;s1++;while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')s1++;s2++;while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')s2++;c1 = isupper(*s1) ? tolower(*s1) : *s1;c2 = isupper(*s2) ? tolower(*s2) : *s2;}return c1 - c2;
}unsigned intel_option_cast_to_unsigned(OptionInfoPtr options, int id, unsigned val)
{
#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,7,99,901,0)const char *str = xf86GetOptValString(options, id);
#elseconst char *str = NULL;
#endifunsigned v;if (str == NULL || *str == '\0')return val;if (namecmp(str, "on") == 0)return val;if (namecmp(str, "true") == 0)return val;if (namecmp(str, "yes") == 0)return val;if (namecmp(str, "0") == 0)return 0;if (namecmp(str, "off") == 0)return 0;if (namecmp(str, "false") == 0)return 0;if (namecmp(str, "no") == 0)return 0;v = atoi(str);if (v)return v;return val;
}
  • OptionInfoRec结构

OptionInfoRec结构在xf86-video-intel源码路径下是无法搜索到其定义的,也就是说它实际上属于其它包。在/usr/include/下搜索,可以看到其在/usr/include/xorg/xf86Opt.h文件中,如下所示:

$ sudo grep -rn "OptionInfoRec" /usr/include/
/usr/include/xorg/xf86Opt.h:71:} OptionInfoRec, *OptionInfoPtr;
/usr/include/xorg/xf86Opt.h:121:extern _X_EXPORT OptionInfoPtr xf86TokenToOptinfo(const OptionInfoRec * table,
/usr/include/xorg/xf86Opt.h:123:extern _X_EXPORT const char *xf86TokenToOptName(const OptionInfoRec * table,
/usr/include/xorg/xf86Opt.h:125:extern _X_EXPORT Bool xf86IsOptionSet(const OptionInfoRec * table, int token);
/usr/include/xorg/xf86Opt.h:126:extern _X_EXPORT const char *xf86GetOptValString(const OptionInfoRec * table,
/usr/include/xorg/xf86Opt.h:128:extern _X_EXPORT Bool xf86GetOptValInteger(const OptionInfoRec * table,
/usr/include/xorg/xf86Opt.h:130:extern _X_EXPORT Bool xf86GetOptValULong(const OptionInfoRec * table, int token,
/usr/include/xorg/xf86Opt.h:132:extern _X_EXPORT Bool xf86GetOptValReal(const OptionInfoRec * table, int token,
/usr/include/xorg/xf86Opt.h:134:extern _X_EXPORT Bool xf86GetOptValFreq(const OptionInfoRec * table, int token,
/usr/include/xorg/xf86Opt.h:137:extern _X_EXPORT Bool xf86GetOptValBool(const OptionInfoRec * table, int token,
/usr/include/xorg/xf86Opt.h:139:extern _X_EXPORT Bool xf86ReturnOptValBool(const OptionInfoRec * table,
/usr/include/xorg/xf86Crtc.h:971:xf86AssignNoOutputInitialSize(ScrnInfoPtr scrn, const OptionInfoRec *options,
/usr/include/xorg/xf86str.h:223:    const OptionInfoRec *(*AvailableOptions) (int chipid, int bustype);

那么xf86Opt.h这个文件是在哪个包中?上边讲intel_options.h的时候提到了它与xorg-server强相关,那么尝试在xorg-server源码中进行搜索,看看能否找到此文件以及OptionInfoRec结构。

前提是要先把xorg-server的源码下载下来,去哪里下载?

下载地址为:GitHub - freedesktop/xorg-xserver: X server

源码下载后,在其中搜索,结果如下:

$ grep -rn "OptionInfoRec," ./
./hw/xfree86/doc/ddxDesign.xml:2944:      } OptionInfoRec, *OptionInfoPtr;
./hw/xfree86/common/xf86Opt.h:71:} OptionInfoRec, *OptionInfoPtr;

由xf86Opt.h得到OptionInfoRec结构体的定义如下:

typedef struct {int token;const char *name;OptionValueType type;ValueUnion value;Bool found;
} OptionInfoRec, *OptionInfoPtr;

弄清楚了OptionInfoRec结构的定义,翻回头来看常量结构体数组const OptionInfoRec intel_options[],其意义就一目了然了。这里仅以第一项详细说明。

{OPTION_ACCEL_ENABLE,	"Accel",	OPTV_BOOLEAN,	{0},	0},

OPTION_ACCEL_ENABLE是在intel_options.h中定义的,是枚举值0。对应的是OptionInfoRec结构中的int token成员。

"Accel"对应OptionInfoRec结构中的const char *name成员。

OPTV_BOOLEAN的定义同样不在xf86-video-intel源码中,但根据其名字就可以推断出来,是布尔类型。对应OptionInfoRec结构中的OptionValueType type成员。

其余两个成员ValueUnion value和Bool found的值都为0,

相关内容

热门资讯

泸州老窖董事长刘淼“重回前三”... 运营商财经网 周颖/文 在中国白酒行业中,茅台与五粮液行业龙头的地位非常稳固,但“老三之争”却从未停...
为什么越简单的人活的越高级?极... 作品声明:个人观点、仅供参考 在现代社会,物质极大丰富,信息爆炸增长,人们却常常感到疲惫,焦虑和迷茫...
张江半导体企业,完成数亿元融资... 01 融资综述 加冕研究院据张通社Link数据库统计,1月19日–1月25日,上海企业共发生19起融...
港股异动 | 智谱午后拉升 近... 1月27日,智谱午后拉升,一度涨超12%,随后涨幅回落。截至15时21分,该股涨7.56%,报233...
2025年国内一级市场募投状况... 2025年,国内一级市场募投状况有所升温。从投中数据近期公布的内容来看,年内投资数量及基金规模同比均...
龙湖集团销售额同比降37.54... 运营商财经网 章少霞/文 根据龙湖集团披露的这两年的财报,龙湖集团可谓中国最赚钱的房地产企业之一,董...
新网银行取得快速回溯数据专利 国家知识产权局信息显示,四川新网银行股份有限公司取得一项名为“一种快速回溯数据的方法及装置”的专利,...
锂、铜、铝、DRAM全在涨!中... 财联社1月27日讯(编辑 潇湘)有迹象显示,中国电动汽车行业当前正面临多重成本因素同时发酵所带来的前...
昔日丘栋荣所管产品如今多失意,... 作者:闵晓强 编辑:李 鑫 今年一月的倒数第二周,内地公募基金四季报落下帷幕,按照圈内的传统,拥有明...
特朗普:中国正在接管加拿大!话... 美国新闻报道称,美国总统特朗普发表了一篇措辞极为激烈的文章,声称:中国正在成功且彻底地接管加拿大,这...
港股异动丨南华期货股份创上市新... 延续昨日涨势,南华期货股份(2691.HK)今日盘中再度涨近10%至12.5港元,股价创上市新高。消...
马化腾员工大会讲话:金融科技不... 来源:市场资讯 (来源:北京商报) 北京商报讯(记者 廖蒙)1月26日,腾讯召开2025年度员工大会...
成交破1亿创历史新高!“重仓有... 1月27日,红利板块整体调整。数据显示,截至14时50分,“重仓有色”的中证红利质量ETF(1592...
爱芯元智通过港交所聆讯,掘金边... 2026年开年以来,港股IPO市场持续火热,AI赛道尤其耀眼,多只登陆港交所的新股上市后实现连续上涨...
东阳光药联手晶泰控股布局“AI... 上证报中国证券网讯(记者 孔令仪)1月26日,东阳光药与晶泰控股正式宣布签署战略合作协议。据悉,在此...
欧瑞博CEO王雄辉入选福布斯新... 2026年1月23日,欧瑞博创始人兼CEO王雄辉入选 “2025福布斯中国新时代颠覆力创始人” 榜单...
小红书爆款心法:吃透人性,轻松... 为啥精心打磨的干货没人看,随手发的日常却爆火?小红书流量逻辑的核心,从来都是对人性的精准拿捏。 一、...
浩天助力海港创投完成史河科技的... 浙江史河科技有限公司(以下简称"史河科技")宣布于2025年12月完成C轮融资(以下简称"本轮融资"...
商务部:2026年将进一步释放... 来源:滚动播报 (来源:上观新闻) 2025年中国社会消费品零售总额首次突破50万亿元,增长平稳,...
黄金白银价格齐创新高,牛市还能... 机构认为,黄金短期仍处于强势区间,金融属性仍在强势回归中,但需警惕交易过热后的波动加剧风险,白银短期...