Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/fb/amdm37x_dispc/main.c

    rde19d4a r4f87a85a  
    11/*
    2  * Copyright (c) 2020 Jiri Svoboda
    32 * Copyright (c) 2013 Jan Vesely
    43 * Copyright (c) 2011 Petr Koupy
     
    3635 */
    3736
    38 #include <ddev_srv.h>
    3937#include <ddf/driver.h>
    4038#include <ddf/log.h>
    4139#include <errno.h>
    42 #include <ipcgfx/server.h>
    4340#include <str_error.h>
    4441#include <stdio.h>
     42#include <graph.h>
    4543
    4644#include "amdm37x_dispc.h"
     
    4846#define NAME  "amdm37x_dispc"
    4947
    50 static void amdm37x_client_conn(ipc_call_t *icall, void *arg)
     48static void graph_vsl_connection(ipc_call_t *icall, void *arg)
    5149{
    52         amdm37x_dispc_t *dispc;
    53         ddev_srv_t srv;
    54         sysarg_t gc_id;
    55         gfx_context_t *gc;
    56         errno_t rc;
     50        visualizer_t *vsl;
    5751
    58         dispc = (amdm37x_dispc_t *) ddf_dev_data_get(
    59             ddf_fun_get_dev((ddf_fun_t *) arg));
    60 
    61         gc_id = ipc_get_arg3(icall);
    62 
    63         if (gc_id == 0) {
    64                 /* Set up protocol structure */
    65                 ddev_srv_initialize(&srv);
    66                 srv.ops = &amdm37x_ddev_ops;
    67                 srv.arg = dispc;
    68 
    69                 /* Handle connection */
    70                 ddev_conn(icall, &srv);
    71         } else {
    72                 assert(gc_id == 42);
    73 
    74                 rc = gfx_context_new(&amdm37x_gc_ops, dispc, &gc);
    75                 if (rc != EOK)
    76                         goto error;
    77 
    78                 /* GC connection */
    79                 gc_conn(icall, gc);
    80         }
    81 
    82         return;
    83 error:
    84         async_answer_0(icall, rc);
     52        vsl = (visualizer_t *) ddf_fun_data_get((ddf_fun_t *)arg);
     53        graph_visualizer_connection(vsl, icall, NULL);
    8554}
    8655
     
    8857{
    8958        assert(dev);
    90 
    91         ddf_fun_t *fun = ddf_fun_create(dev, fun_exposed, "a");
     59        /* Visualizer part */
     60        ddf_fun_t *fun = ddf_fun_create(dev, fun_exposed, "viz");
    9261        if (!fun) {
    93                 ddf_log_error("Failed to create display device function.");
     62                ddf_log_error("Failed to create visualizer function.");
    9463                return ENOMEM;
    9564        }
    9665
    97         ddf_fun_set_conn_handler(fun, &amdm37x_client_conn);
     66        visualizer_t *vis = ddf_fun_data_alloc(fun, sizeof(visualizer_t));
     67        if (!vis) {
     68                ddf_log_error("Failed to allocate visualizer structure.");
     69                ddf_fun_destroy(fun);
     70                return ENOMEM;
     71        }
    9872
     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);
    9977        /* Hw part */
    10078        amdm37x_dispc_t *dispc =
     
    10684        }
    10785
    108         errno_t rc = amdm37x_dispc_init(dispc, fun);
     86        errno_t rc = amdm37x_dispc_init(dispc, vis);
    10987        if (rc != EOK) {
    11088                ddf_log_error("Failed to init dispc: %s.", str_error(rc));
     
    122100        }
    123101
    124         rc = ddf_fun_add_to_category(fun, "display-device");
     102        rc = ddf_fun_add_to_category(fun, "visualizer");
    125103        if (rc != EOK) {
    126                 ddf_log_error("Failed to add function: %s to display device "
     104                ddf_log_error("Failed to add function: %s to visualizer "
    127105                    "category.", str_error(rc));
    128106                amdm37x_dispc_fini(dispc);
Note: See TracChangeset for help on using the changeset viewer.