content
stringlengths
19
48.2k
// SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2013 Intel Corporation. All rights reserved. * * */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <stdbool.h> #include <glib.h> #include "lib/bluetooth.h" #include "lib/sco.h" #include "lib/mgmt.h" #include "monitor/bt.h" #include "emulator/bthost.h" #include "emulator/hciemu.h" #include "src/shared/tester.h" #include "src/shared/mgmt.h" struct test_data { const void *test_data; struct mgmt *mgmt; uint16_t mgmt_index; struct hciemu *hciemu; enum hciemu_type hciemu_type; unsigned int io_id; bool disable_esco; bool enable_codecs; }; struct sco_client_data { int expect_err; const uint8_t *send_data; uint16_t data_len; }; static void print_debug(const char *str, void *user_data) { const char *prefix = user_data; tester_print("%s%s", prefix, str); } static void read_info_callback(uint8_t status, uint16_t length, const void *param, void *user_data) { struct test_data *data = tester_get_data(); const struct mgmt_rp_read_info *rp = param; char addr[18]; uint16_t manufacturer; uint32_t supported_settings, current_settings; tester_print("Read Info callback"); tester_print(" Status: 0x%02x", status); if (status || !param) { tester_pre_setup_failed(); return; } ba2str(&rp->bdaddr, addr); manufacturer = btohs(rp->manufacturer); supported_settings = btohl(rp->supported_settings); current_settings = btohl(rp->current_settings); tester_print(" Address: %s", addr); tester_print(" Version: 0x%02x", rp->version); tester_print(" Manufacturer: 0x%04x", manufacturer); tester_print(" Supported settings: 0x%08x", supported_settings); tester_print(" Current settings: 0x%08x", current_settings); tester_print(" Class: 0x%02x%02x%02x", rp->dev_class[2], rp->dev_class[1], rp->dev_class[0]); tester_print(" Name: %s", rp->name); tester_print(" Short name: %s", rp->short_name); if (strcmp(hciemu_get_address(data->hciemu), addr)) { tester_pre_setup_failed(); return; } tester_pre_setup_complete(); } static void index_added_callback(uint16_t index, uint16_t length, const void *param, void *user_data) { struct test_data *data = tester_get_data(); tester_print("Index Added callback"); tester_print(" Index: 0x%04x", index); data->mgmt_index = index; mgmt_send(data->mgmt, MGMT_OP_READ_INFO, data->mgmt_index, 0, NULL, read_info_callback, NULL, NULL); } static void index_removed_callback(uint16_t index, uint16_t length, const void *param, void *user_data) { struct test_data *data = tester_get_data(); tester_print("Index Removed callback"); tester_print(" Index: 0x%04x", index); if (index != data->mgmt_index) return; mgmt_unregister_index(data->mgmt, data->mgmt_index); mgmt_unref(data->mgmt); data->mgmt = NULL; tester_post_teardown_complete(); } static void enable_codec_callback(uint8_t status, uint16_t length, const void *param, void *user_data) { if (status != MGMT_STATUS_SUCCESS) { tester_warn("Failed to enable codecs"); tester_setup_failed(); return; } tester_print("Enabled codecs"); } static void read_index_list_callback(uint8_t status, uint16_t length, const void *param, void *user_data) { struct test_data *data = tester_get_data(); tester_print("Read Index List callback"); tester_print(" Status: 0x%02x", status); if (status || !param) { tester_pre_setup_failed(); return; } mgmt_register(data->mgmt, MGMT_EV_INDEX_ADDED, MGMT_INDEX_NONE, index_added_callback, NULL, NULL); mgmt_register(data->mgmt, MGMT_EV_INDEX_REMOVED, MGMT_INDEX_NONE, index_removed_callback, NULL, NULL); data->hciemu = hciemu_new(HCIEMU_TYPE_BREDRLE); if (!data->hciemu) { tester_warn("Failed to setup HCI emulation"); tester_pre_setup_failed(); return; } if (tester_use_debug()) hciemu_set_debug(data->hciemu, print_debug, "hciemu: ", NULL); tester_print("New hciemu instance created"); if (data->disable_esco) { uint8_t *features; tester_print("Disabling eSCO packet type support"); features = hciemu_get_features(data->hciemu); if (features) features[3] &= ~0x80; } } static void test_pre_setup(const void *test_data) { struct test_data *data = tester_get_data(); data->mgmt = mgmt_new_default(); if (!data->mgmt) { tester_warn("Failed to setup management interface"); tester_pre_setup_failed(); return; } if (tester_use_debug()) mgmt_set_debug(data->mgmt, print_debug, "mgmt: ", NULL); mgmt_send(data->mgmt, MGMT_OP_READ_INDEX_LIST, MGMT_INDEX_NONE, 0, NULL, read_index_list_callback, NULL, NULL); } static void test_post_teardown(const void *test_data) { struct test_data *data = tester_get_data(); hciemu_unref(data->hciemu); data->hciemu = NULL; } static void test_data_free(void *test_data) { struct test_data *data = test_data; if (data->io_id > 0) g_source_remove(data->io_id); free(data); } #define test_sco_full(name, data, setup, func, _disable_esco, _enable_codecs) \ do { \ struct test_data *user; \ user = malloc(sizeof(struct test_data)); \ if (!user) \ break; \ user->hciemu_type = HCIEMU_TYPE_BREDRLE; \ user->io_id = 0; \ user->test_data = data; \ user->disable_esco = _disable_esco; \ user->enable_codecs = _enable_codecs; \ tester_add_full(name, data, \ test_pre_setup, setup, func, NULL, \ test_post_teardown, 2, user, test_data_free); \ } while (0) #define test_sco(name, data, setup, func) \ test_sco_full(name, data, setup, func, false, false) #define test_sco_11(name, data, setup, func) \ test_sco_full(name, data, setup, func, true, false) #define test_offload_sco(name, data, setup, func) \ test_sco_full(name, data, setup, func, false, true) static const struct sco_client_data connect_success = { .expect_err = 0 }; static const struct sco_client_data connect_failure = { .expect_err = EOPNOTSUPP }; const uint8_t data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8}; static const struct sco_client_data connect_send_success = { .expect_err = 0, .data_len = sizeof(data), .send_data = data }; static void client_connectable_complete(uint16_t opcode, uint8_t status, const void *param, uint8_t len, void *user_data) { if (opcode != BT_HCI_CMD_WRITE_SCAN_ENABLE) return; tester_print("Client set connectable status 0x%02x", status); if (status) tester_setup_failed(); else tester_setup_complete(); } static void setup_powered_callback(uint8_t status, uint16_t length, const void *param, void *user_data) { struct test_data *data = tester_get_data(); struct bthost *bthost; if (status != MGMT_STATUS_SUCCESS) { tester_setup_failed(); return; } tester_print("Controller powered on"); bthost = hciemu_client_get_host(data->hciemu); bthost_set_cmd_complete_cb(bthost, client_connectable_complete, data); bthost_write_scan_enable(bthost, 0x03); } static void setup_powered(const void *test_data) { struct test_data *data = tester_get_data(); unsigned char param[] = { 0x01 }; tester_print("Powering on controller"); mgmt_send(data->mgmt, MGMT_OP_SET_CONNECTABLE, data->mgmt_index, sizeof(param), param, NULL, NULL, NULL); mgmt_send(data->mgmt, MGMT_OP_SET_SSP, data->mgmt_index, sizeof(param), param, NULL, NULL, NULL); mgmt_send(data->mgmt, MGMT_OP_SET_LE, data->mgmt_index, sizeof(param), param, NULL, NULL, NULL); if (data->enable_codecs) { /* a6695ace-ee7f-4fb9-881a-5fac66c629af */ static const uint8_t uuid[16] = { 0xaf, 0x29, 0xc6, 0x66, 0xac, 0x5f, 0x1a, 0x88, 0xb9, 0x4f, 0x7f, 0xee, 0xce, 0x5a, 0x69, 0xa6, }; struct mgmt_cp_set_exp_feature cp; memset(&cp, 0, sizeof(cp)); memcpy(cp.uuid, uuid, 16); cp.action = 1; tester_print("Enabling codecs"); mgmt_send(data->mgmt, MGMT_OP_SET_EXP_FEATURE, data->mgmt_index, sizeof(cp), &cp, enable_codec_callback, NULL, NULL); } mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index, sizeof(param), param, setup_powered_callback, NULL, NULL); } static void test_framework(const void *test_data) { tester_test_passed(); } static void test_socket(const void *test_data) { int sk; sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO); if (sk < 0) { tester_warn("Can't create socket: %s (%d)", strerror(errno), errno); tester_test_failed(); return; } close(sk); tester_test_passed(); } static void test_codecs_getsockopt(const void *test_data) { int sk, err; socklen_t len; char buffer[255]; sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO); if (sk < 0) { tester_warn("Can't create socket: %s (%d)", strerror(errno), errno); tester_test_failed(); return; } len = sizeof(buffer); memset(buffer, 0, len); err = getsockopt(sk, SOL_BLUETOOTH, BT_CODEC, buffer, &len); if (err < 0) { tester_warn("Can't get socket option : %s (%d)", strerror(errno), errno); tester_test_failed(); goto end; } tester_test_passed(); end: close(sk); } static void test_codecs_setsockopt(const void *test_data) { int sk, err; char buffer[255]; struct bt_codecs *codecs; sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO); if (sk < 0) { tester_warn("Can't create socket: %s (%d)", strerror(errno), errno); tester_test_failed(); return; } memset(buffer, 0, sizeof(buffer)); codecs = (void *)buffer; codecs->codecs[0].id = 0x05; codecs->num_codecs = 1; codecs->codecs[0].data_path_id = 1; codecs->codecs[0].num_caps = 0x00; err = setsockopt(sk, SOL_BLUETOOTH, BT_CODEC, codecs, sizeof(buffer)); if (err < 0) { tester_warn("Can't set socket option : %s (%d)", strerror(errno), errno); tester_test_failed(); goto end; } tester_test_passed(); end: close(sk); } static void test_getsockopt(const void *test_data) { int sk, err; socklen_t len; struct bt_voice voice; sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO); if (sk < 0) { tester_warn("Can't create socket: %s (%d)", strerror(errno), errno); tester_test_failed(); return; } len = sizeof(voice); memset(&voice, 0, len); err = getsockopt(sk, SOL_BLUETOOTH, BT_VOICE, &voice, &len); if (err < 0) { tester_warn("Can't get socket option : %s (%d)", strerror(errno), errno); tester_test_failed(); goto end; } if (voice.setting != BT_VOICE_CVSD_16BIT) { tester_warn("Invalid voice setting"); tester_test_failed(); goto end; } tester_test_passed(); end: close(sk); } static void test_setsockopt(const void *test_data) { int sk, err; socklen_t len; struct bt_voice voice; sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO); if (sk < 0) { tester_warn("Can't create socket: %s (%d)", strerror(errno), errno); tester_test_failed(); goto end; } len = sizeof(voice); memset(&voice, 0, len); err = getsockopt(sk, SOL_BLUETOOTH, BT_VOICE, &voice, &len); if (err < 0) { tester_warn("Can't get socket option : %s (%d)", strerror(errno), errno); tester_test_failed(); goto end; } if (voice.setting != BT_VOICE_CVSD_16BIT) { tester_warn("Invalid voice setting"); tester_test_failed(); goto end; } memset(&voice, 0, sizeof(voice)); voice.setting = BT_VOICE_TRANSPARENT; err = setsockopt(sk, SOL_BLUETOOTH, BT_VOICE, &voice, sizeof(voice)); if (err < 0) { tester_warn("Can't set socket option : %s (%d)", strerror(errno), errno); tester_test_failed(); goto end; } len = sizeof(voice); memset(&voice, 0, len); err = getsockopt(sk, SOL_BLUETOOTH, BT_VOICE, &voice, &len); if (err < 0) { tester_warn("Can't get socket option : %s (%d)", strerror(errno), errno); tester_test_failed(); goto end; } if (voice.setting != BT_VOICE_TRANSPARENT) { tester_warn("Invalid voice setting"); tester_test_failed(); goto end; } tester_test_passed(); end: close(sk); } static int create_sco_sock(struct test_data *data) { const uint8_t *central_bdaddr; struct sockaddr_sco addr; int sk, err; sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET | SOCK_NONBLOCK, BTPROTO_SCO); if (sk < 0) { err = -errno; tester_warn("Can't create socket: %s (%d)", strerror(errno), errno); return err; } central_bdaddr = hciemu_get_central_bdaddr(data->hciemu); if (!central_bdaddr) { tester_warn("No central bdaddr"); return -ENODEV; } memset(&addr, 0, sizeof(addr)); addr.sco_family = AF_BLUETOOTH; bacpy(&addr.sco_bdaddr, (void *) central_bdaddr); if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) { err = -errno; tester_warn("Can't bind socket: %s (%d)", strerror(errno), errno); close(sk); return err; } return sk; } static int connect_sco_sock(struct test_data *data, int sk) { const uint8_t *client_bdaddr; struct sockaddr_sco addr; int err; client_bdaddr = hciemu_get_client_bdaddr(data->hciemu); if (!client_bdaddr) { tester_warn("No client bdaddr"); return -ENODEV; } memset(&addr, 0, sizeof(addr)); addr.sco_family = AF_BLUETOOTH; bacpy(&addr.sco_bdaddr, (void *) client_bdaddr); err = connect(sk, (struct sockaddr *) &addr, sizeof(addr)); if (err < 0 && !(errno == EAGAIN || errno == EINPROGRESS)) { err = -errno; tester_warn("Can't connect socket: %s (%d)", strerror(errno), errno); return err; } return 0; } static gboolean sco_connect_cb(GIOChannel *io, GIOCondition cond, gpointer user_data) { struct test_data *data = tester_get_data(); const struct sco_client_data *scodata = data->test_data; int err, sk_err, sk; socklen_t len = sizeof(sk_err); data->io_id = 0; sk = g_io_channel_unix_get_fd(io); if (getsockopt(sk, SOL_SOCKET, SO_ERROR, &sk_err, &len) < 0) err = -errno; else err = -sk_err; if (err < 0) tester_warn("Connect failed: %s (%d)", strerror(-err), -err); else tester_print("Successfully connected"); if (scodata->send_data) { ssize_t ret; tester_print("Writing %u bytes of data", scodata->data_len); ret = write(sk, scodata->send_data, scodata->data_len); if (scodata->data_len != ret) { tester_warn("Failed to write %u bytes: %zu %s (%d)", scodata->data_len, ret, strerror(errno), errno); err = -errno; } } if (-err != scodata->expect_err) tester_test_failed(); else tester_test_passed(); return FALSE; } static void test_connect(const void *test_data) { struct test_data *data = tester_get_data(); GIOChannel *io; int sk; sk = create_sco_sock(data); if (sk < 0) { tester_test_failed(); return; } if (connect_sco_sock(data, sk) < 0) { close(sk); tester_test_failed(); return; } io = g_io_channel_unix_new(sk); g_io_channel_set_close_on_unref(io, TRUE); data->io_id = g_io_add_watch(io, G_IO_OUT, sco_connect_cb, NULL); g_io_channel_unref(io); tester_print("Connect in progress"); } static void test_connect_transp(const void *test_data) { struct test_data *data = tester_get_data(); const struct sco_client_data *scodata = data->test_data; int sk, err; struct bt_voice voice; sk = create_sco_sock(data); if (sk < 0) { tester_test_failed(); return; } memset(&voice, 0, sizeof(voice)); voice.setting = BT_VOICE_TRANSPARENT; err = setsockopt(sk, SOL_BLUETOOTH, BT_VOICE, &voice, sizeof(voice)); if (err < 0) { tester_warn("Can't set socket option : %s (%d)", strerror(errno), errno); tester_test_failed(); goto end; } err = connect_sco_sock(data, sk); tester_warn("Connect returned %s (%d), expected %s (%d)", strerror(-err), -err, strerror(scodata->expect_err), scodata->expect_err); if (-err != scodata->expect_err) tester_test_failed(); else tester_test_passed(); end: close(sk); } static void test_connect_offload_msbc(const void *test_data) { struct test_data *data = tester_get_data(); const struct sco_client_data *scodata = data->test_data; int sk, err; int len; char buffer[255]; struct bt_codecs *codecs; sk = create_sco_sock(data); if (sk < 0) { tester_test_failed(); return; } len = sizeof(buffer); memset(buffer, 0, len); codecs = (void *)buffer; codecs->codecs[0].id = 0x05; codecs->num_codecs = 1; codecs->codecs[0].data_path_id = 1; codecs->codecs[0].num_caps = 0x00; err = setsockopt(sk, SOL_BLUETOOTH, BT_CODEC, codecs, sizeof(buffer)); if (err < 0) { tester_warn("Can't set socket option : %s (%d)", strerror(errno), errno); tester_test_failed(); goto end; } err = connect_sco_sock(data, sk); tester_warn("Connect returned %s (%d), expected %s (%d)", strerror(-err), -err, strerror(scodata->expect_err), scodata->expect_err); if (-err != scodata->expect_err) tester_test_failed(); else tester_test_passed(); end: close(sk); } int main(int argc, char *argv[]) { tester_init(&argc, &argv); test_sco("Basic Framework - Success", NULL, setup_powered, test_framework); test_sco("Basic SCO Socket - Success", NULL, setup_powered, test_socket); test_sco("Basic SCO Get Socket Option - Success", NULL, setup_powered, test_getsockopt); test_sco("Basic SCO Set Socket Option - Success", NULL, setup_powered, test_setsockopt); test_sco("eSCO CVSD - Success", &connect_success, setup_powered, test_connect); test_sco("eSCO mSBC - Success", &connect_success, setup_powered, test_connect_transp); test_sco_11("SCO CVSD 1.1 - Success", &connect_success, setup_powered, test_connect); test_sco_11("SCO mSBC 1.1 - Failure", &connect_failure, setup_powered, test_connect_transp); test_sco("SCO CVSD Send - Success", &connect_send_success, setup_powered, test_connect); test_offload_sco("Basic SCO Get Socket Option - Offload - Success", NULL, setup_powered, test_codecs_getsockopt); test_offload_sco("Basic SCO Set Socket Option - Offload - Success", NULL, setup_powered, test_codecs_setsockopt); test_offload_sco("eSCO mSBC - Offload - Success", &connect_success, setup_powered, test_connect_offload_msbc); return tester_run(); }
#include <stdio.h> /* Merge the sorted subarrays arr[start:mid] & arr[mid:end] */ void merge(int *arr, int start, int mid, int end) { int i, j, k, n1, n2; //printf("%d %d %d\n", start, mid, end); n1 = mid - start; n2 = end - mid; int left[n1], right[n2]; // Store the left and right subarray for(i = 0; i < n1; i++) { left[i] = arr[start+i]; } for(i = 0; i < n2; i++) { right[i] = arr[mid+i]; } i = j = 0; for(k = start; k < end && i < n1 && j < n2; k++) { if(left[i] < right[j]) { arr[k] = left[i++]; } else { arr[k] = right[j++]; } } while(j < n2 && k < end) { arr[k++] = right[j++]; } while(i < n1 && k < end) { arr[k++] = left[i++]; } } /* Sort the subarray arr[start:end] */ void merge_sort(int *arr, int start, int end) { int size = end - start; if(size > 1) { int mid; mid = (start + end) / 2; merge_sort(arr, start, mid); merge_sort(arr, mid, end); //printf("%d %d %d\n", start, mid, end); merge(arr, start, mid, end); } } int main(void) { int n, m, i, diff, min; scanf("%d %d", &n, &m); int arr[m]; for(i = 0; i < m; i++) { scanf("%d", &arr[i]); } merge_sort(arr, 0, m); min = arr[n-1] - arr[0]; for(i = 0; i <= m-n; i++) { diff = arr[n+i-1] - arr[i]; if(diff < min) { min = diff; } } printf("%d\n", min); return 0; }
/** * This function sets the sda pin. * * @param data ab32 config class. * @param state The sda pin state. */ static void ab32_set_sda(void *data, rt_int32_t state) { struct ab32_soft_i2c_config* cfg = (struct ab32_soft_i2c_config*)data; if (cfg->sda_mode == PIN_MODE_INPUT_PULLUP) { cfg->sda_mode = PIN_MODE_OUTPUT_OD; rt_pin_mode(cfg->sda, cfg->sda_mode); } if (state) { rt_pin_write(cfg->sda, PIN_HIGH); } else { rt_pin_write(cfg->sda, PIN_LOW); } }
///< now we deal the message here static int oc_msg_deal(oc_mqtt_profile_msgrcv_t *demo_msg) { oc_mqtt_profile_propertysetresp_t propertysetresp; LINK_LOG_DEBUG("RCVMSG:type:%d reuqestID:%s payloadlen:%d payload:%s\n\r",\ (int) demo_msg->type,demo_msg->request_id==NULL?"NULL":demo_msg->request_id,\ demo_msg->msg_len,(char *)demo_msg->msg); switch(demo_msg->type) { case EN_OC_MQTT_PROFILE_MSG_TYPE_DOWN_MSGDOWN: break; case EN_OC_MQTT_PROFILE_MSG_TYPE_DOWN_COMMANDS: oc_cmd_deal(demo_msg); break; case EN_OC_MQTT_PROFILE_MSG_TYPE_DOWN_PROPERTYSET: propertysetresp.request_id = demo_msg->request_id; propertysetresp.ret_code = 0; propertysetresp.ret_description = NULL; (void)oc_mqtt_profile_propertysetresp(NULL,&propertysetresp); break; case EN_OC_MQTT_PROFILE_MSG_TYPE_DOWN_PROPERTYGET: break; case EN_OC_MQTT_PROFILE_MSG_TYPE_DOWN_EVENT: break; default: break; } return 0; }
/* debug function: a routine I want in the library to make my life easier when * using a source debugger. please ignore any "defined but not used" warnings */ static void dump_keys(MPI_Info info) { int i, nkeys, flag; char key[MPI_MAX_INFO_KEY]; char value[MPI_MAX_INFO_VAL]; MPI_Info_get_nkeys(info, &nkeys); for (i=0; i<nkeys; i++) { MPI_Info_get_nthkey(info, i, key); ADIOI_Info_get(info, key, MPI_MAX_INFO_VAL-1, value, &flag); printf("key = %s, value = %s\n", key, value); } return; }
// Rechercher un membre dans une liste int rechercherUnMembre(liste_membres liste, char *numero_membre) { int test=ECHEC; liste_membres liste_membres_temporaire=liste; while(liste_membres_temporaire != NULL) { if (strcmp(numero_membre, liste_membres_temporaire->numero_membre) == 0) { return test = SUCCES; } else { liste_membres_temporaire = liste_membres_temporaire->suivant; } } return test=ECHEC; }
/********************************************************************** caller: owner of the object prototype: ANSC_STATUS AnscCryptoDecompress ( ULONG algorithm, PVOID compact, ULONG size, PVOID plain, PULONG pOutSize ); description: This function performs cryptography computation. argument: ULONG algorithm Specifies the cryptography algorithm to use. PVOID compact Specifies the data buffer to which the cryptography algorithm is to be applied. ULONG size Specifies the size of the data buffer. PVOID plain Specifies the data buffer to which the cryptography algorithm is to be applied. PULONG pOutSize The buffer of output size; return: the status of the operation. **********************************************************************/ ANSC_STATUS AnscCryptoDecompress ( ULONG algorithm, PVOID compact, ULONG size, PVOID plain, PULONG pOutSize ) { ANSC_STATUS ulResult = 0; switch ( algorithm ) { case ANSC_CRYPTO_COMPRESSION_OUT : ulResult = AnscCryptoOutDecompress ( compact, size, plain, pOutSize ); break; case ANSC_CRYPTO_COMPRESSION_DEFLATE : ulResult = AnscCryptoDeflateDecompress ( compact, size, plain, pOutSize ); break; #ifdef _ANSC_LZS_USED_ case ANSC_CRYPTO_COMPRESSION_LZS : ulResult = AnscCryptoLzsDecompress ( compact, size, plain, pOutSize ); break; #endif case ANSC_CRYPTO_COMPRESSION_V42BIS : ulResult = AnscCryptoV42bisDecompress ( compact, size, plain, pOutSize ); break; case ANSC_CRYPTO_COMPRESSION_ZLIB : ulResult = AnscCryptoZlibDecompress ( compact, size, plain, pOutSize ); break; case ANSC_CRYPTO_COMPRESSION_GZIP : ulResult = AnscCryptoGzipDecompress ( compact, size, plain, pOutSize ); break; default : ulResult = 0; break; } return ulResult; }
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argv,char *argc[]) { char string[101],vowels[6]={'A','O','Y','E','U','I'},i,j,flag=1; scanf("%s",string); getchar(); for (i=0;i<strlen(string);i++) { flag=1; for (j=0;j<6;j++) { if ((string[i]<97)&&string[i]==vowels[j]) { flag=0; break; } else if (string[i]==vowels[j]+32) { flag=0; break; } } if (flag) { if (string[i]<97) { printf(".%c",string[i]+32); } else printf(".%c",string[i]); } } printf("\n"); return 0; }
/** * @brief reset the pointers of a dlb_buffer to point to beginning of * actual data area */ static inline void buffer_reset (buffer *buf ) { unsigned int i; for (i = 0; i != buf->buf.nchannel; ++i) { buf->ppdata[i] = &buf->channeldata[i]; } }
/* * TSParserGetPrsid - find a TS parser by possibly qualified name * * If not found, returns InvalidOid if failOK, else throws error */ Oid TSParserGetPrsid(List *names, bool failOK) { char *schemaname; char *parser_name; Oid namespaceId; Oid prsoid = InvalidOid; ListCell *l; DeconstructQualifiedName(names, &schemaname, &parser_name); if (schemaname) { namespaceId = LookupExplicitNamespace(schemaname); prsoid = GetSysCacheOid2(TSPARSERNAMENSP, PointerGetDatum(parser_name), ObjectIdGetDatum(namespaceId)); } else { recomputeNamespacePath(); foreach(l, activeSearchPath) { namespaceId = lfirst_oid(l); if (namespaceId == myTempNamespace) continue; prsoid = GetSysCacheOid2(TSPARSERNAMENSP, PointerGetDatum(parser_name), ObjectIdGetDatum(namespaceId)); if (OidIsValid(prsoid)) break; } } if (!OidIsValid(prsoid) && !failOK) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("text search parser \"%s\" does not exist", NameListToString(names)))); return prsoid; }
/** * Copyright 2022 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef MINDSPORE_CCSRC_PLUGIN_DEVICE_CPU_KERNEL_ADDCMUL_CPU_KERNEL_H_ #define MINDSPORE_CCSRC_PLUGIN_DEVICE_CPU_KERNEL_ADDCMUL_CPU_KERNEL_H_ #include <iostream> #include <string> #include <vector> #include <map> #include <utility> #include "plugin/device/cpu/kernel/cpu_kernel.h" #include "plugin/factory/ms_factory.h" #include "plugin/device/cpu/kernel/nnacl/arithmetic_parameter.h" namespace mindspore { namespace kernel { class AddcmulCpuKernelMod : public NativeCpuKernelMod { public: AddcmulCpuKernelMod() = default; ~AddcmulCpuKernelMod() override = default; bool Init(const BaseOperatorPtr &base_operator, const std::vector<KernelTensorPtr> &inputs, const std::vector<KernelTensorPtr> &outputs) override; int Resize(const BaseOperatorPtr &base_operator, const std::vector<KernelTensorPtr> &inputs, const std::vector<KernelTensorPtr> &outputs, const std::map<uint32_t, tensor::TensorPtr> &) override; bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace, const std::vector<AddressPtr> &outputs) override; std::vector<KernelAttr> GetOpSupport() override; private: TypeId dtype_{kTypeUnknown}; TypeId dtype_value_{kTypeUnknown}; std::vector<int64_t> input_shape0_; std::vector<int64_t> input_shape1_; std::vector<int64_t> input_shape2_; std::vector<int64_t> input_shape3_; std::vector<int64_t> output_shape_; size_t output_size_{1}; size_t data_shape_size_{0}; size_t inputx_shape_size_{0}; size_t inputy_shape_size_{0}; size_t value_shape_size_{0}; ArithmeticParameter mul_para_{}; template <typename T> bool AddcmulCheck(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &outputs); template <typename T1, typename T2> bool AddcmulCompute(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &outputs); }; } // namespace kernel } // namespace mindspore #endif // MINDSPORE_CCSRC_PLUGIN_DEVICE_CPU_KERNEL_ADDCMUL_CPU_KERNEL_H_
/** * Return the highest NUMA node ID available to the process. * The first node is always identified as 1, as 0 is used to indicate no affinity. * * This function should be called to test the availability of NUMA <em>before</em> * calling any of the other NUMA functions. * * If NUMA is not enabled or supported this will always return 0. * * @return The highest NUMA node ID available to the process. 0 if no affinity, or NUMA not enabled. */ uintptr_t omrthread_numa_get_max_node(void) { uintptr_t result = 0; ULONG nodeNumber = 0; if (isNumaAvailable && (GetNumaHighestNodeNumber(&nodeNumber)) && (nodeNumber > 1)) { result = (uintptr_t)nodeNumber + 1; } return result; }
#include <stdio.h> #include "fitsio.h" int main(int argc, char *argv[]) { fitsfile *infptr; /* FITS file pointers defined in fitsio.h */ int status = 0; /* status must always be initialized = 0 */ int errors = 0; /* 0 means no errors were encountered */ int colnum; /* column number */ int ii; /* dummy index */ if (argc < 3) { printf("usage: fitsdelcol fitsfile.fits[HDU] COLNUM1 [COLNUM2 ...]\n" " where HDU is the HDU number or name to use, \n" " and COLNUM is the name or index of the column to remove\n\n"); exit(0); } /* Open the input file */ if (!fits_open_file(&infptr, argv[1], READWRITE, &status)) { for (ii = 2; ii < argc; ii++) { fits_get_colnum(infptr, CASEINSEN, argv[ii], &colnum, &status); if (status) { /* if error occured, print out error message */ fits_report_error(stderr, status); status = 0; /* Reset to properly register new errors */ errors = 1; } else { fits_delete_col(infptr, colnum, &status); /* if error occured, print out error message */ if (status) { fits_report_error(stderr, status); status = 0; /* Reset to properly register new errors */ errors = 1; } } } /* Close the input file */ fits_close_file(infptr, &status); if (status) { fits_report_error(stderr, status); errors = 1; } } return (errors); }
/*! Make the heap have the given size, by removing the worst elements. Only applicable when s < size(). */ void size ( int s ) { if ( s<=0 ) { init(); return; } if ( s>=size() ) return; GsArray<Elem> tmp(s,s); while ( tmp.size()<s ) { tmp.push() = _heap.top(); remove(); } init(); while ( tmp.size()>0 ) { insert ( tmp.top().e, tmp.top().c ); tmp.pop(); } }
/* * tps65910.c -- TI TPS6591x * * Copyright 2010 Texas Instruments Inc. * * Author: Graeme Gregory <gg@slimlogic.co.uk> * Author: Jorge Eduardo Candelaria <jedu@slimlogic.co.uk> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * */ #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/init.h> #include <linux/err.h> #include <linux/slab.h> #include <linux/i2c.h> #include <linux/interrupt.h> #include <linux/irq.h> #include <linux/irqdomain.h> #include <linux/mfd/core.h> #include <linux/regmap.h> #include <linux/mfd/tps65910.h> #include <linux/of_device.h> static struct resource rtc_resources[] = { { .start = TPS65910_IRQ_RTC_ALARM, .end = TPS65910_IRQ_RTC_ALARM, .flags = IORESOURCE_IRQ, } }; static struct mfd_cell tps65910s[] = { { .name = "tps65910-gpio", }, { .name = "tps65910-pmic", }, { .name = "tps65910-rtc", .num_resources = ARRAY_SIZE(rtc_resources), .resources = &rtc_resources[0], }, { .name = "tps65910-power", }, }; static const struct regmap_irq tps65911_irqs[] = { /* INT_STS */ [TPS65911_IRQ_PWRHOLD_F] = { .mask = INT_MSK_PWRHOLD_F_IT_MSK_MASK, .reg_offset = 0, }, [TPS65911_IRQ_VBAT_VMHI] = { .mask = INT_MSK_VMBHI_IT_MSK_MASK, .reg_offset = 0, }, [TPS65911_IRQ_PWRON] = { .mask = INT_MSK_PWRON_IT_MSK_MASK, .reg_offset = 0, }, [TPS65911_IRQ_PWRON_LP] = { .mask = INT_MSK_PWRON_LP_IT_MSK_MASK, .reg_offset = 0, }, [TPS65911_IRQ_PWRHOLD_R] = { .mask = INT_MSK_PWRHOLD_R_IT_MSK_MASK, .reg_offset = 0, }, [TPS65911_IRQ_HOTDIE] = { .mask = INT_MSK_HOTDIE_IT_MSK_MASK, .reg_offset = 0, }, [TPS65911_IRQ_RTC_ALARM] = { .mask = INT_MSK_RTC_ALARM_IT_MSK_MASK, .reg_offset = 0, }, [TPS65911_IRQ_RTC_PERIOD] = { .mask = INT_MSK_RTC_PERIOD_IT_MSK_MASK, .reg_offset = 0, }, /* INT_STS2 */ [TPS65911_IRQ_GPIO0_R] = { .mask = INT_MSK2_GPIO0_R_IT_MSK_MASK, .reg_offset = 1, }, [TPS65911_IRQ_GPIO0_F] = { .mask = INT_MSK2_GPIO0_F_IT_MSK_MASK, .reg_offset = 1, }, [TPS65911_IRQ_GPIO1_R] = { .mask = INT_MSK2_GPIO1_R_IT_MSK_MASK, .reg_offset = 1, }, [TPS65911_IRQ_GPIO1_F] = { .mask = INT_MSK2_GPIO1_F_IT_MSK_MASK, .reg_offset = 1, }, [TPS65911_IRQ_GPIO2_R] = { .mask = INT_MSK2_GPIO2_R_IT_MSK_MASK, .reg_offset = 1, }, [TPS65911_IRQ_GPIO2_F] = { .mask = INT_MSK2_GPIO2_F_IT_MSK_MASK, .reg_offset = 1, }, [TPS65911_IRQ_GPIO3_R] = { .mask = INT_MSK2_GPIO3_R_IT_MSK_MASK, .reg_offset = 1, }, [TPS65911_IRQ_GPIO3_F] = { .mask = INT_MSK2_GPIO3_F_IT_MSK_MASK, .reg_offset = 1, }, /* INT_STS2 */ [TPS65911_IRQ_GPIO4_R] = { .mask = INT_MSK3_GPIO4_R_IT_MSK_MASK, .reg_offset = 2, }, [TPS65911_IRQ_GPIO4_F] = { .mask = INT_MSK3_GPIO4_F_IT_MSK_MASK, .reg_offset = 2, }, [TPS65911_IRQ_GPIO5_R] = { .mask = INT_MSK3_GPIO5_R_IT_MSK_MASK, .reg_offset = 2, }, [TPS65911_IRQ_GPIO5_F] = { .mask = INT_MSK3_GPIO5_F_IT_MSK_MASK, .reg_offset = 2, }, [TPS65911_IRQ_WTCHDG] = { .mask = INT_MSK3_WTCHDG_IT_MSK_MASK, .reg_offset = 2, }, [TPS65911_IRQ_VMBCH2_H] = { .mask = INT_MSK3_VMBCH2_H_IT_MSK_MASK, .reg_offset = 2, }, [TPS65911_IRQ_VMBCH2_L] = { .mask = INT_MSK3_VMBCH2_L_IT_MSK_MASK, .reg_offset = 2, }, [TPS65911_IRQ_PWRDN] = { .mask = INT_MSK3_PWRDN_IT_MSK_MASK, .reg_offset = 2, }, }; static const struct regmap_irq tps65910_irqs[] = { /* INT_STS */ [TPS65910_IRQ_VBAT_VMBDCH] = { .mask = TPS65910_INT_MSK_VMBDCH_IT_MSK_MASK, .reg_offset = 0, }, [TPS65910_IRQ_VBAT_VMHI] = { .mask = TPS65910_INT_MSK_VMBHI_IT_MSK_MASK, .reg_offset = 0, }, [TPS65910_IRQ_PWRON] = { .mask = TPS65910_INT_MSK_PWRON_IT_MSK_MASK, .reg_offset = 0, }, [TPS65910_IRQ_PWRON_LP] = { .mask = TPS65910_INT_MSK_PWRON_LP_IT_MSK_MASK, .reg_offset = 0, }, [TPS65910_IRQ_PWRHOLD] = { .mask = TPS65910_INT_MSK_PWRHOLD_IT_MSK_MASK, .reg_offset = 0, }, [TPS65910_IRQ_HOTDIE] = { .mask = TPS65910_INT_MSK_HOTDIE_IT_MSK_MASK, .reg_offset = 0, }, [TPS65910_IRQ_RTC_ALARM] = { .mask = TPS65910_INT_MSK_RTC_ALARM_IT_MSK_MASK, .reg_offset = 0, }, [TPS65910_IRQ_RTC_PERIOD] = { .mask = TPS65910_INT_MSK_RTC_PERIOD_IT_MSK_MASK, .reg_offset = 0, }, /* INT_STS2 */ [TPS65910_IRQ_GPIO_R] = { .mask = TPS65910_INT_MSK2_GPIO0_F_IT_MSK_MASK, .reg_offset = 1, }, [TPS65910_IRQ_GPIO_F] = { .mask = TPS65910_INT_MSK2_GPIO0_R_IT_MSK_MASK, .reg_offset = 1, }, }; static struct regmap_irq_chip tps65911_irq_chip = { .name = "tps65910", .irqs = tps65911_irqs, .num_irqs = ARRAY_SIZE(tps65911_irqs), .num_regs = 3, .irq_reg_stride = 2, .status_base = TPS65910_INT_STS, .mask_base = TPS65910_INT_MSK, .ack_base = TPS65910_INT_STS, }; static struct regmap_irq_chip tps65910_irq_chip = { .name = "tps65910", .irqs = tps65910_irqs, .num_irqs = ARRAY_SIZE(tps65910_irqs), .num_regs = 2, .irq_reg_stride = 2, .status_base = TPS65910_INT_STS, .mask_base = TPS65910_INT_MSK, .ack_base = TPS65910_INT_STS, }; static int tps65910_irq_init(struct tps65910 *tps65910, int irq, struct tps65910_platform_data *pdata) { int ret = 0; static struct regmap_irq_chip *tps6591x_irqs_chip; if (!irq) { dev_warn(tps65910->dev, "No interrupt support, no core IRQ\n"); return -EINVAL; } if (!pdata) { dev_warn(tps65910->dev, "No interrupt support, no pdata\n"); return -EINVAL; } switch (tps65910_chip_id(tps65910)) { case TPS65910: tps6591x_irqs_chip = &tps65910_irq_chip; break; case TPS65911: tps6591x_irqs_chip = &tps65911_irq_chip; break; } tps65910->chip_irq = irq; ret = regmap_add_irq_chip(tps65910->regmap, tps65910->chip_irq, IRQF_ONESHOT, pdata->irq_base, tps6591x_irqs_chip, &tps65910->irq_data); if (ret < 0) { dev_warn(tps65910->dev, "Failed to add irq_chip %d\n", ret); tps65910->chip_irq = 0; } return ret; } static int tps65910_irq_exit(struct tps65910 *tps65910) { if (tps65910->chip_irq > 0) regmap_del_irq_chip(tps65910->chip_irq, tps65910->irq_data); return 0; } static bool is_volatile_reg(struct device *dev, unsigned int reg) { struct tps65910 *tps65910 = dev_get_drvdata(dev); /* * Caching all regulator registers. * All regualator register address range is same for * TPS65910 and TPS65911 */ if ((reg >= TPS65910_VIO) && (reg <= TPS65910_VDAC)) { /* Check for non-existing register */ if (tps65910_chip_id(tps65910) == TPS65910) if ((reg == TPS65911_VDDCTRL_OP) || (reg == TPS65911_VDDCTRL_SR)) return true; return false; } return true; } static const struct regmap_config tps65910_regmap_config = { .reg_bits = 8, .val_bits = 8, .volatile_reg = is_volatile_reg, .max_register = TPS65910_MAX_REGISTER - 1, .cache_type = REGCACHE_RBTREE, }; static int tps65910_ck32k_init(struct tps65910 *tps65910, struct tps65910_board *pmic_pdata) { int ret; if (!pmic_pdata->en_ck32k_xtal) return 0; ret = tps65910_reg_clear_bits(tps65910, TPS65910_DEVCTRL, DEVCTRL_CK32K_CTRL_MASK); if (ret < 0) { dev_err(tps65910->dev, "clear ck32k_ctrl failed: %d\n", ret); return ret; } return 0; } static int tps65910_sleepinit(struct tps65910 *tps65910, struct tps65910_board *pmic_pdata) { struct device *dev = NULL; int ret = 0; dev = tps65910->dev; if (!pmic_pdata->en_dev_slp) return 0; /* enabling SLEEP device state */ ret = tps65910_reg_set_bits(tps65910, TPS65910_DEVCTRL, DEVCTRL_DEV_SLP_MASK); if (ret < 0) { dev_err(dev, "set dev_slp failed: %d\n", ret); goto err_sleep_init; } /* Return if there is no sleep keepon data. */ if (!pmic_pdata->slp_keepon) return 0; if (pmic_pdata->slp_keepon->therm_keepon) { ret = tps65910_reg_set_bits(tps65910, TPS65910_SLEEP_KEEP_RES_ON, SLEEP_KEEP_RES_ON_THERM_KEEPON_MASK); if (ret < 0) { dev_err(dev, "set therm_keepon failed: %d\n", ret); goto disable_dev_slp; } } if (pmic_pdata->slp_keepon->clkout32k_keepon) { ret = tps65910_reg_set_bits(tps65910, TPS65910_SLEEP_KEEP_RES_ON, SLEEP_KEEP_RES_ON_CLKOUT32K_KEEPON_MASK); if (ret < 0) { dev_err(dev, "set clkout32k_keepon failed: %d\n", ret); goto disable_dev_slp; } } if (pmic_pdata->slp_keepon->i2chs_keepon) { ret = tps65910_reg_set_bits(tps65910, TPS65910_SLEEP_KEEP_RES_ON, SLEEP_KEEP_RES_ON_I2CHS_KEEPON_MASK); if (ret < 0) { dev_err(dev, "set i2chs_keepon failed: %d\n", ret); goto disable_dev_slp; } } return 0; disable_dev_slp: tps65910_reg_clear_bits(tps65910, TPS65910_DEVCTRL, DEVCTRL_DEV_SLP_MASK); err_sleep_init: return ret; } #ifdef CONFIG_OF static struct of_device_id tps65910_of_match[] = { { .compatible = "ti,tps65910", .data = (void *)TPS65910}, { .compatible = "ti,tps65911", .data = (void *)TPS65911}, { }, }; MODULE_DEVICE_TABLE(of, tps65910_of_match); static struct tps65910_board *tps65910_parse_dt(struct i2c_client *client, int *chip_id) { struct device_node *np = client->dev.of_node; struct tps65910_board *board_info; unsigned int prop; const struct of_device_id *match; int ret = 0; match = of_match_device(tps65910_of_match, &client->dev); if (!match) { dev_err(&client->dev, "Failed to find matching dt id\n"); return NULL; } *chip_id = (int)match->data; board_info = devm_kzalloc(&client->dev, sizeof(*board_info), GFP_KERNEL); if (!board_info) { dev_err(&client->dev, "Failed to allocate pdata\n"); return NULL; } ret = of_property_read_u32(np, "ti,vmbch-threshold", &prop); if (!ret) board_info->vmbch_threshold = prop; else if (*chip_id == TPS65911) dev_warn(&client->dev, "VMBCH-Threshold not specified"); ret = of_property_read_u32(np, "ti,vmbch2-threshold", &prop); if (!ret) board_info->vmbch2_threshold = prop; else if (*chip_id == TPS65911) dev_warn(&client->dev, "VMBCH2-Threshold not specified"); prop = of_property_read_bool(np, "ti,en-ck32k-xtal"); board_info->en_ck32k_xtal = prop; board_info->irq = client->irq; board_info->irq_base = -1; board_info->pm_off = of_property_read_bool(np, "ti,system-power-controller"); return board_info; } #else static inline struct tps65910_board *tps65910_parse_dt(struct i2c_client *client, int *chip_id) { return NULL; } #endif static struct i2c_client *tps65910_i2c_client; static void tps65910_power_off(void) { struct tps65910 *tps65910; tps65910 = dev_get_drvdata(&tps65910_i2c_client->dev); if (tps65910_reg_set_bits(tps65910, TPS65910_DEVCTRL, DEVCTRL_PWR_OFF_MASK) < 0) return; tps65910_reg_clear_bits(tps65910, TPS65910_DEVCTRL, DEVCTRL_DEV_ON_MASK); } static int tps65910_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct tps65910 *tps65910; struct tps65910_board *pmic_plat_data; struct tps65910_board *of_pmic_plat_data = NULL; struct tps65910_platform_data *init_data; int ret = 0; int chip_id = id->driver_data; pmic_plat_data = dev_get_platdata(&i2c->dev); if (!pmic_plat_data && i2c->dev.of_node) { pmic_plat_data = tps65910_parse_dt(i2c, &chip_id); of_pmic_plat_data = pmic_plat_data; } if (!pmic_plat_data) return -EINVAL; init_data = devm_kzalloc(&i2c->dev, sizeof(*init_data), GFP_KERNEL); if (init_data == NULL) return -ENOMEM; tps65910 = devm_kzalloc(&i2c->dev, sizeof(*tps65910), GFP_KERNEL); if (tps65910 == NULL) return -ENOMEM; tps65910->of_plat_data = of_pmic_plat_data; i2c_set_clientdata(i2c, tps65910); tps65910->dev = &i2c->dev; tps65910->i2c_client = i2c; tps65910->id = chip_id; tps65910->regmap = devm_regmap_init_i2c(i2c, &tps65910_regmap_config); if (IS_ERR(tps65910->regmap)) { ret = PTR_ERR(tps65910->regmap); dev_err(&i2c->dev, "regmap initialization failed: %d\n", ret); return ret; } init_data->irq = pmic_plat_data->irq; init_data->irq_base = pmic_plat_data->irq_base; tps65910_irq_init(tps65910, init_data->irq, init_data); tps65910_ck32k_init(tps65910, pmic_plat_data); tps65910_sleepinit(tps65910, pmic_plat_data); if (pmic_plat_data->pm_off && !pm_power_off) { tps65910_i2c_client = i2c; pm_power_off = tps65910_power_off; } ret = mfd_add_devices(tps65910->dev, -1, tps65910s, ARRAY_SIZE(tps65910s), NULL, 0, regmap_irq_get_domain(tps65910->irq_data)); if (ret < 0) { dev_err(&i2c->dev, "mfd_add_devices failed: %d\n", ret); return ret; } return ret; } static int tps65910_i2c_remove(struct i2c_client *i2c) { struct tps65910 *tps65910 = i2c_get_clientdata(i2c); tps65910_irq_exit(tps65910); mfd_remove_devices(tps65910->dev); return 0; } static const struct i2c_device_id tps65910_i2c_id[] = { { "tps65910", TPS65910 }, { "tps65911", TPS65911 }, { } }; MODULE_DEVICE_TABLE(i2c, tps65910_i2c_id); static struct i2c_driver tps65910_i2c_driver = { .driver = { .name = "tps65910", .owner = THIS_MODULE, .of_match_table = of_match_ptr(tps65910_of_match), }, .probe = tps65910_i2c_probe, .remove = tps65910_i2c_remove, .id_table = tps65910_i2c_id, }; static int __init tps65910_i2c_init(void) { return i2c_add_driver(&tps65910_i2c_driver); } /* init early so consumer devices can complete system boot */ subsys_initcall(tps65910_i2c_init); static void __exit tps65910_i2c_exit(void) { i2c_del_driver(&tps65910_i2c_driver); } module_exit(tps65910_i2c_exit); MODULE_AUTHOR("Graeme Gregory <gg@slimlogic.co.uk>"); MODULE_AUTHOR("Jorge Eduardo Candelaria <jedu@slimlogic.co.uk>"); MODULE_DESCRIPTION("TPS6591x chip family multi-function driver"); MODULE_LICENSE("GPL");
/* Trigger a OOB (out of band) request to the GMU */ int a6xx_gmu_set_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state) { int ret; u32 val; int request, ack; const char *name; switch (state) { case GMU_OOB_GPU_SET: request = GMU_OOB_GPU_SET_REQUEST; ack = GMU_OOB_GPU_SET_ACK; name = "GPU_SET"; break; case GMU_OOB_BOOT_SLUMBER: request = GMU_OOB_BOOT_SLUMBER_REQUEST; ack = GMU_OOB_BOOT_SLUMBER_ACK; name = "BOOT_SLUMBER"; break; case GMU_OOB_DCVS_SET: request = GMU_OOB_DCVS_REQUEST; ack = GMU_OOB_DCVS_ACK; name = "GPU_DCVS"; break; default: return -EINVAL; } gmu_write(gmu, REG_A6XX_GMU_HOST2GMU_INTR_SET, 1 << request); ret = gmu_poll_timeout(gmu, REG_A6XX_GMU_GMU2HOST_INTR_INFO, val, val & (1 << ack), 100, 10000); if (ret) dev_err(gmu->dev, "Timeout waiting for GMU OOB set %s: 0x%x\n", name, gmu_read(gmu, REG_A6XX_GMU_GMU2HOST_INTR_INFO)); gmu_write(gmu, REG_A6XX_GMU_GMU2HOST_INTR_CLR, 1 << ack); return ret; }
/* * Copyright (c) 2003 * Francois Dumont * * This material is provided "as is", with absolutely no warranty expressed * or implied. Any use is at your own risk. * * Permission to use or copy this software for any purpose is hereby granted * without fee, provided the above notices are retained on all copies. * Permission to modify the code and to distribute modified code is granted, * provided the above notices are retained, and a notice that the code was * modified is included with the above copyright notice. * */ /* NOTE: This is an internal header file, included by other STL headers. * You should not attempt to use it directly. */ #ifndef _STLP_SPECIALIZED_SLIST_H #define _STLP_SPECIALIZED_SLIST_H #ifndef _STLP_POINTERS_SPEC_TOOLS_H # include <stl/pointers/_tools.h> #endif _STLP_BEGIN_NAMESPACE #define SLIST_IMPL _STLP_PTR_IMPL_NAME(slist) #if defined (__BORLANDC__) || defined (__DMC__) # define typename #endif #if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) _STLP_MOVE_TO_PRIV_NAMESPACE _STLP_EXPORT_TEMPLATE_CLASS _Slist_node<void*>; typedef _Slist_node<void*> _VoidPtrSNode; _STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<_Slist_node_base, _VoidPtrSNode, allocator<_VoidPtrSNode> >; _STLP_EXPORT_TEMPLATE_CLASS _Slist_base<void*, allocator<void*> >; _STLP_EXPORT_TEMPLATE_CLASS SLIST_IMPL<void*, allocator<void*> >; _STLP_MOVE_TO_STD_NAMESPACE #endif #if defined (_STLP_DEBUG) # define slist _STLP_NON_DBG_NAME(slist) _STLP_MOVE_TO_PRIV_NAMESPACE #endif template <class _Tp, _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Tp>) > class slist #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (slist) : public __stlport_class<slist<_Tp, _Alloc> > #endif { typedef _STLP_TYPENAME _STLP_PRIV _StorageType<_Tp>::_Type _StorageType; typedef typename _Alloc_traits<_StorageType, _Alloc>::allocator_type _StorageTypeAlloc; typedef _STLP_PRIV SLIST_IMPL<_StorageType, _StorageTypeAlloc> _Base; typedef typename _Base::iterator _BaseIte; typedef typename _Base::const_iterator _BaseConstIte; typedef slist<_Tp, _Alloc> _Self; typedef _STLP_PRIV _CastTraits<_StorageType, _Tp> cast_traits; typedef _STLP_PRIV _Slist_node_base _Node_base; public: typedef _Tp value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; typedef size_t size_type; typedef ptrdiff_t difference_type; typedef forward_iterator_tag _Iterator_category; typedef _STLP_PRIV _Slist_iterator<value_type, _Nonconst_traits<value_type> > iterator; typedef _STLP_PRIV _Slist_iterator<value_type, _Const_traits<value_type> > const_iterator; _STLP_FORCE_ALLOCATORS(value_type, _Alloc) typedef typename _Alloc_traits<value_type, _Alloc>::allocator_type allocator_type; public: allocator_type get_allocator() const { return _STLP_CONVERT_ALLOCATOR(_M_impl.get_allocator(), value_type); } explicit slist(const allocator_type& __a = allocator_type()) : _M_impl(_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} #if !defined(_STLP_DONT_SUP_DFLT_PARAM) explicit slist(size_type __n, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type), #else slist(size_type __n, const value_type& __x, #endif /*_STLP_DONT_SUP_DFLT_PARAM*/ const allocator_type& __a = allocator_type()) : _M_impl(__n, cast_traits::to_storage_type_cref(__x), _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} #if defined(_STLP_DONT_SUP_DFLT_PARAM) explicit slist(size_type __n) : _M_impl(__n) {} #endif /*_STLP_DONT_SUP_DFLT_PARAM*/ #if defined (_STLP_MEMBER_TEMPLATES) // We don't need any dispatching tricks here, because _M_insert_after_range // already does them. template <class _InputIterator> slist(_InputIterator __first, _InputIterator __last, const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) # if !defined (_STLP_USE_ITERATOR_WRAPPER) : _M_impl(__first, __last, _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} # else : _M_impl(_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) { insert_after(before_begin(), __first, __last); } # endif # if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) // VC++ needs this crazyness template <class _InputIterator> slist(_InputIterator __first, _InputIterator __last) # if !defined (_STLP_USE_WRAPPER_ITERATOR) : _M_impl(__first, __last) {} # else { insert_after(before_begin(), __first, __last); } # endif # endif #else /* _STLP_MEMBER_TEMPLATES */ slist(const_iterator __first, const_iterator __last, const allocator_type& __a = allocator_type() ) : _M_impl(_BaseConstIte(__first._M_node), _BaseConstIte(__last._M_node), _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} slist(const value_type* __first, const value_type* __last, const allocator_type& __a = allocator_type()) : _M_impl(cast_traits::to_storage_type_cptr(__first), cast_traits::to_storage_type_cptr(__last), _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} #endif /* _STLP_MEMBER_TEMPLATES */ slist(const _Self& __x) : _M_impl(__x._M_impl) {} #if !defined (_STLP_NO_MOVE_SEMANTIC) slist(__move_source<_Self> src) : _M_impl(__move_source<_Base>(src.get()._M_impl)) {} #endif _Self& operator= (const _Self& __x) { _M_impl = __x._M_impl; return *this; } void assign(size_type __n, const value_type& __val) { _M_impl.assign(__n, cast_traits::to_storage_type_cref(__val)); } #if defined (_STLP_MEMBER_TEMPLATES) # if defined (_STLP_USE_ITERATOR_WRAPPER) private: template <class _Integer> void _M_assign_dispatch(_Integer __n, _Integer __val, const __true_type&) { _M_impl.assign(__n, __val); } template <class _InputIterator> void _M_assign_dispatch(_InputIterator __first, _InputIterator __last, const __false_type&) { _M_impl.assign(_STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first), _STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last)); } public: # endif template <class _InputIterator> void assign(_InputIterator __first, _InputIterator __last) { # if defined (_STLP_USE_ITERATOR_WRAPPER) typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; _M_assign_dispatch(__first, __last, _Integral()); # else _M_impl.assign(__first, __last); # endif } #else void assign(const value_type *__first, const value_type *__last) { _M_impl.assign(cast_traits::to_storage_type_cptr(__first), cast_traits::to_storage_type_cptr(__last)); } void assign(const_iterator __first, const_iterator __last) { _M_impl.assign(_BaseConstIte(__first._M_node), _BaseConstIte(__last._M_node)); } #endif /* _STLP_MEMBER_TEMPLATES */ iterator before_begin() { return iterator(_M_impl.before_begin()._M_node); } const_iterator before_begin() const { return const_iterator(const_cast<_Node_base*>(_M_impl.before_begin()._M_node)); } iterator begin() { return iterator(_M_impl.begin()._M_node); } const_iterator begin() const { return const_iterator(const_cast<_Node_base*>(_M_impl.begin()._M_node));} iterator end() { return iterator(_M_impl.end()._M_node); } const_iterator end() const { return iterator(_M_impl.end()._M_node); } size_type size() const { return _M_impl.size(); } size_type max_size() const { return _M_impl.max_size(); } bool empty() const { return _M_impl.empty(); } void swap(_Self& __x) { _M_impl.swap(__x._M_impl); } #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) void _M_swap_workaround(_Self& __x) { swap(__x); } #endif public: reference front() { return *begin(); } const_reference front() const { return *begin(); } #if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS) void push_front(const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type)) #else void push_front(const value_type& __x) #endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ { _M_impl.push_front(cast_traits::to_storage_type_cref(__x)); } # if defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS) void push_front() { _M_impl.push_front();} # endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ void pop_front() { _M_impl.pop_front(); } iterator previous(const_iterator __pos) { return iterator(_M_impl.previous(_BaseConstIte(__pos._M_node))._M_node); } const_iterator previous(const_iterator __pos) const { return const_iterator(const_cast<_Node_base*>(_M_impl.previous(_BaseConstIte(__pos._M_node))._M_node)); } #if !defined(_STLP_DONT_SUP_DFLT_PARAM) iterator insert_after(iterator __pos, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type)) #else iterator insert_after(iterator __pos, const value_type& __x) #endif /*_STLP_DONT_SUP_DFLT_PARAM*/ { return iterator(_M_impl.insert_after(_BaseIte(__pos._M_node), cast_traits::to_storage_type_cref(__x))._M_node); } #if defined(_STLP_DONT_SUP_DFLT_PARAM) iterator insert_after(iterator __pos) { return iterator(_M_impl.insert_after(_BaseIte(__pos._M_node))._M_node);} #endif /*_STLP_DONT_SUP_DFLT_PARAM*/ void insert_after(iterator __pos, size_type __n, const value_type& __x) { _M_impl.insert_after(_BaseIte(__pos._M_node), __n, cast_traits::to_storage_type_cref(__x)); } #if defined (_STLP_MEMBER_TEMPLATES) # if defined (_STLP_USE_ITERATOR_WRAPPER) private: template <class _Integer> void _M_insert_after_dispatch(iterator __pos, _Integer __n, _Integer __val, const __true_type&) { _M_impl.insert_after(_BaseIte(__pos._M_node), __n, __val); } template <class _InputIterator> void _M_insert_after_dispatch(iterator __pos, _InputIterator __first, _InputIterator __last, const __false_type&) { _M_impl.insert_after(_BaseIte(__pos._M_node), _STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first), _STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last)); } public: # endif template <class _InputIterator> void insert_after(iterator __pos, _InputIterator __first, _InputIterator __last) { # if defined (_STLP_USE_ITERATOR_WRAPPER) // Check whether it's an integral type. If so, it's not an iterator. typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; _M_insert_after_dispatch(__pos, __first, __last, _Integral()); # else _M_impl.insert_after(_BaseIte(__pos._M_node), __first, __last); # endif } #else /* _STLP_MEMBER_TEMPLATES */ void insert_after(iterator __pos, const_iterator __first, const_iterator __last) { _M_impl.insert_after(_BaseIte(__pos._M_node), _BaseConstIte(__first._M_node), _BaseConstIte(__last._M_node)); } void insert_after(iterator __pos, const value_type* __first, const value_type* __last) { _M_impl.insert_after(_BaseIte(__pos._M_node), cast_traits::to_storage_type_cptr(__first), cast_traits::to_storage_type_cptr(__last)); } #endif /* _STLP_MEMBER_TEMPLATES */ #if !defined(_STLP_DONT_SUP_DFLT_PARAM) iterator insert(iterator __pos, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type)) #else iterator insert(iterator __pos, const value_type& __x) #endif /*_STLP_DONT_SUP_DFLT_PARAM*/ { return iterator(_M_impl.insert(_BaseIte(__pos._M_node), cast_traits::to_storage_type_cref(__x))._M_node); } #if defined(_STLP_DONT_SUP_DFLT_PARAM) iterator insert(iterator __pos) { return iterator(_M_impl.insert(_BaseIte(__pos._M_node))._M_node); } #endif /*_STLP_DONT_SUP_DFLT_PARAM*/ void insert(iterator __pos, size_type __n, const value_type& __x) { _M_impl.insert(_BaseIte(__pos._M_node), __n, cast_traits::to_storage_type_cref(__x)); } #if defined (_STLP_MEMBER_TEMPLATES) # if defined (_STLP_USE_ITERATOR_WRAPPER) private: template <class _Integer> void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val, const __true_type&) { _M_impl.insert(_BaseIte(__pos._M_node), __n, __val); } template <class _InputIterator> void _M_insert_dispatch(iterator __pos, _InputIterator __first, _InputIterator __last, const __false_type&) { _M_impl.insert(_BaseIte(__pos._M_node), _STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first), _STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last)); } public: # endif template <class _InputIterator> void insert(iterator __pos, _InputIterator __first, _InputIterator __last) { # if defined (_STLP_USE_ITERATOR_WRAPPER) // Check whether it's an integral type. If so, it's not an iterator. typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; _M_insert_dispatch(__pos, __first, __last, _Integral()); # else _M_impl.insert(_BaseIte(__pos._M_node), __first, __last); # endif } #else /* _STLP_MEMBER_TEMPLATES */ void insert(iterator __pos, const_iterator __first, const_iterator __last) { _M_impl.insert(_BaseIte(__pos._M_node), _BaseConstIte(__first._M_node), _BaseConstIte(__last._M_node)); } void insert(iterator __pos, const value_type* __first, const value_type* __last) { _M_impl.insert(_BaseIte(__pos._M_node), cast_traits::to_storage_type_cptr(__first), cast_traits::to_storage_type_cptr(__last)); } #endif /* _STLP_MEMBER_TEMPLATES */ iterator erase_after(iterator __pos) { return iterator(_M_impl.erase_after(_BaseIte(__pos._M_node))._M_node); } iterator erase_after(iterator __before_first, iterator __last) { return iterator(_M_impl.erase_after(_BaseIte(__before_first._M_node), _BaseIte(__last._M_node))._M_node); } iterator erase(iterator __pos) { return iterator(_M_impl.erase(_BaseIte(__pos._M_node))._M_node); } iterator erase(iterator __first, iterator __last) { return iterator(_M_impl.erase(_BaseIte(__first._M_node), _BaseIte(__last._M_node))._M_node); } #if !defined(_STLP_DONT_SUP_DFLT_PARAM) void resize(size_type __new_size, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type)) #else void resize(size_type __new_size, const value_type& __x) #endif /*_STLP_DONT_SUP_DFLT_PARAM*/ { _M_impl.resize(__new_size, cast_traits::to_storage_type_cref(__x));} #if defined(_STLP_DONT_SUP_DFLT_PARAM) void resize(size_type __new_size) { _M_impl.resize(__new_size); } #endif /*_STLP_DONT_SUP_DFLT_PARAM*/ void clear() { _M_impl.clear(); } void splice_after(iterator __pos, _Self& __x, iterator __before_first, iterator __before_last) { _M_impl.splice_after(_BaseIte(__pos._M_node), __x._M_impl, _BaseIte(__before_first._M_node), _BaseIte(__before_last._M_node)); } void splice_after(iterator __pos, _Self& __x, iterator __prev) { _M_impl.splice_after(_BaseIte(__pos._M_node), __x._M_impl, _BaseIte(__prev._M_node)); } void splice_after(iterator __pos, _Self& __x) { _M_impl.splice_after(_BaseIte(__pos._M_node), __x._M_impl); } void splice(iterator __pos, _Self& __x) { _M_impl.splice(_BaseIte(__pos._M_node), __x._M_impl); } void splice(iterator __pos, _Self& __x, iterator __i) { _M_impl.splice(_BaseIte(__pos._M_node), __x._M_impl, _BaseIte(__i._M_node)); } void splice(iterator __pos, _Self& __x, iterator __first, iterator __last) { _M_impl.splice(_BaseIte(__pos._M_node), __x._M_impl, _BaseIte(__first._M_node), _BaseIte(__last._M_node)); } void reverse() { _M_impl.reverse(); } void remove(const value_type& __val) { _M_impl.remove(cast_traits::to_storage_type_cref(__val)); } void unique() { _M_impl.unique(); } void merge(_Self& __x) { _M_impl.merge(__x._M_impl); } void sort() {_M_impl.sort(); } #ifdef _STLP_MEMBER_TEMPLATES template <class _Predicate> void remove_if(_Predicate __pred) { _M_impl.remove_if(_STLP_PRIV _UnaryPredWrapper<_StorageType, _Tp, _Predicate>(__pred)); } template <class _BinaryPredicate> void unique(_BinaryPredicate __pred) { _M_impl.unique(_STLP_PRIV _BinaryPredWrapper<_StorageType, _Tp, _BinaryPredicate>(__pred)); } template <class _StrictWeakOrdering> void merge(_Self& __x, _StrictWeakOrdering __comp) { _M_impl.merge(__x._M_impl, _STLP_PRIV _BinaryPredWrapper<_StorageType, _Tp, _StrictWeakOrdering>(__comp)); } template <class _StrictWeakOrdering> void sort(_StrictWeakOrdering __comp) { _M_impl.sort(_STLP_PRIV _BinaryPredWrapper<_StorageType, _Tp, _StrictWeakOrdering>(__comp)); } #endif /* _STLP_MEMBER_TEMPLATES */ private: _Base _M_impl; }; #if defined (slist) # undef slist _STLP_MOVE_TO_STD_NAMESPACE #endif #undef SLIST_IMPL #if defined (__BORLANDC__) || defined (__DMC__) # undef typename #endif _STLP_END_NAMESPACE #endif /* _STLP_SPECIALIZED_SLIST_H */ // Local Variables: // mode:C++ // End:
/* INCIDENTAL: CWE 561 Dead Code, the function below is never called */ static void goodG2B2_vasinkg(char * data, ...) { { va_list args; va_start(args, data); vfprintf(stdout, "%s", args); va_end(args); } }
// Scans the contents of the UART RX buffer for a received message, sets // trans_rx_msg_avail if appropriate // This should be called within an ISR so it is atomic void scan_trans_rx_enc_msg(const uint8_t* buf, uint8_t len) { if (len == TRANS_RX_ENC_MSG_MAX_SIZE && buf[0] == TRANS_PKT_DELIMITER && buf[2] == TRANS_PKT_DELIMITER && buf[len - 6] == TRANS_PKT_DELIMITER && buf[len - 1] == TRANS_PKT_DELIMITER) { for (uint8_t i = 0; i < len; i++) { trans_rx_enc_msg[i] = buf[i]; } trans_rx_enc_len = len; trans_rx_enc_avail = true; } }
/* * Copyright (c) 2008 Oracle. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * OpenIB.org BSD license below: * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * */ #ifndef _LINUX_RDS_H #define _LINUX_RDS_H #include <linux/types.h> #define RDS_IB_ABI_VERSION 0x301 /* * setsockopt/getsockopt for SOL_RDS */ #define RDS_CANCEL_SENT_TO 1 #define RDS_GET_MR 2 #define RDS_FREE_MR 3 /* deprecated: RDS_BARRIER 4 */ #define RDS_RECVERR 5 #define RDS_CONG_MONITOR 6 #define RDS_GET_MR_FOR_DEST 7 /* * Control message types for SOL_RDS. * * CMSG_RDMA_ARGS (sendmsg) * Request a RDMA transfer to/from the specified * memory ranges. * The cmsg_data is a struct rds_rdma_args. * RDS_CMSG_RDMA_DEST (recvmsg, sendmsg) * Kernel informs application about intended * source/destination of a RDMA transfer * RDS_CMSG_RDMA_MAP (sendmsg) * Application asks kernel to map the given * memory range into a IB MR, and send the * R_Key along in an RDS extension header. * The cmsg_data is a struct rds_get_mr_args, * the same as for the GET_MR setsockopt. * RDS_CMSG_RDMA_STATUS (recvmsg) * Returns the status of a completed RDMA operation. */ #define RDS_CMSG_RDMA_ARGS 1 #define RDS_CMSG_RDMA_DEST 2 #define RDS_CMSG_RDMA_MAP 3 #define RDS_CMSG_RDMA_STATUS 4 #define RDS_CMSG_CONG_UPDATE 5 #define RDS_CMSG_ATOMIC_FADD 6 #define RDS_CMSG_ATOMIC_CSWP 7 #define RDS_CMSG_MASKED_ATOMIC_FADD 8 #define RDS_CMSG_MASKED_ATOMIC_CSWP 9 #define RDS_INFO_FIRST 10000 #define RDS_INFO_COUNTERS 10000 #define RDS_INFO_CONNECTIONS 10001 /* 10002 aka RDS_INFO_FLOWS is deprecated */ #define RDS_INFO_SEND_MESSAGES 10003 #define RDS_INFO_RETRANS_MESSAGES 10004 #define RDS_INFO_RECV_MESSAGES 10005 #define RDS_INFO_SOCKETS 10006 #define RDS_INFO_TCP_SOCKETS 10007 #define RDS_INFO_IB_CONNECTIONS 10008 #define RDS_INFO_CONNECTION_STATS 10009 #define RDS_INFO_IWARP_CONNECTIONS 10010 #define RDS_INFO_LAST 10010 struct rds_info_counter { uint8_t name[32]; uint64_t value; } __attribute__((packed)); #define RDS_INFO_CONNECTION_FLAG_SENDING 0x01 #define RDS_INFO_CONNECTION_FLAG_CONNECTING 0x02 #define RDS_INFO_CONNECTION_FLAG_CONNECTED 0x04 #define TRANSNAMSIZ 16 struct rds_info_connection { uint64_t next_tx_seq; uint64_t next_rx_seq; __be32 laddr; __be32 faddr; uint8_t transport[TRANSNAMSIZ]; /* null term ascii */ uint8_t flags; } __attribute__((packed)); #define RDS_INFO_MESSAGE_FLAG_ACK 0x01 #define RDS_INFO_MESSAGE_FLAG_FAST_ACK 0x02 struct rds_info_message { uint64_t seq; uint32_t len; __be32 laddr; __be32 faddr; __be16 lport; __be16 fport; uint8_t flags; } __attribute__((packed)); struct rds_info_socket { uint32_t sndbuf; __be32 bound_addr; __be32 connected_addr; __be16 bound_port; __be16 connected_port; uint32_t rcvbuf; uint64_t inum; } __attribute__((packed)); struct rds_info_tcp_socket { __be32 local_addr; __be16 local_port; __be32 peer_addr; __be16 peer_port; uint64_t hdr_rem; uint64_t data_rem; uint32_t last_sent_nxt; uint32_t last_expected_una; uint32_t last_seen_una; } __attribute__((packed)); #define RDS_IB_GID_LEN 16 struct rds_info_rdma_connection { __be32 src_addr; __be32 dst_addr; uint8_t src_gid[RDS_IB_GID_LEN]; uint8_t dst_gid[RDS_IB_GID_LEN]; uint32_t max_send_wr; uint32_t max_recv_wr; uint32_t max_send_sge; uint32_t rdma_mr_max; uint32_t rdma_mr_size; }; /* * Congestion monitoring. * Congestion control in RDS happens at the host connection * level by exchanging a bitmap marking congested ports. * By default, a process sleeping in poll() is always woken * up when the congestion map is updated. * With explicit monitoring, an application can have more * fine-grained control. * The application installs a 64bit mask value in the socket, * where each bit corresponds to a group of ports. * When a congestion update arrives, RDS checks the set of * ports that are now uncongested against the list bit mask * installed in the socket, and if they overlap, we queue a * cong_notification on the socket. * * To install the congestion monitor bitmask, use RDS_CONG_MONITOR * with the 64bit mask. * Congestion updates are received via RDS_CMSG_CONG_UPDATE * control messages. * * The correspondence between bits and ports is * 1 << (portnum % 64) */ #define RDS_CONG_MONITOR_SIZE 64 #define RDS_CONG_MONITOR_BIT(port) (((unsigned int) port) % RDS_CONG_MONITOR_SIZE) #define RDS_CONG_MONITOR_MASK(port) (1ULL << RDS_CONG_MONITOR_BIT(port)) /* * RDMA related types */ /* * This encapsulates a remote memory location. * In the current implementation, it contains the R_Key * of the remote memory region, and the offset into it * (so that the application does not have to worry about * alignment). */ typedef uint64_t rds_rdma_cookie_t; struct rds_iovec { uint64_t addr; uint64_t bytes; }; struct rds_get_mr_args { struct rds_iovec vec; uint64_t cookie_addr; uint64_t flags; }; struct rds_get_mr_for_dest_args { struct sockaddr_storage dest_addr; struct rds_iovec vec; uint64_t cookie_addr; uint64_t flags; }; struct rds_free_mr_args { rds_rdma_cookie_t cookie; uint64_t flags; }; struct rds_rdma_args { rds_rdma_cookie_t cookie; struct rds_iovec remote_vec; uint64_t local_vec_addr; uint64_t nr_local; uint64_t flags; uint64_t user_token; }; struct rds_atomic_args { rds_rdma_cookie_t cookie; uint64_t local_addr; uint64_t remote_addr; union { struct { uint64_t compare; uint64_t swap; } cswp; struct { uint64_t add; } fadd; struct { uint64_t compare; uint64_t swap; uint64_t compare_mask; uint64_t swap_mask; } m_cswp; struct { uint64_t add; uint64_t nocarry_mask; } m_fadd; }; uint64_t flags; uint64_t user_token; }; struct rds_rdma_notify { uint64_t user_token; int32_t status; }; #define RDS_RDMA_SUCCESS 0 #define RDS_RDMA_REMOTE_ERROR 1 #define RDS_RDMA_CANCELED 2 #define RDS_RDMA_DROPPED 3 #define RDS_RDMA_OTHER_ERROR 4 /* * Common set of flags for all RDMA related structs */ #define RDS_RDMA_READWRITE 0x0001 #define RDS_RDMA_FENCE 0x0002 /* use FENCE for immediate send */ #define RDS_RDMA_INVALIDATE 0x0004 /* invalidate R_Key after freeing MR */ #define RDS_RDMA_USE_ONCE 0x0008 /* free MR after use */ #define RDS_RDMA_DONTWAIT 0x0010 /* Don't wait in SET_BARRIER */ #define RDS_RDMA_NOTIFY_ME 0x0020 /* Notify when operation completes */ #define RDS_RDMA_SILENT 0x0040 /* Do not interrupt remote */ #endif /* IB_RDS_H */
/** * Remove this service. * * A successfully connected service with Favorite=true * can be removed this way. If it is connected, it will * be automatically disconnected first. * * If the service requires a passphrase it will be * cleared and forgotten when removing. * * This is similar to setting the Favorite property * to false, but that is currently not supported. * * In the case a connection attempt failed and the * service is in the State=failure, this method can * also be used to reset the service. * * Calling this method on Ethernet devices will cause * an error message. It is not possible to remove these * kind of devices. * * @param service path to call method on server. * @param cb function to call when server replies or some error happens. * @param data data to give to cb when it is called. * * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise. */ Eina_Bool e_connman_service_remove(E_Connman_Element *service, E_DBus_Method_Return_Cb cb, const void *data) { const char name[] = "Remove"; EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE); return e_connman_element_call_full (service, name, NULL, &service->_pending.service_remove, cb, data); }
/* Return a bit-pattern to use in the range-table bits to match multibyte chars of class CC. */ static int re_wctype_to_bit (re_wctype_t cc) { switch (cc) { case RECC_NONASCII: case RECC_MULTIBYTE: return BIT_MULTIBYTE; case RECC_ALPHA: return BIT_ALPHA; case RECC_ALNUM: return BIT_ALNUM; case RECC_WORD: return BIT_WORD; case RECC_LOWER: return BIT_LOWER; case RECC_UPPER: return BIT_UPPER; case RECC_PUNCT: return BIT_PUNCT; case RECC_SPACE: return BIT_SPACE; case RECC_GRAPH: return BIT_GRAPH; case RECC_PRINT: return BIT_PRINT; case RECC_BLANK: return BIT_BLANK; case RECC_ASCII: case RECC_DIGIT: case RECC_XDIGIT: case RECC_CNTRL: case RECC_UNIBYTE: case RECC_ERROR: return 0; default: abort (); } }
/** ****************************************************************************** ** \brief Read received data from I2C ** ** The received data is copied from Receive Data Register into the provided ** data buffer Mfs_Hl_I2c_Read#pu8Data. ** The slave address (Mfs_Hl_I2c_Read#u8SlaveAddr) is used on master mode. ** The size is defined by Mfs_Hl_I2c_Read#pu16ReadCnt. ** If non-blocking is specified (Mfs_Hl_I2c_Read#bBlocking is FALSE), this ** function will return immediately after available datas from remote device ** are received into the provided buffer. (Mfs_Hl_I2c_Read#pu8Data) ** ** Anyway, Receive interrupt is used in any case. ** ** Note: Don't access to the buffer which specified by pu8Data until reception ** processing completes. ** ** \param [in] pstcI2c Pointer to I2C (MFS) instance register area. ** \param [in] u8SlaveAddr Slave Address. ** \param [in,out] pu8Data Buffer to store received characters. ** \param [in,out] pu16ReadCnt Pointrer to variable for number of bytes ** been read. ** \param [in] bBlocking If TRUE, synchronously wait until pu16ReadCnt ** bytes have been received. ** If FALSE, return immediately. ** ** \retval Ok Read data successfully done or started. ** \retval ErrorInvalidParameter If one of following conditions are met: ** - pstcI2c == NULL ** - pu8Data == NULL ** - pu16ReadCnt == NULL ** - pstcMfsHlInternData == NULL (invalid or disabled MFS unit ** (PDL_PERIPHERAL_ENABLE_MFS)) ** \retval ErrorOperationInProgress If the following condition is met: ** - A transmission or reception is still ongoing while another ** I2C operation should be started. ** \retval ErrorTimeout Interruption state didn't change within ** the specified period of time. ** ******************************************************************************/ en_result_t Mfs_Hl_I2c_Read(volatile stc_mfsn_t* pstcI2c, uint8_t u8SlaveAddr, uint8_t* pu8Data, uint16_t* pu16ReadCnt, boolean_t bBlocking ) { en_result_t enResult; stc_mfs_hl_intern_data_t* pstcMfsHlInternData; stc_mfs_hl_buffer_t* pstcBuffer; stc_mfs_i2c_ibcr_field_t stcIBCR; uint16_t u16Count; uint16_t u16Cnt; pstcMfsHlInternData = MfsHlGetInternDataPtr(pstcI2c); if ((NULL == pstcMfsHlInternData) || (NULL == pu8Data) || (NULL == pu16ReadCnt) ) { enResult = ErrorInvalidParameter; } else if (MfsHlExecStby != pstcMfsHlInternData->u8Exec) { enResult = ErrorOperationInProgress; } else { pstcBuffer = &pstcMfsHlInternData->stcRxBuffer; pstcBuffer->pu8Buffer = pu8Data; pstcBuffer->u16BufferSize = *pu16ReadCnt; pstcBuffer->u16InIndex = 0u; pstcMfsHlInternData->u8Exec = MfsHlExecReceiving; if (MfsHlModeI2cMaster == pstcMfsHlInternData->u8MfsMode) { if (MfsHlUseFifo == pstcMfsHlInternData->u8FifoUsage) { u16Count = MfsHlGetMin((pstcBuffer->u16BufferSize), (MFS_FIFO_MAX_VAL - MFS_HL_NUM_1) ); pstcI2c->FBYTE2 = (uint8_t)u16Count; } else { u16Count = 0u; } u8SlaveAddr <<= MFS_HL_NUM_1; u8SlaveAddr |= (uint8_t)(MfsI2cRead); pstcI2c->TDR = (uint16_t)(u8SlaveAddr); for (u16Cnt = 0u; u16Cnt < u16Count; u16Cnt++) { pstcI2c->TDR = 0x00u; } stcIBCR = pstcI2c->IBCR_f; stcIBCR.ACKE = TRUE; stcIBCR.WSEL = TRUE; stcIBCR.INTE = TRUE; stcIBCR.ACT_SCC = FALSE; stcIBCR.INT = FALSE; stcIBCR.MSS = TRUE; pstcI2c->IBCR_f = stcIBCR; enResult = Ok; } else { enResult = MfsHlI2cStartSlave(pstcI2c, pstcMfsHlInternData); } if (Ok == enResult) { if (FALSE == bBlocking) { pstcMfsHlInternData->u32I2cProcCnt = 0; } else { enResult = MfsHlI2cWaitIntState(pstcMfsHlInternData); if ((Ok != enResult) || (0u == pstcBuffer->u16InIndex)) { *pu16ReadCnt = 0u; enResult = ErrorTimeout; } else { *pu16ReadCnt = pstcBuffer->u16InIndex; } } } } return (enResult); }
/**************************************************************************** * Name: sam_eic_config * * Description: * Configure the interrupt edge sensitivity in CONFIGn register of the EIC * * Input Parameters: * eirq - Pin to be configured * pinset - Configuration of the pin * * Returned Value: * None * ****************************************************************************/ int sam_eic_config(uint8_t eirq, port_pinset_t pinset) { uint32_t reg; uint32_t val; uint32_t config; if (eirq < 8) { reg = SAM_EIC_CONFIG0; val = EIC_CONFIG0_SENSE_BOTH(eirq); if (pinset & PORT_INT_RISING) { val = EIC_CONFIG0_SENSE_RISE(eirq); } if (pinset & PORT_INT_FALLING) { val = EIC_CONFIG0_SENSE_FALL(eirq); } val |= EIC_CONFIG0_FILTEN(eirq); } else if (eirq < 16) { reg = SAM_EIC_CONFIG1; val = EIC_CONFIG1_SENSE_BOTH(eirq); if (pinset & PORT_INT_RISING) { val = EIC_CONFIG1_SENSE_RISE(eirq); } if (pinset & PORT_INT_FALLING) { val = EIC_CONFIG1_SENSE_FALL(eirq); } val |= EIC_CONFIG1_FILTEN(eirq); } else { reg = SAM_EIC_CONFIG2; val = EIC_CONFIG2_SENSE_BOTH(eirq); if (pinset & PORT_INT_RISING) { val = EIC_CONFIG2_SENSE_RISE(eirq); } if (pinset & PORT_INT_FALLING) { val = EIC_CONFIG2_SENSE_FALL(eirq); } val |= EIC_CONFIG2_FILTEN(eirq); } config = getreg32(reg); config |= val; putreg32(config, reg); putreg32(EIC_EXTINT(eirq), SAM_EIC_INTENSET); sam_eic_dumpregs(); return OK; }
/** Compute per-site log likelihoods (PThreads version) Worker threads evaluate the likelihood on their sites @param tr Tree instance @param lhs Likelihood array @param n Number of threads @param tid Thread id */ void perSiteLogLikelihoodsPthreads(pllInstance *tr, partitionList *pr, double *lhs, int n, int tid) { size_t model, i; for(model = 0; model < (size_t)pr->numberOfPartitions; model++) { size_t localIndex = 0; pllBoolean execute = ((tr->manyPartitions && isThisMyPartition(pr, tid, model)) || (!tr->manyPartitions)); if(execute) for(i = (size_t)(pr->partitionData[model]->lower); i < (size_t)(pr->partitionData[model]->upper); i++) { if(tr->manyPartitions || (i % n == (size_t)tid)) { double l; switch(tr->rateHetModel) { case PLL_CAT: l = evaluatePartialGeneric (tr, pr, localIndex, pr->partitionData[model]->perSiteRates[pr->partitionData[model]->rateCategory[localIndex]], model); break; case PLL_GAMMA: l = evaluatePartialGeneric (tr, pr, localIndex, 1.0, model); break; default: assert(0); } lhs[i] = l; localIndex++; } } } }
/** * Retrieve the <code>WM_CLASS</code> of a window and update its * <code>win</code> structure. */ bool win_update_class(session_t *ps, struct managed_win *w) { char **strlst = NULL; int nstr = 0; if (!w->client_win) return false; free(w->class_instance); free(w->class_general); w->class_instance = NULL; w->class_general = NULL; if (!wid_get_text_prop(ps, w->client_win, ps->atoms->aWM_CLASS, &strlst, &nstr)) { return false; } w->class_instance = strdup(strlst[0]); if (nstr > 1) { w->class_general = strdup(strlst[1]); } free(strlst); log_trace("(%#010x): client = %#010x, " "instance = \"%s\", general = \"%s\"", w->base.id, w->client_win, w->class_instance, w->class_general); return true; }
#include<stdio.h> #include<string.h> int a[10],n,t,i; int main() { for(;scanf("%d",&n),n;) { for(memset(a,0,40);n--;a[t]++) scanf("%d",&t); for(i=0;i<10;i++) { if(a[i]==0) puts("-"); else for(;a[i]--;printf("*%s",a[i]==0?"\n":"")); } } }
/* avermedia-m135a.c - Keytable for Avermedia M135A Remote Controllers * * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> * Copyright (c) 2010 by Herton Ronaldo Krzesinski <herton@mandriva.com.br> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */ #include <media/rc-map.h> #include <linux/module.h> /* * Avermedia M135A with RM-JX and RM-K6 remote controls * * On Avermedia M135A with IR model RM-JX, the same codes exist on both * Positivo (BR) and original IR, initial version and remote control codes * added by Mauro Carvalho Chehab <mchehab@infradead.org> * * Positivo also ships Avermedia M135A with model RM-K6, extra control * codes added by Herton Ronaldo Krzesinski <herton@mandriva.com.br> */ static struct rc_map_table avermedia_m135a[] = { /* RM-JX */ { 0x0200, KEY_POWER2 }, { 0x022e, KEY_DOT }, /* '.' */ { 0x0201, KEY_MODE }, /* TV/FM or SOURCE */ { 0x0205, KEY_1 }, { 0x0206, KEY_2 }, { 0x0207, KEY_3 }, { 0x0209, KEY_4 }, { 0x020a, KEY_5 }, { 0x020b, KEY_6 }, { 0x020d, KEY_7 }, { 0x020e, KEY_8 }, { 0x020f, KEY_9 }, { 0x0211, KEY_0 }, { 0x0213, KEY_RIGHT }, /* -> or L */ { 0x0212, KEY_LEFT }, /* <- or R */ { 0x0217, KEY_SLEEP }, /* Capturar Imagem or Snapshot */ { 0x0210, KEY_SHUFFLE }, /* Amostra or 16 chan prev */ { 0x0303, KEY_CHANNELUP }, { 0x0302, KEY_CHANNELDOWN }, { 0x021f, KEY_VOLUMEUP }, { 0x021e, KEY_VOLUMEDOWN }, { 0x020c, KEY_ENTER }, /* Full Screen */ { 0x0214, KEY_MUTE }, { 0x0208, KEY_AUDIO }, { 0x0203, KEY_TEXT }, /* Teletext */ { 0x0204, KEY_EPG }, { 0x022b, KEY_TV2 }, /* TV2 or PIP */ { 0x021d, KEY_RED }, { 0x021c, KEY_YELLOW }, { 0x0301, KEY_GREEN }, { 0x0300, KEY_BLUE }, { 0x021a, KEY_PLAYPAUSE }, { 0x0219, KEY_RECORD }, { 0x0218, KEY_PLAY }, { 0x021b, KEY_STOP }, /* RM-K6 */ { 0x0401, KEY_POWER2 }, { 0x0406, KEY_MUTE }, { 0x0408, KEY_MODE }, /* TV/FM */ { 0x0409, KEY_1 }, { 0x040a, KEY_2 }, { 0x040b, KEY_3 }, { 0x040c, KEY_4 }, { 0x040d, KEY_5 }, { 0x040e, KEY_6 }, { 0x040f, KEY_7 }, { 0x0410, KEY_8 }, { 0x0411, KEY_9 }, { 0x044c, KEY_DOT }, /* '.' */ { 0x0412, KEY_0 }, { 0x0407, KEY_REFRESH }, /* Refresh/Reload */ { 0x0413, KEY_AUDIO }, { 0x0440, KEY_SCREEN }, /* Full Screen toggle */ { 0x0441, KEY_HOME }, { 0x0442, KEY_BACK }, { 0x0447, KEY_UP }, { 0x0448, KEY_DOWN }, { 0x0449, KEY_LEFT }, { 0x044a, KEY_RIGHT }, { 0x044b, KEY_OK }, { 0x0404, KEY_VOLUMEUP }, { 0x0405, KEY_VOLUMEDOWN }, { 0x0402, KEY_CHANNELUP }, { 0x0403, KEY_CHANNELDOWN }, { 0x0443, KEY_RED }, { 0x0444, KEY_GREEN }, { 0x0445, KEY_YELLOW }, { 0x0446, KEY_BLUE }, { 0x0414, KEY_TEXT }, { 0x0415, KEY_EPG }, { 0x041a, KEY_TV2 }, /* PIP */ { 0x041b, KEY_CAMERA }, /* Snapshot */ { 0x0417, KEY_RECORD }, { 0x0416, KEY_PLAYPAUSE }, { 0x0418, KEY_STOP }, { 0x0419, KEY_PAUSE }, { 0x041f, KEY_PREVIOUS }, { 0x041c, KEY_REWIND }, { 0x041d, KEY_FORWARD }, { 0x041e, KEY_NEXT }, }; static struct rc_map_list avermedia_m135a_map = { .map = { .scan = avermedia_m135a, .size = ARRAY_SIZE(avermedia_m135a), .rc_type = RC_TYPE_NEC, .name = RC_MAP_AVERMEDIA_M135A, } }; static int __init init_rc_map_avermedia_m135a(void) { return rc_map_register(&avermedia_m135a_map); } static void __exit exit_rc_map_avermedia_m135a(void) { rc_map_unregister(&avermedia_m135a_map); } module_init(init_rc_map_avermedia_m135a) module_exit(exit_rc_map_avermedia_m135a) MODULE_LICENSE("GPL"); MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>");
//------------------------------------------------------------------------------ // Frees all the nodes and data. Top point to NULL, size is reset to zero, but // memSize is kept intact. //------------------------------------------------------------------------------ void stackClear(Stack *s) { while(s->size > 0) { Node *temp = s->top; s->top = s->top->next; free(temp->data); free(temp); s->size--; } s->top = NULL; }
#include<stdio.h> #include<math.h> #include<string.h> int main() { int a,b,c,s,n,i,j,t; int total_fuel,cap,left,cities,cost=0 ; scanf("%d %d",&cities,&cap) ; total_fuel=cities-1 ; if(total_fuel<=cap) printf("%d",total_fuel) ; else { cost=cost+cap ; for(i=2 ; i<=cities-cap ; i++) { cost=cost+i ; } printf("%d",cost) ; } return 0 ; }
/* caller needs to hold kbdev->pm.backend.metrics.lock before calling this * function */ static void kbase_pm_get_dvfs_utilisation_calc(struct kbase_device *kbdev, ktime_t now) { ktime_t diff; lockdep_assert_held(&kbdev->pm.backend.metrics.lock); diff = ktime_sub(now, kbdev->pm.backend.metrics.time_period_start); if (ktime_to_ns(diff) < 0) return; if (kbdev->pm.backend.metrics.gpu_active) { u32 ns_time = (u32) (ktime_to_ns(diff) >> KBASE_PM_TIME_SHIFT); kbdev->pm.backend.metrics.values.time_busy += ns_time; if (kbdev->pm.backend.metrics.active_cl_ctx[0]) kbdev->pm.backend.metrics.values.busy_cl[0] += ns_time; if (kbdev->pm.backend.metrics.active_cl_ctx[1]) kbdev->pm.backend.metrics.values.busy_cl[1] += ns_time; if (kbdev->pm.backend.metrics.active_gl_ctx[0]) kbdev->pm.backend.metrics.values.busy_gl += ns_time; if (kbdev->pm.backend.metrics.active_gl_ctx[1]) kbdev->pm.backend.metrics.values.busy_gl += ns_time; } else { kbdev->pm.backend.metrics.values.time_idle += (u32) (ktime_to_ns(diff) >> KBASE_PM_TIME_SHIFT); } kbdev->pm.backend.metrics.time_period_start = now; }
/** Free a connection object. * \param c the object to free */ void free_conn(struct conn *c) { if (c->local_bev) bufferevent_free(c->local_bev); if (c->remote_bev) bufferevent_free(c->remote_bev); if (c->remote_host) free(c->remote_host); if (c->remote_ip) free(c->remote_ip); if (c->resolver_req) evdns_cancel_request(resolver, c->resolver_req); free(c); }
/* Dump a principal entry in krb5 beta 7 format. Omit kadmin tl-data if kadm * is false. */ static krb5_error_code k5beta7_common(krb5_context context, krb5_db_entry *entry, const char *name, FILE *fp, krb5_boolean verbose, krb5_boolean omit_nra, krb5_boolean kadm) { krb5_tl_data *tlp; krb5_key_data *kdata; int counter, skip, i; counter = skip = 0; for (tlp = entry->tl_data; tlp; tlp = tlp->tl_data_next) { if (tlp->tl_data_type == KRB5_TL_KADM_DATA && !kadm) skip++; else counter++; } if (counter + skip != entry->n_tl_data) { fprintf(stderr, _("%s: tagged data list inconsistency for %s " "(counted %d, stored %d)\n"), progname, name, counter + skip, (int)entry->n_tl_data); return EINVAL; } fprintf(fp, "princ\t%d\t%lu\t%d\t%d\t%d\t%s\t", (int)entry->len, (unsigned long)strlen(name), counter, (int)entry->n_key_data, (int)entry->e_length, name); fprintf(fp, "%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d", entry->attributes, entry->max_life, entry->max_renewable_life, entry->expiration, entry->pw_expiration, omit_nra ? 0 : entry->last_success, omit_nra ? 0 : entry->last_failed, omit_nra ? 0 : entry->fail_auth_count); dump_tl_data(fp, entry->tl_data, !kadm); fprintf(fp, "\t"); for (counter = 0; counter < entry->n_key_data; counter++) { kdata = &entry->key_data[counter]; fprintf(fp, "%d\t%d\t", (int)kdata->key_data_ver, (int)kdata->key_data_kvno); for (i = 0; i < kdata->key_data_ver; i++) { fprintf(fp, "%d\t%d\t", kdata->key_data_type[i], kdata->key_data_length[i]); dump_octets_or_minus1(fp, kdata->key_data_contents[i], kdata->key_data_length[i]); fprintf(fp, "\t"); } } dump_octets_or_minus1(fp, entry->e_data, entry->e_length); fprintf(fp, ";\n"); if (verbose) fprintf(stderr, "%s\n", name); return 0; }
/* Tests which drag rectangle the cursor is in. */ void DragHandleTest(HWND hwnd) { unsigned i; RECT rt; POINT pt; GetCursorPos(&pt); ScreenToClient(hwnd, &pt); for (i = 0; i < 8; i++) { CopyRect(&rt, &dragHandles[i]); if (dlgHasCaption == TRUE) { rt.top += GetSystemMetrics(SM_CYCAPTION); rt.bottom += GetSystemMetrics(SM_CYCAPTION); } rt.left += DLG2SCR_X(dlgPos.x); rt.top += DLG2SCR_Y(dlgPos.y); rt.right += DLG2SCR_X(dlgPos.x); rt.bottom += DLG2SCR_Y(dlgPos.y); if (PtInRect(&rt, pt)) { curDragHand = i; return; } } curDragHand = -1; return; }
// ***************************************************************************** // ***************************************************************************** // Section: Library/Stack Initialization Data // ***************************************************************************** // ***************************************************************************** /****************************************************** * USB Driver Initialization ******************************************************/ void _DRV_USB_VBUSPowerEnable(uint8_t port, bool enable) { if (enable == true) { VBUS_PowerEnable(); } else { VBUS_PowerDisable(); } }
/** * @brief Release a semaphore that was obtained by osSemaphoreWait. */ osStatus_t osSemaphoreRelease(osSemaphoreId_t semaphore_id) { struct cv2_sem *semaphore = (struct cv2_sem *) semaphore_id; if (semaphore_id == NULL) { return osErrorParameter; } if (k_sem_count_get(&semaphore->z_semaphore) == semaphore->z_semaphore.limit) { return osErrorResource; } k_sem_give(&semaphore->z_semaphore); return osOK; }
#include<stdio.h> int main() { int i,j,k,n,div,l; scanf("%d",&n); j=-1; for(i=0; i<n+1; i++) { for(k=i; k<n; k++)printf(" "); j+=2; div=j/2; l=0; for(k=0; k<div; k++)printf("%d ",k); if(k<=div)printf("%d",k); for(k=div-1;k>=0;k--) { printf(" %d",k); } printf("\n"); } j=(2*n)+1; for(i=n; i>0; i--) { for(k=0; k<=n-i; k++)printf(" "); j-=2; div=j/2; l=0; for(k=0; k<div; k++)printf("%d ",k); if(k<=div)printf("%d",k); for(k=div-1;k>=0;k--) { printf(" %d",k); } printf("\n"); } return 0; }
// WARNING: string parameter is treated as a 2d array static char *convert_ASCII_to_HID(char *string, uint8_t lenght) { uint8_t index = 0; for (int i = 0; i < lenght; i++) { index = (0 * lenght) + i; if ((string[index] >= 'a' && string[index] <= 'z') || (string[index] >= 'A' && string[index] <= 'Z')) { string[(1 * lenght) + i] = (string[index] >= 'a') ? 0x00 : 0x01; string[index] -= ((string[index] >= 'a') ? 0x5D : 0x3D); } else if (string[index] >= '0' && string[index] <= '9') { string[(1 * lenght) + i] = 0x00; string[index] -= ((string[index] == '0') ? 0x09 : 0x13); } else { } } return string; }
/* * Check the number of Columns with a BIOS call. This avoids a crash of the * DOS console when 'columns' is set to a too large value. */ void mch_check_columns() { static union REGS regs; regs.h.ah = 0x0f; (void)int86(0x10, &regs, &regs); if ((unsigned)Columns > (unsigned)regs.h.ah) Columns = (unsigned)regs.h.ah; }
/* Convert between lowlevel sigmask and libc representation of sigset_t. Generic version. Copyright (C) 1998-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Joe Keane <jgk@jgk.org>. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ /* Convert between an old-style 32-bit signal mask and a POSIX sigset_t. */ /* Perform *SET = MASK. Unused bits of *SET are set to 0. Returns zero for success or -1 for errors (from sigaddset/sigemptyset). */ static inline int __attribute__ ((unused)) sigset_set_old_mask (sigset_t *set, int mask) { if (sizeof (__sigset_t) == sizeof (unsigned int)) *set = (unsigned int) mask; else { unsigned int __sig; if (__sigemptyset (set) < 0) return -1; for (__sig = 1; __sig < NSIG && __sig <= sizeof (mask) * 8; __sig++) if (mask & sigmask (__sig)) if (__sigaddset (set, __sig) < 0) return -1; } return 0; } /* Return the sigmask corresponding to *SET. Unused bits of *SET are thrown away. */ static inline int __attribute__ ((unused)) sigset_get_old_mask (const sigset_t *set) { if (sizeof (sigset_t) == sizeof (unsigned int)) return (unsigned int) *set; else { unsigned int mask = 0; unsigned int sig; for (sig = 1; sig < NSIG && sig <= sizeof (mask) * 8; sig++) if (__sigismember (set, sig)) mask |= sigmask (sig); return mask; } }
#ifndef __rt_trace_defs_asm_h #define __rt_trace_defs_asm_h /* * This file is autogenerated from * file: ../../inst/rt_trace/rtl/rt_regs.r * id: rt_regs.r,v 1.18 2005/02/08 15:45:00 stefans Exp * last modfied: Mon Apr 11 16:09:14 2005 * * by /n/asic/design/tools/rdesc/src/rdes2c -asm --outfile asm/rt_trace_defs_asm.h ../../inst/rt_trace/rtl/rt_regs.r * id: $Id: rt_trace_defs_asm.h,v 1.1 2005/04/24 18:31:04 starvik Exp $ * Any changes here will be lost. * * -*- buffer-read-only: t -*- */ #ifndef REG_FIELD #define REG_FIELD( scope, reg, field, value ) \ REG_FIELD_X_( value, reg_##scope##_##reg##___##field##___lsb ) #define REG_FIELD_X_( value, shift ) ((value) << shift) #endif #ifndef REG_STATE #define REG_STATE( scope, reg, field, symbolic_value ) \ REG_STATE_X_( regk_##scope##_##symbolic_value, reg_##scope##_##reg##___##field##___lsb ) #define REG_STATE_X_( k, shift ) (k << shift) #endif #ifndef REG_MASK #define REG_MASK( scope, reg, field ) \ REG_MASK_X_( reg_##scope##_##reg##___##field##___width, reg_##scope##_##reg##___##field##___lsb ) #define REG_MASK_X_( width, lsb ) (((1 << width)-1) << lsb) #endif #ifndef REG_LSB #define REG_LSB( scope, reg, field ) reg_##scope##_##reg##___##field##___lsb #endif #ifndef REG_BIT #define REG_BIT( scope, reg, field ) reg_##scope##_##reg##___##field##___bit #endif #ifndef REG_ADDR #define REG_ADDR( scope, inst, reg ) REG_ADDR_X_(inst, reg_##scope##_##reg##_offset) #define REG_ADDR_X_( inst, offs ) ((inst) + offs) #endif #ifndef REG_ADDR_VECT #define REG_ADDR_VECT( scope, inst, reg, index ) \ REG_ADDR_VECT_X_(inst, reg_##scope##_##reg##_offset, index, \ STRIDE_##scope##_##reg ) #define REG_ADDR_VECT_X_( inst, offs, index, stride ) \ ((inst) + offs + (index) * stride) #endif /* Register rw_cfg, scope rt_trace, type rw */ #define reg_rt_trace_rw_cfg___en___lsb 0 #define reg_rt_trace_rw_cfg___en___width 1 #define reg_rt_trace_rw_cfg___en___bit 0 #define reg_rt_trace_rw_cfg___mode___lsb 1 #define reg_rt_trace_rw_cfg___mode___width 1 #define reg_rt_trace_rw_cfg___mode___bit 1 #define reg_rt_trace_rw_cfg___owner___lsb 2 #define reg_rt_trace_rw_cfg___owner___width 1 #define reg_rt_trace_rw_cfg___owner___bit 2 #define reg_rt_trace_rw_cfg___wp___lsb 3 #define reg_rt_trace_rw_cfg___wp___width 1 #define reg_rt_trace_rw_cfg___wp___bit 3 #define reg_rt_trace_rw_cfg___stall___lsb 4 #define reg_rt_trace_rw_cfg___stall___width 1 #define reg_rt_trace_rw_cfg___stall___bit 4 #define reg_rt_trace_rw_cfg___wp_start___lsb 8 #define reg_rt_trace_rw_cfg___wp_start___width 7 #define reg_rt_trace_rw_cfg___wp_stop___lsb 16 #define reg_rt_trace_rw_cfg___wp_stop___width 7 #define reg_rt_trace_rw_cfg_offset 0 /* Register rw_tap_ctrl, scope rt_trace, type rw */ #define reg_rt_trace_rw_tap_ctrl___ack_data___lsb 0 #define reg_rt_trace_rw_tap_ctrl___ack_data___width 1 #define reg_rt_trace_rw_tap_ctrl___ack_data___bit 0 #define reg_rt_trace_rw_tap_ctrl___ack_guru___lsb 1 #define reg_rt_trace_rw_tap_ctrl___ack_guru___width 1 #define reg_rt_trace_rw_tap_ctrl___ack_guru___bit 1 #define reg_rt_trace_rw_tap_ctrl_offset 4 /* Register r_tap_stat, scope rt_trace, type r */ #define reg_rt_trace_r_tap_stat___dav___lsb 0 #define reg_rt_trace_r_tap_stat___dav___width 1 #define reg_rt_trace_r_tap_stat___dav___bit 0 #define reg_rt_trace_r_tap_stat___empty___lsb 1 #define reg_rt_trace_r_tap_stat___empty___width 1 #define reg_rt_trace_r_tap_stat___empty___bit 1 #define reg_rt_trace_r_tap_stat_offset 8 /* Register rw_tap_data, scope rt_trace, type rw */ #define reg_rt_trace_rw_tap_data_offset 12 /* Register rw_tap_hdata, scope rt_trace, type rw */ #define reg_rt_trace_rw_tap_hdata___op___lsb 0 #define reg_rt_trace_rw_tap_hdata___op___width 4 #define reg_rt_trace_rw_tap_hdata___sub_op___lsb 4 #define reg_rt_trace_rw_tap_hdata___sub_op___width 4 #define reg_rt_trace_rw_tap_hdata_offset 16 /* Register r_redir, scope rt_trace, type r */ #define reg_rt_trace_r_redir_offset 20 /* Constants */ #define regk_rt_trace_brk 0x0000000c #define regk_rt_trace_dbg 0x00000003 #define regk_rt_trace_dbgdi 0x00000004 #define regk_rt_trace_dbgdo 0x00000005 #define regk_rt_trace_gmode 0x00000000 #define regk_rt_trace_no 0x00000000 #define regk_rt_trace_nop 0x00000000 #define regk_rt_trace_normal 0x00000000 #define regk_rt_trace_rdmem 0x00000007 #define regk_rt_trace_rdmemb 0x00000009 #define regk_rt_trace_rdpreg 0x00000002 #define regk_rt_trace_rdreg 0x00000001 #define regk_rt_trace_rdsreg 0x00000003 #define regk_rt_trace_redir 0x00000006 #define regk_rt_trace_ret 0x0000000b #define regk_rt_trace_rw_cfg_default 0x00000000 #define regk_rt_trace_trcfg 0x00000001 #define regk_rt_trace_wp 0x00000001 #define regk_rt_trace_wp0 0x00000001 #define regk_rt_trace_wp1 0x00000002 #define regk_rt_trace_wp2 0x00000004 #define regk_rt_trace_wp3 0x00000008 #define regk_rt_trace_wp4 0x00000010 #define regk_rt_trace_wp5 0x00000020 #define regk_rt_trace_wp6 0x00000040 #define regk_rt_trace_wrmem 0x00000008 #define regk_rt_trace_wrmemb 0x0000000a #define regk_rt_trace_wrpreg 0x00000005 #define regk_rt_trace_wrreg 0x00000004 #define regk_rt_trace_wrsreg 0x00000006 #define regk_rt_trace_yes 0x00000001 #endif /* __rt_trace_defs_asm_h */
/* * Transpose operations on 4 32-bit words */ static inline void transp4(CARD32 d[], unsigned int n, unsigned int m) { CARD32 mask = get_mask(n); switch (m) { case 1: _transp(d, 0, 1, n, mask); _transp(d, 2, 3, n, mask); return; case 2: _transp(d, 0, 2, n, mask); _transp(d, 1, 3, n, mask); return; } c2p_unsupported(); }
/** * @brief Create FilePath object * * @return the pointer of object */ FilePath* new_FilePath(const char* path) { FilePath* self; FilePath_private* pri; pri = malloc(sizeof(FilePath_private)); self = malloc(sizeof(FilePath)); assert(pri); assert(self); pri->path = pri->dir = pri->name = pri->ext = NULL; self->Clone = Clone; self->path_get = GetPath; self->path_set = SetPath; self->dir_get = GetDir; self->dir_set = SetDir; self->name_get = GetName; self->name_set = SetName; self->ext_get = GetExt; self->ext_set = SetExt; self->pri = pri; if(NULL != path) { self->path_set(self, path); } return self; }
//* This file is part of the RACCOON application //* being developed at Dolbow lab at Duke University //* http://dolbow.pratt.duke.edu #pragma once #include "PlasticHardeningModel.h" #include "DerivativeMaterialPropertyNameInterface.h" class ExponentialHardening : public PlasticHardeningModel, public DerivativeMaterialPropertyNameInterface { public: static InputParameters validParams(); ExponentialHardening(const InputParameters & parameters); virtual ADReal plasticEnergy(const ADReal & ep, const unsigned int derivative = 0) override; protected: // @{ The plastic energy parameters const ADMaterialProperty<Real> & _sigma_y; const ADMaterialProperty<Real> & _sigma_ult; const ADMaterialProperty<Real> & _ep0; const ADMaterialProperty<Real> & _H; // @} /// Name of the phase-field variable const VariableName _d_name; // @{ Plastic energy density and its derivative w/r/t damage const MaterialPropertyName _psip_name; ADMaterialProperty<Real> & _psip; ADMaterialProperty<Real> & _psip_active; ADMaterialProperty<Real> & _dpsip_dd; // @} // @{ The degradation function and its derivative w/r/t damage const MaterialPropertyName _gp_name; const ADMaterialProperty<Real> & _gp; const ADMaterialProperty<Real> & _dgp_dd; // @} };
// Initialize alternative hardware timer as RTX kernel timer // Return: IRQ number of the alternative hardware timer int os_tick_init (void) { NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_RC << CLOCK_LFCLKSRC_SRC_Pos); NRF_CLOCK->EVENTS_LFCLKSTARTED = 0; NRF_CLOCK->TASKS_LFCLKSTART = 1; while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0) { } NRF_RTC1->PRESCALER = OS_TRV; NRF_RTC1->INTENSET = RTC_INTENSET_TICK_Msk; NRF_RTC1->TASKS_START = 1; return (RTC1_IRQn); }
/* * btrfs_sync_log does sends a given tree log down to the disk and * updates the super blocks to record it. When this call is done, * you know that any inodes previously logged are safely on disk only * if it returns 0. * * Any other return value means you need to call btrfs_commit_transaction. * Some of the edge cases for fsyncing directories that have had unlinks * or renames done in the past mean that sometimes the only safe * fsync is to commit the whole FS. When btrfs_sync_log returns -EAGAIN, * that has happened. */ int btrfs_sync_log(struct btrfs_trans_handle *trans, struct btrfs_root *root) { int index1; int index2; int mark; int ret; struct btrfs_root *log = root->log_root; struct btrfs_root *log_root_tree = root->fs_info->log_root_tree; unsigned long log_transid = 0; mutex_lock(&root->log_mutex); log_transid = root->log_transid; index1 = root->log_transid % 2; if (atomic_read(&root->log_commit[index1])) { wait_log_commit(trans, root, root->log_transid); mutex_unlock(&root->log_mutex); return 0; } atomic_set(&root->log_commit[index1], 1); if (atomic_read(&root->log_commit[(index1 + 1) % 2])) wait_log_commit(trans, root, root->log_transid - 1); while (1) { int batch = atomic_read(&root->log_batch); if (!btrfs_test_opt(root, SSD) && root->log_multiple_pids) { mutex_unlock(&root->log_mutex); schedule_timeout_uninterruptible(1); mutex_lock(&root->log_mutex); } wait_for_writer(trans, root); if (batch == atomic_read(&root->log_batch)) break; } if (root->fs_info->last_trans_log_full_commit == trans->transid) { ret = -EAGAIN; btrfs_free_logged_extents(log, log_transid); mutex_unlock(&root->log_mutex); goto out; } if (log_transid % 2 == 0) mark = EXTENT_DIRTY; else mark = EXTENT_NEW; ret = btrfs_write_marked_extents(log, &log->dirty_log_pages, mark); if (ret) { btrfs_abort_transaction(trans, root, ret); btrfs_free_logged_extents(log, log_transid); mutex_unlock(&root->log_mutex); goto out; } btrfs_set_root_node(&log->root_item, log->node); root->log_transid++; log->log_transid = root->log_transid; root->log_start_pid = 0; smp_mb(); mutex_unlock(&root->log_mutex); mutex_lock(&log_root_tree->log_mutex); atomic_inc(&log_root_tree->log_batch); atomic_inc(&log_root_tree->log_writers); mutex_unlock(&log_root_tree->log_mutex); ret = update_log_root(trans, log); mutex_lock(&log_root_tree->log_mutex); if (atomic_dec_and_test(&log_root_tree->log_writers)) { smp_mb(); if (waitqueue_active(&log_root_tree->log_writer_wait)) wake_up(&log_root_tree->log_writer_wait); } if (ret) { if (ret != -ENOSPC) { btrfs_abort_transaction(trans, root, ret); mutex_unlock(&log_root_tree->log_mutex); goto out; } root->fs_info->last_trans_log_full_commit = trans->transid; btrfs_wait_marked_extents(log, &log->dirty_log_pages, mark); btrfs_free_logged_extents(log, log_transid); mutex_unlock(&log_root_tree->log_mutex); ret = -EAGAIN; goto out; } index2 = log_root_tree->log_transid % 2; if (atomic_read(&log_root_tree->log_commit[index2])) { btrfs_wait_marked_extents(log, &log->dirty_log_pages, mark); wait_log_commit(trans, log_root_tree, log_root_tree->log_transid); btrfs_free_logged_extents(log, log_transid); mutex_unlock(&log_root_tree->log_mutex); ret = 0; goto out; } atomic_set(&log_root_tree->log_commit[index2], 1); if (atomic_read(&log_root_tree->log_commit[(index2 + 1) % 2])) { wait_log_commit(trans, log_root_tree, log_root_tree->log_transid - 1); } wait_for_writer(trans, log_root_tree); if (root->fs_info->last_trans_log_full_commit == trans->transid) { btrfs_wait_marked_extents(log, &log->dirty_log_pages, mark); btrfs_free_logged_extents(log, log_transid); mutex_unlock(&log_root_tree->log_mutex); ret = -EAGAIN; goto out_wake_log_root; } ret = btrfs_write_and_wait_marked_extents(log_root_tree, &log_root_tree->dirty_log_pages, EXTENT_DIRTY | EXTENT_NEW); if (ret) { btrfs_abort_transaction(trans, root, ret); btrfs_free_logged_extents(log, log_transid); mutex_unlock(&log_root_tree->log_mutex); goto out_wake_log_root; } btrfs_wait_marked_extents(log, &log->dirty_log_pages, mark); btrfs_wait_logged_extents(log, log_transid); btrfs_set_super_log_root(root->fs_info->super_for_commit, log_root_tree->node->start); btrfs_set_super_log_root_level(root->fs_info->super_for_commit, btrfs_header_level(log_root_tree->node)); log_root_tree->log_transid++; smp_mb(); mutex_unlock(&log_root_tree->log_mutex); btrfs_scrub_pause_super(root); ret = write_ctree_super(trans, root->fs_info->tree_root, 1); btrfs_scrub_continue_super(root); if (ret) { btrfs_abort_transaction(trans, root, ret); goto out_wake_log_root; } mutex_lock(&root->log_mutex); if (root->last_log_commit < log_transid) root->last_log_commit = log_transid; mutex_unlock(&root->log_mutex); out_wake_log_root: atomic_set(&log_root_tree->log_commit[index2], 0); smp_mb(); if (waitqueue_active(&log_root_tree->log_commit_wait[index2])) wake_up(&log_root_tree->log_commit_wait[index2]); out: atomic_set(&root->log_commit[index1], 0); smp_mb(); if (waitqueue_active(&root->log_commit_wait[index1])) wake_up(&root->log_commit_wait[index1]); return ret; }
/* Insert a string of characters (0-9 or A-Z) into a "binary" screen array. Uses insert_char to insert each character. Returns offset to next character position */ int insert_string(int x, int y, const char* s, uint8_t dest[32][128], int reverse) { int offset = 0; while(*s != 0) { offset += insert_char(x + offset, y, *s, dest, reverse); s++; } return offset; }
/* This routine applies two inverse preconditioner matrices to the vector r, using the interaction-only block-diagonal Jacobian with block-grouping, denoted Jr, and Gauss-Seidel applied to the diffusion contribution to the Jacobian, denoted Jd. It first calls GSIter for a Gauss-Seidel approximation to ((I - gamma*Jd)-inverse)*r, and stores the result in z. Then it computes ((I - gamma*Jr)-inverse)*z, using LU factors of the blocks in P, and pivot information in pivot, and returns the result in z. */ static int PSolve(realtype tn, N_Vector c, N_Vector fc, N_Vector r, N_Vector z, realtype gamma, realtype delta, int lr, void *user_data, N_Vector vtemp) { realtype ***P; long int **pivot; int jx, jy, igx, igy, iv, ig, *jigx, *jigy, mx, my, ngx; long int mp; WebData wdata; wdata = (WebData) user_data; N_VScale(ONE, r, z); GSIter(gamma, z, vtemp, wdata); P = wdata->P; pivot = wdata->pivot; mx = wdata->mx; my = wdata->my; ngx = wdata->ngx; mp = wdata->mp; jigx = wdata->jigx; jigy = wdata->jigy; iv = 0; for (jy = 0; jy < my; jy++) { igy = jigy[jy]; for (jx = 0; jx < mx; jx++) { igx = jigx[jx]; ig = igx + igy*ngx; denseGETRS(P[ig], mp, pivot[ig], &(NV_DATA_S(z)[iv])); iv += mp; } } return(0); }
/** * zynqmp_pm_api_debugfs_init - Initialize debugfs interface * * Return: Returns 0 on success * Corresponding error code otherwise */ static int zynqmp_pm_api_debugfs_init(void) { int err; zynqmp_pm_debugfs_dir = debugfs_create_dir(DRIVER_NAME, NULL); if (!zynqmp_pm_debugfs_dir) { pr_err("%s debugfs_create_dir failed\n", __func__); return -ENODEV; } zynqmp_pm_debugfs_power = debugfs_create_file("power", S_IWUSR | S_IWGRP | S_IWOTH, zynqmp_pm_debugfs_dir, NULL, &fops_zynqmp_pm_dbgfs); if (!zynqmp_pm_debugfs_power) { pr_err("%s debugfs_create_file power failed\n", __func__); err = -ENODEV; goto err_dbgfs; } zynqmp_pm_debugfs_api_version = debugfs_create_file("api_version", S_IRUSR | S_IRGRP | S_IROTH, zynqmp_pm_debugfs_dir, NULL, &fops_zynqmp_pm_dbgfs); if (!zynqmp_pm_debugfs_api_version) { pr_err("%s debugfs_create_file api_version failed\n", __func__); err = -ENODEV; goto err_dbgfs; } return 0; err_dbgfs: debugfs_remove_recursive(zynqmp_pm_debugfs_dir); zynqmp_pm_debugfs_dir = NULL; return err; }
//===- PassDetails.h - SystemC pass class details ---------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // Stuff shared between the different SystemC passes. // //===----------------------------------------------------------------------===// // clang-tidy seems to expect the absolute path in the header guard on some // systems, so just disable it. // NOLINTNEXTLINE(llvm-header-guard) #ifndef DIALECT_SYSTEMC_TRANSFORMS_PASSDETAILS_H #define DIALECT_SYSTEMC_TRANSFORMS_PASSDETAILS_H #include "circt/Dialect/Interop/InteropDialect.h" #include "circt/Dialect/SystemC/SystemCDialect.h" #include "mlir/Dialect/EmitC/IR/EmitC.h" #include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/IR/BuiltinOps.h" #include "mlir/Pass/Pass.h" namespace circt { namespace systemc { #define GEN_PASS_CLASSES #include "circt/Dialect/SystemC/Passes.h.inc" } // namespace systemc } // namespace circt #endif // DIALECT_SYSTEMC_TRANSFORMS_PASSDETAILS_H
// Appends false to the bitvector. void AppendFalse() { Address addr = IndexToAddress(size_); uint32_t old_blocks_size = static_cast<uint32_t>(blocks_.size()); uint32_t new_blocks_size = addr.block_idx + 1; if (PERFETTO_UNLIKELY(new_blocks_size > old_blocks_size)) { uint32_t t = GetNumBitsSet(); blocks_.emplace_back(); counts_.emplace_back(t); } size_++; }
/** * Convert a GBT DCR and associated tables to OTF * \param in The conversion object * \param inDisk input FITS disk number for base of GBT files * \param scanName Scan name part of FITS file names (e.g. "2003_06_27_01:32:01") * \param err Obit error stack object. * \return pointer to the new object. */ ObitIOCode ObitGBTDCROTFConvert (ObitGBTDCROTF *in, olong inDisk, gchar *scanName, ObitErr *err) { ObitIOCode retCode = OBIT_IO_SpecErr; gchar *routine = "ObitGBTDCROTFConvert"; g_assert (ObitErrIsA(err)); if (err->error) return retCode; g_assert (ObitIsA(in, &myClassInfo)); olong nrec; ObitIOAccess access; gboolean isNew; gint32 dim[MAXINFOELEMDIM] = {1,1,1,1,1}; isNew = GetHeader (in, scanName, inDisk, err); if (err->error) Obit_traceback_val (err, routine, in->name, retCode); if (in->refFrequency>1.0e9) GetAntennaGR (in, scanName, inDisk, err); else GetAntennaPF (in, scanName, inDisk, err); if (err->error) Obit_log_error(err, OBIT_Error, "Error reading Antenna file for scan %s", scanName); if (err->error) Obit_traceback_val (err, routine, in->name, retCode); Obit_log_error(err, OBIT_InfoErr, "Adding scan %s %6.0f to OTF file", scanName, in->scan); dim[0] = 1; nrec = in->StateData->nDCRState; ObitInfoListPut (in->outOTF->info, "nRecPIO", OBIT_long, dim, &nrec, err); ObitInfoListPut (in->outOTF->info, "IOBy", OBIT_long, dim, &nrec, err); if (isNew) access = OBIT_IO_WriteOnly; else access = OBIT_IO_ReadWrite; retCode = ObitOTFOpen (in->outOTF, access, err); if ((retCode != OBIT_IO_OK) || (err->error>0)) Obit_log_error(err, OBIT_Error, "ERROR opening output FITS file"); if (err->error) Obit_traceback_val (err, routine, in->name, retCode); in->target = (ofloat)GetTarget (in, isNew, in->Name, err); InitScan (in, isNew, in->scan, in->target, err); GetData (in, scanName, inDisk, err); SetScan (in, err); retCode = ObitOTFClose (in->outOTF, err); if (err->error) Obit_traceback_val (err, routine, in->name, retCode); in->nAntTime = 0; if (in->AntDMJD) g_free(in->AntDMJD); in->AntDMJD = NULL; if (in->AntRA) g_free(in->AntRA); in->AntRA = NULL; if (in->AntDec) g_free(in->AntDec); in->AntDec = NULL; in->IFdata = ObitGBTIFInfoUnref(in->IFdata); in->BeamOffData = ObitGBTBeamOffInfoUnref(in->BeamOffData); in->StateData = ObitGBTDCRStateInfoUnref(in->StateData); in->StateData = ObitGBTDCRStateInfoUnref(in->StateData); return OBIT_IO_OK; }
/** * Emit code for TGSI_OPCODE_LIT instruction. */ static boolean emit_lit(struct svga_shader_emitter_v10 *emit, const struct tgsi_full_instruction *inst) { struct tgsi_full_src_register one = make_immediate_reg_float(emit, 1.0f); unsigned tmp_move = get_temp_index(emit); struct tgsi_full_src_register move_src = make_src_temp_reg(tmp_move); struct tgsi_full_dst_register move_dst = make_dst_temp_reg(tmp_move); if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_X) { struct tgsi_full_dst_register dst_x = writemask_dst(&move_dst, TGSI_WRITEMASK_X); emit_instruction_op1(emit, VGPU10_OPCODE_MOV, &dst_x, &one); } if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_W) { struct tgsi_full_dst_register dst_w = writemask_dst(&move_dst, TGSI_WRITEMASK_W); emit_instruction_op1(emit, VGPU10_OPCODE_MOV, &dst_w, &one); } if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Y) { struct tgsi_full_dst_register dst_y = writemask_dst(&move_dst, TGSI_WRITEMASK_Y); struct tgsi_full_src_register zero = make_immediate_reg_float(emit, 0.0f); struct tgsi_full_src_register src_xxxx = swizzle_src(&inst->Src[0], TGSI_SWIZZLE_X, TGSI_SWIZZLE_X, TGSI_SWIZZLE_X, TGSI_SWIZZLE_X); emit_instruction_opn(emit, VGPU10_OPCODE_MAX, &dst_y, &src_xxxx, &zero, NULL, inst->Instruction.Saturate, FALSE); } if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Z) { struct tgsi_full_dst_register dst_z = writemask_dst(&move_dst, TGSI_WRITEMASK_Z); unsigned tmp1 = get_temp_index(emit); struct tgsi_full_src_register tmp1_src = make_src_temp_reg(tmp1); struct tgsi_full_dst_register tmp1_dst = make_dst_temp_reg(tmp1); unsigned tmp2 = get_temp_index(emit); struct tgsi_full_src_register tmp2_src = make_src_temp_reg(tmp2); struct tgsi_full_dst_register tmp2_dst = make_dst_temp_reg(tmp2); struct tgsi_full_src_register src_xxxx = scalar_src(&inst->Src[0], TGSI_SWIZZLE_X); struct tgsi_full_src_register src_yyyy = scalar_src(&inst->Src[0], TGSI_SWIZZLE_Y); struct tgsi_full_src_register src_wwww = scalar_src(&inst->Src[0], TGSI_SWIZZLE_W); struct tgsi_full_src_register zero = make_immediate_reg_float(emit, 0.0f); struct tgsi_full_src_register lowerbound = make_immediate_reg_float(emit, -128.0f); struct tgsi_full_src_register upperbound = make_immediate_reg_float(emit, 128.0f); emit_instruction_op2(emit, VGPU10_OPCODE_MAX, &tmp1_dst, &src_wwww, &lowerbound); emit_instruction_op2(emit, VGPU10_OPCODE_MIN, &tmp1_dst, &tmp1_src, &upperbound); emit_instruction_op2(emit, VGPU10_OPCODE_MAX, &tmp2_dst, &src_yyyy, &zero); emit_instruction_op1(emit, VGPU10_OPCODE_LOG, &tmp2_dst, &tmp2_src); emit_instruction_op2(emit, VGPU10_OPCODE_MUL, &tmp1_dst, &tmp2_src, &tmp1_src); emit_instruction_op1(emit, VGPU10_OPCODE_EXP, &tmp1_dst, &tmp1_src); emit_instruction_op2(emit, VGPU10_OPCODE_EQ, &tmp2_dst, &zero, &src_wwww); emit_instruction_op3(emit, VGPU10_OPCODE_MOVC, &tmp1_dst, &tmp2_src, &one, &tmp1_src); emit_instruction_op2(emit, VGPU10_OPCODE_LT, &tmp2_dst, &zero, &src_xxxx); emit_instruction_op3(emit, VGPU10_OPCODE_MOVC, &dst_z, &tmp2_src, &tmp1_src, &zero); } emit_instruction_op1(emit, VGPU10_OPCODE_MOV, &inst->Dst[0], &move_src); free_temp_indexes(emit); return TRUE; }
/* Matches many SETs, up to a limit. */ Py_LOCAL_INLINE(Py_ssize_t) match_many_SET(RE_State* state, RE_Node* node, Py_ssize_t text_pos, Py_ssize_t limit, BOOL match) { void* text; RE_EncodingTable* encoding; RE_LocaleInfo* locale_info; text = state->text; match = node->match == match; encoding = state->encoding; locale_info = state->locale_info; switch (state->charsize) { case 1: { Py_UCS1* text_ptr; Py_UCS1* limit_ptr; text_ptr = (Py_UCS1*)text + text_pos; limit_ptr = (Py_UCS1*)text + limit; while (text_ptr < limit_ptr && matches_SET(encoding, locale_info, node, text_ptr[0]) == match) ++text_ptr; text_pos = text_ptr - (Py_UCS1*)text; break; } case 2: { Py_UCS2* text_ptr; Py_UCS2* limit_ptr; text_ptr = (Py_UCS2*)text + text_pos; limit_ptr = (Py_UCS2*)text + limit; while (text_ptr < limit_ptr && matches_SET(encoding, locale_info, node, text_ptr[0]) == match) ++text_ptr; text_pos = text_ptr - (Py_UCS2*)text; break; } case 4: { Py_UCS4* text_ptr; Py_UCS4* limit_ptr; text_ptr = (Py_UCS4*)text + text_pos; limit_ptr = (Py_UCS4*)text + limit; while (text_ptr < limit_ptr && matches_SET(encoding, locale_info, node, text_ptr[0]) == match) ++text_ptr; text_pos = text_ptr - (Py_UCS4*)text; break; } } return text_pos; }
/* * If @is_allocation is true, reserve space in the system space info necessary * for allocating a chunk, otherwise if it's false, reserve space necessary for * removing a chunk. */ void check_system_chunk(struct btrfs_trans_handle *trans, u64 type) { struct btrfs_fs_info *fs_info = trans->fs_info; struct btrfs_space_info *info; u64 left; u64 thresh; int ret = 0; u64 num_devs; lockdep_assert_held(&fs_info->chunk_mutex); info = btrfs_find_space_info(fs_info, BTRFS_BLOCK_GROUP_SYSTEM); spin_lock(&info->lock); left = info->total_bytes - btrfs_space_info_used(info, true); spin_unlock(&info->lock); num_devs = get_profile_num_devs(fs_info, type); thresh = btrfs_calc_trunc_metadata_size(fs_info, num_devs) + btrfs_calc_trans_metadata_size(fs_info, 1); if (left < thresh && btrfs_test_opt(fs_info, ENOSPC_DEBUG)) { btrfs_info(fs_info, "left=%llu, need=%llu, flags=%llu", left, thresh, type); btrfs_dump_space_info(fs_info, info, 0, 0); } if (left < thresh) { u64 flags = btrfs_system_alloc_profile(fs_info); ret = btrfs_alloc_chunk(trans, flags); } if (!ret) { ret = btrfs_block_rsv_add(fs_info->chunk_root, &fs_info->chunk_block_rsv, thresh, BTRFS_RESERVE_NO_FLUSH); if (!ret) trans->chunk_bytes_reserved += thresh; } }
/* * Copyright 2018 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #import <AVFoundation/AVFoundation.h> #import "RTCMacros.h" #import "RTCVideoFrameBuffer.h" NS_ASSUME_NONNULL_BEGIN /** RTCVideoFrameBuffer containing a CVPixelBufferRef */ RTC_OBJC_EXPORT __attribute__((objc_runtime_name("WK_RTCCVPixelBuffer"))) @interface RTCCVPixelBuffer : NSObject <RTCVideoFrameBuffer> @property(nonatomic, readonly) CVPixelBufferRef pixelBuffer; @property(nonatomic, readonly) int cropX; @property(nonatomic, readonly) int cropY; @property(nonatomic, readonly) int cropWidth; @property(nonatomic, readonly) int cropHeight; + (NSSet<NSNumber *> *)supportedPixelFormats; - (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer; - (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer adaptedWidth:(int)adaptedWidth adaptedHeight:(int)adaptedHeight cropWidth:(int)cropWidth cropHeight:(int)cropHeight cropX:(int)cropX cropY:(int)cropY; - (BOOL)requiresCropping; - (BOOL)requiresScalingToWidth:(int)width height:(int)height; - (int)bufferSizeForCroppingAndScalingToWidth:(int)width height:(int)height; /** The minimum size of the |tmpBuffer| must be the number of bytes returned from the * bufferSizeForCroppingAndScalingToWidth:height: method. * If that size is 0, the |tmpBuffer| may be nil. */ - (BOOL)cropAndScaleTo:(CVPixelBufferRef)outputPixelBuffer withTempBuffer:(nullable uint8_t *)tmpBuffer; #if defined(WEBRTC_WEBKIT_BUILD) - (void)close; #endif @end NS_ASSUME_NONNULL_END
/* * Determine if two signatures are identical for the purpose of tail calls. */ static int signature_identical(jit_type_t type1, jit_type_t type2) { if(type1 == type2) { return 1; } type1 = jit_type_remove_tags(type1); type2 = jit_type_remove_tags(type2); if(!type1 || !type2) { return 0; } if(type1->kind == JIT_TYPE_PTR) { type1 = jit_type_normalize(type1); } if(type2->kind == JIT_TYPE_PTR) { type2 = jit_type_normalize(type2); } #ifdef JIT_NFLOAT_IS_DOUBLE if((type1->kind == JIT_TYPE_FLOAT64 || type1->kind == JIT_TYPE_NFLOAT) && (type2->kind == JIT_TYPE_FLOAT64 || type2->kind == JIT_TYPE_NFLOAT)) { return 1; } #endif if(type1->kind != type2->kind) { return 0; } if(type1->kind == JIT_TYPE_STRUCT || type1->kind == JIT_TYPE_UNION) { return (jit_type_get_size(type1) == jit_type_get_size(type2) && jit_type_get_alignment(type1) == jit_type_get_alignment(type2)); } if(type1->kind == JIT_TYPE_SIGNATURE) { if(type1->abi != type2->abi) { return 0; } if(!signature_identical(type1->sub_type, type2->sub_type)) { return 0; } if(type1->num_components != type2->num_components) { return 0; } unsigned int param; for(param = 0; param < type1->num_components; ++param) { if(!signature_identical(type1->components[param].type, type2->components[param].type)) { return 0; } } } return 1; }
/* Note: Just because the archive is not zip64 doesn't necessarily mean it doesn't have Zip64 extended information extra field, argh. */ mz_bool mz_zip_is_zip64(mz_zip_archive* pZip) { if ((!pZip) || (!pZip->m_pState)) return MZ_FALSE; return pZip->m_pState->m_zip64; }
/* Size of data that has yet to be read */ static inline uint32_t buf_rsize(const struct buf *buf) { ASSERT(buf->rpos <= buf->wpos); return (uint32_t)(buf->wpos - buf->rpos); }
/* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #ifndef _FB_FLOWOP_H #define _FB_FLOWOP_H #include "filebench.h" typedef struct flowop { char fo_name[128]; /* Name */ int fo_instance; /* Instance number */ struct flowop *fo_next; /* Next in global list */ struct flowop *fo_exec_next; /* Next in thread's or compfo's list */ struct flowop *fo_resultnext; /* List of flowops in result */ struct flowop *fo_comp_fops; /* List of flowops in composite fo */ var_t *fo_lvar_list; /* List of composite local vars */ struct threadflow *fo_thread; /* Backpointer to thread */ int (*fo_func)(); /* Method */ int (*fo_init)(); /* Init Method */ void (*fo_destruct)(); /* Destructor Method */ int fo_type; /* Type */ int fo_attrs; /* Flow op attribute */ avd_t fo_filename; /* file/fileset name */ fileset_t *fo_fileset; /* Fileset for op */ int fo_fdnumber; /* User specified file descriptor */ int fo_srcfdnumber; /* User specified src file descriptor */ fbint_t fo_constvalue; /* constant version of fo_value */ fbint_t fo_constwss; /* constant version of fo_wss */ avd_t fo_iosize; /* Size of operation */ avd_t fo_wss; /* Flow op working set size */ char fo_targetname[128]; /* Target, for wakeup etc... */ struct flowop *fo_targets; /* List of targets matching name */ struct flowop *fo_targetnext; /* List of targets matching name */ avd_t fo_iters; /* Number of iterations of op */ avd_t fo_value; /* Attr */ avd_t fo_sequential; /* Attr */ avd_t fo_random; /* Attr */ avd_t fo_stride; /* Attr */ avd_t fo_backwards; /* Attr */ avd_t fo_dsync; /* Attr */ avd_t fo_blocking; /* Attr */ avd_t fo_directio; /* Attr */ avd_t fo_rotatefd; /* Attr */ avd_t fo_fileindex; /* Attr */ avd_t fo_noreadahead; /* Attr */ struct flowstats fo_stats; /* Flow statistics */ pthread_cond_t fo_cv; /* Block/wakeup cv */ pthread_mutex_t fo_lock; /* Mutex around flowop */ void *fo_private; /* Flowop private scratch pad area */ char *fo_buf; /* Per-flowop buffer */ uint64_t fo_buf_size; /* current size of buffer */ #ifdef HAVE_SYSV_SEM int fo_semid_lw; /* sem id */ int fo_semid_hw; /* sem id for highwater block */ #else sem_t fo_sem; /* sem_t for posix semaphores */ #endif /* HAVE_SYSV_SEM */ avd_t fo_highwater; /* value of highwater paramter */ void *fo_idp; /* id, for sems etc */ hrtime_t fo_timestamp; /* for ratecontrol, etc... */ int fo_initted; /* Set to one if initialized */ int64_t fo_tputbucket; /* Throughput bucket, for limiter */ uint64_t fo_tputlast; /* Throughput count, for delta's */ } flowop_t; /* Flow Op Attrs */ #define FLOW_ATTR_SEQUENTIAL 0x1 #define FLOW_ATTR_RANDOM 0x2 #define FLOW_ATTR_STRIDE 0x4 #define FLOW_ATTR_BACKWARDS 0x8 #define FLOW_ATTR_DSYNC 0x10 #define FLOW_ATTR_BLOCKING 0x20 #define FLOW_ATTR_DIRECTIO 0x40 #define FLOW_ATTR_READ 0x80 #define FLOW_ATTR_WRITE 0x100 #define FLOW_ATTR_FADV_RANDOM 0x200 /* Flowop Instance Numbers */ /* Worker flowops have instance numbers > 0 */ #define FLOW_DEFINITION 0 /* Prototype definition of flowop from library */ #define FLOW_INNER_DEF -1 /* Constructed proto flowops within composite */ #define FLOW_MASTER -2 /* Master flowop based on flowop declaration */ /* supplied within a thread definition */ /* Flowop type definitions */ #define FLOW_TYPES 6 #define FLOW_TYPE_GLOBAL 0 /* Rolled up statistics */ #define FLOW_TYPE_IO 1 /* Op is an I/O, reflected in iops and lat */ #define FLOW_TYPE_AIO 2 /* Op is an async I/O, reflected in iops */ #define FLOW_TYPE_SYNC 3 /* Op is a sync event */ #define FLOW_TYPE_COMPOSITE 4 /* Op is a composite flowop */ #define FLOW_TYPE_OTHER 5 /* Op is a something else */ typedef struct flowop_proto { int fl_type; int fl_attrs; char *fl_name; int (*fl_init)(); int (*fl_func)(); void (*fl_destruct)(); } flowop_proto_t; extern struct flowstats controlstats; extern pthread_mutex_t controlstats_lock; flowop_t *flowop_define(threadflow_t *, char *name, flowop_t *inherit, flowop_t **flowoplist_hdp, int instance, int type); flowop_t *flowop_find(char *name); flowop_t *flowop_find_one(char *name, int instance); flowop_t *flowop_find_from_list(char *name, flowop_t *list); int flowop_init_generic(flowop_t *flowop); void flowop_destruct_generic(flowop_t *flowop); void flowop_add_from_proto(flowop_proto_t *list, int nops); int flowoplib_iosetup(threadflow_t *threadflow, flowop_t *flowop, fbint_t *wssp, caddr_t *iobufp, fb_fdesc_t **filedescp, fbint_t iosize); void flowoplib_flowinit(void); void flowop_delete_all(flowop_t **threadlist); void flowop_endop(threadflow_t *threadflow, flowop_t *flowop, int64_t bytes); void flowop_beginop(threadflow_t *threadflow, flowop_t *flowop); void flowop_destruct_all_flows(threadflow_t *threadflow); flowop_t *flowop_new_composite_define(char *name); void flowop_printall(void); void flowop_init(int ismaster); /* Local file system specific */ void fb_lfs_funcvecinit(); void fb_lfs_newflowops(); #endif /* _FB_FLOWOP_H */
/* vbap1.c: Copyright (C) 2000 Ville Pulkki 2012 John ffitch This file is part of Csound. The Csound Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. Csound is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with Csound; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* vbap1.c functions specific gains for loudspeaker VBAP Ville Pulkki heavily modified by John ffitch 2012 */ #include "csoundCore.h" #include "vbap.h" #include <math.h> #include <stdio.h> #include <stdlib.h> static int32_t vbap1_moving_control(CSOUND *, VBAP1_MOVE_DATA *, OPDS *, MYFLT, MYFLT, MYFLT, MYFLT**); static int32_t vbap1_control(CSOUND *, VBAP1_DATA *, MYFLT*, MYFLT*, MYFLT*); int32_t vbap1(CSOUND *csound, VBAP1 *p) /* during note performance: */ { int32_t j; int32_t cnt = p->q.number; vbap1_control(csound,&p->q, p->azi, p->ele, p->spread); /* write gains */ for (j=0; j<cnt; j++) { *p->out_array[j] = p->q.gains[j]; } return OK; } static int32_t vbap1_control(CSOUND *csound, VBAP1_DATA *p, MYFLT* azi, MYFLT* ele, MYFLT* spread) { CART_VEC spreaddir[16]; CART_VEC spreadbase[16]; ANG_VEC atmp; int32 i,j, spreaddirnum; int32_t cnt = p->number; MYFLT *tmp_gains=malloc(sizeof(MYFLT)*cnt),sum=FL(0.0); if (UNLIKELY(p->dim == 2 && fabs(*ele) > 0.0)) { csound->Warning(csound, Str("Warning: truncating elevation to 2-D plane\n")); *ele = FL(0.0); } if (*spread <FL(0.0)) *spread = FL(0.0); else if (*spread >FL(100.0)) *spread = FL(100.0); /* Current panning angles */ p->ang_dir.azi = *azi; p->ang_dir.ele = *ele; p->ang_dir.length = FL(1.0); angle_to_cart(p->ang_dir, &(p->cart_dir)); calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, p->gains, cnt, p->cart_dir); /* Calculated gain factors of a spreaded virtual source*/ if (*spread > FL(0.0)) { if (p->dim == 3) { spreaddirnum = 16; /* four orthogonal dirs*/ new_spread_dir(&spreaddir[0], p->cart_dir, p->spread_base, *azi, *spread); new_spread_base(spreaddir[0], p->cart_dir, *spread, &p->spread_base); cross_prod(p->spread_base, p->cart_dir, &spreadbase[1]); cross_prod(spreadbase[1], p->cart_dir, &spreadbase[2]); cross_prod(spreadbase[2], p->cart_dir, &spreadbase[3]); /* four between them*/ vec_mean(p->spread_base, spreadbase[1], &spreadbase[4]); vec_mean(spreadbase[1], spreadbase[2], &spreadbase[5]); vec_mean(spreadbase[2], spreadbase[3], &spreadbase[6]); vec_mean(spreadbase[3], p->spread_base, &spreadbase[7]); /* four at half spreadangle*/ vec_mean(p->cart_dir, p->spread_base, &spreadbase[8]); vec_mean(p->cart_dir, spreadbase[1], &spreadbase[9]); vec_mean(p->cart_dir, spreadbase[2], &spreadbase[10]); vec_mean(p->cart_dir, spreadbase[3], &spreadbase[11]); /* four at quarter spreadangle*/ vec_mean(p->cart_dir, spreadbase[8], &spreadbase[12]); vec_mean(p->cart_dir, spreadbase[9], &spreadbase[13]); vec_mean(p->cart_dir, spreadbase[10], &spreadbase[14]); vec_mean(p->cart_dir, spreadbase[11], &spreadbase[15]); for (i=1;i<spreaddirnum;i++) { new_spread_dir(&spreaddir[i], p->cart_dir, spreadbase[i],*azi,*spread); calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, tmp_gains, cnt, spreaddir[i]); for (j=0;j<cnt;j++) { p->gains[j] += tmp_gains[j]; } } } else if (p->dim == 2) { spreaddirnum = 6; atmp.ele = FL(0.0); atmp.azi = *azi - *spread; angle_to_cart(atmp, &spreaddir[0]); atmp.azi = *azi - *spread/2; angle_to_cart(atmp, &spreaddir[1]); atmp.azi = *azi - *spread/4; angle_to_cart(atmp, &spreaddir[2]); atmp.azi = *azi + *spread/4; angle_to_cart(atmp, &spreaddir[3]); atmp.azi = *azi + *spread/2; angle_to_cart(atmp, &spreaddir[4]); atmp.azi = *azi + *spread; angle_to_cart(atmp, &spreaddir[5]); for (i=0;i<spreaddirnum;i++) { calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, tmp_gains, cnt, spreaddir[i]); for (j=0;j<cnt;j++) { p->gains[j] += tmp_gains[j]; } } } } if (*spread > FL(70.0)) for (i=0;i<cnt ;i++) { p->gains[i] +=(*spread - FL(70.0))/FL(30.0) * (*spread - FL(70.0))/FL(30.0)*FL(20.0); } /*normalization*/ for (i=0;i<cnt;i++) { sum=sum+(p->gains[i]*p->gains[i]); } sum=SQRT(sum); for (i=0;i<cnt;i++) { p->gains[i] /= sum; } free(tmp_gains); return OK; } int32_t vbap1_init(CSOUND *csound, VBAP1 *p) { /* Initializations before run time*/ int32_t i, j; MYFLT *ls_table, *ptr; LS_SET *ls_set_ptr; char name[24]; snprintf(name, 24, "vbap_ls_table_%d", (int32_t)*p->layout); ls_table = (MYFLT*) (csound->QueryGlobalVariableNoCheck(csound, name)); if (ls_table==NULL) return csound->InitError(csound, Str("could not find layout table no.%d"), (int32_t)*p->layout ); p->q.number = p->OUTOCOUNT; p->q.dim = (int32_t)ls_table[0]; /* reading in loudspeaker info */ p->q.ls_am = (int32_t)ls_table[1]; p->q.ls_set_am = (int32_t)ls_table[2]; ptr = &(ls_table[3]); if (!p->q.ls_set_am) return csound->InitError(csound, Str("vbap system NOT configured.\nMissing" " vbaplsinit opcode in orchestra?")); csound->AuxAlloc(csound, p->q.ls_set_am * sizeof (LS_SET), &p->q.aux); if (UNLIKELY(p->q.aux.auxp == NULL)) { return csound->InitError(csound, Str("could not allocate memory")); } p->q.ls_sets = (LS_SET*) p->q.aux.auxp; ls_set_ptr = p->q.ls_sets; for (i=0; i < p->q.ls_set_am; i++) { ls_set_ptr[i].ls_nos[2] = 0; /* initial setting */ for (j=0 ; j < p->q.dim ; j++) { ls_set_ptr[i].ls_nos[j] = (int32_t)*(ptr++); } memset(ls_set_ptr[i].ls_mx, '\0', 9*sizeof(MYFLT)); // initial setting /* for (j=0 ; j < 9; j++) */ /* ls_set_ptr[i].ls_mx[j] = FL(0.0); /\*initial setting*\/ */ for (j=0 ; j < (p->q.dim) * (p->q.dim); j++) { ls_set_ptr[i].ls_mx[j] = (MYFLT)*(ptr++); } } /* other initialization */ if (UNLIKELY(p->q.dim == 2 && fabs(*p->ele) > 0.0)) { csound->Warning(csound, Str("Warning: truncating elevation to 2-D plane\n")); *p->ele = FL(0.0); } p->q.ang_dir.azi = (MYFLT)*p->azi; p->q.ang_dir.ele = (MYFLT)*p->ele; p->q.ang_dir.length = FL(1.0); angle_to_cart(p->q.ang_dir, &(p->q.cart_dir)); p->q.spread_base.x = p->q.cart_dir.y; p->q.spread_base.y = p->q.cart_dir.z; p->q.spread_base.z = -p->q.cart_dir.x; vbap1_control(csound,&p->q, p->azi, p->ele, p->spread); return OK; } int32_t vbap1a(CSOUND *csound, VBAPA1 *p) /* during note performance: */ { int32_t j; int32_t cnt = p->q.number; vbap1_control(csound,&p->q, p->azi, p->ele, p->spread); /* write gains */ for (j=0; j<cnt; j++) { p->tabout->data[j] = p->q.gains[j]; } return OK; } int32_t vbap1_init_a(CSOUND *csound, VBAPA1 *p) { /* Initializations before run time*/ int32_t i, j; MYFLT *ls_table, *ptr; LS_SET *ls_set_ptr; char name[24]; snprintf(name, 24, "vbap_ls_table_%d", (int32_t)*p->layout); ls_table = (MYFLT*) (csound->QueryGlobalVariableNoCheck(csound, name)); if (ls_table==NULL) return csound->InitError(csound, Str("could not find layout table no.%d"), (int32_t)*p->layout ); p->q.number = p->tabout->sizes[0]; p->q.dim = (int32_t)ls_table[0]; /* reading in loudspeaker info */ p->q.ls_am = (int32_t)ls_table[1]; p->q.ls_set_am = (int32_t)ls_table[2]; ptr = &(ls_table[3]); if (!p->q.ls_set_am) return csound->InitError(csound, Str("vbap system NOT configured.\nMissing" " vbaplsinit opcode in orchestra?")); csound->AuxAlloc(csound, p->q.ls_set_am * sizeof (LS_SET), &p->q.aux); if (UNLIKELY(p->q.aux.auxp == NULL)) { return csound->InitError(csound, Str("could not allocate memory")); } p->q.ls_sets = (LS_SET*) p->q.aux.auxp; ls_set_ptr = p->q.ls_sets; for (i=0; i < p->q.ls_set_am; i++) { ls_set_ptr[i].ls_nos[2] = 0; /* initial setting */ for (j=0 ; j < p->q.dim ; j++) { ls_set_ptr[i].ls_nos[j] = (int32_t)*(ptr++); } memset(ls_set_ptr[i].ls_mx, '\0', 9*sizeof(MYFLT)); /*initial setting*/ for (j=0 ; j < (p->q.dim) * (p->q.dim); j++) { ls_set_ptr[i].ls_mx[j] = (MYFLT)*(ptr++); } } /* other initialization */ if (UNLIKELY(p->q.dim == 2 && fabs(*p->ele) > 0.0)) { csound->Warning(csound, Str("Warning: truncating elevation to 2-D plane\n")); *p->ele = FL(0.0); } p->q.ang_dir.azi = (MYFLT)*p->azi; p->q.ang_dir.ele = (MYFLT)*p->ele; p->q.ang_dir.length = FL(1.0); angle_to_cart(p->q.ang_dir, &(p->q.cart_dir)); p->q.spread_base.x = p->q.cart_dir.y; p->q.spread_base.y = p->q.cart_dir.z; p->q.spread_base.z = -p->q.cart_dir.x; vbap1_control(csound,&p->q, p->azi, p->ele, p->spread); return OK; } int32_t vbap1_moving(CSOUND *csound, VBAP1_MOVING *p) { /* during note performance: */ int32_t j; int32_t cnt = p->q.number; vbap1_moving_control(csound,&p->q, &(p->h), CS_ONEDKR, *p->spread, *p->field_am, p->fld); /* write audio to resulting audio streams weighted with gain factors*/ for (j=0; j<cnt ;j++) { *p->out_array[j] = p->q.gains[j]; } return OK; } int32_t vbap1_moving_a(CSOUND *csound, VBAPA1_MOVING *p) { /* during note performance: */ // int32_t j; int32_t cnt = p->q.number; vbap1_moving_control(csound,&p->q, &(p->h), CS_ONEDKR, *p->spread, *p->field_am, p->fld); /* write audio to resulting audio streams weighted with gain factors*/ memcpy(p->tabout->data, p->q.gains, cnt*sizeof(MYFLT)); /* for (j=0; j<cnt ;j++) { */ /* p->tabout->data[j] = p->q.gains[j]; */ /* } */ return OK; } static int32_t vbap1_moving_control(CSOUND *csound, VBAP1_MOVE_DATA *p, OPDS *h, MYFLT ONEDKR, MYFLT spread, MYFLT field_am, MYFLT **fld) { CART_VEC spreaddir[16]; CART_VEC spreadbase[16]; ANG_VEC atmp; int32 i,j, spreaddirnum; CART_VEC tmp1, tmp2, tmp3; MYFLT coeff, angle; int32_t cnt = p->number; MYFLT *tmp_gains=malloc(sizeof(MYFLT)*cnt),sum=FL(0.0); #ifdef JPFF printf("cnt=%d dim=%d\n", cnt, p->dim); #endif if (UNLIKELY(p->dim == 2 && fabs(p->ang_dir.ele) > 0.0)) { csound->Warning(csound, Str("Warning: truncating elevation to 2-D plane\n")); p->ang_dir.ele = FL(0.0); } if (spread <FL(0.0)) spread = FL(0.0); else if (spread >FL(100.0)) spread = FL(100.0); if (p->point_change_counter++ >= p->point_change_interval) { p->point_change_counter = 0; p->curr_fld = p->next_fld; if (++p->next_fld >= (int32_t) fabs(field_am)) { if (field_am >= FL(0.0)) /* point-to-point */ p->next_fld = 0; else p->next_fld = 1; } if (p->dim == 3) { /*jumping over second field */ p->curr_fld = p->next_fld; if (++p->next_fld >= ((int32_t) fabs(field_am))) { if (field_am >= FL(0.0)) /* point-to-point */ p->next_fld = 0; else p->next_fld = 1; } } if (UNLIKELY((fld[abs(p->next_fld)]==NULL))) { free(tmp_gains); return csound->PerfError(csound, h, Str("Missing fields in vbapmove\n")); } if (field_am >= FL(0.0) && p->dim == 2) /* point-to-point */ if (UNLIKELY(fabs(fabs(*fld[p->next_fld] - *fld[p->curr_fld]) - 180.0) < 1.0)) csound->Warning(csound, Str("Warning: Ambiguous transition 180 degrees.\n")); } if (field_am >= FL(0.0)) { /* point-to-point */ if (p->dim == 3) { /* 3-D*/ p->prev_ang_dir.azi = *fld[p->curr_fld-1]; p->next_ang_dir.azi = *fld[p->next_fld]; p->prev_ang_dir.ele = *fld[p->curr_fld]; p->next_ang_dir.ele = *fld[p->next_fld+1]; coeff = ((MYFLT) p->point_change_counter) / ((MYFLT) p->point_change_interval); angle_to_cart( p->prev_ang_dir,&tmp1); angle_to_cart( p->next_ang_dir,&tmp2); tmp3.x = (FL(1.0)-coeff) * tmp1.x + coeff * tmp2.x; tmp3.y = (FL(1.0)-coeff) * tmp1.y + coeff * tmp2.y; tmp3.z = (FL(1.0)-coeff) * tmp1.z + coeff * tmp2.z; coeff = (MYFLT)sqrt((double)(tmp3.x * tmp3.x + tmp3.y * tmp3.y + tmp3.z * tmp3.z)); tmp3.x /= coeff; tmp3.y /= coeff; tmp3.z /= coeff; cart_to_angle(tmp3,&(p->ang_dir)); } else if (p->dim == 2) { /* 2-D */ p->prev_ang_dir.azi = *fld[p->curr_fld]; p->next_ang_dir.azi = *fld[p->next_fld ]; p->prev_ang_dir.ele = p->next_ang_dir.ele = FL(0.0); scale_angles(&(p->prev_ang_dir)); scale_angles(&(p->next_ang_dir)); angle = (p->prev_ang_dir.azi - p->next_ang_dir.azi); while (angle > FL(180.0)) angle -= FL(360.0); while (angle < -FL(180.0)) angle += FL(360.0); coeff = ((MYFLT) p->point_change_counter) / ((MYFLT) p->point_change_interval); angle *= (coeff); p->ang_dir.azi = p->prev_ang_dir.azi - angle; p->ang_dir.ele = FL(0.0); } else { free(tmp_gains); return csound->PerfError(csound, h, Str("Missing fields in vbapmove\n")); } } else { /* angular velocities */ if (p->dim == 2) { p->ang_dir.azi = p->ang_dir.azi + (*fld[p->next_fld] * ONEDKR); scale_angles(&(p->ang_dir)); } else { /* 3D angular*/ p->ang_dir.azi = p->ang_dir.azi + (*fld[p->next_fld] * ONEDKR); p->ang_dir.ele = p->ang_dir.ele + p->ele_vel * (*fld[p->next_fld+1] * ONEDKR); if (p->ang_dir.ele > FL(90.0)) { p->ang_dir.ele = FL(90.0); p->ele_vel = -p->ele_vel; } if (p->ang_dir.ele < FL(0.0)) { p->ang_dir.ele = FL(0.0); p->ele_vel = -p->ele_vel; } scale_angles(&(p->ang_dir)); } } angle_to_cart(p->ang_dir, &(p->cart_dir)); calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, p->gains, cnt, p->cart_dir); if (spread > FL(0.0)) { if (p->dim == 3) { spreaddirnum=16; /* four orthogonal dirs*/ new_spread_dir(&spreaddir[0], p->cart_dir, p->spread_base, p->ang_dir.azi, spread); new_spread_base(spreaddir[0], p->cart_dir, spread, &p->spread_base); cross_prod(p->spread_base, p->cart_dir, &spreadbase[1]); cross_prod(spreadbase[1], p->cart_dir, &spreadbase[2]); cross_prod(spreadbase[2], p->cart_dir, &spreadbase[3]); /* four between them*/ vec_mean(p->spread_base, spreadbase[1], &spreadbase[4]); vec_mean(spreadbase[1], spreadbase[2], &spreadbase[5]); vec_mean(spreadbase[2], spreadbase[3], &spreadbase[6]); vec_mean(spreadbase[3], p->spread_base, &spreadbase[7]); /* four at half spreadangle*/ vec_mean(p->cart_dir, p->spread_base, &spreadbase[8]); vec_mean(p->cart_dir, spreadbase[1], &spreadbase[9]); vec_mean(p->cart_dir, spreadbase[2], &spreadbase[10]); vec_mean(p->cart_dir, spreadbase[3], &spreadbase[11]); /* four at quarter spreadangle*/ vec_mean(p->cart_dir, spreadbase[8], &spreadbase[12]); vec_mean(p->cart_dir, spreadbase[9], &spreadbase[13]); vec_mean(p->cart_dir, spreadbase[10], &spreadbase[14]); vec_mean(p->cart_dir, spreadbase[11], &spreadbase[15]); for (i=1;i<spreaddirnum;i++) { new_spread_dir(&spreaddir[i], p->cart_dir, spreadbase[i],p->ang_dir.azi,spread); calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, tmp_gains, cnt, spreaddir[i]); for (j=0;j<cnt;j++) { p->gains[j] += tmp_gains[j]; } } } else if (p->dim == 2) { spreaddirnum=6; atmp.ele = FL(0.0); atmp.azi = p->ang_dir.azi - spread; angle_to_cart(atmp, &spreaddir[0]); atmp.azi = p->ang_dir.azi - spread/2; angle_to_cart(atmp, &spreaddir[1]); atmp.azi = p->ang_dir.azi - spread/4; angle_to_cart(atmp, &spreaddir[2]); atmp.azi = p->ang_dir.azi + spread/4; angle_to_cart(atmp, &spreaddir[3]); atmp.azi = p->ang_dir.azi + spread/2; angle_to_cart(atmp, &spreaddir[4]); atmp.azi = p->ang_dir.azi + spread; angle_to_cart(atmp, &spreaddir[5]); for (i=0;i<spreaddirnum;i++) { calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, tmp_gains, cnt, spreaddir[i]); for (j=0;j<cnt;j++) { p->gains[j] += tmp_gains[j]; } } } } if (spread > FL(70.0)) for (i=0;i<cnt ;i++) { p->gains[i] +=(spread - FL(70.0))/FL(30.0) * (spread - FL(70.0))/FL(30.0)*FL(10.0); } /*normalization*/ for (i=0;i<cnt;i++) { sum=sum+(p->gains[i]*p->gains[i]); } sum=SQRT(sum); for (i=0;i<cnt;i++) { p->gains[i] /= sum; } free(tmp_gains); return OK; } int32_t vbap1_moving_init(CSOUND *csound, VBAP1_MOVING *p) { int32_t i, j; MYFLT *ls_table, *ptr; LS_SET *ls_set_ptr; p->q.number = p->OUTCOUNT; ls_table = (MYFLT*) (csound->QueryGlobalVariableNoCheck(csound, "vbap_ls_table_0")); /* reading in loudspeaker info */ p->q.dim = (int32_t)ls_table[0]; p->q.ls_am = (int32_t)ls_table[1]; p->q.ls_set_am = (int32_t)ls_table[2]; ptr = &(ls_table[3]); if (!p->q.ls_set_am) return csound->InitError(csound, Str("vbap system NOT configured.\n" "Missing vbaplsinit opcode" " in orchestra?")); csound->AuxAlloc(csound, p->q.ls_set_am * sizeof(LS_SET), &p->q.aux); if (UNLIKELY(p->q.aux.auxp == NULL)) { return csound->InitError(csound, Str("could not allocate memory")); } p->q.ls_sets = (LS_SET*) p->q.aux.auxp; ls_set_ptr = p->q.ls_sets; for (i=0 ; i < p->q.ls_set_am ; i++) { ls_set_ptr[i].ls_nos[2] = 0; /* initial setting */ for (j=0 ; j < p->q.dim ; j++) { ls_set_ptr[i].ls_nos[j] = (int32_t)*(ptr++); } for (j=0 ; j < 9; j++) ls_set_ptr[i].ls_mx[j] = FL(0.0); /*initial setting*/ for (j=0 ; j < (p->q.dim) * (p->q.dim); j++) { ls_set_ptr[i].ls_mx[j] = (MYFLT)*(ptr++); } } /* other initialization */ p->q.ele_vel = FL(1.0); /* functions specific to movement */ if (UNLIKELY(fabs(*p->field_am) < (2+ (p->q.dim - 2)*2))) { return csound->InitError(csound, Str("Have to have at least %d directions in vbapmove"), 2 + (p->q.dim - 2) * 2); } if (p->q.dim == 2) p->q.point_change_interval = (int32_t)(CS_EKR * *p->dur /(fabs(*p->field_am) - 1.0)); else if (LIKELY(p->q.dim == 3)) p->q.point_change_interval = (int32_t)(CS_EKR * *p->dur /(fabs(*p->field_am)*0.5 - 1.0)); else return csound->InitError(csound, Str("Wrong dimension")); p->q.point_change_counter = 0; p->q.curr_fld = 0; p->q.next_fld = 1; p->q.ang_dir.azi = *p->fld[0]; if (p->q.dim == 3) { p->q.ang_dir.ele = *p->fld[1]; } else { p->q.ang_dir.ele = FL(0.0); } if (p->q.dim == 3) { p->q.curr_fld = 1; p->q.next_fld = 2; } angle_to_cart(p->q.ang_dir, &(p->q.cart_dir)); p->q.spread_base.x = p->q.cart_dir.y; p->q.spread_base.y = p->q.cart_dir.z; p->q.spread_base.z = -p->q.cart_dir.x; vbap1_moving_control(csound,&p->q, &(p->h), CS_ONEDKR, *p->spread, *p->field_am, p->fld); return OK; } int32_t vbap1_moving_init_a(CSOUND *csound, VBAPA1_MOVING *p) { int32_t i, j; MYFLT *ls_table, *ptr; LS_SET *ls_set_ptr; if (UNLIKELY(p->tabout->data == NULL || p->tabout->dimensions!=1)) return csound->InitError(csound, Str("Output array not initialised")); p->q.number = p->tabout->sizes[0]; ls_table = (MYFLT*) (csound->QueryGlobalVariableNoCheck(csound, "vbap_ls_table_0")); /* reading in loudspeaker info */ p->q.dim = (int32_t)ls_table[0]; p->q.ls_am = (int32_t)ls_table[1]; p->q.ls_set_am = (int32_t)ls_table[2]; ptr = &(ls_table[3]); if (UNLIKELY(!p->q.ls_set_am)) return csound->InitError(csound, Str("vbap system NOT configured.\n" "Missing vbaplsinit opcode" " in orchestra?")); csound->AuxAlloc(csound, p->q.ls_set_am * sizeof(LS_SET), &p->q.aux); if (UNLIKELY(p->q.aux.auxp == NULL)) { return csound->InitError(csound, Str("could not allocate memory")); } p->q.ls_sets = (LS_SET*) p->q.aux.auxp; ls_set_ptr = p->q.ls_sets; for (i=0 ; i < p->q.ls_set_am ; i++) { ls_set_ptr[i].ls_nos[2] = 0; /* initial setting */ for (j=0 ; j < p->q.dim ; j++) { ls_set_ptr[i].ls_nos[j] = (int32_t)*(ptr++); } for (j=0 ; j < 9; j++) ls_set_ptr[i].ls_mx[j] = FL(0.0); /*initial setting*/ for (j=0 ; j < (p->q.dim) * (p->q.dim); j++) { ls_set_ptr[i].ls_mx[j] = (MYFLT)*(ptr++); } } /* other initialization */ p->q.ele_vel = FL(1.0); /* functions specific to movement */ if (UNLIKELY(fabs(*p->field_am) < (2+ (p->q.dim - 2)*2))) { return csound->InitError(csound, Str("Have to have at least %d directions in vbapmove"), 2 + (p->q.dim - 2) * 2); } if (p->q.dim == 2) p->q.point_change_interval = (int32_t)(CS_EKR * *p->dur /(fabs(*p->field_am) - 1.0)); else if (LIKELY(p->q.dim == 3)) p->q.point_change_interval = (int32_t)(CS_EKR * *p->dur /(fabs(*p->field_am)*0.5 - 1.0)); else return csound->InitError(csound, Str("Wrong dimension")); p->q.point_change_counter = 0; p->q.curr_fld = 0; p->q.next_fld = 1; p->q.ang_dir.azi = *p->fld[0]; if (p->q.dim == 3) { p->q.ang_dir.ele = *p->fld[1]; } else { p->q.ang_dir.ele = FL(0.0); } if (p->q.dim == 3) { p->q.curr_fld = 1; p->q.next_fld = 2; } angle_to_cart(p->q.ang_dir, &(p->q.cart_dir)); p->q.spread_base.x = p->q.cart_dir.y; p->q.spread_base.y = p->q.cart_dir.z; p->q.spread_base.z = -p->q.cart_dir.x; vbap1_moving_control(csound,&p->q, &(p->h), CS_ONEDKR, *p->spread, *p->field_am, p->fld); return OK; }
/* * Handle byte-size next proto field * * @param **payload Pointer to payload pointer * @param *size Pointer to payload size * @return Updated pointer and size information */ inline int __attribute__((always_inline)) handle_nextproto_b(uint8_t **payload, int *size) { char *p = (char *)*payload; if(*size < sizeof(uint8_t)) { SSENDL(sizeof(SIZEERR)-1,SIZEERR); cgc__terminate(28); } *size -= sizeof(uint8_t); *payload += sizeof(uint8_t); return p[0]; }
#ifndef ECAL_PULSESHAPES_HANDLER_H #define ECAL_PULSESHAPES_HANDLER_H #include <vector> #include <typeinfo> #include <string> #include <map> #include <iostream> #include <ctime> #include "CondCore/PopCon/interface/PopConSourceHandler.h" #include "FWCore/ParameterSet/interface/ParameterSetfwd.h" #include "FWCore/ServiceRegistry/interface/Service.h" #include "CondCore/DBOutputService/interface/PoolDBOutputService.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/Common/interface/Handle.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/EventSetupRecordKey.h" #include "CondFormats/EcalObjects/interface/EcalPulseShapes.h" #include "CondFormats/DataRecord/interface/EcalPulseShapesRcd.h" #include "DataFormats/EcalDetId/interface/EEDetId.h" #include "DataFormats/EcalDetId/interface/EBDetId.h" #include "DataFormats/Provenance/interface/Timestamp.h" namespace edm { class ParameterSet; class Event; class EventSetup; } // namespace edm namespace popcon { class EcalPulseShapesHandler : public popcon::PopConSourceHandler<EcalPulseShapes> { public: EcalPulseShapesHandler(edm::ParameterSet const&); ~EcalPulseShapesHandler() override; bool checkPulseShape(EcalPulseShapes::Item* item); void fillSimPulseShape(EcalPulseShapes::Item* item, bool isbarrel); void getNewObjects() override; std::string id() const override { return m_name; } private: const EcalPulseShapes* mypulseshapes; unsigned int m_firstRun; unsigned int m_lastRun; std::string m_gentag; std::string m_filename; std::string m_name; std::vector<double> m_EBPulseShapeTemplate, m_EEPulseShapeTemplate; }; } // namespace popcon #endif
// SPDX-License-Identifier: GPL-2.0+ /* * Functions related to OMAP3 SDRC. * * This file has been created after exctracting and consolidating * the SDRC related content from mem.c and board.c, also created * generic init function (mem_init). * * Copyright (C) 2004-2010 * Texas Instruments Incorporated - http://www.ti.com/ * * Copyright (C) 2011 * Corscience GmbH & Co. KG - Simon Schwarz <schwarz@corscience.de> * * Author : * Vaibhav Hiremath <hvaibhav@ti.com> * * Original implementation by (mem.c, board.c) : * Sunil Kumar <sunilsaini05@gmail.com> * Shashi Ranjan <shashiranjanmca05@gmail.com> * Manikandan Pillai <mani.pillai@ti.com> */ #include <common.h> #include <init.h> #include <asm/global_data.h> #include <asm/io.h> #include <asm/arch/mem.h> #include <asm/arch/sys_proto.h> DECLARE_GLOBAL_DATA_PTR; extern omap3_sysinfo sysinfo; static struct sdrc *sdrc_base = (struct sdrc *)OMAP34XX_SDRC_BASE; /* * is_mem_sdr - * - Return 1 if mem type in use is SDR */ u32 is_mem_sdr(void) { if (readl(&sdrc_base->cs[CS0].mr) == SDRC_MR_0_SDR) return 1; return 0; } /* * get_sdr_cs_size - * - Get size of chip select 0/1 */ static u32 get_sdr_cs_size(u32 cs) { u32 size; /* get ram size field */ size = readl(&sdrc_base->cs[cs].mcfg) >> 8; size &= 0x3FF; /* remove unwanted bits */ size <<= 21; /* multiply by 2 MiB to find size in MB */ return size; } /* * make_cs1_contiguous - * - When we have CS1 populated we want to have it mapped after cs0 to allow * command line mem=xyz use all memory with out discontinuous support * compiled in. We could do it in the ATAG, but there really is two banks... */ static void make_cs1_contiguous(void) { u32 size, a_add_low, a_add_high; size = get_sdr_cs_size(CS0); size >>= 25; /* divide by 32 MiB to find size to offset CS1 */ a_add_high = (size & 3) << 8; /* set up low field */ a_add_low = (size & 0x3C) >> 2; /* set up high field */ writel((a_add_high | a_add_low), &sdrc_base->cs_cfg); } /* * get_sdr_cs_offset - * - Get offset of cs from cs0 start */ u32 get_sdr_cs_offset(u32 cs) { u32 offset; if (!cs) return 0; offset = readl(&sdrc_base->cs_cfg); offset = (offset & 15) << 27 | (offset & 0x300) << 17; return offset; } /* * write_sdrc_timings - * - Takes CS and associated timings and initalize SDRAM * - Test CS to make sure it's OK for use */ static void write_sdrc_timings(u32 cs, struct sdrc_actim *sdrc_actim_base, struct board_sdrc_timings *timings) { /* Setup timings we got from the board. */ writel(timings->mcfg, &sdrc_base->cs[cs].mcfg); writel(timings->ctrla, &sdrc_actim_base->ctrla); writel(timings->ctrlb, &sdrc_actim_base->ctrlb); writel(timings->rfr_ctrl, &sdrc_base->cs[cs].rfr_ctrl); writel(CMD_NOP, &sdrc_base->cs[cs].manual); writel(CMD_PRECHARGE, &sdrc_base->cs[cs].manual); writel(CMD_AUTOREFRESH, &sdrc_base->cs[cs].manual); writel(CMD_AUTOREFRESH, &sdrc_base->cs[cs].manual); writel(timings->mr, &sdrc_base->cs[cs].mr); /* * Test ram in this bank * Disable if bad or not present */ if (!mem_ok(cs)) writel(0, &sdrc_base->cs[cs].mcfg); } /* * do_sdrc_init - * - Code called once in C-Stack only context for CS0 and with early being * true and a possible 2nd time depending on memory configuration from * stack+global context. */ static void do_sdrc_init(u32 cs, u32 early) { struct sdrc_actim *sdrc_actim_base0, *sdrc_actim_base1; struct board_sdrc_timings timings; sdrc_actim_base0 = (struct sdrc_actim *)SDRC_ACTIM_CTRL0_BASE; sdrc_actim_base1 = (struct sdrc_actim *)SDRC_ACTIM_CTRL1_BASE; /* set some default timings */ timings.sharing = SDRC_SHARING; /* * When called in the early context this may be SPL and we will * need to set all of the timings. This ends up being board * specific so we call a helper function to take care of this * for us. Otherwise, to be safe, we need to copy the settings * from the first bank to the second. We will setup CS0, * then set cs_cfg to the appropriate value then try and * setup CS1. */ #ifdef CONFIG_SPL_BUILD /* set/modify board-specific timings */ get_board_mem_timings(&timings); #endif if (early) { /* reset sdrc controller */ writel(SOFTRESET, &sdrc_base->sysconfig); wait_on_value(RESETDONE, RESETDONE, &sdrc_base->status, 12000000); writel(0, &sdrc_base->sysconfig); /* setup sdrc to ball mux */ writel(timings.sharing, &sdrc_base->sharing); /* Disable Power Down of CKE because of 1 CKE on combo part */ writel(WAKEUPPROC | SRFRONRESET | PAGEPOLICY_HIGH, &sdrc_base->power); writel(ENADLL | DLLPHASE_90, &sdrc_base->dlla_ctrl); sdelay(0x20000); #ifdef CONFIG_SPL_BUILD write_sdrc_timings(CS0, sdrc_actim_base0, &timings); make_cs1_contiguous(); write_sdrc_timings(CS1, sdrc_actim_base1, &timings); #endif } /* * If we aren't using SPL we have been loaded by some * other means which may not have correctly initialized * both CS0 and CS1 (such as some older versions of x-loader) * so we may be asked now to setup CS1. */ if (cs == CS1) { timings.mcfg = readl(&sdrc_base->cs[CS0].mcfg), timings.rfr_ctrl = readl(&sdrc_base->cs[CS0].rfr_ctrl); timings.ctrla = readl(&sdrc_actim_base0->ctrla); timings.ctrlb = readl(&sdrc_actim_base0->ctrlb); timings.mr = readl(&sdrc_base->cs[CS0].mr); write_sdrc_timings(cs, sdrc_actim_base1, &timings); } } /* * dram_init - * - Sets uboots idea of sdram size */ int dram_init(void) { unsigned int size0 = 0, size1 = 0; size0 = get_sdr_cs_size(CS0); /* * We always need to have cs_cfg point at where the second * bank would be, if present. Failure to do so can lead to * strange situations where memory isn't detected and * configured correctly. CS0 will already have been setup * at this point. */ make_cs1_contiguous(); do_sdrc_init(CS1, NOT_EARLY); size1 = get_sdr_cs_size(CS1); gd->ram_size = size0 + size1; return 0; } int dram_init_banksize(void) { unsigned int size0 = 0, size1 = 0; size0 = get_sdr_cs_size(CS0); size1 = get_sdr_cs_size(CS1); gd->bd->bi_dram[0].start = PHYS_SDRAM_1; gd->bd->bi_dram[0].size = size0; gd->bd->bi_dram[1].start = PHYS_SDRAM_1 + get_sdr_cs_offset(CS1); gd->bd->bi_dram[1].size = size1; return 0; } /* * mem_init - * - Init the sdrc chip, * - Selects CS0 and CS1, */ void mem_init(void) { /* only init up first bank here */ do_sdrc_init(CS0, EARLY_INIT); }
//***************************************************************************** // //! Gets the interrupt type for a pin //! //! \param ui32Port is the base address of the GPIO port. //! \param ui8Pin is the pin number. //! //! This function gets the interrupt type for a specified pin on the selected //! GPIO port. The pin can be configured as a falling edge, rising edge, or //! both edge detected interrupt, or can be configured as a low level or //! high level detected interrupt. The type of interrupt detection mechanism //! is returned as an enumerated data type. //! //! \return Returns one of the enumerated data types described for //! GPIOIntTypeSet(). // //***************************************************************************** uint32_t GPIOIntTypeGet(uint32_t ui32Port, uint8_t ui8Pin) { uint32_t ui32IBE, ui32IS, ui32IEV; Check the arguments. ASSERT(GPIOBaseValid(ui32Port)); ASSERT(ui8Pin < 8); Convert from a pin number to a bit position. ui8Pin = 1 << ui8Pin; Return the pin interrupt type. ui32IBE = HWREG(ui32Port + GPIO_O_IBE); ui32IS = HWREG(ui32Port + GPIO_O_IS); ui32IEV = HWREG(ui32Port + GPIO_O_IEV); return(((ui32IBE & ui8Pin) ? 1 : 0) | ((ui32IS & ui8Pin) ? 2 : 0) | ((ui32IEV & ui8Pin) ? 4 : 0)); }
/*! * pixWriteStreamTiff() * * Input: stream (opened for append or write) * pix * comptype (IFF_TIFF, IFF_TIFF_RLE, IFF_TIFF_PACKBITS, * IFF_TIFF_G3, IFF_TIFF_G4, * IFF_TIFF_LZW, IFF_TIFF_ZIP) * Return: 0 if OK, 1 on error * * Notes: * (1) For images with bpp > 1, this resets the comptype, if * necessary, to write uncompressed data. * (2) G3 and G4 are only defined for 1 bpp. * (3) We only allow PACKBITS for bpp = 1, because for bpp > 1 * it typically expands images that are not synthetically generated. * (4) G4 compression is typically about twice as good as G3. * G4 is excellent for binary compression of text/line-art, * but terrible for halftones and dithered patterns. (In * fact, G4 on halftones can give a file that is larger * than uncompressed!) If a binary image has dithered * regions, it is usually better to compress with png. */ l_int32 pixWriteStreamTiff(FILE *fp, PIX *pix, l_int32 comptype) { TIFF *tif; PROCNAME("pixWriteStreamTiff"); if (!fp) return ERROR_INT("stream not defined", procName, 1 ); if (!pix) return ERROR_INT("pix not defined", procName, 1 ); if (pixGetDepth(pix) != 1 && comptype != IFF_TIFF && comptype != IFF_TIFF_LZW && comptype != IFF_TIFF_ZIP) { L_WARNING("invalid compression type for image with bpp > 1", procName); comptype = IFF_TIFF_ZIP; } if ((tif = fopenTiff(fp, "wb")) == NULL) return ERROR_INT("tif not opened", procName, 1); if (pixWriteToTiffStream(tif, pix, comptype, NULL, NULL, NULL, NULL)) { TIFFCleanup(tif); return ERROR_INT("tif write error", procName, 1); } TIFFCleanup(tif); return 0; }
#ifndef _ASM_CRIS_ARCH_TIMEX_H #define _ASM_CRIS_ARCH_TIMEX_H #include <hwregs/reg_map.h> #include <hwregs/reg_rdwr.h> #include <hwregs/timer_defs.h> /* * The clock runs at 100MHz, we divide it by 1000000. If you change anything * here you must check time.c as well. */ #define CLOCK_TICK_RATE 100000000 /* Underlying frequency of the HZ timer */ /* The timer0 values gives 10 ns resolution but interrupts at HZ. */ #define TIMER0_FREQ (CLOCK_TICK_RATE) #define TIMER0_DIV (TIMER0_FREQ/(HZ)) /* Convert the value in step of 10 ns to 1us without overflow: */ #define GET_JIFFIES_USEC() \ ((TIMER0_DIV - REG_RD(timer, regi_timer0, r_tmr0_data)) / 100) extern unsigned long get_ns_in_jiffie(void); static inline unsigned long get_us_in_jiffie_highres(void) { return get_ns_in_jiffie() / 1000; } #endif
/* Assosiate a key cache with a key SYONOPSIS multi_key_cache_set() key key (path to table etc..) length Length of key key_cache cache to assococite with the table NOTES This can be used both to insert a new entry and change an existing entry */ my_bool multi_key_cache_set(const uchar *key, uint length, KEY_CACHE *key_cache) { return safe_hash_set(&key_cache_hash, key, length, (uchar*) key_cache); }
/* * Definitions and platform data for Analog Devices * ADP5520/ADP5501 MFD PMICs (Backlight, LED, GPIO and Keys) * * Copyright 2009 Analog Devices Inc. * * Licensed under the GPL-2 or later. */ #ifndef __LINUX_MFD_ADP5520_H #define __LINUX_MFD_ADP5520_H #define ID_ADP5520 5520 #define ID_ADP5501 5501 /* * ADP5520/ADP5501 Register Map */ #define ADP5520_MODE_STATUS 0x00 #define ADP5520_INTERRUPT_ENABLE 0x01 #define ADP5520_BL_CONTROL 0x02 #define ADP5520_BL_TIME 0x03 #define ADP5520_BL_FADE 0x04 #define ADP5520_DAYLIGHT_MAX 0x05 #define ADP5520_DAYLIGHT_DIM 0x06 #define ADP5520_OFFICE_MAX 0x07 #define ADP5520_OFFICE_DIM 0x08 #define ADP5520_DARK_MAX 0x09 #define ADP5520_DARK_DIM 0x0A #define ADP5520_BL_VALUE 0x0B #define ADP5520_ALS_CMPR_CFG 0x0C #define ADP5520_L2_TRIP 0x0D #define ADP5520_L2_HYS 0x0E #define ADP5520_L3_TRIP 0x0F #define ADP5520_L3_HYS 0x10 #define ADP5520_LED_CONTROL 0x11 #define ADP5520_LED_TIME 0x12 #define ADP5520_LED_FADE 0x13 #define ADP5520_LED1_CURRENT 0x14 #define ADP5520_LED2_CURRENT 0x15 #define ADP5520_LED3_CURRENT 0x16 /* * ADP5520 Register Map */ #define ADP5520_GPIO_CFG_1 0x17 #define ADP5520_GPIO_CFG_2 0x18 #define ADP5520_GPIO_IN 0x19 #define ADP5520_GPIO_OUT 0x1A #define ADP5520_GPIO_INT_EN 0x1B #define ADP5520_GPIO_INT_STAT 0x1C #define ADP5520_GPIO_INT_LVL 0x1D #define ADP5520_GPIO_DEBOUNCE 0x1E #define ADP5520_GPIO_PULLUP 0x1F #define ADP5520_KP_INT_STAT_1 0x20 #define ADP5520_KP_INT_STAT_2 0x21 #define ADP5520_KR_INT_STAT_1 0x22 #define ADP5520_KR_INT_STAT_2 0x23 #define ADP5520_KEY_STAT_1 0x24 #define ADP5520_KEY_STAT_2 0x25 /* * MODE_STATUS bits */ #define ADP5520_nSTNBY (1 << 7) #define ADP5520_BL_EN (1 << 6) #define ADP5520_DIM_EN (1 << 5) #define ADP5520_OVP_INT (1 << 4) #define ADP5520_CMPR_INT (1 << 3) #define ADP5520_GPI_INT (1 << 2) #define ADP5520_KR_INT (1 << 1) #define ADP5520_KP_INT (1 << 0) /* * INTERRUPT_ENABLE bits */ #define ADP5520_AUTO_LD_EN (1 << 4) #define ADP5520_CMPR_IEN (1 << 3) #define ADP5520_OVP_IEN (1 << 2) #define ADP5520_KR_IEN (1 << 1) #define ADP5520_KP_IEN (1 << 0) /* * BL_CONTROL bits */ #define ADP5520_BL_LVL ((x) << 5) #define ADP5520_BL_LAW ((x) << 4) #define ADP5520_BL_AUTO_ADJ (1 << 3) #define ADP5520_OVP_EN (1 << 2) #define ADP5520_FOVR (1 << 1) #define ADP5520_KP_BL_EN (1 << 0) /* * ALS_CMPR_CFG bits */ #define ADP5520_L3_OUT (1 << 3) #define ADP5520_L2_OUT (1 << 2) #define ADP5520_L3_EN (1 << 1) #define ADP5020_MAX_BRIGHTNESS 0x7F #define FADE_VAL(in, out) ((0xF & (in)) | ((0xF & (out)) << 4)) #define BL_CTRL_VAL(law, auto) (((1 & (auto)) << 3) | ((0x3 & (law)) << 4)) #define ALS_CMPR_CFG_VAL(filt, l3_en) (((0x7 & filt) << 5) | l3_en) /* * LEDs subdevice bits and masks */ #define ADP5520_01_MAXLEDS 3 #define ADP5520_FLAG_LED_MASK 0x3 #define ADP5520_FLAG_OFFT_SHIFT 8 #define ADP5520_FLAG_OFFT_MASK 0x3 #define ADP5520_R3_MODE (1 << 5) #define ADP5520_C3_MODE (1 << 4) #define ADP5520_LED_LAW (1 << 3) #define ADP5520_LED3_EN (1 << 2) #define ADP5520_LED2_EN (1 << 1) #define ADP5520_LED1_EN (1 << 0) /* * GPIO subdevice bits and masks */ #define ADP5520_MAXGPIOS 8 #define ADP5520_GPIO_C3 (1 << 7) /* LED2 or GPIO7 aka C3 */ #define ADP5520_GPIO_C2 (1 << 6) #define ADP5520_GPIO_C1 (1 << 5) #define ADP5520_GPIO_C0 (1 << 4) #define ADP5520_GPIO_R3 (1 << 3) /* LED3 or GPIO3 aka R3 */ #define ADP5520_GPIO_R2 (1 << 2) #define ADP5520_GPIO_R1 (1 << 1) #define ADP5520_GPIO_R0 (1 << 0) struct adp5520_gpio_platform_data { unsigned gpio_start; u8 gpio_en_mask; u8 gpio_pullup_mask; }; /* * Keypad subdevice bits and masks */ #define ADP5520_MAXKEYS 16 #define ADP5520_COL_C3 (1 << 7) /* LED2 or GPIO7 aka C3 */ #define ADP5520_COL_C2 (1 << 6) #define ADP5520_COL_C1 (1 << 5) #define ADP5520_COL_C0 (1 << 4) #define ADP5520_ROW_R3 (1 << 3) /* LED3 or GPIO3 aka R3 */ #define ADP5520_ROW_R2 (1 << 2) #define ADP5520_ROW_R1 (1 << 1) #define ADP5520_ROW_R0 (1 << 0) #define ADP5520_KEY(row, col) (col + row * 4) #define ADP5520_KEYMAPSIZE ADP5520_MAXKEYS struct adp5520_keys_platform_data { int rows_en_mask; /* Number of rows */ int cols_en_mask; /* Number of columns */ const unsigned short *keymap; /* Pointer to keymap */ unsigned short keymapsize; /* Keymap size */ unsigned repeat:1; /* Enable key repeat */ }; /* * LEDs subdevice platform data */ #define FLAG_ID_ADP5520_LED1_ADP5501_LED0 1 /* ADP5520 PIN ILED */ #define FLAG_ID_ADP5520_LED2_ADP5501_LED1 2 /* ADP5520 PIN C3 */ #define FLAG_ID_ADP5520_LED3_ADP5501_LED2 3 /* ADP5520 PIN R3 */ #define ADP5520_LED_DIS_BLINK (0 << ADP5520_FLAG_OFFT_SHIFT) #define ADP5520_LED_OFFT_600ms (1 << ADP5520_FLAG_OFFT_SHIFT) #define ADP5520_LED_OFFT_800ms (2 << ADP5520_FLAG_OFFT_SHIFT) #define ADP5520_LED_OFFT_1200ms (3 << ADP5520_FLAG_OFFT_SHIFT) #define ADP5520_LED_ONT_200ms 0 #define ADP5520_LED_ONT_600ms 1 #define ADP5520_LED_ONT_800ms 2 #define ADP5520_LED_ONT_1200ms 3 struct adp5520_leds_platform_data { int num_leds; struct led_info *leds; u8 fade_in; /* Backlight Fade-In Timer */ u8 fade_out; /* Backlight Fade-Out Timer */ u8 led_on_time; }; /* * Backlight subdevice platform data */ #define ADP5520_FADE_T_DIS 0 /* Fade Timer Disabled */ #define ADP5520_FADE_T_300ms 1 /* 0.3 Sec */ #define ADP5520_FADE_T_600ms 2 #define ADP5520_FADE_T_900ms 3 #define ADP5520_FADE_T_1200ms 4 #define ADP5520_FADE_T_1500ms 5 #define ADP5520_FADE_T_1800ms 6 #define ADP5520_FADE_T_2100ms 7 #define ADP5520_FADE_T_2400ms 8 #define ADP5520_FADE_T_2700ms 9 #define ADP5520_FADE_T_3000ms 10 #define ADP5520_FADE_T_3500ms 11 #define ADP5520_FADE_T_4000ms 12 #define ADP5520_FADE_T_4500ms 13 #define ADP5520_FADE_T_5000ms 14 #define ADP5520_FADE_T_5500ms 15 /* 5.5 Sec */ #define ADP5520_BL_LAW_LINEAR 0 #define ADP5520_BL_LAW_SQUARE 1 #define ADP5520_BL_LAW_CUBIC1 2 #define ADP5520_BL_LAW_CUBIC2 3 #define ADP5520_BL_AMBL_FILT_80ms 0 /* Light sensor filter time */ #define ADP5520_BL_AMBL_FILT_160ms 1 #define ADP5520_BL_AMBL_FILT_320ms 2 #define ADP5520_BL_AMBL_FILT_640ms 3 #define ADP5520_BL_AMBL_FILT_1280ms 4 #define ADP5520_BL_AMBL_FILT_2560ms 5 #define ADP5520_BL_AMBL_FILT_5120ms 6 #define ADP5520_BL_AMBL_FILT_10240ms 7 /* 10.24 sec */ /* * Blacklight current 0..30mA */ #define ADP5520_BL_CUR_mA(I) ((I * 127) / 30) /* * L2 comparator current 0..1000uA */ #define ADP5520_L2_COMP_CURR_uA(I) ((I * 255) / 1000) /* * L3 comparator current 0..127uA */ #define ADP5520_L3_COMP_CURR_uA(I) ((I * 255) / 127) struct adp5520_backlight_platform_data { u8 fade_in; /* Backlight Fade-In Timer */ u8 fade_out; /* Backlight Fade-Out Timer */ u8 fade_led_law; /* fade-on/fade-off transfer characteristic */ u8 en_ambl_sens; /* 1 = enable ambient light sensor */ u8 abml_filt; /* Light sensor filter time */ u8 l1_daylight_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */ u8 l1_daylight_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */ u8 l2_office_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */ u8 l2_office_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */ u8 l3_dark_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */ u8 l3_dark_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */ u8 l2_trip; /* use L2_COMP_CURR_uA(I) 0 <= I <= 1000 uA */ u8 l2_hyst; /* use L2_COMP_CURR_uA(I) 0 <= I <= 1000 uA */ u8 l3_trip; /* use L3_COMP_CURR_uA(I) 0 <= I <= 127 uA */ u8 l3_hyst; /* use L3_COMP_CURR_uA(I) 0 <= I <= 127 uA */ }; /* * MFD chip platform data */ struct adp5520_platform_data { struct adp5520_keys_platform_data *keys; struct adp5520_gpio_platform_data *gpio; struct adp5520_leds_platform_data *leds; struct adp5520_backlight_platform_data *backlight; }; /* * MFD chip functions */ extern int adp5520_read(struct device *dev, int reg, uint8_t *val); extern int adp5520_write(struct device *dev, int reg, u8 val); extern int adp5520_clr_bits(struct device *dev, int reg, uint8_t bit_mask); extern int adp5520_set_bits(struct device *dev, int reg, uint8_t bit_mask); extern int adp5520_register_notifier(struct device *dev, struct notifier_block *nb, unsigned int events); extern int adp5520_unregister_notifier(struct device *dev, struct notifier_block *nb, unsigned int events); #endif /* __LINUX_MFD_ADP5520_H */
README.md exists but content is empty. Use the Edit dataset card button to edit it.
Downloads last month
0
Edit dataset card