Permalink
Browse files

Wire up fbdev window system

Signed-off-by: Carsten Munk <carsten.munk@jollamobile.com>
  • Loading branch information...
1 parent 4bba23f commit 0d3b3281aa7dd0276b83efa2a5623fb55462eb41 Carsten Munk committed Dec 10, 2012
Showing with 553 additions and 1 deletion.
  1. +6 −1 egl/Makefile.am
  2. +129 −0 egl/fbdev_window.cpp
  3. +56 −0 egl/fbdev_window.h
  4. +2 −0 egl/nativewindowbase.cpp
  5. +318 −0 egl/nativewindowbase.h
  6. +7 −0 egl/ws.c
  7. +35 −0 egl/ws_fbdev.cpp
View
@@ -1,11 +1,16 @@
lib_LTLIBRARIES = \
libEGL.la
-libEGL_la_SOURCES = egl.c ws.c
+libEGL_la_SOURCES = egl.c ws.c ws_fbdev.cpp nativewindowbase.cpp fbdev_window.cpp
libEGL_la_CFLAGS = -I$(top_srcdir)/include
if WANT_DEBUG
libEGL_la_CFLAGS += -ggdb -O0 -DDEBUG
endif
+libEGL_la_CXXFLAGS = -I$(top_srcdir)/include
+if WANT_DEBUG
+libEGL_la_CXXFLAGS += -ggdb -O0 -DDEBUG
+endif
libEGL_la_LDFLAGS = \
$(top_builddir)/common/libhybris-common.la \
+ $(top_builddir)/hardware/libhardware.la \
-version-info "1":"0":"0"
View
@@ -0,0 +1,129 @@
+#include "fbdev_window.h"
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <linux/matroxfb.h> // for FBIO_WAITFORVSYNC
+#include <sys/mman.h> //mmap, munmap
+#include <errno.h>
+#include <assert.h>
+
+
+FbDevNativeWindow::FbDevNativeWindow(gralloc_module_t* gralloc, alloc_device_t* alloc, framebuffer_device_t* fbDev)
+{
+ m_gralloc = alloc;
+ m_fbDev = fbDev;
+
+ for(unsigned int i = 0; i < FRAMEBUFFER_PARTITIONS; i++) {
+ m_buffers[i] = new FbDevNativeWindowBuffer(width(), height(), m_fbDev->format, GRALLOC_USAGE_HW_FB);
+
+ int err = m_gralloc->alloc(m_gralloc,
+ width(), height(), m_fbDev->format,
+ GRALLOC_USAGE_HW_FB,
+ &m_buffers[i]->handle,
+ &m_buffers[i]->stride);
+ printf("buffer %i is at %p (native %p) err=%s handle=%i stride=%i\n",
+ i, m_buffers[i], (ANativeWindowBuffer*) m_buffers[i],
+ strerror(-err), m_buffers[i]->handle, m_buffers[i]->stride);
+
+
+ }
+ m_frontbuffer = 0;
+ m_tailbuffer = 1;
+}
+
+FbDevNativeWindow::~FbDevNativeWindow() {
+ printf("%s\n",__PRETTY_FUNCTION__);
+}
+
+// overloads from BaseNativeWindow
+int FbDevNativeWindow::setSwapInterval(int interval) {
+ printf("%s\n",__PRETTY_FUNCTION__);
+ return 0;
+}
+
+int FbDevNativeWindow::dequeueBuffer(BaseNativeWindowBuffer **buffer){
+ printf("%s\n",__PRETTY_FUNCTION__);
+ *buffer = m_buffers[m_tailbuffer];
+ printf("dequeueing buffer %i %p",m_tailbuffer, m_buffers[m_tailbuffer]);
+ m_tailbuffer++;
+ if(m_tailbuffer == FRAMEBUFFER_PARTITIONS)
+ m_tailbuffer = 0;
+ return NO_ERROR;
+}
+
+int FbDevNativeWindow::lockBuffer(BaseNativeWindowBuffer* buffer){
+ printf("%s\n",__PRETTY_FUNCTION__);
+ return NO_ERROR;
+}
+
+int FbDevNativeWindow::queueBuffer(BaseNativeWindowBuffer* buffer){
+ FbDevNativeWindowBuffer* buf = static_cast<FbDevNativeWindowBuffer*>(buffer);
+ m_frontbuffer++;
+ if(m_frontbuffer == FRAMEBUFFER_PARTITIONS)
+ m_frontbuffer = 0;
+ int res = m_fbDev->post(m_fbDev, buffer->handle);
+ printf("%s %s\n",__PRETTY_FUNCTION__,strerror(res));
+ return NO_ERROR;
+}
+
+int FbDevNativeWindow::cancelBuffer(BaseNativeWindowBuffer* buffer){
+ printf("%s\n",__PRETTY_FUNCTION__);
+ return 0;
+}
+
+unsigned int FbDevNativeWindow::width() const {
+ unsigned int val = m_fbDev->width;
+ printf("%s value: %i\n",__PRETTY_FUNCTION__, val);
+ return val;
+}
+
+unsigned int FbDevNativeWindow::height() const {
+ unsigned int val = m_fbDev->height;
+ printf("%s value: %i\n",__PRETTY_FUNCTION__, val);
+ return val;
+}
+
+unsigned int FbDevNativeWindow::format() const {
+ unsigned int val = m_fbDev->format;
+ printf("%s value: %i\n",__PRETTY_FUNCTION__, val);
+ return val;
+}
+
+unsigned int FbDevNativeWindow::defaultWidth() const {
+ printf("%s\n",__PRETTY_FUNCTION__);
+ return m_fbDev->width;
+}
+
+unsigned int FbDevNativeWindow::defaultHeight() const {
+ printf("%s\n",__PRETTY_FUNCTION__);
+ return m_fbDev->height;
+}
+
+unsigned int FbDevNativeWindow::queueLength() const {
+ printf("%s\n",__PRETTY_FUNCTION__);
+ return 0;
+}
+
+unsigned int FbDevNativeWindow::type() const {
+ printf("%s\n",__PRETTY_FUNCTION__);
+ return NATIVE_WINDOW_FRAMEBUFFER;
+}
+
+unsigned int FbDevNativeWindow::transformHint() const {
+ printf("%s\n",__PRETTY_FUNCTION__);
+ return 0;
+}
+
+int FbDevNativeWindow::setUsage(int usage) {
+ printf("%s usage %i\n",__PRETTY_FUNCTION__, usage);
+ return NO_ERROR;
+}
+
+int FbDevNativeWindow::setBuffersFormat(int format) {
+ printf("%s format %i\n",__PRETTY_FUNCTION__, format);
+ return NO_ERROR;
+}
+
+int FbDevNativeWindow::setBuffersDimensions(int width, int height) {
+ printf("%s size %ix%i\n",__PRETTY_FUNCTION__, width, height);
+ return NO_ERROR;
+}
View
@@ -0,0 +1,56 @@
+#ifndef FBDEV_WINDOW_H
+#define FBDEV_WINDOW_H
+#include "nativewindowbase.h"
+#include <linux/fb.h>
+#include <hardware/gralloc.h>
+#define FRAMEBUFFER_PARTITIONS 2
+
+class FbDevNativeWindowBuffer : public BaseNativeWindowBuffer
+{
+ friend class FbDevNativeWindow;
+ protected:
+ FbDevNativeWindowBuffer(unsigned int width,
+ unsigned int height,
+ unsigned int format,
+ unsigned int usage) {
+ // Base members
+ ANativeWindowBuffer::width = width;
+ ANativeWindowBuffer::height = height;
+ ANativeWindowBuffer::format = format;
+ ANativeWindowBuffer::usage = usage;
+ };
+};
+
+class FbDevNativeWindow : public BaseNativeWindow
+{
+public:
+ FbDevNativeWindow(gralloc_module_t* gralloc, alloc_device_t* alloc, framebuffer_device_t* fbDev);
+ ~FbDevNativeWindow();
+protected:
+ // overloads from BaseNativeWindow
+ virtual int setSwapInterval(int interval);
+ virtual int dequeueBuffer(BaseNativeWindowBuffer **buffer);
+ virtual int lockBuffer(BaseNativeWindowBuffer* buffer);
+ virtual int queueBuffer(BaseNativeWindowBuffer* buffer);
+ virtual int cancelBuffer(BaseNativeWindowBuffer* buffer);
+ virtual unsigned int type() const;
+ virtual unsigned int width() const;
+ virtual unsigned int height() const;
+ virtual unsigned int format() const;
+ virtual unsigned int defaultWidth() const;
+ virtual unsigned int defaultHeight() const;
+ virtual unsigned int queueLength() const;
+ virtual unsigned int transformHint() const;
+ // perform calls
+ virtual int setUsage(int usage);
+ virtual int setBuffersFormat(int format);
+ virtual int setBuffersDimensions(int width, int height);
+private:
+ unsigned int m_frontbuffer;
+ unsigned int m_tailbuffer;
+ FbDevNativeWindowBuffer* m_buffers[FRAMEBUFFER_PARTITIONS];
+ alloc_device_t* m_gralloc;
+ framebuffer_device_t* m_fbDev;
+};
+
+#endif
View
@@ -0,0 +1,2 @@
+#include "nativewindowbase.h"
+
Oops, something went wrong.

0 comments on commit 0d3b328

Please sign in to comment.