| 1 | #!/usr/bin/perl |
|---|
| 2 | ############################################################################# |
|---|
| 3 | # |
|---|
| 4 | # Copyright (c) 2004-2008, Broadcom Corporation. |
|---|
| 5 | # All rights reserved. |
|---|
| 6 | # Confidential Property of Broadcom Corporation. |
|---|
| 7 | # |
|---|
| 8 | # THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 9 | # AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 10 | # EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 11 | # |
|---|
| 12 | # $brcm_Workfile: bapi_callbacks.pm $ |
|---|
| 13 | # $brcm_Revision: 15 $ |
|---|
| 14 | # $brcm_Date: 8/13/08 6:06p $ |
|---|
| 15 | # |
|---|
| 16 | # File Description: |
|---|
| 17 | # |
|---|
| 18 | # Revision History: |
|---|
| 19 | # |
|---|
| 20 | # $brcm_Log: /BSEAV/api/build/proxy/bapi_callbacks.pm $ |
|---|
| 21 | # |
|---|
| 22 | # 15 8/13/08 6:06p mward |
|---|
| 23 | # PR32047: PCM capture API. Merge to main. |
|---|
| 24 | # |
|---|
| 25 | # PR32047/1 5/16/08 6:39p mward |
|---|
| 26 | # PR32047: Initial PCM capture API implementation, ignores display. |
|---|
| 27 | # |
|---|
| 28 | # 14 10/15/07 10:50a mward |
|---|
| 29 | # PR35863: Missing } |
|---|
| 30 | # |
|---|
| 31 | # 13 10/11/07 10:02a dlwin |
|---|
| 32 | # PR 35927: Coverity Defect ID:3029 CHECKED_RETURN |
|---|
| 33 | # |
|---|
| 34 | # 12 6/20/07 5:31p jgarrett |
|---|
| 35 | # PR 26474: Adding boutput_hdmi_status and hdcp_status_callback |
|---|
| 36 | # |
|---|
| 37 | # 11 6/20/07 11:54a erickson |
|---|
| 38 | # PR32381: added b_unregister_callback and |
|---|
| 39 | # BSETTOP_IOCTL_free_handle_callbacks. when a handle is closed, its |
|---|
| 40 | # callbacks are freed in user and kernel space. |
|---|
| 41 | # |
|---|
| 42 | # 10 6/11/07 10:42a erickson |
|---|
| 43 | # PR31914: update proxy with bdecode_settings callbacks |
|---|
| 44 | # |
|---|
| 45 | # 9 2/23/07 4:00p erickson |
|---|
| 46 | # PR26790: don't recreate callbacks for outparams |
|---|
| 47 | # |
|---|
| 48 | # 8 1/5/07 11:52a erickson |
|---|
| 49 | # PR26790: for proxy-layer callback conversion, we must convert back on |
|---|
| 50 | # callback out params. |
|---|
| 51 | # |
|---|
| 52 | # 7 12/15/06 10:01a gmohile |
|---|
| 53 | # PR 26498: pass in settop api handle to register callback |
|---|
| 54 | # |
|---|
| 55 | # 6 9/14/06 5:40p jgarrett |
|---|
| 56 | # PR 24052: Adding NULL callback check to the driver side |
|---|
| 57 | # |
|---|
| 58 | # 5 6/30/06 5:25p jgarrett |
|---|
| 59 | # PR 20139: Removing compiler warning from callbacks |
|---|
| 60 | # |
|---|
| 61 | # 4 6/9/06 3:19p jgarrett |
|---|
| 62 | # PR 21946: Adding new callbacks for hdmi_disconnect, |
|---|
| 63 | # decode_still_picture |
|---|
| 64 | # |
|---|
| 65 | # 3 5/12/05 7:11p mphillip |
|---|
| 66 | # PR12953: Register hotplug callback with the kernel proxy layer for |
|---|
| 67 | # building in kernel-mode |
|---|
| 68 | # |
|---|
| 69 | # 2 4/28/05 4:49p mphillip |
|---|
| 70 | # PR14721: Update the callbacks to handle kernel-mode builds |
|---|
| 71 | # |
|---|
| 72 | # 1 2/7/05 6:55p dlwin |
|---|
| 73 | # Merge down for release 2005_REFSW_MERGETOMAIN: |
|---|
| 74 | # |
|---|
| 75 | # Irvine_BSEAVSW_Devel/2 7/23/04 2:41p erickson |
|---|
| 76 | # PR11771: updated proxy layer for settop api changes |
|---|
| 77 | # |
|---|
| 78 | # Irvine_BSEAVSW_Devel/1 7/9/04 1:38p erickson |
|---|
| 79 | # PR11771: rebuilt proxy layer for settop api dataflow redesign, and |
|---|
| 80 | # handle all callbacks with new perl module |
|---|
| 81 | # |
|---|
| 82 | ############################################################################# |
|---|
| 83 | use strict; |
|---|
| 84 | |
|---|
| 85 | package bapi_callbacks; |
|---|
| 86 | |
|---|
| 87 | # |
|---|
| 88 | # list of all callbacks in the settop api |
|---|
| 89 | # |
|---|
| 90 | # must be kept in sync with bsettop_callback_ioctl.h and bsettop_callback_mgr.c |
|---|
| 91 | # do this to double check: cd BSEAV/api/include; grep bsettop_callback *.h|wc |
|---|
| 92 | # |
|---|
| 93 | # definition |
|---|
| 94 | # 0: function name where callback is passed in |
|---|
| 95 | # 1: enum for callback (see bsettop_callback_ioctl.h) |
|---|
| 96 | # 2: name of settop api associated with callback (used for unregistering callback upon close) |
|---|
| 97 | # 3: name of structure which contains the callback (only needed for register) |
|---|
| 98 | # 4: name of structure member for the callback (only needed for register) |
|---|
| 99 | # 5: type of operation: "in" or "out" |
|---|
| 100 | # 6: unregister function (not used for "out" functions). In general, this should be the close function, not the stop. If you start/stop, the callback |
|---|
| 101 | # handle will be overwritten. It's possible to start, but have start fail, then close. The callback must be freed on close. |
|---|
| 102 | # |
|---|
| 103 | my @callbacks = ( |
|---|
| 104 | ["bplaypump_start", "ioctl_settopapi_bplaypump_read_callback", |
|---|
| 105 | "playpump", "params", "read_callback", "in", "bplaypump_close"], |
|---|
| 106 | ["brecpump_start", "ioctl_settopapi_brecpump_data_write_callback", |
|---|
| 107 | "recpump", "params", "data_write_callback", "in", "brecpump_close"], |
|---|
| 108 | ["brecpump_start", "ioctl_settopapi_brecpump_index_write_callback", |
|---|
| 109 | "recpump", "params", "index_write_callback", "in", "brecpump_close"], |
|---|
| 110 | ["brecpump_start", "ioctl_settopapi_brecpump_overflow_callback", |
|---|
| 111 | "recpump", "params", "overflow", "in", "brecpump_close"], |
|---|
| 112 | ["buser_input_set_settings", "ioctl_settopapi_buser_input_data_ready_callback", |
|---|
| 113 | "ui", "settings", "data_ready_callback", "in", "buser_input_close"], |
|---|
| 114 | ["bmessage_start", "ioctl_settopapi_bmessage_data_ready_callback", |
|---|
| 115 | "message_stream", "params", "data_ready_callback", "in", "bmessage_close"], |
|---|
| 116 | ["bmessage_start", "ioctl_settopapi_bmessage_overflow_callback", |
|---|
| 117 | "message_stream", "params", "overflow", "in", "bmessage_close"], |
|---|
| 118 | ["bgraphics_set", "ioctl_settopapi_bgraphics_operation_complete_callback", |
|---|
| 119 | "graphics", "settings", "operation_complete_callback", "in", "bgraphics_close"], |
|---|
| 120 | ["bpcm_play_start", "ioctl_settopapi_bpcm_play_callback", |
|---|
| 121 | "pcmplay", "settings", "callback", "in", "bpcm_play_close"], |
|---|
| 122 | ["bstream_vbi_set_settings", "ioctl_settopapi_bvbi_cc_data_ready_callback", |
|---|
| 123 | "stream", "settings", "cc_data_ready_callback", "in", "bstream_close"], # NOTE: This won't unregister for playback streams, but there's a fixed number, so the leak is contained. |
|---|
| 124 | ["btuner_tune_qam", "ioctl_settopapi_btuner_qam_params_lock_callback", |
|---|
| 125 | "tuner", "params", "lock_callback", "in", "btuner_close"], |
|---|
| 126 | ["btuner_tune_oob", "ioctl_settopapi_btuner_oob_params_lock_callback", |
|---|
| 127 | "tuner", "params", "lock_callback", "in", "btuner_close"], |
|---|
| 128 | ["btuner_tune_sds", "ioctl_settopapi_btuner_sds_params_lock_callback", |
|---|
| 129 | "tuner", "params", "lock_callback", "in", "btuner_close"], |
|---|
| 130 | ["btuner_tune_vsb", "ioctl_settopapi_btuner_vsb_params_lock_callback", |
|---|
| 131 | "tuner", "params", "lock_callback", "in", "btuner_close"], |
|---|
| 132 | ["boutput_hdmi_set", "ioctl_settopapi_boutput_dvi_settings_hdmi_hotplug_callback", |
|---|
| 133 | "dvi", "settings", "hdmi_hotplug_callback", "in", ""], # NOTE: There's no way to unregister this, but fortunately boutput_dvi_open returns a static handle, so the leak is contained. |
|---|
| 134 | ["boutput_hdmi_set", "ioctl_settopapi_boutput_dvi_settings_hdmi_disconnect_callback", |
|---|
| 135 | "dvi", "settings", "hdmi_disconnect_callback", "in", ""], # NOTE: There's no way to unregister this, but fortunately boutput_dvi_open returns a static handle, so the leak is contained. |
|---|
| 136 | ["boutput_hdmi_set", "ioctl_settopapi_boutput_dvi_settings_hdmi_hdcp_status_callback", |
|---|
| 137 | "dvi", "settings", "hdmi_hdcp_status_callback", "in", ""], # NOTE: There's no way to unregister this, but fortunately boutput_dvi_open returns a static handle, so the leak is contained. |
|---|
| 138 | ["boutput_hdmi_get", "ioctl_settopapi_boutput_dvi_settings_hdmi_hotplug_callback", |
|---|
| 139 | "dvi", "settings", "hdmi_hotplug_callback", "out", ""], |
|---|
| 140 | ["boutput_hdmi_get", "ioctl_settopapi_boutput_dvi_settings_hdmi_disconnect_callback", |
|---|
| 141 | "dvi", "settings", "hdmi_disconnect_callback", "out", ""], |
|---|
| 142 | ["boutput_hdmi_get", "ioctl_settopapi_boutput_dvi_settings_hdmi_hdcp_status_callback", |
|---|
| 143 | "dvi", "settings", "hdmi_hdcp_status_callback", "out", ""], |
|---|
| 144 | ["bdecode_set", "ioctl_settopapi_bdecode_settings_still_picture_done", |
|---|
| 145 | "decode", "settings", "still_picture_done", "in", "bdecode_close"], |
|---|
| 146 | ["bdecode_get", "ioctl_settopapi_bdecode_settings_still_picture_done", |
|---|
| 147 | "decode", "settings", "still_picture_done", "out", ""], |
|---|
| 148 | ["bdecode_set", "ioctl_settopapi_bdecode_settings_video_source_changed", |
|---|
| 149 | "decode", "settings", "video.source_changed", "in", "bdecode_close"], |
|---|
| 150 | ["bdecode_get", "ioctl_settopapi_bdecode_settings_video_source_changed", |
|---|
| 151 | "decode", "settings", "video.source_changed", "out", ""], |
|---|
| 152 | ["bdecode_set", "ioctl_settopapi_bdecode_settings_audio_source_changed", |
|---|
| 153 | "decode", "settings", "audio.source_changed", "in", "bdecode_close"], |
|---|
| 154 | ["bdecode_get", "ioctl_settopapi_bdecode_settings_audio_source_changed", |
|---|
| 155 | "decode", "settings", "audio.source_changed", "out", ""], |
|---|
| 156 | ["bpcm_capture_start", "ioctl_settopapi_bpcm_capture_callback", |
|---|
| 157 | "pcmcapture", "settings", "callback", "in", "bpcm_capture_close"] |
|---|
| 158 | ); |
|---|
| 159 | |
|---|
| 160 | sub build_user_callback { |
|---|
| 161 | my $func = shift; |
|---|
| 162 | my $in_param = shift; # boolean |
|---|
| 163 | my $cb; |
|---|
| 164 | my $text = ""; |
|---|
| 165 | |
|---|
| 166 | for $cb (@callbacks) { |
|---|
| 167 | if ($cb->[0] eq $func->{FUNCNAME}) { |
|---|
| 168 | my $param = "$cb->[3]\-\>$cb->[4]"; |
|---|
| 169 | my $context = "(void*)$cb->[3]\-\>callback_context"; |
|---|
| 170 | if ($cb->[5] eq "in" && $in_param == 1) { |
|---|
| 171 | $text .= " b_register_callback($cb->[1], (void*)$cb->[2], $param, $context);\n"; |
|---|
| 172 | } |
|---|
| 173 | elsif ($cb->[5] eq "out" && $in_param == 0) { |
|---|
| 174 | $text .= " $param = b_lookup_callback($cb->[1], (void*)$cb->[2]);\n"; |
|---|
| 175 | } |
|---|
| 176 | } |
|---|
| 177 | elsif ($cb->[6] eq $func->{FUNCNAME} && $in_param == 1) { |
|---|
| 178 | $text .= " b_unregister_callback($cb->[1], (void*)$cb->[2]);\n"; |
|---|
| 179 | # tell driver to close all callbacks for this handle |
|---|
| 180 | $text .= " rc = ioctl(g_ioctl_fd, BSETTOP_IOCTL_free_handle_callbacks, (void*)$cb->[2]);\n"; |
|---|
| 181 | $text .= " if (rc) {BSETTOP_ERROR(berr_external_error);}\n"; |
|---|
| 182 | } |
|---|
| 183 | } |
|---|
| 184 | return $text; |
|---|
| 185 | } |
|---|
| 186 | |
|---|
| 187 | sub build_kernel_callback { |
|---|
| 188 | my $func = shift; |
|---|
| 189 | my $cb; |
|---|
| 190 | my $text = ""; |
|---|
| 191 | |
|---|
| 192 | for $cb (@callbacks) { |
|---|
| 193 | if ($cb->[0] eq $func->{FUNCNAME} && $cb->[5] eq "in") { |
|---|
| 194 | my $param = "$cb->[3].$cb->[4]"; |
|---|
| 195 | my $handle = "st.$cb->[2]"; |
|---|
| 196 | my $enumtype = "$cb->[1]"; |
|---|
| 197 | my $context = "$cb->[3].callback_context"; |
|---|
| 198 | $text .= " if ( $param ) { $param = b_proxy_create_callback($enumtype, $handle, $context); }\n"; |
|---|
| 199 | } |
|---|
| 200 | } |
|---|
| 201 | return $text; |
|---|
| 202 | } |
|---|
| 203 | |
|---|
| 204 | 1; |
|---|