1 /* 2 * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 */ 18 19 #ifndef _LINUX_HIMEDIA_DEVICE_H_ 20 #define _LINUX_HIMEDIA_DEVICE_H_ 21 22 #include <linux/module.h> 23 #include <linux/major.h> 24 #include <linux/device.h> 25 #include "osal_list.h" 26 27 #define HIMEDIA_DEVICE_MAJOR 218 28 #define HIMEDIA_DYNAMIC_MINOR 255 29 30 struct himedia_device; 31 32 struct himedia_ops { 33 /* pm methods */ 34 int (*pm_prepare)(struct himedia_device *); 35 void (*pm_complete)(struct himedia_device *); 36 37 int (*pm_suspend)(struct himedia_device *); 38 int (*pm_resume)(struct himedia_device *); 39 40 int (*pm_freeze)(struct himedia_device *); 41 int (*pm_thaw)(struct himedia_device *); 42 int (*pm_poweroff)(struct himedia_device *); 43 int (*pm_restore)(struct himedia_device *); 44 45 int (*pm_suspend_late)(struct himedia_device *); 46 int (*pm_resume_early)(struct himedia_device *); 47 int (*pm_freeze_late)(struct himedia_device *); 48 int (*pm_thaw_early)(struct himedia_device *); 49 int (*pm_poweroff_late)(struct himedia_device *); 50 int (*pm_restore_early)(struct himedia_device *); 51 52 int (*pm_suspend_noirq)(struct himedia_device *); 53 int (*pm_resume_noirq)(struct himedia_device *); 54 55 int (*pm_freeze_noirq)(struct himedia_device *); 56 int (*pm_thaw_noirq)(struct himedia_device *); 57 int (*pm_poweroff_noirq)(struct himedia_device *); 58 int (*pm_restore_noirq)(struct himedia_device *); 59 }; 60 61 #define HIMIDIA_MAX_DEV_NAME_LEN 32 62 63 struct himedia_driver { 64 struct device_driver driver; 65 struct himedia_ops *ops; 66 char name[HIMIDIA_MAX_DEV_NAME_LEN]; 67 }; 68 69 #define to_himedia_driver(drv) \ 70 container_of((drv), struct himedia_driver, driver) 71 72 struct himedia_device { 73 struct osal_list_head list; 74 75 char devfs_name[HIMIDIA_MAX_DEV_NAME_LEN]; 76 77 unsigned int minor; 78 79 struct device device; 80 81 struct module *owner; 82 83 const struct file_operations *fops; 84 85 struct himedia_ops *drvops; 86 87 /* for internal use */ 88 struct himedia_driver *driver; 89 }; 90 91 #define to_himedia_device(dev) \ 92 container_of((dev), struct himedia_device, device) 93 94 int himedia_register(struct himedia_device *pdev); 95 96 int himedia_unregister(struct himedia_device *pdev); 97 98 #define MODULE_ALIAS_HIMEDIA(minor) \ 99 MODULE_ALIAS("himedia-char-major-" __stringify(HIMEDIA_DEVICE_MAJOR) "-" __stringify(minor)) 100 101 #endif /* _LINUX_HIMEDIA_DEVICE_H_ */ 102