1 /*
2  * Copyright (c) 2013 Corey Tabaka
3  *
4  * Use of this source code is governed by a MIT-style
5  * license that can be found in the LICENSE file or at
6  * https://opensource.org/licenses/MIT
7  */
8 
9 #include <lk/err.h>
10 #include <dev/class/fb.h>
11 
class_fb_set_mode(struct device * dev,size_t width,size_t height,size_t bpp)12 status_t class_fb_set_mode(struct device *dev, size_t width, size_t height, size_t bpp) {
13     struct fb_ops *ops = device_get_driver_ops(dev, struct fb_ops, std);
14     if (!ops)
15         return ERR_NOT_CONFIGURED;
16 
17     if (ops->set_mode)
18         return ops->set_mode(dev, width, height, bpp);
19     else
20         return ERR_NOT_SUPPORTED;
21 }
22 
class_fb_get_info(struct device * dev,struct fb_info * info)23 status_t class_fb_get_info(struct device *dev, struct fb_info *info) {
24     struct fb_ops *ops = device_get_driver_ops(dev, struct fb_ops, std);
25     if (!ops)
26         return ERR_NOT_CONFIGURED;
27 
28     if (ops->get_info)
29         return ops->get_info(dev, info);
30     else
31         return ERR_NOT_SUPPORTED;
32 }
33 
class_fb_update(struct device * dev)34 status_t class_fb_update(struct device *dev) {
35     struct fb_ops *ops = device_get_driver_ops(dev, struct fb_ops, std);
36     if (!ops)
37         return ERR_NOT_CONFIGURED;
38 
39     if (ops->update)
40         return ops->update(dev);
41     else
42         return ERR_NOT_SUPPORTED;
43 }
44 
class_fb_update_region(struct device * dev,size_t x,size_t y,size_t width,size_t height)45 status_t class_fb_update_region(struct device *dev, size_t x, size_t y, size_t width, size_t height) {
46     struct fb_ops *ops = device_get_driver_ops(dev, struct fb_ops, std);
47     if (!ops)
48         return ERR_NOT_CONFIGURED;
49 
50     if (ops->update_region)
51         return ops->update_region(dev, x, y, width, height);
52     else
53         return ERR_NOT_SUPPORTED;
54 }
55 
56