| 1 | /*
|
|---|
| 2 | * Copyright (c) 2013 Jan Vesely
|
|---|
| 3 | * Copyright (c) 2011 Petr Koupy
|
|---|
| 4 | * All rights reserved.
|
|---|
| 5 | *
|
|---|
| 6 | * Redistribution and use in source and binary forms, with or without
|
|---|
| 7 | * modification, are permitted provided that the following conditions
|
|---|
| 8 | * are met:
|
|---|
| 9 | *
|
|---|
| 10 | * - Redistributions of source code must retain the above copyright
|
|---|
| 11 | * notice, this list of conditions and the following disclaimer.
|
|---|
| 12 | * - Redistributions in binary form must reproduce the above copyright
|
|---|
| 13 | * notice, this list of conditions and the following disclaimer in the
|
|---|
| 14 | * documentation and/or other materials provided with the distribution.
|
|---|
| 15 | * - The name of the author may not be used to endorse or promote products
|
|---|
| 16 | * derived from this software without specific prior written permission.
|
|---|
| 17 | *
|
|---|
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|---|
| 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|---|
| 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|---|
| 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|---|
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|---|
| 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|---|
| 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|---|
| 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|---|
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|---|
| 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|---|
| 28 | */
|
|---|
| 29 |
|
|---|
| 30 | /** @addtogroup amdm37x
|
|---|
| 31 | * @{
|
|---|
| 32 | */
|
|---|
| 33 | /**
|
|---|
| 34 | * @file
|
|---|
| 35 | */
|
|---|
| 36 |
|
|---|
| 37 | #include <ddf/driver.h>
|
|---|
| 38 | #include <ddf/log.h>
|
|---|
| 39 | #include <errno.h>
|
|---|
| 40 | #include <str_error.h>
|
|---|
| 41 | #include <stdio.h>
|
|---|
| 42 | #include <graph.h>
|
|---|
| 43 |
|
|---|
| 44 | #include "amdm37x_dispc.h"
|
|---|
| 45 |
|
|---|
| 46 | #define NAME "amdm37x_dispc"
|
|---|
| 47 |
|
|---|
| 48 | static void graph_vsl_connection(ipc_call_t *icall, void *arg)
|
|---|
| 49 | {
|
|---|
| 50 | visualizer_t *vsl;
|
|---|
| 51 |
|
|---|
| 52 | vsl = (visualizer_t *) ddf_fun_data_get((ddf_fun_t *)arg);
|
|---|
| 53 | graph_visualizer_connection(vsl, icall, NULL);
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | static errno_t amdm37x_dispc_dev_add(ddf_dev_t *dev)
|
|---|
| 57 | {
|
|---|
| 58 | assert(dev);
|
|---|
| 59 | /* Visualizer part */
|
|---|
| 60 | ddf_fun_t *fun = ddf_fun_create(dev, fun_exposed, "viz");
|
|---|
| 61 | if (!fun) {
|
|---|
| 62 | ddf_log_error("Failed to create visualizer function\n");
|
|---|
| 63 | return ENOMEM;
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 | visualizer_t *vis = ddf_fun_data_alloc(fun, sizeof(visualizer_t));
|
|---|
| 67 | if (!vis) {
|
|---|
| 68 | ddf_log_error("Failed to allocate visualizer structure\n");
|
|---|
| 69 | ddf_fun_destroy(fun);
|
|---|
| 70 | return ENOMEM;
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | graph_init_visualizer(vis);
|
|---|
| 74 | vis->reg_svc_handle = ddf_fun_get_handle(fun);
|
|---|
| 75 |
|
|---|
| 76 | ddf_fun_set_conn_handler(fun, graph_vsl_connection);
|
|---|
| 77 | /* Hw part */
|
|---|
| 78 | amdm37x_dispc_t *dispc =
|
|---|
| 79 | ddf_dev_data_alloc(dev, sizeof(amdm37x_dispc_t));
|
|---|
| 80 | if (!dispc) {
|
|---|
| 81 | ddf_log_error("Failed to allocate dispc structure\n");
|
|---|
| 82 | ddf_fun_destroy(fun);
|
|---|
| 83 | return ENOMEM;
|
|---|
| 84 | }
|
|---|
| 85 |
|
|---|
| 86 | errno_t ret = amdm37x_dispc_init(dispc, vis);
|
|---|
| 87 | if (ret != EOK) {
|
|---|
| 88 | ddf_log_error("Failed to init dispc: %s\n", str_error(ret));
|
|---|
| 89 | ddf_fun_destroy(fun);
|
|---|
| 90 | return ret;
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | /* Bind function */
|
|---|
| 94 | ret = ddf_fun_bind(fun);
|
|---|
| 95 | if (ret != EOK) {
|
|---|
| 96 | ddf_log_error("Failed to bind function: %s\n", str_error(ret));
|
|---|
| 97 | amdm37x_dispc_fini(dispc);
|
|---|
| 98 | ddf_fun_destroy(fun);
|
|---|
| 99 | return ret;
|
|---|
| 100 | }
|
|---|
| 101 | ddf_fun_add_to_category(fun, "visualizer");
|
|---|
| 102 |
|
|---|
| 103 | ddf_log_note("Added device `%s'\n", ddf_dev_get_name(dev));
|
|---|
| 104 | return EOK;
|
|---|
| 105 | }
|
|---|
| 106 |
|
|---|
| 107 | static driver_ops_t amdm37x_dispc_driver_ops = {
|
|---|
| 108 | .dev_add = amdm37x_dispc_dev_add,
|
|---|
| 109 | };
|
|---|
| 110 |
|
|---|
| 111 | static driver_t amdm37x_dispc_driver = {
|
|---|
| 112 | .name = NAME,
|
|---|
| 113 | .driver_ops = &amdm37x_dispc_driver_ops
|
|---|
| 114 | };
|
|---|
| 115 |
|
|---|
| 116 | int main(int argc, char *argv[])
|
|---|
| 117 | {
|
|---|
| 118 | printf("%s: HelenOS AM/DM37x framebuffer driver\n", NAME);
|
|---|
| 119 | ddf_log_init(NAME);
|
|---|
| 120 | return ddf_driver_main(&amdm37x_dispc_driver);
|
|---|
| 121 | }
|
|---|
| 122 |
|
|---|
| 123 | /** @}
|
|---|
| 124 | */
|
|---|