source: mainline/uspace/drv/fb/amdm37x_dispc/main.c@ f03f107

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since f03f107 was 96228d0, checked in by Jan Vesely <jano.vesely@…>, 13 years ago

amdm37x_dispc: Initialize associated visualizer in dispc_init

  • Property mode set to 100644
File size: 3.4 KB
Line 
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/log.h>
38#include <errno.h>
39#include <str_error.h>
40#include <stdio.h>
41#include <ops/graph_dev.h>
42#include <graph.h>
43#include "port.h"
44
45#include "amdm37x_dispc.h"
46
47#define NAME "amdm37x_dispc"
48
49static graph_dev_ops_t graph_vsl_dev_ops = {
50 .connect = (connect_func) &graph_visualizer_connection
51};
52
53static ddf_dev_ops_t graph_fun_ops = {
54 .interfaces[GRAPH_DEV_IFACE] = &graph_vsl_dev_ops
55};
56
57static int amdm37x_dispc_dev_add(ddf_dev_t *dev)
58{
59 /* Visualizer part */
60 ddf_fun_t *fun = ddf_fun_create(dev, fun_exposed, "dispc");
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_ops(fun, &graph_fun_ops);
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 int 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 /* Report to devman */
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 return EOK;
103}
104
105static driver_ops_t amdm37x_dispc_driver_ops = {
106 .dev_add = amdm37x_dispc_dev_add,
107};
108
109static driver_t amdm37x_dispc_driver = {
110 .name = NAME,
111 .driver_ops = &amdm37x_dispc_driver_ops
112};
113
114int main(int argc, char *argv[])
115{
116 printf("%s: HelenOS AM/DM37x framebuffer driver\n", NAME);
117 ddf_log_init(NAME);
118 return ddf_driver_main(&amdm37x_dispc_driver);
119}
120
121/** @}
122 */
Note: See TracBrowser for help on using the repository browser.