summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjinhyung.jo <jinhyung.jo@samsung.com>2014-04-16 15:50:26 +0900
committerSeokYeon Hwang <syeon.hwang@samsung.com>2014-04-24 21:17:27 +0900
commit246564f317dc48b42b05eaecacff61f302c05fd2 (patch)
treea9b9902501134ea79edcc77090bec81b6c5d39dd
parent3e037feaf2fb56e74c2fdafd1d744d42125dc2c1 (diff)
downloadqemu-246564f317dc48b42b05eaecacff61f302c05fd2.tar.gz
qemu-246564f317dc48b42b05eaecacff61f302c05fd2.tar.bz2
qemu-246564f317dc48b42b05eaecacff61f302c05fd2.zip
maru: Change the device initialization routine.
Brightness, overlay and camera device can be added by option instead of forced initializing. Remove unneccessary code, used to check devices(virtgl & camera) Change-Id: Ie5cd5520ca17b7920342f6b2ae21e4c1f685c5e1 Signed-off-by: Jinhyung Jo <jinhyung.jo@samsung.com>
-rw-r--r--tizen/src/emulator.c86
-rw-r--r--tizen/src/hw/maru_board.c5
-rw-r--r--tizen/src/hw/maru_brightness.c10
-rw-r--r--tizen/src/hw/maru_brightness.h2
-rw-r--r--tizen/src/hw/maru_camera_common.h1
-rw-r--r--tizen/src/hw/maru_camera_common_pci.c27
-rw-r--r--tizen/src/hw/maru_overlay.c8
-rw-r--r--tizen/src/hw/maru_overlay.h2
-rw-r--r--vl.c6
9 files changed, 28 insertions, 119 deletions
diff --git a/tizen/src/emulator.c b/tizen/src/emulator.c
index a276ab7507..e7d997f526 100644
--- a/tizen/src/emulator.c
+++ b/tizen/src/emulator.c
@@ -97,7 +97,6 @@ char tizen_target_img_path[PATH_MAX];
int enable_gl = 0;
int enable_yagl = 0;
int enable_spice = 0;
-int is_webcam_enabled;
static int _skin_argc;
static char **_skin_argv;
@@ -351,25 +350,6 @@ static void print_system_info(void)
print_system_info_os();
}
-typedef struct {
- const char *device_name;
- int found;
-} device_opt_finding_t;
-
-static int find_device_opt (QemuOpts *opts, void *opaque)
-{
- device_opt_finding_t *devp = (device_opt_finding_t *) opaque;
- if (devp->found == 1) {
- return 0;
- }
-
- const char *str = qemu_opt_get (opts, "driver");
- if (strcmp (str, devp->device_name) == 0) {
- devp->found = 1;
- }
- return 0;
-}
-
#define DEFAULT_QEMU_DNS_IP "10.0.2.3"
static void prepare_basic_features(void)
{
@@ -420,16 +400,13 @@ static void prepare_opengl_acceleration(void)
if (capability_check_gl != 0) {
enable_gl = enable_yagl = 0;
- WARN("Warn: GL acceleration was disabled due to the fail of GL check!\n");
+ INFO("<WARNING> GL acceleration was disabled due to the fail of GL check!\n");
}
}
if (enable_gl) {
- device_opt_finding_t devp = {VIRTIOGL_DEV_NAME, 0};
- qemu_opts_foreach(qemu_find_opts("device"), find_device_opt, &devp, 0);
- if (devp.found == 0) {
- if (!qemu_opts_parse(qemu_find_opts("device"), VIRTIOGL_DEV_NAME, 1)) {
- exit(1);
- }
+ if (!qemu_opts_parse(qemu_find_opts("device"), VIRTIOGL_DEV_NAME, 1)) {
+ ERR("Failed to initialize the virtio-gl device.\n");
+ exit(1);
}
}
@@ -441,36 +418,6 @@ static void prepare_opengl_acceleration(void)
}
#endif
-#define MARUCAM_DEV_NAME "maru_camera_pci"
-#define WEBCAM_INFO_IGNORE 0x00
-#define WEBCAM_INFO_WRITE 0x04
-static void prepare_host_webcam(void)
-{
- is_webcam_enabled = marucam_device_check(WEBCAM_INFO_WRITE);
-
- if (!is_webcam_enabled) {
- INFO("[Webcam] <WARNING> Webcam support was disabled "
- "due to the fail of webcam capability check!\n");
- }
- else {
- device_opt_finding_t devp = {MARUCAM_DEV_NAME, 0};
- qemu_opts_foreach(qemu_find_opts("device"), find_device_opt, &devp, 0);
- if (devp.found == 0) {
- if (!qemu_opts_parse(qemu_find_opts("device"), MARUCAM_DEV_NAME, 1)) {
- INFO("Failed to initialize the marucam device.\n");
- exit(1);
- }
- }
- INFO("[Webcam] Webcam support was enabled.\n");
- }
-
- gchar * const tmp_str = g_strdup_printf(" enable_cam=%d", is_webcam_enabled);
-
- g_strlcat(maru_kernel_cmdline, tmp_str, LEN_MARU_KERNEL_CMDLINE);
-
- g_free(tmp_str);
-}
-
const gchar *prepare_maru_devices(const gchar *kernel_cmdline)
{
INFO("Prepare maru specified kernel command line\n");
@@ -485,36 +432,11 @@ const gchar *prepare_maru_devices(const gchar *kernel_cmdline)
// Prepare basic features
prepare_basic_features();
- // Prepare host webcam
- prepare_host_webcam();
-
INFO("kernel command : %s\n", maru_kernel_cmdline);
return maru_kernel_cmdline;
}
-int maru_device_check(QemuOpts *opts)
-{
-#if defined(CONFIG_GL_BACKEND)
- // virtio-gl pci device
- if (!enable_gl) {
- // ignore virtio-gl-pci device, even if users set it in option.
- const char *driver = qemu_opt_get(opts, "driver");
- if (driver && (strcmp (driver, VIRTIOGL_DEV_NAME) == 0)) {
- return -1;
- }
- }
-#endif
- if (!is_webcam_enabled) {
- const char *driver = qemu_opt_get(opts, "driver");
- if (driver && (strcmp (driver, MARUCAM_DEV_NAME) == 0)) {
- return -1;
- }
- }
-
- return 0;
-}
-
void prepare_maru(void)
{
INFO("Prepare maru specified feature\n");
diff --git a/tizen/src/hw/maru_board.c b/tizen/src/hw/maru_board.c
index 39c96b876d..884176bbcd 100644
--- a/tizen/src/hw/maru_board.c
+++ b/tizen/src/hw/maru_board.c
@@ -69,8 +69,6 @@
#include "maru_common.h"
#include "guest_debug.h"
#include "maru_pm.h"
-#include "maru_brightness.h"
-#include "maru_overlay.h"
#if defined(__linux__)
#include <X11/Xlib.h>
#endif
@@ -115,9 +113,6 @@ static void maru_device_init(void)
struct work_queue *render_queue = NULL;
struct winsys_interface *vigs_wsi = NULL;
- pci_maru_overlay_init(pci_bus);
- pci_maru_brightness_init(pci_bus);
-
if (enable_vigs || enable_yagl) {
render_queue = work_queue_create("render_queue");
}
diff --git a/tizen/src/hw/maru_brightness.c b/tizen/src/hw/maru_brightness.c
index 30e8e38a15..0605c4bf1f 100644
--- a/tizen/src/hw/maru_brightness.c
+++ b/tizen/src/hw/maru_brightness.c
@@ -41,7 +41,7 @@
MULTI_DEBUG_CHANNEL(qemu, maru_brightness);
-#define QEMU_DEV_NAME "MARU_BRIGHTNESS"
+#define QEMU_DEV_NAME "maru_brightness"
#define BRIGHTNESS_MEM_SIZE (4 * 1024) /* 4KB */
#define BRIGHTNESS_REG_SIZE 256
@@ -56,7 +56,7 @@ enum {
BRIGHTNESS_OFF = 0x04,
};
-uint32_t brightness_level;
+uint32_t brightness_level = BRIGHTNESS_MAX;
uint32_t brightness_off;
pixman_color_t level_color;
pixman_image_t *brightness_image;
@@ -206,12 +206,6 @@ static int brightness_initfn(PCIDevice *dev)
return 0;
}
-/* external interface */
-DeviceState *pci_maru_brightness_init(PCIBus *bus)
-{
- return &pci_create_simple(bus, -1, QEMU_DEV_NAME)->qdev;
-}
-
static void brightness_classinit(ObjectClass *klass, void *data)
{
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
diff --git a/tizen/src/hw/maru_brightness.h b/tizen/src/hw/maru_brightness.h
index 9ecaccb857..2c0449f03f 100644
--- a/tizen/src/hw/maru_brightness.h
+++ b/tizen/src/hw/maru_brightness.h
@@ -43,6 +43,4 @@ extern uint32_t brightness_off;
extern uint8_t brightness_tbl[];
extern pixman_image_t *brightness_image;
-DeviceState *pci_maru_brightness_init(PCIBus *bus);
-
#endif /* MARU_BRIGHTNESS_H_ */
diff --git a/tizen/src/hw/maru_camera_common.h b/tizen/src/hw/maru_camera_common.h
index e3a052d227..45b1a38f15 100644
--- a/tizen/src/hw/maru_camera_common.h
+++ b/tizen/src/hw/maru_camera_common.h
@@ -77,6 +77,7 @@ struct MaruCamState {
QemuCond thread_cond;
QEMUBH *tx_bh;
+ bool initialized;
bool destroying;
void *vaddr; /* vram ptr */
uint32_t isr;
diff --git a/tizen/src/hw/maru_camera_common_pci.c b/tizen/src/hw/maru_camera_common_pci.c
index aa7a1f95dd..e5dd3ce59e 100644
--- a/tizen/src/hw/maru_camera_common_pci.c
+++ b/tizen/src/hw/maru_camera_common_pci.c
@@ -200,11 +200,22 @@ static void marucam_tx_bh(void *opaque)
/*
* Initialization function
*/
+
static int marucam_initfn(PCIDevice *dev)
{
MaruCamState *s = DO_UPCAST(MaruCamState, dev, dev);
uint8_t *pci_conf = s->dev.config;
+ /* Check available webcam
+ * If there is not one, we don't init this device
+ */
+ if (!marucam_device_check(1)) {
+ s->initialized = false;
+ ERR("Failed to check the camera device, "
+ "stop the camera initialization. You can *not* use the camera\n");
+ return 1;
+ }
+
pci_config_set_interrupt_pin(pci_conf, 0x03);
memory_region_init_ram(&s->vram, OBJECT(s), "marucamera.ram", MARUCAM_MEM_SIZE);
@@ -228,6 +239,7 @@ static int marucam_initfn(PCIDevice *dev)
marucam_device_init(s);
s->tx_bh = qemu_bh_new(marucam_tx_bh, s);
+ s->initialized = true;
INFO("[%s] camera device was initialized.\n", __func__);
return 0;
@@ -241,14 +253,15 @@ static void marucam_exitfn(PCIDevice *pci_dev)
MaruCamState *s =
OBJECT_CHECK(MaruCamState, pci_dev, MARU_PCI_CAMERA_DEVICE_NAME);
- marucam_device_exit(s);
- g_free(s->param);
- qemu_cond_destroy(&s->thread_cond);
- qemu_mutex_destroy(&s->thread_mutex);
-
- memory_region_destroy(&s->vram);
- memory_region_destroy(&s->mmio);
+ if (s->initialized) {
+ marucam_device_exit(s);
+ g_free(s->param);
+ qemu_cond_destroy(&s->thread_cond);
+ qemu_mutex_destroy(&s->thread_mutex);
+ memory_region_destroy(&s->vram);
+ memory_region_destroy(&s->mmio);
+ }
INFO("[%s] camera device was released.\n", __func__);
}
diff --git a/tizen/src/hw/maru_overlay.c b/tizen/src/hw/maru_overlay.c
index 5f5d807f58..17afdc799b 100644
--- a/tizen/src/hw/maru_overlay.c
+++ b/tizen/src/hw/maru_overlay.c
@@ -38,7 +38,7 @@
MULTI_DEBUG_CHANNEL(qemu, maru_overlay);
-#define QEMU_DEV_NAME "MARU_OVERLAY"
+#define QEMU_DEV_NAME "maru_overlay"
#define OVERLAY_MEM_SIZE (8192 * 1024) /* 4MB(overlay0) + 4MB(overlay1) */
#define OVERLAY_REG_SIZE 256
@@ -253,12 +253,6 @@ static void overlay_exitfn(PCIDevice *dev)
INFO("<%s>\n", __func__);
}
-DeviceState *pci_maru_overlay_init(PCIBus *bus)
-{
- INFO("Maru overlay was initailized!\n");
- return &pci_create_simple(bus, -1, QEMU_DEV_NAME)->qdev;
-}
-
static void overlay_classinit(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
diff --git a/tizen/src/hw/maru_overlay.h b/tizen/src/hw/maru_overlay.h
index 06ea812a0d..1f40885399 100644
--- a/tizen/src/hw/maru_overlay.h
+++ b/tizen/src/hw/maru_overlay.h
@@ -52,6 +52,4 @@ extern uint16_t overlay1_height;
extern pixman_image_t *overlay0_image;
extern pixman_image_t *overlay1_image;
-DeviceState *pci_maru_overlay_init(PCIBus *bus);
-
#endif /* MARU_OVERLAY_H_ */
diff --git a/vl.c b/vl.c
index 69d834fd93..719816bf27 100644
--- a/vl.c
+++ b/vl.c
@@ -2449,12 +2449,6 @@ static int device_init_func(QemuOpts *opts, void *opaque)
{
DeviceState *dev;
-#ifdef CONFIG_MARU
- if(maru_device_check(opts) == -1) {
- return 0;
- }
-#endif
-
dev = qdev_device_add(opts);
if (!dev)
return -1;