您的位置:首页 > 移动开发 > Android开发

android hwcomposer

2015-10-14 21:40 1481 查看
以pandaboard为例。

linaro1304 release中使用HWC_FRAMEBUFFER, HWC_OVERLAY, 没有使用HWC_FRAMEBUFFER_TARGET. use_sgx = 1. egl_swapbuffer用于在commit的时候将bufer swap到sgx。 egl用于composition. hwc fb_dev的post2将sgx递交显示。composer的版本应该是1.0.

hwc_layer_1_t:

compositionType:composition type. HWC_FRAMEBUFFER/HWC_FRAMEBUFFER_TARGET: use open_gles 做composition. TARGET是compositon的target, 在HWC Composer1.1及以上版本中使用, 就版本的opengl es使用the (dpy, sur) fields in hwc_compositor_device_1_t. HWC_BACKGROUND: backgroundColor,
The HWC can toggle this value to HWC_FRAMEBUFFER to indicate it CANNOT handle the background color. HWC_OVERLAY: 使用HWC去composition, 不使用opengl es, 如果有个层设为HWC_FRAMEBUFFER_TARGET, 但所有其他层设为HWC_OVERLAY, 那么这层被忽略。

HWC_FRAMEBUFFER_TARGET:总是被调用者设置

HWC_FRAMEBUFFER:prepare时,调用者在HWC_GEOMETRY_CHANGED flag被设置的情况下, 设置这个。 hwc本身在prepare时设置这个指示由opengl es画进这个layer的framebuffer. 如果设置成HWC_OVERLAY(只能由hwc本身在prepare时设置。), 表示hwc将处理这个layer(不是opengl es)。

buffer_handle_t handle;: handle of buffer to compose. allocated by gralloc. layer的handle变化或者HWC_GEOMETRY_CHANGED未设(连续prepare之间), composer认为buffer未变。

sourceCrop和displayFrame:The sourceCrop is scaled using linear filtering to the displayFrame.

acquireFenceFd: /* Sync fence object that will be signaled when the buffer's

* contents are available. May be -1 if the contents are already

* available. This field is only valid during set(), and should be

* ignored during prepare(). The set() call must not wait for the

* fence to be signaled before returning, but the HWC must wait for

* all buffers to be signaled before reading from them.

*

* HWC_FRAMEBUFFER layers will never have an acquire fence, since

* reads from them are complete before the framebuffer is ready for

* display.

*

* The HWC takes ownership of the acquireFenceFd and is responsible

* for closing it when no longer needed.

*/-----for overlay

HWC_FRAMEBUFFER layers不需要acquireFenceFd。

hwc_display_contents_1: contents for display frame

//for HWC_DEVICE_VERSION_1_0, opengl es

hwc_display_t dpy; //EGLDisplay object

hwc_surface_t sur; //EGLSurface object

outbuf: the buffer that receives the composed image for

* virtual displays. Writes to the outbuf must wait until

* outbufAcquireFenceFd signals

hwLayers: layers

hwc_procs: 提供给上层的几个回调函数。invalidate: triggers a screen refresh. vsync. hotplug.

hwc_module_t: special hw_module_t for hwc

hwc_composer_device_1: special hw_device_t dor hwc:

prepare:called for each frame before composition and is used by

* SurfaceFlinger to determine what composition steps the HWC can handle.can be called more than once, the last call prevails. The HWC responds by setting the compositionType field in each layer to

* either HWC_FRAMEBUFFER or HWC_OVERLAY. In the former case, OpenGL ES. in the later case, HWC. Typically this happens (but is not limited to)

* when a window is added, removed, resized or moved.

* For HWC 1.0, numDisplays will always be one, and displays[0] will be

* non-NULL.

*

* For HWC 1.1, numDisplays will always be HWC_NUM_DISPLAY_TYPES. Entries

* for unsupported or disabled/disconnected display types will be NULL.

*

* For HWC 1.2 and later, numDisplays will be HWC_NUM_DISPLAY_TYPES or more.

