hexsha stringlengths 40 40 | size int64 5 1.05M | ext stringclasses 588
values | lang stringclasses 305
values | max_stars_repo_path stringlengths 3 363 | max_stars_repo_name stringlengths 5 118 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 10 | max_stars_count float64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringdate 2015-01-01 00:00:35 2022-03-31 23:43:49 ⌀ | max_stars_repo_stars_event_max_datetime stringdate 2015-01-01 12:37:38 2022-03-31 23:59:52 ⌀ | max_issues_repo_path stringlengths 3 363 | max_issues_repo_name stringlengths 5 118 | max_issues_repo_head_hexsha stringlengths 40 40 | max_issues_repo_licenses listlengths 1 10 | max_issues_count float64 1 134k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 3 363 | max_forks_repo_name stringlengths 5 135 | max_forks_repo_head_hexsha stringlengths 40 40 | max_forks_repo_licenses listlengths 1 10 | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringdate 2015-01-01 00:01:02 2022-03-31 23:27:27 ⌀ | max_forks_repo_forks_event_max_datetime stringdate 2015-01-03 08:55:07 2022-03-31 23:59:24 ⌀ | content stringlengths 5 1.05M | avg_line_length float64 1.13 1.04M | max_line_length int64 1 1.05M | alphanum_fraction float64 0 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
f12d25d0bbcc4958a196facbf4409fddfa8e50b2 | 1,913 | c | C | sdk-6.5.20/libs/sdklt/bcmlta/bcmltx/bcm56990_b0/bcm56990_b0_lta_bcmltx_tm_scheduler_shaper_cpu_node_std_val_fv_handler.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | sdk-6.5.20/libs/sdklt/bcmlta/bcmltx/bcm56990_b0/bcm56990_b0_lta_bcmltx_tm_scheduler_shaper_cpu_node_std_val_fv_handler.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | sdk-6.5.20/libs/sdklt/bcmlta/bcmltx/bcm56990_b0/bcm56990_b0_lta_bcmltx_tm_scheduler_shaper_cpu_node_std_val_fv_handler.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | /*******************************************************************************
*
* DO NOT EDIT THIS FILE!
* This file is auto-generated by fltg from Logical Table mapping files.
*
* Tool: $SDK/INTERNAL/fltg/bin/fltg
*
* Edits to this file will be lost when it is regenerated.
*
* This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
*
* Copyright 2007-2020 Broadcom Inc. All rights reserved.
*/
/* Logical Table Adaptor for component bcmltx */
/* Handler: bcm56990_b0_lta_bcmltx_tm_scheduler_shaper_cpu_node_std_val_fv_handler */
#include <bcmltd/chip/bcmltd_id.h>
#include <bcmdrd/chip/bcm56990_b0_enum.h>
#include <bcmltx/bcmltx_std_table_validator.h>
static const uint32_t
bcm56990_b0_lta_bcmltx_tm_scheduler_shaper_cpu_node_std_val_validate_src[4] = {
TM_SCHEDULER_SHAPER_CPU_NODEt_MAX_BANDWIDTH_KBPS_OPERf,
TM_SCHEDULER_SHAPER_CPU_NODEt_MIN_BANDWIDTH_KBPS_OPERf,
TM_SCHEDULER_SHAPER_CPU_NODEt_MAX_BURST_SIZE_KBITS_OPERf,
TM_SCHEDULER_SHAPER_CPU_NODEt_MIN_BURST_SIZE_KBITS_OPERf,
};
static const bcmltd_generic_arg_t
bcm56990_b0_lta_bcmltx_tm_scheduler_shaper_cpu_node_std_val_comp_data = {
.sid = TM_SCHEDULER_SHAPER_CPU_NODEt,
.values = 0,
.value = NULL,
.user_data = NULL
};
const bcmltd_field_val_arg_t
bcm56990_b0_lta_bcmltx_tm_scheduler_shaper_cpu_node_std_val_fv_handler_arg = {
.values = 0,
.value = NULL,
.fields = 4,
.field = bcm56990_b0_lta_bcmltx_tm_scheduler_shaper_cpu_node_std_val_validate_src,
.comp_data = &bcm56990_b0_lta_bcmltx_tm_scheduler_shaper_cpu_node_std_val_comp_data
};
const bcmltd_field_val_handler_t
bcm56990_b0_lta_bcmltx_tm_scheduler_shaper_cpu_node_std_val_fv_handler = {
.validate = bcmltx_std_table_validator,
.arg = &bcm56990_b0_lta_bcmltx_tm_scheduler_shaper_cpu_node_std_val_fv_handler_arg
};
| 36.788462 | 134 | 0.772608 |
fca0d95ae753c5cdb09082563bb70aa37bde5a84 | 3,408 | c | C | util/id.c | d-pauls/corebox | 7265d3e1fd5029005cc9a3553c0abe3b81f55961 | [
"BSD-2-Clause"
] | null | null | null | util/id.c | d-pauls/corebox | 7265d3e1fd5029005cc9a3553c0abe3b81f55961 | [
"BSD-2-Clause"
] | null | null | null | util/id.c | d-pauls/corebox | 7265d3e1fd5029005cc9a3553c0abe3b81f55961 | [
"BSD-2-Clause"
] | 1 | 2020-07-20T19:47:36.000Z | 2020-07-20T19:47:36.000Z | #include <errno.h>
#include <grp.h>
#include <pwd.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "command.h"
static char optstring[] = "gGnruz";
#ifdef _GNU_SOURCE
#include <getopt.h>
struct option longopts[] = {
{"group", no_argument, NULL, 'g'},
{"groups", no_argument, NULL, 'G'},
{"name", no_argument, NULL, 'n'},
{"real", no_argument, NULL, 'r'},
{"user", no_argument, NULL, 'u'},
{"zero", no_argument, NULL, 'z'},
{NULL, 0, NULL, 0},
};
#define GET_OPT(argc, argv, optstring) \
getopt_long(argc, argv, optstring, longopts, NULL)
#else
#define GET_OPT(argc, argv, optstring) getopt(argc, argv, optstring)
#endif
enum { GROUP = 1, GROUPS, USER };
COMMAND(id, int argc, char *argv[]) {
char nl;
bool use_name, use_real;
int choice, i, size, cap;
gid_t *groups;
struct passwd *pass;
struct group *grp;
nl = '\n';
choice = 0;
cap = 0;
pass = NULL;
groups = NULL;
use_name = false;
use_real = false;
while ((i = GET_OPT(argc, argv, optstring)) != -1) {
int next = 0;
switch (i) {
case 'g': next = GROUP; break;
case 'G': next = GROUPS; break;
case 'n': use_name = true; break;
case 'r': use_real = true; break;
case 'u': next = USER; break;
case 'z': nl = '\0'; break;
default: return 1;
}
if (next && choice != next) {
if (choice) {
fprintf(
stderr, "%s: can only use one of -gGu\n",
argv[0]);
return 1;
}
choice = next;
}
}
if (!choice && (!nl || use_real || use_name)) {
fprintf(
stderr, "%s: -zrn not allowed in default format\n",
argv[0]);
return 1;
}
i = optind;
size = argc - i;
errno = 0;
if (size > 1) {
fprintf(stderr, "%s: extra operand '%s'\n", argv[0], argv[i]);
return 1;
} else if (size == 1) {
pass = getpwnam(argv[i]);
} else {
pass = getpwuid(use_real ? getuid() : geteuid());
}
if (!pass) {
switch (errno) {
case 0:
case ENOENT:
case ESRCH:
case EBADF:
case EPERM:
fprintf(
stderr, "%s: name or uid not found\n",
argv[0]);
break;
default:
fprintf(
stderr, "%s: %s\n", argv[0],
strerror(errno));
break;
}
return 1;
}
if (choice == GROUP) {
if (use_name) {
grp = getgrgid(pass->pw_gid);
printf("%s", grp ? grp->gr_name : NULL);
} else {
printf("%u", pass->pw_gid);
}
putc(nl, stdout);
return 0;
}
if (choice == USER) {
if (use_name)
printf("%s", pass->pw_name);
else
printf("%u", pass->pw_uid);
putc(nl, stdout);
return 0;
}
if (-1 == getgrouplist(pass->pw_name, pass->pw_gid, groups, &cap)) {
groups = calloc(cap, sizeof(*groups));
getgrouplist(pass->pw_name, pass->pw_gid, groups, &cap);
}
if (choice == GROUPS) {
for (i = 0; i < cap; ++i) {
if (use_name) {
grp = getgrgid(groups[i]);
printf("%s", grp ? grp->gr_name : NULL);
} else {
printf("%u", groups[i]);
}
putc((i + 1 == cap || !nl) ? nl : ' ', stdout);
}
} else {
grp = getgrgid(pass->pw_gid);
printf("uid=%u(%s) ", pass->pw_uid, pass->pw_name);
printf("gid=%u(%s) ", pass->pw_gid, grp ? grp->gr_name : NULL);
printf("groups=");
for (i = 0; i < cap; ++i) {
grp = getgrgid(groups[i]);
printf("%u(%s)", groups[i], grp ? grp->gr_name : NULL);
if (i + 1 < cap)
putc(',', stdout);
}
putc('\n', stdout);
}
free(groups);
return 0;
}
| 20.53012 | 69 | 0.557512 |
69ad2d4a47c03c8a1e321c6da82562148d9d162f | 420 | c | C | aoj/5/AOJ0512.c | knuu/competitive-programming | 16bc68fdaedd6f96ae24310d697585ca8836ab6e | [
"MIT"
] | 1 | 2018-11-12T15:18:55.000Z | 2018-11-12T15:18:55.000Z | aoj/5/AOJ0512.c | knuu/competitive-programming | 16bc68fdaedd6f96ae24310d697585ca8836ab6e | [
"MIT"
] | null | null | null | aoj/5/AOJ0512.c | knuu/competitive-programming | 16bc68fdaedd6f96ae24310d697585ca8836ab6e | [
"MIT"
] | null | null | null | //
// AOJ0512.c
//
//
// Created by n_knuu on 2014/03/08.
//
//
#include <stdio.h>
#include <string.h>
#define THREE 3
int main(void) {
int i;
char str[1001];
scanf("%s",str);
for (i=0; i<strlen(str); i++) {
if (str[i]-THREE%26>='A') {
printf("%c",str[i]-THREE%26);
} else {
printf("%c",str[i]-THREE%26+26);
}
}
printf("\n");
return 0;
} | 15.555556 | 44 | 0.459524 |
f9e64c949a9ee2cccddd16a5d2751aa32663faa9 | 3,537 | h | C | Gems/AWSClientAuth/Code/Include/Private/Authorization/AWSCognitoAuthorizationController.h | aaarsene/o3de | 37e3b0226958974defd14dd6d808e8557dcd7345 | [
"Apache-2.0",
"MIT"
] | 1 | 2021-09-13T00:01:12.000Z | 2021-09-13T00:01:12.000Z | Gems/AWSClientAuth/Code/Include/Private/Authorization/AWSCognitoAuthorizationController.h | aaarsene/o3de | 37e3b0226958974defd14dd6d808e8557dcd7345 | [
"Apache-2.0",
"MIT"
] | null | null | null | Gems/AWSClientAuth/Code/Include/Private/Authorization/AWSCognitoAuthorizationController.h | aaarsene/o3de | 37e3b0226958974defd14dd6d808e8557dcd7345 | [
"Apache-2.0",
"MIT"
] | 1 | 2021-07-20T11:07:25.000Z | 2021-07-20T11:07:25.000Z | /*
* Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <Authorization/AWSCognitoAuthorizationBus.h>
#include <Authorization/AWSClientAuthPersistentCognitoIdentityProvider.h>
#include <Authentication/AuthenticationProviderBus.h>
#include <Credential/AWSCredentialBus.h>
#include <aws/cognito-identity/CognitoIdentityClient.h>
#include <aws/identity-management/auth/CognitoCachingCredentialsProvider.h>
namespace AWSClientAuth
{
//! Implements AWS Cognito Identity pool authorization.
class AWSCognitoAuthorizationController
: public AWSCognitoAuthorizationRequestBus::Handler
, public AuthenticationProviderNotificationBus::Handler
, public AWSCore::AWSCredentialRequestBus::Handler
{
public:
AZ_RTTI(AWSCognitoAuthorizationController, "{0E731ED1-2F08-4B3C-9282-D452700F58D1}", IAWSCognitoAuthorizationRequests);
AWSCognitoAuthorizationController();
virtual ~AWSCognitoAuthorizationController();
// AWSCognitoAuthorizationRequestsBus interface methods
bool Initialize() override;
void Reset() override;
AZStd::string GetIdentityId() override;
bool HasPersistedLogins() override;
std::shared_ptr<Aws::Auth::AWSCredentialsProvider> GetCognitoCredentialsProvider() override;
std::shared_ptr<Aws::Auth::AWSCredentialsProvider> GetAnonymousCognitoCredentialsProvider() override;
void RequestAWSCredentialsAsync() override;
protected:
// AuthenticationProviderNotificationsBus interface. Update persistent login tokens on successful sign in.
void OnPasswordGrantSingleFactorSignInSuccess(const AWSClientAuth::AuthenticationTokens& authenticationTokens) override;
void OnPasswordGrantMultiFactorConfirmSignInSuccess(const AWSClientAuth::AuthenticationTokens& authenticationTokens) override;
void OnDeviceCodeGrantConfirmSignInSuccess(const AWSClientAuth::AuthenticationTokens& authenticationTokens) override;
void OnRefreshTokensSuccess(const AWSClientAuth::AuthenticationTokens& authenticationTokens) override;
void OnSignOut(const ProviderNameEnum& provideName) override;
// AWSCredentialRequestBus interface implementation
int GetCredentialHandlerOrder() const override;
std::shared_ptr<Aws::Auth::AWSCredentialsProvider> GetCredentialsProvider() override;
std::shared_ptr<AWSClientAuthPersistentCognitoIdentityProvider> m_persistentCognitoIdentityProvider;
std::shared_ptr<AWSClientAuthPersistentCognitoIdentityProvider> m_persistentAnonymousCognitoIdentityProvider;
std::shared_ptr<Aws::Auth::CognitoCachingAuthenticatedCredentialsProvider> m_cognitoCachingCredentialsProvider;
std::shared_ptr<Aws::Auth::CognitoCachingAnonymousCredentialsProvider> m_cognitoCachingAnonymousCredentialsProvider;
AZStd::string m_cognitoIdentityPoolId;
AZStd::string m_formattedCognitoUserPoolId;
AZStd::string m_awsAccountId;
private:
void PersistLoginsAndRefreshAWSCredentials(const AuthenticationTokens& authenticationTokens);
AZStd::string GetAuthenticationProviderId(const ProviderNameEnum& providerName);
AZStd::mutex m_persistentCognitoIdentityProviderMutex;
AZStd::mutex m_persistentAnonymousCognitoIdentityProviderMutex;
};
} // namespace AWSClientAuth
| 51.26087 | 158 | 0.790783 |
52bf1d028a9d7cdf0ffdcefeca8fa9689137db55 | 1,237 | h | C | App_DPRA/dprawidget.h | TWANG006/G-LS3U | bdf854f726202b007a03575868a4117ee694fdf6 | [
"MIT"
] | 2 | 2021-11-11T16:19:06.000Z | 2022-03-31T13:44:29.000Z | App_DPRA/dprawidget.h | TWANG006/G-LS3U | bdf854f726202b007a03575868a4117ee694fdf6 | [
"MIT"
] | null | null | null | App_DPRA/dprawidget.h | TWANG006/G-LS3U | bdf854f726202b007a03575868a4117ee694fdf6 | [
"MIT"
] | 2 | 2019-09-15T14:35:32.000Z | 2020-09-27T23:20:28.000Z | #ifndef DPRAWIDGET_H
#define DPRAWIDGET_H
#include <QWidget>
#include "ui_dprawidget.h"
#include "aia_cpuf.h"
#include "dpra_hybridf.h"
#include "dpra_cudaf.h"
#include "dpra_cpuf.h"
class DPRAWidget : public QWidget
{
Q_OBJECT
public:
DPRAWidget(QWidget *parent = 0);
~DPRAWidget();
signals:
void outputFileNameChanged(const QString&);
void onexit();
private slots:
void openPhi();
void openAIAImages();
void computeAIA();
void openDPRAImages();
void computeDPRA();
void outputVideo();
private:
bool videoWritter(const QString& fileName);
private:
QString m_outputVideoFileName;
QString m_phiFileName;
QString m_filePath;
std::string m_hardware;
QStringList m_AIAImgFileList;
QStringList m_DPRAImgFileList;
Ui::DPRAWidget ui;
// AIA parameters
int m_iMaxIterations;
float m_fMaxError;
int m_iNumberThreads;
std::vector<float> mv_refPhi;
AIA::AIA_CPU_DnF m_aia;
// DPRA parameters
int m_iWidth;
int m_iHeight;
std::vector<std::vector<float>> m_deltaPhiSum;
std::unique_ptr<DPRA::DPRA_CPUF> m_cpudpraPtr;
std::unique_ptr<DPRA::DPRA_HYBRIDF> m_dpraPtr;
std::unique_ptr<DPRA::DPRA_CUDAF> m_cudpraPtr;
//QThread *m_dpraworkerThread;
//DPRAWorker *m_dpraworkerPtr;
};
#endif // DPRAWIDGET_H
| 18.191176 | 47 | 0.759903 |
76cf02bd0ee3a1fcf1ca0e40e305fdaec875c7c9 | 2,147 | c | C | 01-beginner/1983.c | marcosmapl/uri-solutions | 9ff0553966378fc8b0cdcfeec91d3b0693974ad9 | [
"MIT"
] | 1 | 2019-12-24T02:11:50.000Z | 2019-12-24T02:11:50.000Z | 01-beginner/1983.c | marcosmapl/uri-solutions | 9ff0553966378fc8b0cdcfeec91d3b0693974ad9 | [
"MIT"
] | null | null | null | 01-beginner/1983.c | marcosmapl/uri-solutions | 9ff0553966378fc8b0cdcfeec91d3b0693974ad9 | [
"MIT"
] | null | null | null | /*
URI Online Judge | 1983
The Chosen
By Victor Jatobá, UNIME BR Brazil
https://www.urionlinejudge.com.br/judge/en/problems/view/1983
Timelimit: 1
Everyone is talking about the Jatoba Teacher classes. The MEC representatives came to the UNIME of Lauro de Freitas to know more details about this new way of teaching algorithms. In addition, they wanted to select one student to participate in the OBI-Tec (Olympiad Informatics Technical Level) and represent Kroton in the competition, because they know that there are the best. To select the best, they have available a list of the registration number of each student and their respective notes in the discipline. Your task is to help the Ministry of Education staff to find students better able to represent the institution and who knows guarantee your place. If the highest score is not greater than or equal to 8, you should print "Minimum note not reached" .
Input
The file first contains the number of students (3 <= n <= 100) and then the n students bearing the registration number (0 < m < 1000000) each, followed by the note (0 <= note <= 10.0, with 1 decimal place).
Obs .: the notes will not be repeated. In other words, has no chance to have two students with the same note.
Output
You must print the student's registration number with the highest score or "Minimum note not reached" (without quotes) if no student has taken greater note than or equal to 8.
@author Marcos Lima
@profile https://www.urionlinejudge.com.br/judge/pt/profile/242402
@status Accepted
@language C (gcc 4.8.5, -O2 -lm) [+0s]
@time 0.000s
@size 545 Bytes
@submission 1/7/20, 8:00:52 AM
*/
#include <stdio.h>
int main()
{
unsigned char n;
unsigned int mat, mat_maior;
double nota, nota_maior;
scanf("%hhu", &n);
scanf("%u %lf", &mat_maior, ¬a_maior);
n--;
while (n--) {
scanf("%u %lf", &mat, ¬a);
if (nota > nota_maior) {
nota_maior = nota;
mat_maior = mat;
}
}
if (nota_maior < 8.0) {
printf("Minimum note not reached\n");
} else {
printf("%u\n", mat_maior);
}
return 0;
} | 40.509434 | 764 | 0.702375 |
1f30616f2ad94c41bfeebd1140cefc841a2cd6d5 | 1,643 | h | C | src/util.h | LaoZZZZZ/bartender-1.1 | ddfb2e52bdf92258dd837ab8ee34306e9fb45b81 | [
"MIT"
] | 22 | 2016-08-11T06:16:25.000Z | 2022-02-22T00:06:59.000Z | src/util.h | LaoZZZZZ/bartender-1.1 | ddfb2e52bdf92258dd837ab8ee34306e9fb45b81 | [
"MIT"
] | 9 | 2016-12-08T12:42:38.000Z | 2021-12-28T20:12:15.000Z | src/util.h | LaoZZZZZ/bartender-1.1 | ddfb2e52bdf92258dd837ab8ee34306e9fb45b81 | [
"MIT"
] | 8 | 2017-06-26T13:15:06.000Z | 2021-11-12T18:39:54.000Z |
#ifndef UTIL_H_
#define UTIL_H_
#include <array>
#include <limits>
#include <memory>
#include <stdlib.h>
#include <string>
#include <stdexcept>
#include <vector>
#include <list>
//#include "kmer_freq.h"
#include "kmers_dictionary.h"
#include "typdefine.h"
namespace barcodeSpace {
// Check if the average quality is larger than the given threshold.
bool qualityCheck(const std::string& qualities, double threshold);
void reverseComplementInplace(std::string& seq);
std::string reverseComplement(const std::string& seq);
template<typename T>
int hammingDist(const T& seq1,const T& seq2){
int dist = 0;
if (seq1.length() != seq2.length()) {
throw std::runtime_error(" Can not calculate hamming distance between unequal length strings!\n");
} else {
size_t l = seq1.length();
for(size_t i = 0; i < l; i++){
if(seq1[i] != seq2[i])
++dist;
}
}
return dist;
}
size_t kmerDistance(const kmer&, const kmer&, size_t);
/**
* Calculates the the similarity score by doing pair comparison.
*/
//double similarityScore(const kmer&, const std::list<kmers_freq>&,size_t);
/**
* Calculates the similarity score using the frequency table,
* which should be faster than the pairwise compairson method.
*/
double similarityScore(const kmer& center,
const std::vector<std::array<uint64_t, 4>>& frequency_table);
std::list<std::string> strSplit(const std::string&);
void strSplit(const std::string&, std::list<std::string>&);
bool isDnaSequence(const std::string& sequence);
std::string toUpper(const std::string& str);
}
#endif /*ndef UTIL_H_*/
| 27.383333 | 106 | 0.683506 |
d338a9369a7b75d875e970b95fe2faa18cc369b0 | 5,194 | h | C | B2G/gecko/content/svg/content/src/nsSVGMarkerElement.h | wilebeast/FireFox-OS | 43067f28711d78c429a1d6d58c77130f6899135f | [
"Apache-2.0"
] | 3 | 2015-08-31T15:24:31.000Z | 2020-04-24T20:31:29.000Z | B2G/gecko/content/svg/content/src/nsSVGMarkerElement.h | wilebeast/FireFox-OS | 43067f28711d78c429a1d6d58c77130f6899135f | [
"Apache-2.0"
] | null | null | null | B2G/gecko/content/svg/content/src/nsSVGMarkerElement.h | wilebeast/FireFox-OS | 43067f28711d78c429a1d6d58c77130f6899135f | [
"Apache-2.0"
] | 3 | 2015-07-29T07:17:15.000Z | 2020-11-04T06:55:37.000Z | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef __NS_SVGMARKERELEMENT_H__
#define __NS_SVGMARKERELEMENT_H__
#include "gfxMatrix.h"
#include "nsIDOMSVGFitToViewBox.h"
#include "nsIDOMSVGMarkerElement.h"
#include "nsSVGAngle.h"
#include "nsSVGEnum.h"
#include "nsSVGGraphicElement.h"
#include "nsSVGLength2.h"
#include "nsSVGViewBox.h"
#include "SVGAnimatedPreserveAspectRatio.h"
#include "mozilla/Attributes.h"
class nsSVGOrientType
{
public:
nsSVGOrientType()
: mAnimVal(nsIDOMSVGMarkerElement::SVG_MARKER_ORIENT_ANGLE),
mBaseVal(nsIDOMSVGMarkerElement::SVG_MARKER_ORIENT_ANGLE) {}
nsresult SetBaseValue(uint16_t aValue,
nsSVGElement *aSVGElement);
// XXX FIXME like https://bugzilla.mozilla.org/show_bug.cgi?id=545550 but
// without adding an mIsAnimated member...?
void SetBaseValue(uint16_t aValue)
{ mAnimVal = mBaseVal = uint8_t(aValue); }
// no need to notify, since nsSVGAngle does that
void SetAnimValue(uint16_t aValue)
{ mAnimVal = uint8_t(aValue); }
uint16_t GetBaseValue() const
{ return mBaseVal; }
uint16_t GetAnimValue() const
{ return mAnimVal; }
nsresult ToDOMAnimatedEnum(nsIDOMSVGAnimatedEnumeration **aResult,
nsSVGElement* aSVGElement);
private:
nsSVGEnumValue mAnimVal;
nsSVGEnumValue mBaseVal;
struct DOMAnimatedEnum MOZ_FINAL : public nsIDOMSVGAnimatedEnumeration
{
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(DOMAnimatedEnum)
DOMAnimatedEnum(nsSVGOrientType* aVal,
nsSVGElement *aSVGElement)
: mVal(aVal), mSVGElement(aSVGElement) {}
nsSVGOrientType *mVal; // kept alive because it belongs to content
nsRefPtr<nsSVGElement> mSVGElement;
NS_IMETHOD GetBaseVal(uint16_t* aResult)
{ *aResult = mVal->GetBaseValue(); return NS_OK; }
NS_IMETHOD SetBaseVal(uint16_t aValue)
{ return mVal->SetBaseValue(aValue, mSVGElement); }
NS_IMETHOD GetAnimVal(uint16_t* aResult)
{ *aResult = mVal->GetAnimValue(); return NS_OK; }
};
};
typedef nsSVGGraphicElement nsSVGMarkerElementBase;
class nsSVGMarkerElement : public nsSVGMarkerElementBase,
public nsIDOMSVGMarkerElement,
public nsIDOMSVGFitToViewBox
{
friend class nsSVGMarkerFrame;
protected:
friend nsresult NS_NewSVGMarkerElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo);
nsSVGMarkerElement(already_AddRefed<nsINodeInfo> aNodeInfo);
public:
typedef mozilla::SVGAnimatedPreserveAspectRatio SVGAnimatedPreserveAspectRatio;
// interfaces:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMSVGMARKERELEMENT
NS_DECL_NSIDOMSVGFITTOVIEWBOX
// xxx I wish we could use virtual inheritance
NS_FORWARD_NSIDOMNODE(nsSVGElement::)
NS_FORWARD_NSIDOMELEMENT(nsSVGElement::)
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGElement::)
// nsIContent interface
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* name) const;
virtual bool GetAttr(int32_t aNameSpaceID, nsIAtom* aName,
nsAString& aResult) const;
virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
bool aNotify);
// nsSVGSVGElement methods:
virtual bool HasValidDimensions() const;
// public helpers
gfxMatrix GetMarkerTransform(float aStrokeWidth,
float aX, float aY, float aAutoAngle);
nsSVGViewBoxRect GetViewBoxRect();
gfxMatrix GetViewBoxTransform();
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
nsSVGOrientType* GetOrientType() { return &mOrientType; }
virtual nsXPCClassInfo* GetClassInfo();
virtual nsIDOMNode* AsDOMNode() { return this; }
protected:
virtual bool ParseAttribute(int32_t aNameSpaceID, nsIAtom* aName,
const nsAString& aValue,
nsAttrValue& aResult);
void SetParentCoordCtxProvider(nsSVGSVGElement *aContext);
virtual LengthAttributesInfo GetLengthInfo();
virtual AngleAttributesInfo GetAngleInfo();
virtual EnumAttributesInfo GetEnumInfo();
virtual nsSVGViewBox *GetViewBox();
virtual SVGAnimatedPreserveAspectRatio *GetPreserveAspectRatio();
enum { REFX, REFY, MARKERWIDTH, MARKERHEIGHT };
nsSVGLength2 mLengthAttributes[4];
static LengthInfo sLengthInfo[4];
enum { MARKERUNITS };
nsSVGEnum mEnumAttributes[1];
static nsSVGEnumMapping sUnitsMap[];
static EnumInfo sEnumInfo[1];
enum { ORIENT };
nsSVGAngle mAngleAttributes[1];
static AngleInfo sAngleInfo[1];
nsSVGViewBox mViewBox;
SVGAnimatedPreserveAspectRatio mPreserveAspectRatio;
// derived properties (from 'orient') handled separately
nsSVGOrientType mOrientType;
nsSVGSVGElement *mCoordCtx;
nsAutoPtr<gfxMatrix> mViewBoxToViewportTransform;
};
#endif
| 32.4625 | 82 | 0.718136 |
97e0ad966b17d144eeab927c7bb704778ee1cc0e | 99 | h | C | sdk/internal/NSURL+CB.h | cubie-api/cubie-sdk-ios | 5d9fba13d0c43f340698855f14cdc00fa58367f6 | [
"Apache-2.0"
] | 1 | 2020-07-31T04:29:09.000Z | 2020-07-31T04:29:09.000Z | sdk/internal/NSURL+CB.h | cubie-api/cubie-sdk-ios | 5d9fba13d0c43f340698855f14cdc00fa58367f6 | [
"Apache-2.0"
] | null | null | null | sdk/internal/NSURL+CB.h | cubie-api/cubie-sdk-ios | 5d9fba13d0c43f340698855f14cdc00fa58367f6 | [
"Apache-2.0"
] | null | null | null | #import <Foundation/Foundation.h>
@interface NSURL(CB)
- (NSDictionary*) decodeParameters;
@end
| 12.375 | 35 | 0.747475 |
20248d756a4e44dac40a98fa9030631a34cd1647 | 1,063 | h | C | HMModules/HomeMateModule/HomeMateModule/Classes/HMSDK/HMModels/HMSensorEvent.h | kenny2006cen/GYXMPP | fdeaddde91c78b132f747501c09486b7c33ec5d4 | [
"MIT"
] | null | null | null | HMModules/HomeMateModule/HomeMateModule/Classes/HMSDK/HMModels/HMSensorEvent.h | kenny2006cen/GYXMPP | fdeaddde91c78b132f747501c09486b7c33ec5d4 | [
"MIT"
] | null | null | null | HMModules/HomeMateModule/HomeMateModule/Classes/HMSDK/HMModels/HMSensorEvent.h | kenny2006cen/GYXMPP | fdeaddde91c78b132f747501c09486b7c33ec5d4 | [
"MIT"
] | 1 | 2021-10-10T12:32:01.000Z | 2021-10-10T12:32:01.000Z | //
// HMSensorEvent.h
// HomeMate
//
// Created by orvibo on 16/8/22.
// Copyright © 2017年 Air. All rights reserved.
//
#import "HMBaseModel.h"
@interface HMSensorEvent : HMBaseModel
@property (nonatomic, strong) NSString *sensorEventId;
@property (nonatomic, strong) NSString *deviceId;
@property (nonatomic, assign) int powerStatus; ///< 供电状态
@property (nonatomic, assign) int deviceStatus; ///< 设备故障
@property (nonatomic, assign) int muteStatus; ///< 声音状态
@property (nonatomic, assign) int brightness; ///< 指示灯亮度百分比
@property (nonatomic, assign) int alarmLevel; ///< 0: 无报警 1: 报警等级为标准 2: 报警等级为健康 3: 报警等级为绿色
@property (nonatomic, assign) int voiceStatus; ///< 0: 无声音 1: 正在鸣响
+ (instancetype)objectWithDeviceId:(NSString *)deviceId uid:(NSString *)uid;
+ (instancetype)originObjectWithDeviceId:(NSString *)deviceId uid:(NSString *)uid;
+ (BOOL)deleteWithDeviceId:(NSString *)deviceId;
+ (instancetype)sensorEventWithDictionary:(NSDictionary *)dic;
+ (int)changeHostIntToShowBrightness:(int)originBrightness;
@end
| 28.72973 | 96 | 0.714017 |
31ac8583016620a75c87791c441ac38c9e431277 | 501 | c | C | game/src/nemu-pal/hal/timer.c | ryanhe312/nemu-lab | a939001d77eea61ab7926af94e501ec03c9c45ff | [
"Apache-2.0"
] | 29 | 2017-07-30T07:46:11.000Z | 2021-11-21T15:51:04.000Z | game/src/nemu-pal/hal/timer.c | jasha64/ics2015 | b6073effe3a7f4f73e60163b060274350a243d10 | [
"MIT"
] | 2 | 2018-03-22T10:09:35.000Z | 2021-09-12T16:08:35.000Z | game/src/nemu-pal/hal/timer.c | jasha64/ics2015 | b6073effe3a7f4f73e60163b060274350a243d10 | [
"MIT"
] | 9 | 2018-09-03T13:14:08.000Z | 2021-06-25T17:00:46.000Z | #include "hal.h"
static volatile uint32_t jiffy = 0;
static int fps = 0;
static int nr_draw = 0;
void
incr_nr_draw(void) {
nr_draw ++;
}
int
get_fps() {
return fps;
}
void
timer_event(void) {
jiffy ++;
if(jiffy % (HZ / 2) == 0) {
fps = nr_draw * 2 + 1;
nr_draw = 0;
}
}
uint32_t SDL_GetTicks() {
/* TODO: Return the time in millisecond. */
assert(0);
return 0;
}
void SDL_Delay(uint32_t ms) {
/* TODO: Return from this function after waiting for `ms' milliseconds. */
assert(0);
}
| 13.916667 | 75 | 0.636727 |
f6d1b6bc48e8c77e34e72cced782039055a78473 | 11,495 | c | C | rpc/cli/dsHdmiIn.c | rdkcmf/rdk-devicesettings | 84be2264e6f390ee55d513b245326647560b391b | [
"Apache-2.0"
] | null | null | null | rpc/cli/dsHdmiIn.c | rdkcmf/rdk-devicesettings | 84be2264e6f390ee55d513b245326647560b391b | [
"Apache-2.0"
] | null | null | null | rpc/cli/dsHdmiIn.c | rdkcmf/rdk-devicesettings | 84be2264e6f390ee55d513b245326647560b391b | [
"Apache-2.0"
] | 2 | 2018-08-16T19:10:45.000Z | 2019-12-23T11:46:21.000Z | /*
* If not stated otherwise in this file or this component's Licenses.txt file the
* following copyright and licenses apply:
*
* Copyright 2016 RDK Management
*
* 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.
*/
/*
* If not stated otherwise in this file or this component's Licenses.txt file the
* following copyright and licenses apply:
*
* Copyright ARRIS Enterprises, Inc. 2015.
*
* 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
*/
/**
* @defgroup devicesettings
* @{
* @defgroup rpc
* @{
**/
#include <stdio.h>
#include <string.h>
#include "dsHdmiIn.h"
#include "dsRpc.h"
#include "dsMgr.h"
#include "dsclientlogger.h"
#include "iarmUtil.h"
#include "libIARM.h"
#include "libIBus.h"
dsError_t dsHdmiInInit (void)
{
IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
(char *)IARM_BUS_DSMGR_API_dsHdmiInInit,
NULL,
0);
if (IARM_RESULT_SUCCESS == rpcRet)
{
printf("%s:%d - dsERR_NONE\n", __PRETTY_FUNCTION__,__LINE__);
return dsERR_NONE;
}
printf("%s:%d - dsERR_GENERAL\n", __PRETTY_FUNCTION__,__LINE__);
return dsERR_GENERAL;
}
dsError_t dsHdmiInTerm (void)
{
_DEBUG_ENTER();
IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
(char *)IARM_BUS_DSMGR_API_dsHdmiInTerm,
NULL,
0);
if (IARM_RESULT_SUCCESS == rpcRet)
{
printf("%s:%d - dsERR_NONE\n", __PRETTY_FUNCTION__,__LINE__);
return dsERR_NONE;
}
printf("%s:%d - dsERR_GENERAL\n", __PRETTY_FUNCTION__,__LINE__);
return dsERR_GENERAL ;
}
dsError_t dsHdmiInGetNumberOfInputs (uint8_t *pNumHdmiInputs)
{
_DEBUG_ENTER();
_RETURN_IF_ERROR(pNumHdmiInputs != NULL, dsERR_INVALID_PARAM);
dsHdmiInGetNumberOfInputsParam_t param;
param.numHdmiInputs = 0;
IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
(char *)IARM_BUS_DSMGR_API_dsHdmiInGetNumberOfInputs,
(void *)¶m,
sizeof(param));
if (IARM_RESULT_SUCCESS == rpcRet)
{
*pNumHdmiInputs = param.numHdmiInputs;
printf("%s:%d - %d\n", __PRETTY_FUNCTION__,__LINE__, param.result);
return param.result;
}
printf("%s:%d - dsERR_GENERAL\n", __PRETTY_FUNCTION__,__LINE__);
return dsERR_GENERAL;
}
dsError_t dsHdmiInGetStatus (dsHdmiInStatus_t *pStatus)
{
_DEBUG_ENTER();
_RETURN_IF_ERROR(pStatus != NULL, dsERR_INVALID_PARAM);
dsHdmiInGetStatusParam_t param;
memset (¶m, 0, sizeof(param));
IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
(char *)IARM_BUS_DSMGR_API_dsHdmiInGetStatus,
(void *)¶m,
sizeof(param));
if (IARM_RESULT_SUCCESS == rpcRet)
{
*pStatus = param.status;
printf("%s:%d - %d\n", __PRETTY_FUNCTION__,__LINE__, param.result);
return param.result;
}
printf("%s:%d - dsERR_GENERAL\n", __PRETTY_FUNCTION__,__LINE__);
return dsERR_GENERAL;
}
dsError_t dsHdmiInSelectPort (dsHdmiInPort_t ePort)
{
_DEBUG_ENTER();
dsHdmiInSelectPortParam_t param;
param.port = ePort;
IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
(char *)IARM_BUS_DSMGR_API_dsHdmiInSelectPort,
(void *)¶m,
sizeof(param));
if (IARM_RESULT_SUCCESS == rpcRet)
{
printf("%s:%d - %d\n", __PRETTY_FUNCTION__,__LINE__, param.result);
return param.result;
}
printf("%s:%d - dsERR_GENERAL\n", __PRETTY_FUNCTION__,__LINE__);
return dsERR_GENERAL;
}
dsError_t dsHdmiInScaleVideo (int32_t x, int32_t y, int32_t width, int32_t height)
{
_DEBUG_ENTER();
dsHdmiInScaleVideoParam_t param;
param.videoRect.x = x;
param.videoRect.y = y;
param.videoRect.width = width;
param.videoRect.height = height;
IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
(char *)IARM_BUS_DSMGR_API_dsHdmiInScaleVideo,
(void *)¶m,
sizeof(param));
if (IARM_RESULT_SUCCESS == rpcRet)
{
printf("%s:%d - %d\n", __PRETTY_FUNCTION__,__LINE__, param.result);
return param.result;
}
printf("%s:%d - dsERR_GENERAL\n", __PRETTY_FUNCTION__,__LINE__);
return dsERR_GENERAL;
}
dsError_t dsHdmiInSelectZoomMode (dsVideoZoom_t requestedZoomMode)
{
_DEBUG_ENTER();
dsHdmiInSelectZoomModeParam_t param;
param.zoomMode = requestedZoomMode;
IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
(char *)IARM_BUS_DSMGR_API_dsHdmiInSelectZoomMode,
(void *)¶m,
sizeof(param));
if (IARM_RESULT_SUCCESS == rpcRet)
{
printf("%s:%d - %d\n", __PRETTY_FUNCTION__,__LINE__, param.result);
return param.result;
}
printf("%s:%d - dsERR_GENERAL\n", __PRETTY_FUNCTION__,__LINE__);
return dsERR_GENERAL;
}
dsError_t dsHdmiInPauseAudio ()
{
_DEBUG_ENTER();
dsError_t param;
IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
(char *)IARM_BUS_DSMGR_API_dsHdmiInPauseAudio,
(void *)¶m,
sizeof(param));
if (IARM_RESULT_SUCCESS == rpcRet)
{
printf("%s:%d - %d\n", __PRETTY_FUNCTION__,__LINE__, param);
return param;
}
printf("%s:%d - dsERR_GENERAL\n", __PRETTY_FUNCTION__,__LINE__);
return dsERR_GENERAL;
}
dsError_t dsHdmiInResumeAudio ()
{
_DEBUG_ENTER();
dsError_t param;
IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
(char *)IARM_BUS_DSMGR_API_dsHdmiInResumeAudio,
(void *)¶m,
sizeof(param));
if (IARM_RESULT_SUCCESS == rpcRet)
{
printf("%s:%d - %d\n", __PRETTY_FUNCTION__,__LINE__, param);
return param;
}
printf("%s:%d - dsERR_GENERAL\n", __PRETTY_FUNCTION__,__LINE__);
return dsERR_GENERAL;
}
dsError_t dsHdmiInGetCurrentVideoMode (dsVideoPortResolution_t *resolution)
{
_DEBUG_ENTER();
_RETURN_IF_ERROR(resolution != NULL, dsERR_INVALID_PARAM);
_dsHdmiInGetResolutionParam_t param;
param.resolution = *resolution;
IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
(char *)IARM_BUS_DSMGR_API_dsHdmiInGetCurrentVideoMode,
(void *)¶m,
sizeof(param));
if (IARM_RESULT_SUCCESS == rpcRet)
{
*resolution = param.resolution;
printf("%s:%d - %d\n", __PRETTY_FUNCTION__,__LINE__, param.result);
return param.result;
}
printf("%s:%d - dsERR_GENERAL\n", __PRETTY_FUNCTION__,__LINE__);
return dsERR_GENERAL;
}
dsError_t dsGetEDIDBytesInfo (int iHdmiPort, unsigned char **edid, int *length)
{
_DEBUG_ENTER();
_RETURN_IF_ERROR(edid != NULL, dsERR_INVALID_PARAM);
_RETURN_IF_ERROR(length != NULL, dsERR_INVALID_PARAM);
dsGetEDIDBytesInfoParam_t param;
IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
param.iHdmiPort = iHdmiPort;
rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
(char *)IARM_BUS_DSMGR_API_dsGetEDIDBytesInfo,
(void *)¶m,
sizeof(param));
if (IARM_RESULT_SUCCESS == rpcRet)
{
*length = param.length;
*edid = param.edid;
printf("[cli] %s: dsGetEDIDBytesInfo eRet: %d data len: %d \r\n", __FUNCTION__, param.result, *length);
return param.result;
}
printf("%s:%d - dsERR_GENERAL\n", __PRETTY_FUNCTION__,__LINE__);
return dsERR_GENERAL;
}
dsError_t dsGetHDMISPDInfo (int iHdmiPort, unsigned char **spdInfo)
{
_DEBUG_ENTER();
printf("[cli] %s: dsGetHDMISPDInfo \r\n", __FUNCTION__);
_RETURN_IF_ERROR(spdInfo != NULL, dsERR_INVALID_PARAM);
dsGetHDMISPDInfoParam_t param;
IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
param.iHdmiPort = iHdmiPort;
rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
(char *)IARM_BUS_DSMGR_API_dsGetHDMISPDInfo,
(void *)¶m,
sizeof(param));
if (IARM_RESULT_SUCCESS == rpcRet)
{
*spdInfo = param.spdInfo;
printf("[cli] %s: dsGetHDMISPDInfo eRet: %d \r\n", __FUNCTION__, param.result);
return param.result;
}
printf("%s:%d - dsERR_GENERAL\n", __PRETTY_FUNCTION__,__LINE__);
return dsERR_GENERAL;
}
dsError_t dsSetEdidVersion (int iHdmiPort, int iEdidVersion)
{
_DEBUG_ENTER();
dsEdidVersionParam_t param;
IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
param.iHdmiPort = iHdmiPort;
param.iEdidVersion = iEdidVersion;
rpcRet = IARM_Bus_Call (IARM_BUS_DSMGR_NAME,
(char *)IARM_BUS_DSMGR_API_dsSetEdidVersion,
(void *)¶m,
sizeof(param));
if (IARM_RESULT_SUCCESS == rpcRet)
{
printf ("[cli] %s: dsSetEdidVersion eRet: %d \r\n", __FUNCTION__, param.result);
return param.result;
}
printf("%s:%d - dsERR_GENERAL\n", __PRETTY_FUNCTION__,__LINE__);
return dsERR_GENERAL;
}
dsError_t dsGetEdidVersion (int iHdmiPort, int *iEdidVersion)
{
_DEBUG_ENTER();
dsEdidVersionParam_t param;
IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
param.iHdmiPort = iHdmiPort;
rpcRet = IARM_Bus_Call (IARM_BUS_DSMGR_NAME,
(char *)IARM_BUS_DSMGR_API_dsGetEdidVersion,
(void *)¶m,
sizeof(param));
if (IARM_RESULT_SUCCESS == rpcRet)
{
*iEdidVersion = param.iEdidVersion;
printf ("[cli] %s: dsGetEdidVersion EdidVersion: %d \r\n", __FUNCTION__, param.iEdidVersion);
return param.result;
}
printf("%s:%d - dsERR_GENERAL\n", __PRETTY_FUNCTION__,__LINE__);
return dsERR_GENERAL;
}
/** @} */
/** @} */
| 29.249364 | 111 | 0.640191 |
c6e22435365ff284d1036343bc6786493121f3bb | 5,533 | c | C | platform/native/ios-xcode/tt_process_native.c | newser/TitanSDK | fcddad88e91873584e93cee6d2cf1da567388316 | [
"Apache-2.0"
] | 3 | 2017-07-12T07:41:47.000Z | 2018-12-07T07:12:06.000Z | platform/native/ios-xcode/tt_process_native.c | newser/TitanSDK | fcddad88e91873584e93cee6d2cf1da567388316 | [
"Apache-2.0"
] | 4 | 2016-12-12T15:20:52.000Z | 2017-07-12T07:40:23.000Z | platform/native/macos-xcode/tt_process_native.c | newser/TitanSDK | fcddad88e91873584e93cee6d2cf1da567388316 | [
"Apache-2.0"
] | null | null | null | /* Copyright (C) 2017 haniu (niuhao.cn@gmail.com)
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
////////////////////////////////////////////////////////////
// import header files
////////////////////////////////////////////////////////////
#include <tt_process_native.h>
#include <misc/tt_util.h>
#include <os/tt_process.h>
#include <tt_sys_error.h>
#include <errno.h>
#include <mach-o/dyld.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
////////////////////////////////////////////////////////////
// internal macro
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// internal type
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// extern declaration
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// global variant
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// interface declaration
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// interface implementation
////////////////////////////////////////////////////////////
tt_result_t tt_process_create_ntv(IN tt_process_ntv_t *sys_proc,
IN const tt_char_t *path,
IN OPT tt_char_t *const arg[],
IN OPT struct tt_process_attr_s *attr)
{
pid_t pid = fork();
if (pid < 0) {
TT_ERROR_NTV("fork failed");
return TT_FAIL;
}
if (pid > 0) {
// parent process
sys_proc->pid = pid;
return TT_SUCCESS;
}
// child process
execv(path, arg);
// exec returned means error occured
TT_ERROR_NTV("exec[%s] failed", path);
_exit(EXIT_FAILURE);
return TT_FAIL;
}
tt_result_t tt_process_wait_ntv(IN tt_process_ntv_t *sys_proc,
IN tt_bool_t block,
IN OPT tt_u8_t *exit_code)
{
int ret;
int status = 0;
int options = 0;
if (!block) {
options |= WNOHANG;
}
__wait_ag:
ret = waitpid(sys_proc->pid, &status, options);
if (ret > 0) {
if (WIFEXITED(status)) {
TT_SAFE_ASSIGN(exit_code, (tt_u8_t)WEXITSTATUS(status));
} else {
TT_SAFE_ASSIGN(exit_code, TT_PROCESS_EXIT_UNKNOWN);
}
return TT_SUCCESS;
} else if (ret == 0) {
return TT_E_TIMEOUT;
}
// failed
if (errno == EINTR) {
goto __wait_ag;
}
TT_ERROR_NTV("wait process failed");
return TT_FAIL;
}
void tt_process_exit_ntv(IN tt_u8_t exit_code)
{
exit((int)exit_code);
}
tt_char_t *tt_process_path_ntv(IN OPT tt_process_ntv_t *sys_proc)
{
uint32_t len = 0;
tt_char_t *path;
_NSGetExecutablePath((char *)&path, &len);
if (len == 0) {
TT_ERROR("fail to get path len");
return NULL;
}
// returned len including terminating null
path = tt_malloc(len);
if (path == NULL) {
TT_ERROR("no mem for path");
return NULL;
}
if (_NSGetExecutablePath(path, &len) != 0) {
TT_ERROR("fail to get path");
tt_free(path);
return NULL;
}
// path is already null-terminated
return path;
}
tt_char_t *tt_current_path_ntv(IN tt_bool_t end_slash)
{
char *cwd, *d;
tt_u32_t len, append_slash;
cwd = getcwd(NULL, 0);
if (cwd == NULL) {
TT_ERROR_NTV("fail to get current working directory");
return NULL;
}
len = (tt_u32_t)tt_strlen(cwd);
if (end_slash && (len > 0) && (cwd[len - 1] != '/')) {
append_slash = 1;
} else {
append_slash = 0;
}
d = tt_malloc(len + append_slash + 1);
if (d == NULL) {
TT_ERROR("no mem for current working directory");
free(cwd);
return NULL;
}
tt_memcpy(d, cwd, len);
free(cwd);
if (append_slash == 1) {
d[len] = '/';
}
d[len + append_slash] = 0;
return d;
}
tt_result_t tt_set_current_path_ntv(IN const tt_char_t *path)
{
if (chdir(path) == 0) {
return TT_SUCCESS;
} else {
TT_ERROR_NTV("fail to chdir");
return TT_FAIL;
}
}
tt_result_t tt_process_name_ntv(IN tt_char_t *name, IN tt_u32_t len)
{
const char *p = getprogname();
if (p != NULL) {
tt_u32_t n = (tt_u32_t)tt_strlen(p);
if (n >= len) {
n = len - 1;
}
tt_memcpy(name, p, n);
name[n] = 0;
return TT_SUCCESS;
} else {
return TT_FAIL;
}
}
| 25.85514 | 75 | 0.504428 |
dc3cb11904e5bc55852de8d164064b6918cb758d | 1,158 | h | C | core/src/fxcodec/jbig2/JBig2_ArithIntDecoder.h | f100cleveland/external_pdfium | 12eec9c70519554387f199aa1eef42ed15478d02 | [
"BSD-3-Clause"
] | 1 | 2018-01-12T03:24:59.000Z | 2018-01-12T03:24:59.000Z | core/src/fxcodec/jbig2/JBig2_ArithIntDecoder.h | f100cleveland/external_pdfium | 12eec9c70519554387f199aa1eef42ed15478d02 | [
"BSD-3-Clause"
] | null | null | null | core/src/fxcodec/jbig2/JBig2_ArithIntDecoder.h | f100cleveland/external_pdfium | 12eec9c70519554387f199aa1eef42ed15478d02 | [
"BSD-3-Clause"
] | 1 | 2020-07-30T12:07:00.000Z | 2020-07-30T12:07:00.000Z | // Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#ifndef CORE_SRC_FXCODEC_JBIG2_JBIG2_ARITHINTDECODER_H_
#define CORE_SRC_FXCODEC_JBIG2_JBIG2_ARITHINTDECODER_H_
#include <vector>
#include "JBig2_ArithDecoder.h"
#include "core/include/fxcrt/fx_system.h"
class CJBig2_ArithIntDecoder {
public:
CJBig2_ArithIntDecoder();
~CJBig2_ArithIntDecoder();
// Returns true on success, and false when an OOB condition occurs. Many
// callers can tolerate OOB and do not check the return value.
bool decode(CJBig2_ArithDecoder* pArithDecoder, int* nResult);
private:
std::vector<JBig2ArithCtx> m_IAx;
};
class CJBig2_ArithIaidDecoder {
public:
explicit CJBig2_ArithIaidDecoder(unsigned char SBSYMCODELENA);
~CJBig2_ArithIaidDecoder();
void decode(CJBig2_ArithDecoder* pArithDecoder, FX_DWORD* nResult);
private:
std::vector<JBig2ArithCtx> m_IAID;
const unsigned char SBSYMCODELEN;
};
#endif // CORE_SRC_FXCODEC_JBIG2_JBIG2_ARITHINTDECODER_H_
| 27.571429 | 80 | 0.790155 |
87a9ead1be9795661b62583705fe558a4ec07304 | 206 | c | C | Arrays Basics/Arrays Part-2/main.c | bedirhanbuyukoz/C-Programming | af0b3ed4ad18a142537947bde1dd69901e673571 | [
"MIT"
] | null | null | null | Arrays Basics/Arrays Part-2/main.c | bedirhanbuyukoz/C-Programming | af0b3ed4ad18a142537947bde1dd69901e673571 | [
"MIT"
] | null | null | null | Arrays Basics/Arrays Part-2/main.c | bedirhanbuyukoz/C-Programming | af0b3ed4ad18a142537947bde1dd69901e673571 | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <stdlib.h>
#include <locale.h>
int main()
{
setlocale(LC_ALL,"Turkish");
int sayilar[] = {5,10,15,20};
for(int i =0 ;i<4;i++){
printf("%d\n",sayilar[i]);
}
return 0;
} | 9.809524 | 29 | 0.587379 |
effe15ba49e7022a5bca5ca252dd6e7b04c8d6a4 | 387 | h | C | antispam.h | cdidier/clog | cf3da6346390f213a782f69bde5be7b3eaeb9984 | [
"ISC",
"Unlicense"
] | 2 | 2020-02-27T10:35:50.000Z | 2021-05-25T02:17:59.000Z | antispam.h | cdidier/clog | cf3da6346390f213a782f69bde5be7b3eaeb9984 | [
"ISC",
"Unlicense"
] | null | null | null | antispam.h | cdidier/clog | cf3da6346390f213a782f69bde5be7b3eaeb9984 | [
"ISC",
"Unlicense"
] | null | null | null | #ifndef ANTISPAM_H
#define ANTISPAM_H
#ifdef __linux__
#include "openbsd-compat/sha1.h"
#else
#include <sha1.h>
#endif
#define ANTISPAM_JAM_MIN 1
#define ANTISPAM_JAM_MAX 9
struct antispam {
unsigned int jam1, jam2;
char hash[SHA1_DIGEST_STRING_LENGTH];
};
struct antispam *antispam_generate(const char *);
int antispam_verify(const char *, const char *, const char *);
#endif
| 17.590909 | 64 | 0.75969 |
f43cef07422cfc4c84b03da2e87745bccddb16f6 | 1,607 | c | C | quickmenu/arm9/mbedtls/rsa.c | malekairmaroc7/TWiLightMenu | 58bec2f3214d9d14694258f627213d5f5bf44255 | [
"MIT"
] | null | null | null | quickmenu/arm9/mbedtls/rsa.c | malekairmaroc7/TWiLightMenu | 58bec2f3214d9d14694258f627213d5f5bf44255 | [
"MIT"
] | null | null | null | quickmenu/arm9/mbedtls/rsa.c | malekairmaroc7/TWiLightMenu | 58bec2f3214d9d14694258f627213d5f5bf44255 | [
"MIT"
] | null | null | null |
// mbedtls RSA public
// only the pubkey function for signatures verifying
// original rsa.c had too many extra functions not used and too many dependencies
#include <string.h>
#include "bignum.h"
#include "rsa.h"
void rsa_init(rsa_context_t *ctx) {
memset(ctx, 0, sizeof(rsa_context_t));
}
// I don't know why mbedtls doesn't provide this
// instead, all callers set N/E/len manually
// this could be seen in mbedtls_rsa_self_test(rsa.c), main(dh_client.c) and main(rsa_verify.c)
int rsa_set_pubkey(rsa_context_t *ctx, const unsigned char * n_buf, size_t n_len,
const unsigned char * e_buf, size_t e_len)
{
int ret0 = (mbedtls_mpi_read_binary(&ctx->N, n_buf, n_len));
int ret1 = (mbedtls_mpi_read_binary(&ctx->E, e_buf, e_len));
if (ret0 == 0 && ret1 == 0) {
ctx->len = (mbedtls_mpi_bitlen(&ctx->N) + 7) >> 3;
// we should check the key now to be safe?
// anyway usually we load known working keys, so it's omitted
return 0;
} else {
return ret0 || ret1;
}
}
// basically mbedtls_rsa_public
int rsa_public(rsa_context_t *ctx, const unsigned char *input, unsigned char *output) {
int ret;
size_t olen;
mbedtls_mpi T;
mbedtls_mpi_init(&T);
MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&T, input, ctx->len));
if (mbedtls_mpi_cmp_mpi(&T, &ctx->N) >= 0)
{
ret = MBEDTLS_ERR_MPI_BAD_INPUT_DATA;
goto cleanup;
}
olen = ctx->len;
MBEDTLS_MPI_CHK(mbedtls_mpi_exp_mod(&T, &T, &ctx->E, &ctx->N, &ctx->RN));
MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&T, output, olen));
cleanup:
mbedtls_mpi_free(&T);
if (ret != 0)
return(MBEDTLS_ERR_RSA_PUBLIC_FAILED + ret);
return(0);
}
| 25.919355 | 95 | 0.709396 |
4cafb463999df855988e7a6f5cf2c25cd8cec850 | 964 | h | C | BetaCode/Motor_Test.X/BB_Encoder.h | dbazor/BB_Slug | c620827f0daa58e6bed31497a4292abbc25d40bc | [
"MIT"
] | 3 | 2017-01-24T00:28:28.000Z | 2018-12-09T13:14:57.000Z | BetaCode/Motor_Test.X/BB_Encoder.h | dbazor/BB_Slug | c620827f0daa58e6bed31497a4292abbc25d40bc | [
"MIT"
] | null | null | null | BetaCode/Motor_Test.X/BB_Encoder.h | dbazor/BB_Slug | c620827f0daa58e6bed31497a4292abbc25d40bc | [
"MIT"
] | 1 | 2018-04-12T23:52:09.000Z | 2018-04-12T23:52:09.000Z | #ifndef BB_ENCODER_H
#define BB_ENCODER_H
/*******************************************************************************
* PRIVATE #INCLUDES *
******************************************************************************/
/*******************************************************************************
* PRIVATE #DEFINES *
******************************************************************************/
#define TMR3_ROLLOVER 0xFFFF // defines rollover count for IC2?s 16-bit Timer3
// DOUBLE CHECK THIS!
/*******************************************************************************
* FUNCTION PROTOYPES *
******************************************************************************/
void Encoder_Init(void);
#endif /* BB_ENCODER_H */ | 48.2 | 81 | 0.204357 |
733c8b5bb28ca192c8e1dba190eb505636547f20 | 115 | c | C | mb/custom_drm_module_fw/src/RSA/rsa.c | hstowasser/InsecureExample | a6da0a9f71535fdbc017364d9973c54ac50574d4 | [
"Apache-2.0"
] | null | null | null | mb/custom_drm_module_fw/src/RSA/rsa.c | hstowasser/InsecureExample | a6da0a9f71535fdbc017364d9973c54ac50574d4 | [
"Apache-2.0"
] | null | null | null | mb/custom_drm_module_fw/src/RSA/rsa.c | hstowasser/InsecureExample | a6da0a9f71535fdbc017364d9973c54ac50574d4 | [
"Apache-2.0"
] | null | null | null | /*
* rsa.c
*
* Created on: Mar 5, 2020
* Author: heiko
*/
#include "rsa.h"
#include "../frankencrypt.h"
| 12.777778 | 28 | 0.547826 |
2140ab86c22b04a9284b49bb0f7854ebede6114d | 9,286 | h | C | src/Examples/ExampleController.h | eegeo/cardboard-vr-integration | 3f0c3d0f1b7ddaa6b2ef980e46ead71c8a85a260 | [
"BSD-2-Clause"
] | 8 | 2017-07-02T01:14:29.000Z | 2021-06-19T07:14:38.000Z | src/Examples/ExampleController.h | eegeo/cardboard-vr-demo | 3f0c3d0f1b7ddaa6b2ef980e46ead71c8a85a260 | [
"BSD-2-Clause"
] | null | null | null | src/Examples/ExampleController.h | eegeo/cardboard-vr-demo | 3f0c3d0f1b7ddaa6b2ef980e46ead71c8a85a260 | [
"BSD-2-Clause"
] | 5 | 2018-02-07T07:43:51.000Z | 2020-01-24T12:29:25.000Z | // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
#ifndef __ExampleApp__ExampleController__
#define __ExampleApp__ExampleController__
#include "GlobeCameraExampleBase.h"
#include "IExampleFactory.h"
#include "Types.h"
#include "EegeoWorld.h"
#include "UIActionHandler.h"
#include "IExampleControllerView.h"
#include "IInteriorsExplorerModule.h"
#include "Camera.h"
#include "ScreenPropertiesProvider.h"
#include "DefaultCameraControllerFactory.h"
#include "VRCameraSpline/IVRHeadTracker.h"
#include "CameraState.h"
#include "Modules/UI/UIInteraction/IUIInteractionObservable.h"
#include "Modules/UI/IUICameraProvider.h"
#include "Modules/UI/UIQuad/IUIQuadFactory.h"
#include "Modules/DeadZoneMenu/IDeadZoneMenuItemObservable.h"
#include "Modules/UI/Animations/AnimationsController.h"
#include "Modules/WorldMenu/WorldMenu.h"
#include <vector>
#include <string>
#include "ApplicationConfiguration.h"
#include "WorldMenuLoaderModel.h"
#include "IScreenFadeEffectController.h"
namespace Examples
{
class ExampleController : private Eegeo::NonCopyable, public Eegeo::UI::IUICameraProvider
{
IExample* m_pCurrentExample;
int m_currentExampleFactoryIndex;
Eegeo::EegeoWorld& m_world;
std::vector<IExampleFactory*> m_factories;
bool m_uiVisible;
DefaultCameraControllerFactory& m_defaultCameraControllerFactory;
Eegeo::Camera::GlobeCamera::GlobeCameraTouchController& m_globeCameraTouchController;
IExampleControllerView& m_view;
UIActionHandler<ExampleController> m_nextExampleHandler;
UIActionHandler<ExampleController> m_previousExampleHandler;
UIActionHandler<ExampleController> m_selectedExampleChangedHandler;
void DestroyCurrentExample();
void RefreshExample();
public:
ExampleController(Eegeo::EegeoWorld& world,
IExampleControllerView& view,
DefaultCameraControllerFactory& defaultCameraControllerFactory,
Eegeo::Camera::GlobeCamera::GlobeCameraTouchController& globeCameraTouchController);
~ExampleController();
std::vector<std::string> GetExampleNames() const;
void UpdateSelectedExample();
void RestartExample();
void ActivateExample(std::string selectedExampleName);
void ActivatePrevious();
void ActivateNext();
void EarlyUpdate(float dt);
void Update(float dt);
void PreWorldDraw();
void Draw();
void UpdateCardboardProfile(const float cardboardProfile[]);
void RegisterExample(IExampleFactory* pFactory);
const Eegeo::m33& GetOrientation();
const Eegeo::m33& GetBaseOrientation();
const Eegeo::m33& GetHeadTrackerOrientation();
Eegeo::Camera::RenderCamera& GetRenderCamera();
void UpdateHeadOrientation(const float headTansform[]);
Eegeo::Camera::CameraState GetCurrentCameraState() const;
const Eegeo::VRCamera::VRCameraState& GetCurrentVRCameraState();
Eegeo::Streaming::IStreamingVolume& GetCurrentStreamingVolume() const;
void NotifyScreenPropertiesChanged(const Eegeo::Rendering::ScreenProperties& screenProperties);
template <typename TExampleFactory>
void RegisterExample()
{
m_factories.push_back(Eegeo_NEW((TExampleFactory)(m_world)));
}
template <typename TExampleFactory>
void RegisterCameraExample()
{
m_factories.push_back(Eegeo_NEW((TExampleFactory)(m_world, m_defaultCameraControllerFactory, m_globeCameraTouchController)));
}
template <typename TExampleFactory>
void RegisterCameraControllerScreenPropertiesProviderExample(const ScreenPropertiesProvider& screenPropertiesProvider)
{
m_factories.push_back(Eegeo_NEW((TExampleFactory)(m_world, m_defaultCameraControllerFactory, m_globeCameraTouchController, screenPropertiesProvider)));
}
template <typename TExampleFactory>
void RegisterScreenPropertiesProviderExample(const ScreenPropertiesProvider& screenPropertiesProvider)
{
m_factories.push_back(Eegeo_NEW((TExampleFactory)(m_world, screenPropertiesProvider)));
}
template <typename TExampleFactory>
void RegisterScreenPropertiesProviderVRExample(const ScreenPropertiesProvider& screenPropertiesProvider,
InteriorsExplorer::IInteriorsExplorerModule& interiorsExplorerModule,
Examples::IVRHeadTracker& headTracker,
Eegeo::UI::IUIQuadFactory& quadFactory,
ScreenFadeEffect::SdkModel::IScreenFadeEffectController& screenFader,
const ApplicationConfig::ApplicationConfiguration& appConfig,
const Eegeo::Config::DeviceSpec& deviceSpecs)
{
m_factories.push_back(Eegeo_NEW((TExampleFactory)(m_world,
m_defaultCameraControllerFactory,
headTracker,
screenPropertiesProvider,
interiorsExplorerModule,
quadFactory,
screenFader,
appConfig,
deviceSpecs)));
}
template <typename TExampleFactory>
void RegisterJumpPointVRExample(const IScreenPropertiesProvider& screenPropertiesProvider,
Eegeo::UI::IUIQuadFactory& quadFactory,
Eegeo::UI::IUIInteractionObservable& uIInteractionObservable,
const Eegeo::Config::DeviceSpec& deviceSpecs,
InteriorsExplorer::IInteriorsExplorerModule& interiorsExplorerModule,
Eegeo::UI::Animations::AnimationsController& animationsController,
Eegeo::UI::WorldMenu::WorldMenuModule& worldMenuModule,
WorldMenuLoader::SdkModel::WorldMenuLoaderModel& menuLoader,
IVRHeadTracker& headTracker,
Examples::ApplicationConfig::ApplicationConfiguration& appConfig)
{
m_factories.push_back(Eegeo_NEW((TExampleFactory)(m_world,
m_defaultCameraControllerFactory,
screenPropertiesProvider,
quadFactory,
uIInteractionObservable,
deviceSpecs,
interiorsExplorerModule,
animationsController,
worldMenuModule,
menuLoader,
headTracker,
appConfig)));
}
void Event_TouchRotate(const AppInterface::RotateData& data);
void Event_TouchRotate_Start(const AppInterface::RotateData& data);
void Event_TouchRotate_End(const AppInterface::RotateData& data);
void Event_TouchPinch(const AppInterface::PinchData& data);
void Event_TouchPinch_Start(const AppInterface::PinchData& data);
void Event_TouchPinch_End(const AppInterface::PinchData& data);
void Event_TouchPan(const AppInterface::PanData& data);
void Event_TouchPan_Start(const AppInterface::PanData& data);
void Event_TouchPan_End(const AppInterface::PanData& data);
void Event_TouchTap(const AppInterface::TapData& data);
void Event_TouchDoubleTap(const AppInterface::TapData& data);
void Event_TouchDown(const AppInterface::TouchData& data);
void Event_TouchMove(const AppInterface::TouchData& data);
void Event_TouchUp(const AppInterface::TouchData& data);
Eegeo::Camera::RenderCamera& GetRenderCameraForUI();
};
}
#endif /* defined(__ExampleApp__ExampleController__) */
| 47.377551 | 163 | 0.57129 |
9e45b718a716ce28e574cbbaf88af1fe5b041903 | 1,424 | h | C | qudarap/qprop.h | hanswenzel/opticks | b75b5929b6cf36a5eedeffb3031af2920f75f9f0 | [
"Apache-2.0"
] | 11 | 2020-07-05T02:39:32.000Z | 2022-03-20T18:52:44.000Z | qudarap/qprop.h | hanswenzel/opticks | b75b5929b6cf36a5eedeffb3031af2920f75f9f0 | [
"Apache-2.0"
] | null | null | null | qudarap/qprop.h | hanswenzel/opticks | b75b5929b6cf36a5eedeffb3031af2920f75f9f0 | [
"Apache-2.0"
] | 4 | 2020-09-03T20:36:32.000Z | 2022-01-19T07:42:21.000Z | #pragma once
#if defined(__CUDACC__) || defined(__CUDABE__)
#define QPROP_METHOD __device__
#else
#define QPROP_METHOD
#endif
/**
qprop
=======
**/
#include "sview.h"
template<typename T>
struct qprop
{
T* pp ;
unsigned width ;
unsigned height ;
#if defined(__CUDACC__) || defined(__CUDABE__)
QPROP_METHOD T interpolate( unsigned iprop, T x );
#else
qprop()
:
pp(nullptr),
width(0),
height(0)
{
}
#endif
};
#if defined(__CUDACC__) || defined(__CUDABE__)
/**
qprop<T>::interpolate
-----------------------
1. access property data for index iprop
2. interpret the last column to obtain the number of payload values
3. binary search to find the bin relevant to domain argument x
4. linear interpolation to yield the y value at x
**/
template <typename T>
inline QPROP_METHOD T qprop<T>::interpolate( unsigned iprop, T x )
{
const T* vv = pp + width*iprop ;
int ni = sview::int_from<T>( *(vv+width-1) ) ;
int lo = 0 ;
int hi = ni-1 ;
if( x <= vv[2*lo+0] ) return vv[2*lo+1] ;
if( x >= vv[2*hi+0] ) return vv[2*hi+1] ;
while (lo < hi-1)
{
int mi = (lo+hi)/2;
if (x < vv[2*mi+0]) hi = mi ;
else lo = mi;
}
T dy = vv[2*hi+1] - vv[2*lo+1] ;
T dx = vv[2*hi+0] - vv[2*lo+0] ;
T y = vv[2*lo+1] + dy*(x-vv[2*lo+0])/dx ;
return y ;
}
#endif
| 16.752941 | 67 | 0.554775 |
32272755dc8a6b1d8bb3bd8f7d5eed4eda57954c | 373 | c | C | liners/miles.c | lialkaas/hello-c | 7fc4703532fdc77d6b6b93b506582def0356b68f | [
"MIT"
] | 2 | 2020-06-01T02:43:44.000Z | 2021-11-24T16:41:24.000Z | liners/miles.c | lialkaas/ican-c | 7fc4703532fdc77d6b6b93b506582def0356b68f | [
"MIT"
] | null | null | null | liners/miles.c | lialkaas/ican-c | 7fc4703532fdc77d6b6b93b506582def0356b68f | [
"MIT"
] | null | null | null | #include <stdio.h>
#define MILE 1.609
#define GALLON 3.785
int main(void) {
float distance, consumed, mpg;
printf("Enter miles traveled and gallons of gasoline consumed: ");
scanf("%f %f", &distance, &consumed);
mpg = distance/consumed;
printf("%.1f miles per gallon\n", mpg);
printf("%.1f liters per 100km\n", 1/mpg*GALLON/MILE);
return 0;
}
| 24.866667 | 70 | 0.648794 |
829ab55a0b017c82fc4b2905fe4edfc2626262aa | 59,492 | c | C | drivers/video/omap2/omapfb/omapfb-main.c | tuxafgmur/OLD_Dhollmen_Kernel | 90ed4e2e3e6321de246fa193705ae40ede4e2d8e | [
"BSD-Source-Code"
] | null | null | null | drivers/video/omap2/omapfb/omapfb-main.c | tuxafgmur/OLD_Dhollmen_Kernel | 90ed4e2e3e6321de246fa193705ae40ede4e2d8e | [
"BSD-Source-Code"
] | null | null | null | drivers/video/omap2/omapfb/omapfb-main.c | tuxafgmur/OLD_Dhollmen_Kernel | 90ed4e2e3e6321de246fa193705ae40ede4e2d8e | [
"BSD-Source-Code"
] | null | null | null | /*
* linux/drivers/video/omap2/omapfb-main.c
*
* Copyright (C) 2008 Nokia Corporation
* Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
*
* Some code and ideas taken from drivers/video/omap/ driver
* by Imre Deak.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*
* This program 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 General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/fb.h>
#include <linux/dma-mapping.h>
#include <linux/vmalloc.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/omapfb.h>
#include <linux/wait.h>
#include <video/omapdss.h>
#include <plat/vram.h>
#include <plat/vrfb.h>
#include "omapfb.h"
#define MODULE_NAME "omapfb"
#define OMAPFB_PLANE_XRES_MIN 8
#define OMAPFB_PLANE_YRES_MIN 8
static char *def_mode;
static char *def_vram;
static int def_vrfb;
static int def_rotate;
static int def_mirror;
/* Max 4 framebuffers assumed : FB-ix-W-H */
#define MAX_FB_COUNT 4
#define ELEMENT_COUNT 3
struct fb_options {
int ix;
int width;
int height;
};
#ifdef CONFIG_FB_OMAP2_VSYNC_SEND_UEVENTS
static int i_event_mode = 1;
#endif
static int fb_opt[MAX_FB_COUNT*ELEMENT_COUNT] = { -1, -1, -1,
-1, -1, -1,
-1, -1, -1,
-1, -1, -1};
module_param_array(fb_opt, int, NULL, 0);
MODULE_PARM_DESC(fb_opt, "FB[ix][w][h]");
#ifdef DEBUG
unsigned int omapfb_debug;
module_param_named(debug, omapfb_debug, bool, 0644);
static unsigned int omapfb_test_pattern;
module_param_named(test, omapfb_test_pattern, bool, 0644);
#endif
static int initialize_dev_fb_resolution(u16 display_ix,
struct omap_dss_device *dssdev)
{
struct fb_options *pfb_opt = NULL;
if (display_ix > MAX_FB_COUNT || !dssdev)
return -EINVAL;
pfb_opt = (struct fb_options *)&fb_opt[display_ix*ELEMENT_COUNT];
if (pfb_opt->ix != -1) {
dssdev->panel.fb_xres = pfb_opt->width;
dssdev->panel.fb_yres = pfb_opt->height;
} else {
dssdev->panel.fb_xres = dssdev->panel.timings.x_res;
dssdev->panel.fb_yres = dssdev->panel.timings.y_res;
}
return 0;
}
void get_fb_resolution(struct omap_dss_device *dssdev, u16 *xres, u16 *yres)
{
*xres = dssdev->panel.fb_xres;
*yres = dssdev->panel.fb_yres;
return;
}
static int omapfb_fb_init(struct omapfb2_device *fbdev, struct fb_info *fbi);
static int omapfb_get_recommended_bpp(struct omapfb2_device *fbdev,
struct omap_dss_device *dssdev);
#ifdef DEBUG
static void draw_pixel(struct fb_info *fbi, int x, int y, unsigned color)
{
struct fb_var_screeninfo *var = &fbi->var;
struct fb_fix_screeninfo *fix = &fbi->fix;
void __iomem *addr = fbi->screen_base;
const unsigned bytespp = var->bits_per_pixel >> 3;
const unsigned line_len = fix->line_length / bytespp;
int r = (color >> 16) & 0xff;
int g = (color >> 8) & 0xff;
int b = (color >> 0) & 0xff;
if (var->bits_per_pixel == 16) {
u16 __iomem *p = (u16 __iomem *)addr;
p += y * line_len + x;
r = r * 32 / 256;
g = g * 64 / 256;
b = b * 32 / 256;
__raw_writew((r << 11) | (g << 5) | (b << 0), p);
} else if (var->bits_per_pixel == 24) {
u8 __iomem *p = (u8 __iomem *)addr;
p += (y * line_len + x) * 3;
__raw_writeb(b, p + 0);
__raw_writeb(g, p + 1);
__raw_writeb(r, p + 2);
} else if (var->bits_per_pixel == 32) {
u32 __iomem *p = (u32 __iomem *)addr;
p += y * line_len + x;
__raw_writel(color, p);
}
}
static void fill_fb(struct fb_info *fbi)
{
struct fb_var_screeninfo *var = &fbi->var;
const short w = var->xres_virtual;
const short h = var->yres_virtual;
void __iomem *addr = fbi->screen_base;
int y, x;
if (!addr)
return;
DBG("fill_fb %dx%d, line_len %d bytes\n", w, h, fbi->fix.line_length);
for (y = 0; y < h; y++) {
for (x = 0; x < w; x++) {
if (x < 20 && y < 20)
draw_pixel(fbi, x, y, 0xffffff);
else if (x < 20 && (y > 20 && y < h - 20))
draw_pixel(fbi, x, y, 0xff);
else if (y < 20 && (x > 20 && x < w - 20))
draw_pixel(fbi, x, y, 0xff00);
else if (x > w - 20 && (y > 20 && y < h - 20))
draw_pixel(fbi, x, y, 0xff0000);
else if (y > h - 20 && (x > 20 && x < w - 20))
draw_pixel(fbi, x, y, 0xffff00);
else if (x == 20 || x == w - 20 ||
y == 20 || y == h - 20)
draw_pixel(fbi, x, y, 0xffffff);
else if (x == y || w - x == h - y)
draw_pixel(fbi, x, y, 0xff00ff);
else if (w - x == y || x == h - y)
draw_pixel(fbi, x, y, 0x00ffff);
else if (x > 20 && y > 20 && x < w - 20 && y < h - 20) {
int t = x * 3 / w;
unsigned r = 0, g = 0, b = 0;
unsigned c;
if (var->bits_per_pixel == 16) {
if (t == 0)
b = (y % 32) * 256 / 32;
else if (t == 1)
g = (y % 64) * 256 / 64;
else if (t == 2)
r = (y % 32) * 256 / 32;
} else {
if (t == 0)
b = (y % 256);
else if (t == 1)
g = (y % 256);
else if (t == 2)
r = (y % 256);
}
c = (r << 16) | (g << 8) | (b << 0);
draw_pixel(fbi, x, y, c);
} else {
draw_pixel(fbi, x, y, 0);
}
}
}
}
#endif
static unsigned omapfb_get_vrfb_offset(const struct omapfb_info *ofbi, int rot)
{
const struct vrfb *vrfb = &ofbi->region->vrfb;
unsigned offset;
switch (rot) {
case FB_ROTATE_UR:
offset = 0;
break;
case FB_ROTATE_CW:
offset = vrfb->yoffset;
break;
case FB_ROTATE_UD:
offset = vrfb->yoffset * OMAP_VRFB_LINE_LEN + vrfb->xoffset;
break;
case FB_ROTATE_CCW:
offset = vrfb->xoffset * OMAP_VRFB_LINE_LEN;
break;
default:
BUG();
}
offset *= vrfb->bytespp;
return offset;
}
static u32 omapfb_get_region_rot_paddr(const struct omapfb_info *ofbi, int rot)
{
if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) {
return ofbi->region->vrfb.paddr[rot]
+ omapfb_get_vrfb_offset(ofbi, rot);
} else {
return ofbi->region->paddr;
}
}
static u32 omapfb_get_region_paddr(const struct omapfb_info *ofbi)
{
if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB)
return ofbi->region->vrfb.paddr[0];
else
return ofbi->region->paddr;
}
static void __iomem *omapfb_get_region_vaddr(const struct omapfb_info *ofbi)
{
if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB)
return ofbi->region->vrfb.vaddr[0];
else
return ofbi->region->vaddr;
}
static struct omapfb_colormode omapfb_colormodes[] = {
{
.dssmode = OMAP_DSS_COLOR_UYVY,
.bits_per_pixel = 16,
.nonstd = OMAPFB_COLOR_YUV422,
}, {
.dssmode = OMAP_DSS_COLOR_YUV2,
.bits_per_pixel = 16,
.nonstd = OMAPFB_COLOR_YUY422,
}, {
.dssmode = OMAP_DSS_COLOR_ARGB16,
.bits_per_pixel = 16,
.red = { .length = 4, .offset = 8, .msb_right = 0 },
.green = { .length = 4, .offset = 4, .msb_right = 0 },
.blue = { .length = 4, .offset = 0, .msb_right = 0 },
.transp = { .length = 4, .offset = 12, .msb_right = 0 },
}, {
.dssmode = OMAP_DSS_COLOR_RGB16,
.bits_per_pixel = 16,
.red = { .length = 5, .offset = 11, .msb_right = 0 },
.green = { .length = 6, .offset = 5, .msb_right = 0 },
.blue = { .length = 5, .offset = 0, .msb_right = 0 },
.transp = { .length = 0, .offset = 0, .msb_right = 0 },
}, {
.dssmode = OMAP_DSS_COLOR_RGB24P,
.bits_per_pixel = 24,
.red = { .length = 8, .offset = 16, .msb_right = 0 },
.green = { .length = 8, .offset = 8, .msb_right = 0 },
.blue = { .length = 8, .offset = 0, .msb_right = 0 },
.transp = { .length = 0, .offset = 0, .msb_right = 0 },
}, {
.dssmode = OMAP_DSS_COLOR_RGB24U,
.bits_per_pixel = 32,
.red = { .length = 8, .offset = 16, .msb_right = 0 },
.green = { .length = 8, .offset = 8, .msb_right = 0 },
.blue = { .length = 8, .offset = 0, .msb_right = 0 },
.transp = { .length = 0, .offset = 0, .msb_right = 0 },
}, {
.dssmode = OMAP_DSS_COLOR_ARGB32,
.bits_per_pixel = 32,
.red = { .length = 8, .offset = 16, .msb_right = 0 },
.green = { .length = 8, .offset = 8, .msb_right = 0 },
.blue = { .length = 8, .offset = 0, .msb_right = 0 },
.transp = { .length = 8, .offset = 24, .msb_right = 0 },
}, {
.dssmode = OMAP_DSS_COLOR_RGBA32,
.bits_per_pixel = 32,
.red = { .length = 8, .offset = 24, .msb_right = 0 },
.green = { .length = 8, .offset = 16, .msb_right = 0 },
.blue = { .length = 8, .offset = 8, .msb_right = 0 },
.transp = { .length = 8, .offset = 0, .msb_right = 0 },
}, {
.dssmode = OMAP_DSS_COLOR_RGBX32,
.bits_per_pixel = 32,
.red = { .length = 8, .offset = 24, .msb_right = 0 },
.green = { .length = 8, .offset = 16, .msb_right = 0 },
.blue = { .length = 8, .offset = 8, .msb_right = 0 },
.transp = { .length = 0, .offset = 0, .msb_right = 0 },
},
};
static bool cmp_var_to_colormode(struct fb_var_screeninfo *var,
struct omapfb_colormode *color)
{
bool cmp_component(struct fb_bitfield *f1, struct fb_bitfield *f2)
{
return f1->length == f2->length &&
f1->offset == f2->offset &&
f1->msb_right == f2->msb_right;
}
if (var->bits_per_pixel == 0 ||
var->red.length == 0 ||
var->blue.length == 0 ||
var->green.length == 0)
return 0;
return var->bits_per_pixel == color->bits_per_pixel &&
cmp_component(&var->red, &color->red) &&
cmp_component(&var->green, &color->green) &&
cmp_component(&var->blue, &color->blue) &&
cmp_component(&var->transp, &color->transp);
}
static void assign_colormode_to_var(struct fb_var_screeninfo *var,
struct omapfb_colormode *color)
{
var->bits_per_pixel = color->bits_per_pixel;
var->nonstd = color->nonstd;
var->red = color->red;
var->green = color->green;
var->blue = color->blue;
var->transp = color->transp;
}
int omapfb_mode_to_dss_mode(struct fb_var_screeninfo *var,
enum omap_color_mode *mode)
{
enum omap_color_mode dssmode;
int i;
/* first match with nonstd field */
if (var->nonstd) {
for (i = 0; i < ARRAY_SIZE(omapfb_colormodes); ++i) {
struct omapfb_colormode *m = &omapfb_colormodes[i];
if (var->nonstd == m->nonstd) {
assign_colormode_to_var(var, m);
*mode = m->dssmode;
return 0;
}
}
return -EINVAL;
}
/* then try exact match of bpp and colors */
for (i = 0; i < ARRAY_SIZE(omapfb_colormodes); ++i) {
struct omapfb_colormode *m = &omapfb_colormodes[i];
if (cmp_var_to_colormode(var, m)) {
assign_colormode_to_var(var, m);
*mode = m->dssmode;
return 0;
}
}
/* match with bpp if user has not filled color fields
* properly */
switch (var->bits_per_pixel) {
case 1:
dssmode = OMAP_DSS_COLOR_CLUT1;
break;
case 2:
dssmode = OMAP_DSS_COLOR_CLUT2;
break;
case 4:
dssmode = OMAP_DSS_COLOR_CLUT4;
break;
case 8:
dssmode = OMAP_DSS_COLOR_CLUT8;
break;
case 12:
dssmode = OMAP_DSS_COLOR_RGB12U;
break;
case 16:
dssmode = OMAP_DSS_COLOR_RGB16;
break;
case 24:
dssmode = OMAP_DSS_COLOR_RGB24P;
break;
case 32:
dssmode = OMAP_DSS_COLOR_ARGB32;
break;
default:
return -EINVAL;
}
for (i = 0; i < ARRAY_SIZE(omapfb_colormodes); ++i) {
struct omapfb_colormode *m = &omapfb_colormodes[i];
if (dssmode == m->dssmode) {
assign_colormode_to_var(var, m);
*mode = m->dssmode;
return 0;
}
}
return -EINVAL;
}
EXPORT_SYMBOL(omapfb_mode_to_dss_mode);
static int check_fb_res_bounds(struct fb_var_screeninfo *var)
{
int xres_min = OMAPFB_PLANE_XRES_MIN;
int xres_max = 2048;
int yres_min = OMAPFB_PLANE_YRES_MIN;
int yres_max = 2048;
/* XXX: some applications seem to set virtual res to 0. */
if (var->xres_virtual == 0)
var->xres_virtual = var->xres;
if (var->yres_virtual == 0)
var->yres_virtual = var->yres;
if (var->xres_virtual < xres_min || var->yres_virtual < yres_min)
return -EINVAL;
if (var->xres < xres_min)
var->xres = xres_min;
if (var->yres < yres_min)
var->yres = yres_min;
if (var->xres > xres_max)
var->xres = xres_max;
if (var->yres > yres_max)
var->yres = yres_max;
if (var->xres > var->xres_virtual)
var->xres = var->xres_virtual;
if (var->yres > var->yres_virtual)
var->yres = var->yres_virtual;
return 0;
}
static void shrink_height(unsigned long max_frame_size,
struct fb_var_screeninfo *var)
{
var->yres_virtual = max_frame_size /
(var->xres_virtual * var->bits_per_pixel >> 3);
if (var->yres_virtual < OMAPFB_PLANE_YRES_MIN)
var->yres_virtual = OMAPFB_PLANE_YRES_MIN;
if (var->yres > var->yres_virtual)
var->yres = var->yres_virtual;
}
static void shrink_width(unsigned long max_frame_size,
struct fb_var_screeninfo *var)
{
var->xres_virtual = max_frame_size / var->yres_virtual /
(var->bits_per_pixel >> 3);
if (var->xres_virtual < OMAPFB_PLANE_XRES_MIN)
var->xres_virtual = OMAPFB_PLANE_XRES_MIN;
if (var->xres > var->xres_virtual)
var->xres = var->xres_virtual;
}
static int check_vrfb_fb_size(unsigned long region_size,
const struct fb_var_screeninfo *var)
{
unsigned long min_phys_size = omap_vrfb_min_phys_size(var->xres_virtual,
var->yres_virtual, var->bits_per_pixel >> 3);
return min_phys_size > region_size ? -EINVAL : 0;
}
static int check_fb_size(const struct omapfb_info *ofbi,
struct fb_var_screeninfo *var)
{
unsigned long max_frame_size = ofbi->region->size;
int bytespp = var->bits_per_pixel >> 3;
unsigned long line_size = var->xres_virtual * bytespp;
if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) {
/* One needs to check for both VRFB and OMAPFB limitations. */
if (check_vrfb_fb_size(max_frame_size, var))
shrink_height(omap_vrfb_max_height(
max_frame_size, var->xres_virtual, bytespp) *
line_size, var);
if (check_vrfb_fb_size(max_frame_size, var)) {
return -EINVAL;
}
return 0;
}
if (line_size * var->yres_virtual > max_frame_size)
shrink_height(max_frame_size, var);
if (line_size * var->yres_virtual > max_frame_size) {
shrink_width(max_frame_size, var);
line_size = var->xres_virtual * bytespp;
}
if (line_size * var->yres_virtual > max_frame_size) {
return -EINVAL;
}
return 0;
}
/*
* Consider if VRFB assisted rotation is in use and if the virtual space for
* the zero degree view needs to be mapped. The need for mapping also acts as
* the trigger for setting up the hardware on the context in question. This
* ensures that one does not attempt to access the virtual view before the
* hardware is serving the address translations.
*/
static int setup_vrfb_rotation(struct fb_info *fbi)
{
struct omapfb_info *ofbi = FB2OFB(fbi);
struct omapfb2_mem_region *rg = ofbi->region;
struct vrfb *vrfb = &rg->vrfb;
struct fb_var_screeninfo *var = &fbi->var;
struct fb_fix_screeninfo *fix = &fbi->fix;
unsigned bytespp;
bool yuv_mode;
enum omap_color_mode mode;
int r;
bool reconf;
if (!rg->size || ofbi->rotation_type != OMAP_DSS_ROT_VRFB)
return 0;
r = omapfb_mode_to_dss_mode(var, &mode);
if (r)
return r;
bytespp = var->bits_per_pixel >> 3;
yuv_mode = mode == OMAP_DSS_COLOR_YUV2 || mode == OMAP_DSS_COLOR_UYVY;
/* We need to reconfigure VRFB if the resolution changes, if yuv mode
* is enabled/disabled, or if bytes per pixel changes */
/* XXX we shouldn't allow this when framebuffer is mmapped */
reconf = false;
if (yuv_mode != vrfb->yuv_mode)
reconf = true;
else if (bytespp != vrfb->bytespp)
reconf = true;
else if (vrfb->xres != var->xres_virtual ||
vrfb->yres != var->yres_virtual)
reconf = true;
if (vrfb->vaddr[0] && reconf) {
fbi->screen_base = NULL;
fix->smem_start = 0;
fix->smem_len = 0;
iounmap(vrfb->vaddr[0]);
vrfb->vaddr[0] = NULL;
}
if (vrfb->vaddr[0])
return 0;
omap_vrfb_setup(&rg->vrfb, rg->paddr,
var->xres_virtual,
var->yres_virtual,
bytespp, yuv_mode);
/* Now one can ioremap the 0 angle view */
r = omap_vrfb_map_angle(vrfb, var->yres_virtual, 0);
if (r)
return r;
/* used by open/write in fbmem.c */
fbi->screen_base = ofbi->region->vrfb.vaddr[0];
fix->smem_start = ofbi->region->vrfb.paddr[0];
switch (var->nonstd) {
case OMAPFB_COLOR_YUV422:
case OMAPFB_COLOR_YUY422:
fix->line_length =
(OMAP_VRFB_LINE_LEN * var->bits_per_pixel) >> 2;
break;
default:
fix->line_length =
(OMAP_VRFB_LINE_LEN * var->bits_per_pixel) >> 3;
break;
}
fix->smem_len = var->yres_virtual * fix->line_length;
return 0;
}
int dss_mode_to_fb_mode(enum omap_color_mode dssmode,
struct fb_var_screeninfo *var)
{
int i;
for (i = 0; i < ARRAY_SIZE(omapfb_colormodes); ++i) {
struct omapfb_colormode *mode = &omapfb_colormodes[i];
if (dssmode == mode->dssmode) {
assign_colormode_to_var(var, mode);
return 0;
}
}
return -ENOENT;
}
void set_fb_fix(struct fb_info *fbi)
{
struct fb_fix_screeninfo *fix = &fbi->fix;
struct fb_var_screeninfo *var = &fbi->var;
struct omapfb_info *ofbi = FB2OFB(fbi);
struct omapfb2_mem_region *rg = ofbi->region;
/* used by open/write in fbmem.c */
fbi->screen_base = (char __iomem *)omapfb_get_region_vaddr(ofbi);
/* used by mmap in fbmem.c */
if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) {
switch (var->nonstd) {
case OMAPFB_COLOR_YUV422:
case OMAPFB_COLOR_YUY422:
fix->line_length =
(OMAP_VRFB_LINE_LEN * var->bits_per_pixel) >> 2;
break;
default:
fix->line_length =
(OMAP_VRFB_LINE_LEN * var->bits_per_pixel) >> 3;
break;
}
fix->smem_len = var->yres_virtual * fix->line_length;
} else {
/* SGX requires stride to be a multiple of 32 pixels */
int xres_align = ALIGN(var->xres_virtual, 32);
fix->line_length = (xres_align * var->bits_per_pixel) >> 3;
fix->smem_len = rg->size;
}
fix->smem_start = omapfb_get_region_paddr(ofbi);
fix->type = FB_TYPE_PACKED_PIXELS;
if (var->nonstd)
fix->visual = FB_VISUAL_PSEUDOCOLOR;
else {
switch (var->bits_per_pixel) {
case 32:
case 24:
case 16:
case 12:
fix->visual = FB_VISUAL_TRUECOLOR;
/* 12bpp is stored in 16 bits */
break;
case 1:
case 2:
case 4:
case 8:
fix->visual = FB_VISUAL_PSEUDOCOLOR;
break;
}
}
fix->accel = FB_ACCEL_NONE;
fix->xpanstep = 1;
fix->ypanstep = 1;
}
/* check new var and possibly modify it to be ok */
int check_fb_var(struct fb_info *fbi, struct fb_var_screeninfo *var)
{
struct omapfb_info *ofbi = FB2OFB(fbi);
struct omap_dss_device *display = fb2display(fbi);
enum omap_color_mode mode = 0;
int i;
int r;
u32 w = 0, h = 0;
r = omapfb_mode_to_dss_mode(var, &mode);
if (r)
return r;
for (i = 0; i < ofbi->num_overlays; ++i) {
if ((ofbi->overlays[i]->supported_modes & mode) == 0)
return -EINVAL;
}
if (var->rotate > 3)
return -EINVAL;
if (check_fb_res_bounds(var))
return -EINVAL;
/* When no memory is allocated ignore the size check */
if (ofbi->region->size != 0 && check_fb_size(ofbi, var))
return -EINVAL;
if (var->xres + var->xoffset > var->xres_virtual)
var->xoffset = var->xres_virtual - var->xres;
if (var->yres + var->yoffset > var->yres_virtual)
var->yoffset = var->yres_virtual - var->yres;
if (display)
omapdss_display_get_dimensions(display, &w, &h);
if (w && h) {
var->width = DIV_ROUND_CLOSEST(w, 1000);
var->height = DIV_ROUND_CLOSEST(h, 1000);
} else {
var->height = -1;
var->width = -1;
}
var->grayscale = 0;
if (display && display->driver->get_timings) {
struct omap_video_timings timings;
display->driver->get_timings(display, &timings);
/* pixclock in ps, the rest in pixclock */
var->pixclock = timings.pixel_clock != 0 ?
KHZ2PICOS(timings.pixel_clock) :
0;
var->left_margin = timings.hbp;
var->right_margin = timings.hfp;
var->upper_margin = timings.vbp;
var->lower_margin = timings.vfp;
var->hsync_len = timings.hsw;
var->vsync_len = timings.vsw;
} else {
var->pixclock = 0;
var->left_margin = 0;
var->right_margin = 0;
var->upper_margin = 0;
var->lower_margin = 0;
var->hsync_len = 0;
var->vsync_len = 0;
}
/* TODO: get these from panel->config */
var->vmode = FB_VMODE_NONINTERLACED;
var->sync = 0;
return 0;
}
bool check_fb_scale(struct omap_dss_device *dssdev)
{
u16 fb_w, fb_h , pn_w , pn_h;
struct omap_dss_driver *dssdrv;
if (!dssdev || !dssdev->driver)
return false;
fb_w = fb_h = pn_w = pn_h = 0;
dssdrv = dssdev->driver;
get_fb_resolution(dssdev, &fb_w, &fb_h);
if (fb_w == 0 || fb_h == 0)
return false;
if (dssdrv->get_resolution)
dssdrv->get_resolution(dssdev, &pn_w, &pn_h);
if (fb_w != pn_w || fb_h != pn_h)
return true;
else
return false;
}
/*
* ---------------------------------------------------------------------------
* fbdev framework callbacks
* ---------------------------------------------------------------------------
*/
static int omapfb_open(struct fb_info *fbi, int user)
{
return 0;
}
static int omapfb_release(struct fb_info *fbi, int user)
{
struct omapfb_info *ofbi = FB2OFB(fbi);
struct omapfb2_device *fbdev = ofbi->fbdev;
struct omap_dss_device *display = fb2display(fbi);
if (!display)
return -ENODEV;
omapfb_enable_vsync(fbdev, display->channel, false);
return 0;
}
static unsigned calc_rotation_offset_dma(const struct fb_var_screeninfo *var,
const struct fb_fix_screeninfo *fix, int rotation)
{
unsigned offset;
offset = var->yoffset * fix->line_length +
var->xoffset * (var->bits_per_pixel >> 3);
return offset;
}
static unsigned calc_rotation_offset_vrfb(const struct fb_var_screeninfo *var,
const struct fb_fix_screeninfo *fix, int rotation)
{
unsigned offset;
if (rotation == FB_ROTATE_UD)
offset = (var->yres_virtual - var->yres) *
fix->line_length;
else if (rotation == FB_ROTATE_CW)
offset = (var->yres_virtual - var->yres) *
(var->bits_per_pixel >> 3);
else
offset = 0;
if (rotation == FB_ROTATE_UR)
offset += var->yoffset * fix->line_length +
var->xoffset * (var->bits_per_pixel >> 3);
else if (rotation == FB_ROTATE_UD)
offset -= var->yoffset * fix->line_length +
var->xoffset * (var->bits_per_pixel >> 3);
else if (rotation == FB_ROTATE_CW)
offset -= var->xoffset * fix->line_length +
var->yoffset * (var->bits_per_pixel >> 3);
else if (rotation == FB_ROTATE_CCW)
offset += var->xoffset * fix->line_length +
var->yoffset * (var->bits_per_pixel >> 3);
return offset;
}
static void omapfb_calc_addr(const struct omapfb_info *ofbi,
const struct fb_var_screeninfo *var,
const struct fb_fix_screeninfo *fix,
int rotation, u32 *paddr, void __iomem **vaddr)
{
u32 data_start_p;
void __iomem *data_start_v;
int offset;
if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) {
data_start_p = omapfb_get_region_rot_paddr(ofbi, rotation);
data_start_v = NULL;
} else {
data_start_p = omapfb_get_region_paddr(ofbi);
data_start_v = omapfb_get_region_vaddr(ofbi);
}
if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB)
offset = calc_rotation_offset_vrfb(var, fix, rotation);
else
offset = calc_rotation_offset_dma(var, fix, rotation);
data_start_p += offset;
data_start_v += offset;
*paddr = data_start_p;
*vaddr = data_start_v;
}
/* setup overlay according to the fb */
int omapfb_setup_overlay(struct fb_info *fbi, struct omap_overlay *ovl,
u16 posx, u16 posy, u16 outw, u16 outh)
{
int r = 0;
struct omapfb_info *ofbi = FB2OFB(fbi);
struct fb_var_screeninfo *var = &fbi->var;
struct fb_fix_screeninfo *fix = &fbi->fix;
enum omap_color_mode mode = 0;
u32 data_start_p = 0;
void __iomem *data_start_v = NULL;
struct omap_overlay_info info;
int xres, yres;
int screen_width;
int mirror;
int rotation = var->rotate;
int i;
for (i = 0; i < ofbi->num_overlays; i++) {
if (ovl != ofbi->overlays[i])
continue;
rotation = (rotation + ofbi->rotation[i]) % 4;
break;
}
if (rotation == FB_ROTATE_CW || rotation == FB_ROTATE_CCW) {
xres = var->yres;
yres = var->xres;
} else {
xres = var->xres;
yres = var->yres;
}
if (ofbi->region->size)
omapfb_calc_addr(ofbi, var, fix, rotation,
&data_start_p, &data_start_v);
r = omapfb_mode_to_dss_mode(var, &mode);
if (r)
goto err;
switch (var->nonstd) {
case OMAPFB_COLOR_YUV422:
case OMAPFB_COLOR_YUY422:
if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) {
screen_width = fix->line_length
/ (var->bits_per_pixel >> 2);
break;
}
default:
screen_width = fix->line_length / (var->bits_per_pixel >> 3);
break;
}
ovl->get_overlay_info(ovl, &info);
if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB)
mirror = 0;
else
mirror = ofbi->mirror;
info.paddr = data_start_p;
info.vaddr = data_start_v;
info.screen_width = screen_width;
info.width = xres;
info.height = yres;
info.color_mode = mode;
info.rotation_type = ofbi->rotation_type;
info.rotation = rotation;
info.mirror = mirror;
info.pos_x = posx;
info.pos_y = posy;
info.out_width = outw;
info.out_height = outh;
r = ovl->set_overlay_info(ovl, &info);
if (r)
goto err;
return 0;
err:
return r;
}
/* apply var to the overlay */
int omapfb_apply_changes(struct fb_info *fbi, int init)
{
int r = 0;
struct omapfb_info *ofbi = FB2OFB(fbi);
struct fb_var_screeninfo *var = &fbi->var;
struct omap_overlay *ovl;
u16 posx, posy;
u16 outw, outh;
int i;
struct omap_dss_device *display = fb2display(fbi);
#ifdef DEBUG
if (omapfb_test_pattern)
fill_fb(fbi);
#endif
WARN_ON(!atomic_read(&ofbi->region->lock_count));
for (i = 0; i < ofbi->num_overlays; i++) {
ovl = ofbi->overlays[i];
if (ofbi->region->size == 0) {
/* the fb is not available. disable the overlay */
omapfb_overlay_enable(ovl, 0);
if (!init && ovl->manager)
ovl->manager->apply(ovl->manager);
continue;
}
if (init || (ovl->caps & OMAP_DSS_OVL_CAP_SCALE) == 0) {
u16 p_width , p_height;
int rotation = (var->rotate + ofbi->rotation[i]) % 4;
p_width = var->xres;
p_height = var->yres;
if (display->driver->get_resolution)
display->driver->get_resolution(display,
&p_width, &p_height);
if (rotation == FB_ROTATE_CW ||
rotation == FB_ROTATE_CCW) {
outw = p_height;
outh = p_width;
} else {
outw = p_width;
outh = p_height;
}
} else {
outw = ovl->info.out_width;
outh = ovl->info.out_height;
}
if (init) {
posx = 0;
posy = 0;
} else {
posx = ovl->info.pos_x;
posy = ovl->info.pos_y;
}
r = omapfb_setup_overlay(fbi, ovl, posx, posy, outw, outh);
if (r)
goto err;
if (!init && ovl->manager) {
struct omap_dss_device *dev;
struct omap_dss_driver *drv;
ovl->manager->apply(ovl->manager);
drv = ovl->manager->device->driver;
dev = ovl->manager->device;
if (dev->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE &&
drv->get_update_mode(dev) != OMAP_DSS_UPDATE_AUTO)
return drv->update(dev, 0, 0,
dev->panel.timings.x_res,
dev->panel.timings.y_res);
}
}
return 0;
err:
return r;
}
/* checks var and eventually tweaks it to something supported,
* DO NOT MODIFY PAR */
static int omapfb_check_var(struct fb_var_screeninfo *var, struct fb_info *fbi)
{
struct omapfb_info *ofbi = FB2OFB(fbi);
int r;
omapfb_get_mem_region(ofbi->region);
r = check_fb_var(fbi, var);
omapfb_put_mem_region(ofbi->region);
return r;
}
void omapfb_fb2dss_timings(struct fb_videomode *fb_timings,
struct omap_video_timings *dss_timings)
{
dss_timings->x_res = fb_timings->xres;
dss_timings->y_res = fb_timings->yres;
if (fb_timings->vmode & FB_VMODE_INTERLACED)
dss_timings->y_res /= 2;
dss_timings->pixel_clock = fb_timings->pixclock ?
PICOS2KHZ(fb_timings->pixclock) : 0;
dss_timings->hfp = fb_timings->right_margin;
dss_timings->hbp = fb_timings->left_margin;
dss_timings->hsw = fb_timings->hsync_len;
dss_timings->vfp = fb_timings->lower_margin;
dss_timings->vbp = fb_timings->upper_margin;
dss_timings->vsw = fb_timings->vsync_len;
}
EXPORT_SYMBOL(omapfb_fb2dss_timings);
void omapfb_dss2fb_timings(struct omap_video_timings *dss_timings,
struct fb_videomode *fb_timings)
{
memset(fb_timings, 0, sizeof(*fb_timings));
fb_timings->xres = dss_timings->x_res;
fb_timings->yres = dss_timings->y_res;
fb_timings->pixclock = dss_timings->pixel_clock ?
KHZ2PICOS(dss_timings->pixel_clock) : 0;
fb_timings->right_margin = dss_timings->hfp;
fb_timings->left_margin = dss_timings->hbp;
fb_timings->hsync_len = dss_timings->hsw;
fb_timings->lower_margin = dss_timings->vfp;
fb_timings->upper_margin = dss_timings->vbp;
fb_timings->vsync_len = dss_timings->vsw;
}
EXPORT_SYMBOL(omapfb_dss2fb_timings);
/* set the video mode according to info->var */
static int omapfb_set_par(struct fb_info *fbi)
{
struct omapfb_info *ofbi = FB2OFB(fbi);
int r;
omapfb_get_mem_region(ofbi->region);
set_fb_fix(fbi);
r = setup_vrfb_rotation(fbi);
if (r)
goto out;
r = omapfb_apply_changes(fbi, 0);
out:
omapfb_put_mem_region(ofbi->region);
return r;
}
static int omapfb_pan_display(struct fb_var_screeninfo *var,
struct fb_info *fbi)
{
struct omapfb_info *ofbi = FB2OFB(fbi);
struct fb_var_screeninfo new_var;
int r;
if (var->xoffset == fbi->var.xoffset &&
var->yoffset == fbi->var.yoffset)
return 0;
new_var = fbi->var;
new_var.xoffset = var->xoffset;
new_var.yoffset = var->yoffset;
fbi->var = new_var;
omapfb_get_mem_region(ofbi->region);
r = omapfb_apply_changes(fbi, 0);
omapfb_put_mem_region(ofbi->region);
return r;
}
static void mmap_user_open(struct vm_area_struct *vma)
{
struct omapfb2_mem_region *rg = vma->vm_private_data;
omapfb_get_mem_region(rg);
atomic_inc(&rg->map_count);
omapfb_put_mem_region(rg);
}
static void mmap_user_close(struct vm_area_struct *vma)
{
struct omapfb2_mem_region *rg = vma->vm_private_data;
omapfb_get_mem_region(rg);
atomic_dec(&rg->map_count);
omapfb_put_mem_region(rg);
}
static struct vm_operations_struct mmap_user_ops = {
.open = mmap_user_open,
.close = mmap_user_close,
};
static int omapfb_mmap(struct fb_info *fbi, struct vm_area_struct *vma)
{
struct omapfb_info *ofbi = FB2OFB(fbi);
struct fb_fix_screeninfo *fix = &fbi->fix;
struct omapfb2_mem_region *rg;
unsigned long off;
unsigned long start;
u32 len;
int r = -EINVAL;
if (vma->vm_end - vma->vm_start == 0)
return 0;
if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT))
return -EINVAL;
off = vma->vm_pgoff << PAGE_SHIFT;
rg = omapfb_get_mem_region(ofbi->region);
start = omapfb_get_region_paddr(ofbi);
len = fix->smem_len;
if (off >= len)
goto error;
if ((vma->vm_end - vma->vm_start + off) > len)
goto error;
off += start;
vma->vm_pgoff = off >> PAGE_SHIFT;
vma->vm_flags |= VM_IO | VM_RESERVED;
vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
vma->vm_ops = &mmap_user_ops;
vma->vm_private_data = rg;
if (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT,
vma->vm_end - vma->vm_start,
vma->vm_page_prot)) {
r = -EAGAIN;
goto error;
}
/* vm_ops.open won't be called for mmap itself. */
atomic_inc(&rg->map_count);
omapfb_put_mem_region(rg);
return 0;
error:
omapfb_put_mem_region(ofbi->region);
return r;
}
/* Store a single color palette entry into a pseudo palette or the hardware
* palette if one is available. For now we support only 16bpp and thus store
* the entry only to the pseudo palette.
*/
static int _setcolreg(struct fb_info *fbi, u_int regno, u_int red, u_int green,
u_int blue, u_int transp, int update_hw_pal)
{
/*struct omapfb_info *ofbi = FB2OFB(fbi);*/
/*struct omapfb2_device *fbdev = ofbi->fbdev;*/
struct fb_var_screeninfo *var = &fbi->var;
int r = 0;
enum omapfb_color_format mode = OMAPFB_COLOR_RGB24U; /* XXX */
/*switch (plane->color_mode) {*/
switch (mode) {
case OMAPFB_COLOR_YUV422:
case OMAPFB_COLOR_YUV420:
case OMAPFB_COLOR_YUY422:
r = -EINVAL;
break;
case OMAPFB_COLOR_CLUT_8BPP:
case OMAPFB_COLOR_CLUT_4BPP:
case OMAPFB_COLOR_CLUT_2BPP:
case OMAPFB_COLOR_CLUT_1BPP:
/*
if (fbdev->ctrl->setcolreg)
r = fbdev->ctrl->setcolreg(regno, red, green, blue,
transp, update_hw_pal);
*/
/* Fallthrough */
r = -EINVAL;
break;
case OMAPFB_COLOR_RGB565:
case OMAPFB_COLOR_RGB444:
case OMAPFB_COLOR_RGB24P:
case OMAPFB_COLOR_RGB24U:
if (r != 0)
break;
if (regno < 16) {
u16 pal;
pal = ((red >> (16 - var->red.length)) <<
var->red.offset) |
((green >> (16 - var->green.length)) <<
var->green.offset) |
(blue >> (16 - var->blue.length));
((u32 *)(fbi->pseudo_palette))[regno] = pal;
}
break;
default:
BUG();
}
return r;
}
static int omapfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *info)
{
return _setcolreg(info, regno, red, green, blue, transp, 1);
}
static int omapfb_setcmap(struct fb_cmap *cmap, struct fb_info *info)
{
int count, index, r;
u16 *red, *green, *blue, *transp;
u16 trans = 0xffff;
red = cmap->red;
green = cmap->green;
blue = cmap->blue;
transp = cmap->transp;
index = cmap->start;
for (count = 0; count < cmap->len; count++) {
if (transp)
trans = *transp++;
r = _setcolreg(info, index++, *red++, *green++, *blue++, trans,
count == cmap->len - 1);
if (r != 0)
return r;
}
return 0;
}
static int omapfb_blank(int blank, struct fb_info *fbi)
{
struct omapfb_info *ofbi = FB2OFB(fbi);
struct omapfb2_device *fbdev = ofbi->fbdev;
struct omap_dss_device *display = fb2display(fbi);
int r = 0;
if (!display)
return -EINVAL;
omapfb_lock(fbdev);
switch (blank) {
case FB_BLANK_UNBLANK:
if (display->state == OMAP_DSS_DISPLAY_SUSPENDED) {
if (display->driver->resume)
r = display->driver->resume(display);
} else if (display->state == OMAP_DSS_DISPLAY_DISABLED) {
if (display->driver->enable)
r = display->driver->enable(display);
}
if (fbdev->vsync_active &&
(display->state == OMAP_DSS_DISPLAY_ACTIVE))
omapfb_enable_vsync(fbdev, display->channel, true);
break;
case FB_BLANK_NORMAL:
/* FB_BLANK_NORMAL could be implemented.
* Needs DSS additions. */
case FB_BLANK_VSYNC_SUSPEND:
case FB_BLANK_HSYNC_SUSPEND:
case FB_BLANK_POWERDOWN:
if (fbdev->vsync_active)
omapfb_enable_vsync(fbdev, display->channel, false);
if (display->state != OMAP_DSS_DISPLAY_ACTIVE)
goto exit;
if (display->driver->suspend)
r = display->driver->suspend(display);
else if (display->driver->disable)
display->driver->disable(display);
break;
default:
r = -EINVAL;
}
exit:
omapfb_unlock(fbdev);
return r;
}
static struct fb_ops omapfb_ops = {
.owner = THIS_MODULE,
.fb_open = omapfb_open,
.fb_release = omapfb_release,
.fb_fillrect = cfb_fillrect,
.fb_copyarea = cfb_copyarea,
.fb_imageblit = cfb_imageblit,
.fb_blank = omapfb_blank,
.fb_ioctl = omapfb_ioctl,
.fb_check_var = omapfb_check_var,
.fb_set_par = omapfb_set_par,
.fb_pan_display = omapfb_pan_display,
.fb_mmap = omapfb_mmap,
.fb_setcolreg = omapfb_setcolreg,
.fb_setcmap = omapfb_setcmap,
/*.fb_write = omapfb_write,*/
};
static void omapfb_free_fbmem(struct fb_info *fbi)
{
struct omapfb_info *ofbi = FB2OFB(fbi);
struct omapfb2_device *fbdev = ofbi->fbdev;
struct omapfb2_mem_region *rg;
rg = ofbi->region;
if (rg->paddr)
if (omap_vram_free(rg->paddr, rg->size))
dev_err(fbdev->dev, "VRAM FREE failed\n");
if (rg->vaddr)
iounmap(rg->vaddr);
if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) {
/* unmap the 0 angle rotation */
if (rg->vrfb.vaddr[0]) {
iounmap(rg->vrfb.vaddr[0]);
omap_vrfb_release_ctx(&rg->vrfb);
rg->vrfb.vaddr[0] = NULL;
}
}
rg->vaddr = NULL;
rg->paddr = 0;
rg->alloc = 0;
rg->size = 0;
}
static void clear_fb_info(struct fb_info *fbi)
{
memset(&fbi->var, 0, sizeof(fbi->var));
memset(&fbi->fix, 0, sizeof(fbi->fix));
strlcpy(fbi->fix.id, MODULE_NAME, sizeof(fbi->fix.id));
}
static int omapfb_free_all_fbmem(struct omapfb2_device *fbdev)
{
int i;
for (i = 0; i < fbdev->num_fbs; i++) {
struct fb_info *fbi = fbdev->fbs[i];
omapfb_free_fbmem(fbi);
clear_fb_info(fbi);
}
return 0;
}
static int omapfb_alloc_fbmem(struct fb_info *fbi, unsigned long size,
unsigned long paddr)
{
struct omapfb_info *ofbi = FB2OFB(fbi);
struct omapfb2_device *fbdev = ofbi->fbdev;
struct omapfb2_mem_region *rg;
void __iomem *vaddr;
int r;
rg = ofbi->region;
rg->paddr = 0;
rg->vaddr = NULL;
memset(&rg->vrfb, 0, sizeof rg->vrfb);
rg->size = 0;
rg->type = 0;
rg->alloc = false;
rg->map = false;
size = PAGE_ALIGN(size);
if (!paddr) {
r = omap_vram_alloc(OMAP_VRAM_MEMTYPE_SDRAM, size, &paddr);
} else {
r = omap_vram_reserve(paddr, size);
}
if (r) {
dev_err(fbdev->dev, "failed to allocate framebuffer\n");
return -ENOMEM;
}
if (ofbi->rotation_type != OMAP_DSS_ROT_VRFB) {
vaddr = ioremap_wc(paddr, size);
if (!vaddr) {
dev_err(fbdev->dev, "failed to ioremap framebuffer\n");
omap_vram_free(paddr, size);
return -ENOMEM;
}
} else {
r = omap_vrfb_request_ctx(&rg->vrfb);
if (r) {
dev_err(fbdev->dev, "vrfb create ctx failed\n");
return r;
}
vaddr = NULL;
}
rg->paddr = paddr;
rg->vaddr = vaddr;
rg->size = size;
rg->alloc = 1;
return 0;
}
/* allocate fbmem using display resolution as reference */
static int omapfb_alloc_fbmem_display(struct fb_info *fbi, unsigned long size,
unsigned long paddr)
{
struct omapfb_info *ofbi = FB2OFB(fbi);
struct omapfb2_device *fbdev = ofbi->fbdev;
struct omap_dss_device *display;
int bytespp;
display = fb2display(fbi);
if (!display)
return 0;
switch (omapfb_get_recommended_bpp(fbdev, display)) {
case 16:
bytespp = 2;
break;
case 24:
bytespp = 4;
break;
default:
bytespp = 4;
break;
}
if (!size) {
u16 w, h;
get_fb_resolution(display, &w, &h);
if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) {
size = max(omap_vrfb_min_phys_size(w, h, bytespp),
omap_vrfb_min_phys_size(h, w, bytespp));
} else {
size = w * h * bytespp;
}
}
if (!size)
return 0;
return omapfb_alloc_fbmem(fbi, size, paddr);
}
static enum omap_color_mode fb_format_to_dss_mode(enum omapfb_color_format fmt)
{
enum omap_color_mode mode;
switch (fmt) {
case OMAPFB_COLOR_RGB565:
mode = OMAP_DSS_COLOR_RGB16;
break;
case OMAPFB_COLOR_YUV422:
mode = OMAP_DSS_COLOR_YUV2;
break;
case OMAPFB_COLOR_CLUT_8BPP:
mode = OMAP_DSS_COLOR_CLUT8;
break;
case OMAPFB_COLOR_CLUT_4BPP:
mode = OMAP_DSS_COLOR_CLUT4;
break;
case OMAPFB_COLOR_CLUT_2BPP:
mode = OMAP_DSS_COLOR_CLUT2;
break;
case OMAPFB_COLOR_CLUT_1BPP:
mode = OMAP_DSS_COLOR_CLUT1;
break;
case OMAPFB_COLOR_RGB444:
mode = OMAP_DSS_COLOR_RGB12U;
break;
case OMAPFB_COLOR_YUY422:
mode = OMAP_DSS_COLOR_UYVY;
break;
case OMAPFB_COLOR_ARGB16:
mode = OMAP_DSS_COLOR_ARGB16;
break;
case OMAPFB_COLOR_RGB24U:
mode = OMAP_DSS_COLOR_RGB24U;
break;
case OMAPFB_COLOR_RGB24P:
mode = OMAP_DSS_COLOR_RGB24P;
break;
case OMAPFB_COLOR_ARGB32:
mode = OMAP_DSS_COLOR_ARGB32;
break;
case OMAPFB_COLOR_RGBA32:
mode = OMAP_DSS_COLOR_RGBA32;
break;
case OMAPFB_COLOR_RGBX32:
mode = OMAP_DSS_COLOR_RGBX32;
break;
default:
mode = -EINVAL;
}
return mode;
}
static int omapfb_parse_vram_param(const char *param, int max_entries,
unsigned long *sizes, unsigned long *paddrs)
{
int fbnum;
unsigned long size;
unsigned long paddr = 0;
char *p, *start;
start = (char *)param;
while (1) {
p = start;
fbnum = simple_strtoul(p, &p, 10);
if (p == param)
return -EINVAL;
if (*p != ':')
return -EINVAL;
if (fbnum >= max_entries)
return -EINVAL;
size = memparse(p + 1, &p);
if (!size)
return -EINVAL;
paddr = 0;
if (*p == '@') {
paddr = simple_strtoul(p + 1, &p, 16);
if (!paddr)
return -EINVAL;
}
paddrs[fbnum] = paddr;
sizes[fbnum] = size;
if (*p == 0)
break;
if (*p != ',')
return -EINVAL;
++p;
start = p;
}
return 0;
}
static int omapfb_allocate_all_fbs(struct omapfb2_device *fbdev)
{
int i, r;
unsigned long vram_sizes[10];
unsigned long vram_paddrs[10];
memset(&vram_sizes, 0, sizeof(vram_sizes));
memset(&vram_paddrs, 0, sizeof(vram_paddrs));
if (def_vram && omapfb_parse_vram_param(def_vram, 10,
vram_sizes, vram_paddrs)) {
dev_err(fbdev->dev, "failed to parse vram parameter\n");
memset(&vram_sizes, 0, sizeof(vram_sizes));
memset(&vram_paddrs, 0, sizeof(vram_paddrs));
}
if (fbdev->dev->platform_data) {
struct omapfb_platform_data *opd;
opd = fbdev->dev->platform_data;
for (i = 0; i < opd->mem_desc.region_cnt; ++i) {
if (!vram_sizes[i]) {
unsigned long size;
unsigned long paddr;
size = opd->mem_desc.region[i].size;
paddr = opd->mem_desc.region[i].paddr;
vram_sizes[i] = size;
vram_paddrs[i] = paddr;
}
}
}
for (i = 0; i < fbdev->num_fbs; i++) {
/* allocate memory automatically only for fb0, or if
* excplicitly defined with vram or plat data option */
if (i == 0 || vram_sizes[i] != 0) {
r = omapfb_alloc_fbmem_display(fbdev->fbs[i],
vram_sizes[i], vram_paddrs[i]);
if (r)
return r;
}
}
for (i = 0; i < fbdev->num_fbs; i++) {
struct omapfb_info *ofbi = FB2OFB(fbdev->fbs[i]);
struct omapfb2_mem_region *rg;
rg = ofbi->region;
}
return 0;
}
int omapfb_realloc_fbmem(struct fb_info *fbi, unsigned long size, int type)
{
struct omapfb_info *ofbi = FB2OFB(fbi);
struct omapfb2_device *fbdev = ofbi->fbdev;
struct omap_dss_device *display = fb2display(fbi);
struct omapfb2_mem_region *rg = ofbi->region;
unsigned long old_size = rg->size;
unsigned long old_paddr = rg->paddr;
int old_type = rg->type;
int r;
if (type > OMAPFB_MEMTYPE_MAX)
return -EINVAL;
size = PAGE_ALIGN(size);
if (old_size == size && old_type == type)
return 0;
if (display && display->driver->sync)
display->driver->sync(display);
omapfb_free_fbmem(fbi);
if (size == 0) {
clear_fb_info(fbi);
return 0;
}
r = omapfb_alloc_fbmem(fbi, size, 0);
if (r) {
if (old_size)
omapfb_alloc_fbmem(fbi, old_size, old_paddr);
if (rg->size == 0)
clear_fb_info(fbi);
return r;
}
if (old_size == size)
return 0;
if (old_size == 0) {
r = omapfb_fb_init(fbdev, fbi);
if (r)
goto err;
r = omapfb_apply_changes(fbi, 1);
if (r)
goto err;
} else {
struct fb_var_screeninfo new_var;
memcpy(&new_var, &fbi->var, sizeof(new_var));
r = check_fb_var(fbi, &new_var);
if (r)
goto err;
memcpy(&fbi->var, &new_var, sizeof(fbi->var));
set_fb_fix(fbi);
r = setup_vrfb_rotation(fbi);
if (r)
goto err;
}
return 0;
err:
omapfb_free_fbmem(fbi);
clear_fb_info(fbi);
return r;
}
/* initialize fb_info, var, fix to something sane based on the display */
static int omapfb_fb_init(struct omapfb2_device *fbdev, struct fb_info *fbi)
{
struct fb_var_screeninfo *var = &fbi->var;
struct omap_dss_device *display = fb2display(fbi);
struct omapfb_info *ofbi = FB2OFB(fbi);
int r = 0;
fbi->fbops = &omapfb_ops;
fbi->flags = FBINFO_FLAG_DEFAULT;
fbi->pseudo_palette = fbdev->pseudo_palette;
if (ofbi->region->size == 0) {
clear_fb_info(fbi);
return 0;
}
var->nonstd = 0;
var->bits_per_pixel = 0;
var->rotate = def_rotate;
/*
* Check if there is a default color format set in the board file,
* and use this format instead the default deducted from the
* display bpp.
*/
if (fbdev->dev->platform_data) {
struct omapfb_platform_data *opd;
int id = ofbi->id;
opd = fbdev->dev->platform_data;
if (opd->mem_desc.region[id].format_used) {
enum omap_color_mode mode;
enum omapfb_color_format format;
format = opd->mem_desc.region[id].format;
mode = fb_format_to_dss_mode(format);
if (mode < 0) {
r = mode;
goto err;
}
r = dss_mode_to_fb_mode(mode, var);
if (r < 0)
goto err;
}
}
if (display) {
u16 w, h;
int rotation = (var->rotate + ofbi->rotation[0]) % 4;
get_fb_resolution(display, &w, &h);
if (rotation == FB_ROTATE_CW ||
rotation == FB_ROTATE_CCW) {
var->xres = h;
var->yres = w;
} else {
var->xres = w;
var->yres = h;
}
var->xres_virtual = var->xres;
var->yres_virtual = var->yres;
if (!var->bits_per_pixel) {
switch (omapfb_get_recommended_bpp(fbdev, display)) {
case 16:
var->bits_per_pixel = 16;
break;
case 24:
var->bits_per_pixel = 32;
break;
default:
dev_err(fbdev->dev, "illegal display "
"bpp\n");
return -EINVAL;
}
}
} else {
/* if there's no display, let's just guess some basic values */
var->xres = 320;
var->yres = 240;
var->xres_virtual = var->xres;
var->yres_virtual = var->yres;
if (!var->bits_per_pixel)
var->bits_per_pixel = 16;
}
r = check_fb_var(fbi, var);
if (r)
goto err;
set_fb_fix(fbi);
r = setup_vrfb_rotation(fbi);
if (r)
goto err;
r = fb_alloc_cmap(&fbi->cmap, 256, 0);
if (r)
dev_err(fbdev->dev, "unable to allocate color map memory\n");
err:
return r;
}
static void fbinfo_cleanup(struct omapfb2_device *fbdev, struct fb_info *fbi)
{
fb_dealloc_cmap(&fbi->cmap);
}
static void omapfb_free_resources(struct omapfb2_device *fbdev)
{
int i;
if (fbdev == NULL)
return;
for (i = 0; i < fbdev->num_fbs; i++)
unregister_framebuffer(fbdev->fbs[i]);
/* free the reserved fbmem */
omapfb_free_all_fbmem(fbdev);
for (i = 0; i < fbdev->num_fbs; i++) {
fbinfo_cleanup(fbdev, fbdev->fbs[i]);
framebuffer_release(fbdev->fbs[i]);
}
for (i = 0; i < fbdev->num_displays; i++) {
if (fbdev->displays[i]->state != OMAP_DSS_DISPLAY_DISABLED)
fbdev->displays[i]->driver->disable(fbdev->displays[i]);
omap_dss_put_device(fbdev->displays[i]);
}
dev_set_drvdata(fbdev->dev, NULL);
kfree(fbdev);
}
static int omapfb_create_framebuffers(struct omapfb2_device *fbdev)
{
int r, i;
fbdev->num_fbs = 0;
/* allocate fb_infos */
for (i = 0; i < CONFIG_FB_OMAP2_NUM_FBS; i++) {
struct fb_info *fbi;
struct omapfb_info *ofbi;
fbi = framebuffer_alloc(sizeof(struct omapfb_info),
fbdev->dev);
if (fbi == NULL) {
dev_err(fbdev->dev,
"unable to allocate memory for plane info\n");
return -ENOMEM;
}
clear_fb_info(fbi);
fbdev->fbs[i] = fbi;
ofbi = FB2OFB(fbi);
ofbi->fbdev = fbdev;
ofbi->id = i;
ofbi->region = &fbdev->regions[i];
ofbi->region->id = i;
init_rwsem(&ofbi->region->lock);
/* assign these early, so that fb alloc can use them */
ofbi->rotation_type = def_vrfb ? OMAP_DSS_ROT_VRFB :
OMAP_DSS_ROT_DMA;
ofbi->mirror = def_mirror;
fbdev->num_fbs++;
}
/* assign overlays for the fbs */
for (i = 0; i < min(fbdev->num_fbs, fbdev->num_overlays); i++) {
struct omapfb_info *ofbi = FB2OFB(fbdev->fbs[i]);
ofbi->overlays[0] = fbdev->overlays[i];
ofbi->num_overlays = 1;
}
/* allocate fb memories */
r = omapfb_allocate_all_fbs(fbdev);
if (r) {
dev_err(fbdev->dev, "failed to allocate fbmem\n");
return r;
}
/* setup fb_infos */
for (i = 0; i < fbdev->num_fbs; i++) {
struct fb_info *fbi = fbdev->fbs[i];
struct omapfb_info *ofbi = FB2OFB(fbi);
omapfb_get_mem_region(ofbi->region);
r = omapfb_fb_init(fbdev, fbi);
omapfb_put_mem_region(ofbi->region);
if (r) {
dev_err(fbdev->dev, "failed to setup fb_info\n");
return r;
}
}
for (i = 0; i < fbdev->num_fbs; i++) {
r = register_framebuffer(fbdev->fbs[i]);
if (r != 0) {
dev_err(fbdev->dev, "registering framebuffer %d failed\n", i);
return r;
}
}
for (i = 0; i < fbdev->num_fbs; i++) {
struct fb_info *fbi = fbdev->fbs[i];
struct omapfb_info *ofbi = FB2OFB(fbi);
omapfb_get_mem_region(ofbi->region);
r = omapfb_apply_changes(fbi, 1);
omapfb_put_mem_region(ofbi->region);
if (r) {
dev_err(fbdev->dev, "failed to change mode\n");
return r;
}
}
/* Enable fb0 */
if (fbdev->num_fbs > 0) {
struct omapfb_info *ofbi = FB2OFB(fbdev->fbs[0]);
if (ofbi->num_overlays > 0) {
struct omap_overlay *ovl = ofbi->overlays[0];
r = omapfb_overlay_enable(ovl, 1);
if (r) {
dev_err(fbdev->dev, "failed to enable overlay\n");
return r;
}
}
}
return 0;
}
static int omapfb_mode_to_timings(const char *mode_str,
struct omap_video_timings *timings, u8 *bpp)
{
struct fb_info *fbi;
struct fb_var_screeninfo *var;
struct fb_ops *fbops;
int r;
#ifdef CONFIG_OMAP2_DSS_VENC
if (strcmp(mode_str, "pal") == 0) {
*timings = omap_dss_pal_timings;
*bpp = 24;
return 0;
} else if (strcmp(mode_str, "ntsc") == 0) {
*timings = omap_dss_ntsc_timings;
*bpp = 24;
return 0;
}
#endif
/* this is quite a hack, but I wanted to use the modedb and for
* that we need fb_info and var, so we create dummy ones */
*bpp = 0;
fbi = NULL;
var = NULL;
fbops = NULL;
fbi = kzalloc(sizeof(*fbi), GFP_KERNEL);
if (fbi == NULL) {
r = -ENOMEM;
goto err;
}
var = kzalloc(sizeof(*var), GFP_KERNEL);
if (var == NULL) {
r = -ENOMEM;
goto err;
}
fbops = kzalloc(sizeof(*fbops), GFP_KERNEL);
if (fbops == NULL) {
r = -ENOMEM;
goto err;
}
fbi->fbops = fbops;
r = fb_find_mode(var, fbi, mode_str, NULL, 0, NULL, 24);
if (r == 0) {
r = -EINVAL;
goto err;
}
timings->pixel_clock = PICOS2KHZ(var->pixclock);
timings->hbp = var->left_margin;
timings->hfp = var->right_margin;
timings->vbp = var->upper_margin;
timings->vfp = var->lower_margin;
timings->hsw = var->hsync_len;
timings->vsw = var->vsync_len;
timings->x_res = var->xres;
timings->y_res = var->yres;
switch (var->bits_per_pixel) {
case 16:
*bpp = 16;
break;
case 24:
case 32:
default:
*bpp = 24;
break;
}
r = 0;
err:
kfree(fbi);
kfree(var);
kfree(fbops);
return r;
}
static int omapfb_set_def_mode(struct omapfb2_device *fbdev,
struct omap_dss_device *display, char *mode_str)
{
int r;
u8 bpp;
struct omap_video_timings timings, temp_timings;
r = omapfb_mode_to_timings(mode_str, &timings, &bpp);
if (r)
return r;
fbdev->bpp_overrides[fbdev->num_bpp_overrides].dssdev = display;
fbdev->bpp_overrides[fbdev->num_bpp_overrides].bpp = bpp;
++fbdev->num_bpp_overrides;
if (display->driver->check_timings) {
r = display->driver->check_timings(display, &timings);
if (r)
return r;
} else {
/* If check_timings is not present compare xres and yres */
if (display->driver->get_timings) {
display->driver->get_timings(display, &temp_timings);
if (temp_timings.x_res != timings.x_res ||
temp_timings.y_res != timings.y_res)
return -EINVAL;
}
}
if (display->driver->set_timings)
display->driver->set_timings(display, &timings);
return 0;
}
static int omapfb_get_recommended_bpp(struct omapfb2_device *fbdev,
struct omap_dss_device *dssdev)
{
int i;
BUG_ON(dssdev->driver->get_recommended_bpp == NULL);
for (i = 0; i < fbdev->num_bpp_overrides; ++i) {
if (dssdev == fbdev->bpp_overrides[i].dssdev)
return fbdev->bpp_overrides[i].bpp;
}
return dssdev->driver->get_recommended_bpp(dssdev);
}
static int omapfb_parse_def_modes(struct omapfb2_device *fbdev)
{
char *str, *options, *this_opt;
int r = 0;
str = kstrdup(def_mode, GFP_KERNEL);
if (!str)
return -ENOMEM;
options = str;
while (!r && (this_opt = strsep(&options, ",")) != NULL) {
char *p, *display_str, *mode_str;
struct omap_dss_device *display;
int i;
p = strchr(this_opt, ':');
if (!p) {
r = -EINVAL;
break;
}
*p = 0;
display_str = this_opt;
mode_str = p + 1;
display = NULL;
for (i = 0; i < fbdev->num_displays; ++i) {
if (strcmp(fbdev->displays[i]->name,
display_str) == 0) {
display = fbdev->displays[i];
break;
}
}
if (!display) {
r = -EINVAL;
break;
}
r = omapfb_set_def_mode(fbdev, display, mode_str);
if (r)
break;
}
kfree(str);
return r;
}
static int omapfb_init_display(struct omapfb2_device *fbdev,
struct omap_dss_device *dssdev)
{
struct omap_dss_driver *dssdrv = dssdev->driver;
int r;
if (dssdev->state == OMAP_DSS_DISPLAY_DISABLED) {
r = dssdrv->enable(dssdev);
if (r) {
dev_warn(fbdev->dev, "Failed to enable display '%s'\n",
dssdev->name);
return r;
}
}
if (dssdev->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE) {
u16 w, h;
if (dssdrv->enable_te) {
r = dssdrv->enable_te(dssdev, 1);
if (r) {
dev_err(fbdev->dev, "Failed to set TE\n");
return r;
}
}
if (dssdrv->set_update_mode) {
r = dssdrv->set_update_mode(dssdev,
OMAP_DSS_UPDATE_MANUAL);
if (r) {
dev_err(fbdev->dev,
"Failed to set update mode\n");
return r;
}
}
dssdrv->get_resolution(dssdev, &w, &h);
r = dssdrv->update(dssdev, 0, 0, w, h);
if (r) {
dev_err(fbdev->dev,
"Failed to update display\n");
return r;
}
} else {
if (dssdrv->set_update_mode) {
r = dssdrv->set_update_mode(dssdev,
OMAP_DSS_UPDATE_AUTO);
if (r) {
dev_err(fbdev->dev,
"Failed to set update mode\n");
return r;
}
}
}
return 0;
}
#ifdef CONFIG_FB_OMAP2_VSYNC_SYSFS
static ssize_t omapfb_vsync_time(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct omapfb2_device *fbdev = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%llu", ktime_to_ns(fbdev->vsync_timestamp));
}
static DEVICE_ATTR(vsync_time, S_IRUGO, omapfb_vsync_time, NULL);
#endif
#ifdef CONFIG_FB_OMAP2_VSYNC_SEND_UEVENTS
static ssize_t omapfb_vsync_mode_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
int t_mode;
t_mode = sprintf(buf, "%d\n", i_event_mode);
return t_mode;
}
ssize_t omapfb_vsync_mode_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size)
{
int t_mode;
if (kstrtoint(buf, 0, &t_mode)) {
pr_err("failed storing vsync_mode value\n");
return i_event_mode;
}
if (t_mode == 0 || t_mode == 1)
i_event_mode = t_mode;
return t_mode;
}
static DEVICE_ATTR(vsync_mode, S_IRUGO | S_IWUSR, omapfb_vsync_mode_show,
omapfb_vsync_mode_store);
#endif
static void omapfb_send_vsync_work(struct work_struct *work)
{
struct omapfb2_device *fbdev =
container_of(work, typeof(*fbdev), vsync_work);
#ifdef CONFIG_FB_OMAP2_VSYNC_SEND_UEVENTS
if (i_event_mode == 1) {
char buf[64];
char *envp[2];
snprintf(buf, sizeof(buf), "VSYNC=%llu",
ktime_to_ns(fbdev->vsync_timestamp));
envp[0] = buf;
envp[1] = NULL;
kobject_uevent_env(&fbdev->dev->kobj, KOBJ_CHANGE, envp);
}
#endif
#ifdef CONFIG_FB_OMAP2_VSYNC_SYSFS
sysfs_notify(&fbdev->dev->kobj, NULL, "vsync_time");
#endif
}
static void omapfb_vsync_isr(void *data, u32 mask)
{
struct omapfb2_device *fbdev = data;
fbdev->vsync_timestamp = ktime_get();
schedule_work(&fbdev->vsync_work);
}
int omapfb_enable_vsync(struct omapfb2_device *fbdev, enum omap_channel ch,
bool enable)
{
int r = 0;
const u32 masks[] = {
DISPC_IRQ_VSYNC,
DISPC_IRQ_EVSYNC_EVEN,
DISPC_IRQ_VSYNC2
};
if (ch > OMAP_DSS_CHANNEL_LCD2) {
pr_warn("%s wrong channel number\n", __func__);
return -ENODEV;
}
if (enable)
r = omap_dispc_register_isr(omapfb_vsync_isr, fbdev,
masks[ch]);
else
r = omap_dispc_unregister_isr(omapfb_vsync_isr, fbdev,
masks[ch]);
return r;
}
static int omapfb_probe(struct platform_device *pdev)
{
struct omapfb2_device *fbdev = NULL;
int r = 0;
int i;
struct omap_overlay *ovl;
struct omap_dss_device *def_display;
struct omap_dss_device *dssdev;
u16 fb_ov_start_ix = 0;
if (pdev->num_resources != 0) {
dev_err(&pdev->dev, "probed for an unknown device\n");
r = -ENODEV;
goto err0;
}
fbdev = kzalloc(sizeof(struct omapfb2_device), GFP_KERNEL);
if (fbdev == NULL) {
r = -ENOMEM;
goto err0;
}
/* TODO : Replace cpu check with omap_has_vrfb once HAS_FEATURE
* available for OMAP2 and OMAP3
*/
if (def_vrfb && !cpu_is_omap24xx() && !cpu_is_omap34xx()) {
def_vrfb = 0;
dev_warn(&pdev->dev, "VRFB is not supported on this hardware, "
"ignoring the module parameter vrfb=y\n");
}
mutex_init(&fbdev->mtx);
fbdev->dev = &pdev->dev;
platform_set_drvdata(pdev, fbdev);
r = 0;
fbdev->num_displays = 0;
dssdev = NULL;
for_each_dss_dev(dssdev) {
omap_dss_get_device(dssdev);
if (!dssdev->driver) {
dev_err(&pdev->dev, "no driver for display\n");
r = -ENODEV;
}
fbdev->displays[fbdev->num_displays++] = dssdev;
}
if (r)
goto cleanup;
if (fbdev->num_displays == 0) {
dev_err(&pdev->dev, "no displays\n");
r = -EINVAL;
goto cleanup;
}
for (i = 0; i < fbdev->num_displays; i++)
initialize_dev_fb_resolution(i, fbdev->displays[i]);
fbdev->num_managers = omap_dss_get_num_overlay_managers();
for (i = 0; i < fbdev->num_managers; i++)
fbdev->managers[i] = omap_dss_get_overlay_manager(i);
if (def_mode && strlen(def_mode) > 0) {
if (omapfb_parse_def_modes(fbdev))
dev_warn(&pdev->dev, "cannot parse default modes\n");
}
/* All overlays are connected to default device at the start of boot.
See if index 0 device which is default needs scaling. If so dont
use GFX pipeline for FBs */
ovl = omap_dss_get_overlay(fb_ov_start_ix);
if (ovl->manager && ovl->manager->device) {
def_display = ovl->manager->device;
} else {
dev_warn(&pdev->dev, "cannot find default display\n");
def_display = NULL;
}
fbdev->num_overlays = omap_dss_get_num_overlays();
if (def_display && check_fb_scale(def_display)) {
fb_ov_start_ix = 1;
fbdev->num_overlays -= 1;
}
for (i = 0; i < fbdev->num_overlays; i++)
fbdev->overlays[i] = omap_dss_get_overlay(i+fb_ov_start_ix);
r = omapfb_create_framebuffers(fbdev);
if (r)
goto cleanup;
for (i = 0; i < fbdev->num_managers; i++) {
struct omap_overlay_manager *mgr;
mgr = fbdev->managers[i];
r = mgr->apply(mgr);
}
if (def_display) {
r = omapfb_init_display(fbdev, def_display);
if (r) {
dev_err(fbdev->dev,
"failed to initialize default "
"display\n");
goto cleanup;
}
}
r = omapfb_create_sysfs(fbdev);
if (r) {
dev_err(fbdev->dev, "failed to create sysfs entries\n");
goto cleanup;
}
#ifdef CONFIG_FB_OMAP2_VSYNC_SYSFS
r = device_create_file(fbdev->dev, &dev_attr_vsync_time);
if (r) {
dev_err(fbdev->dev, "failed to add sysfs entries\n");
goto cleanup;
}
#endif
#ifdef CONFIG_FB_OMAP2_VSYNC_SEND_UEVENTS
r = device_create_file(fbdev->dev, &dev_attr_vsync_mode);
if (r) {
dev_err(fbdev->dev, "failed to add sysfs entries\n");
goto cleanup;
}
#endif
INIT_WORK(&fbdev->vsync_work, omapfb_send_vsync_work);
return 0;
cleanup:
omapfb_free_resources(fbdev);
err0:
dev_err(&pdev->dev, "failed to setup omapfb\n");
return r;
}
static int omapfb_remove(struct platform_device *pdev)
{
struct omapfb2_device *fbdev = platform_get_drvdata(pdev);
omapfb_remove_sysfs(fbdev);
omapfb_free_resources(fbdev);
return 0;
}
static struct platform_driver omapfb_driver = {
.probe = omapfb_probe,
.remove = omapfb_remove,
.driver = {
.name = "omapfb",
.owner = THIS_MODULE,
},
};
static int __init omapfb_init(void)
{
if (platform_driver_register(&omapfb_driver)) {
printk(KERN_ERR "failed to register omapfb driver\n");
return -ENODEV;
}
return 0;
}
static void __exit omapfb_exit(void)
{
platform_driver_unregister(&omapfb_driver);
}
module_param_named(mode, def_mode, charp, 0);
module_param_named(vram, def_vram, charp, 0);
module_param_named(rotate, def_rotate, int, 0);
module_param_named(vrfb, def_vrfb, bool, 0);
module_param_named(mirror, def_mirror, bool, 0);
/* late_initcall to let panel/ctrl drivers loaded first.
* I guess better option would be a more dynamic approach,
* so that omapfb reacts to new panels when they are loaded */
late_initcall(omapfb_init);
/*module_init(omapfb_init);*/
module_exit(omapfb_exit);
MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@nokia.com>");
MODULE_DESCRIPTION("OMAP2/3 Framebuffer");
MODULE_LICENSE("GPL v2");
| 23.148638 | 79 | 0.669519 |
82e6a2a31d508d756db6b21ddf6683714981f0cc | 2,392 | h | C | src/Coin.h | alicedapp/wallet-core | 532034af30cc5a8f677c7f7b0d182e8198cf698d | [
"MIT"
] | 1 | 2020-10-27T17:27:04.000Z | 2020-10-27T17:27:04.000Z | src/Coin.h | katya559/wallet-core | a6856b9f99bdf7787fda162f3ae61b20ba9fea03 | [
"MIT"
] | null | null | null | src/Coin.h | katya559/wallet-core | a6856b9f99bdf7787fda162f3ae61b20ba9fea03 | [
"MIT"
] | 2 | 2020-01-08T14:28:22.000Z | 2020-01-21T15:46:52.000Z | // Copyright © 2017-2020 Trust Wallet.
//
// This file is part of Trust. The full Trust copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.
#pragma once
#include "Data.h"
#include "Hash.h"
#include "DerivationPath.h"
#include "PrivateKey.h"
#include "PublicKey.h"
#include <TrustWalletCore/TWBlockchain.h>
#include <TrustWalletCore/TWCoinType.h>
#include <TrustWalletCore/TWCurve.h>
#include <TrustWalletCore/TWHDVersion.h>
#include <TrustWalletCore/TWPurpose.h>
#include <string>
#include <set>
namespace TW {
/// Validates an address for a particular coin.
bool validateAddress(TWCoinType coin, const std::string& address);
/// Validates and normalizes an address for a particular coin.
std::string normalizeAddress(TWCoinType coin, const std::string& address);
/// Returns the blockchain for a coin type.
TWBlockchain blockchain(TWCoinType coin);
/// Returns the purpose for a coin type.
TWPurpose purpose(TWCoinType coin);
/// Returns the curve that should be used for a coin type.
TWCurve curve(TWCoinType coin);
/// Returns the xpub HD version that should be used for a coin type.
TWHDVersion xpubVersion(TWCoinType coin);
/// Returns the xprv HD version that should be used for a coin type.
TWHDVersion xprvVersion(TWCoinType coin);
/// Returns the default derivation path for a particular coin.
DerivationPath derivationPath(TWCoinType coin);
/// Returns the public key type for a particular coin.
enum TWPublicKeyType publicKeyType(TWCoinType coin);
/// Derives the address for a particular coin from the private key.
std::string deriveAddress(TWCoinType coin, const PrivateKey& privateKey);
/// Derives the address for a particular coin from the private key.
std::string deriveAddress(TWCoinType coin, const PublicKey& publicKey);
/// Hasher for deriving the public key hash.
Hash::Hasher publicKeyHasher(TWCoinType coin);
/// Hasher to use for base 58 checksums.
Hash::Hasher base58Hasher(TWCoinType coin);
/// Returns static prefix for a coin type.
byte staticPrefix(TWCoinType coin);
/// Returns P2PKH prefix for a coin type.
byte p2pkhPrefix(TWCoinType coin);
/// Returns P2SH prefix for a coin type.
byte p2shPrefix(TWCoinType coin);
/// Returns human readable part for a coin type.
enum TWHRP hrp(TWCoinType coin);
} // namespace TW
| 30.666667 | 77 | 0.771321 |
89dbbca670dd7fa3a77d7808a0a115cb8efd20bb | 2,953 | c | C | core/app-framework/wgl/app/src/wgl_btn.c | BernardXiong/wasm-micro-runtime | 79f163d08b8614d0a4caa0abeade430a7c237e1a | [
"Apache-2.0"
] | 1,723 | 2019-11-12T16:11:15.000Z | 2022-03-31T20:33:17.000Z | core/app-framework/wgl/app/src/wgl_btn.c | BernardXiong/wasm-micro-runtime | 79f163d08b8614d0a4caa0abeade430a7c237e1a | [
"Apache-2.0"
] | 396 | 2019-11-12T21:18:44.000Z | 2022-03-31T16:54:15.000Z | core/app-framework/wgl/app/src/wgl_btn.c | BernardXiong/wasm-micro-runtime | 79f163d08b8614d0a4caa0abeade430a7c237e1a | [
"Apache-2.0"
] | 322 | 2019-11-12T17:16:53.000Z | 2022-03-31T21:07:17.000Z | /*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "wa-inc/lvgl/lvgl.h"
#include "bh_platform.h"
#include "gui_api.h"
#define ARGC sizeof(argv)/sizeof(uint32)
#define CALL_BTN_NATIVE_FUNC(id) wasm_btn_native_call(id, argv, ARGC)
lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy)
{
uint32 argv[2] = {0};
argv[0] = (uint32)par;
argv[1] = (uint32)copy;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_CREATE);
return (lv_obj_t *)argv[0];
}
void lv_btn_set_toggle(lv_obj_t * btn, bool tgl)
{
uint32 argv[2] = {0};
argv[0] = (uint32)btn;
argv[1] = tgl;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_TOGGLE);
}
void lv_btn_set_state(lv_obj_t * btn, lv_btn_state_t state)
{
uint32 argv[2] = {0};
argv[0] = (uint32)btn;
argv[1] = state;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_STATE);
}
void lv_btn_toggle(lv_obj_t * btn)
{
uint32 argv[1] = {0};
argv[0] = (uint32)btn;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_TOGGLE);
}
void lv_btn_set_ink_in_time(lv_obj_t * btn, uint16_t time)
{
uint32 argv[2] = {0};
argv[0] = (uint32)btn;
argv[1] = time;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_INK_IN_TIME);
}
void lv_btn_set_ink_wait_time(lv_obj_t * btn, uint16_t time)
{
uint32 argv[2] = {0};
argv[0] = (uint32)btn;
argv[1] = time;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_INK_WAIT_TIME);
}
void lv_btn_set_ink_out_time(lv_obj_t * btn, uint16_t time)
{
uint32 argv[2] = {0};
argv[0] = (uint32)btn;
argv[1] = time;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_INK_OUT_TIME);
}
//void wgl_btn_set_style(wgl_obj_t btn, wgl_btn_style_t type, const wgl_style_t * style)
//{
// //TODO: pack style
// //wasm_btn_set_style(btn, type, style);
//}
//
lv_btn_state_t lv_btn_get_state(const lv_obj_t * btn)
{
uint32 argv[1] = {0};
argv[0] = (uint32)btn;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_GET_STATE);
return (lv_btn_state_t)argv[0];
}
bool lv_btn_get_toggle(const lv_obj_t * btn)
{
uint32 argv[1] = {0};
argv[0] = (uint32)btn;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_GET_TOGGLE);
return (bool)argv[0];
}
uint16_t lv_btn_get_ink_in_time(const lv_obj_t * btn)
{
uint32 argv[1] = {0};
argv[0] = (uint32)btn;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_GET_INK_IN_TIME);
return (uint16_t)argv[0];
}
uint16_t lv_btn_get_ink_wait_time(const lv_obj_t * btn)
{
uint32 argv[1] = {0};
argv[0] = (uint32)btn;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_GET_INK_WAIT_TIME);
return (uint16_t)argv[0];
}
uint16_t lv_btn_get_ink_out_time(const lv_obj_t * btn)
{
uint32 argv[1] = {0};
argv[0] = (uint32)btn;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_GET_INK_OUT_TIME);
return (uint16_t)argv[0];
}
//
//const wgl_style_t * wgl_btn_get_style(const wgl_obj_t btn, wgl_btn_style_t type)
//{
// //TODO: pack style
// //wasm_btn_get_style(btn, type);
// return NULL;
//}
| 24.204918 | 88 | 0.687098 |
32356f8a4ae0def065807515a2718aad045542b9 | 24 | c | C | keyboards/kudox_game/rev2/rev2.c | fzf/qmk_toolbox | 10d6b425bd24b45002555022baf16fb11254118b | [
"MIT"
] | null | null | null | keyboards/kudox_game/rev2/rev2.c | fzf/qmk_toolbox | 10d6b425bd24b45002555022baf16fb11254118b | [
"MIT"
] | null | null | null | keyboards/kudox_game/rev2/rev2.c | fzf/qmk_toolbox | 10d6b425bd24b45002555022baf16fb11254118b | [
"MIT"
] | null | null | null | #include "kudox_game.h"
| 12 | 23 | 0.75 |
d290ba6f65d7c33f2fa41498735a2ce5d13d5e0e | 4,980 | h | C | httputil.h | mkdym/httpclient | 2cadf455315a0031958712fb559ca43c6c3c5a71 | [
"Unlicense"
] | 11 | 2016-05-16T01:01:44.000Z | 2022-03-20T04:30:42.000Z | httputil.h | mkdym/asynchttpclient | 2cadf455315a0031958712fb559ca43c6c3c5a71 | [
"Unlicense"
] | null | null | null | httputil.h | mkdym/asynchttpclient | 2cadf455315a0031958712fb559ca43c6c3c5a71 | [
"Unlicense"
] | 2 | 2017-05-04T18:48:28.000Z | 2018-03-26T03:51:37.000Z | #pragma once
#include <string>
#include <vector>
#include <map>
#include <boost/algorithm/string.hpp>
#include "httpclientlog.h"
namespace
{
inline unsigned char tohex(const unsigned char x)
{
return (x > 9) ? (x - 10 + 'A') : (x + '0');
}
inline unsigned char fromhex(const unsigned char x)
{
unsigned char y = 0;
if (x >= 'A' && x <= 'Z')
{
y = x - 'A' + 10;
}
else if (x >= 'a' && x <= 'z')
{
y = x - 'a' + 10;
}
else if (x >= '0' && x <= '9')
{
y = x - '0';
}
else
{
y = 0;
}
return y;
}
}
namespace HttpUtil
{
//************************************
// brief: tool function, transform key-value style param to string style param with given separator
// name: build_kv_string
// param: const std::map<std::string, std::string> & kv_param
// param: const std::string & kv_sep separator between key and value
// param: const std::string & pair_sep separator between key-value pairs
// return: std::string
// remarks:
//************************************
inline std::string build_kv_string(const std::map<std::string, std::string>& kv_param,
const std::string& kv_sep = "=", const std::string& pair_sep = "&")
{
std::string s;
for (std::map<std::string, std::string>::const_iterator iterKey = kv_param.begin();
iterKey != kv_param.end();
++iterKey)
{
s += iterKey->first + kv_sep + iterKey->second + pair_sep;
}
boost::algorithm::erase_last(s, "&");
return s;
}
//tool function, transform string style param to key-value style param using given separator, see above
inline void parse_kv_string(const std::string& s, std::map<std::string, std::string>& kv_param,
const std::string& kv_sep = "=", const std::string& pair_sep = "&")
{
kv_param.clear();
std::vector<std::string> pairs;
boost::algorithm::split(pairs, s, boost::algorithm::is_any_of(pair_sep));
for (std::vector<std::string>::iterator iterStr = pairs.begin();
iterStr != pairs.end();
++iterStr)
{
if (iterStr->empty())
{
HTTP_CLIENT_WARN << "encountered an empty pair";
continue;
}
std::vector<std::string> kv;
boost::algorithm::split(kv, *iterStr, boost::algorithm::is_any_of(kv_sep));
if (2 != kv.size())
{
HTTP_CLIENT_WARN << "encountered a pair[" << *iterStr << "] which can not split 2 parts by [" << kv_sep << "]";
continue;
}
kv_param[kv[0]] = kv[1];
}
}
//************************************
// brief: tool function, url encode
// name: url_encode
// param: const std::string & s
// return: std::string
// remarks:
//************************************
inline std::string url_encode(const std::string& s)
{
std::string strEncoded;
for (std::string::const_iterator iterCh = s.begin(); iterCh != s.end(); ++iterCh)
{
const unsigned char ch = *iterCh;
if (isalnum(ch) || (ch == '-') || (ch == '_') || (ch == '.') || (ch == '~'))
{
strEncoded += ch;
}
else if (ch == ' ')
{
strEncoded += '+';
}
else
{
strEncoded += '%';
strEncoded += tohex(ch >> 4);//高4位
strEncoded += tohex(ch % 16);//低4位
}
}
return strEncoded;
}
//url decode, see above
inline std::string url_decode(const std::string& s)
{
std::string strDecoded;
for (std::string::const_iterator iterCh = s.begin(); iterCh != s.end();)
{
if (*iterCh == '+')
{
strDecoded += ' ';
++iterCh;
}
else if (*iterCh == '%')
{
if (++iterCh == s.end())
{
break;
}
unsigned char high = fromhex(*iterCh);
if (++iterCh == s.end())
{
break;
}
unsigned char low = fromhex(*iterCh);
strDecoded += (high * 16 + low);
++iterCh;
}
else
{
strDecoded += *iterCh;
++iterCh;
}
}
return strDecoded;
}
}
| 29.820359 | 128 | 0.41988 |
960c4cb0020dd12ca9045b55950bfb179752b12e | 8,758 | h | C | lib/rawkit-vg/include/rawkit/vg.h | tmpvar/rawk | 0dee2bdf9e11e9033988a0d9d1e52603263c6aca | [
"MIT"
] | 9 | 2020-08-14T19:46:33.000Z | 2021-10-13T09:33:20.000Z | lib/rawkit-vg/include/rawkit/vg.h | tmpvar/rawkit | 0dee2bdf9e11e9033988a0d9d1e52603263c6aca | [
"MIT"
] | null | null | null | lib/rawkit-vg/include/rawkit/vg.h | tmpvar/rawkit | 0dee2bdf9e11e9033988a0d9d1e52603263c6aca | [
"MIT"
] | null | null | null | #pragma once
#include <rawkit/core.h>
#include <rawkit/gpu.h>
#include <rawkit/hot.h>
#include <rawkit/texture.h>
#include <nanovg/nanovg.h>
#include <vulkan/vulkan.h>
typedef struct rawkit_vg_t {
RAWKIT_RESOURCE_FIELDS
// internal
void *_state;
} rawkit_vg_t;
#ifdef __cplusplus
extern "C" {
#endif
rawkit_vg_t *rawkit_vg(
rawkit_gpu_t *gpu,
VkRenderPass render_pass,
const char *name,
rawkit_resource_t *parent
);
rawkit_vg_t *rawkit_default_vg();
void rawkit_vg_draw_texture(rawkit_vg_t *vg, float x, float y, float w, float h, rawkit_texture_t *tex, const rawkit_texture_sampler_t *sampler);
void rawkit_vg_draw_texture_rect(
rawkit_vg_t *vg,
float src_x,
float src_y,
float src_w,
float src_h,
float dest_x,
float dest_y,
rawkit_texture_t *tex,
const rawkit_texture_sampler_t *sampler
);
// select a render to texture context
rawkit_vg_t *rawkit_vg_from_texture_target(rawkit_texture_target_t *target);
NVGpaint rawkit_vg_texture(rawkit_vg_t *vg, float cx, float cy, float w, float h, float angle, rawkit_texture_t *tex, float alpha, const rawkit_texture_sampler_t *sampler);
void rawkit_vg_begin_frame(rawkit_vg_t *vg, VkCommandBuffer command_buffer, float windowWidth, float windowHeight, float devicePixelRatio);
void rawkit_vg_cancel_frame(rawkit_vg_t *vg);
void rawkit_vg_end_frame(rawkit_vg_t *vg);
void rawkit_vg_global_composite_operation(rawkit_vg_t *vg, int op);
void rawkit_vg_global_composite_blend_func(rawkit_vg_t *vg, int sfactor, int dfactor);
void rawkit_vg_global_composite_blend_func_separate(rawkit_vg_t *vg, int srcRGB, int dstRGB, int srcAlpha, int dstAlpha);
NVGcolor rawkit_vg_RGB(unsigned char r, unsigned char g, unsigned char b);
NVGcolor rawkit_vg_RGBf(float r, float g, float b);
NVGcolor rawkit_vg_RGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
NVGcolor rawkit_vg_RGBAf(float r, float g, float b, float a);
NVGcolor rawkit_vg_lerpRGBA(NVGcolor c0, NVGcolor c1, float u);
NVGcolor rawkit_vg_transRGBA(NVGcolor c0, unsigned char a);
NVGcolor rawkit_vg_transRGBAf(NVGcolor c0, float a);
NVGcolor rawkit_vg_HSL(float h, float s, float l);
NVGcolor rawkit_vg_HSLA(float h, float s, float l, unsigned char a);
void rawkit_vg_save(rawkit_vg_t *vg);
void rawkit_vg_restore(rawkit_vg_t *vg);
void rawkit_vg_reset(rawkit_vg_t *vg);
void rawkit_vg_shape_anti_alias(rawkit_vg_t *vg, int enabled);
void rawkit_vg_stroke_color(rawkit_vg_t *vg, NVGcolor color);
void rawkit_vg_stroke_paint(rawkit_vg_t *vg, NVGpaint paint);
void rawkit_vg_fill_color(rawkit_vg_t *vg, NVGcolor color);
void rawkit_vg_fill_paint(rawkit_vg_t *vg, NVGpaint paint);
void rawkit_vg_miter_limit(rawkit_vg_t *vg, float limit);
void rawkit_vg_stroke_width(rawkit_vg_t *vg, float size);
void rawkit_vg_line_cap(rawkit_vg_t *vg, int cap);
void rawkit_vg_line_join(rawkit_vg_t *vg, int join);
void rawkit_vg_global_alpha(rawkit_vg_t *vg, float alpha);
void rawkit_vg_reset_transform(rawkit_vg_t *vg);
void rawkit_vg_transform(rawkit_vg_t *vg, float a, float b, float c, float d, float e, float f);
void rawkit_vg_translate(rawkit_vg_t *vg, float x, float y);
void rawkit_vg_rotate(rawkit_vg_t *vg, float angle);
void rawkit_vg_skewX(rawkit_vg_t *vg, float angle);
void rawkit_vg_skewY(rawkit_vg_t *vg, float angle);
void rawkit_vg_scale(rawkit_vg_t *vg, float x, float y);
void rawkit_vg_current_transform(rawkit_vg_t *vg, float*xform);
void rawkit_vg_transform_identity(float*dst);
void rawkit_vg_transform_translate(float*dst, float tx, float ty);
void rawkit_vg_transform_scale(float*dst, float sx, float sy);
void rawkit_vg_transform_rotate(float*dst, float a);
void rawkit_vg_transform_skewX(float*dst, float a);
void rawkit_vg_transform_skewY(float*dst, float a);
void rawkit_vg_transform_multiply(float*dst, const float*src);
void rawkit_vg_transform_premultiply(float*dst, const float*src);
int rawkit_vg_transform_inverse(float*dst, const float*src);
void rawkit_vg_transform_point(float*dstx, float*dsty, const float*xform, float srcx, float srcy);
float rawkit_vg_deg_to_rad(float deg);
float rawkit_vg_rad_to_deg(float rad);
int rawkit_vg_create_image_rgba(rawkit_vg_t *vg, int w, int h, int imageFlags, const unsigned char* data);
void rawkit_vg_update_image(rawkit_vg_t *vg, int image, const unsigned char *data);
void rawkit_vg_image_size(rawkit_vg_t *vg, int image, int*w, int*h);
void rawkit_vg_delete_image(rawkit_vg_t *vg, int image);
NVGpaint rawkit_vg_linear_gradient(rawkit_vg_t *vg, float sx, float sy, float ex, float ey, NVGcolor icol, NVGcolor ocol);
NVGpaint rawkit_vg_box_gradient(rawkit_vg_t *vg, float x, float y, float w, float h, float r, float f, NVGcolor icol, NVGcolor ocol);
NVGpaint rawkit_vg_radial_gradient(rawkit_vg_t *vg, float cx, float cy, float inr, float outr, NVGcolor icol, NVGcolor ocol);
NVGpaint rawkit_vg_image_pattern(rawkit_vg_t *vg, float ox, float oy, float ex, float ey, float angle, int image, float alpha);
void rawkit_vg_scissor(rawkit_vg_t *vg, float x, float y, float w, float h);
void rawkit_vg_intersect_scissor(rawkit_vg_t *vg, float x, float y, float w, float h);
void rawkit_vg_reset_scissor(rawkit_vg_t *vg);
void rawkit_vg_begin_path(rawkit_vg_t *vg);
void rawkit_vg_move_to(rawkit_vg_t *vg, float x, float y);
void rawkit_vg_line_to(rawkit_vg_t *vg, float x, float y);
void rawkit_vg_bezier_to(rawkit_vg_t *vg, float c1x, float c1y, float c2x, float c2y, float x, float y);
void rawkit_vg_quad_to(rawkit_vg_t *vg, float cx, float cy, float x, float y);
void rawkit_vg_arc_to(rawkit_vg_t *vg, float x1, float y1, float x2, float y2, float radius);
void rawkit_vg_close_path(rawkit_vg_t *vg);
void rawkit_vg_path_winding(rawkit_vg_t *vg, int dir);
void rawkit_vg_arc(rawkit_vg_t *vg, float cx, float cy, float r, float a0, float a1, int dir);
void rawkit_vg_rect(rawkit_vg_t *vg, float x, float y, float w, float h);
void rawkit_vg_rounded_rect(rawkit_vg_t *vg, float x, float y, float w, float h, float r);
void rawkit_vg_rounded_rect_varying(rawkit_vg_t *vg, float x, float y, float w, float h, float radTopLeft, float radTopRight, float radBottomRight, float radBottomLeft);
void rawkit_vg_ellipse(rawkit_vg_t *vg, float cx, float cy, float rx, float ry);
void rawkit_vg_circle(rawkit_vg_t *vg, float cx, float cy, float r);
void rawkit_vg_fill(rawkit_vg_t *vg);
void rawkit_vg_stroke(rawkit_vg_t *vg);
int rawkit_vg_create_font(rawkit_vg_t *vg, const char *name, const char*filename);
int rawkit_vg_create_font_at_index(rawkit_vg_t *vg, const char *name, const char*filename, const int fontIndex);
int rawkit_vg_create_font_mem(rawkit_vg_t *vg, const char *name, unsigned char*data, int ndata, int freeData);
int rawkit_vg_create_font_mem_at_index(rawkit_vg_t *vg, const char *name, unsigned char*data, int ndata, int freeData, const int fontIndex);
int rawkit_vg_find_font(rawkit_vg_t *vg, const char *name);
int rawkit_vg_add_fallback_font_id(rawkit_vg_t *vg, int baseFont, int fallbackFont);
int rawkit_vg_add_fallback_font(rawkit_vg_t *vg, const char *baseFont, const char*fallbackFont);
void rawkit_vg_reset_fallback_fonts_id(rawkit_vg_t *vg, int baseFont);
void rawkit_vg_reset_fallback_fonts(rawkit_vg_t *vg, const char *baseFont);
void rawkit_vg_font_size(rawkit_vg_t *vg, float size);
void rawkit_vg_font_blur(rawkit_vg_t *vg, float blur);
void rawkit_vg_text_letter_spacing(rawkit_vg_t *vg, float spacing);
void rawkit_vg_text_line_height(rawkit_vg_t *vg, float lineHeight);
void rawkit_vg_text_align(rawkit_vg_t *vg, int align);
void rawkit_vg_font_face_id(rawkit_vg_t *vg, int font);
void rawkit_vg_font_face(rawkit_vg_t *vg, const char *font);
float rawkit_vg_text(rawkit_vg_t *vg, float x, float y, const char *string, const char*end);
void rawkit_vg_text_box(rawkit_vg_t *vg, float x, float y, float breakRowWidth, const char *string, const char*end);
float rawkit_vg_text_bounds(rawkit_vg_t *vg, float x, float y, const char *string, const char*end, float*bounds);
void rawkit_vg_text_box_bounds(rawkit_vg_t *vg, float x, float y, float breakRowWidth, const char *string, const char*end, float*bounds);
int rawkit_vg_text_glyph_positions(rawkit_vg_t *vg, float x, float y, const char *string, const char*end, NVGglyphPosition*positions, int maxPositions);
void rawkit_vg_text_metrics(rawkit_vg_t *vg, float*ascender, float*descender, float*lineh);
int rawkit_vg_text_break_lines(rawkit_vg_t *vg, const char *string, const char*end, float breakRowWidth, NVGtextRow*rows, int maxRows);
void rawkit_vg_debug_dump_path_cache(rawkit_vg_t *vg);
#ifdef __cplusplus
}
#endif
| 57.618421 | 174 | 0.781114 |
65ffa4a718b08975a541e359a153f86c2fb877ba | 6,663 | h | C | source/curve25519_mehdi.h | kryptohash/curve25519 | ef3558f740e087c06b5670d41dcd5d5a7fe88a3c | [
"MIT"
] | null | null | null | source/curve25519_mehdi.h | kryptohash/curve25519 | ef3558f740e087c06b5670d41dcd5d5a7fe88a3c | [
"MIT"
] | null | null | null | source/curve25519_mehdi.h | kryptohash/curve25519 | ef3558f740e087c06b5670d41dcd5d5a7fe88a3c | [
"MIT"
] | null | null | null | /* The MIT License (MIT)
*
* Copyright (c) 2015 mehdi sotoodeh
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* 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 __curve25519_mehdi_h__
#define __curve25519_mehdi_h__
#ifdef __cplusplus
extern "C" {
#endif
#include "BaseTypes.h"
#define ECP_VERSION_STR "1.2.0"
#ifdef USE_ASM_LIB
#define U_WORD U64
#define S_WORD S64
#define WORDSIZE_64
#define W64(lo,hi) ((U64)hi<<32)+lo
#else
#define U_WORD U32
#define S_WORD S32
#define WORDSIZE_32
#define W64(lo,hi) lo,hi
#endif
#define K_BYTES 32
#define K_WORDS (K_BYTES/sizeof(U_WORD))
#define W256(x0,x1,x2,x3,x4,x5,x6,x7) {W64(x0,x1),W64(x2,x3),W64(x4,x5),W64(x6,x7)}
/* Affine coordinates */
typedef struct {
U_WORD x[K_WORDS];
U_WORD y[K_WORDS];
} Affine_POINT;
/* Projective coordinates */
typedef struct {
U_WORD x[K_WORDS]; /* x/z */
U_WORD y[K_WORDS]; /* y/z */
U_WORD z[K_WORDS];
U_WORD t[K_WORDS]; /* xy/z */
} Ext_POINT;
/* pre-computed, extended point */
typedef struct
{
U_WORD YpX[K_WORDS]; /* Y+X */
U_WORD YmX[K_WORDS]; /* Y-X */
U_WORD T2d[K_WORDS]; /* 2d*T */
U_WORD Z2[K_WORDS]; /* 2*Z */
} PE_POINT;
/* pre-computed, Affine point */
typedef struct
{
U_WORD YpX[K_WORDS]; /* Y+X */
U_WORD YmX[K_WORDS]; /* Y-X */
U_WORD T2d[K_WORDS]; /* 2d*T */
} PA_POINT;
typedef struct {
U_WORD bl[K_WORDS];
U_WORD zr[K_WORDS];
PE_POINT BP;
} EDP_BLINDING_CTX;
extern const U8 ecp_BasePoint[K_BYTES];
/* Return point Q = k*P */
void ecp_PointMultiply(OUT U8 *Q, IN const U8 *P, IN const U8 *K, IN int len);
/* Set low and high bits */
void ecp_TrimSecretKey(U8 *X);
/* Set low and high bits for BIP32 */
void mul_scalar_by_eight(U8* X);
void div_scalar_by_eight(U8* X);
void ecp_TrimSecretKey_BIP32(U8 *X);
/* -- utils ----------------------------------------------------------------- */
/* Convert big-endian byte array to little-endian byte array and vice versa */
U8* ecp_ReverseByteOrder(OUT U8 *Y, IN const U8 *X);
/* Convert little-endian byte array to little-endian word array */
U_WORD* ecp_BytesToWords(OUT U_WORD *Y, IN const U8 *X);
/* Convert little-endian word array to little-endian byte array */
U8* ecp_WordsToBytes(OUT U8 *Y, IN const U_WORD *X);
U8* ecp_EncodeInt(OUT U8 *Y, IN const U_WORD *X, IN U8 parity);
U8 ecp_DecodeInt(OUT U_WORD *Y, IN const U8 *X);
/* -- base point order ------------------------------------------------------ */
/* Z = (X*Y)/R mod BPO */
void eco_MontMul(OUT U_WORD *Z, IN const U_WORD *X, IN const U_WORD *Y);
/* Return Y = X*R mod BPO */
void eco_ToMont(OUT U_WORD *Y, IN const U_WORD *X);
/* Return Y = X/R mod BPO */
void eco_FromMont(OUT U_WORD *Y, IN const U_WORD *X);
/* Calculate Y = X**E mod BPO */
void eco_ExpModBPO(OUT U_WORD *Y, IN const U_WORD *X, IN const U8 *E, IN int bytes);
/* Calculate Y = 1/X mod BPO */
void eco_InvModBPO(OUT U_WORD *Y, IN const U_WORD *X);
/* Z = X*Y mod BPO */
void eco_MulReduce(OUT U_WORD *Z, IN const U_WORD *X, IN const U_WORD *Y);
/* Return Y = D mod BPO where D is 512-bit big-endian byte array (i.e SHA512 digest) */
void eco_DigestToWords( OUT U_WORD *Y, IN const U8 *D);
/* Z = X + Y mod BPO */
void eco_AddReduce(OUT U_WORD *Z, IN const U_WORD *X, IN const U_WORD *Y);
/* X mod BPO */
void eco_Mod(U_WORD *X);
#define ed25519_PackPoint(buff, Y, parity) ecp_EncodeInt(buff, Y, (U8)(parity & 1))
/* -- big-number ------------------------------------------------------------ */
U_WORD ecp_Add(U_WORD* Z, const U_WORD* X, const U_WORD* Y);
S_WORD ecp_Sub(U_WORD* Z, const U_WORD* X, const U_WORD* Y);
void ecp_SetValue(U_WORD* X, U_WORD value);
void ecp_Copy(U_WORD* Y, const U_WORD* X);
void ecp_AddReduce(U_WORD* Z, const U_WORD* X, const U_WORD* Y);
void ecp_SubReduce(U_WORD* Z, const U_WORD* X, const U_WORD* Y);
void ecp_MulReduce(U_WORD* Z, const U_WORD* X, const U_WORD* Y);
void ecp_SqrReduce(U_WORD* Y, const U_WORD* X);
void ecp_ModExp2523(U_WORD *Y, const U_WORD *X);
void ecp_Inverse(U_WORD *out, const U_WORD *z);
void ecp_MulMod(U_WORD* Z, const U_WORD* X, const U_WORD* Y);
void ecp_Mul(U_WORD* Z, const U_WORD* X, const U_WORD* Y);
/* Computes Y = b*X */
void ecp_WordMulSet(U_WORD *Y, U_WORD b, const U_WORD* X);
/* Computes Z = Y + b*X and return carry */
U_WORD ecp_WordMulAdd(U_WORD *Z, const U_WORD* Y, U_WORD b, const U_WORD* X);
/* Computes Z = Y + b*X */
void ecp_WordMulAddReduce(U_WORD *Z, const U_WORD* Y, U_WORD b, const U_WORD* X);
void ecp_Mod(U_WORD* X);
int ecp_CmpNE(const U_WORD* X, const U_WORD* Y);
int ecp_CmpLT(const U_WORD* X, const U_WORD* Y);
/* Calculate: Y = [b:X] mod BPO */
void eco_ReduceHiWord(U_WORD* Y, U_WORD b, const U_WORD* X);
/* -- ed25519 --------------------------------------------------------------- */
void ed25519_UnpackPoint(Affine_POINT *r, const unsigned char *p);
void ed25519_CalculateX(OUT U_WORD *X, IN const U_WORD *Y, U_WORD parity);
void edp_AddAffinePoint(Ext_POINT *p, const PA_POINT *q);
void edp_AddBasePoint(Ext_POINT *p);
void edp_AddPoint(Ext_POINT *r, const Ext_POINT *p, const PE_POINT *q);
void edp_DoublePoint(Ext_POINT *p);
void edp_ComputePermTable(PE_POINT *qtable, Ext_POINT *Q);
void edp_ExtPoint2PE(PE_POINT *r, const Ext_POINT *p);
void edp_BasePointMult(OUT Ext_POINT *S, IN const U_WORD *sk, IN const U_WORD *R);
void edp_BasePointMultiply(OUT Affine_POINT *Q, IN const U_WORD *sk,
IN const void *blinding);
void ecp_4Folds(U8* Y, const U_WORD* X);
void ecp_8Folds(U8* Y, const U_WORD* X);
#ifdef __cplusplus
}
#endif
#endif /* __curve25519_mehdi_h__ */ | 37.016667 | 87 | 0.667717 |
d0b81a6d93b5673b5f8f8731dd36ead4c6e39ccd | 689 | h | C | Example/Pods/Target Support Files/ELKitSDK/ELKitSDK-umbrella.h | linlinyin1991/ELKitSDK | 438e93b7d465e7050c3731111f65a3d3410c5811 | [
"MIT"
] | 7 | 2019-08-15T02:54:35.000Z | 2022-02-21T03:22:03.000Z | Example/Pods/Target Support Files/ELKitSDK/ELKitSDK-umbrella.h | linlinyin1991/ELKitSDK | 438e93b7d465e7050c3731111f65a3d3410c5811 | [
"MIT"
] | null | null | null | Example/Pods/Target Support Files/ELKitSDK/ELKitSDK-umbrella.h | linlinyin1991/ELKitSDK | 438e93b7d465e7050c3731111f65a3d3410c5811 | [
"MIT"
] | 4 | 2019-11-28T09:53:37.000Z | 2022-01-26T09:57:31.000Z | #ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
#import "NSDate+ELExtension.h"
#import "NSString+ELExtension.h"
#import "UIColor+ELExtension.h"
#import "UIView+ELExtension.h"
#import "ELEncryptAES.h"
#import "ELEncryptMD5.h"
#import "ELEncryptRSA.h"
#import "NSData+ELEncode.h"
#import "NSString+ELEncode.h"
#import "ELTextField.h"
#import "ELTextInput.h"
#import "ELTextView.h"
#import "ELRegular.h"
#import "ELDeviceUtility.h"
FOUNDATION_EXPORT double ELKitSDKVersionNumber;
FOUNDATION_EXPORT const unsigned char ELKitSDKVersionString[];
| 22.225806 | 62 | 0.791001 |
fdfd8d7e36491f9664b2afcde4cde216c56ab703 | 3,871 | h | C | Examples/Display/PerlinNoise/Sources/options.h | xctan/ClanLib | 1a8d6eb6cab3e93fd5c6be618fb6f7bd1146fc2d | [
"Linux-OpenIB"
] | 248 | 2015-01-08T05:21:40.000Z | 2022-03-20T02:59:16.000Z | Examples/Display/PerlinNoise/Sources/options.h | xctan/ClanLib | 1a8d6eb6cab3e93fd5c6be618fb6f7bd1146fc2d | [
"Linux-OpenIB"
] | 39 | 2015-01-14T17:37:07.000Z | 2022-03-17T12:59:26.000Z | Examples/Display/PerlinNoise/Sources/options.h | xctan/ClanLib | 1a8d6eb6cab3e93fd5c6be618fb6f7bd1146fc2d | [
"Linux-OpenIB"
] | 82 | 2015-01-11T13:23:49.000Z | 2022-02-19T03:17:24.000Z | /*
** ClanLib SDK
** Copyright (c) 1997-2020 The ClanLib Team
**
** This software is provided 'as-is', without any express or implied
** warranty. In no event will the authors be held liable for any damages
** arising from the use of this software.
**
** Permission is granted to anyone to use this software for any purpose,
** including commercial applications, and to alter it and redistribute it
** freely, subject to the following restrictions:
**
** 1. The origin of this software must not be misrepresented; you must not
** claim that you wrote the original software. If you use this software
** in a product, an acknowledgment in the product documentation would be
** appreciated but is not required.
** 2. Altered source versions must be plainly marked as such, and must not be
** misrepresented as being the original software.
** 3. This notice may not be removed or altered from any source distribution.
**
** Note: Some of the libraries ClanLib may link to may have additional
** requirements or restrictions.
**
** File Author(s):
**
** Mark Page
*/
#pragma once
#include "../../../ThemeAero/Sources/theme.h"
enum PerlinDimension
{
perlin_1d,
perlin_2d,
perlin_3d,
perlin_4d
};
class Options : public clan::TextureWindow
{
public:
Options(clan::Canvas &canvas);
virtual ~Options();
clan::TextureFormat sized_format;
float amplitude;
int width;
int height;
int octaves;
float start_x;
float length_x;
float start_y;
float length_y;
float position_z;
float position_w;
PerlinDimension dimension;
bool is_normals_set;
private:
void on_format_selected(std::shared_ptr<clan::ListBoxView> listbox);
void on_dimension_selected(std::shared_ptr<clan::ListBoxView> listbox);
std::shared_ptr<clan::ListBoxView> create_listbox(int xpos, int ypos, const std::string &title);
std::shared_ptr<clan::CheckBoxView> create_checkbox(int xpos, int ypos, const std::string &name, bool state);
std::shared_ptr<clan::SliderView> create_slider(int xpos, int ypos);
std::shared_ptr<clan::LabelView> create_slider_label(int xpos, int ypos);
void set_value(std::shared_ptr<clan::SliderView> slider, float value, float max_value);
float get_value(std::shared_ptr<clan::SliderView> slider, float max_value);
void checkbox_normals_changed();
void update_all_slider_text();
void slider_amplitude_changed();
void slider_width_changed();
void slider_height_changed();
void slider_octaves_changed();
void slider_start_x_changed();
void slider_length_x_changed();
void slider_start_y_changed();
void slider_length_y_changed();
void slider_position_z_changed();
void slider_position_w_changed();
void checkbox_normal_changed();
private:
std::shared_ptr<clan::SliderView> slider_width;
std::shared_ptr<clan::LabelView> label_width;
std::shared_ptr<clan::SliderView> slider_height;
std::shared_ptr<clan::LabelView> label_height;
std::shared_ptr<clan::SliderView> slider_start_x;
std::shared_ptr<clan::LabelView> label_start_x;
std::shared_ptr<clan::SliderView> slider_start_y;
std::shared_ptr<clan::LabelView> label_start_y;
std::shared_ptr<clan::SliderView> slider_length_x;
std::shared_ptr<clan::LabelView> label_length_x;
std::shared_ptr<clan::SliderView> slider_length_y;
std::shared_ptr<clan::LabelView> label_length_y;
std::shared_ptr<clan::SliderView> slider_position_z;
std::shared_ptr<clan::LabelView> label_position_z;
std::shared_ptr<clan::SliderView> slider_position_w;
std::shared_ptr<clan::LabelView> label_position_w;
std::shared_ptr<clan::SliderView> slider_octaves;
std::shared_ptr<clan::LabelView> label_octaves;
std::shared_ptr<clan::SliderView> slider_amplitude;
std::shared_ptr<clan::LabelView> label_amplitude;
std::shared_ptr<clan::LabelView> label_format;
std::shared_ptr<clan::LabelView> label_dimension;
std::shared_ptr<clan::CheckBoxView> checkbox_normals;
};
| 33.66087 | 110 | 0.769569 |
a91039ae58fb57bfb229989a127a314bab9725b2 | 1,525 | h | C | Deprecated/Project3/src/ui/openglwidget.h | jesusdz/AGP | fc6401f1432313324d6fd07f7aeec411c0857276 | [
"Unlicense"
] | null | null | null | Deprecated/Project3/src/ui/openglwidget.h | jesusdz/AGP | fc6401f1432313324d6fd07f7aeec411c0857276 | [
"Unlicense"
] | null | null | null | Deprecated/Project3/src/ui/openglwidget.h | jesusdz/AGP | fc6401f1432313324d6fd07f7aeec411c0857276 | [
"Unlicense"
] | null | null | null | #ifndef OPENGLWIDGET_H
#define OPENGLWIDGET_H
#include <QOpenGLWidget>
#include <QOpenGLFunctions_3_3_Core>
#include <QOpenGLDebugMessage>
#include <QTimer>
class Input;
class Camera;
class Interaction;
class Selection;
class DeferredRenderer;
class OpenGLWidget :
public QOpenGLWidget,
protected QOpenGLFunctions_3_3_Core
{
Q_OBJECT
public:
explicit OpenGLWidget(QWidget *parent = nullptr);
~OpenGLWidget() override;
// Virtual OpenGL methods
void initializeGL() override;
void resizeGL(int w, int h) override;
void paintGL() override;
// Virtual event methods
void keyPressEvent(QKeyEvent *event) override;
void keyReleaseEvent(QKeyEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void enterEvent(QEvent *event) override;
void leaveEvent(QEvent *event) override;
void focusOutEvent(QFocusEvent *event) override;
// Public methods
QString getOpenGLInfo();
QImage getScreenshot();
signals:
void interacted();
public slots:
// Not virtual
void frame();
void finalizeGL();
void handleLoggedMessage(const QOpenGLDebugMessage &debugMessage);
private:
QTimer timer;
Input *input = nullptr;
Camera *camera = nullptr;
Interaction *interaction = nullptr;
Selection *selection = nullptr;
DeferredRenderer *renderer = nullptr;
};
#endif // OPENGLWIDGET_H
| 22.761194 | 70 | 0.726557 |
656cc243ca4a795006a933f13fabb60e690ee226 | 1,351 | h | C | glx/glxFFont.h | MAPSWorks/bigView--bigView-glx-Examples-latlon.C | 099071d483f7b3d056f41c15424b2e3e93ffb22e | [
"NASA-1.3"
] | null | null | null | glx/glxFFont.h | MAPSWorks/bigView--bigView-glx-Examples-latlon.C | 099071d483f7b3d056f41c15424b2e3e93ffb22e | [
"NASA-1.3"
] | null | null | null | glx/glxFFont.h | MAPSWorks/bigView--bigView-glx-Examples-latlon.C | 099071d483f7b3d056f41c15424b2e3e93ffb22e | [
"NASA-1.3"
] | null | null | null | #ifndef GLX_FFONT_H
#define GLX_FFONT_H
#include <string>
#include <vector>
#include <map>
#include <X11/Xft/Xft.h>
namespace Glx {
struct Glyph {
char ch;
int index; // FT's index for this char
int x,y; // local offset for this glyph
int w,h; // size of the glyph square
float slo,shi,tlo,thi; // tex coords
int xlo,ylo; // offset into texture, in pixels
float dx,dy; // dist to move after drawing, not including kerning
int texID; // texture this glyph lives in
int texW,texH; // width of the texture this glyph lives in
};
// Cache the font glyphs [images of chars] into a texture
// for faster rendering, uses Xft/Freetype2 lib
class FontCache {
public:
FontCache(Display*, std::string face, double size);
FontCache(Display*, XftFont*);
~FontCache(void);
void draw(int winw, int winh, std::vector<std::string>&);
void draw(int x, int y, std::string);
void setColor(float r, float g, float b);
void setColor(float rgb[3]);
void allocTextures(FT_Face,int,int,float,float,int,
std::vector<Glx::Glyph>&);
void genGlyphs(XftFont*, std::vector<Glx::Glyph>&);
int bigEnough(int);
Display* xdpy;
XftFont* font;
std::vector<Glx::Glyph> glyphs;
const float fscale;
float rgb[3];
};
};
#endif
| 25.490566 | 71 | 0.635825 |
45dab440bc83e1d5ac05bbbebf9f9774019f3729 | 16,109 | h | C | references/rigidcubes_04/dxdbg.h | iancarnation/AIE_Physics | 7e3deeac46f274dec066e5b2fdaba1add63708ce | [
"MIT"
] | null | null | null | references/rigidcubes_04/dxdbg.h | iancarnation/AIE_Physics | 7e3deeac46f274dec066e5b2fdaba1add63708ce | [
"MIT"
] | null | null | null | references/rigidcubes_04/dxdbg.h | iancarnation/AIE_Physics | 7e3deeac46f274dec066e5b2fdaba1add63708ce | [
"MIT"
] | 3 | 2017-01-04T19:48:57.000Z | 2020-03-24T03:05:27.000Z | /**********************************************************************************/
/* */
/* File: dxdbg.h */
/* Author: bkenwright@xbdev.net */
/* Web: www.xbdev.net */
/* Date: 10-12-2005 (xmas) */
/* */
/**********************************************************************************/
/*
Updated: 12-12-05
Simple debug functions/classes.
Implemented so you can add simple debugging/testing output to various demos/
games/test apps etc. Most of the methods make use of static variables so
functions can be called within main loops and won't create/release resources
over and over again - this is so we don't have to create globals and also don't
loose out due to inefficient creation/releasing of resources such as fonts
bitmaps etc.
Also designed for easy implementation of directx8 and directx9
*/
/**********************************************************************************/
/*
Updated: 19-12-2005 (xmas)
*/
/**********************************************************************************/
#ifndef DXDBG_H
#define DXDBG_H
#include <d3dx9.h>
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")
//#pragma comment(lib, "d3d8.lib") // DirectX Library Files
//#pragma comment(lib, "d3dx8.lib")
//#include <d3dx8.h> // DirectX Header File
#include <stdio.h> // sprintf(..)
#if(DIRECT3D_VERSION >= 0x0900)
#define IDirect3DDevice IDirect3DDevice9
#define IDirect3DTexture IDirect3DTexture9
#define IDirect3DIndexBuffer IDirect3DIndexBuffer9
#define IDirect3DVertexBuffer IDirect3DVertexBuffer9
#else
#define IDirect3DDevice IDirect3DDevice8
#define IDirect3DTexture IDirect3DTexture8
#define IDirect3DIndexBuffer IDirect3DIndexBuffer8
#define IDirect3DVertexBuffer IDirect3DVertexBuffer8
#endif // DIRECT3D_VERSION
void StatsDisplay(IDirect3DDevice * pDevice,
char * str);
void FlatTexture(IDirect3DDevice * pDevice,
IDirect3DTexture * pTexture );
void TriDisplay(IDirect3DDevice * pDevice,
int nTris);
void printf(IDirect3DDevice * pDevice,
char * str,
float xpos = 10,
float ypos = 10,
unsigned int rgb = 0xffffff,
int size = 15);
void FPSDisplay(IDirect3DDevice * pDevice);
void FlatSquare(IDirect3DDevice * pDevice,
float x,
float y,
float w,
float h,
unsigned int col );
void DrawLine2D(IDirect3DDevice * pDevice,
float x0, float y0,
float x1, float y1,
unsigned int col );
// Simple 3D Line Drawing Function
void DrawLine3D(IDirect3DDevice9 * pDevice,
const D3DXVECTOR3& from,
const D3DXVECTOR3& to,
unsigned int col = 0xffff00ff,
const D3DXMATRIX& mat = D3DXMATRIX(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1));
void DrawArrowLine(IDirect3DDevice9 * pDevice,
const D3DXVECTOR3& from,
const D3DXVECTOR3& to,
unsigned int col = 0xffff00ff);
//void DrawCube(IDirect3DDevice* pDevice, D3DXMATRIX* matWorld, D3DXVECTOR3 dim=D3DXVECTOR3(1,1,1));
#define DBG_HALT {__asm { int 10 }}
#define ErrMsg(str) ErrorMessageB(str, __FILE__, __FUNCTION__, __LINE__);
//#define ErrMsg(str) ErrorMessageA(str);
void ErrorMessageA(char * str);
void ErrorMessageB(char * str,
char* szFile,
char* szFunction,
long nLine);
void DrawText(IDirect3DDevice9 * pDevice,
char * str,
int xpos = 10,
int ypos = 10,
unsigned int argb = 0xffffffff,
int size =15);
class debugtxt
{
public:
debugtxt(IDirect3DDevice * pDevice){ Create(pDevice); };
~debugtxt(){ Release(); };
public:
ID3DXFont* pFont;
public:
void printf(char * str,
int xpos = 10,
int ypos = 10,
unsigned int rgb = 0xffffffff)
{
static char szbuff[900];
sprintf(szbuff, "%s", str );
RECT rect = {xpos,ypos, xpos+800,ypos+800};
#if(DIRECT3D_VERSION >= 0x0900)
pFont->DrawTextA(NULL, szbuff,
-1,
&rect,
DT_LEFT,
rgb);
#else
pFont->DrawTextA(szbuff,
-1,
&rect,
DT_LEFT,
rgb);
#endif // DIRECT3D_VERSION
}
protected:
bool Create(IDirect3DDevice * pDevice)
{
#if(DIRECT3D_VERSION >= 0x0900)
D3DXCreateFont(pDevice, // LPDIRECT3DDEVICE9
15, // Width
0, // Height
FW_NORMAL, // Weight
1, // MipLevels
false, // Italic
ANSI_CHARSET, // CharSet
OUT_DEFAULT_PRECIS, // OutputPrecision
DEFAULT_QUALITY, // Quality
FIXED_PITCH , // PitchAndFamily
"Arial", // pFacename
&pFont); // LPD3DXFONT
/*
static LOGFONT lfont={
15, // height
0, // width;
0, // lfEscapement;
0, // lfOrientation;
FW_BOLD, // lfWeight;
FALSE, // lfItalic;
FALSE, // lfUnderline;
FALSE, // lfStrikeOut;
DEFAULT_CHARSET, // lfCharSet;
OUT_DEFAULT_PRECIS, // lfOutPrecision;
CLIP_DEFAULT_PRECIS, // lfClipPrecision;
ANTIALIASED_QUALITY, // lfQuality;
FIXED_PITCH, // lfPitchAndFamily;
"Arial" // lfFaceName[LF_FACESIZE];
};
lfont.lfHeight = 15;
//This is all there is to creating a D3DXFont. Hmmmm....
D3DXCreateFontIndirect( pDevice ,&lfont,&pFont );
*/
#else
static LOGFONT lfont={
15, // height
0, // width;
0, // lfEscapement;
0, // lfOrientation;
FW_BOLD, // lfWeight;
FALSE, // lfItalic;
FALSE, // lfUnderline;
FALSE, // lfStrikeOut;
DEFAULT_CHARSET, // lfCharSet;
OUT_DEFAULT_PRECIS, // lfOutPrecision;
CLIP_DEFAULT_PRECIS, // lfClipPrecision;
ANTIALIASED_QUALITY, // lfQuality;
FIXED_PITCH, // lfPitchAndFamily;
"Arial" // lfFaceName[LF_FACESIZE];
};
lfont.lfHeight = 15;
//This is all there is to creating a D3DXFont. Hmmmm....
D3DXCreateFontIndirect( pDevice ,&lfont,&pFont );
#endif // DIRECT3D_VERSION
return true;
}//End Create(..)
void Release()
{
pFont->Release();
}
};
class debugsphere
{
IDirect3DVertexBuffer* m_pVertexBuffer;
IDirect3DIndexBuffer* m_pIndexBuffer;
DWORD m_dwNumOfVertices;
DWORD m_dwNumOfIndices;
UINT D3DFVF_CUSTOMVERTEX; // (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE);
struct CUSTOMVERTEX
{
FLOAT x, y, z; //Vertex position
FLOAT nx, ny, nz; //Direction the vertex is facing(normal)
DWORD colour; //The vertex colour.
};
public:
debugsphere(IDirect3DDevice * pDevice, DWORD col=0xffff0000){ Create(pDevice, col); };
~debugsphere(){ Release(); };
int GetNumTris(){ return (m_dwNumOfIndices - 2); }
void Draw(IDirect3DDevice * pDevice,
const float centerx,
const float centery,
const float centerz,
const float radius )
{
D3DXMATRIX matMove;
D3DXMatrixTranslation(&matMove, centerx, centery, centerz);
D3DXMATRIX matScale;
D3DXMatrixScaling(&matScale, radius, radius, radius);
D3DXMATRIX matWorld = matScale * matMove;
Draw(pDevice, &matWorld, radius * 0.5f);
}
void Draw(IDirect3DDevice * pDevice,
D3DXMATRIX* matWorld,
float radius)
{
D3DXMATRIX matScale;
D3DXMatrixScaling(&matScale, radius, radius, radius);
pDevice->SetTransform(D3DTS_WORLD, &(matScale * (*matWorld)));
//Select the index buffer
DWORD dwNumOfPolygons = m_dwNumOfIndices - 2;
#if(DIRECT3D_VERSION >= 0x0900)
pDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
pDevice->SetVertexShader(NULL);
pDevice->SetPixelShader(NULL);
pDevice->SetStreamSource(0, m_pVertexBuffer, 0, sizeof(CUSTOMVERTEX));
pDevice->SetIndices(m_pIndexBuffer);
//Render the polygons from the index buffer
pDevice->DrawIndexedPrimitive(D3DPT_TRIANGLESTRIP,
0,
0,
m_dwNumOfVertices,
0,
dwNumOfPolygons);
#else
pDevice->SetVertexShader(D3DFVF_CUSTOMVERTEX);
pDevice->SetStreamSource(0, m_pVertexBuffer, sizeof(CUSTOMVERTEX));
pDevice->SetIndices(m_pIndexBuffer, 0);
//Render the polygons from the index buffer
pDevice->DrawIndexedPrimitive(D3DPT_TRIANGLESTRIP,
0,
m_dwNumOfVertices,
0,
dwNumOfPolygons);
#endif
}
protected:
void Release()
{
if (m_pIndexBuffer) m_pIndexBuffer->Release();
if (m_pVertexBuffer) m_pVertexBuffer->Release();
}
void Create(IDirect3DDevice * pDevice, DWORD col)
{
D3DFVF_CUSTOMVERTEX = (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE);
//These two variables determine the quality of our sphere, try changing them,
//if you put a large number in them you'll get a very details sphere...made
//up of very small triangles.
int nRings = 8;
int nSegments = 8;
m_dwNumOfVertices = (nRings + 1) * (nSegments + 1);
m_dwNumOfIndices = 2 * nRings * (nSegments + 1);
m_pVertexBuffer = NULL;
m_pIndexBuffer = NULL;
WORD *pIndices = NULL;
CUSTOMVERTEX *pVertex = NULL;
#if(DIRECT3D_VERSION >= 0x0900)
pDevice->CreateVertexBuffer(m_dwNumOfVertices * sizeof(CUSTOMVERTEX),
0, D3DFVF_CUSTOMVERTEX,
D3DPOOL_DEFAULT, &m_pVertexBuffer,
NULL);
pDevice->CreateIndexBuffer( m_dwNumOfIndices * sizeof(WORD),
0, D3DFMT_INDEX16, D3DPOOL_MANAGED,
&m_pIndexBuffer,
NULL);
m_pVertexBuffer->Lock(0,0, (void**)&pVertex, 0);
m_pIndexBuffer->Lock(0,m_dwNumOfIndices, (void**)&pIndices, 0);
#else
pDevice->CreateVertexBuffer(m_dwNumOfVertices * sizeof(CUSTOMVERTEX),
0, D3DFVF_CUSTOMVERTEX,
D3DPOOL_DEFAULT, &m_pVertexBuffer);
pDevice->CreateIndexBuffer( m_dwNumOfIndices * sizeof(WORD),
0, D3DFMT_INDEX16, D3DPOOL_MANAGED,
&m_pIndexBuffer);
m_pVertexBuffer->Lock(0,0, (BYTE**)&pVertex, 0);
m_pIndexBuffer->Lock(0,m_dwNumOfIndices, (BYTE**)&pIndices, 0);
#endif
WORD wVertexIndex = 0;
D3DXVECTOR3 vNormal;
//Setup some angles
float rDeltaRingAngle = (D3DX_PI / nRings);
float rDeltaSegAngle = (2.0f * D3DX_PI / nSegments);
float red = (static_cast<float>((col>>16)&0xff))/256.0f;
float green = (static_cast<float>((col>>8)&0xff))/256.0f;
float blue = (static_cast<float>((col>>0)&0xff))/256.0f;
//Generate the group of rings for the sphere
for(int nCurrentRing = 0; nCurrentRing < nRings + 1; nCurrentRing++)
{
float r0 = sinf(nCurrentRing * rDeltaRingAngle);
float y0 = cosf(nCurrentRing * rDeltaRingAngle);
//OOooo Gerneate the group of segments for the current ring
for(int nCurrentSegment=0; nCurrentSegment < nSegments + 1; nCurrentSegment++)
{
float x0 = r0 * sinf(nCurrentSegment * rDeltaSegAngle);
float z0 = r0 * cosf(nCurrentSegment * rDeltaSegAngle);
vNormal.x = x0;
vNormal.y = y0;
vNormal.z = z0;
D3DXVec3Normalize(&vNormal, &vNormal);
//Add one vector to the strip which makes up the sphere
pVertex->x = x0;
pVertex->y = y0;
pVertex->z = z0;
pVertex->nx = vNormal.x;
pVertex->ny = vNormal.y;
pVertex->nz = vNormal.z;
pVertex->colour = D3DXCOLOR(red, green, blue, 1.0f);
//red += 0.02f;
//blue += 0.01f;
//green -= 0.015f;
/*
//Alternatively you could set texture coordinates e.g:
pVertex->tu = 1.0f - ( (float)nCurrentSegment / (float)nSegments );
pVertex->tv = (float)nCurrent / (float)nRings;
*/
pVertex++;
//Add two indices except for the last ring
if(nCurrentRing != nRings)
{
*pIndices = wVertexIndex;
pIndices++;
*pIndices = wVertexIndex + (WORD)(nSegments + 1);
pIndices++;
wVertexIndex++;
}
}
}
m_pIndexBuffer->Unlock();
m_pVertexBuffer->Unlock();
}
};
class debug_wire_ground
{
IDirect3DVertexBuffer* m_pVertexBuffer;
DWORD m_dwNumOfVertices;
UINT D3DFVF_CUSTOMVERTEX; // (D3DFVF_XYZ|D3DFVF_DIFFUSE);
struct CUSTOMVERTEX
{
FLOAT x, y, z; //Vertex position
DWORD colour; //The vertex colour.
};
public:
debug_wire_ground( IDirect3DDevice * pDevice, // pointer directx device
int xres, // num lines x plane
int zres) // num lines y plane
{
Create(pDevice, xres, zres);
};
~debug_wire_ground(){ Release(); };
int GetNumTris(){ return (m_dwNumOfVertices / 2); }
void Draw(IDirect3DDevice * pDevice,
float centerx,
float centery,
float centerz,
float scale )
{
D3DXMATRIX matMove;
D3DXMatrixTranslation(&matMove, centerx, centery, centerz);
D3DXMATRIX matScale;
D3DXMatrixScaling(&matScale, scale, scale, scale);
D3DXMATRIX matWorld = matScale * matMove;
pDevice->SetTransform(D3DTS_WORLD, &matWorld);
pDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
pDevice->SetTextureStageState(0,D3DTSS_COLORARG1, D3DTA_DIFFUSE);
#if(DIRECT3D_VERSION >= 0x0900)
pDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
pDevice->SetVertexShader(NULL);
pDevice->SetPixelShader(NULL);
pDevice->SetStreamSource(0, m_pVertexBuffer, 0, sizeof(CUSTOMVERTEX));
pDevice->DrawPrimitive(D3DPT_LINELIST, 0, m_dwNumOfVertices/2);
#else
pDevice->SetVertexShader(D3DFVF_CUSTOMVERTEX);
pDevice->SetStreamSource(0, m_pVertexBuffer, sizeof(CUSTOMVERTEX));
pDevice->DrawPrimitive(D3DPT_LINELIST, 0, m_dwNumOfVertices/2);
#endif
}
protected:
void Release()
{
m_pVertexBuffer->Release();
}
void Create(IDirect3DDevice * pDevice,
int nXResolution,
int nZResolution)
{
D3DFVF_CUSTOMVERTEX = (D3DFVF_XYZ|D3DFVF_DIFFUSE);
//These two variables determine the quality of our sphere, try changing them,
//if you put a large number in them you'll get a very details sphere...made
//up of very small triangles.
int nZ = nZResolution;
int nX = nXResolution;
m_dwNumOfVertices = (nX+1) * (nZ+1) * 2;
m_pVertexBuffer = NULL;
CUSTOMVERTEX *pVertex = NULL;
#if(DIRECT3D_VERSION >= 0x0900)
pDevice->CreateVertexBuffer(m_dwNumOfVertices * sizeof(CUSTOMVERTEX),
0, D3DFVF_CUSTOMVERTEX,
D3DPOOL_DEFAULT, &m_pVertexBuffer,
NULL);
m_pVertexBuffer->Lock(0,0, (void**)&pVertex, 0);
#else
pDevice->CreateVertexBuffer(m_dwNumOfVertices * sizeof(CUSTOMVERTEX),
0, D3DFVF_CUSTOMVERTEX,
D3DPOOL_DEFAULT, &m_pVertexBuffer);
m_pVertexBuffer->Lock(0,0, (BYTE**)&pVertex, 0);
#endif
//So our grid is scaled from 0 to 1
float fDeltaX = (1.0f / nX);
float fDeltaZ = (1.0f / nZ);
//Generate the
DWORD dwColour = 0xff010101; // aarrggbb
for(int nCurrentZ=0; nCurrentZ < nZ+1; nCurrentZ+=2)
{
float z0 = -0.5f + (nCurrentZ * fDeltaZ);
float z1 = -0.5f + (nCurrentZ * fDeltaZ);
float x0 = -0.5f;
float x1 = 0.5f;
float y0 = 0;
float y1 = 0;
//Add one vector to the strip which makes up the sphere
pVertex->x = x0;
pVertex->y = y0;
pVertex->z = z0;
pVertex->colour = dwColour;
pVertex++;
pVertex->x = x1;
pVertex->y = y1;
pVertex->z = z1;
pVertex->colour = dwColour;
pVertex++;
}
for(int nCurrentX=0; nCurrentX < nX+1; nCurrentX+=2)
{
float z0 = -0.5f;
float z1 = 0.5f;
float x0 = -0.5f + (nCurrentX * fDeltaX);
float x1 = -0.5f + (nCurrentX * fDeltaX);
float y0 = 0;
float y1 = 0;
//Add one vector to the strip which makes up the sphere
pVertex->x = x0;
pVertex->y = y0;
pVertex->z = z0;
pVertex->colour = dwColour;
pVertex++;
pVertex->x = x1;
pVertex->y = y1;
pVertex->z = z1;
pVertex->colour = dwColour;
pVertex++;
}
m_pVertexBuffer->Unlock();
}
};
#endif // DXDBG_H | 25.249216 | 100 | 0.619405 |
aa2a9321e4790a8c769f532beeffb8f078bbec42 | 4,606 | h | C | components/i2c/i2c.h | abradianu/esp8266_iot | 53533a50daa6148b6ecea1619fd409e272152b69 | [
"MIT"
] | null | null | null | components/i2c/i2c.h | abradianu/esp8266_iot | 53533a50daa6148b6ecea1619fd409e272152b69 | [
"MIT"
] | null | null | null | components/i2c/i2c.h | abradianu/esp8266_iot | 53533a50daa6148b6ecea1619fd409e272152b69 | [
"MIT"
] | null | null | null | /*
* The MIT License (MIT)
*
* Copyright (c) 2015 Johan Kanflo (github.com/kanflo)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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.
*/
/**
* I2C driver for ESP8266 written for use with esp-open-rtos
* Based on https://en.wikipedia.org/wiki/I²C#Example_of_bit-banging_the_I.C2.B2C_Master_protocol
*/
#ifndef __I2C_H__
#define __I2C_H__
#include <stdint.h>
#include <stdbool.h>
#include <errno.h>
#include <FreeRTOS.h>
#include <task.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* Define i2c bus max number
*/
#ifndef I2C_MAX_BUS
#define I2C_MAX_BUS 2
#endif
/* Default clock strech waiting time, 250 msec. */
#define I2C_DEFAULT_CLK_STRETCH (250 / portTICK_PERIOD_MS)
/**
* Device descriptor
*/
typedef struct i2c_dev
{
uint8_t bus;
uint8_t addr;
} i2c_dev_t;
/// Level 0 API
/**
* Init bitbanging I2C driver on given pins
* @param bus Bus i2c selection
* @param scl_pin SCL pin for I2C
* @param sda_pin SDA pin for I2C
* @param freq frequency of bus in hertz
* @return Non-zero if error occured
*/
int i2c_init(uint8_t bus, uint8_t scl_pin, uint8_t sda_pin, uint32_t freq);
/**
* Change bus frequency
* @param bus Bus i2c selection
* @param freq frequency of bus in hertz
*/
int i2c_set_frequency(uint8_t bus, uint32_t freq);
/**
* Change clock stretch
* @param bus I2C bus
* @param clk_stretch I2C clock stretch, in ticks. I2C_DEFAULT_CLK_STRETCH by default
*/
void i2c_set_clock_stretch(uint8_t bus, TickType_t clk_stretch);
/**
* Write a byte to I2C bus.
* @param bus Bus i2c selection
* @param byte Pointer to device descriptor
* @return true if slave acked
*/
bool i2c_write(uint8_t bus, uint8_t byte);
/**
* Read a byte from I2C bus.
* @param bus Bus i2c selection
* @param ack Set Ack for slave (false: Ack // true: NoAck)
* @return byte read from slave.
*/
uint8_t i2c_read(uint8_t bus, bool ack);
/**
* Send start or restart condition
* @param bus Bus i2c selection
*/
void i2c_start(uint8_t bus);
/**
* Send stop condition
* @param bus Bus i2c selection
* @return false if link was broken
*/
bool i2c_stop(uint8_t bus);
/**
* get status from I2C bus.
* @param bus Bus i2c selection
* @return true if busy.
*/
bool i2c_status(uint8_t bus);
/// Level 1 API (Don't need functions above)
/**
* This function will allow you to force a transmission I2C, cancel current transmission.
* Warning: Use with precaution. Don't use it if you can avoid it. Usefull for priority transmission.
* @param bus Bus i2c selection
* @param state Force the next I2C transmission if true (Use with precaution)
*/
void i2c_force_bus(uint8_t bus, bool state);
/**
* Write 'len' bytes from 'buf' to slave at 'data' register adress .
* @param bus Bus i2c selection
* @param slave_addr slave device address
* @param data Pointer to register address to send if non-null
* @param buf Pointer to data buffer
* @param len Number of byte to send
* @return Non-Zero if error occured
*/
int i2c_slave_write(uint8_t bus, uint8_t slave_addr, const uint8_t *data, const uint8_t *buf, uint32_t len);
/**
* Issue a send operation of 'data' register adress, followed by reading 'len' bytes
* from slave into 'buf'.
* @param bus Bus i2c selection
* @param slave_addr slave device address
* @param data Pointer to register address to send if non-null
* @param buf Pointer to data buffer
* @param len Number of byte to read
* @return Non-Zero if error occured
*/
int i2c_slave_read(uint8_t bus, uint8_t slave_addr, const uint8_t *data, uint8_t *buf, uint32_t len);
#ifdef __cplusplus
}
#endif
#endif /* __I2C_H__ */
| 28.608696 | 108 | 0.729917 |
343270f4b8491108a083aa32c2a0063a5c8fe4b0 | 687 | h | C | src/SIMLib/MotorControl.h | jkapi/SIM1 | 498194ca648c1a566081e7483160ce0542119d4f | [
"Apache-2.0"
] | null | null | null | src/SIMLib/MotorControl.h | jkapi/SIM1 | 498194ca648c1a566081e7483160ce0542119d4f | [
"Apache-2.0"
] | null | null | null | src/SIMLib/MotorControl.h | jkapi/SIM1 | 498194ca648c1a566081e7483160ce0542119d4f | [
"Apache-2.0"
] | null | null | null | #ifndef SIMLib_Motor_h
#define SIMLib_Motor_h
#include "Arduino.h"
#include "LedControl.h"
#define LEFT 1
#define RIGHT 2
#define FORWARD 4
#define BACKWARD -1
#define GO 1
#define BRAKE 0
class MotorControl
{
public:
MotorControl();
void init();
void drive(byte Motor, int Speed, int Action);
void brake(byte Motor, bool Brake);
void forward(int Speed = 127);
void backward(int Speed = 127);
void turn(int Direction, int TurnSpeed = 127);
private:
static int speedLeft;
static int speedRight;
void driveLeft(int Speed, int Action);
void driveRight(int Speed, int Action);
};
extern MotorControl Motors;
#endif
| 19.083333 | 50 | 0.676856 |
836f384bbeabde5d093512915ca9e4abcff2c152 | 1,745 | h | C | micron_flash_32Mb/include/stm32f7xx_hal_msp.h | pacabot/zhonx4 | 99a937f4252fe0e533962195b10f71358e50ec22 | [
"Apache-2.0"
] | 1 | 2020-05-12T04:33:39.000Z | 2020-05-12T04:33:39.000Z | micron_flash_32Mb/include/stm32f7xx_hal_msp.h | pacabot/QSPI_memory_firmware | 99a937f4252fe0e533962195b10f71358e50ec22 | [
"Apache-2.0"
] | null | null | null | micron_flash_32Mb/include/stm32f7xx_hal_msp.h | pacabot/QSPI_memory_firmware | 99a937f4252fe0e533962195b10f71358e50ec22 | [
"Apache-2.0"
] | null | null | null | /*
* stm32f7xx_hal_msp.h
*
* Created on: 24 août 2016
* Author: lord
*/
#ifndef INCLUDE_STM32F7XX_HAL_MSP_H_
#define INCLUDE_STM32F7XX_HAL_MSP_H_
/* Definition for QSPI clock resources */
#define QSPI_CLK_ENABLE() __HAL_RCC_QSPI_CLK_ENABLE()
#define QSPI_CLK_DISABLE() __HAL_RCC_QSPI_CLK_DISABLE()
#define QSPI_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define QSPI_CLK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define QSPI_D0_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
#define QSPI_D1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
#define QSPI_D2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
#define QSPI_D3_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
#define QSPI_DMA_CLK_ENABLE() __HAL_RCC_DMA2_CLK_ENABLE()
#define QSPI_FORCE_RESET() __HAL_RCC_QSPI_FORCE_RESET()
#define QSPI_RELEASE_RESET() __HAL_RCC_QSPI_RELEASE_RESET()
/* Definition for QSPI Pins */
#define QSPI_CS_PIN GPIO_PIN_6
#define QSPI_CS_GPIO_PORT GPIOB
#define QSPI_CLK_PIN GPIO_PIN_2
#define QSPI_CLK_GPIO_PORT GPIOB
#define QSPI_D0_PIN GPIO_PIN_8
#define QSPI_D0_GPIO_PORT GPIOF
#define QSPI_D1_PIN GPIO_PIN_9
#define QSPI_D1_GPIO_PORT GPIOF
#define QSPI_D2_PIN GPIO_PIN_7
#define QSPI_D2_GPIO_PORT GPIOF
#define QSPI_D3_PIN GPIO_PIN_6
#define QSPI_D3_GPIO_PORT GPIOF
/* Definition for QSPI DMA */
#define QSPI_DMA_INSTANCE DMA2_Stream7
#define QSPI_DMA_CHANNEL DMA_CHANNEL_3
#define QSPI_DMA_IRQ DMA2_Stream7_IRQn
#define QSPI_DMA_IRQ_HANDLER DMA2_Stream7_IRQHandler
#endif /* INCLUDE_STM32F7XX_HAL_MSP_H_ */
| 36.354167 | 65 | 0.734097 |
03303cd013bf00763e53dc012d8b70aad5c7b5c0 | 347 | h | C | Flyweight Pattern/ShapeFactory.h | helanzhu/Design-Pattern | d01ed2ed9f5c2898ddb60b80ca8a116503405adf | [
"MIT"
] | null | null | null | Flyweight Pattern/ShapeFactory.h | helanzhu/Design-Pattern | d01ed2ed9f5c2898ddb60b80ca8a116503405adf | [
"MIT"
] | null | null | null | Flyweight Pattern/ShapeFactory.h | helanzhu/Design-Pattern | d01ed2ed9f5c2898ddb60b80ca8a116503405adf | [
"MIT"
] | null | null | null | //
// ShapeFactory.h
// Flyweight Factory
//
// Created by chenqg on 2019/11/7.
// Copyright © 2019 chenqg. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "Circle.h"
NS_ASSUME_NONNULL_BEGIN
@interface ShapeFactory : NSObject
- (Circle *)createCircleWithColorType:(CircleColorType)colorType;
@end
NS_ASSUME_NONNULL_END
| 16.52381 | 65 | 0.74928 |
03e3f3e0ef0b916959412cacadbd805cc9eade54 | 277 | h | C | dfs-adapter-1.0.0/afs.h | GeekerClub/thirdparty | aa3057801b89accee71e0dd697fbec2c216c6b32 | [
"MIT"
] | null | null | null | dfs-adapter-1.0.0/afs.h | GeekerClub/thirdparty | aa3057801b89accee71e0dd697fbec2c216c6b32 | [
"MIT"
] | null | null | null | dfs-adapter-1.0.0/afs.h | GeekerClub/thirdparty | aa3057801b89accee71e0dd697fbec2c216c6b32 | [
"MIT"
] | null | null | null | // Copyright (C) 2018, For authors.
// Author: Xiang Zhang (zhangxiang.gk@gmail.com)
//
// Description:
#ifndef PUBLIC_LIBDFS_SRC_WRAPPER_AFS_H
#define PUBLIC_LIBDFS_SRC_WRAPPER_AFS_H
#include "afs_filesystem.h"
#endif //__AFS_H_
/* vim: set ts=4 sw=4 sts=4 tw=100 et: */
| 19.785714 | 48 | 0.732852 |
23c6686507544d90c78965cfebf894eed9e5a480 | 1,123 | c | C | drivers/fpga_buzzer/fpga_test_buzzer.c | hummingbird-12/embedded-system | 2cd9d1664fd002916d46daa602c25951a7ce9d2b | [
"MIT"
] | null | null | null | drivers/fpga_buzzer/fpga_test_buzzer.c | hummingbird-12/embedded-system | 2cd9d1664fd002916d46daa602c25951a7ce9d2b | [
"MIT"
] | null | null | null | drivers/fpga_buzzer/fpga_test_buzzer.c | hummingbird-12/embedded-system | 2cd9d1664fd002916d46daa602c25951a7ce9d2b | [
"MIT"
] | 1 | 2021-05-29T08:48:43.000Z | 2021-05-29T08:48:43.000Z | /* FPGA Buzzer Test Application
File : fpga_test_buzzer.c
Auth : largest@huins.com */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <signal.h>
#define BUZZER_DEVICE "/dev/fpga_buzzer"
unsigned char quit = 0;
void user_signal1(int sig)
{
quit = 1;
}
int main(int argc, char **argv)
{
int dev;
unsigned char state=0;
unsigned char retval;
unsigned char data;
dev = open(BUZZER_DEVICE, O_RDWR);
if (dev<0) {
printf("Device open error : %s\n",BUZZER_DEVICE);
exit(1);
}
(void)signal(SIGINT, user_signal1);
printf("Press <ctrl+c> to exit.\n");
while(!quit) {
if(state!=0) {
state=0;
data=1;
retval=write(dev,&data,1);
if(retval<0) {
printf("Write Error!\n");
return -1;
}
} else {
state=1;
data=0;
retval=write(dev,&data,1);
if(retval<0) {
printf("Write Error!\n");
return -1;
}
}
sleep(1);
}
printf("Current Buzzer Value : %d\n",data);
close(dev);
return(0);
}
| 16.275362 | 52 | 0.586821 |
aff26cf760b39e10017b39af11e8ea562ef1a2fb | 385 | h | C | w806_fw/src/common/hw/include/led.h | chcbaram/HLK-W806-KIT | 23764b9231f8f36a868e641d56900d618591a3ff | [
"MIT"
] | null | null | null | w806_fw/src/common/hw/include/led.h | chcbaram/HLK-W806-KIT | 23764b9231f8f36a868e641d56900d618591a3ff | [
"MIT"
] | null | null | null | w806_fw/src/common/hw/include/led.h | chcbaram/HLK-W806-KIT | 23764b9231f8f36a868e641d56900d618591a3ff | [
"MIT"
] | null | null | null | #ifndef SRC_COMMON_HW_INCLUDE_LED_H_
#define SRC_COMMON_HW_INCLUDE_LED_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "hw_def.h"
#ifdef _USE_HW_LED
#define LED_MAX_CH HW_LED_MAX_CH
bool ledInit(void);
bool ledDeInit(void);
bool ledIsInit(void);
void ledOn(uint8_t ch);
void ledOff(uint8_t ch);
void ledToggle(uint8_t ch);
#endif
#ifdef __cplusplus
}
#endif
#endif | 12.833333 | 39 | 0.763636 |
96ee2b73f3502128b5a0a598963be6889408f7d2 | 7,108 | c | C | app/out_html5/out/h3d/pass/SortByMaterial.c | Lerg/hashlink-emscripten | 8f5c28a879c78f275fcbc482e1c5f86c08dbe72e | [
"MIT"
] | 1 | 2021-10-03T16:34:38.000Z | 2021-10-03T16:34:38.000Z | app/out_html5/out/h3d/pass/SortByMaterial.c | Lerg/hashlink-emscripten | 8f5c28a879c78f275fcbc482e1c5f86c08dbe72e | [
"MIT"
] | null | null | null | app/out_html5/out/h3d/pass/SortByMaterial.c | Lerg/hashlink-emscripten | 8f5c28a879c78f275fcbc482e1c5f86c08dbe72e | [
"MIT"
] | null | null | null | // Generated by HLC 4.2.1 (HL v4)
#define HLC_BOOT
#include <hlc.h>
#include <h3d/pass/SortByMaterial.h>
#include <h3d/pass/PassList.h>
#include <h3d/pass/PassObject.h>
#include <hxsl/RuntimeShader.h>
void hl_types_ArrayBytes_Int___expand(hl__types__ArrayBytes_Int,int);
#include <hl/natives.h>
hl__types__ArrayBytes_Int hl_types_ArrayBase_allocI32(vbyte*,int);
void h3d_pass_SortByMaterial_sort(h3d__pass__SortByMaterial r0,h3d__pass__PassList r1) {
hxsl__RuntimeShader r11;
bool r16, r25;
hl__types__ArrayBytes_Int r9;
h3d__pass__SortByMaterial r2;
h3d__pass__PassObject r6, r7, r8, r12, r17, r20, r24, r26;
vbyte *r14;
int r4, r5, r10, r13, r15, r18, r19, r21, r22, r23;
r2 = r0;
r4 = r0->shaderCount;
r5 = r0->textureCount;
if( r1 == NULL ) hl_null_access();
r6 = r1->current;
label$b230747_1_5:
if( !r6 ) goto label$b230747_1_69;
r7 = r6;
if( r6 == NULL ) hl_null_access();
r8 = r6->next;
r6 = r8;
r9 = r0->shaderIdMap;
if( r9 == NULL ) hl_null_access();
if( r7 == NULL ) hl_null_access();
r11 = r7->shader;
if( r11 == NULL ) hl_null_access();
r10 = r11->id;
r13 = r9->length;
if( ((unsigned)r10) < ((unsigned)r13) ) goto label$b230747_1_21;
r10 = 0;
goto label$b230747_1_25;
label$b230747_1_21:
r14 = r9->bytes;
r13 = 2;
r13 = r10 << r13;
r10 = *(int*)(r14 + r13);
label$b230747_1_25:
if( r10 >= r4 ) goto label$b230747_1_42;
r9 = r0->shaderIdMap;
if( r9 == NULL ) hl_null_access();
r11 = r7->shader;
if( r11 == NULL ) hl_null_access();
r10 = r11->id;
r13 = r0->shaderCount;
r15 = r13;
++r13;
r0->shaderCount = r13;
r13 = r9->length;
if( ((unsigned)r10) < ((unsigned)r13) ) goto label$b230747_1_38;
hl_types_ArrayBytes_Int___expand(r9,r10);
label$b230747_1_38:
r14 = r9->bytes;
r13 = 2;
r13 = r10 << r13;
*(int*)(r14 + r13) = r15;
label$b230747_1_42:
r9 = r0->textureIdMap;
if( r9 == NULL ) hl_null_access();
r10 = r7->texture;
r13 = r9->length;
if( ((unsigned)r10) < ((unsigned)r13) ) goto label$b230747_1_49;
r10 = 0;
goto label$b230747_1_53;
label$b230747_1_49:
r14 = r9->bytes;
r13 = 2;
r13 = r10 << r13;
r10 = *(int*)(r14 + r13);
label$b230747_1_53:
if( r10 >= r5 ) goto label$b230747_1_68;
r9 = r0->textureIdMap;
if( r9 == NULL ) hl_null_access();
r10 = r7->texture;
r13 = r0->textureCount;
r15 = r13;
++r13;
r0->textureCount = r13;
r13 = r9->length;
if( ((unsigned)r10) < ((unsigned)r13) ) goto label$b230747_1_64;
hl_types_ArrayBytes_Int___expand(r9,r10);
label$b230747_1_64:
r14 = r9->bytes;
r13 = 2;
r13 = r10 << r13;
*(int*)(r14 + r13) = r15;
label$b230747_1_68:
goto label$b230747_1_5;
label$b230747_1_69:
if( r1 == NULL ) hl_null_access();
r6 = r1->current;
if( r6 ) goto label$b230747_1_75;
r8 = NULL;
r7 = r8;
goto label$b230747_1_220;
label$b230747_1_75:
r10 = 1;
r13 = 0;
r15 = 0;
label$b230747_1_78:
r16 = true;
if( !r16 ) goto label$b230747_1_219;
r8 = r6;
r12 = NULL;
r6 = r12;
r17 = NULL;
r12 = r17;
r19 = 0;
r18 = r19;
label$b230747_1_88:
if( !r8 ) goto label$b230747_1_209;
++r18;
r17 = r8;
r19 = 0;
r13 = r19;
r19 = 0;
r21 = r10;
label$b230747_1_96:
if( r19 >= r21 ) goto label$b230747_1_106;
++r19;
++r13;
if( r17 == NULL ) hl_null_access();
r20 = r17->next;
r17 = r20;
if( r20 ) goto label$b230747_1_105;
goto label$b230747_1_106;
label$b230747_1_105:
goto label$b230747_1_96;
label$b230747_1_106:
r15 = r10;
label$b230747_1_107:
r21 = 0;
if( r21 < r13 ) goto label$b230747_1_113;
r21 = 0;
if( r21 >= r15 ) goto label$b230747_1_207;
if( !r17 ) goto label$b230747_1_207;
label$b230747_1_113:
r21 = 0;
if( r13 != r21 ) goto label$b230747_1_121;
r20 = r17;
if( r17 == NULL ) hl_null_access();
r24 = r17->next;
r17 = r24;
--r15;
goto label$b230747_1_200;
label$b230747_1_121:
r21 = 0;
if( r15 == r21 ) goto label$b230747_1_187;
if( !r17 ) goto label$b230747_1_187;
if( r2 == NULL ) hl_null_access();
r9 = r2->shaderIdMap;
if( r9 == NULL ) hl_null_access();
if( r8 == NULL ) hl_null_access();
r11 = r8->shader;
if( r11 == NULL ) hl_null_access();
r19 = r11->id;
r21 = r9->length;
if( ((unsigned)r19) < ((unsigned)r21) ) goto label$b230747_1_135;
r19 = 0;
goto label$b230747_1_139;
label$b230747_1_135:
r14 = r9->bytes;
r21 = 2;
r21 = r19 << r21;
r19 = *(int*)(r14 + r21);
label$b230747_1_139:
r9 = r2->shaderIdMap;
if( r9 == NULL ) hl_null_access();
if( r17 == NULL ) hl_null_access();
r11 = r17->shader;
if( r11 == NULL ) hl_null_access();
r21 = r11->id;
r22 = r9->length;
if( ((unsigned)r21) < ((unsigned)r22) ) goto label$b230747_1_149;
r21 = 0;
goto label$b230747_1_153;
label$b230747_1_149:
r14 = r9->bytes;
r22 = 2;
r22 = r21 << r22;
r21 = *(int*)(r14 + r22);
label$b230747_1_153:
r19 = r19 - r21;
r22 = 0;
if( r19 == r22 ) goto label$b230747_1_158;
r21 = r19;
goto label$b230747_1_181;
label$b230747_1_158:
r9 = r2->textureIdMap;
if( r9 == NULL ) hl_null_access();
r21 = r8->texture;
r22 = r9->length;
if( ((unsigned)r21) < ((unsigned)r22) ) goto label$b230747_1_165;
r21 = 0;
goto label$b230747_1_169;
label$b230747_1_165:
r14 = r9->bytes;
r22 = 2;
r22 = r21 << r22;
r21 = *(int*)(r14 + r22);
label$b230747_1_169:
r9 = r2->textureIdMap;
if( r9 == NULL ) hl_null_access();
r22 = r17->texture;
r23 = r9->length;
if( ((unsigned)r22) < ((unsigned)r23) ) goto label$b230747_1_176;
r22 = 0;
goto label$b230747_1_180;
label$b230747_1_176:
r14 = r9->bytes;
r23 = 2;
r23 = r22 << r23;
r22 = *(int*)(r14 + r23);
label$b230747_1_180:
r21 = r21 - r22;
label$b230747_1_181:
r22 = 0;
if( r21 <= r22 ) goto label$b230747_1_185;
r25 = false;
goto label$b230747_1_186;
label$b230747_1_185:
r25 = true;
label$b230747_1_186:
goto label$b230747_1_188;
label$b230747_1_187:
r25 = true;
label$b230747_1_188:
if( !r25 ) goto label$b230747_1_195;
r20 = r8;
if( r8 == NULL ) hl_null_access();
r24 = r8->next;
r8 = r24;
--r13;
goto label$b230747_1_200;
label$b230747_1_195:
r20 = r17;
if( r17 == NULL ) hl_null_access();
r24 = r17->next;
r17 = r24;
--r15;
label$b230747_1_200:
if( !r12 ) goto label$b230747_1_204;
if( r12 == NULL ) hl_null_access();
r12->next = r20;
goto label$b230747_1_205;
label$b230747_1_204:
r6 = r20;
label$b230747_1_205:
r12 = r20;
goto label$b230747_1_107;
label$b230747_1_207:
r8 = r17;
goto label$b230747_1_88;
label$b230747_1_209:
if( r12 == NULL ) hl_null_access();
r26 = NULL;
r12->next = r26;
r21 = 1;
if( r21 < r18 ) goto label$b230747_1_215;
goto label$b230747_1_219;
label$b230747_1_215:
r21 = 2;
r19 = r10 * r21;
r10 = r19;
goto label$b230747_1_78;
label$b230747_1_219:
r7 = r6;
label$b230747_1_220:
if( r1 == NULL ) hl_null_access();
r1->current = r7;
return;
}
void h3d_pass_SortByMaterial_new(h3d__pass__SortByMaterial r0) {
hl__types__ArrayBytes_Int r2;
vbyte *r3;
int r1;
r1 = 1;
r0->textureCount = r1;
r1 = 1;
r0->shaderCount = r1;
r1 = 0;
r3 = hl_alloc_bytes(r1);
r1 = 0;
r1 = 0;
r2 = hl_types_ArrayBase_allocI32(r3,r1);
r0->shaderIdMap = r2;
r1 = 0;
r3 = hl_alloc_bytes(r1);
r1 = 0;
r1 = 0;
r2 = hl_types_ArrayBase_allocI32(r3,r1);
r0->textureIdMap = r2;
return;
}
| 23.304918 | 88 | 0.662212 |
cab8a549b4f29d3c457a92523fa19bc40e29b2fc | 249 | h | C | src/math_isqrt.h | nptcl/npt | 608c1bf38380aaa9e20748458b7f091da898d535 | [
"Unlicense"
] | 37 | 2019-02-24T00:07:11.000Z | 2022-03-03T09:41:43.000Z | src/math_isqrt.h | nptcl/npt | 608c1bf38380aaa9e20748458b7f091da898d535 | [
"Unlicense"
] | 9 | 2019-07-01T04:08:36.000Z | 2021-06-13T03:51:43.000Z | src/math_isqrt.h | nptcl/npt | 608c1bf38380aaa9e20748458b7f091da898d535 | [
"Unlicense"
] | 2 | 2019-04-11T04:01:02.000Z | 2019-07-15T08:21:00.000Z | #ifndef __MATH_ISQRT_HEADER__
#define __MATH_ISQRT_HEADER__
#include "define.h"
#include "local.h"
#include "typedef.h"
#define isqrt_number_common_ _n(isqrt_number_common_)
int isqrt_number_common_(LocalRoot local, addr var, addr *ret);
#endif
| 19.153846 | 63 | 0.803213 |
6ccc9b53f602092a31b18be6a75bb650c3d82152 | 47 | h | C | XDAudioDevice/stdafx.h | op07n/Digi-XD | 66c5d39ccd384d108ed9dd923798474a64823c70 | [
"MIT"
] | null | null | null | XDAudioDevice/stdafx.h | op07n/Digi-XD | 66c5d39ccd384d108ed9dd923798474a64823c70 | [
"MIT"
] | null | null | null | XDAudioDevice/stdafx.h | op07n/Digi-XD | 66c5d39ccd384d108ed9dd923798474a64823c70 | [
"MIT"
] | 1 | 2020-02-22T04:02:02.000Z | 2020-02-22T04:02:02.000Z | #pragma once
#include <msclr\marshal_cppstd.h>
| 15.666667 | 33 | 0.787234 |
9ba003d9eb9b2c5ac28c796b25f272d97e72fed0 | 1,966 | h | C | src/odil/endian.h | genisysram/odil | e6b12df698ce452f9c5d86858e896e9b6d28cdf0 | [
"CECILL-B"
] | 72 | 2016-02-04T00:41:02.000Z | 2022-03-18T18:10:34.000Z | src/odil/endian.h | genisysram/odil | e6b12df698ce452f9c5d86858e896e9b6d28cdf0 | [
"CECILL-B"
] | 74 | 2016-01-11T16:04:46.000Z | 2021-11-18T16:36:11.000Z | src/odil/endian.h | genisysram/odil | e6b12df698ce452f9c5d86858e896e9b6d28cdf0 | [
"CECILL-B"
] | 23 | 2016-04-27T07:14:56.000Z | 2021-09-28T21:59:31.000Z | /*************************************************************************
* odil - Copyright (C) Universite de Strasbourg
* Distributed under the terms of the CeCILL-B license, as published by
* the CEA-CNRS-INRIA. Refer to the LICENSE file or to
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
* for details.
************************************************************************/
#ifndef _05d00816_25d0_41d1_9768_afd39f0503da
#define _05d00816_25d0_41d1_9768_afd39f0503da
#include "odil/odil.h"
#define ODIL_SWAP \
auto source = reinterpret_cast<char const *>(&value); \
auto const end = source + sizeof(value); \
T result; \
auto destination = reinterpret_cast<char *>(&result) + sizeof(result) - 1; \
while(source != end) \
{ \
*destination = *source; \
++source; \
--destination; \
}
namespace odil
{
enum class ODIL_API ByteOrdering
{
LittleEndian,
BigEndian
};
ByteOrdering ODIL_API get_endianness();
extern ODIL_API ByteOrdering const byte_ordering;
template<typename T>
T host_to_big_endian(T const & value)
{
if(byte_ordering == ByteOrdering::LittleEndian)
{
ODIL_SWAP
return result;
}
else
{
return value;
}
}
template<typename T>
T host_to_little_endian(T const & value)
{
if(byte_ordering == ByteOrdering::BigEndian)
{
ODIL_SWAP
return result;
}
else
{
return value;
}
}
template<typename T>
T big_endian_to_host(T const & value)
{
if(byte_ordering == ByteOrdering::LittleEndian)
{
ODIL_SWAP
return result;
}
else
{
return value;
}
}
template<typename T>
T little_endian_to_host(T const & value)
{
if(byte_ordering == ByteOrdering::BigEndian)
{
ODIL_SWAP
return result;
}
else
{
return value;
}
}
}
#undef ODIL_SWAP
#endif // _05d00816_25d0_41d1_9768_afd39f0503da
| 19.66 | 80 | 0.595626 |
63d7465f7110b5de21dfd45ed8a0957451732eaa | 10,433 | h | C | api/mc_release_10.9.3/fsl_dpmac.h | glikely/mc-utils | 8e0b863693fc2ccbc62a62c79b4e3db6da88c16e | [
"BSD-3-Clause"
] | null | null | null | api/mc_release_10.9.3/fsl_dpmac.h | glikely/mc-utils | 8e0b863693fc2ccbc62a62c79b4e3db6da88c16e | [
"BSD-3-Clause"
] | null | null | null | api/mc_release_10.9.3/fsl_dpmac.h | glikely/mc-utils | 8e0b863693fc2ccbc62a62c79b4e3db6da88c16e | [
"BSD-3-Clause"
] | 1 | 2020-05-23T10:39:48.000Z | 2020-05-23T10:39:48.000Z | /* Copyright 2013-2016 Freescale Semiconductor Inc.
*
* 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.
* * Neither the name of the above-listed copyright holders nor the
* names of any contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
*
* ALTERNATIVELY, this software may be distributed under the terms of the
* GNU General Public License ("GPL") as published by the Free Software
* Foundation, either version 2 of that License or (at your option) any
* later version.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __FSL_DPMAC_H
#define __FSL_DPMAC_H
/** @addtogroup dpmac Data Path MAC API
* Contains initialization APIs and runtime control APIs for DPMAC
* @{
*/
struct fsl_mc_io;
int dpmac_open(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
int dpmac_id,
uint16_t *token);
int dpmac_close(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token);
/**
* enum dpmac_link_type - DPMAC link type
* @DPMAC_LINK_TYPE_NONE: No link
* @DPMAC_LINK_TYPE_FIXED: Link is fixed type
* @DPMAC_LINK_TYPE_PHY: Link by PHY ID
* @DPMAC_LINK_TYPE_BACKPLANE: Backplane link type
*/
enum dpmac_link_type {
DPMAC_LINK_TYPE_NONE,
DPMAC_LINK_TYPE_FIXED,
DPMAC_LINK_TYPE_PHY,
DPMAC_LINK_TYPE_BACKPLANE
};
/**
* enum dpmac_eth_if - DPMAC Ethrnet interface
* @DPMAC_ETH_IF_MII: MII interface
* @DPMAC_ETH_IF_RMII: RMII interface
* @DPMAC_ETH_IF_SMII: SMII interface
* @DPMAC_ETH_IF_GMII: GMII interface
* @DPMAC_ETH_IF_RGMII: RGMII interface
* @DPMAC_ETH_IF_SGMII: SGMII interface
* @DPMAC_ETH_IF_QSGMII: QSGMII interface
* @DPMAC_ETH_IF_XAUI: XAUI interface
* @DPMAC_ETH_IF_XFI: XFI interface
*/
enum dpmac_eth_if {
DPMAC_ETH_IF_MII,
DPMAC_ETH_IF_RMII,
DPMAC_ETH_IF_SMII,
DPMAC_ETH_IF_GMII,
DPMAC_ETH_IF_RGMII,
DPMAC_ETH_IF_SGMII,
DPMAC_ETH_IF_QSGMII,
DPMAC_ETH_IF_XAUI,
DPMAC_ETH_IF_XFI
};
/**
* struct dpmac_cfg - Structure representing DPMAC configuration
* @mac_id: Represents the Hardware MAC ID; in case of multiple WRIOP,
* the MAC IDs are continuous.
* For example: 2 WRIOPs, 16 MACs in each:
* MAC IDs for the 1st WRIOP: 1-16,
* MAC IDs for the 2nd WRIOP: 17-32.
*/
struct dpmac_cfg {
uint16_t mac_id;
};
int dpmac_create(struct fsl_mc_io *mc_io,
uint16_t dprc_token,
uint32_t cmd_flags,
const struct dpmac_cfg *cfg,
uint32_t *obj_id);
int dpmac_destroy(struct fsl_mc_io *mc_io,
uint16_t dprc_token,
uint32_t cmd_flags,
uint32_t object_id);
/**
* DPMAC IRQ Index and Events
*/
/**
* IRQ index
*/
#define DPMAC_IRQ_INDEX 0
/**
* IRQ event - indicates a change in link state
*/
#define DPMAC_IRQ_EVENT_LINK_CFG_REQ 0x00000001
/**
* IRQ event - Indicates that the link state changed
*/
#define DPMAC_IRQ_EVENT_LINK_CHANGED 0x00000002
int dpmac_set_irq_enable(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
uint8_t irq_index,
uint8_t en);
int dpmac_get_irq_enable(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
uint8_t irq_index,
uint8_t *en);
int dpmac_set_irq_mask(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
uint8_t irq_index,
uint32_t mask);
int dpmac_get_irq_mask(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
uint8_t irq_index,
uint32_t *mask);
int dpmac_get_irq_status(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
uint8_t irq_index,
uint32_t *status);
int dpmac_clear_irq_status(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
uint8_t irq_index,
uint32_t status);
/**
* struct dpmac_attr - Structure representing DPMAC attributes
* @id: DPMAC object ID
* @max_rate: Maximum supported rate - in Mbps
* @eth_if: Ethernet interface
* @link_type: link type
*/
struct dpmac_attr {
uint16_t id;
uint32_t max_rate;
enum dpmac_eth_if eth_if;
enum dpmac_link_type link_type;
};
int dpmac_get_attributes(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
struct dpmac_attr *attr);
/**
* DPMAC link configuration/state options
*/
/**
* Enable auto-negotiation
*/
#define DPMAC_LINK_OPT_AUTONEG 0x0000000000000001ULL
/**
* Enable half-duplex mode
*/
#define DPMAC_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
/**
* Enable pause frames
*/
#define DPMAC_LINK_OPT_PAUSE 0x0000000000000004ULL
/**
* Enable a-symmetric pause frames
*/
#define DPMAC_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
/**
* struct dpmac_link_cfg - Structure representing DPMAC link configuration
* @rate: Link's rate - in Mbps
* @options: Enable/Disable DPMAC link cfg features (bitmap)
*/
struct dpmac_link_cfg {
uint32_t rate;
uint64_t options;
};
int dpmac_get_link_cfg(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
struct dpmac_link_cfg *cfg);
/**
* struct dpmac_link_state - DPMAC link configuration request
* @rate: Rate in Mbps
* @options: Enable/Disable DPMAC link cfg features (bitmap)
* @up: Link state
*/
struct dpmac_link_state {
uint32_t rate;
uint64_t options;
int up;
};
int dpmac_set_link_state(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
struct dpmac_link_state *link_state);
/**
* enum dpmac_counter - DPMAC counter types
* @DPMAC_CNT_ING_FRAME_64: counts 64-bytes frames, good or bad.
* @DPMAC_CNT_ING_FRAME_127: counts 65- to 127-bytes frames, good or bad.
* @DPMAC_CNT_ING_FRAME_255: counts 128- to 255-bytes frames, good or bad.
* @DPMAC_CNT_ING_FRAME_511: counts 256- to 511-bytes frames, good or bad.
* @DPMAC_CNT_ING_FRAME_1023: counts 512- to 1023-bytes frames, good or bad.
* @DPMAC_CNT_ING_FRAME_1518: counts 1024- to 1518-bytes frames, good or bad.
* @DPMAC_CNT_ING_FRAME_1519_MAX: counts 1519-bytes frames and larger
* (up to max frame length specified),
* good or bad.
* @DPMAC_CNT_ING_FRAG: counts frames which are shorter than 64 bytes received
* with a wrong CRC
* @DPMAC_CNT_ING_JABBER: counts frames longer than the maximum frame length
* specified, with a bad frame check sequence.
* @DPMAC_CNT_ING_FRAME_DISCARD: counts dropped frames due to internal errors.
* Occurs when a receive FIFO overflows.
* Includes also frames truncated as a result of
* the receive FIFO overflow.
* @DPMAC_CNT_ING_ALIGN_ERR: counts frames with an alignment error
* (optional used for wrong SFD).
* @DPMAC_CNT_EGR_UNDERSIZED: counts frames transmitted that was less than 64
* bytes long with a good CRC.
* @DPMAC_CNT_ING_OVERSIZED: counts frames longer than the maximum frame length
* specified, with a good frame check sequence.
* @DPMAC_CNT_ING_VALID_PAUSE_FRAME: counts valid pause frames (regular and PFC)
* @DPMAC_CNT_EGR_VALID_PAUSE_FRAME: counts valid pause frames transmitted
* (regular and PFC).
* @DPMAC_CNT_ING_BYTE: counts bytes received except preamble for all valid
* frames and valid pause frames.
* @DPMAC_CNT_ING_MCAST_FRAME: counts received multicast frames.
* @DPMAC_CNT_ING_BCAST_FRAME: counts received broadcast frames.
* @DPMAC_CNT_ING_ALL_FRAME: counts each good or bad frames received.
* @DPMAC_CNT_ING_UCAST_FRAME: counts received unicast frames.
* @DPMAC_CNT_ING_ERR_FRAME: counts frames received with an error
* (except for undersized/fragment frame).
* @DPMAC_CNT_EGR_BYTE: counts bytes transmitted except preamble for all valid
* frames and valid pause frames transmitted.
* @DPMAC_CNT_EGR_MCAST_FRAME: counts transmitted multicast frames.
* @DPMAC_CNT_EGR_BCAST_FRAME: counts transmitted broadcast frames.
* @DPMAC_CNT_EGR_UCAST_FRAME: counts transmitted unicast frames.
* @DPMAC_CNT_EGR_ERR_FRAME: counts frames transmitted with an error.
* @DPMAC_CNT_ING_GOOD_FRAME: counts frames received without error, including
* pause frames.
* @DPMAC_CNT_ENG_GOOD_FRAME: counts frames transmitted without error, including
* pause frames.
*/
enum dpmac_counter {
DPMAC_CNT_ING_FRAME_64,
DPMAC_CNT_ING_FRAME_127,
DPMAC_CNT_ING_FRAME_255,
DPMAC_CNT_ING_FRAME_511,
DPMAC_CNT_ING_FRAME_1023,
DPMAC_CNT_ING_FRAME_1518,
DPMAC_CNT_ING_FRAME_1519_MAX,
DPMAC_CNT_ING_FRAG,
DPMAC_CNT_ING_JABBER,
DPMAC_CNT_ING_FRAME_DISCARD,
DPMAC_CNT_ING_ALIGN_ERR,
DPMAC_CNT_EGR_UNDERSIZED,
DPMAC_CNT_ING_OVERSIZED,
DPMAC_CNT_ING_VALID_PAUSE_FRAME,
DPMAC_CNT_EGR_VALID_PAUSE_FRAME,
DPMAC_CNT_ING_BYTE,
DPMAC_CNT_ING_MCAST_FRAME,
DPMAC_CNT_ING_BCAST_FRAME,
DPMAC_CNT_ING_ALL_FRAME,
DPMAC_CNT_ING_UCAST_FRAME,
DPMAC_CNT_ING_ERR_FRAME,
DPMAC_CNT_EGR_BYTE,
DPMAC_CNT_EGR_MCAST_FRAME,
DPMAC_CNT_EGR_BCAST_FRAME,
DPMAC_CNT_EGR_UCAST_FRAME,
DPMAC_CNT_EGR_ERR_FRAME,
DPMAC_CNT_ING_GOOD_FRAME,
DPMAC_CNT_ENG_GOOD_FRAME
};
int dpmac_get_counter(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
enum dpmac_counter type,
uint64_t *counter);
int dpmac_get_api_version(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t *major_ver,
uint16_t *minor_ver);
int dpmac_reset(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token);
#endif /* __FSL_DPMAC_H */
| 31.519637 | 80 | 0.758555 |
4b1056c4066c9e28eb5235fda2693c2d7b779b26 | 1,952 | h | C | Sources/Elastos/Frameworks/Droid/Base/Services/Server/inc/elastos/droid/server/wm/StrictModeFlash.h | jingcao80/Elastos | d0f39852356bdaf3a1234743b86364493a0441bc | [
"Apache-2.0"
] | 7 | 2017-07-13T10:34:54.000Z | 2021-04-16T05:40:35.000Z | Sources/Elastos/Frameworks/Droid/Base/Services/Server/inc/elastos/droid/server/wm/StrictModeFlash.h | jingcao80/Elastos | d0f39852356bdaf3a1234743b86364493a0441bc | [
"Apache-2.0"
] | null | null | null | Sources/Elastos/Frameworks/Droid/Base/Services/Server/inc/elastos/droid/server/wm/StrictModeFlash.h | jingcao80/Elastos | d0f39852356bdaf3a1234743b86364493a0441bc | [
"Apache-2.0"
] | 9 | 2017-07-13T12:33:20.000Z | 2021-06-19T02:46:48.000Z | //=========================================================================
// Copyright (C) 2012 The Elastos Open Source Project
//
// 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 __ELASTOS_DROID_SERVER_WM_STRICTMODEFLASH_H__
#define __ELASTOS_DROID_SERVER_WM_STRICTMODEFLASH_H__
#include "_Elastos.Droid.Server.h"
#include <elastos/core/Object.h>
using Elastos::Droid::View::IDisplay;
using Elastos::Droid::View::ISurfaceSession;
using Elastos::Droid::View::ISurface;
using Elastos::Droid::View::ISurfaceControl;
namespace Elastos {
namespace Droid {
namespace Server {
namespace Wm {
class StrictModeFlash : public Object
{
public:
StrictModeFlash(
/* [in] */ IDisplay* display,
/* [in] */ ISurfaceSession* session);
// Note: caller responsible for being inside
// Surface.openTransaction() / closeTransaction()
CARAPI_(void) SetVisibility(
/* [in] */ Boolean on);
CARAPI_(void) PositionSurface(
/* [in] */ Int32 dw,
/* [in] */ Int32 dh);
private:
CARAPI_(void) DrawIfNeeded();
private:
static const String TAG;
AutoPtr<ISurfaceControl> mSurfaceControl;
AutoPtr<ISurface> mSurface;
Int32 mLastDW;
Int32 mLastDH;
Boolean mDrawNeeded;
Int32 mThickness;
};
} // Wm
} // Server
} // Droid
} // Elastos
#endif //__ELASTOS_DROID_SERVER_WM_STRICTMODEFLASH_H__
| 28.289855 | 75 | 0.659324 |
af596336e8c56143915aba1548790e6bf7326391 | 5,455 | h | C | ThirdParty/Havok/include/Common/Visualize/Process/hkDebugDisplayProcess.h | wobbier/source3-engine | f59df759ee197aef5191cf13768c303c6ed17bf5 | [
"MIT"
] | 11 | 2016-08-02T03:40:36.000Z | 2022-03-15T13:41:29.000Z | ThirdParty/Havok/include/Common/Visualize/Process/hkDebugDisplayProcess.h | wobbier/source3-engine | f59df759ee197aef5191cf13768c303c6ed17bf5 | [
"MIT"
] | null | null | null | ThirdParty/Havok/include/Common/Visualize/Process/hkDebugDisplayProcess.h | wobbier/source3-engine | f59df759ee197aef5191cf13768c303c6ed17bf5 | [
"MIT"
] | 8 | 2017-03-17T05:59:25.000Z | 2021-02-27T08:51:46.000Z | /*
*
* Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's
* prior written consent. This software contains code, techniques and know-how which is confidential and proprietary to Havok.
* Product and Trade Secret source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2014 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement.
*
*/
#ifndef HK_VISUALIZE_DEBUG_DISPLAY_PROCESS
#define HK_VISUALIZE_DEBUG_DISPLAY_PROCESS
#include <Common/Visualize/hkProcess.h>
#include <Common/Visualize/hkDebugDisplayHandler.h>
class hkProcessContext;
/// This class implements the hkDisplayHandler interface. It serializes
/// hkDisplayHandler calls so that they can be streamed over the network.
class HK_EXPORT_COMMON hkDebugDisplayProcess : public hkReferencedObject, public hkProcess, public hkDebugDisplayHandler
{
public:
HK_DECLARE_CLASS_ALLOCATOR(HK_MEMORY_CLASS_VDB);
/// Serializes hkDisplayHandler messages, the stream must be writable.
hkDebugDisplayProcess();
/// Destructor.
virtual ~hkDebugDisplayProcess();
//
// Process
//
static hkProcess* HK_CALL create(const hkArray<hkProcessContext*>& contexts);
/// Registers the hkDebugDisplayProcess with the hkProcessFactory.
static void HK_CALL registerProcess();
/// Gets the tag associated with this viewer type
virtual int getProcessTag() { return m_tag; }
static int getProcessTagStatic() { return m_tag; }
static inline const char* HK_CALL getName() { return "Debug Display"; }
//
// Display handler functions
//
using hkDebugDisplayHandler::addGeometry;
virtual hkResult addGeometry(const hkArrayBase<hkDisplayGeometry*>& geometries, const hkTransform& transform, hkUlong id, int tag, hkUlong shapeIdHint, hkGeometry::GeometryType geomType) HK_OVERRIDE;
virtual hkResult addGeometryInstance(hkUlong instID, const hkTransform& transform, hkUlong id, int tag, hkUlong shapeIdHint) HK_OVERRIDE;
virtual hkResult setGeometryPickable( hkBool isPickable, hkUlong id, int tag ) HK_OVERRIDE;
virtual hkResult setGeometryVisibility(int geometryIndex, bool isVisible, hkUlong id, int tag) HK_OVERRIDE;
virtual hkResult setGeometryColor(hkColor::Argb color, hkUlong id, int tag) HK_OVERRIDE;
virtual hkResult setGeometryTransparency(float alpha, hkUlong id, int tag) HK_OVERRIDE;
virtual hkResult updateGeometry(const hkTransform& transform, hkUlong id, int tag) HK_OVERRIDE;
virtual hkResult updateGeometry( const hkMatrix4& transform, hkUlong id, int tag ) HK_OVERRIDE;
virtual hkResult skinGeometry(hkUlong* ids, int numIds, const hkMatrix4* poseModel, int numPoseModel, const hkMatrix4& worldFromModel, int tag ) HK_OVERRIDE;
virtual hkResult removeGeometry(hkUlong id, int tag, hkUlong shapeIdHint) HK_OVERRIDE;
virtual hkResult updateCamera(const hkVector4& from, const hkVector4& to, const hkVector4& up, hkReal nearPlane, hkReal farPlane, hkReal fov, const char* name) HK_OVERRIDE;
virtual hkResult displayPoint(const hkVector4& position, hkColor::Argb color, int id, int tag) HK_OVERRIDE;
virtual hkResult displayLine(const hkVector4& start, const hkVector4& end, hkColor::Argb color, int id, int tag) HK_OVERRIDE;
virtual hkResult displayTriangle(const hkVector4& a, const hkVector4& b, const hkVector4& c, hkColor::Argb color, int id, int tag) HK_OVERRIDE;
virtual hkResult displayPoint2d(const hkVector4& position, hkColor::Argb color, int id, int tag) HK_OVERRIDE;
virtual hkResult displayLine2d(const hkVector4& start, const hkVector4& end, hkColor::Argb color, int id, int tag) HK_OVERRIDE;
virtual hkResult displayTriangle2d(const hkVector4& a, const hkVector4& b, const hkVector4& c, hkColor::Argb color, int id, int tag) HK_OVERRIDE;
virtual hkResult displayText2d(const char* text, const hkVector4& pos, hkReal sizeScale, hkColor::Argb color, int id, int tag) HK_OVERRIDE;
virtual hkResult displayText(const char* text, hkColor::Argb color, int id, int tag);
virtual hkResult display3dText(const char* text, const hkVector4& pos, hkColor::Argb color, int id, int tag) HK_OVERRIDE;
virtual hkResult displayAnnotation(const char* text, int id, int tag) HK_OVERRIDE;
virtual hkResult displayGeometry(const hkArrayBase<hkDisplayGeometry*>& geometries, const hkTransform& transform, hkColor::Argb color, int id, int tag) HK_OVERRIDE;
virtual hkResult displayGeometry(const hkArrayBase<hkDisplayGeometry*>& geometries, hkColor::Argb color, int id, int tag) HK_OVERRIDE;
virtual hkResult sendMemStatsDump(const char* data, int length);
virtual hkResult holdImmediate();
protected:
static int m_tag;
};
#endif // HK_VISUALIZE_DEBUG_DISPLAY_PROCESS
/*
* Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20140907)
*
* Confidential Information of Havok. (C) Copyright 1999-2014
* Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok
* Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership
* rights, and intellectual property rights in the Havok software remain in
* Havok and/or its suppliers.
*
* Use of this software for evaluation purposes is subject to and indicates
* acceptance of the End User licence Agreement for this product. A copy of
* the license is included with this software and is also available at www.havok.com/tryhavok.
*
*/
| 51.462264 | 251 | 0.783501 |
18b1277d62203a2e5d63cdd2b8492fc226f14bf7 | 154 | h | C | halt.h | Veltas/spectrum-env | 82a747444d46316b24b53af025ff7956c06b73a4 | [
"CC0-1.0"
] | null | null | null | halt.h | Veltas/spectrum-env | 82a747444d46316b24b53af025ff7956c06b73a4 | [
"CC0-1.0"
] | null | null | null | halt.h | Veltas/spectrum-env | 82a747444d46316b24b53af025ff7956c06b73a4 | [
"CC0-1.0"
] | null | null | null | #ifndef HALT_H_INCLUDED
#define HALT_H_INCLUDED
// Halts the processor until the next interrupt is triggered
void Halt(void);
#endif // HALT_H_INCLUDED
| 19.25 | 60 | 0.798701 |
6f9b7b17e48e7164edd5435ed864ade4647e18fe | 5,925 | c | C | ccachy.c | codewillclick/ncachy | 909eb32afd8373ecffaf948edbaace7d7b8632e4 | [
"MIT"
] | null | null | null | ccachy.c | codewillclick/ncachy | 909eb32afd8373ecffaf948edbaace7d7b8632e4 | [
"MIT"
] | 1 | 2018-07-09T14:34:39.000Z | 2018-07-09T14:34:39.000Z | ccachy.c | codewillclick/ncachy | 909eb32afd8373ecffaf948edbaace7d7b8632e4 | [
"MIT"
] | 1 | 2018-07-09T14:31:21.000Z | 2018-07-09T14:31:21.000Z |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//#include <unistd.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <errno.h>
#include <stdarg.h>
void cflog(FILE* f,char* color,char* format, ...) {
va_list args;
va_start(args,format);
fprintf(f,"\033[%sm",color);
vfprintf(f,format,args);
fprintf(f,"\033[0m");
}
void flog(FILE* f,char* format, ...) {
va_list args;
va_start(args,format);
fprintf(f,"\033[93m");
vfprintf(f,format,args);
fprintf(f,"\033[0m");
}
typedef void(*perline)(char*,int len,void*);
int indexof_char(char* s,int a,int b,char c) {
int i;
for (i=a; s[i] && a < b; ++i) {
if (s[i] == c)
return i;
}
return -1;
}
void file_fread_chunks_callback(FILE* f,int bufsize,perline callback,void* p) {
char* s = (char*)malloc(bufsize+1);
int rsize = fread(s,1,bufsize,f);
while (rsize == bufsize) {
callback(s,rsize,p);
rsize = fread(s,1,bufsize,f);
}
if (0 <= rsize && rsize < bufsize) {
callback(s,rsize,p);
}
free(s);
}
void file_read_chunks_callback(int fd,int bufsize,perline callback,void* p) {
char* s = (char*)malloc(bufsize);
int rsize = read(fd,s,bufsize);
#ifdef DEBUG
cflog(stderr,"91","[frcc %i, %i, %x, %x]\n",fd,bufsize,callback,p);
cflog(stderr,"91","[rsize %i]\n",rsize);
#endif
while (rsize == bufsize) {
callback(s,rsize,p);
rsize = read(fd,s,bufsize);
}
if (0 <= rsize && rsize < bufsize) {
callback(s,rsize,p);
}
#ifdef DEBUG
else if (rsize < 0) {
strerror_r(errno,s,bufsize);
cflog(stderr,"31","bad read, errno=%i (%s)\n",errno,s);
}
#endif
free(s);
}
void _file_read_new_string_callback(char* s,int len,void* p) {
int nsize;
char* nbuf;
struct what {
int len;
int size;
char* buf;
}* ob;
ob = (struct what*)p;
#ifdef DEBUG
char ehh[5000]; strncpy(ehh,s,len); ehh[len] = 0;
flog(stderr,"ob {%i, %i, %s}\n",ob->len,ob->size,ehh);
#endif
if (ob->len + len > ob->size) {
#ifdef DEBUG
flog(stderr,"expanding\n");
#endif
nsize = ob->size*2;
nbuf = (char*)malloc(nsize+1);
strncpy(nbuf,ob->buf,ob->len);
free(ob->buf);
ob->buf = nbuf;
ob->size = nsize;
}
strncpy(&ob->buf[ob->len],s,len);
ob->len += len;
}
char* file_read_new_string(int fd,int bufsize) {
struct {
int len;
int size;
char* buf;
} ob;
ob.len = 0;
ob.size = bufsize;
ob.buf = (char*)malloc(ob.size+1);
file_read_chunks_callback(fd,bufsize,
_file_read_new_string_callback,
&ob);
ob.buf[ob.len] = 0;
return ob.buf;
}
typedef struct {
int fd;
int buflen;
struct sockaddr_un addr;
} socket_data;
void thang(char* buffer,int len,void* p) {
socket_data* sock = (socket_data*)p;
char cbuf[4097];
strncpy(cbuf,buffer,len);
cbuf[len] = 0;
cbuf[4096] = 0;
char* s;
// Send to socket.
// TODO: ncachy assumes what it receives is cleanly split by '\n', with no
// breaks in get, set, or commands. Maybe I can use that line iterator I
// wrote on my first ccachy attempt? For now, let's just add an option to
// set the buffer size to arbitrarily large values.
//
// Though that would mean that *all* stdin input would have to fit within
// said single buffer. ... I think that iterator may be my ONLY CHOICE.
int a = write(sock->fd,buffer,len);
//write(sock->fd,cbuf,len);
#ifdef DEBUG
flog(stderr,"[sent... %s]\n",cbuf);
flog(stderr,"[wrote bytes %i]\n",a);
#endif
// ncachy's daemon should only respond on accepting a full line, so...
//
// If there's a '\n' somewhere in the send string, or it's the very last read,
// go ahead and wait to receive something back from the socket.
//if (indexof_char(cbuf,0,len,'\n') >= 0) {
if ((indexof_char(cbuf,0,len,'\n') >= 0 &&
indexof_char(cbuf,0,len,'=') < 0) ||
len < sock->buflen) {
// Receive from socket.
#ifdef DEBUG
flog(stderr,"[Wait for read, I guess?]\n");
#endif
// Force an endline when it's the final line and doesn't end in one.
if (len < sock->buflen && cbuf[len-1] != '\n')
write(sock->fd,"\n",1);
s = file_read_new_string(sock->fd,4096);
if (s[0])
printf("%s",s);
if (s)
free(s);
}
}
typedef struct {
char socket[256];
int args;
} config;
config* init_config(config* c) {
strcpy(c->socket,"/tmp/jeeze.sock");
c->args = 0;
return c;
}
char* arg2(int argc, char** argv, char* arg) {
int i;
char* s;
for (i=0; i < argc-1; ++i) {
if (strcmp(argv[i],arg) == 0) {
s = (char*)malloc(strlen(argv[i+1]));
strcpy(s,argv[i+1]);
return s;
}
}
return 0;
}
void parse_args(int argc, char** argv, config* conf) {
char* sockpath;
int firstarg = 1;
if (argc > 1 && argv[1][0] == '@') {
sprintf(conf->socket,"/tmp/%s.sock",&argv[1][1]);
++firstarg;
}
else {
sockpath = arg2(argc,argv,"--socket");
if (sockpath) {
strcpy(conf->socket,sockpath);
free(sockpath);
}
}
if (argc > firstarg)
conf->args = 1;
}
void usage() {
}
int main(int argc, char** argv) {
FILE* f = stdin;
int conn;
config conf;
init_config(&conf);
parse_args(argc,argv,&conf);
socket_data sock;
sock.addr.sun_family = AF_UNIX;
strcpy(sock.addr.sun_path,conf.socket);
// NOTE: buflen use feels... hacky...
sock.buflen = 4096;
//sock.buflen = 24000;
//sock.buflen = 2;
sock.fd = socket(AF_UNIX, SOCK_STREAM, 0);
// NOTE: What do I use, here? connect? bind?
conn = connect(sock.fd,(struct sockaddr*)&sock.addr,sizeof(sock.addr));
//conn = bind(sock.fd,(struct sockaddr*)&sock,sizeof(sock));
#ifdef DEBUG
char cbuf[1024];
flog(stderr,"[res %i]\n",conn);
if (conn < 0) {
strerror_r(errno,cbuf,1024);
cflog(stderr,"31","bad connect, errno=%i (%s)\n",errno,cbuf);
}
#endif
// Loop through input read.
if (conf.args) {
int i=1;
if (argv[1][0] == '@')
++i;
for (; i < argc; ++i) {
thang(argv[i],strlen(argv[i]),&sock);
}
}
else
file_fread_chunks_callback(f,sock.buflen,thang,&sock);
// UNCERTAIN: Do I need this?
write(sock.fd,"\n",1);
return 0;
}
| 20.644599 | 79 | 0.617553 |
8d8411dfa720bd5b45566364f8eeaf469386848a | 6,965 | h | C | Library/include/mavros_msgs/CommandVtolTransitionRequest.h | Dieptranivsr/Ros_Diep | d790e75e6f5da916701b11a2fdf3e03b6a47086b | [
"MIT"
] | 10 | 2021-03-15T03:58:06.000Z | 2021-12-30T15:33:38.000Z | devel/.private/mavros_msgs/include/mavros_msgs/CommandVtolTransitionRequest.h | arijitnoobstar/UAVProjectileCatcher | 3c1bed80df167192cb4b971b58c891187628142e | [
"Apache-2.0"
] | 1 | 2021-09-09T15:29:31.000Z | 2021-09-09T15:29:31.000Z | melodic/include/mavros_msgs/CommandVtolTransitionRequest.h | Dieptranivsr/Ros_Diep | d790e75e6f5da916701b11a2fdf3e03b6a47086b | [
"MIT"
] | 4 | 2021-03-06T09:35:58.000Z | 2021-05-24T14:34:11.000Z | // Generated by gencpp from file mavros_msgs/CommandVtolTransitionRequest.msg
// DO NOT EDIT!
#ifndef MAVROS_MSGS_MESSAGE_COMMANDVTOLTRANSITIONREQUEST_H
#define MAVROS_MSGS_MESSAGE_COMMANDVTOLTRANSITIONREQUEST_H
#include <string>
#include <vector>
#include <map>
#include <ros/types.h>
#include <ros/serialization.h>
#include <ros/builtin_message_traits.h>
#include <ros/message_operations.h>
#include <std_msgs/Header.h>
namespace mavros_msgs
{
template <class ContainerAllocator>
struct CommandVtolTransitionRequest_
{
typedef CommandVtolTransitionRequest_<ContainerAllocator> Type;
CommandVtolTransitionRequest_()
: header()
, state(0) {
}
CommandVtolTransitionRequest_(const ContainerAllocator& _alloc)
: header(_alloc)
, state(0) {
(void)_alloc;
}
typedef ::std_msgs::Header_<ContainerAllocator> _header_type;
_header_type header;
typedef uint8_t _state_type;
_state_type state;
// reducing the odds to have name collisions with Windows.h
#if defined(_WIN32) && defined(STATE_MC)
#undef STATE_MC
#endif
#if defined(_WIN32) && defined(STATE_FW)
#undef STATE_FW
#endif
enum {
STATE_MC = 3u,
STATE_FW = 4u,
};
typedef boost::shared_ptr< ::mavros_msgs::CommandVtolTransitionRequest_<ContainerAllocator> > Ptr;
typedef boost::shared_ptr< ::mavros_msgs::CommandVtolTransitionRequest_<ContainerAllocator> const> ConstPtr;
}; // struct CommandVtolTransitionRequest_
typedef ::mavros_msgs::CommandVtolTransitionRequest_<std::allocator<void> > CommandVtolTransitionRequest;
typedef boost::shared_ptr< ::mavros_msgs::CommandVtolTransitionRequest > CommandVtolTransitionRequestPtr;
typedef boost::shared_ptr< ::mavros_msgs::CommandVtolTransitionRequest const> CommandVtolTransitionRequestConstPtr;
// constants requiring out of line definition
template<typename ContainerAllocator>
std::ostream& operator<<(std::ostream& s, const ::mavros_msgs::CommandVtolTransitionRequest_<ContainerAllocator> & v)
{
ros::message_operations::Printer< ::mavros_msgs::CommandVtolTransitionRequest_<ContainerAllocator> >::stream(s, "", v);
return s;
}
template<typename ContainerAllocator1, typename ContainerAllocator2>
bool operator==(const ::mavros_msgs::CommandVtolTransitionRequest_<ContainerAllocator1> & lhs, const ::mavros_msgs::CommandVtolTransitionRequest_<ContainerAllocator2> & rhs)
{
return lhs.header == rhs.header &&
lhs.state == rhs.state;
}
template<typename ContainerAllocator1, typename ContainerAllocator2>
bool operator!=(const ::mavros_msgs::CommandVtolTransitionRequest_<ContainerAllocator1> & lhs, const ::mavros_msgs::CommandVtolTransitionRequest_<ContainerAllocator2> & rhs)
{
return !(lhs == rhs);
}
} // namespace mavros_msgs
namespace ros
{
namespace message_traits
{
template <class ContainerAllocator>
struct IsFixedSize< ::mavros_msgs::CommandVtolTransitionRequest_<ContainerAllocator> >
: FalseType
{ };
template <class ContainerAllocator>
struct IsFixedSize< ::mavros_msgs::CommandVtolTransitionRequest_<ContainerAllocator> const>
: FalseType
{ };
template <class ContainerAllocator>
struct IsMessage< ::mavros_msgs::CommandVtolTransitionRequest_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct IsMessage< ::mavros_msgs::CommandVtolTransitionRequest_<ContainerAllocator> const>
: TrueType
{ };
template <class ContainerAllocator>
struct HasHeader< ::mavros_msgs::CommandVtolTransitionRequest_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct HasHeader< ::mavros_msgs::CommandVtolTransitionRequest_<ContainerAllocator> const>
: TrueType
{ };
template<class ContainerAllocator>
struct MD5Sum< ::mavros_msgs::CommandVtolTransitionRequest_<ContainerAllocator> >
{
static const char* value()
{
return "0f073c606cdf8c014b856a5033900f3e";
}
static const char* value(const ::mavros_msgs::CommandVtolTransitionRequest_<ContainerAllocator>&) { return value(); }
static const uint64_t static_value1 = 0x0f073c606cdf8c01ULL;
static const uint64_t static_value2 = 0x4b856a5033900f3eULL;
};
template<class ContainerAllocator>
struct DataType< ::mavros_msgs::CommandVtolTransitionRequest_<ContainerAllocator> >
{
static const char* value()
{
return "mavros_msgs/CommandVtolTransitionRequest";
}
static const char* value(const ::mavros_msgs::CommandVtolTransitionRequest_<ContainerAllocator>&) { return value(); }
};
template<class ContainerAllocator>
struct Definition< ::mavros_msgs::CommandVtolTransitionRequest_<ContainerAllocator> >
{
static const char* value()
{
return "\n"
"# MAVLink command: DO_VTOL_TRANSITION\n"
"# https://mavlink.io/en/messages/common.html#MAV_CMD_DO_VTOL_TRANSITION\n"
"\n"
"std_msgs/Header header\n"
"\n"
"# MAV_VTOL_STATE\n"
"uint8 STATE_MC = 3\n"
"uint8 STATE_FW = 4\n"
"\n"
"uint8 state # See enum MAV_VTOL_STATE.\n"
"\n"
"\n"
"================================================================================\n"
"MSG: std_msgs/Header\n"
"# Standard metadata for higher-level stamped data types.\n"
"# This is generally used to communicate timestamped data \n"
"# in a particular coordinate frame.\n"
"# \n"
"# sequence ID: consecutively increasing ID \n"
"uint32 seq\n"
"#Two-integer timestamp that is expressed as:\n"
"# * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n"
"# * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n"
"# time-handling sugar is provided by the client library\n"
"time stamp\n"
"#Frame this data is associated with\n"
"string frame_id\n"
;
}
static const char* value(const ::mavros_msgs::CommandVtolTransitionRequest_<ContainerAllocator>&) { return value(); }
};
} // namespace message_traits
} // namespace ros
namespace ros
{
namespace serialization
{
template<class ContainerAllocator> struct Serializer< ::mavros_msgs::CommandVtolTransitionRequest_<ContainerAllocator> >
{
template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m)
{
stream.next(m.header);
stream.next(m.state);
}
ROS_DECLARE_ALLINONE_SERIALIZER
}; // struct CommandVtolTransitionRequest_
} // namespace serialization
} // namespace ros
namespace ros
{
namespace message_operations
{
template<class ContainerAllocator>
struct Printer< ::mavros_msgs::CommandVtolTransitionRequest_<ContainerAllocator> >
{
template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::mavros_msgs::CommandVtolTransitionRequest_<ContainerAllocator>& v)
{
s << indent << "header: ";
s << std::endl;
Printer< ::std_msgs::Header_<ContainerAllocator> >::stream(s, indent + " ", v.header);
s << indent << "state: ";
Printer<uint8_t>::stream(s, indent + " ", v.state);
}
};
} // namespace message_operations
} // namespace ros
#endif // MAVROS_MSGS_MESSAGE_COMMANDVTOLTRANSITIONREQUEST_H
| 27.86 | 173 | 0.753338 |
e456fe7af41cef39b429df75b54685ddf06cad12 | 5,905 | c | C | kworkerd/2018.12/xbY7p5Tb_msscan/mas/src/main-status.c | gnaytx/whatMiner | dbfe28a58026a42ae991300562b80960cd050ffb | [
"MIT"
] | 120 | 2018-09-11T09:44:41.000Z | 2022-02-25T06:51:37.000Z | kworkerd/2018.12/xbY7p5Tb_msscan/mas/src/main-status.c | gnaytx/whatMiner | dbfe28a58026a42ae991300562b80960cd050ffb | [
"MIT"
] | 5 | 2018-09-29T08:01:54.000Z | 2019-03-28T05:43:21.000Z | kworkerd/2018.12/xbY7p5Tb_msscan/mas/src/main-status.c | MRdoulestar/whatMiner | c2ada464f7100e15bc9ad77ef9f7233c0f50e5df | [
"MIT"
] | 38 | 2018-10-05T13:01:23.000Z | 2022-01-12T06:14:33.000Z | /*
prints "status" message once per second to the commandline
The status message indicates:
- the rate in packets-per-second
- %done
- estimated time remaining of the scan
- number of 'tcbs' (TCP control blocks) of active TCP connections
*/
#include "main-status.h"
#include "pixie-timer.h"
#include "unusedparm.h"
#include "main-globals.h"
#include "string_s.h"
#include <stdio.h>
/***************************************************************************
* Print a status message about once-per-second to the command-line. This
* algorithm is a little funky because checking the timestamp on EVERY
* packet is slow.
***************************************************************************/
void
status_print(
struct Status *status,
uint64_t count,
uint64_t max_count,
double x,
uint64_t total_tcbs,
uint64_t total_synacks,
uint64_t total_syns,
uint64_t exiting)
{
double elapsed_time;
double rate;
double now;
double percent_done;
double time_remaining;
uint64_t current_tcbs = 0;
uint64_t current_synacks = 0;
uint64_t current_syns = 0;
double tcb_rate = 0.0;
double synack_rate = 0.0;
double syn_rate = 0.0;
/*
* #### FUGGLY TIME HACK ####
*
* PF_RING doesn't timestamp packets well, so we can't base time from
* incoming packets. Checking the time ourself is too ugly on per-packet
* basis. Therefore, we are going to create a global variable that keeps
* the time, and update that variable whenever it's convienient. This
* is one of those convenient places.
*/
global_now = time(0);
/* Get the time. NOTE: this is CLOCK_MONOTONIC_RAW on Linux, not
* wall-clock time. */
now = (double)pixie_gettime();
/* Figure how many SECONDS have elapsed, in a floating point value.
* Since the above timestamp is in microseconds, we need to
* shift it by 1-million
*/
elapsed_time = (now - status->last.clock)/1000000.0;
if (elapsed_time == 0)
return;
/* Figure out the "packets-per-second" number, which is just:
*
* rate = packets_sent / elapsed_time;
*/
rate = (count - status->last.count)*1.0/elapsed_time;
/*
* Smooth the number by averaging over the last 8 seconds
*/
status->last_rates[status->last_count++ & 0x7] = rate;
rate = status->last_rates[0]
+ status->last_rates[1]
+ status->last_rates[2]
+ status->last_rates[3]
+ status->last_rates[4]
+ status->last_rates[5]
+ status->last_rates[6]
+ status->last_rates[7]
;
rate /= 8;
/*if (rate == 0)
return;*/
/*
* Calculate "percent-done", which is just the total number of
* packets sent divided by the number we need to send.
*/
percent_done = (double)(count*100.0/max_count);
/*
* Calulate the time remaining in the scan
*/
time_remaining = (1.0 - percent_done/100.0) * (max_count / rate);
/*
* some other stats
*/
if (total_tcbs) {
current_tcbs = total_tcbs - status->total_tcbs;
status->total_tcbs = total_tcbs;
tcb_rate = (1.0*current_tcbs)/elapsed_time;
}
if (total_synacks) {
current_synacks = total_synacks - status->total_synacks;
status->total_synacks = total_synacks;
synack_rate = (1.0*current_synacks)/elapsed_time;
}
if (total_syns) {
current_syns = total_syns - status->total_syns;
status->total_syns = total_syns;
syn_rate = (1.0*current_syns)/elapsed_time;
}
/*
* Print the message to <stderr> so that <stdout> can be redirected
* to a file (<stdout> reports what systems were found).
*/
if (status->is_infinite) {
fprintf(stderr,
"rate:%6.2f-kpps, syn/s=%.0f ack/s=%.0f tcb-rate=%.0f, %" PRIu64 "-tcbs, \r",
x/1000.0,
syn_rate,
synack_rate,
tcb_rate,
total_tcbs
);
} else {
if (is_tx_done) {
fprintf(stderr,
"rate:%6.2f-kpps, %5.2f%% done, waiting %d-secs, found=%" PRIu64 " \r",
x/1000.0,
percent_done,
(int)exiting,
total_synacks
);
} else {
fprintf(stderr,
"rate:%6.2f-kpps, %5.2f%% done,%4u:%02u:%02u remaining, found=%" PRIu64 " \r",
x/1000.0,
percent_done,
(unsigned)(time_remaining/60/60),
(unsigned)(time_remaining/60)%60,
(unsigned)(time_remaining)%60,
total_synacks
);
}
}
fflush(stderr);
/*
* Remember the values to be diffed against the next time around
*/
status->last.clock = now;
status->last.count = count;
}
/***************************************************************************
***************************************************************************/
void
status_finish(struct Status *status)
{
UNUSEDPARM(status);
fprintf(stderr,
" \r");
}
/***************************************************************************
***************************************************************************/
void
status_start(struct Status *status)
{
memset(status, 0, sizeof(*status));
status->last.clock = clock();
status->last.time = time(0);
status->last.count = 0;
status->timer = 0x1;
}
| 30.438144 | 101 | 0.506181 |
e499b456ef4dfa67cdaa44f27dec95b85a27d89f | 2,920 | h | C | cligen_callback.h | shmuelnatan/cligen | 4d96030ef4c2473ea4ce14627219c7d627348075 | [
"Apache-2.0"
] | 12 | 2020-06-27T18:09:27.000Z | 2021-11-14T20:25:24.000Z | cligen_callback.h | shmuelnatan/cligen | 4d96030ef4c2473ea4ce14627219c7d627348075 | [
"Apache-2.0"
] | 28 | 2020-06-18T06:46:02.000Z | 2022-03-09T18:24:31.000Z | cligen_callback.h | shmuelnatan/cligen | 4d96030ef4c2473ea4ce14627219c7d627348075 | [
"Apache-2.0"
] | 17 | 2020-06-18T00:20:33.000Z | 2022-03-02T22:29:14.000Z | /*
***** BEGIN LICENSE BLOCK *****
Copyright (C) 2001-2021 Olof Hagsand
This file is part of CLIgen.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 or later (the "GPL"),
in which case the provisions of the GPL are applicable instead
of those above. If you wish to allow use of your version of this file only
under the terms of the GPL, and not to allow others to
use your version of this file under the terms of Apache License version 2, indicate
your decision by deleting the provisions above and replace them with the
notice and other provisions required by the GPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the Apache License version 2 or the GPL.
***** END LICENSE BLOCK *****
*/
#ifndef _CLIGEN_CALLBACK_H_
#define _CLIGEN_CALLBACK_H_
/*
* Types
*/
/*
* Callback function type. Is called after a specific syntax node has been identified.,
* arg is an optionalargument
* argc is number of variables (1...)
* argv[] is a vector of variables. The first is always the whole syntax string as entered.
*/
typedef int (cgv_fnstype_t)(cligen_handle h, cvec *vars, cvec *argv);
typedef int (cg_fnstype_t)(cligen_handle h, cvec *vars, cg_var *arg); /* XXX obsolete? */
typedef struct cg_callback cg_callback; /* struct defined in cligen_callback.c.c */
#if 1
/*! A CLIgen object may have one or several callbacks. This type defines one callback
*/
struct cg_callback { /* Linked list of command callbacks */
struct cg_callback *cc_next; /**< Next callback in list. */
cgv_fnstype_t *cc_fn_vec; /**< callback/function pointer using cvec. */
char *cc_fn_str; /**< callback/function name. malloced */
cvec *cc_cvec; /**< callback/function arguments */
};
#endif
/*
* Prototypes
*/
cgv_fnstype_t *co_callback_fn_get(cg_callback *cc);
int co_callback_fn_set(cg_callback *cc, cgv_fnstype_t *fn);
cg_callback *co_callback_next(cg_callback *cc);
int co_callback_copy(cg_callback *cc0, cg_callback **ccn);
int co_callbacks_free(cg_callback **ccp);
int co_callback2cbuf(cbuf *cb, cg_callback *cc);
size_t co_callback_size(cg_callback *cc);
#endif /* _CLIGEN_CALLBACK_H_ */
| 37.435897 | 93 | 0.715411 |
85d433c5965c0a24d83639479b27b225ac7b87a3 | 568 | c | C | backend/gdemu_control.c | retrohead/openmenu | 565f472aef47e7116a0d8e77f7960c2dee0238b0 | [
"BSD-3-Clause"
] | 38 | 2021-07-04T19:03:43.000Z | 2022-03-23T03:31:59.000Z | backend/gdemu_control.c | retrohead/openmenu | 565f472aef47e7116a0d8e77f7960c2dee0238b0 | [
"BSD-3-Clause"
] | 31 | 2021-06-25T13:42:06.000Z | 2022-03-15T00:59:26.000Z | backend/gdemu_control.c | retrohead/openmenu | 565f472aef47e7116a0d8e77f7960c2dee0238b0 | [
"BSD-3-Clause"
] | 5 | 2021-07-16T06:03:37.000Z | 2022-03-23T14:05:09.000Z | #include <arch/arch.h>
#include <dc/sound/sound.h>
#include <kos.h>
#include <kos/thread.h>
#include "backend/gd_item.h"
#include "gdemu_sdk.h"
#include "gdmenu_loader.h"
#ifndef GDROM_FS
void gd_reset_handles(void) {
}
void run_game(const char *region, const char *product) {
(void)region;
(void)product;
void arch_menu(void) __attribute__((noreturn));
arch_menu();
__builtin_unreachable();
}
#endif
void dreamcast_launch_disc(gd_item *disc) {
gdemu_set_img_num((uint16_t)disc->slot_num);
thd_sleep(200);
run_game(disc->region, disc->product);
}
| 19.586207 | 56 | 0.727113 |
12afa6e9b367d151876d3528075930f48af99b06 | 2,181 | h | C | Source/VTKExtensions/Client/vtkSMSceneContourSourceProxy.h | developkits/cmb | caaf9cd7ffe0b7c1ac3be9edbce0f9430068d2cb | [
"BSD-3-Clause"
] | null | null | null | Source/VTKExtensions/Client/vtkSMSceneContourSourceProxy.h | developkits/cmb | caaf9cd7ffe0b7c1ac3be9edbce0f9430068d2cb | [
"BSD-3-Clause"
] | null | null | null | Source/VTKExtensions/Client/vtkSMSceneContourSourceProxy.h | developkits/cmb | caaf9cd7ffe0b7c1ac3be9edbce0f9430068d2cb | [
"BSD-3-Clause"
] | null | null | null | //=========================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//=========================================================================
// .NAME vtkSMSceneContourSourceProxy - "data-centric" proxy for VTK source on a server
// .SECTION Description
// vtkSMSceneContourSourceProxy adds a CopyData method to the vtkSMSourceProxy API
// to give a "data-centric" behaviour; the output data of the input
// vtkSMSourceProxy (to CopyData) is copied by the VTK object managed
// by the vtkSMSceneContourSourceProxy.
// .SECTION See Also
// vtkSMSourceProxy vtkSMNewWidgetRepresentationProxy
#ifndef __vtkSMSceneContourSourceProxy_h
#define __vtkSMSceneContourSourceProxy_h
#include "cmbSystemConfig.h"
#include "vtkCMBClientModule.h" // For export macro
#include "vtkSMSourceProxy.h"
class vtkSMNewWidgetRepresentationProxy;
class VTKCMBCLIENT_EXPORT vtkSMSceneContourSourceProxy : public vtkSMSourceProxy
{
public:
static vtkSMSceneContourSourceProxy* New();
vtkTypeMacro(vtkSMSceneContourSourceProxy, vtkSMSourceProxy);
void PrintSelf(ostream& os, vtkIndent indent) override;
// Description:
// Copies data from a widget proxy to object represented by this
// source proxy object.
void CopyData(vtkSMNewWidgetRepresentationProxy* widgetProxy);
// Description:
// Copies the data this proxy output to the input of the widget
void EditData(vtkSMNewWidgetRepresentationProxy* widgetProxy, bool& closed);
// Dexcription:
//copies the data from a source proxy using the GetOutput method
void ExtractContour(vtkSMSourceProxy* sourceProxy);
//BTX
protected:
vtkSMSceneContourSourceProxy();
~vtkSMSceneContourSourceProxy() override;
private:
vtkSMSceneContourSourceProxy(const vtkSMSceneContourSourceProxy&); // Not implemented
void operator=(const vtkSMSceneContourSourceProxy&); // Not implemented
//ETX
};
#endif
| 36.35 | 87 | 0.731316 |
3f9a59840284a63a9254d80c3517491dc3eccc54 | 634 | h | C | 1785-Minimum Elements to Add to Form a Given Sum/cpp_1785/Solution1.h | ooooo-youwillsee/leetcode | 07b273f133c8cf755ea40b3ae9df242ce044823c | [
"MIT"
] | 12 | 2020-03-18T14:36:23.000Z | 2021-12-19T02:24:33.000Z | 1785-Minimum Elements to Add to Form a Given Sum/cpp_1785/Solution1.h | ooooo-youwillsee/leetcode | 07b273f133c8cf755ea40b3ae9df242ce044823c | [
"MIT"
] | null | null | null | 1785-Minimum Elements to Add to Form a Given Sum/cpp_1785/Solution1.h | ooooo-youwillsee/leetcode | 07b273f133c8cf755ea40b3ae9df242ce044823c | [
"MIT"
] | null | null | null | /**
* @author ooooo
* @date 2021/3/14 15:01
*/
#ifndef CPP_1785__SOLUTION1_H_
#define CPP_1785__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <stack>
#include <numeric>
#include <queue>
using namespace std;
class Solution {
public:
int minElements(vector<int> &nums, int limit, int goal) {
long long sum = accumulate(nums.begin(), nums.end(), (long long) 0);
long long target = abs(goal - sum);
if (target == 0) {
return 0;
}
return target % limit == 0 ? target / limit : target / limit + 1;
}
};
#endif //CPP_1785__SOLUTION1_H_
| 18.647059 | 70 | 0.678233 |
64cedd361faa2faab0a18eb3fd6c7bc9d00efdfa | 1,134 | h | C | AliPayForDebug/AliPayForDebug/AlipayWallet_Headers/HCCardViewMoneyDetailView.h | ceekay1991/AliPayForDebug | 5795e5db31e5b649d4758469b752585e63e84d94 | [
"MIT"
] | 5 | 2020-03-29T12:08:37.000Z | 2021-05-26T05:20:11.000Z | AliPayForDebug/AliPayForDebug/AlipayWallet_Headers/HCCardViewMoneyDetailView.h | ceekay1991/AliPayForDebug | 5795e5db31e5b649d4758469b752585e63e84d94 | [
"MIT"
] | null | null | null | AliPayForDebug/AliPayForDebug/AlipayWallet_Headers/HCCardViewMoneyDetailView.h | ceekay1991/AliPayForDebug | 5795e5db31e5b649d4758469b752585e63e84d94 | [
"MIT"
] | 5 | 2020-04-17T03:24:04.000Z | 2022-03-30T05:42:17.000Z | //
// Generated by class-dump 3.5 (64 bit) (Debug version compiled Sep 17 2017 16:24:48).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard.
//
#import <UIKit/UIView.h>
@class CSCard, MFAttributeLabel, NSDictionary, UILabel;
@interface HCCardViewMoneyDetailView : UIView
{
MFAttributeLabel *_moneyTextLab;
UILabel *_moneyDetailLab;
UIView *_line;
NSDictionary *_moneyDict;
CSCard *_card;
}
+ (double)moneyViewWidthWithCard:(id)arg1;
+ (double)moneyViewHeightWithDict:(id)arg1;
@property(retain, nonatomic) CSCard *card; // @synthesize card=_card;
@property(retain, nonatomic) NSDictionary *moneyDict; // @synthesize moneyDict=_moneyDict;
@property(retain, nonatomic) UIView *line; // @synthesize line=_line;
@property(retain, nonatomic) UILabel *moneyDetailLab; // @synthesize moneyDetailLab=_moneyDetailLab;
@property(retain, nonatomic) MFAttributeLabel *moneyTextLab; // @synthesize moneyTextLab=_moneyTextLab;
- (void).cxx_destruct;
- (_Bool)deptNumber:(id)arg1;
- (void)layout;
- (void)loadMoneyViewWithCard:(id)arg1;
- (id)initWithFrame:(struct CGRect)arg1;
@end
| 32.4 | 103 | 0.746032 |
5fbeec357ad9d2dbc32bf393d8243af556f8fc8f | 552 | c | C | lib/elf.c | ChrisCummins/euclid | da3eadeb6d02daf5be878b6c549abe92bda34c84 | [
"MIT"
] | null | null | null | lib/elf.c | ChrisCummins/euclid | da3eadeb6d02daf5be878b6c549abe92bda34c84 | [
"MIT"
] | null | null | null | lib/elf.c | ChrisCummins/euclid | da3eadeb6d02daf5be878b6c549abe92bda34c84 | [
"MIT"
] | null | null | null | #include <elf.h>
#include <kernel/panic.h>
#include <stddef.h>
#include <stdio.h>
const char *symbol_from_elf(struct elf *elf, u32 address) {
unsigned int i;
for (i = 0; i < (elf->symtabsz / sizeof(struct elf_symbol)); i++) {
if (ELF32_ST_TYPE(elf->symtab[i].info) != 0x2)
continue;
if ((address >= elf->symtab[i].value) &&
(address < (elf->symtab[i].value + elf->symtab[i].size))) {
return (const char *)((u32)elf->strtab
+ elf->symtab[i].name);
}
}
printf("Unable to find address %x in elf\n");
return NULL;
}
| 22.08 | 68 | 0.612319 |
58059fbf96e55ed4745fa0c455ff10c8d774bc59 | 8,623 | h | C | ARCHIVE/ICCDEF/IccdefRegistrator.h | pnlbwh/BRAINSTools | a2fe63ab5b795f03da140a4081d1fef6314dab95 | [
"Apache-2.0"
] | null | null | null | ARCHIVE/ICCDEF/IccdefRegistrator.h | pnlbwh/BRAINSTools | a2fe63ab5b795f03da140a4081d1fef6314dab95 | [
"Apache-2.0"
] | null | null | null | ARCHIVE/ICCDEF/IccdefRegistrator.h | pnlbwh/BRAINSTools | a2fe63ab5b795f03da140a4081d1fef6314dab95 | [
"Apache-2.0"
] | 1 | 2022-02-08T05:39:46.000Z | 2022-02-08T05:39:46.000Z | /*=========================================================================
*
* Copyright SINAPSE: Scalable Informatics for Neuroscience, Processing and Software Engineering
* The University of Iowa
*
* 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.txt
*
* 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 _iccdefRegistrator_h
#define _iccdefRegistrator_h
#include "itkObject.h"
#include "itkVector.h"
#include "itkImage.h"
#include "itkMultiResolutionICCDeformableRegistration.h"
#include "itkRecursiveMultiResolutionPyramidImageFilter.h"
#include "itkICCDeformableRegistrationFilter.h"
#include "itkArray.h"
namespace itk
{
/** \class IccdefRegistrator
*
* This component computes the transform to register a
* moving image onto a fixed image.
*
* In particular, it uses the deformable demons registration
* algorithm.
*
* The registration is done using a multiresolution strategy.
* At each resolution level, the downsampled images are obtained
* using a RecursiveMultiResolutionPyramidImageFilter.
*
* \warning This class requires both images to be 3D.
* It can write out the deformation field and the checker board image
* of the fixed and output image.
*
* The registration process is activated by method Execute().
*
* Inputs:
* - pointer to fixed image
* - pointer to moving image
* - number of resolution levels
* - number of optimization iterations at each level
* - the initial rigid (quaternion) transform parameters
* - the coarest level shrink factors for the fixed image
* - the coarest level shrink factors for the moving image
*
* Outputs:
* - output deformation field
* - output image
* - Checkerboard image
* - x,y,z components of displacement fields.
*/
template <typename TRealImage, typename TOutputImage, typename TFieldValue = typename TRealImage::PixelType>
class IccdefRegistrator : public Object
{
public:
ITK_DISALLOW_COPY_AND_ASSIGN(IccdefRegistrator);
/** Standard class type alias. */
using Self = IccdefRegistrator;
using Superclass = Object;
using Pointer = SmartPointer<Self>;
using ConstPointer = SmartPointer<const Self>;
/** Run-time type information (and related methods). */
itkTypeMacro(IccdefRegistrator, Object);
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Fixed Image Type. */
using RealImageType = TRealImage;
/** Moving Image Type. */
using OutputImageType = TOutputImage;
using PixelType = typename OutputImageType::PixelType;
/** Image dimension enumeration. */
static constexpr unsigned int ImageDimension = TRealImage::ImageDimension;
/** Deformation field value type. */
using FieldValueType = TFieldValue;
/** Deformation field pixel type. */
using FieldPixelType = Vector<FieldValueType, Self::ImageDimension>;
/** Deformation field type. */
using TDisplacementField = Image<FieldPixelType, Self::ImageDimension>;
/** Fixed Image Pyramid Type. */
using FixedImagePyramidType = RecursiveMultiResolutionPyramidImageFilter<RealImageType, RealImageType>;
/** Moving Image Pyramid Type. */
using MovingImagePyramidType = RecursiveMultiResolutionPyramidImageFilter<RealImageType, RealImageType>;
/** Registration Method. */
using RegistrationType = MultiResolutionICCDeformableRegistration<RealImageType, RealImageType, TDisplacementField>;
/** UnsignedIntArray type. */
using UnsignedIntArray = Array<unsigned int>;
/** ShrinkFactorsArray type. */
using ShrinkFactorsArray = FixedArray<unsigned int, Self::ImageDimension>;
/** Set the intial deformation field **/
itkSetObjectMacro(InitialDisplacementField, TDisplacementField);
/** Set the fixed image. */
itkSetObjectMacro(FixedImage, RealImageType);
/** Set the moving image. */
itkSetObjectMacro(MovingImage, RealImageType);
/** Set the Unnormalized moving image. */
itkSetObjectMacro(UnNormalizedMovingImage, RealImageType);
/** Set the Unnormalized moving image. */
itkSetObjectMacro(UnNormalizedFixedImage, RealImageType);
/** Set the number of resolution levels. */
itkSetClampMacro(NumberOfLevels, unsigned short, 1, NumericTraits<unsigned short>::max());
/** Set the number of iterations per level. */
itkSetMacro(NumberOfIterations, UnsignedIntArray);
itkSetStringMacro(InitialFixedDisplacementFieldFilename);
itkGetStringMacro(InitialFixedDisplacementFieldFilename);
itkSetStringMacro(InitialMovingDisplacementFieldFilename);
itkGetStringMacro(InitialMovingDisplacementFieldFilename);
itkSetMacro(OutputJacobianImage, bool);
itkGetConstMacro(OutputJacobianImage, bool);
itkSetMacro(OutputDisplacementField, bool);
itkGetConstMacro(OutputDisplacementField, bool);
itkSetMacro(OutputDisplacement, bool);
itkGetConstMacro(OutputDisplacement, bool);
/** Set WarpedImageName */
itkSetStringMacro(OutputPrefix);
itkGetStringMacro(OutputPrefix);
/** Set Deformation field output file Name */
itkSetStringMacro(ForwardDisplacementFieldOutputName);
itkGetStringMacro(ForwardDisplacementFieldOutputName);
itkSetStringMacro(BackwardDisplacementFieldOutputName);
itkGetStringMacro(BackwardDisplacementFieldOutputName);
/**Set histogram matching*/
itkSetMacro(UseHistogramMatching, bool);
itkGetConstMacro(UseHistogramMatching, bool);
/** Method to execute the registration. */
virtual void
Execute();
/** Get the deformation field. */
itkGetConstObjectMacro(DisplacementField, TDisplacementField);
/** Initialize registration at the start of new level. */
void
StartNewLevel();
/**Set Debug mode*/
itkSetMacro(OutDebug, bool);
itkGetConstMacro(OutDebug, bool);
itkSetMacro(DefaultPixelValue, typename RealImageType::PixelType);
itkGetMacro(DefaultPixelValue, typename RealImageType::PixelType);
using BaseRegistrationFilterType = ICCDeformableRegistrationFilter<RealImageType, RealImageType, TDisplacementField>;
void
SetRegistrationFilter(BaseRegistrationFilterType * filter)
{
this->m_Registration->SetRegistrationFilter(filter);
}
RegistrationType *
GetRegistrationType(void)
{
return m_Registration;
}
protected:
IccdefRegistrator();
~IccdefRegistrator() override;
private:
void
WriteDisplacementComponents(TDisplacementField *, std::string);
typename TDisplacementField::Pointer m_InitialDisplacementField;
typename RealImageType::Pointer m_FixedImage;
typename RealImageType::Pointer m_MovingImage;
typename RealImageType::Pointer m_UnNormalizedMovingImage;
typename RealImageType::Pointer m_UnNormalizedFixedImage;
typename FixedImagePyramidType::Pointer m_FixedImagePyramid;
typename MovingImagePyramidType::Pointer m_MovingImagePyramid;
typename RegistrationType::Pointer m_Registration;
typename RealImageType::PixelType m_DefaultPixelValue;
unsigned short m_NumberOfLevels;
UnsignedIntArray m_NumberOfIterations;
typename TDisplacementField::Pointer m_DisplacementField;
typename TDisplacementField::Pointer m_BackwardDisplacementField;
unsigned long m_Tag;
std::string m_DisplacementBaseName;
std::string m_OutputPrefix;
std::string m_ForwardDisplacementFieldOutputName;
std::string m_BackwardDisplacementFieldOutputName;
bool m_OutDebug;
bool m_UseHistogramMatching;
std::string m_InitialMovingDisplacementFieldFilename;
std::string m_InitialFixedDisplacementFieldFilename;
bool m_OutputJacobianImage;
bool m_OutputDisplacement;
bool m_OutputDisplacementField;
std::string m_ForwardDir;
std::string m_BackwardDir;
};
} // namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
# include "IccdefRegistrator.hxx"
#endif
#endif
| 35.195918 | 119 | 0.724342 |
169242f220715d6cb2a3f3bea409735fda6b8fa6 | 1,622 | h | C | dali/public-api/common/compile-time-assert.h | pwisbey/dali-core | 53117f5d4178001b0d688c5bce14d7bf8e861631 | [
"Apache-2.0"
] | 1 | 2016-08-05T09:58:38.000Z | 2016-08-05T09:58:38.000Z | dali/public-api/common/compile-time-assert.h | tizenorg/platform.core.uifw.dali-core | dd89513b4bb1fdde74a83996c726e10adaf58349 | [
"Apache-2.0"
] | null | null | null | dali/public-api/common/compile-time-assert.h | tizenorg/platform.core.uifw.dali-core | dd89513b4bb1fdde74a83996c726e10adaf58349 | [
"Apache-2.0"
] | null | null | null | #ifndef __DALI_COMPILE_TIME_ASSERT_H__
#define __DALI_COMPILE_TIME_ASSERT_H__
/*
* Copyright (c) 2015 Samsung Electronics 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.
*
*/
// INTERNAL INCLUDES
#include <dali/public-api/common/dali-common.h>
// EXTERNAL INCLUDES
#include <cstddef>
namespace Dali
{
/**
* @addtogroup dali_core_common
* @{
*/
template <bool x> struct CompileTimeAssertBool; ///< Bool Template to test condition
template <> struct CompileTimeAssertBool<true> {}; ///< Specialize for true, but not for false @SINCE_1_0.0
template<int x> struct CompileTimeAssertInt {}; ///< Template to wrap conditional template CompileTimeAsserBool @SINCE_1_0.0
/**
* @brief Use DALI_COMPILE_TIME_ASSERT to test expressions at compile time.
*
* If x is false, then 'sizeof' will be attempted with incomplete type.
* @SINCE_1_0.0
*/
#define DALI_COMPILE_TIME_ASSERT( x ) typedef Dali::CompileTimeAssertInt< sizeof( Dali::CompileTimeAssertBool< ( x ) > ) > CompileTimeAssertType __attribute__((__unused__))
/**
* @}
*/
} // namespace Dali
#endif // __DALI_COMPILE_TIME_ASSERT_H__
| 30.603774 | 172 | 0.743527 |
556d511cdcb609cf1d0cb373747744136967ee23 | 930 | h | C | foo_vis_spectrogram/config.h | stengerh/foo_vis_spectrogram | e6aaf682eb2cb8d18f45b7093798b15301282e06 | [
"BSD-3-Clause"
] | 6 | 2017-01-12T19:58:26.000Z | 2021-09-15T01:57:21.000Z | foo_vis_spectrogram/config.h | stengerh/foo_vis_spectrogram | e6aaf682eb2cb8d18f45b7093798b15301282e06 | [
"BSD-3-Clause"
] | null | null | null | foo_vis_spectrogram/config.h | stengerh/foo_vis_spectrogram | e6aaf682eb2cb8d18f45b7093798b15301282e06 | [
"BSD-3-Clause"
] | 2 | 2019-04-14T03:10:44.000Z | 2021-03-07T21:28:19.000Z | #ifndef __FOO_VIS_SPECTRUM__CONFIG_H__
#define __FOO_VIS_SPECTRUM__CONFIG_H__
extern cfg_bool cfg_popup_enabled;
extern cfg_window_placement cfg_popup_window_placement;
enum t_blend_mode
{
blend_mode_linear,
blend_mode_clockwise,
blend_mode_counterclockwise,
};
extern cfg_struct_t<t_spectrum_color_info> cfg_spectrum_color_info;
extern void g_fire_spectrum_colors_changed(const t_spectrum_color_info & p_info);
extern cfg_uint cfg_frames_per_second, cfg_lines_per_second;
extern cfg_int cfg_low_power_centibel;
extern cfg_int cfg_high_power_centibel;
extern void g_create_mapper(service_ptr_t<colormap> & p_out, t_spectrum_color_info p_info);
inline void g_create_mapper(service_ptr_t<colormap> & p_out, COLORREF p_colorLow, COLORREF p_colorHigh, unsigned p_blend_mode) {g_create_mapper(p_out, t_spectrum_color_info(p_blend_mode, p_colorLow, p_colorHigh));}
extern const GUID guid_prefs_vis_spectrum;
#endif
| 32.068966 | 214 | 0.858065 |
362096fac0dda1b8b5bfc25e55a03cb8beb2bd1d | 333 | h | C | src/xdcc.h | meqif/lolbot | 76361d7c3e84271b2224b902154d07d23b5fc444 | [
"MIT"
] | 2 | 2015-10-24T06:05:40.000Z | 2016-08-09T21:33:36.000Z | src/xdcc.h | meqif/lolbot | 76361d7c3e84271b2224b902154d07d23b5fc444 | [
"MIT"
] | 6 | 2015-03-17T14:12:35.000Z | 2015-06-11T22:42:13.000Z | src/xdcc.h | meqif/lolbot | 76361d7c3e84271b2224b902154d07d23b5fc444 | [
"MIT"
] | null | null | null | /* See LICENSE file for copyright and license details. */
#ifndef XDCC_H
#define XDCC_H
struct xdcc_request {
char *nick;
struct file_data *file;
unsigned long offset;
};
int xdcc_send(struct file_data *requested_file, char *remote_nick, int sockfd);
int xdcc_list(char *remote_nick, int sockfd);
#endif /* XDCC_H */
| 20.8125 | 79 | 0.726727 |
0d94fae525c9c5d61e4ac5709171d59cc0d49827 | 13,585 | c | C | apps/pic32mz_ef_sk_meb2/audio_player/audio_player_lab5/firmware/src/config/default/gfx/libaria/src/libaria_widget_window_skin_classic.c | SyedThaseemuddin/reference_apps | 55aeaa3b0dfc1b28c8f952845a059fdee9567c76 | [
"0BSD"
] | 7 | 2019-03-19T23:00:02.000Z | 2021-06-06T15:35:26.000Z | apps/pic32mz_ef_sk_meb2/audio_player/audio_player_lab5/firmware/src/config/default/gfx/libaria/src/libaria_widget_window_skin_classic.c | SyedThaseemuddin/reference_apps | 55aeaa3b0dfc1b28c8f952845a059fdee9567c76 | [
"0BSD"
] | null | null | null | apps/pic32mz_ef_sk_meb2/audio_player/audio_player_lab5/firmware/src/config/default/gfx/libaria/src/libaria_widget_window_skin_classic.c | SyedThaseemuddin/reference_apps | 55aeaa3b0dfc1b28c8f952845a059fdee9567c76 | [
"0BSD"
] | 2 | 2019-08-01T02:39:59.000Z | 2020-07-29T19:16:17.000Z | // DOM-IGNORE-BEGIN
/*******************************************************************************
* Copyright (C) 2020 Microchip Technology Inc. and its subsidiaries.
*
* Subject to your compliance with these terms, you may use Microchip software
* and any derivatives exclusively with Microchip products. It is your
* responsibility to comply with third party license terms applicable to your
* use of third party software (including open source software) that may
* accompany Microchip software.
*
* THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
* EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
* WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
* INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
* WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
* BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
* FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
* ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
* THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
*******************************************************************************/
// DOM-IGNORE-END
#include "gfx/libaria/inc/libaria_widget_window.h"
#if LA_WINDOW_WIDGET_ENABLED
#include "gfx/libaria/inc/libaria_context.h"
#include "gfx/libaria/inc/libaria_draw.h"
#include "gfx/libaria/inc/libaria_layer.h"
#include "gfx/libaria/inc/libaria_string.h"
#include "gfx/libaria/inc/libaria_utils.h"
#include "gfx/libaria/inc/libaria_widget.h"
#include "gfx/libaria/inc/libaria_widget_skin_classic_common.h"
#define DEFAULT_BAR_HEIGHT 20
enum
{
NOT_STARTED = LA_WIDGET_DRAW_STATE_READY,
DONE = LA_WIDGET_DRAW_STATE_DONE,
DRAW_BACKGROUND,
DRAW_TITLE_BAR,
DRAW_ICON,
WAIT_ICON,
DRAW_STRING,
WAIT_STRING,
DRAW_BORDER,
};
void laWindowWidget_GetTitleBarRect(laWindowWidget* win, GFX_Rect* barRect)
{
barRect->x = win->widget.margin.left;
barRect->y = win->widget.margin.top;
barRect->width = win->widget.rect.width -
win->widget.margin.left -
win->widget.margin.right;
barRect->height = laString_GetHeight(&win->title) +
win->widget.margin.top +
win->widget.margin.bottom;
if(barRect->height == 0)
barRect->height = DEFAULT_BAR_HEIGHT;
}
void laWindowWidget_GetIconRect(laWindowWidget* win,
GFX_Rect* imgRect,
GFX_Rect* imgSrcRect)
{
GFX_Rect barRect;
imgRect->x = 0;
imgRect->y = 0;
if(win->icon == NULL)
{
imgRect->width = 0;
imgRect->height = 0;
imgSrcRect->x = 0;
imgSrcRect->y = 0;
imgSrcRect->width = 0;
imgRect->height = 0;
return;
}
imgRect->width = win->icon->width;
imgRect->height = win->icon->height;
*imgSrcRect = *imgRect;
laWindowWidget_GetTitleBarRect(win, &barRect);
barRect.y += 2;
barRect.height -= 4;
laUtils_ArrangeRectangleRelative(imgRect,
GFX_Rect_Zero,
barRect,
LA_HALIGN_LEFT,
LA_VALIGN_MIDDLE,
LA_RELATIVE_POSITION_LEFTOF,
win->widget.margin.left,
win->widget.margin.top,
win->widget.margin.left,
win->widget.margin.bottom,
win->iconMargin);
*imgRect = GFX_RectClipAdj(imgRect, &barRect, imgSrcRect);
laUtils_RectToLayerSpace((laWidget*)win, imgRect);
}
void laWindowWidget_GetTextRect(laWindowWidget* win,
GFX_Rect* textRect,
GFX_Rect* drawRect)
{
GFX_Rect barRect, imageRect;
laWindowWidget_GetTitleBarRect(win, &barRect);
laString_GetRect(&win->title, textRect);
imageRect = GFX_Rect_Zero;
if(win->icon != NULL)
{
imageRect.width = win->icon->width;
imageRect.height = win->icon->height;
}
// arrange relative to image rect
laUtils_ArrangeRectangleRelative(textRect,
imageRect,
barRect,
LA_HALIGN_LEFT,
LA_VALIGN_MIDDLE,
LA_RELATIVE_POSITION_LEFTOF,
win->widget.margin.left,
win->widget.margin.top,
win->widget.margin.right,
win->widget.margin.bottom,
win->iconMargin);
GFX_RectClip(textRect, &barRect, drawRect);
laUtils_RectToLayerSpace((laWidget*)win, textRect);
laUtils_RectToLayerSpace((laWidget*)win, drawRect);
}
static void drawBackground(laWindowWidget* win);
static void drawTitleBar(laWindowWidget* win);
static void drawIcon(laWindowWidget* win);
static void waitIcon(laWindowWidget* win);
static void drawString(laWindowWidget* win);
static void waitString(laWindowWidget* win);
static void drawBorder(laWindowWidget* win);
static void nextState(laWindowWidget* win)
{
switch(win->widget.drawState)
{
case NOT_STARTED:
{
if(win->widget.backgroundType != LA_WIDGET_BACKGROUND_NONE)
{
win->widget.drawState = DRAW_BACKGROUND;
win->widget.drawFunc = (laWidget_DrawFunction_FnPtr)&drawBackground;
return;
}
}
case DRAW_BACKGROUND:
{
win->widget.drawState = DRAW_TITLE_BAR;
win->widget.drawFunc = (laWidget_DrawFunction_FnPtr)&drawTitleBar;
return;
}
case DRAW_TITLE_BAR:
{
if(win->icon != NULL)
{
win->widget.drawState = DRAW_ICON;
win->widget.drawFunc = (laWidget_DrawFunction_FnPtr)&drawIcon;
return;
}
}
case DRAW_ICON:
{
if(laString_IsEmpty(&win->title) == LA_FALSE)
{
win->widget.drawState = DRAW_STRING;
win->widget.drawFunc = (laWidget_DrawFunction_FnPtr)&drawString;
return;
}
}
case DRAW_STRING:
{
if(win->widget.borderType != LA_WIDGET_BORDER_NONE)
{
win->widget.drawFunc = (laWidget_DrawFunction_FnPtr)&drawBorder;
win->widget.drawState = DRAW_BORDER;
return;
}
}
case DRAW_BORDER:
{
win->widget.drawState = DONE;
win->widget.drawFunc = NULL;
}
}
}
static void drawBackground(laWindowWidget* win)
{
laWidget_SkinClassic_DrawStandardBackground((laWidget*)win);
nextState(win);
}
static void drawTitleBar(laWindowWidget* win)
{
GFX_Rect barRect;
laLayer* layer = laUtils_GetLayer((laWidget*)win);
laWindowWidget_GetTitleBarRect(win, &barRect);
laUtils_RectToLayerSpace((laWidget*)win, &barRect);
laWidget_SkinClassic_FillRect(&barRect,
win->widget.scheme->background,
&layer->clippedDrawingRect);
// draw title bar border
/*if(win->widget.borderType == LA_WIDGET_BORDER_LINE)
{
laDraw_LineBorder(&barRect, win->widget.scheme->shadowDark);
}
else if(win->widget.borderType == LA_WIDGET_BORDER_BEVEL)
{
laDraw_2x2BevelBorder(&barRect,
win->widget.scheme->base,
win->widget.scheme->highlightLight,
win->widget.scheme->shadow,
win->widget.scheme->shadowDark);
}*/
nextState(win);
}
static void drawIcon(laWindowWidget* win)
{
GFX_Rect iconRect, imgSrcRect, clipRect;
GFX_Bool alphaEnable;
laLayer* layer = laUtils_GetLayer((laWidget*)win);
laWindowWidget_GetIconRect(win, &iconRect, &imgSrcRect);
if(GFX_RectIntersects(&layer->clippedDrawingRect, &iconRect) == GFX_TRUE)
{
clipRect = GFX_RectClipAdj(&iconRect, &layer->clippedDrawingRect, &imgSrcRect);
GFX_Get(GFXF_DRAW_ALPHA_ENABLE, &alphaEnable);
GFX_Set(GFXF_DRAW_ALPHA_ENABLE, win->widget.alphaEnabled);
GFXU_DrawImage(win->icon,
imgSrcRect.x,
imgSrcRect.y,
imgSrcRect.width,
imgSrcRect.height,
clipRect.x,
clipRect.y,
&laContext_GetActive()->memIntf,
&win->reader);
GFX_Set(GFXF_DRAW_ALPHA_ENABLE, alphaEnable);
if (win->reader != NULL)
{
win->widget.drawState = WAIT_ICON;
win->widget.drawFunc = (laWidget_DrawFunction_FnPtr)&waitIcon;
return;
}
}
nextState(win);
}
static void waitIcon(laWindowWidget* win)
{
if(win->reader->status != GFXU_READER_STATUS_FINISHED)
{
win->reader->run(win->reader);
return;
}
// free the reader
win->reader->memIntf->heap.free(win->reader);
win->reader = NULL;
win->widget.drawState = DRAW_ICON;
nextState(win);
}
static void drawString(laWindowWidget* win)
{
GFX_Rect textRect, drawRect, clipRect;
laLayer* layer = laUtils_GetLayer((laWidget*)win);
laWindowWidget_GetTextRect(win, &textRect, &drawRect);
if(GFX_RectIntersects(&layer->clippedDrawingRect, &drawRect) == GFX_TRUE)
{
GFX_Set(GFXF_DRAW_MASK_ENABLE, GFX_FALSE);
GFX_Set(GFXF_DRAW_COLOR, win->widget.scheme->text);
GFX_RectClip(&drawRect, &layer->clippedDrawingRect, &clipRect);
laString_DrawClipped(&win->title,
clipRect.x,
clipRect.y,
clipRect.width,
clipRect.height,
textRect.x,
textRect.y,
&win->reader);
if(win->reader != NULL)
{
win->widget.drawFunc = (laWidget_DrawFunction_FnPtr)&waitString;
win->widget.drawState = WAIT_STRING;
return;
}
}
nextState(win);
}
static void waitString(laWindowWidget* win)
{
if(win->reader->status != GFXU_READER_STATUS_FINISHED)
{
win->reader->run(win->reader);
return;
}
// free the reader
win->reader->memIntf->heap.free(win->reader);
win->reader = NULL;
win->widget.drawState = DRAW_STRING;
nextState(win);
}
static void drawBorder(laWindowWidget* win)
{
GFX_Rect rect;
laLayer* layer;
if(win->widget.borderType == LA_WIDGET_BORDER_LINE)
{
laWidget_SkinClassic_DrawStandardLineBorder((laWidget*)win);
}
else if(win->widget.borderType == LA_WIDGET_BORDER_BEVEL)
{
rect = laUtils_WidgetLocalRect((laWidget*)win);
layer = laUtils_GetLayer((laWidget*)win);
laUtils_RectToLayerSpace((laWidget*)win, &rect);
laWidget_SkinClassic_Draw2x2BeveledBorder(&rect,
win->widget.scheme->base,
win->widget.scheme->highlightLight,
win->widget.scheme->shadowDark,
win->widget.scheme->shadow,
&layer->clippedDrawingRect);
}
nextState(win);
}
void _laWindowWidget_Paint(laWindowWidget* win)
{
laContext* context = laContext_GetActive();
if(win->widget.scheme == NULL)
{
win->widget.drawState = DONE;
return;
}
if(win->widget.drawState == NOT_STARTED)
nextState(win);
while(win->widget.drawState != DONE)
{
win->widget.drawFunc((laWidget*)win);
if(context->preemptLevel == LA_PREEMPTION_LEVEL_2 ||
win->widget.drawState == WAIT_ICON ||
win->widget.drawState == WAIT_STRING)
break;
}
}
#endif // LA_WINDOW_WIDGET_ENABLED | 31.889671 | 97 | 0.530144 |
3d4733aa956fa7a4daabdc1581c647d87dfd8059 | 592 | h | C | base/bits.h | romange/helio | 445ebf76b96b7360982f2b3c4558ec347ba3adb5 | [
"Apache-2.0"
] | 13 | 2021-12-09T19:04:01.000Z | 2022-02-20T08:49:06.000Z | base/bits.h | romange/async | 30d387fa0f2b5eee32eec570781be00157b2d07d | [
"Apache-2.0"
] | 1 | 2022-01-15T20:09:37.000Z | 2022-01-15T20:09:37.000Z | base/bits.h | romange/async | 30d387fa0f2b5eee32eec570781be00157b2d07d | [
"Apache-2.0"
] | null | null | null | // Copyright 2021, Beeri 15. All rights reserved.
// Author: Roman Gershman (romange@gmail.com)
//
#pragma once
#include <absl/numeric/bits.h>
class [[deprecated]] Bits {
public:
static int CountOnes(uint32_t n) {
return __builtin_popcount(n);
}
static inline constexpr int CountOnes64(uint64_t n) {
return __builtin_popcountll(n);
}
static uint32_t RoundUp(uint32_t x) {
return absl::bit_ceil(x);
}
static uint64_t RoundUp64(uint64_t x) {
return absl::bit_ceil(x);
}
private:
Bits(const Bits&) = delete;
void operator=(const Bits&) = delete;
};
| 19.096774 | 55 | 0.684122 |
ce56b93695a5915ff791f9916f0bef7580607e56 | 90 | h | C | Core/Sources/Utils/utFuncs.h | guoxx/ProtoLab | fe9678e6ee85bb5fabb9896544e797f4d086e0cd | [
"MIT"
] | 2 | 2016-10-08T07:08:24.000Z | 2018-04-19T14:59:12.000Z | Core/Sources/Utils/utFuncs.h | guoxx/ProtoLab | fe9678e6ee85bb5fabb9896544e797f4d086e0cd | [
"MIT"
] | null | null | null | Core/Sources/Utils/utFuncs.h | guoxx/ProtoLab | fe9678e6ee85bb5fabb9896544e797f4d086e0cd | [
"MIT"
] | null | null | null | #pragma once
void print(const char* fmt, ...);
void checkSucceeded(uint32_t result); | 18 | 37 | 0.7 |
35e7c663910f2c943e4a36a2f00c6a9a659d3319 | 1,730 | h | C | ui/ozone/platform/cast/surface_factory_cast.h | Yannic/chromium | ab32e8aacb08c9fce0dc4bf09eec456ba46e3710 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 76 | 2020-09-02T03:05:41.000Z | 2022-03-30T04:40:55.000Z | ui/ozone/platform/cast/surface_factory_cast.h | blueboxd/chromium-legacy | 07223bc94bd97499909c9ed3c3f5769d718fe2e0 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 45 | 2020-09-02T03:21:37.000Z | 2022-03-31T22:19:45.000Z | ui/ozone/platform/cast/surface_factory_cast.h | Yannic/chromium | ab32e8aacb08c9fce0dc4bf09eec456ba46e3710 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 8 | 2020-07-22T18:49:18.000Z | 2022-02-08T10:27:16.000Z | // Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_OZONE_PLATFORM_CAST_SURFACE_FACTORY_CAST_H_
#define UI_OZONE_PLATFORM_CAST_SURFACE_FACTORY_CAST_H_
#include <memory>
#include <vector>
#include "base/macros.h"
#include "ui/gfx/geometry/size.h"
#include "ui/ozone/platform/cast/gl_ozone_egl_cast.h"
#include "ui/ozone/public/gl_ozone.h"
#include "ui/ozone/public/surface_factory_ozone.h"
namespace chromecast {
class CastEglPlatform;
}
namespace ui {
// SurfaceFactoryOzone implementation for OzonePlatformCast.
class SurfaceFactoryCast : public SurfaceFactoryOzone {
public:
SurfaceFactoryCast();
explicit SurfaceFactoryCast(
std::unique_ptr<chromecast::CastEglPlatform> egl_platform);
SurfaceFactoryCast(const SurfaceFactoryCast&) = delete;
SurfaceFactoryCast& operator=(const SurfaceFactoryCast&) = delete;
~SurfaceFactoryCast() override;
// SurfaceFactoryOzone implementation:
std::vector<gl::GLImplementationParts> GetAllowedGLImplementations() override;
GLOzone* GetGLOzone(const gl::GLImplementationParts& implementation) override;
std::unique_ptr<SurfaceOzoneCanvas> CreateCanvasForWidget(
gfx::AcceleratedWidget widget) override;
scoped_refptr<gfx::NativePixmap> CreateNativePixmap(
gfx::AcceleratedWidget widget,
VkDevice vk_device,
gfx::Size size,
gfx::BufferFormat format,
gfx::BufferUsage usage,
absl::optional<gfx::Size> framebuffer_size = absl::nullopt) override;
private:
std::unique_ptr<GLOzoneEglCast> egl_implementation_;
};
} // namespace ui
#endif // UI_OZONE_PLATFORM_CAST_SURFACE_FACTORY_CAST_H_
| 31.454545 | 80 | 0.782659 |
6d9c0ff34a3a640117132276b8d0a97f73a7596d | 21,155 | h | C | src/amuse/community/seba/src/SeBa/include/star/single_star.h | andrisdorozsmai/amuse | 768d27ffe4acc21880f945199417589eabf0d600 | [
"Apache-2.0"
] | null | null | null | src/amuse/community/seba/src/SeBa/include/star/single_star.h | andrisdorozsmai/amuse | 768d27ffe4acc21880f945199417589eabf0d600 | [
"Apache-2.0"
] | null | null | null | src/amuse/community/seba/src/SeBa/include/star/single_star.h | andrisdorozsmai/amuse | 768d27ffe4acc21880f945199417589eabf0d600 | [
"Apache-2.0"
] | null | null | null |
//=======================================================// _\|/_
// __ _____ ___ ___ // /|\
// / | ^ | \ | ^ | \ // _\|/_
// \__ | / \ |___/ | / \ |___/ // /|\
// \ | /___\ | \ | /___\ | \ // _\|/_
// ___/ | / \ | \ |____ / \ |___/ // /|\
// // _\|/_
//=======================================================// /|\
/*
* single_star.h: derived class for single star base element.
*
*.............................................................................
* version 1: Jan 1994 Simon F. Portegies Zwart
* version 2:
*.............................................................................
* This file includes:
* 1) definition of class estar
*
*.............................................................................
*/
#ifndef _SINGLE_STAR
# define _SINGLE_STAR
#include "star.h"
#include "star_state.h"
/*-----------------------------------------------------------------------------
* star -- the standard class for stellar evolution, with core and envelope
*-----------------------------------------------------------------------------
*/
class single_star : public star
{
protected:
int identity;
stellar_type star_type;
star_type_spec spec_type[no_of_spec_type];
real metalicity;
real current_time;
real relative_age;
real last_update_age;
real next_update_age;
// AMUSE
real time_offset;
// AMUSE
real relative_mass;
real envelope_mass;
real core_mass;
real COcore_mass;
real mzams;
real radius;
real core_radius;
real effective_radius;
real luminosity;
real velocity;
vec anomal_velocity;
real birth_mass;
real magnetic_field; //[log G]
real rotation_period; //[s]
real wind_constant;
real accreted_mass;
star_hist previous;
real beta_interpolated;
real k_interpolated;
real beta_array[19][25];
real timestamp_array[19][25];
real k_array[19][25];
real beta_array_SSO[14][15];
real timestamp_array_SSO[14][15];
real k_array_SSO[14][15];
public:
single_star(node*);
single_star(single_star&);
~single_star() {
get_seba_counters()->del_sstar++;
}
int no_of_elements() {return 1;}
star_type_spec get_spec_type(star_type_spec i) {
return spec_type[i];}
int get_identity() {return identity;}
real get_metalicity() {return metalicity;}
void set_metalicity(const real z) {metalicity = z;}
real get_previous_current_time() {return previous.current_time;}
real get_previous_total_mass() {return previous.envelope_mass
+ previous.core_mass;}
real get_current_time() {return current_time;}
real get_relative_age() {return relative_age;}
real get_effective_radius() {return effective_radius;}
real get_last_update_age() {return last_update_age;}
real get_next_update_age() {return next_update_age;}
real get_relative_mass() {return relative_mass;}
real get_envelope_mass() {return envelope_mass;}
real get_core_mass() {return core_mass;}
real get_COcore_mass() {return COcore_mass;}
real get_core_radius() {return core_radius;}
real get_radius() {return radius;}
real get_luminosity() {return luminosity;}
real get_velocity() {return velocity;}
vec get_anomal_velocity() {return anomal_velocity;}
real get_magnetic_field() {return magnetic_field;}
real get_rotation_period() {return rotation_period;}
real get_fallback(){return 0;}// only meaningful for BHs
stellar_type get_sep(){return star_type;}
real get_total_mass() {return envelope_mass + core_mass;}
real get_mzams() {return mzams;}
real get_beta_interpolated() {return beta_interpolated;}
real get_k_interpolated() {return k_interpolated;}
void set_current_time(real t) {current_time=t;}
void set_relative_age(real t) {relative_age=t;}
void set_luminosity(real l) {luminosity = l;}
void set_magnetic_field(real b){magnetic_field=b;}
void set_rotation_period(real p){rotation_period=p;}
void set_identity(int i) {identity=i;}
void set_envelope_mass(const real m) {envelope_mass = m;}
void set_core_mass(const real m) {core_mass = m;}
void set_COcore_mass(const real m) {COcore_mass = m;}
void set_spec_type(star_type_spec s, bool on=true);
void set_effective_radius(const real r) {effective_radius=r;}
void set_last_update_age(const real t) {last_update_age = t;}
void set_next_update_age(const real t) {next_update_age = t;}
void set_previous_radius(const real r) {previous.radius = r;}
void set_velocity(const real v) {velocity = v;}
void set_anomal_velocity(const vec v) {anomal_velocity = v;}
void set_beta_interpolated(real b) {beta_interpolated = b;}
void set_k_interpolated(real k) {k_interpolated = k;}
real magnitude();
real temperature();
real get_wind_constant();
// void clean();
// Replaced see below
// bool low_mass_star();
// bool medium_mass_star();
// bool high_mass_star();
void initialize(int id, real z, real t_cur,
real t_rel, real m_rel, real m_tot,
real m_core, real co_core);
// Time scales
real nucleair_evolution_timescale();
real kelvin_helmholds_timescale();
real dynamic_timescale();
real nucleair_evolution_time();
real nucleair_evolution_time(const real, const real, const real);
real get_evolve_timestep();
real mass_transfer_timescale(mass_transfer_type &type);
// Luminosities
real bolometric_correction();
bool remnant() {return false;} // default: not a remnant.
bool magnetic() {return false;} // default: no magnetic stellar wind.
bool hydrogen_envelope_star() {return true;}
bool giant_star() {return false;}
bool star_with_COcore() {return false;}
// real helium_core_radius();
void refresh_memory();
void recall_memory();
// stellar wind routines.
void update_wind_constant();
void stellar_wind(const real);
real wind_velocity();
real accrete_from_stellar_wind(const real, const real);
// Stability rourines.
real zeta_adiabatic();
real zeta_thermal();
real angular_momentum();
// radius change for donors/accretors
void adjust_donor_radius(const real);
void adjust_accretor_radius(const real, const real);
// Mass transfer routines.
// void add_mass_to_core(const real);
real add_mass_to_accretor(real, bool, const real = -1.);
// star* reduce_mass(const real);
real rejuvenation_fraction(const real);
void update_relative_mass(const real);
void lose_envelope_decent();
star* merge_elements(star*);
real mdot_limit(const real, real);
real mass_ratio_mdot_limit(real);
real accretion_limit(const real, const real);
real expansionA(const real);
real expansionB(const real);
real accretion_limit_eddington(const real, const real);
void update();
void detect_spectral_features();
// Input/Output
void read_element();
void put_element();
void dump(ostream&, bool brief = true);
void dump(char*, bool brief = true);
void print_status();
void print_roche();
void put_state();
void put_hrd(ostream &);
virtual void read_in_csv_table(real beta_array[19][25], char* filename);
virtual void read_in_csv_table(real beta_array[14][15], char* filename){};
virtual void determine_beta(const real mass, const real time);
//virtual void determine_beta_bd(const real mass, const real time);
//virtual void read_in_csv_table_bd(real beta_array_SSO[14][15], char* filename);
real tf2_energy_diss(const real);
real tf3_energy_diss(const real);
real potential_energy();
real kinetic_energy();
real total_energy();
void post_constructor();
void star_transformation_story(stellar_type);
void post_supernova_story();
void first_roche_lobe_contact_story(stellar_type);
virtual istream& scan_star_story(istream&);
virtual ostream& print_star_story(ostream&,
int short_output = 0);
real linear_function_inversion(real (single_star::*fptr)(real, const real),
const real x_guess, const real y_value, const real z = 0,
const real xmin = cnsts.parameters(minimum_main_sequence),
const real xmax = cnsts.parameters(maximum_main_sequence));
real update_core_and_envelope_mass(const real m_core);
real update_core_and_envelope_mass_TPAGB(const real m_core);
real update_COcore_mass(const real mco_core);
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// The new metalicity dependencies come here:
real get_zeta(const real z);
real helium_flash_mass(const real z);
real helium_ignition_mass(const real z);
real helium_ignition_luminosity(const real mass,
const real z);
real helium_ignition_radius(const real mass, const real mass_tot, const real z);
real helium_ignition_core_mass(const real mass,
const real z); // Eq.67
// real core_helium_burning_core_mass_from_helium_star(const real time,
// const real mass,
// const real z,
// const real mc);
// real core_helium_burning_core_mass_from_helium_star(const real mass,
// const real z);
bool low_mass_star(const real mass,
const real z);
bool low_mass_star();
bool medium_mass_star();
bool intermediate_mass_star(const real mass,
const real z);
bool high_mass_star(const real mass,
const real z);
bool high_mass_star();
real base_giant_branch_time(const real mass,
const real z);
// real base_giant_branch_time(const real mass);
real base_giant_branch_time();
real base_giant_branch_luminosity(const real mass,
const real z);
real base_giant_branch_luminosity(const real mass);
real base_giant_branch_luminosity();
real FGB_mass(const real z);
real get_hydrogen_fraction(const real z);
// real convective_envelope_mass(const real z);
real convective_envelope_mass(){return 0;}
real convective_envelope_radius(){return 0;}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// These functions are part of main_sequence.C
real main_sequence_hook_mass(const real z);
// friend main_sequence::main_sequence_hook_mass(const real z);
// real helium_flash_mass(const real z);
real main_sequence_time(const real mass,
const real z);
real main_sequence_time();
real main_sequence_hook_time(const real mass,
const real z);
real stars_without_main_sequence_hook(const real mass,
const real z);
real stars_with_main_sequence_hook(const real mass,
const real z);
real terminal_main_sequence_luminosity(const real mass,
const real z);
real terminal_main_sequence_radius(const real mass,
const real z);
//real base_main_sequence_radius(const real mass);
real base_main_sequence_radius(const real mass, const real z);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Hertzsprung-gap
real initial_hertzsprung_gap_core_mass(const real mass, const real z);
real terminal_hertzsprung_gap_core_mass(const real mass,
const real z);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++
//Functions for core helium burning
real giant_branch_radius(const real l_hb,
const real mass_tot,
const real z);
real minimum_blue_loop_radius(const real mass, const real mass_tot, const real z);
real base_horizontal_branch_luminosity(const real mass, const real z);
real minimum_horizontal_branch_luminosity(const real mass, const real z);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Core helium burning without envelope (helium star)
real helium_main_sequence_time_for_solar_metalicity(const real mass);
real helium_star_luminosity_for_solar_metalicity(const real mass);
real helium_star_radius_for_solar_metalicity(const real mass_tot);
real helium_main_sequence_luminosity(const real time, const real mass);
real helium_main_sequence_radius(const real time, const real mass, const real mass_tot);
real terminal_helium_main_sequence_luminosity(const real mass);
real helium_giant_luminosity_from_core_mass(
const real m_core, const real mass, const real z);
real helium_giant_radius(const real lum, const real mass,
const real mass_tot, const real z);
real helium_giant_x_mass(const real mass);
real helium_giant_x_luminosity(const real mass);
real helium_giant_B_factor();
real helium_giant_D_factor(const real mass);
real helium_giant_p_parameter();
real helium_giant_q_parameter();
real helium_giant_initial_core_mass(const real mass, const real z = 0);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Small envelope behaviour
void small_envelope_perturbation();
real small_envelope_mu(const real lum, const real mass_tot,
const real m_core);
real perturb_luminosity(const real lum, const real lum_c,
const real mass_tot, const real m_core, const real mu);
real perturb_radius(const real rad, const real rad_c, const real mass_tot,
const real m_core, const real mu);
real s_helper(const real mass_tot, const real mu);
real r_helper(const real rad, const real rad_c, const real mass_tot,
const real mu);
// don't do this:
// real small_envelope_core_luminosity(){return 0;};
// real small_envelope_core_radius(){return 0;};
// real helium_core_radius(){return 0;};
virtual real small_envelope_core_luminosity(){};
virtual real small_envelope_core_radius(){};
virtual real helium_core_radius(){};
//white dwarf
real white_dwarf_radius(real mass, real time);
// for virtual declaration in
// void evolve_core_mass(const real) {}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Shell hydrogen burning with envelope (sub giant)
real hydrogen_rate_constant(const real mass);
real sub_giant_Ah_estimator(const real mass);
real sub_giant_B_factor(const real mass);
real sub_giant_D_factor(const real mass);
real sub_giant_D_factor(const real mass,
const real z);
real sub_giant_p_parameter(const real mass,
const real z);
real sub_giant_q_parameter(const real mass,
const real z);
// real sub_giant_core_mass(const real time,
// const real mass,
// const real z);
real determine_core_mass(const real time,
const real mass,
const real z,
const real A,
const real t_b,
const real l_b);
real determine_age(const real m_core, const real mass,
const real z, const real A,
const real t_b, const real l_b);
real FGB_x_luminosity(const real mass, const real z);
real FGB_x_mass(const real mass, const real z);
real FGB_core_mass_luminosity_relation(const real lum,
const real mass,
const real z);
//real FGB_core_mass_luminosity_relation(const real time,
// const real mass,
// const real z);
real FGB_luminosity_core_mass_relation(const real time,
const real mass,
const real z);
real FGB_luminosity_core_mass_relation(const real m_core,
const real mass);
// real sub_giant_luminosity(const real time,
// const real mass,
// const real z);
// real specific_time_x_factor(const real mass,
// const real z);
real specific_time_boundary(const real mass,
const real A,
const real t_b,
const real l_b,
const real D,
const real p,
const real l_x);
// real specific_time_boundary(const real mass,
// const real z);
real specific_time_limit(const real A,
const real t_min,
const real DB,
const real l_min,
const real pq);
// real specific_upper_time_limit(const real mass,
// const real z,
// real (single_star::*fptr_time)(const real, const real),
// real (single_star::*fptr_luminosity)(const real, const real));
real helium_ignition_time(const real mass,
const real z);
real helium_ignition_time();
real base_giant_branch_core_mass(const real mass,
const real z);
real base_horizontal_branch_radius(const real mass,
const real mass_tot, const real z);
real core_helium_burning_timescale(const real mass,
const real z); //Eq.57
real core_helium_burning_timescale();
real base_AGB_luminosity(const real mass, const real z); // Eq.56
real base_AGB_time(const real mass, const real z);
real base_AGB_time();
real AGB_A_He_estimator(); //Eq.68
real AGB_radius(const real lum, const real mass, const real mass_tot, const real z);
real base_AGB_core_mass(const real mass, const real z); // Eq.66
real base_AGB_relative_mass(const real m_core, const real z); // Eq.66 inverted
real TAGB_time(const real mass, const real mass_tot, const real z);
real dredge_up_core_mass(const real mass, const real z);
real TPAGB_AH_He_estimator();
real maximum_AGB_core_mass(const real mass,
const real z); //Eq.75
real AGB_luminosity(const real CO_core_mass, const real mass,
const real z); //Eq.37
real dredge_up_time(const real mass, const real z);// Eq.70
real dredge_up_luminosity(const real mass, const real z);
// AMUSE
real get_time_offset() {return time_offset;}
void set_time_offset(real t) {time_offset=t;}
//AMUSE
};
// Shorthand for conversion from node pointer to star pointer:
#define N_SS_PTR ((single_star *)n->get_starbase())
// note: automatic conversion from star to dyn scaling
node* mkstar(int, real, stellar_type type=Main_Sequence);
void extract_story_chapter(stellar_type&, real& z,
real& t_cur, real& t_ral,
real&, real&, real&,
real&, real&,
real&, real&, real&,
story&);
void extract_line_text(stellar_type&, real& z, real&, real&, real&,
real&, real&, real&, real&, real&,
real&, real&, story&);
bool merge_elements(single_star* primary, single_star *secondary);
void addstar(node*,
real t_cur=0,
stellar_type type=Main_Sequence,
real z = cnsts.parameters(Zsun),
int id = 1,
bool verbose = false,
real m_rel = 1,
real m_env = 0,
real m_core = 0.0,
real mco_core = 0,
real t_rel = 0);
#endif // _SINGLE_STAR
| 38.887868 | 94 | 0.57731 |
6df63de611c2d060d2f4d16bd141d6d80631d8ca | 718 | h | C | V5ClientSDK/V5MediaMessage.h | Chyrain/V5ClientWithFramework | 7fedca4d5c0057fbe63b52079143d4ab3fad318b | [
"MIT"
] | 7 | 2016-05-23T07:27:13.000Z | 2020-01-14T02:43:17.000Z | V5ClientSDK/V5MediaMessage.h | Chyrain/V5ClientWithFramework | 7fedca4d5c0057fbe63b52079143d4ab3fad318b | [
"MIT"
] | 3 | 2016-06-27T14:32:23.000Z | 2017-09-22T06:52:45.000Z | V5ClientSDK/V5MediaMessage.h | Chyrain/V5ClientWithFramework | 7fedca4d5c0057fbe63b52079143d4ab3fad318b | [
"MIT"
] | 4 | 2017-04-07T04:23:26.000Z | 2021-07-02T16:24:46.000Z | //
// V5MediaMessage.h
// mcss
//
// Created by chyrain on 16/8/19.
// Copyright © 2016年 V5KF. All rights reserved.
//
#import "V5Message.h"
@class V5MediaMessage;
typedef void (^V5MediaLoadSuccessBlock)(V5MediaMessage *message);
typedef void (^V5MediaLoadFailureBlock)(V5MediaMessage *message, NSString *reason);
@interface V5MediaMessage : V5Message
// 本地路径
@property (nonatomic, strong) NSString *filePath;
// 格式
@property (nonatomic, strong) NSString * format;
- (NSString *)getDefaultFormat;
- (NSString *)getDefaultURL;
- (void)loadMediaSuccess:(V5MediaLoadSuccessBlock)success
failure:(V5MediaLoadFailureBlock)failure
progress:(void (^)(float progress))progress;
@end
| 24.758621 | 83 | 0.721448 |
0d36c6c75dfa2f554a02ed61bd61b3fd10fb5288 | 19,217 | h | C | FireRender.Max.Plugin/plugin/light/FireRenderIES_Panel.h | Vsevolod1983/RadeonProRenderMaxPlugin | d5393fd04e45dd2c77c8b17fac4e10b20df55285 | [
"Apache-2.0"
] | 6 | 2020-05-24T12:00:43.000Z | 2021-07-13T06:22:49.000Z | FireRender.Max.Plugin/plugin/light/FireRenderIES_Panel.h | Vsevolod1983/RadeonProRenderMaxPlugin | d5393fd04e45dd2c77c8b17fac4e10b20df55285 | [
"Apache-2.0"
] | 4 | 2020-09-17T17:05:38.000Z | 2021-06-23T14:29:14.000Z | FireRender.Max.Plugin/plugin/light/FireRenderIES_Panel.h | Vsevolod1983/RadeonProRenderMaxPlugin | d5393fd04e45dd2c77c8b17fac4e10b20df55285 | [
"Apache-2.0"
] | 8 | 2020-05-15T08:29:17.000Z | 2021-07-14T08:38:07.000Z | /**********************************************************************
Copyright 2020 Advanced Micro Devices, Inc
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.
********************************************************************/
#pragma once
#include <functional>
#include "frScope.h"
#include "utils/KelvinToColor.h"
FIRERENDER_NAMESPACE_BEGIN
class FireRenderIESLight;
/* This class contains common code for 3dsMax specific controls
'ControlTraits' must have:
TControl typedef which represents 3dsMax control
static TControl* Capture(HWND) method
static void Release(TControl*) method
*/
template<typename ControlTraits>
class MaxControl
{
using TControl = typename ControlTraits::TControl;
public:
using Traits = ControlTraits;
MaxControl() :
m_ctrl(nullptr)
{}
MaxControl(MaxControl&& that)
{
MoveFrom(that);
}
MaxControl(const MaxControl&) = delete;
~MaxControl()
{
Release();
}
void Capture(HWND dialog, int control)
{
// Release previous control
Release();
HWND controlHwnd = GetDlgItem(dialog, control);
if (controlHwnd == nullptr)
{
FASSERT(!"Failed to capture the control");
return;
}
m_ctrl = ControlTraits::Capture(controlHwnd);
FASSERT(m_ctrl != nullptr);
}
void Release()
{
if (m_ctrl != nullptr)
{
ControlTraits::Release(m_ctrl);
m_ctrl = nullptr;
}
}
void Enable()
{
FASSERT(m_ctrl != nullptr);
m_ctrl->Enable(TRUE);
}
void Disable()
{
FASSERT(m_ctrl != nullptr);
m_ctrl->Enable(FALSE);
}
TControl* GetControl() const { return m_ctrl; }
MaxControl& operator=(const MaxControl&) = delete;
MaxControl& operator=(MaxControl&& that)
{
Release();
MoveFrom(that);
return *this;
}
protected:
void MoveFrom(MaxControl& that)
{
m_ctrl = that.m_ctrl;
that.m_ctrl = nullptr;
}
TControl* m_ctrl;
};
class MaxSpinnerTraits
{
public:
using TControl = ISpinnerControl;
static TControl* Capture(HWND wnd) { return GetISpinner(wnd); }
static void Release(TControl* ctrl) { ReleaseISpinner(ctrl); }
};
class MaxEditTraits
{
public:
using TControl = ICustEdit;
static TControl* Capture(HWND wnd) { return GetICustEdit(wnd); }
static void Release(TControl* ctrl) { ReleaseICustEdit(ctrl); }
};
class MaxButtonTraits
{
public:
using TControl = ICustButton;
static TControl* Capture(HWND wnd) { return GetICustButton(wnd); }
static void Release(TControl* ctrl) { ReleaseICustButton(ctrl); }
};
class MaxColorSwatchTraits
{
public:
using TControl = IColorSwatch;
static TControl* Capture(HWND wnd) { return GetIColorSwatch(wnd); }
static void Release(TControl* ctrl) { ReleaseIColorSwatch(ctrl); }
};
/* This class wraps 3dsMax ISpinnerControl */
class MaxSpinner :
public MaxControl<MaxSpinnerTraits>
{
using ParentClass = MaxControl<MaxSpinnerTraits>;
public:
using ParentClass::ParentClass;
using ParentClass::operator=;
struct DefaultFloatSettings
{
static const float Min;
static const float Max;
static const float Default;
static const float Delta;
};
struct DefaultRotationSettings
{
static const float Min;
static const float Max;
static const float Default;
static const float Delta;
};
template<typename T>
void SetLimits(T min, T max, bool limitCurrent = false)
{
FASSERT(m_ctrl != nullptr);
m_ctrl->SetLimits(min, max, limitCurrent);
}
template<typename T>
void SetResetValue(T resetValue)
{
FASSERT(m_ctrl != nullptr);
m_ctrl->SetResetValue(resetValue);
}
void SetScale(float scale)
{
FASSERT(m_ctrl != nullptr);
m_ctrl->SetScale(scale);
}
template<typename T>
void SetValue(T value, bool notify = false)
{
FASSERT(m_ctrl != nullptr);
m_ctrl->SetValue(value, notify);
}
template<typename Settings>
void SetSettings()
{
SetLimits(Settings::Min, Settings::Max);
SetResetValue(Settings::Default);
SetScale(Settings::Delta);
}
template<typename T>
T GetValue() const
{
FASSERT(m_ctrl != nullptr);
return static_cast<T>(GetValueHelper<T>::GetValue(m_ctrl));
}
private:
template<typename T, typename Enable = void>
struct GetValueHelper;
// Specialization for integral types
template<typename T>
struct GetValueHelper<T, std::enable_if_t<std::is_integral<T>::value>>
{
static int GetValue(Traits::TControl* pControl)
{
return pControl->GetIVal();
}
};
// Specialization for floating-point types
template<typename T>
struct GetValueHelper<T, std::enable_if_t<std::is_floating_point<T>::value>>
{
static float GetValue(Traits::TControl* pControl)
{
return pControl->GetFVal();
}
};
};
/* This class wraps 3dsMax ICustEdit control */
class MaxEdit :
public MaxControl<MaxEditTraits>
{
using ParentClass = MaxControl<MaxEditTraits>;
public:
using ParentClass::ParentClass;
using ParentClass::operator=;
template<typename T>
T GetValue() const
{
FASSERT(m_ctrl != nullptr);
return static_cast<T>(GetValueHelper<T>::GetValue(m_ctrl));
}
private:
template<typename T, typename Enable = void>
struct GetValueHelper;
// Specialization for integral types
template<typename T>
struct GetValueHelper<T, std::enable_if_t<std::is_integral<T>::value>>
{
static int GetValue(Traits::TControl* pControl)
{
return pControl->GetInt();
}
};
// Specialization for floating-point types
template<typename T>
struct GetValueHelper<T, std::enable_if_t<std::is_floating_point<T>::value>>
{
static float GetValue(Traits::TControl* pControl)
{
return pControl->GetFloat();
}
};
};
/* This class wraps 3dsMax ICustButton control */
class MaxButton :
public MaxControl<MaxButtonTraits>
{
using ParentClass = MaxControl<MaxButtonTraits>;
public:
using ParentClass::ParentClass;
using ParentClass::operator=;
void SetType(CustButType type)
{
FASSERT(m_ctrl != nullptr);
m_ctrl->SetType(type);
}
void SetButtonDownNotify(bool notify)
{
FASSERT(m_ctrl != nullptr);
m_ctrl->SetButtonDownNotify(notify);
}
RECT GetRect() const
{
FASSERT(m_ctrl != nullptr);
RECT rect;
BOOL ret = GetWindowRect(m_ctrl->GetHwnd(), &rect);
FASSERT(ret);
return rect;
}
bool PointIsOver(POINT pt) const
{
RECT rect = GetRect();
return bool_cast(PtInRect(&rect, pt));
}
bool CursorIsOver() const
{
POINT cursorPos;
BOOL ret = GetCursorPos(&cursorPos);
FASSERT(ret);
return PointIsOver(cursorPos);
}
};
class MaxColorSwatch :
public MaxControl<MaxColorSwatchTraits>
{
using ParentClass = MaxControl<MaxColorSwatchTraits>;
public:
using ParentClass::ParentClass;
using ParentClass::operator=;
Color GetColor() const
{
FASSERT(m_ctrl != nullptr);
COLORREF c = m_ctrl->GetColor();
Color result;
result.r = GetRValue(c) / 255.f;
result.g = GetGValue(c) / 255.f;
result.b = GetBValue(c) / 255.f;
return result;
}
void SetColor(Color c)
{
FASSERT(m_ctrl != nullptr);
m_ctrl->SetColor(c);
}
};
/* This class contains common code for Windows controls */
class WinControl
{
public:
WinControl() :
m_hWnd(nullptr)
{}
void Capture(HWND parentWindow, int controlId)
{
m_hWnd = GetDlgItem(parentWindow, controlId);
CheckControl();
}
void Release()
{
m_hWnd = nullptr;
}
protected:
void CheckControl() const
{
FASSERT(m_hWnd != nullptr);
}
HWND m_hWnd;
};
// Combines 3dsMax edit and spinner controls in one object
class MaxEditAndSpinner
{
public:
MaxEditAndSpinner() = default;
MaxEditAndSpinner(MaxEditAndSpinner&&) = default;
MaxEditAndSpinner(const MaxEditAndSpinner&) = delete;
void Capture(HWND hWnd, int editId, int spinnerId)
{
m_edit.Capture(hWnd, editId);
m_spinner.Capture(hWnd, spinnerId);
}
void Bind(EditSpinnerType editType)
{
ICustEdit* pEdit = m_edit.GetControl();
ISpinnerControl* pSpinner = m_spinner.GetControl();
pSpinner->LinkToEdit(pEdit->GetHwnd(), editType);
}
void Release()
{
m_edit.Release();
m_spinner.Release();
}
void Enable()
{
m_edit.Enable();
m_spinner.Enable();
}
void Disable()
{
m_edit.Disable();
m_spinner.Disable();
}
template<typename T>
T GetValue() const
{
return m_spinner.GetValue<T>();
}
MaxEdit& GetEdit() { return m_edit; }
MaxSpinner& GetSpinner() { return m_spinner; }
const MaxEdit& GetEdit() const { return m_edit; }
const MaxSpinner& GetSpinner() const { return m_spinner; }
MaxEditAndSpinner& operator=(MaxEditAndSpinner&&) = default;
MaxEditAndSpinner& operator=(const MaxEditAndSpinner&) = delete;
private:
MaxEdit m_edit;
MaxSpinner m_spinner;
};
// Combines 3dsMax colors watch, edit and spinner controls in one object
class MaxKelvinColor
{
public:
MaxKelvinColor() = default;
MaxKelvinColor(MaxKelvinColor&&) = default;
MaxKelvinColor(const MaxKelvinColor&) = delete;
void Capture(HWND window, int colorsWatch, int edit, int spinnerId)
{
m_color.Capture(window, colorsWatch);
m_kelvin.Capture(window, edit, spinnerId);
m_kelvin.Bind(EditSpinnerType::EDITTYPE_FLOAT);
MaxSpinner& spinner = m_kelvin.GetSpinner();
spinner.SetLimits(MinKelvin, MaxKelvin);
spinner.SetResetValue(DefaultKelvin);
spinner.SetScale(10.f);
}
float GetTemperature() const
{
return m_kelvin.GetValue<float>();
}
Color GetColor() const
{
return m_color.GetColor();
}
void SetTemperature(float value)
{
m_kelvin.GetSpinner().SetValue(value);
UpdateColor();
}
void UpdateColor()
{
m_color.SetColor(KelvinToColor(GetTemperature()));
}
void Release()
{
m_color.Release();
m_kelvin.Release();
}
void Enable()
{
m_color.Enable();
m_kelvin.Enable();
}
void Disable()
{
m_color.Disable();
m_kelvin.Disable();
}
MaxKelvinColor& operator=(MaxKelvinColor&&) = default;
MaxKelvinColor& operator=(const MaxKelvinColor&) = delete;
private:
MaxColorSwatch m_color;
MaxEditAndSpinner m_kelvin;
};
/* Wraps Windows button control */
class WinButton :
public WinControl
{
public:
bool IsChecked() const
{
CheckControl();
int result = Button_GetCheck(m_hWnd);
FASSERT(result != BST_INDETERMINATE);
return result == BST_CHECKED;
}
void SetCheck(bool checked)
{
CheckControl();
Button_SetCheck(m_hWnd, checked ? BST_CHECKED : BST_UNCHECKED);
}
void Enable()
{
CheckControl();
Button_Enable(m_hWnd, TRUE);
}
void Disable()
{
CheckControl();
Button_Enable(m_hWnd, FALSE);
}
};
/* Wraps Windows combo box control */
class WinCombobox :
public WinControl
{
using TString = std::basic_string<TCHAR>;
public:
enum class Style
{
Dropdown,
DropdownList
};
// Returns the index of selected item.
// Returns -1 if nothing is selected
int GetSelectedIndex() const
{
CheckControl();
return ComboBox_GetCurSel(m_hWnd);
}
TString GetItemText(int index) const
{
TString result;
GetItemText(index, result);
return result;
}
void GetItemText(int index, TString& outText) const
{
CheckControl();
int chars = ComboBox_GetLBTextLen(m_hWnd, index);
FASSERT(chars != CB_ERR && "Index out of range");
int len = chars + 1;
outText.resize(len);
int getLBText_result = ComboBox_GetLBText(m_hWnd, index, &outText[0]);
FASSERT(getLBText_result != CB_ERR && getLBText_result == chars);
}
int AddItem(const TCHAR* name)
{
CheckControl();
int index = ComboBox_AddString(m_hWnd, name);
FASSERT(index != CB_ERR);
FASSERT(index != CB_ERRSPACE);
return index;
}
void DeleteItem(int index)
{
CheckControl();
int res = ComboBox_DeleteString(m_hWnd, index);
FASSERT(res != CB_ERR);
}
void SetItemData(int index, size_t data)
{
CheckControl();
int ret = ComboBox_SetItemData(m_hWnd, index, data);
FASSERT(ret != CB_ERR);
}
bool SetSelected(const TCHAR* text)
{
FASSERT(text != nullptr);
return ForEachItem([&](int index, const TString& str)
{
if (_tcscmp(text, str.c_str()) == 0)
{
SetSelected(index);
return true;
}
return false;
});
}
// -1 to clear selection
void SetSelected(int index)
{
CheckControl();
int ret = ComboBox_SetCurSel(m_hWnd, index);
// -1 is valid input but ComboBox_SetCurSel returns CB_ERR in this case
FASSERT(ret == -1 || ret != CB_ERR);
}
int GetItemsCount() const
{
CheckControl();
int result = ComboBox_GetCount(m_hWnd);
FASSERT(result != CB_ERR);
return result;
}
void Enable()
{
CheckControl();
ComboBox_Enable(m_hWnd, TRUE);
}
void Disable()
{
CheckControl();
ComboBox_Enable(m_hWnd, FALSE);
}
bool ForEachItem(std::function<bool(int index, const TString& str)> f)
{
int cnt = GetItemsCount();
TString cache;
for (int i = 0; i < cnt; ++i)
{
GetItemText(i, cache);
if (f(i, cache))
{
return true;
}
}
return false;
}
};
/* This class contains common code to manage 3dsMax rollup pages.
* Derived class must define:
* static DialogId variable;
* static PanelName variable.
*/
template<typename Derived>
class IES_Panel
{
public:
using BasePanel = IES_Panel;
IES_Panel(FireRenderIESLight* parent) :
m_panel(nullptr),
m_parent(parent)
{}
bool IsInitialized() const
{
return m_panel != nullptr;
}
void BeginEdit(IObjParam* objParam, ULONG flags, Animatable* prev)
{
FASSERT(m_panel == nullptr);
Derived* _this = static_cast<Derived*>(this);
m_panel = objParam->AddRollupPage(
fireRenderHInstance,
MAKEINTRESOURCE(Derived::DialogId),
Derived::DlgProc,
Derived::PanelName,
(LPARAM)_this);
LONG_PTR wndContext = reinterpret_cast<LONG_PTR>(_this);
LONG_PTR prevLong = SetWindowLongPtr(m_panel, GWLP_USERDATA, wndContext);
_this->InitializePage(objParam->GetTime());
objParam->RegisterDlgWnd(m_panel);
FASSERT(prevLong == 0);
}
void EndEdit(IObjParam* objParam, ULONG flags, Animatable* next)
{
FASSERT(IsInitialized());
Derived* _this = static_cast<Derived*>(this);
_this->UninitializePage();
objParam->DeleteRollupPage(m_panel);
m_panel = nullptr;
}
// These methods are optional to override in the derived class
// Capture and initialize page controls
bool InitializePage(TimeValue time) { return true; }
// Release page controls
void UninitializePage() {}
// WM_COMMAND simplified event
bool HandleControlCommand(TimeValue t, WORD code, WORD controlId) { return false; }
// 3ds Max custom edit change event
bool OnEditChange(TimeValue t, int editId, HWND editHWND) { return false; }
// Spinner change event
bool OnSpinnerChange(TimeValue t, ISpinnerControl* spinner, WORD controlId, bool isDragging) { return false; }
// Color shatch change event
bool OnColorSwatchChange(TimeValue t, IColorSwatch* colorSwatch, WORD controlId, bool final) { return false; }
// Returns message for undo / redo stack
const TCHAR* GetAcceptMessage(WORD controlId) const { return _T("IES light: change parameter"); }
// Update controls state from param block
void UpdateUI(TimeValue t) {}
// Enable controls on the panel
void Enable() {}
// Disable controls on the panel
void Disable() {}
protected:
HWND m_panel;
FireRenderIESLight* m_parent;
private:
static void BeginUndoDelta()
{
theHold.Begin();
}
static void EndUndoDelta(bool accept, Derived* _this, int control)
{
if (accept)
{
theHold.Accept(_this->GetAcceptMessage(control));
}
else
{
theHold.Cancel();
}
}
static INT_PTR CALLBACK DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_INITDIALOG:
return TRUE;
break;
case BM_CLICK:
FASSERT(false);
break;
case WM_COMMAND:
{
if (lParam != 0)
{
TimeValue time = GetCOREInterface()->GetTime();
WORD code = HIWORD(wParam);
WORD controlId = LOWORD(wParam);
Derived* _this = GetAttachedThis(hWnd);
BeginUndoDelta();
bool accept = _this->HandleControlCommand(time, code, controlId);
EndUndoDelta(accept, _this, controlId);
}
}
break;
case WM_CUSTEDIT_ENTER:
{
WPARAM customEditId = wParam;
HWND customEditHWND = reinterpret_cast<HWND>(lParam);
Derived* _this = GetAttachedThis(hWnd);
TimeValue time = GetCOREInterface()->GetTime();
BeginUndoDelta();
bool accept = _this->OnEditChange(time, customEditId, customEditHWND);
EndUndoDelta(accept, _this, customEditId);
return TRUE;
}
break;
// start dragging the spinner
case CC_SPINNER_BUTTONDOWN:
BeginUndoDelta();
break;
// on change value in the spinner
case CC_SPINNER_CHANGE:
{
ISpinnerControl* spinner = reinterpret_cast<ISpinnerControl*>(lParam);
WORD spinnerId = LOWORD(wParam);
WORD isDragging = HIWORD(wParam);
Derived* _this = GetAttachedThis(hWnd);
TimeValue time = GetCOREInterface()->GetTime();
if (!isDragging)
{
BeginUndoDelta();
}
bool accept = _this->OnSpinnerChange(time, spinner, spinnerId, bool_cast(isDragging));
if (!isDragging)
{
EndUndoDelta(accept, _this, spinnerId);
}
return TRUE;
}
break;
// finish spinner editing
case CC_SPINNER_BUTTONUP:
{
Derived* _this = GetAttachedThis(hWnd);
ISpinnerControl* spinner = reinterpret_cast<ISpinnerControl*>(lParam);
WORD spinnerId = LOWORD(wParam);
WORD accept = HIWORD(wParam);
TimeValue time = GetCOREInterface()->GetTime();
bool retVal = _this->OnSpinnerChange(time, spinner, spinnerId, false);
EndUndoDelta( bool_cast(accept), _this, spinnerId);
}
break;
case CC_COLOR_CHANGE:
case CC_COLOR_CLOSE:
{
IColorSwatch* controlPtr = reinterpret_cast<IColorSwatch*>(lParam);
WORD controlId = LOWORD(wParam);
Derived* _this = GetAttachedThis(hWnd);
TimeValue time = GetCOREInterface()->GetTime();
BeginUndoDelta();
bool accept = _this->OnColorSwatchChange(time, controlPtr, controlId, msg == CC_COLOR_CLOSE);
EndUndoDelta(accept, _this, controlId);
}
break;
}
return FALSE;
}
static Derived* GetAttachedThis(HWND hWnd)
{
LONG_PTR wndUserData = GetWindowLongPtr(hWnd, GWLP_USERDATA);
Derived* _this = reinterpret_cast<Derived*>(wndUserData);
FASSERT(_this != nullptr);
return _this;
}
};
namespace ies_panel_utils
{
// Need this helper to use partial specialization
template<typename Control, bool enable>
struct EnableControlHelper
{
static void EnablePanel(Control& control)
{
control.Enable();
}
};
// Disable case specialization
template<typename Control>
struct EnableControlHelper<Control, false>
{
static void EnablePanel(Control& control)
{
control.Disable();
}
};
template<bool enable, typename Control>
void EnableControl(Control& control)
{
EnableControlHelper<Control, enable>::EnablePanel(control);
}
template<bool enable, typename... Control>
void EnableControls(Control&... controls)
{
// Call EnableControl for each control
(void)std::initializer_list<int>
{
(EnableControl<enable>(controls), 0)...
};
}
}
FIRERENDER_NAMESPACE_END
| 20.465389 | 111 | 0.702867 |
0d21264f115c633c4c269613c81960995292b525 | 24,968 | h | C | kernel/drivers/mmc/host/dw_mmc_hi3xxx.h | wonderful666/marx-10.1.0 | a8be8880fe31bff4f94d6e3fad17c455666ff60f | [
"MIT"
] | null | null | null | kernel/drivers/mmc/host/dw_mmc_hi3xxx.h | wonderful666/marx-10.1.0 | a8be8880fe31bff4f94d6e3fad17c455666ff60f | [
"MIT"
] | null | null | null | kernel/drivers/mmc/host/dw_mmc_hi3xxx.h | wonderful666/marx-10.1.0 | a8be8880fe31bff4f94d6e3fad17c455666ff60f | [
"MIT"
] | null | null | null | /*
* support definition interface for dw_mmc_hi3xxx
* Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved.
*
* 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.
*
* This program 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 General Public License for more details.
*/
#ifndef _DW_MMC_HI3XXX_
#define _DW_MMC_HI3XXX_
#include <linux/mmc/host.h>
#include <linux/mmc/dw_mmc.h>
#define EMMC_TYPE 0
#define SD_TYPE 1
#define SDIO_TYPE 2
#define LEGACY_400K 0
#define MMC_HS 1
#define SD_HS 2
#define SDR12 3
#define SDR25 4
#define SDR50 5
#define SDR104 6
#define DDR50 7
#define DDR52 8
#define HS200 9
#define VOL_SWITCH_LOOP_MAX 0x100000
#define ENABLE_CLK 0x10000
#define SD_HWLOCK_ID 11
#define SD_LOCK_TIMEOUT 1000
#define MMC_CLOCK_FREQUENCY_137 137
#define MMC_CLOCK_FREQUENCY_192 192
static void __iomem *hsdt_crg_base;
static void __iomem *hsdt1_crg_base;
static void __iomem *mmc0_crg_base;
struct dw_mci *sdio_host;
/* Common capabilities of hisilicon SoC */
static unsigned long g_hs_dwmmc_caps[3] = { /* for eMMC, sd, sdio */
#ifdef CONFIG_MMC_DW_EMMC_USED_AS_MODEM
/* sdio1 - via modem */
MMC_CAP_4_BIT_DATA | MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
#else
MMC_CAP_8_BIT_DATA | MMC_CAP_CMD23 | MMC_CAP_ERASE,
#endif
/* sd */
MMC_CAP_DRIVER_TYPE_A | MMC_CAP_4_BIT_DATA | MMC_CAP_SD_HIGHSPEED |
MMC_CAP_MMC_HIGHSPEED | MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 |
MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104,
/* sdio */
MMC_CAP_4_BIT_DATA | MMC_CAP_SD_HIGHSPEED | MMC_CAP_NONREMOVABLE,
};
int hs_timing_config[][TUNING_INIT_TIMING_MODE][TUNING_INIT_CONFIG_NUM] = {
/* bus_clk, div, drv_phase, sam_dly, sam_phase_max, sam_phase_min, input_clk */
{
/* MMC */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{ 400000000, 7, 6, 0, 15, 15, 50000000 }, /* 1: MMC_HS */
{ 200000000, 7, 6, 0, 15, 15, 25000000 }, /* 2: SD_HS */
{ 200000000, 7, 6, 0, 15, 15, 25000000 }, /* 3: SDR12 */
{ 400000000, 7, 6, 0, 15, 15, 50000000 }, /* 4: SDR25 */
{ 800000000, 7, 4, 0, 12, 0, 100000000 }, /* 5: SDR50 */
{ 1600000000, 7, 5, 4, 15, 0, 200000000 }, /* 6: SDR104 */
{ 800000000, 7, 6, 0, 7, 0, 100000000 }, /* 7: DDR50 */
{ 800000000, 7, 6, 0, 7, 0, 100000000 }, /* 8: DDR52 */
{ 1600000000, 7, 5, 4, 15, 0, 200000000 }, /* 9: HS200 */
},
{
/* SD */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{0}, /* 1: MMC_HS */
{ 400000000, 7, 6, 0, 1, 1, 50000000 }, /* 2: SD_HS */
{ 200000000, 7, 6, 0, 15, 15, 25000000 }, /* 3: SDR12 */
{ 400000000, 7, 6, 0, 1, 1, 50000000 }, /* 4: SDR25 */
{ 800000000, 7, 3, 0, 12, 0, 100000000 }, /* 5: SDR50 */
{ 1600000000, 7, 5, 4, 15, 0, 200000000 }, /* 6: SDR104 */
{0}, /* 7: DDR50 */
{0}, /* 8: DDR52 */
{0}, /* 9: HS200 */
},
{
/* SDIO */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{0}, /* 1: MMC_HS */
{ 400000000, 7, 6, 0, 15, 15, 50000000 }, /* 2: SD_HS */
{ 200000000, 7, 6, 0, 15, 15, 25000000 }, /* 3: SDR12 */
{ 400000000, 7, 6, 0, 15, 15, 50000000 }, /* 4: SDR25 */
{ 800000000, 7, 5, 0, 12, 0, 100000000 }, /* 5: SDR50 */
{ 1600000000, 7, 5, 4, 15, 0, 200000000 }, /* 6: SDR104 */
{0}, /* 7: DDR50 */
{0}, /* 8: DDR52 */
{0}, /* 9: HS200 */
}
};
static int hs_timing_config_aries_cs
[][TUNING_INIT_TIMING_MODE][TUNING_INIT_CONFIG_NUM] = {
/* bus_clk, div, drv_phase, sam_dly, sam_phase_max, sam_phase_min, input_clk */
{
/* MMC */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{ 480000000, 9, 6, 0, 1, 1, 48000000 }, /* 1: MMC_HS */
{ 200000000, 7, 6, 0, 15, 15, 25000000 }, /* 2: SD_HS */
{ 200000000, 7, 6, 0, 15, 15, 25000000 }, /* 3: SDR12 */
{ 400000000, 7, 6, 0, 15, 15, 50000000 }, /* 4: SDR25 */
{ 800000000, 7, 4, 0, 12, 0, 100000000 }, /* 5: SDR50 */
{ 1600000000, 7, 5, 4, 15, 0, 200000000 }, /* 6: SDR104 */
{ 800000000, 7, 6, 0, 7, 0, 100000000 }, /* 7: DDR50 */
{ 800000000, 7, 6, 0, 7, 0, 100000000 }, /* 8: DDR52 */
{ 1920000000, 9, 5, 4, 15, 0, 192000000 }, /* 9: HS200 */
},
{
/* SD */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{ 240000000, 9, 8, 0, 3, 3, 24000000 }, /* 1: MMC_HS */
{ 480000000, 9, 7, 0, 4, 4, 48000000 }, /* 2: SD_HS */
{ 240000000, 9, 8, 0, 19, 19, 24000000 }, /* 3: SDR12 */
{ 480000000, 9, 7, 0, 3, 3, 48000000 }, /* 4: SDR25 */
{ 960000000, 9, 4, 0, 16, 0, 96000000 }, /* 5: SDR50 */
{ 960000000, 4, 2, 1, 9, 0, 192000000 }, /* 6: SDR104 */
{0}, /* 7: DDR50 */
{0}, /* 8: DDR52 */
{0}, /* 9: HS200 */
},
{
/* SDIO */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{0}, /* 1: MMC_HS */
{ 480000000, 9, 7, 0, 19, 19, 48000000 }, /* 2: SD_HS */
{ 240000000, 9, 8, 0, 19, 19, 24000000 }, /* 3: SDR12 */
{ 480000000, 9, 7, 0, 19, 19, 48000000 }, /* 4: SDR25 */
{ 960000000, 9, 4, 0, 16, 0, 96000000 }, /* 5: SDR50 */
{ 1200000000, 6, 4, 0, 13, 0, 171000000 }, /* 6: SDR104 */
{0}, /* 7: DDR50 */
{0}, /* 8: DDR52 */
{0}, /* 9: HS200 */
}
};
static int hs_timing_config_libra
[][TUNING_INIT_TIMING_MODE][TUNING_INIT_CONFIG_NUM] = {
/* bus_clk, div, drv_phase, sam_dly, sam_phase_max, sam_phase_min, input_clk */
{
/* MMC */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{ 480000000, 9, 6, 0, 1, 1, 48000000 }, /* 1: MMC_HS */
{ 200000000, 7, 6, 0, 15, 15, 25000000 }, /* 2: SD_HS */
{ 200000000, 7, 6, 0, 15, 15, 25000000 }, /* 3: SDR12 */
{ 400000000, 7, 6, 0, 15, 15, 50000000 }, /* 4: SDR25 */
{ 800000000, 7, 4, 0, 12, 0, 100000000 }, /* 5: SDR50 */
{ 1600000000, 7, 5, 4, 15, 0, 200000000 }, /* 6: SDR104 */
{ 800000000, 7, 6, 0, 7, 0, 100000000 }, /* 7: DDR50 */
{ 800000000, 7, 6, 0, 7, 0, 100000000 }, /* 8: DDR52 */
{ 1920000000, 9, 5, 4, 15, 0, 192000000 }, /* 9: HS200 */
},
{
/* SD */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{ 203000000, 8, 6, 0, 0, 0, 22500000 }, /* 1: MMC_HS */
{ 406000000, 8, 6, 0, 1, 1, 45000000 }, /* 2: SD_HS */
{ 203000000, 8, 6, 0, 0, 0, 22500000 }, /* 3: SDR12 */
{ 406000000, 8, 6, 0, 1, 1, 45000000 }, /* 4: SDR25 */
{ 812000000, 8, 4, 0, 13, 0, 90000000 }, /* 5: SDR50 */
{ 1623000000, 8, 6, 4, 17, 0, 180000000 }, /* 6: SDR104 */
{0}, /* 7: DDR50 */
{0}, /* 8: DDR52 */
#ifdef CONFIG_MMC_DW_MUX_SDSIM_LIBRA
{ 1623000000, 8, 6, 4, 17, 0, 180000000 }, /* 9: HS200 */
#else
{0}, /* 9: HS200 */
#endif
},
{
/* SDIO */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{0}, /* 1: MMC_HS */
{ 406000000, 8, 6, 0, 17, 17, 45000000 }, /* 2: SD_HS */
{ 203000000, 8, 6, 0, 17, 17, 22500000 }, /* 3: SDR12 */
{ 406000000, 8, 6, 0, 17, 17, 45000000 }, /* 4: SDR25 */
{ 812000000, 8, 4, 0, 13, 0, 90000000 }, /* 5: SDR50 */
{ 1623000000, 8, 5, 4, 17, 0, 180000000 }, /* 6: SDR104 */
{0}, /* 7: DDR50 */
{0}, /* 8: DDR52 */
{0}, /* 9: HS200 */
}
};
static int hs_timing_config_libra_c50
[][TUNING_INIT_TIMING_MODE][TUNING_INIT_CONFIG_NUM] = {
/* bus_clk, div, drv_phase, sam_dly, sam_phase_max, sam_phase_min, input_clk */
{
/* MMC */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{ 480000000, 9, 6, 0, 1, 1, 48000000 }, /* 1: MMC_HS */
{ 200000000, 7, 6, 0, 15, 15, 25000000 }, /* 2: SD_HS */
{ 200000000, 7, 6, 0, 15, 15, 25000000 }, /* 3: SDR12 */
{ 400000000, 7, 6, 0, 15, 15, 50000000 }, /* 4: SDR25 */
{ 800000000, 7, 4, 0, 12, 0, 100000000 }, /* 5: SDR50 */
{ 1600000000, 7, 5, 4, 15, 0, 200000000 }, /* 6: SDR104 */
{ 800000000, 7, 6, 0, 7, 0, 100000000 }, /* 7: DDR50 */
{ 800000000, 7, 6, 0, 7, 0, 100000000 }, /* 8: DDR52 */
{ 1920000000, 9, 5, 4, 15, 0, 192000000 }, /* 9: HS200 */
},
{
/* SD */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{ 203000000, 8, 6, 0, 0, 0, 22500000 }, /* 1: MMC_HS */
{ 406000000, 8, 6, 0, 1, 1, 45000000 }, /* 2: SD_HS */
{ 203000000, 8, 6, 0, 0, 0, 22500000 }, /* 3: SDR12 */
{ 406000000, 8, 6, 0, 1, 1, 45000000 }, /* 4: SDR25 */
{ 812000000, 8, 4, 0, 13, 0, 90000000 }, /* 5: SDR50 */
{ 1623000000, 8, 6, 2, 17, 0, 180000000 }, /* 6: SDR104 */
{0}, /* 7: DDR50 */
{0}, /* 8: DDR52 */
{ 1623000000, 8, 6, 2, 17, 0, 180000000 }, /* 9: HS200 */
},
{
/* SDIO */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{0}, /* 1: MMC_HS */
{ 406000000, 8, 6, 0, 17, 17, 45000000 }, /* 2: SD_HS */
{ 203000000, 8, 6, 0, 17, 17, 22500000 }, /* 3: SDR12 */
{ 406000000, 8, 6, 0, 17, 17, 45000000 }, /* 4: SDR25 */
{ 812000000, 8, 4, 0, 11, 0, 90000000 }, /* 5: SDR50 */
{ 1623000000, 8, 6, 2, 17, 0, 180000000 }, /* 6: SDR104 */
{0}, /* 7: DDR50 */
{0}, /* 8: DDR52 */
{0}, /* 9: HS200 */
}
};
static int hs_timing_config_libra_c60
[][TUNING_INIT_TIMING_MODE][TUNING_INIT_CONFIG_NUM] = {
/* bus_clk, div, drv_phase, sam_dly, sam_phase_max, sam_phase_min, input_clk */
{
/* MMC */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{ 480000000, 9, 6, 0, 1, 1, 48000000 }, /* 1: MMC_HS */
{ 200000000, 7, 6, 0, 15, 15, 25000000 }, /* 2: SD_HS */
{ 200000000, 7, 6, 0, 15, 15, 25000000 }, /* 3: SDR12 */
{ 400000000, 7, 6, 0, 15, 15, 50000000 }, /* 4: SDR25 */
{ 800000000, 7, 4, 0, 12, 0, 100000000 }, /* 5: SDR50 */
{ 1600000000, 7, 5, 4, 15, 0, 200000000 }, /* 6: SDR104 */
{ 800000000, 7, 6, 0, 7, 0, 100000000 }, /* 7: DDR50 */
{ 800000000, 7, 6, 0, 7, 0, 100000000 }, /* 8: DDR52 */
{ 1920000000, 9, 5, 4, 15, 0, 192000000 }, /* 9: HS200 */
},
{
/* SD */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{ 203000000, 8, 6, 0, 0, 0, 22500000 }, /* 1: MMC_HS */
{ 406000000, 8, 6, 0, 1, 1, 45000000 }, /* 2: SD_HS */
{ 203000000, 8, 6, 0, 0, 0, 22500000 }, /* 3: SDR12 */
{ 406000000, 8, 6, 0, 1, 1, 45000000 }, /* 4: SDR25 */
{ 812000000, 8, 4, 0, 13, 0, 90000000 }, /* 5: SDR50 */
{ 1623000000, 8, 6, 2, 17, 0, 180000000 }, /* 6: SDR104 */
{0}, /* 7: DDR50 */
{0}, /* 8: DDR52 */
{ 1623000000, 8, 6, 2, 17, 0, 180000000 }, /* 9: HS200 */
},
{
/* SDIO */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{0}, /* 1: MMC_HS */
{ 406000000, 8, 6, 0, 17, 17, 45000000 }, /* 2: SD_HS */
{ 203000000, 8, 6, 0, 17, 17, 22500000 }, /* 3: SDR12 */
{ 406000000, 8, 6, 0, 17, 17, 45000000 }, /* 4: SDR25 */
{ 812000000, 8, 4, 0, 11, 0, 90000000 }, /* 5: SDR50 */
{ 1623000000, 7, 5, 2, 15, 0, 203000000 }, /* 6: SDR104 */
{0}, /* 7: DDR50 */
{0}, /* 8: DDR52 */
{0}, /* 9: HS200 */
}
};
static int hs_timing_config_cancer_cs
[][TUNING_INIT_TIMING_MODE][TUNING_INIT_CONFIG_NUM] = {
/* bus_clk, div, drv_phase, sam_dly, sam_phase_max, sam_phase_min, input_clk */
{
/* MMC */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{ 240000000, 4, 3, 0, 0, 0, 48000000 }, /* 1: MMC_HS */
{ 120000000, 4, 3, 0, 9, 9, 24000000 }, /* 2: SD_DS */
{ 120000000, 4, 3, 0, 9, 9, 24000000 }, /* 3: SDR12 */
{ 240000000, 4, 3, 0, 0, 0, 48000000 }, /* 4: SDR25 */
{ 480000000, 4, 2, 0, 5, 0, 96000000 }, /* 5: SDR50 */
{ 960000000, 4, 4, 2, 9, 0, 192000000 }, /* 6: SDR104 */
{0}, /* 7: DDR50 */
{0}, /* 8: DDR52 */
{ 960000000, 4, 4, 2, 9, 0, 192000000 }, /* 9: HS200 */
},
{
/* SD */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{ 120000000, 4, 3, 0, 3, 3, 24000000 }, /* 1: SD_DS */
{ 240000000, 4, 3, 0, 9, 9, 48000000 }, /* 2: SD_HS */
{ 120000000, 4, 3, 0, 9, 9, 24000000 }, /* 3: SDR12 */
{ 240000000, 4, 3, 0, 0, 0, 48000000 }, /* 4: SDR25 */
{ 480000000, 4, 2, 0, 5, 0, 96000000 }, /* 5: SDR50 */
{ 960000000, 4, 4, 2, 9, 0, 192000000 }, /* 6: SDR104 */
{0}, /* 7: DDR50 */
{0}, /* 8: DDR52 */
{ 960000000, 4, 4, 2, 9, 0, 192000000 }, /* 9: HS200 */
},
{
/* SDIO */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{0}, /* 1: MMC_HS */
{0}, /* 2: SD_HS */
{ 120000000, 4, 3, 0, 9, 9, 24000000 }, /* 3: SDR12 */
{ 240000000, 4, 3, 0, 0, 0, 48000000 }, /* 4: SDR25 */
{ 480000000, 4, 2, 0, 5, 0, 96000000 }, /* 5: SDR50 */
{ 960000000, 4, 4, 2, 9, 0, 192000000 }, /* 6: SDR104 */
{0}, /* 7: DDR50 */
{0}, /* 8: DDR52 */
{0}, /* 9: HS200 */
}
};
static int hs_timing_config_capricorn
[][TUNING_INIT_TIMING_MODE][TUNING_INIT_CONFIG_NUM] = {
/* bus_clk, div, drv_phase, sam_dly, sam_phase_max, sam_phase_min, input_clk */
{
/* MMC */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{ 240000000, 4, 3, 0, 0, 0, 48000000 }, /* 1: MMC_HS */
{ 120000000, 4, 3, 0, 9, 9, 24000000 }, /* 2: SD_DS */
{ 120000000, 4, 3, 0, 9, 9, 24000000 }, /* 3: SDR12 */
{ 240000000, 4, 3, 0, 0, 0, 48000000 }, /* 4: SDR25 */
{ 480000000, 4, 2, 0, 5, 0, 96000000 }, /* 5: SDR50 */
{ 960000000, 4, 3, 2, 9, 0, 192000000 }, /* 6: SDR104 */
{0}, /* 7: DDR50 */
{0}, /* 8: DDR52 */
{ 960000000, 4, 3, 2, 9, 0, 192000000 }, /* 9: HS200 */
},
{
/* SD */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{ 120000000, 4, 3, 0, 3, 3, 24000000 }, /* 1: SD_DS */
{ 240000000, 4, 3, 0, 2, 2, 48000000 }, /* 2: SD_HS */
{ 120000000, 4, 3, 0, 9, 9, 24000000 }, /* 3: SDR12 */
{ 240000000, 4, 3, 0, 0, 0, 48000000 }, /* 4: SDR25 */
{ 480000000, 4, 2, 0, 5, 0, 96000000 }, /* 5: SDR50 */
{ 960000000, 4, 3, 2, 9, 0, 192000000 }, /* 6: SDR104 */
{0}, /* 7: DDR50 */
{0}, /* 8: DDR52 */
{ 960000000, 4, 3, 2, 9, 0, 192000000 }, /* 9: HS200 */
},
{
/* SDIO */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{0}, /* 1: MMC_HS */
{0}, /* 2: SD_HS */
{ 120000000, 4, 3, 0, 9, 9, 24000000 }, /* 3: SDR12 */
{ 240000000, 4, 3, 0, 0, 0, 48000000 }, /* 4: SDR25 */
{ 480000000, 4, 2, 0, 5, 0, 96000000 }, /* 5: SDR50 */
{ 960000000, 4, 3, 2, 9, 0, 192000000 }, /* 6: SDR104 */
{0}, /* 7: DDR50 */
{0}, /* 8: DDR52 */
{0}, /* 9: HS200 */
}
};
static int hs_timing_config_taurus_cs
[][TUNING_INIT_TIMING_MODE][TUNING_INIT_CONFIG_NUM] = {
/* bus_clk, div, drv_phase, sam_dly, sam_phase_max, sam_phase_min, input_clk */
{
/* MMC */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{ 480000000, 9, 7, 0, 19, 19, 48000000 }, /* 1: MMC_HS */
{ 200000000, 7, 6, 0, 15, 15, 25000000 }, /* 2: SD_HS */
{ 200000000, 7, 6, 0, 15, 15, 25000000 }, /* 3: SDR12 */
{ 400000000, 7, 6, 0, 15, 15, 50000000 }, /* 4: SDR25 */
{ 800000000, 7, 4, 0, 12, 0, 100000000 }, /* 5: SDR50 */
{ 1600000000, 7, 5, 4, 15, 0, 200000000 }, /* 6: SDR104 */
{ 800000000, 7, 6, 0, 7, 0, 100000000 }, /* 7: DDR50 */
{ 800000000, 7, 6, 0, 7, 0, 100000000 }, /* 8: DDR52 */
{ 1920000000, 9, 7, 4, 19, 0, 192000000 }, /* 9: HS200 */
},
{
/* SD */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{ 120000000, 4, 3, 0, 9, 9, 24000000 }, /* 1: MMC_HS */
{ 240000000, 4, 2, 0, 0, 0, 48000000 }, /* 2: SD_HS */
{ 120000000, 4, 3, 0, 4, 4, 24000000 }, /* 3: SDR12 */
{ 240000000, 4, 2, 0, 0, 0, 48000000 }, /* 4: SDR25 */
{ 480000000, 4, 2, 0, 5, 0, 96000000 }, /* 5: SDR50 */
{ 960000000, 4, 3, 3, 9, 0, 192000000 }, /* 6: SDR104 */
{0}, /* 7: DDR50 */
{0}, /* 8: DDR52 */
{ 960000000, 4, 3, 3, 9, 0, 192000000 }, /* 9: HS200 */
},
{
/* SDIO */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{0}, /* 1: MMC_HS */
{0}, /* 2: SD_HS */
{ 197000000, 7, 8, 0, 15, 15, 25000000 }, /* 3: SDR12 */
{ 394000000, 7, 7, 0, 1, 1, 49000000 }, /* 4: SDR25 */
{ 787000000, 7, 5, 0, 8, 0, 98000000 }, /* 5: SDR50 */
{ 1573000000, 7, 5, 6, 15, 0, 197000000 }, /* 6: SDR104 */
{0}, /* 7: DDR50 */
{0}, /* 8: DDR52 */
{0}, /* 9: HS200 */
}
};
static int hs_timing_config_taurus_cs2
[][TUNING_INIT_TIMING_MODE][TUNING_INIT_CONFIG_NUM] = {
/* bus_clk, div, drv_phase, sam_dly, sam_phase_max, sam_phase_min, input_clk */
{
/* MMC */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{ 480000000, 9, 7, 0, 19, 19, 48000000 }, /* 1: MMC_HS */
{ 200000000, 7, 6, 0, 15, 15, 25000000 }, /* 2: SD_HS */
{ 200000000, 7, 6, 0, 15, 15, 25000000 }, /* 3: SDR12 */
{ 400000000, 7, 6, 0, 15, 15, 50000000 }, /* 4: SDR25 */
{ 800000000, 7, 4, 0, 12, 0, 100000000 }, /* 5: SDR50 */
{ 1600000000, 7, 5, 4, 15, 0, 200000000 }, /* 6: SDR104 */
{ 800000000, 7, 6, 0, 7, 0, 100000000 }, /* 7: DDR50 */
{ 800000000, 7, 6, 0, 7, 0, 100000000 }, /* 8: DDR52 */
{ 1920000000, 9, 7, 4, 19, 0, 192000000}, /* 9: HS200 */
},
{
/* SD */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{ 120000000, 4, 3, 0, 4, 4, 24000000 }, /* 1: MMC_HS */
{ 240000000, 4, 2, 0, 0, 0, 48000000 }, /* 2: SD_HS */
{ 120000000, 4, 3, 0, 9, 9, 24000000 }, /* 3: SDR12 */
{ 240000000, 4, 2, 0, 0, 0, 48000000 }, /* 4: SDR25 */
{ 480000000, 4, 2, 0, 5, 0, 96000000 }, /* 5: SDR50 */
{ 960000000, 4, 3, 3, 9, 0, 192000000 }, /* 6: SDR104 */
{0}, /* 7: DDR50 */
{0}, /* 8: DDR52 */
{ 960000000, 4, 3, 3, 9, 0, 192000000 }, /* 9: HS200 */
},
{
/* SDIO */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{0}, /* 1: MMC_HS */
{0}, /* 2: SD_HS */
{ 197000000, 7, 8, 0, 2, 2, 25000000 }, /* 3: SDR12 */
{ 394000000, 7, 7, 0, 1, 1, 49000000 }, /* 4: SDR25 */
{ 787000000, 7, 5, 0, 8, 0, 98000000 }, /* 5: SDR50 */
{ 1573000000, 7, 5, 6, 15, 0, 197000000 }, /* 6: SDR104 */
{0}, /* 7: DDR50 */
{0}, /* 8: DDR52 */
{0}, /* 9: HS200 */
}
};
static int hs_timing_config_pisces
[][TUNING_INIT_TIMING_MODE][TUNING_INIT_CONFIG_NUM] = {
/* bus_clk, div, drv_phase, sam_dly, sam_phase_max, sam_phase_min, input_clk */
{
/* MMC */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{ 480000000, 9, 7, 0, 19, 19, 48000000 }, /* 1: MMC_HS */
{ 200000000, 7, 6, 0, 15, 15, 25000000 }, /* 2: SD_HS */
{ 200000000, 7, 6, 0, 15, 15, 25000000 }, /* 3: SDR12 */
{ 400000000, 7, 6, 0, 15, 15, 50000000 }, /* 4: SDR25 */
{ 800000000, 7, 4, 0, 12, 0, 100000000 }, /* 5: SDR50 */
{ 1600000000, 7, 5, 4, 15, 0, 200000000}, /* 6: SDR104 */
{ 800000000, 7, 6, 0, 7, 0, 100000000 }, /* 7: DDR50 */
{ 800000000, 7, 6, 0, 7, 0, 100000000 }, /* 8: DDR52 */
{ 1920000000, 9, 7, 4, 19, 0, 192000000 }, /* 9: HS200 */
},
{
/* SD */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{ 120000000, 4, 3, 0, 9, 9, 24000000 }, /* 1: MMC_HS */
{ 240000000, 4, 2, 0, 5, 0, 48000000 }, /* 2: SD_HS */
{ 120000000, 4, 3, 0, 9, 9, 24000000 }, /* 3: SDR12 */
{ 240000000, 4, 2, 0, 5, 0, 48000000 }, /* 4: SDR25 */
{ 480000000, 4, 2, 0, 5, 0, 96000000 }, /* 5: SDR50 */
{ 960000000, 4, 3, 3, 9, 0, 192000000}, /* 6: SDR104 */
{0}, /* 7: DDR50 */
{0}, /* 8: DDR52 */
{ 960000000, 4, 3, 3, 9, 0, 192000000 }, /* 9: HS200 */
},
{
/* SDIO */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{0}, /* 1: MMC_HS */
{0}, /* 2: SD_HS */
{ 120000000, 4, 3, 0, 9, 9, 24000000 }, /* 3: SDR12 */
{ 240000000, 4, 2, 0, 5, 0, 48000000 }, /* 4: SDR25 */
{ 480000000, 4, 2, 0, 5, 0, 96000000 }, /* 5: SDR50 */
{ 960000000, 4, 3, 3, 9, 0, 192000000}, /* 6: SDR104 */
{0}, /* 7: DDR50 */
{0}, /* 8: DDR52 */
{0}, /* 9: HS200 */
}
};
static int hs_timing_config_leo
[][TUNING_INIT_TIMING_MODE][TUNING_INIT_CONFIG_NUM] = {
/* bus_clk, div, drv_phase, sam_dly, sam_phase_max, sam_phase_min, input_clk */
{
/* MMC */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{ 480000000, 9, 7, 0, 19, 19, 48000000 }, /* 1: MMC_HS */
{ 200000000, 7, 6, 0, 15, 15, 25000000 }, /* 2: SD_HS */
{ 200000000, 7, 6, 0, 15, 15, 25000000 }, /* 3: SDR12 */
{ 400000000, 7, 6, 0, 15, 15, 50000000 }, /* 4: SDR25 */
{ 800000000, 7, 4, 0, 12, 0, 100000000 }, /* 5: SDR50 */
{ 1600000000, 7, 5, 4, 15, 0, 200000000 }, /* 6: SDR104 */
{ 800000000, 7, 6, 0, 7, 0, 100000000 }, /* 7: DDR50 */
{ 800000000, 7, 6, 0, 7, 0, 100000000 }, /* 8: DDR52 */
{ 1920000000, 9, 7, 4, 19, 0, 192000000 }, /* 9: HS200 */
},
{
/* SD */
{ 3200000, 7, 7, 0, 15, 15, 400000 }, /* 0: LEGACY 400k */
{ 120000000, 4, 3, 0, 6, 6, 24000000 }, /* 1: MMC_HS */
{ 240000000, 4, 2, 0, 0, 0, 48000000 }, /* 2: SD_HS */
{ 120000000, 4, 3, 0, 7, 7, 24000000 }, /* 3: SDR12 */
{ 240000000, 4, 2, 0, 0, 0, 48000000 }, /* 4: SDR25 */
{ 480000000, 4, 3, 0, 5, 0, 96000000 }, /* 5: SDR50 */
{ 960000000, 4, 3, 3, 9, 0, 192000000 }, /* 6: SDR104 */
{0}, /* 7: DDR50 */
{0}, /* 8: DDR52 */
{ 960000000, 4, 3, 3, 9, 0, 192000000 }, /* 9: HS200 */
},
{
/* SDIO */
{ 3200000, 7, 7, 0, 15, 15, 400000}, /* 0: LEGACY 400k */
{0}, /* 1: MMC_HS */
{0}, /* 2: SD_HS */
{ 120000000, 4, 3, 0, 7, 7, 25000000 }, /* 3: SDR12 */
{ 240000000, 4, 3, 0, 0, 0, 48000000 }, /* 4: SDR25 */
{ 480000000, 4, 3, 0, 8, 0, 96000000 }, /* 5: SDR50 */
{ 1622016000, 7, 5, 6, 15, 0, 203000000 }, /* 6: SDR104 */
{0}, /* 7: DDR50 */
{0}, /* 8: DDR52 */
{0}, /* 9: HS200 */
}
};
void dw_mci_hi3xxx_work_fail_reset(struct dw_mci *host);
#endif /* DW_MMC_HI3XXX_ */
| 44.74552 | 81 | 0.449255 |
891ed4f4171595e83a541b64c19553e8a341cd6f | 730 | c | C | nitan/d/luoyang/road2.c | cantona/NT6 | 073f4d491b3cfe6bfbe02fbad12db8983c1b9201 | [
"MIT"
] | 1 | 2019-03-27T07:25:16.000Z | 2019-03-27T07:25:16.000Z | nitan/d/luoyang/road2.c | cantona/NT6 | 073f4d491b3cfe6bfbe02fbad12db8983c1b9201 | [
"MIT"
] | null | null | null | nitan/d/luoyang/road2.c | cantona/NT6 | 073f4d491b3cfe6bfbe02fbad12db8983c1b9201 | [
"MIT"
] | null | null | null | // Room: /d/luoyang/road2.c
inherit ROOM;
void create ()
{
set("short", "大官道");
set("long", @LONG
這是一條寬闊筆直的官道,足可容得下十馬並馳。路邊還開着些不
入流的牡丹花,一看就知道是洛陽城的轄地。東面就是通往揚州的大官
道,西面則是著名的洛陽城,而東北面則是著名的旅遊勝地:白馬寺。
寺廟進香的遊客很多,路邊草地已經給踩得相當平了。
LONG);
set("exits", ([ /* sizeof() == 2 */
"east" : __DIR__"hulaoguan",
"westup" : __DIR__"ebridge",
"south" : __DIR__"road7",
"northeast" : __DIR__"baimasi",
"southeast" : __DIR__"road0",
]));
set("outdoors", "luoyang");
set("no_clean_up", 0);
set("coor/x", -6910);
set("coor/y", 2150);
set("coor/z", -10);
setup();
replace_program(ROOM);
} | 26.071429 | 50 | 0.516438 |
89760784e376eeb172aa54fe3d490b85278dfcd0 | 12,168 | c | C | source/programs/Xserver/hw/xfree86/drivers/aspeed/ast_cursor.c | binaryblob01/zfree86 | e80ea992d87501b8e3e2d7c07a414591c2e11c70 | [
"Xnet",
"X11"
] | 1 | 2021-09-08T21:13:25.000Z | 2021-09-08T21:13:25.000Z | source/programs/Xserver/hw/xfree86/drivers/aspeed/ast_cursor.c | binaryblob01/zfree86 | e80ea992d87501b8e3e2d7c07a414591c2e11c70 | [
"Xnet",
"X11"
] | null | null | null | source/programs/Xserver/hw/xfree86/drivers/aspeed/ast_cursor.c | binaryblob01/zfree86 | e80ea992d87501b8e3e2d7c07a414591c2e11c70 | [
"Xnet",
"X11"
] | 1 | 2021-01-22T00:19:47.000Z | 2021-01-22T00:19:47.000Z | /*
* Copyright (c) 2005 ASPEED Technology Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of the authors not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. The authors makes no representations
* about the suitability of this software for any purpose. It is provided
* "as is" without express or implied warranty.
*
* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/aspeed/ast_cursor.c,v 1.1 2006/04/14 00:50:38 dawes Exp $ */
#include "xf86.h"
#include "xf86_ansic.h"
#include "compiler.h"
/* Cursor includes */
#include "cursorstr.h"
/* Driver specific headers */
#include "ast.h"
#ifdef HWC
/* Prototype type declaration */
static void ASTShowCursor(ScrnInfoPtr pScrn);
static void ASTHideCursor(ScrnInfoPtr pScrn);
static void ASTSetCursorPosition(ScrnInfoPtr pScrn, int x, int y);
static void ASTSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg);
static void ASTLoadCursorImage(ScrnInfoPtr pScrn, UCHAR *src);
static Bool ASTUseHWCursor(ScreenPtr pScreen, CursorPtr pCurs);
static void ASTLoadCursorARGB(ScrnInfoPtr pScrn, CursorPtr pCurs);
static Bool ASTUseHWCursorARGB(ScreenPtr pScreen, CursorPtr pCurs);
static void ASTFireCursor(ScrnInfoPtr pScrn);
Bool
ASTCursorInit(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
ASTRecPtr pAST = ASTPTR(pScrn);
xf86CursorInfoPtr infoPtr;
infoPtr = xf86CreateCursorInfoRec();
if(!infoPtr) return FALSE;
pAST->HWCInfoPtr = infoPtr;
infoPtr->Flags = HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
HARDWARE_CURSOR_INVERT_MASK |
HARDWARE_CURSOR_BIT_ORDER_MSBFIRST;
infoPtr->MaxWidth = MAX_HWC_WIDTH;
infoPtr->MaxHeight = MAX_HWC_HEIGHT;
infoPtr->ShowCursor = ASTShowCursor;
infoPtr->HideCursor = ASTHideCursor;
infoPtr->SetCursorPosition = ASTSetCursorPosition;
infoPtr->SetCursorColors = ASTSetCursorColors;
infoPtr->LoadCursorImage = ASTLoadCursorImage;
infoPtr->UseHWCursor = ASTUseHWCursor;
#ifdef ARGB_CURSOR
infoPtr->UseHWCursorARGB = ASTUseHWCursorARGB;
infoPtr->LoadCursorARGB = ASTLoadCursorARGB;
#endif
return(xf86InitCursor(pScreen, infoPtr));
}
Bool bASTInitHWC(ScrnInfoPtr pScrn, ASTRecPtr pAST)
{
ScreenPtr pScreen;
/* init cursor cache info */
/* Set HWC_NUM in Options instead */
/* pAST->HWCInfo.HWC_NUM = DEFAULT_HWC_NUM; */
pAST->HWCInfo.HWC_NUM_Next = 0;
/* allocate HWC cache */
if (!pAST->pHWCPtr) {
pScreen = screenInfo.screens[pScrn->scrnIndex];
pAST->pHWCPtr = xf86AllocateOffscreenLinear (pScreen, (HWC_SIZE+HWC_SIGNATURE_SIZE)*pAST->HWCInfo.HWC_NUM, HWC_ALIGN, NULL, NULL, NULL);
if (!pAST->pHWCPtr) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"Allocate HWC Cache failed \n");
return (FALSE);
}
pAST->HWCInfo.ulHWCOffsetAddr = pAST->pHWCPtr->offset*((pScrn->bitsPerPixel + 1) / 8);
pAST->HWCInfo.pjHWCVirtualAddr = pAST->FBVirtualAddr + pAST->HWCInfo.ulHWCOffsetAddr;
}
return (TRUE);
}
static void
ASTShowCursor(ScrnInfoPtr pScrn)
{
ASTRecPtr pAST = ASTPTR(pScrn);
UCHAR jReg;
jReg= 0x02;
if (pAST->HWCInfo.cursortype ==HWC_COLOR)
jReg |= 0x01;
SetIndexRegMask(CRTC_PORT, 0xCB, 0xFC, jReg); /* enable mono */
}
static void
ASTHideCursor(ScrnInfoPtr pScrn)
{
ASTRecPtr pAST = ASTPTR(pScrn);
SetIndexRegMask(CRTC_PORT, 0xCB, 0xFC, 0x00); /* disable HWC */
}
static void
ASTSetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
{
ASTRecPtr pAST = ASTPTR(pScrn);
DisplayModePtr mode = pAST->ModePtr;
int x_offset, y_offset;
UCHAR *pjSignature;
/* Set cursor info to Offscreen */
pjSignature = (UCHAR *) pAST->HWCInfo.pjHWCVirtualAddr + (HWC_SIZE+HWC_SIGNATURE_SIZE)*pAST->HWCInfo.HWC_NUM_Next + HWC_SIZE;
*((ULONG *) (pjSignature + HWC_SIGNATURE_X)) = x;
*((ULONG *) (pjSignature + HWC_SIGNATURE_Y)) = y;
x_offset = pAST->HWCInfo.offset_x;
y_offset = pAST->HWCInfo.offset_y;
if(x < 0) {
x_offset = (-x) + pAST->HWCInfo.offset_x;
x = 0;
}
if(y < 0) {
y_offset = (-y) + pAST->HWCInfo.offset_y;
y = 0;
}
if(mode->Flags & V_DBLSCAN) y *= 2;
/* Set to Reg. */
SetIndexReg(CRTC_PORT, 0xC2, (UCHAR) (x_offset));
SetIndexReg(CRTC_PORT, 0xC3, (UCHAR) (y_offset));
SetIndexReg(CRTC_PORT, 0xC4, (UCHAR) (x & 0xFF));
SetIndexReg(CRTC_PORT, 0xC5, (UCHAR) ((x >> 8) & 0x0F));
SetIndexReg(CRTC_PORT, 0xC6, (UCHAR) (y & 0xFF));
SetIndexReg(CRTC_PORT, 0xC7, (UCHAR) ((y >> 8) & 0x07));
/* Fire HWC */
ASTFireCursor(pScrn);
}
static void
ASTSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
{
ASTRecPtr pAST = ASTPTR(pScrn);
pAST->HWCInfo.fg = (fg & 0x0F) | (((fg>>8) & 0x0F) << 4) | (((fg>>16) & 0x0F) << 8);
pAST->HWCInfo.bg = (bg & 0x0F) | (((bg>>8) & 0x0F) << 4) | (((bg>>16) & 0x0F) << 8);
}
static void
ASTLoadCursorImage(ScrnInfoPtr pScrn, UCHAR *src)
{
ASTRecPtr pAST = ASTPTR(pScrn);
int i, j, k;
UCHAR *pjSrcAnd, *pjSrcXor, *pjDstData;
ULONG ulTempDstAnd32[2], ulTempDstXor32[2], ulTempDstData32[2];
UCHAR jTempSrcAnd32, jTempSrcXor32;
ULONG ulCheckSum = 0;
ULONG ulPatternAddr;
/* init cursor info. */
pAST->HWCInfo.cursortype = HWC_MONO;
pAST->HWCInfo.width = (USHORT) MAX_HWC_WIDTH;
pAST->HWCInfo.height = (USHORT) MAX_HWC_HEIGHT;
pAST->HWCInfo.offset_x = MAX_HWC_WIDTH - pAST->HWCInfo.width;
pAST->HWCInfo.offset_y = MAX_HWC_HEIGHT - pAST->HWCInfo.height;
/* copy cursor image to cache */
pjSrcXor = src;
pjSrcAnd = src + (MAX_HWC_WIDTH*MAX_HWC_HEIGHT/8);
pjDstData = pAST->HWCInfo.pjHWCVirtualAddr+(HWC_SIZE+HWC_SIGNATURE_SIZE)*pAST->HWCInfo.HWC_NUM_Next;
for (j = 0; j < MAX_HWC_HEIGHT; j++)
{
for (i = 0; i < (MAX_HWC_WIDTH/8); i++ )
{
for (k=7; k>0; k-=2)
{
jTempSrcAnd32 = *((UCHAR *) pjSrcAnd);
jTempSrcXor32 = *((UCHAR *) pjSrcXor);
ulTempDstAnd32[0] = ((jTempSrcAnd32 >> k) & 0x01) ? 0x00008000L:0x00L;
ulTempDstXor32[0] = ((jTempSrcXor32 >> k) & 0x01) ? 0x00004000L:0x00L;
ulTempDstData32[0] = ((jTempSrcXor32 >> k) & 0x01) ? pAST->HWCInfo.fg:pAST->HWCInfo.bg;
ulTempDstAnd32[1] = ((jTempSrcAnd32 >> (k-1)) & 0x01) ? 0x80000000L:0x00L;
ulTempDstXor32[1] = ((jTempSrcXor32 >> (k-1)) & 0x01) ? 0x40000000L:0x00L;
ulTempDstData32[1] = ((jTempSrcXor32 >> (k-1)) & 0x01) ? (pAST->HWCInfo.fg << 16):(pAST->HWCInfo.bg << 16);
*((ULONG *) pjDstData) = ulTempDstAnd32[0] | ulTempDstXor32[0] | ulTempDstData32[0] | ulTempDstAnd32[1] | ulTempDstXor32[1] | ulTempDstData32[1];
ulCheckSum += *((ULONG *) pjDstData);
pjDstData += 4;
}
pjSrcAnd ++;
pjSrcXor ++;
}
}
/* Write Checksum as signature */
pjDstData = (UCHAR *) pAST->HWCInfo.pjHWCVirtualAddr + (HWC_SIZE+HWC_SIGNATURE_SIZE)*pAST->HWCInfo.HWC_NUM_Next + HWC_SIZE;
*((ULONG *) pjDstData) = ulCheckSum;
*((ULONG *) (pjDstData + HWC_SIGNATURE_SizeX)) = pAST->HWCInfo.width;
*((ULONG *) (pjDstData + HWC_SIGNATURE_SizeY)) = pAST->HWCInfo.height;
*((ULONG *) (pjDstData + HWC_SIGNATURE_HOTSPOTX)) = 0;
*((ULONG *) (pjDstData + HWC_SIGNATURE_HOTSPOTY)) = 0;
/* set pattern offset */
ulPatternAddr = ((pAST->HWCInfo.ulHWCOffsetAddr+(HWC_SIZE+HWC_SIGNATURE_SIZE)*pAST->HWCInfo.HWC_NUM_Next) >> 3);
SetIndexReg(CRTC_PORT, 0xC8, (UCHAR) (ulPatternAddr & 0xFF));
SetIndexReg(CRTC_PORT, 0xC9, (UCHAR) ((ulPatternAddr >> 8) & 0xFF));
SetIndexReg(CRTC_PORT, 0xCA, (UCHAR) ((ulPatternAddr >> 16) & 0xFF));
/* update HWC_NUM_Next */
pAST->HWCInfo.HWC_NUM_Next = (pAST->HWCInfo.HWC_NUM_Next+1) % pAST->HWCInfo.HWC_NUM;
}
static Bool
ASTUseHWCursor(ScreenPtr pScreen, CursorPtr pCurs)
{
return TRUE;
}
static void
ASTLoadCursorARGB(ScrnInfoPtr pScrn, CursorPtr pCurs)
{
ASTRecPtr pAST = ASTPTR(pScrn);
UCHAR *pjDstXor, *pjSrcXor;
ULONG i, j, ulSrcWidth, ulSrcHeight;
ULONG ulPerPixelCopy, ulTwoPixelCopy;
LONG lAlphaDstDelta, lLastAlphaDstDelta;
union
{
ULONG ul;
UCHAR b[4];
} ulSrcData32[2], ulData32;
union
{
USHORT us;
UCHAR b[2];
} usData16;
ULONG ulCheckSum = 0;
ULONG ulPatternAddr;
/* init cursor info. */
pAST->HWCInfo.cursortype = HWC_COLOR;
pAST->HWCInfo.width = pCurs->bits->width;
pAST->HWCInfo.height = pCurs->bits->height;
pAST->HWCInfo.offset_x = MAX_HWC_WIDTH - pAST->HWCInfo.width;
pAST->HWCInfo.offset_y = MAX_HWC_HEIGHT - pAST->HWCInfo.height;
/* copy cursor image to cache */
ulSrcWidth = pAST->HWCInfo.width;
ulSrcHeight = pAST->HWCInfo.height;
lAlphaDstDelta = MAX_HWC_WIDTH << 1;
lLastAlphaDstDelta = lAlphaDstDelta - (ulSrcWidth << 1);
pjSrcXor = (UCHAR *) pCurs->bits->argb;;
pjDstXor = (UCHAR *) pAST->HWCInfo.pjHWCVirtualAddr + (HWC_SIZE+HWC_SIGNATURE_SIZE)*pAST->HWCInfo.HWC_NUM_Next
+ lLastAlphaDstDelta + (MAX_HWC_HEIGHT - ulSrcHeight) * lAlphaDstDelta;
ulPerPixelCopy = ulSrcWidth & 1;
ulTwoPixelCopy = ulSrcWidth >> 1;
for (j = 0; j < ulSrcHeight; j++)
{
for (i = 0; i < ulTwoPixelCopy; i++ )
{
ulSrcData32[0].ul = *((ULONG *) pjSrcXor) & 0xF0F0F0F0;
ulSrcData32[1].ul = *((ULONG *) (pjSrcXor+4)) & 0xF0F0F0F0;
ulData32.b[0] = ulSrcData32[0].b[1] | (ulSrcData32[0].b[0] >> 4);
ulData32.b[1] = ulSrcData32[0].b[3] | (ulSrcData32[0].b[2] >> 4);
ulData32.b[2] = ulSrcData32[1].b[1] | (ulSrcData32[1].b[0] >> 4);
ulData32.b[3] = ulSrcData32[1].b[3] | (ulSrcData32[1].b[2] >> 4);
*((ULONG *) pjDstXor) = ulData32.ul;
ulCheckSum += (ULONG) ulData32.ul;
pjDstXor += 4;
pjSrcXor += 8;
}
for (i = 0; i < ulPerPixelCopy; i++ )
{
ulSrcData32[0].ul = *((ULONG *) pjSrcXor) & 0xF0F0F0F0;
usData16.b[0] = ulSrcData32[0].b[1] | (ulSrcData32[0].b[0] >> 4);
usData16.b[1] = ulSrcData32[0].b[3] | (ulSrcData32[0].b[2] >> 4);
*((USHORT *) pjDstXor) = usData16.us;
ulCheckSum += (ULONG) usData16.us;
pjDstXor += 2;
pjSrcXor += 4;
}
/* Point to next source and dest scans */
pjDstXor += lLastAlphaDstDelta;
} /* end of for-loop */
/* Write Checksum as signature */
pjDstXor = (UCHAR *) pAST->HWCInfo.pjHWCVirtualAddr + (HWC_SIZE+HWC_SIGNATURE_SIZE)*pAST->HWCInfo.HWC_NUM_Next + HWC_SIZE;
*((ULONG *) pjDstXor) = ulCheckSum;
*((ULONG *) (pjDstXor + HWC_SIGNATURE_SizeX)) = pAST->HWCInfo.width;
*((ULONG *) (pjDstXor + HWC_SIGNATURE_SizeY)) = pAST->HWCInfo.height;
*((ULONG *) (pjDstXor + HWC_SIGNATURE_HOTSPOTX)) = 0;
*((ULONG *) (pjDstXor + HWC_SIGNATURE_HOTSPOTY)) = 0;
/* set pattern offset */
ulPatternAddr = ((pAST->HWCInfo.ulHWCOffsetAddr +(HWC_SIZE+HWC_SIGNATURE_SIZE)*pAST->HWCInfo.HWC_NUM_Next) >> 3);
SetIndexReg(CRTC_PORT, 0xC8, (UCHAR) (ulPatternAddr & 0xFF));
SetIndexReg(CRTC_PORT, 0xC9, (UCHAR) ((ulPatternAddr >> 8) & 0xFF));
SetIndexReg(CRTC_PORT, 0xCA, (UCHAR) ((ulPatternAddr >> 16) & 0xFF));
/* update HWC_NUM_Next */
pAST->HWCInfo.HWC_NUM_Next = (pAST->HWCInfo.HWC_NUM_Next+1) % pAST->HWCInfo.HWC_NUM;
}
static Bool
ASTUseHWCursorARGB(ScreenPtr pScreen, CursorPtr pCurs)
{
return TRUE;
}
static void
ASTFireCursor(ScrnInfoPtr pScrn)
{
ASTRecPtr pAST = ASTPTR(pScrn);
SetIndexRegMask(CRTC_PORT, 0xCB, 0xFF, 0x00); /* dummp write to fire HWC */
}
#endif /* End of HWC */
| 33.245902 | 147 | 0.673159 |
a6bf9dcab208a04580b024c4a11ec8fe8ef36b29 | 6,762 | c | C | src/SL_serial_xeno.c | sschaal2/SL | 9d05bbc9c323bccda12f28d75428851c3406a614 | [
"Apache-2.0"
] | 1 | 2020-04-20T15:32:18.000Z | 2020-04-20T15:32:18.000Z | src/SL_serial_xeno.c | sschaal2/SL | 9d05bbc9c323bccda12f28d75428851c3406a614 | [
"Apache-2.0"
] | null | null | null | src/SL_serial_xeno.c | sschaal2/SL | 9d05bbc9c323bccda12f28d75428851c3406a614 | [
"Apache-2.0"
] | null | null | null | /*!=============================================================================
==============================================================================
\file SL_serial.c
\author Stefan Schaal
\date Oct 2011
==============================================================================
\remarks
generic routines for managing serial communiction
============================================================================*/
// SL general includes of system headers
#include "SL_system_headers.h"
// private includes
#include "SL.h"
#include "utility.h"
#include "SL_serial_xeno.h"
#include "SL_man.h"
#include "fcntl.h"
#include "unistd.h"
#include <rtdm/rtdm.h>
#include <rtdm/rtserial.h>
/* local variables */
/* global variables */
/* local functions */
/*!*****************************************************************************
*******************************************************************************
\note open_serial
\date Oct 2000
\remarks
opens a specific serial port
*******************************************************************************
Function Parameters: [in]=input,[out]=output
\param[in] fname : name of serial port
\param[in] baud : baudrate (choose from termios.h, e.g., B38400)
\param[in] mode : O_RDONLY or O_RDWR
return serial_fd, i.e., the file descriptor, or FALSE
******************************************************************************/
int
open_serial(char *fname, int baud, int mode)
{
int serial_fd;
struct rtser_config get_config;
int rc;
serial_fd = rt_dev_open( fname, mode | O_NOCTTY | O_NDELAY );
if (serial_fd < 0) {
printf("Can't open serial port %s for mode %d (err=%d)\n",fname,mode,serial_fd);
return FALSE;
}
// get settings of the serial port
rc = rt_dev_ioctl(serial_fd, RTSER_RTIOC_GET_CONFIG, &get_config);
if (rc) {
printf("ERROR: cannot get RTSER_RTIOC_GET_CONFIG, status = %d, errno = %d, strerror = %s \n",
rc,errno,strerror(errno));
return FALSE;
}
// set baud rate
get_config.baud_rate = baud;
// set parity and bits
get_config.parity = RTSER_NO_PARITY;
get_config.data_bits = RTSER_8_BITS;
get_config.stop_bits = RTSER_DEF_STOPB;
get_config.rx_timeout = 50*1000; // in ns
get_config.tx_timeout = 50*1000; // in ns
get_config.event_timeout = 50*1000; // in ns
get_config.event_mask = RTSER_EVENT_RXPEND;
get_config.config_mask =
RTSER_SET_BAUD | RTSER_SET_PARITY | RTSER_SET_DATA_BITS | RTSER_SET_STOP_BITS |
RTSER_SET_TIMEOUT_RX | RTSER_SET_TIMEOUT_TX | RTSER_SET_TIMEOUT_EVENT | RTSER_SET_EVENT_MASK;
// and update the serial line
rc = rt_dev_ioctl(serial_fd, RTSER_RTIOC_SET_CONFIG, &get_config);
if (rc) {
printf("ERROR: cannot get RTSER_RTIOC_SET_CONFIG, status = %d, errno = %d, strerror = %s \n",
rc,errno,strerror(errno));
return FALSE;
}
// clear the buffer
clear_serial(serial_fd);
return serial_fd;
}
/*!*****************************************************************************
*******************************************************************************
\note close_serial
\date Oct 2000
\remarks
closes the serial connection
*******************************************************************************
Function Parameters: [in]=input,[out]=output
\param[in] fd : file descriptor
******************************************************************************/
void
close_serial(int fd)
{
rt_dev_close(fd);
}
/*!*****************************************************************************
*******************************************************************************
\note clear_serial
\date Oct 2000
\remarks
empties the serial buffer
*******************************************************************************
Function Parameters: [in]=input,[out]=output
\param[in] fd : file descriptor
******************************************************************************/
int
clear_serial(int fd)
{
int n_bytes;
int n_bytes_read;
char buf[10000];
while(TRUE) {
n_bytes = check_serial(fd);
if (n_bytes > 10000) {
n_bytes = 10000;
n_bytes_read = read_serial(fd,n_bytes,buf);
} else {
n_bytes_read = read_serial(fd,n_bytes,buf);
break;
}
}
return TRUE;
}
/*!*****************************************************************************
*******************************************************************************
\note read_serial
\date Oct 2000
\remarks
reads into a buffer
*******************************************************************************
Function Parameters: [in]=input,[out]=output
\param[in] fd : file descriptor
\param[in] n_bytes: number of bytes to read
\param[out] buffer: buffer for read
returns the number of bytes actually read
******************************************************************************/
int
read_serial(int fd,int n_bytes, char *buffer)
{
return rt_dev_read(fd, buffer, n_bytes);
}
/*!*****************************************************************************
*******************************************************************************
\note write_serial
\date Oct 2000
\remarks
write to the serial port
*******************************************************************************
Function Parameters: [in]=input,[out]=output
\param[in] fd : file descriptor
\param[in] n_bytes: number of bytes to write
\param[in] buffer: buffer with bytes to write
returns the number of bytes actually written
******************************************************************************/
int
write_serial(int fd,int n_bytes, char *buffer)
{
return rt_dev_write(fd, buffer, (size_t) n_bytes);
}
/*!*****************************************************************************
*******************************************************************************
\note check_serial
\date Oct 2000
\remarks
checks the number of bytes in serial input buffer
*******************************************************************************
Function Parameters: [in]=input,[out]=output
\param[in] fd : file descriptor
returns the number of bytes in buffer
******************************************************************************/
int
check_serial(int fd)
{
int n_bytes;
int rc;
struct rtser_event rx_event;
rc = rt_dev_ioctl(fd, RTSER_RTIOC_WAIT_EVENT, &rx_event );
if (rc) {
if (rc != -ETIMEDOUT)
printf("ERROR on RTSER_RTIOC_WAIT_EVENT, %s\n",strerror(-rc));
return 0;
}
n_bytes = rx_event.rx_pending;
return n_bytes;
}
| 26.833333 | 97 | 0.449719 |
074d0967a3bcb87fb3d7b01752fbd65cb6dab209 | 4,468 | h | C | Ornate_cpp/Collisions/Collisions_engine_Engine_collider_relation.h | pkolodziej13/Ornate_cpp | 9774b71b2a3a9f9a970cc236a0b49729d7369017 | [
"MIT"
] | null | null | null | Ornate_cpp/Collisions/Collisions_engine_Engine_collider_relation.h | pkolodziej13/Ornate_cpp | 9774b71b2a3a9f9a970cc236a0b49729d7369017 | [
"MIT"
] | null | null | null | Ornate_cpp/Collisions/Collisions_engine_Engine_collider_relation.h | pkolodziej13/Ornate_cpp | 9774b71b2a3a9f9a970cc236a0b49729d7369017 | [
"MIT"
] | null | null | null | #pragma once
#include <bitset>
#include <Types/Pack.h>
#include "Synchronized_vector.h"
#include "Collisions_requirements.h"
namespace col
{
template<class Individualist>
struct Collider_relation_side
{
void add_pool_index_for_engine(Engine_unified & engine,size_t pool_index)
{
engine_pool_indexes.emplace_for(individualist().engines(), &engine, pool_index);
}
size_t engine_place(Engine_unified& engine)
{
return engine_pool_indexes.get(individualist().engines(), &engine);
}
void change_engine_index_on_this_side(Engine_unified& engine, size_t pool_index)
{
engine_pool_indexes.set_for(individualist().engines(),&engine, pool_index);
}
size_t removed_engine_pool_index(Engine_unified& engine)
{
return engine_pool_indexes.get(individualist().engines(),&engine);
}
void remove_engine_on_this_side(Engine_unified& engine)
{
engine_pool_indexes.remove_element_of(individualist().engines(), &engine);
}
Synchronized_vector<size_t> engine_pool_indexes;
inline Individualist& individualist()
{
return static_cast< Individualist&>(*this);
}
};
template<class Individualist, class Comparer>
struct Engine_collider_relation_wing
{
using Layers_p = typename Comparer::Layers_p;
using Layers_key = std::bitset<Layers_p::size>;
template<class Collider_type>
Layers_key get_key_of_collider(Collider_type& collider)
{
Layers_key result;
auto lam = [&](auto& object)
{
result.set(object.layer_index());
};
collider.for_every_object_conected_with_engine(individualist().individualist(), lam);
return result;
}
template<class Object_type>
Layers_key remove_layer_from_key( Layers_key key, Object_type& object)
{
key.reset(object.layer_index());
return key;
}
template<class Object_type>
Layers_key add_layer_to_key( Layers_key key, Object_type& object)
{
size_t index = object.layer_index_in_engine(individualist().individualist());
key.set(index);
return key;
}
template<class Collider_type>
size_t add_collider_on_this_side( Collider_type& collider, const Layers_key& key)
{
return individualist().add_collider_on_this_side(collider, key);
}
template<class Collider_type>
size_t change_collider_on_this_side( Collider_type& collider,size_t old_place, const Layers_key& old_key, const Layers_key& new_key)
{
return individualist().change_collider_on_this_side(collider, old_place, old_key, new_key);
}
template<class Collider_type>
void remove_collider_on_this_side(Collider_type& collider, size_t old_place, const Layers_key& old_key)
{
return individualist().remove_collider_on_this_side(collider, old_place, old_key);
}
inline Individualist& individualist()
{
return static_cast<Individualist&>(*this);
}
};
template<class Collecting_engine>
struct Engine_collider_relation
{
using layers_key = typename Collecting_engine::Layers_key;
template<class Collider_type>
static void verify_relation_after_add(Collecting_engine& engine, Collider_type& collider, Object_unified& object)
{
auto current_layers_key = engine.get_key_of_collider(collider);
auto previus_layers_key = engine.remove_layer_from_key(current_layers_key, object);
if (previus_layers_key.none())
{
size_t place = engine.add_collider_on_this_side(collider, current_layers_key);
collider.add_pool_index_for_engine(engine, place);
}
else
{
size_t old_place = collider.engine_place(engine);
size_t place = engine.change_collider_on_this_side(collider, old_place, previus_layers_key, current_layers_key);
collider.change_engine_index_on_this_side(engine, place);
}
}
template<class Collider_type>
static void verify_relation_after_remove(Collecting_engine& engine, Collider_type& collider, Object_unified& object)
{
auto current_layers_key = engine.get_key_of_collider(collider);
auto previus_layers_key = engine.add_layer_to_key(current_layers_key, object);
if (current_layers_key.none())
{
size_t old_place = collider.removed_engine_pool_index(engine);
engine.remove_collider_on_this_side(collider, old_place, previus_layers_key);
collider.remove_engine_on_this_side(engine);
}
else
{
size_t old_place = collider.engine_place(engine);
size_t place = engine.change_collider_on_this_side(collider, old_place, previus_layers_key, current_layers_key);
collider.change_engine_index_on_this_side(engine, place);
}
}
};
} | 32.143885 | 134 | 0.771262 |
60663c061706af9fe3c467cdf937695a12ca4e99 | 509 | c | C | generate_parameter.c | sjj-star/wallace-tree-verilogHDL-code | 80b8c39c49ecd516e3f64bb7f4e91dee7eacd156 | [
"MIT"
] | 10 | 2020-08-08T10:47:47.000Z | 2022-03-25T05:51:33.000Z | generate_parameter.c | wofanqiang/automatically-generate-Wallace-Tree-VerilogHDL-code | bcc3e4f01a80acd2944290b75695f8d5d0e962e4 | [
"MIT"
] | null | null | null | generate_parameter.c | wofanqiang/automatically-generate-Wallace-Tree-VerilogHDL-code | bcc3e4f01a80acd2944290b75695f8d5d0e962e4 | [
"MIT"
] | 2 | 2020-11-23T11:30:40.000Z | 2022-03-09T21:58:55.000Z | #include <stdio.h>
#define width 32
int main(void)
{
int a[width/2+1][width*2]={0};
int i, j;
for(i=0; i<width/2; i++) {
for(j=i*2, a[i][j]+=1; j<(i+1)*2+width; j++) {
a[i][j]++;
}
}
for(i=width; i<width*2; i++) {
a[width/2][i]++;
}
for(i=1; i<width/2+1; i++) {
for(j=0; j<width*2; j++) {
a[0][j] += a[i][j];
}
}
for(i=0; i<width*2; i++)
printf("%d ", a[0][i]);
printf("\n\n");
return 0;
}
| 18.178571 | 54 | 0.37721 |
e6758395e44cdbc157c8eda4fc6ee84920a9b3f0 | 2,094 | h | C | jni/mcpe/client/gui/TextBox.h | affogatoman/FlatLayerGui | a829d5a7a536c79d2c7faddc7cd24b8b5c51c60f | [
"Apache-2.0"
] | 4 | 2015-10-12T13:26:06.000Z | 2020-04-26T11:57:47.000Z | jni/mcpe/client/gui/TextBox.h | affogatoman/FlatLayerGui | a829d5a7a536c79d2c7faddc7cd24b8b5c51c60f | [
"Apache-2.0"
] | null | null | null | jni/mcpe/client/gui/TextBox.h | affogatoman/FlatLayerGui | a829d5a7a536c79d2c7faddc7cd24b8b5c51c60f | [
"Apache-2.0"
] | null | null | null | #pragma once
#include "GuiElement.h"
#include "../settings/Options.h"
namespace Touch {
class TButton;
}
class Screen;
//Size : 180
class TextBox : public GuiElement {
public:
int key; //120
Touch::TButton* doneButton; //124
char filler1[12]; //128
std::string text; //140
std::string name; //144
bool focus; //148
char filler2[11]; //149
std::string validChars; //160
char filler3[16]; //164
public:
static char* extendedASCII;
static char* numberChars;
static char* identifierChars;
public:
TextBox(MinecraftClient&, Options::Option const*, std::string const&, std::string const&);
TextBox(MinecraftClient&, std::string const&, int, std::string const&, Screen*, void (Screen::*)(int), int, bool);
virtual ~TextBox();
virtual void tick(MinecraftClient*);
virtual void render(MinecraftClient*, int, int);
virtual void topRender(MinecraftClient*, int, int);
virtual void pointerPressed(MinecraftClient*, int, int);
virtual void pointerReleased(MinecraftClient*, int, int);
virtual void focusedMouseClicked(MinecraftClient*, int, int);
virtual void focusedMouseReleased(MinecraftClient*, int, int);
virtual void handleButtonPress(MinecraftClient*, short);
virtual void handleTextChar(MinecraftClient*, std::string const&, bool);
virtual bool backPressed(MinecraftClient*, bool);
virtual bool suppressOtherGUI();
virtual void setTextboxText(std::string const&);
virtual bool hasFocus() const;
virtual void setFocus(MinecraftClient*);
virtual void loseFocus(MinecraftClient*);
std::string _getClippedString(MinecraftClient*) const;
int getKey();
std::string& getText() const;
bool isValidCharacter(std::string const&);
void setName(std::string const&);
void setText(std::string const&);
void setValidChars(std::string const&);
void updateText(MinecraftClient*);
};
| 36.736842 | 118 | 0.644699 |
32e176b0b3c9138d0709db9acb3322a7a6b34715 | 2,617 | c | C | src/Dolphin/nubinit.c | projectPiki/pikmin2 | a431d992acde856d092889a515ecca0e07a3ea7c | [
"Unlicense"
] | 33 | 2021-12-08T11:10:59.000Z | 2022-03-26T19:59:37.000Z | src/Dolphin/nubinit.c | projectPiki/pikmin2 | a431d992acde856d092889a515ecca0e07a3ea7c | [
"Unlicense"
] | 6 | 2021-12-22T17:54:31.000Z | 2022-01-07T21:43:18.000Z | src/Dolphin/nubinit.c | projectPiki/pikmin2 | a431d992acde856d092889a515ecca0e07a3ea7c | [
"Unlicense"
] | 2 | 2022-01-04T06:00:49.000Z | 2022-01-26T07:27:28.000Z |
/*
* --INFO--
* Address: ........
* Size: 000070
*/
void TRKInitializeEndian(void)
{
// UNUSED FUNCTION
}
/*
* --INFO--
* Address: 800BB6B0
* Size: 000028
*/
// extern char lbl_804796C8[27];
extern void TRK_board_display(char*);
void TRKNubWelcome(void)
{
TRK_board_display("MetroTRK for GAMECUBE v2.6"); //"MetroTRK for GAMECUBE v2.6"
return;
}
/*
* --INFO--
* Address: 800BB6D8
* Size: 000024
*/
extern unsigned int TRKTerminateSerialHandler(void);
unsigned int TRKTerminateNub(void)
{
TRKTerminateSerialHandler();
return 0;
}
/*
* --INFO--
* Address: 800BB6FC
* Size: 00014C
*/
// void TRKInitializeNub(void)
//{
/*
.loc_0x0:
stwu r1, -0x20(r1)
mflr r0
li r5, 0x12
li r4, 0x34
stw r0, 0x24(r1)
li r3, 0x56
li r0, 0x78
li r6, 0x1
stb r5, 0x8(r1)
lis r5, 0x804F
stw r31, 0x1C(r1)
li r31, 0
stw r30, 0x18(r1)
stb r4, 0x9(r1)
stb r3, 0xA(r1)
stb r0, 0xB(r1)
lwz r3, 0x8(r1)
stwu r6, 0x28A8(r5)
subis r0, r3, 0x1234
cmplwi r0, 0x5678
bne- .loc_0x5C
stw r6, 0x0(r5)
b .loc_0x74
.loc_0x5C:
subis r0, r3, 0x7856
cmplwi r0, 0x3412
bne- .loc_0x70
stw r31, 0x0(r5)
b .loc_0x74
.loc_0x70:
mr r31, r6
.loc_0x74:
lis r3, 0x8048
subi r4, r3, 0x691C
li r3, 0x1
crclr 6, 0x6
bl 0x5DC8
cmpwi r31, 0
bne- .loc_0x94
bl 0xBF4
.loc_0x94:
cmpwi r31, 0
bne- .loc_0xA4
bl -0x140
mr r31, r3
.loc_0xA4:
cmpwi r31, 0
bne- .loc_0xB4
bl 0x8AC
mr r31, r3
.loc_0xB4:
cmpwi r31, 0
bne- .loc_0xC4
bl 0xDC4
mr r31, r3
.loc_0xC4:
bl 0x4D30
cmpwi r31, 0
bne- .loc_0xD8
bl 0x904
mr r31, r3
.loc_0xD8:
cmpwi r31, 0
bne- .loc_0xE8
bl 0x4A40
mr r31, r3
.loc_0xE8:
cmpwi r31, 0
bne- .loc_0x130
lis r3, 0x8051
lis r5, 0x1
addi r6, r3, 0x5308
li r4, 0x1
subi r3, r5, 0x1F00
li r5, 0
bl 0x4EC4
lis r4, 0x8051
mr r0, r3
addi r3, r4, 0x5308
lwz r3, 0x0(r3)
mr r30, r0
bl 0x2B2C
cmpwi r30, 0
beq- .loc_0x130
mr r31, r30
.loc_0x130:
lwz r0, 0x24(r1)
mr r3, r31
lwz r31, 0x1C(r1)
lwz r30, 0x18(r1)
mtlr r0
addi r1, r1, 0x20
blr
*/
//}
const char lbl_804796E4[] = "Initialize NUB\n";
| 16.993506 | 80 | 0.51089 |
52d18a54e5d71704e1705dfcef2a3067294dddd7 | 3,083 | h | C | src/avt/Expressions/MeshQuality/avtSideVolume.h | visit-dav/vis | c08bc6e538ecd7d30ddc6399ec3022b9e062127e | [
"BSD-3-Clause"
] | 226 | 2018-12-29T01:13:49.000Z | 2022-03-30T19:16:31.000Z | src/avt/Expressions/MeshQuality/avtSideVolume.h | visit-dav/vis | c08bc6e538ecd7d30ddc6399ec3022b9e062127e | [
"BSD-3-Clause"
] | 5,100 | 2019-01-14T18:19:25.000Z | 2022-03-31T23:08:36.000Z | src/avt/Expressions/MeshQuality/avtSideVolume.h | visit-dav/vis | c08bc6e538ecd7d30ddc6399ec3022b9e062127e | [
"BSD-3-Clause"
] | 84 | 2019-01-24T17:41:50.000Z | 2022-03-10T10:01:46.000Z | // Copyright (c) Lawrence Livermore National Security, LLC and other VisIt
// Project developers. See the top-level LICENSE file for dates and other
// details. No copyright assignment is required to contribute to VisIt.
// ************************************************************************* //
// avtSideVolume.h //
// ************************************************************************* //
#ifndef AVT_SIDE_VOLUME_H
#define AVT_SIDE_VOLUME_H
#include <avtSingleInputExpressionFilter.h>
class vtkCell;
// ****************************************************************************
// Class: avtSideVolume
//
// Purpose:
// Calculates all of the side volumes of the sides of a cell and then
// assigns the side volume for the cell to be smallest.
//
// A side volume is defined as the following:
// A zone Z is comprised of edges, faces, and nodes.
// Each face F has a center, C, where C is the linear average
// of the nodes on F.
// The center of Z is the linear average of the center of its
// faces.
//
// Then there are two sides for each edge, E.
// If edge E is made up of points V1 and V2 and E is incident
// to faces F1 and F2, then one side is a tet consisting of
// V1, V2, center(F1) and center(Z), where the other tet
// consists of V1, V2, center(F2) and center(Z).
//
// The side volume expression returns either the smallest volume or the
// largest volume of the sides of a zone. This is a little bit of
// laziness on our part, since the right thing to do would probably be to
// subdivide the mesh into tets and go from there. But then there would
// be additional issues, and all of the customers agree this is a
// reasonable thing to do.
//
// Programmer: Hank Childs
// Creation: January 20, 2005
//
// Modifications:
//
// Hank Childs, Thu Sep 22 15:39:11 PDT 2005
// Add min and max variants.
//
// Hank Childs, Wed May 21 15:55:53 PDT 2008
// Re-define GetVariableDimension.
//
// ****************************************************************************
class EXPRESSION_API avtSideVolume : public avtSingleInputExpressionFilter
{
public:
avtSideVolume();
virtual const char *GetType(void) { return "avtSideVolume"; };
virtual const char *GetDescription(void)
{ return "Calculating side volume"; };
void SetTakeMin(bool tm) { takeMin = tm; };
protected:
bool haveIssuedWarning;
bool takeMin;
virtual vtkDataArray *DeriveVariable(vtkDataSet *, int currentDomainsIndex);
virtual void PreExecute(void);
virtual bool IsPointVariable(void) { return false; };
virtual int GetVariableDimension() { return 1; };
double GetZoneVolume(vtkCell *);
};
#endif
| 35.848837 | 86 | 0.546546 |
fd3e9b8231f08c45e28509b0fe6878c69872becf | 935 | h | C | main_app.h | EricJeffrey/my_http_server | b2649c890b7842e44fcd074859b9d5769ad08d21 | [
"BSD-2-Clause"
] | 2 | 2019-11-26T07:51:25.000Z | 2019-12-24T10:53:03.000Z | main_app.h | EricJeffrey/my_http_server | b2649c890b7842e44fcd074859b9d5769ad08d21 | [
"BSD-2-Clause"
] | null | null | null | main_app.h | EricJeffrey/my_http_server | b2649c890b7842e44fcd074859b9d5769ad08d21 | [
"BSD-2-Clause"
] | null | null | null | #if !defined(MAIN_APP_H)
#define MAIN_APP_H
#include <set>
#include <string>
#include <unistd.h>
using std::set;
using std::string;
enum state {
initialize,
start,
stop
};
class main_app {
private:
// arguments to parse
static int argc;
static char **argv;
static const string usage;
static set<pid_t> set_child_pids;
static int createConfigFile();
static int parseArgs();
static int loadConfig();
static void init();
static void start();
static void stop();
public:
static state app_state;
main_app() {}
~main_app() {}
static void run(int argc, char *argv[]) {
main_app::argc = argc;
main_app::argv = argv;
init();
start();
}
static void addChildProcess(pid_t pid) {
set_child_pids.insert(pid);
}
static void removeChild(pid_t pid) {
set_child_pids.erase(pid);
}
};
#endif // MAIN_APP_H
| 18.333333 | 45 | 0.616043 |
1307ea94deeff21e5f8a3d5f8e4ba045e4b9b3ac | 5,294 | h | C | CloudTools.Common/IO/Result.h | mcserep/PointCloudTools | c8cd0c5915cc3802b68164f1732f93dc11efb0d5 | [
"BSD-3-Clause"
] | 6 | 2020-12-30T03:47:43.000Z | 2022-03-01T16:24:27.000Z | CloudTools.Common/IO/Result.h | mcserep/PointCloudTools | c8cd0c5915cc3802b68164f1732f93dc11efb0d5 | [
"BSD-3-Clause"
] | null | null | null | CloudTools.Common/IO/Result.h | mcserep/PointCloudTools | c8cd0c5915cc3802b68164f1732f93dc11efb0d5 | [
"BSD-3-Clause"
] | 3 | 2021-03-20T14:54:25.000Z | 2022-02-23T12:55:41.000Z | #pragma once
#include <string>
#include <boost/filesystem.hpp>
#include <gdal_priv.h>
namespace fs = boost::filesystem;
namespace CloudTools
{
namespace IO
{
/// <summary>
/// Represents a result object.
/// </summary>
struct Result
{
protected:
/// <summary>
/// File path.
/// </summary>
/// <remarks>
/// Empty for GDAL memory objects, starts with <c>"/vsimem/"</c> for virtual files.
/// </remarks>
fs::path _path;
public:
/// <summary>
/// Dataset.
/// </summary>
GDALDataset* dataset;
protected:
/// <summary>
/// Initializes a new instance of the struct.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="dataset">The dataset.</param>
explicit Result(const std::string& path, GDALDataset* dataset = nullptr)
: _path(path), dataset(dataset)
{ }
/// <summary>
/// Initializes a new instance of the struct.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="dataset">The dataset.</param>
explicit Result(const fs::path& path, GDALDataset* dataset = nullptr)
: _path(path), dataset(dataset)
{ }
public:
virtual ~Result();
Result(const Result&) = delete;
Result& operator=(const Result&) = delete;
Result(Result&& other) noexcept;
Result& operator=(Result&& other) noexcept;
/// <summary>
/// Gets the path.
/// </summary>
std::string path() const { return _path.string(); }
};
/// <summary>
/// Represents a permanent file result.
/// </summary>
struct PermanentFileResult : Result
{
/// <summary>
/// Initializes a new instance of the struct.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="dataset">The dataset.</param>
explicit PermanentFileResult(const std::string& path, GDALDataset* dataset = nullptr)
: Result(path, dataset)
{ }
/// <summary>
/// Initializes a new instance of the struct.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="dataset">The dataset.</param>
explicit PermanentFileResult(const fs::path& path, GDALDataset* dataset = nullptr)
: Result(path, dataset)
{ }
PermanentFileResult(const PermanentFileResult&) = delete;
PermanentFileResult& operator=(const PermanentFileResult&) = delete;
PermanentFileResult(PermanentFileResult&& other) noexcept
: Result(std::move(other))
{ }
PermanentFileResult& operator=(PermanentFileResult&& other) noexcept
{
*this = std::move(other);
return *this;
}
};
/// <summary>
/// Represents a temporary file result.
/// </summary>
struct TemporaryFileResult : PermanentFileResult
{
/// <summary>
/// Initializes a new instance of the struct.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="dataset">The dataset.</param>
explicit TemporaryFileResult(const std::string& path, GDALDataset* dataset = nullptr)
: PermanentFileResult(path, dataset)
{ }
/// <summary>
/// Initializes a new instance of the struct.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="dataset">The dataset.</param>
explicit TemporaryFileResult(const fs::path& path, GDALDataset* dataset = nullptr)
: PermanentFileResult(path, dataset)
{ }
~TemporaryFileResult();
TemporaryFileResult(const TemporaryFileResult&) = delete;
TemporaryFileResult& operator=(const TemporaryFileResult&) = delete;
TemporaryFileResult(TemporaryFileResult&& other) noexcept
: PermanentFileResult(std::move(other))
{ }
TemporaryFileResult& operator=(TemporaryFileResult&& other) noexcept
{
*this = std::move(other);
return *this;
}
};
/// <summary>
/// Represents a virtual file result.
/// </summary>
struct VirtualResult : Result
{
/// <summary>
/// Initializes a new instance of the struct.
/// </summary>
/// <remarks>
/// The <paramref name="path"/> must start with <c>"/vsimem/"</c>, otherwise added.
/// </remarks>
/// <param name="path">The path.</param>
/// <param name="dataset">The dataset.</param>
explicit VirtualResult(const std::string& path, GDALDataset* dataset = nullptr);
/// <summary>
/// Initializes a new instance of the struct.
/// </summary>
/// <remarks>
/// The <paramref name="path"/> must start with <c>"/vsimem/"</c>, otherwise added.
/// </remarks>
/// <param name="path">The path.</param>
/// <param name="dataset">The dataset.</param>
explicit VirtualResult(const fs::path& path, GDALDataset* dataset = nullptr);
~VirtualResult();
VirtualResult(const VirtualResult&) = delete;
VirtualResult& operator=(const VirtualResult&) = delete;
VirtualResult(VirtualResult&& other) noexcept
: Result(std::move(other))
{ }
VirtualResult& operator=(VirtualResult&& other) noexcept
{
*this = std::move(other);
return *this;
}
};
/// <summary>
/// Represents a GDAL memory object result.
/// </summary>
struct MemoryResult : Result
{
/// <summary>
/// Initializes a new instance of the struct.
/// </summary>
/// <param name="dataset">The dataset.</param>
explicit MemoryResult(GDALDataset* dataset = nullptr)
: Result(std::string(), dataset)
{
}
MemoryResult(const MemoryResult&) = delete;
MemoryResult& operator=(const MemoryResult&) = delete;
MemoryResult(MemoryResult&& other) noexcept
: Result(std::move(other))
{ }
MemoryResult& operator=(MemoryResult&& other) noexcept
{
*this = std::move(other);
return *this;
}
};
} // IO
} // CloudTools
| 25.090047 | 86 | 0.67756 |
594a40b8b8a1b2db100e44ee794617743c67e333 | 347 | h | C | PolyvVodSDKDemo/PolyvVodSDKDemo/PolyvOpenSourceModule/PPT/View/PLVPPTFailView.h | polyv/polyv-ios-vod-sdk | 38d55132025aa01e6e181af9fc91488333eed86c | [
"Apache-2.0"
] | 42 | 2018-03-22T06:33:58.000Z | 2021-12-28T01:39:50.000Z | PolyvVodSDKDemo/PolyvVodSDKDemo/PolyvOpenSourceModule/PPT/View/PLVPPTFailView.h | polyv/polyv-ios-vod-sdk | 38d55132025aa01e6e181af9fc91488333eed86c | [
"Apache-2.0"
] | 37 | 2018-03-29T12:03:36.000Z | 2021-08-12T02:09:06.000Z | PolyvVodSDKDemo/PolyvVodSDKDemo/PolyvOpenSourceModule/PPT/View/PLVPPTFailView.h | polyv/polyv-ios-vod-sdk | 38d55132025aa01e6e181af9fc91488333eed86c | [
"Apache-2.0"
] | 10 | 2018-04-11T08:35:00.000Z | 2022-01-17T10:32:30.000Z | //
// PLVPPTFailView.h
// PolyvVodSDKDemo
//
// Created by MissYasiky on 2019/8/6.
// Copyright © 2019 POLYV. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface PLVPPTFailView : UIView
@property (nonatomic, strong) UIButton *button;
- (void)setLabelTextColor:(UIColor *)color;
@end
NS_ASSUME_NONNULL_END
| 15.772727 | 48 | 0.73487 |
f7cd1448f8e992477eb064ab7038ffe2d6a756f2 | 1,908 | h | C | modules/scene_manager/include/unique_identifier_msgs/msg/rosidl_typesupport_opensplice_c__visibility_control.h | Omnirobotic/godot | d50b5d047bbf6c68fc458c1ad097321ca627185d | [
"CC-BY-3.0",
"Apache-2.0",
"MIT"
] | null | null | null | modules/scene_manager/include/unique_identifier_msgs/msg/rosidl_typesupport_opensplice_c__visibility_control.h | Omnirobotic/godot | d50b5d047bbf6c68fc458c1ad097321ca627185d | [
"CC-BY-3.0",
"Apache-2.0",
"MIT"
] | 3 | 2019-11-14T12:20:06.000Z | 2020-08-07T13:51:10.000Z | modules/scene_manager/include/unique_identifier_msgs/msg/rosidl_typesupport_opensplice_c__visibility_control.h | Omnirobotic/godot | d50b5d047bbf6c68fc458c1ad097321ca627185d | [
"CC-BY-3.0",
"Apache-2.0",
"MIT"
] | null | null | null | // generated from
// rosidl_typesupport_opensplice_c/resource/rosidl_typesupport_opensplice_c__visibility_control.h.in
// generated code does not contain a copyright notice
#ifndef UNIQUE_IDENTIFIER_MSGS__MSG__ROSIDL_TYPESUPPORT_OPENSPLICE_C__VISIBILITY_CONTROL_H_
#define UNIQUE_IDENTIFIER_MSGS__MSG__ROSIDL_TYPESUPPORT_OPENSPLICE_C__VISIBILITY_CONTROL_H_
#ifdef __cplusplus
extern "C"
{
#endif
// This logic was borrowed (then namespaced) from the examples on the gcc wiki:
// https://gcc.gnu.org/wiki/Visibility
#if defined _WIN32 || defined __CYGWIN__
#ifdef __GNUC__
#define ROSIDL_TYPESUPPORT_OPENSPLICE_C_EXPORT_unique_identifier_msgs __attribute__ ((dllexport))
#define ROSIDL_TYPESUPPORT_OPENSPLICE_C_IMPORT_unique_identifier_msgs __attribute__ ((dllimport))
#else
#define ROSIDL_TYPESUPPORT_OPENSPLICE_C_EXPORT_unique_identifier_msgs __declspec(dllexport)
#define ROSIDL_TYPESUPPORT_OPENSPLICE_C_IMPORT_unique_identifier_msgs __declspec(dllimport)
#endif
#ifdef ROSIDL_TYPESUPPORT_OPENSPLICE_C_BUILDING_DLL_unique_identifier_msgs
#define ROSIDL_TYPESUPPORT_OPENSPLICE_C_PUBLIC_unique_identifier_msgs ROSIDL_TYPESUPPORT_OPENSPLICE_C_EXPORT_unique_identifier_msgs
#else
#define ROSIDL_TYPESUPPORT_OPENSPLICE_C_PUBLIC_unique_identifier_msgs ROSIDL_TYPESUPPORT_OPENSPLICE_C_IMPORT_unique_identifier_msgs
#endif
#else
#define ROSIDL_TYPESUPPORT_OPENSPLICE_C_EXPORT_unique_identifier_msgs __attribute__ ((visibility("default")))
#define ROSIDL_TYPESUPPORT_OPENSPLICE_C_IMPORT_unique_identifier_msgs
#if __GNUC__ >= 4
#define ROSIDL_TYPESUPPORT_OPENSPLICE_C_PUBLIC_unique_identifier_msgs __attribute__ ((visibility("default")))
#else
#define ROSIDL_TYPESUPPORT_OPENSPLICE_C_PUBLIC_unique_identifier_msgs
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif // UNIQUE_IDENTIFIER_MSGS__MSG__ROSIDL_TYPESUPPORT_OPENSPLICE_C__VISIBILITY_CONTROL_H_
| 43.363636 | 135 | 0.865304 |
ea243f67cc1757ebf0b2251e31d260270d0dab57 | 4,895 | h | C | lib/IRremoteESP8266/src/ir_Ecoclim.h | Eliauk-Forever/JARVIS | 69569e530f0bc66c90bc2ba2a266edb65006bd6f | [
"MulanPSL-1.0"
] | 14 | 2019-07-09T09:38:59.000Z | 2022-02-11T13:57:18.000Z | lib/IRremoteESP8266/src/ir_Ecoclim.h | Eliauk-Forever/JARVIS | 69569e530f0bc66c90bc2ba2a266edb65006bd6f | [
"MulanPSL-1.0"
] | null | null | null | lib/IRremoteESP8266/src/ir_Ecoclim.h | Eliauk-Forever/JARVIS | 69569e530f0bc66c90bc2ba2a266edb65006bd6f | [
"MulanPSL-1.0"
] | 1 | 2021-06-26T22:26:58.000Z | 2021-06-26T22:26:58.000Z | // Copyright 2021 David Conran
/// @file
/// @brief EcoClim A/C protocol.
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/1397
// Supports:
// Brand: EcoClim, Model: HYSFR-P348 remote
// Brand: EcoClim, Model: ZC200DPO A/C
#ifndef IR_ECOCLIM_H_
#define IR_ECOCLIM_H_
#define __STDC_LIMIT_MACROS
#include <stdint.h>
#ifndef UNIT_TEST
#include <Arduino.h>
#endif
#include "IRremoteESP8266.h"
#include "IRsend.h"
#ifdef UNIT_TEST
#include "IRsend_test.h"
#endif
// Constants
// Modes
const uint8_t kEcoclimAuto = 0b000; ///< 0. a.k.a Slave
const uint8_t kEcoclimCool = 0b001; ///< 1
const uint8_t kEcoclimDry = 0b010; ///< 2
const uint8_t kEcoclimRecycle = 0b011; ///< 3
const uint8_t kEcoclimFan = 0b100; ///< 4
const uint8_t kEcoclimHeat = 0b101; ///< 5
const uint8_t kEcoclimSleep = 0b111; ///< 7
// Fan Control
const uint8_t kEcoclimFanMin = 0b00; ///< 0
const uint8_t kEcoclimFanMed = 0b01; ///< 1
const uint8_t kEcoclimFanMax = 0b10; ///< 2
const uint8_t kEcoclimFanAuto = 0b11; ///< 3
// DIP settings
const uint8_t kEcoclimDipMaster = 0b0000;
const uint8_t kEcoclimDipSlave = 0b0111;
// Temperature
const uint8_t kEcoclimTempMin = 5; // Celsius
const uint8_t kEcoclimTempMax = kEcoclimTempMin + 31; // Celsius
// Timer
const uint16_t kEcoclimTimerDisable = 0x1F * 60 + 7 * 10; // 4774
// Power: Off, Mode: Auto, Temp: 11C, Sensor: 22C, Fan: Auto, Clock: 00:00
const uint64_t kEcoclimDefaultState = 0x11063000FFFF02;
/// Native representation of a Ecoclim A/C message.
union EcoclimProtocol {
uint64_t raw; ///< The state in IR code form.
struct { // Only 56 bits (7 bytes are used.
// Byte
uint64_t :3; ///< Fixed 0b010
uint64_t :1; ///< Unknown
uint64_t DipConfig :4; ///< 0b0000 = Master, 0b0111 = Slave
// Byte
uint64_t OffTenMins :3; ///< Off Timer minutes (in tens of mins)
uint64_t OffHours :5; ///< Off Timer nr of Hours
// Byte
uint64_t OnTenMins :3; ///< On Timer minutes (in tens of mins)
uint64_t OnHours :5; ///< On Timer nr of Hours
// Byte+Byte
uint64_t Clock :11;
uint64_t :1; ///< Unknown
uint64_t Fan :2; ///< Fan Speed
uint64_t Power :1; ///< Power control
uint64_t Clear :1; // Not sure what this is
// Byte
uint64_t Temp :5; ///< Desired Temperature (Celsius)
uint64_t Mode :3; ///< Operating Mode
// Byte
uint64_t SensorTemp :5; ///< Sensed Temperature (Celsius)
uint64_t :3; ///< Fixed
};
};
// Classes
/// Class for handling detailed EcoClim A/C 56 bit messages.
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/1397
class IREcoclimAc {
public:
explicit IREcoclimAc(const uint16_t pin, const bool inverted = false,
const bool use_modulation = true);
void stateReset(void);
#if SEND_ECOCLIM
void send(const uint16_t repeat = kNoRepeat);
/// Run the calibration to calculate uSec timing offsets for this platform.
/// @return The uSec timing offset needed per modulation of the IR Led.
/// @note This will produce a 65ms IR signal pulse at 38kHz.
/// Only ever needs to be run once per object instantiation, if at all.
int8_t calibrate(void) { return _irsend.calibrate(); }
#endif // SEND_ECOCLIM
void begin(void);
void on(void);
void off(void);
void setPower(const bool on);
bool getPower(void) const;
void setTemp(const uint8_t celsius);
uint8_t getTemp(void) const;
void setSensorTemp(const uint8_t celsius);
uint8_t getSensorTemp(void) const;
void setFan(const uint8_t speed);
uint8_t getFan(void) const;
void setMode(const uint8_t mode);
uint8_t getMode(void) const;
void setClock(const uint16_t nr_of_mins);
uint16_t getClock(void) const;
uint64_t getRaw(void) const;
void setRaw(const uint64_t new_code);
void setType(const uint8_t code);
uint8_t getType(void) const;
static uint8_t convertMode(const stdAc::opmode_t mode);
static uint8_t convertFan(const stdAc::fanspeed_t speed);
static stdAc::opmode_t toCommonMode(const uint8_t mode);
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
stdAc::state_t toCommon(void) const;
void setOnTimer(const uint16_t nr_of_mins);
uint16_t getOnTimer(void) const;
bool isOnTimerEnabled(void) const;
void disableOnTimer(void);
void setOffTimer(const uint16_t nr_of_mins);
uint16_t getOffTimer(void) const;
bool isOffTimerEnabled(void) const;
void disableOffTimer(void);
String toString(void) const;
#ifndef UNIT_TEST
private:
IRsend _irsend; ///< Instance of the IR send class
#else // UNIT_TEST
/// @cond IGNORE
IRsendTest _irsend; ///< Instance of the testing IR send class
/// @endcond
#endif // UNIT_TEST
EcoclimProtocol _; ///< The state of the IR remote in IR code form.
};
#endif // IR_ECOCLIM_H_
| 34.230769 | 77 | 0.688049 |
31d703df983b10d00cc1b8741a6cf4da30da404c | 557 | h | C | sourcecode/iOS/dConnectDevicePlugin/dConnectDeviceHost/dConnectDeviceHost/Classes/profile/DPHostMediaStreamRecording/DPHostMediaStreamRecordingProfile.h | nokok/DeviceConnect | fa93a692f3ad231f869304b02a17e96326205eb0 | [
"MIT"
] | 1 | 2015-11-08T09:17:26.000Z | 2015-11-08T09:17:26.000Z | sourcecode/iOS/dConnectDevicePlugin/dConnectDeviceHost/dConnectDeviceHost/Classes/profile/DPHostMediaStreamRecording/DPHostMediaStreamRecordingProfile.h | nokok/DeviceConnect | fa93a692f3ad231f869304b02a17e96326205eb0 | [
"MIT"
] | null | null | null | sourcecode/iOS/dConnectDevicePlugin/dConnectDeviceHost/dConnectDeviceHost/Classes/profile/DPHostMediaStreamRecording/DPHostMediaStreamRecordingProfile.h | nokok/DeviceConnect | fa93a692f3ad231f869304b02a17e96326205eb0 | [
"MIT"
] | null | null | null | //
// DPHostMediaStreamRecordingProfile.h
// DConnectSDK
//
// Copyright (c) 2014 NTT DOCOMO, INC.
// Released under the MIT license
// http://opensource.org/licenses/mit-license.php
//
#import <AVFoundation/AVFoundation.h>
#import <DConnectSDK/DConnectSDK.h>
@interface DPHostMediaStreamRecordingProfile : DConnectMediaStreamRecordingProfile<DConnectMediaStreamRecordingProfileDelegate, AVCaptureAudioDataOutputSampleBufferDelegate, AVCaptureVideoDataOutputSampleBufferDelegate>
/// @brief イベントマネージャ
@property DConnectEventManager *eventMgr;
@end
| 29.315789 | 219 | 0.818671 |
0c786027fc5188e0a4f17e80538dd0ef1e33fc25 | 2,225 | c | C | c12/ex01(ft_list_push_front)/ft_list_push_front.c | ShadowOfBeing/COMPLETED_PISCINE_C | 5e518b135a694ffb850a8bf0af9a7c3637584b3a | [
"MIT"
] | 180 | 2020-12-26T19:36:48.000Z | 2022-03-31T02:49:42.000Z | c12/ex01(ft_list_push_front)/ft_list_push_front.c | HALIP192/COMPLETED_PISCINE_C | c4b9be847e55bb9611ef78b8a9a2acfcf3c828f3 | [
"MIT"
] | 5 | 2021-01-23T11:59:02.000Z | 2022-03-20T16:36:56.000Z | c12/ex01(ft_list_push_front)/ft_list_push_front.c | HALIP192/COMPLETED_PISCINE_C | c4b9be847e55bb9611ef78b8a9a2acfcf3c828f3 | [
"MIT"
] | 83 | 2021-01-19T01:18:58.000Z | 2022-03-20T20:48:39.000Z | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_list_push_front.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: evgenkarlson <RTFM@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 12:33:14 by evgenkarlson #+# #+# */
/* Updated: 2021/02/16 23:40:50 by evgenkarlson ### ########.fr */
/* */
/* ************************************************************************** */
/* ************************************************************************** */
/* ************************************************************************** *
**
** Каталог сдачи задания: ex01/
** Файлы для сдачи: ft_list_push_front.c, ft_list.h
** Разрешенные функции: ft_create_elem
**
** ************************************************************************** **
**
**
** • Создайте функцию "ft_list_push_front", которая добавляет новый элемент
** типа "t_list" в начало списка.
**
**
** • Он должен присваивать 'data' данному аргументу.
**
**
** • При необходимости он обновит указатель в начале списка.
**
**
** • Вот как эта функция должна быть объявлена :
**
** void ft_list_push_front(t_list **begin_list, void *data);
**
**
** ************************************************************************** */
/* ************************************************************************** */
#include "ft_list.h"
void ft_list_push_front(t_list **begin_list, void *data)
{
t_list *list;
if (*begin_list)
{
list = ft_create_elem(data);
list->next = *begin_list;
*begin_list = list;
}
else
*begin_list = ft_create_elem(data);
}
/* ************************************************************************** */
/* ************************************************************************** */
| 35.887097 | 80 | 0.282247 |
6b074f84af5b65a483d7bdfd4adb9dfde13a39ab | 552 | h | C | iOS/Hummer/Classes/Core/EventTrack/UIView+HMEventTrack.h | jiangkang/Hummer | f3acf523e3e8c6727b4884450317bdd8d482f563 | [
"Apache-2.0"
] | 825 | 2020-12-02T03:40:09.000Z | 2022-03-31T15:25:25.000Z | iOS/Hummer/Classes/Core/EventTrack/UIView+HMEventTrack.h | jiangkang/Hummer | f3acf523e3e8c6727b4884450317bdd8d482f563 | [
"Apache-2.0"
] | 140 | 2020-12-09T10:01:16.000Z | 2022-03-23T08:18:02.000Z | iOS/Hummer/Classes/Core/EventTrack/UIView+HMEventTrack.h | jiangkang/Hummer | f3acf523e3e8c6727b4884450317bdd8d482f563 | [
"Apache-2.0"
] | 119 | 2020-12-03T03:02:34.000Z | 2022-03-31T07:47:28.000Z | //
// UIView+HMEventTrack.h
// AFDownloadRequestOperation
//
// Created by didi on 2020/8/13.
//
#import <UIKit/UIKit.h>
#import "HMEventTrackViewProperty.h"
NS_ASSUME_NONNULL_BEGIN
@interface UIView (HMEventTrack)<HMEventTrackViewProperty>
@end
@interface UIButton (HMEventTrack)<HMEventTrackViewProperty>
@end
@interface UILabel (HMEventTrack)<HMEventTrackViewProperty>
@end
@interface UIImageView (HMEventTrack)<HMEventTrackViewProperty>
@end
@interface UIControl (HMEventTrack)<HMEventTrackViewProperty>
@end
NS_ASSUME_NONNULL_END
| 15.771429 | 63 | 0.797101 |
7347c0486a719d1f1d04232e0e458d8c6bf49e6c | 457 | c | C | 001/demo.c | jiejieTop/libuv-learning-code | 25ca84eb49c7c7a55ebbeaec43c33c4b0d196fc1 | [
"Apache-2.0"
] | 21 | 2020-04-24T02:24:17.000Z | 2022-03-18T02:21:37.000Z | 001/demo.c | jiejieTop/libuv-learning-code | 25ca84eb49c7c7a55ebbeaec43c33c4b0d196fc1 | [
"Apache-2.0"
] | null | null | null | 001/demo.c | jiejieTop/libuv-learning-code | 25ca84eb49c7c7a55ebbeaec43c33c4b0d196fc1 | [
"Apache-2.0"
] | 12 | 2020-04-30T05:55:41.000Z | 2021-11-03T19:06:06.000Z | /*
* @Author: jiejie
* @Github: https://github.com/jiejieTop
* @Date: 2020-04-17 14:59:21
* @LastEditTime: 2020-04-17 17:16:02
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
*/
#include <stdio.h>
#include <stdlib.h>
#include <uv.h>
int main()
{
char *version;
version = (char*) uv_version_string();
printf("libuv version is %s\n", version);
return 0;
} | 21.761905 | 121 | 0.658643 |
71991744f7e60683f4e240b813a519e0fe7c8c3f | 5,946 | c | C | source/menu.c | mgba-emu/multi2l | 88ff3fa0236cd151da108144db512b7248c95ffe | [
"BSD-2-Clause"
] | 6 | 2017-12-18T09:43:09.000Z | 2021-04-23T12:13:28.000Z | source/menu.c | mgba-emu/multi2l | 88ff3fa0236cd151da108144db512b7248c95ffe | [
"BSD-2-Clause"
] | 1 | 2018-05-19T20:12:06.000Z | 2018-05-19T20:12:06.000Z | source/menu.c | mgba-emu/multi2l | 88ff3fa0236cd151da108144db512b7248c95ffe | [
"BSD-2-Clause"
] | null | null | null | #include <nds.h>
#include <math.h>
#include "fifo3d.h"
#include "menu.h"
#include "text.h"
#include "tween.h"
#define MAX_MENUS 32
#define MAX_EDITOR_ENTRIES 32
struct Menu {
bool isEditor;
union {
const struct MenuEntry* entries;
struct {
const struct EditorEntry* editor;
size_t editorValues[MAX_EDITOR_ENTRIES];
};
};
size_t nEntries;
int active;
int oldActive;
};
static struct Menu _menus[MAX_MENUS];
static int _maxMenu = 0;
static int _activeMenu = 0;
static int _menuStack[MAX_MENUS];
static int _menuStackPointer = 0;
static struct Tween _menuTween = {
.x = -1,
.type = TWEEN_LOGISTIC
};
static struct Tween _oldMenuTween = {
.x = -1,
.type = TWEEN_LOGISTIC
};
extern int frame;
int registerMenu(const struct MenuEntry* entries, size_t nEntries) {
if (_maxMenu >= MAX_MENUS) {
return -1;
}
_menus[_maxMenu].isEditor = false;
_menus[_maxMenu].entries = entries;
_menus[_maxMenu].nEntries = nEntries;
_menus[_maxMenu].active = 0;
_menus[_maxMenu].oldActive = 0;
return _maxMenu++;
}
int registerEditor(const struct EditorEntry* entries, size_t nEntries) {
if (_maxMenu >= MAX_MENUS) {
return -1;
}
_menus[_maxMenu].isEditor = true;
_menus[_maxMenu].editor = entries;
_menus[_maxMenu].nEntries = nEntries;
_menus[_maxMenu].active = 0;
_menus[_maxMenu].oldActive = 0;
size_t i;
for (i = 0; i < nEntries; ++i) {
if (!entries[i].nChoices) {
continue;
}
_menus[_maxMenu].active = i;
_menus[_maxMenu].oldActive = i;
break;
}
memset(_menus[_maxMenu].editorValues, 0, nEntries * sizeof(*_menus[_maxMenu].editorValues));
return _maxMenu++;
}
void setMenu(int menuid) {
_activeMenu = menuid;
if (_menuTween.x < 0) {
_menuTween.x = 0;
_menuTween.y0 = 10;
_menuTween.y1 = 10;
addTween(&_menuTween);
}
if (_oldMenuTween.x < 0) {
_oldMenuTween.x = 0;
_oldMenuTween.y0 = 10;
_oldMenuTween.y1 = 10;
addTween(&_oldMenuTween);
}
}
void pushMenu(int menuid) {
if (_menuStackPointer >= MAX_MENUS) {
return;
}
_menuStack[_menuStackPointer] = _activeMenu;
++_menuStackPointer;
setMenu(menuid);
}
void popMenu(void) {
if (_menuStackPointer > 0) {
--_menuStackPointer;
}
setMenu(_menuStack[_menuStackPointer]);
}
void setEditorValue(int editor, int entry, size_t value) {
if (editor >= MAX_MENUS) {
return;
}
struct Menu* menu = &_menus[editor];
if (!menu->isEditor) {
return;
}
if (entry >= menu->nEntries) {
return;
}
if (value >= menu->editor[entry].nChoices) {
return;
}
menu->editorValues[entry] = value;
}
size_t getEditorValue(int editor, int entry) {
if (editor >= MAX_MENUS) {
return 0;
}
const struct Menu* menu = &_menus[editor];
if (!menu->isEditor) {
return 0;
}
if (entry >= menu->nEntries) {
return 0;
}
return menu->editorValues[entry];
}
void renderMenu(void) {
const struct Menu* menu = &_menus[_activeMenu];
int bounce = (frame & 0x3F) - 0x20;
bounce *= bounce;
bounce = (0x400 - bounce) >> 5;
size_t i;
if (menu->isEditor) {
int x = 20;
for (i = 0; i < menu->nEntries; ++i) {
int bright = 0;
int y = 170;
if (menu->active == i) {
bright = (bright + bounce) >> 1;
}
const char* text = menu->editor[i].placeholder;
if (menu->editor[i].choices) {
text = menu->editor[i].choices[menu->editorValues[i]];
}
render3DText(text, x, y, bright * 0x421);
x += strlen(text) * 8;
}
} else {
int y = 170;
for (i = 0; i < menu->nEntries; ++i) {
int bright = !menu->entries[i].enabled * 0x12;
int x = 20;
if (menu->active == i) {
bright = (bright + bounce) >> 1;
x += _menuTween.y;
} else if (menu->oldActive == i) {
x += _oldMenuTween.y;
}
render3DText(menu->entries[i].text, x, y, bright * 0x421);
y -= 10;
}
}
}
void cursorMove(enum CursorDirection dir) {
struct Menu* menu = &_menus[_activeMenu];
int new = menu->active;
if (menu->isEditor) {
const struct EditorEntry* editor = &menu->editor[new];
switch (dir) {
case CUR_UP:
menu->editorValues[new] = (menu->editorValues[new] + 1) % editor->nChoices;
break;
case CUR_DOWN:
menu->editorValues[new] = (editor->nChoices + menu->editorValues[new] - 1) % editor->nChoices;
break;
case CUR_LEFT:
do {
new = (menu->nEntries + new - 1) % menu->nEntries;
} while (!menu->editor[new].nChoices);
break;
case CUR_RIGHT:
do {
new = (new + 1) % menu->nEntries;
} while (!menu->editor[new].nChoices);
break;
}
} else {
switch (dir) {
case CUR_UP:
new = (menu->nEntries + menu->active - 1) % menu->nEntries;
break;
case CUR_DOWN:
new = (menu->active + 1) % menu->nEntries;
break;
case CUR_LEFT:
new = 0;
break;
case CUR_RIGHT:
new = menu->nEntries - 1;
break;
}
}
if (new == menu->active) {
return;
}
_oldMenuTween.y0 = _menuTween.y;
_oldMenuTween.y1 = 0;
_oldMenuTween.x0 = frame;
_oldMenuTween.x1 = frame + 8;
_menuTween.y0 = 0;
_menuTween.y1 = 10;
_menuTween.x0 = frame + 4;
_menuTween.x1 = frame + 12;
menu->oldActive = menu->active;
menu->active = new;
}
void menuActivate(void) {
const struct Menu* menu = &_menus[_activeMenu];
if (menu->isEditor) {
popMenu();
size_t i;
for (i = 0; i < menu->nEntries; ++i) {
const struct EditorEntry* entry = &menu->editor[i];
if (!entry->fn) {
continue;
}
entry->fn(menu->editorValues[i], entry->context);
}
} else {
const struct MenuEntry* entry = &menu->entries[menu->active];
if (!entry->enabled) {
return;
}
if (entry->submenu == MENU_BACK) {
popMenu();
} else if (entry->submenu >= 0) {
pushMenu(entry->submenu);
}
if (entry->fn) {
entry->fn(entry->context);
}
}
}
void menuBack(void) {
const struct Menu* menu = &_menus[_activeMenu];
if (!menu->isEditor) {
size_t i;
for (i = 0; i < menu->nEntries; ++i) {
const struct MenuEntry* entry = &menu->entries[i];
if (entry->submenu == MENU_BACK && entry->fn) {
entry->fn(entry->context);
}
}
}
popMenu();
}
| 21.235714 | 97 | 0.637571 |
34b13b1e6b95b802d7327ab8caf05e09d778c608 | 2,510 | c | C | libsrc/common/getopt.c | C-Chads/cc65 | 52e43879298c2fb30c7bc6fd95fae3b3f1458793 | [
"Zlib"
] | 1,673 | 2015-01-01T23:03:31.000Z | 2022-03-30T21:49:03.000Z | libsrc/common/getopt.c | Fabrizio-Caruso/cc65 | 84dba7f6ae43e8e93ed1601e1d565e97503cd0b2 | [
"Zlib"
] | 1,307 | 2015-01-06T09:32:26.000Z | 2022-03-31T19:57:16.000Z | libsrc/common/getopt.c | Fabrizio-Caruso/cc65 | 84dba7f6ae43e8e93ed1601e1d565e97503cd0b2 | [
"Zlib"
] | 423 | 2015-01-01T19:11:31.000Z | 2022-03-30T14:36:00.000Z | /*
** This is part of a changed public domain getopt implementation that
** had the following text on top:
**
** I got this off net.sources from Henry Spencer.
** It is a public domain getopt(3) like in System V.
** I have made the following modifications:
**
** A test main program was added, ifdeffed by GETOPT.
** This main program is a public domain implementation
** of the getopt(1) program like in System V. The getopt
** program can be used to standardize shell option handling.
** e.g. cc -DGETOPT getopt.c -o getopt
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define ARGCH ':'
#define BADCH '?'
#define EMSG ""
int opterr = 1; /* useless, never set or used */
int optind = 1; /* index into parent argv vector */
int optopt; /* character checked for validity */
char *optarg; /* argument associated with option */
#define tell(s) fputs(*argv,stderr);fputs(s,stderr); \
fputc(optopt,stderr);fputc('\n',stderr);return(BADCH);
int __fastcall__ getopt (int argc, char* const* argv, const char* optstring)
/* Get option letter from argument vector */
{
static char *place = EMSG; /* option letter processing */
register char *oli; /* option letter list index */
if (!*place) { /* update scanning pointer */
if (optind >= argc || *(place = argv[optind]) != '-' || !*++place) {
return (EOF);
}
if (*place == '-') {
/* found "--" */
++optind;
return (EOF);
}
}
/* option letter okay? */
if ((optopt = (int) *place++) == ARGCH ||
!(oli = strchr (optstring, optopt))) {
if (!*place) {
++optind;
}
tell (": illegal option -- ");
}
if (*++oli != ARGCH) {
/* don't need argument */
optarg = NULL;
if (!*place) {
++optind;
}
} else {
/* need an argument */
if (*place) {
/* no white space */
optarg = place;
}
else if (argc <= ++optind) { /* no arg */
place = EMSG;
tell (": option requires an argument -- ");
} else {
/* white space */
optarg = argv[optind];
}
place = EMSG;
++optind;
}
return (optopt); /* dump back option letter */
}
| 29.529412 | 76 | 0.509562 |
4298417a003e2d1ed260c9e1684a238227803dea | 20,245 | c | C | sdk/sdk/driver/sd/sd/common.c | doyaGu/C0501Q_HWJL01 | 07a71328bd9038453cbb1cf9c276a3dd1e416d63 | [
"MIT"
] | 1 | 2021-10-09T08:05:50.000Z | 2021-10-09T08:05:50.000Z | sdk/sdk/driver/sd/sd/common.c | doyaGu/C0501Q_HWJL01 | 07a71328bd9038453cbb1cf9c276a3dd1e416d63 | [
"MIT"
] | null | null | null | sdk/sdk/driver/sd/sd/common.c | doyaGu/C0501Q_HWJL01 | 07a71328bd9038453cbb1cf9c276a3dd1e416d63 | [
"MIT"
] | null | null | null | /*
* Copyright (c) 2007 SMedia Corp. All Rights Reserved.
*/
/** @file
* SD/MMC common function.
*
* @author Irene Lin
*/
//=============================================================================
// Include Files
//=============================================================================
#include "config.h"
#include "sd_hw.h"
#include "sd.h"
#if defined (__OPENRTOS__)
#include "ite/ith.h"
#endif
//=============================================================================
// Constant Definition
//=============================================================================
//=============================================================================
// Macro
//=============================================================================
//=============================================================================
// Global Data Definition
//=============================================================================
extern uint8_t sdResp[17];
//=============================================================================
// Private Function Definition
//=============================================================================
static inline void SD_DumpCID(SD_CTXT* ctxt)
{
SD_ReadResponseReg(0xFFFF);
memcpy((void*)ctxt->cid, (void*)sdResp, sizeof(ctxt->cid));
#if defined(SD_DUMP_CID)
{
uint8_t tmp8 = 0;
uint16_t tmp16 = 0;
LOG_DATA " CID Register: \n" LOG_END
LOG_DATA " D[7:1] CRC7 checksum : 0x%02X \n", (sdResp[0]>>1) LOG_END
if(ctxt->flags & SD_FLAGS_CARD_SD)
{
tmp8 = sdResp[1] & 0x0F;
tmp16 = (((sdResp[2]&0xF) << 4) | ((sdResp[1]&0xF0) >> 4)) + 2000;
LOG_DATA " D[19:8] Manufacturing date : %d-%d \n", tmp16, tmp8 LOG_END
LOG_DATA " D[55:24] Product serial number: %02X%02X%02X%02X \n", sdResp[6], sdResp[5], sdResp[4], sdResp[3] LOG_END
LOG_DATA " D[63:56] Product revision : %01X.%01X \n", ((sdResp[7]&0xF0)>>4), (sdResp[7]&0x0F) LOG_END
LOG_DATA " D[103:64] Product name : %c%c%c%c%c \n", sdResp[12], sdResp[11], sdResp[10], sdResp[9], sdResp[8] LOG_END
}
else
{
LOG_DATA " D[15:8] Manufacturing date : %d-%d \n", (1997+(sdResp[1]&0xF)), ((sdResp[1]&0xF0)>>4) LOG_END
LOG_DATA " D[55:24] Product serial number: %02X%02X%02X%02X \n", sdResp[5], sdResp[4], sdResp[3], sdResp[2] LOG_END
LOG_DATA " D[63:56] Product revision : %01X.%01X \n", ((sdResp[6]&0xF0)>>4), (sdResp[6]&0x0F) LOG_END
LOG_DATA " D[103:64] Product name : %c%c%c%c%c%c \n", sdResp[12], sdResp[11], sdResp[10], sdResp[9], sdResp[8], sdResp[7] LOG_END
}
LOG_DATA " D[119:104] OEM/Application ID : %c%c \n", sdResp[14], sdResp[13] LOG_END
LOG_DATA " D[127:120] Manufacturer ID : %02X \n", sdResp[15] LOG_END
}
#endif
}
//=============================================================================
// Public Function Definition
//=============================================================================
//=============================================================================
/**
* SD/MMC start up function.
*
* Step 1: Go into Ready State
* Step 2: Go into Identification State.
* Step 3: Go into Stand-by State.
*/
//=============================================================================
int SDMMC_StartUp(SD_CTXT* ctxt)
{
int result = 0;
uint8_t retry = 3;
uint32_t lastTick;
ctxt->cardBusWidth = 1;
//============================
// CMD 0: Go Idle State
//============================
#if 1//!defined(SD_HW_POWER_RESET) /** FPGA need this command to replace power reset for card reset */
result = SD_SendCmdReg(ctxt, COM_BC_GO_IDLE_STATE, 0, 0, 0, 0, (SD_RESP_TYPE_NON|SD_CMD_NO_DATA));
if(result)
{
result = ERROR_SD_GO_IDLE_STATE_FAIL;
goto end;
}
#endif
//============================
// Go into Ready State.
//
// MMC: Send CMD1
// SD : Send ACMD41
//============================
while(1)
{
if(SD_SendCmdReg(ctxt, SD_AC_APP_CMD, 0, 0, 0, 0, (SD_RESP_TYPE_48|SD_CMD_NO_DATA)))
{
retry--;
if(retry)
continue;
LOG_INFO " MMC Start Up! \n" LOG_END
result = MMC_StartUp(ctxt);
if(result)
goto end;
break;
}
else
{
#if 1
result = SD_SendCmdReg(ctxt, COM_BC_GO_IDLE_STATE, 0, 0, 0, 0, (SD_RESP_TYPE_NON|SD_CMD_NO_DATA));
if(result)
{
result = ERROR_SD_GO_IDLE_STATE_FAIL;
goto end;
}
#endif
LOG_INFO " SD Start Up! \n" LOG_END
result = SD_StartUp(ctxt);
if(result)
goto end;
break;
}
}
lastTick = itpGetTickCount();
do
{
//============================
// Go into Identification State.
// Send CMD2 to get CID.
//============================
if(itpGetTickDuration(lastTick) > 1000) /** MMC may send multiple times */
{
result = ERROR_MMC_SEND_CMD2_TIMEOUT;
goto end;
}
if(!SD_IsCardInserted(ctxt->index))
{
result = ERROR_SD_NO_CARD_INSERTED;
goto end;
}
if(SD_SendCmdReg(ctxt, COM_BCR_ALL_SEND_CID, 0, 0, 0, 0, (SD_RESP_TYPE_136|SD_CMD_NO_DATA)))
continue;
SD_DumpCID(ctxt);
//============================
// Go into Stand-by State.
// Send CMD3 to get/set RCA.
//============================
if(ctxt->flags & SD_FLAGS_CARD_SD)
{
result = SD_GetRca(ctxt);
if(result)
goto end;
}
else if(ctxt->flags & SD_FLAGS_CARD_MMC)
{
result = MMC_SetRca(ctxt);
if(result)
goto end;
}
break;
} while(1);
end:
if(result)
LOG_ERROR " SDMMC_StartUp() return error code 0x%08X \n", result LOG_END
return result;
}
//=============================================================================
/**
* SD/MMC Get Capacity function.
*
* Send CMD9 to get CSD register.
*/
//=============================================================================
int SDMMC_GetCapacity(SD_CTXT* ctxt)
{
int result = 0;
uint8_t retry = 3;
while(SD_SendCmdReg(ctxt, COM_AC_SEND_CSD, ctxt->rcaByte3, ctxt->rcaByte2, 0, 0, (SD_RESP_TYPE_136|SD_CMD_NO_DATA)))
{
retry--;
if(!retry)
{
result = ERROR_SD_SEND_CSD_FAIL;
goto end;
}
}
SD_ReadResponseReg(0xFFFF);
#if defined(SD_DUMP_CSD)
{
uint32_t i;
LOG_DATA " CSD:" LOG_END
for(i=0; i<16; i++)
LOG_DATA " %02X", sdResp[i] LOG_END
LOG_DATA " \n" LOG_END
}
#endif
if( (ctxt->flags & SD_FLAGS_CARD_SD) && /** SD card */
(sdResp[15] & 0xC0) && /** CSD V2.0 */
((sdResp[8] & 0x2F)==0) ) /** The max. capacity of the Physical Layer Spec. V2.0 is 32GB. */
{
uint32_t c_size = 0;
c_size = (sdResp[6] |
(sdResp[7] << 8) |
((sdResp[8]&0x3F) << 16));
ctxt->totalSectors = (c_size+1)*1024;
if(c_size >= 0xFFFF)
LOG_DATA " SDXC Card! \n" LOG_END
LOG_INFO " SD with CSD V2.0 \n" LOG_END
LOG_INFO " TAAC = 0x%02X, NSAC = 0x%02X, TRAN_SPEED = 0x%02X \n", sdResp[15], sdResp[14], sdResp[13] LOG_END
}
else /** CSD V1.0 or MMC */
{
uint16_t c_size=0, c_size_mult=0, mult=0, block_len=0, i;
c_size = (uint16_t)(((sdResp[7] & 0xC0) >> 6) |
(sdResp[8] << 2) |
((sdResp[9] & 0x03) << 10));
c_size_mult = (uint16_t)(((sdResp[5] & 0x80) >> 7) |
((sdResp[6] & 0x03) << 1));
mult = 1;
for(i=0; i<(c_size_mult+2); i++)
mult <<= 1;
block_len = 1;
for(i=0; i<(sdResp[10]&0x0F); i++)
block_len <<= 1;
block_len /= SD_SECTOR_SIZE; /** secotr unit: 512 bytes */
ctxt->totalSectors = (uint32_t)((c_size+1) * mult * block_len);
LOG_INFO " CSD V1.0 or MMC \n" LOG_END
LOG_INFO " TAAC = 0x%02X, NSAC = 0x%02X, TRAN_SPEED = 0x%02X \n", sdResp[14], sdResp[13], sdResp[12] LOG_END
}
LOG_INFO " Total secotor number = 0x%08X \n", ctxt->totalSectors LOG_END
if( (ctxt->flags & SD_FLAGS_CARD_MMC) && /** MMC card */
((sdResp[15] & 0x3C) >= 0x10) ) /** >= MMC V4.0 */
{
ctxt->flags |= SD_FLAGS_CARD_MMC4;
}
end:
if(result)
LOG_ERROR " SDMMC_GetCapacity() return error code 0x%08X \n", result LOG_END
return result;
}
//=============================================================================
/**
* Put SD/MMC card into Transfer State.
*
* Send CMD7
*/
//=============================================================================
int SDMMC_TransferState(SD_CTXT* ctxt)
{
int result = 0;
result = SD_SendCmdReg(ctxt, COM_AC_SELECT_DESELECT_CARD, ctxt->rcaByte3, ctxt->rcaByte2, 0, 0, (SD_RESP_TYPE_48_BUSY|SD_CMD_NO_DATA));
if(result)
{
result = ERROR_SD_SEND_CMD7_FAIL;
goto end;
}
SD_ReadResponseReg(0x4);
if( ((sdResp[2] & 0x1E) >> 1) != 3 )
{
result = ERROR_SD_PUT_INTO_TRANSFER_STATE_FAIL;
goto end;
}
end:
if(result)
LOG_ERROR " SDMMC_TransferState() return error code 0x%08X \n", result LOG_END
return result;
}
//=============================================================================
/**
* Set SD/MMC bus width.
*/
//=============================================================================
int SDMMC_Switch(SD_CTXT* ctxt)
{
int result = 0;
if(ctxt->flags & SD_FLAGS_CARD_MMC)
{
result = MMC_Switch(ctxt);
if(result)
goto end;
}
else
{
result = SD_Switch(ctxt);
if(result)
goto end;
}
/** Set sector size */
result = SD_SendCmdReg(ctxt, COM_AC_SET_BLOCK_LEN, 0, 0, 0x02, 0, (SD_RESP_TYPE_48|SD_CMD_NO_DATA));
if(result)
goto end;
SD_SetSectorLengthReg(SD_SECTOR_SIZE);
end:
if(result)
LOG_ERROR " SDMMC_Switch() return error code 0x%08X \n", result LOG_END
return result;
}
//=============================================================================
/**
* Programing DMA engine for SD read.
*
* @param data the destination system memory address
* @param size the total transfer size
*/
//=============================================================================
void SDMMC_DmaRead(SD_CTXT* ctxt, uint8_t* data, uint32_t size)
{
ithDmaSetSrcAddr(ctxt->dmaCh, SD_AHB_DATA_PORT);
ithDmaSetDstAddr(ctxt->dmaCh, (uint32_t)data);
ithDmaSetRequest(ctxt->dmaCh, ITH_DMA_HW_HANDSHAKE_MODE, ITH_DMA_HW_SD, ITH_DMA_NORMAL_MODE, ITH_DMA_MEM);
ithDmaSetSrcParams(ctxt->dmaCh, ITH_DMA_WIDTH_32, ITH_DMA_CTRL_FIX, ITH_DMA_MASTER_1);
ithDmaSetDstParams(ctxt->dmaCh, dmaWidthMap[((uint32_t)data)&0x3], ITH_DMA_CTRL_INC, ITH_DMA_MASTER_0);
ithDmaSetTxSize(ctxt->dmaCh, size);
ithDmaStart(ctxt->dmaCh);
}
//=============================================================================
/**
* Programing DMA engine for SD write.
*
* @param data the source system memory address
* @param size the total transfer size
*/
//=============================================================================
void SDMMC_DmaWrite(SD_CTXT* ctxt, uint8_t* data, uint32_t size)
{
ithDmaSetSrcAddr(ctxt->dmaCh, (uint32_t)data);
ithDmaSetDstAddr(ctxt->dmaCh, SD_AHB_DATA_PORT);
ithDmaSetRequest(ctxt->dmaCh, ITH_DMA_NORMAL_MODE, ITH_DMA_MEM, ITH_DMA_HW_HANDSHAKE_MODE, ITH_DMA_HW_SD);
ithDmaSetSrcParams(ctxt->dmaCh, dmaWidthMap[((uint32_t)data)&0x3], ITH_DMA_CTRL_INC, ITH_DMA_MASTER_0);
ithDmaSetDstParams(ctxt->dmaCh, ITH_DMA_WIDTH_32, ITH_DMA_CTRL_FIX, ITH_DMA_MASTER_1);
ithDmaSetTxSize(ctxt->dmaCh, size);
ithDmaStart(ctxt->dmaCh);
}
//=============================================================================
/**
* Read data from card. From host controller's register by CPU. (without DMA)
*
* @param data the destination system memory address
* @param size the total size to be read
*/
//=============================================================================
int SDMMC_ReadData(SD_CTXT* ctxt, uint8_t* data, uint32_t totalSize)
{
int result = 0;
uint32_t i,j;
uint32_t tmpData = 0;
uint32_t fifoSizeInbyte = SD_FIFO_DEPTH * SD_FIFO_WIDTH;
if(totalSize % fifoSizeInbyte)
LOG_WARNING " FIFO size not match! \n" LOG_END
for(i=0; i<(totalSize/fifoSizeInbyte); i++)
{
result = SD_WaitFifoFullReg();
if(result)
goto end;
for(j=0; j<SD_FIFO_DEPTH; j++, data+=4)
{
tmpData = SD_ReadDataReg();
*(uint32_t*)data = cpu_to_le32(tmpData);
}
}
result = SD_WaitSendCmdReadyReg(ctxt);
if(result)
goto end;
result = SDW_WaitWrapReadyReg(ctxt);
if(result)
goto end;
end:
if(result)
LOG_ERROR " SDMMC_ReadData() return error code 0x%08X, i = %d \n", result, i LOG_END
return result;
}
//=============================================================================
/**
* Write data to card. Write to host controller's register by CPU. (without DMA)
*
* @param data the source system memory address
* @param size the total size to be write
*/
//=============================================================================
int SDMMC_WriteData(SD_CTXT* ctxt, uint8_t* data, uint32_t totalSize)
{
int result = 0;
uint32_t i,j;
uint32_t tmpData = 0;
uint32_t fifoSizeInbyte = SD_FIFO_DEPTH * SD_FIFO_WIDTH;
if(totalSize % fifoSizeInbyte)
LOG_WARNING " FIFO size not match! \n" LOG_END
for(i=0; i<(totalSize/fifoSizeInbyte); i++)
{
result = SD_WaitFifoEmptyReg();
if(result)
goto end;
for(j=0; j<SD_FIFO_DEPTH; j++, data+=4)
{
tmpData = (*(data+3) << 24 |
*(data+2) << 16 |
*(data+1) << 8 |
*(data));
SD_WriteDataReg(tmpData);
}
#if 0
if(ithReadRegA(SD_REG_STS1) & SD_MSK_CMD_RESP_TIMEOUT)
{
ithGpioSet(31);
ithPrintf(" command response timeout!!!!! \n");
}
#endif
}
result = SDW_WaitWrapReadyReg(ctxt);
if(result)
goto end;
result = SD_WaitSendCmdReadyReg(ctxt);
if(result)
goto end;
end:
if(result)
LOG_ERROR " SDMMC_WriteData() return error code 0x%08X \n", result LOG_END
return result;
}
//=============================================================================
/**
* SD/MMC read multi-sector process.
*
* @param sector start sector to be read
* @param count total sectors to be read
* @param data the buffer to receive data
*/
//=============================================================================
int
SDMMC_ReadMultiSector(SD_CTXT* ctxt, uint32_t sector, uint32_t count, void* data)
{
int result = 0;
//uint8_t command = (count == 1) ? COM_ADTC_READ_SINGLE_BLOCK : COM_ADTC_READ_MULTIPLE_BLOCK;
uint8_t command = COM_ADTC_READ_MULTIPLE_BLOCK;
/** Data address is in byte units in a Standard Capacity SD Memory Card. */
if(!(ctxt->flags & SD_FLAGS_CARD_SDHC) && !(ctxt->flags & SD_FLAGS_CARD_MMC_HC))
{
sector *= SD_SECTOR_SIZE;
}
SD_SetSectorCountReg(count);
if((ctxt->flags & SD_FLAGS_DMA_ENABLE) && (ctxt->dmaCh >= 0))
{
SDMMC_DmaRead(ctxt, data, SD_SECTOR_SIZE*count);
SDW_SetWrapCtrlReg(ctxt, SDW_DATA_IN, SDW_DMA); /** set smedia wrap control */
result = SD_SendCmdReg( ctxt, command,
(uint8_t)((sector & 0xFF000000) >> 24),
(uint8_t)((sector & 0x00FF0000) >> 16),
(uint8_t)((sector & 0x0000FF00) >> 8),
(uint8_t)((sector & 0x000000FF)),
(SD_RESP_TYPE_48|SD_CMD_DATA_IN|SD_MSK_AUTO_SWAP));
if(result)
goto end;
#if !defined(WIN32)
ithInvalidateDCacheRange(data, SD_SECTOR_SIZE*count);
#endif
}
else
{
SDW_SetWrapCtrlReg(ctxt, SDW_DATA_IN, SDW_NON_DMA); /** set smedia wrap control */
SD_SendCmdNoWaitReg(ctxt, command,
(uint8_t)((sector & 0xFF000000) >> 24),
(uint8_t)((sector & 0x00FF0000) >> 16),
(uint8_t)((sector & 0x0000FF00) >> 8),
(uint8_t)((sector & 0x000000FF)),
(SD_RESP_TYPE_48|SD_CMD_DATA_IN|SD_MSK_AUTO_SWAP));
result = SDMMC_ReadData(ctxt, data, SD_SECTOR_SIZE*count);
if(result)
goto end;
}
if(command == COM_ADTC_READ_MULTIPLE_BLOCK)
{
result = SD_SendCmdReg(ctxt, COM_AC_STOP_TRANSMISSION, 0, 0, 0, 0, (SD_RESP_TYPE_48_BUSY|SD_CMD_NO_DATA));
if(result)
goto end;
}
end:
if(result)
LOG_ERROR " SDMMC_ReadMultiSector() return error code 0x%08X \n", result LOG_END
return result;
}
//=============================================================================
/**
* SD/MMC write multi-sector process.
*
* @param sector start sector to be write
* @param count total sectors to be write
* @param data the buffer contain the data to be written
*/
//=============================================================================
int
SDMMC_WriteMultiSector(SD_CTXT* ctxt, uint32_t sector, uint32_t count, void* data)
{
int result = 0;
//uint8_t command = (count==1) ? COM_ADTC_WRITE_SINGLE_BLOCK : COM_ADTC_WRITE_MULTIPLE_BLOCK;
uint8_t command = COM_ADTC_WRITE_MULTIPLE_BLOCK;
if(!(ctxt->flags & SD_FLAGS_CARD_SDHC) & !(ctxt->flags & SD_FLAGS_CARD_MMC_HC))
{
sector *= SD_SECTOR_SIZE;
}
SD_SetSectorCountReg(count);
if((ctxt->flags & SD_FLAGS_DMA_ENABLE) && (ctxt->dmaCh >= 0))
{
SDMMC_DmaWrite(ctxt, data, SD_SECTOR_SIZE*count);
SDW_SetWrapCtrlReg(ctxt, SDW_DATA_OUT, SDW_DMA); /** set smedia wrap control */
result = SD_SendCmdReg( ctxt, command,
(uint8_t)((sector & 0xFF000000) >> 24),
(uint8_t)((sector & 0x00FF0000) >> 16),
(uint8_t)((sector & 0x0000FF00) >> 8),
(uint8_t)((sector & 0x000000FF)),
(SD_RESP_TYPE_48|SD_CMD_DATA_OUT|SD_MSK_AUTO_SWAP));
if(result)
goto end;
}
else
{
SDW_SetWrapCtrlReg(ctxt, SDW_DATA_OUT, SDW_NON_DMA); /** set smedia wrap control */
SD_SendCmdNoWaitReg(ctxt, command,
(uint8_t)((sector & 0xFF000000) >> 24),
(uint8_t)((sector & 0x00FF0000) >> 16),
(uint8_t)((sector & 0x0000FF00) >> 8),
(uint8_t)((sector & 0x000000FF)),
(SD_RESP_TYPE_48|SD_CMD_DATA_OUT|SD_MSK_AUTO_SWAP));
result = SDMMC_WriteData(ctxt, data, SD_SECTOR_SIZE*count);
if(result)
goto end;
}
if(command == COM_ADTC_WRITE_MULTIPLE_BLOCK)
{
result = SD_SendCmdReg(ctxt, COM_AC_STOP_TRANSMISSION, 0, 0, 0, 0, (SD_RESP_TYPE_48_BUSY|SD_CMD_NO_DATA));
if(result)
goto end;
}
end:
if(result)
LOG_ERROR " SDMMC_WriteMultiSector() return error code 0x%08X \n", result LOG_END
return result;
}
| 33.685524 | 150 | 0.486836 |
51e9a53c1edb65bd9e34978c20d97c5c01dab008 | 1,330 | h | C | PrivateFrameworks/PhotoPrintProduct/KHLayoutPickerCell.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 17 | 2018-11-13T04:02:58.000Z | 2022-01-20T09:27:13.000Z | PrivateFrameworks/PhotoPrintProduct/KHLayoutPickerCell.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 3 | 2018-04-06T02:02:27.000Z | 2018-10-02T01:12:10.000Z | PrivateFrameworks/PhotoPrintProduct/KHLayoutPickerCell.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 1 | 2018-09-28T13:54:23.000Z | 2018-09-28T13:54:23.000Z | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import <PhotoPrintProduct/KHPickerCell.h>
#import "KHLayoutThumbnailerDelegate.h"
@class KHLayout, KHTreatment, NSString, UXView;
@interface KHLayoutPickerCell : KHPickerCell <KHLayoutThumbnailerDelegate>
{
BOOL _leftFacing;
KHLayout *_layoutObject;
KHTreatment *_treatment;
UXView *_selectionView;
struct CGRect _thumbRect;
}
@property(retain) UXView *selectionView; // @synthesize selectionView=_selectionView;
@property struct CGRect thumbRect; // @synthesize thumbRect=_thumbRect;
@property BOOL leftFacing; // @synthesize leftFacing=_leftFacing;
@property(retain) KHTreatment *treatment; // @synthesize treatment=_treatment;
@property(retain, nonatomic) KHLayout *layoutObject; // @synthesize layoutObject=_layoutObject;
- (void).cxx_destruct;
- (BOOL)accessibilityPerformPress;
- (void)renderImage;
- (void)thumbnailerCompleted:(id)arg1;
- (void)layoutThumbnailerCompletedOnMain:(id)arg1;
- (void)_renderImage;
- (id)initWithLayout:(id)arg1;
// Remaining properties
@property(readonly, copy) NSString *debugDescription;
@property(readonly, copy) NSString *description;
@property(readonly) unsigned long long hash;
@property(readonly) Class superclass;
@end
| 30.930233 | 95 | 0.768421 |
e2f26a8ac76fc1179574c7467b9777b33f1faf49 | 3,741 | c | C | utils/content_type_bench.c | msuslu/rspamd | 95764f816a9e1251a755c6edad339637345cfe28 | [
"Apache-2.0"
] | 789 | 2018-08-14T12:49:01.000Z | 2022-03-29T18:26:59.000Z | utils/content_type_bench.c | msuslu/rspamd | 95764f816a9e1251a755c6edad339637345cfe28 | [
"Apache-2.0"
] | 1,279 | 2018-08-16T19:47:33.000Z | 2022-03-31T14:58:37.000Z | utils/content_type_bench.c | msuslu/rspamd | 95764f816a9e1251a755c6edad339637345cfe28 | [
"Apache-2.0"
] | 221 | 2018-08-23T05:57:15.000Z | 2022-03-11T05:33:43.000Z | /*-
* Copyright 2016 Vsevolod Stakhov
*
* 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.
*/
#include "config.h"
#include "printf.h"
#include "message.h"
#include "util.h"
#include "content_type.h"
static gdouble total_time = 0;
static gint total_parsed = 0;
static gint total_valid = 0;
static gint total_type = 0;
static gint total_subtype = 0;
static gint total_charset = 0;
static gint total_attrs = 0;
static gint total_boundaries = 0;
static gboolean verbose = 1;
#define MODE_NORMAL 0
#define MODE_GMIME 1
#define MODE_COMPARE 2
static void
rspamd_process_file (const gchar *fname, gint mode)
{
rspamd_mempool_t *pool;
GIOChannel *f;
GError *err = NULL;
GString *buf;
struct rspamd_content_type *ct;
gdouble t1, t2;
rspamd_ftok_t t;
f = g_io_channel_new_file (fname, "r", &err);
if (!f) {
rspamd_fprintf (stderr, "cannot open %s: %e\n", fname, err);
g_error_free (err);
return;
}
g_io_channel_set_encoding (f, NULL, NULL);
buf = g_string_sized_new (8192);
pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), "test");
while (g_io_channel_read_line_string (f, buf, NULL, &err)
== G_IO_STATUS_NORMAL) {
while (buf->len > 0 && g_ascii_isspace (buf->str[buf->len - 1])) {
buf->len --;
}
if (mode == MODE_NORMAL) {
t1 = rspamd_get_virtual_ticks ();
ct = rspamd_content_type_parse (buf->str, buf->len, pool);
t2 = rspamd_get_virtual_ticks ();
}
else {
rspamd_fprintf (stderr, "gmime is no longer supported\n");
exit (EXIT_FAILURE);
}
total_time += t2 - t1;
total_parsed ++;
if (mode == MODE_NORMAL) {
if (ct) {
total_valid ++;
if (ct->type.len > 0) {
total_type ++;
}
if (ct->subtype.len > 0) {
total_subtype ++;
}
if (ct->charset.len > 0) {
total_charset ++;
}
if (ct->boundary.len > 0) {
total_boundaries ++;
}
if (ct->attrs) {
total_attrs ++;
}
}
}
}
if (err) {
rspamd_fprintf (stderr, "cannot read %s: %e\n", fname, err);
g_error_free (err);
}
g_io_channel_unref (f);
g_string_free (buf, TRUE);
rspamd_mempool_delete (pool);
}
int
main (int argc, char **argv)
{
gint i, start = 1, mode = MODE_NORMAL;
if (argc > 2 && *argv[1] == '-') {
start = 2;
if (argv[1][1] == 'g') {
mode = MODE_GMIME;
}
else if (argv[1][1] == 'c') {
mode = MODE_COMPARE;
}
}
for (i = start; i < argc; i ++) {
if (argv[i]) {
rspamd_process_file (argv[i], mode);
}
}
if (mode != MODE_COMPARE) {
rspamd_printf ("Parsed %d received headers in %.3f seconds\n"
"Total valid (has type): %d\n"
"Total known type: %d\n"
"Total known subtype: %d\n"
"Total known charset: %d\n"
"Total has attrs: %d\n"
"Total has boundaries: %d\n",
total_parsed, total_time,
total_valid, total_type,
total_subtype, total_charset,
total_attrs,
total_boundaries);
}
else {
rspamd_printf ("Parsed %d received headers in %.3f seconds\n"
"Total valid (parsed by both): %d\n"
"Total same type: %d\n"
"Total same subtype: %d\n"
"Total same charset: %d\n"
"Total same boundaries: %d\n",
total_parsed, total_time,
total_valid, total_type,
total_subtype, total_charset,
total_boundaries);
}
return 0;
}
| 22.536145 | 75 | 0.647688 |
e862333d1e064876d5cc1c777fdcb7d3404f6b6f | 417 | h | C | OutPutHeaders/WloginTlv_0x165.h | cocos543/WeChatTimeLineRobot | 1e93480e502e36ca9a21a506f481aa1fcb70ac4b | [
"MIT"
] | 106 | 2016-04-09T01:16:14.000Z | 2021-06-04T00:20:24.000Z | OutPutHeaders/WloginTlv_0x165.h | cocos543/WeChatTimeLineRobot | 1e93480e502e36ca9a21a506f481aa1fcb70ac4b | [
"MIT"
] | 2 | 2017-06-13T09:41:29.000Z | 2018-03-26T03:32:07.000Z | OutPutHeaders/WloginTlv_0x165.h | cocos543/WeChatTimeLineRobot | 1e93480e502e36ca9a21a506f481aa1fcb70ac4b | [
"MIT"
] | 58 | 2016-04-28T09:52:08.000Z | 2021-12-25T06:42:14.000Z | /**
* This header is generated by class-dump-z 0.2a.
* class-dump-z is Copyright (C) 2009 by KennyTM~, licensed under GPLv3.
*
* Source: (null)
*/
#import "WloginTlv.h"
@class NSMutableDictionary;
@interface WloginTlv_0x165 : WloginTlv {
NSMutableDictionary* picWordings;
}
@property(readonly, retain) NSMutableDictionary* picWordings;
-(void)dealloc;
-(int)decode:(char**)decode andBuffLen:(int*)len;
@end
| 20.85 | 72 | 0.726619 |
e5e01011bec5f8509bfafaba721b92c6f0d37e69 | 2,200 | c | C | core/src/init.c | achilikin/mk-52 | d3992d9d69c1f3e04cfc74636ec9c7f3d0313387 | [
"MIT"
] | null | null | null | core/src/init.c | achilikin/mk-52 | d3992d9d69c1f3e04cfc74636ec9c7f3d0313387 | [
"MIT"
] | null | null | null | core/src/init.c | achilikin/mk-52 | d3992d9d69c1f3e04cfc74636ec9c7f3d0313387 | [
"MIT"
] | null | null | null | /* some initialization stuff moved here to keep main.c clean */
#include "main.h"
/**
* @brief System Clock Configuration
* @retval None
*/
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/**
* Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
Error_Handler();
}
/* Initializes the CPU, AHB and APB buses clocks */
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) {
Error_Handler();
}
}
/**
* @brief This function is executed in case of error occurrence.
* @retval None
*/
void Error_Handler(void)
{
/* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return state */
__disable_irq();
while (1) {
}
/* USER CODE END Error_Handler_Debug */
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t *file, uint32_t line)
{
/* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */ | 31.884058 | 117 | 0.752273 |
0f3c5567c0ebc001a8cfdc45cd7a493db756a8bc | 656 | h | C | qos-cpp/src/gst_ios_init.h | zafaco/nntool | 273b77164a7b471edc66e3b332c9485f4b964b5e | [
"Apache-2.0"
] | null | null | null | qos-cpp/src/gst_ios_init.h | zafaco/nntool | 273b77164a7b471edc66e3b332c9485f4b964b5e | [
"Apache-2.0"
] | 4 | 2021-09-14T11:34:53.000Z | 2022-03-02T12:04:58.000Z | qos-cpp/src/gst_ios_init.h | zafaco/nntool | 273b77164a7b471edc66e3b332c9485f4b964b5e | [
"Apache-2.0"
] | null | null | null | #ifndef __GST_IOS_INIT_H__
#define __GST_IOS_INIT_H__
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_G_IO_MODULE_DECLARE(name) \
extern void G_PASTE(g_io_, G_PASTE(name, _load)) (gpointer module)
#define GST_G_IO_MODULE_LOAD(name) \
G_PASTE(g_io_, G_PASTE(name, _load)) (NULL)
/* Uncomment each line to enable the plugin categories that your application needs.
* You can also enable individual plugins. See gst_ios_init.c to see their names
*/
#define GST_IOS_PLUGINS_CORE
#define GST_IOS_PLUGINS_CODECS
#define GST_IOS_PLUGINS_NET
#define GST_IOS_PLUGINS_PLAYBACK
#define GST_IOS_GIO_MODULE_GNUTLS
void gst_ios_init (void);
G_END_DECLS
#endif
| 21.866667 | 83 | 0.807927 |
bf6778df712a38485e9c0197e5696cef985a59d5 | 802 | c | C | src/main.c | Hvvang/ush | 6c1984e88408e236ae098354f50a94b51d3b7442 | [
"MIT"
] | 3 | 2020-03-07T04:48:25.000Z | 2020-09-02T08:39:54.000Z | src/main.c | Hvvang/ush | 6c1984e88408e236ae098354f50a94b51d3b7442 | [
"MIT"
] | null | null | null | src/main.c | Hvvang/ush | 6c1984e88408e236ae098354f50a94b51d3b7442 | [
"MIT"
] | null | null | null | #include "ush.h"
static bool check_stdin(t_hash_table *hash_table) {
char *buff = NULL;
size_t linecap = 0;
ssize_t linelen = 0;
if (isatty(STDIN_FILENO))
return false;
buff = mx_strnew(ARG_MAX + 1);
while ((linelen = getline(&buff, &linecap, stdin)) > 0) {
buff[linelen] = '\0';
if (buff[linelen - 1] == '\n')
buff[linelen - 1] = '\0';
mx_handle_command(buff, hash_table);
}
return true;
}
int main(int argc, char **argv) {
t_hash_table *hash_table = mx_init_env();
if (argc > 1) {
fprintf(stderr, "%s: illegal option -- %s\n", MX_SHELL_NAME, argv[1]);
fprintf(stderr, "usage: %s ./ush\n", MX_SHELL_NAME);
return 1;
}
if (check_stdin(hash_table)) {
mx_clear_all(hash_table);
}
mx_ush_loop(hash_table);
}
| 24.30303 | 72 | 0.600998 |
24082f9f091c99e96db30031ee581a184fb6dd1c | 616 | h | C | PrivateFrameworks/CoreDuetContext/_CDAsyncContext-Protocol.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 17 | 2018-11-13T04:02:58.000Z | 2022-01-20T09:27:13.000Z | PrivateFrameworks/CoreDuetContext/_CDAsyncContext-Protocol.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 3 | 2018-04-06T02:02:27.000Z | 2018-10-02T01:12:10.000Z | PrivateFrameworks/CoreDuetContext/_CDAsyncContext-Protocol.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 1 | 2018-09-28T13:54:23.000Z | 2018-09-28T13:54:23.000Z | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "_CDContext.h"
@class NSObject<OS_dispatch_queue>, _CDContextualKeyPath;
@protocol _CDAsyncContext <_CDContext>
- (void)lastModifiedDateForContextualKeyPath:(_CDContextualKeyPath *)arg1 responseQueue:(NSObject<OS_dispatch_queue> *)arg2 withCompletion:(void (^)(NSDate *))arg3;
- (void)objectForContextualKeyPath:(_CDContextualKeyPath *)arg1 responseQueue:(NSObject<OS_dispatch_queue> *)arg2 withCompletion:(void (^)(NSObject<NSCopying><NSSecureCoding> *))arg3;
@end
| 38.5 | 183 | 0.76461 |
c7f91d509f4dccdd01f25ab8fc43dc7d496edfe8 | 2,096 | h | C | src/config.h | kenshinx/rps | 3d141056f3512598525430ecc9ddb1ee79b887cf | [
"MIT"
] | 6 | 2017-06-20T09:44:03.000Z | 2018-07-28T06:44:10.000Z | src/config.h | kenshinx/rps | 3d141056f3512598525430ecc9ddb1ee79b887cf | [
"MIT"
] | null | null | null | src/config.h | kenshinx/rps | 3d141056f3512598525430ecc9ddb1ee79b887cf | [
"MIT"
] | 3 | 2017-09-23T16:48:18.000Z | 2018-05-26T19:12:12.000Z | #ifndef _RPS_CONFIG_H
#define _RPS_CONFIG_H
#include "array.h"
#include "_string.h"
#include <yaml.h>
#include <stdio.h>
#include <stdint.h>
#define UPSTREAM_DEFAULT_REFRESH 60
#define UPSTREAM_DEFAULT_STATS 600
#define UPSTREAM_DEFAULT_BYBRID 0
#define UPSTREAM_DEFAULT_MAXRECONN 3
#define UPSTREAM_DEFAULT_MAXRETRY 3
#define UPSTREAM_DEFAULT_MR1M 0
#define UPSTREAM_DEFAULT_MR1H 0
#define UPSTREAM_DEFAULT_MR1D 0
#define UPSTREAM_DEFAULT_MAX_FIAL_RATE 0.0
struct config_servers {
rps_array_t *ss;
uint32_t rtimeout;
uint32_t ftimeout;
};
struct config_server {
rps_str_t proto;
rps_str_t listen;
uint16_t port;
rps_str_t username;
rps_str_t password;
};
struct config_upstream {
rps_str_t proto;
};
struct config_upstreams {
uint32_t refresh;
uint32_t stats;
rps_str_t schedule;
unsigned hybrid:1;
uint32_t maxreconn;
uint32_t maxretry;
uint32_t mr1m;
uint32_t mr1h;
uint32_t mr1d;
float max_fail_rate;
rps_array_t *pools;
};
struct config_api {
rps_str_t url;
rps_str_t s5_source;
rps_str_t http_source;
rps_str_t http_tunnel_source;
uint32_t timeout;
};
struct config_log {
rps_str_t file;
rps_str_t level;
};
struct config {
char *fname;
rps_str_t title;
rps_str_t pidfile;
FILE *fd;
unsigned daemon:1;
struct config_servers servers;
struct config_upstreams upstreams;
struct config_api api;
struct config_log log;
rps_array_t *args;
uint32_t depth;
unsigned seq:1;
yaml_parser_t parser;
yaml_event_t event;
};
int config_init(char *config_file, struct config *cfg);
void config_deinit(struct config *cfg);
void config_dump(struct config *cfg);
#endif
| 22.782609 | 55 | 0.605916 |
b599cda5ba3c90f4f7beccb6ff8d227d5e83ffbe | 5,081 | c | C | drivers/platform/x86/simatic-ipc.c | Sunrisepeak/Linux2.6-Reading | c25102a494a37f9f30a27ca2cd4a1a412bffc80f | [
"MIT"
] | 44 | 2022-03-16T08:32:31.000Z | 2022-03-31T16:02:35.000Z | drivers/platform/x86/simatic-ipc.c | Sunrisepeak/Linux2.6-Reading | c25102a494a37f9f30a27ca2cd4a1a412bffc80f | [
"MIT"
] | 1 | 2022-03-29T02:30:28.000Z | 2022-03-30T03:40:46.000Z | drivers/platform/x86/simatic-ipc.c | Sunrisepeak/Linux2.6-Reading | c25102a494a37f9f30a27ca2cd4a1a412bffc80f | [
"MIT"
] | 18 | 2022-03-19T04:41:04.000Z | 2022-03-31T03:32:12.000Z | // SPDX-License-Identifier: GPL-2.0
/*
* Siemens SIMATIC IPC platform driver
*
* Copyright (c) Siemens AG, 2018-2021
*
* Authors:
* Henning Schild <henning.schild@siemens.com>
* Jan Kiszka <jan.kiszka@siemens.com>
* Gerd Haeussler <gerd.haeussler.ext@siemens.com>
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/dmi.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/platform_data/x86/simatic-ipc.h>
#include <linux/platform_device.h>
static struct platform_device *ipc_led_platform_device;
static struct platform_device *ipc_wdt_platform_device;
static const struct dmi_system_id simatic_ipc_whitelist[] = {
{
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "SIEMENS AG"),
},
},
{}
};
static struct simatic_ipc_platform platform_data;
static struct {
u32 station_id;
u8 led_mode;
u8 wdt_mode;
} device_modes[] = {
{SIMATIC_IPC_IPC127E, SIMATIC_IPC_DEVICE_127E, SIMATIC_IPC_DEVICE_NONE},
{SIMATIC_IPC_IPC227D, SIMATIC_IPC_DEVICE_227D, SIMATIC_IPC_DEVICE_NONE},
{SIMATIC_IPC_IPC227E, SIMATIC_IPC_DEVICE_427E, SIMATIC_IPC_DEVICE_227E},
{SIMATIC_IPC_IPC277E, SIMATIC_IPC_DEVICE_NONE, SIMATIC_IPC_DEVICE_227E},
{SIMATIC_IPC_IPC427D, SIMATIC_IPC_DEVICE_427E, SIMATIC_IPC_DEVICE_NONE},
{SIMATIC_IPC_IPC427E, SIMATIC_IPC_DEVICE_427E, SIMATIC_IPC_DEVICE_427E},
{SIMATIC_IPC_IPC477E, SIMATIC_IPC_DEVICE_NONE, SIMATIC_IPC_DEVICE_427E},
};
static int register_platform_devices(u32 station_id)
{
u8 ledmode = SIMATIC_IPC_DEVICE_NONE;
u8 wdtmode = SIMATIC_IPC_DEVICE_NONE;
int i;
platform_data.devmode = SIMATIC_IPC_DEVICE_NONE;
for (i = 0; i < ARRAY_SIZE(device_modes); i++) {
if (device_modes[i].station_id == station_id) {
ledmode = device_modes[i].led_mode;
wdtmode = device_modes[i].wdt_mode;
break;
}
}
if (ledmode != SIMATIC_IPC_DEVICE_NONE) {
platform_data.devmode = ledmode;
ipc_led_platform_device =
platform_device_register_data(NULL,
KBUILD_MODNAME "_leds", PLATFORM_DEVID_NONE,
&platform_data,
sizeof(struct simatic_ipc_platform));
if (IS_ERR(ipc_led_platform_device))
return PTR_ERR(ipc_led_platform_device);
pr_debug("device=%s created\n",
ipc_led_platform_device->name);
}
if (wdtmode != SIMATIC_IPC_DEVICE_NONE) {
platform_data.devmode = wdtmode;
ipc_wdt_platform_device =
platform_device_register_data(NULL,
KBUILD_MODNAME "_wdt", PLATFORM_DEVID_NONE,
&platform_data,
sizeof(struct simatic_ipc_platform));
if (IS_ERR(ipc_wdt_platform_device))
return PTR_ERR(ipc_wdt_platform_device);
pr_debug("device=%s created\n",
ipc_wdt_platform_device->name);
}
if (ledmode == SIMATIC_IPC_DEVICE_NONE &&
wdtmode == SIMATIC_IPC_DEVICE_NONE) {
pr_warn("unsupported IPC detected, station id=%08x\n",
station_id);
return -EINVAL;
}
return 0;
}
/* FIXME: this should eventually be done with generic P2SB discovery code
* the individual drivers for watchdogs and LEDs access memory that implements
* GPIO, but pinctrl will not come up because of missing ACPI entries
*
* While there is no conflict a cleaner solution would be to somehow bring up
* pinctrl even with these ACPI entries missing, and base the drivers on pinctrl.
* After which the following function could be dropped, together with the code
* poking the memory.
*/
/*
* Get membase address from PCI, used in leds and wdt module. Here we read
* the bar0. The final address calculation is done in the appropriate modules
*/
u32 simatic_ipc_get_membase0(unsigned int p2sb)
{
struct pci_bus *bus;
u32 bar0 = 0;
/*
* The GPIO memory is in bar0 of the hidden P2SB device.
* Unhide the device to have a quick look at it, before we hide it
* again.
* Also grab the pci rescan lock so that device does not get discovered
* and remapped while it is visible.
* This code is inspired by drivers/mfd/lpc_ich.c
*/
bus = pci_find_bus(0, 0);
pci_lock_rescan_remove();
pci_bus_write_config_byte(bus, p2sb, 0xE1, 0x0);
pci_bus_read_config_dword(bus, p2sb, PCI_BASE_ADDRESS_0, &bar0);
bar0 &= ~0xf;
pci_bus_write_config_byte(bus, p2sb, 0xE1, 0x1);
pci_unlock_rescan_remove();
return bar0;
}
EXPORT_SYMBOL(simatic_ipc_get_membase0);
static int __init simatic_ipc_init_module(void)
{
const struct dmi_system_id *match;
u32 station_id;
int err;
match = dmi_first_match(simatic_ipc_whitelist);
if (!match)
return 0;
err = dmi_walk(simatic_ipc_find_dmi_entry_helper, &station_id);
if (err || station_id == SIMATIC_IPC_INVALID_STATION_ID) {
pr_warn("DMI entry %d not found\n", SIMATIC_IPC_DMI_ENTRY_OEM);
return 0;
}
return register_platform_devices(station_id);
}
static void __exit simatic_ipc_exit_module(void)
{
platform_device_unregister(ipc_led_platform_device);
ipc_led_platform_device = NULL;
platform_device_unregister(ipc_wdt_platform_device);
ipc_wdt_platform_device = NULL;
}
module_init(simatic_ipc_init_module);
module_exit(simatic_ipc_exit_module);
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Gerd Haeussler <gerd.haeussler.ext@siemens.com>");
MODULE_ALIAS("dmi:*:svnSIEMENSAG:*");
| 28.706215 | 81 | 0.765401 |
db0754f30aa584e5a594946e257170c3d8ceb1ca | 58 | h | C | elabora.h | alfredogiacconi/EserciziC | bb75b52122f68ddfed4fc1abe741923b92bda1f7 | [
"MIT"
] | null | null | null | elabora.h | alfredogiacconi/EserciziC | bb75b52122f68ddfed4fc1abe741923b92bda1f7 | [
"MIT"
] | null | null | null | elabora.h | alfredogiacconi/EserciziC | bb75b52122f68ddfed4fc1abe741923b92bda1f7 | [
"MIT"
] | null | null | null | void elabora(int contatore_parametri, char *parametri[]);
| 29 | 57 | 0.793103 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.