PCIe driver: accept spot finding parameters
This commit is contained in:
@@ -103,6 +103,9 @@
|
||||
#define ADDR_NFRAMES 0x0098
|
||||
#define ADDR_NSTORAGE_CELLS 0x009C
|
||||
|
||||
#define ADDR_SPOT_FINDER_THRESHOLD 0x0100
|
||||
#define ADDR_SPOT_FINDER_SNR 0x0104
|
||||
|
||||
#define ADDR_MAILBOX_WRDATA 0x00
|
||||
#define ADDR_MAILBOX_RDDATA 0x08
|
||||
#define ADDR_MAILBOX_STATUS 0x10
|
||||
|
||||
@@ -204,3 +204,8 @@ uint16_t *JungfraujochDevice::MapKernelBuffer(uint32_t id) {
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
void JungfraujochDevice::SetSpotFinderParameters(const SpotFinderParameters& params) {
|
||||
if (ioctl(fd, IOCTL_JFJOCH_SPOT_FINDER_PAR, ¶ms) != 0)
|
||||
throw JFJochException(JFJochExceptionCategory::PCIeError, "Failed settings spot finder parameters", errno);
|
||||
}
|
||||
|
||||
@@ -87,6 +87,8 @@ public:
|
||||
// Must be placed in first <modules> kernel buffer locations
|
||||
void LoadIntegrationMap(uint32_t modules);
|
||||
|
||||
void SetSpotFinderParameters(const SpotFinderParameters ¶ms);
|
||||
|
||||
// Get number of kernel buffers
|
||||
uint32_t GetBufferCount() const;
|
||||
// Allocate id kernel buffer ( id must be less than GetBufferCount() )
|
||||
|
||||
@@ -84,6 +84,10 @@ struct RegisterConfig {
|
||||
uint32_t val;
|
||||
};
|
||||
|
||||
struct SpotFinderParameters {
|
||||
int16_t count_threshold;
|
||||
uint16_t snr_threshold;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif //JUNGFRAUJOCH_ACTIONCONFIG_H
|
||||
|
||||
@@ -127,6 +127,7 @@ int jfjoch_load_calibration(struct jfjoch_drvdata *drvdata, struct DataCollectio
|
||||
int jfjoch_load_integration_map(struct jfjoch_drvdata *drvdata, struct DataCollectionConfig *config);
|
||||
int jfjoch_run_frame_gen(struct jfjoch_drvdata *drvdata, struct FrameGeneratorConfig *config);
|
||||
u32 jfjoch_get_c2h_descriptors(struct jfjoch_drvdata *drvdata);
|
||||
void jfjoch_set_spot_finder_parameters(struct jfjoch_drvdata *drvdata, struct SpotFinderParameters *params);
|
||||
|
||||
u64 jfjoch_read_mac_addr(struct jfjoch_drvdata *drvdata);
|
||||
|
||||
|
||||
@@ -446,3 +446,8 @@ int jfjoch_run_frame_gen(struct jfjoch_drvdata *drvdata, struct FrameGeneratorCo
|
||||
u32 jfjoch_get_c2h_descriptors(struct jfjoch_drvdata *drvdata) {
|
||||
return ioread32(drvdata->bar0 + PCIE_OFFSET + (1<<12) + 0x48);
|
||||
}
|
||||
|
||||
void jfjoch_set_spot_finder_parameters(struct jfjoch_drvdata *drvdata, struct SpotFinderParameters *params) {
|
||||
iowrite32(params->count_threshold, drvdata->bar0 + ADDR_SPOT_FINDER_THRESHOLD);
|
||||
iowrite32(params->snr_threshold, drvdata->bar0 + ADDR_SPOT_FINDER_SNR);
|
||||
}
|
||||
@@ -10,6 +10,7 @@ long jfjoch_cdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) {
|
||||
struct DeviceStatus env_params;
|
||||
struct FrameGeneratorConfig frame_generator_config;
|
||||
struct RegisterConfig reg_config;
|
||||
struct SpotFinderParameters spot_finder_parameters;
|
||||
u32 exchange[16];
|
||||
int err;
|
||||
|
||||
@@ -107,6 +108,13 @@ long jfjoch_cdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) {
|
||||
if (copy_to_user((char *) arg, exchange, sizeof(u32)) != 0)
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
case IOCTL_JFJOCH_SPOT_FINDER_PAR:
|
||||
if (!(file->f_mode & FMODE_WRITE))
|
||||
return -EACCES;
|
||||
if (copy_from_user(&spot_finder_parameters, (char *) arg, sizeof(struct SpotFinderParameters)) != 0)
|
||||
return -EFAULT;
|
||||
jfjoch_set_spot_finder_parameters(drvdata, &spot_finder_parameters);
|
||||
return 0;
|
||||
case IOCTL_JFJOCH_ISIDLE:
|
||||
jfjoch_is_idle(drvdata, exchange);
|
||||
if (copy_to_user((char *) arg, exchange, sizeof(int32_t)) != 0)
|
||||
|
||||
@@ -39,5 +39,6 @@
|
||||
#define IOCTL_JFJOCH_C2H_DMA_DESC _IOR(IOCTL_JFJOCH_MAGIC, 24, uint32_t)
|
||||
#define IOCTL_JFJOCH_WRITE_REGISTER _IOW(IOCTL_JFJOCH_MAGIC, 25, struct RegisterConfig )
|
||||
#define IOCTL_JFJOCH_READ_REGISTER _IOWR(IOCTL_JFJOCH_MAGIC, 26, struct RegisterConfig )
|
||||
#define IOCTL_JFJOCH_SPOT_FINDER_PAR _IOW(IOCTL_JFJOCH_MAGIC, 27, struct SpotFinderParameters)
|
||||
|
||||
#endif //JUNGFRAUJOCH_JFJOCH_IOCTL_H
|
||||
|
||||
@@ -110,6 +110,7 @@ public:
|
||||
virtual void InitializeIntegrationMap(const DiffractionExperiment &experiment, const std::vector<uint16_t> &v);
|
||||
const AcquisitionCounters& Counters() const;
|
||||
|
||||
virtual void SetSpotFinderParameters(int16_t count_threshold, double snr_threshold) {};
|
||||
virtual std::string GetIPv4Address() const;
|
||||
virtual std::string GetMACAddress() const;
|
||||
virtual uint16_t GetUDPPort() const;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "FPGAAcquisitionDevice.h"
|
||||
#include <random>
|
||||
#include <bitset>
|
||||
#include "../common/to_fixed.h"
|
||||
|
||||
void FPGAAcquisitionDevice::StartSendingWorkRequests() {
|
||||
stop_work_requests = false;
|
||||
@@ -317,3 +318,16 @@ FPGAAcquisitionDevice::FPGAAcquisitionDevice(uint16_t data_stream)
|
||||
internal_pkt_gen_frame(RAW_MODULE_SIZE * FRAME_GENERATOR_MODULES) {
|
||||
}
|
||||
|
||||
void FPGAAcquisitionDevice::SetSpotFinderParameters(int16_t count_threshold, double snr_threshold) {
|
||||
if (snr_threshold < 0) {
|
||||
if (logger)
|
||||
logger->Warning("Trying to set SNR threshold below zero: {}", snr_threshold );
|
||||
snr_threshold = 0;
|
||||
} else if (snr_threshold > 64) {
|
||||
if (logger)
|
||||
logger->Warning("Trying to set SNR threshold too high: {}", snr_threshold );
|
||||
snr_threshold = 64;
|
||||
}
|
||||
SpotFinderParameters params{.count_threshold = count_threshold, .snr_threshold = to_fixed(snr_threshold, 4)};
|
||||
HW_SetSpotFinderParameters(params);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ class FPGAAcquisitionDevice : public AcquisitionDevice {
|
||||
virtual void HW_LoadInternalGeneratorFrame(uint32_t modules) = 0;
|
||||
virtual bool HW_ReadMailbox(uint32_t values[16]) = 0;
|
||||
virtual bool HW_SendWorkRequest(uint32_t handle) = 0;
|
||||
virtual void HW_SetSpotFinderParameters(const SpotFinderParameters ¶ms) = 0;
|
||||
void StartSendingWorkRequests() override;
|
||||
void Start(const DiffractionExperiment &experiment) override;
|
||||
protected:
|
||||
@@ -48,6 +49,7 @@ public:
|
||||
void SetInternalGeneratorFrame(const std::vector<uint16_t> &v);
|
||||
void SetInternalGeneratorFrame();
|
||||
std::vector<uint16_t> GetInternalGeneratorFrame() const override;
|
||||
void SetSpotFinderParameters(int16_t count_threshold, double snr_threshold) override;
|
||||
};
|
||||
|
||||
#endif //JUNGFRAUJOCH_FPGAACQUISITIONDEVICE_H
|
||||
|
||||
@@ -348,14 +348,10 @@ void HLSSimulatedDevice::HLSMainThread() {
|
||||
hbm_if_size); });
|
||||
|
||||
|
||||
ap_int<16> photon_count_threshold = 5;
|
||||
ap_uint<16> strong_pixel_threshold = 7;
|
||||
|
||||
|
||||
// 6. Spot finding
|
||||
hls_cores.emplace_back([&] { spot_finder(converted_5, converted_6,
|
||||
spot_finder_result_0,
|
||||
photon_count_threshold,
|
||||
strong_pixel_threshold);});
|
||||
hls_cores.emplace_back([&] { spot_finder(converted_5, converted_6, spot_finder_result_0, count_threshold, snr_threshold);});
|
||||
|
||||
hls_cores.emplace_back([&] { axis_32_to_512(spot_finder_result_0, spot_finder_result_1);});
|
||||
|
||||
@@ -553,4 +549,9 @@ void HLSSimulatedDevice::HW_LoadInternalGeneratorFrame(uint32_t modules) {
|
||||
|
||||
uint32_t HLSSimulatedDevice::GetCompletedDescriptors() const {
|
||||
return datamover_out.GetCompletedDescriptors();
|
||||
}
|
||||
}
|
||||
|
||||
void HLSSimulatedDevice::HW_SetSpotFinderParameters(const SpotFinderParameters ¶ms) {
|
||||
count_threshold = params.count_threshold;
|
||||
snr_threshold = params.snr_threshold;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ class HLSSimulatedDevice : public FPGAAcquisitionDevice {
|
||||
AXI_STREAM din_frame_generator;
|
||||
AXI_STREAM dout_eth;
|
||||
|
||||
ap_int<16> count_threshold = INT16_MAX;
|
||||
ap_uint<16> snr_threshold = 0;
|
||||
|
||||
DataCollectionConfig cfg;
|
||||
|
||||
volatile bool idle;
|
||||
@@ -55,8 +58,8 @@ class HLSSimulatedDevice : public FPGAAcquisitionDevice {
|
||||
void HW_LoadIntegrationMap(uint32_t modules) override;
|
||||
void HW_LoadInternalGeneratorFrame(uint32_t modules) override;
|
||||
void HW_GetStatus(DataCollectionStatus *status) const override;
|
||||
void HW_SetSpotFinderParameters(const SpotFinderParameters ¶ms) override;
|
||||
void HLSMainThread() ;
|
||||
void RunFrameGenerator(const FrameGeneratorConfig& config);
|
||||
public:
|
||||
HLSSimulatedDevice(uint16_t data_stream, size_t in_frame_buffer_size_modules, int16_t numa_node = -1);
|
||||
~HLSSimulatedDevice();
|
||||
|
||||
@@ -127,3 +127,6 @@ void PCIExpressDevice::HW_LoadInternalGeneratorFrame(uint32_t in_modules) {
|
||||
dev.LoadInternalGeneratorFrame(in_modules);
|
||||
}
|
||||
|
||||
void PCIExpressDevice::HW_SetSpotFinderParameters(const SpotFinderParameters ¶ms) {
|
||||
dev.SetSpotFinderParameters(params);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ class PCIExpressDevice : public FPGAAcquisitionDevice {
|
||||
void HW_LoadCalibration(uint32_t modules, uint32_t storage_cells) override;
|
||||
void HW_LoadIntegrationMap(uint32_t modules) override;
|
||||
void HW_LoadInternalGeneratorFrame(uint32_t modules) override;
|
||||
void HW_SetSpotFinderParameters(const SpotFinderParameters ¶ms) override;
|
||||
void FPGA_EndAction() override;
|
||||
public:
|
||||
explicit PCIExpressDevice(uint16_t data_stream);
|
||||
|
||||
Reference in New Issue
Block a user