rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | /* |
| 2 | *FM radio driver kernel module insmod file for wmt dynamic loader |
| 3 | */ |
| 4 | #include <stdlib.h> |
| 5 | #include <stdio.h> |
| 6 | #include <fcntl.h> |
| 7 | #include <errno.h> |
| 8 | #include <unistd.h> |
| 9 | #include <cutils/misc.h> |
| 10 | |
| 11 | //For directory operation |
| 12 | #include <dirent.h> |
| 13 | |
| 14 | #define FMR_MODULES_PATH "/system/lib/modules/mtk_fm_drv.ko" |
| 15 | extern int load_fm_module(int chip_id); |
| 16 | extern int init_module(void *, unsigned long, const char *); |
| 17 | |
| 18 | //insmod |
| 19 | static int insmod(const char *filename, const char *args) |
| 20 | { |
| 21 | void *module; |
| 22 | unsigned int size; |
| 23 | int ret = -1; |
| 24 | int retry = 10; |
| 25 | |
| 26 | printf("filename(%s)\n",filename); |
| 27 | |
| 28 | module = load_file(filename, &size); |
| 29 | if (!module) |
| 30 | { |
| 31 | printf("load file fail\n"); |
| 32 | return -1; |
| 33 | } |
| 34 | |
| 35 | while(retry-- > 0){ |
| 36 | ret = init_module(module, size, args); |
| 37 | |
| 38 | if(ret < 0) |
| 39 | { |
| 40 | printf("insmod module fail(%d)\n",ret); |
| 41 | usleep(10000); |
| 42 | } |
| 43 | else |
| 44 | break; |
| 45 | |
| 46 | } |
| 47 | |
| 48 | free(module); |
| 49 | |
| 50 | return ret; |
| 51 | } |
| 52 | |
| 53 | int load_fm_module(int chip_id) |
| 54 | { |
| 55 | int ret=-1; |
| 56 | ret = insmod(FMR_MODULES_PATH, ""); |
| 57 | if(ret) |
| 58 | { |
| 59 | printf("insert mtk_fm_drv.ko fail(%d)\n",ret); |
| 60 | } |
| 61 | else |
| 62 | { |
| 63 | printf("insert mtk_fm_drv.ko ok\n"); |
| 64 | } |
| 65 | return ret; |
| 66 | } |
| 67 | |