[a202dbb] | 1 | /*
|
---|
[d57ff6f] | 2 | * Copyright (c) 2013 Jan Vesely
|
---|
[a202dbb] | 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 |
|
---|
[74db5a1] | 30 | /** @addtogroup amdm37x
|
---|
[a202dbb] | 31 | * @{
|
---|
| 32 | */
|
---|
| 33 | /**
|
---|
| 34 | * @file
|
---|
| 35 | */
|
---|
| 36 |
|
---|
[8e4a408] | 37 | #include <ddf/driver.h>
|
---|
[74db5a1] | 38 | #include <ddf/log.h>
|
---|
[a202dbb] | 39 | #include <errno.h>
|
---|
[74db5a1] | 40 | #include <str_error.h>
|
---|
[a202dbb] | 41 | #include <stdio.h>
|
---|
[74db5a1] | 42 | #include <graph.h>
|
---|
[d57ff6f] | 43 |
|
---|
[74db5a1] | 44 | #include "amdm37x_dispc.h"
|
---|
| 45 |
|
---|
[d57ff6f] | 46 | #define NAME "amdm37x_dispc"
|
---|
[a202dbb] | 47 |
|
---|
[8e4a408] | 48 | static void graph_vsl_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
|
---|
| 49 | {
|
---|
| 50 | visualizer_t *vsl;
|
---|
[74db5a1] | 51 |
|
---|
[8e4a408] | 52 | vsl = (visualizer_t *) ddf_fun_data_get((ddf_fun_t *)arg);
|
---|
| 53 | graph_visualizer_connection(vsl, iid, icall, NULL);
|
---|
| 54 | }
|
---|
[74db5a1] | 55 |
|
---|
[4e3bfab] | 56 | static int amdm37x_dispc_dev_add(ddf_dev_t *dev)
|
---|
[a202dbb] | 57 | {
|
---|
[c7d11a0b] | 58 | assert(dev);
|
---|
[96228d0] | 59 | /* Visualizer part */
|
---|
[c7d11a0b] | 60 | ddf_fun_t *fun = ddf_fun_create(dev, fun_exposed, "viz");
|
---|
[74db5a1] | 61 | if (!fun) {
|
---|
| 62 | ddf_log_error("Failed to create visualizer function\n");
|
---|
| 63 | return ENOMEM;
|
---|
| 64 | }
|
---|
[9cc4b2b4] | 65 |
|
---|
[96228d0] | 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 |
|
---|
[8e4a408] | 76 | ddf_fun_set_conn_handler(fun, graph_vsl_connection);
|
---|
[9cc4b2b4] | 77 | /* Hw part */
|
---|
[74db5a1] | 78 | amdm37x_dispc_t *dispc =
|
---|
[9cc4b2b4] | 79 | ddf_dev_data_alloc(dev, sizeof(amdm37x_dispc_t));
|
---|
[74db5a1] | 80 | if (!dispc) {
|
---|
| 81 | ddf_log_error("Failed to allocate dispc structure\n");
|
---|
| 82 | ddf_fun_destroy(fun);
|
---|
| 83 | return ENOMEM;
|
---|
| 84 | }
|
---|
[9cc4b2b4] | 85 |
|
---|
[96228d0] | 86 | int ret = amdm37x_dispc_init(dispc, vis);
|
---|
[74db5a1] | 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 | }
|
---|
[9cc4b2b4] | 92 |
|
---|
[96228d0] | 93 | /* Report to devman */
|
---|
[74db5a1] | 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 | }
|
---|
[9cc4b2b4] | 101 | ddf_fun_add_to_category(fun, "visualizer");
|
---|
[c7d11a0b] | 102 |
|
---|
| 103 | ddf_log_note("Added device `%s'\n", ddf_dev_get_name(dev));
|
---|
[a202dbb] | 104 | return EOK;
|
---|
| 105 | }
|
---|
| 106 |
|
---|
[4e3bfab] | 107 | static driver_ops_t amdm37x_dispc_driver_ops = {
|
---|
| 108 | .dev_add = amdm37x_dispc_dev_add,
|
---|
[a202dbb] | 109 | };
|
---|
| 110 |
|
---|
[4e3bfab] | 111 | static driver_t amdm37x_dispc_driver = {
|
---|
[a202dbb] | 112 | .name = NAME,
|
---|
[4e3bfab] | 113 | .driver_ops = &amdm37x_dispc_driver_ops
|
---|
[a202dbb] | 114 | };
|
---|
| 115 |
|
---|
| 116 | int main(int argc, char *argv[])
|
---|
| 117 | {
|
---|
[4e3bfab] | 118 | printf("%s: HelenOS AM/DM37x framebuffer driver\n", NAME);
|
---|
[74db5a1] | 119 | ddf_log_init(NAME);
|
---|
[4e3bfab] | 120 | return ddf_driver_main(&amdm37x_dispc_driver);
|
---|
[a202dbb] | 121 | }
|
---|
| 122 |
|
---|
| 123 | /** @}
|
---|
| 124 | */
|
---|