Prepare pulbic open 31/52331/2
authorSangjin Lee <lsj119@samsung.com>
Fri, 20 Nov 2015 08:17:26 +0000 (17:17 +0900)
committerSangjin Lee <lsj119@samsung.com>
Mon, 23 Nov 2015 02:56:32 +0000 (18:56 -0800)
   - Add auto-config
   - tbm is default backend

Change-Id: I3f96200d0fd14574475bc0e3ca5b7f4f0796ee2a
Signed-off-by: Sangjin Lee <lsj119@samsung.com>
14 files changed:
Makefile [deleted file]
Makefile.am [new file with mode: 0644]
autogen.sh [new file with mode: 0755]
backends/tbm/gbm_tbm.c [new file with mode: 0644]
backends/tbm/gbm_tbm.h [new file with mode: 0644]
backends/tbm/gbm_tbmint.h [new file with mode: 0644]
configure.ac [new file with mode: 0644]
gbm.pc.in [moved from pkgconfig/gbm.pc with 82% similarity]
packaging/libgbm.spec
src/backend.c
src/backends/Makefile [deleted file]
src/common.c [deleted file]
src/common.h [deleted file]
src/gbm.c

diff --git a/Makefile b/Makefile
deleted file mode 100644 (file)
index dfbd191..0000000
--- a/Makefile
+++ /dev/null
@@ -1,64 +0,0 @@
-SRC_DIR = ./src
-SO_NAME = libgbm.so.$(major_ver)
-BIN_NAME = $(SO_NAME).$(minor_ver)
-
-#CROSS_COMPILE ?= arm-none-linux-gnueabi-
-TARGET_CC ?= $(CROSS_COMPILE)gcc
-TARGET_AR ?= $(CROSS_COMPILE)ar
-CFLAGS += -Wall -ludev -fPIC
-
-#gbm backend sources
-GBM_BACKENDS_DIR = $(SRC_DIR)/backends
-
-#gbm backend module location
-CFLAGS += -DMODULEDIR='"$(libdir)/gbm"'
-
-#gbm main source
-GBM_SRCS +=  \
-                       $(SRC_DIR)/gbm.c \
-                       $(SRC_DIR)/common.c \
-                       $(SRC_DIR)/backend.c
-
-%.o: %.c
-       $(TARGET_CC) -c -o $@ $< $(CFLAGS)
-
-GBM_OBJS := $(GBM_SRCS:.c=.o)
-
-$(BIN_NAME): $(GBM_OBJS)
-       $(TARGET_CC) -shared -Wl,-soname,$(SO_NAME) -o $@ $(GBM_OBJS) $(CFLAGS)
-backend: 
-       @for dir in $(GBM_BACKENDS_DIR) ; do \
-               $(MAKE) -C $$dir ; \
-       done
-
-.DEFAULT_GOAL = all
-all: $(BIN_NAME) backend
-
-clean:
-       -rm -f $(GBM_OBJS) $(BIN_NAME)
-       @for dir in $(GBM_BACKENDS_DIR) ; do \
-               $(MAKE) $@ -C $$dir ; \
-       done
-
-install: all
-       cp $(SRC_DIR)/gbm.h $(includedir)/
-       -mkdir $(includedir)/gbm/
-       cp $(SRC_DIR)/backend.h $(includedir)/gbm/
-       cp $(SRC_DIR)/common.h $(includedir)/gbm/
-       cp $(SRC_DIR)/gbmint.h $(includedir)/gbm/
-       cp pkgconfig/gbm.pc $(libdir)/pkgconfig/
-       cp $(BIN_NAME) $(libdir)/
-       @for dir in $(GBM_BACKENDS_DIR) ; do \
-               $(MAKE) $@ -C $$dir ; \
-       done
-
-uninstall:
-       -rm -f $(includedir)/gbm.h
-       -rm -f $(includedir)/gbm/backend.h
-       -rm -f $(includedir)/gbm/common.h
-       -rm -f $(includedir)/gbm/gbmint.h
-       -rm -f $(libdir)/pkgconfig/gbm.pc
-       -rm -f $(libdir)/$(BIN_NAME)
-       @for dir in $(GBM_BACKENDS_DIR) ; do \
-               $(MAKE) $@ -C $$dir ; \
-       done
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..8289c37
--- /dev/null
@@ -0,0 +1,48 @@
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = gbm.pc
+
+AM_CFLAGS = \
+       -D_OS_UNIX=1 \
+       -DMODULEDIR='"$(libdir)/gbm"' \
+       -I$(top_srcdir)/src 
+
+lib_LTLIBRARIES = libgbm.la
+include_HEADERS = src/gbm.h
+
+libgbm_la_SOURCES = \
+       src/backend.c \
+       src/backend.h \
+       src/gbm.c \
+       src/gbm.h \
+       src/gbmint.h
+
+libgbm_la_LDFLAGS = \
+       -no-undefined \
+       -version-info 1:0
+
+libgbm_la_LIBADD = 
+
+libgbmincludedir=$(includedir)
+libgbminclude_HEADERS = \
+       src/gbm.h \
+       src/gbmint.h
+
+if HAVE_TBM
+libgbm_la_SOURCES += \
+       backends/tbm/gbm_tbm.c \
+       backends/tbm/gbm_tbmint.h
+
+AM_CFLAGS += \
+       $(TBM_CFALGS)
+
+libgbm_la_LIBADD += \
+       $(TBM_LIBS)
+
+libgbmtbmincludedir=$(includedir)/gbm
+libgbmtbminclude_HEADERS = \
+       backends/tbm/gbm_tbm.h \
+       backends/tbm/gbm_tbmint.h
+
+endif
+
+CLEANFILES = 
diff --git a/autogen.sh b/autogen.sh
new file mode 100755 (executable)
index 0000000..d247709
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+rm -rf autom4te.cache
+rm -f aclocal.m4 ltmain.sh
+
+echo "Running aclocal..." ; aclocal $ACLOCAL_FLAGS || exit 1
+echo "Running autoheader..." ; autoheader || exit 1
+echo "Running autoconf..." ; autoconf || exit 1
+echo "Running libtoolize..." ; (libtoolize --copy --automake || glibtoolize --automake) || exit 1
+echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1
+
+if [ -z "$NOCONFIGURE" ]; then
+         ./configure "$@"
+fi
+
diff --git a/backends/tbm/gbm_tbm.c b/backends/tbm/gbm_tbm.c
new file mode 100644 (file)
index 0000000..e5393a2
--- /dev/null
@@ -0,0 +1,370 @@
+/**************************************************************************
+
+Copyright 2012 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: Sangjin Lee <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <string.h>
+#include <limits.h>
+
+#include "gbm_tbmint.h"
+#include <tbm_surface_internal.h>
+#include <wayland-tbm-server.h>
+
+GBM_EXPORT tbm_bo
+gbm_tbm_bo_get_tbm_bo(struct gbm_tbm_bo *bo)
+{
+   tbm_bo tbo;
+   tbo = tbm_surface_internal_get_bo(bo->tbm_surf, 0);
+   return tbo;
+}
+
+GBM_EXPORT uint32_t
+gbm_tbm_surface_get_width(struct gbm_tbm_surface *surf)
+{
+   return surf->base.width;
+}
+
+GBM_EXPORT uint32_t
+gbm_tbm_surface_get_height(struct gbm_tbm_surface *surf)
+{
+   return surf->base.height;
+}
+
+GBM_EXPORT uint32_t
+gbm_tbm_surface_get_format(struct gbm_tbm_surface *surf)
+{
+   return surf->base.format;
+}
+
+GBM_EXPORT uint32_t
+gbm_tbm_surface_get_flags(struct gbm_tbm_surface *surf)
+{
+   return surf->base.flags;
+}
+
+GBM_EXPORT void
+gbm_tbm_surface_set_user_data(struct gbm_tbm_surface *surf, void *data)
+{
+   surf->tbm_private = data;
+}
+
+GBM_EXPORT void *
+gbm_tbm_surface_get_user_data(struct gbm_tbm_surface *surf)
+{
+   return surf->tbm_private;
+}
+
+GBM_EXPORT void
+gbm_tbm_device_set_callback_surface_has_free_buffers(struct gbm_tbm_device *gbm_tbm, int (*callback)(struct gbm_surface *))
+{
+   gbm_tbm->base.surface_has_free_buffers = callback;
+}
+
+GBM_EXPORT void
+gbm_tbm_device_set_callback_surface_lock_front_buffer(struct gbm_tbm_device *gbm_tbm, struct gbm_bo *(*callback)(struct gbm_surface *))
+{
+   gbm_tbm->base.surface_lock_front_buffer = callback;
+}
+
+GBM_EXPORT void
+gbm_tbm_device_set_callback_surface_release_buffer(struct gbm_tbm_device *gbm_tbm, void (*callback)(struct gbm_surface *, struct gbm_bo *))
+{
+   gbm_tbm->base.surface_release_buffer = callback;
+}
+
+static int
+__gbm_tbm_is_format_supported(struct gbm_device *gbm,
+                           uint32_t format,
+                           uint32_t usage)
+{
+   switch (format)
+   {
+   case GBM_BO_FORMAT_XRGB8888:
+   case GBM_FORMAT_XRGB8888:
+       break;
+   case GBM_BO_FORMAT_ARGB8888:
+   case GBM_FORMAT_ARGB8888:
+       if (usage & GBM_BO_USE_SCANOUT)
+          return 0;
+       break;
+   default:
+       return 0;
+   }
+
+   if (usage & GBM_BO_USE_CURSOR_64X64 &&
+       usage & GBM_BO_USE_RENDERING)
+       return 0;
+
+   return 1;
+}
+
+static int
+__gbm_tbm_bo_write(struct gbm_bo *_bo, const void *buf, size_t count)
+{
+   struct gbm_tbm_bo *bo = gbm_tbm_bo(_bo);
+   tbm_surface_info_s info;
+
+   if (TBM_SURFACE_ERROR_NONE == tbm_surface_map(bo->tbm_surf, TBM_OPTION_WRITE, &info))
+   {
+               memcpy(info.planes[0].ptr, buf, count);
+               tbm_surface_unmap(bo->tbm_surf);
+               return 1;
+   }
+
+   return 0;
+}
+
+static int
+__gbm_tbm_bo_get_fd(struct gbm_bo *_bo)
+{
+   struct gbm_tbm_bo *bo = gbm_tbm_bo(_bo);
+   tbm_bo tbo;
+   tbm_bo_handle handle;
+
+   tbo = tbm_surface_internal_get_bo(bo->tbm_surf, 0);
+   if (!tbo)
+   {
+      fprintf(stderr, "%s::tbm_surface_internal_get_bo() failed.\n", __FUNCTION__);
+         return 0;
+   }
+   handle = tbm_bo_get_handle(tbo, TBM_DEVICE_MM);
+
+   return handle.s32;
+}
+
+static void
+__gbm_tbm_bo_destroy(struct gbm_bo *_bo)
+{
+   struct gbm_tbm_bo *bo = gbm_tbm_bo(_bo);
+
+   if(bo->tbm_surf)
+   {
+         tbm_surface_destroy(bo->tbm_surf);
+      bo->tbm_surf = NULL;
+   }
+
+   free(bo);
+}
+
+struct gbm_bo *
+__gbm_tbm_bo_import(struct gbm_device *gbm, uint32_t type,
+                                       void *buffer, uint32_t usage)
+{
+   struct gbm_tbm_bo *bo;
+   tbm_surface_h tbm_surf = NULL;
+   tbm_bo tbo;
+   tbm_bo_handle handle;
+   uint32_t size, offset, stride;
+
+   bo = calloc(1, sizeof *bo);
+   if (bo == NULL)
+         return NULL;
+
+   switch (type)
+   {
+      case GBM_BO_IMPORT_WL_BUFFER:
+         tbm_surf = wayland_tbm_server_get_surface(NULL, (struct wl_resource*)buffer);
+         tbo = tbm_surface_internal_get_bo(tbm_surf, 0);
+            break;
+      default:
+         free(bo);
+         return NULL;
+   }
+
+   if (!tbm_surf)
+   {
+      free(bo);
+         return NULL;
+   }
+
+   tbm_surface_internal_get_plane_data(tbm_surf, 0, &size, &offset, &stride);
+   bo->base.gbm = gbm;
+   bo->base.width = tbm_surface_get_width(tbm_surf);
+   bo->base.height = tbm_surface_get_height(tbm_surf);
+   bo->base.format = tbm_surface_get_format(tbm_surf);
+   bo->base.stride = stride;
+   bo->usage = usage;
+
+   handle = tbm_bo_get_handle(tbo, TBM_DEVICE_DEFAULT);
+   bo->base.handle.u64 = handle.u64;
+
+   return &bo->base;
+}
+
+static struct gbm_bo *
+__gbm_tbm_bo_create(struct gbm_device *gbm,
+                 uint32_t width, uint32_t height,
+                 uint32_t format, uint32_t usage)
+{
+   struct gbm_tbm_bo *bo;
+   uint32_t size, offset, pitch;
+   int flags = TBM_BO_DEFAULT;
+   int surface_format;
+   tbm_bo_handle handle;
+   tbm_bo tbo;
+
+   bo = calloc(1, sizeof *bo);
+   if (bo == NULL)
+       return NULL;
+
+   bo->base.gbm = gbm;
+   bo->base.width = width;
+   bo->base.height = height;
+   bo->base.format = format;
+   bo->usage = usage;
+
+   switch (format)
+   {
+   case GBM_FORMAT_RGB565:
+       surface_format = TBM_FORMAT_BGR565;
+       break;
+   case GBM_FORMAT_XRGB8888:
+   case GBM_BO_FORMAT_XRGB8888:
+       surface_format = TBM_FORMAT_XRGB8888;
+       break;
+   case GBM_FORMAT_ARGB8888:
+   case GBM_BO_FORMAT_ARGB8888:
+   case GBM_FORMAT_ABGR8888:
+       surface_format = TBM_FORMAT_ABGR8888;
+       break;
+   default:
+       free(bo);
+       return NULL;
+   }
+
+   if ((usage & GBM_BO_USE_SCANOUT) || (usage & GBM_BO_USE_CURSOR_64X64))
+   {
+       flags |= TBM_BO_SCANOUT;
+   }
+
+   bo->tbm_surf = tbm_surface_internal_create_with_flags(width, height, surface_format, flags);
+   if (!bo->tbm_surf)
+   {
+      free(bo);
+      return NULL;
+   }
+
+   if (!tbm_surface_internal_get_plane_data(bo->tbm_surf, 0, &size, &offset, &pitch))
+   {
+      tbm_surface_destroy(bo->tbm_surf);
+      free(bo);
+      return NULL;
+   }
+
+   bo->base.stride = pitch;
+   tbo = tbm_surface_internal_get_bo(bo->tbm_surf, 0);
+   handle = tbm_bo_get_handle(tbo, TBM_DEVICE_DEFAULT);
+   bo->base.handle.u64 = handle.u64;
+
+   return &bo->base;
+}
+
+static struct gbm_surface *
+__gbm_tbm_surface_create(struct gbm_device *gbm,
+                      uint32_t width, uint32_t height,
+                      uint32_t format, uint32_t flags)
+{
+   struct gbm_tbm_surface *surf;
+
+   surf = calloc(1, sizeof *surf);
+   if (surf == NULL)
+       return NULL;
+
+   surf->base.gbm = gbm;
+   surf->base.width = width;
+   surf->base.height = height;
+   surf->base.format = format;
+   surf->base.flags = flags;
+
+   return &surf->base;
+}
+
+static void
+__gbm_tbm_surface_destroy(struct gbm_surface *_surf)
+{
+   struct gbm_tbm_surface *surf = gbm_tbm_surface(_surf);
+
+   free(surf);
+}
+
+static void
+__tbm_destroy(struct gbm_device *gbm)
+{
+   struct gbm_tbm_device *dri = gbm_tbm_device(gbm);
+
+   if (dri->bufmgr)
+         tbm_bufmgr_deinit(dri->bufmgr);
+
+   if (dri->driver_name)
+         free(dri->driver_name);
+
+   free(dri);
+}
+
+static struct gbm_device *
+__tbm_device_create(int fd)
+{
+   struct gbm_tbm_device *dri;
+
+   dri = calloc(1, sizeof *dri);
+
+   dri->bufmgr = tbm_bufmgr_init(fd);
+   if (dri->bufmgr == NULL)
+      goto fail;
+
+   dri->base.fd = fd;
+   dri->base.bo_create = __gbm_tbm_bo_create;
+   dri->base.bo_import = __gbm_tbm_bo_import;
+   dri->base.is_format_supported = __gbm_tbm_is_format_supported;
+   dri->base.bo_write = __gbm_tbm_bo_write;
+   dri->base.bo_get_fd = __gbm_tbm_bo_get_fd;
+   dri->base.bo_destroy = __gbm_tbm_bo_destroy;
+   dri->base.destroy = __tbm_destroy;
+   dri->base.surface_create = __gbm_tbm_surface_create;
+   dri->base.surface_destroy = __gbm_tbm_surface_destroy;
+   dri->base.name = "gbm_tbm";
+
+   return &dri->base;
+
+fail:
+   if (dri->bufmgr)
+      tbm_bufmgr_deinit(dri->bufmgr);
+
+   if (dri->driver_name)
+      free(dri->driver_name);
+
+   free(dri);
+   return NULL;
+}
+
+struct gbm_backend gbm_tbm_backend = {
+   .backend_name = "gbm_tbm",
+   .create_device = __tbm_device_create,
+};
diff --git a/backends/tbm/gbm_tbm.h b/backends/tbm/gbm_tbm.h
new file mode 100644 (file)
index 0000000..651a4a2
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef _GBM_TBM_H_
+#define _GBM_TBM_H_
+
+#include <gbm.h>
+#include <tbm_bufmgr.h>
+
+struct gbm_tbm_device;
+struct gbm_tbm_bo;
+struct gbm_tbm_surface;
+
+
+void
+gbm_tbm_device_set_callback_surface_has_free_buffers(struct gbm_tbm_device *gbm_tbm, int (*callback)(struct gbm_surface *));
+
+void
+gbm_tbm_device_set_callback_surface_lock_front_buffer(struct gbm_tbm_device *gbm_tbm, struct gbm_bo *(*callback)(struct gbm_surface *));
+
+void
+gbm_tbm_device_set_callback_surface_release_buffer(struct gbm_tbm_device *gbm_tbm, void (*callback)(struct gbm_surface *, struct gbm_bo *));
+
+uint32_t
+gbm_tbm_surface_get_width(struct gbm_tbm_surface *surf);
+
+uint32_t
+gbm_tbm_surface_get_height(struct gbm_tbm_surface *surf);
+
+uint32_t
+gbm_tbm_surface_get_format(struct gbm_tbm_surface *surf);
+
+uint32_t
+gbm_tbm_surface_get_flags(struct gbm_tbm_surface *surf);
+
+void
+gbm_tbm_surface_set_user_data(struct gbm_tbm_surface *surf, void *data);
+
+void *
+gbm_tbm_surface_get_user_data(struct gbm_tbm_surface *surf);
+
+tbm_bo
+gbm_tbm_bo_get_tbm_bo(struct gbm_tbm_bo *bo);
+
+#endif
diff --git a/backends/tbm/gbm_tbmint.h b/backends/tbm/gbm_tbmint.h
new file mode 100644 (file)
index 0000000..9dd9b71
--- /dev/null
@@ -0,0 +1,72 @@
+/**************************************************************************
+
+Copyright 2012 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: Sangjin Lee <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef _GBM_TBM_INTERNAL_H_
+#define _GBM_TBM_INTERNAL_H_
+
+#include <tbm_bufmgr.h>
+#include <tbm_surface.h>
+#include "gbm_tbm.h"
+#include "gbmint.h"
+
+struct gbm_tbm_device {
+   struct gbm_device base;
+   tbm_bufmgr bufmgr;
+   char *driver_name;
+};
+
+struct gbm_tbm_bo {
+   struct gbm_bo base;
+   tbm_surface_h tbm_surf;
+   uint32_t usage;
+};
+
+struct gbm_tbm_surface {
+   struct gbm_surface base;
+   void *tbm_private;
+};
+
+static inline struct gbm_tbm_device *
+gbm_tbm_device(struct gbm_device *gbm)
+{
+   return (struct gbm_tbm_device *) gbm;
+}
+
+static inline struct gbm_tbm_bo *
+gbm_tbm_bo(struct gbm_bo *bo)
+{
+   return (struct gbm_tbm_bo *) bo;
+}
+
+static inline struct gbm_tbm_surface *
+gbm_tbm_surface(struct gbm_surface *surface)
+{
+   return (struct gbm_tbm_surface *) surface;
+}
+
+#endif
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..8042948
--- /dev/null
@@ -0,0 +1,24 @@
+AC_INIT(libgbm, [1.0.0], lsj119@samsung.com)
+
+AC_CONFIG_SRCDIR(configure.ac)
+AC_CONFIG_HEADERS([config.h])
+
+AM_INIT_AUTOMAKE(1.6 foreign subdir-objects)
+AM_SILENT_RULES([yes])
+
+# Checks for programs.
+AC_PROG_CC
+AC_PROG_LIBTOOL
+
+PKG_CHECK_MODULES([TBM], [libtbm wayland-tbm-server], [have_tbm=yes], [have_tbm=no])
+if test x$have_tbm = xyes; then
+   AC_DEFINE([HAVE_TBM], [1], [Build the tbm backend])
+fi
+
+AM_CONDITIONAL(HAVE_TBM, test "x$have_tbm" = "xyes")
+AC_CONFIG_FILES([
+   Makefile
+   gbm.pc
+])
+AC_OUTPUT
+
similarity index 82%
rename from pkgconfig/gbm.pc
rename to gbm.pc.in
index 9493742..5219f5e 100644 (file)
+++ b/gbm.pc.in
@@ -5,8 +5,7 @@ includedir=${prefix}/include
 
 Name: gbm
 Description: Wayland Generic Buffer Management for TIZEN (from Mesa)
-Version: 10.2.0
-Requires.private: libudev >= 151
+Version: 1.0.0
 Libs: -L${libdir} -lgbm
 Libs.private: -ldl
 Cflags: -I${includedir}
index edc2727..44ca2dd 100644 (file)
@@ -1,5 +1,5 @@
 %define MAJOR_VER      1
-%define MINOR_VER      0s
+%define MINOR_VER      0
 
 Summary:       Wayland GBM for TIZEN
 Name:          libgbm
@@ -9,11 +9,11 @@ Group:                System/Libraries
 License:       MIT
 Source:                %{name}-%{version}.tar.gz
 
-BuildRequires: autoconf
-BuildRequires: libtool
-BuildRequires: systemd-devel
-BuildRequires: pkgconfig(libudev)
-BuildRequires: libdrm-devel
+BuildRequires: autoconf
+BuildRequires: libtool
+BuildRequires: systemd-devel
+BuildRequires: pkgconfig(libtbm)
+BuildRequires: pkgconfig(wayland-tbm-server)
 
 %description
 Wayland Generic Buffer Management for TIZEN
@@ -30,16 +30,14 @@ Development header files for use with Wayland GBM
 %setup -q -n %{name}
 
 %build
-make clean
+%reconfigure --disable-static
 make libdir=%{_libdir} major_ver=%{MAJOR_VER} minor_ver=%{MINOR_VER}
 
 %install
-mkdir -p %{buildroot}%{_includedir}
-mkdir -p %{buildroot}%{_libdir}/pkgconfig
-
 %makeinstall major_ver=%{MAJOR_VER} minor_ver=%{MINOR_VER}
+rm -f %{buildroot}/%{_libdir}/*.la
 
-ln -sf libgbm.so.%{MAJOR_VER}.%{MINOR_VER}     %{buildroot}%{_libdir}/libgbm.so.%{MAJOR_VER}
+ln -sf libgbm.so.%{MAJOR_VER}.%{MINOR_VER}.0   %{buildroot}%{_libdir}/libgbm.so.%{MAJOR_VER}
 ln -sf libgbm.so.%{MAJOR_VER}                  %{buildroot}%{_libdir}/libgbm.so
 
 %post -p /sbin/ldconfig
@@ -51,10 +49,11 @@ ln -sf libgbm.so.%{MAJOR_VER}                       %{buildroot}%{_libdir}/libgbm.so
 %defattr(-,root,root,-)
 %{_libdir}/libgbm.so
 %{_libdir}/libgbm.so.%{MAJOR_VER}
-%{_libdir}/libgbm.so.%{MAJOR_VER}.%{MINOR_VER}
+%{_libdir}/libgbm.so.%{MAJOR_VER}.%{MINOR_VER}.0
 
 %files devel
 %defattr(-,root,root,-)
 %{_includedir}/gbm.h
+%{_includedir}/gbmint.h
 %{_includedir}/gbm/*
 %{_libdir}/pkgconfig/gbm.pc
index a38b71f..a0aa744 100644 (file)
 #include <limits.h>
 #include <dlfcn.h>
 
+#include "config.h"
 #include "backend.h"
 
 #define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
 
+#if HAVE_TBM
+extern const struct gbm_backend gbm_tbm_backend;
+#endif
+
 struct backend_desc {
    const char *name;
    const struct gbm_backend *builtin;
 };
 
 static const struct backend_desc backends[] = {
-   { "gbm_dri.so", NULL },
-   { "gbm_gallium_drm.so", NULL },
-   { "gbm_tbm.so", NULL },
+#if HAVE_TBM
+   { "gbm_tbm.so", &gbm_tbm_backend },
+#endif
 };
 
 static const void *
diff --git a/src/backends/Makefile b/src/backends/Makefile
deleted file mode 100644 (file)
index 115b394..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#SUBDIRS = 
-
-default: subdirs
-
-subdirs:
-       @for dir in $(SUBDIRS) ; do \
-               $(MAKE) -C $$dir ; \
-       done
-
-clean:
-       @for dir in $(SUBDIRS) ; do \
-               $(MAKE) $@ -C $$dir ; \
-       done
-
-install: subdirs
-       @for dir in $(SUBDIRS) ; do \
-               $(MAKE) $@ -C $$dir ; \
-       done
-
-uninstall:
-       @for dir in $(SUBDIRS) ; do \
-               $(MAKE) $@ -C $$dir ; \
-       done
diff --git a/src/common.c b/src/common.c
deleted file mode 100644 (file)
index f02162d..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright © 2011 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- *    Benjamin Franzke <benjaminfranzke@googlemail.com>
- */
-
-#include <stdio.h>
-#include <string.h>
-
-#include <libudev.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-#include "common.h"
-#include "gbmint.h"
-
-GBM_EXPORT struct udev_device *
-_gbm_udev_device_new_from_fd(struct udev *udev, int fd)
-{
-   struct udev_device *device;
-   struct stat buf;
-
-   if (fstat(fd, &buf) < 0) {
-      fprintf(stderr, "gbm: failed to stat fd %d", fd);
-      return NULL;
-   }
-
-   device = udev_device_new_from_devnum(udev, 'c', buf.st_rdev);
-   if (device == NULL) {
-      fprintf(stderr,
-              "gbm: could not create udev device for fd %d", fd);
-      return NULL;
-   }
-
-   return device;
-}
-
-GBM_EXPORT char *
-_gbm_fd_get_device_name(int fd)
-{
-   struct udev *udev;
-   struct udev_device *device;
-   const char *const_device_name;
-   char *device_name = NULL;
-
-   udev = udev_new();
-   device = _gbm_udev_device_new_from_fd(udev, fd);
-   if (device == NULL)
-      return NULL;
-
-   const_device_name = udev_device_get_devnode(device);
-   if (!const_device_name)
-      goto out;
-   device_name = strdup(const_device_name);
-
-out:
-   udev_device_unref(device);
-   udev_unref(udev);
-
-   return device_name;
-}
-
-GBM_EXPORT void
-_gbm_log(const char *fmt_str, ...)
-{
-}
diff --git a/src/common.h b/src/common.h
deleted file mode 100644 (file)
index 1fcdfca..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright © 2011 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- *    Benjamin Franzke <benjaminfranzke@googlemail.com>
- */
-
-#ifndef _COMMON_H_
-#define _COMMON_H_
-
-#include <libudev.h>
-
-struct udev_device *
-_gbm_udev_device_new_from_fd(struct udev *udev, int fd);
-
-char *
-_gbm_fd_get_device_name(int fd);
-
-void
-_gbm_log(const char *fmt_str, ...);
-
-#endif
index 6179e5b..07f1589 100644 (file)
--- a/src/gbm.c
+++ b/src/gbm.c
@@ -25,8 +25,6 @@
  *    Benjamin Franzke <benjaminfranzke@googlemail.com>
  */
 
-#define _BSD_SOURCE
-
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>