* The extra entries correspond to enabled virtual displays, and will be

* non-NULL. In HWC 1.2, support for one virtual display is required, and

* no more than one will be used. Future HWC versions might require more.

set:

used in place of eglSwapBuffers(), and assumes the same

* functionality, except it also commits the work list atomically with

* the actual eglSwapBuffers().(http://www.2cto.com/kf/201210/160882.html)

* A display with zero layers indicates that the entire composition has

* been handled by SurfaceFlinger with OpenGL ES. In this case, (*set)()

* behaves just like eglSwapBuffers().

eventControl:

Enables or disables h/w composer events for a display. HWC_EVENT_VSYNC

blank:

Blanks or unblanks a display's screen.

query:

Used to retrieve information about the h/w composer

registerProcs:

registers callbacks that the h/w composer HAL can

* later use(sync, invalidate, hotplug)

getDisplayConfigs:

returns handles for the configurations available

* on the connected display.

getDisplayAttributes:

returns attributes for a specific config of a

* connected display. The config parameter is one of the config handles

* returned by getDisplayConfigs.

setParameter:

makes the hardware composer aware of the system state. vendor spec

omap4_hwc_device_open:

调用gralloc module, 得到fb dev

初始化hwc_dev的一些函数指针

open dsscomp_fd: ----主要作用:omap4_hwc_set_best_hdmi_mode中query display, DSSCIOC_SETUP_DISPLAY

open hdmi_fb_fd(fb1)----主要作用, hotplug时unblank

open fb_fd(fb0)---主要作用就是vsync

map fb0的帧buffer地址给 img_mem_ptr

open pipe pipe_fds

创建omap4_hwc_hdmi_thread线程

handle_hotplug:得到hdmi等的状态等, 并invalidate给上层。

omap4_hwc_event_control:

向fb0驱动写OMAPFB_ENABLEVSYNC ioctrl命令

omap4_hwc_query:仅支持query HWC_VSYNC_PERIOD

omap4_hwc_hdmi_thread:

poll用法:/article/9238163.html

pipe_fds等待pipe[0],更新timeout时间

等待uevent, for vsync, hotplug(invalidate), 并通知上层

prepare会检查layer是用sgx还是dss进行composer.并进行一些设置。 未详读。

>set调用fb_dev的post2进行composer. 如果使用SGX, 先调用eglSwapBuffers swap。(奇怪, 前面说dpy, sur是个egl用的, 这个时候应该是HWC_FRAMEBUFFER. 那么

>从代码中, 不管是framebuffer还是overlay, 都调用post2. 是否使用sgx, 只影响是否使用opengl es, 不是用来区分dss还是sgx的吗? 在三星的hwc中的set里, 调用

>exynos_v4l2_s_ctrl进行更新。 明了很多。

如果所有层能由dss render, 那么use_sgx=0, 在hwc->set中不会调用eglswapbuffer. linaro1304中不是都能dss render。所以不会在这里调用swap. dpy/sur来自egl. LAYER类型是HWC_FRAMEBUFER. 估计如果所有都能被dss处理, 那么也就不需要egl了。 这里还是要的。

surfaceflinger的displaydevice的swapbuffer在有virtual_display, frametarget且hasGlesComposition时(有frametarget但没有hasGlesComposition, 不调用), 调用egl的swap。 无virtual display, 无frametarget, 在hwc中调用swap.

从surfaceflinger的hwcomposer知。hwcomposer1.1及以上版本不用fb dev.而以下版本则fb dev, hw composer都使用(在surfaceflinger这层)。1.1及以上有framebuffertarget(这里是从surfaceflinger的角度看的。 并不代表hwcomposer的用法(指fb dev), framebuffer各版本的hwc都有的。 在surfaceflinger层,framebuffer你的函数是要被注册进open es的, 在hwcomposer层,
也指明framebuffer用于opengl es composition的)。

版权声明:本文为博主原创文章,未经博主允许不得转载。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: